@gram-ai/elements 1.2.5 → 1.3.0
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/elements.cjs +49 -0
- package/dist/models-BuM4eiir.cjs +33 -0
- package/dist/server.cjs +54 -0
- package/dist/server.js +850 -836
- package/dist/types/index.d.ts +1 -2
- package/package.json +5 -3
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { gl as
|
|
2
|
-
var
|
|
3
|
-
function
|
|
1
|
+
import { gl as ti, gm as dt, gn as Mt, go as se, gp as ri, gq as Nt, fI as ai, dc as ni, gr as M, gs as oi, eu as Oe, fr as v, ev as I, eS as Kt, fM as c, fd as C, fZ as D, f_ as Re, fq as R, fB as De, gt as Yt, gj as J, f0 as $t, eH as si, fc as ii, fn as li, ez as _e, eM as ui, gu as Ze, fe as ze, gv as ci, gw as di, gx as pi, fs as $, g9 as In, ga as Sn, ew as En, dR as fi, aQ as hi, gk as mi } from "./models-DBbuJvSc.js";
|
|
2
|
+
var gi = typeof globalThis == "object" ? globalThis : typeof self == "object" ? self : typeof window == "object" ? window : typeof global == "object" ? global : {}, qe = "1.9.0", Ta = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
|
|
3
|
+
function vi(e) {
|
|
4
4
|
var t = /* @__PURE__ */ new Set([e]), r = /* @__PURE__ */ new Set(), a = e.match(Ta);
|
|
5
5
|
if (!a)
|
|
6
6
|
return function() {
|
|
@@ -39,7 +39,7 @@ function gi(e) {
|
|
|
39
39
|
return d.prerelease != null || o.major !== d.major ? n(u) : o.major === 0 ? o.minor === d.minor && o.patch <= d.patch ? i(u) : n(u) : o.minor <= d.minor ? i(u) : n(u);
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
var
|
|
42
|
+
var yi = vi(qe), _i = qe.split(".")[0], pt = Symbol.for("opentelemetry.js.api." + _i), ft = gi;
|
|
43
43
|
function Gr(e, t, r, a) {
|
|
44
44
|
var o;
|
|
45
45
|
a === void 0 && (a = !1);
|
|
@@ -58,7 +58,7 @@ function Gr(e, t, r, a) {
|
|
|
58
58
|
}
|
|
59
59
|
function ht(e) {
|
|
60
60
|
var t, r, a = (t = ft[pt]) === null || t === void 0 ? void 0 : t.version;
|
|
61
|
-
if (!(!a || !
|
|
61
|
+
if (!(!a || !yi(a)))
|
|
62
62
|
return (r = ft[pt]) === null || r === void 0 ? void 0 : r[e];
|
|
63
63
|
}
|
|
64
64
|
function Jr(e, t) {
|
|
@@ -66,7 +66,7 @@ function Jr(e, t) {
|
|
|
66
66
|
var r = ft[pt];
|
|
67
67
|
r && delete r[e];
|
|
68
68
|
}
|
|
69
|
-
var
|
|
69
|
+
var wi = function(e, t) {
|
|
70
70
|
var r = typeof Symbol == "function" && e[Symbol.iterator];
|
|
71
71
|
if (!r) return e;
|
|
72
72
|
var a = r.call(e), o, n = [], i;
|
|
@@ -82,11 +82,11 @@ var _i = function(e, t) {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
return n;
|
|
85
|
-
},
|
|
85
|
+
}, bi = function(e, t, r) {
|
|
86
86
|
if (r || arguments.length === 2) for (var a = 0, o = t.length, n; a < o; a++)
|
|
87
87
|
(n || !(a in t)) && (n || (n = Array.prototype.slice.call(t, 0, a)), n[a] = t[a]);
|
|
88
88
|
return e.concat(n || Array.prototype.slice.call(t));
|
|
89
|
-
},
|
|
89
|
+
}, Ti = (
|
|
90
90
|
/** @class */
|
|
91
91
|
(function() {
|
|
92
92
|
function e(t) {
|
|
@@ -118,13 +118,13 @@ var _i = function(e, t) {
|
|
|
118
118
|
function ot(e, t, r) {
|
|
119
119
|
var a = ht("diag");
|
|
120
120
|
if (a)
|
|
121
|
-
return r.unshift(t), a[e].apply(a,
|
|
121
|
+
return r.unshift(t), a[e].apply(a, bi([], wi(r), !1));
|
|
122
122
|
}
|
|
123
123
|
var le;
|
|
124
124
|
(function(e) {
|
|
125
125
|
e[e.NONE = 0] = "NONE", e[e.ERROR = 30] = "ERROR", e[e.WARN = 50] = "WARN", e[e.INFO = 60] = "INFO", e[e.DEBUG = 70] = "DEBUG", e[e.VERBOSE = 80] = "VERBOSE", e[e.ALL = 9999] = "ALL";
|
|
126
126
|
})(le || (le = {}));
|
|
127
|
-
function
|
|
127
|
+
function Ii(e, t) {
|
|
128
128
|
e < le.NONE ? e = le.NONE : e > le.ALL && (e = le.ALL), t = t || {};
|
|
129
129
|
function r(a, o) {
|
|
130
130
|
var n = t[a];
|
|
@@ -139,7 +139,7 @@ function Ti(e, t) {
|
|
|
139
139
|
verbose: r("verbose", le.VERBOSE)
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
|
-
var
|
|
142
|
+
var Si = function(e, t) {
|
|
143
143
|
var r = typeof Symbol == "function" && e[Symbol.iterator];
|
|
144
144
|
if (!r) return e;
|
|
145
145
|
var a = r.call(e), o, n = [], i;
|
|
@@ -155,11 +155,11 @@ var Ii = function(e, t) {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
return n;
|
|
158
|
-
},
|
|
158
|
+
}, Ei = function(e, t, r) {
|
|
159
159
|
if (r || arguments.length === 2) for (var a = 0, o = t.length, n; a < o; a++)
|
|
160
160
|
(n || !(a in t)) && (n || (n = Array.prototype.slice.call(t, 0, a)), n[a] = t[a]);
|
|
161
161
|
return e.concat(n || Array.prototype.slice.call(t));
|
|
162
|
-
},
|
|
162
|
+
}, xi = "diag", Ut = (
|
|
163
163
|
/** @class */
|
|
164
164
|
(function() {
|
|
165
165
|
function e() {
|
|
@@ -169,7 +169,7 @@ var Ii = function(e, t) {
|
|
|
169
169
|
n[i] = arguments[i];
|
|
170
170
|
var s = ht("diag");
|
|
171
171
|
if (s)
|
|
172
|
-
return s[o].apply(s,
|
|
172
|
+
return s[o].apply(s, Ei([], Si(n), !1));
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
175
|
var r = this, a = function(o, n) {
|
|
@@ -181,7 +181,7 @@ var Ii = function(e, t) {
|
|
|
181
181
|
typeof n == "number" && (n = {
|
|
182
182
|
logLevel: n
|
|
183
183
|
});
|
|
184
|
-
var d = ht("diag"), p =
|
|
184
|
+
var d = ht("diag"), p = Ii((s = n.logLevel) !== null && s !== void 0 ? s : le.INFO, o);
|
|
185
185
|
if (d && !n.suppressOverrideMessage) {
|
|
186
186
|
var m = (u = new Error().stack) !== null && u !== void 0 ? u : "<failed to generate stacktrace>";
|
|
187
187
|
d.warn("Current logger will be overwritten from " + m), p.warn("Current logger will overwrite one already registered from " + m);
|
|
@@ -189,9 +189,9 @@ var Ii = function(e, t) {
|
|
|
189
189
|
return Gr("diag", p, r, !0);
|
|
190
190
|
};
|
|
191
191
|
r.setLogger = a, r.disable = function() {
|
|
192
|
-
Jr(
|
|
192
|
+
Jr(xi, r);
|
|
193
193
|
}, r.createComponentLogger = function(o) {
|
|
194
|
-
return new
|
|
194
|
+
return new Ti(o);
|
|
195
195
|
}, r.verbose = t("verbose"), r.debug = t("debug"), r.info = t("info"), r.warn = t("warn"), r.error = t("error");
|
|
196
196
|
}
|
|
197
197
|
return e.instance = function() {
|
|
@@ -199,10 +199,10 @@ var Ii = function(e, t) {
|
|
|
199
199
|
}, e;
|
|
200
200
|
})()
|
|
201
201
|
);
|
|
202
|
-
function
|
|
202
|
+
function Ri(e) {
|
|
203
203
|
return Symbol.for(e);
|
|
204
204
|
}
|
|
205
|
-
var
|
|
205
|
+
var Ci = (
|
|
206
206
|
/** @class */
|
|
207
207
|
/* @__PURE__ */ (function() {
|
|
208
208
|
function e(t) {
|
|
@@ -219,7 +219,7 @@ var Ri = (
|
|
|
219
219
|
}
|
|
220
220
|
return e;
|
|
221
221
|
})()
|
|
222
|
-
),
|
|
222
|
+
), Ai = new Ci(), ki = function(e, t) {
|
|
223
223
|
var r = typeof Symbol == "function" && e[Symbol.iterator];
|
|
224
224
|
if (!r) return e;
|
|
225
225
|
var a = r.call(e), o, n = [], i;
|
|
@@ -235,21 +235,21 @@ var Ri = (
|
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
return n;
|
|
238
|
-
},
|
|
238
|
+
}, Oi = function(e, t, r) {
|
|
239
239
|
if (r || arguments.length === 2) for (var a = 0, o = t.length, n; a < o; a++)
|
|
240
240
|
(n || !(a in t)) && (n || (n = Array.prototype.slice.call(t, 0, a)), n[a] = t[a]);
|
|
241
241
|
return e.concat(n || Array.prototype.slice.call(t));
|
|
242
|
-
},
|
|
242
|
+
}, Pi = (
|
|
243
243
|
/** @class */
|
|
244
244
|
(function() {
|
|
245
245
|
function e() {
|
|
246
246
|
}
|
|
247
247
|
return e.prototype.active = function() {
|
|
248
|
-
return
|
|
248
|
+
return Ai;
|
|
249
249
|
}, e.prototype.with = function(t, r, a) {
|
|
250
250
|
for (var o = [], n = 3; n < arguments.length; n++)
|
|
251
251
|
o[n - 3] = arguments[n];
|
|
252
|
-
return r.call.apply(r,
|
|
252
|
+
return r.call.apply(r, Oi([a], ki(o), !1));
|
|
253
253
|
}, e.prototype.bind = function(t, r) {
|
|
254
254
|
return r;
|
|
255
255
|
}, e.prototype.enable = function() {
|
|
@@ -258,7 +258,7 @@ var Ri = (
|
|
|
258
258
|
return this;
|
|
259
259
|
}, e;
|
|
260
260
|
})()
|
|
261
|
-
),
|
|
261
|
+
), Mi = function(e, t) {
|
|
262
262
|
var r = typeof Symbol == "function" && e[Symbol.iterator];
|
|
263
263
|
if (!r) return e;
|
|
264
264
|
var a = r.call(e), o, n = [], i;
|
|
@@ -274,11 +274,11 @@ var Ri = (
|
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
return n;
|
|
277
|
-
},
|
|
277
|
+
}, Ni = function(e, t, r) {
|
|
278
278
|
if (r || arguments.length === 2) for (var a = 0, o = t.length, n; a < o; a++)
|
|
279
279
|
(n || !(a in t)) && (n || (n = Array.prototype.slice.call(t, 0, a)), n[a] = t[a]);
|
|
280
280
|
return e.concat(n || Array.prototype.slice.call(t));
|
|
281
|
-
}, hr = "context",
|
|
281
|
+
}, hr = "context", $i = new Pi(), xn = (
|
|
282
282
|
/** @class */
|
|
283
283
|
(function() {
|
|
284
284
|
function e() {
|
|
@@ -292,11 +292,11 @@ var Ri = (
|
|
|
292
292
|
}, e.prototype.with = function(t, r, a) {
|
|
293
293
|
for (var o, n = [], i = 3; i < arguments.length; i++)
|
|
294
294
|
n[i - 3] = arguments[i];
|
|
295
|
-
return (o = this._getContextManager()).with.apply(o,
|
|
295
|
+
return (o = this._getContextManager()).with.apply(o, Ni([t, r, a], Mi(n), !1));
|
|
296
296
|
}, e.prototype.bind = function(t, r) {
|
|
297
297
|
return this._getContextManager().bind(t, r);
|
|
298
298
|
}, e.prototype._getContextManager = function() {
|
|
299
|
-
return ht(hr) ||
|
|
299
|
+
return ht(hr) || $i;
|
|
300
300
|
}, e.prototype.disable = function() {
|
|
301
301
|
this._getContextManager().disable(), Jr(hr, Ut.instance());
|
|
302
302
|
}, e;
|
|
@@ -305,15 +305,15 @@ var Ri = (
|
|
|
305
305
|
(function(e) {
|
|
306
306
|
e[e.NONE = 0] = "NONE", e[e.SAMPLED = 1] = "SAMPLED";
|
|
307
307
|
})(kr || (kr = {}));
|
|
308
|
-
var
|
|
309
|
-
traceId:
|
|
310
|
-
spanId:
|
|
308
|
+
var Rn = "0000000000000000", Cn = "00000000000000000000000000000000", Ui = {
|
|
309
|
+
traceId: Cn,
|
|
310
|
+
spanId: Rn,
|
|
311
311
|
traceFlags: kr.NONE
|
|
312
312
|
}, ut = (
|
|
313
313
|
/** @class */
|
|
314
314
|
(function() {
|
|
315
315
|
function e(t) {
|
|
316
|
-
t === void 0 && (t =
|
|
316
|
+
t === void 0 && (t = Ui), this._spanContext = t;
|
|
317
317
|
}
|
|
318
318
|
return e.prototype.spanContext = function() {
|
|
319
319
|
return this._spanContext;
|
|
@@ -337,40 +337,40 @@ var xn = "0000000000000000", Rn = "00000000000000000000000000000000", $i = {
|
|
|
337
337
|
}, e.prototype.recordException = function(t, r) {
|
|
338
338
|
}, e;
|
|
339
339
|
})()
|
|
340
|
-
), Zr =
|
|
340
|
+
), Zr = Ri("OpenTelemetry Context Key SPAN");
|
|
341
341
|
function zr(e) {
|
|
342
342
|
return e.getValue(Zr) || void 0;
|
|
343
343
|
}
|
|
344
|
-
function
|
|
345
|
-
return zr(
|
|
344
|
+
function Di() {
|
|
345
|
+
return zr(xn.getInstance().active());
|
|
346
346
|
}
|
|
347
347
|
function Wr(e, t) {
|
|
348
348
|
return e.setValue(Zr, t);
|
|
349
349
|
}
|
|
350
|
-
function
|
|
350
|
+
function ji(e) {
|
|
351
351
|
return e.deleteValue(Zr);
|
|
352
352
|
}
|
|
353
|
-
function
|
|
353
|
+
function qi(e, t) {
|
|
354
354
|
return Wr(e, new ut(t));
|
|
355
355
|
}
|
|
356
|
-
function
|
|
356
|
+
function An(e) {
|
|
357
357
|
var t;
|
|
358
358
|
return (t = zr(e)) === null || t === void 0 ? void 0 : t.spanContext();
|
|
359
359
|
}
|
|
360
|
-
var
|
|
361
|
-
function Vi(e) {
|
|
362
|
-
return qi.test(e) && e !== Rn;
|
|
363
|
-
}
|
|
360
|
+
var Li = /^([0-9a-f]{32})$/i, Vi = /^[0-9a-f]{16}$/i;
|
|
364
361
|
function Fi(e) {
|
|
365
|
-
return Li.test(e) && e !==
|
|
366
|
-
}
|
|
367
|
-
function An(e) {
|
|
368
|
-
return Vi(e.traceId) && Fi(e.spanId);
|
|
362
|
+
return Li.test(e) && e !== Cn;
|
|
369
363
|
}
|
|
370
364
|
function Bi(e) {
|
|
365
|
+
return Vi.test(e) && e !== Rn;
|
|
366
|
+
}
|
|
367
|
+
function kn(e) {
|
|
368
|
+
return Fi(e.traceId) && Bi(e.spanId);
|
|
369
|
+
}
|
|
370
|
+
function Hi(e) {
|
|
371
371
|
return new ut(e);
|
|
372
372
|
}
|
|
373
|
-
var mr =
|
|
373
|
+
var mr = xn.getInstance(), On = (
|
|
374
374
|
/** @class */
|
|
375
375
|
(function() {
|
|
376
376
|
function e() {
|
|
@@ -380,8 +380,8 @@ var mr = En.getInstance(), kn = (
|
|
|
380
380
|
var o = !!r?.root;
|
|
381
381
|
if (o)
|
|
382
382
|
return new ut();
|
|
383
|
-
var n = a &&
|
|
384
|
-
return
|
|
383
|
+
var n = a && An(a);
|
|
384
|
+
return Gi(n) && kn(n) ? new ut(n) : new ut();
|
|
385
385
|
}, e.prototype.startActiveSpan = function(t, r, a, o) {
|
|
386
386
|
var n, i, s;
|
|
387
387
|
if (!(arguments.length < 2)) {
|
|
@@ -392,10 +392,10 @@ var mr = En.getInstance(), kn = (
|
|
|
392
392
|
}, e;
|
|
393
393
|
})()
|
|
394
394
|
);
|
|
395
|
-
function
|
|
395
|
+
function Gi(e) {
|
|
396
396
|
return typeof e == "object" && typeof e.spanId == "string" && typeof e.traceId == "string" && typeof e.traceFlags == "number";
|
|
397
397
|
}
|
|
398
|
-
var
|
|
398
|
+
var Ji = new On(), Zi = (
|
|
399
399
|
/** @class */
|
|
400
400
|
(function() {
|
|
401
401
|
function e(t, r, a, o) {
|
|
@@ -410,29 +410,29 @@ var Gi = new kn(), Ji = (
|
|
|
410
410
|
if (this._delegate)
|
|
411
411
|
return this._delegate;
|
|
412
412
|
var t = this._provider.getDelegateTracer(this.name, this.version, this.options);
|
|
413
|
-
return t ? (this._delegate = t, this._delegate) :
|
|
413
|
+
return t ? (this._delegate = t, this._delegate) : Ji;
|
|
414
414
|
}, e;
|
|
415
415
|
})()
|
|
416
|
-
),
|
|
416
|
+
), zi = (
|
|
417
417
|
/** @class */
|
|
418
418
|
(function() {
|
|
419
419
|
function e() {
|
|
420
420
|
}
|
|
421
421
|
return e.prototype.getTracer = function(t, r, a) {
|
|
422
|
-
return new
|
|
422
|
+
return new On();
|
|
423
423
|
}, e;
|
|
424
424
|
})()
|
|
425
|
-
),
|
|
425
|
+
), Wi = new zi(), Ia = (
|
|
426
426
|
/** @class */
|
|
427
427
|
(function() {
|
|
428
428
|
function e() {
|
|
429
429
|
}
|
|
430
430
|
return e.prototype.getTracer = function(t, r, a) {
|
|
431
431
|
var o;
|
|
432
|
-
return (o = this.getDelegateTracer(t, r, a)) !== null && o !== void 0 ? o : new
|
|
432
|
+
return (o = this.getDelegateTracer(t, r, a)) !== null && o !== void 0 ? o : new Zi(this, t, r, a);
|
|
433
433
|
}, e.prototype.getDelegate = function() {
|
|
434
434
|
var t;
|
|
435
|
-
return (t = this._delegate) !== null && t !== void 0 ? t :
|
|
435
|
+
return (t = this._delegate) !== null && t !== void 0 ? t : Wi;
|
|
436
436
|
}, e.prototype.setDelegate = function(t) {
|
|
437
437
|
this._delegate = t;
|
|
438
438
|
}, e.prototype.getDelegateTracer = function(t, r, a) {
|
|
@@ -444,11 +444,11 @@ var Gi = new kn(), Ji = (
|
|
|
444
444
|
(function(e) {
|
|
445
445
|
e[e.UNSET = 0] = "UNSET", e[e.OK = 1] = "OK", e[e.ERROR = 2] = "ERROR";
|
|
446
446
|
})(Dt || (Dt = {}));
|
|
447
|
-
var gr = "trace",
|
|
447
|
+
var gr = "trace", Ki = (
|
|
448
448
|
/** @class */
|
|
449
449
|
(function() {
|
|
450
450
|
function e() {
|
|
451
|
-
this._proxyTracerProvider = new Ia(), this.wrapSpanContext =
|
|
451
|
+
this._proxyTracerProvider = new Ia(), this.wrapSpanContext = Hi, this.isSpanContextValid = kn, this.deleteSpan = ji, this.getSpan = zr, this.getActiveSpan = Di, this.getSpanContext = An, this.setSpan = Wr, this.setSpanContext = qi;
|
|
452
452
|
}
|
|
453
453
|
return e.getInstance = function() {
|
|
454
454
|
return this._instance || (this._instance = new e()), this._instance;
|
|
@@ -463,7 +463,7 @@ var gr = "trace", Wi = (
|
|
|
463
463
|
Jr(gr, Ut.instance()), this._proxyTracerProvider = new Ia();
|
|
464
464
|
}, e;
|
|
465
465
|
})()
|
|
466
|
-
),
|
|
466
|
+
), Yi = Ki.getInstance();
|
|
467
467
|
function Or(...e) {
|
|
468
468
|
return e.reduce(
|
|
469
469
|
(t, r) => ({
|
|
@@ -473,7 +473,7 @@ function Or(...e) {
|
|
|
473
473
|
{}
|
|
474
474
|
);
|
|
475
475
|
}
|
|
476
|
-
async function
|
|
476
|
+
async function Xi(e, t) {
|
|
477
477
|
if (e == null)
|
|
478
478
|
return Promise.resolve();
|
|
479
479
|
const r = t?.abortSignal;
|
|
@@ -513,28 +513,28 @@ var It = ({
|
|
|
513
513
|
if (e == null)
|
|
514
514
|
return o;
|
|
515
515
|
if (r.includes(a))
|
|
516
|
-
throw new
|
|
516
|
+
throw new ti({
|
|
517
517
|
argument: "separator",
|
|
518
518
|
message: `The separator "${a}" must not be part of the alphabet "${r}".`
|
|
519
519
|
});
|
|
520
520
|
return () => `${e}${a}${o()}`;
|
|
521
|
-
},
|
|
522
|
-
function
|
|
521
|
+
}, Qi = It();
|
|
522
|
+
function Pn(e) {
|
|
523
523
|
return e == null ? "unknown error" : typeof e == "string" ? e : e instanceof Error ? e.message : JSON.stringify(e);
|
|
524
524
|
}
|
|
525
525
|
function Le(e) {
|
|
526
526
|
return (e instanceof Error || e instanceof DOMException) && (e.name === "AbortError" || e.name === "ResponseAborted" || // Next.js
|
|
527
527
|
e.name === "TimeoutError");
|
|
528
528
|
}
|
|
529
|
-
var
|
|
530
|
-
function
|
|
529
|
+
var el = ["fetch failed", "failed to fetch"];
|
|
530
|
+
function Mn({
|
|
531
531
|
error: e,
|
|
532
532
|
url: t,
|
|
533
533
|
requestBodyValues: r
|
|
534
534
|
}) {
|
|
535
535
|
if (Le(e))
|
|
536
536
|
return e;
|
|
537
|
-
if (e instanceof TypeError &&
|
|
537
|
+
if (e instanceof TypeError && el.includes(e.message.toLowerCase())) {
|
|
538
538
|
const a = e.cause;
|
|
539
539
|
if (a != null)
|
|
540
540
|
return new se({
|
|
@@ -552,7 +552,7 @@ function Kr(e = globalThis) {
|
|
|
552
552
|
var t, r, a;
|
|
553
553
|
return e.window ? "runtime/browser" : (t = e.navigator) != null && t.userAgent ? `runtime/${e.navigator.userAgent.toLowerCase()}` : (a = (r = e.process) == null ? void 0 : r.versions) != null && a.node ? `runtime/node.js/${e.process.version.substring(0)}` : e.EdgeRuntime ? "runtime/vercel-edge" : "runtime/unknown";
|
|
554
554
|
}
|
|
555
|
-
function
|
|
555
|
+
function tl(e) {
|
|
556
556
|
if (e == null)
|
|
557
557
|
return {};
|
|
558
558
|
const t = {};
|
|
@@ -568,26 +568,26 @@ function el(e) {
|
|
|
568
568
|
return t;
|
|
569
569
|
}
|
|
570
570
|
function Xt(e, ...t) {
|
|
571
|
-
const r = new Headers(
|
|
571
|
+
const r = new Headers(tl(e)), a = r.get("user-agent") || "";
|
|
572
572
|
return r.set(
|
|
573
573
|
"user-agent",
|
|
574
574
|
[a, ...t].filter(Boolean).join(" ")
|
|
575
575
|
), Object.fromEntries(r.entries());
|
|
576
576
|
}
|
|
577
|
-
var
|
|
577
|
+
var Nn = "3.0.16", rl = () => globalThis.fetch, Ea = async ({
|
|
578
578
|
url: e,
|
|
579
579
|
headers: t = {},
|
|
580
580
|
successfulResponseHandler: r,
|
|
581
581
|
failedResponseHandler: a,
|
|
582
582
|
abortSignal: o,
|
|
583
|
-
fetch: n =
|
|
583
|
+
fetch: n = rl()
|
|
584
584
|
}) => {
|
|
585
585
|
try {
|
|
586
586
|
const i = await n(e, {
|
|
587
587
|
method: "GET",
|
|
588
588
|
headers: Xt(
|
|
589
589
|
t,
|
|
590
|
-
`ai-sdk/provider-utils/${
|
|
590
|
+
`ai-sdk/provider-utils/${Nn}`,
|
|
591
591
|
Kr()
|
|
592
592
|
),
|
|
593
593
|
signal: o
|
|
@@ -629,10 +629,10 @@ var Mn = "3.0.16", tl = () => globalThis.fetch, Ea = async ({
|
|
|
629
629
|
});
|
|
630
630
|
}
|
|
631
631
|
} catch (i) {
|
|
632
|
-
throw
|
|
632
|
+
throw Mn({ error: i, url: e, requestBodyValues: {} });
|
|
633
633
|
}
|
|
634
634
|
};
|
|
635
|
-
function
|
|
635
|
+
function al({
|
|
636
636
|
mediaType: e,
|
|
637
637
|
url: t,
|
|
638
638
|
supportedUrls: r
|
|
@@ -651,12 +651,12 @@ function Ot({
|
|
|
651
651
|
if (!(e != null || typeof process > "u") && (e = process.env[t], !(e == null || typeof e != "string")))
|
|
652
652
|
return e;
|
|
653
653
|
}
|
|
654
|
-
var
|
|
655
|
-
function
|
|
654
|
+
var nl = /"__proto__"\s*:/, ol = /"constructor"\s*:/;
|
|
655
|
+
function sl(e) {
|
|
656
656
|
const t = JSON.parse(e);
|
|
657
|
-
return t === null || typeof t != "object" ||
|
|
657
|
+
return t === null || typeof t != "object" || nl.test(e) === !1 && ol.test(e) === !1 ? t : il(t);
|
|
658
658
|
}
|
|
659
|
-
function
|
|
659
|
+
function il(e) {
|
|
660
660
|
let t = [e];
|
|
661
661
|
for (; t.length; ) {
|
|
662
662
|
const r = t;
|
|
@@ -674,31 +674,31 @@ function sl(e) {
|
|
|
674
674
|
}
|
|
675
675
|
return e;
|
|
676
676
|
}
|
|
677
|
-
function
|
|
677
|
+
function $n(e) {
|
|
678
678
|
const { stackTraceLimit: t } = Error;
|
|
679
679
|
Error.stackTraceLimit = 0;
|
|
680
680
|
try {
|
|
681
|
-
return
|
|
681
|
+
return sl(e);
|
|
682
682
|
} finally {
|
|
683
683
|
Error.stackTraceLimit = t;
|
|
684
684
|
}
|
|
685
685
|
}
|
|
686
686
|
var jt = Symbol.for("vercel.ai.validator");
|
|
687
|
-
function
|
|
687
|
+
function ll(e) {
|
|
688
688
|
return { [jt]: !0, validate: e };
|
|
689
689
|
}
|
|
690
|
-
function
|
|
690
|
+
function ul(e) {
|
|
691
691
|
return typeof e == "object" && e !== null && jt in e && e[jt] === !0 && "validate" in e;
|
|
692
692
|
}
|
|
693
693
|
function Xe(e) {
|
|
694
694
|
let t;
|
|
695
695
|
return () => (t == null && (t = e()), t);
|
|
696
696
|
}
|
|
697
|
-
function ul(e) {
|
|
698
|
-
return ll(e) ? e : typeof e == "function" ? e() : cl(e);
|
|
699
|
-
}
|
|
700
697
|
function cl(e) {
|
|
701
|
-
return
|
|
698
|
+
return ul(e) ? e : typeof e == "function" ? e() : dl(e);
|
|
699
|
+
}
|
|
700
|
+
function dl(e) {
|
|
701
|
+
return ll(async (t) => {
|
|
702
702
|
const r = await e["~standard"].validate(t);
|
|
703
703
|
return r.issues == null ? { success: !0, value: r.value } : {
|
|
704
704
|
success: !1,
|
|
@@ -722,7 +722,7 @@ async function je({
|
|
|
722
722
|
value: e,
|
|
723
723
|
schema: t
|
|
724
724
|
}) {
|
|
725
|
-
const r =
|
|
725
|
+
const r = cl(t);
|
|
726
726
|
try {
|
|
727
727
|
if (r.validate == null)
|
|
728
728
|
return { success: !0, value: e, rawValue: e };
|
|
@@ -740,12 +740,12 @@ async function je({
|
|
|
740
740
|
};
|
|
741
741
|
}
|
|
742
742
|
}
|
|
743
|
-
async function
|
|
743
|
+
async function pl({
|
|
744
744
|
text: e,
|
|
745
745
|
schema: t
|
|
746
746
|
}) {
|
|
747
747
|
try {
|
|
748
|
-
const r =
|
|
748
|
+
const r = $n(e);
|
|
749
749
|
return t == null ? r : Pr({ value: r, schema: t });
|
|
750
750
|
} catch (r) {
|
|
751
751
|
throw Mt.isInstance(r) || dt.isInstance(r) ? r : new Mt({ text: e, cause: r });
|
|
@@ -756,7 +756,7 @@ async function Ve({
|
|
|
756
756
|
schema: t
|
|
757
757
|
}) {
|
|
758
758
|
try {
|
|
759
|
-
const r =
|
|
759
|
+
const r = $n(e);
|
|
760
760
|
return t == null ? { success: !0, value: r, rawValue: r } : await je({ value: r, schema: t });
|
|
761
761
|
} catch (r) {
|
|
762
762
|
return {
|
|
@@ -766,7 +766,7 @@ async function Ve({
|
|
|
766
766
|
};
|
|
767
767
|
}
|
|
768
768
|
}
|
|
769
|
-
function
|
|
769
|
+
function fl({
|
|
770
770
|
stream: e,
|
|
771
771
|
schema: t
|
|
772
772
|
}) {
|
|
@@ -778,7 +778,7 @@ function pl({
|
|
|
778
778
|
})
|
|
779
779
|
);
|
|
780
780
|
}
|
|
781
|
-
var
|
|
781
|
+
var hl = () => globalThis.fetch, Mr = async ({
|
|
782
782
|
url: e,
|
|
783
783
|
headers: t,
|
|
784
784
|
body: r,
|
|
@@ -786,7 +786,7 @@ var fl = () => globalThis.fetch, Mr = async ({
|
|
|
786
786
|
successfulResponseHandler: o,
|
|
787
787
|
abortSignal: n,
|
|
788
788
|
fetch: i
|
|
789
|
-
}) =>
|
|
789
|
+
}) => ml({
|
|
790
790
|
url: e,
|
|
791
791
|
headers: {
|
|
792
792
|
"Content-Type": "application/json",
|
|
@@ -800,21 +800,21 @@ var fl = () => globalThis.fetch, Mr = async ({
|
|
|
800
800
|
successfulResponseHandler: o,
|
|
801
801
|
abortSignal: n,
|
|
802
802
|
fetch: i
|
|
803
|
-
}),
|
|
803
|
+
}), ml = async ({
|
|
804
804
|
url: e,
|
|
805
805
|
headers: t = {},
|
|
806
806
|
body: r,
|
|
807
807
|
successfulResponseHandler: a,
|
|
808
808
|
failedResponseHandler: o,
|
|
809
809
|
abortSignal: n,
|
|
810
|
-
fetch: i =
|
|
810
|
+
fetch: i = hl()
|
|
811
811
|
}) => {
|
|
812
812
|
try {
|
|
813
813
|
const s = await i(e, {
|
|
814
814
|
method: "POST",
|
|
815
815
|
headers: Xt(
|
|
816
816
|
t,
|
|
817
|
-
`ai-sdk/provider-utils/${
|
|
817
|
+
`ai-sdk/provider-utils/${Nn}`,
|
|
818
818
|
Kr()
|
|
819
819
|
),
|
|
820
820
|
body: r.content,
|
|
@@ -857,7 +857,7 @@ var fl = () => globalThis.fetch, Mr = async ({
|
|
|
857
857
|
});
|
|
858
858
|
}
|
|
859
859
|
} catch (s) {
|
|
860
|
-
throw
|
|
860
|
+
throw Mn({ error: s, url: e, requestBodyValues: r.values });
|
|
861
861
|
}
|
|
862
862
|
};
|
|
863
863
|
async function Ue(e) {
|
|
@@ -883,7 +883,7 @@ var mt = ({
|
|
|
883
883
|
})
|
|
884
884
|
};
|
|
885
885
|
try {
|
|
886
|
-
const u = await
|
|
886
|
+
const u = await pl({
|
|
887
887
|
text: i,
|
|
888
888
|
schema: e
|
|
889
889
|
});
|
|
@@ -914,13 +914,13 @@ var mt = ({
|
|
|
914
914
|
})
|
|
915
915
|
};
|
|
916
916
|
}
|
|
917
|
-
},
|
|
917
|
+
}, gl = (e) => async ({ response: t }) => {
|
|
918
918
|
const r = Tt(t);
|
|
919
919
|
if (t.body == null)
|
|
920
|
-
throw new
|
|
920
|
+
throw new ri({});
|
|
921
921
|
return {
|
|
922
922
|
responseHeaders: r,
|
|
923
|
-
value:
|
|
923
|
+
value: fl({
|
|
924
924
|
stream: t.body,
|
|
925
925
|
schema: e
|
|
926
926
|
})
|
|
@@ -945,12 +945,12 @@ var mt = ({
|
|
|
945
945
|
value: n.value,
|
|
946
946
|
rawValue: n.rawValue
|
|
947
947
|
};
|
|
948
|
-
},
|
|
948
|
+
}, vl = (e, t) => {
|
|
949
949
|
let r = 0;
|
|
950
950
|
for (; r < e.length && r < t.length && e[r] === t[r]; r++)
|
|
951
951
|
;
|
|
952
952
|
return [(e.length - r).toString(), ...t.slice(r)].join("/");
|
|
953
|
-
},
|
|
953
|
+
}, yl = Symbol(
|
|
954
954
|
"Let zodToJsonSchema decide on which parser to use"
|
|
955
955
|
), xa = {
|
|
956
956
|
name: void 0,
|
|
@@ -972,7 +972,7 @@ var mt = ({
|
|
|
972
972
|
emailStrategy: "format:email",
|
|
973
973
|
base64Strategy: "contentEncoding:base64",
|
|
974
974
|
nameStrategy: "ref"
|
|
975
|
-
},
|
|
975
|
+
}, _l = (e) => typeof e == "string" ? {
|
|
976
976
|
...xa,
|
|
977
977
|
name: e
|
|
978
978
|
} : {
|
|
@@ -982,7 +982,7 @@ var mt = ({
|
|
|
982
982
|
function ue() {
|
|
983
983
|
return {};
|
|
984
984
|
}
|
|
985
|
-
function
|
|
985
|
+
function wl(e, t) {
|
|
986
986
|
var r, a, o;
|
|
987
987
|
const n = {
|
|
988
988
|
type: "array"
|
|
@@ -992,7 +992,7 @@ function _l(e, t) {
|
|
|
992
992
|
currentPath: [...t.currentPath, "items"]
|
|
993
993
|
})), e.minLength && (n.minItems = e.minLength.value), e.maxLength && (n.maxItems = e.maxLength.value), e.exactLength && (n.minItems = e.exactLength.value, n.maxItems = e.exactLength.value), n;
|
|
994
994
|
}
|
|
995
|
-
function
|
|
995
|
+
function bl(e) {
|
|
996
996
|
const t = {
|
|
997
997
|
type: "integer",
|
|
998
998
|
format: "int64"
|
|
@@ -1012,18 +1012,18 @@ function wl(e) {
|
|
|
1012
1012
|
}
|
|
1013
1013
|
return t;
|
|
1014
1014
|
}
|
|
1015
|
-
function
|
|
1015
|
+
function Tl() {
|
|
1016
1016
|
return { type: "boolean" };
|
|
1017
1017
|
}
|
|
1018
|
-
function
|
|
1018
|
+
function Un(e, t) {
|
|
1019
1019
|
return G(e.type._def, t);
|
|
1020
1020
|
}
|
|
1021
|
-
var
|
|
1022
|
-
function
|
|
1021
|
+
var Il = (e, t) => G(e.innerType._def, t);
|
|
1022
|
+
function Dn(e, t, r) {
|
|
1023
1023
|
const a = r ?? t.dateStrategy;
|
|
1024
1024
|
if (Array.isArray(a))
|
|
1025
1025
|
return {
|
|
1026
|
-
anyOf: a.map((o, n) =>
|
|
1026
|
+
anyOf: a.map((o, n) => Dn(e, t, o))
|
|
1027
1027
|
};
|
|
1028
1028
|
switch (a) {
|
|
1029
1029
|
case "string":
|
|
@@ -1038,10 +1038,10 @@ function Un(e, t, r) {
|
|
|
1038
1038
|
format: "date"
|
|
1039
1039
|
};
|
|
1040
1040
|
case "integer":
|
|
1041
|
-
return
|
|
1041
|
+
return Sl(e);
|
|
1042
1042
|
}
|
|
1043
1043
|
}
|
|
1044
|
-
var
|
|
1044
|
+
var Sl = (e) => {
|
|
1045
1045
|
const t = {
|
|
1046
1046
|
type: "integer",
|
|
1047
1047
|
format: "unix-time"
|
|
@@ -1057,23 +1057,23 @@ var Il = (e) => {
|
|
|
1057
1057
|
}
|
|
1058
1058
|
return t;
|
|
1059
1059
|
};
|
|
1060
|
-
function
|
|
1060
|
+
function El(e, t) {
|
|
1061
1061
|
return {
|
|
1062
1062
|
...G(e.innerType._def, t),
|
|
1063
1063
|
default: e.defaultValue()
|
|
1064
1064
|
};
|
|
1065
1065
|
}
|
|
1066
|
-
function
|
|
1066
|
+
function xl(e, t) {
|
|
1067
1067
|
return t.effectStrategy === "input" ? G(e.schema._def, t) : ue();
|
|
1068
1068
|
}
|
|
1069
|
-
function
|
|
1069
|
+
function Rl(e) {
|
|
1070
1070
|
return {
|
|
1071
1071
|
type: "string",
|
|
1072
1072
|
enum: Array.from(e.values)
|
|
1073
1073
|
};
|
|
1074
1074
|
}
|
|
1075
|
-
var
|
|
1076
|
-
function
|
|
1075
|
+
var Cl = (e) => "type" in e && e.type === "string" ? !1 : "allOf" in e;
|
|
1076
|
+
function Al(e, t) {
|
|
1077
1077
|
const r = [
|
|
1078
1078
|
G(e.left._def, {
|
|
1079
1079
|
...t,
|
|
@@ -1085,7 +1085,7 @@ function Cl(e, t) {
|
|
|
1085
1085
|
})
|
|
1086
1086
|
].filter((o) => !!o), a = [];
|
|
1087
1087
|
return r.forEach((o) => {
|
|
1088
|
-
if (
|
|
1088
|
+
if (Cl(o))
|
|
1089
1089
|
a.push(...o.allOf);
|
|
1090
1090
|
else {
|
|
1091
1091
|
let n = o;
|
|
@@ -1097,7 +1097,7 @@ function Cl(e, t) {
|
|
|
1097
1097
|
}
|
|
1098
1098
|
}), a.length ? { allOf: a } : void 0;
|
|
1099
1099
|
}
|
|
1100
|
-
function
|
|
1100
|
+
function kl(e) {
|
|
1101
1101
|
const t = typeof e.value;
|
|
1102
1102
|
return t !== "bigint" && t !== "number" && t !== "boolean" && t !== "string" ? {
|
|
1103
1103
|
type: Array.isArray(e.value) ? "array" : "object"
|
|
@@ -1151,7 +1151,7 @@ var vr = void 0, ge = {
|
|
|
1151
1151
|
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
1152
1152
|
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
1153
1153
|
};
|
|
1154
|
-
function
|
|
1154
|
+
function jn(e, t) {
|
|
1155
1155
|
const r = {
|
|
1156
1156
|
type: "string"
|
|
1157
1157
|
};
|
|
@@ -1276,15 +1276,15 @@ function Dn(e, t) {
|
|
|
1276
1276
|
return r;
|
|
1277
1277
|
}
|
|
1278
1278
|
function yr(e, t) {
|
|
1279
|
-
return t.patternStrategy === "escape" ?
|
|
1279
|
+
return t.patternStrategy === "escape" ? Pl(e) : e;
|
|
1280
1280
|
}
|
|
1281
|
-
var
|
|
1281
|
+
var Ol = new Set(
|
|
1282
1282
|
"ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789"
|
|
1283
1283
|
);
|
|
1284
|
-
function
|
|
1284
|
+
function Pl(e) {
|
|
1285
1285
|
let t = "";
|
|
1286
1286
|
for (let r = 0; r < e.length; r++)
|
|
1287
|
-
|
|
1287
|
+
Ol.has(e[r]) || (t += "\\"), t += e[r];
|
|
1288
1288
|
return t;
|
|
1289
1289
|
}
|
|
1290
1290
|
function ve(e, t, r, a) {
|
|
@@ -1364,7 +1364,7 @@ function Ra(e, t) {
|
|
|
1364
1364
|
}
|
|
1365
1365
|
return n;
|
|
1366
1366
|
}
|
|
1367
|
-
function
|
|
1367
|
+
function qn(e, t) {
|
|
1368
1368
|
var r, a, o, n, i, s;
|
|
1369
1369
|
const u = {
|
|
1370
1370
|
type: "object",
|
|
@@ -1374,7 +1374,7 @@ function jn(e, t) {
|
|
|
1374
1374
|
})) != null ? r : t.allowedAdditionalProperties
|
|
1375
1375
|
};
|
|
1376
1376
|
if (((a = e.keyType) == null ? void 0 : a._def.typeName) === M.ZodString && ((o = e.keyType._def.checks) != null && o.length)) {
|
|
1377
|
-
const { type: l, ...d } =
|
|
1377
|
+
const { type: l, ...d } = jn(e.keyType._def, t);
|
|
1378
1378
|
return {
|
|
1379
1379
|
...u,
|
|
1380
1380
|
propertyNames: d
|
|
@@ -1388,7 +1388,7 @@ function jn(e, t) {
|
|
|
1388
1388
|
}
|
|
1389
1389
|
};
|
|
1390
1390
|
if (((i = e.keyType) == null ? void 0 : i._def.typeName) === M.ZodBranded && e.keyType._def.type._def.typeName === M.ZodString && ((s = e.keyType._def.type._def.checks) != null && s.length)) {
|
|
1391
|
-
const { type: l, ...d } =
|
|
1391
|
+
const { type: l, ...d } = Un(
|
|
1392
1392
|
e.keyType._def,
|
|
1393
1393
|
t
|
|
1394
1394
|
);
|
|
@@ -1400,9 +1400,9 @@ function jn(e, t) {
|
|
|
1400
1400
|
}
|
|
1401
1401
|
return u;
|
|
1402
1402
|
}
|
|
1403
|
-
function
|
|
1403
|
+
function Ml(e, t) {
|
|
1404
1404
|
if (t.mapStrategy === "record")
|
|
1405
|
-
return
|
|
1405
|
+
return qn(e, t);
|
|
1406
1406
|
const r = G(e.keyType._def, {
|
|
1407
1407
|
...t,
|
|
1408
1408
|
currentPath: [...t.currentPath, "items", "items", "0"]
|
|
@@ -1421,7 +1421,7 @@ function Pl(e, t) {
|
|
|
1421
1421
|
}
|
|
1422
1422
|
};
|
|
1423
1423
|
}
|
|
1424
|
-
function
|
|
1424
|
+
function Nl(e) {
|
|
1425
1425
|
const t = e.values, a = Object.keys(e.values).filter((n) => typeof t[t[n]] != "number").map((n) => t[n]), o = Array.from(
|
|
1426
1426
|
new Set(a.map((n) => typeof n))
|
|
1427
1427
|
);
|
|
@@ -1430,10 +1430,10 @@ function Ml(e) {
|
|
|
1430
1430
|
enum: a
|
|
1431
1431
|
};
|
|
1432
1432
|
}
|
|
1433
|
-
function
|
|
1433
|
+
function $l() {
|
|
1434
1434
|
return { not: ue() };
|
|
1435
1435
|
}
|
|
1436
|
-
function
|
|
1436
|
+
function Ul() {
|
|
1437
1437
|
return {
|
|
1438
1438
|
type: "null"
|
|
1439
1439
|
};
|
|
@@ -1445,7 +1445,7 @@ var Nr = {
|
|
|
1445
1445
|
ZodBoolean: "boolean",
|
|
1446
1446
|
ZodNull: "null"
|
|
1447
1447
|
};
|
|
1448
|
-
function
|
|
1448
|
+
function Dl(e, t) {
|
|
1449
1449
|
const r = e.options instanceof Map ? Array.from(e.options.values()) : e.options;
|
|
1450
1450
|
if (r.every(
|
|
1451
1451
|
(a) => a._def.typeName in Nr && (!a._def.checks || !a._def.checks.length)
|
|
@@ -1500,9 +1500,9 @@ function Ul(e, t) {
|
|
|
1500
1500
|
[]
|
|
1501
1501
|
)
|
|
1502
1502
|
};
|
|
1503
|
-
return
|
|
1503
|
+
return jl(e, t);
|
|
1504
1504
|
}
|
|
1505
|
-
var
|
|
1505
|
+
var jl = (e, t) => {
|
|
1506
1506
|
const r = (e.options instanceof Map ? Array.from(e.options.values()) : e.options).map(
|
|
1507
1507
|
(a, o) => G(a._def, {
|
|
1508
1508
|
...t,
|
|
@@ -1513,7 +1513,7 @@ var Dl = (e, t) => {
|
|
|
1513
1513
|
);
|
|
1514
1514
|
return r.length ? { anyOf: r } : void 0;
|
|
1515
1515
|
};
|
|
1516
|
-
function
|
|
1516
|
+
function ql(e, t) {
|
|
1517
1517
|
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(
|
|
1518
1518
|
e.innerType._def.typeName
|
|
1519
1519
|
) && (!e.innerType._def.checks || !e.innerType._def.checks.length))
|
|
@@ -1529,7 +1529,7 @@ function jl(e, t) {
|
|
|
1529
1529
|
});
|
|
1530
1530
|
return r && { anyOf: [r, { type: "null" }] };
|
|
1531
1531
|
}
|
|
1532
|
-
function
|
|
1532
|
+
function Ll(e) {
|
|
1533
1533
|
const t = {
|
|
1534
1534
|
type: "number"
|
|
1535
1535
|
};
|
|
@@ -1551,7 +1551,7 @@ function ql(e) {
|
|
|
1551
1551
|
}
|
|
1552
1552
|
return t;
|
|
1553
1553
|
}
|
|
1554
|
-
function
|
|
1554
|
+
function Vl(e, t) {
|
|
1555
1555
|
const r = {
|
|
1556
1556
|
type: "object",
|
|
1557
1557
|
properties: {}
|
|
@@ -1560,7 +1560,7 @@ function Ll(e, t) {
|
|
|
1560
1560
|
let s = o[i];
|
|
1561
1561
|
if (s === void 0 || s._def === void 0)
|
|
1562
1562
|
continue;
|
|
1563
|
-
const u =
|
|
1563
|
+
const u = Bl(s), l = G(s._def, {
|
|
1564
1564
|
...t,
|
|
1565
1565
|
currentPath: [...t.currentPath, "properties", i],
|
|
1566
1566
|
propertyPath: [...t.currentPath, "properties", i]
|
|
@@ -1568,10 +1568,10 @@ function Ll(e, t) {
|
|
|
1568
1568
|
l !== void 0 && (r.properties[i] = l, u || a.push(i));
|
|
1569
1569
|
}
|
|
1570
1570
|
a.length && (r.required = a);
|
|
1571
|
-
const n =
|
|
1571
|
+
const n = Fl(e, t);
|
|
1572
1572
|
return n !== void 0 && (r.additionalProperties = n), r;
|
|
1573
1573
|
}
|
|
1574
|
-
function
|
|
1574
|
+
function Fl(e, t) {
|
|
1575
1575
|
if (e.catchall._def.typeName !== "ZodNever")
|
|
1576
1576
|
return G(e.catchall._def, {
|
|
1577
1577
|
...t,
|
|
@@ -1586,14 +1586,14 @@ function Vl(e, t) {
|
|
|
1586
1586
|
return t.removeAdditionalStrategy === "strict" ? t.allowedAdditionalProperties : t.rejectedAdditionalProperties;
|
|
1587
1587
|
}
|
|
1588
1588
|
}
|
|
1589
|
-
function
|
|
1589
|
+
function Bl(e) {
|
|
1590
1590
|
try {
|
|
1591
1591
|
return e.isOptional();
|
|
1592
1592
|
} catch {
|
|
1593
1593
|
return !0;
|
|
1594
1594
|
}
|
|
1595
1595
|
}
|
|
1596
|
-
var
|
|
1596
|
+
var Hl = (e, t) => {
|
|
1597
1597
|
var r;
|
|
1598
1598
|
if (t.currentPath.toString() === ((r = t.propertyPath) == null ? void 0 : r.toString()))
|
|
1599
1599
|
return G(e.innerType._def, t);
|
|
@@ -1602,7 +1602,7 @@ var Bl = (e, t) => {
|
|
|
1602
1602
|
currentPath: [...t.currentPath, "anyOf", "1"]
|
|
1603
1603
|
});
|
|
1604
1604
|
return a ? { anyOf: [{ not: ue() }, a] } : ue();
|
|
1605
|
-
},
|
|
1605
|
+
}, Gl = (e, t) => {
|
|
1606
1606
|
if (t.pipeStrategy === "input")
|
|
1607
1607
|
return G(e.in._def, t);
|
|
1608
1608
|
if (t.pipeStrategy === "output")
|
|
@@ -1618,10 +1618,10 @@ var Bl = (e, t) => {
|
|
|
1618
1618
|
allOf: [r, a].filter((o) => o !== void 0)
|
|
1619
1619
|
};
|
|
1620
1620
|
};
|
|
1621
|
-
function
|
|
1621
|
+
function Jl(e, t) {
|
|
1622
1622
|
return G(e.type._def, t);
|
|
1623
1623
|
}
|
|
1624
|
-
function
|
|
1624
|
+
function Zl(e, t) {
|
|
1625
1625
|
const a = {
|
|
1626
1626
|
type: "array",
|
|
1627
1627
|
uniqueItems: !0,
|
|
@@ -1632,7 +1632,7 @@ function Jl(e, t) {
|
|
|
1632
1632
|
};
|
|
1633
1633
|
return e.minSize && (a.minItems = e.minSize.value), e.maxSize && (a.maxItems = e.maxSize.value), a;
|
|
1634
1634
|
}
|
|
1635
|
-
function
|
|
1635
|
+
function zl(e, t) {
|
|
1636
1636
|
return e.rest ? {
|
|
1637
1637
|
type: "array",
|
|
1638
1638
|
minItems: e.items.length,
|
|
@@ -1664,80 +1664,80 @@ function Zl(e, t) {
|
|
|
1664
1664
|
)
|
|
1665
1665
|
};
|
|
1666
1666
|
}
|
|
1667
|
-
function
|
|
1667
|
+
function Wl() {
|
|
1668
1668
|
return {
|
|
1669
1669
|
not: ue()
|
|
1670
1670
|
};
|
|
1671
1671
|
}
|
|
1672
|
-
function
|
|
1672
|
+
function Kl() {
|
|
1673
1673
|
return ue();
|
|
1674
1674
|
}
|
|
1675
|
-
var
|
|
1675
|
+
var Yl = (e, t) => G(e.innerType._def, t), Xl = (e, t, r) => {
|
|
1676
1676
|
switch (t) {
|
|
1677
1677
|
case M.ZodString:
|
|
1678
|
-
return
|
|
1678
|
+
return jn(e, r);
|
|
1679
1679
|
case M.ZodNumber:
|
|
1680
|
-
return
|
|
1680
|
+
return Ll(e);
|
|
1681
1681
|
case M.ZodObject:
|
|
1682
|
-
return
|
|
1682
|
+
return Vl(e, r);
|
|
1683
1683
|
case M.ZodBigInt:
|
|
1684
|
-
return
|
|
1684
|
+
return bl(e);
|
|
1685
1685
|
case M.ZodBoolean:
|
|
1686
|
-
return
|
|
1686
|
+
return Tl();
|
|
1687
1687
|
case M.ZodDate:
|
|
1688
|
-
return
|
|
1688
|
+
return Dn(e, r);
|
|
1689
1689
|
case M.ZodUndefined:
|
|
1690
|
-
return
|
|
1690
|
+
return Wl();
|
|
1691
1691
|
case M.ZodNull:
|
|
1692
|
-
return
|
|
1692
|
+
return Ul();
|
|
1693
1693
|
case M.ZodArray:
|
|
1694
|
-
return
|
|
1694
|
+
return wl(e, r);
|
|
1695
1695
|
case M.ZodUnion:
|
|
1696
1696
|
case M.ZodDiscriminatedUnion:
|
|
1697
|
-
return
|
|
1697
|
+
return Dl(e, r);
|
|
1698
1698
|
case M.ZodIntersection:
|
|
1699
|
-
return
|
|
1699
|
+
return Al(e, r);
|
|
1700
1700
|
case M.ZodTuple:
|
|
1701
|
-
return
|
|
1701
|
+
return zl(e, r);
|
|
1702
1702
|
case M.ZodRecord:
|
|
1703
|
-
return
|
|
1703
|
+
return qn(e, r);
|
|
1704
1704
|
case M.ZodLiteral:
|
|
1705
|
-
return
|
|
1705
|
+
return kl(e);
|
|
1706
1706
|
case M.ZodEnum:
|
|
1707
|
-
return
|
|
1707
|
+
return Rl(e);
|
|
1708
1708
|
case M.ZodNativeEnum:
|
|
1709
|
-
return
|
|
1709
|
+
return Nl(e);
|
|
1710
1710
|
case M.ZodNullable:
|
|
1711
|
-
return
|
|
1711
|
+
return ql(e, r);
|
|
1712
1712
|
case M.ZodOptional:
|
|
1713
|
-
return
|
|
1713
|
+
return Hl(e, r);
|
|
1714
1714
|
case M.ZodMap:
|
|
1715
|
-
return
|
|
1715
|
+
return Ml(e, r);
|
|
1716
1716
|
case M.ZodSet:
|
|
1717
|
-
return
|
|
1717
|
+
return Zl(e, r);
|
|
1718
1718
|
case M.ZodLazy:
|
|
1719
1719
|
return () => e.getter()._def;
|
|
1720
1720
|
case M.ZodPromise:
|
|
1721
|
-
return
|
|
1721
|
+
return Jl(e, r);
|
|
1722
1722
|
case M.ZodNaN:
|
|
1723
1723
|
case M.ZodNever:
|
|
1724
|
-
return
|
|
1724
|
+
return $l();
|
|
1725
1725
|
case M.ZodEffects:
|
|
1726
|
-
return
|
|
1726
|
+
return xl(e, r);
|
|
1727
1727
|
case M.ZodAny:
|
|
1728
1728
|
return ue();
|
|
1729
1729
|
case M.ZodUnknown:
|
|
1730
|
-
return
|
|
1730
|
+
return Kl();
|
|
1731
1731
|
case M.ZodDefault:
|
|
1732
|
-
return
|
|
1732
|
+
return El(e, r);
|
|
1733
1733
|
case M.ZodBranded:
|
|
1734
|
-
return
|
|
1734
|
+
return Un(e, r);
|
|
1735
1735
|
case M.ZodReadonly:
|
|
1736
|
-
return
|
|
1736
|
+
return Yl(e, r);
|
|
1737
1737
|
case M.ZodCatch:
|
|
1738
|
-
return
|
|
1738
|
+
return Il(e, r);
|
|
1739
1739
|
case M.ZodPipeline:
|
|
1740
|
-
return
|
|
1740
|
+
return Gl(e, r);
|
|
1741
1741
|
case M.ZodFunction:
|
|
1742
1742
|
case M.ZodVoid:
|
|
1743
1743
|
case M.ZodSymbol:
|
|
@@ -1758,29 +1758,29 @@ function G(e, t, r = !1) {
|
|
|
1758
1758
|
o,
|
|
1759
1759
|
r
|
|
1760
1760
|
);
|
|
1761
|
-
if (u !==
|
|
1761
|
+
if (u !== yl)
|
|
1762
1762
|
return u;
|
|
1763
1763
|
}
|
|
1764
1764
|
if (o && !r) {
|
|
1765
|
-
const u =
|
|
1765
|
+
const u = Ql(o, t);
|
|
1766
1766
|
if (u !== void 0)
|
|
1767
1767
|
return u;
|
|
1768
1768
|
}
|
|
1769
1769
|
const n = { def: e, path: t.currentPath, jsonSchema: void 0 };
|
|
1770
1770
|
t.seen.set(e, n);
|
|
1771
|
-
const i =
|
|
1772
|
-
if (s &&
|
|
1771
|
+
const i = Xl(e, e.typeName, t), s = typeof i == "function" ? G(i(), t) : i;
|
|
1772
|
+
if (s && eu(e, t, s), t.postProcess) {
|
|
1773
1773
|
const u = t.postProcess(s, e, t);
|
|
1774
1774
|
return n.jsonSchema = s, u;
|
|
1775
1775
|
}
|
|
1776
1776
|
return n.jsonSchema = s, s;
|
|
1777
1777
|
}
|
|
1778
|
-
var
|
|
1778
|
+
var Ql = (e, t) => {
|
|
1779
1779
|
switch (t.$refStrategy) {
|
|
1780
1780
|
case "root":
|
|
1781
1781
|
return { $ref: e.path.join("/") };
|
|
1782
1782
|
case "relative":
|
|
1783
|
-
return { $ref:
|
|
1783
|
+
return { $ref: vl(t.currentPath, e.path) };
|
|
1784
1784
|
case "none":
|
|
1785
1785
|
case "seen":
|
|
1786
1786
|
return e.path.length < t.currentPath.length && e.path.every((r, a) => t.currentPath[a] === r) ? (console.warn(
|
|
@@ -1789,8 +1789,8 @@ var Xl = (e, t) => {
|
|
|
1789
1789
|
)}! Defaulting to any`
|
|
1790
1790
|
), ue()) : t.$refStrategy === "seen" ? ue() : void 0;
|
|
1791
1791
|
}
|
|
1792
|
-
},
|
|
1793
|
-
const t =
|
|
1792
|
+
}, eu = (e, t, r) => (e.description && (r.description = e.description), r), tu = (e) => {
|
|
1793
|
+
const t = _l(e), r = t.name !== void 0 ? [...t.basePath, t.definitionPath, t.name] : t.basePath;
|
|
1794
1794
|
return {
|
|
1795
1795
|
...t,
|
|
1796
1796
|
currentPath: r,
|
|
@@ -1807,9 +1807,9 @@ var Xl = (e, t) => {
|
|
|
1807
1807
|
])
|
|
1808
1808
|
)
|
|
1809
1809
|
};
|
|
1810
|
-
},
|
|
1810
|
+
}, ru = (e, t) => {
|
|
1811
1811
|
var r;
|
|
1812
|
-
const a =
|
|
1812
|
+
const a = tu(t);
|
|
1813
1813
|
let o = typeof t == "object" && t.definitions ? Object.entries(t.definitions).reduce(
|
|
1814
1814
|
(l, [d, p]) => {
|
|
1815
1815
|
var m;
|
|
@@ -1851,13 +1851,13 @@ var Xl = (e, t) => {
|
|
|
1851
1851
|
}
|
|
1852
1852
|
};
|
|
1853
1853
|
return u.$schema = "http://json-schema.org/draft-07/schema#", u;
|
|
1854
|
-
},
|
|
1855
|
-
function
|
|
1854
|
+
}, au = ru;
|
|
1855
|
+
function nu(e, t) {
|
|
1856
1856
|
var r;
|
|
1857
1857
|
const a = (r = void 0) != null ? r : !1;
|
|
1858
1858
|
return Yr(
|
|
1859
1859
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
1860
|
-
() =>
|
|
1860
|
+
() => au(e, {
|
|
1861
1861
|
$refStrategy: a ? "root" : "none"
|
|
1862
1862
|
}),
|
|
1863
1863
|
{
|
|
@@ -1868,29 +1868,29 @@ function au(e, t) {
|
|
|
1868
1868
|
}
|
|
1869
1869
|
);
|
|
1870
1870
|
}
|
|
1871
|
-
function
|
|
1871
|
+
function ou(e, t) {
|
|
1872
1872
|
var r;
|
|
1873
1873
|
const a = (r = void 0) != null ? r : !1;
|
|
1874
1874
|
return Yr(
|
|
1875
1875
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
1876
|
-
() =>
|
|
1876
|
+
() => ni(e, {
|
|
1877
1877
|
target: "draft-7",
|
|
1878
1878
|
io: "output",
|
|
1879
1879
|
reused: a ? "ref" : "inline"
|
|
1880
1880
|
}),
|
|
1881
1881
|
{
|
|
1882
1882
|
validate: async (o) => {
|
|
1883
|
-
const n = await
|
|
1883
|
+
const n = await ai(e, o);
|
|
1884
1884
|
return n.success ? { success: !0, value: n.data } : { success: !1, error: n.error };
|
|
1885
1885
|
}
|
|
1886
1886
|
}
|
|
1887
1887
|
);
|
|
1888
1888
|
}
|
|
1889
|
-
function
|
|
1889
|
+
function su(e) {
|
|
1890
1890
|
return "_zod" in e;
|
|
1891
1891
|
}
|
|
1892
1892
|
function Be(e, t) {
|
|
1893
|
-
return
|
|
1893
|
+
return su(e) ? ou(e) : nu(e);
|
|
1894
1894
|
}
|
|
1895
1895
|
var $r = Symbol.for("vercel.ai.schema");
|
|
1896
1896
|
function Yr(e, {
|
|
@@ -1907,39 +1907,39 @@ function Yr(e, {
|
|
|
1907
1907
|
validate: t
|
|
1908
1908
|
};
|
|
1909
1909
|
}
|
|
1910
|
-
function
|
|
1910
|
+
function iu(e) {
|
|
1911
1911
|
return typeof e == "object" && e !== null && $r in e && e[$r] === !0 && "jsonSchema" in e && "validate" in e;
|
|
1912
1912
|
}
|
|
1913
1913
|
function Qt(e) {
|
|
1914
1914
|
return e == null ? Yr({
|
|
1915
1915
|
properties: {},
|
|
1916
1916
|
additionalProperties: !1
|
|
1917
|
-
}) :
|
|
1917
|
+
}) : iu(e) ? e : typeof e == "function" ? e() : Be(e);
|
|
1918
1918
|
}
|
|
1919
|
-
var { btoa:
|
|
1919
|
+
var { btoa: lu, atob: uu } = globalThis;
|
|
1920
1920
|
function Xr(e) {
|
|
1921
|
-
const t = e.replace(/-/g, "+").replace(/_/g, "/"), r =
|
|
1921
|
+
const t = e.replace(/-/g, "+").replace(/_/g, "/"), r = uu(t);
|
|
1922
1922
|
return Uint8Array.from(r, (a) => a.codePointAt(0));
|
|
1923
1923
|
}
|
|
1924
1924
|
function Ur(e) {
|
|
1925
1925
|
let t = "";
|
|
1926
1926
|
for (let r = 0; r < e.length; r++)
|
|
1927
1927
|
t += String.fromCodePoint(e[r]);
|
|
1928
|
-
return
|
|
1928
|
+
return lu(t);
|
|
1929
1929
|
}
|
|
1930
|
-
function
|
|
1930
|
+
function cu(e) {
|
|
1931
1931
|
return e?.replace(/\/$/, "");
|
|
1932
1932
|
}
|
|
1933
|
-
function
|
|
1933
|
+
function du(e) {
|
|
1934
1934
|
return e != null && typeof e[Symbol.asyncIterator] == "function";
|
|
1935
1935
|
}
|
|
1936
|
-
async function*
|
|
1936
|
+
async function* pu({
|
|
1937
1937
|
execute: e,
|
|
1938
1938
|
input: t,
|
|
1939
1939
|
options: r
|
|
1940
1940
|
}) {
|
|
1941
1941
|
const a = e(t, r);
|
|
1942
|
-
if (
|
|
1942
|
+
if (du(a)) {
|
|
1943
1943
|
let o;
|
|
1944
1944
|
for await (const n of a)
|
|
1945
1945
|
o = n, yield { type: "preliminary", output: n };
|
|
@@ -1948,7 +1948,7 @@ async function* du({
|
|
|
1948
1948
|
yield { type: "final", output: await a };
|
|
1949
1949
|
}
|
|
1950
1950
|
var _r, Ca;
|
|
1951
|
-
function
|
|
1951
|
+
function fu() {
|
|
1952
1952
|
if (Ca) return _r;
|
|
1953
1953
|
Ca = 1;
|
|
1954
1954
|
var e = Object.defineProperty, t = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, a = Object.prototype.hasOwnProperty, o = (d, p) => {
|
|
@@ -1971,7 +1971,7 @@ function pu() {
|
|
|
1971
1971
|
return _r;
|
|
1972
1972
|
}
|
|
1973
1973
|
var wr, Aa;
|
|
1974
|
-
function
|
|
1974
|
+
function hu() {
|
|
1975
1975
|
if (Aa) return wr;
|
|
1976
1976
|
Aa = 1;
|
|
1977
1977
|
var e = Object.defineProperty, t = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, a = Object.prototype.hasOwnProperty, o = (p, m) => {
|
|
@@ -1988,7 +1988,7 @@ function fu() {
|
|
|
1988
1988
|
getVercelOidcToken: () => l,
|
|
1989
1989
|
getVercelOidcTokenSync: () => d
|
|
1990
1990
|
}), wr = i(s);
|
|
1991
|
-
var u =
|
|
1991
|
+
var u = fu();
|
|
1992
1992
|
async function l() {
|
|
1993
1993
|
return "";
|
|
1994
1994
|
}
|
|
@@ -1997,7 +1997,7 @@ function fu() {
|
|
|
1997
1997
|
}
|
|
1998
1998
|
return wr;
|
|
1999
1999
|
}
|
|
2000
|
-
var
|
|
2000
|
+
var Ln = hu(), mu = "vercel.ai.gateway.error", br = Symbol.for(mu), ka, Oa, ce = class Vn extends (Oa = Error, ka = br, Oa) {
|
|
2001
2001
|
constructor({
|
|
2002
2002
|
message: t,
|
|
2003
2003
|
statusCode: r = 500,
|
|
@@ -2011,18 +2011,18 @@ var qn = fu(), hu = "vercel.ai.gateway.error", br = Symbol.for(hu), ka, Oa, ce =
|
|
|
2011
2011
|
* @returns {boolean} True if the error is a Gateway Error, false otherwise.
|
|
2012
2012
|
*/
|
|
2013
2013
|
static isInstance(t) {
|
|
2014
|
-
return
|
|
2014
|
+
return Vn.hasMarker(t);
|
|
2015
2015
|
}
|
|
2016
2016
|
static hasMarker(t) {
|
|
2017
2017
|
return typeof t == "object" && t !== null && br in t && t[br] === !0;
|
|
2018
2018
|
}
|
|
2019
|
-
},
|
|
2019
|
+
}, Fn = "GatewayAuthenticationError", gu = `vercel.ai.gateway.error.${Fn}`, Pa = Symbol.for(gu), Ma, Na, Qr = class Bn extends (Na = ce, Ma = Pa, Na) {
|
|
2020
2020
|
constructor({
|
|
2021
2021
|
message: t = "Authentication failed",
|
|
2022
2022
|
statusCode: r = 401,
|
|
2023
2023
|
cause: a
|
|
2024
2024
|
} = {}) {
|
|
2025
|
-
super({ message: t, statusCode: r, cause: a }), this[Ma] = !0, this.name =
|
|
2025
|
+
super({ message: t, statusCode: r, cause: a }), this[Ma] = !0, this.name = Fn, this.type = "authentication_error";
|
|
2026
2026
|
}
|
|
2027
2027
|
static isInstance(t) {
|
|
2028
2028
|
return ce.hasMarker(t) && Pa in t;
|
|
@@ -2053,64 +2053,64 @@ Create an API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
|
2053
2053
|
Provide via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.
|
|
2054
2054
|
|
|
2055
2055
|
Option 2 - OIDC token:
|
|
2056
|
-
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.`, new
|
|
2056
|
+
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.`, new Bn({
|
|
2057
2057
|
message: i,
|
|
2058
2058
|
statusCode: o,
|
|
2059
2059
|
cause: n
|
|
2060
2060
|
});
|
|
2061
2061
|
}
|
|
2062
|
-
},
|
|
2062
|
+
}, Hn = "GatewayInvalidRequestError", vu = `vercel.ai.gateway.error.${Hn}`, $a = Symbol.for(vu), Ua, Da, yu = class extends (Da = ce, Ua = $a, Da) {
|
|
2063
2063
|
constructor({
|
|
2064
2064
|
message: e = "Invalid request",
|
|
2065
2065
|
statusCode: t = 400,
|
|
2066
2066
|
cause: r
|
|
2067
2067
|
} = {}) {
|
|
2068
|
-
super({ message: e, statusCode: t, cause: r }), this[Ua] = !0, this.name =
|
|
2068
|
+
super({ message: e, statusCode: t, cause: r }), this[Ua] = !0, this.name = Hn, this.type = "invalid_request_error";
|
|
2069
2069
|
}
|
|
2070
2070
|
static isInstance(e) {
|
|
2071
2071
|
return ce.hasMarker(e) && $a in e;
|
|
2072
2072
|
}
|
|
2073
|
-
},
|
|
2073
|
+
}, Gn = "GatewayRateLimitError", _u = `vercel.ai.gateway.error.${Gn}`, ja = Symbol.for(_u), qa, La, wu = class extends (La = ce, qa = ja, La) {
|
|
2074
2074
|
constructor({
|
|
2075
2075
|
message: e = "Rate limit exceeded",
|
|
2076
2076
|
statusCode: t = 429,
|
|
2077
2077
|
cause: r
|
|
2078
2078
|
} = {}) {
|
|
2079
|
-
super({ message: e, statusCode: t, cause: r }), this[qa] = !0, this.name =
|
|
2079
|
+
super({ message: e, statusCode: t, cause: r }), this[qa] = !0, this.name = Gn, this.type = "rate_limit_exceeded";
|
|
2080
2080
|
}
|
|
2081
2081
|
static isInstance(e) {
|
|
2082
2082
|
return ce.hasMarker(e) && ja in e;
|
|
2083
2083
|
}
|
|
2084
|
-
},
|
|
2084
|
+
}, Jn = "GatewayModelNotFoundError", bu = `vercel.ai.gateway.error.${Jn}`, Va = Symbol.for(bu), Tu = Xe(
|
|
2085
2085
|
() => Be(
|
|
2086
2086
|
v({
|
|
2087
2087
|
modelId: c()
|
|
2088
2088
|
})
|
|
2089
2089
|
)
|
|
2090
|
-
), Fa, Ba,
|
|
2090
|
+
), Fa, Ba, Zn = class extends (Ba = ce, Fa = Va, Ba) {
|
|
2091
2091
|
constructor({
|
|
2092
2092
|
message: e = "Model not found",
|
|
2093
2093
|
statusCode: t = 404,
|
|
2094
2094
|
modelId: r,
|
|
2095
2095
|
cause: a
|
|
2096
2096
|
} = {}) {
|
|
2097
|
-
super({ message: e, statusCode: t, cause: a }), this[Fa] = !0, this.name =
|
|
2097
|
+
super({ message: e, statusCode: t, cause: a }), this[Fa] = !0, this.name = Jn, this.type = "model_not_found", this.modelId = r;
|
|
2098
2098
|
}
|
|
2099
2099
|
static isInstance(e) {
|
|
2100
2100
|
return ce.hasMarker(e) && Va in e;
|
|
2101
2101
|
}
|
|
2102
|
-
},
|
|
2102
|
+
}, zn = "GatewayInternalServerError", Iu = `vercel.ai.gateway.error.${zn}`, Ha = Symbol.for(Iu), Ga, Ja, Za = class extends (Ja = ce, Ga = Ha, Ja) {
|
|
2103
2103
|
constructor({
|
|
2104
2104
|
message: e = "Internal server error",
|
|
2105
2105
|
statusCode: t = 500,
|
|
2106
2106
|
cause: r
|
|
2107
2107
|
} = {}) {
|
|
2108
|
-
super({ message: e, statusCode: t, cause: r }), this[Ga] = !0, this.name =
|
|
2108
|
+
super({ message: e, statusCode: t, cause: r }), this[Ga] = !0, this.name = zn, this.type = "internal_server_error";
|
|
2109
2109
|
}
|
|
2110
2110
|
static isInstance(e) {
|
|
2111
2111
|
return ce.hasMarker(e) && Ha in e;
|
|
2112
2112
|
}
|
|
2113
|
-
},
|
|
2113
|
+
}, Wn = "GatewayResponseError", Su = `vercel.ai.gateway.error.${Wn}`, za = Symbol.for(Su), Wa, Ka, Eu = class extends (Ka = ce, Wa = za, Ka) {
|
|
2114
2114
|
constructor({
|
|
2115
2115
|
message: e = "Invalid response from Gateway",
|
|
2116
2116
|
statusCode: t = 502,
|
|
@@ -2118,7 +2118,7 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
2118
2118
|
validationError: a,
|
|
2119
2119
|
cause: o
|
|
2120
2120
|
} = {}) {
|
|
2121
|
-
super({ message: e, statusCode: t, cause: o }), this[Wa] = !0, this.name =
|
|
2121
|
+
super({ message: e, statusCode: t, cause: o }), this[Wa] = !0, this.name = Wn, this.type = "response_error", this.response = r, this.validationError = a;
|
|
2122
2122
|
}
|
|
2123
2123
|
static isInstance(e) {
|
|
2124
2124
|
return ce.hasMarker(e) && za in e;
|
|
@@ -2133,10 +2133,10 @@ async function Ya({
|
|
|
2133
2133
|
}) {
|
|
2134
2134
|
const n = await je({
|
|
2135
2135
|
value: e,
|
|
2136
|
-
schema:
|
|
2136
|
+
schema: xu
|
|
2137
2137
|
});
|
|
2138
2138
|
if (!n.success)
|
|
2139
|
-
return new
|
|
2139
|
+
return new Eu({
|
|
2140
2140
|
message: `Invalid error response format: ${r}`,
|
|
2141
2141
|
statusCode: t,
|
|
2142
2142
|
response: e,
|
|
@@ -2153,15 +2153,15 @@ async function Ya({
|
|
|
2153
2153
|
cause: a
|
|
2154
2154
|
});
|
|
2155
2155
|
case "invalid_request_error":
|
|
2156
|
-
return new
|
|
2156
|
+
return new yu({ message: u, statusCode: t, cause: a });
|
|
2157
2157
|
case "rate_limit_exceeded":
|
|
2158
|
-
return new
|
|
2158
|
+
return new wu({ message: u, statusCode: t, cause: a });
|
|
2159
2159
|
case "model_not_found": {
|
|
2160
2160
|
const l = await je({
|
|
2161
2161
|
value: i.error.param,
|
|
2162
|
-
schema:
|
|
2162
|
+
schema: Tu
|
|
2163
2163
|
});
|
|
2164
|
-
return new
|
|
2164
|
+
return new Zn({
|
|
2165
2165
|
message: u,
|
|
2166
2166
|
statusCode: t,
|
|
2167
2167
|
modelId: l.success ? l.value.modelId : void 0,
|
|
@@ -2174,7 +2174,7 @@ async function Ya({
|
|
|
2174
2174
|
return new Za({ message: u, statusCode: t, cause: a });
|
|
2175
2175
|
}
|
|
2176
2176
|
}
|
|
2177
|
-
var
|
|
2177
|
+
var xu = Xe(
|
|
2178
2178
|
() => Be(
|
|
2179
2179
|
v({
|
|
2180
2180
|
error: v({
|
|
@@ -2189,7 +2189,7 @@ var Eu = Xe(
|
|
|
2189
2189
|
function Fe(e, t) {
|
|
2190
2190
|
var r;
|
|
2191
2191
|
return ce.isInstance(e) ? e : se.isInstance(e) ? Ya({
|
|
2192
|
-
response:
|
|
2192
|
+
response: Ru(e),
|
|
2193
2193
|
statusCode: (r = e.statusCode) != null ? r : 500,
|
|
2194
2194
|
defaultMessage: "Gateway request failed",
|
|
2195
2195
|
cause: e,
|
|
@@ -2202,7 +2202,7 @@ function Fe(e, t) {
|
|
|
2202
2202
|
authMethod: t
|
|
2203
2203
|
});
|
|
2204
2204
|
}
|
|
2205
|
-
function
|
|
2205
|
+
function Ru(e) {
|
|
2206
2206
|
if (e.data !== void 0)
|
|
2207
2207
|
return e.data;
|
|
2208
2208
|
if (e.responseBody != null)
|
|
@@ -2213,15 +2213,15 @@ function xu(e) {
|
|
|
2213
2213
|
}
|
|
2214
2214
|
return {};
|
|
2215
2215
|
}
|
|
2216
|
-
var
|
|
2216
|
+
var Kn = "ai-gateway-auth-method";
|
|
2217
2217
|
async function gt(e) {
|
|
2218
2218
|
const t = await je({
|
|
2219
|
-
value: e[
|
|
2220
|
-
schema:
|
|
2219
|
+
value: e[Kn],
|
|
2220
|
+
schema: Cu
|
|
2221
2221
|
});
|
|
2222
2222
|
return t.success ? t.value : void 0;
|
|
2223
2223
|
}
|
|
2224
|
-
var
|
|
2224
|
+
var Cu = Xe(
|
|
2225
2225
|
() => Be(D([C("api-key"), C("oidc")]))
|
|
2226
2226
|
), Xa = class {
|
|
2227
2227
|
constructor(e) {
|
|
@@ -2233,7 +2233,7 @@ var Ru = Xe(
|
|
|
2233
2233
|
url: `${this.config.baseURL}/config`,
|
|
2234
2234
|
headers: await Ue(this.config.headers()),
|
|
2235
2235
|
successfulResponseHandler: qt(
|
|
2236
|
-
|
|
2236
|
+
Au
|
|
2237
2237
|
),
|
|
2238
2238
|
failedResponseHandler: mt({
|
|
2239
2239
|
errorSchema: Oe(),
|
|
@@ -2252,7 +2252,7 @@ var Ru = Xe(
|
|
|
2252
2252
|
url: `${e.origin}/v1/credits`,
|
|
2253
2253
|
headers: await Ue(this.config.headers()),
|
|
2254
2254
|
successfulResponseHandler: qt(
|
|
2255
|
-
|
|
2255
|
+
ku
|
|
2256
2256
|
),
|
|
2257
2257
|
failedResponseHandler: mt({
|
|
2258
2258
|
errorSchema: Oe(),
|
|
@@ -2265,7 +2265,7 @@ var Ru = Xe(
|
|
|
2265
2265
|
throw await Fe(e);
|
|
2266
2266
|
}
|
|
2267
2267
|
}
|
|
2268
|
-
},
|
|
2268
|
+
}, Au = Xe(
|
|
2269
2269
|
() => Be(
|
|
2270
2270
|
v({
|
|
2271
2271
|
models: I(
|
|
@@ -2296,7 +2296,7 @@ var Ru = Xe(
|
|
|
2296
2296
|
)
|
|
2297
2297
|
})
|
|
2298
2298
|
)
|
|
2299
|
-
),
|
|
2299
|
+
), ku = Xe(
|
|
2300
2300
|
() => Be(
|
|
2301
2301
|
v({
|
|
2302
2302
|
balance: c(),
|
|
@@ -2306,7 +2306,7 @@ var Ru = Xe(
|
|
|
2306
2306
|
totalUsed: t
|
|
2307
2307
|
}))
|
|
2308
2308
|
)
|
|
2309
|
-
),
|
|
2309
|
+
), Ou = class {
|
|
2310
2310
|
constructor(e, t) {
|
|
2311
2311
|
this.modelId = e, this.config = t, this.specificationVersion = "v2", this.supportedUrls = { "*/*": [/.*/] };
|
|
2312
2312
|
}
|
|
@@ -2366,7 +2366,7 @@ var Ru = Xe(
|
|
|
2366
2366
|
await Ue(this.config.o11yHeaders)
|
|
2367
2367
|
),
|
|
2368
2368
|
body: t,
|
|
2369
|
-
successfulResponseHandler:
|
|
2369
|
+
successfulResponseHandler: gl(Oe()),
|
|
2370
2370
|
failedResponseHandler: mt({
|
|
2371
2371
|
errorSchema: Oe(),
|
|
2372
2372
|
errorToMessage: (s) => s
|
|
@@ -2433,7 +2433,7 @@ var Ru = Xe(
|
|
|
2433
2433
|
"ai-language-model-streaming": String(t)
|
|
2434
2434
|
};
|
|
2435
2435
|
}
|
|
2436
|
-
},
|
|
2436
|
+
}, Pu = class {
|
|
2437
2437
|
constructor(e, t) {
|
|
2438
2438
|
this.modelId = e, this.config = t, this.specificationVersion = "v2", this.maxEmbeddingsPerCall = 2048, this.supportsParallelCalls = !0;
|
|
2439
2439
|
}
|
|
@@ -2466,7 +2466,7 @@ var Ru = Xe(
|
|
|
2466
2466
|
...a ? { providerOptions: a } : {}
|
|
2467
2467
|
},
|
|
2468
2468
|
successfulResponseHandler: qt(
|
|
2469
|
-
|
|
2469
|
+
Mu
|
|
2470
2470
|
),
|
|
2471
2471
|
failedResponseHandler: mt({
|
|
2472
2472
|
errorSchema: Oe(),
|
|
@@ -2494,7 +2494,7 @@ var Ru = Xe(
|
|
|
2494
2494
|
"ai-model-id": this.modelId
|
|
2495
2495
|
};
|
|
2496
2496
|
}
|
|
2497
|
-
},
|
|
2497
|
+
}, Mu = Xe(
|
|
2498
2498
|
() => Be(
|
|
2499
2499
|
v({
|
|
2500
2500
|
embeddings: I(I(R())),
|
|
@@ -2503,27 +2503,27 @@ var Ru = Xe(
|
|
|
2503
2503
|
})
|
|
2504
2504
|
)
|
|
2505
2505
|
);
|
|
2506
|
-
async function
|
|
2506
|
+
async function Nu() {
|
|
2507
2507
|
var e;
|
|
2508
|
-
return (e =
|
|
2508
|
+
return (e = Ln.getContext().headers) == null ? void 0 : e["x-vercel-id"];
|
|
2509
2509
|
}
|
|
2510
|
-
var
|
|
2511
|
-
function
|
|
2510
|
+
var $u = "2.0.7", Uu = "0.0.1";
|
|
2511
|
+
function Du(e = {}) {
|
|
2512
2512
|
var t, r;
|
|
2513
2513
|
let a = null, o = null;
|
|
2514
2514
|
const n = (t = e.metadataCacheRefreshMillis) != null ? t : 1e3 * 60 * 5;
|
|
2515
2515
|
let i = 0;
|
|
2516
|
-
const s = (r =
|
|
2517
|
-
const h = await
|
|
2516
|
+
const s = (r = cu(e.baseURL)) != null ? r : "https://ai-gateway.vercel.sh/v1/ai", u = async () => {
|
|
2517
|
+
const h = await qu(e);
|
|
2518
2518
|
if (h)
|
|
2519
2519
|
return Xt(
|
|
2520
2520
|
{
|
|
2521
2521
|
Authorization: `Bearer ${h.token}`,
|
|
2522
|
-
"ai-gateway-protocol-version":
|
|
2523
|
-
[
|
|
2522
|
+
"ai-gateway-protocol-version": Uu,
|
|
2523
|
+
[Kn]: h.authMethod,
|
|
2524
2524
|
...e.headers
|
|
2525
2525
|
},
|
|
2526
|
-
`ai-sdk/gateway/${
|
|
2526
|
+
`ai-sdk/gateway/${$u}`
|
|
2527
2527
|
);
|
|
2528
2528
|
throw Qr.createContextualError({
|
|
2529
2529
|
apiKeyProvided: !1,
|
|
@@ -2542,7 +2542,7 @@ function Uu(e = {}) {
|
|
|
2542
2542
|
environmentVariableName: "VERCEL_REGION"
|
|
2543
2543
|
});
|
|
2544
2544
|
return async () => {
|
|
2545
|
-
const _ = await
|
|
2545
|
+
const _ = await Nu();
|
|
2546
2546
|
return {
|
|
2547
2547
|
...h && { "ai-o11y-deployment-id": h },
|
|
2548
2548
|
...y && { "ai-o11y-environment": y },
|
|
@@ -2550,7 +2550,7 @@ function Uu(e = {}) {
|
|
|
2550
2550
|
..._ && { "ai-o11y-request-id": _ }
|
|
2551
2551
|
};
|
|
2552
2552
|
};
|
|
2553
|
-
}, d = (h) => new
|
|
2553
|
+
}, d = (h) => new Ou(h, {
|
|
2554
2554
|
provider: "gateway",
|
|
2555
2555
|
baseURL: s,
|
|
2556
2556
|
headers: u,
|
|
@@ -2586,8 +2586,8 @@ function Uu(e = {}) {
|
|
|
2586
2586
|
return d(h);
|
|
2587
2587
|
};
|
|
2588
2588
|
return f.getAvailableModels = p, f.getCredits = m, f.imageModel = (h) => {
|
|
2589
|
-
throw new
|
|
2590
|
-
}, f.languageModel = d, f.textEmbeddingModel = (h) => new
|
|
2589
|
+
throw new oi({ modelId: h, modelType: "imageModel" });
|
|
2590
|
+
}, f.languageModel = d, f.textEmbeddingModel = (h) => new Pu(h, {
|
|
2591
2591
|
provider: "gateway",
|
|
2592
2592
|
baseURL: s,
|
|
2593
2593
|
headers: u,
|
|
@@ -2595,8 +2595,8 @@ function Uu(e = {}) {
|
|
|
2595
2595
|
o11yHeaders: l()
|
|
2596
2596
|
}), f;
|
|
2597
2597
|
}
|
|
2598
|
-
var
|
|
2599
|
-
async function
|
|
2598
|
+
var ju = Du();
|
|
2599
|
+
async function qu(e) {
|
|
2600
2600
|
const t = Ot({
|
|
2601
2601
|
settingValue: e.apiKey,
|
|
2602
2602
|
environmentVariableName: "AI_GATEWAY_API_KEY"
|
|
@@ -2608,27 +2608,27 @@ async function ju(e) {
|
|
|
2608
2608
|
};
|
|
2609
2609
|
try {
|
|
2610
2610
|
return {
|
|
2611
|
-
token: await
|
|
2611
|
+
token: await Ln.getVercelOidcToken(),
|
|
2612
2612
|
authMethod: "oidc"
|
|
2613
2613
|
};
|
|
2614
2614
|
} catch {
|
|
2615
2615
|
return null;
|
|
2616
2616
|
}
|
|
2617
2617
|
}
|
|
2618
|
-
var
|
|
2618
|
+
var Lu = Object.defineProperty, Vu = (e, t) => {
|
|
2619
2619
|
for (var r in t)
|
|
2620
|
-
|
|
2621
|
-
},
|
|
2620
|
+
Lu(e, r, { get: t[r], enumerable: !0 });
|
|
2621
|
+
}, Yn = "AI_NoOutputSpecifiedError", Xn = `vercel.ai.error.${Yn}`, Fu = Symbol.for(Xn), Qn, Bu = class extends J {
|
|
2622
2622
|
// used in isInstance
|
|
2623
2623
|
constructor({ message: e = "No output specified." } = {}) {
|
|
2624
|
-
super({ name:
|
|
2624
|
+
super({ name: Yn, message: e }), this[Qn] = !0;
|
|
2625
2625
|
}
|
|
2626
2626
|
static isInstance(e) {
|
|
2627
|
-
return J.hasMarker(e,
|
|
2627
|
+
return J.hasMarker(e, Xn);
|
|
2628
2628
|
}
|
|
2629
2629
|
};
|
|
2630
|
-
|
|
2631
|
-
function
|
|
2630
|
+
Qn = Fu;
|
|
2631
|
+
function Hu(e) {
|
|
2632
2632
|
const t = "AI SDK Warning:";
|
|
2633
2633
|
switch (e.type) {
|
|
2634
2634
|
case "unsupported-setting": {
|
|
@@ -2646,7 +2646,7 @@ function Bu(e) {
|
|
|
2646
2646
|
return `${t} ${JSON.stringify(e, null, 2)}`;
|
|
2647
2647
|
}
|
|
2648
2648
|
}
|
|
2649
|
-
var
|
|
2649
|
+
var Gu = "AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.", Qa = !1, Ju = (e) => {
|
|
2650
2650
|
if (e.length === 0)
|
|
2651
2651
|
return;
|
|
2652
2652
|
const t = globalThis.AI_SDK_LOG_WARNINGS;
|
|
@@ -2655,41 +2655,41 @@ var Hu = "AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG
|
|
|
2655
2655
|
t(e);
|
|
2656
2656
|
return;
|
|
2657
2657
|
}
|
|
2658
|
-
Qa || (Qa = !0, console.info(
|
|
2658
|
+
Qa || (Qa = !0, console.info(Gu));
|
|
2659
2659
|
for (const r of e)
|
|
2660
|
-
console.warn(
|
|
2660
|
+
console.warn(Hu(r));
|
|
2661
2661
|
}
|
|
2662
|
-
},
|
|
2662
|
+
}, eo = "AI_InvalidArgumentError", to = `vercel.ai.error.${eo}`, Zu = Symbol.for(to), ro, xe = class extends J {
|
|
2663
2663
|
constructor({
|
|
2664
2664
|
parameter: t,
|
|
2665
2665
|
value: r,
|
|
2666
2666
|
message: a
|
|
2667
2667
|
}) {
|
|
2668
2668
|
super({
|
|
2669
|
-
name:
|
|
2669
|
+
name: eo,
|
|
2670
2670
|
message: `Invalid argument for parameter ${t}: ${a}`
|
|
2671
|
-
}), this[
|
|
2671
|
+
}), this[ro] = !0, this.parameter = t, this.value = r;
|
|
2672
2672
|
}
|
|
2673
2673
|
static isInstance(t) {
|
|
2674
|
-
return J.hasMarker(t,
|
|
2674
|
+
return J.hasMarker(t, to);
|
|
2675
2675
|
}
|
|
2676
2676
|
};
|
|
2677
|
-
|
|
2678
|
-
var
|
|
2677
|
+
ro = Zu;
|
|
2678
|
+
var ao = "AI_InvalidToolInputError", no = `vercel.ai.error.${ao}`, zu = Symbol.for(no), oo, so = class extends J {
|
|
2679
2679
|
constructor({
|
|
2680
2680
|
toolInput: e,
|
|
2681
2681
|
toolName: t,
|
|
2682
2682
|
cause: r,
|
|
2683
2683
|
message: a = `Invalid input for tool ${t}: ${Yt(r)}`
|
|
2684
2684
|
}) {
|
|
2685
|
-
super({ name:
|
|
2685
|
+
super({ name: ao, message: a, cause: r }), this[oo] = !0, this.toolInput = e, this.toolName = t;
|
|
2686
2686
|
}
|
|
2687
2687
|
static isInstance(e) {
|
|
2688
|
-
return J.hasMarker(e,
|
|
2688
|
+
return J.hasMarker(e, no);
|
|
2689
2689
|
}
|
|
2690
2690
|
};
|
|
2691
|
-
|
|
2692
|
-
var
|
|
2691
|
+
oo = zu;
|
|
2692
|
+
var io = "AI_NoObjectGeneratedError", lo = `vercel.ai.error.${io}`, Wu = Symbol.for(lo), uo, en = class extends J {
|
|
2693
2693
|
constructor({
|
|
2694
2694
|
message: e = "No object generated.",
|
|
2695
2695
|
cause: t,
|
|
@@ -2698,84 +2698,84 @@ var so = "AI_NoObjectGeneratedError", io = `vercel.ai.error.${so}`, zu = Symbol.
|
|
|
2698
2698
|
usage: o,
|
|
2699
2699
|
finishReason: n
|
|
2700
2700
|
}) {
|
|
2701
|
-
super({ name:
|
|
2701
|
+
super({ name: io, message: e, cause: t }), this[uo] = !0, this.text = r, this.response = a, this.usage = o, this.finishReason = n;
|
|
2702
2702
|
}
|
|
2703
2703
|
static isInstance(e) {
|
|
2704
|
-
return J.hasMarker(e,
|
|
2704
|
+
return J.hasMarker(e, lo);
|
|
2705
2705
|
}
|
|
2706
2706
|
};
|
|
2707
|
-
|
|
2708
|
-
var
|
|
2707
|
+
uo = Wu;
|
|
2708
|
+
var co = "AI_NoOutputGeneratedError", po = `vercel.ai.error.${co}`, Ku = Symbol.for(po), fo, Yu = class extends J {
|
|
2709
2709
|
// used in isInstance
|
|
2710
2710
|
constructor({
|
|
2711
2711
|
message: e = "No output generated.",
|
|
2712
2712
|
cause: t
|
|
2713
2713
|
} = {}) {
|
|
2714
|
-
super({ name:
|
|
2714
|
+
super({ name: co, message: e, cause: t }), this[fo] = !0;
|
|
2715
2715
|
}
|
|
2716
2716
|
static isInstance(e) {
|
|
2717
|
-
return J.hasMarker(e,
|
|
2717
|
+
return J.hasMarker(e, po);
|
|
2718
2718
|
}
|
|
2719
2719
|
};
|
|
2720
|
-
|
|
2721
|
-
var
|
|
2720
|
+
fo = Ku;
|
|
2721
|
+
var ho = "AI_NoSuchToolError", mo = `vercel.ai.error.${ho}`, Xu = Symbol.for(mo), go, Dr = class extends J {
|
|
2722
2722
|
constructor({
|
|
2723
2723
|
toolName: e,
|
|
2724
2724
|
availableTools: t = void 0,
|
|
2725
2725
|
message: r = `Model tried to call unavailable tool '${e}'. ${t === void 0 ? "No tools are available." : `Available tools: ${t.join(", ")}.`}`
|
|
2726
2726
|
}) {
|
|
2727
|
-
super({ name:
|
|
2727
|
+
super({ name: ho, message: r }), this[go] = !0, this.toolName = e, this.availableTools = t;
|
|
2728
2728
|
}
|
|
2729
2729
|
static isInstance(e) {
|
|
2730
|
-
return J.hasMarker(e,
|
|
2730
|
+
return J.hasMarker(e, mo);
|
|
2731
2731
|
}
|
|
2732
2732
|
};
|
|
2733
|
-
|
|
2734
|
-
var
|
|
2733
|
+
go = Xu;
|
|
2734
|
+
var vo = "AI_ToolCallRepairError", yo = `vercel.ai.error.${vo}`, Qu = Symbol.for(yo), _o, ec = class extends J {
|
|
2735
2735
|
constructor({
|
|
2736
2736
|
cause: e,
|
|
2737
2737
|
originalError: t,
|
|
2738
2738
|
message: r = `Error repairing tool call: ${Yt(e)}`
|
|
2739
2739
|
}) {
|
|
2740
|
-
super({ name:
|
|
2740
|
+
super({ name: vo, message: r, cause: e }), this[_o] = !0, this.originalError = t;
|
|
2741
2741
|
}
|
|
2742
2742
|
static isInstance(e) {
|
|
2743
|
-
return J.hasMarker(e,
|
|
2743
|
+
return J.hasMarker(e, yo);
|
|
2744
2744
|
}
|
|
2745
2745
|
};
|
|
2746
|
-
|
|
2747
|
-
var
|
|
2746
|
+
_o = Qu;
|
|
2747
|
+
var tc = class extends J {
|
|
2748
2748
|
constructor(e) {
|
|
2749
2749
|
super({
|
|
2750
2750
|
name: "AI_UnsupportedModelVersionError",
|
|
2751
2751
|
message: `Unsupported model version ${e.version} for provider "${e.provider}" and model "${e.modelId}". AI SDK 5 only supports models that implement specification version "v2".`
|
|
2752
2752
|
}), this.version = e.version, this.provider = e.provider, this.modelId = e.modelId;
|
|
2753
2753
|
}
|
|
2754
|
-
},
|
|
2754
|
+
}, wo = "AI_InvalidMessageRoleError", bo = `vercel.ai.error.${wo}`, rc = Symbol.for(bo), To, ac = class extends J {
|
|
2755
2755
|
constructor({
|
|
2756
2756
|
role: e,
|
|
2757
2757
|
message: t = `Invalid message role: '${e}'. Must be one of: "system", "user", "assistant", "tool".`
|
|
2758
2758
|
}) {
|
|
2759
|
-
super({ name:
|
|
2759
|
+
super({ name: wo, message: t }), this[To] = !0, this.role = e;
|
|
2760
2760
|
}
|
|
2761
2761
|
static isInstance(e) {
|
|
2762
|
-
return J.hasMarker(e,
|
|
2762
|
+
return J.hasMarker(e, bo);
|
|
2763
2763
|
}
|
|
2764
2764
|
};
|
|
2765
|
-
|
|
2766
|
-
var
|
|
2765
|
+
To = rc;
|
|
2766
|
+
var Io = "AI_MessageConversionError", So = `vercel.ai.error.${Io}`, nc = Symbol.for(So), Eo, oc = class extends J {
|
|
2767
2767
|
constructor({
|
|
2768
2768
|
originalMessage: e,
|
|
2769
2769
|
message: t
|
|
2770
2770
|
}) {
|
|
2771
|
-
super({ name:
|
|
2771
|
+
super({ name: Io, message: t }), this[Eo] = !0, this.originalMessage = e;
|
|
2772
2772
|
}
|
|
2773
2773
|
static isInstance(e) {
|
|
2774
|
-
return J.hasMarker(e,
|
|
2774
|
+
return J.hasMarker(e, So);
|
|
2775
2775
|
}
|
|
2776
2776
|
};
|
|
2777
|
-
|
|
2778
|
-
var
|
|
2777
|
+
Eo = nc;
|
|
2778
|
+
var xo = "AI_DownloadError", Ro = `vercel.ai.error.${xo}`, sc = Symbol.for(Ro), Co, Tr = class extends J {
|
|
2779
2779
|
constructor({
|
|
2780
2780
|
url: e,
|
|
2781
2781
|
statusCode: t,
|
|
@@ -2783,43 +2783,43 @@ var Eo = "AI_DownloadError", xo = `vercel.ai.error.${Eo}`, oc = Symbol.for(xo),
|
|
|
2783
2783
|
cause: a,
|
|
2784
2784
|
message: o = a == null ? `Failed to download ${e}: ${t} ${r}` : `Failed to download ${e}: ${a}`
|
|
2785
2785
|
}) {
|
|
2786
|
-
super({ name:
|
|
2786
|
+
super({ name: xo, message: o, cause: a }), this[Co] = !0, this.url = e, this.statusCode = t, this.statusText = r;
|
|
2787
2787
|
}
|
|
2788
2788
|
static isInstance(e) {
|
|
2789
|
-
return J.hasMarker(e,
|
|
2789
|
+
return J.hasMarker(e, Ro);
|
|
2790
2790
|
}
|
|
2791
2791
|
};
|
|
2792
|
-
|
|
2793
|
-
var
|
|
2792
|
+
Co = sc;
|
|
2793
|
+
var Ao = "AI_RetryError", ko = `vercel.ai.error.${Ao}`, ic = Symbol.for(ko), Oo, tn = class extends J {
|
|
2794
2794
|
constructor({
|
|
2795
2795
|
message: e,
|
|
2796
2796
|
reason: t,
|
|
2797
2797
|
errors: r
|
|
2798
2798
|
}) {
|
|
2799
|
-
super({ name:
|
|
2799
|
+
super({ name: Ao, message: e }), this[Oo] = !0, this.reason = t, this.errors = r, this.lastError = r[r.length - 1];
|
|
2800
2800
|
}
|
|
2801
2801
|
static isInstance(e) {
|
|
2802
|
-
return J.hasMarker(e,
|
|
2802
|
+
return J.hasMarker(e, ko);
|
|
2803
2803
|
}
|
|
2804
2804
|
};
|
|
2805
|
-
|
|
2806
|
-
function
|
|
2805
|
+
Oo = ic;
|
|
2806
|
+
function Po(e) {
|
|
2807
2807
|
if (typeof e != "string") {
|
|
2808
2808
|
if (e.specificationVersion !== "v2")
|
|
2809
|
-
throw new
|
|
2809
|
+
throw new tc({
|
|
2810
2810
|
version: e.specificationVersion,
|
|
2811
2811
|
provider: e.provider,
|
|
2812
2812
|
modelId: e.modelId
|
|
2813
2813
|
});
|
|
2814
2814
|
return e;
|
|
2815
2815
|
}
|
|
2816
|
-
return
|
|
2816
|
+
return lc().languageModel(e);
|
|
2817
2817
|
}
|
|
2818
|
-
function
|
|
2818
|
+
function lc() {
|
|
2819
2819
|
var e;
|
|
2820
|
-
return (e = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? e :
|
|
2820
|
+
return (e = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? e : ju;
|
|
2821
2821
|
}
|
|
2822
|
-
var
|
|
2822
|
+
var uc = [
|
|
2823
2823
|
{
|
|
2824
2824
|
mediaType: "image/gif",
|
|
2825
2825
|
bytesPrefix: [71, 73, 70]
|
|
@@ -2901,20 +2901,20 @@ var lc = [
|
|
|
2901
2901
|
99
|
|
2902
2902
|
]
|
|
2903
2903
|
}
|
|
2904
|
-
],
|
|
2904
|
+
], cc = (e) => {
|
|
2905
2905
|
const t = typeof e == "string" ? Xr(e) : e, r = (t[6] & 127) << 21 | (t[7] & 127) << 14 | (t[8] & 127) << 7 | t[9] & 127;
|
|
2906
2906
|
return t.slice(r + 10);
|
|
2907
2907
|
};
|
|
2908
|
-
function
|
|
2908
|
+
function dc(e) {
|
|
2909
2909
|
return typeof e == "string" && e.startsWith("SUQz") || typeof e != "string" && e.length > 10 && e[0] === 73 && // 'I'
|
|
2910
2910
|
e[1] === 68 && // 'D'
|
|
2911
|
-
e[2] === 51 ?
|
|
2911
|
+
e[2] === 51 ? cc(e) : e;
|
|
2912
2912
|
}
|
|
2913
|
-
function
|
|
2913
|
+
function pc({
|
|
2914
2914
|
data: e,
|
|
2915
2915
|
signatures: t
|
|
2916
2916
|
}) {
|
|
2917
|
-
const r =
|
|
2917
|
+
const r = dc(e), a = typeof r == "string" ? Xr(
|
|
2918
2918
|
r.substring(0, Math.min(r.length, 24))
|
|
2919
2919
|
) : r;
|
|
2920
2920
|
for (const o of t)
|
|
@@ -2923,14 +2923,14 @@ function dc({
|
|
|
2923
2923
|
))
|
|
2924
2924
|
return o.mediaType;
|
|
2925
2925
|
}
|
|
2926
|
-
var
|
|
2926
|
+
var fc = "5.0.90", hc = async ({ url: e }) => {
|
|
2927
2927
|
var t;
|
|
2928
2928
|
const r = e.toString();
|
|
2929
2929
|
try {
|
|
2930
2930
|
const a = await fetch(r, {
|
|
2931
2931
|
headers: Xt(
|
|
2932
2932
|
{},
|
|
2933
|
-
`ai-sdk/${
|
|
2933
|
+
`ai-sdk/${fc}`,
|
|
2934
2934
|
Kr()
|
|
2935
2935
|
)
|
|
2936
2936
|
});
|
|
@@ -2947,12 +2947,12 @@ var pc = "5.0.90", fc = async ({ url: e }) => {
|
|
|
2947
2947
|
} catch (a) {
|
|
2948
2948
|
throw Tr.isInstance(a) ? a : new Tr({ url: r, cause: a });
|
|
2949
2949
|
}
|
|
2950
|
-
},
|
|
2950
|
+
}, mc = (e = hc) => (t) => Promise.all(
|
|
2951
2951
|
t.map(
|
|
2952
2952
|
async (r) => r.isUrlSupportedByModel ? null : e(r)
|
|
2953
2953
|
)
|
|
2954
2954
|
);
|
|
2955
|
-
function
|
|
2955
|
+
function gc(e) {
|
|
2956
2956
|
try {
|
|
2957
2957
|
const [t, r] = e.split(",");
|
|
2958
2958
|
return {
|
|
@@ -2966,11 +2966,11 @@ function mc(e) {
|
|
|
2966
2966
|
};
|
|
2967
2967
|
}
|
|
2968
2968
|
}
|
|
2969
|
-
var
|
|
2969
|
+
var Mo = D([
|
|
2970
2970
|
c(),
|
|
2971
2971
|
$t(Uint8Array),
|
|
2972
2972
|
$t(ArrayBuffer),
|
|
2973
|
-
|
|
2973
|
+
si(
|
|
2974
2974
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
2975
2975
|
(e) => {
|
|
2976
2976
|
var t, r;
|
|
@@ -2979,7 +2979,7 @@ var Po = D([
|
|
|
2979
2979
|
{ message: "Must be a Buffer" }
|
|
2980
2980
|
)
|
|
2981
2981
|
]);
|
|
2982
|
-
function
|
|
2982
|
+
function No(e) {
|
|
2983
2983
|
if (e instanceof Uint8Array)
|
|
2984
2984
|
return { data: e, mediaType: void 0 };
|
|
2985
2985
|
if (e instanceof ArrayBuffer)
|
|
@@ -2990,7 +2990,7 @@ function Mo(e) {
|
|
|
2990
2990
|
} catch {
|
|
2991
2991
|
}
|
|
2992
2992
|
if (e instanceof URL && e.protocol === "data:") {
|
|
2993
|
-
const { mediaType: t, base64Content: r } =
|
|
2993
|
+
const { mediaType: t, base64Content: r } = gc(
|
|
2994
2994
|
e.toString()
|
|
2995
2995
|
);
|
|
2996
2996
|
if (t == null || r == null)
|
|
@@ -3002,15 +3002,15 @@ function Mo(e) {
|
|
|
3002
3002
|
}
|
|
3003
3003
|
return { data: e, mediaType: void 0 };
|
|
3004
3004
|
}
|
|
3005
|
-
function
|
|
3005
|
+
function vc(e) {
|
|
3006
3006
|
return typeof e == "string" ? e : e instanceof ArrayBuffer ? Ur(new Uint8Array(e)) : Ur(e);
|
|
3007
3007
|
}
|
|
3008
|
-
async function
|
|
3008
|
+
async function yc({
|
|
3009
3009
|
prompt: e,
|
|
3010
3010
|
supportedUrls: t,
|
|
3011
|
-
download: r =
|
|
3011
|
+
download: r = mc()
|
|
3012
3012
|
}) {
|
|
3013
|
-
const a = await
|
|
3013
|
+
const a = await wc(
|
|
3014
3014
|
e.messages,
|
|
3015
3015
|
r,
|
|
3016
3016
|
t
|
|
@@ -3018,11 +3018,11 @@ async function vc({
|
|
|
3018
3018
|
return [
|
|
3019
3019
|
...e.system != null ? [{ role: "system", content: e.system }] : [],
|
|
3020
3020
|
...e.messages.map(
|
|
3021
|
-
(o) =>
|
|
3021
|
+
(o) => _c({ message: o, downloadedAssets: a })
|
|
3022
3022
|
)
|
|
3023
3023
|
];
|
|
3024
3024
|
}
|
|
3025
|
-
function
|
|
3025
|
+
function _c({
|
|
3026
3026
|
message: e,
|
|
3027
3027
|
downloadedAssets: t
|
|
3028
3028
|
}) {
|
|
@@ -3041,7 +3041,7 @@ function yc({
|
|
|
3041
3041
|
providerOptions: e.providerOptions
|
|
3042
3042
|
} : {
|
|
3043
3043
|
role: "user",
|
|
3044
|
-
content: e.content.map((a) =>
|
|
3044
|
+
content: e.content.map((a) => bc(a, t)).filter((a) => a.type !== "text" || a.text !== ""),
|
|
3045
3045
|
providerOptions: e.providerOptions
|
|
3046
3046
|
};
|
|
3047
3047
|
case "assistant":
|
|
@@ -3058,7 +3058,7 @@ function yc({
|
|
|
3058
3058
|
const o = a.providerOptions;
|
|
3059
3059
|
switch (a.type) {
|
|
3060
3060
|
case "file": {
|
|
3061
|
-
const { data: n, mediaType: i } =
|
|
3061
|
+
const { data: n, mediaType: i } = No(
|
|
3062
3062
|
a.data
|
|
3063
3063
|
);
|
|
3064
3064
|
return {
|
|
@@ -3116,11 +3116,11 @@ function yc({
|
|
|
3116
3116
|
};
|
|
3117
3117
|
default: {
|
|
3118
3118
|
const a = r;
|
|
3119
|
-
throw new
|
|
3119
|
+
throw new ac({ role: a });
|
|
3120
3120
|
}
|
|
3121
3121
|
}
|
|
3122
3122
|
}
|
|
3123
|
-
async function
|
|
3123
|
+
async function wc(e, t, r) {
|
|
3124
3124
|
const a = e.filter((n) => n.role === "user").map((n) => n.content).filter(
|
|
3125
3125
|
(n) => Array.isArray(n)
|
|
3126
3126
|
).flat().filter(
|
|
@@ -3139,7 +3139,7 @@ async function _c(e, t, r) {
|
|
|
3139
3139
|
(n) => n.data instanceof URL
|
|
3140
3140
|
).map((n) => ({
|
|
3141
3141
|
url: n.data,
|
|
3142
|
-
isUrlSupportedByModel: n.mediaType != null &&
|
|
3142
|
+
isUrlSupportedByModel: n.mediaType != null && al({
|
|
3143
3143
|
url: n.data.toString(),
|
|
3144
3144
|
mediaType: n.mediaType,
|
|
3145
3145
|
supportedUrls: r
|
|
@@ -3154,7 +3154,7 @@ async function _c(e, t, r) {
|
|
|
3154
3154
|
).filter((n) => n != null)
|
|
3155
3155
|
);
|
|
3156
3156
|
}
|
|
3157
|
-
function
|
|
3157
|
+
function bc(e, t) {
|
|
3158
3158
|
var r;
|
|
3159
3159
|
if (e.type === "text")
|
|
3160
3160
|
return {
|
|
@@ -3174,7 +3174,7 @@ function wc(e, t) {
|
|
|
3174
3174
|
default:
|
|
3175
3175
|
throw new Error(`Unsupported part type: ${o}`);
|
|
3176
3176
|
}
|
|
3177
|
-
const { data: n, mediaType: i } =
|
|
3177
|
+
const { data: n, mediaType: i } = No(a);
|
|
3178
3178
|
let s = i ?? e.mediaType, u = n;
|
|
3179
3179
|
if (u instanceof URL) {
|
|
3180
3180
|
const l = t[u.toString()];
|
|
@@ -3182,7 +3182,7 @@ function wc(e, t) {
|
|
|
3182
3182
|
}
|
|
3183
3183
|
switch (o) {
|
|
3184
3184
|
case "image":
|
|
3185
|
-
return (u instanceof Uint8Array || typeof u == "string") && (s = (r =
|
|
3185
|
+
return (u instanceof Uint8Array || typeof u == "string") && (s = (r = pc({ data: u, signatures: uc })) != null ? r : s), {
|
|
3186
3186
|
type: "file",
|
|
3187
3187
|
mediaType: s ?? "image/*",
|
|
3188
3188
|
// any image
|
|
@@ -3203,7 +3203,7 @@ function wc(e, t) {
|
|
|
3203
3203
|
}
|
|
3204
3204
|
}
|
|
3205
3205
|
}
|
|
3206
|
-
function
|
|
3206
|
+
function Tc({
|
|
3207
3207
|
maxOutputTokens: e,
|
|
3208
3208
|
temperature: t,
|
|
3209
3209
|
topP: r,
|
|
@@ -3274,15 +3274,15 @@ function bc({
|
|
|
3274
3274
|
seed: i
|
|
3275
3275
|
};
|
|
3276
3276
|
}
|
|
3277
|
-
function
|
|
3277
|
+
function Ic(e) {
|
|
3278
3278
|
return e != null && Object.keys(e).length > 0;
|
|
3279
3279
|
}
|
|
3280
|
-
function
|
|
3280
|
+
function Sc({
|
|
3281
3281
|
tools: e,
|
|
3282
3282
|
toolChoice: t,
|
|
3283
3283
|
activeTools: r
|
|
3284
3284
|
}) {
|
|
3285
|
-
return
|
|
3285
|
+
return Ic(e) ? {
|
|
3286
3286
|
tools: (r != null ? Object.entries(e).filter(
|
|
3287
3287
|
([o]) => r.includes(o)
|
|
3288
3288
|
) : Object.entries(e)).map(([o, n]) => {
|
|
@@ -3317,9 +3317,9 @@ function Ic({
|
|
|
3317
3317
|
toolChoice: void 0
|
|
3318
3318
|
};
|
|
3319
3319
|
}
|
|
3320
|
-
var vt =
|
|
3320
|
+
var vt = ii(
|
|
3321
3321
|
() => D([
|
|
3322
|
-
|
|
3322
|
+
li(),
|
|
3323
3323
|
c(),
|
|
3324
3324
|
R(),
|
|
3325
3325
|
_e(),
|
|
@@ -3329,33 +3329,33 @@ var vt = si(
|
|
|
3329
3329
|
), Ce = De(
|
|
3330
3330
|
c(),
|
|
3331
3331
|
De(c(), vt)
|
|
3332
|
-
),
|
|
3332
|
+
), $o = v({
|
|
3333
3333
|
type: C("text"),
|
|
3334
3334
|
text: c(),
|
|
3335
3335
|
providerOptions: Ce.optional()
|
|
3336
|
-
}),
|
|
3336
|
+
}), Ec = v({
|
|
3337
3337
|
type: C("image"),
|
|
3338
|
-
image: D([
|
|
3338
|
+
image: D([Mo, $t(URL)]),
|
|
3339
3339
|
mediaType: c().optional(),
|
|
3340
3340
|
providerOptions: Ce.optional()
|
|
3341
|
-
}),
|
|
3341
|
+
}), Uo = v({
|
|
3342
3342
|
type: C("file"),
|
|
3343
|
-
data: D([
|
|
3343
|
+
data: D([Mo, $t(URL)]),
|
|
3344
3344
|
filename: c().optional(),
|
|
3345
3345
|
mediaType: c(),
|
|
3346
3346
|
providerOptions: Ce.optional()
|
|
3347
|
-
}),
|
|
3347
|
+
}), xc = v({
|
|
3348
3348
|
type: C("reasoning"),
|
|
3349
3349
|
text: c(),
|
|
3350
3350
|
providerOptions: Ce.optional()
|
|
3351
|
-
}),
|
|
3351
|
+
}), Rc = v({
|
|
3352
3352
|
type: C("tool-call"),
|
|
3353
3353
|
toolCallId: c(),
|
|
3354
3354
|
toolName: c(),
|
|
3355
3355
|
input: Re(),
|
|
3356
3356
|
providerOptions: Ce.optional(),
|
|
3357
3357
|
providerExecuted: _e().optional()
|
|
3358
|
-
}),
|
|
3358
|
+
}), Cc = ui("type", [
|
|
3359
3359
|
v({
|
|
3360
3360
|
type: C("text"),
|
|
3361
3361
|
value: c()
|
|
@@ -3388,51 +3388,51 @@ var vt = si(
|
|
|
3388
3388
|
])
|
|
3389
3389
|
)
|
|
3390
3390
|
})
|
|
3391
|
-
]),
|
|
3391
|
+
]), Do = v({
|
|
3392
3392
|
type: C("tool-result"),
|
|
3393
3393
|
toolCallId: c(),
|
|
3394
3394
|
toolName: c(),
|
|
3395
|
-
output:
|
|
3395
|
+
output: Cc,
|
|
3396
3396
|
providerOptions: Ce.optional()
|
|
3397
|
-
}),
|
|
3397
|
+
}), Ac = v(
|
|
3398
3398
|
{
|
|
3399
3399
|
role: C("system"),
|
|
3400
3400
|
content: c(),
|
|
3401
3401
|
providerOptions: Ce.optional()
|
|
3402
3402
|
}
|
|
3403
|
-
),
|
|
3403
|
+
), kc = v({
|
|
3404
3404
|
role: C("user"),
|
|
3405
3405
|
content: D([
|
|
3406
3406
|
c(),
|
|
3407
|
-
I(D([
|
|
3407
|
+
I(D([$o, Ec, Uo]))
|
|
3408
3408
|
]),
|
|
3409
3409
|
providerOptions: Ce.optional()
|
|
3410
|
-
}),
|
|
3410
|
+
}), Oc = v({
|
|
3411
3411
|
role: C("assistant"),
|
|
3412
3412
|
content: D([
|
|
3413
3413
|
c(),
|
|
3414
3414
|
I(
|
|
3415
3415
|
D([
|
|
3416
|
-
No,
|
|
3417
3416
|
$o,
|
|
3418
|
-
|
|
3417
|
+
Uo,
|
|
3419
3418
|
xc,
|
|
3420
|
-
|
|
3419
|
+
Rc,
|
|
3420
|
+
Do
|
|
3421
3421
|
])
|
|
3422
3422
|
)
|
|
3423
3423
|
]),
|
|
3424
3424
|
providerOptions: Ce.optional()
|
|
3425
|
-
}),
|
|
3425
|
+
}), Pc = v({
|
|
3426
3426
|
role: C("tool"),
|
|
3427
|
-
content: I(
|
|
3427
|
+
content: I(Do),
|
|
3428
3428
|
providerOptions: Ce.optional()
|
|
3429
|
-
}),
|
|
3430
|
-
Cc,
|
|
3429
|
+
}), Mc = D([
|
|
3431
3430
|
Ac,
|
|
3432
3431
|
kc,
|
|
3433
|
-
Oc
|
|
3432
|
+
Oc,
|
|
3433
|
+
Pc
|
|
3434
3434
|
]);
|
|
3435
|
-
async function
|
|
3435
|
+
async function Nc(e) {
|
|
3436
3436
|
if (e.prompt == null && e.messages == null)
|
|
3437
3437
|
throw new Ze({
|
|
3438
3438
|
prompt: e,
|
|
@@ -3467,7 +3467,7 @@ async function Mc(e) {
|
|
|
3467
3467
|
});
|
|
3468
3468
|
const r = await je({
|
|
3469
3469
|
value: t,
|
|
3470
|
-
schema: I(
|
|
3470
|
+
schema: I(Mc)
|
|
3471
3471
|
});
|
|
3472
3472
|
if (!r.success)
|
|
3473
3473
|
throw new Ze({
|
|
@@ -3480,8 +3480,8 @@ async function Mc(e) {
|
|
|
3480
3480
|
system: e.system
|
|
3481
3481
|
};
|
|
3482
3482
|
}
|
|
3483
|
-
function
|
|
3484
|
-
return Qr.isInstance(e) ||
|
|
3483
|
+
function $c(e) {
|
|
3484
|
+
return Qr.isInstance(e) || Zn.isInstance(e) ? new J({
|
|
3485
3485
|
name: "GatewayError",
|
|
3486
3486
|
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.",
|
|
3487
3487
|
cause: e
|
|
@@ -3500,7 +3500,7 @@ function jr({
|
|
|
3500
3500
|
"ai.telemetry.functionId": t?.functionId
|
|
3501
3501
|
};
|
|
3502
3502
|
}
|
|
3503
|
-
function
|
|
3503
|
+
function Uc({
|
|
3504
3504
|
model: e,
|
|
3505
3505
|
settings: t,
|
|
3506
3506
|
telemetry: r,
|
|
@@ -3521,7 +3521,7 @@ function $c({
|
|
|
3521
3521
|
...Object.entries(a ?? {}).reduce((n, [i, s]) => (s !== void 0 && (n[`ai.request.headers.${i}`] = s), n), {})
|
|
3522
3522
|
};
|
|
3523
3523
|
}
|
|
3524
|
-
var
|
|
3524
|
+
var Dc = {
|
|
3525
3525
|
startSpan() {
|
|
3526
3526
|
return Rt;
|
|
3527
3527
|
},
|
|
@@ -3535,7 +3535,7 @@ var Uc = {
|
|
|
3535
3535
|
}
|
|
3536
3536
|
}, Rt = {
|
|
3537
3537
|
spanContext() {
|
|
3538
|
-
return
|
|
3538
|
+
return jc;
|
|
3539
3539
|
},
|
|
3540
3540
|
setAttribute() {
|
|
3541
3541
|
return this;
|
|
@@ -3567,16 +3567,16 @@ var Uc = {
|
|
|
3567
3567
|
recordException() {
|
|
3568
3568
|
return this;
|
|
3569
3569
|
}
|
|
3570
|
-
},
|
|
3570
|
+
}, jc = {
|
|
3571
3571
|
traceId: "",
|
|
3572
3572
|
spanId: "",
|
|
3573
3573
|
traceFlags: 0
|
|
3574
3574
|
};
|
|
3575
|
-
function
|
|
3575
|
+
function qc({
|
|
3576
3576
|
isEnabled: e = !1,
|
|
3577
3577
|
tracer: t
|
|
3578
3578
|
} = {}) {
|
|
3579
|
-
return e ? t ||
|
|
3579
|
+
return e ? t || Yi.getTracer("ai") : Dc;
|
|
3580
3580
|
}
|
|
3581
3581
|
function qr({
|
|
3582
3582
|
name: e,
|
|
@@ -3591,7 +3591,7 @@ function qr({
|
|
|
3591
3591
|
return o && n.end(), i;
|
|
3592
3592
|
} catch (i) {
|
|
3593
3593
|
try {
|
|
3594
|
-
|
|
3594
|
+
jo(n, i);
|
|
3595
3595
|
} finally {
|
|
3596
3596
|
n.end();
|
|
3597
3597
|
}
|
|
@@ -3599,7 +3599,7 @@ function qr({
|
|
|
3599
3599
|
}
|
|
3600
3600
|
});
|
|
3601
3601
|
}
|
|
3602
|
-
function
|
|
3602
|
+
function jo(e, t) {
|
|
3603
3603
|
t instanceof Error ? (e.recordException({
|
|
3604
3604
|
name: t.name,
|
|
3605
3605
|
message: t.message,
|
|
@@ -3631,20 +3631,20 @@ function We({
|
|
|
3631
3631
|
return { ...r, [a]: o };
|
|
3632
3632
|
}, {});
|
|
3633
3633
|
}
|
|
3634
|
-
function
|
|
3634
|
+
function Lc(e) {
|
|
3635
3635
|
return JSON.stringify(
|
|
3636
3636
|
e.map((t) => ({
|
|
3637
3637
|
...t,
|
|
3638
3638
|
content: typeof t.content == "string" ? t.content : t.content.map(
|
|
3639
3639
|
(r) => r.type === "file" ? {
|
|
3640
3640
|
...r,
|
|
3641
|
-
data: r.data instanceof Uint8Array ?
|
|
3641
|
+
data: r.data instanceof Uint8Array ? vc(r.data) : r.data
|
|
3642
3642
|
} : r
|
|
3643
3643
|
)
|
|
3644
3644
|
}))
|
|
3645
3645
|
);
|
|
3646
3646
|
}
|
|
3647
|
-
function
|
|
3647
|
+
function Vc(e, t) {
|
|
3648
3648
|
return {
|
|
3649
3649
|
inputTokens: st(e.inputTokens, t.inputTokens),
|
|
3650
3650
|
outputTokens: st(e.outputTokens, t.outputTokens),
|
|
@@ -3665,7 +3665,7 @@ function st(e, t) {
|
|
|
3665
3665
|
function rn(e) {
|
|
3666
3666
|
return e === void 0 ? [] : Array.isArray(e) ? e : [e];
|
|
3667
3667
|
}
|
|
3668
|
-
function
|
|
3668
|
+
function Fc({
|
|
3669
3669
|
error: e,
|
|
3670
3670
|
exponentialBackoffDelay: t
|
|
3671
3671
|
}) {
|
|
@@ -3685,18 +3685,18 @@ function Vc({
|
|
|
3685
3685
|
}
|
|
3686
3686
|
return a != null && !Number.isNaN(a) && 0 <= a && (a < 60 * 1e3 || a < t) ? a : t;
|
|
3687
3687
|
}
|
|
3688
|
-
var
|
|
3688
|
+
var Bc = ({
|
|
3689
3689
|
maxRetries: e = 2,
|
|
3690
3690
|
initialDelayInMs: t = 2e3,
|
|
3691
3691
|
backoffFactor: r = 2,
|
|
3692
3692
|
abortSignal: a
|
|
3693
|
-
} = {}) => async (o) =>
|
|
3693
|
+
} = {}) => async (o) => qo(o, {
|
|
3694
3694
|
maxRetries: e,
|
|
3695
3695
|
delayInMs: t,
|
|
3696
3696
|
backoffFactor: r,
|
|
3697
3697
|
abortSignal: a
|
|
3698
3698
|
});
|
|
3699
|
-
async function
|
|
3699
|
+
async function qo(e, {
|
|
3700
3700
|
maxRetries: t,
|
|
3701
3701
|
delayInMs: r,
|
|
3702
3702
|
backoffFactor: a,
|
|
@@ -3707,7 +3707,7 @@ async function jo(e, {
|
|
|
3707
3707
|
} catch (i) {
|
|
3708
3708
|
if (Le(i) || t === 0)
|
|
3709
3709
|
throw i;
|
|
3710
|
-
const s =
|
|
3710
|
+
const s = Pn(i), u = [...n, i], l = u.length;
|
|
3711
3711
|
if (l > t)
|
|
3712
3712
|
throw new tn({
|
|
3713
3713
|
message: `Failed after ${l} attempts. Last error: ${s}`,
|
|
@@ -3715,13 +3715,13 @@ async function jo(e, {
|
|
|
3715
3715
|
errors: u
|
|
3716
3716
|
});
|
|
3717
3717
|
if (i instanceof Error && se.isInstance(i) && i.isRetryable === !0 && l <= t)
|
|
3718
|
-
return await
|
|
3719
|
-
|
|
3718
|
+
return await Xi(
|
|
3719
|
+
Fc({
|
|
3720
3720
|
error: i,
|
|
3721
3721
|
exponentialBackoffDelay: r
|
|
3722
3722
|
}),
|
|
3723
3723
|
{ abortSignal: o }
|
|
3724
|
-
),
|
|
3724
|
+
), qo(
|
|
3725
3725
|
e,
|
|
3726
3726
|
{
|
|
3727
3727
|
maxRetries: t,
|
|
@@ -3738,7 +3738,7 @@ async function jo(e, {
|
|
|
3738
3738
|
});
|
|
3739
3739
|
}
|
|
3740
3740
|
}
|
|
3741
|
-
function
|
|
3741
|
+
function Hc({
|
|
3742
3742
|
maxRetries: e,
|
|
3743
3743
|
abortSignal: t
|
|
3744
3744
|
}) {
|
|
@@ -3759,13 +3759,13 @@ function Bc({
|
|
|
3759
3759
|
const r = e ?? 2;
|
|
3760
3760
|
return {
|
|
3761
3761
|
maxRetries: r,
|
|
3762
|
-
retry:
|
|
3762
|
+
retry: Bc({
|
|
3763
3763
|
maxRetries: r,
|
|
3764
3764
|
abortSignal: t
|
|
3765
3765
|
})
|
|
3766
3766
|
};
|
|
3767
3767
|
}
|
|
3768
|
-
var
|
|
3768
|
+
var Gc = class {
|
|
3769
3769
|
constructor({
|
|
3770
3770
|
data: e,
|
|
3771
3771
|
mediaType: t
|
|
@@ -3781,12 +3781,12 @@ var Hc = class {
|
|
|
3781
3781
|
get uint8Array() {
|
|
3782
3782
|
return this.uint8ArrayData == null && (this.uint8ArrayData = Xr(this.base64Data)), this.uint8ArrayData;
|
|
3783
3783
|
}
|
|
3784
|
-
},
|
|
3784
|
+
}, Jc = class extends Gc {
|
|
3785
3785
|
constructor(e) {
|
|
3786
3786
|
super(e), this.type = "file";
|
|
3787
3787
|
}
|
|
3788
3788
|
};
|
|
3789
|
-
async function
|
|
3789
|
+
async function Zc({
|
|
3790
3790
|
toolCall: e,
|
|
3791
3791
|
tools: t,
|
|
3792
3792
|
repairToolCall: r,
|
|
@@ -3799,7 +3799,7 @@ async function Jc({
|
|
|
3799
3799
|
try {
|
|
3800
3800
|
return await an({ toolCall: e, tools: t });
|
|
3801
3801
|
} catch (n) {
|
|
3802
|
-
if (r == null || !(Dr.isInstance(n) ||
|
|
3802
|
+
if (r == null || !(Dr.isInstance(n) || so.isInstance(n)))
|
|
3803
3803
|
throw n;
|
|
3804
3804
|
let i = null;
|
|
3805
3805
|
try {
|
|
@@ -3815,7 +3815,7 @@ async function Jc({
|
|
|
3815
3815
|
error: n
|
|
3816
3816
|
});
|
|
3817
3817
|
} catch (s) {
|
|
3818
|
-
throw new
|
|
3818
|
+
throw new ec({
|
|
3819
3819
|
cause: s,
|
|
3820
3820
|
originalError: n
|
|
3821
3821
|
});
|
|
@@ -3849,7 +3849,7 @@ async function an({
|
|
|
3849
3849
|
});
|
|
3850
3850
|
const o = Qt(a.inputSchema), n = e.input.trim() === "" ? await je({ value: {}, schema: o }) : await Ve({ text: e.input, schema: o });
|
|
3851
3851
|
if (n.success === !1)
|
|
3852
|
-
throw new
|
|
3852
|
+
throw new so({
|
|
3853
3853
|
toolName: r,
|
|
3854
3854
|
toolInput: e.input,
|
|
3855
3855
|
cause: n.error
|
|
@@ -3871,7 +3871,7 @@ async function an({
|
|
|
3871
3871
|
providerMetadata: e.providerMetadata
|
|
3872
3872
|
};
|
|
3873
3873
|
}
|
|
3874
|
-
var
|
|
3874
|
+
var zc = class {
|
|
3875
3875
|
constructor({
|
|
3876
3876
|
content: e,
|
|
3877
3877
|
finishReason: t,
|
|
@@ -3925,10 +3925,10 @@ var Zc = class {
|
|
|
3925
3925
|
);
|
|
3926
3926
|
}
|
|
3927
3927
|
};
|
|
3928
|
-
function
|
|
3928
|
+
function Wc(e) {
|
|
3929
3929
|
return ({ steps: t }) => t.length === e;
|
|
3930
3930
|
}
|
|
3931
|
-
async function
|
|
3931
|
+
async function Kc({
|
|
3932
3932
|
stopConditions: e,
|
|
3933
3933
|
steps: t
|
|
3934
3934
|
}) {
|
|
@@ -4036,7 +4036,7 @@ function er(e, t) {
|
|
|
4036
4036
|
r.has(a) || r.set(a, o);
|
|
4037
4037
|
return r;
|
|
4038
4038
|
}
|
|
4039
|
-
function
|
|
4039
|
+
function Yc({
|
|
4040
4040
|
status: e,
|
|
4041
4041
|
statusText: t,
|
|
4042
4042
|
headers: r,
|
|
@@ -4050,7 +4050,7 @@ function Kc({
|
|
|
4050
4050
|
})
|
|
4051
4051
|
});
|
|
4052
4052
|
}
|
|
4053
|
-
function
|
|
4053
|
+
function Lo({
|
|
4054
4054
|
response: e,
|
|
4055
4055
|
status: t,
|
|
4056
4056
|
statusText: r,
|
|
@@ -4076,14 +4076,14 @@ function qo({
|
|
|
4076
4076
|
}
|
|
4077
4077
|
})();
|
|
4078
4078
|
}
|
|
4079
|
-
function
|
|
4079
|
+
function Xc({
|
|
4080
4080
|
response: e,
|
|
4081
4081
|
status: t,
|
|
4082
4082
|
statusText: r,
|
|
4083
4083
|
headers: a,
|
|
4084
4084
|
textStream: o
|
|
4085
4085
|
}) {
|
|
4086
|
-
|
|
4086
|
+
Lo({
|
|
4087
4087
|
response: e,
|
|
4088
4088
|
status: t,
|
|
4089
4089
|
statusText: r,
|
|
@@ -4095,7 +4095,7 @@ function Yc({
|
|
|
4095
4095
|
stream: o.pipeThrough(new TextEncoderStream())
|
|
4096
4096
|
});
|
|
4097
4097
|
}
|
|
4098
|
-
var
|
|
4098
|
+
var Vo = class extends TransformStream {
|
|
4099
4099
|
constructor() {
|
|
4100
4100
|
super({
|
|
4101
4101
|
transform(e, t) {
|
|
@@ -4110,7 +4110,7 @@ var Lo = class extends TransformStream {
|
|
|
4110
4110
|
}
|
|
4111
4111
|
});
|
|
4112
4112
|
}
|
|
4113
|
-
},
|
|
4113
|
+
}, Fo = {
|
|
4114
4114
|
"content-type": "text/event-stream",
|
|
4115
4115
|
"cache-control": "no-cache",
|
|
4116
4116
|
connection: "keep-alive",
|
|
@@ -4118,14 +4118,14 @@ var Lo = class extends TransformStream {
|
|
|
4118
4118
|
"x-accel-buffering": "no"
|
|
4119
4119
|
// disable nginx buffering
|
|
4120
4120
|
};
|
|
4121
|
-
function
|
|
4121
|
+
function Qc({
|
|
4122
4122
|
status: e,
|
|
4123
4123
|
statusText: t,
|
|
4124
4124
|
headers: r,
|
|
4125
4125
|
stream: a,
|
|
4126
4126
|
consumeSseStream: o
|
|
4127
4127
|
}) {
|
|
4128
|
-
let n = a.pipeThrough(new
|
|
4128
|
+
let n = a.pipeThrough(new Vo());
|
|
4129
4129
|
if (o) {
|
|
4130
4130
|
const [i, s] = n.tee();
|
|
4131
4131
|
n = i, o({ stream: s });
|
|
@@ -4133,10 +4133,10 @@ function Xc({
|
|
|
4133
4133
|
return new Response(n.pipeThrough(new TextEncoderStream()), {
|
|
4134
4134
|
status: e,
|
|
4135
4135
|
statusText: t,
|
|
4136
|
-
headers: er(r,
|
|
4136
|
+
headers: er(r, Fo)
|
|
4137
4137
|
});
|
|
4138
4138
|
}
|
|
4139
|
-
function
|
|
4139
|
+
function ed({
|
|
4140
4140
|
originalMessages: e,
|
|
4141
4141
|
responseMessageId: t
|
|
4142
4142
|
}) {
|
|
@@ -4145,10 +4145,10 @@ function Qc({
|
|
|
4145
4145
|
const r = e[e.length - 1];
|
|
4146
4146
|
return r?.role === "assistant" ? r.id : typeof t == "function" ? t() : t;
|
|
4147
4147
|
}
|
|
4148
|
-
function
|
|
4148
|
+
function td(e) {
|
|
4149
4149
|
return e.type.startsWith("data-");
|
|
4150
4150
|
}
|
|
4151
|
-
function
|
|
4151
|
+
function Bo(e, t) {
|
|
4152
4152
|
if (e === void 0 && t === void 0)
|
|
4153
4153
|
return;
|
|
4154
4154
|
if (e === void 0)
|
|
@@ -4162,14 +4162,14 @@ function Fo(e, t) {
|
|
|
4162
4162
|
if (o === void 0)
|
|
4163
4163
|
continue;
|
|
4164
4164
|
const n = a in e ? e[a] : void 0, i = o !== null && typeof o == "object" && !Array.isArray(o) && !(o instanceof Date) && !(o instanceof RegExp), s = n != null && typeof n == "object" && !Array.isArray(n) && !(n instanceof Date) && !(n instanceof RegExp);
|
|
4165
|
-
i && s ? r[a] =
|
|
4165
|
+
i && s ? r[a] = Bo(
|
|
4166
4166
|
n,
|
|
4167
4167
|
o
|
|
4168
4168
|
) : r[a] = o;
|
|
4169
4169
|
}
|
|
4170
4170
|
return r;
|
|
4171
4171
|
}
|
|
4172
|
-
function
|
|
4172
|
+
function rd(e) {
|
|
4173
4173
|
const t = ["ROOT"];
|
|
4174
4174
|
let r = -1, a = null;
|
|
4175
4175
|
function o(u, l, d) {
|
|
@@ -4417,11 +4417,11 @@ function td(e) {
|
|
|
4417
4417
|
}
|
|
4418
4418
|
return s;
|
|
4419
4419
|
}
|
|
4420
|
-
async function
|
|
4420
|
+
async function Ho(e) {
|
|
4421
4421
|
if (e === void 0)
|
|
4422
4422
|
return { value: void 0, state: "undefined-input" };
|
|
4423
4423
|
let t = await Ve({ text: e });
|
|
4424
|
-
return t.success ? { value: t.value, state: "successful-parse" } : (t = await Ve({ text:
|
|
4424
|
+
return t.success ? { value: t.value, state: "successful-parse" } : (t = await Ve({ text: rd(e) }), t.success ? { value: t.value, state: "repaired-parse" } : { value: void 0, state: "failed-parse" });
|
|
4425
4425
|
}
|
|
4426
4426
|
function Ir(e) {
|
|
4427
4427
|
return e.type.startsWith("data-");
|
|
@@ -4447,10 +4447,10 @@ function ln(e) {
|
|
|
4447
4447
|
function Lt(e) {
|
|
4448
4448
|
return e.type.split("-").slice(1).join("-");
|
|
4449
4449
|
}
|
|
4450
|
-
function
|
|
4450
|
+
function ad(e) {
|
|
4451
4451
|
return ea(e) ? e.toolName : Lt(e);
|
|
4452
4452
|
}
|
|
4453
|
-
function
|
|
4453
|
+
function nd({
|
|
4454
4454
|
lastMessage: e,
|
|
4455
4455
|
messageId: t
|
|
4456
4456
|
}) {
|
|
@@ -4466,7 +4466,7 @@ function ad({
|
|
|
4466
4466
|
partialToolCalls: {}
|
|
4467
4467
|
};
|
|
4468
4468
|
}
|
|
4469
|
-
function
|
|
4469
|
+
function od({
|
|
4470
4470
|
stream: e,
|
|
4471
4471
|
messageMetadataSchema: t,
|
|
4472
4472
|
dataPartSchemas: r,
|
|
@@ -4540,7 +4540,7 @@ function nd({
|
|
|
4540
4540
|
}
|
|
4541
4541
|
async function b(g) {
|
|
4542
4542
|
if (g != null) {
|
|
4543
|
-
const x = l.message.metadata != null ?
|
|
4543
|
+
const x = l.message.metadata != null ? Bo(l.message.metadata, g) : g;
|
|
4544
4544
|
t != null && await Pr({
|
|
4545
4545
|
value: x,
|
|
4546
4546
|
schema: t
|
|
@@ -4642,7 +4642,7 @@ function nd({
|
|
|
4642
4642
|
case "tool-input-delta": {
|
|
4643
4643
|
const g = l.partialToolCalls[s.toolCallId];
|
|
4644
4644
|
g.text += s.inputTextDelta;
|
|
4645
|
-
const { value: x } = await
|
|
4645
|
+
const { value: x } = await Ho(
|
|
4646
4646
|
g.text
|
|
4647
4647
|
);
|
|
4648
4648
|
g.dynamic ? T({
|
|
@@ -4780,7 +4780,7 @@ function nd({
|
|
|
4780
4780
|
break;
|
|
4781
4781
|
}
|
|
4782
4782
|
default:
|
|
4783
|
-
if (
|
|
4783
|
+
if (td(s)) {
|
|
4784
4784
|
r?.[s.type] != null && await Pr({
|
|
4785
4785
|
value: s.data,
|
|
4786
4786
|
schema: r[s.type]
|
|
@@ -4802,7 +4802,7 @@ function nd({
|
|
|
4802
4802
|
})
|
|
4803
4803
|
);
|
|
4804
4804
|
}
|
|
4805
|
-
function
|
|
4805
|
+
function sd({
|
|
4806
4806
|
messageId: e,
|
|
4807
4807
|
originalMessages: t = [],
|
|
4808
4808
|
onFinish: r,
|
|
@@ -4825,7 +4825,7 @@ function od({
|
|
|
4825
4825
|
);
|
|
4826
4826
|
if (r == null)
|
|
4827
4827
|
return s;
|
|
4828
|
-
const u =
|
|
4828
|
+
const u = nd({
|
|
4829
4829
|
lastMessage: n ? structuredClone(n) : void 0,
|
|
4830
4830
|
messageId: e ?? ""
|
|
4831
4831
|
// will be overridden by the stream
|
|
@@ -4849,7 +4849,7 @@ function od({
|
|
|
4849
4849
|
]
|
|
4850
4850
|
});
|
|
4851
4851
|
};
|
|
4852
|
-
return
|
|
4852
|
+
return od({
|
|
4853
4853
|
stream: s,
|
|
4854
4854
|
runUpdateMessageJob: l,
|
|
4855
4855
|
onError: a
|
|
@@ -4868,7 +4868,7 @@ function od({
|
|
|
4868
4868
|
})
|
|
4869
4869
|
);
|
|
4870
4870
|
}
|
|
4871
|
-
function
|
|
4871
|
+
function id({
|
|
4872
4872
|
response: e,
|
|
4873
4873
|
status: t,
|
|
4874
4874
|
statusText: r,
|
|
@@ -4876,17 +4876,17 @@ function sd({
|
|
|
4876
4876
|
stream: o,
|
|
4877
4877
|
consumeSseStream: n
|
|
4878
4878
|
}) {
|
|
4879
|
-
let i = o.pipeThrough(new
|
|
4879
|
+
let i = o.pipeThrough(new Vo());
|
|
4880
4880
|
if (n) {
|
|
4881
4881
|
const [s, u] = i.tee();
|
|
4882
4882
|
i = s, n({ stream: u });
|
|
4883
4883
|
}
|
|
4884
|
-
|
|
4884
|
+
Lo({
|
|
4885
4885
|
response: e,
|
|
4886
4886
|
status: t,
|
|
4887
4887
|
statusText: r,
|
|
4888
4888
|
headers: Object.fromEntries(
|
|
4889
|
-
er(a,
|
|
4889
|
+
er(a, Fo).entries()
|
|
4890
4890
|
),
|
|
4891
4891
|
stream: i.pipeThrough(new TextEncoderStream())
|
|
4892
4892
|
});
|
|
@@ -4939,7 +4939,7 @@ function Ct(e) {
|
|
|
4939
4939
|
};
|
|
4940
4940
|
}, t;
|
|
4941
4941
|
}
|
|
4942
|
-
async function
|
|
4942
|
+
async function ld({
|
|
4943
4943
|
stream: e,
|
|
4944
4944
|
onError: t
|
|
4945
4945
|
}) {
|
|
@@ -4966,7 +4966,7 @@ function un() {
|
|
|
4966
4966
|
reject: t
|
|
4967
4967
|
};
|
|
4968
4968
|
}
|
|
4969
|
-
function
|
|
4969
|
+
function ud() {
|
|
4970
4970
|
let e = [], t = null, r = !1, a = un();
|
|
4971
4971
|
const o = () => {
|
|
4972
4972
|
r = !0, a.resolve(), e.forEach((i) => i.cancel()), e = [], t?.close();
|
|
@@ -5033,11 +5033,11 @@ var At = class {
|
|
|
5033
5033
|
this.status = { type: "rejected", error: e }, this._promise && ((t = this._reject) == null || t.call(this, e));
|
|
5034
5034
|
}
|
|
5035
5035
|
};
|
|
5036
|
-
function
|
|
5036
|
+
function cd() {
|
|
5037
5037
|
var e, t;
|
|
5038
5038
|
return (t = (e = globalThis?.performance) == null ? void 0 : e.now()) != null ? t : Date.now();
|
|
5039
5039
|
}
|
|
5040
|
-
function
|
|
5040
|
+
function dd({
|
|
5041
5041
|
tools: e,
|
|
5042
5042
|
generatorStream: t,
|
|
5043
5043
|
tracer: r,
|
|
@@ -5082,7 +5082,7 @@ function cd({
|
|
|
5082
5082
|
case "file": {
|
|
5083
5083
|
T.enqueue({
|
|
5084
5084
|
type: "file",
|
|
5085
|
-
file: new
|
|
5085
|
+
file: new Jc({
|
|
5086
5086
|
data: _.data,
|
|
5087
5087
|
mediaType: _.mediaType
|
|
5088
5088
|
})
|
|
@@ -5100,7 +5100,7 @@ function cd({
|
|
|
5100
5100
|
}
|
|
5101
5101
|
case "tool-call": {
|
|
5102
5102
|
try {
|
|
5103
|
-
const g = await
|
|
5103
|
+
const g = await Zc({
|
|
5104
5104
|
toolCall: _,
|
|
5105
5105
|
tools: e,
|
|
5106
5106
|
repairToolCall: s,
|
|
@@ -5113,7 +5113,7 @@ function cd({
|
|
|
5113
5113
|
toolCallId: g.toolCallId,
|
|
5114
5114
|
toolName: g.toolName,
|
|
5115
5115
|
input: g.input,
|
|
5116
|
-
error:
|
|
5116
|
+
error: Pn(g.error),
|
|
5117
5117
|
dynamic: !0
|
|
5118
5118
|
});
|
|
5119
5119
|
break;
|
|
@@ -5126,7 +5126,7 @@ function cd({
|
|
|
5126
5126
|
abortSignal: i,
|
|
5127
5127
|
experimental_context: u
|
|
5128
5128
|
}), x.execute != null && g.providerExecuted !== !0) {
|
|
5129
|
-
const A =
|
|
5129
|
+
const A = Qi();
|
|
5130
5130
|
p.add(A), qr({
|
|
5131
5131
|
name: "ai.toolCall",
|
|
5132
5132
|
attributes: We({
|
|
@@ -5147,7 +5147,7 @@ function cd({
|
|
|
5147
5147
|
fn: async (E) => {
|
|
5148
5148
|
let k;
|
|
5149
5149
|
try {
|
|
5150
|
-
const U =
|
|
5150
|
+
const U = pu({
|
|
5151
5151
|
execute: x.execute.bind(x),
|
|
5152
5152
|
input: g.input,
|
|
5153
5153
|
options: {
|
|
@@ -5167,7 +5167,7 @@ function cd({
|
|
|
5167
5167
|
}
|
|
5168
5168
|
}), z.type === "final" && (k = z.output);
|
|
5169
5169
|
} catch (U) {
|
|
5170
|
-
|
|
5170
|
+
jo(E, U), l.enqueue({
|
|
5171
5171
|
...g,
|
|
5172
5172
|
type: "tool-error",
|
|
5173
5173
|
error: U
|
|
@@ -5251,11 +5251,11 @@ function cd({
|
|
|
5251
5251
|
}
|
|
5252
5252
|
});
|
|
5253
5253
|
}
|
|
5254
|
-
var
|
|
5254
|
+
var pd = It({
|
|
5255
5255
|
prefix: "aitxt",
|
|
5256
5256
|
size: 24
|
|
5257
5257
|
});
|
|
5258
|
-
function
|
|
5258
|
+
function fd({
|
|
5259
5259
|
model: e,
|
|
5260
5260
|
tools: t,
|
|
5261
5261
|
toolChoice: r,
|
|
@@ -5265,7 +5265,7 @@ function pd({
|
|
|
5265
5265
|
maxRetries: i,
|
|
5266
5266
|
abortSignal: s,
|
|
5267
5267
|
headers: u,
|
|
5268
|
-
stopWhen: l =
|
|
5268
|
+
stopWhen: l = Wc(1),
|
|
5269
5269
|
experimental_output: d,
|
|
5270
5270
|
experimental_telemetry: p,
|
|
5271
5271
|
prepareStep: m,
|
|
@@ -5285,14 +5285,14 @@ function pd({
|
|
|
5285
5285
|
onStepFinish: k,
|
|
5286
5286
|
experimental_context: U,
|
|
5287
5287
|
_internal: {
|
|
5288
|
-
now: z =
|
|
5289
|
-
generateId: ee =
|
|
5288
|
+
now: z = cd,
|
|
5289
|
+
generateId: ee = pd,
|
|
5290
5290
|
currentDate: be = () => /* @__PURE__ */ new Date()
|
|
5291
5291
|
} = {},
|
|
5292
5292
|
...Z
|
|
5293
5293
|
}) {
|
|
5294
|
-
return new
|
|
5295
|
-
model:
|
|
5294
|
+
return new md({
|
|
5295
|
+
model: Po(e),
|
|
5296
5296
|
telemetry: p,
|
|
5297
5297
|
headers: u,
|
|
5298
5298
|
settings: Z,
|
|
@@ -5323,7 +5323,7 @@ function pd({
|
|
|
5323
5323
|
download: T
|
|
5324
5324
|
});
|
|
5325
5325
|
}
|
|
5326
|
-
function
|
|
5326
|
+
function hd(e) {
|
|
5327
5327
|
if (!e)
|
|
5328
5328
|
return new TransformStream({
|
|
5329
5329
|
transform(i, s) {
|
|
@@ -5373,7 +5373,7 @@ function fd(e) {
|
|
|
5373
5373
|
}
|
|
5374
5374
|
});
|
|
5375
5375
|
}
|
|
5376
|
-
var
|
|
5376
|
+
var md = class {
|
|
5377
5377
|
constructor({
|
|
5378
5378
|
model: e,
|
|
5379
5379
|
telemetry: t,
|
|
@@ -5416,7 +5416,7 @@ var hd = class {
|
|
|
5416
5416
|
var te, V, he, et;
|
|
5417
5417
|
Y.enqueue(K);
|
|
5418
5418
|
const { part: S } = K;
|
|
5419
|
-
if ((S.type === "text-delta" || S.type === "reasoning-delta" || S.type === "source" || S.type === "tool-call" || S.type === "tool-result" || S.type === "tool-input-start" || S.type === "tool-input-delta" || S.type === "raw") && await A?.({ chunk: S }), S.type === "error" && await E({ error:
|
|
5419
|
+
if ((S.type === "text-delta" || S.type === "reasoning-delta" || S.type === "source" || S.type === "tool-call" || S.type === "tool-result" || S.type === "tool-input-start" || S.type === "tool-input-delta" || S.type === "raw") && await A?.({ chunk: S }), S.type === "error" && await E({ error: $c(S.error) }), S.type === "text-start" && (fe[S.id] = {
|
|
5420
5420
|
type: "text",
|
|
5421
5421
|
text: "",
|
|
5422
5422
|
providerMetadata: S.providerMetadata
|
|
@@ -5484,7 +5484,7 @@ var hd = class {
|
|
|
5484
5484
|
const W = on({
|
|
5485
5485
|
content: L,
|
|
5486
5486
|
tools: l
|
|
5487
|
-
}), tt = new
|
|
5487
|
+
}), tt = new zc({
|
|
5488
5488
|
content: L,
|
|
5489
5489
|
finishReason: S.finishReason,
|
|
5490
5490
|
usage: S.usage,
|
|
@@ -5496,14 +5496,14 @@ var hd = class {
|
|
|
5496
5496
|
},
|
|
5497
5497
|
providerMetadata: S.providerMetadata
|
|
5498
5498
|
});
|
|
5499
|
-
await z?.(tt),
|
|
5499
|
+
await z?.(tt), Ju(q), O.push(tt), L = [], N = {}, fe = {}, Te.push(...W), Z.resolve();
|
|
5500
5500
|
}
|
|
5501
5501
|
S.type === "finish" && (Me = S.totalUsage, Ie = S.finishReason);
|
|
5502
5502
|
},
|
|
5503
5503
|
async flush(K) {
|
|
5504
5504
|
try {
|
|
5505
5505
|
if (O.length === 0) {
|
|
5506
|
-
const he = new
|
|
5506
|
+
const he = new Yu({
|
|
5507
5507
|
message: "No output generated. Check the stream for errors."
|
|
5508
5508
|
});
|
|
5509
5509
|
pe._finishReason.reject(he), pe._totalUsage.reject(he), pe._steps.reject(he);
|
|
@@ -5566,7 +5566,7 @@ var hd = class {
|
|
|
5566
5566
|
Q.end();
|
|
5567
5567
|
}
|
|
5568
5568
|
}
|
|
5569
|
-
}), F =
|
|
5569
|
+
}), F = ud();
|
|
5570
5570
|
this.addStream = F.addStream, this.closeStream = F.close;
|
|
5571
5571
|
const ae = F.stream.getReader();
|
|
5572
5572
|
let or = new ReadableStream({
|
|
@@ -5605,15 +5605,15 @@ var hd = class {
|
|
|
5605
5605
|
}
|
|
5606
5606
|
})
|
|
5607
5607
|
);
|
|
5608
|
-
this.baseStream = or.pipeThrough(
|
|
5609
|
-
const { maxRetries:
|
|
5608
|
+
this.baseStream = or.pipeThrough(hd(y)).pipeThrough(j);
|
|
5609
|
+
const { maxRetries: Ks, retry: Ys } = Hc({
|
|
5610
5610
|
maxRetries: o,
|
|
5611
5611
|
abortSignal: n
|
|
5612
|
-
}), sr =
|
|
5612
|
+
}), sr = qc(t), Ae = Tc(a), da = Uc({
|
|
5613
5613
|
model: e,
|
|
5614
5614
|
telemetry: t,
|
|
5615
5615
|
headers: r,
|
|
5616
|
-
settings: { ...Ae, maxRetries:
|
|
5616
|
+
settings: { ...Ae, maxRetries: Ks }
|
|
5617
5617
|
}), pe = this;
|
|
5618
5618
|
qr({
|
|
5619
5619
|
name: "ai.streamText",
|
|
@@ -5640,7 +5640,7 @@ var hd = class {
|
|
|
5640
5640
|
var et, S, W, tt, pa;
|
|
5641
5641
|
const fa = pe.includeRawChunks;
|
|
5642
5642
|
Z = new At();
|
|
5643
|
-
const ha = await
|
|
5643
|
+
const ha = await Nc({
|
|
5644
5644
|
system: i,
|
|
5645
5645
|
prompt: s,
|
|
5646
5646
|
messages: u
|
|
@@ -5652,24 +5652,24 @@ var hd = class {
|
|
|
5652
5652
|
steps: O,
|
|
5653
5653
|
stepNumber: O.length,
|
|
5654
5654
|
messages: rt
|
|
5655
|
-
}), He =
|
|
5655
|
+
}), He = Po(
|
|
5656
5656
|
(et = Se?.model) != null ? et : e
|
|
5657
|
-
), ma = await
|
|
5657
|
+
), ma = await yc({
|
|
5658
5658
|
prompt: {
|
|
5659
5659
|
system: (S = Se?.system) != null ? S : ha.system,
|
|
5660
5660
|
messages: (W = Se?.messages) != null ? W : rt
|
|
5661
5661
|
},
|
|
5662
5662
|
supportedUrls: await He.supportedUrls,
|
|
5663
5663
|
download: be
|
|
5664
|
-
}), { toolChoice: ir, tools: lr } =
|
|
5664
|
+
}), { toolChoice: ir, tools: lr } = Sc({
|
|
5665
5665
|
tools: l,
|
|
5666
5666
|
toolChoice: (tt = Se?.toolChoice) != null ? tt : d,
|
|
5667
5667
|
activeTools: (pa = Se?.activeTools) != null ? pa : m
|
|
5668
5668
|
}), {
|
|
5669
|
-
result: { stream:
|
|
5669
|
+
result: { stream: Xs, response: ga, request: va },
|
|
5670
5670
|
doStreamSpan: Ge,
|
|
5671
5671
|
startTimestampMs: ya
|
|
5672
|
-
} = await
|
|
5672
|
+
} = await Ys(
|
|
5673
5673
|
() => qr({
|
|
5674
5674
|
name: "ai.streamText.doStream",
|
|
5675
5675
|
attributes: We({
|
|
@@ -5685,7 +5685,7 @@ var hd = class {
|
|
|
5685
5685
|
"ai.model.id": He.modelId,
|
|
5686
5686
|
// prompt:
|
|
5687
5687
|
"ai.prompt.messages": {
|
|
5688
|
-
input: () =>
|
|
5688
|
+
input: () => Lc(ma)
|
|
5689
5689
|
},
|
|
5690
5690
|
"ai.prompt.tools": {
|
|
5691
5691
|
// convert the language model level tools:
|
|
@@ -5725,9 +5725,9 @@ var hd = class {
|
|
|
5725
5725
|
})
|
|
5726
5726
|
})
|
|
5727
5727
|
})
|
|
5728
|
-
),
|
|
5728
|
+
), Qs = dd({
|
|
5729
5729
|
tools: l,
|
|
5730
|
-
generatorStream:
|
|
5730
|
+
generatorStream: Xs,
|
|
5731
5731
|
tracer: sr,
|
|
5732
5732
|
telemetry: t,
|
|
5733
5733
|
system: i,
|
|
@@ -5735,7 +5735,7 @@ var hd = class {
|
|
|
5735
5735
|
repairToolCall: f,
|
|
5736
5736
|
abortSignal: n,
|
|
5737
5737
|
experimental_context: ee
|
|
5738
|
-
}),
|
|
5738
|
+
}), ei = va ?? {}, Et = [], ur = [];
|
|
5739
5739
|
let cr;
|
|
5740
5740
|
const dr = {};
|
|
5741
5741
|
let Je = "unknown", me = {
|
|
@@ -5748,7 +5748,7 @@ var hd = class {
|
|
|
5748
5748
|
modelId: e.modelId
|
|
5749
5749
|
}, wa = "";
|
|
5750
5750
|
pe.addStream(
|
|
5751
|
-
|
|
5751
|
+
Qs.pipeThrough(
|
|
5752
5752
|
new TransformStream({
|
|
5753
5753
|
async transform(P, re) {
|
|
5754
5754
|
var at, nt, xt, ke;
|
|
@@ -5764,7 +5764,7 @@ var hd = class {
|
|
|
5764
5764
|
"ai.response.msToFirstChunk": ne
|
|
5765
5765
|
}), re.enqueue({
|
|
5766
5766
|
type: "start-step",
|
|
5767
|
-
request:
|
|
5767
|
+
request: ei,
|
|
5768
5768
|
warnings: cr ?? []
|
|
5769
5769
|
});
|
|
5770
5770
|
}
|
|
@@ -5925,7 +5925,7 @@ var hd = class {
|
|
|
5925
5925
|
headers: ga?.headers
|
|
5926
5926
|
}
|
|
5927
5927
|
});
|
|
5928
|
-
const at =
|
|
5928
|
+
const at = Vc(he, me);
|
|
5929
5929
|
await Z.promise;
|
|
5930
5930
|
const nt = Et.filter(
|
|
5931
5931
|
(ke) => ke.providerExecuted !== !0
|
|
@@ -5934,7 +5934,7 @@ var hd = class {
|
|
|
5934
5934
|
);
|
|
5935
5935
|
if (nt.length > 0 && // all current tool calls have outputs (incl. execution errors):
|
|
5936
5936
|
xt.length === nt.length && // continue until a stop condition is met:
|
|
5937
|
-
!await
|
|
5937
|
+
!await Kc({
|
|
5938
5938
|
stopConditions: h,
|
|
5939
5939
|
steps: O
|
|
5940
5940
|
})) {
|
|
@@ -6090,7 +6090,7 @@ var hd = class {
|
|
|
6090
6090
|
async consumeStream(e) {
|
|
6091
6091
|
var t;
|
|
6092
6092
|
try {
|
|
6093
|
-
await
|
|
6093
|
+
await ld({
|
|
6094
6094
|
stream: this.fullStream,
|
|
6095
6095
|
onError: e?.onError
|
|
6096
6096
|
});
|
|
@@ -6100,7 +6100,7 @@ var hd = class {
|
|
|
6100
6100
|
}
|
|
6101
6101
|
get experimental_partialOutputStream() {
|
|
6102
6102
|
if (this.output == null)
|
|
6103
|
-
throw new
|
|
6103
|
+
throw new Bu();
|
|
6104
6104
|
return Ct(
|
|
6105
6105
|
this.teeStream().pipeThrough(
|
|
6106
6106
|
new TransformStream({
|
|
@@ -6122,7 +6122,7 @@ var hd = class {
|
|
|
6122
6122
|
sendFinish: s = !0,
|
|
6123
6123
|
onError: u = Yt
|
|
6124
6124
|
} = {}) {
|
|
6125
|
-
const l = t != null ?
|
|
6125
|
+
const l = t != null ? ed({
|
|
6126
6126
|
originalMessages: e,
|
|
6127
6127
|
responseMessageId: t
|
|
6128
6128
|
}) : void 0, d = {}, p = (f) => {
|
|
@@ -6326,7 +6326,7 @@ var hd = class {
|
|
|
6326
6326
|
})
|
|
6327
6327
|
);
|
|
6328
6328
|
return Ct(
|
|
6329
|
-
|
|
6329
|
+
sd({
|
|
6330
6330
|
stream: m,
|
|
6331
6331
|
messageId: l ?? t?.(),
|
|
6332
6332
|
originalMessages: e,
|
|
@@ -6347,7 +6347,7 @@ var hd = class {
|
|
|
6347
6347
|
onError: l,
|
|
6348
6348
|
...d
|
|
6349
6349
|
} = {}) {
|
|
6350
|
-
|
|
6350
|
+
id({
|
|
6351
6351
|
response: e,
|
|
6352
6352
|
stream: this.toUIMessageStream({
|
|
6353
6353
|
originalMessages: t,
|
|
@@ -6364,7 +6364,7 @@ var hd = class {
|
|
|
6364
6364
|
});
|
|
6365
6365
|
}
|
|
6366
6366
|
pipeTextStreamToResponse(e, t) {
|
|
6367
|
-
|
|
6367
|
+
Xc({
|
|
6368
6368
|
response: e,
|
|
6369
6369
|
textStream: this.textStream,
|
|
6370
6370
|
...t
|
|
@@ -6382,7 +6382,7 @@ var hd = class {
|
|
|
6382
6382
|
onError: u,
|
|
6383
6383
|
...l
|
|
6384
6384
|
} = {}) {
|
|
6385
|
-
return
|
|
6385
|
+
return Qc({
|
|
6386
6386
|
stream: this.toUIMessageStream({
|
|
6387
6387
|
originalMessages: e,
|
|
6388
6388
|
generateMessageId: t,
|
|
@@ -6398,13 +6398,13 @@ var hd = class {
|
|
|
6398
6398
|
});
|
|
6399
6399
|
}
|
|
6400
6400
|
toTextStreamResponse(e) {
|
|
6401
|
-
return
|
|
6401
|
+
return Yc({
|
|
6402
6402
|
textStream: this.textStream,
|
|
6403
6403
|
...e
|
|
6404
6404
|
});
|
|
6405
6405
|
}
|
|
6406
6406
|
};
|
|
6407
|
-
function
|
|
6407
|
+
function gd(e, t) {
|
|
6408
6408
|
const r = [];
|
|
6409
6409
|
t?.ignoreIncompleteToolCalls && (e = e.map((a) => ({
|
|
6410
6410
|
...a,
|
|
@@ -6532,7 +6532,7 @@ function md(e, t) {
|
|
|
6532
6532
|
switch (p.state) {
|
|
6533
6533
|
case "output-error":
|
|
6534
6534
|
case "output-available": {
|
|
6535
|
-
const f =
|
|
6535
|
+
const f = ad(p);
|
|
6536
6536
|
return {
|
|
6537
6537
|
type: "tool-result",
|
|
6538
6538
|
toolCallId: p.toolCallId,
|
|
@@ -6561,7 +6561,7 @@ function md(e, t) {
|
|
|
6561
6561
|
}
|
|
6562
6562
|
default: {
|
|
6563
6563
|
const o = a.role;
|
|
6564
|
-
throw new
|
|
6564
|
+
throw new oc({
|
|
6565
6565
|
originalMessage: a,
|
|
6566
6566
|
message: `Unsupported role: ${o}`
|
|
6567
6567
|
});
|
|
@@ -6571,12 +6571,12 @@ function md(e, t) {
|
|
|
6571
6571
|
}
|
|
6572
6572
|
It({ prefix: "aiobj", size: 24 });
|
|
6573
6573
|
It({ prefix: "aiobj", size: 24 });
|
|
6574
|
-
var
|
|
6575
|
-
|
|
6576
|
-
object: () =>
|
|
6577
|
-
text: () =>
|
|
6574
|
+
var vd = {};
|
|
6575
|
+
Vu(vd, {
|
|
6576
|
+
object: () => _d,
|
|
6577
|
+
text: () => yd
|
|
6578
6578
|
});
|
|
6579
|
-
var
|
|
6579
|
+
var yd = () => ({
|
|
6580
6580
|
type: "text",
|
|
6581
6581
|
responseFormat: { type: "text" },
|
|
6582
6582
|
async parsePartial({ text: e }) {
|
|
@@ -6585,7 +6585,7 @@ var vd = () => ({
|
|
|
6585
6585
|
async parseOutput({ text: e }) {
|
|
6586
6586
|
return e;
|
|
6587
6587
|
}
|
|
6588
|
-
}),
|
|
6588
|
+
}), _d = ({
|
|
6589
6589
|
schema: e
|
|
6590
6590
|
}) => {
|
|
6591
6591
|
const t = Qt(e);
|
|
@@ -6596,7 +6596,7 @@ var vd = () => ({
|
|
|
6596
6596
|
schema: t.jsonSchema
|
|
6597
6597
|
},
|
|
6598
6598
|
async parsePartial({ text: r }) {
|
|
6599
|
-
const a = await
|
|
6599
|
+
const a = await Ho(r);
|
|
6600
6600
|
switch (a.state) {
|
|
6601
6601
|
case "failed-parse":
|
|
6602
6602
|
case "undefined-input":
|
|
@@ -6640,14 +6640,14 @@ var vd = () => ({
|
|
|
6640
6640
|
return n.value;
|
|
6641
6641
|
}
|
|
6642
6642
|
};
|
|
6643
|
-
},
|
|
6643
|
+
}, wd = Object.defineProperty, bd = Object.defineProperties, Td = Object.getOwnPropertyDescriptors, cn = Object.getOwnPropertySymbols, Id = Object.prototype.hasOwnProperty, Sd = Object.prototype.propertyIsEnumerable, dn = (e, t, r) => t in e ? wd(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, B = (e, t) => {
|
|
6644
6644
|
for (var r in t || (t = {}))
|
|
6645
|
-
|
|
6645
|
+
Id.call(t, r) && dn(e, r, t[r]);
|
|
6646
6646
|
if (cn)
|
|
6647
6647
|
for (var r of cn(t))
|
|
6648
|
-
|
|
6648
|
+
Sd.call(t, r) && dn(e, r, t[r]);
|
|
6649
6649
|
return e;
|
|
6650
|
-
}, Vt = (e, t) =>
|
|
6650
|
+
}, Vt = (e, t) => bd(e, Td(t)), Go = "vercel.ai.error", Ed = Symbol.for(Go), Jo, xd = class Zo extends Error {
|
|
6651
6651
|
/**
|
|
6652
6652
|
* Creates an AI SDK Error.
|
|
6653
6653
|
*
|
|
@@ -6661,7 +6661,7 @@ var vd = () => ({
|
|
|
6661
6661
|
message: r,
|
|
6662
6662
|
cause: a
|
|
6663
6663
|
}) {
|
|
6664
|
-
super(r), this[
|
|
6664
|
+
super(r), this[Jo] = !0, this.name = t, this.cause = a;
|
|
6665
6665
|
}
|
|
6666
6666
|
/**
|
|
6667
6667
|
* Checks if the given error is an AI SDK Error.
|
|
@@ -6669,15 +6669,15 @@ var vd = () => ({
|
|
|
6669
6669
|
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
6670
6670
|
*/
|
|
6671
6671
|
static isInstance(t) {
|
|
6672
|
-
return
|
|
6672
|
+
return Zo.hasMarker(t, Go);
|
|
6673
6673
|
}
|
|
6674
6674
|
static hasMarker(t, r) {
|
|
6675
6675
|
const a = Symbol.for(r);
|
|
6676
6676
|
return t != null && typeof t == "object" && a in t && typeof t[a] == "boolean" && t[a] === !0;
|
|
6677
6677
|
}
|
|
6678
6678
|
};
|
|
6679
|
-
|
|
6680
|
-
var X =
|
|
6679
|
+
Jo = Ed;
|
|
6680
|
+
var X = xd, zo = "AI_APICallError", Wo = `vercel.ai.error.${zo}`, Rd = Symbol.for(Wo), Ko, we = class extends X {
|
|
6681
6681
|
constructor({
|
|
6682
6682
|
message: e,
|
|
6683
6683
|
url: t,
|
|
@@ -6693,111 +6693,111 @@ var X = Ed, Zo = "AI_APICallError", zo = `vercel.ai.error.${Zo}`, xd = Symbol.fo
|
|
|
6693
6693
|
// server error
|
|
6694
6694
|
data: u
|
|
6695
6695
|
}) {
|
|
6696
|
-
super({ name:
|
|
6696
|
+
super({ name: zo, message: e, cause: i }), this[Ko] = !0, this.url = t, this.requestBodyValues = r, this.statusCode = a, this.responseHeaders = o, this.responseBody = n, this.isRetryable = s, this.data = u;
|
|
6697
6697
|
}
|
|
6698
6698
|
static isInstance(e) {
|
|
6699
|
-
return X.hasMarker(e,
|
|
6699
|
+
return X.hasMarker(e, Wo);
|
|
6700
6700
|
}
|
|
6701
6701
|
};
|
|
6702
|
-
|
|
6703
|
-
var
|
|
6702
|
+
Ko = Rd;
|
|
6703
|
+
var Yo = "AI_EmptyResponseBodyError", Xo = `vercel.ai.error.${Yo}`, Cd = Symbol.for(Xo), Qo, Ad = class extends X {
|
|
6704
6704
|
// used in isInstance
|
|
6705
6705
|
constructor({ message: e = "Empty response body" } = {}) {
|
|
6706
|
-
super({ name:
|
|
6706
|
+
super({ name: Yo, message: e }), this[Qo] = !0;
|
|
6707
6707
|
}
|
|
6708
6708
|
static isInstance(e) {
|
|
6709
|
-
return X.hasMarker(e,
|
|
6709
|
+
return X.hasMarker(e, Xo);
|
|
6710
6710
|
}
|
|
6711
6711
|
};
|
|
6712
|
-
|
|
6713
|
-
function
|
|
6712
|
+
Qo = Cd;
|
|
6713
|
+
function es(e) {
|
|
6714
6714
|
return e == null ? "unknown error" : typeof e == "string" ? e : e instanceof Error ? e.message : JSON.stringify(e);
|
|
6715
6715
|
}
|
|
6716
|
-
var
|
|
6716
|
+
var ts = "AI_InvalidArgumentError", rs = `vercel.ai.error.${ts}`, kd = Symbol.for(rs), as, ns = class extends X {
|
|
6717
6717
|
constructor({
|
|
6718
6718
|
message: e,
|
|
6719
6719
|
cause: t,
|
|
6720
6720
|
argument: r
|
|
6721
6721
|
}) {
|
|
6722
|
-
super({ name:
|
|
6722
|
+
super({ name: ts, message: e, cause: t }), this[as] = !0, this.argument = r;
|
|
6723
6723
|
}
|
|
6724
6724
|
static isInstance(e) {
|
|
6725
|
-
return X.hasMarker(e,
|
|
6725
|
+
return X.hasMarker(e, rs);
|
|
6726
6726
|
}
|
|
6727
6727
|
};
|
|
6728
|
-
|
|
6729
|
-
var
|
|
6728
|
+
as = kd;
|
|
6729
|
+
var os = "AI_InvalidPromptError", ss = `vercel.ai.error.${os}`, Od = Symbol.for(ss), is, Pd = class extends X {
|
|
6730
6730
|
constructor({
|
|
6731
6731
|
prompt: e,
|
|
6732
6732
|
message: t,
|
|
6733
6733
|
cause: r
|
|
6734
6734
|
}) {
|
|
6735
|
-
super({ name:
|
|
6735
|
+
super({ name: os, message: `Invalid prompt: ${t}`, cause: r }), this[is] = !0, this.prompt = e;
|
|
6736
6736
|
}
|
|
6737
6737
|
static isInstance(e) {
|
|
6738
|
-
return X.hasMarker(e,
|
|
6738
|
+
return X.hasMarker(e, ss);
|
|
6739
6739
|
}
|
|
6740
6740
|
};
|
|
6741
|
-
|
|
6742
|
-
var
|
|
6741
|
+
is = Od;
|
|
6742
|
+
var ls = "AI_InvalidResponseDataError", us = `vercel.ai.error.${ls}`, Md = Symbol.for(us), cs, it = class extends X {
|
|
6743
6743
|
constructor({
|
|
6744
6744
|
data: e,
|
|
6745
6745
|
message: t = `Invalid response data: ${JSON.stringify(e)}.`
|
|
6746
6746
|
}) {
|
|
6747
|
-
super({ name:
|
|
6747
|
+
super({ name: ls, message: t }), this[cs] = !0, this.data = e;
|
|
6748
6748
|
}
|
|
6749
6749
|
static isInstance(e) {
|
|
6750
|
-
return X.hasMarker(e,
|
|
6750
|
+
return X.hasMarker(e, us);
|
|
6751
6751
|
}
|
|
6752
6752
|
};
|
|
6753
|
-
|
|
6754
|
-
var
|
|
6753
|
+
cs = Md;
|
|
6754
|
+
var ds = "AI_JSONParseError", ps = `vercel.ai.error.${ds}`, Nd = Symbol.for(ps), fs, Ft = class extends X {
|
|
6755
6755
|
constructor({ text: e, cause: t }) {
|
|
6756
6756
|
super({
|
|
6757
|
-
name:
|
|
6757
|
+
name: ds,
|
|
6758
6758
|
message: `JSON parsing failed: Text: ${e}.
|
|
6759
|
-
Error message: ${
|
|
6759
|
+
Error message: ${es(t)}`,
|
|
6760
6760
|
cause: t
|
|
6761
|
-
}), this[
|
|
6761
|
+
}), this[fs] = !0, this.text = e;
|
|
6762
6762
|
}
|
|
6763
6763
|
static isInstance(e) {
|
|
6764
|
-
return X.hasMarker(e,
|
|
6764
|
+
return X.hasMarker(e, ps);
|
|
6765
6765
|
}
|
|
6766
6766
|
};
|
|
6767
|
-
|
|
6768
|
-
var
|
|
6767
|
+
fs = Nd;
|
|
6768
|
+
var hs = "AI_LoadAPIKeyError", ms = `vercel.ai.error.${hs}`, $d = Symbol.for(ms), gs, kt = class extends X {
|
|
6769
6769
|
// used in isInstance
|
|
6770
6770
|
constructor({ message: e }) {
|
|
6771
|
-
super({ name:
|
|
6771
|
+
super({ name: hs, message: e }), this[gs] = !0;
|
|
6772
6772
|
}
|
|
6773
6773
|
static isInstance(e) {
|
|
6774
|
-
return X.hasMarker(e,
|
|
6774
|
+
return X.hasMarker(e, ms);
|
|
6775
6775
|
}
|
|
6776
6776
|
};
|
|
6777
|
-
|
|
6778
|
-
var
|
|
6777
|
+
gs = $d;
|
|
6778
|
+
var vs = "AI_NoContentGeneratedError", ys = `vercel.ai.error.${vs}`, Ud = Symbol.for(ys), _s, ws = class extends X {
|
|
6779
6779
|
// used in isInstance
|
|
6780
6780
|
constructor({
|
|
6781
6781
|
message: e = "No content generated."
|
|
6782
6782
|
} = {}) {
|
|
6783
|
-
super({ name:
|
|
6783
|
+
super({ name: vs, message: e }), this[_s] = !0;
|
|
6784
6784
|
}
|
|
6785
6785
|
static isInstance(e) {
|
|
6786
|
-
return X.hasMarker(e,
|
|
6786
|
+
return X.hasMarker(e, ys);
|
|
6787
6787
|
}
|
|
6788
6788
|
};
|
|
6789
|
-
|
|
6790
|
-
var
|
|
6789
|
+
_s = Ud;
|
|
6790
|
+
var bs = "AI_TypeValidationError", Ts = `vercel.ai.error.${bs}`, Dd = Symbol.for(Ts), Is, jd = class Lr extends X {
|
|
6791
6791
|
constructor({ value: t, cause: r }) {
|
|
6792
6792
|
super({
|
|
6793
|
-
name:
|
|
6793
|
+
name: bs,
|
|
6794
6794
|
message: `Type validation failed: Value: ${JSON.stringify(t)}.
|
|
6795
|
-
Error message: ${
|
|
6795
|
+
Error message: ${es(r)}`,
|
|
6796
6796
|
cause: r
|
|
6797
|
-
}), this[
|
|
6797
|
+
}), this[Is] = !0, this.value = t;
|
|
6798
6798
|
}
|
|
6799
6799
|
static isInstance(t) {
|
|
6800
|
-
return X.hasMarker(t,
|
|
6800
|
+
return X.hasMarker(t, Ts);
|
|
6801
6801
|
}
|
|
6802
6802
|
/**
|
|
6803
6803
|
* Wraps an error into a TypeValidationError.
|
|
@@ -6816,19 +6816,19 @@ Error message: ${Qo(r)}`,
|
|
|
6816
6816
|
return Lr.isInstance(r) && r.value === t ? r : new Lr({ value: t, cause: r });
|
|
6817
6817
|
}
|
|
6818
6818
|
};
|
|
6819
|
-
|
|
6820
|
-
var yt =
|
|
6819
|
+
Is = Dd;
|
|
6820
|
+
var yt = jd, Ss = "AI_UnsupportedFunctionalityError", Es = `vercel.ai.error.${Ss}`, qd = Symbol.for(Es), xs, $e = class extends X {
|
|
6821
6821
|
constructor({
|
|
6822
6822
|
functionality: e,
|
|
6823
6823
|
message: t = `'${e}' functionality not supported.`
|
|
6824
6824
|
}) {
|
|
6825
|
-
super({ name:
|
|
6825
|
+
super({ name: Ss, message: t }), this[xs] = !0, this.functionality = e;
|
|
6826
6826
|
}
|
|
6827
6827
|
static isInstance(e) {
|
|
6828
|
-
return X.hasMarker(e,
|
|
6828
|
+
return X.hasMarker(e, Es);
|
|
6829
6829
|
}
|
|
6830
6830
|
};
|
|
6831
|
-
|
|
6831
|
+
xs = qd;
|
|
6832
6832
|
var pn = class extends Error {
|
|
6833
6833
|
constructor(e, t) {
|
|
6834
6834
|
super(e), this.name = "ParseError", this.type = t.type, this.field = t.field, this.value = t.value, this.line = t.line;
|
|
@@ -6836,7 +6836,7 @@ var pn = class extends Error {
|
|
|
6836
6836
|
};
|
|
6837
6837
|
function xr(e) {
|
|
6838
6838
|
}
|
|
6839
|
-
function
|
|
6839
|
+
function Ld(e) {
|
|
6840
6840
|
if (typeof e == "function")
|
|
6841
6841
|
throw new TypeError(
|
|
6842
6842
|
"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
|
|
@@ -6844,7 +6844,7 @@ function qd(e) {
|
|
|
6844
6844
|
const { onEvent: t = xr, onError: r = xr, onRetry: a = xr, onComment: o } = e;
|
|
6845
6845
|
let n = "", i = !0, s, u = "", l = "";
|
|
6846
6846
|
function d(y) {
|
|
6847
|
-
const w = i ? y.replace(/^\xEF\xBB\xBF/, "") : y, [_, T] =
|
|
6847
|
+
const w = i ? y.replace(/^\xEF\xBB\xBF/, "") : y, [_, T] = Vd(`${n}${w}`);
|
|
6848
6848
|
for (const b of _)
|
|
6849
6849
|
p(b);
|
|
6850
6850
|
n = T, i = !1;
|
|
@@ -6912,7 +6912,7 @@ function qd(e) {
|
|
|
6912
6912
|
}
|
|
6913
6913
|
return { feed: d, reset: h };
|
|
6914
6914
|
}
|
|
6915
|
-
function
|
|
6915
|
+
function Vd(e) {
|
|
6916
6916
|
const t = [];
|
|
6917
6917
|
let r = "", a = 0;
|
|
6918
6918
|
for (; a < e.length; ) {
|
|
@@ -6930,12 +6930,12 @@ function Ld(e) {
|
|
|
6930
6930
|
}
|
|
6931
6931
|
return [t, r];
|
|
6932
6932
|
}
|
|
6933
|
-
var
|
|
6933
|
+
var Fd = class extends TransformStream {
|
|
6934
6934
|
constructor({ onError: e, onRetry: t, onComment: r } = {}) {
|
|
6935
6935
|
let a;
|
|
6936
6936
|
super({
|
|
6937
6937
|
start(o) {
|
|
6938
|
-
a =
|
|
6938
|
+
a = Ld({
|
|
6939
6939
|
onEvent: (n) => {
|
|
6940
6940
|
o.enqueue(n);
|
|
6941
6941
|
},
|
|
@@ -6962,7 +6962,7 @@ function _t(...e) {
|
|
|
6962
6962
|
function tr(e) {
|
|
6963
6963
|
return Object.fromEntries([...e.headers]);
|
|
6964
6964
|
}
|
|
6965
|
-
var
|
|
6965
|
+
var Bd = ({
|
|
6966
6966
|
prefix: e,
|
|
6967
6967
|
size: t = 16,
|
|
6968
6968
|
alphabet: r = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
@@ -6977,25 +6977,25 @@ var Fd = ({
|
|
|
6977
6977
|
if (e == null)
|
|
6978
6978
|
return o;
|
|
6979
6979
|
if (r.includes(a))
|
|
6980
|
-
throw new
|
|
6980
|
+
throw new ns({
|
|
6981
6981
|
argument: "separator",
|
|
6982
6982
|
message: `The separator "${a}" must not be part of the alphabet "${r}".`
|
|
6983
6983
|
});
|
|
6984
6984
|
return () => `${e}${a}${o()}`;
|
|
6985
|
-
}, ye =
|
|
6985
|
+
}, ye = Bd();
|
|
6986
6986
|
function Vr(e) {
|
|
6987
6987
|
return (e instanceof Error || e instanceof DOMException) && (e.name === "AbortError" || e.name === "ResponseAborted" || // Next.js
|
|
6988
6988
|
e.name === "TimeoutError");
|
|
6989
6989
|
}
|
|
6990
|
-
var
|
|
6991
|
-
function
|
|
6990
|
+
var Hd = ["fetch failed", "failed to fetch"];
|
|
6991
|
+
function Gd({
|
|
6992
6992
|
error: e,
|
|
6993
6993
|
url: t,
|
|
6994
6994
|
requestBodyValues: r
|
|
6995
6995
|
}) {
|
|
6996
6996
|
if (Vr(e))
|
|
6997
6997
|
return e;
|
|
6998
|
-
if (e instanceof TypeError &&
|
|
6998
|
+
if (e instanceof TypeError && Hd.includes(e.message.toLowerCase())) {
|
|
6999
6999
|
const a = e.cause;
|
|
7000
7000
|
if (a != null)
|
|
7001
7001
|
return new we({
|
|
@@ -7009,12 +7009,12 @@ function Hd({
|
|
|
7009
7009
|
}
|
|
7010
7010
|
return e;
|
|
7011
7011
|
}
|
|
7012
|
-
function
|
|
7012
|
+
function Jd(e) {
|
|
7013
7013
|
return Object.fromEntries(
|
|
7014
7014
|
Object.entries(e).filter(([t, r]) => r != null)
|
|
7015
7015
|
);
|
|
7016
7016
|
}
|
|
7017
|
-
function
|
|
7017
|
+
function Zd({
|
|
7018
7018
|
apiKey: e,
|
|
7019
7019
|
environmentVariableName: t,
|
|
7020
7020
|
apiKeyParameterName: r = "apiKey",
|
|
@@ -7040,12 +7040,12 @@ function Jd({
|
|
|
7040
7040
|
});
|
|
7041
7041
|
return e;
|
|
7042
7042
|
}
|
|
7043
|
-
var
|
|
7044
|
-
function
|
|
7043
|
+
var zd = /"__proto__"\s*:/, Wd = /"constructor"\s*:/;
|
|
7044
|
+
function Kd(e) {
|
|
7045
7045
|
const t = JSON.parse(e);
|
|
7046
|
-
return t === null || typeof t != "object" ||
|
|
7046
|
+
return t === null || typeof t != "object" || zd.test(e) === !1 && Wd.test(e) === !1 ? t : Yd(t);
|
|
7047
7047
|
}
|
|
7048
|
-
function
|
|
7048
|
+
function Yd(e) {
|
|
7049
7049
|
let t = [e];
|
|
7050
7050
|
for (; t.length; ) {
|
|
7051
7051
|
const r = t;
|
|
@@ -7067,23 +7067,23 @@ function ta(e) {
|
|
|
7067
7067
|
const { stackTraceLimit: t } = Error;
|
|
7068
7068
|
Error.stackTraceLimit = 0;
|
|
7069
7069
|
try {
|
|
7070
|
-
return
|
|
7070
|
+
return Kd(e);
|
|
7071
7071
|
} finally {
|
|
7072
7072
|
Error.stackTraceLimit = t;
|
|
7073
7073
|
}
|
|
7074
7074
|
}
|
|
7075
7075
|
var Fr = Symbol.for("vercel.ai.validator");
|
|
7076
|
-
function Yd(e) {
|
|
7077
|
-
return { [Fr]: !0, validate: e };
|
|
7078
|
-
}
|
|
7079
7076
|
function Xd(e) {
|
|
7080
|
-
return
|
|
7077
|
+
return { [Fr]: !0, validate: e };
|
|
7081
7078
|
}
|
|
7082
7079
|
function Qd(e) {
|
|
7083
|
-
return
|
|
7080
|
+
return typeof e == "object" && e !== null && Fr in e && e[Fr] === !0 && "validate" in e;
|
|
7084
7081
|
}
|
|
7085
7082
|
function ep(e) {
|
|
7086
|
-
return
|
|
7083
|
+
return Qd(e) ? e : tp(e);
|
|
7084
|
+
}
|
|
7085
|
+
function tp(e) {
|
|
7086
|
+
return Xd(async (t) => {
|
|
7087
7087
|
const r = await e["~standard"].validate(t);
|
|
7088
7088
|
return r.issues == null ? { success: !0, value: r.value } : {
|
|
7089
7089
|
success: !1,
|
|
@@ -7094,20 +7094,20 @@ function ep(e) {
|
|
|
7094
7094
|
};
|
|
7095
7095
|
});
|
|
7096
7096
|
}
|
|
7097
|
-
async function
|
|
7097
|
+
async function rp({
|
|
7098
7098
|
value: e,
|
|
7099
7099
|
schema: t
|
|
7100
7100
|
}) {
|
|
7101
|
-
const r = await
|
|
7101
|
+
const r = await Rs({ value: e, schema: t });
|
|
7102
7102
|
if (!r.success)
|
|
7103
7103
|
throw yt.wrap({ value: e, cause: r.error });
|
|
7104
7104
|
return r.value;
|
|
7105
7105
|
}
|
|
7106
|
-
async function
|
|
7106
|
+
async function Rs({
|
|
7107
7107
|
value: e,
|
|
7108
7108
|
schema: t
|
|
7109
7109
|
}) {
|
|
7110
|
-
const r =
|
|
7110
|
+
const r = ep(t);
|
|
7111
7111
|
try {
|
|
7112
7112
|
if (r.validate == null)
|
|
7113
7113
|
return { success: !0, value: e, rawValue: e };
|
|
@@ -7125,24 +7125,24 @@ async function xs({
|
|
|
7125
7125
|
};
|
|
7126
7126
|
}
|
|
7127
7127
|
}
|
|
7128
|
-
async function
|
|
7128
|
+
async function ap({
|
|
7129
7129
|
text: e,
|
|
7130
7130
|
schema: t
|
|
7131
7131
|
}) {
|
|
7132
7132
|
try {
|
|
7133
7133
|
const r = ta(e);
|
|
7134
|
-
return t == null ? r :
|
|
7134
|
+
return t == null ? r : rp({ value: r, schema: t });
|
|
7135
7135
|
} catch (r) {
|
|
7136
7136
|
throw Ft.isInstance(r) || yt.isInstance(r) ? r : new Ft({ text: e, cause: r });
|
|
7137
7137
|
}
|
|
7138
7138
|
}
|
|
7139
|
-
async function
|
|
7139
|
+
async function Cs({
|
|
7140
7140
|
text: e,
|
|
7141
7141
|
schema: t
|
|
7142
7142
|
}) {
|
|
7143
7143
|
try {
|
|
7144
7144
|
const r = ta(e);
|
|
7145
|
-
return t == null ? { success: !0, value: r, rawValue: r } : await
|
|
7145
|
+
return t == null ? { success: !0, value: r, rawValue: r } : await Rs({ value: r, schema: t });
|
|
7146
7146
|
} catch (r) {
|
|
7147
7147
|
return {
|
|
7148
7148
|
success: !1,
|
|
@@ -7158,19 +7158,19 @@ function Rr(e) {
|
|
|
7158
7158
|
return !1;
|
|
7159
7159
|
}
|
|
7160
7160
|
}
|
|
7161
|
-
function
|
|
7161
|
+
function np({
|
|
7162
7162
|
stream: e,
|
|
7163
7163
|
schema: t
|
|
7164
7164
|
}) {
|
|
7165
|
-
return e.pipeThrough(new TextDecoderStream()).pipeThrough(new
|
|
7165
|
+
return e.pipeThrough(new TextDecoderStream()).pipeThrough(new Fd()).pipeThrough(
|
|
7166
7166
|
new TransformStream({
|
|
7167
7167
|
async transform({ data: r }, a) {
|
|
7168
|
-
r !== "[DONE]" && a.enqueue(await
|
|
7168
|
+
r !== "[DONE]" && a.enqueue(await Cs({ text: r, schema: t }));
|
|
7169
7169
|
}
|
|
7170
7170
|
})
|
|
7171
7171
|
);
|
|
7172
7172
|
}
|
|
7173
|
-
var
|
|
7173
|
+
var op = () => globalThis.fetch, wt = async ({
|
|
7174
7174
|
url: e,
|
|
7175
7175
|
headers: t,
|
|
7176
7176
|
body: r,
|
|
@@ -7178,7 +7178,7 @@ var np = () => globalThis.fetch, wt = async ({
|
|
|
7178
7178
|
successfulResponseHandler: o,
|
|
7179
7179
|
abortSignal: n,
|
|
7180
7180
|
fetch: i
|
|
7181
|
-
}) =>
|
|
7181
|
+
}) => sp({
|
|
7182
7182
|
url: e,
|
|
7183
7183
|
headers: B({
|
|
7184
7184
|
"Content-Type": "application/json"
|
|
@@ -7191,19 +7191,19 @@ var np = () => globalThis.fetch, wt = async ({
|
|
|
7191
7191
|
successfulResponseHandler: o,
|
|
7192
7192
|
abortSignal: n,
|
|
7193
7193
|
fetch: i
|
|
7194
|
-
}),
|
|
7194
|
+
}), sp = async ({
|
|
7195
7195
|
url: e,
|
|
7196
7196
|
headers: t = {},
|
|
7197
7197
|
body: r,
|
|
7198
7198
|
successfulResponseHandler: a,
|
|
7199
7199
|
failedResponseHandler: o,
|
|
7200
7200
|
abortSignal: n,
|
|
7201
|
-
fetch: i =
|
|
7201
|
+
fetch: i = op()
|
|
7202
7202
|
}) => {
|
|
7203
7203
|
try {
|
|
7204
7204
|
const s = await i(e, {
|
|
7205
7205
|
method: "POST",
|
|
7206
|
-
headers:
|
|
7206
|
+
headers: Jd(t),
|
|
7207
7207
|
body: r.content,
|
|
7208
7208
|
signal: n
|
|
7209
7209
|
}), u = tr(s);
|
|
@@ -7244,9 +7244,9 @@ var np = () => globalThis.fetch, wt = async ({
|
|
|
7244
7244
|
});
|
|
7245
7245
|
}
|
|
7246
7246
|
} catch (s) {
|
|
7247
|
-
throw
|
|
7247
|
+
throw Gd({ error: s, url: e, requestBodyValues: r.values });
|
|
7248
7248
|
}
|
|
7249
|
-
},
|
|
7249
|
+
}, ip = ({
|
|
7250
7250
|
errorSchema: e,
|
|
7251
7251
|
errorToMessage: t,
|
|
7252
7252
|
isRetryable: r
|
|
@@ -7266,7 +7266,7 @@ var np = () => globalThis.fetch, wt = async ({
|
|
|
7266
7266
|
})
|
|
7267
7267
|
};
|
|
7268
7268
|
try {
|
|
7269
|
-
const u = await
|
|
7269
|
+
const u = await ap({
|
|
7270
7270
|
text: i,
|
|
7271
7271
|
schema: e
|
|
7272
7272
|
});
|
|
@@ -7297,19 +7297,19 @@ var np = () => globalThis.fetch, wt = async ({
|
|
|
7297
7297
|
})
|
|
7298
7298
|
};
|
|
7299
7299
|
}
|
|
7300
|
-
},
|
|
7300
|
+
}, As = (e) => async ({ response: t }) => {
|
|
7301
7301
|
const r = tr(t);
|
|
7302
7302
|
if (t.body == null)
|
|
7303
|
-
throw new
|
|
7303
|
+
throw new Ad({});
|
|
7304
7304
|
return {
|
|
7305
7305
|
responseHeaders: r,
|
|
7306
|
-
value:
|
|
7306
|
+
value: np({
|
|
7307
7307
|
stream: t.body,
|
|
7308
7308
|
schema: e
|
|
7309
7309
|
})
|
|
7310
7310
|
};
|
|
7311
7311
|
}, ra = (e) => async ({ response: t, url: r, requestBodyValues: a }) => {
|
|
7312
|
-
const o = await t.text(), n = await
|
|
7312
|
+
const o = await t.text(), n = await Cs({
|
|
7313
7313
|
text: o,
|
|
7314
7314
|
schema: e
|
|
7315
7315
|
}), i = tr(t);
|
|
@@ -7328,36 +7328,36 @@ var np = () => globalThis.fetch, wt = async ({
|
|
|
7328
7328
|
value: n.value,
|
|
7329
7329
|
rawValue: n.rawValue
|
|
7330
7330
|
};
|
|
7331
|
-
}, { btoa:
|
|
7332
|
-
function
|
|
7331
|
+
}, { btoa: lp } = globalThis;
|
|
7332
|
+
function up(e) {
|
|
7333
7333
|
let t = "";
|
|
7334
7334
|
for (let r = 0; r < e.length; r++)
|
|
7335
7335
|
t += String.fromCodePoint(e[r]);
|
|
7336
|
-
return
|
|
7336
|
+
return lp(t);
|
|
7337
7337
|
}
|
|
7338
|
-
function
|
|
7338
|
+
function cp(e) {
|
|
7339
7339
|
return e?.replace(/\/$/, "");
|
|
7340
7340
|
}
|
|
7341
7341
|
function Cr(e) {
|
|
7342
7342
|
return e != null;
|
|
7343
7343
|
}
|
|
7344
|
-
var
|
|
7344
|
+
var ks = /* @__PURE__ */ ((e) => (e.Unknown = "unknown", e.OpenAIResponsesV1 = "openai-responses-v1", e.XAIResponsesV1 = "xai-responses-v1", e.AnthropicClaudeV1 = "anthropic-claude-v1", e.GoogleGeminiV1 = "google-gemini-v1", e))(ks || {}), aa = v({
|
|
7345
7345
|
id: c().nullish(),
|
|
7346
|
-
format: Kt(
|
|
7346
|
+
format: Kt(ks).nullish(),
|
|
7347
7347
|
index: R().optional()
|
|
7348
|
-
}).loose(),
|
|
7348
|
+
}).loose(), dp = v({
|
|
7349
7349
|
type: C(
|
|
7350
7350
|
"reasoning.summary"
|
|
7351
7351
|
/* Summary */
|
|
7352
7352
|
),
|
|
7353
7353
|
summary: c()
|
|
7354
|
-
}).extend(aa.shape),
|
|
7354
|
+
}).extend(aa.shape), pp = v({
|
|
7355
7355
|
type: C(
|
|
7356
7356
|
"reasoning.encrypted"
|
|
7357
7357
|
/* Encrypted */
|
|
7358
7358
|
),
|
|
7359
7359
|
data: c()
|
|
7360
|
-
}).extend(aa.shape),
|
|
7360
|
+
}).extend(aa.shape), fp = v({
|
|
7361
7361
|
type: C(
|
|
7362
7362
|
"reasoning.text"
|
|
7363
7363
|
/* Text */
|
|
@@ -7365,9 +7365,9 @@ var As = /* @__PURE__ */ ((e) => (e.Unknown = "unknown", e.OpenAIResponsesV1 = "
|
|
|
7365
7365
|
text: c().nullish(),
|
|
7366
7366
|
signature: c().nullish()
|
|
7367
7367
|
}).extend(aa.shape), na = D([
|
|
7368
|
-
cp,
|
|
7369
7368
|
dp,
|
|
7370
|
-
pp
|
|
7369
|
+
pp,
|
|
7370
|
+
fp
|
|
7371
7371
|
]), Pt = D([
|
|
7372
7372
|
na,
|
|
7373
7373
|
Re().transform(() => null)
|
|
@@ -7399,10 +7399,10 @@ var rr = v({
|
|
|
7399
7399
|
type: c().nullable().optional().default(null),
|
|
7400
7400
|
param: Oe().nullable().optional().default(null)
|
|
7401
7401
|
}).passthrough()
|
|
7402
|
-
}).passthrough(), bt =
|
|
7402
|
+
}).passthrough(), bt = ip({
|
|
7403
7403
|
errorSchema: rr,
|
|
7404
7404
|
errorToMessage: (e) => e.error.message
|
|
7405
|
-
}),
|
|
7405
|
+
}), Os = v({
|
|
7406
7406
|
type: C("file"),
|
|
7407
7407
|
file: v({
|
|
7408
7408
|
hash: c(),
|
|
@@ -7414,10 +7414,10 @@ var rr = v({
|
|
|
7414
7414
|
}).passthrough()
|
|
7415
7415
|
).optional()
|
|
7416
7416
|
}).passthrough()
|
|
7417
|
-
}),
|
|
7417
|
+
}), hp = v({
|
|
7418
7418
|
provider: c(),
|
|
7419
7419
|
reasoning_details: I(na).optional(),
|
|
7420
|
-
annotations: I(
|
|
7420
|
+
annotations: I(Os).optional(),
|
|
7421
7421
|
usage: v({
|
|
7422
7422
|
promptTokens: R(),
|
|
7423
7423
|
promptTokensDetails: v({
|
|
@@ -7436,7 +7436,7 @@ var rr = v({
|
|
|
7436
7436
|
}).passthrough(), fn = v({
|
|
7437
7437
|
openrouter: v({
|
|
7438
7438
|
reasoning_details: I(na).optional(),
|
|
7439
|
-
annotations: I(
|
|
7439
|
+
annotations: I(Os).optional()
|
|
7440
7440
|
}).optional()
|
|
7441
7441
|
}).optional();
|
|
7442
7442
|
function Bt(e) {
|
|
@@ -7471,7 +7471,7 @@ function Br({
|
|
|
7471
7471
|
}) {
|
|
7472
7472
|
var r, a;
|
|
7473
7473
|
if (e.data instanceof Uint8Array) {
|
|
7474
|
-
const n =
|
|
7474
|
+
const n = up(e.data);
|
|
7475
7475
|
return `data:${(r = e.mediaType) != null ? r : t};base64,${n}`;
|
|
7476
7476
|
}
|
|
7477
7477
|
const o = e.data.toString();
|
|
@@ -7489,7 +7489,7 @@ function Hr(e) {
|
|
|
7489
7489
|
const t = e.match(/^data:[^;]*;base64,(.+)$/);
|
|
7490
7490
|
return t ? t[1] : e;
|
|
7491
7491
|
}
|
|
7492
|
-
function
|
|
7492
|
+
function mp(e) {
|
|
7493
7493
|
const t = Br({
|
|
7494
7494
|
part: e,
|
|
7495
7495
|
defaultMediaType: "audio/mpeg"
|
|
@@ -7529,7 +7529,7 @@ function Ne(e) {
|
|
|
7529
7529
|
const o = e?.anthropic, n = e?.openrouter;
|
|
7530
7530
|
return (a = (r = (t = n?.cacheControl) != null ? t : n?.cache_control) != null ? r : o?.cacheControl) != null ? a : o?.cache_control;
|
|
7531
7531
|
}
|
|
7532
|
-
function
|
|
7532
|
+
function gp(e) {
|
|
7533
7533
|
var t, r, a, o, n, i, s, u, l, d;
|
|
7534
7534
|
const p = [];
|
|
7535
7535
|
for (const { role: m, content: f, providerOptions: h } of e)
|
|
@@ -7585,7 +7585,7 @@ function mp(e) {
|
|
|
7585
7585
|
if ((g = _.mediaType) != null && g.startsWith("audio/"))
|
|
7586
7586
|
return {
|
|
7587
7587
|
type: "input_audio",
|
|
7588
|
-
input_audio:
|
|
7588
|
+
input_audio: mp(_),
|
|
7589
7589
|
cache_control: U
|
|
7590
7590
|
};
|
|
7591
7591
|
const z = String(
|
|
@@ -7673,7 +7673,7 @@ function mp(e) {
|
|
|
7673
7673
|
}
|
|
7674
7674
|
case "tool": {
|
|
7675
7675
|
for (const y of f) {
|
|
7676
|
-
const w =
|
|
7676
|
+
const w = vp(y);
|
|
7677
7677
|
p.push({
|
|
7678
7678
|
role: "tool",
|
|
7679
7679
|
tool_call_id: y.toolCallId,
|
|
@@ -7686,7 +7686,7 @@ function mp(e) {
|
|
|
7686
7686
|
}
|
|
7687
7687
|
return p;
|
|
7688
7688
|
}
|
|
7689
|
-
function
|
|
7689
|
+
function vp(e) {
|
|
7690
7690
|
return e.output.type === "text" ? e.output.value : JSON.stringify(e.output.value);
|
|
7691
7691
|
}
|
|
7692
7692
|
D([
|
|
@@ -7700,7 +7700,7 @@ D([
|
|
|
7700
7700
|
})
|
|
7701
7701
|
})
|
|
7702
7702
|
]);
|
|
7703
|
-
function
|
|
7703
|
+
function yp(e) {
|
|
7704
7704
|
switch (e.type) {
|
|
7705
7705
|
case "auto":
|
|
7706
7706
|
case "none":
|
|
@@ -7712,21 +7712,21 @@ function vp(e) {
|
|
|
7712
7712
|
function: { name: e.toolName }
|
|
7713
7713
|
};
|
|
7714
7714
|
default:
|
|
7715
|
-
throw new
|
|
7715
|
+
throw new ns({
|
|
7716
7716
|
argument: "toolChoice",
|
|
7717
7717
|
message: `Invalid tool choice type: ${JSON.stringify(e)}`
|
|
7718
7718
|
});
|
|
7719
7719
|
}
|
|
7720
7720
|
}
|
|
7721
|
-
var
|
|
7721
|
+
var _p = v({
|
|
7722
7722
|
type: C("image_url"),
|
|
7723
7723
|
image_url: v({
|
|
7724
7724
|
url: c()
|
|
7725
7725
|
}).passthrough()
|
|
7726
|
-
}).passthrough(),
|
|
7727
|
-
|
|
7726
|
+
}).passthrough(), wp = D([
|
|
7727
|
+
_p,
|
|
7728
7728
|
Re().transform(() => null)
|
|
7729
|
-
]),
|
|
7729
|
+
]), Ps = I(wp).transform((e) => e.filter((t) => !!t)), Ms = v({
|
|
7730
7730
|
id: c().optional(),
|
|
7731
7731
|
model: c().optional(),
|
|
7732
7732
|
provider: c().optional(),
|
|
@@ -7745,9 +7745,9 @@ var yp = v({
|
|
|
7745
7745
|
upstream_inference_cost: R().nullish()
|
|
7746
7746
|
}).passthrough().nullish()
|
|
7747
7747
|
}).passthrough().nullish()
|
|
7748
|
-
}).passthrough(),
|
|
7748
|
+
}).passthrough(), bp = D([
|
|
7749
7749
|
// Success response with choices
|
|
7750
|
-
|
|
7750
|
+
Ms.extend({
|
|
7751
7751
|
choices: I(
|
|
7752
7752
|
v({
|
|
7753
7753
|
message: v({
|
|
@@ -7755,7 +7755,7 @@ var yp = v({
|
|
|
7755
7755
|
content: c().nullable().optional(),
|
|
7756
7756
|
reasoning: c().nullable().optional(),
|
|
7757
7757
|
reasoning_details: oa.nullish(),
|
|
7758
|
-
images:
|
|
7758
|
+
images: Ps.nullish(),
|
|
7759
7759
|
tool_calls: I(
|
|
7760
7760
|
v({
|
|
7761
7761
|
id: c().optional().nullable(),
|
|
@@ -7827,8 +7827,8 @@ var yp = v({
|
|
|
7827
7827
|
rr.extend({
|
|
7828
7828
|
user_id: c().optional()
|
|
7829
7829
|
})
|
|
7830
|
-
]),
|
|
7831
|
-
|
|
7830
|
+
]), Tp = D([
|
|
7831
|
+
Ms.extend({
|
|
7832
7832
|
choices: I(
|
|
7833
7833
|
v({
|
|
7834
7834
|
delta: v({
|
|
@@ -7836,7 +7836,7 @@ var yp = v({
|
|
|
7836
7836
|
content: c().nullish(),
|
|
7837
7837
|
reasoning: c().nullish().optional(),
|
|
7838
7838
|
reasoning_details: oa.nullish(),
|
|
7839
|
-
images:
|
|
7839
|
+
images: Ps.nullish(),
|
|
7840
7840
|
tool_calls: I(
|
|
7841
7841
|
v({
|
|
7842
7842
|
index: R().nullish(),
|
|
@@ -7906,7 +7906,7 @@ var yp = v({
|
|
|
7906
7906
|
)
|
|
7907
7907
|
}),
|
|
7908
7908
|
rr
|
|
7909
|
-
]),
|
|
7909
|
+
]), Ip = class {
|
|
7910
7910
|
constructor(e, t, r) {
|
|
7911
7911
|
this.specificationVersion = "v2", this.provider = "openrouter", this.defaultObjectGenerationMode = "tool", this.supportsImageUrls = !0, this.supportedUrls = {
|
|
7912
7912
|
"image/*": [
|
|
@@ -7962,7 +7962,7 @@ var yp = v({
|
|
|
7962
7962
|
} : { type: "json_object" } : void 0,
|
|
7963
7963
|
top_k: l,
|
|
7964
7964
|
// messages:
|
|
7965
|
-
messages:
|
|
7965
|
+
messages: gp(e),
|
|
7966
7966
|
// OpenRouter specific settings:
|
|
7967
7967
|
include_reasoning: this.settings.includeReasoning,
|
|
7968
7968
|
reasoning: this.settings.reasoning,
|
|
@@ -7988,7 +7988,7 @@ var yp = v({
|
|
|
7988
7988
|
}));
|
|
7989
7989
|
return Vt(B({}, f), {
|
|
7990
7990
|
tools: h,
|
|
7991
|
-
tool_choice: p ?
|
|
7991
|
+
tool_choice: p ? yp(p) : void 0
|
|
7992
7992
|
});
|
|
7993
7993
|
}
|
|
7994
7994
|
return f;
|
|
@@ -8004,7 +8004,7 @@ var yp = v({
|
|
|
8004
8004
|
body: z,
|
|
8005
8005
|
failedResponseHandler: bt,
|
|
8006
8006
|
successfulResponseHandler: ra(
|
|
8007
|
-
|
|
8007
|
+
bp
|
|
8008
8008
|
),
|
|
8009
8009
|
abortSignal: e.abortSignal,
|
|
8010
8010
|
fetch: this.config.fetch
|
|
@@ -8025,7 +8025,7 @@ var yp = v({
|
|
|
8025
8025
|
}
|
|
8026
8026
|
const Z = ee, L = Z.choices[0];
|
|
8027
8027
|
if (!L)
|
|
8028
|
-
throw new
|
|
8028
|
+
throw new ws({
|
|
8029
8029
|
message: "No choice in response"
|
|
8030
8030
|
});
|
|
8031
8031
|
const Te = Z.usage ? {
|
|
@@ -8135,7 +8135,7 @@ var yp = v({
|
|
|
8135
8135
|
usage: Te,
|
|
8136
8136
|
warnings: [],
|
|
8137
8137
|
providerMetadata: {
|
|
8138
|
-
openrouter:
|
|
8138
|
+
openrouter: hp.parse({
|
|
8139
8139
|
provider: (m = Z.provider) != null ? m : "",
|
|
8140
8140
|
reasoning_details: (f = L.message.reasoning_details) != null ? f : [],
|
|
8141
8141
|
annotations: q && q.length > 0 ? q : void 0,
|
|
@@ -8183,8 +8183,8 @@ var yp = v({
|
|
|
8183
8183
|
}, (t = this.settings.usage) != null && t.include ? { include_usage: !0 } : {}) : void 0
|
|
8184
8184
|
}),
|
|
8185
8185
|
failedResponseHandler: bt,
|
|
8186
|
-
successfulResponseHandler:
|
|
8187
|
-
|
|
8186
|
+
successfulResponseHandler: As(
|
|
8187
|
+
Tp
|
|
8188
8188
|
),
|
|
8189
8189
|
abortSignal: e.abortSignal,
|
|
8190
8190
|
fetch: this.config.fetch
|
|
@@ -8444,7 +8444,7 @@ var yp = v({
|
|
|
8444
8444
|
};
|
|
8445
8445
|
}
|
|
8446
8446
|
};
|
|
8447
|
-
function
|
|
8447
|
+
function Sp({
|
|
8448
8448
|
prompt: e,
|
|
8449
8449
|
inputFormat: t,
|
|
8450
8450
|
user: r = "user",
|
|
@@ -8459,7 +8459,7 @@ function Ip({
|
|
|
8459
8459
|
for (const { role: n, content: i } of e)
|
|
8460
8460
|
switch (n) {
|
|
8461
8461
|
case "system":
|
|
8462
|
-
throw new
|
|
8462
|
+
throw new Pd({
|
|
8463
8463
|
message: `Unexpected system message in prompt: ${i}`,
|
|
8464
8464
|
prompt: e
|
|
8465
8465
|
});
|
|
@@ -8560,7 +8560,7 @@ var mn = D([
|
|
|
8560
8560
|
}).passthrough().nullish()
|
|
8561
8561
|
}).passthrough(),
|
|
8562
8562
|
rr
|
|
8563
|
-
]),
|
|
8563
|
+
]), Ep = class {
|
|
8564
8564
|
constructor(e, t, r) {
|
|
8565
8565
|
this.specificationVersion = "v2", this.provider = "openrouter", this.supportsImageUrls = !0, this.supportedUrls = {
|
|
8566
8566
|
"image/*": [
|
|
@@ -8585,7 +8585,7 @@ var mn = D([
|
|
|
8585
8585
|
tools: d,
|
|
8586
8586
|
toolChoice: p
|
|
8587
8587
|
}) {
|
|
8588
|
-
const { prompt: m } =
|
|
8588
|
+
const { prompt: m } = Sp({
|
|
8589
8589
|
prompt: e,
|
|
8590
8590
|
inputFormat: "prompt"
|
|
8591
8591
|
});
|
|
@@ -8655,7 +8655,7 @@ var mn = D([
|
|
|
8655
8655
|
}
|
|
8656
8656
|
const x = b.choices[0];
|
|
8657
8657
|
if (!x)
|
|
8658
|
-
throw new
|
|
8658
|
+
throw new ws({
|
|
8659
8659
|
message: "No choice in OpenRouter completion response"
|
|
8660
8660
|
});
|
|
8661
8661
|
return {
|
|
@@ -8692,7 +8692,7 @@ var mn = D([
|
|
|
8692
8692
|
stream_options: this.config.compatibility === "strict" ? { include_usage: !0 } : void 0
|
|
8693
8693
|
}),
|
|
8694
8694
|
failedResponseHandler: bt,
|
|
8695
|
-
successfulResponseHandler:
|
|
8695
|
+
successfulResponseHandler: As(
|
|
8696
8696
|
mn
|
|
8697
8697
|
),
|
|
8698
8698
|
abortSignal: e.abortSignal,
|
|
@@ -8765,21 +8765,21 @@ var mn = D([
|
|
|
8765
8765
|
}
|
|
8766
8766
|
};
|
|
8767
8767
|
}
|
|
8768
|
-
},
|
|
8768
|
+
}, xp = v({
|
|
8769
8769
|
prompt_tokens: R(),
|
|
8770
8770
|
total_tokens: R(),
|
|
8771
8771
|
cost: R().optional()
|
|
8772
|
-
}),
|
|
8772
|
+
}), Rp = v({
|
|
8773
8773
|
object: C("embedding"),
|
|
8774
8774
|
embedding: I(R()),
|
|
8775
8775
|
index: R().optional()
|
|
8776
|
-
}),
|
|
8776
|
+
}), Cp = v({
|
|
8777
8777
|
id: c().optional(),
|
|
8778
8778
|
object: C("list"),
|
|
8779
|
-
data: I(
|
|
8779
|
+
data: I(Rp),
|
|
8780
8780
|
model: c(),
|
|
8781
|
-
usage:
|
|
8782
|
-
}),
|
|
8781
|
+
usage: xp.optional()
|
|
8782
|
+
}), Ap = class {
|
|
8783
8783
|
constructor(e, t, r) {
|
|
8784
8784
|
this.specificationVersion = "v2", this.provider = "openrouter", this.maxEmbeddingsPerCall = void 0, this.supportsParallelCalls = !0, this.modelId = e, this.settings = t, this.config = r;
|
|
8785
8785
|
}
|
|
@@ -8799,7 +8799,7 @@ var mn = D([
|
|
|
8799
8799
|
body: n,
|
|
8800
8800
|
failedResponseHandler: bt,
|
|
8801
8801
|
successfulResponseHandler: ra(
|
|
8802
|
-
|
|
8802
|
+
Cp
|
|
8803
8803
|
),
|
|
8804
8804
|
abortSignal: a,
|
|
8805
8805
|
fetch: this.config.fetch
|
|
@@ -8821,25 +8821,25 @@ var mn = D([
|
|
|
8821
8821
|
};
|
|
8822
8822
|
}
|
|
8823
8823
|
};
|
|
8824
|
-
function
|
|
8824
|
+
function kp(e) {
|
|
8825
8825
|
return Object.fromEntries(
|
|
8826
8826
|
Object.entries(e).filter(([, t]) => t !== null)
|
|
8827
8827
|
);
|
|
8828
8828
|
}
|
|
8829
|
-
function
|
|
8830
|
-
const r =
|
|
8829
|
+
function Op(e, ...t) {
|
|
8830
|
+
const r = kp(
|
|
8831
8831
|
e ?? {}
|
|
8832
8832
|
), o = [r["user-agent"] || "", ...t].filter(Boolean).join(" ");
|
|
8833
8833
|
return Vt(B({}, r), {
|
|
8834
8834
|
"user-agent": o
|
|
8835
8835
|
});
|
|
8836
8836
|
}
|
|
8837
|
-
var
|
|
8838
|
-
function
|
|
8837
|
+
var Pp = "1.4.1";
|
|
8838
|
+
function Ns(e = {}) {
|
|
8839
8839
|
var t, r, a;
|
|
8840
|
-
const o = (r =
|
|
8840
|
+
const o = (r = cp((t = e.baseURL) != null ? t : e.baseUrl)) != null ? r : "https://openrouter.ai/api/v1", n = (a = e.compatibility) != null ? a : "compatible", i = () => Op(
|
|
8841
8841
|
B(B({
|
|
8842
|
-
Authorization: `Bearer ${
|
|
8842
|
+
Authorization: `Bearer ${Zd({
|
|
8843
8843
|
apiKey: e.apiKey,
|
|
8844
8844
|
environmentVariableName: "OPENROUTER_API_KEY",
|
|
8845
8845
|
description: "OpenRouter"
|
|
@@ -8847,22 +8847,22 @@ function Ms(e = {}) {
|
|
|
8847
8847
|
}, e.headers), e.api_keys && Object.keys(e.api_keys).length > 0 && {
|
|
8848
8848
|
"X-Provider-API-Keys": JSON.stringify(e.api_keys)
|
|
8849
8849
|
}),
|
|
8850
|
-
`ai-sdk/openrouter/${
|
|
8851
|
-
), s = (m, f = {}) => new
|
|
8850
|
+
`ai-sdk/openrouter/${Pp}`
|
|
8851
|
+
), s = (m, f = {}) => new Ip(m, f, {
|
|
8852
8852
|
provider: "openrouter.chat",
|
|
8853
8853
|
url: ({ path: h }) => `${o}${h}`,
|
|
8854
8854
|
headers: i,
|
|
8855
8855
|
compatibility: n,
|
|
8856
8856
|
fetch: e.fetch,
|
|
8857
8857
|
extraBody: e.extraBody
|
|
8858
|
-
}), u = (m, f = {}) => new
|
|
8858
|
+
}), u = (m, f = {}) => new Ep(m, f, {
|
|
8859
8859
|
provider: "openrouter.completion",
|
|
8860
8860
|
url: ({ path: h }) => `${o}${h}`,
|
|
8861
8861
|
headers: i,
|
|
8862
8862
|
compatibility: n,
|
|
8863
8863
|
fetch: e.fetch,
|
|
8864
8864
|
extraBody: e.extraBody
|
|
8865
|
-
}), l = (m, f = {}) => new
|
|
8865
|
+
}), l = (m, f = {}) => new Ap(m, f, {
|
|
8866
8866
|
provider: "openrouter.embedding",
|
|
8867
8867
|
url: ({ path: h }) => `${o}${h}`,
|
|
8868
8868
|
headers: i,
|
|
@@ -8880,42 +8880,42 @@ function Ms(e = {}) {
|
|
|
8880
8880
|
}, p = (m, f) => d(m, f);
|
|
8881
8881
|
return p.languageModel = d, p.chat = s, p.completion = u, p.textEmbeddingModel = l, p.embedding = l, p;
|
|
8882
8882
|
}
|
|
8883
|
-
|
|
8883
|
+
Ns({
|
|
8884
8884
|
compatibility: "strict"
|
|
8885
8885
|
// strict for OpenRouter API
|
|
8886
8886
|
});
|
|
8887
8887
|
let ia;
|
|
8888
8888
|
ia = globalThis.crypto;
|
|
8889
|
-
async function
|
|
8889
|
+
async function Mp(e) {
|
|
8890
8890
|
return (await ia).getRandomValues(new Uint8Array(e));
|
|
8891
8891
|
}
|
|
8892
|
-
async function
|
|
8892
|
+
async function Np(e) {
|
|
8893
8893
|
const t = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~", r = Math.pow(2, 8) - Math.pow(2, 8) % t.length;
|
|
8894
8894
|
let a = "";
|
|
8895
8895
|
for (; a.length < e; ) {
|
|
8896
|
-
const o = await
|
|
8896
|
+
const o = await Mp(e - a.length);
|
|
8897
8897
|
for (const n of o)
|
|
8898
8898
|
n < r && (a += t[n % t.length]);
|
|
8899
8899
|
}
|
|
8900
8900
|
return a;
|
|
8901
8901
|
}
|
|
8902
|
-
async function Np(e) {
|
|
8903
|
-
return await Mp(e);
|
|
8904
|
-
}
|
|
8905
8902
|
async function $p(e) {
|
|
8903
|
+
return await Np(e);
|
|
8904
|
+
}
|
|
8905
|
+
async function Up(e) {
|
|
8906
8906
|
const t = await (await ia).subtle.digest("SHA-256", new TextEncoder().encode(e));
|
|
8907
8907
|
return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g, "_").replace(/\+/g, "-").replace(/=/g, "");
|
|
8908
8908
|
}
|
|
8909
|
-
async function
|
|
8909
|
+
async function Dp(e) {
|
|
8910
8910
|
if (e || (e = 43), e < 43 || e > 128)
|
|
8911
8911
|
throw `Expected a length between 43 and 128. Received ${e}.`;
|
|
8912
|
-
const t = await
|
|
8912
|
+
const t = await $p(e), r = await Up(t);
|
|
8913
8913
|
return {
|
|
8914
8914
|
code_verifier: t,
|
|
8915
8915
|
code_challenge: r
|
|
8916
8916
|
};
|
|
8917
8917
|
}
|
|
8918
|
-
var
|
|
8918
|
+
var jp = "AI_MCPClientError", $s = `vercel.ai.error.${jp}`, qp = Symbol.for($s), gn, vn, H = class extends (vn = J, gn = qp, vn) {
|
|
8919
8919
|
constructor({
|
|
8920
8920
|
name: e = "MCPClientError",
|
|
8921
8921
|
message: t,
|
|
@@ -8926,23 +8926,23 @@ var Dp = "AI_MCPClientError", Ns = `vercel.ai.error.${Dp}`, jp = Symbol.for(Ns),
|
|
|
8926
8926
|
super({ name: e, message: t, cause: r }), this[gn] = !0, this.data = a, this.code = o;
|
|
8927
8927
|
}
|
|
8928
8928
|
static isInstance(e) {
|
|
8929
|
-
return J.hasMarker(e,
|
|
8929
|
+
return J.hasMarker(e, $s);
|
|
8930
8930
|
}
|
|
8931
|
-
}, Qe = "2025-06-18",
|
|
8931
|
+
}, Qe = "2025-06-18", Lp = [
|
|
8932
8932
|
Qe,
|
|
8933
8933
|
"2025-03-26",
|
|
8934
8934
|
"2024-11-05"
|
|
8935
|
-
],
|
|
8935
|
+
], Vp = ze({
|
|
8936
8936
|
name: c(),
|
|
8937
8937
|
version: c()
|
|
8938
8938
|
}), ar = ze({
|
|
8939
8939
|
_meta: $(v({}).loose())
|
|
8940
|
-
}), Pe = ar,
|
|
8940
|
+
}), Pe = ar, Us = v({
|
|
8941
8941
|
method: c(),
|
|
8942
8942
|
params: $(ar)
|
|
8943
|
-
}),
|
|
8943
|
+
}), Ds = v({
|
|
8944
8944
|
applyDefaults: $(_e())
|
|
8945
|
-
}).loose(),
|
|
8945
|
+
}).loose(), Fp = ze({
|
|
8946
8946
|
experimental: $(v({}).loose()),
|
|
8947
8947
|
logging: $(v({}).loose()),
|
|
8948
8948
|
prompts: $(
|
|
@@ -8961,44 +8961,44 @@ var Dp = "AI_MCPClientError", Ns = `vercel.ai.error.${Dp}`, jp = Symbol.for(Ns),
|
|
|
8961
8961
|
listChanged: $(_e())
|
|
8962
8962
|
})
|
|
8963
8963
|
),
|
|
8964
|
-
elicitation: $(
|
|
8964
|
+
elicitation: $(Ds)
|
|
8965
8965
|
});
|
|
8966
8966
|
v({
|
|
8967
|
-
elicitation: $(
|
|
8967
|
+
elicitation: $(Ds)
|
|
8968
8968
|
}).loose();
|
|
8969
|
-
var
|
|
8969
|
+
var Bp = Pe.extend({
|
|
8970
8970
|
protocolVersion: c(),
|
|
8971
|
-
capabilities:
|
|
8972
|
-
serverInfo:
|
|
8971
|
+
capabilities: Fp,
|
|
8972
|
+
serverInfo: Vp,
|
|
8973
8973
|
instructions: $(c())
|
|
8974
8974
|
}), la = Pe.extend({
|
|
8975
8975
|
nextCursor: $(c())
|
|
8976
|
-
}),
|
|
8976
|
+
}), Hp = v({
|
|
8977
8977
|
name: c(),
|
|
8978
8978
|
description: $(c()),
|
|
8979
8979
|
inputSchema: v({
|
|
8980
8980
|
type: C("object"),
|
|
8981
8981
|
properties: $(v({}).loose())
|
|
8982
8982
|
}).loose()
|
|
8983
|
-
}).loose(),
|
|
8984
|
-
tools: I(
|
|
8985
|
-
}),
|
|
8983
|
+
}).loose(), Gp = la.extend({
|
|
8984
|
+
tools: I(Hp)
|
|
8985
|
+
}), js = v({
|
|
8986
8986
|
type: C("text"),
|
|
8987
8987
|
text: c()
|
|
8988
|
-
}).loose(),
|
|
8988
|
+
}).loose(), qs = v({
|
|
8989
8989
|
type: C("image"),
|
|
8990
|
-
data:
|
|
8990
|
+
data: En(),
|
|
8991
8991
|
mimeType: c()
|
|
8992
|
-
}).loose(),
|
|
8992
|
+
}).loose(), Jp = v({
|
|
8993
8993
|
uri: c(),
|
|
8994
8994
|
name: c(),
|
|
8995
8995
|
title: $(c()),
|
|
8996
8996
|
description: $(c()),
|
|
8997
8997
|
mimeType: $(c()),
|
|
8998
8998
|
size: $(R())
|
|
8999
|
-
}).loose(),
|
|
9000
|
-
resources: I(
|
|
9001
|
-
}),
|
|
8999
|
+
}).loose(), Zp = la.extend({
|
|
9000
|
+
resources: I(Jp)
|
|
9001
|
+
}), Ls = v({
|
|
9002
9002
|
/**
|
|
9003
9003
|
* The URI of this resource.
|
|
9004
9004
|
*/
|
|
@@ -9015,76 +9015,76 @@ var Fp = Pe.extend({
|
|
|
9015
9015
|
* The MIME type of this resource, if known.
|
|
9016
9016
|
*/
|
|
9017
9017
|
mimeType: $(c())
|
|
9018
|
-
}).loose(),
|
|
9018
|
+
}).loose(), Vs = Ls.extend({
|
|
9019
9019
|
text: c()
|
|
9020
|
-
}),
|
|
9021
|
-
blob:
|
|
9022
|
-
}),
|
|
9020
|
+
}), Fs = Ls.extend({
|
|
9021
|
+
blob: En()
|
|
9022
|
+
}), Bs = v({
|
|
9023
9023
|
type: C("resource"),
|
|
9024
|
-
resource: D([
|
|
9025
|
-
}).loose(),
|
|
9024
|
+
resource: D([Vs, Fs])
|
|
9025
|
+
}).loose(), zp = Pe.extend({
|
|
9026
9026
|
content: I(
|
|
9027
|
-
D([
|
|
9027
|
+
D([js, qs, Bs])
|
|
9028
9028
|
),
|
|
9029
9029
|
isError: _e().default(!1).optional()
|
|
9030
9030
|
}).or(
|
|
9031
9031
|
Pe.extend({
|
|
9032
9032
|
toolResult: Re()
|
|
9033
9033
|
})
|
|
9034
|
-
),
|
|
9034
|
+
), Wp = v({
|
|
9035
9035
|
uriTemplate: c(),
|
|
9036
9036
|
name: c(),
|
|
9037
9037
|
title: $(c()),
|
|
9038
9038
|
description: $(c()),
|
|
9039
9039
|
mimeType: $(c())
|
|
9040
|
-
}).loose(),
|
|
9041
|
-
resourceTemplates: I(
|
|
9042
|
-
}),
|
|
9040
|
+
}).loose(), Kp = Pe.extend({
|
|
9041
|
+
resourceTemplates: I(Wp)
|
|
9042
|
+
}), Yp = Pe.extend({
|
|
9043
9043
|
contents: I(
|
|
9044
|
-
D([
|
|
9044
|
+
D([Vs, Fs])
|
|
9045
9045
|
)
|
|
9046
|
-
}),
|
|
9046
|
+
}), Xp = v({
|
|
9047
9047
|
name: c(),
|
|
9048
9048
|
description: $(c()),
|
|
9049
9049
|
required: $(_e())
|
|
9050
|
-
}).loose(),
|
|
9050
|
+
}).loose(), Qp = v({
|
|
9051
9051
|
name: c(),
|
|
9052
9052
|
title: $(c()),
|
|
9053
9053
|
description: $(c()),
|
|
9054
|
-
arguments: $(I(
|
|
9055
|
-
}).loose(),
|
|
9056
|
-
prompts: I(
|
|
9057
|
-
}),
|
|
9054
|
+
arguments: $(I(Xp))
|
|
9055
|
+
}).loose(), ef = la.extend({
|
|
9056
|
+
prompts: I(Qp)
|
|
9057
|
+
}), tf = v({
|
|
9058
9058
|
role: D([C("user"), C("assistant")]),
|
|
9059
9059
|
content: D([
|
|
9060
|
-
Ds,
|
|
9061
9060
|
js,
|
|
9062
|
-
|
|
9061
|
+
qs,
|
|
9062
|
+
Bs
|
|
9063
9063
|
])
|
|
9064
|
-
}).loose(),
|
|
9064
|
+
}).loose(), rf = Pe.extend({
|
|
9065
9065
|
description: $(c()),
|
|
9066
|
-
messages: I(
|
|
9067
|
-
}),
|
|
9066
|
+
messages: I(tf)
|
|
9067
|
+
}), af = ar.extend({
|
|
9068
9068
|
message: c(),
|
|
9069
9069
|
requestedSchema: Re()
|
|
9070
|
-
}), yn =
|
|
9070
|
+
}), yn = Us.extend({
|
|
9071
9071
|
method: C("elicitation/create"),
|
|
9072
|
-
params:
|
|
9073
|
-
}),
|
|
9072
|
+
params: af
|
|
9073
|
+
}), nf = Pe.extend({
|
|
9074
9074
|
action: D([
|
|
9075
9075
|
C("accept"),
|
|
9076
9076
|
C("decline"),
|
|
9077
9077
|
C("cancel")
|
|
9078
9078
|
]),
|
|
9079
9079
|
content: $(De(c(), Re()))
|
|
9080
|
-
}), nr = "2.0",
|
|
9080
|
+
}), nr = "2.0", of = v({
|
|
9081
9081
|
jsonrpc: C(nr),
|
|
9082
9082
|
id: D([c(), R().int()])
|
|
9083
|
-
}).merge(
|
|
9083
|
+
}).merge(Us).strict(), sf = v({
|
|
9084
9084
|
jsonrpc: C(nr),
|
|
9085
9085
|
id: D([c(), R().int()]),
|
|
9086
9086
|
result: Pe
|
|
9087
|
-
}).strict(),
|
|
9087
|
+
}).strict(), lf = v({
|
|
9088
9088
|
jsonrpc: C(nr),
|
|
9089
9089
|
id: D([c(), R().int()]),
|
|
9090
9090
|
error: v({
|
|
@@ -9092,7 +9092,7 @@ var Fp = Pe.extend({
|
|
|
9092
9092
|
message: c(),
|
|
9093
9093
|
data: $(Re())
|
|
9094
9094
|
})
|
|
9095
|
-
}).strict(),
|
|
9095
|
+
}).strict(), uf = v({
|
|
9096
9096
|
jsonrpc: C(nr)
|
|
9097
9097
|
}).merge(
|
|
9098
9098
|
v({
|
|
@@ -9100,11 +9100,11 @@ var Fp = Pe.extend({
|
|
|
9100
9100
|
params: $(ar)
|
|
9101
9101
|
})
|
|
9102
9102
|
).strict(), lt = D([
|
|
9103
|
-
nf,
|
|
9104
|
-
lf,
|
|
9105
9103
|
of,
|
|
9106
|
-
|
|
9107
|
-
|
|
9104
|
+
uf,
|
|
9105
|
+
sf,
|
|
9106
|
+
lf
|
|
9107
|
+
]), Hs = typeof __PACKAGE_VERSION__ < "u" ? __PACKAGE_VERSION__ : "0.0.0-test", Gs = v({
|
|
9108
9108
|
access_token: c(),
|
|
9109
9109
|
id_token: c().optional(),
|
|
9110
9110
|
// Optional for OAuth 2.1, but necessary in OpenID Connect
|
|
@@ -9115,17 +9115,17 @@ var Fp = Pe.extend({
|
|
|
9115
9115
|
}).strip(), ie = c().url().superRefine((e, t) => {
|
|
9116
9116
|
if (!URL.canParse(e))
|
|
9117
9117
|
return t.addIssue({
|
|
9118
|
-
code:
|
|
9118
|
+
code: fi.custom,
|
|
9119
9119
|
message: "URL must be parseable",
|
|
9120
9120
|
fatal: !0
|
|
9121
|
-
}),
|
|
9121
|
+
}), hi;
|
|
9122
9122
|
}).refine(
|
|
9123
9123
|
(e) => {
|
|
9124
9124
|
const t = new URL(e);
|
|
9125
9125
|
return t.protocol !== "javascript:" && t.protocol !== "data:" && t.protocol !== "vbscript:";
|
|
9126
9126
|
},
|
|
9127
9127
|
{ message: "URL cannot use javascript:, data:, or vbscript: scheme" }
|
|
9128
|
-
),
|
|
9128
|
+
), cf = v({
|
|
9129
9129
|
resource: c().url(),
|
|
9130
9130
|
authorization_servers: I(ie).optional(),
|
|
9131
9131
|
jwks_uri: c().url().optional(),
|
|
@@ -9140,7 +9140,7 @@ var Fp = Pe.extend({
|
|
|
9140
9140
|
authorization_details_types_supported: I(c()).optional(),
|
|
9141
9141
|
dpop_signing_alg_values_supported: I(c()).optional(),
|
|
9142
9142
|
dpop_bound_access_tokens_required: _e().optional()
|
|
9143
|
-
}).passthrough(),
|
|
9143
|
+
}).passthrough(), Js = v({
|
|
9144
9144
|
issuer: c(),
|
|
9145
9145
|
authorization_endpoint: ie,
|
|
9146
9146
|
token_endpoint: ie,
|
|
@@ -9151,7 +9151,7 @@ var Fp = Pe.extend({
|
|
|
9151
9151
|
code_challenge_methods_supported: I(c()),
|
|
9152
9152
|
token_endpoint_auth_methods_supported: I(c()).optional(),
|
|
9153
9153
|
token_endpoint_auth_signing_alg_values_supported: I(c()).optional()
|
|
9154
|
-
}).passthrough(),
|
|
9154
|
+
}).passthrough(), df = v({
|
|
9155
9155
|
issuer: c(),
|
|
9156
9156
|
authorization_endpoint: ie,
|
|
9157
9157
|
token_endpoint: ie,
|
|
@@ -9165,16 +9165,16 @@ var Fp = Pe.extend({
|
|
|
9165
9165
|
id_token_signing_alg_values_supported: I(c()),
|
|
9166
9166
|
claims_supported: I(c()).optional(),
|
|
9167
9167
|
token_endpoint_auth_methods_supported: I(c()).optional()
|
|
9168
|
-
}).passthrough(),
|
|
9169
|
-
|
|
9168
|
+
}).passthrough(), pf = df.merge(
|
|
9169
|
+
Js.pick({
|
|
9170
9170
|
code_challenge_methods_supported: !0
|
|
9171
9171
|
})
|
|
9172
|
-
),
|
|
9172
|
+
), ff = v({
|
|
9173
9173
|
client_id: c(),
|
|
9174
9174
|
client_secret: c().optional(),
|
|
9175
9175
|
client_id_issued_at: R().optional(),
|
|
9176
9176
|
client_secret_expires_at: R().optional()
|
|
9177
|
-
}).strip(),
|
|
9177
|
+
}).strip(), hf = v({
|
|
9178
9178
|
redirect_uris: I(ie),
|
|
9179
9179
|
token_endpoint_auth_method: c().optional(),
|
|
9180
9180
|
grant_types: I(c()).optional(),
|
|
@@ -9191,13 +9191,13 @@ var Fp = Pe.extend({
|
|
|
9191
9191
|
software_id: c().optional(),
|
|
9192
9192
|
software_version: c().optional(),
|
|
9193
9193
|
software_statement: c().optional()
|
|
9194
|
-
}).strip(),
|
|
9194
|
+
}).strip(), mf = v({
|
|
9195
9195
|
error: c(),
|
|
9196
9196
|
error_description: c().optional(),
|
|
9197
9197
|
error_uri: c().optional()
|
|
9198
|
-
}),
|
|
9199
|
-
|
|
9200
|
-
),
|
|
9198
|
+
}), gf = hf.merge(
|
|
9199
|
+
ff
|
|
9200
|
+
), vf = "AI_MCPClientOAuthError", Zs = `vercel.ai.error.${vf}`, yf = Symbol.for(Zs), _n, wn, St = class extends (wn = J, _n = yf, wn) {
|
|
9201
9201
|
constructor({
|
|
9202
9202
|
name: e = "MCPClientOAuthError",
|
|
9203
9203
|
message: t,
|
|
@@ -9206,7 +9206,7 @@ var Fp = Pe.extend({
|
|
|
9206
9206
|
super({ name: e, message: t, cause: r }), this[_n] = !0;
|
|
9207
9207
|
}
|
|
9208
9208
|
static isInstance(e) {
|
|
9209
|
-
return J.hasMarker(e,
|
|
9209
|
+
return J.hasMarker(e, Zs);
|
|
9210
9210
|
}
|
|
9211
9211
|
}, Ye = class extends St {
|
|
9212
9212
|
};
|
|
@@ -9220,17 +9220,17 @@ Gt.errorCode = "invalid_grant";
|
|
|
9220
9220
|
var Jt = class extends St {
|
|
9221
9221
|
};
|
|
9222
9222
|
Jt.errorCode = "unauthorized_client";
|
|
9223
|
-
var
|
|
9223
|
+
var _f = {
|
|
9224
9224
|
[Ye.errorCode]: Ye,
|
|
9225
9225
|
[Ht.errorCode]: Ht,
|
|
9226
9226
|
[Gt.errorCode]: Gt,
|
|
9227
9227
|
[Jt.errorCode]: Jt
|
|
9228
9228
|
};
|
|
9229
|
-
function
|
|
9229
|
+
function wf(e) {
|
|
9230
9230
|
const t = typeof e == "string" ? new URL(e) : new URL(e.href);
|
|
9231
9231
|
return t.hash = "", t;
|
|
9232
9232
|
}
|
|
9233
|
-
function
|
|
9233
|
+
function bf({
|
|
9234
9234
|
requestedResource: e,
|
|
9235
9235
|
configuredResource: t
|
|
9236
9236
|
}) {
|
|
@@ -9261,7 +9261,7 @@ function zt(e) {
|
|
|
9261
9261
|
return;
|
|
9262
9262
|
}
|
|
9263
9263
|
}
|
|
9264
|
-
function
|
|
9264
|
+
function Tf(e, t = "", r = {}) {
|
|
9265
9265
|
return t.endsWith("/") && (t = t.slice(0, -1)), r.prependPathname ? `${t}/.well-known/${e}` : `/.well-known/${e}${t}`;
|
|
9266
9266
|
}
|
|
9267
9267
|
async function ua(e, t, r = fetch) {
|
|
@@ -9278,28 +9278,28 @@ async function bn(e, t, r = fetch) {
|
|
|
9278
9278
|
"MCP-Protocol-Version": t
|
|
9279
9279
|
}, r);
|
|
9280
9280
|
}
|
|
9281
|
-
function
|
|
9281
|
+
function If(e, t) {
|
|
9282
9282
|
return !e || e.status >= 400 && e.status < 500 && t !== "/";
|
|
9283
9283
|
}
|
|
9284
|
-
async function
|
|
9284
|
+
async function Sf(e, t, r, a) {
|
|
9285
9285
|
var o, n;
|
|
9286
9286
|
const i = new URL(e), s = (o = a?.protocolVersion) != null ? o : Qe;
|
|
9287
9287
|
let u;
|
|
9288
9288
|
if (a?.metadataUrl)
|
|
9289
9289
|
u = new URL(a.metadataUrl);
|
|
9290
9290
|
else {
|
|
9291
|
-
const d =
|
|
9291
|
+
const d = Tf(t, i.pathname);
|
|
9292
9292
|
u = new URL(d, (n = a?.metadataServerUrl) != null ? n : i), u.search = i.search;
|
|
9293
9293
|
}
|
|
9294
9294
|
let l = await bn(u, s, r);
|
|
9295
|
-
if (!a?.metadataUrl &&
|
|
9295
|
+
if (!a?.metadataUrl && If(l, i.pathname)) {
|
|
9296
9296
|
const d = new URL(`/.well-known/${t}`, i);
|
|
9297
9297
|
l = await bn(d, s, r);
|
|
9298
9298
|
}
|
|
9299
9299
|
return l;
|
|
9300
9300
|
}
|
|
9301
|
-
async function
|
|
9302
|
-
const a = await
|
|
9301
|
+
async function Ef(e, t, r = fetch) {
|
|
9302
|
+
const a = await Sf(
|
|
9303
9303
|
e,
|
|
9304
9304
|
"oauth-protected-resource",
|
|
9305
9305
|
r,
|
|
@@ -9316,9 +9316,9 @@ async function Sf(e, t, r = fetch) {
|
|
|
9316
9316
|
throw new Error(
|
|
9317
9317
|
`HTTP ${a.status} trying to load well-known OAuth protected resource metadata.`
|
|
9318
9318
|
);
|
|
9319
|
-
return
|
|
9319
|
+
return cf.parse(await a.json());
|
|
9320
9320
|
}
|
|
9321
|
-
function
|
|
9321
|
+
function xf(e) {
|
|
9322
9322
|
const t = typeof e == "string" ? new URL(e) : e, r = t.pathname !== "/", a = [];
|
|
9323
9323
|
if (!r)
|
|
9324
9324
|
return a.push({
|
|
@@ -9346,12 +9346,12 @@ function Ef(e) {
|
|
|
9346
9346
|
type: "oidc"
|
|
9347
9347
|
}), a;
|
|
9348
9348
|
}
|
|
9349
|
-
async function
|
|
9349
|
+
async function Rf(e, {
|
|
9350
9350
|
fetchFn: t = fetch,
|
|
9351
9351
|
protocolVersion: r = Qe
|
|
9352
9352
|
} = {}) {
|
|
9353
9353
|
var a;
|
|
9354
|
-
const o = { "MCP-Protocol-Version": r }, n =
|
|
9354
|
+
const o = { "MCP-Protocol-Version": r }, n = xf(e);
|
|
9355
9355
|
for (const { url: i, type: s } of n) {
|
|
9356
9356
|
const u = await ua(i, o, t);
|
|
9357
9357
|
if (u) {
|
|
@@ -9363,9 +9363,9 @@ async function xf(e, {
|
|
|
9363
9363
|
);
|
|
9364
9364
|
}
|
|
9365
9365
|
if (s === "oauth")
|
|
9366
|
-
return
|
|
9366
|
+
return Js.parse(await u.json());
|
|
9367
9367
|
{
|
|
9368
|
-
const l =
|
|
9368
|
+
const l = pf.parse(
|
|
9369
9369
|
await u.json()
|
|
9370
9370
|
);
|
|
9371
9371
|
if (!((a = l.code_challenge_methods_supported) != null && a.includes("S256")))
|
|
@@ -9377,7 +9377,7 @@ async function xf(e, {
|
|
|
9377
9377
|
}
|
|
9378
9378
|
}
|
|
9379
9379
|
}
|
|
9380
|
-
async function
|
|
9380
|
+
async function Cf(e, {
|
|
9381
9381
|
metadata: t,
|
|
9382
9382
|
clientInformation: r,
|
|
9383
9383
|
redirectUrl: a,
|
|
@@ -9398,33 +9398,33 @@ async function Rf(e, {
|
|
|
9398
9398
|
);
|
|
9399
9399
|
} else
|
|
9400
9400
|
l = new URL("/authorize", e);
|
|
9401
|
-
const d = await
|
|
9401
|
+
const d = await Dp(), p = d.code_verifier, m = d.code_challenge;
|
|
9402
9402
|
return l.searchParams.set("response_type", s), l.searchParams.set("client_id", r.client_id), l.searchParams.set("code_challenge", m), l.searchParams.set(
|
|
9403
9403
|
"code_challenge_method",
|
|
9404
9404
|
u
|
|
9405
9405
|
), l.searchParams.set("redirect_uri", String(a)), n && l.searchParams.set("state", n), o && l.searchParams.set("scope", o), o?.includes("offline_access") && l.searchParams.append("prompt", "consent"), i && l.searchParams.set("resource", i.href), { authorizationUrl: l, codeVerifier: p };
|
|
9406
9406
|
}
|
|
9407
|
-
function
|
|
9407
|
+
function zs(e, t) {
|
|
9408
9408
|
const r = e.client_secret !== void 0;
|
|
9409
9409
|
return t.length === 0 ? r ? "client_secret_post" : "none" : r && t.includes("client_secret_basic") ? "client_secret_basic" : r && t.includes("client_secret_post") ? "client_secret_post" : t.includes("none") ? "none" : r ? "client_secret_post" : "none";
|
|
9410
9410
|
}
|
|
9411
|
-
function
|
|
9411
|
+
function Ws(e, t, r, a) {
|
|
9412
9412
|
const { client_id: o, client_secret: n } = t;
|
|
9413
9413
|
switch (e) {
|
|
9414
9414
|
case "client_secret_basic":
|
|
9415
|
-
|
|
9415
|
+
Af(o, n, r);
|
|
9416
9416
|
return;
|
|
9417
9417
|
case "client_secret_post":
|
|
9418
|
-
|
|
9418
|
+
kf(o, n, a);
|
|
9419
9419
|
return;
|
|
9420
9420
|
case "none":
|
|
9421
|
-
|
|
9421
|
+
Of(o, a);
|
|
9422
9422
|
return;
|
|
9423
9423
|
default:
|
|
9424
9424
|
throw new Error(`Unsupported client authentication method: ${e}`);
|
|
9425
9425
|
}
|
|
9426
9426
|
}
|
|
9427
|
-
function
|
|
9427
|
+
function Af(e, t, r) {
|
|
9428
9428
|
if (!t)
|
|
9429
9429
|
throw new Error(
|
|
9430
9430
|
"client_secret_basic authentication requires a client_secret"
|
|
@@ -9432,16 +9432,16 @@ function Cf(e, t, r) {
|
|
|
9432
9432
|
const a = btoa(`${e}:${t}`);
|
|
9433
9433
|
r.set("Authorization", `Basic ${a}`);
|
|
9434
9434
|
}
|
|
9435
|
-
function
|
|
9435
|
+
function kf(e, t, r) {
|
|
9436
9436
|
r.set("client_id", e), t && r.set("client_secret", t);
|
|
9437
9437
|
}
|
|
9438
|
-
function
|
|
9438
|
+
function Of(e, t) {
|
|
9439
9439
|
t.set("client_id", e);
|
|
9440
9440
|
}
|
|
9441
9441
|
async function ca(e) {
|
|
9442
9442
|
const t = e instanceof Response ? e.status : void 0, r = e instanceof Response ? await e.text() : e;
|
|
9443
9443
|
try {
|
|
9444
|
-
const a =
|
|
9444
|
+
const a = mf.parse(JSON.parse(r)), { error: o, error_description: n, error_uri: i } = a, s = _f[o] || Ye;
|
|
9445
9445
|
return new s({
|
|
9446
9446
|
message: n || "",
|
|
9447
9447
|
cause: i
|
|
@@ -9451,7 +9451,7 @@ async function ca(e) {
|
|
|
9451
9451
|
return new Ye({ message: o });
|
|
9452
9452
|
}
|
|
9453
9453
|
}
|
|
9454
|
-
async function
|
|
9454
|
+
async function Pf(e, {
|
|
9455
9455
|
metadata: t,
|
|
9456
9456
|
clientInformation: r,
|
|
9457
9457
|
authorizationCode: a,
|
|
@@ -9479,11 +9479,11 @@ async function Of(e, {
|
|
|
9479
9479
|
if (s)
|
|
9480
9480
|
s(m, f, e, t);
|
|
9481
9481
|
else {
|
|
9482
|
-
const y = (l = t?.token_endpoint_auth_methods_supported) != null ? l : [], w =
|
|
9482
|
+
const y = (l = t?.token_endpoint_auth_methods_supported) != null ? l : [], w = zs(
|
|
9483
9483
|
r,
|
|
9484
9484
|
y
|
|
9485
9485
|
);
|
|
9486
|
-
|
|
9486
|
+
Ws(w, r, m, f);
|
|
9487
9487
|
}
|
|
9488
9488
|
i && f.set("resource", i.href);
|
|
9489
9489
|
const h = await (u ?? fetch)(p, {
|
|
@@ -9493,9 +9493,9 @@ async function Of(e, {
|
|
|
9493
9493
|
});
|
|
9494
9494
|
if (!h.ok)
|
|
9495
9495
|
throw await ca(h);
|
|
9496
|
-
return
|
|
9496
|
+
return Gs.parse(await h.json());
|
|
9497
9497
|
}
|
|
9498
|
-
async function
|
|
9498
|
+
async function Mf(e, {
|
|
9499
9499
|
metadata: t,
|
|
9500
9500
|
clientInformation: r,
|
|
9501
9501
|
refreshToken: a,
|
|
@@ -9522,11 +9522,11 @@ async function Pf(e, {
|
|
|
9522
9522
|
if (n)
|
|
9523
9523
|
n(d, p, e, t);
|
|
9524
9524
|
else {
|
|
9525
|
-
const f = (s = t?.token_endpoint_auth_methods_supported) != null ? s : [], h =
|
|
9525
|
+
const f = (s = t?.token_endpoint_auth_methods_supported) != null ? s : [], h = zs(
|
|
9526
9526
|
r,
|
|
9527
9527
|
f
|
|
9528
9528
|
);
|
|
9529
|
-
|
|
9529
|
+
Ws(h, r, d, p);
|
|
9530
9530
|
}
|
|
9531
9531
|
o && p.set("resource", o.href);
|
|
9532
9532
|
const m = await (i ?? fetch)(l, {
|
|
@@ -9536,12 +9536,12 @@ async function Pf(e, {
|
|
|
9536
9536
|
});
|
|
9537
9537
|
if (!m.ok)
|
|
9538
9538
|
throw await ca(m);
|
|
9539
|
-
return
|
|
9539
|
+
return Gs.parse({
|
|
9540
9540
|
refresh_token: a,
|
|
9541
9541
|
...await m.json()
|
|
9542
9542
|
});
|
|
9543
9543
|
}
|
|
9544
|
-
async function
|
|
9544
|
+
async function Nf(e, {
|
|
9545
9545
|
metadata: t,
|
|
9546
9546
|
clientMetadata: r,
|
|
9547
9547
|
fetchFn: a
|
|
@@ -9564,7 +9564,7 @@ async function Mf(e, {
|
|
|
9564
9564
|
});
|
|
9565
9565
|
if (!n.ok)
|
|
9566
9566
|
throw await ca(n);
|
|
9567
|
-
return
|
|
9567
|
+
return gf.parse(await n.json());
|
|
9568
9568
|
}
|
|
9569
9569
|
async function Wt(e, t) {
|
|
9570
9570
|
var r, a;
|
|
@@ -9578,15 +9578,15 @@ async function Wt(e, t) {
|
|
|
9578
9578
|
throw o;
|
|
9579
9579
|
}
|
|
9580
9580
|
}
|
|
9581
|
-
async function
|
|
9582
|
-
const a =
|
|
9581
|
+
async function $f(e, t, r) {
|
|
9582
|
+
const a = wf(e);
|
|
9583
9583
|
if (t.validateResourceURL)
|
|
9584
9584
|
return await t.validateResourceURL(
|
|
9585
9585
|
a,
|
|
9586
9586
|
r?.resource
|
|
9587
9587
|
);
|
|
9588
9588
|
if (r) {
|
|
9589
|
-
if (!
|
|
9589
|
+
if (!bf({
|
|
9590
9590
|
requestedResource: a,
|
|
9591
9591
|
configuredResource: r.resource
|
|
9592
9592
|
}))
|
|
@@ -9605,7 +9605,7 @@ async function Ar(e, {
|
|
|
9605
9605
|
}) {
|
|
9606
9606
|
let i, s;
|
|
9607
9607
|
try {
|
|
9608
|
-
i = await
|
|
9608
|
+
i = await Ef(
|
|
9609
9609
|
t,
|
|
9610
9610
|
{ resourceMetadataUrl: o },
|
|
9611
9611
|
n
|
|
@@ -9613,11 +9613,11 @@ async function Ar(e, {
|
|
|
9613
9613
|
} catch {
|
|
9614
9614
|
}
|
|
9615
9615
|
s || (s = t);
|
|
9616
|
-
const u = await
|
|
9616
|
+
const u = await $f(
|
|
9617
9617
|
t,
|
|
9618
9618
|
e,
|
|
9619
9619
|
i
|
|
9620
|
-
), l = await
|
|
9620
|
+
), l = await Rf(
|
|
9621
9621
|
s,
|
|
9622
9622
|
{
|
|
9623
9623
|
fetchFn: n
|
|
@@ -9633,7 +9633,7 @@ async function Ar(e, {
|
|
|
9633
9633
|
throw new Error(
|
|
9634
9634
|
"OAuth client information must be saveable for dynamic registration"
|
|
9635
9635
|
);
|
|
9636
|
-
const y = await
|
|
9636
|
+
const y = await Nf(s, {
|
|
9637
9637
|
metadata: l,
|
|
9638
9638
|
clientMetadata: e.clientMetadata,
|
|
9639
9639
|
fetchFn: n
|
|
@@ -9641,7 +9641,7 @@ async function Ar(e, {
|
|
|
9641
9641
|
await e.saveClientInformation(y), d = y;
|
|
9642
9642
|
}
|
|
9643
9643
|
if (r !== void 0) {
|
|
9644
|
-
const y = await e.codeVerifier(), w = await
|
|
9644
|
+
const y = await e.codeVerifier(), w = await Pf(s, {
|
|
9645
9645
|
metadata: l,
|
|
9646
9646
|
clientInformation: d,
|
|
9647
9647
|
authorizationCode: r,
|
|
@@ -9656,7 +9656,7 @@ async function Ar(e, {
|
|
|
9656
9656
|
const p = await e.tokens();
|
|
9657
9657
|
if (p?.refresh_token)
|
|
9658
9658
|
try {
|
|
9659
|
-
const y = await
|
|
9659
|
+
const y = await Mf(s, {
|
|
9660
9660
|
metadata: l,
|
|
9661
9661
|
clientInformation: d,
|
|
9662
9662
|
refreshToken: p.refresh_token,
|
|
@@ -9671,7 +9671,7 @@ async function Ar(e, {
|
|
|
9671
9671
|
!(!(y instanceof St) || y instanceof Ye)
|
|
9672
9672
|
) throw y;
|
|
9673
9673
|
}
|
|
9674
|
-
const m = e.state ? await e.state() : void 0, { authorizationUrl: f, codeVerifier: h } = await
|
|
9674
|
+
const m = e.state ? await e.state() : void 0, { authorizationUrl: f, codeVerifier: h } = await Cf(
|
|
9675
9675
|
s,
|
|
9676
9676
|
{
|
|
9677
9677
|
metadata: l,
|
|
@@ -9684,7 +9684,7 @@ async function Ar(e, {
|
|
|
9684
9684
|
);
|
|
9685
9685
|
return await e.saveCodeVerifier(h), await e.redirectToAuthorization(f), "REDIRECT";
|
|
9686
9686
|
}
|
|
9687
|
-
var
|
|
9687
|
+
var Uf = class {
|
|
9688
9688
|
constructor({
|
|
9689
9689
|
url: e,
|
|
9690
9690
|
headers: t,
|
|
@@ -9702,10 +9702,10 @@ var $f = class {
|
|
|
9702
9702
|
const r = await this.authProvider.tokens();
|
|
9703
9703
|
r?.access_token && (t.Authorization = `Bearer ${r.access_token}`);
|
|
9704
9704
|
}
|
|
9705
|
-
return
|
|
9705
|
+
return In(
|
|
9706
9706
|
t,
|
|
9707
|
-
`ai-sdk/${
|
|
9708
|
-
|
|
9707
|
+
`ai-sdk/${Hs}`,
|
|
9708
|
+
Sn()
|
|
9709
9709
|
);
|
|
9710
9710
|
}
|
|
9711
9711
|
async start() {
|
|
@@ -9847,7 +9847,7 @@ var $f = class {
|
|
|
9847
9847
|
};
|
|
9848
9848
|
await r();
|
|
9849
9849
|
}
|
|
9850
|
-
},
|
|
9850
|
+
}, Df = class {
|
|
9851
9851
|
constructor({
|
|
9852
9852
|
url: e,
|
|
9853
9853
|
headers: t,
|
|
@@ -9870,10 +9870,10 @@ var $f = class {
|
|
|
9870
9870
|
const r = await this.authProvider.tokens();
|
|
9871
9871
|
r?.access_token && (t.Authorization = `Bearer ${r.access_token}`);
|
|
9872
9872
|
}
|
|
9873
|
-
return
|
|
9873
|
+
return In(
|
|
9874
9874
|
t,
|
|
9875
|
-
`ai-sdk/${
|
|
9876
|
-
|
|
9875
|
+
`ai-sdk/${Hs}`,
|
|
9876
|
+
Sn()
|
|
9877
9877
|
);
|
|
9878
9878
|
}
|
|
9879
9879
|
async start() {
|
|
@@ -10093,35 +10093,35 @@ var $f = class {
|
|
|
10093
10093
|
}
|
|
10094
10094
|
}
|
|
10095
10095
|
};
|
|
10096
|
-
function
|
|
10096
|
+
function jf(e) {
|
|
10097
10097
|
switch (e.type) {
|
|
10098
10098
|
case "sse":
|
|
10099
|
-
return new $f(e);
|
|
10100
|
-
case "http":
|
|
10101
10099
|
return new Uf(e);
|
|
10100
|
+
case "http":
|
|
10101
|
+
return new Df(e);
|
|
10102
10102
|
default:
|
|
10103
10103
|
throw new H({
|
|
10104
10104
|
message: "Unsupported or invalid transport configuration. If you are using a custom transport, make sure it implements the MCPTransport interface."
|
|
10105
10105
|
});
|
|
10106
10106
|
}
|
|
10107
10107
|
}
|
|
10108
|
-
function
|
|
10108
|
+
function qf(e) {
|
|
10109
10109
|
return "start" in e && typeof e.start == "function" && "send" in e && typeof e.send == "function" && "close" in e && typeof e.close == "function";
|
|
10110
10110
|
}
|
|
10111
|
-
var
|
|
10112
|
-
async function
|
|
10113
|
-
const t = new
|
|
10111
|
+
var Lf = "1.0.0";
|
|
10112
|
+
async function Vf(e) {
|
|
10113
|
+
const t = new Ff(e);
|
|
10114
10114
|
return await t.init(), t;
|
|
10115
10115
|
}
|
|
10116
|
-
var
|
|
10116
|
+
var Ff = class {
|
|
10117
10117
|
constructor({
|
|
10118
10118
|
transport: e,
|
|
10119
10119
|
name: t = "ai-sdk-mcp-client",
|
|
10120
|
-
version: r =
|
|
10120
|
+
version: r = Lf,
|
|
10121
10121
|
onUncaughtError: a,
|
|
10122
10122
|
capabilities: o
|
|
10123
10123
|
}) {
|
|
10124
|
-
this.requestMessageId = 0, this.responseHandlers = /* @__PURE__ */ new Map(), this.serverCapabilities = {}, this.isClosed = !0, this.onUncaughtError = a, this.clientCapabilities = o ?? {},
|
|
10124
|
+
this.requestMessageId = 0, this.responseHandlers = /* @__PURE__ */ new Map(), this.serverCapabilities = {}, this.isClosed = !0, this.onUncaughtError = a, this.clientCapabilities = o ?? {}, qf(e) ? this.transport = e : this.transport = jf(e), this.transport.onclose = () => this.onClose(), this.transport.onerror = (n) => this.onError(n), this.transport.onmessage = (n) => {
|
|
10125
10125
|
if ("method" in n) {
|
|
10126
10126
|
"id" in n ? this.onRequestMessage(n) : this.onError(
|
|
10127
10127
|
new H({
|
|
@@ -10148,13 +10148,13 @@ var Vf = class {
|
|
|
10148
10148
|
clientInfo: this.clientInfo
|
|
10149
10149
|
}
|
|
10150
10150
|
},
|
|
10151
|
-
resultSchema:
|
|
10151
|
+
resultSchema: Bp
|
|
10152
10152
|
});
|
|
10153
10153
|
if (e === void 0)
|
|
10154
10154
|
throw new H({
|
|
10155
10155
|
message: "Server sent invalid initialize result"
|
|
10156
10156
|
});
|
|
10157
|
-
if (!
|
|
10157
|
+
if (!Lp.includes(e.protocolVersion))
|
|
10158
10158
|
throw new H({
|
|
10159
10159
|
message: `Server's protocol version is not supported: ${e.protocolVersion}`
|
|
10160
10160
|
});
|
|
@@ -10255,7 +10255,7 @@ var Vf = class {
|
|
|
10255
10255
|
try {
|
|
10256
10256
|
return this.request({
|
|
10257
10257
|
request: { method: "tools/list", params: e },
|
|
10258
|
-
resultSchema:
|
|
10258
|
+
resultSchema: Gp,
|
|
10259
10259
|
options: t
|
|
10260
10260
|
});
|
|
10261
10261
|
} catch (r) {
|
|
@@ -10270,7 +10270,7 @@ var Vf = class {
|
|
|
10270
10270
|
try {
|
|
10271
10271
|
return this.request({
|
|
10272
10272
|
request: { method: "tools/call", params: { name: e, arguments: t } },
|
|
10273
|
-
resultSchema:
|
|
10273
|
+
resultSchema: zp,
|
|
10274
10274
|
options: {
|
|
10275
10275
|
signal: r?.abortSignal
|
|
10276
10276
|
}
|
|
@@ -10286,7 +10286,7 @@ var Vf = class {
|
|
|
10286
10286
|
try {
|
|
10287
10287
|
return this.request({
|
|
10288
10288
|
request: { method: "resources/list", params: e },
|
|
10289
|
-
resultSchema:
|
|
10289
|
+
resultSchema: Zp,
|
|
10290
10290
|
options: t
|
|
10291
10291
|
});
|
|
10292
10292
|
} catch (r) {
|
|
@@ -10300,7 +10300,7 @@ var Vf = class {
|
|
|
10300
10300
|
try {
|
|
10301
10301
|
return this.request({
|
|
10302
10302
|
request: { method: "resources/read", params: { uri: e } },
|
|
10303
|
-
resultSchema:
|
|
10303
|
+
resultSchema: Yp,
|
|
10304
10304
|
options: t
|
|
10305
10305
|
});
|
|
10306
10306
|
} catch (r) {
|
|
@@ -10313,7 +10313,7 @@ var Vf = class {
|
|
|
10313
10313
|
try {
|
|
10314
10314
|
return this.request({
|
|
10315
10315
|
request: { method: "resources/templates/list" },
|
|
10316
|
-
resultSchema:
|
|
10316
|
+
resultSchema: Kp,
|
|
10317
10317
|
options: e
|
|
10318
10318
|
});
|
|
10319
10319
|
} catch (t) {
|
|
@@ -10327,7 +10327,7 @@ var Vf = class {
|
|
|
10327
10327
|
try {
|
|
10328
10328
|
return this.request({
|
|
10329
10329
|
request: { method: "prompts/list", params: e },
|
|
10330
|
-
resultSchema:
|
|
10330
|
+
resultSchema: ef,
|
|
10331
10331
|
options: t
|
|
10332
10332
|
});
|
|
10333
10333
|
} catch (r) {
|
|
@@ -10342,7 +10342,7 @@ var Vf = class {
|
|
|
10342
10342
|
try {
|
|
10343
10343
|
return this.request({
|
|
10344
10344
|
request: { method: "prompts/get", params: { name: e, arguments: t } },
|
|
10345
|
-
resultSchema:
|
|
10345
|
+
resultSchema: rf,
|
|
10346
10346
|
options: r
|
|
10347
10347
|
});
|
|
10348
10348
|
} catch (a) {
|
|
@@ -10373,15 +10373,15 @@ var Vf = class {
|
|
|
10373
10373
|
const s = this, u = async (d, p) => {
|
|
10374
10374
|
var m;
|
|
10375
10375
|
return (m = p?.abortSignal) == null || m.throwIfAborted(), s.callTool({ name: o, args: d, options: p });
|
|
10376
|
-
}, l = e === "automatic" ?
|
|
10376
|
+
}, l = e === "automatic" ? ci({
|
|
10377
10377
|
description: n,
|
|
10378
|
-
inputSchema:
|
|
10378
|
+
inputSchema: di({
|
|
10379
10379
|
...i,
|
|
10380
10380
|
properties: (t = i.properties) != null ? t : {},
|
|
10381
10381
|
additionalProperties: !1
|
|
10382
10382
|
}),
|
|
10383
10383
|
execute: u
|
|
10384
|
-
}) :
|
|
10384
|
+
}) : pi({
|
|
10385
10385
|
description: n,
|
|
10386
10386
|
inputSchema: e[o].inputSchema,
|
|
10387
10387
|
execute: u
|
|
@@ -10471,7 +10471,7 @@ var Vf = class {
|
|
|
10471
10471
|
return;
|
|
10472
10472
|
}
|
|
10473
10473
|
try {
|
|
10474
|
-
const r = await this.elicitationRequestHandler(t.data), a =
|
|
10474
|
+
const r = await this.elicitationRequestHandler(t.data), a = nf.parse(r);
|
|
10475
10475
|
await this.transport.send({
|
|
10476
10476
|
jsonrpc: "2.0",
|
|
10477
10477
|
id: e.id,
|
|
@@ -10522,27 +10522,32 @@ var Vf = class {
|
|
|
10522
10522
|
);
|
|
10523
10523
|
}
|
|
10524
10524
|
};
|
|
10525
|
-
const
|
|
10526
|
-
chat:
|
|
10527
|
-
}),
|
|
10525
|
+
const Bf = "https://app.getgram.ai", Wf = () => ({
|
|
10526
|
+
chat: Gf
|
|
10527
|
+
}), Hf = v({
|
|
10528
10528
|
// currently only supports serverURL, however we will support other config shapes for this via a union type in the future
|
|
10529
10529
|
mcp: D([c()]),
|
|
10530
10530
|
environment: De(c(), Re()).optional(),
|
|
10531
10531
|
projectSlug: c(),
|
|
10532
|
-
model: Kt(
|
|
10533
|
-
}),
|
|
10532
|
+
model: Kt(mi)
|
|
10533
|
+
}), Gf = async (e, t) => {
|
|
10534
10534
|
if (e.method === "POST")
|
|
10535
10535
|
try {
|
|
10536
10536
|
const r = [];
|
|
10537
10537
|
for await (const p of e)
|
|
10538
10538
|
r.push(p);
|
|
10539
|
-
const a = Buffer.concat(r).toString(), { messages: o, config: n } = JSON.parse(a), i =
|
|
10539
|
+
const a = Buffer.concat(r).toString(), { messages: o, config: n } = JSON.parse(a), i = Hf.parse(n), u = await (await Vf({
|
|
10540
10540
|
transport: {
|
|
10541
10541
|
type: "http",
|
|
10542
|
-
url: i.mcp
|
|
10542
|
+
url: i.mcp,
|
|
10543
|
+
headers: {
|
|
10544
|
+
...Jf(i.environment ?? {}),
|
|
10545
|
+
// Always send the Gram-Key header last so that it isn't clobbered by the environment variables.
|
|
10546
|
+
Authorization: `Bearer ${process.env.GRAM_API_KEY ?? ""}`
|
|
10547
|
+
}
|
|
10543
10548
|
}
|
|
10544
|
-
})).tools(), l =
|
|
10545
|
-
baseURL:
|
|
10549
|
+
})).tools(), l = Ns({
|
|
10550
|
+
baseURL: Bf,
|
|
10546
10551
|
// We do not use the apiKey field as the requests are proxied through the Gram API.
|
|
10547
10552
|
// Instead we use the Gram-Key header to authenticate the request.
|
|
10548
10553
|
apiKey: "must be set",
|
|
@@ -10550,9 +10555,9 @@ const Ff = "https://app.getgram.ai", Zf = () => ({
|
|
|
10550
10555
|
"Gram-Project": i.projectSlug,
|
|
10551
10556
|
"Gram-Key": process.env.GRAM_API_KEY ?? ""
|
|
10552
10557
|
}
|
|
10553
|
-
}), d =
|
|
10558
|
+
}), d = fd({
|
|
10554
10559
|
model: l.chat(i.model),
|
|
10555
|
-
messages:
|
|
10560
|
+
messages: gd(o),
|
|
10556
10561
|
tools: u
|
|
10557
10562
|
});
|
|
10558
10563
|
t.setHeader("Content-Type", "text/event-stream"), t.setHeader("Cache-Control", "no-cache"), t.setHeader("Connection", "keep-alive"), t.setHeader("Transfer-Encoding", "chunked"), t.statusCode = 200, d.pipeUIMessageStreamToResponse(t, {
|
|
@@ -10566,7 +10571,16 @@ const Ff = "https://app.getgram.ai", Zf = () => ({
|
|
|
10566
10571
|
})
|
|
10567
10572
|
);
|
|
10568
10573
|
}
|
|
10569
|
-
};
|
|
10574
|
+
}, Tn = "MCP-";
|
|
10575
|
+
function Jf(e) {
|
|
10576
|
+
return typeof e != "object" || e === null ? {} : Object.entries(e).reduce(
|
|
10577
|
+
(t, [r, a]) => {
|
|
10578
|
+
const o = r.replace(/_/g, "-"), n = o.startsWith(Tn) ? o : `${Tn}${o}`;
|
|
10579
|
+
return t[n] = a, t;
|
|
10580
|
+
},
|
|
10581
|
+
{}
|
|
10582
|
+
);
|
|
10583
|
+
}
|
|
10570
10584
|
export {
|
|
10571
|
-
|
|
10585
|
+
Wf as createElementsServerHandlers
|
|
10572
10586
|
};
|