@polka-codes/runner 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 +1480 -892
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -9658,8 +9658,8 @@ var require_directives = __commonJS((exports) => {
|
|
|
9658
9658
|
if (prefix) {
|
|
9659
9659
|
try {
|
|
9660
9660
|
return prefix + decodeURIComponent(suffix);
|
|
9661
|
-
} catch (
|
|
9662
|
-
onError(String(
|
|
9661
|
+
} catch (error82) {
|
|
9662
|
+
onError(String(error82));
|
|
9663
9663
|
return null;
|
|
9664
9664
|
}
|
|
9665
9665
|
}
|
|
@@ -9751,9 +9751,9 @@ var require_anchors = __commonJS((exports) => {
|
|
|
9751
9751
|
if (typeof ref === "object" && ref.anchor && (identity.isScalar(ref.node) || identity.isCollection(ref.node))) {
|
|
9752
9752
|
ref.node.anchor = ref.anchor;
|
|
9753
9753
|
} else {
|
|
9754
|
-
const
|
|
9755
|
-
|
|
9756
|
-
throw
|
|
9754
|
+
const error82 = new Error("Failed to resolve repeated object (this should not happen)");
|
|
9755
|
+
error82.source = source;
|
|
9756
|
+
throw error82;
|
|
9757
9757
|
}
|
|
9758
9758
|
}
|
|
9759
9759
|
},
|
|
@@ -12742,12 +12742,12 @@ var require_errors = __commonJS((exports) => {
|
|
|
12742
12742
|
super("YAMLWarning", pos, code, message);
|
|
12743
12743
|
}
|
|
12744
12744
|
}
|
|
12745
|
-
var prettifyError3 = (src, lc) => (
|
|
12746
|
-
if (
|
|
12745
|
+
var prettifyError3 = (src, lc) => (error82) => {
|
|
12746
|
+
if (error82.pos[0] === -1)
|
|
12747
12747
|
return;
|
|
12748
|
-
|
|
12749
|
-
const { line, col } =
|
|
12750
|
-
|
|
12748
|
+
error82.linePos = error82.pos.map((pos) => lc.linePos(pos));
|
|
12749
|
+
const { line, col } = error82.linePos[0];
|
|
12750
|
+
error82.message += ` at line ${line}, column ${col}`;
|
|
12751
12751
|
let ci = col - 1;
|
|
12752
12752
|
let lineStr = src.substring(lc.lineStarts[line - 1], lc.lineStarts[line]).replace(/[\n\r]+$/, "");
|
|
12753
12753
|
if (ci >= 60 && lineStr.length > 80) {
|
|
@@ -12766,12 +12766,12 @@ var require_errors = __commonJS((exports) => {
|
|
|
12766
12766
|
}
|
|
12767
12767
|
if (/[^ ]/.test(lineStr)) {
|
|
12768
12768
|
let count = 1;
|
|
12769
|
-
const end =
|
|
12769
|
+
const end = error82.linePos[1];
|
|
12770
12770
|
if (end && end.line === line && end.col > col) {
|
|
12771
12771
|
count = Math.max(1, Math.min(end.col - col, 80 - ci));
|
|
12772
12772
|
}
|
|
12773
12773
|
const pointer = " ".repeat(ci) + "^".repeat(count);
|
|
12774
|
-
|
|
12774
|
+
error82.message += `:
|
|
12775
12775
|
|
|
12776
12776
|
${lineStr}
|
|
12777
12777
|
${pointer}
|
|
@@ -13563,7 +13563,7 @@ var require_resolve_block_scalar = __commonJS((exports) => {
|
|
|
13563
13563
|
const mode = source[0];
|
|
13564
13564
|
let indent = 0;
|
|
13565
13565
|
let chomp = "";
|
|
13566
|
-
let
|
|
13566
|
+
let error82 = -1;
|
|
13567
13567
|
for (let i = 1;i < source.length; ++i) {
|
|
13568
13568
|
const ch = source[i];
|
|
13569
13569
|
if (!chomp && (ch === "-" || ch === "+"))
|
|
@@ -13572,12 +13572,12 @@ var require_resolve_block_scalar = __commonJS((exports) => {
|
|
|
13572
13572
|
const n = Number(ch);
|
|
13573
13573
|
if (!indent && n)
|
|
13574
13574
|
indent = n;
|
|
13575
|
-
else if (
|
|
13576
|
-
|
|
13575
|
+
else if (error82 === -1)
|
|
13576
|
+
error82 = offset + i;
|
|
13577
13577
|
}
|
|
13578
13578
|
}
|
|
13579
|
-
if (
|
|
13580
|
-
onError(
|
|
13579
|
+
if (error82 !== -1)
|
|
13580
|
+
onError(error82, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${source}`);
|
|
13581
13581
|
let hasSpace = false;
|
|
13582
13582
|
let comment = "";
|
|
13583
13583
|
let length = source.length;
|
|
@@ -13863,8 +13863,8 @@ var require_compose_scalar = __commonJS((exports) => {
|
|
|
13863
13863
|
try {
|
|
13864
13864
|
const res = tag.resolve(value, (msg) => onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg), ctx.options);
|
|
13865
13865
|
scalar = identity.isScalar(res) ? res : new Scalar.Scalar(res);
|
|
13866
|
-
} catch (
|
|
13867
|
-
const msg =
|
|
13866
|
+
} catch (error82) {
|
|
13867
|
+
const msg = error82 instanceof Error ? error82.message : String(error82);
|
|
13868
13868
|
onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg);
|
|
13869
13869
|
scalar = new Scalar.Scalar(value);
|
|
13870
13870
|
}
|
|
@@ -14227,11 +14227,11 @@ ${cb}` : comment;
|
|
|
14227
14227
|
break;
|
|
14228
14228
|
case "error": {
|
|
14229
14229
|
const msg = token.source ? `${token.message}: ${JSON.stringify(token.source)}` : token.message;
|
|
14230
|
-
const
|
|
14230
|
+
const error82 = new errors5.YAMLParseError(getErrorPos(token), "UNEXPECTED_TOKEN", msg);
|
|
14231
14231
|
if (this.atDirectives || !this.doc)
|
|
14232
|
-
this.errors.push(
|
|
14232
|
+
this.errors.push(error82);
|
|
14233
14233
|
else
|
|
14234
|
-
this.doc.errors.push(
|
|
14234
|
+
this.doc.errors.push(error82);
|
|
14235
14235
|
break;
|
|
14236
14236
|
}
|
|
14237
14237
|
case "doc-end": {
|
|
@@ -15504,8 +15504,8 @@ var require_parser = __commonJS((exports) => {
|
|
|
15504
15504
|
peek(n) {
|
|
15505
15505
|
return this.stack[this.stack.length - n];
|
|
15506
15506
|
}
|
|
15507
|
-
*pop(
|
|
15508
|
-
const token =
|
|
15507
|
+
*pop(error82) {
|
|
15508
|
+
const token = error82 ?? this.stack.pop();
|
|
15509
15509
|
if (!token) {
|
|
15510
15510
|
const message = "Tried to pop an empty stack";
|
|
15511
15511
|
yield { type: "error", offset: this.offset, source: "", message };
|
|
@@ -18901,14 +18901,14 @@ var require_receiver = __commonJS((exports, module) => {
|
|
|
18901
18901
|
}
|
|
18902
18902
|
const buf = this.consume(2);
|
|
18903
18903
|
if ((buf[0] & 48) !== 0) {
|
|
18904
|
-
const
|
|
18905
|
-
cb(
|
|
18904
|
+
const error82 = this.createError(RangeError, "RSV2 and RSV3 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_2_3");
|
|
18905
|
+
cb(error82);
|
|
18906
18906
|
return;
|
|
18907
18907
|
}
|
|
18908
18908
|
const compressed = (buf[0] & 64) === 64;
|
|
18909
18909
|
if (compressed && !this._extensions[PerMessageDeflate.extensionName]) {
|
|
18910
|
-
const
|
|
18911
|
-
cb(
|
|
18910
|
+
const error82 = this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1");
|
|
18911
|
+
cb(error82);
|
|
18912
18912
|
return;
|
|
18913
18913
|
}
|
|
18914
18914
|
this._fin = (buf[0] & 128) === 128;
|
|
@@ -18916,42 +18916,42 @@ var require_receiver = __commonJS((exports, module) => {
|
|
|
18916
18916
|
this._payloadLength = buf[1] & 127;
|
|
18917
18917
|
if (this._opcode === 0) {
|
|
18918
18918
|
if (compressed) {
|
|
18919
|
-
const
|
|
18920
|
-
cb(
|
|
18919
|
+
const error82 = this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1");
|
|
18920
|
+
cb(error82);
|
|
18921
18921
|
return;
|
|
18922
18922
|
}
|
|
18923
18923
|
if (!this._fragmented) {
|
|
18924
|
-
const
|
|
18925
|
-
cb(
|
|
18924
|
+
const error82 = this.createError(RangeError, "invalid opcode 0", true, 1002, "WS_ERR_INVALID_OPCODE");
|
|
18925
|
+
cb(error82);
|
|
18926
18926
|
return;
|
|
18927
18927
|
}
|
|
18928
18928
|
this._opcode = this._fragmented;
|
|
18929
18929
|
} else if (this._opcode === 1 || this._opcode === 2) {
|
|
18930
18930
|
if (this._fragmented) {
|
|
18931
|
-
const
|
|
18932
|
-
cb(
|
|
18931
|
+
const error82 = this.createError(RangeError, `invalid opcode ${this._opcode}`, true, 1002, "WS_ERR_INVALID_OPCODE");
|
|
18932
|
+
cb(error82);
|
|
18933
18933
|
return;
|
|
18934
18934
|
}
|
|
18935
18935
|
this._compressed = compressed;
|
|
18936
18936
|
} else if (this._opcode > 7 && this._opcode < 11) {
|
|
18937
18937
|
if (!this._fin) {
|
|
18938
|
-
const
|
|
18939
|
-
cb(
|
|
18938
|
+
const error82 = this.createError(RangeError, "FIN must be set", true, 1002, "WS_ERR_EXPECTED_FIN");
|
|
18939
|
+
cb(error82);
|
|
18940
18940
|
return;
|
|
18941
18941
|
}
|
|
18942
18942
|
if (compressed) {
|
|
18943
|
-
const
|
|
18944
|
-
cb(
|
|
18943
|
+
const error82 = this.createError(RangeError, "RSV1 must be clear", true, 1002, "WS_ERR_UNEXPECTED_RSV_1");
|
|
18944
|
+
cb(error82);
|
|
18945
18945
|
return;
|
|
18946
18946
|
}
|
|
18947
18947
|
if (this._payloadLength > 125 || this._opcode === 8 && this._payloadLength === 1) {
|
|
18948
|
-
const
|
|
18949
|
-
cb(
|
|
18948
|
+
const error82 = this.createError(RangeError, `invalid payload length ${this._payloadLength}`, true, 1002, "WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");
|
|
18949
|
+
cb(error82);
|
|
18950
18950
|
return;
|
|
18951
18951
|
}
|
|
18952
18952
|
} else {
|
|
18953
|
-
const
|
|
18954
|
-
cb(
|
|
18953
|
+
const error82 = this.createError(RangeError, `invalid opcode ${this._opcode}`, true, 1002, "WS_ERR_INVALID_OPCODE");
|
|
18954
|
+
cb(error82);
|
|
18955
18955
|
return;
|
|
18956
18956
|
}
|
|
18957
18957
|
if (!this._fin && !this._fragmented)
|
|
@@ -18959,13 +18959,13 @@ var require_receiver = __commonJS((exports, module) => {
|
|
|
18959
18959
|
this._masked = (buf[1] & 128) === 128;
|
|
18960
18960
|
if (this._isServer) {
|
|
18961
18961
|
if (!this._masked) {
|
|
18962
|
-
const
|
|
18963
|
-
cb(
|
|
18962
|
+
const error82 = this.createError(RangeError, "MASK must be set", true, 1002, "WS_ERR_EXPECTED_MASK");
|
|
18963
|
+
cb(error82);
|
|
18964
18964
|
return;
|
|
18965
18965
|
}
|
|
18966
18966
|
} else if (this._masked) {
|
|
18967
|
-
const
|
|
18968
|
-
cb(
|
|
18967
|
+
const error82 = this.createError(RangeError, "MASK must be clear", true, 1002, "WS_ERR_UNEXPECTED_MASK");
|
|
18968
|
+
cb(error82);
|
|
18969
18969
|
return;
|
|
18970
18970
|
}
|
|
18971
18971
|
if (this._payloadLength === 126)
|
|
@@ -18991,8 +18991,8 @@ var require_receiver = __commonJS((exports, module) => {
|
|
|
18991
18991
|
const buf = this.consume(8);
|
|
18992
18992
|
const num = buf.readUInt32BE(0);
|
|
18993
18993
|
if (num > Math.pow(2, 53 - 32) - 1) {
|
|
18994
|
-
const
|
|
18995
|
-
cb(
|
|
18994
|
+
const error82 = this.createError(RangeError, "Unsupported WebSocket frame: payload length > 2^53 - 1", false, 1009, "WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");
|
|
18995
|
+
cb(error82);
|
|
18996
18996
|
return;
|
|
18997
18997
|
}
|
|
18998
18998
|
this._payloadLength = num * Math.pow(2, 32) + buf.readUInt32BE(4);
|
|
@@ -19002,8 +19002,8 @@ var require_receiver = __commonJS((exports, module) => {
|
|
|
19002
19002
|
if (this._payloadLength && this._opcode < 8) {
|
|
19003
19003
|
this._totalPayloadLength += this._payloadLength;
|
|
19004
19004
|
if (this._totalPayloadLength > this._maxPayload && this._maxPayload > 0) {
|
|
19005
|
-
const
|
|
19006
|
-
cb(
|
|
19005
|
+
const error82 = this.createError(RangeError, "Max payload size exceeded", false, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");
|
|
19006
|
+
cb(error82);
|
|
19007
19007
|
return;
|
|
19008
19008
|
}
|
|
19009
19009
|
}
|
|
@@ -19055,8 +19055,8 @@ var require_receiver = __commonJS((exports, module) => {
|
|
|
19055
19055
|
if (buf.length) {
|
|
19056
19056
|
this._messageLength += buf.length;
|
|
19057
19057
|
if (this._messageLength > this._maxPayload && this._maxPayload > 0) {
|
|
19058
|
-
const
|
|
19059
|
-
cb(
|
|
19058
|
+
const error82 = this.createError(RangeError, "Max payload size exceeded", false, 1009, "WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");
|
|
19059
|
+
cb(error82);
|
|
19060
19060
|
return;
|
|
19061
19061
|
}
|
|
19062
19062
|
this._fragments.push(buf);
|
|
@@ -19102,8 +19102,8 @@ var require_receiver = __commonJS((exports, module) => {
|
|
|
19102
19102
|
} else {
|
|
19103
19103
|
const buf = concat(fragments, messageLength);
|
|
19104
19104
|
if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
|
|
19105
|
-
const
|
|
19106
|
-
cb(
|
|
19105
|
+
const error82 = this.createError(Error, "invalid UTF-8 sequence", true, 1007, "WS_ERR_INVALID_UTF8");
|
|
19106
|
+
cb(error82);
|
|
19107
19107
|
return;
|
|
19108
19108
|
}
|
|
19109
19109
|
if (this._state === INFLATING || this._allowSynchronousEvents) {
|
|
@@ -19128,14 +19128,14 @@ var require_receiver = __commonJS((exports, module) => {
|
|
|
19128
19128
|
} else {
|
|
19129
19129
|
const code = data.readUInt16BE(0);
|
|
19130
19130
|
if (!isValidStatusCode(code)) {
|
|
19131
|
-
const
|
|
19132
|
-
cb(
|
|
19131
|
+
const error82 = this.createError(RangeError, `invalid status code ${code}`, true, 1002, "WS_ERR_INVALID_CLOSE_CODE");
|
|
19132
|
+
cb(error82);
|
|
19133
19133
|
return;
|
|
19134
19134
|
}
|
|
19135
19135
|
const buf = new FastBuffer(data.buffer, data.byteOffset + 2, data.length - 2);
|
|
19136
19136
|
if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
|
|
19137
|
-
const
|
|
19138
|
-
cb(
|
|
19137
|
+
const error82 = this.createError(Error, "invalid UTF-8 sequence", true, 1007, "WS_ERR_INVALID_UTF8");
|
|
19138
|
+
cb(error82);
|
|
19139
19139
|
return;
|
|
19140
19140
|
}
|
|
19141
19141
|
this._loop = false;
|
|
@@ -19625,10 +19625,10 @@ var require_event_target = __commonJS((exports, module) => {
|
|
|
19625
19625
|
callListener(handler15, this, event);
|
|
19626
19626
|
};
|
|
19627
19627
|
} else if (type === "error") {
|
|
19628
|
-
wrapper = function onError(
|
|
19628
|
+
wrapper = function onError(error82) {
|
|
19629
19629
|
const event = new ErrorEvent("error", {
|
|
19630
|
-
error:
|
|
19631
|
-
message:
|
|
19630
|
+
error: error82,
|
|
19631
|
+
message: error82.message
|
|
19632
19632
|
});
|
|
19633
19633
|
event[kTarget] = this;
|
|
19634
19634
|
callListener(handler15, this, event);
|
|
@@ -21067,7 +21067,7 @@ var {
|
|
|
21067
21067
|
Help
|
|
21068
21068
|
} = import__.default;
|
|
21069
21069
|
// package.json
|
|
21070
|
-
var version = "0.9.
|
|
21070
|
+
var version = "0.9.19";
|
|
21071
21071
|
|
|
21072
21072
|
// src/runner.ts
|
|
21073
21073
|
import { execSync } from "node:child_process";
|
|
@@ -33733,6 +33733,7 @@ __export(exports_external2, {
|
|
|
33733
33733
|
int: () => int2,
|
|
33734
33734
|
instanceof: () => _instanceof2,
|
|
33735
33735
|
includes: () => _includes2,
|
|
33736
|
+
hostname: () => hostname3,
|
|
33736
33737
|
guid: () => guid4,
|
|
33737
33738
|
gte: () => _gte2,
|
|
33738
33739
|
gt: () => _gt2,
|
|
@@ -33895,6 +33896,7 @@ __export(exports_core4, {
|
|
|
33895
33896
|
_toLowerCase: () => _toLowerCase2,
|
|
33896
33897
|
_templateLiteral: () => _templateLiteral2,
|
|
33897
33898
|
_symbol: () => _symbol2,
|
|
33899
|
+
_superRefine: () => _superRefine,
|
|
33898
33900
|
_success: () => _success2,
|
|
33899
33901
|
_stringbool: () => _stringbool2,
|
|
33900
33902
|
_stringFormat: () => _stringFormat2,
|
|
@@ -33980,6 +33982,7 @@ __export(exports_core4, {
|
|
|
33980
33982
|
_coercedBigint: () => _coercedBigint2,
|
|
33981
33983
|
_cidrv6: () => _cidrv62,
|
|
33982
33984
|
_cidrv4: () => _cidrv42,
|
|
33985
|
+
_check: () => _check,
|
|
33983
33986
|
_catch: () => _catch3,
|
|
33984
33987
|
_boolean: () => _boolean2,
|
|
33985
33988
|
_bigint: () => _bigint2,
|
|
@@ -34157,6 +34160,7 @@ var exports_util2 = {};
|
|
|
34157
34160
|
__export(exports_util2, {
|
|
34158
34161
|
unwrapMessage: () => unwrapMessage2,
|
|
34159
34162
|
stringifyPrimitive: () => stringifyPrimitive2,
|
|
34163
|
+
shallowClone: () => shallowClone,
|
|
34160
34164
|
required: () => required2,
|
|
34161
34165
|
randomString: () => randomString2,
|
|
34162
34166
|
propertyKeyTypes: () => propertyKeyTypes2,
|
|
@@ -34167,6 +34171,7 @@ __export(exports_util2, {
|
|
|
34167
34171
|
partial: () => partial2,
|
|
34168
34172
|
optionalKeys: () => optionalKeys2,
|
|
34169
34173
|
omit: () => omit2,
|
|
34174
|
+
objectClone: () => objectClone,
|
|
34170
34175
|
numKeys: () => numKeys2,
|
|
34171
34176
|
nullish: () => nullish3,
|
|
34172
34177
|
normalizeParams: () => normalizeParams2,
|
|
@@ -34254,22 +34259,32 @@ function cleanRegex2(source) {
|
|
|
34254
34259
|
}
|
|
34255
34260
|
function floatSafeRemainder2(val, step) {
|
|
34256
34261
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
34257
|
-
const
|
|
34262
|
+
const stepString = step.toString();
|
|
34263
|
+
let stepDecCount = (stepString.split(".")[1] || "").length;
|
|
34264
|
+
if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
|
|
34265
|
+
const match = stepString.match(/\d?e-(\d?)/);
|
|
34266
|
+
if (match?.[1]) {
|
|
34267
|
+
stepDecCount = Number.parseInt(match[1]);
|
|
34268
|
+
}
|
|
34269
|
+
}
|
|
34258
34270
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
34259
34271
|
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
34260
34272
|
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
34261
34273
|
return valInt % stepInt / 10 ** decCount;
|
|
34262
34274
|
}
|
|
34275
|
+
var EVALUATING = Symbol("evaluating");
|
|
34263
34276
|
function defineLazy2(object2, key, getter) {
|
|
34264
|
-
|
|
34277
|
+
let value = undefined;
|
|
34265
34278
|
Object.defineProperty(object2, key, {
|
|
34266
34279
|
get() {
|
|
34267
|
-
if (
|
|
34268
|
-
|
|
34269
|
-
object2[key] = value;
|
|
34270
|
-
return value;
|
|
34280
|
+
if (value === EVALUATING) {
|
|
34281
|
+
return;
|
|
34271
34282
|
}
|
|
34272
|
-
|
|
34283
|
+
if (value === undefined) {
|
|
34284
|
+
value = EVALUATING;
|
|
34285
|
+
value = getter();
|
|
34286
|
+
}
|
|
34287
|
+
return value;
|
|
34273
34288
|
},
|
|
34274
34289
|
set(v) {
|
|
34275
34290
|
Object.defineProperty(object2, key, {
|
|
@@ -34279,6 +34294,9 @@ function defineLazy2(object2, key, getter) {
|
|
|
34279
34294
|
configurable: true
|
|
34280
34295
|
});
|
|
34281
34296
|
}
|
|
34297
|
+
function objectClone(obj) {
|
|
34298
|
+
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
|
|
34299
|
+
}
|
|
34282
34300
|
function assignProp2(target, prop, value) {
|
|
34283
34301
|
Object.defineProperty(target, prop, {
|
|
34284
34302
|
value,
|
|
@@ -34355,6 +34373,11 @@ function isPlainObject2(o) {
|
|
|
34355
34373
|
}
|
|
34356
34374
|
return true;
|
|
34357
34375
|
}
|
|
34376
|
+
function shallowClone(o) {
|
|
34377
|
+
if (isPlainObject2(o))
|
|
34378
|
+
return { ...o };
|
|
34379
|
+
return o;
|
|
34380
|
+
}
|
|
34358
34381
|
function numKeys2(data) {
|
|
34359
34382
|
let keyCount = 0;
|
|
34360
34383
|
for (const key in data) {
|
|
@@ -34910,6 +34933,7 @@ __export(exports_regexes2, {
|
|
|
34910
34933
|
ipv6: () => ipv63,
|
|
34911
34934
|
ipv4: () => ipv43,
|
|
34912
34935
|
integer: () => integer2,
|
|
34936
|
+
idnEmail: () => idnEmail,
|
|
34913
34937
|
html5Email: () => html5Email2,
|
|
34914
34938
|
hostname: () => hostname2,
|
|
34915
34939
|
guid: () => guid3,
|
|
@@ -34952,6 +34976,7 @@ var email3 = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][
|
|
|
34952
34976
|
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])?)*$/;
|
|
34953
34977
|
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,}))$/;
|
|
34954
34978
|
var unicodeEmail2 = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
|
|
34979
|
+
var idnEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
|
|
34955
34980
|
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])?)*$/;
|
|
34956
34981
|
var _emoji3 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
34957
34982
|
function emoji3() {
|
|
@@ -34963,7 +34988,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
|
|
|
34963
34988
|
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])$/;
|
|
34964
34989
|
var base643 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
34965
34990
|
var base64url3 = /^[A-Za-z0-9_-]*$/;
|
|
34966
|
-
var hostname2 = /^([a-zA-Z0-9-]
|
|
34991
|
+
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])?)*\.?$/;
|
|
34967
34992
|
var domain2 = /^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
34968
34993
|
var e1643 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
|
34969
34994
|
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])))`;
|
|
@@ -34982,7 +35007,7 @@ function datetime3(args) {
|
|
|
34982
35007
|
if (args.local)
|
|
34983
35008
|
opts.push("");
|
|
34984
35009
|
if (args.offset)
|
|
34985
|
-
opts.push(`([+-]\\d
|
|
35010
|
+
opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
34986
35011
|
const timeRegex = `${time4}(?:${opts.join("|")})`;
|
|
34987
35012
|
return new RegExp(`^${dateSource2}T(?:${timeRegex})$`);
|
|
34988
35013
|
}
|
|
@@ -35111,6 +35136,7 @@ var $ZodCheckNumberFormat2 = /* @__PURE__ */ $constructor2("$ZodCheckNumberForma
|
|
|
35111
35136
|
expected: origin,
|
|
35112
35137
|
format: def.format,
|
|
35113
35138
|
code: "invalid_type",
|
|
35139
|
+
continue: false,
|
|
35114
35140
|
input,
|
|
35115
35141
|
inst
|
|
35116
35142
|
});
|
|
@@ -35525,7 +35551,8 @@ var $ZodCheckMimeType2 = /* @__PURE__ */ $constructor2("$ZodCheckMimeType", (ins
|
|
|
35525
35551
|
code: "invalid_value",
|
|
35526
35552
|
values: def.mime,
|
|
35527
35553
|
input: payload.value.type,
|
|
35528
|
-
inst
|
|
35554
|
+
inst,
|
|
35555
|
+
continue: !def.abort
|
|
35529
35556
|
});
|
|
35530
35557
|
};
|
|
35531
35558
|
});
|
|
@@ -35578,7 +35605,7 @@ class Doc2 {
|
|
|
35578
35605
|
var version3 = {
|
|
35579
35606
|
major: 4,
|
|
35580
35607
|
minor: 0,
|
|
35581
|
-
patch:
|
|
35608
|
+
patch: 17
|
|
35582
35609
|
};
|
|
35583
35610
|
|
|
35584
35611
|
// ../../node_modules/zod/v4/core/schemas.js
|
|
@@ -36212,7 +36239,7 @@ var $ZodObject2 = /* @__PURE__ */ $constructor2("$ZodObject", (inst, def) => {
|
|
|
36212
36239
|
const _normalized = cached2(() => {
|
|
36213
36240
|
const keys = Object.keys(def.shape);
|
|
36214
36241
|
for (const k of keys) {
|
|
36215
|
-
if (!
|
|
36242
|
+
if (!def.shape[k]._zod.traits.has("$ZodType")) {
|
|
36216
36243
|
throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
36217
36244
|
}
|
|
36218
36245
|
}
|
|
@@ -36359,7 +36386,7 @@ function handleUnionResults2(results, final, inst, ctx) {
|
|
|
36359
36386
|
}
|
|
36360
36387
|
}
|
|
36361
36388
|
const nonaborted = results.filter((r) => !aborted2(r));
|
|
36362
|
-
if (nonaborted.length
|
|
36389
|
+
if (nonaborted.length === 1) {
|
|
36363
36390
|
final.value = nonaborted[0].value;
|
|
36364
36391
|
return nonaborted[0];
|
|
36365
36392
|
}
|
|
@@ -36388,7 +36415,12 @@ var $ZodUnion2 = /* @__PURE__ */ $constructor2("$ZodUnion", (inst, def) => {
|
|
|
36388
36415
|
}
|
|
36389
36416
|
return;
|
|
36390
36417
|
});
|
|
36418
|
+
const single = def.options.length === 1;
|
|
36419
|
+
const first = def.options[0]._zod.run;
|
|
36391
36420
|
inst._zod.parse = (payload, ctx) => {
|
|
36421
|
+
if (single) {
|
|
36422
|
+
return first(payload, ctx);
|
|
36423
|
+
}
|
|
36392
36424
|
let async = false;
|
|
36393
36425
|
const results = [];
|
|
36394
36426
|
for (const option of def.options) {
|
|
@@ -36469,6 +36501,7 @@ var $ZodDiscriminatedUnion2 = /* @__PURE__ */ $constructor2("$ZodDiscriminatedUn
|
|
|
36469
36501
|
code: "invalid_union",
|
|
36470
36502
|
errors: [],
|
|
36471
36503
|
note: "No matching discriminator",
|
|
36504
|
+
discriminator: def.discriminator,
|
|
36472
36505
|
input,
|
|
36473
36506
|
path: [def.discriminator],
|
|
36474
36507
|
inst
|
|
@@ -36573,10 +36606,10 @@ var $ZodTuple2 = /* @__PURE__ */ $constructor2("$ZodTuple", (inst, def) => {
|
|
|
36573
36606
|
const tooSmall = input.length < optStart - 1;
|
|
36574
36607
|
if (tooBig || tooSmall) {
|
|
36575
36608
|
payload.issues.push({
|
|
36609
|
+
...tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length },
|
|
36576
36610
|
input,
|
|
36577
36611
|
inst,
|
|
36578
|
-
origin: "array"
|
|
36579
|
-
...tooBig ? { code: "too_big", maximum: items.length } : { code: "too_small", minimum: items.length }
|
|
36612
|
+
origin: "array"
|
|
36580
36613
|
});
|
|
36581
36614
|
return payload;
|
|
36582
36615
|
}
|
|
@@ -36685,8 +36718,8 @@ var $ZodRecord2 = /* @__PURE__ */ $constructor2("$ZodRecord", (inst, def) => {
|
|
|
36685
36718
|
}
|
|
36686
36719
|
if (keyResult.issues.length) {
|
|
36687
36720
|
payload.issues.push({
|
|
36688
|
-
origin: "record",
|
|
36689
36721
|
code: "invalid_key",
|
|
36722
|
+
origin: "record",
|
|
36690
36723
|
issues: keyResult.issues.map((iss) => finalizeIssue2(iss, ctx, config2())),
|
|
36691
36724
|
input: key,
|
|
36692
36725
|
path: [key],
|
|
@@ -36754,8 +36787,8 @@ function handleMapResult2(keyResult, valueResult, final, key, input, inst, ctx)
|
|
|
36754
36787
|
final.issues.push(...prefixIssues2(key, keyResult.issues));
|
|
36755
36788
|
} else {
|
|
36756
36789
|
final.issues.push({
|
|
36757
|
-
origin: "map",
|
|
36758
36790
|
code: "invalid_key",
|
|
36791
|
+
origin: "map",
|
|
36759
36792
|
input,
|
|
36760
36793
|
inst,
|
|
36761
36794
|
issues: keyResult.issues.map((iss) => finalizeIssue2(iss, ctx, config2()))
|
|
@@ -36833,6 +36866,9 @@ var $ZodEnum2 = /* @__PURE__ */ $constructor2("$ZodEnum", (inst, def) => {
|
|
|
36833
36866
|
});
|
|
36834
36867
|
var $ZodLiteral2 = /* @__PURE__ */ $constructor2("$ZodLiteral", (inst, def) => {
|
|
36835
36868
|
$ZodType2.init(inst, def);
|
|
36869
|
+
if (def.values.length === 0) {
|
|
36870
|
+
throw new Error("Cannot create literal schema with no valid values");
|
|
36871
|
+
}
|
|
36836
36872
|
inst._zod.values = new Set(def.values);
|
|
36837
36873
|
inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex2(o) : o ? escapeRegex2(o.toString()) : String(o)).join("|")})$`);
|
|
36838
36874
|
inst._zod.parse = (payload, _ctx) => {
|
|
@@ -36882,6 +36918,12 @@ var $ZodTransform2 = /* @__PURE__ */ $constructor2("$ZodTransform", (inst, def)
|
|
|
36882
36918
|
return payload;
|
|
36883
36919
|
};
|
|
36884
36920
|
});
|
|
36921
|
+
function handleOptionalResult(result, input) {
|
|
36922
|
+
if (result.issues.length && input === undefined) {
|
|
36923
|
+
return { issues: [], value: undefined };
|
|
36924
|
+
}
|
|
36925
|
+
return result;
|
|
36926
|
+
}
|
|
36885
36927
|
var $ZodOptional2 = /* @__PURE__ */ $constructor2("$ZodOptional", (inst, def) => {
|
|
36886
36928
|
$ZodType2.init(inst, def);
|
|
36887
36929
|
inst._zod.optin = "optional";
|
|
@@ -36895,7 +36937,10 @@ var $ZodOptional2 = /* @__PURE__ */ $constructor2("$ZodOptional", (inst, def) =>
|
|
|
36895
36937
|
});
|
|
36896
36938
|
inst._zod.parse = (payload, ctx) => {
|
|
36897
36939
|
if (def.innerType._zod.optin === "optional") {
|
|
36898
|
-
|
|
36940
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
36941
|
+
if (result instanceof Promise)
|
|
36942
|
+
return result.then((r) => handleOptionalResult(r, payload.value));
|
|
36943
|
+
return handleOptionalResult(result, payload.value);
|
|
36899
36944
|
}
|
|
36900
36945
|
if (payload.value === undefined) {
|
|
36901
36946
|
return payload;
|
|
@@ -37086,7 +37131,7 @@ var $ZodTemplateLiteral2 = /* @__PURE__ */ $constructor2("$ZodTemplateLiteral",
|
|
|
37086
37131
|
$ZodType2.init(inst, def);
|
|
37087
37132
|
const regexParts = [];
|
|
37088
37133
|
for (const part of def.parts) {
|
|
37089
|
-
if (part
|
|
37134
|
+
if (typeof part === "object" && part !== null) {
|
|
37090
37135
|
if (!part._zod.pattern) {
|
|
37091
37136
|
throw new Error(`Invalid template literal part, no pattern found: ${[...part._zod.traits].shift()}`);
|
|
37092
37137
|
}
|
|
@@ -37138,8 +37183,8 @@ var $ZodLazy2 = /* @__PURE__ */ $constructor2("$ZodLazy", (inst, def) => {
|
|
|
37138
37183
|
defineLazy2(inst._zod, "innerType", () => def.getter());
|
|
37139
37184
|
defineLazy2(inst._zod, "pattern", () => inst._zod.innerType._zod.pattern);
|
|
37140
37185
|
defineLazy2(inst._zod, "propValues", () => inst._zod.innerType._zod.propValues);
|
|
37141
|
-
defineLazy2(inst._zod, "optin", () => inst._zod.innerType._zod.optin);
|
|
37142
|
-
defineLazy2(inst._zod, "optout", () => inst._zod.innerType._zod.optout);
|
|
37186
|
+
defineLazy2(inst._zod, "optin", () => inst._zod.innerType._zod.optin ?? undefined);
|
|
37187
|
+
defineLazy2(inst._zod, "optout", () => inst._zod.innerType._zod.optout ?? undefined);
|
|
37143
37188
|
inst._zod.parse = (payload, ctx) => {
|
|
37144
37189
|
const inner = inst._zod.innerType;
|
|
37145
37190
|
return inner._zod.run(payload, ctx);
|
|
@@ -37180,6 +37225,7 @@ var exports_locales2 = {};
|
|
|
37180
37225
|
__export(exports_locales2, {
|
|
37181
37226
|
zhTW: () => zh_TW_default2,
|
|
37182
37227
|
zhCN: () => zh_CN_default2,
|
|
37228
|
+
yo: () => yo_default,
|
|
37183
37229
|
vi: () => vi_default2,
|
|
37184
37230
|
ur: () => ur_default2,
|
|
37185
37231
|
ua: () => ua_default2,
|
|
@@ -42142,6 +42188,121 @@ function zh_TW_default2() {
|
|
|
42142
42188
|
localeError: error80()
|
|
42143
42189
|
};
|
|
42144
42190
|
}
|
|
42191
|
+
// ../../node_modules/zod/v4/locales/yo.js
|
|
42192
|
+
var error81 = () => {
|
|
42193
|
+
const Sizable = {
|
|
42194
|
+
string: { unit: "àmi", verb: "ní" },
|
|
42195
|
+
file: { unit: "bytes", verb: "ní" },
|
|
42196
|
+
array: { unit: "nkan", verb: "ní" },
|
|
42197
|
+
set: { unit: "nkan", verb: "ní" }
|
|
42198
|
+
};
|
|
42199
|
+
function getSizing(origin) {
|
|
42200
|
+
return Sizable[origin] ?? null;
|
|
42201
|
+
}
|
|
42202
|
+
const parsedType8 = (data) => {
|
|
42203
|
+
const t = typeof data;
|
|
42204
|
+
switch (t) {
|
|
42205
|
+
case "number": {
|
|
42206
|
+
return Number.isNaN(data) ? "NaN" : "nọ́mbà";
|
|
42207
|
+
}
|
|
42208
|
+
case "object": {
|
|
42209
|
+
if (Array.isArray(data)) {
|
|
42210
|
+
return "akopọ";
|
|
42211
|
+
}
|
|
42212
|
+
if (data === null) {
|
|
42213
|
+
return "null";
|
|
42214
|
+
}
|
|
42215
|
+
if (Object.getPrototypeOf(data) !== Object.prototype && data.constructor) {
|
|
42216
|
+
return data.constructor.name;
|
|
42217
|
+
}
|
|
42218
|
+
}
|
|
42219
|
+
}
|
|
42220
|
+
return t;
|
|
42221
|
+
};
|
|
42222
|
+
const Nouns = {
|
|
42223
|
+
regex: "ẹ̀rọ ìbáwọlé",
|
|
42224
|
+
email: "àdírẹ́sì ìmẹ́lì",
|
|
42225
|
+
url: "URL",
|
|
42226
|
+
emoji: "emoji",
|
|
42227
|
+
uuid: "UUID",
|
|
42228
|
+
uuidv4: "UUIDv4",
|
|
42229
|
+
uuidv6: "UUIDv6",
|
|
42230
|
+
nanoid: "nanoid",
|
|
42231
|
+
guid: "GUID",
|
|
42232
|
+
cuid: "cuid",
|
|
42233
|
+
cuid2: "cuid2",
|
|
42234
|
+
ulid: "ULID",
|
|
42235
|
+
xid: "XID",
|
|
42236
|
+
ksuid: "KSUID",
|
|
42237
|
+
datetime: "àkókò ISO",
|
|
42238
|
+
date: "ọjọ́ ISO",
|
|
42239
|
+
time: "àkókò ISO",
|
|
42240
|
+
duration: "àkókò tó pé ISO",
|
|
42241
|
+
ipv4: "àdírẹ́sì IPv4",
|
|
42242
|
+
ipv6: "àdírẹ́sì IPv6",
|
|
42243
|
+
cidrv4: "àgbègbè IPv4",
|
|
42244
|
+
cidrv6: "àgbègbè IPv6",
|
|
42245
|
+
base64: "ọ̀rọ̀ tí a kọ́ ní base64",
|
|
42246
|
+
base64url: "ọ̀rọ̀ base64url",
|
|
42247
|
+
json_string: "ọ̀rọ̀ JSON",
|
|
42248
|
+
e164: "nọ́mbà E.164",
|
|
42249
|
+
jwt: "JWT",
|
|
42250
|
+
template_literal: "ẹ̀rọ ìbáwọlé"
|
|
42251
|
+
};
|
|
42252
|
+
return (issue3) => {
|
|
42253
|
+
switch (issue3.code) {
|
|
42254
|
+
case "invalid_type":
|
|
42255
|
+
return `Ìbáwọlé aṣìṣe: a ní láti fi ${issue3.expected}, àmọ̀ a rí ${parsedType8(issue3.input)}`;
|
|
42256
|
+
case "invalid_value":
|
|
42257
|
+
if (issue3.values.length === 1)
|
|
42258
|
+
return `Ìbáwọlé aṣìṣe: a ní láti fi ${stringifyPrimitive2(issue3.values[0])}`;
|
|
42259
|
+
return `Àṣàyàn aṣìṣe: yan ọ̀kan lára ${joinValues2(issue3.values, "|")}`;
|
|
42260
|
+
case "too_big": {
|
|
42261
|
+
const adj = issue3.inclusive ? "<=" : "<";
|
|
42262
|
+
const sizing = getSizing(issue3.origin);
|
|
42263
|
+
if (sizing)
|
|
42264
|
+
return `Tó pọ̀ jù: a ní láti jẹ́ pé ${issue3.origin ?? "iye"} ${sizing.verb} ${adj}${issue3.maximum} ${sizing.unit}`;
|
|
42265
|
+
return `Tó pọ̀ jù: a ní láti jẹ́ ${adj}${issue3.maximum}`;
|
|
42266
|
+
}
|
|
42267
|
+
case "too_small": {
|
|
42268
|
+
const adj = issue3.inclusive ? ">=" : ">";
|
|
42269
|
+
const sizing = getSizing(issue3.origin);
|
|
42270
|
+
if (sizing)
|
|
42271
|
+
return `Kéré ju: a ní láti jẹ́ pé ${issue3.origin} ${sizing.verb} ${adj}${issue3.minimum} ${sizing.unit}`;
|
|
42272
|
+
return `Kéré ju: a ní láti jẹ́ ${adj}${issue3.minimum}`;
|
|
42273
|
+
}
|
|
42274
|
+
case "invalid_format": {
|
|
42275
|
+
const _issue = issue3;
|
|
42276
|
+
if (_issue.format === "starts_with")
|
|
42277
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bẹ̀rẹ̀ pẹ̀lú "${_issue.prefix}"`;
|
|
42278
|
+
if (_issue.format === "ends_with")
|
|
42279
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ parí pẹ̀lú "${_issue.suffix}"`;
|
|
42280
|
+
if (_issue.format === "includes")
|
|
42281
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ ní "${_issue.includes}"`;
|
|
42282
|
+
if (_issue.format === "regex")
|
|
42283
|
+
return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bá àpẹẹrẹ mu ${_issue.pattern}`;
|
|
42284
|
+
return `Aṣìṣe: ${Nouns[_issue.format] ?? issue3.format}`;
|
|
42285
|
+
}
|
|
42286
|
+
case "not_multiple_of":
|
|
42287
|
+
return `Nọ́mbà aṣìṣe: gbọ́dọ̀ jẹ́ èyà pípín ti ${issue3.divisor}`;
|
|
42288
|
+
case "unrecognized_keys":
|
|
42289
|
+
return `Bọtìnì àìmọ̀: ${joinValues2(issue3.keys, ", ")}`;
|
|
42290
|
+
case "invalid_key":
|
|
42291
|
+
return `Bọtìnì aṣìṣe nínú ${issue3.origin}`;
|
|
42292
|
+
case "invalid_union":
|
|
42293
|
+
return "Ìbáwọlé aṣìṣe";
|
|
42294
|
+
case "invalid_element":
|
|
42295
|
+
return `Iye aṣìṣe nínú ${issue3.origin}`;
|
|
42296
|
+
default:
|
|
42297
|
+
return "Ìbáwọlé aṣìṣe";
|
|
42298
|
+
}
|
|
42299
|
+
};
|
|
42300
|
+
};
|
|
42301
|
+
function yo_default() {
|
|
42302
|
+
return {
|
|
42303
|
+
localeError: error81()
|
|
42304
|
+
};
|
|
42305
|
+
}
|
|
42145
42306
|
// ../../node_modules/zod/v4/core/registries.js
|
|
42146
42307
|
var $output2 = Symbol("ZodOutput");
|
|
42147
42308
|
var $input2 = Symbol("ZodInput");
|
|
@@ -42901,7 +43062,7 @@ function _default3(Class3, innerType, defaultValue) {
|
|
|
42901
43062
|
type: "default",
|
|
42902
43063
|
innerType,
|
|
42903
43064
|
get defaultValue() {
|
|
42904
|
-
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
43065
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
42905
43066
|
}
|
|
42906
43067
|
});
|
|
42907
43068
|
}
|
|
@@ -42977,6 +43138,34 @@ function _refine2(Class3, fn, _params) {
|
|
|
42977
43138
|
});
|
|
42978
43139
|
return schema;
|
|
42979
43140
|
}
|
|
43141
|
+
function _superRefine(fn) {
|
|
43142
|
+
const ch = _check((payload) => {
|
|
43143
|
+
payload.addIssue = (issue3) => {
|
|
43144
|
+
if (typeof issue3 === "string") {
|
|
43145
|
+
payload.issues.push(issue2(issue3, payload.value, ch._zod.def));
|
|
43146
|
+
} else {
|
|
43147
|
+
const _issue = issue3;
|
|
43148
|
+
if (_issue.fatal)
|
|
43149
|
+
_issue.continue = false;
|
|
43150
|
+
_issue.code ?? (_issue.code = "custom");
|
|
43151
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
43152
|
+
_issue.inst ?? (_issue.inst = ch);
|
|
43153
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
43154
|
+
payload.issues.push(issue2(_issue));
|
|
43155
|
+
}
|
|
43156
|
+
};
|
|
43157
|
+
return fn(payload.value, payload);
|
|
43158
|
+
});
|
|
43159
|
+
return ch;
|
|
43160
|
+
}
|
|
43161
|
+
function _check(fn, params) {
|
|
43162
|
+
const ch = new $ZodCheck2({
|
|
43163
|
+
check: "custom",
|
|
43164
|
+
...normalizeParams2(params)
|
|
43165
|
+
});
|
|
43166
|
+
ch._zod.check = fn;
|
|
43167
|
+
return ch;
|
|
43168
|
+
}
|
|
42980
43169
|
function _stringbool2(Classes, _params) {
|
|
42981
43170
|
const params = normalizeParams2(_params);
|
|
42982
43171
|
let truthyArray = params.truthy ?? ["true", "1", "yes", "on", "y", "enabled"];
|
|
@@ -43007,7 +43196,8 @@ function _stringbool2(Classes, _params) {
|
|
|
43007
43196
|
expected: "stringbool",
|
|
43008
43197
|
values: [...truthySet, ...falsySet],
|
|
43009
43198
|
input: payload.value,
|
|
43010
|
-
inst: tx
|
|
43199
|
+
inst: tx,
|
|
43200
|
+
continue: false
|
|
43011
43201
|
});
|
|
43012
43202
|
return {};
|
|
43013
43203
|
}
|
|
@@ -43188,7 +43378,7 @@ class JSONSchemaGenerator2 {
|
|
|
43188
43378
|
else if (regexes.length > 1) {
|
|
43189
43379
|
result.schema.allOf = [
|
|
43190
43380
|
...regexes.map((regex) => ({
|
|
43191
|
-
...this.target === "draft-7" ? { type: "string" } : {},
|
|
43381
|
+
...this.target === "draft-7" || this.target === "draft-4" ? { type: "string" } : {},
|
|
43192
43382
|
pattern: regex.source
|
|
43193
43383
|
}))
|
|
43194
43384
|
];
|
|
@@ -43203,22 +43393,34 @@ class JSONSchemaGenerator2 {
|
|
|
43203
43393
|
json2.type = "integer";
|
|
43204
43394
|
else
|
|
43205
43395
|
json2.type = "number";
|
|
43206
|
-
if (typeof exclusiveMinimum === "number")
|
|
43207
|
-
|
|
43396
|
+
if (typeof exclusiveMinimum === "number") {
|
|
43397
|
+
if (this.target === "draft-4") {
|
|
43398
|
+
json2.minimum = exclusiveMinimum;
|
|
43399
|
+
json2.exclusiveMinimum = true;
|
|
43400
|
+
} else {
|
|
43401
|
+
json2.exclusiveMinimum = exclusiveMinimum;
|
|
43402
|
+
}
|
|
43403
|
+
}
|
|
43208
43404
|
if (typeof minimum === "number") {
|
|
43209
43405
|
json2.minimum = minimum;
|
|
43210
|
-
if (typeof exclusiveMinimum === "number") {
|
|
43406
|
+
if (typeof exclusiveMinimum === "number" && this.target !== "draft-4") {
|
|
43211
43407
|
if (exclusiveMinimum >= minimum)
|
|
43212
43408
|
delete json2.minimum;
|
|
43213
43409
|
else
|
|
43214
43410
|
delete json2.exclusiveMinimum;
|
|
43215
43411
|
}
|
|
43216
43412
|
}
|
|
43217
|
-
if (typeof exclusiveMaximum === "number")
|
|
43218
|
-
|
|
43413
|
+
if (typeof exclusiveMaximum === "number") {
|
|
43414
|
+
if (this.target === "draft-4") {
|
|
43415
|
+
json2.maximum = exclusiveMaximum;
|
|
43416
|
+
json2.exclusiveMaximum = true;
|
|
43417
|
+
} else {
|
|
43418
|
+
json2.exclusiveMaximum = exclusiveMaximum;
|
|
43419
|
+
}
|
|
43420
|
+
}
|
|
43219
43421
|
if (typeof maximum === "number") {
|
|
43220
43422
|
json2.maximum = maximum;
|
|
43221
|
-
if (typeof exclusiveMaximum === "number") {
|
|
43423
|
+
if (typeof exclusiveMaximum === "number" && this.target !== "draft-4") {
|
|
43222
43424
|
if (exclusiveMaximum <= maximum)
|
|
43223
43425
|
delete json2.maximum;
|
|
43224
43426
|
else
|
|
@@ -43387,7 +43589,12 @@ class JSONSchemaGenerator2 {
|
|
|
43387
43589
|
case "record": {
|
|
43388
43590
|
const json2 = _json;
|
|
43389
43591
|
json2.type = "object";
|
|
43390
|
-
|
|
43592
|
+
if (this.target !== "draft-4") {
|
|
43593
|
+
json2.propertyNames = this.process(def.keyType, {
|
|
43594
|
+
...params,
|
|
43595
|
+
path: [...params.path, "propertyNames"]
|
|
43596
|
+
});
|
|
43597
|
+
}
|
|
43391
43598
|
json2.additionalProperties = this.process(def.valueType, {
|
|
43392
43599
|
...params,
|
|
43393
43600
|
path: [...params.path, "additionalProperties"]
|
|
@@ -43437,7 +43644,11 @@ class JSONSchemaGenerator2 {
|
|
|
43437
43644
|
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
43438
43645
|
const val = vals[0];
|
|
43439
43646
|
json2.type = val === null ? "null" : typeof val;
|
|
43440
|
-
|
|
43647
|
+
if (this.target === "draft-4") {
|
|
43648
|
+
json2.enum = [val];
|
|
43649
|
+
} else {
|
|
43650
|
+
json2.const = val;
|
|
43651
|
+
}
|
|
43441
43652
|
} else {
|
|
43442
43653
|
if (vals.every((v) => typeof v === "number"))
|
|
43443
43654
|
json2.type = "number";
|
|
@@ -43683,7 +43894,7 @@ class JSONSchemaGenerator2 {
|
|
|
43683
43894
|
if (ref) {
|
|
43684
43895
|
flattenRef(ref, params2);
|
|
43685
43896
|
const refSchema = this.seen.get(ref).schema;
|
|
43686
|
-
if (refSchema.$ref && params2.target === "draft-7") {
|
|
43897
|
+
if (refSchema.$ref && (params2.target === "draft-7" || params2.target === "draft-4")) {
|
|
43687
43898
|
schema2.allOf = schema2.allOf ?? [];
|
|
43688
43899
|
schema2.allOf.push(refSchema);
|
|
43689
43900
|
} else {
|
|
@@ -43706,6 +43917,8 @@ class JSONSchemaGenerator2 {
|
|
|
43706
43917
|
result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
43707
43918
|
} else if (this.target === "draft-7") {
|
|
43708
43919
|
result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
43920
|
+
} else if (this.target === "draft-4") {
|
|
43921
|
+
result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
43709
43922
|
} else {
|
|
43710
43923
|
console.warn(`Invalid target: ${this.target}`);
|
|
43711
43924
|
}
|
|
@@ -44226,6 +44439,9 @@ var ZodCustomStringFormat2 = /* @__PURE__ */ $constructor2("ZodCustomStringForma
|
|
|
44226
44439
|
function stringFormat2(format, fnOrRegex, _params = {}) {
|
|
44227
44440
|
return _stringFormat2(ZodCustomStringFormat2, format, fnOrRegex, _params);
|
|
44228
44441
|
}
|
|
44442
|
+
function hostname3(_params) {
|
|
44443
|
+
return _stringFormat2(ZodCustomStringFormat2, "hostname", exports_regexes2.hostname, _params);
|
|
44444
|
+
}
|
|
44229
44445
|
var ZodNumber2 = /* @__PURE__ */ $constructor2("ZodNumber", (inst, def) => {
|
|
44230
44446
|
$ZodNumber2.init(inst, def);
|
|
44231
44447
|
ZodType2.init(inst, def);
|
|
@@ -44390,7 +44606,7 @@ function array2(element, params) {
|
|
|
44390
44606
|
}
|
|
44391
44607
|
function keyof2(schema) {
|
|
44392
44608
|
const shape = schema._zod.def.shape;
|
|
44393
|
-
return
|
|
44609
|
+
return _enum4(Object.keys(shape));
|
|
44394
44610
|
}
|
|
44395
44611
|
var ZodObject2 = /* @__PURE__ */ $constructor2("ZodObject", (inst, def) => {
|
|
44396
44612
|
$ZodObject2.init(inst, def);
|
|
@@ -44415,7 +44631,7 @@ function object2(shape, params) {
|
|
|
44415
44631
|
const def = {
|
|
44416
44632
|
type: "object",
|
|
44417
44633
|
get shape() {
|
|
44418
|
-
exports_util2.assignProp(this, "shape",
|
|
44634
|
+
exports_util2.assignProp(this, "shape", shape ? exports_util2.objectClone(shape) : {});
|
|
44419
44635
|
return this.shape;
|
|
44420
44636
|
},
|
|
44421
44637
|
...exports_util2.normalizeParams(params)
|
|
@@ -44426,7 +44642,7 @@ function strictObject2(shape, params) {
|
|
|
44426
44642
|
return new ZodObject2({
|
|
44427
44643
|
type: "object",
|
|
44428
44644
|
get shape() {
|
|
44429
|
-
exports_util2.assignProp(this, "shape",
|
|
44645
|
+
exports_util2.assignProp(this, "shape", exports_util2.objectClone(shape));
|
|
44430
44646
|
return this.shape;
|
|
44431
44647
|
},
|
|
44432
44648
|
catchall: never2(),
|
|
@@ -44437,7 +44653,7 @@ function looseObject2(shape, params) {
|
|
|
44437
44653
|
return new ZodObject2({
|
|
44438
44654
|
type: "object",
|
|
44439
44655
|
get shape() {
|
|
44440
|
-
exports_util2.assignProp(this, "shape",
|
|
44656
|
+
exports_util2.assignProp(this, "shape", exports_util2.objectClone(shape));
|
|
44441
44657
|
return this.shape;
|
|
44442
44658
|
},
|
|
44443
44659
|
catchall: unknown2(),
|
|
@@ -44703,7 +44919,7 @@ function _default4(innerType, defaultValue) {
|
|
|
44703
44919
|
type: "default",
|
|
44704
44920
|
innerType,
|
|
44705
44921
|
get defaultValue() {
|
|
44706
|
-
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
44922
|
+
return typeof defaultValue === "function" ? defaultValue() : exports_util2.shallowClone(defaultValue);
|
|
44707
44923
|
}
|
|
44708
44924
|
});
|
|
44709
44925
|
}
|
|
@@ -44717,7 +44933,7 @@ function prefault2(innerType, defaultValue) {
|
|
|
44717
44933
|
type: "prefault",
|
|
44718
44934
|
innerType,
|
|
44719
44935
|
get defaultValue() {
|
|
44720
|
-
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
44936
|
+
return typeof defaultValue === "function" ? defaultValue() : exports_util2.shallowClone(defaultValue);
|
|
44721
44937
|
}
|
|
44722
44938
|
});
|
|
44723
44939
|
}
|
|
@@ -44839,24 +45055,7 @@ function refine2(fn, _params = {}) {
|
|
|
44839
45055
|
return _refine2(ZodCustom2, fn, _params);
|
|
44840
45056
|
}
|
|
44841
45057
|
function superRefine2(fn) {
|
|
44842
|
-
|
|
44843
|
-
payload.addIssue = (issue3) => {
|
|
44844
|
-
if (typeof issue3 === "string") {
|
|
44845
|
-
payload.issues.push(exports_util2.issue(issue3, payload.value, ch._zod.def));
|
|
44846
|
-
} else {
|
|
44847
|
-
const _issue = issue3;
|
|
44848
|
-
if (_issue.fatal)
|
|
44849
|
-
_issue.continue = false;
|
|
44850
|
-
_issue.code ?? (_issue.code = "custom");
|
|
44851
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
44852
|
-
_issue.inst ?? (_issue.inst = ch);
|
|
44853
|
-
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
44854
|
-
payload.issues.push(exports_util2.issue(_issue));
|
|
44855
|
-
}
|
|
44856
|
-
};
|
|
44857
|
-
return fn(payload.value, payload);
|
|
44858
|
-
});
|
|
44859
|
-
return ch;
|
|
45058
|
+
return _superRefine(fn);
|
|
44860
45059
|
}
|
|
44861
45060
|
function _instanceof2(cls, params = {
|
|
44862
45061
|
error: `Input not instance of ${cls.name}`
|
|
@@ -45190,8 +45389,8 @@ class ZodError3 extends Error {
|
|
|
45190
45389
|
return issue3.message;
|
|
45191
45390
|
};
|
|
45192
45391
|
const fieldErrors = { _errors: [] };
|
|
45193
|
-
const processError = (
|
|
45194
|
-
for (const issue3 of
|
|
45392
|
+
const processError = (error82) => {
|
|
45393
|
+
for (const issue3 of error82.issues) {
|
|
45195
45394
|
if (issue3.code === "invalid_union") {
|
|
45196
45395
|
issue3.unionErrors.map(processError);
|
|
45197
45396
|
} else if (issue3.code === "invalid_return_type") {
|
|
@@ -45254,8 +45453,8 @@ class ZodError3 extends Error {
|
|
|
45254
45453
|
}
|
|
45255
45454
|
}
|
|
45256
45455
|
ZodError3.create = (issues) => {
|
|
45257
|
-
const
|
|
45258
|
-
return
|
|
45456
|
+
const error82 = new ZodError3(issues);
|
|
45457
|
+
return error82;
|
|
45259
45458
|
};
|
|
45260
45459
|
|
|
45261
45460
|
// ../../node_modules/zod-to-json-schema/node_modules/zod/v3/locales/en.js
|
|
@@ -45512,8 +45711,8 @@ var handleResult = (ctx, result) => {
|
|
|
45512
45711
|
get error() {
|
|
45513
45712
|
if (this._error)
|
|
45514
45713
|
return this._error;
|
|
45515
|
-
const
|
|
45516
|
-
this._error =
|
|
45714
|
+
const error82 = new ZodError3(ctx.common.issues);
|
|
45715
|
+
this._error = error82;
|
|
45517
45716
|
return this._error;
|
|
45518
45717
|
}
|
|
45519
45718
|
};
|
|
@@ -48095,25 +48294,25 @@ class ZodFunction extends ZodType3 {
|
|
|
48095
48294
|
});
|
|
48096
48295
|
return INVALID;
|
|
48097
48296
|
}
|
|
48098
|
-
function makeArgsIssue(args,
|
|
48297
|
+
function makeArgsIssue(args, error82) {
|
|
48099
48298
|
return makeIssue({
|
|
48100
48299
|
data: args,
|
|
48101
48300
|
path: ctx.path,
|
|
48102
48301
|
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap3(), en_default3].filter((x) => !!x),
|
|
48103
48302
|
issueData: {
|
|
48104
48303
|
code: ZodIssueCode3.invalid_arguments,
|
|
48105
|
-
argumentsError:
|
|
48304
|
+
argumentsError: error82
|
|
48106
48305
|
}
|
|
48107
48306
|
});
|
|
48108
48307
|
}
|
|
48109
|
-
function makeReturnsIssue(returns,
|
|
48308
|
+
function makeReturnsIssue(returns, error82) {
|
|
48110
48309
|
return makeIssue({
|
|
48111
48310
|
data: returns,
|
|
48112
48311
|
path: ctx.path,
|
|
48113
48312
|
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap3(), en_default3].filter((x) => !!x),
|
|
48114
48313
|
issueData: {
|
|
48115
48314
|
code: ZodIssueCode3.invalid_return_type,
|
|
48116
|
-
returnTypeError:
|
|
48315
|
+
returnTypeError: error82
|
|
48117
48316
|
}
|
|
48118
48317
|
});
|
|
48119
48318
|
}
|
|
@@ -48122,15 +48321,15 @@ class ZodFunction extends ZodType3 {
|
|
|
48122
48321
|
if (this._def.returns instanceof ZodPromise3) {
|
|
48123
48322
|
const me = this;
|
|
48124
48323
|
return OK(async function(...args) {
|
|
48125
|
-
const
|
|
48324
|
+
const error82 = new ZodError3([]);
|
|
48126
48325
|
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
48127
|
-
|
|
48128
|
-
throw
|
|
48326
|
+
error82.addIssue(makeArgsIssue(args, e));
|
|
48327
|
+
throw error82;
|
|
48129
48328
|
});
|
|
48130
48329
|
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
48131
48330
|
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
48132
|
-
|
|
48133
|
-
throw
|
|
48331
|
+
error82.addIssue(makeReturnsIssue(result, e));
|
|
48332
|
+
throw error82;
|
|
48134
48333
|
});
|
|
48135
48334
|
return parsedReturns;
|
|
48136
48335
|
});
|
|
@@ -49993,8 +50192,33 @@ function combineHeaders(...headers) {
|
|
|
49993
50192
|
...currentHeaders != null ? currentHeaders : {}
|
|
49994
50193
|
}), {});
|
|
49995
50194
|
}
|
|
49996
|
-
async function delay(delayInMs) {
|
|
49997
|
-
|
|
50195
|
+
async function delay(delayInMs, options) {
|
|
50196
|
+
if (delayInMs == null) {
|
|
50197
|
+
return Promise.resolve();
|
|
50198
|
+
}
|
|
50199
|
+
const signal = options == null ? undefined : options.abortSignal;
|
|
50200
|
+
return new Promise((resolve2, reject) => {
|
|
50201
|
+
if (signal == null ? undefined : signal.aborted) {
|
|
50202
|
+
reject(createAbortError());
|
|
50203
|
+
return;
|
|
50204
|
+
}
|
|
50205
|
+
const timeoutId = setTimeout(() => {
|
|
50206
|
+
cleanup();
|
|
50207
|
+
resolve2();
|
|
50208
|
+
}, delayInMs);
|
|
50209
|
+
const cleanup = () => {
|
|
50210
|
+
clearTimeout(timeoutId);
|
|
50211
|
+
signal == null || signal.removeEventListener("abort", onAbort);
|
|
50212
|
+
};
|
|
50213
|
+
const onAbort = () => {
|
|
50214
|
+
cleanup();
|
|
50215
|
+
reject(createAbortError());
|
|
50216
|
+
};
|
|
50217
|
+
signal == null || signal.addEventListener("abort", onAbort);
|
|
50218
|
+
});
|
|
50219
|
+
}
|
|
50220
|
+
function createAbortError() {
|
|
50221
|
+
return new DOMException("Delay was aborted", "AbortError");
|
|
49998
50222
|
}
|
|
49999
50223
|
function extractResponseHeaders(response) {
|
|
50000
50224
|
return Object.fromEntries([...response.headers]);
|
|
@@ -50025,32 +50249,32 @@ var createIdGenerator = ({
|
|
|
50025
50249
|
return () => `${prefix}${separator}${generator()}`;
|
|
50026
50250
|
};
|
|
50027
50251
|
var generateId = createIdGenerator();
|
|
50028
|
-
function getErrorMessage2(
|
|
50029
|
-
if (
|
|
50252
|
+
function getErrorMessage2(error82) {
|
|
50253
|
+
if (error82 == null) {
|
|
50030
50254
|
return "unknown error";
|
|
50031
50255
|
}
|
|
50032
|
-
if (typeof
|
|
50033
|
-
return
|
|
50256
|
+
if (typeof error82 === "string") {
|
|
50257
|
+
return error82;
|
|
50034
50258
|
}
|
|
50035
|
-
if (
|
|
50036
|
-
return
|
|
50259
|
+
if (error82 instanceof Error) {
|
|
50260
|
+
return error82.message;
|
|
50037
50261
|
}
|
|
50038
|
-
return JSON.stringify(
|
|
50262
|
+
return JSON.stringify(error82);
|
|
50039
50263
|
}
|
|
50040
|
-
function isAbortError(
|
|
50041
|
-
return
|
|
50264
|
+
function isAbortError(error82) {
|
|
50265
|
+
return (error82 instanceof Error || error82 instanceof DOMException) && (error82.name === "AbortError" || error82.name === "ResponseAborted" || error82.name === "TimeoutError");
|
|
50042
50266
|
}
|
|
50043
50267
|
var FETCH_FAILED_ERROR_MESSAGES = ["fetch failed", "failed to fetch"];
|
|
50044
50268
|
function handleFetchError({
|
|
50045
|
-
error:
|
|
50269
|
+
error: error82,
|
|
50046
50270
|
url: url3,
|
|
50047
50271
|
requestBodyValues
|
|
50048
50272
|
}) {
|
|
50049
|
-
if (isAbortError(
|
|
50050
|
-
return
|
|
50273
|
+
if (isAbortError(error82)) {
|
|
50274
|
+
return error82;
|
|
50051
50275
|
}
|
|
50052
|
-
if (
|
|
50053
|
-
const cause =
|
|
50276
|
+
if (error82 instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES.includes(error82.message.toLowerCase())) {
|
|
50277
|
+
const cause = error82.cause;
|
|
50054
50278
|
if (cause != null) {
|
|
50055
50279
|
return new APICallError({
|
|
50056
50280
|
message: `Cannot connect to API: ${cause.message}`,
|
|
@@ -50061,7 +50285,7 @@ function handleFetchError({
|
|
|
50061
50285
|
});
|
|
50062
50286
|
}
|
|
50063
50287
|
}
|
|
50064
|
-
return
|
|
50288
|
+
return error82;
|
|
50065
50289
|
}
|
|
50066
50290
|
function removeUndefinedEntries(record4) {
|
|
50067
50291
|
return Object.fromEntries(Object.entries(record4).filter(([_key, value]) => value != null));
|
|
@@ -50090,13 +50314,13 @@ var getFromApi = async ({
|
|
|
50090
50314
|
url: url3,
|
|
50091
50315
|
requestBodyValues: {}
|
|
50092
50316
|
});
|
|
50093
|
-
} catch (
|
|
50094
|
-
if (isAbortError(
|
|
50095
|
-
throw
|
|
50317
|
+
} catch (error82) {
|
|
50318
|
+
if (isAbortError(error82) || APICallError.isInstance(error82)) {
|
|
50319
|
+
throw error82;
|
|
50096
50320
|
}
|
|
50097
50321
|
throw new APICallError({
|
|
50098
50322
|
message: "Failed to process error response",
|
|
50099
|
-
cause:
|
|
50323
|
+
cause: error82,
|
|
50100
50324
|
statusCode: response.status,
|
|
50101
50325
|
url: url3,
|
|
50102
50326
|
responseHeaders,
|
|
@@ -50111,23 +50335,23 @@ var getFromApi = async ({
|
|
|
50111
50335
|
url: url3,
|
|
50112
50336
|
requestBodyValues: {}
|
|
50113
50337
|
});
|
|
50114
|
-
} catch (
|
|
50115
|
-
if (
|
|
50116
|
-
if (isAbortError(
|
|
50117
|
-
throw
|
|
50338
|
+
} catch (error82) {
|
|
50339
|
+
if (error82 instanceof Error) {
|
|
50340
|
+
if (isAbortError(error82) || APICallError.isInstance(error82)) {
|
|
50341
|
+
throw error82;
|
|
50118
50342
|
}
|
|
50119
50343
|
}
|
|
50120
50344
|
throw new APICallError({
|
|
50121
50345
|
message: "Failed to process successful response",
|
|
50122
|
-
cause:
|
|
50346
|
+
cause: error82,
|
|
50123
50347
|
statusCode: response.status,
|
|
50124
50348
|
url: url3,
|
|
50125
50349
|
responseHeaders,
|
|
50126
50350
|
requestBodyValues: {}
|
|
50127
50351
|
});
|
|
50128
50352
|
}
|
|
50129
|
-
} catch (
|
|
50130
|
-
throw handleFetchError({ error:
|
|
50353
|
+
} catch (error82) {
|
|
50354
|
+
throw handleFetchError({ error: error82, url: url3, requestBodyValues: {} });
|
|
50131
50355
|
}
|
|
50132
50356
|
};
|
|
50133
50357
|
function isUrlSupported({
|
|
@@ -50251,10 +50475,10 @@ async function safeValidateTypes({
|
|
|
50251
50475
|
error: TypeValidationError.wrap({ value, cause: result.error }),
|
|
50252
50476
|
rawValue: value
|
|
50253
50477
|
};
|
|
50254
|
-
} catch (
|
|
50478
|
+
} catch (error82) {
|
|
50255
50479
|
return {
|
|
50256
50480
|
success: false,
|
|
50257
|
-
error: TypeValidationError.wrap({ value, cause:
|
|
50481
|
+
error: TypeValidationError.wrap({ value, cause: error82 }),
|
|
50258
50482
|
rawValue: value
|
|
50259
50483
|
};
|
|
50260
50484
|
}
|
|
@@ -50269,11 +50493,11 @@ async function parseJSON({
|
|
|
50269
50493
|
return value;
|
|
50270
50494
|
}
|
|
50271
50495
|
return validateTypes({ value, schema });
|
|
50272
|
-
} catch (
|
|
50273
|
-
if (JSONParseError.isInstance(
|
|
50274
|
-
throw
|
|
50496
|
+
} catch (error82) {
|
|
50497
|
+
if (JSONParseError.isInstance(error82) || TypeValidationError.isInstance(error82)) {
|
|
50498
|
+
throw error82;
|
|
50275
50499
|
}
|
|
50276
|
-
throw new JSONParseError({ text, cause:
|
|
50500
|
+
throw new JSONParseError({ text, cause: error82 });
|
|
50277
50501
|
}
|
|
50278
50502
|
}
|
|
50279
50503
|
async function safeParseJSON({
|
|
@@ -50286,10 +50510,10 @@ async function safeParseJSON({
|
|
|
50286
50510
|
return { success: true, value, rawValue: value };
|
|
50287
50511
|
}
|
|
50288
50512
|
return await safeValidateTypes({ value, schema });
|
|
50289
|
-
} catch (
|
|
50513
|
+
} catch (error82) {
|
|
50290
50514
|
return {
|
|
50291
50515
|
success: false,
|
|
50292
|
-
error: JSONParseError.isInstance(
|
|
50516
|
+
error: JSONParseError.isInstance(error82) ? error82 : new JSONParseError({ text, cause: error82 }),
|
|
50293
50517
|
rawValue: undefined
|
|
50294
50518
|
};
|
|
50295
50519
|
}
|
|
@@ -50356,13 +50580,13 @@ var postToApi = async ({
|
|
|
50356
50580
|
url: url3,
|
|
50357
50581
|
requestBodyValues: body.values
|
|
50358
50582
|
});
|
|
50359
|
-
} catch (
|
|
50360
|
-
if (isAbortError(
|
|
50361
|
-
throw
|
|
50583
|
+
} catch (error82) {
|
|
50584
|
+
if (isAbortError(error82) || APICallError.isInstance(error82)) {
|
|
50585
|
+
throw error82;
|
|
50362
50586
|
}
|
|
50363
50587
|
throw new APICallError({
|
|
50364
50588
|
message: "Failed to process error response",
|
|
50365
|
-
cause:
|
|
50589
|
+
cause: error82,
|
|
50366
50590
|
statusCode: response.status,
|
|
50367
50591
|
url: url3,
|
|
50368
50592
|
responseHeaders,
|
|
@@ -50377,23 +50601,23 @@ var postToApi = async ({
|
|
|
50377
50601
|
url: url3,
|
|
50378
50602
|
requestBodyValues: body.values
|
|
50379
50603
|
});
|
|
50380
|
-
} catch (
|
|
50381
|
-
if (
|
|
50382
|
-
if (isAbortError(
|
|
50383
|
-
throw
|
|
50604
|
+
} catch (error82) {
|
|
50605
|
+
if (error82 instanceof Error) {
|
|
50606
|
+
if (isAbortError(error82) || APICallError.isInstance(error82)) {
|
|
50607
|
+
throw error82;
|
|
50384
50608
|
}
|
|
50385
50609
|
}
|
|
50386
50610
|
throw new APICallError({
|
|
50387
50611
|
message: "Failed to process successful response",
|
|
50388
|
-
cause:
|
|
50612
|
+
cause: error82,
|
|
50389
50613
|
statusCode: response.status,
|
|
50390
50614
|
url: url3,
|
|
50391
50615
|
responseHeaders,
|
|
50392
50616
|
requestBodyValues: body.values
|
|
50393
50617
|
});
|
|
50394
50618
|
}
|
|
50395
|
-
} catch (
|
|
50396
|
-
throw handleFetchError({ error:
|
|
50619
|
+
} catch (error82) {
|
|
50620
|
+
throw handleFetchError({ error: error82, url: url3, requestBodyValues: body.values });
|
|
50397
50621
|
}
|
|
50398
50622
|
};
|
|
50399
50623
|
async function resolve(value) {
|
|
@@ -50585,11 +50809,11 @@ var GatewayError = class _GatewayError extends (_b = Error, _a15 = symbol17, _b)
|
|
|
50585
50809
|
this.statusCode = statusCode;
|
|
50586
50810
|
this.cause = cause;
|
|
50587
50811
|
}
|
|
50588
|
-
static isInstance(
|
|
50589
|
-
return _GatewayError.hasMarker(
|
|
50812
|
+
static isInstance(error82) {
|
|
50813
|
+
return _GatewayError.hasMarker(error82);
|
|
50590
50814
|
}
|
|
50591
|
-
static hasMarker(
|
|
50592
|
-
return typeof
|
|
50815
|
+
static hasMarker(error82) {
|
|
50816
|
+
return typeof error82 === "object" && error82 !== null && symbol17 in error82 && error82[symbol17] === true;
|
|
50593
50817
|
}
|
|
50594
50818
|
};
|
|
50595
50819
|
var name14 = "GatewayAuthenticationError";
|
|
@@ -50608,8 +50832,8 @@ var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b2
|
|
|
50608
50832
|
this.name = name14;
|
|
50609
50833
|
this.type = "authentication_error";
|
|
50610
50834
|
}
|
|
50611
|
-
static isInstance(
|
|
50612
|
-
return GatewayError.hasMarker(
|
|
50835
|
+
static isInstance(error82) {
|
|
50836
|
+
return GatewayError.hasMarker(error82) && symbol23 in error82;
|
|
50613
50837
|
}
|
|
50614
50838
|
static createContextualError({
|
|
50615
50839
|
apiKeyProvided,
|
|
@@ -50673,8 +50897,8 @@ var GatewayInvalidRequestError = class extends (_b3 = GatewayError, _a32 = symbo
|
|
|
50673
50897
|
this.name = name22;
|
|
50674
50898
|
this.type = "invalid_request_error";
|
|
50675
50899
|
}
|
|
50676
|
-
static isInstance(
|
|
50677
|
-
return GatewayError.hasMarker(
|
|
50900
|
+
static isInstance(error82) {
|
|
50901
|
+
return GatewayError.hasMarker(error82) && symbol32 in error82;
|
|
50678
50902
|
}
|
|
50679
50903
|
};
|
|
50680
50904
|
var name32 = "GatewayRateLimitError";
|
|
@@ -50693,8 +50917,8 @@ var GatewayRateLimitError = class extends (_b4 = GatewayError, _a42 = symbol42,
|
|
|
50693
50917
|
this.name = name32;
|
|
50694
50918
|
this.type = "rate_limit_exceeded";
|
|
50695
50919
|
}
|
|
50696
|
-
static isInstance(
|
|
50697
|
-
return GatewayError.hasMarker(
|
|
50920
|
+
static isInstance(error82) {
|
|
50921
|
+
return GatewayError.hasMarker(error82) && symbol42 in error82;
|
|
50698
50922
|
}
|
|
50699
50923
|
};
|
|
50700
50924
|
var name42 = "GatewayModelNotFoundError";
|
|
@@ -50718,8 +50942,8 @@ var GatewayModelNotFoundError = class extends (_b5 = GatewayError, _a52 = symbol
|
|
|
50718
50942
|
this.type = "model_not_found";
|
|
50719
50943
|
this.modelId = modelId;
|
|
50720
50944
|
}
|
|
50721
|
-
static isInstance(
|
|
50722
|
-
return GatewayError.hasMarker(
|
|
50945
|
+
static isInstance(error82) {
|
|
50946
|
+
return GatewayError.hasMarker(error82) && symbol52 in error82;
|
|
50723
50947
|
}
|
|
50724
50948
|
};
|
|
50725
50949
|
var name52 = "GatewayInternalServerError";
|
|
@@ -50738,8 +50962,8 @@ var GatewayInternalServerError = class extends (_b6 = GatewayError, _a62 = symbo
|
|
|
50738
50962
|
this.name = name52;
|
|
50739
50963
|
this.type = "internal_server_error";
|
|
50740
50964
|
}
|
|
50741
|
-
static isInstance(
|
|
50742
|
-
return GatewayError.hasMarker(
|
|
50965
|
+
static isInstance(error82) {
|
|
50966
|
+
return GatewayError.hasMarker(error82) && symbol62 in error82;
|
|
50743
50967
|
}
|
|
50744
50968
|
};
|
|
50745
50969
|
var name62 = "GatewayResponseError";
|
|
@@ -50762,8 +50986,8 @@ var GatewayResponseError = class extends (_b7 = GatewayError, _a72 = symbol72, _
|
|
|
50762
50986
|
this.response = response;
|
|
50763
50987
|
this.validationError = validationError;
|
|
50764
50988
|
}
|
|
50765
|
-
static isInstance(
|
|
50766
|
-
return GatewayError.hasMarker(
|
|
50989
|
+
static isInstance(error82) {
|
|
50990
|
+
return GatewayError.hasMarker(error82) && symbol72 in error82;
|
|
50767
50991
|
}
|
|
50768
50992
|
};
|
|
50769
50993
|
function createGatewayErrorFromResponse({
|
|
@@ -50821,42 +51045,42 @@ var gatewayErrorResponseSchema = exports_external2.object({
|
|
|
50821
51045
|
code: exports_external2.union([exports_external2.string(), exports_external2.number()]).nullish()
|
|
50822
51046
|
})
|
|
50823
51047
|
});
|
|
50824
|
-
function asGatewayError(
|
|
51048
|
+
function asGatewayError(error82, authMethod) {
|
|
50825
51049
|
var _a82;
|
|
50826
|
-
if (GatewayError.isInstance(
|
|
50827
|
-
return
|
|
51050
|
+
if (GatewayError.isInstance(error82)) {
|
|
51051
|
+
return error82;
|
|
50828
51052
|
}
|
|
50829
|
-
if (APICallError.isInstance(
|
|
51053
|
+
if (APICallError.isInstance(error82)) {
|
|
50830
51054
|
return createGatewayErrorFromResponse({
|
|
50831
|
-
response: extractApiCallResponse(
|
|
50832
|
-
statusCode: (_a82 =
|
|
51055
|
+
response: extractApiCallResponse(error82),
|
|
51056
|
+
statusCode: (_a82 = error82.statusCode) != null ? _a82 : 500,
|
|
50833
51057
|
defaultMessage: "Gateway request failed",
|
|
50834
|
-
cause:
|
|
51058
|
+
cause: error82,
|
|
50835
51059
|
authMethod
|
|
50836
51060
|
});
|
|
50837
51061
|
}
|
|
50838
51062
|
return createGatewayErrorFromResponse({
|
|
50839
51063
|
response: {},
|
|
50840
51064
|
statusCode: 500,
|
|
50841
|
-
defaultMessage:
|
|
50842
|
-
cause:
|
|
51065
|
+
defaultMessage: error82 instanceof Error ? `Gateway request failed: ${error82.message}` : "Unknown Gateway error",
|
|
51066
|
+
cause: error82,
|
|
50843
51067
|
authMethod
|
|
50844
51068
|
});
|
|
50845
51069
|
}
|
|
50846
|
-
function extractApiCallResponse(
|
|
50847
|
-
if (
|
|
50848
|
-
return
|
|
51070
|
+
function extractApiCallResponse(error82) {
|
|
51071
|
+
if (error82.data !== undefined) {
|
|
51072
|
+
return error82.data;
|
|
50849
51073
|
}
|
|
50850
|
-
if (
|
|
51074
|
+
if (error82.responseBody != null) {
|
|
50851
51075
|
try {
|
|
50852
|
-
return JSON.parse(
|
|
51076
|
+
return JSON.parse(error82.responseBody);
|
|
50853
51077
|
} catch (e) {
|
|
50854
|
-
return
|
|
51078
|
+
return error82.responseBody;
|
|
50855
51079
|
}
|
|
50856
51080
|
}
|
|
50857
51081
|
return {};
|
|
50858
51082
|
}
|
|
50859
|
-
var GATEWAY_AUTH_METHOD_HEADER = "
|
|
51083
|
+
var GATEWAY_AUTH_METHOD_HEADER = "ai-gateway-auth-method";
|
|
50860
51084
|
function parseAuthMethod(headers) {
|
|
50861
51085
|
const result = gatewayAuthMethodSchema.safeParse(headers[GATEWAY_AUTH_METHOD_HEADER]);
|
|
50862
51086
|
return result.success ? result.data : undefined;
|
|
@@ -50882,8 +51106,8 @@ var GatewayFetchMetadata = class {
|
|
|
50882
51106
|
fetch: this.config.fetch
|
|
50883
51107
|
});
|
|
50884
51108
|
return value;
|
|
50885
|
-
} catch (
|
|
50886
|
-
throw asGatewayError(
|
|
51109
|
+
} catch (error82) {
|
|
51110
|
+
throw asGatewayError(error82);
|
|
50887
51111
|
}
|
|
50888
51112
|
}
|
|
50889
51113
|
};
|
|
@@ -50916,8 +51140,16 @@ var GatewayLanguageModel = class {
|
|
|
50916
51140
|
get provider() {
|
|
50917
51141
|
return this.config.provider;
|
|
50918
51142
|
}
|
|
51143
|
+
async getArgs(options) {
|
|
51144
|
+
const { abortSignal: _abortSignal, ...optionsWithoutSignal } = options;
|
|
51145
|
+
return {
|
|
51146
|
+
args: this.maybeEncodeFileParts(optionsWithoutSignal),
|
|
51147
|
+
warnings: []
|
|
51148
|
+
};
|
|
51149
|
+
}
|
|
50919
51150
|
async doGenerate(options) {
|
|
50920
|
-
const {
|
|
51151
|
+
const { args, warnings } = await this.getArgs(options);
|
|
51152
|
+
const { abortSignal } = options;
|
|
50921
51153
|
const resolvedHeaders = await resolve(this.config.headers());
|
|
50922
51154
|
try {
|
|
50923
51155
|
const {
|
|
@@ -50927,7 +51159,7 @@ var GatewayLanguageModel = class {
|
|
|
50927
51159
|
} = await postJsonToApi({
|
|
50928
51160
|
url: this.getUrl(),
|
|
50929
51161
|
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, false), await resolve(this.config.o11yHeaders)),
|
|
50930
|
-
body:
|
|
51162
|
+
body: args,
|
|
50931
51163
|
successfulResponseHandler: createJsonResponseHandler(exports_external2.any()),
|
|
50932
51164
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
50933
51165
|
errorSchema: exports_external2.any(),
|
|
@@ -50938,22 +51170,23 @@ var GatewayLanguageModel = class {
|
|
|
50938
51170
|
});
|
|
50939
51171
|
return {
|
|
50940
51172
|
...responseBody,
|
|
50941
|
-
request: { body },
|
|
51173
|
+
request: { body: args },
|
|
50942
51174
|
response: { headers: responseHeaders, body: rawResponse },
|
|
50943
|
-
warnings
|
|
51175
|
+
warnings
|
|
50944
51176
|
};
|
|
50945
|
-
} catch (
|
|
50946
|
-
throw asGatewayError(
|
|
51177
|
+
} catch (error82) {
|
|
51178
|
+
throw asGatewayError(error82, parseAuthMethod(resolvedHeaders));
|
|
50947
51179
|
}
|
|
50948
51180
|
}
|
|
50949
51181
|
async doStream(options) {
|
|
50950
|
-
const {
|
|
51182
|
+
const { args, warnings } = await this.getArgs(options);
|
|
51183
|
+
const { abortSignal } = options;
|
|
50951
51184
|
const resolvedHeaders = await resolve(this.config.headers());
|
|
50952
51185
|
try {
|
|
50953
51186
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
50954
51187
|
url: this.getUrl(),
|
|
50955
51188
|
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, true), await resolve(this.config.o11yHeaders)),
|
|
50956
|
-
body:
|
|
51189
|
+
body: args,
|
|
50957
51190
|
successfulResponseHandler: createEventSourceResponseHandler(exports_external2.any()),
|
|
50958
51191
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
50959
51192
|
errorSchema: exports_external2.any(),
|
|
@@ -50964,6 +51197,11 @@ var GatewayLanguageModel = class {
|
|
|
50964
51197
|
});
|
|
50965
51198
|
return {
|
|
50966
51199
|
stream: response.pipeThrough(new TransformStream({
|
|
51200
|
+
start(controller) {
|
|
51201
|
+
if (warnings.length > 0) {
|
|
51202
|
+
controller.enqueue({ type: "stream-start", warnings });
|
|
51203
|
+
}
|
|
51204
|
+
},
|
|
50967
51205
|
transform(chunk, controller) {
|
|
50968
51206
|
if (chunk.success) {
|
|
50969
51207
|
const streamPart = chunk.value;
|
|
@@ -50979,11 +51217,11 @@ var GatewayLanguageModel = class {
|
|
|
50979
51217
|
}
|
|
50980
51218
|
}
|
|
50981
51219
|
})),
|
|
50982
|
-
request: { body },
|
|
51220
|
+
request: { body: args },
|
|
50983
51221
|
response: { headers: responseHeaders }
|
|
50984
51222
|
};
|
|
50985
|
-
} catch (
|
|
50986
|
-
throw asGatewayError(
|
|
51223
|
+
} catch (error82) {
|
|
51224
|
+
throw asGatewayError(error82, parseAuthMethod(resolvedHeaders));
|
|
50987
51225
|
}
|
|
50988
51226
|
}
|
|
50989
51227
|
isFilePart(part) {
|
|
@@ -51015,6 +51253,70 @@ var GatewayLanguageModel = class {
|
|
|
51015
51253
|
};
|
|
51016
51254
|
}
|
|
51017
51255
|
};
|
|
51256
|
+
var GatewayEmbeddingModel = class {
|
|
51257
|
+
constructor(modelId, config3) {
|
|
51258
|
+
this.modelId = modelId;
|
|
51259
|
+
this.config = config3;
|
|
51260
|
+
this.specificationVersion = "v2";
|
|
51261
|
+
this.maxEmbeddingsPerCall = 2048;
|
|
51262
|
+
this.supportsParallelCalls = true;
|
|
51263
|
+
}
|
|
51264
|
+
get provider() {
|
|
51265
|
+
return this.config.provider;
|
|
51266
|
+
}
|
|
51267
|
+
async doEmbed({
|
|
51268
|
+
values,
|
|
51269
|
+
headers,
|
|
51270
|
+
abortSignal,
|
|
51271
|
+
providerOptions
|
|
51272
|
+
}) {
|
|
51273
|
+
var _a82;
|
|
51274
|
+
const resolvedHeaders = await resolve(this.config.headers());
|
|
51275
|
+
try {
|
|
51276
|
+
const {
|
|
51277
|
+
responseHeaders,
|
|
51278
|
+
value: responseBody,
|
|
51279
|
+
rawValue
|
|
51280
|
+
} = await postJsonToApi({
|
|
51281
|
+
url: this.getUrl(),
|
|
51282
|
+
headers: combineHeaders(resolvedHeaders, headers != null ? headers : {}, this.getModelConfigHeaders(), await resolve(this.config.o11yHeaders)),
|
|
51283
|
+
body: {
|
|
51284
|
+
input: values.length === 1 ? values[0] : values,
|
|
51285
|
+
...providerOptions != null ? providerOptions : {}
|
|
51286
|
+
},
|
|
51287
|
+
successfulResponseHandler: createJsonResponseHandler(gatewayEmbeddingResponseSchema),
|
|
51288
|
+
failedResponseHandler: createJsonErrorResponseHandler({
|
|
51289
|
+
errorSchema: exports_external2.any(),
|
|
51290
|
+
errorToMessage: (data) => data
|
|
51291
|
+
}),
|
|
51292
|
+
...abortSignal && { abortSignal },
|
|
51293
|
+
fetch: this.config.fetch
|
|
51294
|
+
});
|
|
51295
|
+
return {
|
|
51296
|
+
embeddings: responseBody.embeddings,
|
|
51297
|
+
usage: (_a82 = responseBody.usage) != null ? _a82 : undefined,
|
|
51298
|
+
providerMetadata: responseBody.providerMetadata,
|
|
51299
|
+
response: { headers: responseHeaders, body: rawValue }
|
|
51300
|
+
};
|
|
51301
|
+
} catch (error82) {
|
|
51302
|
+
throw asGatewayError(error82, parseAuthMethod(resolvedHeaders));
|
|
51303
|
+
}
|
|
51304
|
+
}
|
|
51305
|
+
getUrl() {
|
|
51306
|
+
return `${this.config.baseURL}/embedding-model`;
|
|
51307
|
+
}
|
|
51308
|
+
getModelConfigHeaders() {
|
|
51309
|
+
return {
|
|
51310
|
+
"ai-embedding-model-specification-version": "2",
|
|
51311
|
+
"ai-model-id": this.modelId
|
|
51312
|
+
};
|
|
51313
|
+
}
|
|
51314
|
+
};
|
|
51315
|
+
var gatewayEmbeddingResponseSchema = exports_external2.object({
|
|
51316
|
+
embeddings: exports_external2.array(exports_external2.array(exports_external2.number())),
|
|
51317
|
+
usage: exports_external2.object({ tokens: exports_external2.number() }).nullish(),
|
|
51318
|
+
providerMetadata: exports_external2.record(exports_external2.string(), exports_external2.record(exports_external2.string(), exports_external2.unknown())).optional()
|
|
51319
|
+
});
|
|
51018
51320
|
async function getVercelOidcToken() {
|
|
51019
51321
|
var _a82, _b8;
|
|
51020
51322
|
const token = (_b8 = (_a82 = getContext().headers) == null ? undefined : _a82["x-vercel-oidc-token"]) != null ? _b8 : process.env.VERCEL_OIDC_TOKEN;
|
|
@@ -51060,7 +51362,7 @@ function createGatewayProvider(options = {}) {
|
|
|
51060
51362
|
statusCode: 401
|
|
51061
51363
|
});
|
|
51062
51364
|
};
|
|
51063
|
-
const
|
|
51365
|
+
const createO11yHeaders = () => {
|
|
51064
51366
|
const deploymentId = loadOptionalSetting({
|
|
51065
51367
|
settingValue: undefined,
|
|
51066
51368
|
environmentVariableName: "VERCEL_DEPLOYMENT_ID"
|
|
@@ -51073,20 +51375,23 @@ function createGatewayProvider(options = {}) {
|
|
|
51073
51375
|
settingValue: undefined,
|
|
51074
51376
|
environmentVariableName: "VERCEL_REGION"
|
|
51075
51377
|
});
|
|
51378
|
+
return async () => {
|
|
51379
|
+
const requestId = await getVercelRequestId();
|
|
51380
|
+
return {
|
|
51381
|
+
...deploymentId && { "ai-o11y-deployment-id": deploymentId },
|
|
51382
|
+
...environment && { "ai-o11y-environment": environment },
|
|
51383
|
+
...region && { "ai-o11y-region": region },
|
|
51384
|
+
...requestId && { "ai-o11y-request-id": requestId }
|
|
51385
|
+
};
|
|
51386
|
+
};
|
|
51387
|
+
};
|
|
51388
|
+
const createLanguageModel = (modelId) => {
|
|
51076
51389
|
return new GatewayLanguageModel(modelId, {
|
|
51077
51390
|
provider: "gateway",
|
|
51078
51391
|
baseURL,
|
|
51079
51392
|
headers: getHeaders,
|
|
51080
51393
|
fetch: options.fetch,
|
|
51081
|
-
o11yHeaders:
|
|
51082
|
-
const requestId = await getVercelRequestId();
|
|
51083
|
-
return {
|
|
51084
|
-
...deploymentId && { "ai-o11y-deployment-id": deploymentId },
|
|
51085
|
-
...environment && { "ai-o11y-environment": environment },
|
|
51086
|
-
...region && { "ai-o11y-region": region },
|
|
51087
|
-
...requestId && { "ai-o11y-request-id": requestId }
|
|
51088
|
-
};
|
|
51089
|
-
}
|
|
51394
|
+
o11yHeaders: createO11yHeaders()
|
|
51090
51395
|
});
|
|
51091
51396
|
};
|
|
51092
51397
|
const getAvailableModels = async () => {
|
|
@@ -51101,8 +51406,8 @@ function createGatewayProvider(options = {}) {
|
|
|
51101
51406
|
}).getAvailableModels().then((metadata) => {
|
|
51102
51407
|
metadataCache = metadata;
|
|
51103
51408
|
return metadata;
|
|
51104
|
-
}).catch(async (
|
|
51105
|
-
throw asGatewayError(
|
|
51409
|
+
}).catch(async (error82) => {
|
|
51410
|
+
throw asGatewayError(error82, parseAuthMethod(await getHeaders()));
|
|
51106
51411
|
});
|
|
51107
51412
|
}
|
|
51108
51413
|
return metadataCache ? Promise.resolve(metadataCache) : pendingMetadata;
|
|
@@ -51119,7 +51424,13 @@ function createGatewayProvider(options = {}) {
|
|
|
51119
51424
|
};
|
|
51120
51425
|
provider2.languageModel = createLanguageModel;
|
|
51121
51426
|
provider2.textEmbeddingModel = (modelId) => {
|
|
51122
|
-
|
|
51427
|
+
return new GatewayEmbeddingModel(modelId, {
|
|
51428
|
+
provider: "gateway",
|
|
51429
|
+
baseURL,
|
|
51430
|
+
headers: getHeaders,
|
|
51431
|
+
fetch: options.fetch,
|
|
51432
|
+
o11yHeaders: createO11yHeaders()
|
|
51433
|
+
});
|
|
51123
51434
|
};
|
|
51124
51435
|
return provider2;
|
|
51125
51436
|
}
|
|
@@ -51141,7 +51452,7 @@ async function getGatewayAuthToken(options) {
|
|
|
51141
51452
|
token: oidcToken,
|
|
51142
51453
|
authMethod: "oidc"
|
|
51143
51454
|
};
|
|
51144
|
-
} catch (
|
|
51455
|
+
} catch (e) {
|
|
51145
51456
|
return null;
|
|
51146
51457
|
}
|
|
51147
51458
|
}
|
|
@@ -51163,14 +51474,11 @@ var NoOutputSpecifiedError = class extends AISDKError {
|
|
|
51163
51474
|
super({ name: name16, message });
|
|
51164
51475
|
this[_a17] = true;
|
|
51165
51476
|
}
|
|
51166
|
-
static isInstance(
|
|
51167
|
-
return AISDKError.hasMarker(
|
|
51477
|
+
static isInstance(error82) {
|
|
51478
|
+
return AISDKError.hasMarker(error82, marker17);
|
|
51168
51479
|
}
|
|
51169
51480
|
};
|
|
51170
51481
|
_a17 = symbol18;
|
|
51171
|
-
function asArray(value) {
|
|
51172
|
-
return value === undefined ? [] : Array.isArray(value) ? value : [value];
|
|
51173
|
-
}
|
|
51174
51482
|
var name23 = "AI_InvalidArgumentError";
|
|
51175
51483
|
var marker23 = `vercel.ai.error.${name23}`;
|
|
51176
51484
|
var symbol24 = Symbol.for(marker23);
|
|
@@ -51189,132 +51497,210 @@ var InvalidArgumentError3 = class extends AISDKError {
|
|
|
51189
51497
|
this.parameter = parameter;
|
|
51190
51498
|
this.value = value;
|
|
51191
51499
|
}
|
|
51192
|
-
static isInstance(
|
|
51193
|
-
return AISDKError.hasMarker(
|
|
51500
|
+
static isInstance(error82) {
|
|
51501
|
+
return AISDKError.hasMarker(error82, marker23);
|
|
51194
51502
|
}
|
|
51195
51503
|
};
|
|
51196
51504
|
_a23 = symbol24;
|
|
51197
|
-
var name33 = "
|
|
51505
|
+
var name33 = "AI_InvalidStreamPartError";
|
|
51198
51506
|
var marker33 = `vercel.ai.error.${name33}`;
|
|
51199
51507
|
var symbol33 = Symbol.for(marker33);
|
|
51200
51508
|
var _a33;
|
|
51509
|
+
_a33 = symbol33;
|
|
51510
|
+
var name43 = "AI_InvalidToolInputError";
|
|
51511
|
+
var marker43 = `vercel.ai.error.${name43}`;
|
|
51512
|
+
var symbol43 = Symbol.for(marker43);
|
|
51513
|
+
var _a43;
|
|
51514
|
+
var InvalidToolInputError = class extends AISDKError {
|
|
51515
|
+
constructor({
|
|
51516
|
+
toolInput,
|
|
51517
|
+
toolName,
|
|
51518
|
+
cause,
|
|
51519
|
+
message = `Invalid input for tool ${toolName}: ${getErrorMessage(cause)}`
|
|
51520
|
+
}) {
|
|
51521
|
+
super({ name: name43, message, cause });
|
|
51522
|
+
this[_a43] = true;
|
|
51523
|
+
this.toolInput = toolInput;
|
|
51524
|
+
this.toolName = toolName;
|
|
51525
|
+
}
|
|
51526
|
+
static isInstance(error82) {
|
|
51527
|
+
return AISDKError.hasMarker(error82, marker43);
|
|
51528
|
+
}
|
|
51529
|
+
};
|
|
51530
|
+
_a43 = symbol43;
|
|
51531
|
+
var name53 = "AI_MCPClientError";
|
|
51532
|
+
var marker53 = `vercel.ai.error.${name53}`;
|
|
51533
|
+
var symbol53 = Symbol.for(marker53);
|
|
51534
|
+
var _a53;
|
|
51535
|
+
_a53 = symbol53;
|
|
51536
|
+
var name63 = "AI_NoImageGeneratedError";
|
|
51537
|
+
var marker63 = `vercel.ai.error.${name63}`;
|
|
51538
|
+
var symbol63 = Symbol.for(marker63);
|
|
51539
|
+
var _a63;
|
|
51540
|
+
_a63 = symbol63;
|
|
51541
|
+
var name72 = "AI_NoObjectGeneratedError";
|
|
51542
|
+
var marker73 = `vercel.ai.error.${name72}`;
|
|
51543
|
+
var symbol73 = Symbol.for(marker73);
|
|
51544
|
+
var _a73;
|
|
51545
|
+
var NoObjectGeneratedError = class extends AISDKError {
|
|
51546
|
+
constructor({
|
|
51547
|
+
message = "No object generated.",
|
|
51548
|
+
cause,
|
|
51549
|
+
text: text2,
|
|
51550
|
+
response,
|
|
51551
|
+
usage,
|
|
51552
|
+
finishReason
|
|
51553
|
+
}) {
|
|
51554
|
+
super({ name: name72, message, cause });
|
|
51555
|
+
this[_a73] = true;
|
|
51556
|
+
this.text = text2;
|
|
51557
|
+
this.response = response;
|
|
51558
|
+
this.usage = usage;
|
|
51559
|
+
this.finishReason = finishReason;
|
|
51560
|
+
}
|
|
51561
|
+
static isInstance(error82) {
|
|
51562
|
+
return AISDKError.hasMarker(error82, marker73);
|
|
51563
|
+
}
|
|
51564
|
+
};
|
|
51565
|
+
_a73 = symbol73;
|
|
51566
|
+
var name82 = "AI_NoSuchToolError";
|
|
51567
|
+
var marker82 = `vercel.ai.error.${name82}`;
|
|
51568
|
+
var symbol82 = Symbol.for(marker82);
|
|
51569
|
+
var _a82;
|
|
51570
|
+
var NoSuchToolError = class extends AISDKError {
|
|
51571
|
+
constructor({
|
|
51572
|
+
toolName,
|
|
51573
|
+
availableTools = undefined,
|
|
51574
|
+
message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === undefined ? "No tools are available." : `Available tools: ${availableTools.join(", ")}.`}`
|
|
51575
|
+
}) {
|
|
51576
|
+
super({ name: name82, message });
|
|
51577
|
+
this[_a82] = true;
|
|
51578
|
+
this.toolName = toolName;
|
|
51579
|
+
this.availableTools = availableTools;
|
|
51580
|
+
}
|
|
51581
|
+
static isInstance(error82) {
|
|
51582
|
+
return AISDKError.hasMarker(error82, marker82);
|
|
51583
|
+
}
|
|
51584
|
+
};
|
|
51585
|
+
_a82 = symbol82;
|
|
51586
|
+
var name92 = "AI_ToolCallRepairError";
|
|
51587
|
+
var marker92 = `vercel.ai.error.${name92}`;
|
|
51588
|
+
var symbol92 = Symbol.for(marker92);
|
|
51589
|
+
var _a92;
|
|
51590
|
+
var ToolCallRepairError = class extends AISDKError {
|
|
51591
|
+
constructor({
|
|
51592
|
+
cause,
|
|
51593
|
+
originalError,
|
|
51594
|
+
message = `Error repairing tool call: ${getErrorMessage(cause)}`
|
|
51595
|
+
}) {
|
|
51596
|
+
super({ name: name92, message, cause });
|
|
51597
|
+
this[_a92] = true;
|
|
51598
|
+
this.originalError = originalError;
|
|
51599
|
+
}
|
|
51600
|
+
static isInstance(error82) {
|
|
51601
|
+
return AISDKError.hasMarker(error82, marker92);
|
|
51602
|
+
}
|
|
51603
|
+
};
|
|
51604
|
+
_a92 = symbol92;
|
|
51605
|
+
var UnsupportedModelVersionError = class extends AISDKError {
|
|
51606
|
+
constructor(options) {
|
|
51607
|
+
super({
|
|
51608
|
+
name: "AI_UnsupportedModelVersionError",
|
|
51609
|
+
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".`
|
|
51610
|
+
});
|
|
51611
|
+
this.version = options.version;
|
|
51612
|
+
this.provider = options.provider;
|
|
51613
|
+
this.modelId = options.modelId;
|
|
51614
|
+
}
|
|
51615
|
+
};
|
|
51616
|
+
var name102 = "AI_InvalidDataContentError";
|
|
51617
|
+
var marker102 = `vercel.ai.error.${name102}`;
|
|
51618
|
+
var symbol102 = Symbol.for(marker102);
|
|
51619
|
+
var _a102;
|
|
51620
|
+
_a102 = symbol102;
|
|
51621
|
+
var name112 = "AI_InvalidMessageRoleError";
|
|
51622
|
+
var marker112 = `vercel.ai.error.${name112}`;
|
|
51623
|
+
var symbol112 = Symbol.for(marker112);
|
|
51624
|
+
var _a112;
|
|
51625
|
+
var InvalidMessageRoleError = class extends AISDKError {
|
|
51626
|
+
constructor({
|
|
51627
|
+
role,
|
|
51628
|
+
message = `Invalid message role: '${role}'. Must be one of: "system", "user", "assistant", "tool".`
|
|
51629
|
+
}) {
|
|
51630
|
+
super({ name: name112, message });
|
|
51631
|
+
this[_a112] = true;
|
|
51632
|
+
this.role = role;
|
|
51633
|
+
}
|
|
51634
|
+
static isInstance(error82) {
|
|
51635
|
+
return AISDKError.hasMarker(error82, marker112);
|
|
51636
|
+
}
|
|
51637
|
+
};
|
|
51638
|
+
_a112 = symbol112;
|
|
51639
|
+
var name122 = "AI_MessageConversionError";
|
|
51640
|
+
var marker122 = `vercel.ai.error.${name122}`;
|
|
51641
|
+
var symbol122 = Symbol.for(marker122);
|
|
51642
|
+
var _a122;
|
|
51643
|
+
_a122 = symbol122;
|
|
51644
|
+
var name132 = "AI_DownloadError";
|
|
51645
|
+
var marker132 = `vercel.ai.error.${name132}`;
|
|
51646
|
+
var symbol132 = Symbol.for(marker132);
|
|
51647
|
+
var _a132;
|
|
51648
|
+
var DownloadError = class extends AISDKError {
|
|
51649
|
+
constructor({
|
|
51650
|
+
url: url3,
|
|
51651
|
+
statusCode,
|
|
51652
|
+
statusText,
|
|
51653
|
+
cause,
|
|
51654
|
+
message = cause == null ? `Failed to download ${url3}: ${statusCode} ${statusText}` : `Failed to download ${url3}: ${cause}`
|
|
51655
|
+
}) {
|
|
51656
|
+
super({ name: name132, message, cause });
|
|
51657
|
+
this[_a132] = true;
|
|
51658
|
+
this.url = url3;
|
|
51659
|
+
this.statusCode = statusCode;
|
|
51660
|
+
this.statusText = statusText;
|
|
51661
|
+
}
|
|
51662
|
+
static isInstance(error82) {
|
|
51663
|
+
return AISDKError.hasMarker(error82, marker132);
|
|
51664
|
+
}
|
|
51665
|
+
};
|
|
51666
|
+
_a132 = symbol132;
|
|
51667
|
+
var name142 = "AI_RetryError";
|
|
51668
|
+
var marker142 = `vercel.ai.error.${name142}`;
|
|
51669
|
+
var symbol142 = Symbol.for(marker142);
|
|
51670
|
+
var _a142;
|
|
51201
51671
|
var RetryError = class extends AISDKError {
|
|
51202
51672
|
constructor({
|
|
51203
51673
|
message,
|
|
51204
51674
|
reason,
|
|
51205
51675
|
errors: errors5
|
|
51206
51676
|
}) {
|
|
51207
|
-
super({ name:
|
|
51208
|
-
this[
|
|
51677
|
+
super({ name: name142, message });
|
|
51678
|
+
this[_a142] = true;
|
|
51209
51679
|
this.reason = reason;
|
|
51210
51680
|
this.errors = errors5;
|
|
51211
51681
|
this.lastError = errors5[errors5.length - 1];
|
|
51212
51682
|
}
|
|
51213
|
-
static isInstance(
|
|
51214
|
-
return AISDKError.hasMarker(
|
|
51683
|
+
static isInstance(error82) {
|
|
51684
|
+
return AISDKError.hasMarker(error82, marker142);
|
|
51215
51685
|
}
|
|
51216
51686
|
};
|
|
51217
|
-
|
|
51218
|
-
function
|
|
51219
|
-
|
|
51220
|
-
|
|
51221
|
-
|
|
51222
|
-
|
|
51223
|
-
|
|
51224
|
-
|
|
51225
|
-
const timeoutMs = parseFloat(retryAfterMs);
|
|
51226
|
-
if (!Number.isNaN(timeoutMs)) {
|
|
51227
|
-
timeoutMillis = timeoutMs;
|
|
51228
|
-
}
|
|
51229
|
-
}
|
|
51230
|
-
const retryAfter = headers["retry-after"];
|
|
51231
|
-
if (retryAfter && timeoutMillis === undefined) {
|
|
51232
|
-
const timeoutSeconds = parseFloat(retryAfter);
|
|
51233
|
-
if (!Number.isNaN(timeoutSeconds)) {
|
|
51234
|
-
timeoutMillis = timeoutSeconds * 1000;
|
|
51235
|
-
} else {
|
|
51236
|
-
timeoutMillis = Date.parse(retryAfter) - Date.now();
|
|
51237
|
-
}
|
|
51238
|
-
}
|
|
51239
|
-
if (timeoutMillis !== undefined && 0 <= timeoutMillis && timeoutMillis < 60 * 1000) {
|
|
51240
|
-
return timeoutMillis;
|
|
51241
|
-
}
|
|
51242
|
-
return exponentialBackoffDelay;
|
|
51243
|
-
}
|
|
51244
|
-
var retryWithExponentialBackoffRespectingRetryHeaders = ({
|
|
51245
|
-
maxRetries = 2,
|
|
51246
|
-
initialDelayInMs = 2000,
|
|
51247
|
-
backoffFactor = 2
|
|
51248
|
-
} = {}) => async (f) => _retryWithExponentialBackoff(f, {
|
|
51249
|
-
maxRetries,
|
|
51250
|
-
delayInMs: initialDelayInMs,
|
|
51251
|
-
backoffFactor
|
|
51252
|
-
});
|
|
51253
|
-
async function _retryWithExponentialBackoff(f, {
|
|
51254
|
-
maxRetries,
|
|
51255
|
-
delayInMs,
|
|
51256
|
-
backoffFactor
|
|
51257
|
-
}, errors5 = []) {
|
|
51258
|
-
try {
|
|
51259
|
-
return await f();
|
|
51260
|
-
} catch (error81) {
|
|
51261
|
-
if (isAbortError(error81)) {
|
|
51262
|
-
throw error81;
|
|
51263
|
-
}
|
|
51264
|
-
if (maxRetries === 0) {
|
|
51265
|
-
throw error81;
|
|
51266
|
-
}
|
|
51267
|
-
const errorMessage = getErrorMessage2(error81);
|
|
51268
|
-
const newErrors = [...errors5, error81];
|
|
51269
|
-
const tryNumber = newErrors.length;
|
|
51270
|
-
if (tryNumber > maxRetries) {
|
|
51271
|
-
throw new RetryError({
|
|
51272
|
-
message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
|
|
51273
|
-
reason: "maxRetriesExceeded",
|
|
51274
|
-
errors: newErrors
|
|
51687
|
+
_a142 = symbol142;
|
|
51688
|
+
function resolveLanguageModel(model) {
|
|
51689
|
+
if (typeof model !== "string") {
|
|
51690
|
+
if (model.specificationVersion !== "v2") {
|
|
51691
|
+
throw new UnsupportedModelVersionError({
|
|
51692
|
+
version: model.specificationVersion,
|
|
51693
|
+
provider: model.provider,
|
|
51694
|
+
modelId: model.modelId
|
|
51275
51695
|
});
|
|
51276
51696
|
}
|
|
51277
|
-
|
|
51278
|
-
const actualDelay = getRetryDelay(error81, delayInMs);
|
|
51279
|
-
await delay(actualDelay);
|
|
51280
|
-
return _retryWithExponentialBackoff(f, { maxRetries, delayInMs: backoffFactor * delayInMs, backoffFactor }, newErrors);
|
|
51281
|
-
}
|
|
51282
|
-
if (tryNumber === 1) {
|
|
51283
|
-
throw error81;
|
|
51284
|
-
}
|
|
51285
|
-
throw new RetryError({
|
|
51286
|
-
message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
|
|
51287
|
-
reason: "errorNotRetryable",
|
|
51288
|
-
errors: newErrors
|
|
51289
|
-
});
|
|
51697
|
+
return model;
|
|
51290
51698
|
}
|
|
51699
|
+
return getGlobalProvider().languageModel(model);
|
|
51291
51700
|
}
|
|
51292
|
-
function
|
|
51293
|
-
|
|
51294
|
-
|
|
51295
|
-
if (maxRetries != null) {
|
|
51296
|
-
if (!Number.isInteger(maxRetries)) {
|
|
51297
|
-
throw new InvalidArgumentError3({
|
|
51298
|
-
parameter: "maxRetries",
|
|
51299
|
-
value: maxRetries,
|
|
51300
|
-
message: "maxRetries must be an integer"
|
|
51301
|
-
});
|
|
51302
|
-
}
|
|
51303
|
-
if (maxRetries < 0) {
|
|
51304
|
-
throw new InvalidArgumentError3({
|
|
51305
|
-
parameter: "maxRetries",
|
|
51306
|
-
value: maxRetries,
|
|
51307
|
-
message: "maxRetries must be >= 0"
|
|
51308
|
-
});
|
|
51309
|
-
}
|
|
51310
|
-
}
|
|
51311
|
-
const maxRetriesResult = maxRetries != null ? maxRetries : 2;
|
|
51312
|
-
return {
|
|
51313
|
-
maxRetries: maxRetriesResult,
|
|
51314
|
-
retry: retryWithExponentialBackoffRespectingRetryHeaders({
|
|
51315
|
-
maxRetries: maxRetriesResult
|
|
51316
|
-
})
|
|
51317
|
-
};
|
|
51701
|
+
function getGlobalProvider() {
|
|
51702
|
+
var _a16;
|
|
51703
|
+
return (_a16 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a16 : gateway;
|
|
51318
51704
|
}
|
|
51319
51705
|
var imageMediaTypeSignatures = [
|
|
51320
51706
|
{
|
|
@@ -51410,29 +51796,6 @@ function detectMediaType({
|
|
|
51410
51796
|
}
|
|
51411
51797
|
return;
|
|
51412
51798
|
}
|
|
51413
|
-
var name43 = "AI_DownloadError";
|
|
51414
|
-
var marker43 = `vercel.ai.error.${name43}`;
|
|
51415
|
-
var symbol43 = Symbol.for(marker43);
|
|
51416
|
-
var _a43;
|
|
51417
|
-
var DownloadError = class extends AISDKError {
|
|
51418
|
-
constructor({
|
|
51419
|
-
url: url3,
|
|
51420
|
-
statusCode,
|
|
51421
|
-
statusText,
|
|
51422
|
-
cause,
|
|
51423
|
-
message = cause == null ? `Failed to download ${url3}: ${statusCode} ${statusText}` : `Failed to download ${url3}: ${cause}`
|
|
51424
|
-
}) {
|
|
51425
|
-
super({ name: name43, message, cause });
|
|
51426
|
-
this[_a43] = true;
|
|
51427
|
-
this.url = url3;
|
|
51428
|
-
this.statusCode = statusCode;
|
|
51429
|
-
this.statusText = statusText;
|
|
51430
|
-
}
|
|
51431
|
-
static isInstance(error81) {
|
|
51432
|
-
return AISDKError.hasMarker(error81, marker43);
|
|
51433
|
-
}
|
|
51434
|
-
};
|
|
51435
|
-
_a43 = symbol43;
|
|
51436
51799
|
async function download({ url: url3 }) {
|
|
51437
51800
|
var _a16;
|
|
51438
51801
|
const urlText = url3.toString();
|
|
@@ -51449,18 +51812,13 @@ async function download({ url: url3 }) {
|
|
|
51449
51812
|
data: new Uint8Array(await response.arrayBuffer()),
|
|
51450
51813
|
mediaType: (_a16 = response.headers.get("content-type")) != null ? _a16 : undefined
|
|
51451
51814
|
};
|
|
51452
|
-
} catch (
|
|
51453
|
-
if (DownloadError.isInstance(
|
|
51454
|
-
throw
|
|
51815
|
+
} catch (error82) {
|
|
51816
|
+
if (DownloadError.isInstance(error82)) {
|
|
51817
|
+
throw error82;
|
|
51455
51818
|
}
|
|
51456
|
-
throw new DownloadError({ url: urlText, cause:
|
|
51819
|
+
throw new DownloadError({ url: urlText, cause: error82 });
|
|
51457
51820
|
}
|
|
51458
51821
|
}
|
|
51459
|
-
var name53 = "AI_InvalidDataContentError";
|
|
51460
|
-
var marker53 = `vercel.ai.error.${name53}`;
|
|
51461
|
-
var symbol53 = Symbol.for(marker53);
|
|
51462
|
-
var _a53;
|
|
51463
|
-
_a53 = symbol53;
|
|
51464
51822
|
function splitDataUrl(dataUrl) {
|
|
51465
51823
|
try {
|
|
51466
51824
|
const [header, base64Content] = dataUrl.split(",");
|
|
@@ -51468,7 +51826,7 @@ function splitDataUrl(dataUrl) {
|
|
|
51468
51826
|
mediaType: header.split(";")[0].split(":")[1],
|
|
51469
51827
|
base64Content
|
|
51470
51828
|
};
|
|
51471
|
-
} catch (
|
|
51829
|
+
} catch (error82) {
|
|
51472
51830
|
return {
|
|
51473
51831
|
mediaType: undefined,
|
|
51474
51832
|
base64Content: undefined
|
|
@@ -51494,7 +51852,7 @@ function convertToLanguageModelV2DataContent(content) {
|
|
|
51494
51852
|
if (typeof content === "string") {
|
|
51495
51853
|
try {
|
|
51496
51854
|
content = new URL(content);
|
|
51497
|
-
} catch (
|
|
51855
|
+
} catch (error82) {}
|
|
51498
51856
|
}
|
|
51499
51857
|
if (content instanceof URL && content.protocol === "data:") {
|
|
51500
51858
|
const { mediaType: dataUrlMediaType, base64Content } = splitDataUrl(content.toString());
|
|
@@ -51517,24 +51875,6 @@ function convertDataContentToBase64String(content) {
|
|
|
51517
51875
|
}
|
|
51518
51876
|
return convertUint8ArrayToBase64(content);
|
|
51519
51877
|
}
|
|
51520
|
-
var name63 = "AI_InvalidMessageRoleError";
|
|
51521
|
-
var marker63 = `vercel.ai.error.${name63}`;
|
|
51522
|
-
var symbol63 = Symbol.for(marker63);
|
|
51523
|
-
var _a63;
|
|
51524
|
-
var InvalidMessageRoleError = class extends AISDKError {
|
|
51525
|
-
constructor({
|
|
51526
|
-
role,
|
|
51527
|
-
message = `Invalid message role: '${role}'. Must be one of: "system", "user", "assistant", "tool".`
|
|
51528
|
-
}) {
|
|
51529
|
-
super({ name: name63, message });
|
|
51530
|
-
this[_a63] = true;
|
|
51531
|
-
this.role = role;
|
|
51532
|
-
}
|
|
51533
|
-
static isInstance(error81) {
|
|
51534
|
-
return AISDKError.hasMarker(error81, marker63);
|
|
51535
|
-
}
|
|
51536
|
-
};
|
|
51537
|
-
_a63 = symbol63;
|
|
51538
51878
|
async function convertToLanguageModelPrompt({
|
|
51539
51879
|
prompt,
|
|
51540
51880
|
supportedUrls,
|
|
@@ -51844,12 +52184,14 @@ function prepareToolsAndToolChoice({
|
|
|
51844
52184
|
const toolType = tool3.type;
|
|
51845
52185
|
switch (toolType) {
|
|
51846
52186
|
case undefined:
|
|
52187
|
+
case "dynamic":
|
|
51847
52188
|
case "function":
|
|
51848
52189
|
return {
|
|
51849
52190
|
type: "function",
|
|
51850
52191
|
name: name162,
|
|
51851
52192
|
description: tool3.description,
|
|
51852
|
-
inputSchema: asSchema(tool3.inputSchema).jsonSchema
|
|
52193
|
+
inputSchema: asSchema(tool3.inputSchema).jsonSchema,
|
|
52194
|
+
providerOptions: tool3.providerOptions
|
|
51853
52195
|
};
|
|
51854
52196
|
case "provider-defined":
|
|
51855
52197
|
return {
|
|
@@ -51867,136 +52209,6 @@ function prepareToolsAndToolChoice({
|
|
|
51867
52209
|
toolChoice: toolChoice == null ? { type: "auto" } : typeof toolChoice === "string" ? { type: toolChoice } : { type: "tool", toolName: toolChoice.toolName }
|
|
51868
52210
|
};
|
|
51869
52211
|
}
|
|
51870
|
-
var name72 = "AI_InvalidStreamPartError";
|
|
51871
|
-
var marker73 = `vercel.ai.error.${name72}`;
|
|
51872
|
-
var symbol73 = Symbol.for(marker73);
|
|
51873
|
-
var _a73;
|
|
51874
|
-
_a73 = symbol73;
|
|
51875
|
-
var name82 = "AI_InvalidToolInputError";
|
|
51876
|
-
var marker82 = `vercel.ai.error.${name82}`;
|
|
51877
|
-
var symbol82 = Symbol.for(marker82);
|
|
51878
|
-
var _a82;
|
|
51879
|
-
var InvalidToolInputError = class extends AISDKError {
|
|
51880
|
-
constructor({
|
|
51881
|
-
toolInput,
|
|
51882
|
-
toolName,
|
|
51883
|
-
cause,
|
|
51884
|
-
message = `Invalid input for tool ${toolName}: ${getErrorMessage(cause)}`
|
|
51885
|
-
}) {
|
|
51886
|
-
super({ name: name82, message, cause });
|
|
51887
|
-
this[_a82] = true;
|
|
51888
|
-
this.toolInput = toolInput;
|
|
51889
|
-
this.toolName = toolName;
|
|
51890
|
-
}
|
|
51891
|
-
static isInstance(error81) {
|
|
51892
|
-
return AISDKError.hasMarker(error81, marker82);
|
|
51893
|
-
}
|
|
51894
|
-
};
|
|
51895
|
-
_a82 = symbol82;
|
|
51896
|
-
var name92 = "AI_MCPClientError";
|
|
51897
|
-
var marker92 = `vercel.ai.error.${name92}`;
|
|
51898
|
-
var symbol92 = Symbol.for(marker92);
|
|
51899
|
-
var _a92;
|
|
51900
|
-
_a92 = symbol92;
|
|
51901
|
-
var name102 = "AI_NoImageGeneratedError";
|
|
51902
|
-
var marker102 = `vercel.ai.error.${name102}`;
|
|
51903
|
-
var symbol102 = Symbol.for(marker102);
|
|
51904
|
-
var _a102;
|
|
51905
|
-
_a102 = symbol102;
|
|
51906
|
-
var name112 = "AI_NoObjectGeneratedError";
|
|
51907
|
-
var marker112 = `vercel.ai.error.${name112}`;
|
|
51908
|
-
var symbol112 = Symbol.for(marker112);
|
|
51909
|
-
var _a112;
|
|
51910
|
-
var NoObjectGeneratedError = class extends AISDKError {
|
|
51911
|
-
constructor({
|
|
51912
|
-
message = "No object generated.",
|
|
51913
|
-
cause,
|
|
51914
|
-
text: text2,
|
|
51915
|
-
response,
|
|
51916
|
-
usage,
|
|
51917
|
-
finishReason
|
|
51918
|
-
}) {
|
|
51919
|
-
super({ name: name112, message, cause });
|
|
51920
|
-
this[_a112] = true;
|
|
51921
|
-
this.text = text2;
|
|
51922
|
-
this.response = response;
|
|
51923
|
-
this.usage = usage;
|
|
51924
|
-
this.finishReason = finishReason;
|
|
51925
|
-
}
|
|
51926
|
-
static isInstance(error81) {
|
|
51927
|
-
return AISDKError.hasMarker(error81, marker112);
|
|
51928
|
-
}
|
|
51929
|
-
};
|
|
51930
|
-
_a112 = symbol112;
|
|
51931
|
-
var name122 = "AI_NoSuchToolError";
|
|
51932
|
-
var marker122 = `vercel.ai.error.${name122}`;
|
|
51933
|
-
var symbol122 = Symbol.for(marker122);
|
|
51934
|
-
var _a122;
|
|
51935
|
-
var NoSuchToolError = class extends AISDKError {
|
|
51936
|
-
constructor({
|
|
51937
|
-
toolName,
|
|
51938
|
-
availableTools = undefined,
|
|
51939
|
-
message = `Model tried to call unavailable tool '${toolName}'. ${availableTools === undefined ? "No tools are available." : `Available tools: ${availableTools.join(", ")}.`}`
|
|
51940
|
-
}) {
|
|
51941
|
-
super({ name: name122, message });
|
|
51942
|
-
this[_a122] = true;
|
|
51943
|
-
this.toolName = toolName;
|
|
51944
|
-
this.availableTools = availableTools;
|
|
51945
|
-
}
|
|
51946
|
-
static isInstance(error81) {
|
|
51947
|
-
return AISDKError.hasMarker(error81, marker122);
|
|
51948
|
-
}
|
|
51949
|
-
};
|
|
51950
|
-
_a122 = symbol122;
|
|
51951
|
-
var name132 = "AI_ToolCallRepairError";
|
|
51952
|
-
var marker132 = `vercel.ai.error.${name132}`;
|
|
51953
|
-
var symbol132 = Symbol.for(marker132);
|
|
51954
|
-
var _a132;
|
|
51955
|
-
var ToolCallRepairError = class extends AISDKError {
|
|
51956
|
-
constructor({
|
|
51957
|
-
cause,
|
|
51958
|
-
originalError,
|
|
51959
|
-
message = `Error repairing tool call: ${getErrorMessage(cause)}`
|
|
51960
|
-
}) {
|
|
51961
|
-
super({ name: name132, message, cause });
|
|
51962
|
-
this[_a132] = true;
|
|
51963
|
-
this.originalError = originalError;
|
|
51964
|
-
}
|
|
51965
|
-
static isInstance(error81) {
|
|
51966
|
-
return AISDKError.hasMarker(error81, marker132);
|
|
51967
|
-
}
|
|
51968
|
-
};
|
|
51969
|
-
_a132 = symbol132;
|
|
51970
|
-
var UnsupportedModelVersionError = class extends AISDKError {
|
|
51971
|
-
constructor(options) {
|
|
51972
|
-
super({
|
|
51973
|
-
name: "AI_UnsupportedModelVersionError",
|
|
51974
|
-
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".`
|
|
51975
|
-
});
|
|
51976
|
-
this.version = options.version;
|
|
51977
|
-
this.provider = options.provider;
|
|
51978
|
-
this.modelId = options.modelId;
|
|
51979
|
-
}
|
|
51980
|
-
};
|
|
51981
|
-
var name142 = "AI_MessageConversionError";
|
|
51982
|
-
var marker142 = `vercel.ai.error.${name142}`;
|
|
51983
|
-
var symbol142 = Symbol.for(marker142);
|
|
51984
|
-
var _a142;
|
|
51985
|
-
_a142 = symbol142;
|
|
51986
|
-
function resolveLanguageModel(model) {
|
|
51987
|
-
if (typeof model !== "string") {
|
|
51988
|
-
if (model.specificationVersion !== "v2") {
|
|
51989
|
-
throw new UnsupportedModelVersionError({
|
|
51990
|
-
version: model.specificationVersion,
|
|
51991
|
-
provider: model.provider,
|
|
51992
|
-
modelId: model.modelId
|
|
51993
|
-
});
|
|
51994
|
-
}
|
|
51995
|
-
return model;
|
|
51996
|
-
}
|
|
51997
|
-
const globalProvider = globalThis.AI_SDK_DEFAULT_PROVIDER;
|
|
51998
|
-
return (globalProvider != null ? globalProvider : gateway).languageModel(model);
|
|
51999
|
-
}
|
|
52000
52212
|
var jsonValueSchema = exports_external2.lazy(() => exports_external2.union([
|
|
52001
52213
|
exports_external2.null(),
|
|
52002
52214
|
exports_external2.string(),
|
|
@@ -52168,15 +52380,15 @@ async function standardizePrompt(prompt) {
|
|
|
52168
52380
|
system: prompt.system
|
|
52169
52381
|
};
|
|
52170
52382
|
}
|
|
52171
|
-
function wrapGatewayError(
|
|
52172
|
-
if (GatewayAuthenticationError.isInstance(
|
|
52383
|
+
function wrapGatewayError(error82) {
|
|
52384
|
+
if (GatewayAuthenticationError.isInstance(error82) || GatewayModelNotFoundError.isInstance(error82)) {
|
|
52173
52385
|
return new AISDKError({
|
|
52174
52386
|
name: "GatewayError",
|
|
52175
52387
|
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.",
|
|
52176
|
-
cause:
|
|
52388
|
+
cause: error82
|
|
52177
52389
|
});
|
|
52178
52390
|
}
|
|
52179
|
-
return
|
|
52391
|
+
return error82;
|
|
52180
52392
|
}
|
|
52181
52393
|
function assembleOperationName({
|
|
52182
52394
|
operationId,
|
|
@@ -52297,26 +52509,26 @@ function recordSpan({
|
|
|
52297
52509
|
span.end();
|
|
52298
52510
|
}
|
|
52299
52511
|
return result;
|
|
52300
|
-
} catch (
|
|
52512
|
+
} catch (error82) {
|
|
52301
52513
|
try {
|
|
52302
|
-
recordErrorOnSpan(span,
|
|
52514
|
+
recordErrorOnSpan(span, error82);
|
|
52303
52515
|
} finally {
|
|
52304
52516
|
span.end();
|
|
52305
52517
|
}
|
|
52306
|
-
throw
|
|
52518
|
+
throw error82;
|
|
52307
52519
|
}
|
|
52308
52520
|
});
|
|
52309
52521
|
}
|
|
52310
|
-
function recordErrorOnSpan(span,
|
|
52311
|
-
if (
|
|
52522
|
+
function recordErrorOnSpan(span, error82) {
|
|
52523
|
+
if (error82 instanceof Error) {
|
|
52312
52524
|
span.recordException({
|
|
52313
|
-
name:
|
|
52314
|
-
message:
|
|
52315
|
-
stack:
|
|
52525
|
+
name: error82.name,
|
|
52526
|
+
message: error82.message,
|
|
52527
|
+
stack: error82.stack
|
|
52316
52528
|
});
|
|
52317
52529
|
span.setStatus({
|
|
52318
52530
|
code: import_api4.SpanStatusCode.ERROR,
|
|
52319
|
-
message:
|
|
52531
|
+
message: error82.message
|
|
52320
52532
|
});
|
|
52321
52533
|
} else {
|
|
52322
52534
|
span.setStatus({ code: import_api4.SpanStatusCode.ERROR });
|
|
@@ -52371,6 +52583,125 @@ function addLanguageModelUsage(usage1, usage2) {
|
|
|
52371
52583
|
function addTokenCounts(tokenCount1, tokenCount2) {
|
|
52372
52584
|
return tokenCount1 == null && tokenCount2 == null ? undefined : (tokenCount1 != null ? tokenCount1 : 0) + (tokenCount2 != null ? tokenCount2 : 0);
|
|
52373
52585
|
}
|
|
52586
|
+
function asArray(value) {
|
|
52587
|
+
return value === undefined ? [] : Array.isArray(value) ? value : [value];
|
|
52588
|
+
}
|
|
52589
|
+
function getRetryDelayInMs({
|
|
52590
|
+
error: error82,
|
|
52591
|
+
exponentialBackoffDelay
|
|
52592
|
+
}) {
|
|
52593
|
+
const headers = error82.responseHeaders;
|
|
52594
|
+
if (!headers)
|
|
52595
|
+
return exponentialBackoffDelay;
|
|
52596
|
+
let ms;
|
|
52597
|
+
const retryAfterMs = headers["retry-after-ms"];
|
|
52598
|
+
if (retryAfterMs) {
|
|
52599
|
+
const timeoutMs = parseFloat(retryAfterMs);
|
|
52600
|
+
if (!Number.isNaN(timeoutMs)) {
|
|
52601
|
+
ms = timeoutMs;
|
|
52602
|
+
}
|
|
52603
|
+
}
|
|
52604
|
+
const retryAfter = headers["retry-after"];
|
|
52605
|
+
if (retryAfter && ms === undefined) {
|
|
52606
|
+
const timeoutSeconds = parseFloat(retryAfter);
|
|
52607
|
+
if (!Number.isNaN(timeoutSeconds)) {
|
|
52608
|
+
ms = timeoutSeconds * 1000;
|
|
52609
|
+
} else {
|
|
52610
|
+
ms = Date.parse(retryAfter) - Date.now();
|
|
52611
|
+
}
|
|
52612
|
+
}
|
|
52613
|
+
if (ms != null && !Number.isNaN(ms) && 0 <= ms && (ms < 60 * 1000 || ms < exponentialBackoffDelay)) {
|
|
52614
|
+
return ms;
|
|
52615
|
+
}
|
|
52616
|
+
return exponentialBackoffDelay;
|
|
52617
|
+
}
|
|
52618
|
+
var retryWithExponentialBackoffRespectingRetryHeaders = ({
|
|
52619
|
+
maxRetries = 2,
|
|
52620
|
+
initialDelayInMs = 2000,
|
|
52621
|
+
backoffFactor = 2,
|
|
52622
|
+
abortSignal
|
|
52623
|
+
} = {}) => async (f) => _retryWithExponentialBackoff(f, {
|
|
52624
|
+
maxRetries,
|
|
52625
|
+
delayInMs: initialDelayInMs,
|
|
52626
|
+
backoffFactor,
|
|
52627
|
+
abortSignal
|
|
52628
|
+
});
|
|
52629
|
+
async function _retryWithExponentialBackoff(f, {
|
|
52630
|
+
maxRetries,
|
|
52631
|
+
delayInMs,
|
|
52632
|
+
backoffFactor,
|
|
52633
|
+
abortSignal
|
|
52634
|
+
}, errors5 = []) {
|
|
52635
|
+
try {
|
|
52636
|
+
return await f();
|
|
52637
|
+
} catch (error82) {
|
|
52638
|
+
if (isAbortError(error82)) {
|
|
52639
|
+
throw error82;
|
|
52640
|
+
}
|
|
52641
|
+
if (maxRetries === 0) {
|
|
52642
|
+
throw error82;
|
|
52643
|
+
}
|
|
52644
|
+
const errorMessage = getErrorMessage2(error82);
|
|
52645
|
+
const newErrors = [...errors5, error82];
|
|
52646
|
+
const tryNumber = newErrors.length;
|
|
52647
|
+
if (tryNumber > maxRetries) {
|
|
52648
|
+
throw new RetryError({
|
|
52649
|
+
message: `Failed after ${tryNumber} attempts. Last error: ${errorMessage}`,
|
|
52650
|
+
reason: "maxRetriesExceeded",
|
|
52651
|
+
errors: newErrors
|
|
52652
|
+
});
|
|
52653
|
+
}
|
|
52654
|
+
if (error82 instanceof Error && APICallError.isInstance(error82) && error82.isRetryable === true && tryNumber <= maxRetries) {
|
|
52655
|
+
await delay(getRetryDelayInMs({
|
|
52656
|
+
error: error82,
|
|
52657
|
+
exponentialBackoffDelay: delayInMs
|
|
52658
|
+
}), { abortSignal });
|
|
52659
|
+
return _retryWithExponentialBackoff(f, {
|
|
52660
|
+
maxRetries,
|
|
52661
|
+
delayInMs: backoffFactor * delayInMs,
|
|
52662
|
+
backoffFactor,
|
|
52663
|
+
abortSignal
|
|
52664
|
+
}, newErrors);
|
|
52665
|
+
}
|
|
52666
|
+
if (tryNumber === 1) {
|
|
52667
|
+
throw error82;
|
|
52668
|
+
}
|
|
52669
|
+
throw new RetryError({
|
|
52670
|
+
message: `Failed after ${tryNumber} attempts with non-retryable error: '${errorMessage}'`,
|
|
52671
|
+
reason: "errorNotRetryable",
|
|
52672
|
+
errors: newErrors
|
|
52673
|
+
});
|
|
52674
|
+
}
|
|
52675
|
+
}
|
|
52676
|
+
function prepareRetries({
|
|
52677
|
+
maxRetries,
|
|
52678
|
+
abortSignal
|
|
52679
|
+
}) {
|
|
52680
|
+
if (maxRetries != null) {
|
|
52681
|
+
if (!Number.isInteger(maxRetries)) {
|
|
52682
|
+
throw new InvalidArgumentError3({
|
|
52683
|
+
parameter: "maxRetries",
|
|
52684
|
+
value: maxRetries,
|
|
52685
|
+
message: "maxRetries must be an integer"
|
|
52686
|
+
});
|
|
52687
|
+
}
|
|
52688
|
+
if (maxRetries < 0) {
|
|
52689
|
+
throw new InvalidArgumentError3({
|
|
52690
|
+
parameter: "maxRetries",
|
|
52691
|
+
value: maxRetries,
|
|
52692
|
+
message: "maxRetries must be >= 0"
|
|
52693
|
+
});
|
|
52694
|
+
}
|
|
52695
|
+
}
|
|
52696
|
+
const maxRetriesResult = maxRetries != null ? maxRetries : 2;
|
|
52697
|
+
return {
|
|
52698
|
+
maxRetries: maxRetriesResult,
|
|
52699
|
+
retry: retryWithExponentialBackoffRespectingRetryHeaders({
|
|
52700
|
+
maxRetries: maxRetriesResult,
|
|
52701
|
+
abortSignal
|
|
52702
|
+
})
|
|
52703
|
+
};
|
|
52704
|
+
}
|
|
52374
52705
|
function extractContentText(content) {
|
|
52375
52706
|
const parts = content.filter((content2) => content2.type === "text");
|
|
52376
52707
|
if (parts.length === 0) {
|
|
@@ -52414,38 +52745,50 @@ async function parseToolCall({
|
|
|
52414
52745
|
system,
|
|
52415
52746
|
messages
|
|
52416
52747
|
}) {
|
|
52417
|
-
if (tools == null) {
|
|
52418
|
-
throw new NoSuchToolError({ toolName: toolCall.toolName });
|
|
52419
|
-
}
|
|
52420
52748
|
try {
|
|
52421
|
-
|
|
52422
|
-
|
|
52423
|
-
if (repairToolCall == null || !(NoSuchToolError.isInstance(error81) || InvalidToolInputError.isInstance(error81))) {
|
|
52424
|
-
throw error81;
|
|
52749
|
+
if (tools == null) {
|
|
52750
|
+
throw new NoSuchToolError({ toolName: toolCall.toolName });
|
|
52425
52751
|
}
|
|
52426
|
-
let repairedToolCall = null;
|
|
52427
52752
|
try {
|
|
52428
|
-
|
|
52429
|
-
|
|
52430
|
-
|
|
52431
|
-
|
|
52432
|
-
|
|
52433
|
-
|
|
52434
|
-
|
|
52435
|
-
|
|
52436
|
-
|
|
52437
|
-
|
|
52438
|
-
|
|
52439
|
-
|
|
52440
|
-
|
|
52441
|
-
|
|
52442
|
-
|
|
52443
|
-
|
|
52444
|
-
|
|
52445
|
-
|
|
52446
|
-
|
|
52753
|
+
return await doParseToolCall({ toolCall, tools });
|
|
52754
|
+
} catch (error82) {
|
|
52755
|
+
if (repairToolCall == null || !(NoSuchToolError.isInstance(error82) || InvalidToolInputError.isInstance(error82))) {
|
|
52756
|
+
throw error82;
|
|
52757
|
+
}
|
|
52758
|
+
let repairedToolCall = null;
|
|
52759
|
+
try {
|
|
52760
|
+
repairedToolCall = await repairToolCall({
|
|
52761
|
+
toolCall,
|
|
52762
|
+
tools,
|
|
52763
|
+
inputSchema: ({ toolName }) => {
|
|
52764
|
+
const { inputSchema } = tools[toolName];
|
|
52765
|
+
return asSchema(inputSchema).jsonSchema;
|
|
52766
|
+
},
|
|
52767
|
+
system,
|
|
52768
|
+
messages,
|
|
52769
|
+
error: error82
|
|
52770
|
+
});
|
|
52771
|
+
} catch (repairError) {
|
|
52772
|
+
throw new ToolCallRepairError({
|
|
52773
|
+
cause: repairError,
|
|
52774
|
+
originalError: error82
|
|
52775
|
+
});
|
|
52776
|
+
}
|
|
52777
|
+
if (repairedToolCall == null) {
|
|
52778
|
+
throw error82;
|
|
52779
|
+
}
|
|
52780
|
+
return await doParseToolCall({ toolCall: repairedToolCall, tools });
|
|
52447
52781
|
}
|
|
52448
|
-
|
|
52782
|
+
} catch (error82) {
|
|
52783
|
+
return {
|
|
52784
|
+
type: "tool-call",
|
|
52785
|
+
toolCallId: toolCall.toolCallId,
|
|
52786
|
+
toolName: toolCall.toolName,
|
|
52787
|
+
input: toolCall.input,
|
|
52788
|
+
dynamic: true,
|
|
52789
|
+
invalid: true,
|
|
52790
|
+
error: error82
|
|
52791
|
+
};
|
|
52449
52792
|
}
|
|
52450
52793
|
}
|
|
52451
52794
|
async function doParseToolCall({
|
|
@@ -52469,7 +52812,15 @@ async function doParseToolCall({
|
|
|
52469
52812
|
cause: parseResult.error
|
|
52470
52813
|
});
|
|
52471
52814
|
}
|
|
52472
|
-
return {
|
|
52815
|
+
return tool3.type === "dynamic" ? {
|
|
52816
|
+
type: "tool-call",
|
|
52817
|
+
toolCallId: toolCall.toolCallId,
|
|
52818
|
+
toolName: toolCall.toolName,
|
|
52819
|
+
input: parseResult.value,
|
|
52820
|
+
providerExecuted: toolCall.providerExecuted,
|
|
52821
|
+
providerMetadata: toolCall.providerMetadata,
|
|
52822
|
+
dynamic: true
|
|
52823
|
+
} : {
|
|
52473
52824
|
type: "tool-call",
|
|
52474
52825
|
toolCallId: toolCall.toolCallId,
|
|
52475
52826
|
toolName,
|
|
@@ -52514,9 +52865,21 @@ var DefaultStepResult = class {
|
|
|
52514
52865
|
get toolCalls() {
|
|
52515
52866
|
return this.content.filter((part) => part.type === "tool-call");
|
|
52516
52867
|
}
|
|
52868
|
+
get staticToolCalls() {
|
|
52869
|
+
return this.toolCalls.filter((toolCall) => toolCall.dynamic === false);
|
|
52870
|
+
}
|
|
52871
|
+
get dynamicToolCalls() {
|
|
52872
|
+
return this.toolCalls.filter((toolCall) => toolCall.dynamic === true);
|
|
52873
|
+
}
|
|
52517
52874
|
get toolResults() {
|
|
52518
52875
|
return this.content.filter((part) => part.type === "tool-result");
|
|
52519
52876
|
}
|
|
52877
|
+
get staticToolResults() {
|
|
52878
|
+
return this.toolResults.filter((toolResult) => toolResult.dynamic === false);
|
|
52879
|
+
}
|
|
52880
|
+
get dynamicToolResults() {
|
|
52881
|
+
return this.toolResults.filter((toolResult) => toolResult.dynamic === true);
|
|
52882
|
+
}
|
|
52520
52883
|
};
|
|
52521
52884
|
function stepCountIs(stepCount) {
|
|
52522
52885
|
return ({ steps }) => steps.length === stepCount;
|
|
@@ -52535,12 +52898,15 @@ function createToolModelOutput({
|
|
|
52535
52898
|
if (errorMode === "text") {
|
|
52536
52899
|
return { type: "error-text", value: getErrorMessage(output) };
|
|
52537
52900
|
} else if (errorMode === "json") {
|
|
52538
|
-
return { type: "error-json", value: output };
|
|
52901
|
+
return { type: "error-json", value: toJSONValue(output) };
|
|
52539
52902
|
}
|
|
52540
52903
|
if (tool3 == null ? undefined : tool3.toModelOutput) {
|
|
52541
52904
|
return tool3.toModelOutput(output);
|
|
52542
52905
|
}
|
|
52543
|
-
return typeof output === "string" ? { type: "text", value: output } : { type: "json", value: output };
|
|
52906
|
+
return typeof output === "string" ? { type: "text", value: output } : { type: "json", value: toJSONValue(output) };
|
|
52907
|
+
}
|
|
52908
|
+
function toJSONValue(value) {
|
|
52909
|
+
return value === undefined ? null : value;
|
|
52544
52910
|
}
|
|
52545
52911
|
function toResponseMessages({
|
|
52546
52912
|
content: inputContent,
|
|
@@ -52651,6 +53017,7 @@ async function generateText({
|
|
|
52651
53017
|
experimental_prepareStep,
|
|
52652
53018
|
prepareStep = experimental_prepareStep,
|
|
52653
53019
|
experimental_repairToolCall: repairToolCall,
|
|
53020
|
+
experimental_context,
|
|
52654
53021
|
_internal: {
|
|
52655
53022
|
generateId: generateId3 = originalGenerateId,
|
|
52656
53023
|
currentDate = () => /* @__PURE__ */ new Date
|
|
@@ -52660,7 +53027,10 @@ async function generateText({
|
|
|
52660
53027
|
}) {
|
|
52661
53028
|
const model = resolveLanguageModel(modelArg);
|
|
52662
53029
|
const stopConditions = asArray(stopWhen);
|
|
52663
|
-
const { maxRetries, retry } = prepareRetries({
|
|
53030
|
+
const { maxRetries, retry } = prepareRetries({
|
|
53031
|
+
maxRetries: maxRetriesArg,
|
|
53032
|
+
abortSignal
|
|
53033
|
+
});
|
|
52664
53034
|
const callSettings = prepareCallSettings(settings);
|
|
52665
53035
|
const baseTelemetryAttributes = getBaseTelemetryAttributes({
|
|
52666
53036
|
model,
|
|
@@ -52817,25 +53187,44 @@ async function generateText({
|
|
|
52817
53187
|
messages: stepInputMessages
|
|
52818
53188
|
})));
|
|
52819
53189
|
for (const toolCall of stepToolCalls) {
|
|
53190
|
+
if (toolCall.invalid) {
|
|
53191
|
+
continue;
|
|
53192
|
+
}
|
|
52820
53193
|
const tool3 = tools[toolCall.toolName];
|
|
52821
53194
|
if ((tool3 == null ? undefined : tool3.onInputAvailable) != null) {
|
|
52822
53195
|
await tool3.onInputAvailable({
|
|
52823
53196
|
input: toolCall.input,
|
|
52824
53197
|
toolCallId: toolCall.toolCallId,
|
|
52825
53198
|
messages: stepInputMessages,
|
|
52826
|
-
abortSignal
|
|
53199
|
+
abortSignal,
|
|
53200
|
+
experimental_context
|
|
52827
53201
|
});
|
|
52828
53202
|
}
|
|
52829
53203
|
}
|
|
52830
|
-
|
|
52831
|
-
clientToolOutputs =
|
|
52832
|
-
|
|
52833
|
-
|
|
52834
|
-
|
|
52835
|
-
|
|
52836
|
-
|
|
52837
|
-
|
|
52838
|
-
|
|
53204
|
+
const invalidToolCalls = stepToolCalls.filter((toolCall) => toolCall.invalid && toolCall.dynamic);
|
|
53205
|
+
clientToolOutputs = [];
|
|
53206
|
+
for (const toolCall of invalidToolCalls) {
|
|
53207
|
+
clientToolOutputs.push({
|
|
53208
|
+
type: "tool-error",
|
|
53209
|
+
toolCallId: toolCall.toolCallId,
|
|
53210
|
+
toolName: toolCall.toolName,
|
|
53211
|
+
input: toolCall.input,
|
|
53212
|
+
error: getErrorMessage2(toolCall.error),
|
|
53213
|
+
dynamic: true
|
|
53214
|
+
});
|
|
53215
|
+
}
|
|
53216
|
+
clientToolCalls = stepToolCalls.filter((toolCall) => !toolCall.providerExecuted);
|
|
53217
|
+
if (tools != null) {
|
|
53218
|
+
clientToolOutputs.push(...await executeTools({
|
|
53219
|
+
toolCalls: clientToolCalls.filter((toolCall) => !toolCall.invalid),
|
|
53220
|
+
tools,
|
|
53221
|
+
tracer,
|
|
53222
|
+
telemetry,
|
|
53223
|
+
messages: stepInputMessages,
|
|
53224
|
+
abortSignal,
|
|
53225
|
+
experimental_context
|
|
53226
|
+
}));
|
|
53227
|
+
}
|
|
52839
53228
|
const stepContent = asContent({
|
|
52840
53229
|
content: currentModelResponse.content,
|
|
52841
53230
|
toolCalls: stepToolCalls,
|
|
@@ -52889,8 +53278,8 @@ async function generateText({
|
|
|
52889
53278
|
});
|
|
52890
53279
|
}
|
|
52891
53280
|
});
|
|
52892
|
-
} catch (
|
|
52893
|
-
throw wrapGatewayError(
|
|
53281
|
+
} catch (error82) {
|
|
53282
|
+
throw wrapGatewayError(error82);
|
|
52894
53283
|
}
|
|
52895
53284
|
}
|
|
52896
53285
|
async function executeTools({
|
|
@@ -52899,7 +53288,8 @@ async function executeTools({
|
|
|
52899
53288
|
tracer,
|
|
52900
53289
|
telemetry,
|
|
52901
53290
|
messages,
|
|
52902
|
-
abortSignal
|
|
53291
|
+
abortSignal,
|
|
53292
|
+
experimental_context
|
|
52903
53293
|
}) {
|
|
52904
53294
|
const toolOutputs = await Promise.all(toolCalls.map(async ({ toolCallId, toolName, input }) => {
|
|
52905
53295
|
const tool3 = tools[toolName];
|
|
@@ -52917,7 +53307,7 @@ async function executeTools({
|
|
|
52917
53307
|
}),
|
|
52918
53308
|
"ai.toolCall.name": toolName,
|
|
52919
53309
|
"ai.toolCall.id": toolCallId,
|
|
52920
|
-
"ai.toolCall.
|
|
53310
|
+
"ai.toolCall.args": {
|
|
52921
53311
|
output: () => JSON.stringify(input)
|
|
52922
53312
|
}
|
|
52923
53313
|
}
|
|
@@ -52925,17 +53315,18 @@ async function executeTools({
|
|
|
52925
53315
|
tracer,
|
|
52926
53316
|
fn: async (span) => {
|
|
52927
53317
|
try {
|
|
52928
|
-
const
|
|
53318
|
+
const output = await tool3.execute(input, {
|
|
52929
53319
|
toolCallId,
|
|
52930
53320
|
messages,
|
|
52931
|
-
abortSignal
|
|
53321
|
+
abortSignal,
|
|
53322
|
+
experimental_context
|
|
52932
53323
|
});
|
|
52933
53324
|
try {
|
|
52934
53325
|
span.setAttributes(selectTelemetryAttributes({
|
|
52935
53326
|
telemetry,
|
|
52936
53327
|
attributes: {
|
|
52937
53328
|
"ai.toolCall.result": {
|
|
52938
|
-
output: () => JSON.stringify(
|
|
53329
|
+
output: () => JSON.stringify(output)
|
|
52939
53330
|
}
|
|
52940
53331
|
}
|
|
52941
53332
|
}));
|
|
@@ -52945,16 +53336,18 @@ async function executeTools({
|
|
|
52945
53336
|
toolCallId,
|
|
52946
53337
|
toolName,
|
|
52947
53338
|
input,
|
|
52948
|
-
output
|
|
53339
|
+
output,
|
|
53340
|
+
dynamic: tool3.type === "dynamic"
|
|
52949
53341
|
};
|
|
52950
|
-
} catch (
|
|
52951
|
-
recordErrorOnSpan(span,
|
|
53342
|
+
} catch (error82) {
|
|
53343
|
+
recordErrorOnSpan(span, error82);
|
|
52952
53344
|
return {
|
|
52953
53345
|
type: "tool-error",
|
|
52954
53346
|
toolCallId,
|
|
52955
53347
|
toolName,
|
|
52956
53348
|
input,
|
|
52957
|
-
error:
|
|
53349
|
+
error: error82,
|
|
53350
|
+
dynamic: tool3.type === "dynamic"
|
|
52958
53351
|
};
|
|
52959
53352
|
}
|
|
52960
53353
|
}
|
|
@@ -52988,9 +53381,21 @@ var DefaultGenerateTextResult = class {
|
|
|
52988
53381
|
get toolCalls() {
|
|
52989
53382
|
return this.finalStep.toolCalls;
|
|
52990
53383
|
}
|
|
53384
|
+
get staticToolCalls() {
|
|
53385
|
+
return this.finalStep.staticToolCalls;
|
|
53386
|
+
}
|
|
53387
|
+
get dynamicToolCalls() {
|
|
53388
|
+
return this.finalStep.dynamicToolCalls;
|
|
53389
|
+
}
|
|
52991
53390
|
get toolResults() {
|
|
52992
53391
|
return this.finalStep.toolResults;
|
|
52993
53392
|
}
|
|
53393
|
+
get staticToolResults() {
|
|
53394
|
+
return this.finalStep.staticToolResults;
|
|
53395
|
+
}
|
|
53396
|
+
get dynamicToolResults() {
|
|
53397
|
+
return this.finalStep.dynamicToolResults;
|
|
53398
|
+
}
|
|
52994
53399
|
get sources() {
|
|
52995
53400
|
return this.finalStep.sources;
|
|
52996
53401
|
}
|
|
@@ -53074,7 +53479,8 @@ function asContent({
|
|
|
53074
53479
|
toolName: part.toolName,
|
|
53075
53480
|
input: toolCall.input,
|
|
53076
53481
|
error: part.result,
|
|
53077
|
-
providerExecuted: true
|
|
53482
|
+
providerExecuted: true,
|
|
53483
|
+
dynamic: toolCall.dynamic
|
|
53078
53484
|
};
|
|
53079
53485
|
}
|
|
53080
53486
|
return {
|
|
@@ -53083,7 +53489,8 @@ function asContent({
|
|
|
53083
53489
|
toolName: part.toolName,
|
|
53084
53490
|
input: toolCall.input,
|
|
53085
53491
|
output: part.result,
|
|
53086
|
-
providerExecuted: true
|
|
53492
|
+
providerExecuted: true,
|
|
53493
|
+
dynamic: toolCall.dynamic
|
|
53087
53494
|
};
|
|
53088
53495
|
}
|
|
53089
53496
|
}
|
|
@@ -53131,8 +53538,8 @@ function writeToServerResponse({
|
|
|
53131
53538
|
break;
|
|
53132
53539
|
response.write(value);
|
|
53133
53540
|
}
|
|
53134
|
-
} catch (
|
|
53135
|
-
throw
|
|
53541
|
+
} catch (error82) {
|
|
53542
|
+
throw error82;
|
|
53136
53543
|
} finally {
|
|
53137
53544
|
response.end();
|
|
53138
53545
|
}
|
|
@@ -53233,7 +53640,8 @@ var uiMessageChunkSchema = exports_external2.union([
|
|
|
53233
53640
|
type: exports_external2.literal("tool-input-start"),
|
|
53234
53641
|
toolCallId: exports_external2.string(),
|
|
53235
53642
|
toolName: exports_external2.string(),
|
|
53236
|
-
providerExecuted: exports_external2.boolean().optional()
|
|
53643
|
+
providerExecuted: exports_external2.boolean().optional(),
|
|
53644
|
+
dynamic: exports_external2.boolean().optional()
|
|
53237
53645
|
}),
|
|
53238
53646
|
exports_external2.strictObject({
|
|
53239
53647
|
type: exports_external2.literal("tool-input-delta"),
|
|
@@ -53246,19 +53654,32 @@ var uiMessageChunkSchema = exports_external2.union([
|
|
|
53246
53654
|
toolName: exports_external2.string(),
|
|
53247
53655
|
input: exports_external2.unknown(),
|
|
53248
53656
|
providerExecuted: exports_external2.boolean().optional(),
|
|
53249
|
-
providerMetadata: providerMetadataSchema.optional()
|
|
53657
|
+
providerMetadata: providerMetadataSchema.optional(),
|
|
53658
|
+
dynamic: exports_external2.boolean().optional()
|
|
53659
|
+
}),
|
|
53660
|
+
exports_external2.strictObject({
|
|
53661
|
+
type: exports_external2.literal("tool-input-error"),
|
|
53662
|
+
toolCallId: exports_external2.string(),
|
|
53663
|
+
toolName: exports_external2.string(),
|
|
53664
|
+
input: exports_external2.unknown(),
|
|
53665
|
+
providerExecuted: exports_external2.boolean().optional(),
|
|
53666
|
+
providerMetadata: providerMetadataSchema.optional(),
|
|
53667
|
+
dynamic: exports_external2.boolean().optional(),
|
|
53668
|
+
errorText: exports_external2.string()
|
|
53250
53669
|
}),
|
|
53251
53670
|
exports_external2.strictObject({
|
|
53252
53671
|
type: exports_external2.literal("tool-output-available"),
|
|
53253
53672
|
toolCallId: exports_external2.string(),
|
|
53254
53673
|
output: exports_external2.unknown(),
|
|
53255
|
-
providerExecuted: exports_external2.boolean().optional()
|
|
53674
|
+
providerExecuted: exports_external2.boolean().optional(),
|
|
53675
|
+
dynamic: exports_external2.boolean().optional()
|
|
53256
53676
|
}),
|
|
53257
53677
|
exports_external2.strictObject({
|
|
53258
53678
|
type: exports_external2.literal("tool-output-error"),
|
|
53259
53679
|
toolCallId: exports_external2.string(),
|
|
53260
53680
|
errorText: exports_external2.string(),
|
|
53261
|
-
providerExecuted: exports_external2.boolean().optional()
|
|
53681
|
+
providerExecuted: exports_external2.boolean().optional(),
|
|
53682
|
+
dynamic: exports_external2.boolean().optional()
|
|
53262
53683
|
}),
|
|
53263
53684
|
exports_external2.strictObject({
|
|
53264
53685
|
type: exports_external2.literal("reasoning"),
|
|
@@ -53719,18 +54140,34 @@ function createStreamingUIMessageState({
|
|
|
53719
54140
|
}
|
|
53720
54141
|
function processUIMessageStream({
|
|
53721
54142
|
stream,
|
|
53722
|
-
onToolCall,
|
|
53723
54143
|
messageMetadataSchema,
|
|
53724
54144
|
dataPartSchemas,
|
|
53725
54145
|
runUpdateMessageJob,
|
|
53726
54146
|
onError,
|
|
54147
|
+
onToolCall,
|
|
53727
54148
|
onData
|
|
53728
54149
|
}) {
|
|
53729
54150
|
return stream.pipeThrough(new TransformStream({
|
|
53730
54151
|
async transform(chunk, controller) {
|
|
53731
54152
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
53732
54153
|
var _a16, _b8, _c, _d;
|
|
53733
|
-
function
|
|
54154
|
+
function getToolInvocation(toolCallId) {
|
|
54155
|
+
const toolInvocations = state.message.parts.filter(isToolUIPart);
|
|
54156
|
+
const toolInvocation = toolInvocations.find((invocation) => invocation.toolCallId === toolCallId);
|
|
54157
|
+
if (toolInvocation == null) {
|
|
54158
|
+
throw new Error("tool-output-error must be preceded by a tool-input-available");
|
|
54159
|
+
}
|
|
54160
|
+
return toolInvocation;
|
|
54161
|
+
}
|
|
54162
|
+
function getDynamicToolInvocation(toolCallId) {
|
|
54163
|
+
const toolInvocations = state.message.parts.filter((part) => part.type === "dynamic-tool");
|
|
54164
|
+
const toolInvocation = toolInvocations.find((invocation) => invocation.toolCallId === toolCallId);
|
|
54165
|
+
if (toolInvocation == null) {
|
|
54166
|
+
throw new Error("tool-output-error must be preceded by a tool-input-available");
|
|
54167
|
+
}
|
|
54168
|
+
return toolInvocation;
|
|
54169
|
+
}
|
|
54170
|
+
function updateToolPart(options) {
|
|
53734
54171
|
var _a172;
|
|
53735
54172
|
const part = state.message.parts.find((part2) => isToolUIPart(part2) && part2.toolCallId === options.toolCallId);
|
|
53736
54173
|
const anyOptions = options;
|
|
@@ -53740,6 +54177,7 @@ function processUIMessageStream({
|
|
|
53740
54177
|
anyPart.input = anyOptions.input;
|
|
53741
54178
|
anyPart.output = anyOptions.output;
|
|
53742
54179
|
anyPart.errorText = anyOptions.errorText;
|
|
54180
|
+
anyPart.rawInput = anyOptions.rawInput;
|
|
53743
54181
|
anyPart.providerExecuted = (_a172 = anyOptions.providerExecuted) != null ? _a172 : part.providerExecuted;
|
|
53744
54182
|
if (anyOptions.providerMetadata != null && part.state === "input-available") {
|
|
53745
54183
|
part.callProviderMetadata = anyOptions.providerMetadata;
|
|
@@ -53751,12 +54189,41 @@ function processUIMessageStream({
|
|
|
53751
54189
|
state: options.state,
|
|
53752
54190
|
input: anyOptions.input,
|
|
53753
54191
|
output: anyOptions.output,
|
|
54192
|
+
rawInput: anyOptions.rawInput,
|
|
53754
54193
|
errorText: anyOptions.errorText,
|
|
53755
54194
|
providerExecuted: anyOptions.providerExecuted,
|
|
53756
54195
|
...anyOptions.providerMetadata != null ? { callProviderMetadata: anyOptions.providerMetadata } : {}
|
|
53757
54196
|
});
|
|
53758
54197
|
}
|
|
53759
54198
|
}
|
|
54199
|
+
function updateDynamicToolPart(options) {
|
|
54200
|
+
var _a172;
|
|
54201
|
+
const part = state.message.parts.find((part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId);
|
|
54202
|
+
const anyOptions = options;
|
|
54203
|
+
const anyPart = part;
|
|
54204
|
+
if (part != null) {
|
|
54205
|
+
part.state = options.state;
|
|
54206
|
+
anyPart.toolName = options.toolName;
|
|
54207
|
+
anyPart.input = anyOptions.input;
|
|
54208
|
+
anyPart.output = anyOptions.output;
|
|
54209
|
+
anyPart.errorText = anyOptions.errorText;
|
|
54210
|
+
anyPart.rawInput = (_a172 = anyOptions.rawInput) != null ? _a172 : anyPart.rawInput;
|
|
54211
|
+
if (anyOptions.providerMetadata != null && part.state === "input-available") {
|
|
54212
|
+
part.callProviderMetadata = anyOptions.providerMetadata;
|
|
54213
|
+
}
|
|
54214
|
+
} else {
|
|
54215
|
+
state.message.parts.push({
|
|
54216
|
+
type: "dynamic-tool",
|
|
54217
|
+
toolName: options.toolName,
|
|
54218
|
+
toolCallId: options.toolCallId,
|
|
54219
|
+
state: options.state,
|
|
54220
|
+
input: anyOptions.input,
|
|
54221
|
+
output: anyOptions.output,
|
|
54222
|
+
errorText: anyOptions.errorText,
|
|
54223
|
+
...anyOptions.providerMetadata != null ? { callProviderMetadata: anyOptions.providerMetadata } : {}
|
|
54224
|
+
});
|
|
54225
|
+
}
|
|
54226
|
+
}
|
|
53760
54227
|
async function updateMessageMetadata(metadata) {
|
|
53761
54228
|
if (metadata != null) {
|
|
53762
54229
|
const mergedMetadata = state.message.metadata != null ? mergeObjects(state.message.metadata, metadata) : metadata;
|
|
@@ -53861,15 +54328,25 @@ function processUIMessageStream({
|
|
|
53861
54328
|
state.partialToolCalls[chunk.toolCallId] = {
|
|
53862
54329
|
text: "",
|
|
53863
54330
|
toolName: chunk.toolName,
|
|
53864
|
-
index: toolInvocations.length
|
|
54331
|
+
index: toolInvocations.length,
|
|
54332
|
+
dynamic: chunk.dynamic
|
|
53865
54333
|
};
|
|
53866
|
-
|
|
53867
|
-
|
|
53868
|
-
|
|
53869
|
-
|
|
53870
|
-
|
|
53871
|
-
|
|
53872
|
-
|
|
54334
|
+
if (chunk.dynamic) {
|
|
54335
|
+
updateDynamicToolPart({
|
|
54336
|
+
toolCallId: chunk.toolCallId,
|
|
54337
|
+
toolName: chunk.toolName,
|
|
54338
|
+
state: "input-streaming",
|
|
54339
|
+
input: undefined
|
|
54340
|
+
});
|
|
54341
|
+
} else {
|
|
54342
|
+
updateToolPart({
|
|
54343
|
+
toolCallId: chunk.toolCallId,
|
|
54344
|
+
toolName: chunk.toolName,
|
|
54345
|
+
state: "input-streaming",
|
|
54346
|
+
input: undefined,
|
|
54347
|
+
providerExecuted: chunk.providerExecuted
|
|
54348
|
+
});
|
|
54349
|
+
}
|
|
53873
54350
|
write();
|
|
53874
54351
|
break;
|
|
53875
54352
|
}
|
|
@@ -53877,81 +54354,121 @@ function processUIMessageStream({
|
|
|
53877
54354
|
const partialToolCall = state.partialToolCalls[chunk.toolCallId];
|
|
53878
54355
|
partialToolCall.text += chunk.inputTextDelta;
|
|
53879
54356
|
const { value: partialArgs } = await parsePartialJson(partialToolCall.text);
|
|
53880
|
-
|
|
53881
|
-
|
|
53882
|
-
|
|
53883
|
-
|
|
53884
|
-
|
|
53885
|
-
|
|
54357
|
+
if (partialToolCall.dynamic) {
|
|
54358
|
+
updateDynamicToolPart({
|
|
54359
|
+
toolCallId: chunk.toolCallId,
|
|
54360
|
+
toolName: partialToolCall.toolName,
|
|
54361
|
+
state: "input-streaming",
|
|
54362
|
+
input: partialArgs
|
|
54363
|
+
});
|
|
54364
|
+
} else {
|
|
54365
|
+
updateToolPart({
|
|
54366
|
+
toolCallId: chunk.toolCallId,
|
|
54367
|
+
toolName: partialToolCall.toolName,
|
|
54368
|
+
state: "input-streaming",
|
|
54369
|
+
input: partialArgs
|
|
54370
|
+
});
|
|
54371
|
+
}
|
|
53886
54372
|
write();
|
|
53887
54373
|
break;
|
|
53888
54374
|
}
|
|
53889
54375
|
case "tool-input-available": {
|
|
53890
|
-
|
|
53891
|
-
|
|
53892
|
-
|
|
53893
|
-
|
|
53894
|
-
|
|
53895
|
-
|
|
53896
|
-
|
|
53897
|
-
|
|
54376
|
+
if (chunk.dynamic) {
|
|
54377
|
+
updateDynamicToolPart({
|
|
54378
|
+
toolCallId: chunk.toolCallId,
|
|
54379
|
+
toolName: chunk.toolName,
|
|
54380
|
+
state: "input-available",
|
|
54381
|
+
input: chunk.input,
|
|
54382
|
+
providerMetadata: chunk.providerMetadata
|
|
54383
|
+
});
|
|
54384
|
+
} else {
|
|
54385
|
+
updateToolPart({
|
|
54386
|
+
toolCallId: chunk.toolCallId,
|
|
54387
|
+
toolName: chunk.toolName,
|
|
54388
|
+
state: "input-available",
|
|
54389
|
+
input: chunk.input,
|
|
54390
|
+
providerExecuted: chunk.providerExecuted,
|
|
54391
|
+
providerMetadata: chunk.providerMetadata
|
|
54392
|
+
});
|
|
54393
|
+
}
|
|
53898
54394
|
write();
|
|
53899
54395
|
if (onToolCall && !chunk.providerExecuted) {
|
|
53900
|
-
|
|
54396
|
+
await onToolCall({
|
|
53901
54397
|
toolCall: chunk
|
|
53902
54398
|
});
|
|
53903
|
-
if (result != null) {
|
|
53904
|
-
updateToolInvocationPart({
|
|
53905
|
-
toolCallId: chunk.toolCallId,
|
|
53906
|
-
toolName: chunk.toolName,
|
|
53907
|
-
state: "output-available",
|
|
53908
|
-
input: chunk.input,
|
|
53909
|
-
output: result
|
|
53910
|
-
});
|
|
53911
|
-
write();
|
|
53912
|
-
}
|
|
53913
54399
|
}
|
|
53914
54400
|
break;
|
|
53915
54401
|
}
|
|
53916
|
-
case "tool-
|
|
53917
|
-
|
|
53918
|
-
|
|
53919
|
-
|
|
54402
|
+
case "tool-input-error": {
|
|
54403
|
+
if (chunk.dynamic) {
|
|
54404
|
+
updateDynamicToolPart({
|
|
54405
|
+
toolCallId: chunk.toolCallId,
|
|
54406
|
+
toolName: chunk.toolName,
|
|
54407
|
+
state: "output-error",
|
|
54408
|
+
input: chunk.input,
|
|
54409
|
+
errorText: chunk.errorText,
|
|
54410
|
+
providerMetadata: chunk.providerMetadata
|
|
54411
|
+
});
|
|
54412
|
+
} else {
|
|
54413
|
+
updateToolPart({
|
|
54414
|
+
toolCallId: chunk.toolCallId,
|
|
54415
|
+
toolName: chunk.toolName,
|
|
54416
|
+
state: "output-error",
|
|
54417
|
+
input: undefined,
|
|
54418
|
+
rawInput: chunk.input,
|
|
54419
|
+
errorText: chunk.errorText,
|
|
54420
|
+
providerExecuted: chunk.providerExecuted,
|
|
54421
|
+
providerMetadata: chunk.providerMetadata
|
|
54422
|
+
});
|
|
53920
54423
|
}
|
|
53921
|
-
|
|
53922
|
-
|
|
53923
|
-
|
|
54424
|
+
write();
|
|
54425
|
+
break;
|
|
54426
|
+
}
|
|
54427
|
+
case "tool-output-available": {
|
|
54428
|
+
if (chunk.dynamic) {
|
|
54429
|
+
const toolInvocation = getDynamicToolInvocation(chunk.toolCallId);
|
|
54430
|
+
updateDynamicToolPart({
|
|
54431
|
+
toolCallId: chunk.toolCallId,
|
|
54432
|
+
toolName: toolInvocation.toolName,
|
|
54433
|
+
state: "output-available",
|
|
54434
|
+
input: toolInvocation.input,
|
|
54435
|
+
output: chunk.output
|
|
54436
|
+
});
|
|
54437
|
+
} else {
|
|
54438
|
+
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
54439
|
+
updateToolPart({
|
|
54440
|
+
toolCallId: chunk.toolCallId,
|
|
54441
|
+
toolName: getToolName(toolInvocation),
|
|
54442
|
+
state: "output-available",
|
|
54443
|
+
input: toolInvocation.input,
|
|
54444
|
+
output: chunk.output,
|
|
54445
|
+
providerExecuted: chunk.providerExecuted
|
|
54446
|
+
});
|
|
53924
54447
|
}
|
|
53925
|
-
const toolName = getToolName(toolInvocations[toolInvocationIndex]);
|
|
53926
|
-
updateToolInvocationPart({
|
|
53927
|
-
toolCallId: chunk.toolCallId,
|
|
53928
|
-
toolName,
|
|
53929
|
-
state: "output-available",
|
|
53930
|
-
input: toolInvocations[toolInvocationIndex].input,
|
|
53931
|
-
output: chunk.output,
|
|
53932
|
-
providerExecuted: chunk.providerExecuted
|
|
53933
|
-
});
|
|
53934
54448
|
write();
|
|
53935
54449
|
break;
|
|
53936
54450
|
}
|
|
53937
54451
|
case "tool-output-error": {
|
|
53938
|
-
|
|
53939
|
-
|
|
53940
|
-
|
|
53941
|
-
|
|
53942
|
-
|
|
53943
|
-
|
|
53944
|
-
|
|
54452
|
+
if (chunk.dynamic) {
|
|
54453
|
+
const toolInvocation = getDynamicToolInvocation(chunk.toolCallId);
|
|
54454
|
+
updateDynamicToolPart({
|
|
54455
|
+
toolCallId: chunk.toolCallId,
|
|
54456
|
+
toolName: toolInvocation.toolName,
|
|
54457
|
+
state: "output-error",
|
|
54458
|
+
input: toolInvocation.input,
|
|
54459
|
+
errorText: chunk.errorText
|
|
54460
|
+
});
|
|
54461
|
+
} else {
|
|
54462
|
+
const toolInvocation = getToolInvocation(chunk.toolCallId);
|
|
54463
|
+
updateToolPart({
|
|
54464
|
+
toolCallId: chunk.toolCallId,
|
|
54465
|
+
toolName: getToolName(toolInvocation),
|
|
54466
|
+
state: "output-error",
|
|
54467
|
+
input: toolInvocation.input,
|
|
54468
|
+
rawInput: toolInvocation.rawInput,
|
|
54469
|
+
errorText: chunk.errorText
|
|
54470
|
+
});
|
|
53945
54471
|
}
|
|
53946
|
-
const toolName = getToolName(toolInvocations[toolInvocationIndex]);
|
|
53947
|
-
updateToolInvocationPart({
|
|
53948
|
-
toolCallId: chunk.toolCallId,
|
|
53949
|
-
toolName,
|
|
53950
|
-
state: "output-error",
|
|
53951
|
-
input: toolInvocations[toolInvocationIndex].input,
|
|
53952
|
-
errorText: chunk.errorText,
|
|
53953
|
-
providerExecuted: chunk.providerExecuted
|
|
53954
|
-
});
|
|
53955
54472
|
write();
|
|
53956
54473
|
break;
|
|
53957
54474
|
}
|
|
@@ -54127,8 +54644,8 @@ async function consumeStream({
|
|
|
54127
54644
|
if (done)
|
|
54128
54645
|
break;
|
|
54129
54646
|
}
|
|
54130
|
-
} catch (
|
|
54131
|
-
onError == null || onError(
|
|
54647
|
+
} catch (error82) {
|
|
54648
|
+
onError == null || onError(error82);
|
|
54132
54649
|
} finally {
|
|
54133
54650
|
reader.releaseLock();
|
|
54134
54651
|
}
|
|
@@ -54180,8 +54697,8 @@ function createStitchableStream() {
|
|
|
54180
54697
|
} else {
|
|
54181
54698
|
controller == null || controller.enqueue(value);
|
|
54182
54699
|
}
|
|
54183
|
-
} catch (
|
|
54184
|
-
controller == null || controller.error(
|
|
54700
|
+
} catch (error82) {
|
|
54701
|
+
controller == null || controller.error(error82);
|
|
54185
54702
|
innerStreamReaders.shift();
|
|
54186
54703
|
terminate();
|
|
54187
54704
|
}
|
|
@@ -54245,18 +54762,14 @@ var DelayedPromise = class {
|
|
|
54245
54762
|
(_a16 = this._resolve) == null || _a16.call(this, value);
|
|
54246
54763
|
}
|
|
54247
54764
|
}
|
|
54248
|
-
reject(
|
|
54765
|
+
reject(error82) {
|
|
54249
54766
|
var _a16;
|
|
54250
|
-
this.status = { type: "rejected", error:
|
|
54767
|
+
this.status = { type: "rejected", error: error82 };
|
|
54251
54768
|
if (this._promise) {
|
|
54252
|
-
(_a16 = this._reject) == null || _a16.call(this,
|
|
54769
|
+
(_a16 = this._reject) == null || _a16.call(this, error82);
|
|
54253
54770
|
}
|
|
54254
54771
|
}
|
|
54255
54772
|
};
|
|
54256
|
-
function now() {
|
|
54257
|
-
var _a16, _b8;
|
|
54258
|
-
return (_b8 = (_a16 = globalThis == null ? undefined : globalThis.performance) == null ? undefined : _a16.now()) != null ? _b8 : Date.now();
|
|
54259
|
-
}
|
|
54260
54773
|
function filterStreamErrors(readable, onError) {
|
|
54261
54774
|
return new ReadableStream({
|
|
54262
54775
|
async start(controller) {
|
|
@@ -54270,8 +54783,8 @@ function filterStreamErrors(readable, onError) {
|
|
|
54270
54783
|
}
|
|
54271
54784
|
controller.enqueue(value);
|
|
54272
54785
|
}
|
|
54273
|
-
} catch (
|
|
54274
|
-
await onError({ error:
|
|
54786
|
+
} catch (error82) {
|
|
54787
|
+
await onError({ error: error82, controller });
|
|
54275
54788
|
}
|
|
54276
54789
|
},
|
|
54277
54790
|
cancel(reason) {
|
|
@@ -54279,6 +54792,10 @@ function filterStreamErrors(readable, onError) {
|
|
|
54279
54792
|
}
|
|
54280
54793
|
});
|
|
54281
54794
|
}
|
|
54795
|
+
function now() {
|
|
54796
|
+
var _a16, _b8;
|
|
54797
|
+
return (_b8 = (_a16 = globalThis == null ? undefined : globalThis.performance) == null ? undefined : _a16.now()) != null ? _b8 : Date.now();
|
|
54798
|
+
}
|
|
54282
54799
|
function runToolsTransformation({
|
|
54283
54800
|
tools,
|
|
54284
54801
|
generatorStream,
|
|
@@ -54287,7 +54804,8 @@ function runToolsTransformation({
|
|
|
54287
54804
|
system,
|
|
54288
54805
|
messages,
|
|
54289
54806
|
abortSignal,
|
|
54290
|
-
repairToolCall
|
|
54807
|
+
repairToolCall,
|
|
54808
|
+
experimental_context
|
|
54291
54809
|
}) {
|
|
54292
54810
|
let toolResultsStreamController = null;
|
|
54293
54811
|
const toolResultsStream = new ReadableStream({
|
|
@@ -54357,6 +54875,17 @@ function runToolsTransformation({
|
|
|
54357
54875
|
messages
|
|
54358
54876
|
});
|
|
54359
54877
|
controller.enqueue(toolCall);
|
|
54878
|
+
if (toolCall.invalid) {
|
|
54879
|
+
toolResultsStreamController.enqueue({
|
|
54880
|
+
type: "tool-error",
|
|
54881
|
+
toolCallId: toolCall.toolCallId,
|
|
54882
|
+
toolName: toolCall.toolName,
|
|
54883
|
+
input: toolCall.input,
|
|
54884
|
+
error: getErrorMessage2(toolCall.error),
|
|
54885
|
+
dynamic: true
|
|
54886
|
+
});
|
|
54887
|
+
break;
|
|
54888
|
+
}
|
|
54360
54889
|
const tool3 = tools[toolCall.toolName];
|
|
54361
54890
|
toolInputs.set(toolCall.toolCallId, toolCall.input);
|
|
54362
54891
|
if (tool3.onInputAvailable != null) {
|
|
@@ -54364,7 +54893,8 @@ function runToolsTransformation({
|
|
|
54364
54893
|
input: toolCall.input,
|
|
54365
54894
|
toolCallId: toolCall.toolCallId,
|
|
54366
54895
|
messages,
|
|
54367
|
-
abortSignal
|
|
54896
|
+
abortSignal,
|
|
54897
|
+
experimental_context
|
|
54368
54898
|
});
|
|
54369
54899
|
}
|
|
54370
54900
|
if (tool3.execute != null && toolCall.providerExecuted !== true) {
|
|
@@ -54381,7 +54911,7 @@ function runToolsTransformation({
|
|
|
54381
54911
|
}),
|
|
54382
54912
|
"ai.toolCall.name": toolCall.toolName,
|
|
54383
54913
|
"ai.toolCall.id": toolCall.toolCallId,
|
|
54384
|
-
"ai.toolCall.
|
|
54914
|
+
"ai.toolCall.args": {
|
|
54385
54915
|
output: () => JSON.stringify(toolCall.input)
|
|
54386
54916
|
}
|
|
54387
54917
|
}
|
|
@@ -54393,14 +54923,15 @@ function runToolsTransformation({
|
|
|
54393
54923
|
output = await tool3.execute(toolCall.input, {
|
|
54394
54924
|
toolCallId: toolCall.toolCallId,
|
|
54395
54925
|
messages,
|
|
54396
|
-
abortSignal
|
|
54926
|
+
abortSignal,
|
|
54927
|
+
experimental_context
|
|
54397
54928
|
});
|
|
54398
|
-
} catch (
|
|
54399
|
-
recordErrorOnSpan(span,
|
|
54929
|
+
} catch (error82) {
|
|
54930
|
+
recordErrorOnSpan(span, error82);
|
|
54400
54931
|
toolResultsStreamController.enqueue({
|
|
54401
54932
|
...toolCall,
|
|
54402
54933
|
type: "tool-error",
|
|
54403
|
-
error:
|
|
54934
|
+
error: error82
|
|
54404
54935
|
});
|
|
54405
54936
|
outstandingToolResults.delete(toolExecutionId);
|
|
54406
54937
|
attemptClose();
|
|
@@ -54417,7 +54948,7 @@ function runToolsTransformation({
|
|
|
54417
54948
|
span.setAttributes(selectTelemetryAttributes({
|
|
54418
54949
|
telemetry,
|
|
54419
54950
|
attributes: {
|
|
54420
|
-
"ai.toolCall.
|
|
54951
|
+
"ai.toolCall.result": {
|
|
54421
54952
|
output: () => JSON.stringify(output)
|
|
54422
54953
|
}
|
|
54423
54954
|
}
|
|
@@ -54426,8 +54957,8 @@ function runToolsTransformation({
|
|
|
54426
54957
|
}
|
|
54427
54958
|
});
|
|
54428
54959
|
}
|
|
54429
|
-
} catch (
|
|
54430
|
-
toolResultsStreamController.enqueue({ type: "error", error:
|
|
54960
|
+
} catch (error82) {
|
|
54961
|
+
toolResultsStreamController.enqueue({ type: "error", error: error82 });
|
|
54431
54962
|
}
|
|
54432
54963
|
break;
|
|
54433
54964
|
}
|
|
@@ -54511,12 +55042,13 @@ function streamText({
|
|
|
54511
55042
|
experimental_transform: transform3,
|
|
54512
55043
|
includeRawChunks = false,
|
|
54513
55044
|
onChunk,
|
|
54514
|
-
onError = ({ error:
|
|
54515
|
-
console.error(
|
|
55045
|
+
onError = ({ error: error82 }) => {
|
|
55046
|
+
console.error(error82);
|
|
54516
55047
|
},
|
|
54517
55048
|
onFinish,
|
|
54518
55049
|
onAbort,
|
|
54519
55050
|
onStepFinish,
|
|
55051
|
+
experimental_context,
|
|
54520
55052
|
_internal: {
|
|
54521
55053
|
now: now2 = now,
|
|
54522
55054
|
generateId: generateId3 = originalGenerateId2,
|
|
@@ -54551,7 +55083,8 @@ function streamText({
|
|
|
54551
55083
|
onStepFinish,
|
|
54552
55084
|
now: now2,
|
|
54553
55085
|
currentDate,
|
|
54554
|
-
generateId: generateId3
|
|
55086
|
+
generateId: generateId3,
|
|
55087
|
+
experimental_context
|
|
54555
55088
|
});
|
|
54556
55089
|
}
|
|
54557
55090
|
function createOutputTransformStream(output) {
|
|
@@ -54572,7 +55105,7 @@ function createOutputTransformStream(output) {
|
|
|
54572
55105
|
}) {
|
|
54573
55106
|
controller.enqueue({
|
|
54574
55107
|
part: {
|
|
54575
|
-
type: "text",
|
|
55108
|
+
type: "text-delta",
|
|
54576
55109
|
id: firstTextChunkId,
|
|
54577
55110
|
text: textChunk
|
|
54578
55111
|
},
|
|
@@ -54585,7 +55118,7 @@ function createOutputTransformStream(output) {
|
|
|
54585
55118
|
if (chunk.type === "finish-step" && textChunk.length > 0) {
|
|
54586
55119
|
publishTextChunk({ controller });
|
|
54587
55120
|
}
|
|
54588
|
-
if (chunk.type !== "text" && chunk.type !== "text-start" && chunk.type !== "text-end") {
|
|
55121
|
+
if (chunk.type !== "text-delta" && chunk.type !== "text-start" && chunk.type !== "text-end") {
|
|
54589
55122
|
controller.enqueue({ part: chunk, partialOutput: undefined });
|
|
54590
55123
|
return;
|
|
54591
55124
|
}
|
|
@@ -54647,13 +55180,15 @@ var DefaultStreamTextResult = class {
|
|
|
54647
55180
|
onError,
|
|
54648
55181
|
onFinish,
|
|
54649
55182
|
onAbort,
|
|
54650
|
-
onStepFinish
|
|
55183
|
+
onStepFinish,
|
|
55184
|
+
experimental_context
|
|
54651
55185
|
}) {
|
|
54652
55186
|
this._totalUsage = new DelayedPromise;
|
|
54653
55187
|
this._finishReason = new DelayedPromise;
|
|
54654
55188
|
this._steps = new DelayedPromise;
|
|
54655
55189
|
this.output = output;
|
|
54656
55190
|
this.includeRawChunks = includeRawChunks;
|
|
55191
|
+
this.tools = tools;
|
|
54657
55192
|
let stepFinish;
|
|
54658
55193
|
let recordedContent = [];
|
|
54659
55194
|
const recordedResponseMessages = [];
|
|
@@ -54670,7 +55205,7 @@ var DefaultStreamTextResult = class {
|
|
|
54670
55205
|
var _a16, _b8, _c;
|
|
54671
55206
|
controller.enqueue(chunk);
|
|
54672
55207
|
const { part } = chunk;
|
|
54673
|
-
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") {
|
|
55208
|
+
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") {
|
|
54674
55209
|
await (onChunk == null ? undefined : onChunk({ chunk: part }));
|
|
54675
55210
|
}
|
|
54676
55211
|
if (part.type === "error") {
|
|
@@ -54684,7 +55219,7 @@ var DefaultStreamTextResult = class {
|
|
|
54684
55219
|
};
|
|
54685
55220
|
recordedContent.push(activeTextContent[part.id]);
|
|
54686
55221
|
}
|
|
54687
|
-
if (part.type === "text") {
|
|
55222
|
+
if (part.type === "text-delta") {
|
|
54688
55223
|
const activeText = activeTextContent[part.id];
|
|
54689
55224
|
if (activeText == null) {
|
|
54690
55225
|
controller.enqueue({
|
|
@@ -54710,7 +55245,7 @@ var DefaultStreamTextResult = class {
|
|
|
54710
55245
|
};
|
|
54711
55246
|
recordedContent.push(activeReasoningContent[part.id]);
|
|
54712
55247
|
}
|
|
54713
|
-
if (part.type === "reasoning") {
|
|
55248
|
+
if (part.type === "reasoning-delta") {
|
|
54714
55249
|
const activeReasoning = activeReasoningContent[part.id];
|
|
54715
55250
|
if (activeReasoning == null) {
|
|
54716
55251
|
controller.enqueue({
|
|
@@ -54815,7 +55350,11 @@ var DefaultStreamTextResult = class {
|
|
|
54815
55350
|
files: finalStep.files,
|
|
54816
55351
|
sources: finalStep.sources,
|
|
54817
55352
|
toolCalls: finalStep.toolCalls,
|
|
55353
|
+
staticToolCalls: finalStep.staticToolCalls,
|
|
55354
|
+
dynamicToolCalls: finalStep.dynamicToolCalls,
|
|
54818
55355
|
toolResults: finalStep.toolResults,
|
|
55356
|
+
staticToolResults: finalStep.staticToolResults,
|
|
55357
|
+
dynamicToolResults: finalStep.dynamicToolResults,
|
|
54819
55358
|
request: finalStep.request,
|
|
54820
55359
|
response: finalStep.response,
|
|
54821
55360
|
warnings: finalStep.warnings,
|
|
@@ -54841,8 +55380,8 @@ var DefaultStreamTextResult = class {
|
|
|
54841
55380
|
"ai.usage.cachedInputTokens": totalUsage.cachedInputTokens
|
|
54842
55381
|
}
|
|
54843
55382
|
}));
|
|
54844
|
-
} catch (
|
|
54845
|
-
controller.error(
|
|
55383
|
+
} catch (error82) {
|
|
55384
|
+
controller.error(error82);
|
|
54846
55385
|
} finally {
|
|
54847
55386
|
rootSpan.end();
|
|
54848
55387
|
}
|
|
@@ -54852,13 +55391,13 @@ var DefaultStreamTextResult = class {
|
|
|
54852
55391
|
this.addStream = stitchableStream.addStream;
|
|
54853
55392
|
this.closeStream = stitchableStream.close;
|
|
54854
55393
|
let stream = stitchableStream.stream;
|
|
54855
|
-
stream = filterStreamErrors(stream, ({ error:
|
|
54856
|
-
if (isAbortError(
|
|
55394
|
+
stream = filterStreamErrors(stream, ({ error: error82, controller }) => {
|
|
55395
|
+
if (isAbortError(error82) && (abortSignal == null ? undefined : abortSignal.aborted)) {
|
|
54857
55396
|
onAbort == null || onAbort({ steps: recordedSteps });
|
|
54858
55397
|
controller.enqueue({ type: "abort" });
|
|
54859
55398
|
controller.close();
|
|
54860
55399
|
} else {
|
|
54861
|
-
controller.error(
|
|
55400
|
+
controller.error(error82);
|
|
54862
55401
|
}
|
|
54863
55402
|
});
|
|
54864
55403
|
stream = stream.pipeThrough(new TransformStream({
|
|
@@ -54876,7 +55415,8 @@ var DefaultStreamTextResult = class {
|
|
|
54876
55415
|
}
|
|
54877
55416
|
this.baseStream = stream.pipeThrough(createOutputTransformStream(output)).pipeThrough(eventProcessor);
|
|
54878
55417
|
const { maxRetries, retry } = prepareRetries({
|
|
54879
|
-
maxRetries: maxRetriesArg
|
|
55418
|
+
maxRetries: maxRetriesArg,
|
|
55419
|
+
abortSignal
|
|
54880
55420
|
});
|
|
54881
55421
|
const tracer = getTracer(telemetry);
|
|
54882
55422
|
const callSettings = prepareCallSettings(settings);
|
|
@@ -55003,7 +55543,8 @@ var DefaultStreamTextResult = class {
|
|
|
55003
55543
|
system,
|
|
55004
55544
|
messages: stepInputMessages,
|
|
55005
55545
|
repairToolCall,
|
|
55006
|
-
abortSignal
|
|
55546
|
+
abortSignal,
|
|
55547
|
+
experimental_context
|
|
55007
55548
|
});
|
|
55008
55549
|
const stepRequest = request != null ? request : {};
|
|
55009
55550
|
const stepToolCalls = [];
|
|
@@ -55056,7 +55597,7 @@ var DefaultStreamTextResult = class {
|
|
|
55056
55597
|
case "text-delta": {
|
|
55057
55598
|
if (chunk.delta.length > 0) {
|
|
55058
55599
|
controller.enqueue({
|
|
55059
|
-
type: "text",
|
|
55600
|
+
type: "text-delta",
|
|
55060
55601
|
id: chunk.id,
|
|
55061
55602
|
text: chunk.delta,
|
|
55062
55603
|
providerMetadata: chunk.providerMetadata
|
|
@@ -55072,7 +55613,7 @@ var DefaultStreamTextResult = class {
|
|
|
55072
55613
|
}
|
|
55073
55614
|
case "reasoning-delta": {
|
|
55074
55615
|
controller.enqueue({
|
|
55075
|
-
type: "reasoning",
|
|
55616
|
+
type: "reasoning-delta",
|
|
55076
55617
|
id: chunk.id,
|
|
55077
55618
|
text: chunk.delta,
|
|
55078
55619
|
providerMetadata: chunk.providerMetadata
|
|
@@ -55129,10 +55670,14 @@ var DefaultStreamTextResult = class {
|
|
|
55129
55670
|
await tool3.onInputStart({
|
|
55130
55671
|
toolCallId: chunk.id,
|
|
55131
55672
|
messages: stepInputMessages,
|
|
55132
|
-
abortSignal
|
|
55673
|
+
abortSignal,
|
|
55674
|
+
experimental_context
|
|
55133
55675
|
});
|
|
55134
55676
|
}
|
|
55135
|
-
controller.enqueue(
|
|
55677
|
+
controller.enqueue({
|
|
55678
|
+
...chunk,
|
|
55679
|
+
dynamic: (tool3 == null ? undefined : tool3.type) === "dynamic"
|
|
55680
|
+
});
|
|
55136
55681
|
break;
|
|
55137
55682
|
}
|
|
55138
55683
|
case "tool-input-end": {
|
|
@@ -55148,7 +55693,8 @@ var DefaultStreamTextResult = class {
|
|
|
55148
55693
|
inputTextDelta: chunk.delta,
|
|
55149
55694
|
toolCallId: chunk.id,
|
|
55150
55695
|
messages: stepInputMessages,
|
|
55151
|
-
abortSignal
|
|
55696
|
+
abortSignal,
|
|
55697
|
+
experimental_context
|
|
55152
55698
|
});
|
|
55153
55699
|
}
|
|
55154
55700
|
controller.enqueue(chunk);
|
|
@@ -55200,7 +55746,7 @@ var DefaultStreamTextResult = class {
|
|
|
55200
55746
|
"gen_ai.usage.output_tokens": stepUsage.outputTokens
|
|
55201
55747
|
}
|
|
55202
55748
|
}));
|
|
55203
|
-
} catch (
|
|
55749
|
+
} catch (error82) {} finally {
|
|
55204
55750
|
doStreamSpan.end();
|
|
55205
55751
|
}
|
|
55206
55752
|
controller.enqueue({
|
|
@@ -55231,10 +55777,10 @@ var DefaultStreamTextResult = class {
|
|
|
55231
55777
|
responseMessages,
|
|
55232
55778
|
usage: combinedUsage
|
|
55233
55779
|
});
|
|
55234
|
-
} catch (
|
|
55780
|
+
} catch (error82) {
|
|
55235
55781
|
controller.enqueue({
|
|
55236
55782
|
type: "error",
|
|
55237
|
-
error:
|
|
55783
|
+
error: error82
|
|
55238
55784
|
});
|
|
55239
55785
|
self2.closeStream();
|
|
55240
55786
|
}
|
|
@@ -55259,10 +55805,10 @@ var DefaultStreamTextResult = class {
|
|
|
55259
55805
|
}
|
|
55260
55806
|
});
|
|
55261
55807
|
}
|
|
55262
|
-
}).catch((
|
|
55808
|
+
}).catch((error82) => {
|
|
55263
55809
|
self2.addStream(new ReadableStream({
|
|
55264
55810
|
start(controller) {
|
|
55265
|
-
controller.enqueue({ type: "error", error:
|
|
55811
|
+
controller.enqueue({ type: "error", error: error82 });
|
|
55266
55812
|
controller.close();
|
|
55267
55813
|
}
|
|
55268
55814
|
}));
|
|
@@ -55302,9 +55848,21 @@ var DefaultStreamTextResult = class {
|
|
|
55302
55848
|
get toolCalls() {
|
|
55303
55849
|
return this.finalStep.then((step) => step.toolCalls);
|
|
55304
55850
|
}
|
|
55851
|
+
get staticToolCalls() {
|
|
55852
|
+
return this.finalStep.then((step) => step.staticToolCalls);
|
|
55853
|
+
}
|
|
55854
|
+
get dynamicToolCalls() {
|
|
55855
|
+
return this.finalStep.then((step) => step.dynamicToolCalls);
|
|
55856
|
+
}
|
|
55305
55857
|
get toolResults() {
|
|
55306
55858
|
return this.finalStep.then((step) => step.toolResults);
|
|
55307
55859
|
}
|
|
55860
|
+
get staticToolResults() {
|
|
55861
|
+
return this.finalStep.then((step) => step.staticToolResults);
|
|
55862
|
+
}
|
|
55863
|
+
get dynamicToolResults() {
|
|
55864
|
+
return this.finalStep.then((step) => step.dynamicToolResults);
|
|
55865
|
+
}
|
|
55308
55866
|
get usage() {
|
|
55309
55867
|
return this.finalStep.then((step) => step.usage);
|
|
55310
55868
|
}
|
|
@@ -55328,7 +55886,7 @@ var DefaultStreamTextResult = class {
|
|
|
55328
55886
|
get textStream() {
|
|
55329
55887
|
return createAsyncIterableStream(this.teeStream().pipeThrough(new TransformStream({
|
|
55330
55888
|
transform({ part }, controller) {
|
|
55331
|
-
if (part.type === "text") {
|
|
55889
|
+
if (part.type === "text-delta") {
|
|
55332
55890
|
controller.enqueue(part.text);
|
|
55333
55891
|
}
|
|
55334
55892
|
}
|
|
@@ -55348,8 +55906,8 @@ var DefaultStreamTextResult = class {
|
|
|
55348
55906
|
stream: this.fullStream,
|
|
55349
55907
|
onError: options == null ? undefined : options.onError
|
|
55350
55908
|
});
|
|
55351
|
-
} catch (
|
|
55352
|
-
(_a16 = options == null ? undefined : options.onError) == null || _a16.call(options,
|
|
55909
|
+
} catch (error82) {
|
|
55910
|
+
(_a16 = options == null ? undefined : options.onError) == null || _a16.call(options, error82);
|
|
55353
55911
|
}
|
|
55354
55912
|
}
|
|
55355
55913
|
get experimental_partialOutputStream() {
|
|
@@ -55379,6 +55937,13 @@ var DefaultStreamTextResult = class {
|
|
|
55379
55937
|
originalMessages,
|
|
55380
55938
|
responseMessageId: generateMessageId
|
|
55381
55939
|
}) : undefined;
|
|
55940
|
+
const toolNamesByCallId = {};
|
|
55941
|
+
const isDynamic = (toolCallId) => {
|
|
55942
|
+
var _a16, _b8;
|
|
55943
|
+
const toolName = toolNamesByCallId[toolCallId];
|
|
55944
|
+
const dynamic = ((_b8 = (_a16 = this.tools) == null ? undefined : _a16[toolName]) == null ? undefined : _b8.type) === "dynamic";
|
|
55945
|
+
return dynamic ? true : undefined;
|
|
55946
|
+
};
|
|
55382
55947
|
const baseStream = this.fullStream.pipeThrough(new TransformStream({
|
|
55383
55948
|
transform: async (part, controller) => {
|
|
55384
55949
|
const messageMetadataValue = messageMetadata == null ? undefined : messageMetadata({ part });
|
|
@@ -55392,7 +55957,7 @@ var DefaultStreamTextResult = class {
|
|
|
55392
55957
|
});
|
|
55393
55958
|
break;
|
|
55394
55959
|
}
|
|
55395
|
-
case "text": {
|
|
55960
|
+
case "text-delta": {
|
|
55396
55961
|
controller.enqueue({
|
|
55397
55962
|
type: "text-delta",
|
|
55398
55963
|
id: part.id,
|
|
@@ -55417,7 +55982,7 @@ var DefaultStreamTextResult = class {
|
|
|
55417
55982
|
});
|
|
55418
55983
|
break;
|
|
55419
55984
|
}
|
|
55420
|
-
case "reasoning": {
|
|
55985
|
+
case "reasoning-delta": {
|
|
55421
55986
|
if (sendReasoning) {
|
|
55422
55987
|
controller.enqueue({
|
|
55423
55988
|
type: "reasoning-delta",
|
|
@@ -55467,11 +56032,14 @@ var DefaultStreamTextResult = class {
|
|
|
55467
56032
|
break;
|
|
55468
56033
|
}
|
|
55469
56034
|
case "tool-input-start": {
|
|
56035
|
+
toolNamesByCallId[part.id] = part.toolName;
|
|
56036
|
+
const dynamic = isDynamic(part.id);
|
|
55470
56037
|
controller.enqueue({
|
|
55471
56038
|
type: "tool-input-start",
|
|
55472
56039
|
toolCallId: part.id,
|
|
55473
56040
|
toolName: part.toolName,
|
|
55474
|
-
providerExecuted: part.providerExecuted
|
|
56041
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
56042
|
+
...dynamic != null ? { dynamic } : {}
|
|
55475
56043
|
});
|
|
55476
56044
|
break;
|
|
55477
56045
|
}
|
|
@@ -55484,31 +56052,51 @@ var DefaultStreamTextResult = class {
|
|
|
55484
56052
|
break;
|
|
55485
56053
|
}
|
|
55486
56054
|
case "tool-call": {
|
|
55487
|
-
|
|
55488
|
-
|
|
55489
|
-
|
|
55490
|
-
|
|
55491
|
-
|
|
55492
|
-
|
|
55493
|
-
|
|
55494
|
-
|
|
56055
|
+
toolNamesByCallId[part.toolCallId] = part.toolName;
|
|
56056
|
+
const dynamic = isDynamic(part.toolCallId);
|
|
56057
|
+
if (part.invalid) {
|
|
56058
|
+
controller.enqueue({
|
|
56059
|
+
type: "tool-input-error",
|
|
56060
|
+
toolCallId: part.toolCallId,
|
|
56061
|
+
toolName: part.toolName,
|
|
56062
|
+
input: part.input,
|
|
56063
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
56064
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
56065
|
+
...dynamic != null ? { dynamic } : {},
|
|
56066
|
+
errorText: onError(part.error)
|
|
56067
|
+
});
|
|
56068
|
+
} else {
|
|
56069
|
+
controller.enqueue({
|
|
56070
|
+
type: "tool-input-available",
|
|
56071
|
+
toolCallId: part.toolCallId,
|
|
56072
|
+
toolName: part.toolName,
|
|
56073
|
+
input: part.input,
|
|
56074
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
56075
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
56076
|
+
...dynamic != null ? { dynamic } : {}
|
|
56077
|
+
});
|
|
56078
|
+
}
|
|
55495
56079
|
break;
|
|
55496
56080
|
}
|
|
55497
56081
|
case "tool-result": {
|
|
56082
|
+
const dynamic = isDynamic(part.toolCallId);
|
|
55498
56083
|
controller.enqueue({
|
|
55499
56084
|
type: "tool-output-available",
|
|
55500
56085
|
toolCallId: part.toolCallId,
|
|
55501
56086
|
output: part.output,
|
|
55502
|
-
providerExecuted: part.providerExecuted
|
|
56087
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
56088
|
+
...dynamic != null ? { dynamic } : {}
|
|
55503
56089
|
});
|
|
55504
56090
|
break;
|
|
55505
56091
|
}
|
|
55506
56092
|
case "tool-error": {
|
|
56093
|
+
const dynamic = isDynamic(part.toolCallId);
|
|
55507
56094
|
controller.enqueue({
|
|
55508
56095
|
type: "tool-output-error",
|
|
55509
56096
|
toolCallId: part.toolCallId,
|
|
55510
56097
|
errorText: onError(part.error),
|
|
55511
|
-
providerExecuted: part.providerExecuted
|
|
56098
|
+
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
56099
|
+
...dynamic != null ? { dynamic } : {}
|
|
55512
56100
|
});
|
|
55513
56101
|
break;
|
|
55514
56102
|
}
|
|
@@ -55725,32 +56313,32 @@ var marker152 = `vercel.ai.error.${name15}`;
|
|
|
55725
56313
|
var symbol152 = Symbol.for(marker152);
|
|
55726
56314
|
var _a152;
|
|
55727
56315
|
_a152 = symbol152;
|
|
55728
|
-
var ClientOrServerImplementationSchema = exports_external2.
|
|
56316
|
+
var ClientOrServerImplementationSchema = exports_external2.looseObject({
|
|
55729
56317
|
name: exports_external2.string(),
|
|
55730
56318
|
version: exports_external2.string()
|
|
55731
|
-
})
|
|
55732
|
-
var BaseParamsSchema = exports_external2.
|
|
55733
|
-
_meta: exports_external2.optional(exports_external2.object({}).
|
|
55734
|
-
})
|
|
56319
|
+
});
|
|
56320
|
+
var BaseParamsSchema = exports_external2.looseObject({
|
|
56321
|
+
_meta: exports_external2.optional(exports_external2.object({}).loose())
|
|
56322
|
+
});
|
|
55735
56323
|
var ResultSchema = BaseParamsSchema;
|
|
55736
56324
|
var RequestSchema = exports_external2.object({
|
|
55737
56325
|
method: exports_external2.string(),
|
|
55738
56326
|
params: exports_external2.optional(BaseParamsSchema)
|
|
55739
56327
|
});
|
|
55740
|
-
var ServerCapabilitiesSchema = exports_external2.
|
|
55741
|
-
experimental: exports_external2.optional(exports_external2.object({}).
|
|
55742
|
-
logging: exports_external2.optional(exports_external2.object({}).
|
|
55743
|
-
prompts: exports_external2.optional(exports_external2.
|
|
56328
|
+
var ServerCapabilitiesSchema = exports_external2.looseObject({
|
|
56329
|
+
experimental: exports_external2.optional(exports_external2.object({}).loose()),
|
|
56330
|
+
logging: exports_external2.optional(exports_external2.object({}).loose()),
|
|
56331
|
+
prompts: exports_external2.optional(exports_external2.looseObject({
|
|
55744
56332
|
listChanged: exports_external2.optional(exports_external2.boolean())
|
|
55745
|
-
})
|
|
55746
|
-
resources: exports_external2.optional(exports_external2.
|
|
56333
|
+
})),
|
|
56334
|
+
resources: exports_external2.optional(exports_external2.looseObject({
|
|
55747
56335
|
subscribe: exports_external2.optional(exports_external2.boolean()),
|
|
55748
56336
|
listChanged: exports_external2.optional(exports_external2.boolean())
|
|
55749
|
-
})
|
|
55750
|
-
tools: exports_external2.optional(exports_external2.
|
|
56337
|
+
})),
|
|
56338
|
+
tools: exports_external2.optional(exports_external2.looseObject({
|
|
55751
56339
|
listChanged: exports_external2.optional(exports_external2.boolean())
|
|
55752
|
-
})
|
|
55753
|
-
})
|
|
56340
|
+
}))
|
|
56341
|
+
});
|
|
55754
56342
|
var InitializeResultSchema = ResultSchema.extend({
|
|
55755
56343
|
protocolVersion: exports_external2.string(),
|
|
55756
56344
|
capabilities: ServerCapabilitiesSchema,
|
|
@@ -55765,35 +56353,35 @@ var ToolSchema = exports_external2.object({
|
|
|
55765
56353
|
description: exports_external2.optional(exports_external2.string()),
|
|
55766
56354
|
inputSchema: exports_external2.object({
|
|
55767
56355
|
type: exports_external2.literal("object"),
|
|
55768
|
-
properties: exports_external2.optional(exports_external2.object({}).
|
|
55769
|
-
}).
|
|
55770
|
-
}).
|
|
56356
|
+
properties: exports_external2.optional(exports_external2.object({}).loose())
|
|
56357
|
+
}).loose()
|
|
56358
|
+
}).loose();
|
|
55771
56359
|
var ListToolsResultSchema = PaginatedResultSchema.extend({
|
|
55772
56360
|
tools: exports_external2.array(ToolSchema)
|
|
55773
56361
|
});
|
|
55774
56362
|
var TextContentSchema = exports_external2.object({
|
|
55775
56363
|
type: exports_external2.literal("text"),
|
|
55776
56364
|
text: exports_external2.string()
|
|
55777
|
-
}).
|
|
56365
|
+
}).loose();
|
|
55778
56366
|
var ImageContentSchema = exports_external2.object({
|
|
55779
56367
|
type: exports_external2.literal("image"),
|
|
55780
|
-
data: exports_external2.
|
|
56368
|
+
data: exports_external2.base64(),
|
|
55781
56369
|
mimeType: exports_external2.string()
|
|
55782
|
-
}).
|
|
56370
|
+
}).loose();
|
|
55783
56371
|
var ResourceContentsSchema = exports_external2.object({
|
|
55784
56372
|
uri: exports_external2.string(),
|
|
55785
56373
|
mimeType: exports_external2.optional(exports_external2.string())
|
|
55786
|
-
}).
|
|
56374
|
+
}).loose();
|
|
55787
56375
|
var TextResourceContentsSchema = ResourceContentsSchema.extend({
|
|
55788
56376
|
text: exports_external2.string()
|
|
55789
56377
|
});
|
|
55790
56378
|
var BlobResourceContentsSchema = ResourceContentsSchema.extend({
|
|
55791
|
-
blob: exports_external2.
|
|
56379
|
+
blob: exports_external2.base64()
|
|
55792
56380
|
});
|
|
55793
56381
|
var EmbeddedResourceSchema = exports_external2.object({
|
|
55794
56382
|
type: exports_external2.literal("resource"),
|
|
55795
56383
|
resource: exports_external2.union([TextResourceContentsSchema, BlobResourceContentsSchema])
|
|
55796
|
-
}).
|
|
56384
|
+
}).loose();
|
|
55797
56385
|
var CallToolResultSchema = ResultSchema.extend({
|
|
55798
56386
|
content: exports_external2.array(exports_external2.union([TextContentSchema, ImageContentSchema, EmbeddedResourceSchema])),
|
|
55799
56387
|
isError: exports_external2.boolean().default(false).optional()
|
|
@@ -55865,8 +56453,8 @@ function zodSchemaToParameters(schema) {
|
|
|
55865
56453
|
}
|
|
55866
56454
|
return parameters;
|
|
55867
56455
|
}
|
|
55868
|
-
function toToolInfoV1(
|
|
55869
|
-
const { parameters: zodSchema2, ...rest } =
|
|
56456
|
+
function toToolInfoV1(tool2) {
|
|
56457
|
+
const { parameters: zodSchema2, ...rest } = tool2;
|
|
55870
56458
|
const v1Parameters = zodSchemaToParameters(zodSchema2);
|
|
55871
56459
|
const examples = zodSchema2.meta()?.examples;
|
|
55872
56460
|
const v1Tool = {
|
|
@@ -55930,7 +56518,7 @@ function parseNestedParameters(content, parameterPrefix, childrenParams) {
|
|
|
55930
56518
|
function parseAssistantMessage(assistantMessage, tools, toolNamePrefix) {
|
|
55931
56519
|
const parameterPrefix = `${toolNamePrefix}parameter_`;
|
|
55932
56520
|
const results = [];
|
|
55933
|
-
const toolTags = tools.map((
|
|
56521
|
+
const toolTags = tools.map((tool2) => `${toolNamePrefix}${tool2.name}`);
|
|
55934
56522
|
const toolPattern = toolTags.join("|");
|
|
55935
56523
|
let remainingMessage = assistantMessage;
|
|
55936
56524
|
let match;
|
|
@@ -55948,11 +56536,11 @@ function parseAssistantMessage(assistantMessage, tools, toolNamePrefix) {
|
|
|
55948
56536
|
}
|
|
55949
56537
|
const tagName = match[1];
|
|
55950
56538
|
const toolName = tagName.replace(toolNamePrefix, "");
|
|
55951
|
-
const
|
|
56539
|
+
const tool2 = tools.find((t) => t.name === toolName);
|
|
55952
56540
|
const fullTagContent = match[0];
|
|
55953
|
-
if (
|
|
56541
|
+
if (tool2) {
|
|
55954
56542
|
const params = {};
|
|
55955
|
-
for (const param of
|
|
56543
|
+
for (const param of tool2.parameters) {
|
|
55956
56544
|
const paramName = `${parameterPrefix}${param.name}`;
|
|
55957
56545
|
const escapedParamName = paramName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
55958
56546
|
const paramRegex = new RegExp(`<${escapedParamName}>([\\s\\S]*?)<\\/${escapedParamName}>`, "gs");
|
|
@@ -56033,28 +56621,28 @@ var renderParameterValue = (key, value, parameterPrefix) => {
|
|
|
56033
56621
|
${inner}
|
|
56034
56622
|
</${parameterPrefix}${key}>`;
|
|
56035
56623
|
};
|
|
56036
|
-
var toolInfoPrompt = (
|
|
56037
|
-
## ${toolNamePrefix}${
|
|
56624
|
+
var toolInfoPrompt = (tool2, toolNamePrefix, parameterPrefix) => `
|
|
56625
|
+
## ${toolNamePrefix}${tool2.name}
|
|
56038
56626
|
|
|
56039
|
-
Description: ${
|
|
56627
|
+
Description: ${tool2.description}
|
|
56040
56628
|
|
|
56041
56629
|
Parameters:
|
|
56042
|
-
${
|
|
56630
|
+
${tool2.parameters.map((param) => `- ${parameterPrefix}${param.name}: (${param.required ? "required" : "optional"})${param.allowMultiple ? " (multiple allowed)" : ""} ${param.description}`).join(`
|
|
56043
56631
|
`)}
|
|
56044
56632
|
|
|
56045
56633
|
Usage:
|
|
56046
|
-
<${toolNamePrefix}${
|
|
56047
|
-
${
|
|
56634
|
+
<${toolNamePrefix}${tool2.name}>
|
|
56635
|
+
${tool2.parameters.map((param) => param.allowMultiple ? `<${parameterPrefix}${param.name}>${param.usageValue}</${parameterPrefix}${param.name}>
|
|
56048
56636
|
<${parameterPrefix}${param.name}>${param.usageValue}</${parameterPrefix}${param.name}>` : `<${parameterPrefix}${param.name}>${param.usageValue}</${parameterPrefix}${param.name}>`).join(`
|
|
56049
56637
|
`)}
|
|
56050
|
-
</${toolNamePrefix}${
|
|
56051
|
-
var toolInfoExamplesPrompt = (
|
|
56638
|
+
</${toolNamePrefix}${tool2.name}>`;
|
|
56639
|
+
var toolInfoExamplesPrompt = (tool2, example, toolNamePrefix, parameterPrefix) => `
|
|
56052
56640
|
## Example: ${example.description}
|
|
56053
56641
|
|
|
56054
|
-
<${toolNamePrefix}${
|
|
56642
|
+
<${toolNamePrefix}${tool2.name}>
|
|
56055
56643
|
${Object.entries(example.input).map(([name17, value]) => renderParameterValue(name17, value, parameterPrefix)).join(`
|
|
56056
56644
|
`)}
|
|
56057
|
-
</${toolNamePrefix}${
|
|
56645
|
+
</${toolNamePrefix}${tool2.name}>
|
|
56058
56646
|
`;
|
|
56059
56647
|
var toolUsePrompt = (useNativeTool, tools, toolNamePrefix) => {
|
|
56060
56648
|
if (useNativeTool) {
|
|
@@ -56130,14 +56718,14 @@ Always adhere to this format, ensuring every opening tag has a matching closing
|
|
|
56130
56718
|
NEVER surround tool use with triple backticks (\`\`\`).
|
|
56131
56719
|
|
|
56132
56720
|
# Tools
|
|
56133
|
-
${v1Tools.map((
|
|
56721
|
+
${v1Tools.map((tool2) => toolInfoPrompt(tool2, toolNamePrefix, parameterPrefix)).join(`
|
|
56134
56722
|
`)}
|
|
56135
56723
|
|
|
56136
56724
|
# Tool Use Examples
|
|
56137
|
-
${v1Tools.map((
|
|
56725
|
+
${v1Tools.map((tool2) => {
|
|
56138
56726
|
let promp = "";
|
|
56139
|
-
for (const example of
|
|
56140
|
-
promp += toolInfoExamplesPrompt(
|
|
56727
|
+
for (const example of tool2.examples ?? []) {
|
|
56728
|
+
promp += toolInfoExamplesPrompt(tool2, example, toolNamePrefix, parameterPrefix);
|
|
56141
56729
|
}
|
|
56142
56730
|
return promp;
|
|
56143
56731
|
}).join("")}
|
|
@@ -56220,7 +56808,7 @@ The following additional commands are provided by the user, and should be follow
|
|
|
56220
56808
|
${joined}`;
|
|
56221
56809
|
};
|
|
56222
56810
|
var responsePrompts = {
|
|
56223
|
-
errorInvokeTool: (
|
|
56811
|
+
errorInvokeTool: (tool2, error82) => `An error occurred while invoking the tool "${tool2}": ${error82}`,
|
|
56224
56812
|
requireUseTool: `Error: No tool use detected. You MUST use a tool before proceeding.
|
|
56225
56813
|
e.g. <tool_tool_name>tool_name</tool_tool_name>
|
|
56226
56814
|
|
|
@@ -56230,19 +56818,19 @@ Avoid unnecessary escape characters or special characters.
|
|
|
56230
56818
|
`,
|
|
56231
56819
|
requireUseToolNative: `Error: No tool use detected. You MUST use a tool before proceeding.
|
|
56232
56820
|
`,
|
|
56233
|
-
toolResults: (
|
|
56821
|
+
toolResults: (tool2, result) => {
|
|
56234
56822
|
if (typeof result === "string") {
|
|
56235
56823
|
return [
|
|
56236
56824
|
{
|
|
56237
56825
|
type: "text",
|
|
56238
|
-
text: `<tool_response name=${
|
|
56826
|
+
text: `<tool_response name=${tool2}>${result}</tool_response>`
|
|
56239
56827
|
}
|
|
56240
56828
|
];
|
|
56241
56829
|
}
|
|
56242
56830
|
return [
|
|
56243
56831
|
{
|
|
56244
56832
|
type: "text",
|
|
56245
|
-
text: `<tool_response name=${
|
|
56833
|
+
text: `<tool_response name=${tool2}>`
|
|
56246
56834
|
},
|
|
56247
56835
|
...result,
|
|
56248
56836
|
{
|
|
@@ -56279,8 +56867,8 @@ class AgentBase {
|
|
|
56279
56867
|
${agents}`;
|
|
56280
56868
|
}
|
|
56281
56869
|
const handlers = {};
|
|
56282
|
-
for (const
|
|
56283
|
-
handlers[
|
|
56870
|
+
for (const tool2 of config3.tools) {
|
|
56871
|
+
handlers[tool2.name] = tool2;
|
|
56284
56872
|
}
|
|
56285
56873
|
const policies = [];
|
|
56286
56874
|
for (const policy of config3.policies) {
|
|
@@ -56292,8 +56880,8 @@ ${agents}`;
|
|
|
56292
56880
|
${instance.prompt}`;
|
|
56293
56881
|
}
|
|
56294
56882
|
if (instance.tools) {
|
|
56295
|
-
for (const
|
|
56296
|
-
handlers[
|
|
56883
|
+
for (const tool2 of instance.tools) {
|
|
56884
|
+
handlers[tool2.name] = tool2;
|
|
56297
56885
|
}
|
|
56298
56886
|
}
|
|
56299
56887
|
}
|
|
@@ -56307,13 +56895,13 @@ ${instance.prompt}`;
|
|
|
56307
56895
|
});
|
|
56308
56896
|
if (this.config.toolFormat === "native") {
|
|
56309
56897
|
const tools = {};
|
|
56310
|
-
for (const
|
|
56311
|
-
const toolName = import_lodash.camelCase(
|
|
56898
|
+
for (const tool2 of Object.values(this.handlers)) {
|
|
56899
|
+
const toolName = import_lodash.camelCase(tool2.name);
|
|
56312
56900
|
tools[toolName] = {
|
|
56313
|
-
description:
|
|
56314
|
-
inputSchema: jsonSchema(toJSONSchema(
|
|
56901
|
+
description: tool2.description,
|
|
56902
|
+
inputSchema: jsonSchema(toJSONSchema(tool2.parameters))
|
|
56315
56903
|
};
|
|
56316
|
-
this.handlers[toolName] =
|
|
56904
|
+
this.handlers[toolName] = tool2;
|
|
56317
56905
|
}
|
|
56318
56906
|
this.#toolSet = tools;
|
|
56319
56907
|
} else {
|
|
@@ -56433,10 +57021,10 @@ Request timeout after ${requestTimeoutSeconds} seconds. Canceling current reques
|
|
|
56433
57021
|
onChunk: async ({ chunk }) => {
|
|
56434
57022
|
resetTimeout();
|
|
56435
57023
|
switch (chunk.type) {
|
|
56436
|
-
case "text":
|
|
57024
|
+
case "text-delta":
|
|
56437
57025
|
await this.#callback({ kind: "Text" /* Text */, agent: this, newText: chunk.text });
|
|
56438
57026
|
break;
|
|
56439
|
-
case "reasoning":
|
|
57027
|
+
case "reasoning-delta":
|
|
56440
57028
|
await this.#callback({ kind: "Reasoning" /* Reasoning */, agent: this, newText: chunk.text });
|
|
56441
57029
|
break;
|
|
56442
57030
|
case "tool-call":
|
|
@@ -56444,8 +57032,8 @@ Request timeout after ${requestTimeoutSeconds} seconds. Canceling current reques
|
|
|
56444
57032
|
}
|
|
56445
57033
|
},
|
|
56446
57034
|
onFinish: this.config.usageMeter.onFinishHandler(this.ai),
|
|
56447
|
-
onError: async (
|
|
56448
|
-
console.error("Error in stream:",
|
|
57035
|
+
onError: async (error82) => {
|
|
57036
|
+
console.error("Error in stream:", error82);
|
|
56449
57037
|
},
|
|
56450
57038
|
abortSignal: requestAbortController.signal
|
|
56451
57039
|
};
|
|
@@ -56454,8 +57042,8 @@ Request timeout after ${requestTimeoutSeconds} seconds. Canceling current reques
|
|
|
56454
57042
|
}
|
|
56455
57043
|
const stream = streamText(streamTextOptions);
|
|
56456
57044
|
await stream.consumeStream({
|
|
56457
|
-
onError: (
|
|
56458
|
-
console.error("Error in stream:",
|
|
57045
|
+
onError: (error82) => {
|
|
57046
|
+
console.error("Error in stream:", error82);
|
|
56459
57047
|
}
|
|
56460
57048
|
});
|
|
56461
57049
|
const resp = await stream.response;
|
|
@@ -56464,14 +57052,14 @@ Request timeout after ${requestTimeoutSeconds} seconds. Canceling current reques
|
|
|
56464
57052
|
clearTimeout(timeout);
|
|
56465
57053
|
timeout = undefined;
|
|
56466
57054
|
}
|
|
56467
|
-
} catch (
|
|
56468
|
-
if (
|
|
57055
|
+
} catch (error82) {
|
|
57056
|
+
if (error82 instanceof Error && error82.name === "AbortError") {
|
|
56469
57057
|
if (this.#aborted) {
|
|
56470
57058
|
break;
|
|
56471
57059
|
}
|
|
56472
57060
|
console.debug(`Request attempt ${i + 1} timed out, will retry`);
|
|
56473
57061
|
} else {
|
|
56474
|
-
console.error("Error in stream:",
|
|
57062
|
+
console.error("Error in stream:", error82);
|
|
56475
57063
|
}
|
|
56476
57064
|
} finally {
|
|
56477
57065
|
if (timeout) {
|
|
@@ -56668,7 +57256,7 @@ Retrying request ${i + 2} of ${retryCount}`);
|
|
|
56668
57256
|
}
|
|
56669
57257
|
};
|
|
56670
57258
|
}
|
|
56671
|
-
const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool, response: response2 }) => responsePrompts.toolResults(
|
|
57259
|
+
const finalResp = toolResponses.filter((resp) => resp.type === "response").flatMap(({ tool: tool2, response: response2 }) => responsePrompts.toolResults(tool2, response2));
|
|
56672
57260
|
return {
|
|
56673
57261
|
type: "reply",
|
|
56674
57262
|
message: {
|
|
@@ -56700,10 +57288,10 @@ Retrying request ${i + 2} of ${retryCount}`);
|
|
|
56700
57288
|
return resp;
|
|
56701
57289
|
}
|
|
56702
57290
|
return await handler14(this.config.provider, args);
|
|
56703
|
-
} catch (
|
|
57291
|
+
} catch (error82) {
|
|
56704
57292
|
return {
|
|
56705
57293
|
type: "Error" /* Error */,
|
|
56706
|
-
message: responsePrompts.errorInvokeTool(name17,
|
|
57294
|
+
message: responsePrompts.errorInvokeTool(name17, error82),
|
|
56707
57295
|
canRetry: false
|
|
56708
57296
|
};
|
|
56709
57297
|
}
|
|
@@ -56922,8 +57510,8 @@ class CodeFixerAgent extends AgentBase {
|
|
|
56922
57510
|
message: responsePrompts.commandResult(checkCommand, exitCode, stdout, stderr)
|
|
56923
57511
|
};
|
|
56924
57512
|
}
|
|
56925
|
-
} catch (
|
|
56926
|
-
console.warn(`Failed to check code using command: ${checkCommand}`,
|
|
57513
|
+
} catch (error82) {
|
|
57514
|
+
console.warn(`Failed to check code using command: ${checkCommand}`, error82);
|
|
56927
57515
|
}
|
|
56928
57516
|
}
|
|
56929
57517
|
const test = this.config.scripts?.test;
|
|
@@ -56937,8 +57525,8 @@ class CodeFixerAgent extends AgentBase {
|
|
|
56937
57525
|
message: responsePrompts.commandResult(testCommand, exitCode, stdout, stderr)
|
|
56938
57526
|
};
|
|
56939
57527
|
}
|
|
56940
|
-
} catch (
|
|
56941
|
-
console.warn(`Failed to test code using command: ${testCommand}`,
|
|
57528
|
+
} catch (error82) {
|
|
57529
|
+
console.warn(`Failed to test code using command: ${testCommand}`, error82);
|
|
56942
57530
|
}
|
|
56943
57531
|
}
|
|
56944
57532
|
}
|
|
@@ -57115,8 +57703,8 @@ class CoderAgent extends AgentBase {
|
|
|
57115
57703
|
message: responsePrompts.commandResult(command, exitCode, stdout, stderr)
|
|
57116
57704
|
};
|
|
57117
57705
|
}
|
|
57118
|
-
} catch (
|
|
57119
|
-
console.warn(`Failed to run ${scriptName} using command: ${command}`,
|
|
57706
|
+
} catch (error82) {
|
|
57707
|
+
console.warn(`Failed to run ${scriptName} using command: ${command}`, error82);
|
|
57120
57708
|
}
|
|
57121
57709
|
}
|
|
57122
57710
|
}
|
|
@@ -57734,10 +58322,10 @@ ${diffOutput}
|
|
|
57734
58322
|
message: `\`${command}\` exited with code ${result.exitCode}:
|
|
57735
58323
|
${result.stderr}`
|
|
57736
58324
|
};
|
|
57737
|
-
} catch (
|
|
58325
|
+
} catch (error82) {
|
|
57738
58326
|
return {
|
|
57739
58327
|
type: "Error" /* Error */,
|
|
57740
|
-
message:
|
|
58328
|
+
message: error82 instanceof Error ? error82.message : String(error82)
|
|
57741
58329
|
};
|
|
57742
58330
|
}
|
|
57743
58331
|
};
|
|
@@ -57861,8 +58449,8 @@ ${instructions}
|
|
|
57861
58449
|
const content = match ? match[1] : output;
|
|
57862
58450
|
try {
|
|
57863
58451
|
return JSON.parse(content);
|
|
57864
|
-
} catch (
|
|
57865
|
-
console.error("Error parsing JSON output:",
|
|
58452
|
+
} catch (error82) {
|
|
58453
|
+
console.error("Error parsing JSON output:", error82);
|
|
57866
58454
|
return {
|
|
57867
58455
|
overview: `Could not parse review output. Raw output:
|
|
57868
58456
|
${output}`,
|
|
@@ -58159,8 +58747,8 @@ class ZodError4 extends Error {
|
|
|
58159
58747
|
return issue3.message;
|
|
58160
58748
|
};
|
|
58161
58749
|
const fieldErrors = { _errors: [] };
|
|
58162
|
-
const processError = (
|
|
58163
|
-
for (const issue3 of
|
|
58750
|
+
const processError = (error82) => {
|
|
58751
|
+
for (const issue3 of error82.issues) {
|
|
58164
58752
|
if (issue3.code === "invalid_union") {
|
|
58165
58753
|
issue3.unionErrors.map(processError);
|
|
58166
58754
|
} else if (issue3.code === "invalid_return_type") {
|
|
@@ -58222,8 +58810,8 @@ class ZodError4 extends Error {
|
|
|
58222
58810
|
}
|
|
58223
58811
|
}
|
|
58224
58812
|
ZodError4.create = (issues) => {
|
|
58225
|
-
const
|
|
58226
|
-
return
|
|
58813
|
+
const error82 = new ZodError4(issues);
|
|
58814
|
+
return error82;
|
|
58227
58815
|
};
|
|
58228
58816
|
var errorMap2 = (issue3, _ctx) => {
|
|
58229
58817
|
let message;
|
|
@@ -58486,8 +59074,8 @@ var handleResult2 = (ctx, result) => {
|
|
|
58486
59074
|
get error() {
|
|
58487
59075
|
if (this._error)
|
|
58488
59076
|
return this._error;
|
|
58489
|
-
const
|
|
58490
|
-
this._error =
|
|
59077
|
+
const error82 = new ZodError4(ctx.common.issues);
|
|
59078
|
+
this._error = error82;
|
|
58491
59079
|
return this._error;
|
|
58492
59080
|
}
|
|
58493
59081
|
};
|
|
@@ -61071,7 +61659,7 @@ class ZodFunction2 extends ZodType4 {
|
|
|
61071
61659
|
});
|
|
61072
61660
|
return INVALID2;
|
|
61073
61661
|
}
|
|
61074
|
-
function makeArgsIssue(args,
|
|
61662
|
+
function makeArgsIssue(args, error82) {
|
|
61075
61663
|
return makeIssue2({
|
|
61076
61664
|
data: args,
|
|
61077
61665
|
path: ctx.path,
|
|
@@ -61083,11 +61671,11 @@ class ZodFunction2 extends ZodType4 {
|
|
|
61083
61671
|
].filter((x) => !!x),
|
|
61084
61672
|
issueData: {
|
|
61085
61673
|
code: ZodIssueCode4.invalid_arguments,
|
|
61086
|
-
argumentsError:
|
|
61674
|
+
argumentsError: error82
|
|
61087
61675
|
}
|
|
61088
61676
|
});
|
|
61089
61677
|
}
|
|
61090
|
-
function makeReturnsIssue(returns,
|
|
61678
|
+
function makeReturnsIssue(returns, error82) {
|
|
61091
61679
|
return makeIssue2({
|
|
61092
61680
|
data: returns,
|
|
61093
61681
|
path: ctx.path,
|
|
@@ -61099,7 +61687,7 @@ class ZodFunction2 extends ZodType4 {
|
|
|
61099
61687
|
].filter((x) => !!x),
|
|
61100
61688
|
issueData: {
|
|
61101
61689
|
code: ZodIssueCode4.invalid_return_type,
|
|
61102
|
-
returnTypeError:
|
|
61690
|
+
returnTypeError: error82
|
|
61103
61691
|
}
|
|
61104
61692
|
});
|
|
61105
61693
|
}
|
|
@@ -61108,15 +61696,15 @@ class ZodFunction2 extends ZodType4 {
|
|
|
61108
61696
|
if (this._def.returns instanceof ZodPromise4) {
|
|
61109
61697
|
const me = this;
|
|
61110
61698
|
return OK2(async function(...args) {
|
|
61111
|
-
const
|
|
61699
|
+
const error82 = new ZodError4([]);
|
|
61112
61700
|
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
61113
|
-
|
|
61114
|
-
throw
|
|
61701
|
+
error82.addIssue(makeArgsIssue(args, e));
|
|
61702
|
+
throw error82;
|
|
61115
61703
|
});
|
|
61116
61704
|
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
61117
61705
|
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
61118
|
-
|
|
61119
|
-
throw
|
|
61706
|
+
error82.addIssue(makeReturnsIssue(result, e));
|
|
61707
|
+
throw error82;
|
|
61120
61708
|
});
|
|
61121
61709
|
return parsedReturns;
|
|
61122
61710
|
});
|
|
@@ -61862,9 +62450,9 @@ function loadConfig(paths, cwd = process.cwd(), home = homedir()) {
|
|
|
61862
62450
|
try {
|
|
61863
62451
|
const globalConfig3 = readConfig(globalConfigPath);
|
|
61864
62452
|
configs.push(globalConfig3);
|
|
61865
|
-
} catch (
|
|
62453
|
+
} catch (error82) {
|
|
61866
62454
|
console.warn(`Error loading global config file: ${globalConfigPath}
|
|
61867
|
-
${
|
|
62455
|
+
${error82}`);
|
|
61868
62456
|
}
|
|
61869
62457
|
}
|
|
61870
62458
|
if (paths && paths.length > 0) {
|
|
@@ -61873,10 +62461,10 @@ ${error81}`);
|
|
|
61873
62461
|
try {
|
|
61874
62462
|
const config4 = readConfig(path);
|
|
61875
62463
|
configs.push(config4);
|
|
61876
|
-
} catch (
|
|
62464
|
+
} catch (error82) {
|
|
61877
62465
|
console.error(`Error loading config file: ${path}
|
|
61878
|
-
${
|
|
61879
|
-
throw
|
|
62466
|
+
${error82}`);
|
|
62467
|
+
throw error82;
|
|
61880
62468
|
}
|
|
61881
62469
|
}
|
|
61882
62470
|
} else {
|
|
@@ -61884,11 +62472,11 @@ ${error81}`);
|
|
|
61884
62472
|
try {
|
|
61885
62473
|
const projectConfig = readConfig(configPath);
|
|
61886
62474
|
configs.push(projectConfig);
|
|
61887
|
-
} catch (
|
|
61888
|
-
if (
|
|
62475
|
+
} catch (error82) {
|
|
62476
|
+
if (error82 instanceof ZodError4) {
|
|
61889
62477
|
console.error(`Error in config file: ${configPath}
|
|
61890
|
-
${
|
|
61891
|
-
throw
|
|
62478
|
+
${error82}`);
|
|
62479
|
+
throw error82;
|
|
61892
62480
|
}
|
|
61893
62481
|
}
|
|
61894
62482
|
}
|
|
@@ -62918,16 +63506,16 @@ function createPrompt(view) {
|
|
|
62918
63506
|
const [content, bottomContent] = typeof nextView === "string" ? [nextView] : nextView;
|
|
62919
63507
|
screen.render(content, bottomContent);
|
|
62920
63508
|
effectScheduler.run();
|
|
62921
|
-
} catch (
|
|
62922
|
-
reject(
|
|
63509
|
+
} catch (error82) {
|
|
63510
|
+
reject(error82);
|
|
62923
63511
|
}
|
|
62924
63512
|
});
|
|
62925
63513
|
return Object.assign(promise4.then((answer) => {
|
|
62926
63514
|
effectScheduler.clearAll();
|
|
62927
63515
|
return answer;
|
|
62928
|
-
}, (
|
|
63516
|
+
}, (error82) => {
|
|
62929
63517
|
effectScheduler.clearAll();
|
|
62930
|
-
throw
|
|
63518
|
+
throw error82;
|
|
62931
63519
|
}).finally(() => {
|
|
62932
63520
|
cleanups.forEach((cleanup) => cleanup());
|
|
62933
63521
|
screen.done({ clearContent: Boolean(context.clearPromptOnDone) });
|
|
@@ -63013,13 +63601,13 @@ var esm_default3 = createPrompt((config4, done) => {
|
|
|
63013
63601
|
if (defaultValue && status !== "done" && !value) {
|
|
63014
63602
|
defaultStr = theme.style.defaultAnswer(defaultValue);
|
|
63015
63603
|
}
|
|
63016
|
-
let
|
|
63604
|
+
let error82 = "";
|
|
63017
63605
|
if (errorMsg) {
|
|
63018
|
-
|
|
63606
|
+
error82 = theme.style.error(errorMsg);
|
|
63019
63607
|
}
|
|
63020
63608
|
return [
|
|
63021
63609
|
[prefix, message, defaultStr, formattedValue].filter((v) => v !== undefined).join(" "),
|
|
63022
|
-
|
|
63610
|
+
error82
|
|
63023
63611
|
];
|
|
63024
63612
|
});
|
|
63025
63613
|
// ../../node_modules/@inquirer/select/dist/esm/index.js
|
|
@@ -63331,8 +63919,8 @@ async function searchFiles(path, regex, filePattern, cwd, excludeFiles) {
|
|
|
63331
63919
|
`).filter(Boolean);
|
|
63332
63920
|
results.push(...lines);
|
|
63333
63921
|
});
|
|
63334
|
-
rg.on("error", (
|
|
63335
|
-
reject(new Error(`Failed to execute ripgrep: ${
|
|
63922
|
+
rg.on("error", (error82) => {
|
|
63923
|
+
reject(new Error(`Failed to execute ripgrep: ${error82.message}`));
|
|
63336
63924
|
});
|
|
63337
63925
|
rg.on("close", (code) => {
|
|
63338
63926
|
if (code !== 0 && code !== 1) {
|
|
@@ -63443,9 +64031,9 @@ var getProvider = (_agentName, _config, options = {}) => {
|
|
|
63443
64031
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
63444
64032
|
}
|
|
63445
64033
|
return await response.text();
|
|
63446
|
-
} catch (
|
|
63447
|
-
console.error("Error fetching URL:",
|
|
63448
|
-
throw
|
|
64034
|
+
} catch (error82) {
|
|
64035
|
+
console.error("Error fetching URL:", error82);
|
|
64036
|
+
throw error82;
|
|
63449
64037
|
}
|
|
63450
64038
|
}
|
|
63451
64039
|
};
|
|
@@ -63648,8 +64236,8 @@ class ZodError5 extends Error {
|
|
|
63648
64236
|
return issue3.message;
|
|
63649
64237
|
};
|
|
63650
64238
|
const fieldErrors = { _errors: [] };
|
|
63651
|
-
const processError = (
|
|
63652
|
-
for (const issue3 of
|
|
64239
|
+
const processError = (error82) => {
|
|
64240
|
+
for (const issue3 of error82.issues) {
|
|
63653
64241
|
if (issue3.code === "invalid_union") {
|
|
63654
64242
|
issue3.unionErrors.map(processError);
|
|
63655
64243
|
} else if (issue3.code === "invalid_return_type") {
|
|
@@ -63711,8 +64299,8 @@ class ZodError5 extends Error {
|
|
|
63711
64299
|
}
|
|
63712
64300
|
}
|
|
63713
64301
|
ZodError5.create = (issues) => {
|
|
63714
|
-
const
|
|
63715
|
-
return
|
|
64302
|
+
const error82 = new ZodError5(issues);
|
|
64303
|
+
return error82;
|
|
63716
64304
|
};
|
|
63717
64305
|
var errorMap3 = (issue3, _ctx) => {
|
|
63718
64306
|
let message;
|
|
@@ -63979,8 +64567,8 @@ var handleResult3 = (ctx, result) => {
|
|
|
63979
64567
|
get error() {
|
|
63980
64568
|
if (this._error)
|
|
63981
64569
|
return this._error;
|
|
63982
|
-
const
|
|
63983
|
-
this._error =
|
|
64570
|
+
const error82 = new ZodError5(ctx.common.issues);
|
|
64571
|
+
this._error = error82;
|
|
63984
64572
|
return this._error;
|
|
63985
64573
|
}
|
|
63986
64574
|
};
|
|
@@ -66564,7 +67152,7 @@ class ZodFunction3 extends ZodType5 {
|
|
|
66564
67152
|
});
|
|
66565
67153
|
return INVALID3;
|
|
66566
67154
|
}
|
|
66567
|
-
function makeArgsIssue(args,
|
|
67155
|
+
function makeArgsIssue(args, error82) {
|
|
66568
67156
|
return makeIssue3({
|
|
66569
67157
|
data: args,
|
|
66570
67158
|
path: ctx.path,
|
|
@@ -66576,11 +67164,11 @@ class ZodFunction3 extends ZodType5 {
|
|
|
66576
67164
|
].filter((x) => !!x),
|
|
66577
67165
|
issueData: {
|
|
66578
67166
|
code: ZodIssueCode5.invalid_arguments,
|
|
66579
|
-
argumentsError:
|
|
67167
|
+
argumentsError: error82
|
|
66580
67168
|
}
|
|
66581
67169
|
});
|
|
66582
67170
|
}
|
|
66583
|
-
function makeReturnsIssue(returns,
|
|
67171
|
+
function makeReturnsIssue(returns, error82) {
|
|
66584
67172
|
return makeIssue3({
|
|
66585
67173
|
data: returns,
|
|
66586
67174
|
path: ctx.path,
|
|
@@ -66592,7 +67180,7 @@ class ZodFunction3 extends ZodType5 {
|
|
|
66592
67180
|
].filter((x) => !!x),
|
|
66593
67181
|
issueData: {
|
|
66594
67182
|
code: ZodIssueCode5.invalid_return_type,
|
|
66595
|
-
returnTypeError:
|
|
67183
|
+
returnTypeError: error82
|
|
66596
67184
|
}
|
|
66597
67185
|
});
|
|
66598
67186
|
}
|
|
@@ -66601,15 +67189,15 @@ class ZodFunction3 extends ZodType5 {
|
|
|
66601
67189
|
if (this._def.returns instanceof ZodPromise5) {
|
|
66602
67190
|
const me = this;
|
|
66603
67191
|
return OK3(async function(...args) {
|
|
66604
|
-
const
|
|
67192
|
+
const error82 = new ZodError5([]);
|
|
66605
67193
|
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
66606
|
-
|
|
66607
|
-
throw
|
|
67194
|
+
error82.addIssue(makeArgsIssue(args, e));
|
|
67195
|
+
throw error82;
|
|
66608
67196
|
});
|
|
66609
67197
|
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
66610
67198
|
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
66611
|
-
|
|
66612
|
-
throw
|
|
67199
|
+
error82.addIssue(makeReturnsIssue(result, e));
|
|
67200
|
+
throw error82;
|
|
66613
67201
|
});
|
|
66614
67202
|
return parsedReturns;
|
|
66615
67203
|
});
|
|
@@ -67590,13 +68178,13 @@ class WebSocketManager {
|
|
|
67590
68178
|
try {
|
|
67591
68179
|
const messageString = JSON.stringify(message);
|
|
67592
68180
|
this.ws.send(messageString);
|
|
67593
|
-
} catch (
|
|
67594
|
-
console.error("Failed to send message:",
|
|
68181
|
+
} catch (error82) {
|
|
68182
|
+
console.error("Failed to send message:", error82);
|
|
67595
68183
|
try {
|
|
67596
68184
|
const errorMsg = {
|
|
67597
68185
|
type: "error",
|
|
67598
68186
|
message: "Failed to send message",
|
|
67599
|
-
details: String(
|
|
68187
|
+
details: String(error82)
|
|
67600
68188
|
};
|
|
67601
68189
|
if (this.ws && this.ws.readyState === wrapper_default.OPEN) {
|
|
67602
68190
|
this.ws.send(JSON.stringify(errorMsg));
|
|
@@ -67638,17 +68226,17 @@ class WebSocketManager {
|
|
|
67638
68226
|
const rawMessage = JSON.parse(data.toString());
|
|
67639
68227
|
const message = wsIncomingMessageSchema.parse(rawMessage);
|
|
67640
68228
|
await this.options.onMessage(message);
|
|
67641
|
-
} catch (
|
|
67642
|
-
console.error("Error processing message:",
|
|
68229
|
+
} catch (error82) {
|
|
68230
|
+
console.error("Error processing message:", error82);
|
|
67643
68231
|
this.sendMessage({
|
|
67644
68232
|
type: "error",
|
|
67645
68233
|
message: "Failed to process message",
|
|
67646
|
-
details: String(
|
|
68234
|
+
details: String(error82)
|
|
67647
68235
|
});
|
|
67648
68236
|
}
|
|
67649
68237
|
}
|
|
67650
|
-
handleError(
|
|
67651
|
-
console.error("WebSocket error occurred:",
|
|
68238
|
+
handleError(error82) {
|
|
68239
|
+
console.error("WebSocket error occurred:", error82);
|
|
67652
68240
|
}
|
|
67653
68241
|
handleClose(code, reason) {
|
|
67654
68242
|
console.log(`WebSocket connection closed. Code: ${code}, Reason: ${reason.toString() || "No reason provided"}`);
|
|
@@ -67697,8 +68285,8 @@ class Runner {
|
|
|
67697
68285
|
onExit(code) {
|
|
67698
68286
|
console.log(`$ <<<< $ Command exited with code: ${code}`);
|
|
67699
68287
|
},
|
|
67700
|
-
onError(
|
|
67701
|
-
console.log(`$ <<<< $ Command error: ${
|
|
68288
|
+
onError(error82) {
|
|
68289
|
+
console.log(`$ <<<< $ Command error: ${error82}`);
|
|
67702
68290
|
}
|
|
67703
68291
|
},
|
|
67704
68292
|
excludeFiles: config5.excludeFiles,
|
|
@@ -67753,8 +68341,8 @@ class Runner {
|
|
|
67753
68341
|
if (format) {
|
|
67754
68342
|
try {
|
|
67755
68343
|
await this.provider.executeCommand(format, false);
|
|
67756
|
-
} catch (
|
|
67757
|
-
console.warn(`Failed to format code using command: ${format}`,
|
|
68344
|
+
} catch (error82) {
|
|
68345
|
+
console.warn(`Failed to format code using command: ${format}`, error82);
|
|
67758
68346
|
}
|
|
67759
68347
|
}
|
|
67760
68348
|
if (check3) {
|
|
@@ -67763,8 +68351,8 @@ class Runner {
|
|
|
67763
68351
|
if (exitCode !== 0) {
|
|
67764
68352
|
return responsePrompts.commandResult(check3, exitCode, stdout, stderr);
|
|
67765
68353
|
}
|
|
67766
|
-
} catch (
|
|
67767
|
-
console.warn(`Failed to check code using command: ${check3}`,
|
|
68354
|
+
} catch (error82) {
|
|
68355
|
+
console.warn(`Failed to check code using command: ${check3}`, error82);
|
|
67768
68356
|
}
|
|
67769
68357
|
}
|
|
67770
68358
|
if (test) {
|
|
@@ -67773,17 +68361,17 @@ class Runner {
|
|
|
67773
68361
|
if (exitCode !== 0) {
|
|
67774
68362
|
return responsePrompts.commandResult(test, exitCode, stdout, stderr);
|
|
67775
68363
|
}
|
|
67776
|
-
} catch (
|
|
67777
|
-
console.warn(`Failed to test code using command: ${test}`,
|
|
68364
|
+
} catch (error82) {
|
|
68365
|
+
console.warn(`Failed to test code using command: ${test}`, error82);
|
|
67778
68366
|
}
|
|
67779
68367
|
}
|
|
67780
68368
|
return {
|
|
67781
68369
|
type: "exit"
|
|
67782
68370
|
};
|
|
67783
68371
|
}
|
|
67784
|
-
const
|
|
67785
|
-
if (
|
|
67786
|
-
const resp = await
|
|
68372
|
+
const tool3 = this.availableTools[request.tool];
|
|
68373
|
+
if (tool3) {
|
|
68374
|
+
const resp = await tool3.handler(this.provider, request.params);
|
|
67787
68375
|
if (resp.type === "Reply" /* Reply */) {
|
|
67788
68376
|
return responsePrompts.toolResults(request.tool, resp.message);
|
|
67789
68377
|
}
|
|
@@ -67900,12 +68488,12 @@ class Runner {
|
|
|
67900
68488
|
}
|
|
67901
68489
|
this.wsManager.sendMessage({ type: "get_files_completed" });
|
|
67902
68490
|
console.log(`Processed ${fileChanges.length} changed files`);
|
|
67903
|
-
} catch (
|
|
67904
|
-
console.error("Error getting changed files:",
|
|
68491
|
+
} catch (error82) {
|
|
68492
|
+
console.error("Error getting changed files:", error82);
|
|
67905
68493
|
this.wsManager.sendMessage({
|
|
67906
68494
|
type: "error",
|
|
67907
68495
|
message: "Failed to get changed files using git",
|
|
67908
|
-
details:
|
|
68496
|
+
details: error82 instanceof Error ? error82.message : String(error82)
|
|
67909
68497
|
});
|
|
67910
68498
|
}
|
|
67911
68499
|
}
|
|
@@ -67968,8 +68556,8 @@ class Runner {
|
|
|
67968
68556
|
} else {
|
|
67969
68557
|
console.error(`Path is not a file or directory: ${path}`);
|
|
67970
68558
|
}
|
|
67971
|
-
} catch (
|
|
67972
|
-
console.error(`Error processing path ${path}:`,
|
|
68559
|
+
} catch (error82) {
|
|
68560
|
+
console.error(`Error processing path ${path}:`, error82);
|
|
67973
68561
|
}
|
|
67974
68562
|
}
|
|
67975
68563
|
sendFileDeleted(path) {
|