@polka-codes/cli-shared 0.9.17 → 0.9.19
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.js +1408 -817
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7160,8 +7160,8 @@ var require_directives = __commonJS((exports) => {
|
|
|
7160
7160
|
if (prefix) {
|
|
7161
7161
|
try {
|
|
7162
7162
|
return prefix + decodeURIComponent(suffix);
|
|
7163
|
-
} catch (
|
|
7164
|
-
onError(String(
|
|
7163
|
+
} catch (error82) {
|
|
7164
|
+
onError(String(error82));
|
|
7165
7165
|
return null;
|
|
7166
7166
|
}
|
|
7167
7167
|
}
|
|
@@ -7253,9 +7253,9 @@ var require_anchors = __commonJS((exports) => {
|
|
|
7253
7253
|
if (typeof ref === "object" && ref.anchor && (identity.isScalar(ref.node) || identity.isCollection(ref.node))) {
|
|
7254
7254
|
ref.node.anchor = ref.anchor;
|
|
7255
7255
|
} else {
|
|
7256
|
-
const
|
|
7257
|
-
|
|
7258
|
-
throw
|
|
7256
|
+
const error82 = new Error("Failed to resolve repeated object (this should not happen)");
|
|
7257
|
+
error82.source = source;
|
|
7258
|
+
throw error82;
|
|
7259
7259
|
}
|
|
7260
7260
|
}
|
|
7261
7261
|
},
|
|
@@ -10244,12 +10244,12 @@ var require_errors = __commonJS((exports) => {
|
|
|
10244
10244
|
super("YAMLWarning", pos, code, message);
|
|
10245
10245
|
}
|
|
10246
10246
|
}
|
|
10247
|
-
var prettifyError3 = (src, lc) => (
|
|
10248
|
-
if (
|
|
10247
|
+
var prettifyError3 = (src, lc) => (error82) => {
|
|
10248
|
+
if (error82.pos[0] === -1)
|
|
10249
10249
|
return;
|
|
10250
|
-
|
|
10251
|
-
const { line, col } =
|
|
10252
|
-
|
|
10250
|
+
error82.linePos = error82.pos.map((pos) => lc.linePos(pos));
|
|
10251
|
+
const { line, col } = error82.linePos[0];
|
|
10252
|
+
error82.message += ` at line ${line}, column ${col}`;
|
|
10253
10253
|
let ci = col - 1;
|
|
10254
10254
|
let lineStr = src.substring(lc.lineStarts[line - 1], lc.lineStarts[line]).replace(/[\n\r]+$/, "");
|
|
10255
10255
|
if (ci >= 60 && lineStr.length > 80) {
|
|
@@ -10268,12 +10268,12 @@ var require_errors = __commonJS((exports) => {
|
|
|
10268
10268
|
}
|
|
10269
10269
|
if (/[^ ]/.test(lineStr)) {
|
|
10270
10270
|
let count = 1;
|
|
10271
|
-
const end =
|
|
10271
|
+
const end = error82.linePos[1];
|
|
10272
10272
|
if (end && end.line === line && end.col > col) {
|
|
10273
10273
|
count = Math.max(1, Math.min(end.col - col, 80 - ci));
|
|
10274
10274
|
}
|
|
10275
10275
|
const pointer = " ".repeat(ci) + "^".repeat(count);
|
|
10276
|
-
|
|
10276
|
+
error82.message += `:
|
|
10277
10277
|
|
|
10278
10278
|
${lineStr}
|
|
10279
10279
|
${pointer}
|
|
@@ -11065,7 +11065,7 @@ var require_resolve_block_scalar = __commonJS((exports) => {
|
|
|
11065
11065
|
const mode = source[0];
|
|
11066
11066
|
let indent = 0;
|
|
11067
11067
|
let chomp = "";
|
|
11068
|
-
let
|
|
11068
|
+
let error82 = -1;
|
|
11069
11069
|
for (let i = 1;i < source.length; ++i) {
|
|
11070
11070
|
const ch = source[i];
|
|
11071
11071
|
if (!chomp && (ch === "-" || ch === "+"))
|
|
@@ -11074,12 +11074,12 @@ var require_resolve_block_scalar = __commonJS((exports) => {
|
|
|
11074
11074
|
const n = Number(ch);
|
|
11075
11075
|
if (!indent && n)
|
|
11076
11076
|
indent = n;
|
|
11077
|
-
else if (
|
|
11078
|
-
|
|
11077
|
+
else if (error82 === -1)
|
|
11078
|
+
error82 = offset + i;
|
|
11079
11079
|
}
|
|
11080
11080
|
}
|
|
11081
|
-
if (
|
|
11082
|
-
onError(
|
|
11081
|
+
if (error82 !== -1)
|
|
11082
|
+
onError(error82, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${source}`);
|
|
11083
11083
|
let hasSpace = false;
|
|
11084
11084
|
let comment = "";
|
|
11085
11085
|
let length = source.length;
|
|
@@ -11365,8 +11365,8 @@ var require_compose_scalar = __commonJS((exports) => {
|
|
|
11365
11365
|
try {
|
|
11366
11366
|
const res = tag.resolve(value, (msg) => onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg), ctx.options);
|
|
11367
11367
|
scalar = identity.isScalar(res) ? res : new Scalar.Scalar(res);
|
|
11368
|
-
} catch (
|
|
11369
|
-
const msg =
|
|
11368
|
+
} catch (error82) {
|
|
11369
|
+
const msg = error82 instanceof Error ? error82.message : String(error82);
|
|
11370
11370
|
onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg);
|
|
11371
11371
|
scalar = new Scalar.Scalar(value);
|
|
11372
11372
|
}
|
|
@@ -11729,11 +11729,11 @@ ${cb}` : comment;
|
|
|
11729
11729
|
break;
|
|
11730
11730
|
case "error": {
|
|
11731
11731
|
const msg = token.source ? `${token.message}: ${JSON.stringify(token.source)}` : token.message;
|
|
11732
|
-
const
|
|
11732
|
+
const error82 = new errors5.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg);
|
|
11733
11733
|
if (this.atDirectives || !this.doc)
|
|
11734
|
-
this.errors.push(
|
|
11734
|
+
this.errors.push(error82);
|
|
11735
11735
|
else
|
|
11736
|
-
this.doc.errors.push(
|
|
11736
|
+
this.doc.errors.push(error82);
|
|
11737
11737
|
break;
|
|
11738
11738
|
}
|
|
11739
11739
|
case "doc-end": {
|
|
@@ -13006,8 +13006,8 @@ var require_parser = __commonJS((exports) => {
|
|
|
13006
13006
|
peek(n) {
|
|
13007
13007
|
return this.stack[this.stack.length - n];
|
|
13008
13008
|
}
|
|
13009
|
-
*pop(
|
|
13010
|
-
const token =
|
|
13009
|
+
*pop(error82) {
|
|
13010
|
+
const token = error82 ?? this.stack.pop();
|
|
13011
13011
|
if (!token) {
|
|
13012
13012
|
const message = "Tried to pop an empty stack";
|
|
13013
13013
|
yield { type: "error", offset: this.offset, source: "", message };
|
|
@@ -28371,6 +28371,7 @@ __export(exports_external2, {
|
|
|
28371
28371
|
int: () => int2,
|
|
28372
28372
|
instanceof: () => _instanceof2,
|
|
28373
28373
|
includes: () => _includes2,
|
|
28374
|
+
hostname: () => hostname3,
|
|
28374
28375
|
guid: () => guid4,
|
|
28375
28376
|
gte: () => _gte2,
|
|
28376
28377
|
gt: () => _gt2,
|
|
@@ -28533,6 +28534,7 @@ __export(exports_core4, {
|
|
|
28533
28534
|
_toLowerCase: () => _toLowerCase2,
|
|
28534
28535
|
_templateLiteral: () => _templateLiteral2,
|
|
28535
28536
|
_symbol: () => _symbol2,
|
|
28537
|
+
_superRefine: () => _superRefine,
|
|
28536
28538
|
_success: () => _success2,
|
|
28537
28539
|
_stringbool: () => _stringbool2,
|
|
28538
28540
|
_stringFormat: () => _stringFormat2,
|
|
@@ -28618,6 +28620,7 @@ __export(exports_core4, {
|
|
|
28618
28620
|
_coercedBigint: () => _coercedBigint2,
|
|
28619
28621
|
_cidrv6: () => _cidrv62,
|
|
28620
28622
|
_cidrv4: () => _cidrv42,
|
|
28623
|
+
_check: () => _check,
|
|
28621
28624
|
_catch: () => _catch3,
|
|
28622
28625
|
_boolean: () => _boolean2,
|
|
28623
28626
|
_bigint: () => _bigint2,
|
|
@@ -28795,6 +28798,7 @@ var exports_util2 = {};
|
|
|
28795
28798
|
__export(exports_util2, {
|
|
28796
28799
|
unwrapMessage: () => unwrapMessage2,
|
|
28797
28800
|
stringifyPrimitive: () => stringifyPrimitive2,
|
|
28801
|
+
shallowClone: () => shallowClone,
|
|
28798
28802
|
required: () => required2,
|
|
28799
28803
|
randomString: () => randomString2,
|
|
28800
28804
|
propertyKeyTypes: () => propertyKeyTypes2,
|
|
@@ -28805,6 +28809,7 @@ __export(exports_util2, {
|
|
|
28805
28809
|
partial: () => partial2,
|
|
28806
28810
|
optionalKeys: () => optionalKeys2,
|
|
28807
28811
|
omit: () => omit2,
|
|
28812
|
+
objectClone: () => objectClone,
|
|
28808
28813
|
numKeys: () => numKeys2,
|
|
28809
28814
|
nullish: () => nullish3,
|
|
28810
28815
|
normalizeParams: () => normalizeParams2,
|
|
@@ -28892,22 +28897,32 @@ function cleanRegex2(source) {
|
|
|
28892
28897
|
}
|
|
28893
28898
|
function floatSafeRemainder2(val, step) {
|
|
28894
28899
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
28895
|
-
const
|
|
28900
|
+
const stepString = step.toString();
|
|
28901
|
+
let stepDecCount = (stepString.split(".")[1] || "").length;
|
|
28902
|
+
if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
|
|
28903
|
+
const match = stepString.match(/\d?e-(\d?)/);
|
|
28904
|
+
if (match?.[1]) {
|
|
28905
|
+
stepDecCount = Number.parseInt(match[1]);
|
|
28906
|
+
}
|
|
28907
|
+
}
|
|
28896
28908
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
28897
28909
|
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
28898
28910
|
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
28899
28911
|
return valInt % stepInt / 10 ** decCount;
|
|
28900
28912
|
}
|
|
28913
|
+
var EVALUATING = Symbol("evaluating");
|
|
28901
28914
|
function defineLazy2(object2, key, getter) {
|
|
28902
|
-
|
|
28915
|
+
let value = undefined;
|
|
28903
28916
|
Object.defineProperty(object2, key, {
|
|
28904
28917
|
get() {
|
|
28905
|
-
if (
|
|
28906
|
-
|
|
28907
|
-
object2[key] = value;
|
|
28908
|
-
return value;
|
|
28918
|
+
if (value === EVALUATING) {
|
|
28919
|
+
return;
|
|
28909
28920
|
}
|
|
28910
|
-
|
|
28921
|
+
if (value === undefined) {
|
|
28922
|
+
value = EVALUATING;
|
|
28923
|
+
value = getter();
|
|
28924
|
+
}
|
|
28925
|
+
return value;
|
|
28911
28926
|
},
|
|
28912
28927
|
set(v) {
|
|
28913
28928
|
Object.defineProperty(object2, key, {
|
|
@@ -28917,6 +28932,9 @@ function defineLazy2(object2, key, getter) {
|
|
|
28917
28932
|
configurable: true
|
|
28918
28933
|
});
|
|
28919
28934
|
}
|
|
28935
|
+
function objectClone(obj) {
|
|
28936
|
+
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
|
28937
|
+
}
|
|
28920
28938
|
function assignProp2(target, prop, value) {
|
|
28921
28939
|
Object.defineProperty(target, prop, {
|
|
28922
28940
|
value,
|
|
@@ -28993,6 +29011,11 @@ function isPlainObject2(o) {
|
|
|
28993
29011
|
}
|
|
28994
29012
|
return true;
|
|
28995
29013
|
}
|
|
29014
|
+
function shallowClone(o) {
|
|
29015
|
+
if (isPlainObject2(o))
|
|
29016
|
+
return { ...o };
|
|
29017
|
+
return o;
|
|
29018
|
+
}
|
|
28996
29019
|
function numKeys2(data) {
|
|
28997
29020
|
let keyCount = 0;
|
|
28998
29021
|
for (const key in data) {
|
|
@@ -29548,6 +29571,7 @@ __export(exports_regexes2, {
|
|
|
29548
29571
|
ipv6: () => ipv63,
|
|
29549
29572
|
ipv4: () => ipv43,
|
|
29550
29573
|
integer: () => integer2,
|
|
29574
|
+
idnEmail: () => idnEmail,
|
|
29551
29575
|
html5Email: () => html5Email2,
|
|
29552
29576
|
hostname: () => hostname2,
|
|
29553
29577
|
guid: () => guid3,
|
|
@@ -29590,6 +29614,7 @@ var email3 = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][
|
|
|
29590
29614
|
var html5Email2 = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
29591
29615
|
var rfc5322Email2 = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
29592
29616
|
var unicodeEmail2 = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
|
|
29617
|
+
var idnEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
|
|
29593
29618
|
var browserEmail2 = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
29594
29619
|
var _emoji3 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
29595
29620
|
function emoji3() {
|
|
@@ -29601,7 +29626,7 @@ var cidrv43 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5
|
|
|
29601
29626
|
var cidrv63 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
29602
29627
|
var base643 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
29603
29628
|
var base64url3 = /^[A-Za-z0-9_-]*$/;
|
|
29604
|
-
var hostname2 = /^([a-zA-Z0-9-]
|
|
29629
|
+
var hostname2 = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
|
|
29605
29630
|
var domain2 = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
29606
29631
|
var e1643 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
|
29607
29632
|
var dateSource2 = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
|
|
@@ -29620,7 +29645,7 @@ function datetime3(args) {
|
|
|
29620
29645
|
if (args.local)
|
|
29621
29646
|
opts.push("");
|
|
29622
29647
|
if (args.offset)
|
|
29623
|
-
opts.push(`([+-]\\d
|
|
29648
|
+
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
29624
29649
|
const timeRegex = `${time4}(?:${opts.join("|")})`;
|
|
29625
29650
|
return new RegExp(`^${dateSource2}T(?:${timeRegex})$`);
|
|
29626
29651
|
}
|
|
@@ -29749,6 +29774,7 @@ var $ZodCheckNumberFormat2 = /* @__PURE__ */ $constructor2("$ZodCheckNumberForma
|
|
|
29749
29774
|
expected: origin,
|
|
29750
29775
|
format: def.format,
|
|
29751
29776
|
code: "invalid_type",
|
|
29777
|
+
continue: false,
|
|
29752
29778
|
input,
|
|
29753
29779
|
inst
|
|
29754
29780
|
});
|
|
@@ -30163,7 +30189,8 @@ var $ZodCheckMimeType2 = /* @__PURE__ */ $constructor2("$ZodCheckMimeType", (ins
|
|
|
30163
30189
|
code: "invalid_value",
|
|
30164
30190
|
values: def.mime,
|
|
30165
30191
|
input: payload.value.type,
|
|
30166
|
-
inst
|
|
30192
|
+
inst,
|
|
30193
|
+
continue: !def.abort
|
|
30167
30194
|
});
|
|
30168
30195
|
};
|
|
30169
30196
|
});
|
|
@@ -30216,7 +30243,7 @@ class Doc2 {
|
|
|
30216
30243
|
var version2 = {
|
|
30217
30244
|
major: 4,
|
|
30218
30245
|
minor: 0,
|
|
30219
|
-
patch:
|
|
30246
|
+
patch: 17
|
|
30220
30247
|
};
|
|
30221
30248
|
|
|
30222
30249
|
// ../../node_modules/zod/v4/core/schemas.js
|
|
@@ -30850,7 +30877,7 @@ var $ZodObject2 = /* @__PURE__ */ $constructor2("$ZodObject", (inst, def) => {
|
|
|
30850
30877
|
const _normalized = cached2(() => {
|
|
30851
30878
|
const keys = Object.keys(def.shape);
|
|
30852
30879
|
for (const k of keys) {
|
|
30853
|
-
if (!
|
|
30880
|
+
if (!def.shape[k]._zod.traits.has("$ZodType")) {
|
|
30854
30881
|
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
30855
30882
|
}
|
|
30856
30883
|
}
|
|
@@ -30997,7 +31024,7 @@ function handleUnionResults2(results, final, inst, ctx) {
|
|
|
30997
31024
|
}
|
|
30998
31025
|
}
|
|
30999
31026
|
const nonaborted = results.filter((r) => !aborted2(r));
|
|
31000
|
-
if (nonaborted.length
|
|
31027
|
+
if (nonaborted.length === 1) {
|
|
31001
31028
|
final.value = nonaborted[0].value;
|
|
31002
31029
|
return nonaborted[0];
|
|
31003
31030
|
}
|
|
@@ -31026,7 +31053,12 @@ var $ZodUnion2 = /* @__PURE__ */ $constructor2("$ZodUnion", (inst, def) => {
|
|
|
31026
31053
|
}
|
|
31027
31054
|
return;
|
|
31028
31055
|
});
|
|
31056
|
+
const single = def.options.length === 1;
|
|
31057
|
+
const first = def.options[0]._zod.run;
|
|
31029
31058
|
inst._zod.parse = (payload, ctx) => {
|
|
31059
|
+
if (single) {
|
|
31060
|
+
return first(payload, ctx);
|
|
31061
|
+
}
|
|
31030
31062
|
let async = false;
|
|
31031
31063
|
const results = [];
|
|
31032
31064
|
for (const option of def.options) {
|
|
@@ -31107,6 +31139,7 @@ var $ZodDiscriminatedUnion2 = /* @__PURE__ */ $constructor2("$ZodDiscriminatedUn
|
|
|
31107
31139
|
code: "invalid_union",
|
|
31108
31140
|
errors: [],
|
|
31109
31141
|
note: "No matching discriminator",
|
|
31142
|
+
discriminator: def.discriminator,
|
|
31110
31143
|
input,
|
|
31111
31144
|
path: [def.discriminator],
|
|
31112
31145
|
inst
|
|
@@ -31211,10 +31244,10 @@ var $ZodTuple2 = /* @__PURE__ */ $constructor2("$ZodTuple", (inst, def) => {
|
|
|
31211
31244
|
const tooSmall = input.length < optStart - 1;
|
|
31212
31245
|
if (tooBig || tooSmall) {
|
|
31213
31246
|
payload.issues.push({
|
|
31247
|
+
...tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length },
|
|
31214
31248
|
input,
|
|
31215
31249
|
inst,
|
|
31216
|
-
origin: "array"
|
|
31217
|
-
...tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }
|
|
31250
|
+
origin: "array"
|
|
31218
31251
|
});
|
|
31219
31252
|
return payload;
|
|
31220
31253
|
}
|
|
@@ -31323,8 +31356,8 @@ var $ZodRecord2 = /* @__PURE__ */ $constructor2("$ZodRecord", (inst, def) => {
|
|
|
31323
31356
|
}
|
|
31324
31357
|
if (keyResult.issues.length) {
|
|
31325
31358
|
payload.issues.push({
|
|
31326
|
-
origin: "record",
|
|
31327
31359
|
code: "invalid_key",
|
|
31360
|
+
origin: "record",
|
|
31328
31361
|
issues: keyResult.issues.map((iss) => finalizeIssue2(iss, ctx, config2())),
|
|
31329
31362
|
input: key,
|
|
31330
31363
|
path: [key],
|
|
@@ -31392,8 +31425,8 @@ function handleMapResult2(keyResult, valueResult, final, key, input, inst, ctx)
|
|
|
31392
31425
|
final.issues.push(...prefixIssues2(key, keyResult.issues));
|
|
31393
31426
|
} else {
|
|
31394
31427
|
final.issues.push({
|
|
31395
|
-
origin: "map",
|
|
31396
31428
|
code: "invalid_key",
|
|
31429
|
+
origin: "map",
|
|
31397
31430
|
input,
|
|
31398
31431
|
inst,
|
|
31399
31432
|
issues: keyResult.issues.map((iss) => finalizeIssue2(iss, ctx, config2()))
|
|
@@ -31471,6 +31504,9 @@ var $ZodEnum2 = /* @__PURE__ */ $constructor2("$ZodEnum", (inst, def) => {
|
|
|
31471
31504
|
});
|
|
31472
31505
|
var $ZodLiteral2 = /* @__PURE__ */ $constructor2("$ZodLiteral", (inst, def) => {
|
|
31473
31506
|
$ZodType2.init(inst, def);
|
|
31507
|
+
if (def.values.length === 0) {
|
|
31508
|
+
throw new Error("Cannot create literal schema with no valid values");
|
|
31509
|
+
}
|
|
31474
31510
|
inst._zod.values = new Set(def.values);
|
|
31475
31511
|
inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex2(o) : o ? escapeRegex2(o.toString()) : String(o)).join("|")})$`);
|
|
31476
31512
|
inst._zod.parse = (payload, _ctx) => {
|
|
@@ -31520,6 +31556,12 @@ var $ZodTransform2 = /* @__PURE__ */ $constructor2("$ZodTransform", (inst, def)
|
|
|
31520
31556
|
return payload;
|
|
31521
31557
|
};
|
|
31522
31558
|
});
|
|
31559
|
+
function handleOptionalResult(result, input) {
|
|
31560
|
+
if (result.issues.length && input === undefined) {
|
|
31561
|
+
return { issues: [], value: undefined };
|
|
31562
|
+
}
|
|
31563
|
+
return result;
|
|
31564
|
+
}
|
|
31523
31565
|
var $ZodOptional2 = /* @__PURE__ */ $constructor2("$ZodOptional", (inst, def) => {
|
|
31524
31566
|
$ZodType2.init(inst, def);
|
|
31525
31567
|
inst._zod.optin = "optional";
|
|
@@ -31533,7 +31575,10 @@ var $ZodOptional2 = /* @__PURE__ */ $constructor2("$ZodOptional", (inst, def) =>
|
|
|
31533
31575
|
});
|
|
31534
31576
|
inst._zod.parse = (payload, ctx) => {
|
|
31535
31577
|
if (def.innerType._zod.optin === "optional") {
|
|
31536
|
-
|
|
31578
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
31579
|
+
if (result instanceof Promise)
|
|
31580
|
+
return result.then((r) => handleOptionalResult(r, payload.value));
|
|
31581
|
+
return handleOptionalResult(result, payload.value);
|
|
31537
31582
|
}
|
|
31538
31583
|
if (payload.value === undefined) {
|
|
31539
31584
|
return payload;
|
|
@@ -31724,7 +31769,7 @@ var $ZodTemplateLiteral2 = /* @__PURE__ */ $constructor2("$ZodTemplateLiteral",
|
|
|
31724
31769
|
$ZodType2.init(inst, def);
|
|
31725
31770
|
const regexParts = [];
|
|
31726
31771
|
for (const part of def.parts) {
|
|
31727
|
-
if (part
|
|
31772
|
+
if (typeof part === "object" && part !== null) {
|
|
31728
31773
|
if (!part._zod.pattern) {
|
|
31729
31774
|
throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
|
|
31730
31775
|
}
|
|
@@ -31776,8 +31821,8 @@ var $ZodLazy2 = /* @__PURE__ */ $constructor2("$ZodLazy", (inst, def) => {
|
|
|
31776
31821
|
defineLazy2(inst._zod, "innerType", () => def.getter());
|
|
31777
31822
|
defineLazy2(inst._zod, "pattern", () => inst._zod.innerType._zod.pattern);
|
|
31778
31823
|
defineLazy2(inst._zod, "propValues", () => inst._zod.innerType._zod.propValues);
|
|
31779
|
-
defineLazy2(inst._zod, "optin", () => inst._zod.innerType._zod.optin);
|
|
31780
|
-
defineLazy2(inst._zod, "optout", () => inst._zod.innerType._zod.optout);
|
|
31824
|
+
defineLazy2(inst._zod, "optin", () => inst._zod.innerType._zod.optin ?? undefined);
|
|
31825
|
+
defineLazy2(inst._zod, "optout", () => inst._zod.innerType._zod.optout ?? undefined);
|
|
31781
31826
|
inst._zod.parse = (payload, ctx) => {
|
|
31782
31827
|
const inner = inst._zod.innerType;
|
|
31783
31828
|
return inner._zod.run(payload, ctx);
|
|
@@ -31818,6 +31863,7 @@ var exports_locales2 = {};
|
|
|
31818
31863
|
__export(exports_locales2, {
|
|
31819
31864
|
zhTW: () => zh_TW_default2,
|
|
31820
31865
|
zhCN: () => zh_CN_default2,
|
|
31866
|
+
yo: () => yo_default,
|
|
31821
31867
|
vi: () => vi_default2,
|
|
31822
31868
|
ur: () => ur_default2,
|
|
31823
31869
|
ua: () => ua_default2,
|
|
@@ -36780,6 +36826,121 @@ function zh_TW_default2() {
|
|
|
36780
36826
|
localeError: error80()
|
|
36781
36827
|
};
|
|
36782
36828
|
}
|
|
36829
|
+
// ../../node_modules/zod/v4/locales/yo.js
|
|
36830
|
+
var error81 = () => {
|
|
36831
|
+
const Sizable = {
|
|
36832
|
+
string: { unit: "àmi", verb: "ní" },
|
|
36833
|
+
file: { unit: "bytes", verb: "ní" },
|
|
36834
|
+
array: { unit: "nkan", verb: "ní" },
|
|
36835
|
+
set: { unit: "nkan", verb: "ní" }
|
|
36836
|
+
};
|
|
36837
|
+
function getSizing(origin) {
|
|
36838
|
+
return Sizable[origin] ?? null;
|
|
36839
|
+
}
|
|
36840
|
+
const parsedType8 = (data) => {
|
|
36841
|
+
const t = typeof data;
|
|
36842
|
+
switch (t) {
|
|
36843
|
+
case "number": {
|
|
36844
|
+
return Number.isNaN(data) ? "NaN" : "nọ́mbà";
|
|
36845
|
+
}
|
|
36846
|
+
case "object": {
|
|
36847
|
+
if (Array.isArray(data)) {
|
|
36848
|
+
return "akopọ";
|
|
36849
|
+
}
|
|
36850
|
+
if (data === null) {
|
|
36851
|
+
return "null";
|
|
36852
|
+
}
|
|
36853
|
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
36854
|
+
return data.constructor.name;
|
|
36855
|
+
}
|
|
36856
|
+
}
|
|
36857
|
+
}
|
|
36858
|
+
return t;
|
|
36859
|
+
};
|
|
36860
|
+
const Nouns = {
|
|
36861
|
+
regex: "ẹ̀rọ ìbáwọlé",
|
|
36862
|
+
email: "àdírẹ́sì ìmẹ́lì",
|
|
36863
|
+
url: "URL",
|
|
36864
|
+
emoji: "emoji",
|
|
36865
|
+
uuid: "UUID",
|
|
36866
|
+
uuidv4: "UUIDv4",
|
|
36867
|
+
uuidv6: "UUIDv6",
|
|
36868
|
+
nanoid: "nanoid",
|
|
36869
|
+
guid: "GUID",
|
|
36870
|
+
cuid: "cuid",
|
|
36871
|
+
cuid2: "cuid2",
|
|
36872
|
+
ulid: "ULID",
|
|
36873
|
+
xid: "XID",
|
|
36874
|
+
ksuid: "KSUID",
|
|
36875
|
+
datetime: "àkókò ISO",
|
|
36876
|
+
date: "ọjọ́ ISO",
|
|
36877
|
+
time: "àkókò ISO",
|
|
36878
|
+
duration: "àkókò tó pé ISO",
|
|
36879
|
+
ipv4: "àdírẹ́sì IPv4",
|
|
36880
|
+
ipv6: "àdírẹ́sì IPv6",
|
|
36881
|
+
cidrv4: "àgbègbè IPv4",
|
|
36882
|
+
cidrv6: "àgbègbè IPv6",
|
|
36883
|
+
base64: "ọ̀rọ̀ tí a kọ́ ní base64",
|
|
36884
|
+
base64url: "ọ̀rọ̀ base64url",
|
|
36885
|
+
json_string: "ọ̀rọ̀ JSON",
|
|
36886
|
+
e164: "nọ́mbà E.164",
|
|
36887
|
+
jwt: "JWT",
|
|
36888
|
+
template_literal: "ẹ̀rọ ìbáwọlé"
|
|
36889
|
+
};
|
|
36890
|
+
return (issue3) => {
|
|
36891
|
+
switch (issue3.code) {
|
|
36892
|
+
case "invalid_type":
|
|
36893
|
+
return `Ìbáwọlé aṣìṣe: a ní láti fi ${issue3.expected}, àmọ̀ a rí ${parsedType8(issue3.input)}`;
|
|
36894
|
+
case "invalid_value":
|
|
36895
|
+
if (issue3.values.length === 1)
|
|
36896
|
+
return `Ìbáwọlé aṣìṣe: a ní láti fi ${stringifyPrimitive2(issue3.values[0])}`;
|
|
36897
|
+
return `Àṣàyàn aṣìṣe: yan ọ̀kan lára ${joinValues2(issue3.values, "|")}`;
|
|
36898
|
+
case "too_big": {
|
|
36899
|
+
const adj = issue3.inclusive ? "<=" : "<";
|
|
36900
|
+
const sizing = getSizing(issue3.origin);
|
|
36901
|
+
if (sizing)
|
|
36902
|
+
return `Tó pọ̀ jù: a ní láti jẹ́ pé ${issue3.origin ?? "iye"} ${sizing.verb} ${adj}${issue3.maximum} ${sizing.unit}`;
|
|
36903
|
+
return `Tó pọ̀ jù: a ní láti jẹ́ ${adj}${issue3.maximum}`;
|
|
36904
|
+
}
|
|
36905
|
+
case "too_small": {
|
|
36906
|
+
const adj = issue3.inclusive ? ">=" : ">";
|
|
36907
|
+
const sizing = getSizing(issue3.origin);
|
|
36908
|
+
if (sizing)
|
|
36909
|
+
return `Kéré ju: a ní láti jẹ́ pé ${issue3.origin} ${sizing.verb} ${adj}${issue3.minimum} ${sizing.unit}`;
|
|
36910
|
+
return `Kéré ju: a ní láti jẹ́ ${adj}${issue3.minimum}`;
|
|
36911
|
+
}
|
|
36912
|
+
case "invalid_format": {
|
|
36913
|
+
const _issue = issue3;
|
|
36914
|
+
if (_issue.format === "starts_with")
|
|
36915
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bẹ̀rẹ̀ pẹ̀lú "${_issue.prefix}"`;
|
|
36916
|
+
if (_issue.format === "ends_with")
|
|
36917
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ parí pẹ̀lú "${_issue.suffix}"`;
|
|
36918
|
+
if (_issue.format === "includes")
|
|
36919
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ ní "${_issue.includes}"`;
|
|
36920
|
+
if (_issue.format === "regex")
|
|
36921
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bá àpẹẹrẹ mu ${_issue.pattern}`;
|
|
36922
|
+
return `Aṣìṣe: ${Nouns[_issue.format] ?? issue3.format}`;
|
|
36923
|
+
}
|
|
36924
|
+
case "not_multiple_of":
|
|
36925
|
+
return `Nọ́mbà aṣìṣe: gbọ́dọ̀ jẹ́ èyà pípín ti ${issue3.divisor}`;
|
|
36926
|
+
case "unrecognized_keys":
|
|
36927
|
+
return `Bọtìnì àìmọ̀: ${joinValues2(issue3.keys, ", ")}`;
|
|
36928
|
+
case "invalid_key":
|
|
36929
|
+
return `Bọtìnì aṣìṣe nínú ${issue3.origin}`;
|
|
36930
|
+
case "invalid_union":
|
|
36931
|
+
return "Ìbáwọlé aṣìṣe";
|
|
36932
|
+
case "invalid_element":
|
|
36933
|
+
return `Iye aṣìṣe nínú ${issue3.origin}`;
|
|
36934
|
+
default:
|
|
36935
|
+
return "Ìbáwọlé aṣìṣe";
|
|
36936
|
+
}
|
|
36937
|
+
};
|
|
36938
|
+
};
|
|
36939
|
+
function yo_default() {
|
|
36940
|
+
return {
|
|
36941
|
+
localeError: error81()
|
|
36942
|
+
};
|
|
36943
|
+
}
|
|
36783
36944
|
// ../../node_modules/zod/v4/core/registries.js
|
|
36784
36945
|
var $output2 = Symbol("ZodOutput");
|
|
36785
36946
|
var $input2 = Symbol("ZodInput");
|
|
@@ -37539,7 +37700,7 @@ function _default3(Class3, innerType, defaultValue) {
|
|
|
37539
37700
|
type: "default",
|
|
37540
37701
|
innerType,
|
|
37541
37702
|
get defaultValue() {
|
|
37542
|
-
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
37703
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
37543
37704
|
}
|
|
37544
37705
|
});
|
|
37545
37706
|
}
|
|
@@ -37615,6 +37776,34 @@ function _refine2(Class3, fn, _params) {
|
|
|
37615
37776
|
});
|
|
37616
37777
|
return schema;
|
|
37617
37778
|
}
|
|
37779
|
+
function _superRefine(fn) {
|
|
37780
|
+
const ch = _check((payload) => {
|
|
37781
|
+
payload.addIssue = (issue3) => {
|
|
37782
|
+
if (typeof issue3 === "string") {
|
|
37783
|
+
payload.issues.push(issue2(issue3, payload.value, ch._zod.def));
|
|
37784
|
+
} else {
|
|
37785
|
+
const _issue = issue3;
|
|
37786
|
+
if (_issue.fatal)
|
|
37787
|
+
_issue.continue = false;
|
|
37788
|
+
_issue.code ?? (_issue.code = "custom");
|
|
37789
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
37790
|
+
_issue.inst ?? (_issue.inst = ch);
|
|
37791
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
37792
|
+
payload.issues.push(issue2(_issue));
|
|
37793
|
+
}
|
|
37794
|
+
};
|
|
37795
|
+
return fn(payload.value, payload);
|
|
37796
|
+
});
|
|
37797
|
+
return ch;
|
|
37798
|
+
}
|
|
37799
|
+
function _check(fn, params) {
|
|
37800
|
+
const ch = new $ZodCheck2({
|
|
37801
|
+
check: "custom",
|
|
37802
|
+
...normalizeParams2(params)
|
|
37803
|
+
});
|
|
37804
|
+
ch._zod.check = fn;
|
|
37805
|
+
return ch;
|
|
37806
|
+
}
|
|
37618
37807
|
function _stringbool2(Classes, _params) {
|
|
37619
37808
|
const params = normalizeParams2(_params);
|
|
37620
37809
|
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
@@ -37645,7 +37834,8 @@ function _stringbool2(Classes, _params) {
|
|
|
37645
37834
|
expected: "stringbool",
|
|
37646
37835
|
values: [...truthySet, ...falsySet],
|
|
37647
37836
|
input: payload.value,
|
|
37648
|
-
inst: tx
|
|
37837
|
+
inst: tx,
|
|
37838
|
+
continue: false
|
|
37649
37839
|
});
|
|
37650
37840
|
return {};
|
|
37651
37841
|
}
|
|
@@ -37826,7 +38016,7 @@ class JSONSchemaGenerator2 {
|
|
|
37826
38016
|
else if (regexes.length > 1) {
|
|
37827
38017
|
result.schema.allOf = [
|
|
37828
38018
|
...regexes.map((regex) => ({
|
|
37829
|
-
...this.target === "draft-7" ? { type: "string" } : {},
|
|
38019
|
+
...this.target === "draft-7" || this.target === "draft-4" ? { type: "string" } : {},
|
|
37830
38020
|
pattern: regex.source
|
|
37831
38021
|
}))
|
|
37832
38022
|
];
|
|
@@ -37841,22 +38031,34 @@ class JSONSchemaGenerator2 {
|
|
|
37841
38031
|
json2.type = "integer";
|
|
37842
38032
|
else
|
|
37843
38033
|
json2.type = "number";
|
|
37844
|
-
if (typeof exclusiveMinimum === "number")
|
|
37845
|
-
|
|
38034
|
+
if (typeof exclusiveMinimum === "number") {
|
|
38035
|
+
if (this.target === "draft-4") {
|
|
38036
|
+
json2.minimum = exclusiveMinimum;
|
|
38037
|
+
json2.exclusiveMinimum = true;
|
|
38038
|
+
} else {
|
|
38039
|
+
json2.exclusiveMinimum = exclusiveMinimum;
|
|
38040
|
+
}
|
|
38041
|
+
}
|
|
37846
38042
|
if (typeof minimum === "number") {
|
|
37847
38043
|
json2.minimum = minimum;
|
|
37848
|
-
if (typeof exclusiveMinimum === "number") {
|
|
38044
|
+
if (typeof exclusiveMinimum === "number" && this.target !== "draft-4") {
|
|
37849
38045
|
if (exclusiveMinimum >= minimum)
|
|
37850
38046
|
delete json2.minimum;
|
|
37851
38047
|
else
|
|
37852
38048
|
delete json2.exclusiveMinimum;
|
|
37853
38049
|
}
|
|
37854
38050
|
}
|
|
37855
|
-
if (typeof exclusiveMaximum === "number")
|
|
37856
|
-
|
|
38051
|
+
if (typeof exclusiveMaximum === "number") {
|
|
38052
|
+
if (this.target === "draft-4") {
|
|
38053
|
+
json2.maximum = exclusiveMaximum;
|
|
38054
|
+
json2.exclusiveMaximum = true;
|
|
38055
|
+
} else {
|
|
38056
|
+
json2.exclusiveMaximum = exclusiveMaximum;
|
|
38057
|
+
}
|
|
38058
|
+
}
|
|
37857
38059
|
if (typeof maximum === "number") {
|
|
37858
38060
|
json2.maximum = maximum;
|
|
37859
|
-
if (typeof exclusiveMaximum === "number") {
|
|
38061
|
+
if (typeof exclusiveMaximum === "number" && this.target !== "draft-4") {
|
|
37860
38062
|
if (exclusiveMaximum <= maximum)
|
|
37861
38063
|
delete json2.maximum;
|
|
37862
38064
|
else
|
|
@@ -38025,7 +38227,12 @@ class JSONSchemaGenerator2 {
|
|
|
38025
38227
|
case "record": {
|
|
38026
38228
|
const json2 = _json;
|
|
38027
38229
|
json2.type = "object";
|
|
38028
|
-
|
|
38230
|
+
if (this.target !== "draft-4") {
|
|
38231
|
+
json2.propertyNames = this.process(def.keyType, {
|
|
38232
|
+
...params,
|
|
38233
|
+
path: [...params.path, "propertyNames"]
|
|
38234
|
+
});
|
|
38235
|
+
}
|
|
38029
38236
|
json2.additionalProperties = this.process(def.valueType, {
|
|
38030
38237
|
...params,
|
|
38031
38238
|
path: [...params.path, "additionalProperties"]
|
|
@@ -38075,7 +38282,11 @@ class JSONSchemaGenerator2 {
|
|
|
38075
38282
|
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
38076
38283
|
const val = vals[0];
|
|
38077
38284
|
json2.type = val === null ? "null" : typeof val;
|
|
38078
|
-
|
|
38285
|
+
if (this.target === "draft-4") {
|
|
38286
|
+
json2.enum = [val];
|
|
38287
|
+
} else {
|
|
38288
|
+
json2.const = val;
|
|
38289
|
+
}
|
|
38079
38290
|
} else {
|
|
38080
38291
|
if (vals.every((v) => typeof v === "number"))
|
|
38081
38292
|
json2.type = "number";
|
|
@@ -38321,7 +38532,7 @@ class JSONSchemaGenerator2 {
|
|
|
38321
38532
|
if (ref) {
|
|
38322
38533
|
flattenRef(ref, params2);
|
|
38323
38534
|
const refSchema = this.seen.get(ref).schema;
|
|
38324
|
-
if (refSchema.$ref && params2.target === "draft-7") {
|
|
38535
|
+
if (refSchema.$ref && (params2.target === "draft-7" || params2.target === "draft-4")) {
|
|
38325
38536
|
schema2.allOf = schema2.allOf ?? [];
|
|
38326
38537
|
schema2.allOf.push(refSchema);
|
|
38327
38538
|
} else {
|
|
@@ -38344,6 +38555,8 @@ class JSONSchemaGenerator2 {
|
|
|
38344
38555
|
result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
38345
38556
|
} else if (this.target === "draft-7") {
|
|
38346
38557
|
result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
38558
|
+
} else if (this.target === "draft-4") {
|
|
38559
|
+
result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
38347
38560
|
} else {
|
|
38348
38561
|
console.warn(`Invalid target: ${this.target}`);
|
|
38349
38562
|
}
|
|
@@ -38864,6 +39077,9 @@ var ZodCustomStringFormat2 = /* @__PURE__ */ $constructor2("ZodCustomStringForma
|
|
|
38864
39077
|
function stringFormat2(format, fnOrRegex, _params = {}) {
|
|
38865
39078
|
return _stringFormat2(ZodCustomStringFormat2, format, fnOrRegex, _params);
|
|
38866
39079
|
}
|
|
39080
|
+
function hostname3(_params) {
|
|
39081
|
+
return _stringFormat2(ZodCustomStringFormat2, "hostname", exports_regexes2.hostname, _params);
|
|
39082
|
+
}
|
|
38867
39083
|
var ZodNumber2 = /* @__PURE__ */ $constructor2("ZodNumber", (inst, def) => {
|
|
38868
39084
|
$ZodNumber2.init(inst, def);
|
|
38869
39085
|
ZodType2.init(inst, def);
|
|
@@ -39028,7 +39244,7 @@ function array2(element, params) {
|
|
|
39028
39244
|
}
|
|
39029
39245
|
function keyof2(schema) {
|
|
39030
39246
|
const shape = schema._zod.def.shape;
|
|
39031
|
-
return
|
|
39247
|
+
return _enum4(Object.keys(shape));
|
|
39032
39248
|
}
|
|
39033
39249
|
var ZodObject2 = /* @__PURE__ */ $constructor2("ZodObject", (inst, def) => {
|
|
39034
39250
|
$ZodObject2.init(inst, def);
|
|
@@ -39053,7 +39269,7 @@ function object2(shape, params) {
|
|
|
39053
39269
|
const def = {
|
|
39054
39270
|
type: "object",
|
|
39055
39271
|
get shape() {
|
|
39056
|
-
exports_util2.assignProp(this, "shape",
|
|
39272
|
+
exports_util2.assignProp(this, "shape", shape ? exports_util2.objectClone(shape) : {});
|
|
39057
39273
|
return this.shape;
|
|
39058
39274
|
},
|
|
39059
39275
|
...exports_util2.normalizeParams(params)
|
|
@@ -39064,7 +39280,7 @@ function strictObject2(shape, params) {
|
|
|
39064
39280
|
return new ZodObject2({
|
|
39065
39281
|
type: "object",
|
|
39066
39282
|
get shape() {
|
|
39067
|
-
exports_util2.assignProp(this, "shape",
|
|
39283
|
+
exports_util2.assignProp(this, "shape", exports_util2.objectClone(shape));
|
|
39068
39284
|
return this.shape;
|
|
39069
39285
|
},
|
|
39070
39286
|
catchall: never2(),
|
|
@@ -39075,7 +39291,7 @@ function looseObject2(shape, params) {
|
|
|
39075
39291
|
return new ZodObject2({
|
|
39076
39292
|
type: "object",
|
|
39077
39293
|
get shape() {
|
|
39078
|
-
exports_util2.assignProp(this, "shape",
|
|
39294
|
+
exports_util2.assignProp(this, "shape", exports_util2.objectClone(shape));
|
|
39079
39295
|
return this.shape;
|
|
39080
39296
|
},
|
|
39081
39297
|
catchall: unknown2(),
|
|
@@ -39341,7 +39557,7 @@ function _default4(innerType, defaultValue) {
|
|
|
39341
39557
|
type: "default",
|
|
39342
39558
|
innerType,
|
|
39343
39559
|
get defaultValue() {
|
|
39344
|
-
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
39560
|
+
return typeof defaultValue === "function" ? defaultValue() : exports_util2.shallowClone(defaultValue);
|
|
39345
39561
|
}
|
|
39346
39562
|
});
|
|
39347
39563
|
}
|
|
@@ -39355,7 +39571,7 @@ function prefault2(innerType, defaultValue) {
|
|
|
39355
39571
|
type: "prefault",
|
|
39356
39572
|
innerType,
|
|
39357
39573
|
get defaultValue() {
|
|
39358
|
-
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
39574
|
+
return typeof defaultValue === "function" ? defaultValue() : exports_util2.shallowClone(defaultValue);
|
|
39359
39575
|
}
|
|
39360
39576
|
});
|
|
39361
39577
|
}
|
|
@@ -39477,24 +39693,7 @@ function refine2(fn, _params = {}) {
|
|
|
39477
39693
|
return _refine2(ZodCustom2, fn, _params);
|
|
39478
39694
|
}
|
|
39479
39695
|
function superRefine2(fn) {
|
|
39480
|
-
|
|
39481
|
-
payload.addIssue = (issue3) => {
|
|
39482
|
-
if (typeof issue3 === "string") {
|
|
39483
|
-
payload.issues.push(exports_util2.issue(issue3, payload.value, ch._zod.def));
|
|
39484
|
-
} else {
|
|
39485
|
-
const _issue = issue3;
|
|
39486
|
-
if (_issue.fatal)
|
|
39487
|
-
_issue.continue = false;
|
|
39488
|
-
_issue.code ?? (_issue.code = "custom");
|
|
39489
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
39490
|
-
_issue.inst ?? (_issue.inst = ch);
|
|
39491
|
-
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
39492
|
-
payload.issues.push(exports_util2.issue(_issue));
|
|
39493
|
-
}
|
|
39494
|
-
};
|
|
39495
|
-
return fn(payload.value, payload);
|
|
39496
|
-
});
|
|
39497
|
-
return ch;
|
|
39696
|
+
return _superRefine(fn);
|
|
39498
39697
|
}
|
|
39499
39698
|
function _instanceof2(cls, params = {
|
|
39500
39699
|
error: `Input not instance of ${cls.name}`
|
|
@@ -39828,8 +40027,8 @@ class ZodError3 extends Error {
|
|
|
39828
40027
|
return issue3.message;
|
|
39829
40028
|
};
|
|
39830
40029
|
const fieldErrors = { _errors: [] };
|
|
39831
|
-
const processError = (
|
|
39832
|
-
for (const issue3 of
|
|
40030
|
+
const processError = (error82) => {
|
|
40031
|
+
for (const issue3 of error82.issues) {
|
|
39833
40032
|
if (issue3.code === "invalid_union") {
|
|
39834
40033
|
issue3.unionErrors.map(processError);
|
|
39835
40034
|
} else if (issue3.code === "invalid_return_type") {
|
|
@@ -39892,8 +40091,8 @@ class ZodError3 extends Error {
|
|
|
39892
40091
|
}
|
|
39893
40092
|
}
|
|
39894
40093
|
ZodError3.create = (issues) => {
|
|
39895
|
-
const
|
|
39896
|
-
return
|
|
40094
|
+
const error82 = new ZodError3(issues);
|
|
40095
|
+
return error82;
|
|
39897
40096
|
};
|
|
39898
40097
|
|
|
39899
40098
|
// ../../node_modules/zod-to-json-schema/node_modules/zod/v3/locales/en.js
|
|
@@ -40150,8 +40349,8 @@ var handleResult = (ctx, result) => {
|
|
|
40150
40349
|
get error() {
|
|
40151
40350
|
if (this._error)
|
|
40152
40351
|
return this._error;
|
|
40153
|
-
const
|
|
40154
|
-
this._error =
|
|
40352
|
+
const error82 = new ZodError3(ctx.common.issues);
|
|
40353
|
+
this._error = error82;
|
|
40155
40354
|
return this._error;
|
|
40156
40355
|
}
|
|
40157
40356
|
};
|
|
@@ -42733,25 +42932,25 @@ class ZodFunction extends ZodType3 {
|
|
|
42733
42932
|
});
|
|
42734
42933
|
return INVALID;
|
|
42735
42934
|
}
|
|
42736
|
-
function makeArgsIssue(args,
|
|
42935
|
+
function makeArgsIssue(args, error82) {
|
|
42737
42936
|
return makeIssue({
|
|
42738
42937
|
data: args,
|
|
42739
42938
|
path: ctx.path,
|
|
42740
42939
|
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap3(), en_default3].filter((x) => !!x),
|
|
42741
42940
|
issueData: {
|
|
42742
42941
|
code: ZodIssueCode3.invalid_arguments,
|
|
42743
|
-
argumentsError:
|
|
42942
|
+
argumentsError: error82
|
|
42744
42943
|
}
|
|
42745
42944
|
});
|
|
42746
42945
|
}
|
|
42747
|
-
function makeReturnsIssue(returns,
|
|
42946
|
+
function makeReturnsIssue(returns, error82) {
|
|
42748
42947
|
return makeIssue({
|
|
42749
42948
|
data: returns,
|
|
42750
42949
|
path: ctx.path,
|
|
42751
42950
|
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap3(), en_default3].filter((x) => !!x),
|
|
42752
42951
|
issueData: {
|
|
42753
42952
|
code: ZodIssueCode3.invalid_return_type,
|
|
42754
|
-
returnTypeError:
|
|
42953
|
+
returnTypeError: error82
|
|
42755
42954
|
}
|
|
42756
42955
|
});
|
|
42757
42956
|
}
|
|
@@ -42760,15 +42959,15 @@ class ZodFunction extends ZodType3 {
|
|
|
42760
42959
|
if (this._def.returns instanceof ZodPromise3) {
|
|
42761
42960
|
const me = this;
|
|
42762
42961
|
return OK(async function(...args) {
|
|
42763
|
-
const
|
|
42962
|
+
const error82 = new ZodError3([]);
|
|
42764
42963
|
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
42765
|
-
|
|
42766
|
-
throw
|
|
42964
|
+
error82.addIssue(makeArgsIssue(args, e));
|
|
42965
|
+
throw error82;
|
|
42767
42966
|
});
|
|
42768
42967
|
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
42769
42968
|
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
42770
|
-
|
|
42771
|
-
throw
|
|
42969
|
+
error82.addIssue(makeReturnsIssue(result, e));
|
|
42970
|
+
throw error82;
|
|
42772
42971
|
});
|
|
42773
42972
|
return parsedReturns;
|
|
42774
42973
|
});
|
|
@@ -44631,8 +44830,33 @@ function combineHeaders(...headers) {
|
|
|
44631
44830
|
...currentHeaders != null ? currentHeaders : {}
|
|
44632
44831
|
}), {});
|
|
44633
44832
|
}
|
|
44634
|
-
async function delay(delayInMs) {
|
|
44635
|
-
|
|
44833
|
+
async function delay(delayInMs, options) {
|
|
44834
|
+
if (delayInMs == null) {
|
|
44835
|
+
return Promise.resolve();
|
|
44836
|
+
}
|
|
44837
|
+
const signal = options == null ? undefined : options.abortSignal;
|
|
44838
|
+
return new Promise((resolve2, reject) => {
|
|
44839
|
+
if (signal == null ? undefined : signal.aborted) {
|
|
44840
|
+
reject(createAbortError());
|
|
44841
|
+
return;
|
|
44842
|
+
}
|
|
44843
|
+
const timeoutId = setTimeout(() => {
|
|
44844
|
+
cleanup();
|
|
44845
|
+
resolve2();
|
|
44846
|
+
}, delayInMs);
|
|
44847
|
+
const cleanup = () => {
|
|
44848
|
+
clearTimeout(timeoutId);
|
|
44849
|
+
signal == null || signal.removeEventListener("abort", onAbort);
|
|
44850
|
+
};
|
|
44851
|
+
const onAbort = () => {
|
|
44852
|
+
cleanup();
|
|
44853
|
+
reject(createAbortError());
|
|
44854
|
+
};
|
|
44855
|
+
signal == null || signal.addEventListener("abort", onAbort);
|
|
44856
|
+
});
|
|
44857
|
+
}
|
|
44858
|
+
function createAbortError() {
|
|
44859
|
+
return new DOMException("Delay was aborted", "AbortError");
|
|
44636
44860
|
}
|
|
44637
44861
|
function extractResponseHeaders(response) {
|
|
44638
44862
|
return Object.fromEntries([...response.headers]);
|
|
@@ -44663,32 +44887,32 @@ var createIdGenerator = ({
|
|
|
44663
44887
|
return () => `${prefix}${separator}${generator()}`;
|
|
44664
44888
|
};
|
|
44665
44889
|
var generateId = createIdGenerator();
|
|
44666
|
-
function getErrorMessage2(
|
|
44667
|
-
if (
|
|
44890
|
+
function getErrorMessage2(error82) {
|
|
44891
|
+
if (error82 == null) {
|
|
44668
44892
|
return "unknown error";
|
|
44669
44893
|
}
|
|
44670
|
-
if (typeof
|
|
44671
|
-
return
|
|
44894
|
+
if (typeof error82 === "string") {
|
|
44895
|
+
return error82;
|
|
44672
44896
|
}
|
|
44673
|
-
if (
|
|
44674
|
-
return
|
|
44897
|
+
if (error82 instanceof Error) {
|
|
44898
|
+
return error82.message;
|
|
44675
44899
|
}
|
|
44676
|
-
return JSON.stringify(
|
|
44900
|
+
return JSON.stringify(error82);
|
|
44677
44901
|
}
|
|
44678
|
-
function isAbortError(
|
|
44679
|
-
return
|
|
44902
|
+
function isAbortError(error82) {
|
|
44903
|
+
return (error82 instanceof Error || error82 instanceof DOMException) && (error82.name === "AbortError" || error82.name === "ResponseAborted" || error82.name === "TimeoutError");
|
|
44680
44904
|
}
|
|
44681
44905
|
var FETCH_FAILED_ERROR_MESSAGES = ["fetch failed", "failed to fetch"];
|
|
44682
44906
|
function handleFetchError({
|
|
44683
|
-
error:
|
|
44907
|
+
error: error82,
|
|
44684
44908
|
url: url3,
|
|
44685
44909
|
requestBodyValues
|
|
44686
44910
|
}) {
|
|
44687
|
-
if (isAbortError(
|
|
44688
|
-
return
|
|
44911
|
+
if (isAbortError(error82)) {
|
|
44912
|
+
return error82;
|
|
44689
44913
|
}
|
|
44690
|
-
if (
|
|
44691
|
-
const cause =
|
|
44914
|
+
if (error82 instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error82.message.toLowerCase())) {
|
|
44915
|
+
const cause = error82.cause;
|
|
44692
44916
|
if (cause != null) {
|
|
44693
44917
|
return new APICallError({
|
|
44694
44918
|
message: `Cannot connect to API: ${cause.message}`,
|
|
@@ -44699,7 +44923,7 @@ function handleFetchError({
|
|
|
44699
44923
|
});
|
|
44700
44924
|
}
|
|
44701
44925
|
}
|
|
44702
|
-
return
|
|
44926
|
+
return error82;
|
|
44703
44927
|
}
|
|
44704
44928
|
function removeUndefinedEntries(record4) {
|
|
44705
44929
|
return Object.fromEntries(Object.entries(record4).filter(([_key, value]) => value != null));
|
|
@@ -44728,13 +44952,13 @@ var getFromApi = async ({
|
|
|
44728
44952
|
url: url3,
|
|
44729
44953
|
requestBodyValues: {}
|
|
44730
44954
|
});
|
|
44731
|
-
} catch (
|
|
44732
|
-
if (isAbortError(
|
|
44733
|
-
throw
|
|
44955
|
+
} catch (error82) {
|
|
44956
|
+
if (isAbortError(error82) || APICallError.isInstance(error82)) {
|
|
44957
|
+
throw error82;
|
|
44734
44958
|
}
|
|
44735
44959
|
throw new APICallError({
|
|
44736
44960
|
message: "Failed to process error response",
|
|
44737
|
-
cause:
|
|
44961
|
+
cause: error82,
|
|
44738
44962
|
statusCode: response.status,
|
|
44739
44963
|
url: url3,
|
|
44740
44964
|
responseHeaders,
|
|
@@ -44749,23 +44973,23 @@ var getFromApi = async ({
|
|
|
44749
44973
|
url: url3,
|
|
44750
44974
|
requestBodyValues: {}
|
|
44751
44975
|
});
|
|
44752
|
-
} catch (
|
|
44753
|
-
if (
|
|
44754
|
-
if (isAbortError(
|
|
44755
|
-
throw
|
|
44976
|
+
} catch (error82) {
|
|
44977
|
+
if (error82 instanceof Error) {
|
|
44978
|
+
if (isAbortError(error82) || APICallError.isInstance(error82)) {
|
|
44979
|
+
throw error82;
|
|
44756
44980
|
}
|
|
44757
44981
|
}
|
|
44758
44982
|
throw new APICallError({
|
|
44759
44983
|
message: "Failed to process successful response",
|
|
44760
|
-
cause:
|
|
44984
|
+
cause: error82,
|
|
44761
44985
|
statusCode: response.status,
|
|
44762
44986
|
url: url3,
|
|
44763
44987
|
responseHeaders,
|
|
44764
44988
|
requestBodyValues: {}
|
|
44765
44989
|
});
|
|
44766
44990
|
}
|
|
44767
|
-
} catch (
|
|
44768
|
-
throw handleFetchError({ error:
|
|
44991
|
+
} catch (error82) {
|
|
44992
|
+
throw handleFetchError({ error: error82, url: url3, requestBodyValues: {} });
|
|
44769
44993
|
}
|
|
44770
44994
|
};
|
|
44771
44995
|
function isUrlSupported({
|
|
@@ -44889,10 +45113,10 @@ async function safeValidateTypes({
|
|
|
44889
45113
|
error: TypeValidationError.wrap({ value, cause: result.error }),
|
|
44890
45114
|
rawValue: value
|
|
44891
45115
|
};
|
|
44892
|
-
} catch (
|
|
45116
|
+
} catch (error82) {
|
|
44893
45117
|
return {
|
|
44894
45118
|
success: false,
|
|
44895
|
-
error: TypeValidationError.wrap({ value, cause:
|
|
45119
|
+
error: TypeValidationError.wrap({ value, cause: error82 }),
|
|
44896
45120
|
rawValue: value
|
|
44897
45121
|
};
|
|
44898
45122
|
}
|
|
@@ -44907,11 +45131,11 @@ async function parseJSON({
|
|
|
44907
45131
|
return value;
|
|
44908
45132
|
}
|
|
44909
45133
|
return validateTypes({ value, schema });
|
|
44910
|
-
} catch (
|
|
44911
|
-
if (JSONParseError.isInstance(
|
|
44912
|
-
throw
|
|
45134
|
+
} catch (error82) {
|
|
45135
|
+
if (JSONParseError.isInstance(error82) || TypeValidationError.isInstance(error82)) {
|
|
45136
|
+
throw error82;
|
|
44913
45137
|
}
|
|
44914
|
-
throw new JSONParseError({ text, cause:
|
|
45138
|
+
throw new JSONParseError({ text, cause: error82 });
|
|
44915
45139
|
}
|
|
44916
45140
|
}
|
|
44917
45141
|
async function safeParseJSON({
|
|
@@ -44924,10 +45148,10 @@ async function safeParseJSON({
|
|
|
44924
45148
|
return { success: true, value, rawValue: value };
|
|
44925
45149
|
}
|
|
44926
45150
|
return await safeValidateTypes({ value, schema });
|
|
44927
|
-
} catch (
|
|
45151
|
+
} catch (error82) {
|
|
44928
45152
|
return {
|
|
44929
45153
|
success: false,
|
|
44930
|
-
error: JSONParseError.isInstance(
|
|
45154
|
+
error: JSONParseError.isInstance(error82) ? error82 : new JSONParseError({ text, cause: error82 }),
|
|
44931
45155
|
rawValue: undefined
|
|
44932
45156
|
};
|
|
44933
45157
|
}
|
|
@@ -44994,13 +45218,13 @@ var postToApi = async ({
|
|
|
44994
45218
|
url: url3,
|
|
44995
45219
|
requestBodyValues: body.values
|
|
44996
45220
|
});
|
|
44997
|
-
} catch (
|
|
44998
|
-
if (isAbortError(
|
|
44999
|
-
throw
|
|
45221
|
+
} catch (error82) {
|
|
45222
|
+
if (isAbortError(error82) || APICallError.isInstance(error82)) {
|
|
45223
|
+
throw error82;
|
|
45000
45224
|
}
|
|
45001
45225
|
throw new APICallError({
|
|
45002
45226
|
message: "Failed to process error response",
|
|
45003
|
-
cause:
|
|
45227
|
+
cause: error82,
|
|
45004
45228
|
statusCode: response.status,
|
|
45005
45229
|
url: url3,
|
|
45006
45230
|
responseHeaders,
|
|
@@ -45015,23 +45239,23 @@ var postToApi = async ({
|
|
|
45015
45239
|
url: url3,
|
|
45016
45240
|
requestBodyValues: body.values
|
|
45017
45241
|
});
|
|
45018
|
-
} catch (
|
|
45019
|
-
if (
|
|
45020
|
-
if (isAbortError(
|
|
45021
|
-
throw
|
|
45242
|
+
} catch (error82) {
|
|
45243
|
+
if (error82 instanceof Error) {
|
|
45244
|
+
if (isAbortError(error82) || APICallError.isInstance(error82)) {
|
|
45245
|
+
throw error82;
|
|
45022
45246
|
}
|
|
45023
45247
|
}
|
|
45024
45248
|
throw new APICallError({
|
|
45025
45249
|
message: "Failed to process successful response",
|
|
45026
|
-
cause:
|
|
45250
|
+
cause: error82,
|
|
45027
45251
|
statusCode: response.status,
|
|
45028
45252
|
url: url3,
|
|
45029
45253
|
responseHeaders,
|
|
45030
45254
|
requestBodyValues: body.values
|
|
45031
45255
|
});
|
|
45032
45256
|
}
|
|
45033
|
-
} catch (
|
|
45034
|
-
throw handleFetchError({ error:
|
|
45257
|
+
} catch (error82) {
|
|
45258
|
+
throw handleFetchError({ error: error82, url: url3, requestBodyValues: body.values });
|
|
45035
45259
|
}
|
|
45036
45260
|
};
|
|
45037
45261
|
async function resolve(value) {
|
|
@@ -45223,11 +45447,11 @@ var GatewayError = class _GatewayError extends (_b = Error, _a15 = symbol17, _b)
|
|
|
45223
45447
|
this.statusCode = statusCode;
|
|
45224
45448
|
this.cause = cause;
|
|
45225
45449
|
}
|
|
45226
|
-
static isInstance(
|
|
45227
|
-
return _GatewayError.hasMarker(
|
|
45450
|
+
static isInstance(error82) {
|
|
45451
|
+
return _GatewayError.hasMarker(error82);
|
|
45228
45452
|
}
|
|
45229
|
-
static hasMarker(
|
|
45230
|
-
return typeof
|
|
45453
|
+
static hasMarker(error82) {
|
|
45454
|
+
return typeof error82 === "object" && error82 !== null && symbol17 in error82 && error82[symbol17] === true;
|
|
45231
45455
|
}
|
|
45232
45456
|
};
|
|
45233
45457
|
var name14 = "GatewayAuthenticationError";
|
|
@@ -45246,8 +45470,8 @@ var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b2
|
|
|
45246
45470
|
this.name = name14;
|
|
45247
45471
|
this.type = "authentication_error";
|
|
45248
45472
|
}
|
|
45249
|
-
static isInstance(
|
|
45250
|
-
return GatewayError.hasMarker(
|
|
45473
|
+
static isInstance(error82) {
|
|
45474
|
+
return GatewayError.hasMarker(error82) && symbol23 in error82;
|
|
45251
45475
|
}
|
|
45252
45476
|
static createContextualError({
|
|
45253
45477
|
apiKeyProvided,
|
|
@@ -45311,8 +45535,8 @@ var GatewayInvalidRequestError = class extends (_b3 = GatewayError, _a32 = symbo
|
|
|
45311
45535
|
this.name = name22;
|
|
45312
45536
|
this.type = "invalid_request_error";
|
|
45313
45537
|
}
|
|
45314
|
-
static isInstance(
|
|
45315
|
-
return GatewayError.hasMarker(
|
|
45538
|
+
static isInstance(error82) {
|
|
45539
|
+
return GatewayError.hasMarker(error82) && symbol32 in error82;
|
|
45316
45540
|
}
|
|
45317
45541
|
};
|
|
45318
45542
|
var name32 = "GatewayRateLimitError";
|
|
@@ -45331,8 +45555,8 @@ var GatewayRateLimitError = class extends (_b4 = GatewayError, _a42 = symbol42,
|
|
|
45331
45555
|
this.name = name32;
|
|
45332
45556
|
this.type = "rate_limit_exceeded";
|
|
45333
45557
|
}
|
|
45334
|
-
static isInstance(
|
|
45335
|
-
return GatewayError.hasMarker(
|
|
45558
|
+
static isInstance(error82) {
|
|
45559
|
+
return GatewayError.hasMarker(error82) && symbol42 in error82;
|
|
45336
45560
|
}
|
|
45337
45561
|
};
|
|
45338
45562
|
var name42 = "GatewayModelNotFoundError";
|
|
@@ -45356,8 +45580,8 @@ var GatewayModelNotFoundError = class extends (_b5 = GatewayError, _a52 = symbol
|
|
|
45356
45580
|
this.type = "model_not_found";
|
|
45357
45581
|
this.modelId = modelId;
|
|
45358
45582
|
}
|
|
45359
|
-
static isInstance(
|
|
45360
|
-
return GatewayError.hasMarker(
|
|
45583
|
+
static isInstance(error82) {
|
|
45584
|
+
return GatewayError.hasMarker(error82) && symbol52 in error82;
|
|
45361
45585
|
}
|
|
45362
45586
|
};
|
|
45363
45587
|
var name52 = "GatewayInternalServerError";
|
|
@@ -45376,8 +45600,8 @@ var GatewayInternalServerError = class extends (_b6 = GatewayError, _a62 = symbo
|
|
|
45376
45600
|
this.name = name52;
|
|
45377
45601
|
this.type = "internal_server_error";
|
|
45378
45602
|
}
|
|
45379
|
-
static isInstance(
|
|
45380
|
-
return GatewayError.hasMarker(
|
|
45603
|
+
static isInstance(error82) {
|
|
45604
|
+
return GatewayError.hasMarker(error82) && symbol62 in error82;
|
|
45381
45605
|
}
|
|
45382
45606
|
};
|
|
45383
45607
|
var name62 = "GatewayResponseError";
|
|
@@ -45400,8 +45624,8 @@ var GatewayResponseError = class extends (_b7 = GatewayError, _a72 = symbol72, _
|
|
|
45400
45624
|
this.response = response;
|
|
45401
45625
|
this.validationError = validationError;
|
|
45402
45626
|
}
|
|
45403
|
-
static isInstance(
|
|
45404
|
-
return GatewayError.hasMarker(
|
|
45627
|
+
static isInstance(error82) {
|
|
45628
|
+
return GatewayError.hasMarker(error82) && symbol72 in error82;
|
|
45405
45629
|
}
|
|
45406
45630
|
};
|
|
45407
45631
|
function createGatewayErrorFromResponse({
|
|
@@ -45459,42 +45683,42 @@ var gatewayErrorResponseSchema = exports_external2.object({
|
|
|
45459
45683
|
code: exports_external2.union([exports_external2.string(), exports_external2.number()]).nullish()
|
|
45460
45684
|
})
|
|
45461
45685
|
});
|
|
45462
|
-
function asGatewayError(
|
|
45686
|
+
function asGatewayError(error82, authMethod) {
|
|
45463
45687
|
var _a82;
|
|
45464
|
-
if (GatewayError.isInstance(
|
|
45465
|
-
return
|
|
45688
|
+
if (GatewayError.isInstance(error82)) {
|
|
45689
|
+
return error82;
|
|
45466
45690
|
}
|
|
45467
|
-
if (APICallError.isInstance(
|
|
45691
|
+
if (APICallError.isInstance(error82)) {
|
|
45468
45692
|
return createGatewayErrorFromResponse({
|
|
45469
|
-
response: extractApiCallResponse(
|
|
45470
|
-
statusCode: (_a82 =
|
|
45693
|
+
response: extractApiCallResponse(error82),
|
|
45694
|
+
statusCode: (_a82 = error82.statusCode) != null ? _a82 : 500,
|
|
45471
45695
|
defaultMessage: "Gateway request failed",
|
|
45472
|
-
cause:
|
|
45696
|
+
cause: error82,
|
|
45473
45697
|
authMethod
|
|
45474
45698
|
});
|
|
45475
45699
|
}
|
|
45476
45700
|
return createGatewayErrorFromResponse({
|
|
45477
45701
|
response: {},
|
|
45478
45702
|
statusCode: 500,
|
|
45479
|
-
defaultMessage:
|
|
45480
|
-
cause:
|
|
45703
|
+
defaultMessage: error82 instanceof Error ? `Gateway request failed: ${error82.message}` : "Unknown Gateway error",
|
|
45704
|
+
cause: error82,
|
|
45481
45705
|
authMethod
|
|
45482
45706
|
});
|
|
45483
45707
|
}
|
|
45484
|
-
function extractApiCallResponse(
|
|
45485
|
-
if (
|
|
45486
|
-
return
|
|
45708
|
+
function extractApiCallResponse(error82) {
|
|
45709
|
+
if (error82.data !== undefined) {
|
|
45710
|
+
return error82.data;
|
|
45487
45711
|
}
|
|
45488
|
-
if (
|
|
45712
|
+
if (error82.responseBody != null) {
|
|
45489
45713
|
try {
|
|
45490
|
-
return JSON.parse(
|
|
45714
|
+
return JSON.parse(error82.responseBody);
|
|
45491
45715
|
} catch (e) {
|
|
45492
|
-
return
|
|
45716
|
+
return error82.responseBody;
|
|
45493
45717
|
}
|
|
45494
45718
|
}
|
|
45495
45719
|
return {};
|
|
45496
45720
|
}
|
|
45497
|
-
var GATEWAY_AUTH_METHOD_HEADER = "
|
|
45721
|
+
var GATEWAY_AUTH_METHOD_HEADER = "ai-gateway-auth-method";
|
|
45498
45722
|
function parseAuthMethod(headers) {
|
|
45499
45723
|
const result = gatewayAuthMethodSchema.safeParse(headers[GATEWAY_AUTH_METHOD_HEADER]);
|
|
45500
45724
|
return result.success ? result.data : undefined;
|
|
@@ -45520,8 +45744,8 @@ var GatewayFetchMetadata = class {
|
|
|
45520
45744
|
fetch: this.config.fetch
|
|
45521
45745
|
});
|
|
45522
45746
|
return value;
|
|
45523
|
-
} catch (
|
|
45524
|
-
throw asGatewayError(
|
|
45747
|
+
} catch (error82) {
|
|
45748
|
+
throw asGatewayError(error82);
|
|
45525
45749
|
}
|
|
45526
45750
|
}
|
|
45527
45751
|
};
|
|
@@ -45554,8 +45778,16 @@ var GatewayLanguageModel = class {
|
|
|
45554
45778
|
get provider() {
|
|
45555
45779
|
return this.config.provider;
|
|
45556
45780
|
}
|
|
45781
|
+
async getArgs(options) {
|
|
45782
|
+
const { abortSignal: _abortSignal, ...optionsWithoutSignal } = options;
|
|
45783
|
+
return {
|
|
45784
|
+
args: this.maybeEncodeFileParts(optionsWithoutSignal),
|
|
45785
|
+
warnings: []
|
|
45786
|
+
};
|
|
45787
|
+
}
|
|
45557
45788
|
async doGenerate(options) {
|
|
45558
|
-
const {
|
|
45789
|
+
const { args, warnings } = await this.getArgs(options);
|
|
45790
|
+
const { abortSignal } = options;
|
|
45559
45791
|
const resolvedHeaders = await resolve(this.config.headers());
|
|
45560
45792
|
try {
|
|
45561
45793
|
const {
|
|
@@ -45565,7 +45797,7 @@ var GatewayLanguageModel = class {
|
|
|
45565
45797
|
} = await postJsonToApi({
|
|
45566
45798
|
url: this.getUrl(),
|
|
45567
45799
|
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, false), await resolve(this.config.o11yHeaders)),
|
|
45568
|
-
body:
|
|
45800
|
+
body: args,
|
|
45569
45801
|
successfulResponseHandler: createJsonResponseHandler(exports_external2.any()),
|
|
45570
45802
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
45571
45803
|
errorSchema: exports_external2.any(),
|
|
@@ -45576,22 +45808,23 @@ var GatewayLanguageModel = class {
|
|
|
45576
45808
|
});
|
|
45577
45809
|
return {
|
|
45578
45810
|
...responseBody,
|
|
45579
|
-
request: { body },
|
|
45811
|
+
request: { body: args },
|
|
45580
45812
|
response: { headers: responseHeaders, body: rawResponse },
|
|
45581
|
-
warnings
|
|
45813
|
+
warnings
|
|
45582
45814
|
};
|
|
45583
|
-
} catch (
|
|
45584
|
-
throw asGatewayError(
|
|
45815
|
+
} catch (error82) {
|
|
45816
|
+
throw asGatewayError(error82, parseAuthMethod(resolvedHeaders));
|
|
45585
45817
|
}
|
|
45586
45818
|
}
|
|
45587
45819
|
async doStream(options) {
|
|
45588
|
-
const {
|
|
45820
|
+
const { args, warnings } = await this.getArgs(options);
|
|
45821
|
+
const { abortSignal } = options;
|
|
45589
45822
|
const resolvedHeaders = await resolve(this.config.headers());
|
|
45590
45823
|
try {
|
|
45591
45824
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
45592
45825
|
url: this.getUrl(),
|
|
45593
45826
|
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, true), await resolve(this.config.o11yHeaders)),
|
|
45594
|
-
body:
|
|
45827
|
+
body: args,
|
|
45595
45828
|
successfulResponseHandler: createEventSourceResponseHandler(exports_external2.any()),
|
|
45596
45829
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
45597
45830
|
errorSchema: exports_external2.any(),
|
|
@@ -45602,6 +45835,11 @@ var GatewayLanguageModel = class {
|
|
|
45602
45835
|
});
|
|
45603
45836
|
return {
|
|
45604
45837
|
stream: response.pipeThrough(new TransformStream({
|
|
45838
|
+
start(controller) {
|
|
45839
|
+
if (warnings.length > 0) {
|
|
45840
|
+
controller.enqueue({ type: "stream-start", warnings });
|
|
45841
|
+
}
|
|
45842
|
+
},
|
|
45605
45843
|
transform(chunk, controller) {
|
|
45606
45844
|
if (chunk.success) {
|
|
45607
45845
|
const streamPart = chunk.value;
|
|
@@ -45617,11 +45855,11 @@ var GatewayLanguageModel = class {
|
|
|
45617
45855
|
}
|
|
45618
45856
|
}
|
|
45619
45857
|
})),
|
|
45620
|
-
request: { body },
|
|
45858
|
+
request: { body: args },
|
|
45621
45859
|
response: { headers: responseHeaders }
|
|
45622
45860
|
};
|
|
45623
|
-
} catch (
|
|
45624
|
-
throw asGatewayError(
|
|
45861
|
+
} catch (error82) {
|
|
45862
|
+
throw asGatewayError(error82, parseAuthMethod(resolvedHeaders));
|
|
45625
45863
|
}
|
|
45626
45864
|
}
|
|
45627
45865
|
isFilePart(part) {
|
|
@@ -45653,6 +45891,70 @@ var GatewayLanguageModel = class {
|
|
|
45653
45891
|
};
|
|
45654
45892
|
}
|
|
45655
45893
|
};
|
|
45894
|
+
var GatewayEmbeddingModel = class {
|
|
45895
|
+
constructor(modelId, config3) {
|
|
45896
|
+
this.modelId = modelId;
|
|
45897
|
+
this.config = config3;
|
|
45898
|
+
this.specificationVersion = "v2";
|
|
45899
|
+
this.maxEmbeddingsPerCall = 2048;
|
|
45900
|
+
this.supportsParallelCalls = true;
|
|
45901
|
+
}
|
|
45902
|
+
get provider() {
|
|
45903
|
+
return this.config.provider;
|
|
45904
|
+
}
|
|
45905
|
+
async doEmbed({
|
|
45906
|
+
values,
|
|
45907
|
+
headers,
|
|
45908
|
+
abortSignal,
|
|
45909
|
+
providerOptions
|
|
45910
|
+
}) {
|
|
45911
|
+
var _a82;
|
|
45912
|
+
const resolvedHeaders = await resolve(this.config.headers());
|
|
45913
|
+
try {
|
|
45914
|
+
const {
|
|
45915
|
+
responseHeaders,
|
|
45916
|
+
value: responseBody,
|
|
45917
|
+
rawValue
|
|
45918
|
+
} = await postJsonToApi({
|
|
45919
|
+
url: this.getUrl(),
|
|
45920
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve(this.config.o11yHeaders)),
|
|
45921
|
+
body: {
|
|
45922
|
+
input: values.length === 1 ? values[0] : values,
|
|
45923
|
+
...providerOptions != null ? providerOptions : {}
|
|
45924
|
+
},
|
|
45925
|
+
successfulResponseHandler: createJsonResponseHandler(gatewayEmbeddingResponseSchema),
|
|
45926
|
+
failedResponseHandler: createJsonErrorResponseHandler({
|
|
45927
|
+
errorSchema: exports_external2.any(),
|
|
45928
|
+
errorToMessage: (data) => data
|
|
45929
|
+
}),
|
|
45930
|
+
...abortSignal && { abortSignal },
|
|
45931
|
+
fetch: this.config.fetch
|
|
45932
|
+
});
|
|
45933
|
+
return {
|
|
45934
|
+
embeddings: responseBody.embeddings,
|
|
45935
|
+
usage: (_a82 = responseBody.usage) != null ? _a82 : undefined,
|
|
45936
|
+
providerMetadata: responseBody.providerMetadata,
|
|
45937
|
+
response: { headers: responseHeaders, body: rawValue }
|
|
45938
|
+
};
|
|
45939
|
+
} catch (error82) {
|
|
45940
|
+
throw asGatewayError(error82, parseAuthMethod(resolvedHeaders));
|
|
45941
|
+
}
|
|
45942
|
+
}
|
|
45943
|
+
getUrl() {
|
|
45944
|
+
return `${this.config.baseURL}/embedding-model`;
|
|
45945
|
+
}
|
|
45946
|
+
getModelConfigHeaders() {
|
|
45947
|
+
return {
|
|
45948
|
+
"ai-embedding-model-specification-version": "2",
|
|
45949
|
+
"ai-model-id": this.modelId
|
|
45950
|
+
};
|
|
45951
|
+
}
|
|
45952
|
+
};
|
|
45953
|
+
var gatewayEmbeddingResponseSchema = exports_external2.object({
|
|
45954
|
+
embeddings: exports_external2.array(exports_external2.array(exports_external2.number())),
|
|
45955
|
+
usage: exports_external2.object({ tokens: exports_external2.number() }).nullish(),
|
|
45956
|
+
providerMetadata: exports_external2.record(exports_external2.string(), exports_external2.record(exports_external2.string(), exports_external2.unknown())).optional()
|
|
45957
|
+
});
|
|
45656
45958
|
async function getVercelOidcToken() {
|
|
45657
45959
|
var _a82, _b8;
|
|
45658
45960
|
const token = (_b8 = (_a82 = getContext().headers) == null ? undefined : _a82["x-vercel-oidc-token"]) != null ? _b8 : process.env.VERCEL_OIDC_TOKEN;
|
|
@@ -45698,7 +46000,7 @@ function createGatewayProvider(options = {}) {
|
|
|
45698
46000
|
statusCode: 401
|
|
45699
46001
|
});
|
|
45700
46002
|
};
|
|
45701
|
-
const
|
|
46003
|
+
const createO11yHeaders = () => {
|
|
45702
46004
|
const deploymentId = loadOptionalSetting({
|
|
45703
46005
|
settingValue: undefined,
|
|
45704
46006
|
environmentVariableName: "VERCEL_DEPLOYMENT_ID"
|
|
@@ -45711,20 +46013,23 @@ function createGatewayProvider(options = {}) {
|
|
|
45711
46013
|
settingValue: undefined,
|
|
45712
46014
|
environmentVariableName: "VERCEL_REGION"
|
|
45713
46015
|
});
|
|
46016
|
+
return async () => {
|
|
46017
|
+
const requestId = await getVercelRequestId();
|
|
46018
|
+
return {
|
|
46019
|
+
...deploymentId && { "ai-o11y-deployment-id": deploymentId },
|
|
46020
|
+
...environment && { "ai-o11y-environment": environment },
|
|
46021
|
+
...region && { "ai-o11y-region": region },
|
|
46022
|
+
...requestId && { "ai-o11y-request-id": requestId }
|
|
46023
|
+
};
|
|
46024
|
+
};
|
|
46025
|
+
};
|
|
46026
|
+
const createLanguageModel = (modelId) => {
|
|
45714
46027
|
return new GatewayLanguageModel(modelId, {
|
|
45715
46028
|
provider: "gateway",
|
|
45716
46029
|
baseURL,
|
|
45717
46030
|
headers: getHeaders,
|
|
45718
46031
|
fetch: options.fetch,
|
|
45719
|
-
o11yHeaders:
|
|
45720
|
-
const requestId = await getVercelRequestId();
|
|
45721
|
-
return {
|
|
45722
|
-
...deploymentId && { "ai-o11y-deployment-id": deploymentId },
|
|
45723
|
-
...environment && { "ai-o11y-environment": environment },
|
|
45724
|
-
...region && { "ai-o11y-region": region },
|
|
45725
|
-
...requestId && { "ai-o11y-request-id": requestId }
|
|
45726
|
-
};
|
|
45727
|
-
}
|
|
46032
|
+
o11yHeaders: createO11yHeaders()
|
|
45728
46033
|
});
|
|
45729
46034
|
};
|
|
45730
46035
|
const getAvailableModels = async () => {
|
|
@@ -45739,8 +46044,8 @@ function createGatewayProvider(options = {}) {
|
|
|
45739
46044
|
}).getAvailableModels().then((metadata) => {
|
|
45740
46045
|
metadataCache = metadata;
|
|
45741
46046
|
return metadata;
|
|
45742
|
-
}).catch(async (
|
|
45743
|
-
throw asGatewayError(
|
|
46047
|
+
}).catch(async (error82) => {
|
|
46048
|
+
throw asGatewayError(error82, parseAuthMethod(await getHeaders()));
|
|
45744
46049
|
});
|
|
45745
46050
|
}
|
|
45746
46051
|
return metadataCache ? Promise.resolve(metadataCache) : pendingMetadata;
|
|
@@ -45757,7 +46062,13 @@ function createGatewayProvider(options = {}) {
|
|
|
45757
46062
|
};
|
|
45758
46063
|
provider2.languageModel = createLanguageModel;
|
|
45759
46064
|
provider2.textEmbeddingModel = (modelId) => {
|
|
45760
|
-
|
|
46065
|
+
return new GatewayEmbeddingModel(modelId, {
|
|
46066
|
+
provider: "gateway",
|
|
46067
|
+
baseURL,
|
|
46068
|
+
headers: getHeaders,
|
|
46069
|
+
fetch: options.fetch,
|
|
46070
|
+
o11yHeaders: createO11yHeaders()
|
|
46071
|
+
});
|
|
45761
46072
|
};
|
|
45762
46073
|
return provider2;
|
|
45763
46074
|
}
|
|
@@ -45779,7 +46090,7 @@ async function getGatewayAuthToken(options) {
|
|
|
45779
46090
|
token: oidcToken,
|
|
45780
46091
|
authMethod: "oidc"
|
|
45781
46092
|
};
|
|
45782
|
-
} catch (
|
|
46093
|
+
} catch (e) {
|
|
45783
46094
|
return null;
|
|
45784
46095
|
}
|
|
45785
46096
|
}
|
|
@@ -45801,14 +46112,11 @@ var NoOutputSpecifiedError = class extends AISDKError {
|
|
|
45801
46112
|
super({ name: name16, message });
|
|
45802
46113
|
this[_a17] = true;
|
|
45803
46114
|
}
|
|
45804
|
-
static isInstance(
|
|
45805
|
-
return AISDKError.hasMarker(
|
|
46115
|
+
static isInstance(error82) {
|
|
46116
|
+
return AISDKError.hasMarker(error82, marker17);
|
|
45806
46117
|
}
|
|
45807
46118
|
};
|
|
45808
46119
|
_a17 = symbol18;
|
|
45809
|
-
function asArray(value) {
|
|
45810
|
-
return value === undefined ? [] : Array.isArray(value) ? value : [value];
|
|
45811
|
-
}
|
|
45812
46120
|
var name23 = "AI_InvalidArgumentError";
|
|
45813
46121
|
var marker23 = `vercel.ai.error.${name23}`;
|
|
45814
46122
|
var symbol24 = Symbol.for(marker23);
|
|
@@ -45827,132 +46135,210 @@ var InvalidArgumentError2 = class extends AISDKError {
|
|
|
45827
46135
|
this.parameter = parameter;
|
|
45828
46136
|
this.value = value;
|
|
45829
46137
|
}
|
|
45830
|
-
static isInstance(
|
|
45831
|
-
return AISDKError.hasMarker(
|
|
46138
|
+
static isInstance(error82) {
|
|
46139
|
+
return AISDKError.hasMarker(error82, marker23);
|
|
45832
46140
|
}
|
|
45833
46141
|
};
|
|
45834
46142
|
_a23 = symbol24;
|
|
45835
|
-
var name33 = "
|
|
46143
|
+
var name33 = "AI_InvalidStreamPartError";
|
|
45836
46144
|
var marker33 = `vercel.ai.error.${name33}`;
|
|
45837
46145
|
var symbol33 = Symbol.for(marker33);
|
|
45838
46146
|
var _a33;
|
|
46147
|
+
_a33 = symbol33;
|
|
46148
|
+
var name43 = "AI_InvalidToolInputError";
|
|
46149
|
+
var marker43 = `vercel.ai.error.${name43}`;
|
|
46150
|
+
var symbol43 = Symbol.for(marker43);
|
|
46151
|
+
var _a43;
|
|
46152
|
+
var InvalidToolInputError = class extends AISDKError {
|
|
46153
|
+
constructor({
|
|
46154
|
+
toolInput,
|
|
46155
|
+
toolName,
|
|
46156
|
+
cause,
|
|
46157
|
+
message = `Invalid input for tool ${toolName}: ${getErrorMessage(cause)}`
|
|
46158
|
+
}) {
|
|
46159
|
+
super({ name: name43, message, cause });
|
|
46160
|
+
this[_a43] = true;
|
|
46161
|
+
this.toolInput = toolInput;
|
|
46162
|
+
this.toolName = toolName;
|
|
46163
|
+
}
|
|
46164
|
+
static isInstance(error82) {
|
|
46165
|
+
return AISDKError.hasMarker(error82, marker43);
|
|
46166
|
+
}
|
|
46167
|
+
};
|
|
46168
|
+
_a43 = symbol43;
|
|
46169
|
+
var name53 = "AI_MCPClientError";
|
|
46170
|
+
var marker53 = `vercel.ai.error.${name53}`;
|
|
46171
|
+
var symbol53 = Symbol.for(marker53);
|
|
46172
|
+
var _a53;
|
|
46173
|
+
_a53 = symbol53;
|
|
46174
|
+
var name63 = "AI_NoImageGeneratedError";
|
|
46175
|
+
var marker63 = `vercel.ai.error.${name63}`;
|
|
46176
|
+
var symbol63 = Symbol.for(marker63);
|
|
46177
|
+
var _a63;
|
|
46178
|
+
_a63 = symbol63;
|
|
46179
|
+
var name72 = "AI_NoObjectGeneratedError";
|
|
46180
|
+
var marker73 = `vercel.ai.error.${name72}`;
|
|
46181
|
+
var symbol73 = Symbol.for(marker73);
|
|
46182
|
+
var _a73;
|
|
46183
|
+
var NoObjectGeneratedError = class extends AISDKError {
|
|
46184
|
+
constructor({
|
|
46185
|
+
message = "No object generated.",
|
|
46186
|
+
cause,
|
|
46187
|
+
text: text2,
|
|
46188
|
+
response,
|
|
46189
|
+
usage,
|
|
46190
|
+
finishReason
|
|
46191
|
+
}) {
|
|
46192
|
+
super({ name: name72, message, cause });
|
|
46193
|
+
this[_a73] = true;
|
|
46194
|
+
this.text = text2;
|
|
46195
|
+
this.response = response;
|
|
46196
|
+
this.usage = usage;
|
|
46197
|
+
this.finishReason = finishReason;
|
|
46198
|
+
}
|
|
46199
|
+
static isInstance(error82) {
|
|
46200
|
+
return AISDKError.hasMarker(error82, marker73);
|
|
46201
|
+
}
|
|
46202
|
+
};
|
|
46203
|
+
_a73 = symbol73;
|
|
46204
|
+
var name82 = "AI_NoSuchToolError";
|
|
46205
|
+
var marker82 = `vercel.ai.error.${name82}`;
|
|
46206
|
+
var symbol82 = Symbol.for(marker82);
|
|
46207
|
+
var _a82;
|
|
46208
|
+
var NoSuchToolError = class extends AISDKError {
|
|
46209
|
+
constructor({
|
|
46210
|
+
toolName,
|
|
46211
|
+
availableTools = undefined,
|
|
46212
|
+
message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === undefined ? "No tools are available." : `Available tools: ${availableTools.join(", ")}.`}`
|
|
46213
|
+
}) {
|
|
46214
|
+
super({ name: name82, message });
|
|
46215
|
+
this[_a82] = true;
|
|
46216
|
+
this.toolName = toolName;
|
|
46217
|
+
this.availableTools = availableTools;
|
|
46218
|
+
}
|
|
46219
|
+
static isInstance(error82) {
|
|
46220
|
+
return AISDKError.hasMarker(error82, marker82);
|
|
46221
|
+
}
|
|
46222
|
+
};
|
|
46223
|
+
_a82 = symbol82;
|
|
46224
|
+
var name92 = "AI_ToolCallRepairError";
|
|
46225
|
+
var marker92 = `vercel.ai.error.${name92}`;
|
|
46226
|
+
var symbol92 = Symbol.for(marker92);
|
|
46227
|
+
var _a92;
|
|
46228
|
+
var ToolCallRepairError = class extends AISDKError {
|
|
46229
|
+
constructor({
|
|
46230
|
+
cause,
|
|
46231
|
+
originalError,
|
|
46232
|
+
message = `Error repairing tool call: ${getErrorMessage(cause)}`
|
|
46233
|
+
}) {
|
|
46234
|
+
super({ name: name92, message, cause });
|
|
46235
|
+
this[_a92] = true;
|
|
46236
|
+
this.originalError = originalError;
|
|
46237
|
+
}
|
|
46238
|
+
static isInstance(error82) {
|
|
46239
|
+
return AISDKError.hasMarker(error82, marker92);
|
|
46240
|
+
}
|
|
46241
|
+
};
|
|
46242
|
+
_a92 = symbol92;
|
|
46243
|
+
var UnsupportedModelVersionError = class extends AISDKError {
|
|
46244
|
+
constructor(options) {
|
|
46245
|
+
super({
|
|
46246
|
+
name: "AI_UnsupportedModelVersionError",
|
|
46247
|
+
message: `Unsupported model version ${options.version} for provider "${options.provider}" and model "${options.modelId}". AI SDK 5 only supports models that implement specification version "v2".`
|
|
46248
|
+
});
|
|
46249
|
+
this.version = options.version;
|
|
46250
|
+
this.provider = options.provider;
|
|
46251
|
+
this.modelId = options.modelId;
|
|
46252
|
+
}
|
|
46253
|
+
};
|
|
46254
|
+
var name102 = "AI_InvalidDataContentError";
|
|
46255
|
+
var marker102 = `vercel.ai.error.${name102}`;
|
|
46256
|
+
var symbol102 = Symbol.for(marker102);
|
|
46257
|
+
var _a102;
|
|
46258
|
+
_a102 = symbol102;
|
|
46259
|
+
var name112 = "AI_InvalidMessageRoleError";
|
|
46260
|
+
var marker112 = `vercel.ai.error.${name112}`;
|
|
46261
|
+
var symbol112 = Symbol.for(marker112);
|
|
46262
|
+
var _a112;
|
|
46263
|
+
var InvalidMessageRoleError = class extends AISDKError {
|
|
46264
|
+
constructor({
|
|
46265
|
+
role,
|
|
46266
|
+
message = `Invalid message role: '${role}'. Must be one of: "system", "user", "assistant", "tool".`
|
|
46267
|
+
}) {
|
|
46268
|
+
super({ name: name112, message });
|
|
46269
|
+
this[_a112] = true;
|
|
46270
|
+
this.role = role;
|
|
46271
|
+
}
|
|
46272
|
+
static isInstance(error82) {
|
|
46273
|
+
return AISDKError.hasMarker(error82, marker112);
|
|
46274
|
+
}
|
|
46275
|
+
};
|
|
46276
|
+
_a112 = symbol112;
|
|
46277
|
+
var name122 = "AI_MessageConversionError";
|
|
46278
|
+
var marker122 = `vercel.ai.error.${name122}`;
|
|
46279
|
+
var symbol122 = Symbol.for(marker122);
|
|
46280
|
+
var _a122;
|
|
46281
|
+
_a122 = symbol122;
|
|
46282
|
+
var name132 = "AI_DownloadError";
|
|
46283
|
+
var marker132 = `vercel.ai.error.${name132}`;
|
|
46284
|
+
var symbol132 = Symbol.for(marker132);
|
|
46285
|
+
var _a132;
|
|
46286
|
+
var DownloadError = class extends AISDKError {
|
|
46287
|
+
constructor({
|
|
46288
|
+
url: url3,
|
|
46289
|
+
statusCode,
|
|
46290
|
+
statusText,
|
|
46291
|
+
cause,
|
|
46292
|
+
message = cause == null ? `Failed to download ${url3}: ${statusCode} ${statusText}` : `Failed to download ${url3}: ${cause}`
|
|
46293
|
+
}) {
|
|
46294
|
+
super({ name: name132, message, cause });
|
|
46295
|
+
this[_a132] = true;
|
|
46296
|
+
this.url = url3;
|
|
46297
|
+
this.statusCode = statusCode;
|
|
46298
|
+
this.statusText = statusText;
|
|
46299
|
+
}
|
|
46300
|
+
static isInstance(error82) {
|
|
46301
|
+
return AISDKError.hasMarker(error82, marker132);
|
|
46302
|
+
}
|
|
46303
|
+
};
|
|
46304
|
+
_a132 = symbol132;
|
|
46305
|
+
var name142 = "AI_RetryError";
|
|
46306
|
+
var marker142 = `vercel.ai.error.${name142}`;
|
|
46307
|
+
var symbol142 = Symbol.for(marker142);
|
|
46308
|
+
var _a142;
|
|
45839
46309
|
var RetryError = class extends AISDKError {
|
|
45840
46310
|
constructor({
|
|
45841
46311
|
message,
|
|
45842
46312
|
reason,
|
|
45843
46313
|
errors: errors5
|
|
45844
46314
|
}) {
|
|
45845
|
-
super({ name:
|
|
45846
|
-
this[
|
|
46315
|
+
super({ name: name142, message });
|
|
46316
|
+
this[_a142] = true;
|
|
45847
46317
|
this.reason = reason;
|
|
45848
46318
|
this.errors = errors5;
|
|
45849
46319
|
this.lastError = errors5[errors5.length - 1];
|
|
45850
46320
|
}
|
|
45851
|
-
static isInstance(
|
|
45852
|
-
return AISDKError.hasMarker(
|
|
46321
|
+
static isInstance(error82) {
|
|
46322
|
+
return AISDKError.hasMarker(error82, marker142);
|
|
45853
46323
|
}
|
|
45854
46324
|
};
|
|
45855
|
-
|
|
45856
|
-
function
|
|
45857
|
-
|
|
45858
|
-
|
|
45859
|
-
|
|
45860
|
-
|
|
45861
|
-
|
|
45862
|
-
|
|
45863
|
-
const timeoutMs = parseFloat(retryAfterMs);
|
|
45864
|
-
if (!Number.isNaN(timeoutMs)) {
|
|
45865
|
-
timeoutMillis = timeoutMs;
|
|
45866
|
-
}
|
|
45867
|
-
}
|
|
45868
|
-
const retryAfter = headers["retry-after"];
|
|
45869
|
-
if (retryAfter && timeoutMillis === undefined) {
|
|
45870
|
-
const timeoutSeconds = parseFloat(retryAfter);
|
|
45871
|
-
if (!Number.isNaN(timeoutSeconds)) {
|
|
45872
|
-
timeoutMillis = timeoutSeconds * 1000;
|
|
45873
|
-
} else {
|
|
45874
|
-
timeoutMillis = Date.parse(retryAfter) - Date.now();
|
|
45875
|
-
}
|
|
45876
|
-
}
|
|
45877
|
-
if (timeoutMillis !== undefined && 0 <= timeoutMillis && timeoutMillis < 60 * 1000) {
|
|
45878
|
-
return timeoutMillis;
|
|
45879
|
-
}
|
|
45880
|
-
return exponentialBackoffDelay;
|
|
45881
|
-
}
|
|
45882
|
-
var retryWithExponentialBackoffRespectingRetryHeaders = ({
|
|
45883
|
-
maxRetries = 2,
|
|
45884
|
-
initialDelayInMs = 2000,
|
|
45885
|
-
backoffFactor = 2
|
|
45886
|
-
} = {}) => async (f) => _retryWithExponentialBackoff(f, {
|
|
45887
|
-
maxRetries,
|
|
45888
|
-
delayInMs: initialDelayInMs,
|
|
45889
|
-
backoffFactor
|
|
45890
|
-
});
|
|
45891
|
-
async function _retryWithExponentialBackoff(f, {
|
|
45892
|
-
maxRetries,
|
|
45893
|
-
delayInMs,
|
|
45894
|
-
backoffFactor
|
|
45895
|
-
}, errors5 = []) {
|
|
45896
|
-
try {
|
|
45897
|
-
return await f();
|
|
45898
|
-
} catch (error81) {
|
|
45899
|
-
if (isAbortError(error81)) {
|
|
45900
|
-
throw error81;
|
|
45901
|
-
}
|
|
45902
|
-
if (maxRetries === 0) {
|
|
45903
|
-
throw error81;
|
|
45904
|
-
}
|
|
45905
|
-
const errorMessage = getErrorMessage2(error81);
|
|
45906
|
-
const newErrors = [...errors5, error81];
|
|
45907
|
-
const tryNumber = newErrors.length;
|
|
45908
|
-
if (tryNumber > maxRetries) {
|
|
45909
|
-
throw new RetryError({
|
|
45910
|
-
message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
|
|
45911
|
-
reason: "maxRetriesExceeded",
|
|
45912
|
-
errors: newErrors
|
|
46325
|
+
_a142 = symbol142;
|
|
46326
|
+
function resolveLanguageModel(model) {
|
|
46327
|
+
if (typeof model !== "string") {
|
|
46328
|
+
if (model.specificationVersion !== "v2") {
|
|
46329
|
+
throw new UnsupportedModelVersionError({
|
|
46330
|
+
version: model.specificationVersion,
|
|
46331
|
+
provider: model.provider,
|
|
46332
|
+
modelId: model.modelId
|
|
45913
46333
|
});
|
|
45914
46334
|
}
|
|
45915
|
-
|
|
45916
|
-
const actualDelay = getRetryDelay(error81, delayInMs);
|
|
45917
|
-
await delay(actualDelay);
|
|
45918
|
-
return _retryWithExponentialBackoff(f, { maxRetries, delayInMs: backoffFactor * delayInMs, backoffFactor }, newErrors);
|
|
45919
|
-
}
|
|
45920
|
-
if (tryNumber === 1) {
|
|
45921
|
-
throw error81;
|
|
45922
|
-
}
|
|
45923
|
-
throw new RetryError({
|
|
45924
|
-
message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
|
|
45925
|
-
reason: "errorNotRetryable",
|
|
45926
|
-
errors: newErrors
|
|
45927
|
-
});
|
|
46335
|
+
return model;
|
|
45928
46336
|
}
|
|
46337
|
+
return getGlobalProvider().languageModel(model);
|
|
45929
46338
|
}
|
|
45930
|
-
function
|
|
45931
|
-
|
|
45932
|
-
|
|
45933
|
-
if (maxRetries != null) {
|
|
45934
|
-
if (!Number.isInteger(maxRetries)) {
|
|
45935
|
-
throw new InvalidArgumentError2({
|
|
45936
|
-
parameter: "maxRetries",
|
|
45937
|
-
value: maxRetries,
|
|
45938
|
-
message: "maxRetries must be an integer"
|
|
45939
|
-
});
|
|
45940
|
-
}
|
|
45941
|
-
if (maxRetries < 0) {
|
|
45942
|
-
throw new InvalidArgumentError2({
|
|
45943
|
-
parameter: "maxRetries",
|
|
45944
|
-
value: maxRetries,
|
|
45945
|
-
message: "maxRetries must be >= 0"
|
|
45946
|
-
});
|
|
45947
|
-
}
|
|
45948
|
-
}
|
|
45949
|
-
const maxRetriesResult = maxRetries != null ? maxRetries : 2;
|
|
45950
|
-
return {
|
|
45951
|
-
maxRetries: maxRetriesResult,
|
|
45952
|
-
retry: retryWithExponentialBackoffRespectingRetryHeaders({
|
|
45953
|
-
maxRetries: maxRetriesResult
|
|
45954
|
-
})
|
|
45955
|
-
};
|
|
46339
|
+
function getGlobalProvider() {
|
|
46340
|
+
var _a16;
|
|
46341
|
+
return (_a16 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a16 : gateway;
|
|
45956
46342
|
}
|
|
45957
46343
|
var imageMediaTypeSignatures = [
|
|
45958
46344
|
{
|
|
@@ -46048,29 +46434,6 @@ function detectMediaType({
|
|
|
46048
46434
|
}
|
|
46049
46435
|
return;
|
|
46050
46436
|
}
|
|
46051
|
-
var name43 = "AI_DownloadError";
|
|
46052
|
-
var marker43 = `vercel.ai.error.${name43}`;
|
|
46053
|
-
var symbol43 = Symbol.for(marker43);
|
|
46054
|
-
var _a43;
|
|
46055
|
-
var DownloadError = class extends AISDKError {
|
|
46056
|
-
constructor({
|
|
46057
|
-
url: url3,
|
|
46058
|
-
statusCode,
|
|
46059
|
-
statusText,
|
|
46060
|
-
cause,
|
|
46061
|
-
message = cause == null ? `Failed to download ${url3}: ${statusCode} ${statusText}` : `Failed to download ${url3}: ${cause}`
|
|
46062
|
-
}) {
|
|
46063
|
-
super({ name: name43, message, cause });
|
|
46064
|
-
this[_a43] = true;
|
|
46065
|
-
this.url = url3;
|
|
46066
|
-
this.statusCode = statusCode;
|
|
46067
|
-
this.statusText = statusText;
|
|
46068
|
-
}
|
|
46069
|
-
static isInstance(error81) {
|
|
46070
|
-
return AISDKError.hasMarker(error81, marker43);
|
|
46071
|
-
}
|
|
46072
|
-
};
|
|
46073
|
-
_a43 = symbol43;
|
|
46074
46437
|
async function download({ url: url3 }) {
|
|
46075
46438
|
var _a16;
|
|
46076
46439
|
const urlText = url3.toString();
|
|
@@ -46087,18 +46450,13 @@ async function download({ url: url3 }) {
|
|
|
46087
46450
|
data: new Uint8Array(await response.arrayBuffer()),
|
|
46088
46451
|
mediaType: (_a16 = response.headers.get("content-type")) != null ? _a16 : undefined
|
|
46089
46452
|
};
|
|
46090
|
-
} catch (
|
|
46091
|
-
if (DownloadError.isInstance(
|
|
46092
|
-
throw
|
|
46453
|
+
} catch (error82) {
|
|
46454
|
+
if (DownloadError.isInstance(error82)) {
|
|
46455
|
+
throw error82;
|
|
46093
46456
|
}
|
|
46094
|
-
throw new DownloadError({ url: urlText, cause:
|
|
46457
|
+
throw new DownloadError({ url: urlText, cause: error82 });
|
|
46095
46458
|
}
|
|
46096
46459
|
}
|
|
46097
|
-
var name53 = "AI_InvalidDataContentError";
|
|
46098
|
-
var marker53 = `vercel.ai.error.${name53}`;
|
|
46099
|
-
var symbol53 = Symbol.for(marker53);
|
|
46100
|
-
var _a53;
|
|
46101
|
-
_a53 = symbol53;
|
|
46102
46460
|
function splitDataUrl(dataUrl) {
|
|
46103
46461
|
try {
|
|
46104
46462
|
const [header, base64Content] = dataUrl.split(",");
|
|
@@ -46106,7 +46464,7 @@ function splitDataUrl(dataUrl) {
|
|
|
46106
46464
|
mediaType: header.split(";")[0].split(":")[1],
|
|
46107
46465
|
base64Content
|
|
46108
46466
|
};
|
|
46109
|
-
} catch (
|
|
46467
|
+
} catch (error82) {
|
|
46110
46468
|
return {
|
|
46111
46469
|
mediaType: undefined,
|
|
46112
46470
|
base64Content: undefined
|
|
@@ -46132,7 +46490,7 @@ function convertToLanguageModelV2DataContent(content) {
|
|
|
46132
46490
|
if (typeof content === "string") {
|
|
46133
46491
|
try {
|
|
46134
46492
|
content = new URL(content);
|
|
46135
|
-
} catch (
|
|
46493
|
+
} catch (error82) {}
|
|
46136
46494
|
}
|
|
46137
46495
|
if (content instanceof URL && content.protocol === "data:") {
|
|
46138
46496
|
const { mediaType: dataUrlMediaType, base64Content } = splitDataUrl(content.toString());
|
|
@@ -46155,24 +46513,6 @@ function convertDataContentToBase64String(content) {
|
|
|
46155
46513
|
}
|
|
46156
46514
|
return convertUint8ArrayToBase64(content);
|
|
46157
46515
|
}
|
|
46158
|
-
var name63 = "AI_InvalidMessageRoleError";
|
|
46159
|
-
var marker63 = `vercel.ai.error.${name63}`;
|
|
46160
|
-
var symbol63 = Symbol.for(marker63);
|
|
46161
|
-
var _a63;
|
|
46162
|
-
var InvalidMessageRoleError = class extends AISDKError {
|
|
46163
|
-
constructor({
|
|
46164
|
-
role,
|
|
46165
|
-
message = `Invalid message role: '${role}'. Must be one of: "system", "user", "assistant", "tool".`
|
|
46166
|
-
}) {
|
|
46167
|
-
super({ name: name63, message });
|
|
46168
|
-
this[_a63] = true;
|
|
46169
|
-
this.role = role;
|
|
46170
|
-
}
|
|
46171
|
-
static isInstance(error81) {
|
|
46172
|
-
return AISDKError.hasMarker(error81, marker63);
|
|
46173
|
-
}
|
|
46174
|
-
};
|
|
46175
|
-
_a63 = symbol63;
|
|
46176
46516
|
async function convertToLanguageModelPrompt({
|
|
46177
46517
|
prompt,
|
|
46178
46518
|
supportedUrls,
|
|
@@ -46482,12 +46822,14 @@ function prepareToolsAndToolChoice({
|
|
|
46482
46822
|
const toolType = tool3.type;
|
|
46483
46823
|
switch (toolType) {
|
|
46484
46824
|
case undefined:
|
|
46825
|
+
case "dynamic":
|
|
46485
46826
|
case "function":
|
|
46486
46827
|
return {
|
|
46487
46828
|
type: "function",
|
|
46488
46829
|
name: name162,
|
|
46489
46830
|
description: tool3.description,
|
|
46490
|
-
inputSchema: asSchema(tool3.inputSchema).jsonSchema
|
|
46831
|
+
inputSchema: asSchema(tool3.inputSchema).jsonSchema,
|
|
46832
|
+
providerOptions: tool3.providerOptions
|
|
46491
46833
|
};
|
|
46492
46834
|
case "provider-defined":
|
|
46493
46835
|
return {
|
|
@@ -46505,136 +46847,6 @@ function prepareToolsAndToolChoice({
|
|
|
46505
46847
|
toolChoice: toolChoice == null ? { type: "auto" } : typeof toolChoice === "string" ? { type: toolChoice } : { type: "tool", toolName: toolChoice.toolName }
|
|
46506
46848
|
};
|
|
46507
46849
|
}
|
|
46508
|
-
var name72 = "AI_InvalidStreamPartError";
|
|
46509
|
-
var marker73 = `vercel.ai.error.${name72}`;
|
|
46510
|
-
var symbol73 = Symbol.for(marker73);
|
|
46511
|
-
var _a73;
|
|
46512
|
-
_a73 = symbol73;
|
|
46513
|
-
var name82 = "AI_InvalidToolInputError";
|
|
46514
|
-
var marker82 = `vercel.ai.error.${name82}`;
|
|
46515
|
-
var symbol82 = Symbol.for(marker82);
|
|
46516
|
-
var _a82;
|
|
46517
|
-
var InvalidToolInputError = class extends AISDKError {
|
|
46518
|
-
constructor({
|
|
46519
|
-
toolInput,
|
|
46520
|
-
toolName,
|
|
46521
|
-
cause,
|
|
46522
|
-
message = `Invalid input for tool ${toolName}: ${getErrorMessage(cause)}`
|
|
46523
|
-
}) {
|
|
46524
|
-
super({ name: name82, message, cause });
|
|
46525
|
-
this[_a82] = true;
|
|
46526
|
-
this.toolInput = toolInput;
|
|
46527
|
-
this.toolName = toolName;
|
|
46528
|
-
}
|
|
46529
|
-
static isInstance(error81) {
|
|
46530
|
-
return AISDKError.hasMarker(error81, marker82);
|
|
46531
|
-
}
|
|
46532
|
-
};
|
|
46533
|
-
_a82 = symbol82;
|
|
46534
|
-
var name92 = "AI_MCPClientError";
|
|
46535
|
-
var marker92 = `vercel.ai.error.${name92}`;
|
|
46536
|
-
var symbol92 = Symbol.for(marker92);
|
|
46537
|
-
var _a92;
|
|
46538
|
-
_a92 = symbol92;
|
|
46539
|
-
var name102 = "AI_NoImageGeneratedError";
|
|
46540
|
-
var marker102 = `vercel.ai.error.${name102}`;
|
|
46541
|
-
var symbol102 = Symbol.for(marker102);
|
|
46542
|
-
var _a102;
|
|
46543
|
-
_a102 = symbol102;
|
|
46544
|
-
var name112 = "AI_NoObjectGeneratedError";
|
|
46545
|
-
var marker112 = `vercel.ai.error.${name112}`;
|
|
46546
|
-
var symbol112 = Symbol.for(marker112);
|
|
46547
|
-
var _a112;
|
|
46548
|
-
var NoObjectGeneratedError = class extends AISDKError {
|
|
46549
|
-
constructor({
|
|
46550
|
-
message = "No object generated.",
|
|
46551
|
-
cause,
|
|
46552
|
-
text: text2,
|
|
46553
|
-
response,
|
|
46554
|
-
usage,
|
|
46555
|
-
finishReason
|
|
46556
|
-
}) {
|
|
46557
|
-
super({ name: name112, message, cause });
|
|
46558
|
-
this[_a112] = true;
|
|
46559
|
-
this.text = text2;
|
|
46560
|
-
this.response = response;
|
|
46561
|
-
this.usage = usage;
|
|
46562
|
-
this.finishReason = finishReason;
|
|
46563
|
-
}
|
|
46564
|
-
static isInstance(error81) {
|
|
46565
|
-
return AISDKError.hasMarker(error81, marker112);
|
|
46566
|
-
}
|
|
46567
|
-
};
|
|
46568
|
-
_a112 = symbol112;
|
|
46569
|
-
var name122 = "AI_NoSuchToolError";
|
|
46570
|
-
var marker122 = `vercel.ai.error.${name122}`;
|
|
46571
|
-
var symbol122 = Symbol.for(marker122);
|
|
46572
|
-
var _a122;
|
|
46573
|
-
var NoSuchToolError = class extends AISDKError {
|
|
46574
|
-
constructor({
|
|
46575
|
-
toolName,
|
|
46576
|
-
availableTools = undefined,
|
|
46577
|
-
message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === undefined ? "No tools are available." : `Available tools: ${availableTools.join(", ")}.`}`
|
|
46578
|
-
}) {
|
|
46579
|
-
super({ name: name122, message });
|
|
46580
|
-
this[_a122] = true;
|
|
46581
|
-
this.toolName = toolName;
|
|
46582
|
-
this.availableTools = availableTools;
|
|
46583
|
-
}
|
|
46584
|
-
static isInstance(error81) {
|
|
46585
|
-
return AISDKError.hasMarker(error81, marker122);
|
|
46586
|
-
}
|
|
46587
|
-
};
|
|
46588
|
-
_a122 = symbol122;
|
|
46589
|
-
var name132 = "AI_ToolCallRepairError";
|
|
46590
|
-
var marker132 = `vercel.ai.error.${name132}`;
|
|
46591
|
-
var symbol132 = Symbol.for(marker132);
|
|
46592
|
-
var _a132;
|
|
46593
|
-
var ToolCallRepairError = class extends AISDKError {
|
|
46594
|
-
constructor({
|
|
46595
|
-
cause,
|
|
46596
|
-
originalError,
|
|
46597
|
-
message = `Error repairing tool call: ${getErrorMessage(cause)}`
|
|
46598
|
-
}) {
|
|
46599
|
-
super({ name: name132, message, cause });
|
|
46600
|
-
this[_a132] = true;
|
|
46601
|
-
this.originalError = originalError;
|
|
46602
|
-
}
|
|
46603
|
-
static isInstance(error81) {
|
|
46604
|
-
return AISDKError.hasMarker(error81, marker132);
|
|
46605
|
-
}
|
|
46606
|
-
};
|
|
46607
|
-
_a132 = symbol132;
|
|
46608
|
-
var UnsupportedModelVersionError = class extends AISDKError {
|
|
46609
|
-
constructor(options) {
|
|
46610
|
-
super({
|
|
46611
|
-
name: "AI_UnsupportedModelVersionError",
|
|
46612
|
-
message: `Unsupported model version ${options.version} for provider "${options.provider}" and model "${options.modelId}". AI SDK 5 only supports models that implement specification version "v2".`
|
|
46613
|
-
});
|
|
46614
|
-
this.version = options.version;
|
|
46615
|
-
this.provider = options.provider;
|
|
46616
|
-
this.modelId = options.modelId;
|
|
46617
|
-
}
|
|
46618
|
-
};
|
|
46619
|
-
var name142 = "AI_MessageConversionError";
|
|
46620
|
-
var marker142 = `vercel.ai.error.${name142}`;
|
|
46621
|
-
var symbol142 = Symbol.for(marker142);
|
|
46622
|
-
var _a142;
|
|
46623
|
-
_a142 = symbol142;
|
|
46624
|
-
function resolveLanguageModel(model) {
|
|
46625
|
-
if (typeof model !== "string") {
|
|
46626
|
-
if (model.specificationVersion !== "v2") {
|
|
46627
|
-
throw new UnsupportedModelVersionError({
|
|
46628
|
-
version: model.specificationVersion,
|
|
46629
|
-
provider: model.provider,
|
|
46630
|
-
modelId: model.modelId
|
|
46631
|
-
});
|
|
46632
|
-
}
|
|
46633
|
-
return model;
|
|
46634
|
-
}
|
|
46635
|
-
const globalProvider = globalThis.AI_SDK_DEFAULT_PROVIDER;
|
|
46636
|
-
return (globalProvider != null ? globalProvider : gateway).languageModel(model);
|
|
46637
|
-
}
|
|
46638
46850
|
var jsonValueSchema = exports_external2.lazy(() => exports_external2.union([
|
|
46639
46851
|
exports_external2.null(),
|
|
46640
46852
|
exports_external2.string(),
|
|
@@ -46806,15 +47018,15 @@ async function standardizePrompt(prompt) {
|
|
|
46806
47018
|
system: prompt.system
|
|
46807
47019
|
};
|
|
46808
47020
|
}
|
|
46809
|
-
function wrapGatewayError(
|
|
46810
|
-
if (GatewayAuthenticationError.isInstance(
|
|
47021
|
+
function wrapGatewayError(error82) {
|
|
47022
|
+
if (GatewayAuthenticationError.isInstance(error82) || GatewayModelNotFoundError.isInstance(error82)) {
|
|
46811
47023
|
return new AISDKError({
|
|
46812
47024
|
name: "GatewayError",
|
|
46813
47025
|
message: "Vercel AI Gateway access failed. If you want to use AI SDK providers directly, use the providers, e.g. @ai-sdk/openai, or register a different global default provider.",
|
|
46814
|
-
cause:
|
|
47026
|
+
cause: error82
|
|
46815
47027
|
});
|
|
46816
47028
|
}
|
|
46817
|
-
return
|
|
47029
|
+
return error82;
|
|
46818
47030
|
}
|
|
46819
47031
|
function assembleOperationName({
|
|
46820
47032
|
operationId,
|
|
@@ -46935,26 +47147,26 @@ function recordSpan({
|
|
|
46935
47147
|
span.end();
|
|
46936
47148
|
}
|
|
46937
47149
|
return result;
|
|
46938
|
-
} catch (
|
|
47150
|
+
} catch (error82) {
|
|
46939
47151
|
try {
|
|
46940
|
-
recordErrorOnSpan(span,
|
|
47152
|
+
recordErrorOnSpan(span, error82);
|
|
46941
47153
|
} finally {
|
|
46942
47154
|
span.end();
|
|
46943
47155
|
}
|
|
46944
|
-
throw
|
|
47156
|
+
throw error82;
|
|
46945
47157
|
}
|
|
46946
47158
|
});
|
|
46947
47159
|
}
|
|
46948
|
-
function recordErrorOnSpan(span,
|
|
46949
|
-
if (
|
|
47160
|
+
function recordErrorOnSpan(span, error82) {
|
|
47161
|
+
if (error82 instanceof Error) {
|
|
46950
47162
|
span.recordException({
|
|
46951
|
-
name:
|
|
46952
|
-
message:
|
|
46953
|
-
stack:
|
|
47163
|
+
name: error82.name,
|
|
47164
|
+
message: error82.message,
|
|
47165
|
+
stack: error82.stack
|
|
46954
47166
|
});
|
|
46955
47167
|
span.setStatus({
|
|
46956
47168
|
code: import_api4.SpanStatusCode.ERROR,
|
|
46957
|
-
message:
|
|
47169
|
+
message: error82.message
|
|
46958
47170
|
});
|
|
46959
47171
|
} else {
|
|
46960
47172
|
span.setStatus({ code: import_api4.SpanStatusCode.ERROR });
|
|
@@ -47009,6 +47221,125 @@ function addLanguageModelUsage(usage1, usage2) {
|
|
|
47009
47221
|
function addTokenCounts(tokenCount1, tokenCount2) {
|
|
47010
47222
|
return tokenCount1 == null && tokenCount2 == null ? undefined : (tokenCount1 != null ? tokenCount1 : 0) + (tokenCount2 != null ? tokenCount2 : 0);
|
|
47011
47223
|
}
|
|
47224
|
+
function asArray(value) {
|
|
47225
|
+
return value === undefined ? [] : Array.isArray(value) ? value : [value];
|
|
47226
|
+
}
|
|
47227
|
+
function getRetryDelayInMs({
|
|
47228
|
+
error: error82,
|
|
47229
|
+
exponentialBackoffDelay
|
|
47230
|
+
}) {
|
|
47231
|
+
const headers = error82.responseHeaders;
|
|
47232
|
+
if (!headers)
|
|
47233
|
+
return exponentialBackoffDelay;
|
|
47234
|
+
let ms;
|
|
47235
|
+
const retryAfterMs = headers["retry-after-ms"];
|
|
47236
|
+
if (retryAfterMs) {
|
|
47237
|
+
const timeoutMs = parseFloat(retryAfterMs);
|
|
47238
|
+
if (!Number.isNaN(timeoutMs)) {
|
|
47239
|
+
ms = timeoutMs;
|
|
47240
|
+
}
|
|
47241
|
+
}
|
|
47242
|
+
const retryAfter = headers["retry-after"];
|
|
47243
|
+
if (retryAfter && ms === undefined) {
|
|
47244
|
+
const timeoutSeconds = parseFloat(retryAfter);
|
|
47245
|
+
if (!Number.isNaN(timeoutSeconds)) {
|
|
47246
|
+
ms = timeoutSeconds * 1000;
|
|
47247
|
+
} else {
|
|
47248
|
+
ms = Date.parse(retryAfter) - Date.now();
|
|
47249
|
+
}
|
|
47250
|
+
}
|
|
47251
|
+
if (ms != null && !Number.isNaN(ms) && 0 <= ms && (ms < 60 * 1000 || ms < exponentialBackoffDelay)) {
|
|
47252
|
+
return ms;
|
|
47253
|
+
}
|
|
47254
|
+
return exponentialBackoffDelay;
|
|
47255
|
+
}
|
|
47256
|
+
var retryWithExponentialBackoffRespectingRetryHeaders = ({
|
|
47257
|
+
maxRetries = 2,
|
|
47258
|
+
initialDelayInMs = 2000,
|
|
47259
|
+
backoffFactor = 2,
|
|
47260
|
+
abortSignal
|
|
47261
|
+
} = {}) => async (f) => _retryWithExponentialBackoff(f, {
|
|
47262
|
+
maxRetries,
|
|
47263
|
+
delayInMs: initialDelayInMs,
|
|
47264
|
+
backoffFactor,
|
|
47265
|
+
abortSignal
|
|
47266
|
+
});
|
|
47267
|
+
async function _retryWithExponentialBackoff(f, {
|
|
47268
|
+
maxRetries,
|
|
47269
|
+
delayInMs,
|
|
47270
|
+
backoffFactor,
|
|
47271
|
+
abortSignal
|
|
47272
|
+
}, errors5 = []) {
|
|
47273
|
+
try {
|
|
47274
|
+
return await f();
|
|
47275
|
+
} catch (error82) {
|
|
47276
|
+
if (isAbortError(error82)) {
|
|
47277
|
+
throw error82;
|
|
47278
|
+
}
|
|
47279
|
+
if (maxRetries === 0) {
|
|
47280
|
+
throw error82;
|
|
47281
|
+
}
|
|
47282
|
+
const errorMessage = getErrorMessage2(error82);
|
|
47283
|
+
const newErrors = [...errors5, error82];
|
|
47284
|
+
const tryNumber = newErrors.length;
|
|
47285
|
+
if (tryNumber > maxRetries) {
|
|
47286
|
+
throw new RetryError({
|
|
47287
|
+
message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
|
|
47288
|
+
reason: "maxRetriesExceeded",
|
|
47289
|
+
errors: newErrors
|
|
47290
|
+
});
|
|
47291
|
+
}
|
|
47292
|
+
if (error82 instanceof Error && APICallError.isInstance(error82) && error82.isRetryable === true && tryNumber <= maxRetries) {
|
|
47293
|
+
await delay(getRetryDelayInMs({
|
|
47294
|
+
error: error82,
|
|
47295
|
+
exponentialBackoffDelay: delayInMs
|
|
47296
|
+
}), { abortSignal });
|
|
47297
|
+
return _retryWithExponentialBackoff(f, {
|
|
47298
|
+
maxRetries,
|
|
47299
|
+
delayInMs: backoffFactor * delayInMs,
|
|
47300
|
+
backoffFactor,
|
|
47301
|
+
abortSignal
|
|
47302
|
+
}, newErrors);
|
|
47303
|
+
}
|
|
47304
|
+
if (tryNumber === 1) {
|
|
47305
|
+
throw error82;
|
|
47306
|
+
}
|
|
47307
|
+
throw new RetryError({
|
|
47308
|
+
message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
|
|
47309
|
+
reason: "errorNotRetryable",
|
|
47310
|
+
errors: newErrors
|
|
47311
|
+
});
|
|
47312
|
+
}
|
|
47313
|
+
}
|
|
47314
|
+
function prepareRetries({
|
|
47315
|
+
maxRetries,
|
|
47316
|
+
abortSignal
|
|
47317
|
+
}) {
|
|
47318
|
+
if (maxRetries != null) {
|
|
47319
|
+
if (!Number.isInteger(maxRetries)) {
|
|
47320
|
+
throw new InvalidArgumentError2({
|
|
47321
|
+
parameter: "maxRetries",
|
|
47322
|
+
value: maxRetries,
|
|
47323
|
+
message: "maxRetries must be an integer"
|
|
47324
|
+
});
|
|
47325
|
+
}
|
|
47326
|
+
if (maxRetries < 0) {
|
|
47327
|
+
throw new InvalidArgumentError2({
|
|
47328
|
+
parameter: "maxRetries",
|
|
47329
|
+
value: maxRetries,
|
|
47330
|
+
message: "maxRetries must be >= 0"
|
|
47331
|
+
});
|
|
47332
|
+
}
|
|
47333
|
+
}
|
|
47334
|
+
const maxRetriesResult = maxRetries != null ? maxRetries : 2;
|
|
47335
|
+
return {
|
|
47336
|
+
maxRetries: maxRetriesResult,
|
|
47337
|
+
retry: retryWithExponentialBackoffRespectingRetryHeaders({
|
|
47338
|
+
maxRetries: maxRetriesResult,
|
|
47339
|
+
abortSignal
|
|
47340
|
+
})
|
|
47341
|
+
};
|
|
47342
|
+
}
|
|
47012
47343
|
function extractContentText(content) {
|
|
47013
47344
|
const parts = content.filter((content2) => content2.type === "text");
|
|
47014
47345
|
if (parts.length === 0) {
|
|
@@ -47052,38 +47383,50 @@ async function parseToolCall({
|
|
|
47052
47383
|
system,
|
|
47053
47384
|
messages
|
|
47054
47385
|
}) {
|
|
47055
|
-
if (tools == null) {
|
|
47056
|
-
throw new NoSuchToolError({ toolName: toolCall.toolName });
|
|
47057
|
-
}
|
|
47058
47386
|
try {
|
|
47059
|
-
|
|
47060
|
-
|
|
47061
|
-
if (repairToolCall == null || !(NoSuchToolError.isInstance(error81) || InvalidToolInputError.isInstance(error81))) {
|
|
47062
|
-
throw error81;
|
|
47387
|
+
if (tools == null) {
|
|
47388
|
+
throw new NoSuchToolError({ toolName: toolCall.toolName });
|
|
47063
47389
|
}
|
|
47064
|
-
let repairedToolCall = null;
|
|
47065
47390
|
try {
|
|
47066
|
-
|
|
47067
|
-
|
|
47068
|
-
|
|
47069
|
-
|
|
47070
|
-
|
|
47071
|
-
|
|
47072
|
-
|
|
47073
|
-
|
|
47074
|
-
|
|
47075
|
-
|
|
47076
|
-
|
|
47077
|
-
|
|
47078
|
-
|
|
47079
|
-
|
|
47080
|
-
|
|
47081
|
-
|
|
47082
|
-
|
|
47083
|
-
|
|
47084
|
-
|
|
47391
|
+
return await doParseToolCall({ toolCall, tools });
|
|
47392
|
+
} catch (error82) {
|
|
47393
|
+
if (repairToolCall == null || !(NoSuchToolError.isInstance(error82) || InvalidToolInputError.isInstance(error82))) {
|
|
47394
|
+
throw error82;
|
|
47395
|
+
}
|
|
47396
|
+
let repairedToolCall = null;
|
|
47397
|
+
try {
|
|
47398
|
+
repairedToolCall = await repairToolCall({
|
|
47399
|
+
toolCall,
|
|
47400
|
+
tools,
|
|
47401
|
+
inputSchema: ({ toolName }) => {
|
|
47402
|
+
const { inputSchema } = tools[toolName];
|
|
47403
|
+
return asSchema(inputSchema).jsonSchema;
|
|
47404
|
+
},
|
|
47405
|
+
system,
|
|
47406
|
+
messages,
|
|
47407
|
+
error: error82
|
|
47408
|
+
});
|
|
47409
|
+
} catch (repairError) {
|
|
47410
|
+
throw new ToolCallRepairError({
|
|
47411
|
+
cause: repairError,
|
|
47412
|
+
originalError: error82
|
|
47413
|
+
});
|
|
47414
|
+
}
|
|
47415
|
+
if (repairedToolCall == null) {
|
|
47416
|
+
throw error82;
|
|
47417
|
+
}
|
|
47418
|
+
return await doParseToolCall({ toolCall: repairedToolCall, tools });
|
|
47085
47419
|
}
|
|
47086
|
-
|
|
47420
|
+
} catch (error82) {
|
|
47421
|
+
return {
|
|
47422
|
+
type: "tool-call",
|
|
47423
|
+
toolCallId: toolCall.toolCallId,
|
|
47424
|
+
toolName: toolCall.toolName,
|
|
47425
|
+
input: toolCall.input,
|
|
47426
|
+
dynamic: true,
|
|
47427
|
+
invalid: true,
|
|
47428
|
+
error: error82
|
|
47429
|
+
};
|
|
47087
47430
|
}
|
|
47088
47431
|
}
|
|
47089
47432
|
async function doParseToolCall({
|
|
@@ -47107,7 +47450,15 @@ async function doParseToolCall({
|
|
|
47107
47450
|
cause: parseResult.error
|
|
47108
47451
|
});
|
|
47109
47452
|
}
|
|
47110
|
-
return {
|
|
47453
|
+
return tool3.type === "dynamic" ? {
|
|
47454
|
+
type: "tool-call",
|
|
47455
|
+
toolCallId: toolCall.toolCallId,
|
|
47456
|
+
toolName: toolCall.toolName,
|
|
47457
|
+
input: parseResult.value,
|
|
47458
|
+
providerExecuted: toolCall.providerExecuted,
|
|
47459
|
+
providerMetadata: toolCall.providerMetadata,
|
|
47460
|
+
dynamic: true
|
|
47461
|
+
} : {
|
|
47111
47462
|
type: "tool-call",
|
|
47112
47463
|
toolCallId: toolCall.toolCallId,
|
|
47113
47464
|
toolName,
|
|
@@ -47152,9 +47503,21 @@ var DefaultStepResult = class {
|
|
|
47152
47503
|
get toolCalls() {
|
|
47153
47504
|
return this.content.filter((part) => part.type === "tool-call");
|
|
47154
47505
|
}
|
|
47506
|
+
get staticToolCalls() {
|
|
47507
|
+
return this.toolCalls.filter((toolCall) => toolCall.dynamic === false);
|
|
47508
|
+
}
|
|
47509
|
+
get dynamicToolCalls() {
|
|
47510
|
+
return this.toolCalls.filter((toolCall) => toolCall.dynamic === true);
|
|
47511
|
+
}
|
|
47155
47512
|
get toolResults() {
|
|
47156
47513
|
return this.content.filter((part) => part.type === "tool-result");
|
|
47157
47514
|
}
|
|
47515
|
+
get staticToolResults() {
|
|
47516
|
+
return this.toolResults.filter((toolResult) => toolResult.dynamic === false);
|
|
47517
|
+
}
|
|
47518
|
+
get dynamicToolResults() {
|
|
47519
|
+
return this.toolResults.filter((toolResult) => toolResult.dynamic === true);
|
|
47520
|
+
}
|
|
47158
47521
|
};
|
|
47159
47522
|
function stepCountIs(stepCount) {
|
|
47160
47523
|
return ({ steps }) => steps.length === stepCount;
|
|
@@ -47173,12 +47536,15 @@ function createToolModelOutput({
|
|
|
47173
47536
|
if (errorMode === "text") {
|
|
47174
47537
|
return { type: "error-text", value: getErrorMessage(output) };
|
|
47175
47538
|
} else if (errorMode === "json") {
|
|
47176
|
-
return { type: "error-json", value: output };
|
|
47539
|
+
return { type: "error-json", value: toJSONValue(output) };
|
|
47177
47540
|
}
|
|
47178
47541
|
if (tool3 == null ? undefined : tool3.toModelOutput) {
|
|
47179
47542
|
return tool3.toModelOutput(output);
|
|
47180
47543
|
}
|
|
47181
|
-
return typeof output === "string" ? { type: "text", value: output } : { type: "json", value: output };
|
|
47544
|
+
return typeof output === "string" ? { type: "text", value: output } : { type: "json", value: toJSONValue(output) };
|
|
47545
|
+
}
|
|
47546
|
+
function toJSONValue(value) {
|
|
47547
|
+
return value === undefined ? null : value;
|
|
47182
47548
|
}
|
|
47183
47549
|
function toResponseMessages({
|
|
47184
47550
|
content: inputContent,
|
|
@@ -47289,6 +47655,7 @@ async function generateText({
|
|
|
47289
47655
|
experimental_prepareStep,
|
|
47290
47656
|
prepareStep = experimental_prepareStep,
|
|
47291
47657
|
experimental_repairToolCall: repairToolCall,
|
|
47658
|
+
experimental_context,
|
|
47292
47659
|
_internal: {
|
|
47293
47660
|
generateId: generateId3 = originalGenerateId,
|
|
47294
47661
|
currentDate = () => /* @__PURE__ */ new Date
|
|
@@ -47298,7 +47665,10 @@ async function generateText({
|
|
|
47298
47665
|
}) {
|
|
47299
47666
|
const model = resolveLanguageModel(modelArg);
|
|
47300
47667
|
const stopConditions = asArray(stopWhen);
|
|
47301
|
-
const { maxRetries, retry } = prepareRetries({
|
|
47668
|
+
const { maxRetries, retry } = prepareRetries({
|
|
47669
|
+
maxRetries: maxRetriesArg,
|
|
47670
|
+
abortSignal
|
|
47671
|
+
});
|
|
47302
47672
|
const callSettings = prepareCallSettings(settings);
|
|
47303
47673
|
const baseTelemetryAttributes = getBaseTelemetryAttributes({
|
|
47304
47674
|
model,
|
|
@@ -47455,25 +47825,44 @@ async function generateText({
|
|
|
47455
47825
|
messages: stepInputMessages
|
|
47456
47826
|
})));
|
|
47457
47827
|
for (const toolCall of stepToolCalls) {
|
|
47828
|
+
if (toolCall.invalid) {
|
|
47829
|
+
continue;
|
|
47830
|
+
}
|
|
47458
47831
|
const tool3 = tools[toolCall.toolName];
|
|
47459
47832
|
if ((tool3 == null ? undefined : tool3.onInputAvailable) != null) {
|
|
47460
47833
|
await tool3.onInputAvailable({
|
|
47461
47834
|
input: toolCall.input,
|
|
47462
47835
|
toolCallId: toolCall.toolCallId,
|
|
47463
47836
|
messages: stepInputMessages,
|
|
47464
|
-
abortSignal
|
|
47837
|
+
abortSignal,
|
|
47838
|
+
experimental_context
|
|
47465
47839
|
});
|
|
47466
47840
|
}
|
|
47467
47841
|
}
|
|
47468
|
-
|
|
47469
|
-
clientToolOutputs =
|
|
47470
|
-
|
|
47471
|
-
|
|
47472
|
-
|
|
47473
|
-
|
|
47474
|
-
|
|
47475
|
-
|
|
47476
|
-
|
|
47842
|
+
const invalidToolCalls = stepToolCalls.filter((toolCall) => toolCall.invalid && toolCall.dynamic);
|
|
47843
|
+
clientToolOutputs = [];
|
|
47844
|
+
for (const toolCall of invalidToolCalls) {
|
|
47845
|
+
clientToolOutputs.push({
|
|
47846
|
+
type: "tool-error",
|
|
47847
|
+
toolCallId: toolCall.toolCallId,
|
|
47848
|
+
toolName: toolCall.toolName,
|
|
47849
|
+
input: toolCall.input,
|
|
47850
|
+
error: getErrorMessage2(toolCall.error),
|
|
47851
|
+
dynamic: true
|
|
47852
|
+
});
|
|
47853
|
+
}
|
|
47854
|
+
clientToolCalls = stepToolCalls.filter((toolCall) => !toolCall.providerExecuted);
|
|
47855
|
+
if (tools != null) {
|
|
47856
|
+
clientToolOutputs.push(...await executeTools({
|
|
47857
|
+
toolCalls: clientToolCalls.filter((toolCall) => !toolCall.invalid),
|
|
47858
|
+
tools,
|
|
47859
|
+
tracer,
|
|
47860
|
+
telemetry,
|
|
47861
|
+
messages: stepInputMessages,
|
|
47862
|
+
abortSignal,
|
|
47863
|
+
experimental_context
|
|
47864
|
+
}));
|
|
47865
|
+
}
|
|
47477
47866
|
const stepContent = asContent({
|
|
47478
47867
|
content: currentModelResponse.content,
|
|
47479
47868
|
toolCalls: stepToolCalls,
|
|
@@ -47527,8 +47916,8 @@ async function generateText({
|
|
|
47527
47916
|
});
|
|
47528
47917
|
}
|
|
47529
47918
|
});
|
|
47530
|
-
} catch (
|
|
47531
|
-
throw wrapGatewayError(
|
|
47919
|
+
} catch (error82) {
|
|
47920
|
+
throw wrapGatewayError(error82);
|
|
47532
47921
|
}
|
|
47533
47922
|
}
|
|
47534
47923
|
async function executeTools({
|
|
@@ -47537,7 +47926,8 @@ async function executeTools({
|
|
|
47537
47926
|
tracer,
|
|
47538
47927
|
telemetry,
|
|
47539
47928
|
messages,
|
|
47540
|
-
abortSignal
|
|
47929
|
+
abortSignal,
|
|
47930
|
+
experimental_context
|
|
47541
47931
|
}) {
|
|
47542
47932
|
const toolOutputs = await Promise.all(toolCalls.map(async ({ toolCallId, toolName, input }) => {
|
|
47543
47933
|
const tool3 = tools[toolName];
|
|
@@ -47555,7 +47945,7 @@ async function executeTools({
|
|
|
47555
47945
|
}),
|
|
47556
47946
|
"ai.toolCall.name": toolName,
|
|
47557
47947
|
"ai.toolCall.id": toolCallId,
|
|
47558
|
-
"ai.toolCall.
|
|
47948
|
+
"ai.toolCall.args": {
|
|
47559
47949
|
output: () => JSON.stringify(input)
|
|
47560
47950
|
}
|
|
47561
47951
|
}
|
|
@@ -47563,17 +47953,18 @@ async function executeTools({
|
|
|
47563
47953
|
tracer,
|
|
47564
47954
|
fn: async (span) => {
|
|
47565
47955
|
try {
|
|
47566
|
-
const
|
|
47956
|
+
const output = await tool3.execute(input, {
|
|
47567
47957
|
toolCallId,
|
|
47568
47958
|
messages,
|
|
47569
|
-
abortSignal
|
|
47959
|
+
abortSignal,
|
|
47960
|
+
experimental_context
|
|
47570
47961
|
});
|
|
47571
47962
|
try {
|
|
47572
47963
|
span.setAttributes(selectTelemetryAttributes({
|
|
47573
47964
|
telemetry,
|
|
47574
47965
|
attributes: {
|
|
47575
47966
|
"ai.toolCall.result": {
|
|
47576
|
-
output: () => JSON.stringify(
|
|
47967
|
+
output: () => JSON.stringify(output)
|
|
47577
47968
|
}
|
|
47578
47969
|
}
|
|
47579
47970
|
}));
|
|
@@ -47583,16 +47974,18 @@ async function executeTools({
|
|
|
47583
47974
|
toolCallId,
|
|
47584
47975
|
toolName,
|
|
47585
47976
|
input,
|
|
47586
|
-
output
|
|
47977
|
+
output,
|
|
47978
|
+
dynamic: tool3.type === "dynamic"
|
|
47587
47979
|
};
|
|
47588
|
-
} catch (
|
|
47589
|
-
recordErrorOnSpan(span,
|
|
47980
|
+
} catch (error82) {
|
|
47981
|
+
recordErrorOnSpan(span, error82);
|
|
47590
47982
|
return {
|
|
47591
47983
|
type: "tool-error",
|
|
47592
47984
|
toolCallId,
|
|
47593
47985
|
toolName,
|
|
47594
47986
|
input,
|
|
47595
|
-
error:
|
|
47987
|
+
error: error82,
|
|
47988
|
+
dynamic: tool3.type === "dynamic"
|
|
47596
47989
|
};
|
|
47597
47990
|
}
|
|
47598
47991
|
}
|
|
@@ -47626,9 +48019,21 @@ var DefaultGenerateTextResult = class {
|
|
|
47626
48019
|
get toolCalls() {
|
|
47627
48020
|
return this.finalStep.toolCalls;
|
|
47628
48021
|
}
|
|
48022
|
+
get staticToolCalls() {
|
|
48023
|
+
return this.finalStep.staticToolCalls;
|
|
48024
|
+
}
|
|
48025
|
+
get dynamicToolCalls() {
|
|
48026
|
+
return this.finalStep.dynamicToolCalls;
|
|
48027
|
+
}
|
|
47629
48028
|
get toolResults() {
|
|
47630
48029
|
return this.finalStep.toolResults;
|
|
47631
48030
|
}
|
|
48031
|
+
get staticToolResults() {
|
|
48032
|
+
return this.finalStep.staticToolResults;
|
|
48033
|
+
}
|
|
48034
|
+
get dynamicToolResults() {
|
|
48035
|
+
return this.finalStep.dynamicToolResults;
|
|
48036
|
+
}
|
|
47632
48037
|
get sources() {
|
|
47633
48038
|
return this.finalStep.sources;
|
|
47634
48039
|
}
|
|
@@ -47712,7 +48117,8 @@ function asContent({
|
|
|
47712
48117
|
toolName: part.toolName,
|
|
47713
48118
|
input: toolCall.input,
|
|
47714
48119
|
error: part.result,
|
|
47715
|
-
providerExecuted: true
|
|
48120
|
+
providerExecuted: true,
|
|
48121
|
+
dynamic: toolCall.dynamic
|
|
47716
48122
|
};
|
|
47717
48123
|
}
|
|
47718
48124
|
return {
|
|
@@ -47721,7 +48127,8 @@ function asContent({
|
|
|
47721
48127
|
toolName: part.toolName,
|
|
47722
48128
|
input: toolCall.input,
|
|
47723
48129
|
output: part.result,
|
|
47724
|
-
providerExecuted: true
|
|
48130
|
+
providerExecuted: true,
|
|
48131
|
+
dynamic: toolCall.dynamic
|
|
47725
48132
|
};
|
|
47726
48133
|
}
|
|
47727
48134
|
}
|
|
@@ -47769,8 +48176,8 @@ function writeToServerResponse({
|
|
|
47769
48176
|
break;
|
|
47770
48177
|
response.write(value);
|
|
47771
48178
|
}
|
|
47772
|
-
} catch (
|
|
47773
|
-
throw
|
|
48179
|
+
} catch (error82) {
|
|
48180
|
+
throw error82;
|
|
47774
48181
|
} finally {
|
|
47775
48182
|
response.end();
|
|
47776
48183
|
}
|
|
@@ -47871,7 +48278,8 @@ var uiMessageChunkSchema = exports_external2.union([
|
|
|
47871
48278
|
type: exports_external2.literal("tool-input-start"),
|
|
47872
48279
|
toolCallId: exports_external2.string(),
|
|
47873
48280
|
toolName: exports_external2.string(),
|
|
47874
|
-
providerExecuted: exports_external2.boolean().optional()
|
|
48281
|
+
providerExecuted: exports_external2.boolean().optional(),
|
|
48282
|
+
dynamic: exports_external2.boolean().optional()
|
|
47875
48283
|
}),
|
|
47876
48284
|
exports_external2.strictObject({
|
|
47877
48285
|
type: exports_external2.literal("tool-input-delta"),
|
|
@@ -47884,19 +48292,32 @@ var uiMessageChunkSchema = exports_external2.union([
|
|
|
47884
48292
|
toolName: exports_external2.string(),
|
|
47885
48293
|
input: exports_external2.unknown(),
|
|
47886
48294
|
providerExecuted: exports_external2.boolean().optional(),
|
|
47887
|
-
providerMetadata: providerMetadataSchema.optional()
|
|
48295
|
+
providerMetadata: providerMetadataSchema.optional(),
|
|
48296
|
+
dynamic: exports_external2.boolean().optional()
|
|
48297
|
+
}),
|
|
48298
|
+
exports_external2.strictObject({
|
|
48299
|
+
type: exports_external2.literal("tool-input-error"),
|
|
48300
|
+
toolCallId: exports_external2.string(),
|
|
48301
|
+
toolName: exports_external2.string(),
|
|
48302
|
+
input: exports_external2.unknown(),
|
|
48303
|
+
providerExecuted: exports_external2.boolean().optional(),
|
|
48304
|
+
providerMetadata: providerMetadataSchema.optional(),
|
|
48305
|
+
dynamic: exports_external2.boolean().optional(),
|
|
48306
|
+
errorText: exports_external2.string()
|
|
47888
48307
|
}),
|
|
47889
48308
|
exports_external2.strictObject({
|
|
47890
48309
|
type: exports_external2.literal("tool-output-available"),
|
|
47891
48310
|
toolCallId: exports_external2.string(),
|
|
47892
48311
|
output: exports_external2.unknown(),
|
|
47893
|
-
providerExecuted: exports_external2.boolean().optional()
|
|
48312
|
+
providerExecuted: exports_external2.boolean().optional(),
|
|
48313
|
+
dynamic: exports_external2.boolean().optional()
|
|
47894
48314
|
}),
|
|
47895
48315
|
exports_external2.strictObject({
|
|
47896
48316
|
type: exports_external2.literal("tool-output-error"),
|
|
47897
48317
|
toolCallId: exports_external2.string(),
|
|
47898
48318
|
errorText: exports_external2.string(),
|
|
47899
|
-
providerExecuted: exports_external2.boolean().optional()
|
|
48319
|
+
providerExecuted: exports_external2.boolean().optional(),
|
|
48320
|
+
dynamic: exports_external2.boolean().optional()
|
|
47900
48321
|
}),
|
|
47901
48322
|
exports_external2.strictObject({
|
|
47902
48323
|
type: exports_external2.literal("reasoning"),
|
|
@@ -48357,18 +48778,34 @@ function createStreamingUIMessageState({
|
|
|
48357
48778
|
}
|
|
48358
48779
|
function processUIMessageStream({
|
|
48359
48780
|
stream,
|
|
48360
|
-
onToolCall,
|
|
48361
48781
|
messageMetadataSchema,
|
|
48362
48782
|
dataPartSchemas,
|
|
48363
48783
|
runUpdateMessageJob,
|
|
48364
48784
|
onError,
|
|
48785
|
+
onToolCall,
|
|
48365
48786
|
onData
|
|
48366
48787
|
}) {
|
|
48367
48788
|
return stream.pipeThrough(new TransformStream({
|
|
48368
48789
|
async transform(chunk, controller) {
|
|
48369
48790
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
48370
48791
|
var _a16, _b8, _c, _d;
|
|
48371
|
-
function
|
|
48792
|
+
function getToolInvocation(toolCallId) {
|
|
48793
|
+
const toolInvocations = state.message.parts.filter(isToolUIPart);
|
|
48794
|
+
const toolInvocation = toolInvocations.find((invocation) => invocation.toolCallId === toolCallId);
|
|
48795
|
+
if (toolInvocation == null) {
|
|
48796
|
+
throw new Error("tool-output-error must be preceded by a tool-input-available");
|
|
48797
|
+
}
|
|
48798
|
+
return toolInvocation;
|
|
48799
|
+
}
|
|
48800
|
+
function getDynamicToolInvocation(toolCallId) {
|
|
48801
|
+
const toolInvocations = state.message.parts.filter((part) => part.type === "dynamic-tool");
|
|
48802
|
+
const toolInvocation = toolInvocations.find((invocation) => invocation.toolCallId === toolCallId);
|
|
48803
|
+
if (toolInvocation == null) {
|
|
48804
|
+
throw new Error("tool-output-error must be preceded by a tool-input-available");
|
|
48805
|
+
}
|
|
48806
|
+
return toolInvocation;
|
|
48807
|
+
}
|
|
48808
|
+
function updateToolPart(options) {
|
|
48372
48809
|
var _a172;
|
|
48373
48810
|
const part = state.message.parts.find((part2) => isToolUIPart(part2) && part2.toolCallId === options.toolCallId);
|
|
48374
48811
|
const anyOptions = options;
|
|
@@ -48378,6 +48815,7 @@ function processUIMessageStream({
|
|
|
48378
48815
|
anyPart.input = anyOptions.input;
|
|
48379
48816
|
anyPart.output = anyOptions.output;
|
|
48380
48817
|
anyPart.errorText = anyOptions.errorText;
|
|
48818
|
+
anyPart.rawInput = anyOptions.rawInput;
|
|
48381
48819
|
anyPart.providerExecuted = (_a172 = anyOptions.providerExecuted) != null ? _a172 : part.providerExecuted;
|
|
48382
48820
|
if (anyOptions.providerMetadata != null && part.state === "input-available") {
|
|
48383
48821
|
part.callProviderMetadata = anyOptions.providerMetadata;
|
|
@@ -48389,12 +48827,41 @@ function processUIMessageStream({
|
|
|
48389
48827
|
state: options.state,
|
|
48390
48828
|
input: anyOptions.input,
|
|
48391
48829
|
output: anyOptions.output,
|
|
48830
|
+
rawInput: anyOptions.rawInput,
|
|
48392
48831
|
errorText: anyOptions.errorText,
|
|
48393
48832
|
providerExecuted: anyOptions.providerExecuted,
|
|
48394
48833
|
...anyOptions.providerMetadata != null ? { callProviderMetadata: anyOptions.providerMetadata } : {}
|
|
48395
48834
|
});
|
|
48396
48835
|
}
|
|
48397
48836
|
}
|
|
48837
|
+
function updateDynamicToolPart(options) {
|
|
48838
|
+
var _a172;
|
|
48839
|
+
const part = state.message.parts.find((part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId);
|
|
48840
|
+
const anyOptions = options;
|
|
48841
|
+
const anyPart = part;
|
|
48842
|
+
if (part != null) {
|
|
48843
|
+
part.state = options.state;
|
|
48844
|
+
anyPart.toolName = options.toolName;
|
|
48845
|
+
anyPart.input = anyOptions.input;
|
|
48846
|
+
anyPart.output = anyOptions.output;
|
|
48847
|
+
anyPart.errorText = anyOptions.errorText;
|
|
48848
|
+
anyPart.rawInput = (_a172 = anyOptions.rawInput) != null ? _a172 : anyPart.rawInput;
|
|
48849
|
+
if (anyOptions.providerMetadata != null && part.state === "input-available") {
|
|
48850
|
+
part.callProviderMetadata = anyOptions.providerMetadata;
|
|
48851
|
+
}
|
|
48852
|
+
} else {
|
|
48853
|
+
state.message.parts.push({
|
|
48854
|
+
type: "dynamic-tool",
|
|
48855
|
+
toolName: options.toolName,
|
|
48856
|
+
toolCallId: options.toolCallId,
|
|
48857
|
+
state: options.state,
|
|
48858
|
+
input: anyOptions.input,
|
|
48859
|
+
output: anyOptions.output,
|
|
48860
|
+
errorText: anyOptions.errorText,
|
|
48861
|
+
...anyOptions.providerMetadata != null ? { callProviderMetadata: anyOptions.providerMetadata } : {}
|
|
48862
|
+
});
|
|
48863
|
+
}
|
|
48864
|
+
}
|
|
48398
48865
|
async function updateMessageMetadata(metadata) {
|
|
48399
48866
|
if (metadata != null) {
|
|
48400
48867
|
const mergedMetadata = state.message.metadata != null ? mergeObjects(state.message.metadata, metadata) : metadata;
|
|
@@ -48499,15 +48966,25 @@ function processUIMessageStream({
|
|
|
48499
48966
|
state.partialToolCalls[chunk.toolCallId] = {
|
|
48500
48967
|
text: "",
|
|
48501
48968
|
toolName: chunk.toolName,
|
|
48502
|
-
index: toolInvocations.length
|
|
48969
|
+
index: toolInvocations.length,
|
|
48970
|
+
dynamic: chunk.dynamic
|
|
48503
48971
|
};
|
|
48504
|
-
|
|
48505
|
-
|
|
48506
|
-
|
|
48507
|
-
|
|
48508
|
-
|
|
48509
|
-
|
|
48510
|
-
|
|
48972
|
+
if (chunk.dynamic) {
|
|
48973
|
+
updateDynamicToolPart({
|
|
48974
|
+
toolCallId: chunk.toolCallId,
|
|
48975
|
+
toolName: chunk.toolName,
|
|
48976
|
+
state: "input-streaming",
|
|
48977
|
+
input: undefined
|
|
48978
|
+
});
|
|
48979
|
+
} else {
|
|
48980
|
+
updateToolPart({
|
|
48981
|
+
toolCallId: chunk.toolCallId,
|
|
48982
|
+
toolName: chunk.toolName,
|
|
48983
|
+
state: "input-streaming",
|
|
48984
|
+
input: undefined,
|
|
48985
|
+
providerExecuted: chunk.providerExecuted
|
|
48986
|
+
});
|
|
48987
|
+
}
|
|
48511
48988
|
write();
|
|
48512
48989
|
break;
|
|
48513
48990
|
}
|
|
@@ -48515,81 +48992,121 @@ function processUIMessageStream({
|
|
|
48515
48992
|
const partialToolCall = state.partialToolCalls[chunk.toolCallId];
|
|
48516
48993
|
partialToolCall.text += chunk.inputTextDelta;
|
|
48517
48994
|
const { value: partialArgs } = await parsePartialJson(partialToolCall.text);
|
|
48518
|
-
|
|
48519
|
-
|
|
48520
|
-
|
|
48521
|
-
|
|
48522
|
-
|
|
48523
|
-
|
|
48995
|
+
if (partialToolCall.dynamic) {
|
|
48996
|
+
updateDynamicToolPart({
|
|
48997
|
+
toolCallId: chunk.toolCallId,
|
|
48998
|
+
toolName: partialToolCall.toolName,
|
|
48999
|
+
state: "input-streaming",
|
|
49000
|
+
input: partialArgs
|
|
49001
|
+
});
|
|
49002
|
+
} else {
|
|
49003
|
+
updateToolPart({
|
|
49004
|
+
toolCallId: chunk.toolCallId,
|
|
49005
|
+
toolName: partialToolCall.toolName,
|
|
49006
|
+
state: "input-streaming",
|
|
49007
|
+
input: partialArgs
|
|
49008
|
+
});
|
|
49009
|
+
}
|
|
48524
49010
|
write();
|
|
48525
49011
|
break;
|
|
48526
49012
|
}
|
|
48527
49013
|
case "tool-input-available": {
|
|
48528
|
-
|
|
48529
|
-
|
|
48530
|
-
|
|
48531
|
-
|
|
48532
|
-
|
|
48533
|
-
|
|
48534
|
-
|
|
48535
|
-
|
|
49014
|
+
if (chunk.dynamic) {
|
|
49015
|
+
updateDynamicToolPart({
|
|
49016
|
+
toolCallId: chunk.toolCallId,
|
|
49017
|
+
toolName: chunk.toolName,
|
|
49018
|
+
state: "input-available",
|
|
49019
|
+
input: chunk.input,
|
|
49020
|
+
providerMetadata: chunk.providerMetadata
|
|
49021
|
+
});
|
|
49022
|
+
} else {
|
|
49023
|
+
updateToolPart({
|
|
49024
|
+
toolCallId: chunk.toolCallId,
|
|
49025
|
+
toolName: chunk.toolName,
|
|
49026
|
+
state: "input-available",
|
|
49027
|
+
input: chunk.input,
|
|
49028
|
+
providerExecuted: chunk.providerExecuted,
|
|
49029
|
+
providerMetadata: chunk.providerMetadata
|
|
49030
|
+
});
|
|
49031
|
+
}
|
|
48536
49032
|
write();
|
|
48537
49033
|
if (onToolCall && !chunk.providerExecuted) {
|
|
48538
|
-
|
|
49034
|
+
await onToolCall({
|
|
48539
49035
|
toolCall: chunk
|
|
48540
49036
|
});
|
|
48541
|
-
if (result != null) {
|
|
48542
|
-
updateToolInvocationPart({
|
|
48543
|
-
toolCallId: chunk.toolCallId,
|
|
48544
|
-
toolName: chunk.toolName,
|
|
48545
|
-
state: "output-available",
|
|
48546
|
-
input: chunk.input,
|
|
48547
|
-
output: result
|
|
48548
|
-
});
|
|
48549
|
-
write();
|
|
48550
|
-
}
|
|
48551
49037
|
}
|
|
48552
49038
|
break;
|
|
48553
49039
|
}
|
|
48554
|
-
case "tool-
|
|
48555
|
-
|
|
48556
|
-
|
|
48557
|
-
|
|
49040
|
+
case "tool-input-error": {
|
|
49041
|
+
if (chunk.dynamic) {
|
|
49042
|
+
updateDynamicToolPart({
|
|
49043
|
+
toolCallId: chunk.toolCallId,
|
|
49044
|
+
toolName: chunk.toolName,
|
|
49045
|
+
state: "output-error",
|
|
49046
|
+
input: chunk.input,
|
|
49047
|
+
errorText: chunk.errorText,
|
|
49048
|
+
providerMetadata: chunk.providerMetadata
|
|
49049
|
+
});
|
|
49050
|
+
} else {
|
|
49051
|
+
updateToolPart({
|
|
49052
|
+
toolCallId: chunk.toolCallId,
|
|
49053
|
+
toolName: chunk.toolName,
|
|
49054
|
+
state: "output-error",
|
|
49055
|
+
input: undefined,
|
|
49056
|
+
rawInput: chunk.input,
|
|
49057
|
+
errorText: chunk.errorText,
|
|
49058
|
+
providerExecuted: chunk.providerExecuted,
|
|
49059
|
+
providerMetadata: chunk.providerMetadata
|
|
49060
|
+
});
|
|
48558
49061
|
}
|
|
48559
|
-
|
|
48560
|
-
|
|
48561
|
-
|
|
49062
|
+
write();
|
|
49063
|
+
break;
|
|
49064
|
+
}
|
|
49065
|
+
case "tool-output-available": {
|
|
49066
|
+
if (chunk.dynamic) {
|
|
49067
|
+
const toolInvocation = getDynamicToolInvocation(chunk.toolCallId);
|
|
49068
|
+
updateDynamicToolPart({
|
|
49069
|
+
toolCallId: chunk.toolCallId,
|
|
49070
|
+
toolName: toolInvocation.toolName,
|
|
49071
|
+
state: "output-available",
|
|
49072
|
+
input: toolInvocation.input,
|
|
49073
|
+
output: chunk.output
|
|
49074
|
+
});
|
|
49075
|
+
} else {
|
|
49076
|
+
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
49077
|
+
updateToolPart({
|
|
49078
|
+
toolCallId: chunk.toolCallId,
|
|
49079
|
+
toolName: getToolName(toolInvocation),
|
|
49080
|
+
state: "output-available",
|
|
49081
|
+
input: toolInvocation.input,
|
|
49082
|
+
output: chunk.output,
|
|
49083
|
+
providerExecuted: chunk.providerExecuted
|
|
49084
|
+
});
|
|
48562
49085
|
}
|
|
48563
|
-
const toolName = getToolName(toolInvocations[toolInvocationIndex]);
|
|
48564
|
-
updateToolInvocationPart({
|
|
48565
|
-
toolCallId: chunk.toolCallId,
|
|
48566
|
-
toolName,
|
|
48567
|
-
state: "output-available",
|
|
48568
|
-
input: toolInvocations[toolInvocationIndex].input,
|
|
48569
|
-
output: chunk.output,
|
|
48570
|
-
providerExecuted: chunk.providerExecuted
|
|
48571
|
-
});
|
|
48572
49086
|
write();
|
|
48573
49087
|
break;
|
|
48574
49088
|
}
|
|
48575
49089
|
case "tool-output-error": {
|
|
48576
|
-
|
|
48577
|
-
|
|
48578
|
-
|
|
48579
|
-
|
|
48580
|
-
|
|
48581
|
-
|
|
48582
|
-
|
|
49090
|
+
if (chunk.dynamic) {
|
|
49091
|
+
const toolInvocation = getDynamicToolInvocation(chunk.toolCallId);
|
|
49092
|
+
updateDynamicToolPart({
|
|
49093
|
+
toolCallId: chunk.toolCallId,
|
|
49094
|
+
toolName: toolInvocation.toolName,
|
|
49095
|
+
state: "output-error",
|
|
49096
|
+
input: toolInvocation.input,
|
|
49097
|
+
errorText: chunk.errorText
|
|
49098
|
+
});
|
|
49099
|
+
} else {
|
|
49100
|
+
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
49101
|
+
updateToolPart({
|
|
49102
|
+
toolCallId: chunk.toolCallId,
|
|
49103
|
+
toolName: getToolName(toolInvocation),
|
|
49104
|
+
state: "output-error",
|
|
49105
|
+
input: toolInvocation.input,
|
|
49106
|
+
rawInput: toolInvocation.rawInput,
|
|
49107
|
+
errorText: chunk.errorText
|
|
49108
|
+
});
|
|
48583
49109
|
}
|
|
48584
|
-
const toolName = getToolName(toolInvocations[toolInvocationIndex]);
|
|
48585
|
-
updateToolInvocationPart({
|
|
48586
|
-
toolCallId: chunk.toolCallId,
|
|
48587
|
-
toolName,
|
|
48588
|
-
state: "output-error",
|
|
48589
|
-
input: toolInvocations[toolInvocationIndex].input,
|
|
48590
|
-
errorText: chunk.errorText,
|
|
48591
|
-
providerExecuted: chunk.providerExecuted
|
|
48592
|
-
});
|
|
48593
49110
|
write();
|
|
48594
49111
|
break;
|
|
48595
49112
|
}
|
|
@@ -48765,8 +49282,8 @@ async function consumeStream({
|
|
|
48765
49282
|
if (done)
|
|
48766
49283
|
break;
|
|
48767
49284
|
}
|
|
48768
|
-
} catch (
|
|
48769
|
-
onError == null || onError(
|
|
49285
|
+
} catch (error82) {
|
|
49286
|
+
onError == null || onError(error82);
|
|
48770
49287
|
} finally {
|
|
48771
49288
|
reader.releaseLock();
|
|
48772
49289
|
}
|
|
@@ -48818,8 +49335,8 @@ function createStitchableStream() {
|
|
|
48818
49335
|
} else {
|
|
48819
49336
|
controller == null || controller.enqueue(value);
|
|
48820
49337
|
}
|
|
48821
|
-
} catch (
|
|
48822
|
-
controller == null || controller.error(
|
|
49338
|
+
} catch (error82) {
|
|
49339
|
+
controller == null || controller.error(error82);
|
|
48823
49340
|
innerStreamReaders.shift();
|
|
48824
49341
|
terminate();
|
|
48825
49342
|
}
|
|
@@ -48883,18 +49400,14 @@ var DelayedPromise = class {
|
|
|
48883
49400
|
(_a16 = this._resolve) == null || _a16.call(this, value);
|
|
48884
49401
|
}
|
|
48885
49402
|
}
|
|
48886
|
-
reject(
|
|
49403
|
+
reject(error82) {
|
|
48887
49404
|
var _a16;
|
|
48888
|
-
this.status = { type: "rejected", error:
|
|
49405
|
+
this.status = { type: "rejected", error: error82 };
|
|
48889
49406
|
if (this._promise) {
|
|
48890
|
-
(_a16 = this._reject) == null || _a16.call(this,
|
|
49407
|
+
(_a16 = this._reject) == null || _a16.call(this, error82);
|
|
48891
49408
|
}
|
|
48892
49409
|
}
|
|
48893
49410
|
};
|
|
48894
|
-
function now() {
|
|
48895
|
-
var _a16, _b8;
|
|
48896
|
-
return (_b8 = (_a16 = globalThis == null ? undefined : globalThis.performance) == null ? undefined : _a16.now()) != null ? _b8 : Date.now();
|
|
48897
|
-
}
|
|
48898
49411
|
function filterStreamErrors(readable, onError) {
|
|
48899
49412
|
return new ReadableStream({
|
|
48900
49413
|
async start(controller) {
|
|
@@ -48908,8 +49421,8 @@ function filterStreamErrors(readable, onError) {
|
|
|
48908
49421
|
}
|
|
48909
49422
|
controller.enqueue(value);
|
|
48910
49423
|
}
|
|
48911
|
-
} catch (
|
|
48912
|
-
await onError({ error:
|
|
49424
|
+
} catch (error82) {
|
|
49425
|
+
await onError({ error: error82, controller });
|
|
48913
49426
|
}
|
|
48914
49427
|
},
|
|
48915
49428
|
cancel(reason) {
|
|
@@ -48917,6 +49430,10 @@ function filterStreamErrors(readable, onError) {
|
|
|
48917
49430
|
}
|
|
48918
49431
|
});
|
|
48919
49432
|
}
|
|
49433
|
+
function now() {
|
|
49434
|
+
var _a16, _b8;
|
|
49435
|
+
return (_b8 = (_a16 = globalThis == null ? undefined : globalThis.performance) == null ? undefined : _a16.now()) != null ? _b8 : Date.now();
|
|
49436
|
+
}
|
|
48920
49437
|
function runToolsTransformation({
|
|
48921
49438
|
tools,
|
|
48922
49439
|
generatorStream,
|
|
@@ -48925,7 +49442,8 @@ function runToolsTransformation({
|
|
|
48925
49442
|
system,
|
|
48926
49443
|
messages,
|
|
48927
49444
|
abortSignal,
|
|
48928
|
-
repairToolCall
|
|
49445
|
+
repairToolCall,
|
|
49446
|
+
experimental_context
|
|
48929
49447
|
}) {
|
|
48930
49448
|
let toolResultsStreamController = null;
|
|
48931
49449
|
const toolResultsStream = new ReadableStream({
|
|
@@ -48995,6 +49513,17 @@ function runToolsTransformation({
|
|
|
48995
49513
|
messages
|
|
48996
49514
|
});
|
|
48997
49515
|
controller.enqueue(toolCall);
|
|
49516
|
+
if (toolCall.invalid) {
|
|
49517
|
+
toolResultsStreamController.enqueue({
|
|
49518
|
+
type: "tool-error",
|
|
49519
|
+
toolCallId: toolCall.toolCallId,
|
|
49520
|
+
toolName: toolCall.toolName,
|
|
49521
|
+
input: toolCall.input,
|
|
49522
|
+
error: getErrorMessage2(toolCall.error),
|
|
49523
|
+
dynamic: true
|
|
49524
|
+
});
|
|
49525
|
+
break;
|
|
49526
|
+
}
|
|
48998
49527
|
const tool3 = tools[toolCall.toolName];
|
|
48999
49528
|
toolInputs.set(toolCall.toolCallId, toolCall.input);
|
|
49000
49529
|
if (tool3.onInputAvailable != null) {
|
|
@@ -49002,7 +49531,8 @@ function runToolsTransformation({
|
|
|
49002
49531
|
input: toolCall.input,
|
|
49003
49532
|
toolCallId: toolCall.toolCallId,
|
|
49004
49533
|
messages,
|
|
49005
|
-
abortSignal
|
|
49534
|
+
abortSignal,
|
|
49535
|
+
experimental_context
|
|
49006
49536
|
});
|
|
49007
49537
|
}
|
|
49008
49538
|
if (tool3.execute != null && toolCall.providerExecuted !== true) {
|
|
@@ -49019,7 +49549,7 @@ function runToolsTransformation({
|
|
|
49019
49549
|
}),
|
|
49020
49550
|
"ai.toolCall.name": toolCall.toolName,
|
|
49021
49551
|
"ai.toolCall.id": toolCall.toolCallId,
|
|
49022
|
-
"ai.toolCall.
|
|
49552
|
+
"ai.toolCall.args": {
|
|
49023
49553
|
output: () => JSON.stringify(toolCall.input)
|
|
49024
49554
|
}
|
|
49025
49555
|
}
|
|
@@ -49031,14 +49561,15 @@ function runToolsTransformation({
|
|
|
49031
49561
|
output = await tool3.execute(toolCall.input, {
|
|
49032
49562
|
toolCallId: toolCall.toolCallId,
|
|
49033
49563
|
messages,
|
|
49034
|
-
abortSignal
|
|
49564
|
+
abortSignal,
|
|
49565
|
+
experimental_context
|
|
49035
49566
|
});
|
|
49036
|
-
} catch (
|
|
49037
|
-
recordErrorOnSpan(span,
|
|
49567
|
+
} catch (error82) {
|
|
49568
|
+
recordErrorOnSpan(span, error82);
|
|
49038
49569
|
toolResultsStreamController.enqueue({
|
|
49039
49570
|
...toolCall,
|
|
49040
49571
|
type: "tool-error",
|
|
49041
|
-
error:
|
|
49572
|
+
error: error82
|
|
49042
49573
|
});
|
|
49043
49574
|
outstandingToolResults.delete(toolExecutionId);
|
|
49044
49575
|
attemptClose();
|
|
@@ -49055,7 +49586,7 @@ function runToolsTransformation({
|
|
|
49055
49586
|
span.setAttributes(selectTelemetryAttributes({
|
|
49056
49587
|
telemetry,
|
|
49057
49588
|
attributes: {
|
|
49058
|
-
"ai.toolCall.
|
|
49589
|
+
"ai.toolCall.result": {
|
|
49059
49590
|
output: () => JSON.stringify(output)
|
|
49060
49591
|
}
|
|
49061
49592
|
}
|
|
@@ -49064,8 +49595,8 @@ function runToolsTransformation({
|
|
|
49064
49595
|
}
|
|
49065
49596
|
});
|
|
49066
49597
|
}
|
|
49067
|
-
} catch (
|
|
49068
|
-
toolResultsStreamController.enqueue({ type: "error", error:
|
|
49598
|
+
} catch (error82) {
|
|
49599
|
+
toolResultsStreamController.enqueue({ type: "error", error: error82 });
|
|
49069
49600
|
}
|
|
49070
49601
|
break;
|
|
49071
49602
|
}
|
|
@@ -49149,12 +49680,13 @@ function streamText({
|
|
|
49149
49680
|
experimental_transform: transform3,
|
|
49150
49681
|
includeRawChunks = false,
|
|
49151
49682
|
onChunk,
|
|
49152
|
-
onError = ({ error:
|
|
49153
|
-
console.error(
|
|
49683
|
+
onError = ({ error: error82 }) => {
|
|
49684
|
+
console.error(error82);
|
|
49154
49685
|
},
|
|
49155
49686
|
onFinish,
|
|
49156
49687
|
onAbort,
|
|
49157
49688
|
onStepFinish,
|
|
49689
|
+
experimental_context,
|
|
49158
49690
|
_internal: {
|
|
49159
49691
|
now: now2 = now,
|
|
49160
49692
|
generateId: generateId3 = originalGenerateId2,
|
|
@@ -49189,7 +49721,8 @@ function streamText({
|
|
|
49189
49721
|
onStepFinish,
|
|
49190
49722
|
now: now2,
|
|
49191
49723
|
currentDate,
|
|
49192
|
-
generateId: generateId3
|
|
49724
|
+
generateId: generateId3,
|
|
49725
|
+
experimental_context
|
|
49193
49726
|
});
|
|
49194
49727
|
}
|
|
49195
49728
|
function createOutputTransformStream(output) {
|
|
@@ -49210,7 +49743,7 @@ function createOutputTransformStream(output) {
|
|
|
49210
49743
|
}) {
|
|
49211
49744
|
controller.enqueue({
|
|
49212
49745
|
part: {
|
|
49213
|
-
type: "text",
|
|
49746
|
+
type: "text-delta",
|
|
49214
49747
|
id: firstTextChunkId,
|
|
49215
49748
|
text: textChunk
|
|
49216
49749
|
},
|
|
@@ -49223,7 +49756,7 @@ function createOutputTransformStream(output) {
|
|
|
49223
49756
|
if (chunk.type === "finish-step" && textChunk.length > 0) {
|
|
49224
49757
|
publishTextChunk({ controller });
|
|
49225
49758
|
}
|
|
49226
|
-
if (chunk.type !== "text" && chunk.type !== "text-start" && chunk.type !== "text-end") {
|
|
49759
|
+
if (chunk.type !== "text-delta" && chunk.type !== "text-start" && chunk.type !== "text-end") {
|
|
49227
49760
|
controller.enqueue({ part: chunk, partialOutput: undefined });
|
|
49228
49761
|
return;
|
|
49229
49762
|
}
|
|
@@ -49285,13 +49818,15 @@ var DefaultStreamTextResult = class {
|
|
|
49285
49818
|
onError,
|
|
49286
49819
|
onFinish,
|
|
49287
49820
|
onAbort,
|
|
49288
|
-
onStepFinish
|
|
49821
|
+
onStepFinish,
|
|
49822
|
+
experimental_context
|
|
49289
49823
|
}) {
|
|
49290
49824
|
this._totalUsage = new DelayedPromise;
|
|
49291
49825
|
this._finishReason = new DelayedPromise;
|
|
49292
49826
|
this._steps = new DelayedPromise;
|
|
49293
49827
|
this.output = output;
|
|
49294
49828
|
this.includeRawChunks = includeRawChunks;
|
|
49829
|
+
this.tools = tools;
|
|
49295
49830
|
let stepFinish;
|
|
49296
49831
|
let recordedContent = [];
|
|
49297
49832
|
const recordedResponseMessages = [];
|
|
@@ -49308,7 +49843,7 @@ var DefaultStreamTextResult = class {
|
|
|
49308
49843
|
var _a16, _b8, _c;
|
|
49309
49844
|
controller.enqueue(chunk);
|
|
49310
49845
|
const { part } = chunk;
|
|
49311
|
-
if (part.type === "text" || part.type === "reasoning" || part.type === "source" || part.type === "tool-call" || part.type === "tool-result" || part.type === "tool-input-start" || part.type === "tool-input-delta" || part.type === "raw") {
|
|
49846
|
+
if (part.type === "text-delta" || part.type === "reasoning-delta" || part.type === "source" || part.type === "tool-call" || part.type === "tool-result" || part.type === "tool-input-start" || part.type === "tool-input-delta" || part.type === "raw") {
|
|
49312
49847
|
await (onChunk == null ? undefined : onChunk({ chunk: part }));
|
|
49313
49848
|
}
|
|
49314
49849
|
if (part.type === "error") {
|
|
@@ -49322,7 +49857,7 @@ var DefaultStreamTextResult = class {
|
|
|
49322
49857
|
};
|
|
49323
49858
|
recordedContent.push(activeTextContent[part.id]);
|
|
49324
49859
|
}
|
|
49325
|
-
if (part.type === "text") {
|
|
49860
|
+
if (part.type === "text-delta") {
|
|
49326
49861
|
const activeText = activeTextContent[part.id];
|
|
49327
49862
|
if (activeText == null) {
|
|
49328
49863
|
controller.enqueue({
|
|
@@ -49348,7 +49883,7 @@ var DefaultStreamTextResult = class {
|
|
|
49348
49883
|
};
|
|
49349
49884
|
recordedContent.push(activeReasoningContent[part.id]);
|
|
49350
49885
|
}
|
|
49351
|
-
if (part.type === "reasoning") {
|
|
49886
|
+
if (part.type === "reasoning-delta") {
|
|
49352
49887
|
const activeReasoning = activeReasoningContent[part.id];
|
|
49353
49888
|
if (activeReasoning == null) {
|
|
49354
49889
|
controller.enqueue({
|
|
@@ -49453,7 +49988,11 @@ var DefaultStreamTextResult = class {
|
|
|
49453
49988
|
files: finalStep.files,
|
|
49454
49989
|
sources: finalStep.sources,
|
|
49455
49990
|
toolCalls: finalStep.toolCalls,
|
|
49991
|
+
staticToolCalls: finalStep.staticToolCalls,
|
|
49992
|
+
dynamicToolCalls: finalStep.dynamicToolCalls,
|
|
49456
49993
|
toolResults: finalStep.toolResults,
|
|
49994
|
+
staticToolResults: finalStep.staticToolResults,
|
|
49995
|
+
dynamicToolResults: finalStep.dynamicToolResults,
|
|
49457
49996
|
request: finalStep.request,
|
|
49458
49997
|
response: finalStep.response,
|
|
49459
49998
|
warnings: finalStep.warnings,
|
|
@@ -49479,8 +50018,8 @@ var DefaultStreamTextResult = class {
|
|
|
49479
50018
|
"ai.usage.cachedInputTokens": totalUsage.cachedInputTokens
|
|
49480
50019
|
}
|
|
49481
50020
|
}));
|
|
49482
|
-
} catch (
|
|
49483
|
-
controller.error(
|
|
50021
|
+
} catch (error82) {
|
|
50022
|
+
controller.error(error82);
|
|
49484
50023
|
} finally {
|
|
49485
50024
|
rootSpan.end();
|
|
49486
50025
|
}
|
|
@@ -49490,13 +50029,13 @@ var DefaultStreamTextResult = class {
|
|
|
49490
50029
|
this.addStream = stitchableStream.addStream;
|
|
49491
50030
|
this.closeStream = stitchableStream.close;
|
|
49492
50031
|
let stream = stitchableStream.stream;
|
|
49493
|
-
stream = filterStreamErrors(stream, ({ error:
|
|
49494
|
-
if (isAbortError(
|
|
50032
|
+
stream = filterStreamErrors(stream, ({ error: error82, controller }) => {
|
|
50033
|
+
if (isAbortError(error82) && (abortSignal == null ? undefined : abortSignal.aborted)) {
|
|
49495
50034
|
onAbort == null || onAbort({ steps: recordedSteps });
|
|
49496
50035
|
controller.enqueue({ type: "abort" });
|
|
49497
50036
|
controller.close();
|
|
49498
50037
|
} else {
|
|
49499
|
-
controller.error(
|
|
50038
|
+
controller.error(error82);
|
|
49500
50039
|
}
|
|
49501
50040
|
});
|
|
49502
50041
|
stream = stream.pipeThrough(new TransformStream({
|
|
@@ -49514,7 +50053,8 @@ var DefaultStreamTextResult = class {
|
|
|
49514
50053
|
}
|
|
49515
50054
|
this.baseStream = stream.pipeThrough(createOutputTransformStream(output)).pipeThrough(eventProcessor);
|
|
49516
50055
|
const { maxRetries, retry } = prepareRetries({
|
|
49517
|
-
maxRetries: maxRetriesArg
|
|
50056
|
+
maxRetries: maxRetriesArg,
|
|
50057
|
+
abortSignal
|
|
49518
50058
|
});
|
|
49519
50059
|
const tracer = getTracer(telemetry);
|
|
49520
50060
|
const callSettings = prepareCallSettings(settings);
|
|
@@ -49641,7 +50181,8 @@ var DefaultStreamTextResult = class {
|
|
|
49641
50181
|
system,
|
|
49642
50182
|
messages: stepInputMessages,
|
|
49643
50183
|
repairToolCall,
|
|
49644
|
-
abortSignal
|
|
50184
|
+
abortSignal,
|
|
50185
|
+
experimental_context
|
|
49645
50186
|
});
|
|
49646
50187
|
const stepRequest = request != null ? request : {};
|
|
49647
50188
|
const stepToolCalls = [];
|
|
@@ -49694,7 +50235,7 @@ var DefaultStreamTextResult = class {
|
|
|
49694
50235
|
case "text-delta": {
|
|
49695
50236
|
if (chunk.delta.length > 0) {
|
|
49696
50237
|
controller.enqueue({
|
|
49697
|
-
type: "text",
|
|
50238
|
+
type: "text-delta",
|
|
49698
50239
|
id: chunk.id,
|
|
49699
50240
|
text: chunk.delta,
|
|
49700
50241
|
providerMetadata: chunk.providerMetadata
|
|
@@ -49710,7 +50251,7 @@ var DefaultStreamTextResult = class {
|
|
|
49710
50251
|
}
|
|
49711
50252
|
case "reasoning-delta": {
|
|
49712
50253
|
controller.enqueue({
|
|
49713
|
-
type: "reasoning",
|
|
50254
|
+
type: "reasoning-delta",
|
|
49714
50255
|
id: chunk.id,
|
|
49715
50256
|
text: chunk.delta,
|
|
49716
50257
|
providerMetadata: chunk.providerMetadata
|
|
@@ -49767,10 +50308,14 @@ var DefaultStreamTextResult = class {
|
|
|
49767
50308
|
await tool3.onInputStart({
|
|
49768
50309
|
toolCallId: chunk.id,
|
|
49769
50310
|
messages: stepInputMessages,
|
|
49770
|
-
abortSignal
|
|
50311
|
+
abortSignal,
|
|
50312
|
+
experimental_context
|
|
49771
50313
|
});
|
|
49772
50314
|
}
|
|
49773
|
-
controller.enqueue(
|
|
50315
|
+
controller.enqueue({
|
|
50316
|
+
...chunk,
|
|
50317
|
+
dynamic: (tool3 == null ? undefined : tool3.type) === "dynamic"
|
|
50318
|
+
});
|
|
49774
50319
|
break;
|
|
49775
50320
|
}
|
|
49776
50321
|
case "tool-input-end": {
|
|
@@ -49786,7 +50331,8 @@ var DefaultStreamTextResult = class {
|
|
|
49786
50331
|
inputTextDelta: chunk.delta,
|
|
49787
50332
|
toolCallId: chunk.id,
|
|
49788
50333
|
messages: stepInputMessages,
|
|
49789
|
-
abortSignal
|
|
50334
|
+
abortSignal,
|
|
50335
|
+
experimental_context
|
|
49790
50336
|
});
|
|
49791
50337
|
}
|
|
49792
50338
|
controller.enqueue(chunk);
|
|
@@ -49838,7 +50384,7 @@ var DefaultStreamTextResult = class {
|
|
|
49838
50384
|
"gen_ai.usage.output_tokens": stepUsage.outputTokens
|
|
49839
50385
|
}
|
|
49840
50386
|
}));
|
|
49841
|
-
} catch (
|
|
50387
|
+
} catch (error82) {} finally {
|
|
49842
50388
|
doStreamSpan.end();
|
|
49843
50389
|
}
|
|
49844
50390
|
controller.enqueue({
|
|
@@ -49869,10 +50415,10 @@ var DefaultStreamTextResult = class {
|
|
|
49869
50415
|
responseMessages,
|
|
49870
50416
|
usage: combinedUsage
|
|
49871
50417
|
});
|
|
49872
|
-
} catch (
|
|
50418
|
+
} catch (error82) {
|
|
49873
50419
|
controller.enqueue({
|
|
49874
50420
|
type: "error",
|
|
49875
|
-
error:
|
|
50421
|
+
error: error82
|
|
49876
50422
|
});
|
|
49877
50423
|
self2.closeStream();
|
|
49878
50424
|
}
|
|
@@ -49897,10 +50443,10 @@ var DefaultStreamTextResult = class {
|
|
|
49897
50443
|
}
|
|
49898
50444
|
});
|
|
49899
50445
|
}
|
|
49900
|
-
}).catch((
|
|
50446
|
+
}).catch((error82) => {
|
|
49901
50447
|
self2.addStream(new ReadableStream({
|
|
49902
50448
|
start(controller) {
|
|
49903
|
-
controller.enqueue({ type: "error", error:
|
|
50449
|
+
controller.enqueue({ type: "error", error: error82 });
|
|
49904
50450
|
controller.close();
|
|
49905
50451
|
}
|
|
49906
50452
|
}));
|
|
@@ -49940,9 +50486,21 @@ var DefaultStreamTextResult = class {
|
|
|
49940
50486
|
get toolCalls() {
|
|
49941
50487
|
return this.finalStep.then((step) => step.toolCalls);
|
|
49942
50488
|
}
|
|
50489
|
+
get staticToolCalls() {
|
|
50490
|
+
return this.finalStep.then((step) => step.staticToolCalls);
|
|
50491
|
+
}
|
|
50492
|
+
get dynamicToolCalls() {
|
|
50493
|
+
return this.finalStep.then((step) => step.dynamicToolCalls);
|
|
50494
|
+
}
|
|
49943
50495
|
get toolResults() {
|
|
49944
50496
|
return this.finalStep.then((step) => step.toolResults);
|
|
49945
50497
|
}
|
|
50498
|
+
get staticToolResults() {
|
|
50499
|
+
return this.finalStep.then((step) => step.staticToolResults);
|
|
50500
|
+
}
|
|
50501
|
+
get dynamicToolResults() {
|
|
50502
|
+
return this.finalStep.then((step) => step.dynamicToolResults);
|
|
50503
|
+
}
|
|
49946
50504
|
get usage() {
|
|
49947
50505
|
return this.finalStep.then((step) => step.usage);
|
|
49948
50506
|
}
|
|
@@ -49966,7 +50524,7 @@ var DefaultStreamTextResult = class {
|
|
|
49966
50524
|
get textStream() {
|
|
49967
50525
|
return createAsyncIterableStream(this.teeStream().pipeThrough(new TransformStream({
|
|
49968
50526
|
transform({ part }, controller) {
|
|
49969
|
-
if (part.type === "text") {
|
|
50527
|
+
if (part.type === "text-delta") {
|
|
49970
50528
|
controller.enqueue(part.text);
|
|
49971
50529
|
}
|
|
49972
50530
|
}
|
|
@@ -49986,8 +50544,8 @@ var DefaultStreamTextResult = class {
|
|
|
49986
50544
|
stream: this.fullStream,
|
|
49987
50545
|
onError: options == null ? undefined : options.onError
|
|
49988
50546
|
});
|
|
49989
|
-
} catch (
|
|
49990
|
-
(_a16 = options == null ? undefined : options.onError) == null || _a16.call(options,
|
|
50547
|
+
} catch (error82) {
|
|
50548
|
+
(_a16 = options == null ? undefined : options.onError) == null || _a16.call(options, error82);
|
|
49991
50549
|
}
|
|
49992
50550
|
}
|
|
49993
50551
|
get experimental_partialOutputStream() {
|
|
@@ -50017,6 +50575,13 @@ var DefaultStreamTextResult = class {
|
|
|
50017
50575
|
originalMessages,
|
|
50018
50576
|
responseMessageId: generateMessageId
|
|
50019
50577
|
}) : undefined;
|
|
50578
|
+
const toolNamesByCallId = {};
|
|
50579
|
+
const isDynamic = (toolCallId) => {
|
|
50580
|
+
var _a16, _b8;
|
|
50581
|
+
const toolName = toolNamesByCallId[toolCallId];
|
|
50582
|
+
const dynamic = ((_b8 = (_a16 = this.tools) == null ? undefined : _a16[toolName]) == null ? undefined : _b8.type) === "dynamic";
|
|
50583
|
+
return dynamic ? true : undefined;
|
|
50584
|
+
};
|
|
50020
50585
|
const baseStream = this.fullStream.pipeThrough(new TransformStream({
|
|
50021
50586
|
transform: async (part, controller) => {
|
|
50022
50587
|
const messageMetadataValue = messageMetadata == null ? undefined : messageMetadata({ part });
|
|
@@ -50030,7 +50595,7 @@ var DefaultStreamTextResult = class {
|
|
|
50030
50595
|
});
|
|
50031
50596
|
break;
|
|
50032
50597
|
}
|
|
50033
|
-
case "text": {
|
|
50598
|
+
case "text-delta": {
|
|
50034
50599
|
controller.enqueue({
|
|
50035
50600
|
type: "text-delta",
|
|
50036
50601
|
id: part.id,
|
|
@@ -50055,7 +50620,7 @@ var DefaultStreamTextResult = class {
|
|
|
50055
50620
|
});
|
|
50056
50621
|
break;
|
|
50057
50622
|
}
|
|
50058
|
-
case "reasoning": {
|
|
50623
|
+
case "reasoning-delta": {
|
|
50059
50624
|
if (sendReasoning) {
|
|
50060
50625
|
controller.enqueue({
|
|
50061
50626
|
type: "reasoning-delta",
|
|
@@ -50105,11 +50670,14 @@ var DefaultStreamTextResult = class {
|
|
|
50105
50670
|
break;
|
|
50106
50671
|
}
|
|
50107
50672
|
case "tool-input-start": {
|
|
50673
|
+
toolNamesByCallId[part.id] = part.toolName;
|
|
50674
|
+
const dynamic = isDynamic(part.id);
|
|
50108
50675
|
controller.enqueue({
|
|
50109
50676
|
type: "tool-input-start",
|
|
50110
50677
|
toolCallId: part.id,
|
|
50111
50678
|
toolName: part.toolName,
|
|
50112
|
-
providerExecuted: part.providerExecuted
|
|
50679
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
50680
|
+
...dynamic != null ? { dynamic } : {}
|
|
50113
50681
|
});
|
|
50114
50682
|
break;
|
|
50115
50683
|
}
|
|
@@ -50122,31 +50690,51 @@ var DefaultStreamTextResult = class {
|
|
|
50122
50690
|
break;
|
|
50123
50691
|
}
|
|
50124
50692
|
case "tool-call": {
|
|
50125
|
-
|
|
50126
|
-
|
|
50127
|
-
|
|
50128
|
-
|
|
50129
|
-
|
|
50130
|
-
|
|
50131
|
-
|
|
50132
|
-
|
|
50693
|
+
toolNamesByCallId[part.toolCallId] = part.toolName;
|
|
50694
|
+
const dynamic = isDynamic(part.toolCallId);
|
|
50695
|
+
if (part.invalid) {
|
|
50696
|
+
controller.enqueue({
|
|
50697
|
+
type: "tool-input-error",
|
|
50698
|
+
toolCallId: part.toolCallId,
|
|
50699
|
+
toolName: part.toolName,
|
|
50700
|
+
input: part.input,
|
|
50701
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
50702
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
50703
|
+
...dynamic != null ? { dynamic } : {},
|
|
50704
|
+
errorText: onError(part.error)
|
|
50705
|
+
});
|
|
50706
|
+
} else {
|
|
50707
|
+
controller.enqueue({
|
|
50708
|
+
type: "tool-input-available",
|
|
50709
|
+
toolCallId: part.toolCallId,
|
|
50710
|
+
toolName: part.toolName,
|
|
50711
|
+
input: part.input,
|
|
50712
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
50713
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
50714
|
+
...dynamic != null ? { dynamic } : {}
|
|
50715
|
+
});
|
|
50716
|
+
}
|
|
50133
50717
|
break;
|
|
50134
50718
|
}
|
|
50135
50719
|
case "tool-result": {
|
|
50720
|
+
const dynamic = isDynamic(part.toolCallId);
|
|
50136
50721
|
controller.enqueue({
|
|
50137
50722
|
type: "tool-output-available",
|
|
50138
50723
|
toolCallId: part.toolCallId,
|
|
50139
50724
|
output: part.output,
|
|
50140
|
-
providerExecuted: part.providerExecuted
|
|
50725
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
50726
|
+
...dynamic != null ? { dynamic } : {}
|
|
50141
50727
|
});
|
|
50142
50728
|
break;
|
|
50143
50729
|
}
|
|
50144
50730
|
case "tool-error": {
|
|
50731
|
+
const dynamic = isDynamic(part.toolCallId);
|
|
50145
50732
|
controller.enqueue({
|
|
50146
50733
|
type: "tool-output-error",
|
|
50147
50734
|
toolCallId: part.toolCallId,
|
|
50148
50735
|
errorText: onError(part.error),
|
|
50149
|
-
providerExecuted: part.providerExecuted
|
|
50736
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
50737
|
+
...dynamic != null ? { dynamic } : {}
|
|
50150
50738
|
});
|
|
50151
50739
|
break;
|
|
50152
50740
|
}
|
|
@@ -50363,32 +50951,32 @@ var marker152 = `vercel.ai.error.${name15}`;
|
|
|
50363
50951
|
var symbol152 = Symbol.for(marker152);
|
|
50364
50952
|
var _a152;
|
|
50365
50953
|
_a152 = symbol152;
|
|
50366
|
-
var ClientOrServerImplementationSchema = exports_external2.
|
|
50954
|
+
var ClientOrServerImplementationSchema = exports_external2.looseObject({
|
|
50367
50955
|
name: exports_external2.string(),
|
|
50368
50956
|
version: exports_external2.string()
|
|
50369
|
-
})
|
|
50370
|
-
var BaseParamsSchema = exports_external2.
|
|
50371
|
-
_meta: exports_external2.optional(exports_external2.object({}).
|
|
50372
|
-
})
|
|
50957
|
+
});
|
|
50958
|
+
var BaseParamsSchema = exports_external2.looseObject({
|
|
50959
|
+
_meta: exports_external2.optional(exports_external2.object({}).loose())
|
|
50960
|
+
});
|
|
50373
50961
|
var ResultSchema = BaseParamsSchema;
|
|
50374
50962
|
var RequestSchema = exports_external2.object({
|
|
50375
50963
|
method: exports_external2.string(),
|
|
50376
50964
|
params: exports_external2.optional(BaseParamsSchema)
|
|
50377
50965
|
});
|
|
50378
|
-
var ServerCapabilitiesSchema = exports_external2.
|
|
50379
|
-
experimental: exports_external2.optional(exports_external2.object({}).
|
|
50380
|
-
logging: exports_external2.optional(exports_external2.object({}).
|
|
50381
|
-
prompts: exports_external2.optional(exports_external2.
|
|
50966
|
+
var ServerCapabilitiesSchema = exports_external2.looseObject({
|
|
50967
|
+
experimental: exports_external2.optional(exports_external2.object({}).loose()),
|
|
50968
|
+
logging: exports_external2.optional(exports_external2.object({}).loose()),
|
|
50969
|
+
prompts: exports_external2.optional(exports_external2.looseObject({
|
|
50382
50970
|
listChanged: exports_external2.optional(exports_external2.boolean())
|
|
50383
|
-
})
|
|
50384
|
-
resources: exports_external2.optional(exports_external2.
|
|
50971
|
+
})),
|
|
50972
|
+
resources: exports_external2.optional(exports_external2.looseObject({
|
|
50385
50973
|
subscribe: exports_external2.optional(exports_external2.boolean()),
|
|
50386
50974
|
listChanged: exports_external2.optional(exports_external2.boolean())
|
|
50387
|
-
})
|
|
50388
|
-
tools: exports_external2.optional(exports_external2.
|
|
50975
|
+
})),
|
|
50976
|
+
tools: exports_external2.optional(exports_external2.looseObject({
|
|
50389
50977
|
listChanged: exports_external2.optional(exports_external2.boolean())
|
|
50390
|
-
})
|
|
50391
|
-
})
|
|
50978
|
+
}))
|
|
50979
|
+
});
|
|
50392
50980
|
var InitializeResultSchema = ResultSchema.extend({
|
|
50393
50981
|
protocolVersion: exports_external2.string(),
|
|
50394
50982
|
capabilities: ServerCapabilitiesSchema,
|
|
@@ -50403,35 +50991,35 @@ var ToolSchema = exports_external2.object({
|
|
|
50403
50991
|
description: exports_external2.optional(exports_external2.string()),
|
|
50404
50992
|
inputSchema: exports_external2.object({
|
|
50405
50993
|
type: exports_external2.literal("object"),
|
|
50406
|
-
properties: exports_external2.optional(exports_external2.object({}).
|
|
50407
|
-
}).
|
|
50408
|
-
}).
|
|
50994
|
+
properties: exports_external2.optional(exports_external2.object({}).loose())
|
|
50995
|
+
}).loose()
|
|
50996
|
+
}).loose();
|
|
50409
50997
|
var ListToolsResultSchema = PaginatedResultSchema.extend({
|
|
50410
50998
|
tools: exports_external2.array(ToolSchema)
|
|
50411
50999
|
});
|
|
50412
51000
|
var TextContentSchema = exports_external2.object({
|
|
50413
51001
|
type: exports_external2.literal("text"),
|
|
50414
51002
|
text: exports_external2.string()
|
|
50415
|
-
}).
|
|
51003
|
+
}).loose();
|
|
50416
51004
|
var ImageContentSchema = exports_external2.object({
|
|
50417
51005
|
type: exports_external2.literal("image"),
|
|
50418
|
-
data: exports_external2.
|
|
51006
|
+
data: exports_external2.base64(),
|
|
50419
51007
|
mimeType: exports_external2.string()
|
|
50420
|
-
}).
|
|
51008
|
+
}).loose();
|
|
50421
51009
|
var ResourceContentsSchema = exports_external2.object({
|
|
50422
51010
|
uri: exports_external2.string(),
|
|
50423
51011
|
mimeType: exports_external2.optional(exports_external2.string())
|
|
50424
|
-
}).
|
|
51012
|
+
}).loose();
|
|
50425
51013
|
var TextResourceContentsSchema = ResourceContentsSchema.extend({
|
|
50426
51014
|
text: exports_external2.string()
|
|
50427
51015
|
});
|
|
50428
51016
|
var BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
|
50429
|
-
blob: exports_external2.
|
|
51017
|
+
blob: exports_external2.base64()
|
|
50430
51018
|
});
|
|
50431
51019
|
var EmbeddedResourceSchema = exports_external2.object({
|
|
50432
51020
|
type: exports_external2.literal("resource"),
|
|
50433
51021
|
resource: exports_external2.union([TextResourceContentsSchema, BlobResourceContentsSchema])
|
|
50434
|
-
}).
|
|
51022
|
+
}).loose();
|
|
50435
51023
|
var CallToolResultSchema = ResultSchema.extend({
|
|
50436
51024
|
content: exports_external2.array(exports_external2.union([TextContentSchema, ImageContentSchema, EmbeddedResourceSchema])),
|
|
50437
51025
|
isError: exports_external2.boolean().default(false).optional()
|
|
@@ -50503,8 +51091,8 @@ function zodSchemaToParameters(schema) {
|
|
|
50503
51091
|
}
|
|
50504
51092
|
return parameters;
|
|
50505
51093
|
}
|
|
50506
|
-
function toToolInfoV1(
|
|
50507
|
-
const { parameters: zodSchema2, ...rest } =
|
|
51094
|
+
function toToolInfoV1(tool2) {
|
|
51095
|
+
const { parameters: zodSchema2, ...rest } = tool2;
|
|
50508
51096
|
const v1Parameters = zodSchemaToParameters(zodSchema2);
|
|
50509
51097
|
const examples = zodSchema2.meta()?.examples;
|
|
50510
51098
|
const v1Tool = {
|
|
@@ -50568,7 +51156,7 @@ function parseNestedParameters(content, parameterPrefix, childrenParams) {
|
|
|
50568
51156
|
function parseAssistantMessage(assistantMessage, tools, toolNamePrefix) {
|
|
50569
51157
|
const parameterPrefix = `${toolNamePrefix}parameter_`;
|
|
50570
51158
|
const results = [];
|
|
50571
|
-
const toolTags = tools.map((
|
|
51159
|
+
const toolTags = tools.map((tool2) => `${toolNamePrefix}${tool2.name}`);
|
|
50572
51160
|
const toolPattern = toolTags.join("|");
|
|
50573
51161
|
let remainingMessage = assistantMessage;
|
|
50574
51162
|
let match;
|
|
@@ -50586,11 +51174,11 @@ function parseAssistantMessage(assistantMessage, tools, toolNamePrefix) {
|
|
|
50586
51174
|
}
|
|
50587
51175
|
const tagName = match[1];
|
|
50588
51176
|
const toolName = tagName.replace(toolNamePrefix, "");
|
|
50589
|
-
const
|
|
51177
|
+
const tool2 = tools.find((t) => t.name === toolName);
|
|
50590
51178
|
const fullTagContent = match[0];
|
|
50591
|
-
if (
|
|
51179
|
+
if (tool2) {
|
|
50592
51180
|
const params = {};
|
|
50593
|
-
for (const param of
|
|
51181
|
+
for (const param of tool2.parameters) {
|
|
50594
51182
|
const paramName = `${parameterPrefix}${param.name}`;
|
|
50595
51183
|
const escapedParamName = paramName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
50596
51184
|
const paramRegex = new RegExp(`<${escapedParamName}>([\\s\\S]*?)<\\/${escapedParamName}>`, "gs");
|
|
@@ -50671,28 +51259,28 @@ var renderParameterValue = (key, value, parameterPrefix) => {
|
|
|
50671
51259
|
${inner}
|
|
50672
51260
|
</${parameterPrefix}${key}>`;
|
|
50673
51261
|
};
|
|
50674
|
-
var toolInfoPrompt = (
|
|
50675
|
-
## ${toolNamePrefix}${
|
|
51262
|
+
var toolInfoPrompt = (tool2, toolNamePrefix, parameterPrefix) => `
|
|
51263
|
+
## ${toolNamePrefix}${tool2.name}
|
|
50676
51264
|
|
|
50677
|
-
Description: ${
|
|
51265
|
+
Description: ${tool2.description}
|
|
50678
51266
|
|
|
50679
51267
|
Parameters:
|
|
50680
|
-
${
|
|
51268
|
+
${tool2.parameters.map((param) => `- ${parameterPrefix}${param.name}: (${param.required ? "required" : "optional"})${param.allowMultiple ? " (multiple allowed)" : ""} ${param.description}`).join(`
|
|
50681
51269
|
`)}
|
|
50682
51270
|
|
|
50683
51271
|
Usage:
|
|
50684
|
-
<${toolNamePrefix}${
|
|
50685
|
-
${
|
|
51272
|
+
<${toolNamePrefix}${tool2.name}>
|
|
51273
|
+
${tool2.parameters.map((param) => param.allowMultiple ? `<${parameterPrefix}${param.name}>${param.usageValue}</${parameterPrefix}${param.name}>
|
|
50686
51274
|
<${parameterPrefix}${param.name}>${param.usageValue}</${parameterPrefix}${param.name}>` : `<${parameterPrefix}${param.name}>${param.usageValue}</${parameterPrefix}${param.name}>`).join(`
|
|
50687
51275
|
`)}
|
|
50688
|
-
</${toolNamePrefix}${
|
|
50689
|
-
var toolInfoExamplesPrompt = (
|
|
51276
|
+
</${toolNamePrefix}${tool2.name}>`;
|
|
51277
|
+
var toolInfoExamplesPrompt = (tool2, example, toolNamePrefix, parameterPrefix) => `
|
|
50690
51278
|
## Example: ${example.description}
|
|
50691
51279
|
|
|
50692
|
-
<${toolNamePrefix}${
|
|
51280
|
+
<${toolNamePrefix}${tool2.name}>
|
|
50693
51281
|
${Object.entries(example.input).map(([name17, value]) => renderParameterValue(name17, value, parameterPrefix)).join(`
|
|
50694
51282
|
`)}
|
|
50695
|
-
</${toolNamePrefix}${
|
|
51283
|
+
</${toolNamePrefix}${tool2.name}>
|
|
50696
51284
|
`;
|
|
50697
51285
|
var toolUsePrompt = (useNativeTool, tools, toolNamePrefix) => {
|
|
50698
51286
|
if (useNativeTool) {
|
|
@@ -50768,14 +51356,14 @@ Always adhere to this format, ensuring every opening tag has a matching closing
|
|
|
50768
51356
|
NEVER surround tool use with triple backticks (\`\`\`).
|
|
50769
51357
|
|
|
50770
51358
|
# Tools
|
|
50771
|
-
${v1Tools.map((
|
|
51359
|
+
${v1Tools.map((tool2) => toolInfoPrompt(tool2, toolNamePrefix, parameterPrefix)).join(`
|
|
50772
51360
|
`)}
|
|
50773
51361
|
|
|
50774
51362
|
# Tool Use Examples
|
|
50775
|
-
${v1Tools.map((
|
|
51363
|
+
${v1Tools.map((tool2) => {
|
|
50776
51364
|
let promp = "";
|
|
50777
|
-
for (const example of
|
|
50778
|
-
promp += toolInfoExamplesPrompt(
|
|
51365
|
+
for (const example of tool2.examples ?? []) {
|
|
51366
|
+
promp += toolInfoExamplesPrompt(tool2, example, toolNamePrefix, parameterPrefix);
|
|
50779
51367
|
}
|
|
50780
51368
|
return promp;
|
|
50781
51369
|
}).join("")}
|
|
@@ -50858,7 +51446,7 @@ The following additional commands are provided by the user, and should be follow
|
|
|
50858
51446
|
${joined}`;
|
|
50859
51447
|
};
|
|
50860
51448
|
var responsePrompts = {
|
|
50861
|
-
errorInvokeTool: (
|
|
51449
|
+
errorInvokeTool: (tool2, error82) => `An error occurred while invoking the tool "${tool2}": ${error82}`,
|
|
50862
51450
|
requireUseTool: `Error: No tool use detected. You MUST use a tool before proceeding.
|
|
50863
51451
|
e.g. <tool_tool_name>tool_name</tool_tool_name>
|
|
50864
51452
|
|
|
@@ -50868,19 +51456,19 @@ Avoid unnecessary escape characters or special characters.
|
|
|
50868
51456
|
`,
|
|
50869
51457
|
requireUseToolNative: `Error: No tool use detected. You MUST use a tool before proceeding.
|
|
50870
51458
|
`,
|
|
50871
|
-
toolResults: (
|
|
51459
|
+
toolResults: (tool2, result) => {
|
|
50872
51460
|
if (typeof result === "string") {
|
|
50873
51461
|
return [
|
|
50874
51462
|
{
|
|
50875
51463
|
type: "text",
|
|
50876
|
-
text: `<tool_response name=${
|
|
51464
|
+
text: `<tool_response name=${tool2}>${result}</tool_response>`
|
|
50877
51465
|
}
|
|
50878
51466
|
];
|
|
50879
51467
|
}
|
|
50880
51468
|
return [
|
|
50881
51469
|
{
|
|
50882
51470
|
type: "text",
|
|
50883
|
-
text: `<tool_response name=${
|
|
51471
|
+
text: `<tool_response name=${tool2}>`
|
|
50884
51472
|
},
|
|
50885
51473
|
...result,
|
|
50886
51474
|
{
|
|
@@ -50917,8 +51505,8 @@ class AgentBase {
|
|
|
50917
51505
|
${agents}`;
|
|
50918
51506
|
}
|
|
50919
51507
|
const handlers = {};
|
|
50920
|
-
for (const
|
|
50921
|
-
handlers[
|
|
51508
|
+
for (const tool2 of config3.tools) {
|
|
51509
|
+
handlers[tool2.name] = tool2;
|
|
50922
51510
|
}
|
|
50923
51511
|
const policies = [];
|
|
50924
51512
|
for (const policy of config3.policies) {
|
|
@@ -50930,8 +51518,8 @@ ${agents}`;
|
|
|
50930
51518
|
${instance.prompt}`;
|
|
50931
51519
|
}
|
|
50932
51520
|
if (instance.tools) {
|
|
50933
|
-
for (const
|
|
50934
|
-
handlers[
|
|
51521
|
+
for (const tool2 of instance.tools) {
|
|
51522
|
+
handlers[tool2.name] = tool2;
|
|
50935
51523
|
}
|
|
50936
51524
|
}
|
|
50937
51525
|
}
|
|
@@ -50945,13 +51533,13 @@ ${instance.prompt}`;
|
|
|
50945
51533
|
});
|
|
50946
51534
|
if (this.config.toolFormat === "native") {
|
|
50947
51535
|
const tools = {};
|
|
50948
|
-
for (const
|
|
50949
|
-
const toolName = import_lodash.camelCase(
|
|
51536
|
+
for (const tool2 of Object.values(this.handlers)) {
|
|
51537
|
+
const toolName = import_lodash.camelCase(tool2.name);
|
|
50950
51538
|
tools[toolName] = {
|
|
50951
|
-
description:
|
|
50952
|
-
inputSchema: jsonSchema(toJSONSchema(
|
|
51539
|
+
description: tool2.description,
|
|
51540
|
+
inputSchema: jsonSchema(toJSONSchema(tool2.parameters))
|
|
50953
51541
|
};
|
|
50954
|
-
this.handlers[toolName] =
|
|
51542
|
+
this.handlers[toolName] = tool2;
|
|
50955
51543
|
}
|
|
50956
51544
|
this.#toolSet = tools;
|
|
50957
51545
|
} else {
|
|
@@ -51071,10 +51659,10 @@ Request timeout after ${requestTimeoutSeconds} seconds. Canceling current reques
|
|
|
51071
51659
|
onChunk: async ({ chunk }) => {
|
|
51072
51660
|
resetTimeout();
|
|
51073
51661
|
switch (chunk.type) {
|
|
51074
|
-
case "text":
|
|
51662
|
+
case "text-delta":
|
|
51075
51663
|
await this.#callback({ kind: "Text" /* Text */, agent: this, newText: chunk.text });
|
|
51076
51664
|
break;
|
|
51077
|
-
case "reasoning":
|
|
51665
|
+
case "reasoning-delta":
|
|
51078
51666
|
await this.#callback({ kind: "Reasoning" /* Reasoning */, agent: this, newText: chunk.text });
|
|
51079
51667
|
break;
|
|
51080
51668
|
case "tool-call":
|
|
@@ -51082,8 +51670,8 @@ Request timeout after ${requestTimeoutSeconds} seconds. Canceling current reques
|
|
|
51082
51670
|
}
|
|
51083
51671
|
},
|
|
51084
51672
|
onFinish: this.config.usageMeter.onFinishHandler(this.ai),
|
|
51085
|
-
onError: async (
|
|
51086
|
-
console.error("Error in stream:",
|
|
51673
|
+
onError: async (error82) => {
|
|
51674
|
+
console.error("Error in stream:", error82);
|
|
51087
51675
|
},
|
|
51088
51676
|
abortSignal: requestAbortController.signal
|
|
51089
51677
|
};
|
|
@@ -51092,8 +51680,8 @@ Request timeout after ${requestTimeoutSeconds} seconds. Canceling current reques
|
|
|
51092
51680
|
}
|
|
51093
51681
|
const stream = streamText(streamTextOptions);
|
|
51094
51682
|
await stream.consumeStream({
|
|
51095
|
-
onError: (
|
|
51096
|
-
console.error("Error in stream:",
|
|
51683
|
+
onError: (error82) => {
|
|
51684
|
+
console.error("Error in stream:", error82);
|
|
51097
51685
|
}
|
|
51098
51686
|
});
|
|
51099
51687
|
const resp = await stream.response;
|
|
@@ -51102,14 +51690,14 @@ Request timeout after ${requestTimeoutSeconds} seconds. Canceling current reques
|
|
|
51102
51690
|
clearTimeout(timeout);
|
|
51103
51691
|
timeout = undefined;
|
|
51104
51692
|
}
|
|
51105
|
-
} catch (
|
|
51106
|
-
if (
|
|
51693
|
+
} catch (error82) {
|
|
51694
|
+
if (error82 instanceof Error && error82.name === "AbortError") {
|
|
51107
51695
|
if (this.#aborted) {
|
|
51108
51696
|
break;
|
|
51109
51697
|
}
|
|
51110
51698
|
console.debug(`Request attempt ${i + 1} timed out, will retry`);
|
|
51111
51699
|
} else {
|
|
51112
|
-
console.error("Error in stream:",
|
|
51700
|
+
console.error("Error in stream:", error82);
|
|
51113
51701
|
}
|
|
51114
51702
|
} finally {
|
|
51115
51703
|
if (timeout) {
|
|
@@ -51306,7 +51894,7 @@ Retrying request ${i + 2} of ${retryCount}`);
|
|
|
51306
51894
|
}
|
|
51307
51895
|
};
|
|
51308
51896
|
}
|
|
51309
|
-
const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool, response: response2 }) => responsePrompts.toolResults(
|
|
51897
|
+
const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool: tool2, response: response2 }) => responsePrompts.toolResults(tool2, response2));
|
|
51310
51898
|
return {
|
|
51311
51899
|
type: "reply",
|
|
51312
51900
|
message: {
|
|
@@ -51338,10 +51926,10 @@ Retrying request ${i + 2} of ${retryCount}`);
|
|
|
51338
51926
|
return resp;
|
|
51339
51927
|
}
|
|
51340
51928
|
return await handler14(this.config.provider, args);
|
|
51341
|
-
} catch (
|
|
51929
|
+
} catch (error82) {
|
|
51342
51930
|
return {
|
|
51343
51931
|
type: "Error" /* Error */,
|
|
51344
|
-
message: responsePrompts.errorInvokeTool(name17,
|
|
51932
|
+
message: responsePrompts.errorInvokeTool(name17, error82),
|
|
51345
51933
|
canRetry: false
|
|
51346
51934
|
};
|
|
51347
51935
|
}
|
|
@@ -51560,8 +52148,8 @@ class CodeFixerAgent extends AgentBase {
|
|
|
51560
52148
|
message: responsePrompts.commandResult(checkCommand, exitCode, stdout, stderr)
|
|
51561
52149
|
};
|
|
51562
52150
|
}
|
|
51563
|
-
} catch (
|
|
51564
|
-
console.warn(`Failed to check code using command: ${checkCommand}`,
|
|
52151
|
+
} catch (error82) {
|
|
52152
|
+
console.warn(`Failed to check code using command: ${checkCommand}`, error82);
|
|
51565
52153
|
}
|
|
51566
52154
|
}
|
|
51567
52155
|
const test = this.config.scripts?.test;
|
|
@@ -51575,8 +52163,8 @@ class CodeFixerAgent extends AgentBase {
|
|
|
51575
52163
|
message: responsePrompts.commandResult(testCommand, exitCode, stdout, stderr)
|
|
51576
52164
|
};
|
|
51577
52165
|
}
|
|
51578
|
-
} catch (
|
|
51579
|
-
console.warn(`Failed to test code using command: ${testCommand}`,
|
|
52166
|
+
} catch (error82) {
|
|
52167
|
+
console.warn(`Failed to test code using command: ${testCommand}`, error82);
|
|
51580
52168
|
}
|
|
51581
52169
|
}
|
|
51582
52170
|
}
|
|
@@ -51753,8 +52341,8 @@ class CoderAgent extends AgentBase {
|
|
|
51753
52341
|
message: responsePrompts.commandResult(command, exitCode, stdout, stderr)
|
|
51754
52342
|
};
|
|
51755
52343
|
}
|
|
51756
|
-
} catch (
|
|
51757
|
-
console.warn(`Failed to run ${scriptName} using command: ${command}`,
|
|
52344
|
+
} catch (error82) {
|
|
52345
|
+
console.warn(`Failed to run ${scriptName} using command: ${command}`, error82);
|
|
51758
52346
|
}
|
|
51759
52347
|
}
|
|
51760
52348
|
}
|
|
@@ -52372,10 +52960,10 @@ ${diffOutput}
|
|
|
52372
52960
|
message: `\`${command}\` exited with code ${result.exitCode}:
|
|
52373
52961
|
${result.stderr}`
|
|
52374
52962
|
};
|
|
52375
|
-
} catch (
|
|
52963
|
+
} catch (error82) {
|
|
52376
52964
|
return {
|
|
52377
52965
|
type: "Error" /* Error */,
|
|
52378
|
-
message:
|
|
52966
|
+
message: error82 instanceof Error ? error82.message : String(error82)
|
|
52379
52967
|
};
|
|
52380
52968
|
}
|
|
52381
52969
|
};
|
|
@@ -52499,8 +53087,8 @@ ${instructions}
|
|
|
52499
53087
|
const content = match ? match[1] : output;
|
|
52500
53088
|
try {
|
|
52501
53089
|
return JSON.parse(content);
|
|
52502
|
-
} catch (
|
|
52503
|
-
console.error("Error parsing JSON output:",
|
|
53090
|
+
} catch (error82) {
|
|
53091
|
+
console.error("Error parsing JSON output:", error82);
|
|
52504
53092
|
return {
|
|
52505
53093
|
overview: `Could not parse review output. Raw output:
|
|
52506
53094
|
${output}`,
|
|
@@ -52797,8 +53385,8 @@ class ZodError4 extends Error {
|
|
|
52797
53385
|
return issue3.message;
|
|
52798
53386
|
};
|
|
52799
53387
|
const fieldErrors = { _errors: [] };
|
|
52800
|
-
const processError = (
|
|
52801
|
-
for (const issue3 of
|
|
53388
|
+
const processError = (error82) => {
|
|
53389
|
+
for (const issue3 of error82.issues) {
|
|
52802
53390
|
if (issue3.code === "invalid_union") {
|
|
52803
53391
|
issue3.unionErrors.map(processError);
|
|
52804
53392
|
} else if (issue3.code === "invalid_return_type") {
|
|
@@ -52860,8 +53448,8 @@ class ZodError4 extends Error {
|
|
|
52860
53448
|
}
|
|
52861
53449
|
}
|
|
52862
53450
|
ZodError4.create = (issues) => {
|
|
52863
|
-
const
|
|
52864
|
-
return
|
|
53451
|
+
const error82 = new ZodError4(issues);
|
|
53452
|
+
return error82;
|
|
52865
53453
|
};
|
|
52866
53454
|
var errorMap2 = (issue3, _ctx) => {
|
|
52867
53455
|
let message;
|
|
@@ -53124,8 +53712,8 @@ var handleResult2 = (ctx, result) => {
|
|
|
53124
53712
|
get error() {
|
|
53125
53713
|
if (this._error)
|
|
53126
53714
|
return this._error;
|
|
53127
|
-
const
|
|
53128
|
-
this._error =
|
|
53715
|
+
const error82 = new ZodError4(ctx.common.issues);
|
|
53716
|
+
this._error = error82;
|
|
53129
53717
|
return this._error;
|
|
53130
53718
|
}
|
|
53131
53719
|
};
|
|
@@ -55709,7 +56297,7 @@ class ZodFunction2 extends ZodType4 {
|
|
|
55709
56297
|
});
|
|
55710
56298
|
return INVALID2;
|
|
55711
56299
|
}
|
|
55712
|
-
function makeArgsIssue(args,
|
|
56300
|
+
function makeArgsIssue(args, error82) {
|
|
55713
56301
|
return makeIssue2({
|
|
55714
56302
|
data: args,
|
|
55715
56303
|
path: ctx.path,
|
|
@@ -55721,11 +56309,11 @@ class ZodFunction2 extends ZodType4 {
|
|
|
55721
56309
|
].filter((x) => !!x),
|
|
55722
56310
|
issueData: {
|
|
55723
56311
|
code: ZodIssueCode4.invalid_arguments,
|
|
55724
|
-
argumentsError:
|
|
56312
|
+
argumentsError: error82
|
|
55725
56313
|
}
|
|
55726
56314
|
});
|
|
55727
56315
|
}
|
|
55728
|
-
function makeReturnsIssue(returns,
|
|
56316
|
+
function makeReturnsIssue(returns, error82) {
|
|
55729
56317
|
return makeIssue2({
|
|
55730
56318
|
data: returns,
|
|
55731
56319
|
path: ctx.path,
|
|
@@ -55737,7 +56325,7 @@ class ZodFunction2 extends ZodType4 {
|
|
|
55737
56325
|
].filter((x) => !!x),
|
|
55738
56326
|
issueData: {
|
|
55739
56327
|
code: ZodIssueCode4.invalid_return_type,
|
|
55740
|
-
returnTypeError:
|
|
56328
|
+
returnTypeError: error82
|
|
55741
56329
|
}
|
|
55742
56330
|
});
|
|
55743
56331
|
}
|
|
@@ -55746,15 +56334,15 @@ class ZodFunction2 extends ZodType4 {
|
|
|
55746
56334
|
if (this._def.returns instanceof ZodPromise4) {
|
|
55747
56335
|
const me = this;
|
|
55748
56336
|
return OK2(async function(...args) {
|
|
55749
|
-
const
|
|
56337
|
+
const error82 = new ZodError4([]);
|
|
55750
56338
|
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
55751
|
-
|
|
55752
|
-
throw
|
|
56339
|
+
error82.addIssue(makeArgsIssue(args, e));
|
|
56340
|
+
throw error82;
|
|
55753
56341
|
});
|
|
55754
56342
|
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
55755
56343
|
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
55756
|
-
|
|
55757
|
-
throw
|
|
56344
|
+
error82.addIssue(makeReturnsIssue(result, e));
|
|
56345
|
+
throw error82;
|
|
55758
56346
|
});
|
|
55759
56347
|
return parsedReturns;
|
|
55760
56348
|
});
|
|
@@ -56507,9 +57095,9 @@ function loadConfig(paths, cwd = process.cwd(), home = homedir()) {
|
|
|
56507
57095
|
try {
|
|
56508
57096
|
const globalConfig3 = readConfig(globalConfigPath);
|
|
56509
57097
|
configs.push(globalConfig3);
|
|
56510
|
-
} catch (
|
|
57098
|
+
} catch (error82) {
|
|
56511
57099
|
console.warn(`Error loading global config file: ${globalConfigPath}
|
|
56512
|
-
${
|
|
57100
|
+
${error82}`);
|
|
56513
57101
|
}
|
|
56514
57102
|
}
|
|
56515
57103
|
if (paths && paths.length > 0) {
|
|
@@ -56518,10 +57106,10 @@ ${error81}`);
|
|
|
56518
57106
|
try {
|
|
56519
57107
|
const config4 = readConfig(path);
|
|
56520
57108
|
configs.push(config4);
|
|
56521
|
-
} catch (
|
|
57109
|
+
} catch (error82) {
|
|
56522
57110
|
console.error(`Error loading config file: ${path}
|
|
56523
|
-
${
|
|
56524
|
-
throw
|
|
57111
|
+
${error82}`);
|
|
57112
|
+
throw error82;
|
|
56525
57113
|
}
|
|
56526
57114
|
}
|
|
56527
57115
|
} else {
|
|
@@ -56529,11 +57117,11 @@ ${error81}`);
|
|
|
56529
57117
|
try {
|
|
56530
57118
|
const projectConfig = readConfig(configPath);
|
|
56531
57119
|
configs.push(projectConfig);
|
|
56532
|
-
} catch (
|
|
56533
|
-
if (
|
|
57120
|
+
} catch (error82) {
|
|
57121
|
+
if (error82 instanceof ZodError4) {
|
|
56534
57122
|
console.error(`Error in config file: ${configPath}
|
|
56535
|
-
${
|
|
56536
|
-
throw
|
|
57123
|
+
${error82}`);
|
|
57124
|
+
throw error82;
|
|
56537
57125
|
}
|
|
56538
57126
|
}
|
|
56539
57127
|
}
|
|
@@ -57570,16 +58158,16 @@ function createPrompt(view) {
|
|
|
57570
58158
|
const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
|
|
57571
58159
|
screen.render(content, bottomContent);
|
|
57572
58160
|
effectScheduler.run();
|
|
57573
|
-
} catch (
|
|
57574
|
-
reject(
|
|
58161
|
+
} catch (error82) {
|
|
58162
|
+
reject(error82);
|
|
57575
58163
|
}
|
|
57576
58164
|
});
|
|
57577
58165
|
return Object.assign(promise4.then((answer) => {
|
|
57578
58166
|
effectScheduler.clearAll();
|
|
57579
58167
|
return answer;
|
|
57580
|
-
}, (
|
|
58168
|
+
}, (error82) => {
|
|
57581
58169
|
effectScheduler.clearAll();
|
|
57582
|
-
throw
|
|
58170
|
+
throw error82;
|
|
57583
58171
|
}).finally(() => {
|
|
57584
58172
|
cleanups.forEach((cleanup) => cleanup());
|
|
57585
58173
|
screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
|
|
@@ -57665,13 +58253,13 @@ var esm_default3 = createPrompt((config4, done) => {
|
|
|
57665
58253
|
if (defaultValue && status !== "done" && !value) {
|
|
57666
58254
|
defaultStr = theme.style.defaultAnswer(defaultValue);
|
|
57667
58255
|
}
|
|
57668
|
-
let
|
|
58256
|
+
let error82 = "";
|
|
57669
58257
|
if (errorMsg) {
|
|
57670
|
-
|
|
58258
|
+
error82 = theme.style.error(errorMsg);
|
|
57671
58259
|
}
|
|
57672
58260
|
return [
|
|
57673
58261
|
[prefix, message, defaultStr, formattedValue].filter((v) => v !== undefined).join(" "),
|
|
57674
|
-
|
|
58262
|
+
error82
|
|
57675
58263
|
];
|
|
57676
58264
|
});
|
|
57677
58265
|
// ../../node_modules/@inquirer/select/dist/esm/index.js
|
|
@@ -57983,8 +58571,8 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
|
57983
58571
|
`).filter(Boolean);
|
|
57984
58572
|
results.push(...lines);
|
|
57985
58573
|
});
|
|
57986
|
-
rg.on("error", (
|
|
57987
|
-
reject(new Error(`Failed to execute ripgrep: ${
|
|
58574
|
+
rg.on("error", (error82) => {
|
|
58575
|
+
reject(new Error(`Failed to execute ripgrep: ${error82.message}`));
|
|
57988
58576
|
});
|
|
57989
58577
|
rg.on("close", (code) => {
|
|
57990
58578
|
if (code !== 0 && code !== 1) {
|
|
@@ -58095,9 +58683,9 @@ var getProvider = (_agentName, _config, options = {}) => {
|
|
|
58095
58683
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
58096
58684
|
}
|
|
58097
58685
|
return await response.text();
|
|
58098
|
-
} catch (
|
|
58099
|
-
console.error("Error fetching URL:",
|
|
58100
|
-
throw
|
|
58686
|
+
} catch (error82) {
|
|
58687
|
+
console.error("Error fetching URL:", error82);
|
|
58688
|
+
throw error82;
|
|
58101
58689
|
}
|
|
58102
58690
|
}
|
|
58103
58691
|
};
|
|
@@ -58378,6 +58966,9 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
58378
58966
|
if (env.TERM === "xterm-kitty") {
|
|
58379
58967
|
return 3;
|
|
58380
58968
|
}
|
|
58969
|
+
if (env.TERM === "xterm-ghostty") {
|
|
58970
|
+
return 3;
|
|
58971
|
+
}
|
|
58381
58972
|
if ("TERM_PROGRAM" in env) {
|
|
58382
58973
|
const version3 = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
58383
58974
|
switch (env.TERM_PROGRAM) {
|
|
@@ -58761,10 +59352,10 @@ Tool error:`, event.tool));
|
|
|
58761
59352
|
|
|
58762
59353
|
======== Tool Call Stats ========`);
|
|
58763
59354
|
if (toolCallStats.size > 0) {
|
|
58764
|
-
const tableData = [...toolCallStats.entries()].map(([
|
|
59355
|
+
const tableData = [...toolCallStats.entries()].map(([tool3, stats]) => {
|
|
58765
59356
|
const successRate = stats.calls > 0 ? stats.success / stats.calls * 100 : 0;
|
|
58766
59357
|
return {
|
|
58767
|
-
"Tool Name":
|
|
59358
|
+
"Tool Name": tool3,
|
|
58768
59359
|
Calls: stats.calls,
|
|
58769
59360
|
Success: stats.success,
|
|
58770
59361
|
Errors: stats.errors,
|