@roomle/embedding-lib 0.0.0-dev-ac159d1 → 0.0.0-dev-2fa1a85
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/THIRD-PARTY-NOTICES.txt +1 -1
- package/{ai-model-host-BE_xdV6e.mjs → ai-model-host-CaiYrZkh.mjs} +42 -43
- package/{ai-model-host-DHfBsFC2.mjs → ai-model-host-HAJONHCj.mjs} +40 -38
- package/ai.js +1 -1
- package/ai.min.js +1 -1
- package/construction.js +98 -79
- package/construction.min.js +882 -866
- package/hi.js +60 -59
- package/hi.min.js +54 -53
- package/package.json +1 -1
- package/packages/embedding-lib/src/ai-model-host.d.ts +1 -0
- package/packages/web-sdk/packages/common-core/src/planning-assistant/runtime.d.ts +2 -1
- package/packages/web-sdk/packages/common-core/src/planning-assistant/types.d.ts +0 -2
- package/roomle-embedding-lib.js +2 -5
- package/roomle-embedding-lib.min.js +5 -9
- package/sbom.cdx.json +5 -5
package/construction.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! Third-party licenses: THIRD-PARTY-NOTICES.txt and sbom.cdx.json in the root of this package */
|
|
2
2
|
import { n as e, t } from "./rolldown-runtime--db92txo.mjs";
|
|
3
3
|
import { t as n } from "./mcp-tools-m_3IX0vB.mjs";
|
|
4
|
-
import { $ as r, An as i, At as a, B as o, Bt as s, C as c, Cn as l, Ct as u, Dn as d, Dt as f, E as p, En as m, G as h, Gt as g, H as _, Ht as v, I as y, It as b, J as x, Jt as S, Kt as C, Lt as w, Mn as T, Nn as ee, Nt as E, On as D, Ot as O, P as k, Pn as A, Pt as te, Q as ne, R as re, Rt as j, S as ie, Sn as M, T as N, Tn as ae, U as P, V as oe, Vt as
|
|
4
|
+
import { $ as r, An as i, At as a, B as o, Bt as s, C as c, Cn as l, Ct as u, Dn as d, Dt as f, E as p, En as m, G as h, Gt as g, H as _, Ht as v, I as y, It as b, J as x, Jt as S, Kt as C, Lt as w, Mn as T, Nn as ee, Nt as E, On as D, Ot as O, P as k, Pn as A, Pt as te, Q as ne, R as re, Rt as j, S as ie, Sn as M, T as N, Tn as ae, U as P, V as oe, Vt as se, W as F, Wt as ce, Xt as le, Y as I, Yt as ue, Z as de, Zt as fe, _n as pe, _t as me, a as he, an as ge, at as _e, bn as ve, bt as ye, c as be, ct as L, d as xe, dn as Se, en as Ce, et as we, f as R, fn as Te, gn as z, gt as Ee, h as B, i as De, in as Oe, it as ke, j as Ae, jn as V, jt as je, kn as Me, kt as H, l as Ne, ln as Pe, m as Fe, mt as Ie, n as U, nn as Le, ot as W, p as Re, pt as ze, qt as Be, r as Ve, rn as He, s as Ue, sn as We, tn as Ge, tt as Ke, u as qe, vn as Je, vt as Ye, w as G, wn as Xe, wt as K, xn as Ze, y as Qe, yn as $e, z as et, zt as tt } from "./dist-D2ZAAHGn.mjs";
|
|
5
5
|
import { t as nt } from "./chat-model-DooKwd8I.mjs";
|
|
6
6
|
import { a as rt, i as it, o as at, r as ot, s as st, t as ct } from "./usage-C3HE9yXi.mjs";
|
|
7
7
|
var lt = t((e, t) => {
|
|
@@ -95,18 +95,18 @@ function mt(e, t, n) {
|
|
|
95
95
|
}(n.teamIdOrSlug)}`), r;
|
|
96
96
|
}
|
|
97
97
|
var ht, gt, _t, vt, yt, bt, xt, St, Ct, wt, Tt, Et, Dt, Ot, kt, At, jt, Mt, Nt, Pt, q = {
|
|
98
|
-
any:
|
|
98
|
+
any: Be,
|
|
99
99
|
array: S,
|
|
100
|
-
boolean:
|
|
101
|
-
discriminatedUnion:
|
|
102
|
-
enum:
|
|
103
|
-
literal:
|
|
104
|
-
number:
|
|
105
|
-
object:
|
|
106
|
-
record:
|
|
107
|
-
string:
|
|
108
|
-
union:
|
|
109
|
-
unknown:
|
|
100
|
+
boolean: ue,
|
|
101
|
+
discriminatedUnion: fe,
|
|
102
|
+
enum: ce,
|
|
103
|
+
literal: Ge,
|
|
104
|
+
number: Oe,
|
|
105
|
+
object: ge,
|
|
106
|
+
record: We,
|
|
107
|
+
string: Pe,
|
|
108
|
+
union: Se,
|
|
109
|
+
unknown: Te
|
|
110
110
|
}, Ft = Symbol.for("vercel.ai.gateway.error"), It = class e extends (gt = Error, ht = Ft, gt) {
|
|
111
111
|
constructor({ message: e, statusCode: t = 500, cause: n, generationId: r, isRetryable: i = t != null && (t === 408 || t === 409 || t === 429 || t >= 500) }) {
|
|
112
112
|
super(r ? `${e} [${r}]` : e), this[ht] = !0, this.statusCode = t, this.cause = n, this.generationId = r, this.isRetryable = i;
|
|
@@ -162,7 +162,7 @@ var ht, gt, _t, vt, yt, bt, xt, St, Ct, wt, Tt, Et, Dt, Ot, kt, At, jt, Mt, Nt,
|
|
|
162
162
|
static isInstance(e) {
|
|
163
163
|
return It.hasMarker(e) && qt in e;
|
|
164
164
|
}
|
|
165
|
-
}, Yt = "GatewayModelNotFoundError", Xt = `vercel.ai.gateway.error.${Yt}`, Zt = Symbol.for(Xt), Qt =
|
|
165
|
+
}, Yt = "GatewayModelNotFoundError", Xt = `vercel.ai.gateway.error.${Yt}`, Zt = Symbol.for(Xt), Qt = W(() => s(q.object({ modelId: q.string() }))), $t = class extends (wt = It, Ct = Zt, wt) {
|
|
166
166
|
constructor({ message: e = "Model not found", statusCode: t = 404, modelId: n, cause: r, generationId: i } = {}) {
|
|
167
167
|
super({
|
|
168
168
|
message: e,
|
|
@@ -210,7 +210,7 @@ var ht, gt, _t, vt, yt, bt, xt, St, Ct, wt, Tt, Et, Dt, Ot, kt, At, jt, Mt, Nt,
|
|
|
210
210
|
static isInstance(e) {
|
|
211
211
|
return It.hasMarker(e) && dn in e;
|
|
212
212
|
}
|
|
213
|
-
}, pn = "GatewayForbiddenError", mn = `vercel.ai.gateway.error.${pn}`, hn = Symbol.for(mn), gn =
|
|
213
|
+
}, pn = "GatewayForbiddenError", mn = `vercel.ai.gateway.error.${pn}`, hn = Symbol.for(mn), gn = W(() => s(q.object({ ruleId: q.string() }))), _n = class extends (Mt = It, jt = hn, Mt) {
|
|
214
214
|
constructor({ message: e = "Forbidden", statusCode: t = 403, cause: n, generationId: r, ruleId: i } = {}) {
|
|
215
215
|
super({
|
|
216
216
|
message: e,
|
|
@@ -237,7 +237,7 @@ var ht, gt, _t, vt, yt, bt, xt, St, Ct, wt, Tt, Et, Dt, Ot, kt, At, jt, Mt, Nt,
|
|
|
237
237
|
}
|
|
238
238
|
};
|
|
239
239
|
async function Sn({ response: e, statusCode: t, defaultMessage: n = "Gateway request failed", cause: r, authMethod: i, isRetryable: a }) {
|
|
240
|
-
let o = await
|
|
240
|
+
let o = await H({
|
|
241
241
|
value: e,
|
|
242
242
|
schema: Cn
|
|
243
243
|
});
|
|
@@ -275,7 +275,7 @@ async function Sn({ response: e, statusCode: t, defaultMessage: n = "Gateway req
|
|
|
275
275
|
generationId: u
|
|
276
276
|
});
|
|
277
277
|
case "model_not_found": {
|
|
278
|
-
let e = await
|
|
278
|
+
let e = await H({
|
|
279
279
|
value: s.error.param,
|
|
280
280
|
schema: Qt
|
|
281
281
|
});
|
|
@@ -307,7 +307,7 @@ async function Sn({ response: e, statusCode: t, defaultMessage: n = "Gateway req
|
|
|
307
307
|
generationId: u
|
|
308
308
|
});
|
|
309
309
|
case "forbidden": {
|
|
310
|
-
let e = await
|
|
310
|
+
let e = await H({
|
|
311
311
|
value: s.error.param,
|
|
312
312
|
schema: gn
|
|
313
313
|
});
|
|
@@ -321,7 +321,7 @@ async function Sn({ response: e, statusCode: t, defaultMessage: n = "Gateway req
|
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
|
-
var Cn =
|
|
324
|
+
var Cn = W(() => s(q.object({
|
|
325
325
|
error: q.object({
|
|
326
326
|
message: q.string(),
|
|
327
327
|
type: q.string().nullish(),
|
|
@@ -373,7 +373,7 @@ async function J(e, t) {
|
|
|
373
373
|
return It.isInstance(e) ? e : jn(e) ? An.createTimeoutError({
|
|
374
374
|
originalMessage: e instanceof Error ? e.message : "Unknown error",
|
|
375
375
|
cause: e
|
|
376
|
-
}) :
|
|
376
|
+
}) : pe.isInstance(e) ? e.cause && jn(e.cause) ? An.createTimeoutError({
|
|
377
377
|
originalMessage: e.message,
|
|
378
378
|
cause: e
|
|
379
379
|
}) : await Sn({
|
|
@@ -393,13 +393,13 @@ async function J(e, t) {
|
|
|
393
393
|
}
|
|
394
394
|
var Mn = "ai-gateway-auth-method", Nn = "x-vercel-ai-gateway-team";
|
|
395
395
|
async function Pn(e) {
|
|
396
|
-
let t = await
|
|
396
|
+
let t = await H({
|
|
397
397
|
value: e[Mn],
|
|
398
398
|
schema: Fn
|
|
399
399
|
});
|
|
400
400
|
return t.success ? t.value : void 0;
|
|
401
401
|
}
|
|
402
|
-
var Fn =
|
|
402
|
+
var Fn = W(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
403
403
|
"embedding",
|
|
404
404
|
"evaluation",
|
|
405
405
|
"image",
|
|
@@ -420,7 +420,7 @@ var Fn = G(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
|
420
420
|
validateUrl: !1,
|
|
421
421
|
headers: this.config.headers ? await K(this.config.headers) : void 0,
|
|
422
422
|
successfulResponseHandler: p(Rn),
|
|
423
|
-
failedResponseHandler:
|
|
423
|
+
failedResponseHandler: G({
|
|
424
424
|
errorSchema: q.any(),
|
|
425
425
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
426
426
|
}),
|
|
@@ -438,7 +438,7 @@ var Fn = G(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
|
438
438
|
validateUrl: !1,
|
|
439
439
|
headers: this.config.headers ? await K(this.config.headers) : void 0,
|
|
440
440
|
successfulResponseHandler: p(zn),
|
|
441
|
-
failedResponseHandler:
|
|
441
|
+
failedResponseHandler: G({
|
|
442
442
|
errorSchema: q.any(),
|
|
443
443
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
444
444
|
}),
|
|
@@ -449,7 +449,7 @@ var Fn = G(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
|
449
449
|
throw await J(e);
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
|
-
}, Rn =
|
|
452
|
+
}, Rn = W(() => s(q.object({ models: q.array(q.object({
|
|
453
453
|
id: q.string(),
|
|
454
454
|
name: q.string(),
|
|
455
455
|
description: q.string().nullish(),
|
|
@@ -470,7 +470,7 @@ var Fn = G(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
|
470
470
|
modelId: q.string()
|
|
471
471
|
}),
|
|
472
472
|
modelType: q.string().nullish()
|
|
473
|
-
})).transform((e) => e.filter((e) => e.modelType == null || In.includes(e.modelType))) }))), zn =
|
|
473
|
+
})).transform((e) => e.filter((e) => e.modelType == null || In.includes(e.modelType))) }))), zn = W(() => s(q.object({
|
|
474
474
|
balance: q.string(),
|
|
475
475
|
total_used: q.string()
|
|
476
476
|
}).transform(({ balance: e, total_used: t }) => ({
|
|
@@ -489,7 +489,7 @@ var Fn = G(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
|
489
489
|
validateUrl: !1,
|
|
490
490
|
headers: this.config.headers ? await K(this.config.headers) : void 0,
|
|
491
491
|
successfulResponseHandler: p(Vn),
|
|
492
|
-
failedResponseHandler:
|
|
492
|
+
failedResponseHandler: G({
|
|
493
493
|
errorSchema: q.any(),
|
|
494
494
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
495
495
|
}),
|
|
@@ -500,7 +500,7 @@ var Fn = G(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
|
500
500
|
throw await J(e);
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
|
-
}, Vn =
|
|
503
|
+
}, Vn = W(() => s(q.object({ results: q.array(q.object({
|
|
504
504
|
day: q.string().optional(),
|
|
505
505
|
hour: q.string().optional(),
|
|
506
506
|
user: q.string().optional(),
|
|
@@ -538,7 +538,7 @@ var Fn = G(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
|
538
538
|
validateUrl: !1,
|
|
539
539
|
headers: this.config.headers ? await K(this.config.headers) : void 0,
|
|
540
540
|
successfulResponseHandler: p(Un),
|
|
541
|
-
failedResponseHandler:
|
|
541
|
+
failedResponseHandler: G({
|
|
542
542
|
errorSchema: q.any(),
|
|
543
543
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
544
544
|
}),
|
|
@@ -549,7 +549,7 @@ var Fn = G(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
|
549
549
|
throw await J(e);
|
|
550
550
|
}
|
|
551
551
|
}
|
|
552
|
-
}, Un =
|
|
552
|
+
}, Un = W(() => s(q.object({ data: q.object({
|
|
553
553
|
id: q.string(),
|
|
554
554
|
total_cost: q.number(),
|
|
555
555
|
upstream_inference_cost: q.number(),
|
|
@@ -591,7 +591,7 @@ var Fn = G(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
|
591
591
|
(function(e) {
|
|
592
592
|
for (let t of e) {
|
|
593
593
|
let e = t.type;
|
|
594
|
-
if (e !== "text") throw new
|
|
594
|
+
if (e !== "text") throw new V({
|
|
595
595
|
functionality: `batch request type: ${e}`,
|
|
596
596
|
message: `The AI Gateway Batch API does not support batch requests with type "${e}".`
|
|
597
597
|
});
|
|
@@ -599,11 +599,11 @@ var Fn = G(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
|
599
599
|
})(e);
|
|
600
600
|
let a = function(e) {
|
|
601
601
|
let t = e[0]?.modelId;
|
|
602
|
-
if (t == null) throw new
|
|
602
|
+
if (t == null) throw new ve({
|
|
603
603
|
argument: "requests",
|
|
604
604
|
message: "The AI Gateway Batch API requires at least one request."
|
|
605
605
|
});
|
|
606
|
-
for (let n of e) if (n.modelId !== t) throw new
|
|
606
|
+
for (let n of e) if (n.modelId !== t) throw new ve({
|
|
607
607
|
argument: "requests",
|
|
608
608
|
message: `The AI Gateway Batch API requires all requests in a batch to use the same model. Found "${t}" and "${n.modelId}".`
|
|
609
609
|
});
|
|
@@ -620,9 +620,9 @@ var Fn = G(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
|
620
620
|
return Object.keys(r).length === 0 ? delete i.gateway : i.gateway = r, Object.keys(i).length === 0 ? void 0 : i;
|
|
621
621
|
}(t);
|
|
622
622
|
try {
|
|
623
|
-
let { value: t } = await
|
|
623
|
+
let { value: t } = await ye({
|
|
624
624
|
url: this.getBatchUrl("start"),
|
|
625
|
-
headers:
|
|
625
|
+
headers: R(o, n, { "ai-model-id": a }, await K(this.config.o11yHeaders), s == null ? void 0 : { "idempotency-key": s }),
|
|
626
626
|
body: {
|
|
627
627
|
...i != null && { callbackUrl: i },
|
|
628
628
|
requests: e.map((e) => ({
|
|
@@ -634,7 +634,7 @@ var Fn = G(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
|
634
634
|
...c != null && { providerOptions: c }
|
|
635
635
|
},
|
|
636
636
|
successfulResponseHandler: p(er),
|
|
637
|
-
failedResponseHandler:
|
|
637
|
+
failedResponseHandler: G({
|
|
638
638
|
errorSchema: q.any(),
|
|
639
639
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
640
640
|
}),
|
|
@@ -653,12 +653,12 @@ var Fn = G(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
|
653
653
|
async doGetBatchStatus({ batchId: e, headers: t, abortSignal: n }) {
|
|
654
654
|
let r = this.config.headers ? await K(this.config.headers) : void 0;
|
|
655
655
|
try {
|
|
656
|
-
let { value: i } = await
|
|
656
|
+
let { value: i } = await ye({
|
|
657
657
|
url: this.getBatchUrl("status"),
|
|
658
|
-
headers:
|
|
658
|
+
headers: R(r, t, await K(this.config.o11yHeaders)),
|
|
659
659
|
body: { batchId: e },
|
|
660
660
|
successfulResponseHandler: p(tr),
|
|
661
|
-
failedResponseHandler:
|
|
661
|
+
failedResponseHandler: G({
|
|
662
662
|
errorSchema: q.any(),
|
|
663
663
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
664
664
|
}),
|
|
@@ -673,19 +673,19 @@ var Fn = G(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
|
673
673
|
async doGetBatchResults({ batchId: e, headers: t, abortSignal: n }) {
|
|
674
674
|
let r = this.config.headers ? await K(this.config.headers) : void 0;
|
|
675
675
|
try {
|
|
676
|
-
let { value: i } = await
|
|
676
|
+
let { value: i } = await ye({
|
|
677
677
|
url: this.getBatchUrl("results"),
|
|
678
|
-
headers:
|
|
678
|
+
headers: R(r, t, await K(this.config.o11yHeaders)),
|
|
679
679
|
body: { batchId: e },
|
|
680
680
|
successfulResponseHandler: N(Yn),
|
|
681
|
-
failedResponseHandler:
|
|
681
|
+
failedResponseHandler: G({
|
|
682
682
|
errorSchema: q.any(),
|
|
683
683
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
684
684
|
}),
|
|
685
685
|
...n && { abortSignal: n },
|
|
686
686
|
fetch: this.config.fetch
|
|
687
687
|
});
|
|
688
|
-
return
|
|
688
|
+
return Fe(async function* (e) {
|
|
689
689
|
for await (let t of e) {
|
|
690
690
|
let e = t;
|
|
691
691
|
if (e.status === "succeeded") {
|
|
@@ -702,12 +702,12 @@ var Fn = G(() => s(q.union([q.literal("api-key"), q.literal("oidc")]))), In = [
|
|
|
702
702
|
async doCancelBatch({ batchId: e, headers: t, abortSignal: n }) {
|
|
703
703
|
let r = this.config.headers ? await K(this.config.headers) : void 0;
|
|
704
704
|
try {
|
|
705
|
-
let { value: i } = await
|
|
705
|
+
let { value: i } = await ye({
|
|
706
706
|
url: this.getBatchUrl("cancel"),
|
|
707
|
-
headers:
|
|
707
|
+
headers: R(r, t, await K(this.config.o11yHeaders)),
|
|
708
708
|
body: { batchId: e },
|
|
709
709
|
successfulResponseHandler: p(tr),
|
|
710
|
-
failedResponseHandler:
|
|
710
|
+
failedResponseHandler: G({
|
|
711
711
|
errorSchema: q.any(),
|
|
712
712
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
713
713
|
}),
|
|
@@ -744,7 +744,7 @@ function qn(e) {
|
|
|
744
744
|
return (e instanceof Error || e instanceof DOMException) && (e.name === "AbortError" || e.name === "TimeoutError");
|
|
745
745
|
}
|
|
746
746
|
function Jn(e) {
|
|
747
|
-
let t =
|
|
747
|
+
let t = ze({
|
|
748
748
|
total: e.requestCounts?.total,
|
|
749
749
|
pending: e.requestCounts?.pending,
|
|
750
750
|
completed: e.requestCounts?.completed,
|
|
@@ -807,12 +807,12 @@ var Yn = q.object({
|
|
|
807
807
|
this.modelId = e, this.config = t, this.specificationVersion = "v4", this.supportedUrls = { "*/*": [/.*/] };
|
|
808
808
|
}
|
|
809
809
|
static [v](e) {
|
|
810
|
-
return
|
|
810
|
+
return je({
|
|
811
811
|
modelId: e.modelId,
|
|
812
812
|
config: e.config
|
|
813
813
|
});
|
|
814
814
|
}
|
|
815
|
-
static [
|
|
815
|
+
static [se](t) {
|
|
816
816
|
return new e(t.modelId, t.config);
|
|
817
817
|
}
|
|
818
818
|
get provider() {
|
|
@@ -828,12 +828,12 @@ var Yn = q.object({
|
|
|
828
828
|
async doGenerate(e) {
|
|
829
829
|
let { args: t, warnings: n } = await this.getArgs(e), { abortSignal: r } = e, i = this.config.headers ? await K(this.config.headers) : void 0;
|
|
830
830
|
try {
|
|
831
|
-
let { responseHeaders: a, value: o, rawValue: s } = await
|
|
831
|
+
let { responseHeaders: a, value: o, rawValue: s } = await ye({
|
|
832
832
|
url: this.getUrl(),
|
|
833
|
-
headers:
|
|
833
|
+
headers: R(i, e.headers, this.getModelConfigHeaders(this.modelId, !1), await K(this.config.o11yHeaders)),
|
|
834
834
|
body: t,
|
|
835
835
|
successfulResponseHandler: p(q.any()),
|
|
836
|
-
failedResponseHandler:
|
|
836
|
+
failedResponseHandler: G({
|
|
837
837
|
errorSchema: q.any(),
|
|
838
838
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
839
839
|
}),
|
|
@@ -856,12 +856,12 @@ var Yn = q.object({
|
|
|
856
856
|
async doStream(e) {
|
|
857
857
|
let { args: t, warnings: n } = await this.getArgs(e), { abortSignal: r } = e, i = this.config.headers ? await K(this.config.headers) : void 0;
|
|
858
858
|
try {
|
|
859
|
-
let { value: a, responseHeaders: o } = await
|
|
859
|
+
let { value: a, responseHeaders: o } = await ye({
|
|
860
860
|
url: this.getUrl(),
|
|
861
|
-
headers:
|
|
861
|
+
headers: R(i, e.headers, this.getModelConfigHeaders(this.modelId, !0), await K(this.config.o11yHeaders)),
|
|
862
862
|
body: t,
|
|
863
863
|
successfulResponseHandler: ie(q.any()),
|
|
864
|
-
failedResponseHandler:
|
|
864
|
+
failedResponseHandler: G({
|
|
865
865
|
errorSchema: q.any(),
|
|
866
866
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
867
867
|
}),
|
|
@@ -924,12 +924,12 @@ var ir = class e {
|
|
|
924
924
|
this.modelId = e, this.config = t, this.specificationVersion = "v4", this.maxEmbeddingsPerCall = 2048, this.supportsParallelCalls = !0;
|
|
925
925
|
}
|
|
926
926
|
static [v](e) {
|
|
927
|
-
return
|
|
927
|
+
return je({
|
|
928
928
|
modelId: e.modelId,
|
|
929
929
|
config: e.config
|
|
930
930
|
});
|
|
931
931
|
}
|
|
932
|
-
static [
|
|
932
|
+
static [se](t) {
|
|
933
933
|
return new e(t.modelId, t.config);
|
|
934
934
|
}
|
|
935
935
|
get provider() {
|
|
@@ -938,15 +938,15 @@ var ir = class e {
|
|
|
938
938
|
async doEmbed({ values: e, headers: t, abortSignal: n, providerOptions: r }) {
|
|
939
939
|
let i = this.config.headers ? await K(this.config.headers) : void 0;
|
|
940
940
|
try {
|
|
941
|
-
let { responseHeaders: a, value: o, rawValue: s } = await
|
|
941
|
+
let { responseHeaders: a, value: o, rawValue: s } = await ye({
|
|
942
942
|
url: this.getUrl(),
|
|
943
|
-
headers:
|
|
943
|
+
headers: R(i, t ?? {}, this.getModelConfigHeaders(), await K(this.config.o11yHeaders)),
|
|
944
944
|
body: {
|
|
945
945
|
values: e,
|
|
946
946
|
...r ? { providerOptions: r } : {}
|
|
947
947
|
},
|
|
948
948
|
successfulResponseHandler: p(or),
|
|
949
|
-
failedResponseHandler:
|
|
949
|
+
failedResponseHandler: G({
|
|
950
950
|
errorSchema: q.any(),
|
|
951
951
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
952
952
|
}),
|
|
@@ -996,7 +996,7 @@ var ir = class e {
|
|
|
996
996
|
type: q.literal("other"),
|
|
997
997
|
message: q.string()
|
|
998
998
|
})
|
|
999
|
-
]), or =
|
|
999
|
+
]), or = W(() => s(q.object({
|
|
1000
1000
|
embeddings: q.array(q.array(q.number())),
|
|
1001
1001
|
usage: q.object({ tokens: q.number() }).nullish(),
|
|
1002
1002
|
warnings: q.array(ar).optional(),
|
|
@@ -1006,12 +1006,12 @@ var ir = class e {
|
|
|
1006
1006
|
this.modelId = e, this.config = t, this.specificationVersion = "v4", this.maxImagesPerCall = 2 ** 53 - 1;
|
|
1007
1007
|
}
|
|
1008
1008
|
static [v](e) {
|
|
1009
|
-
return
|
|
1009
|
+
return je({
|
|
1010
1010
|
modelId: e.modelId,
|
|
1011
1011
|
config: e.config
|
|
1012
1012
|
});
|
|
1013
1013
|
}
|
|
1014
|
-
static [
|
|
1014
|
+
static [se](t) {
|
|
1015
1015
|
return new e(t.modelId, t.config);
|
|
1016
1016
|
}
|
|
1017
1017
|
get provider() {
|
|
@@ -1020,9 +1020,9 @@ var ir = class e {
|
|
|
1020
1020
|
async doGenerate({ prompt: e, n: t, size: n, aspectRatio: r, seed: i, files: a, mask: o, providerOptions: s, headers: c, abortSignal: l }) {
|
|
1021
1021
|
let u = this.config.headers ? await K(this.config.headers) : void 0;
|
|
1022
1022
|
try {
|
|
1023
|
-
let { responseHeaders: d, value: f } = await
|
|
1023
|
+
let { responseHeaders: d, value: f } = await ye({
|
|
1024
1024
|
url: this.getUrl(),
|
|
1025
|
-
headers:
|
|
1025
|
+
headers: R(u, c ?? {}, this.getModelConfigHeaders(), await K(this.config.o11yHeaders)),
|
|
1026
1026
|
body: {
|
|
1027
1027
|
prompt: e,
|
|
1028
1028
|
n: t,
|
|
@@ -1034,7 +1034,7 @@ var ir = class e {
|
|
|
1034
1034
|
...o && { mask: cr(o) }
|
|
1035
1035
|
},
|
|
1036
1036
|
successfulResponseHandler: p(fr),
|
|
1037
|
-
failedResponseHandler:
|
|
1037
|
+
failedResponseHandler: G({
|
|
1038
1038
|
errorSchema: q.any(),
|
|
1039
1039
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
1040
1040
|
}),
|
|
@@ -1117,28 +1117,28 @@ var lr = q.object({ images: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1117
1117
|
async doGenerate(e) {
|
|
1118
1118
|
let { headers: t, abortSignal: n } = e, r = this.config.headers ? await K(this.config.headers) : void 0;
|
|
1119
1119
|
try {
|
|
1120
|
-
let { responseHeaders: i, value: a } = await
|
|
1120
|
+
let { responseHeaders: i, value: a } = await ye({
|
|
1121
1121
|
url: this.getUrl(),
|
|
1122
|
-
headers:
|
|
1122
|
+
headers: R(r, t ?? {}, this.getModelConfigHeaders(), await K(this.config.o11yHeaders), { accept: "text/event-stream" }),
|
|
1123
1123
|
body: this.buildRequestBody(e),
|
|
1124
1124
|
successfulResponseHandler: async ({ response: e, url: t, requestBodyValues: n }) => {
|
|
1125
|
-
if (e.body == null) throw new
|
|
1125
|
+
if (e.body == null) throw new pe({
|
|
1126
1126
|
message: "SSE response body is empty",
|
|
1127
1127
|
url: t,
|
|
1128
1128
|
requestBodyValues: n,
|
|
1129
1129
|
statusCode: e.status
|
|
1130
1130
|
});
|
|
1131
|
-
let r =
|
|
1131
|
+
let r = Ee({
|
|
1132
1132
|
stream: e.body,
|
|
1133
1133
|
schema: vr
|
|
1134
1134
|
}).getReader(), { done: i, value: a } = await r.read();
|
|
1135
|
-
if (r.releaseLock(), i || !a) throw new
|
|
1135
|
+
if (r.releaseLock(), i || !a) throw new pe({
|
|
1136
1136
|
message: "SSE stream ended without a data event",
|
|
1137
1137
|
url: t,
|
|
1138
1138
|
requestBodyValues: n,
|
|
1139
1139
|
statusCode: e.status
|
|
1140
1140
|
});
|
|
1141
|
-
if (!a.success) throw new
|
|
1141
|
+
if (!a.success) throw new pe({
|
|
1142
1142
|
message: "Failed to parse video SSE event",
|
|
1143
1143
|
cause: a.error,
|
|
1144
1144
|
url: t,
|
|
@@ -1146,7 +1146,7 @@ var lr = q.object({ images: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1146
1146
|
statusCode: e.status
|
|
1147
1147
|
});
|
|
1148
1148
|
let o = a.value;
|
|
1149
|
-
if (o.type === "error") throw new
|
|
1149
|
+
if (o.type === "error") throw new pe({
|
|
1150
1150
|
message: o.message,
|
|
1151
1151
|
statusCode: o.statusCode,
|
|
1152
1152
|
url: t,
|
|
@@ -1168,7 +1168,7 @@ var lr = q.object({ images: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1168
1168
|
responseHeaders: Object.fromEntries([...e.headers])
|
|
1169
1169
|
};
|
|
1170
1170
|
},
|
|
1171
|
-
failedResponseHandler:
|
|
1171
|
+
failedResponseHandler: G({
|
|
1172
1172
|
errorSchema: q.any(),
|
|
1173
1173
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
1174
1174
|
}),
|
|
@@ -1199,15 +1199,15 @@ var lr = q.object({ images: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1199
1199
|
async doStart(e) {
|
|
1200
1200
|
let { headers: t, abortSignal: n, webhookUrl: r } = e, i = this.config.headers ? await K(this.config.headers) : void 0;
|
|
1201
1201
|
try {
|
|
1202
|
-
let { responseHeaders: a, value: o } = await
|
|
1202
|
+
let { responseHeaders: a, value: o } = await ye({
|
|
1203
1203
|
url: this.getStartUrl(),
|
|
1204
|
-
headers:
|
|
1204
|
+
headers: R(i, t ?? {}, this.getModelConfigHeaders(), await K(this.config.o11yHeaders)),
|
|
1205
1205
|
body: {
|
|
1206
1206
|
...this.buildRequestBody(e),
|
|
1207
1207
|
...r && { callbackUrl: r }
|
|
1208
1208
|
},
|
|
1209
1209
|
successfulResponseHandler: p(yr),
|
|
1210
|
-
failedResponseHandler:
|
|
1210
|
+
failedResponseHandler: G({
|
|
1211
1211
|
errorSchema: q.any(),
|
|
1212
1212
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
1213
1213
|
}),
|
|
@@ -1231,12 +1231,12 @@ var lr = q.object({ images: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1231
1231
|
async doStatus({ operation: e, abortSignal: t, headers: n }) {
|
|
1232
1232
|
let r = this.config.headers ? await K(this.config.headers) : void 0;
|
|
1233
1233
|
try {
|
|
1234
|
-
let { responseHeaders: i, value: a } = await
|
|
1234
|
+
let { responseHeaders: i, value: a } = await ye({
|
|
1235
1235
|
url: this.getStatusUrl(),
|
|
1236
|
-
headers:
|
|
1236
|
+
headers: R(r, n ?? {}, this.getModelConfigHeaders(), await K(this.config.o11yHeaders)),
|
|
1237
1237
|
body: { operation: e },
|
|
1238
1238
|
successfulResponseHandler: p(br),
|
|
1239
|
-
failedResponseHandler:
|
|
1239
|
+
failedResponseHandler: G({
|
|
1240
1240
|
errorSchema: q.any(),
|
|
1241
1241
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
1242
1242
|
}),
|
|
@@ -1378,7 +1378,7 @@ var hr = q.object({ videos: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1378
1378
|
status: q.literal("cancelled"),
|
|
1379
1379
|
providerMetadata: q.record(q.string(), hr).nullish()
|
|
1380
1380
|
})
|
|
1381
|
-
]), xr =
|
|
1381
|
+
]), xr = W(() => s(q.object({ models: Dr.optional() }).catchall(q.unknown()))), Sr = q.number().finite().min(0).max(1), Cr = q.string().min(1).max(256), wr = q.union([q.object({
|
|
1382
1382
|
question: Cr.optional(),
|
|
1383
1383
|
confidenceBelow: Sr
|
|
1384
1384
|
}).strict(), q.object({
|
|
@@ -1433,7 +1433,7 @@ var hr = q.object({ videos: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1433
1433
|
return this.config.provider;
|
|
1434
1434
|
}
|
|
1435
1435
|
async doEvaluate({ state: e, questions: t, headers: n, abortSignal: r, providerOptions: i }) {
|
|
1436
|
-
let a = await
|
|
1436
|
+
let a = await me({
|
|
1437
1437
|
provider: "gateway",
|
|
1438
1438
|
providerOptions: i,
|
|
1439
1439
|
schema: xr
|
|
@@ -1442,16 +1442,16 @@ var hr = q.object({ videos: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1442
1442
|
gateway: a
|
|
1443
1443
|
}, s = this.config.headers ? await K(this.config.headers) : void 0;
|
|
1444
1444
|
try {
|
|
1445
|
-
let { responseHeaders: i, value: a, rawValue: c } = await
|
|
1445
|
+
let { responseHeaders: i, value: a, rawValue: c } = await ye({
|
|
1446
1446
|
url: this.getUrl(),
|
|
1447
|
-
headers:
|
|
1447
|
+
headers: R(s, n ?? {}, this.getModelConfigHeaders(), await K(this.config.o11yHeaders)),
|
|
1448
1448
|
body: {
|
|
1449
1449
|
state: e,
|
|
1450
1450
|
questions: t,
|
|
1451
1451
|
...o ? { providerOptions: o } : {}
|
|
1452
1452
|
},
|
|
1453
1453
|
successfulResponseHandler: p(jr),
|
|
1454
|
-
failedResponseHandler:
|
|
1454
|
+
failedResponseHandler: G({
|
|
1455
1455
|
errorSchema: q.any(),
|
|
1456
1456
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
1457
1457
|
}),
|
|
@@ -1518,7 +1518,7 @@ var hr = q.object({ videos: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1518
1518
|
type: q.literal("other"),
|
|
1519
1519
|
message: q.string()
|
|
1520
1520
|
})
|
|
1521
|
-
]), jr =
|
|
1521
|
+
]), jr = W(() => s(q.object({
|
|
1522
1522
|
answers: q.record(q.string(), kr),
|
|
1523
1523
|
model: q.string().optional(),
|
|
1524
1524
|
rounding: q.object({
|
|
@@ -1541,9 +1541,9 @@ var hr = q.object({ videos: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1541
1541
|
async doRerank({ documents: e, query: t, topN: n, headers: r, abortSignal: i, providerOptions: a }) {
|
|
1542
1542
|
let o = this.config.headers ? await K(this.config.headers) : void 0;
|
|
1543
1543
|
try {
|
|
1544
|
-
let { responseHeaders: s, value: c, rawValue: l } = await
|
|
1544
|
+
let { responseHeaders: s, value: c, rawValue: l } = await ye({
|
|
1545
1545
|
url: this.getUrl(),
|
|
1546
|
-
headers:
|
|
1546
|
+
headers: R(o, r ?? {}, this.getModelConfigHeaders(), await K(this.config.o11yHeaders)),
|
|
1547
1547
|
body: {
|
|
1548
1548
|
documents: e,
|
|
1549
1549
|
query: t,
|
|
@@ -1551,7 +1551,7 @@ var hr = q.object({ videos: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1551
1551
|
...a ? { providerOptions: a } : {}
|
|
1552
1552
|
},
|
|
1553
1553
|
successfulResponseHandler: p(Pr),
|
|
1554
|
-
failedResponseHandler:
|
|
1554
|
+
failedResponseHandler: G({
|
|
1555
1555
|
errorSchema: q.any(),
|
|
1556
1556
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
1557
1557
|
}),
|
|
@@ -1600,7 +1600,7 @@ var hr = q.object({ videos: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1600
1600
|
type: q.literal("other"),
|
|
1601
1601
|
message: q.string()
|
|
1602
1602
|
})
|
|
1603
|
-
]), Pr =
|
|
1603
|
+
]), Pr = W(() => s(q.object({
|
|
1604
1604
|
ranking: q.array(q.object({
|
|
1605
1605
|
index: q.number(),
|
|
1606
1606
|
relevanceScore: q.number()
|
|
@@ -1617,9 +1617,9 @@ var hr = q.object({ videos: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1617
1617
|
async doGenerate({ text: e, voice: t, outputFormat: n, instructions: r, speed: i, language: a, providerOptions: o, headers: s, abortSignal: c }) {
|
|
1618
1618
|
let l = this.config.headers ? await K(this.config.headers) : void 0;
|
|
1619
1619
|
try {
|
|
1620
|
-
let { responseHeaders: u, value: d, rawValue: f } = await
|
|
1620
|
+
let { responseHeaders: u, value: d, rawValue: f } = await ye({
|
|
1621
1621
|
url: this.getUrl(),
|
|
1622
|
-
headers:
|
|
1622
|
+
headers: R(l, s ?? {}, this.getModelConfigHeaders(), await K(this.config.o11yHeaders)),
|
|
1623
1623
|
body: {
|
|
1624
1624
|
text: e,
|
|
1625
1625
|
...t && { voice: t },
|
|
@@ -1630,7 +1630,7 @@ var hr = q.object({ videos: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1630
1630
|
...o && { providerOptions: o }
|
|
1631
1631
|
},
|
|
1632
1632
|
successfulResponseHandler: p(Rr),
|
|
1633
|
-
failedResponseHandler:
|
|
1633
|
+
failedResponseHandler: G({
|
|
1634
1634
|
errorSchema: q.any(),
|
|
1635
1635
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
1636
1636
|
}),
|
|
@@ -1695,16 +1695,16 @@ var hr = q.object({ videos: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1695
1695
|
async doGenerate({ audio: e, mediaType: t, providerOptions: n, headers: r, abortSignal: i }) {
|
|
1696
1696
|
let a = this.config.headers ? await K(this.config.headers) : void 0;
|
|
1697
1697
|
try {
|
|
1698
|
-
let { responseHeaders: o, value: s, rawValue: c } = await
|
|
1698
|
+
let { responseHeaders: o, value: s, rawValue: c } = await ye({
|
|
1699
1699
|
url: this.getUrl(),
|
|
1700
|
-
headers:
|
|
1700
|
+
headers: R(a, r ?? {}, this.getModelConfigHeaders(), await K(this.config.o11yHeaders)),
|
|
1701
1701
|
body: {
|
|
1702
1702
|
audio: e instanceof Uint8Array ? Qe(e) : e,
|
|
1703
1703
|
mediaType: t,
|
|
1704
1704
|
...n && { providerOptions: n }
|
|
1705
1705
|
},
|
|
1706
1706
|
successfulResponseHandler: p(Kr),
|
|
1707
|
-
failedResponseHandler:
|
|
1707
|
+
failedResponseHandler: G({
|
|
1708
1708
|
errorSchema: q.any(),
|
|
1709
1709
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
1710
1710
|
}),
|
|
@@ -1730,8 +1730,8 @@ var hr = q.object({ videos: q.array(q.unknown()).optional() }).catchall(q.unknow
|
|
|
1730
1730
|
}
|
|
1731
1731
|
}
|
|
1732
1732
|
async doStream(e) {
|
|
1733
|
-
let t = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date(), n =
|
|
1734
|
-
type:
|
|
1733
|
+
let t = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date(), n = R(await K(this.config.headers ?? {}), e.headers ?? {}, this.getModelConfigHeaders(), await K(this.config.o11yHeaders)), r = await Pn(n), i = {
|
|
1734
|
+
type: be,
|
|
1735
1735
|
inputAudioFormat: e.inputAudioFormat,
|
|
1736
1736
|
...e.providerOptions != null && { providerOptions: e.providerOptions },
|
|
1737
1737
|
...e.includeRawChunks != null && { includeRawChunks: e.includeRawChunks }
|
|
@@ -1769,7 +1769,7 @@ function Br(e, t) {
|
|
|
1769
1769
|
return n.searchParams.set("ai-model-id", t), n.toString();
|
|
1770
1770
|
}
|
|
1771
1771
|
function Vr(e) {
|
|
1772
|
-
let t =
|
|
1772
|
+
let t = Ie(e), n = t.authorization, r = n?.startsWith("Bearer ") ? n.slice(7) : void 0;
|
|
1773
1773
|
return r == null ? [ft] : function(e, t) {
|
|
1774
1774
|
return mt(ft, e, t);
|
|
1775
1775
|
}(r, { teamIdOrSlug: t[Nn] });
|
|
@@ -1788,7 +1788,7 @@ function Ur({ webSocket: e, url: t, protocols: n, headers: r, startFrame: i, aud
|
|
|
1788
1788
|
e.error(await J(t, n));
|
|
1789
1789
|
}(u, e, s));
|
|
1790
1790
|
};
|
|
1791
|
-
p =
|
|
1791
|
+
p = Re({
|
|
1792
1792
|
url: t,
|
|
1793
1793
|
protocols: n,
|
|
1794
1794
|
headers: r,
|
|
@@ -1806,18 +1806,18 @@ function Ur({ webSocket: e, url: t, protocols: n, headers: r, startFrame: i, aud
|
|
|
1806
1806
|
for (;;) {
|
|
1807
1807
|
let { done: n, value: r } = await t.read();
|
|
1808
1808
|
if (n || c) break;
|
|
1809
|
-
let i = typeof r == "string" ?
|
|
1809
|
+
let i = typeof r == "string" ? B(r) : r;
|
|
1810
1810
|
for (let t = 0; t < i.length && !c; t += Hr) e.send(i.subarray(t, t + Hr)), await w(e);
|
|
1811
1811
|
}
|
|
1812
1812
|
} finally {
|
|
1813
1813
|
t.releaseLock(), d === t && (d = void 0);
|
|
1814
1814
|
}
|
|
1815
|
-
c || h || e.send(JSON.stringify({ type:
|
|
1815
|
+
c || h || e.send(JSON.stringify({ type: Ue }));
|
|
1816
1816
|
})(e).catch(g);
|
|
1817
1817
|
},
|
|
1818
1818
|
onMessageText: (e) => {
|
|
1819
1819
|
if (c) return;
|
|
1820
|
-
let t =
|
|
1820
|
+
let t = Ye(e);
|
|
1821
1821
|
if (t != null) {
|
|
1822
1822
|
if (t.type === "finish") return c = !0, u.enqueue(t), u.close(), void l(1e3);
|
|
1823
1823
|
t.type === "error" && (m = !0, f = t.error, h = !0, d == null ? a.cancel().catch(() => {}) : (d.cancel().catch(() => {}), d = void 0)), u.enqueue(t);
|
|
@@ -1924,9 +1924,9 @@ function Yr(e, t) {
|
|
|
1924
1924
|
let n = new URL(`${e.replace(/^http/, "ws")}/realtime-model`);
|
|
1925
1925
|
return n.searchParams.set("ai-model-id", t), n.toString();
|
|
1926
1926
|
}
|
|
1927
|
-
var Xr = q.record(q.string(), q.unknown()), Zr =
|
|
1927
|
+
var Xr = q.record(q.string(), q.unknown()), Zr = Ae({
|
|
1928
1928
|
id: "gateway.browserbase_fetch",
|
|
1929
|
-
inputSchema:
|
|
1929
|
+
inputSchema: W(() => s(q.object({
|
|
1930
1930
|
url: q.string().url().describe("URL of the page to fetch."),
|
|
1931
1931
|
allow_redirects: q.boolean().optional().describe("Whether to follow HTTP redirects (default: false)."),
|
|
1932
1932
|
allow_insecure_ssl: q.boolean().optional().describe("Whether to bypass TLS certificate verification (default: false). Only use for trusted hosts."),
|
|
@@ -1938,7 +1938,7 @@ var Xr = q.record(q.string(), q.unknown()), Zr = ke({
|
|
|
1938
1938
|
]).optional().describe("Output format. raw returns the response body unchanged, markdown returns page content as Markdown, and json returns structured content using schema."),
|
|
1939
1939
|
schema: Xr.optional().describe("JSON Schema for structured extraction. Only use with format set to json.")
|
|
1940
1940
|
}))),
|
|
1941
|
-
outputSchema:
|
|
1941
|
+
outputSchema: W(() => s(q.union([q.object({
|
|
1942
1942
|
id: q.string(),
|
|
1943
1943
|
content: q.union([q.string(), Xr]),
|
|
1944
1944
|
contentType: q.string(),
|
|
@@ -1958,13 +1958,13 @@ var Xr = q.record(q.string(), q.unknown()), Zr = ke({
|
|
|
1958
1958
|
statusCode: q.number().optional(),
|
|
1959
1959
|
message: q.string()
|
|
1960
1960
|
})])))
|
|
1961
|
-
}), Qr =
|
|
1961
|
+
}), Qr = Ae({
|
|
1962
1962
|
id: "gateway.browserbase_search",
|
|
1963
|
-
inputSchema:
|
|
1963
|
+
inputSchema: W(() => s(q.object({
|
|
1964
1964
|
query: q.string().min(1).max(200).describe("Web search query. Must be between 1 and 200 characters."),
|
|
1965
1965
|
num_results: q.number().int().min(1).max(25).optional().describe("Maximum number of results to return (1-25, default: 10).")
|
|
1966
1966
|
}))),
|
|
1967
|
-
outputSchema:
|
|
1967
|
+
outputSchema: W(() => s(q.union([q.object({
|
|
1968
1968
|
query: q.string(),
|
|
1969
1969
|
requestId: q.string(),
|
|
1970
1970
|
results: q.array(q.object({
|
|
@@ -1989,9 +1989,9 @@ var Xr = q.record(q.string(), q.unknown()), Zr = ke({
|
|
|
1989
1989
|
statusCode: q.number().optional(),
|
|
1990
1990
|
message: q.string()
|
|
1991
1991
|
})])))
|
|
1992
|
-
}), $r =
|
|
1992
|
+
}), $r = Ae({
|
|
1993
1993
|
id: "gateway.exa_search",
|
|
1994
|
-
inputSchema:
|
|
1994
|
+
inputSchema: W(() => s(q.object({
|
|
1995
1995
|
query: q.string().describe("Natural-language web search query. This is required."),
|
|
1996
1996
|
type: q.enum([
|
|
1997
1997
|
"auto",
|
|
@@ -2054,7 +2054,7 @@ var Xr = q.record(q.string(), q.unknown()), Zr = ke({
|
|
|
2054
2054
|
}).optional()
|
|
2055
2055
|
}).optional().describe("Controls extracted page content and freshness.")
|
|
2056
2056
|
}))),
|
|
2057
|
-
outputSchema:
|
|
2057
|
+
outputSchema: W(() => s(q.union([q.object({
|
|
2058
2058
|
requestId: q.string(),
|
|
2059
2059
|
searchType: q.string().optional(),
|
|
2060
2060
|
resolvedSearchType: q.string().optional(),
|
|
@@ -2093,9 +2093,9 @@ var Xr = q.record(q.string(), q.unknown()), Zr = ke({
|
|
|
2093
2093
|
statusCode: q.number().optional(),
|
|
2094
2094
|
message: q.string()
|
|
2095
2095
|
})])))
|
|
2096
|
-
}), ei =
|
|
2096
|
+
}), ei = Ae({
|
|
2097
2097
|
id: "gateway.parallel_search",
|
|
2098
|
-
inputSchema:
|
|
2098
|
+
inputSchema: W(() => s(q.object({
|
|
2099
2099
|
objective: q.string().describe("Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."),
|
|
2100
2100
|
search_queries: q.array(q.string()).optional().describe("Optional search queries to supplement the objective. Maximum 200 characters per query."),
|
|
2101
2101
|
mode: q.enum(["one-shot", "agentic"]).optional().describe("Mode preset: \"one-shot\" for comprehensive results with longer excerpts (default), \"agentic\" for concise, token-efficient results for multi-step workflows."),
|
|
@@ -2111,7 +2111,7 @@ var Xr = q.record(q.string(), q.unknown()), Zr = ke({
|
|
|
2111
2111
|
}).optional().describe("Excerpt configuration for controlling result length."),
|
|
2112
2112
|
fetch_policy: q.object({ max_age_seconds: q.number().optional().describe("Maximum age in seconds for cached content. Set to 0 to always fetch fresh content.") }).optional().describe("Fetch policy for controlling content freshness.")
|
|
2113
2113
|
}))),
|
|
2114
|
-
outputSchema:
|
|
2114
|
+
outputSchema: W(() => s(q.union([q.object({
|
|
2115
2115
|
searchId: q.string(),
|
|
2116
2116
|
results: q.array(q.object({
|
|
2117
2117
|
url: q.string(),
|
|
@@ -2132,9 +2132,9 @@ var Xr = q.record(q.string(), q.unknown()), Zr = ke({
|
|
|
2132
2132
|
statusCode: q.number().optional(),
|
|
2133
2133
|
message: q.string()
|
|
2134
2134
|
})])))
|
|
2135
|
-
}), ti =
|
|
2135
|
+
}), ti = Ae({
|
|
2136
2136
|
id: "gateway.perplexity_search",
|
|
2137
|
-
inputSchema:
|
|
2137
|
+
inputSchema: W(() => s(q.object({
|
|
2138
2138
|
query: q.union([q.string(), q.array(q.string())]).describe("Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."),
|
|
2139
2139
|
max_results: q.number().optional().describe("Maximum number of search results to return (1-20, default: 10)"),
|
|
2140
2140
|
max_tokens_per_page: q.number().optional().describe("Maximum number of tokens to extract per search result page (256-2048, default: 2048)"),
|
|
@@ -2153,7 +2153,7 @@ var Xr = q.record(q.string(), q.unknown()), Zr = ke({
|
|
|
2153
2153
|
"year"
|
|
2154
2154
|
]).optional().describe("Filter results by relative time period. Cannot be used with search_after_date or search_before_date.")
|
|
2155
2155
|
}))),
|
|
2156
|
-
outputSchema:
|
|
2156
|
+
outputSchema: W(() => s(q.union([q.object({
|
|
2157
2157
|
results: q.array(q.object({
|
|
2158
2158
|
title: q.string(),
|
|
2159
2159
|
url: q.string(),
|
|
@@ -2201,7 +2201,7 @@ var Xr = q.record(q.string(), q.unknown()), Zr = ke({
|
|
|
2201
2201
|
article_content_max_chars: q.number().optional().describe("Maximum extracted characters per web page when including contents."),
|
|
2202
2202
|
published_after: q.string().optional().describe("Keep results published on or after this ISO date (YYYY-MM-DD)."),
|
|
2203
2203
|
published_before: q.string().optional().describe("Keep results published on or before this ISO date (YYYY-MM-DD).")
|
|
2204
|
-
}), ii =
|
|
2204
|
+
}), ii = W(() => s(q.object({
|
|
2205
2205
|
query: q.string().describe("Natural-language search query. Include the entity, metric, and time period. Quote a phrase to force it to one entity, for example \"Tesla\":PRODUCT price."),
|
|
2206
2206
|
effort: q.enum([
|
|
2207
2207
|
"deep",
|
|
@@ -2335,10 +2335,10 @@ var Xr = q.record(q.string(), q.unknown()), Zr = ke({
|
|
|
2335
2335
|
source_name: q.string().nullish(),
|
|
2336
2336
|
publish_date: q.string().nullish(),
|
|
2337
2337
|
content: oi.nullish()
|
|
2338
|
-
}).passthrough(), li =
|
|
2338
|
+
}).passthrough(), li = Ae({
|
|
2339
2339
|
id: "gateway.tako_search",
|
|
2340
2340
|
inputSchema: ii,
|
|
2341
|
-
outputSchema:
|
|
2341
|
+
outputSchema: W(() => s(q.union([q.object({
|
|
2342
2342
|
request_id: q.string(),
|
|
2343
2343
|
cards: q.array(si).optional(),
|
|
2344
2344
|
web_results: q.array(ci).optional(),
|
|
@@ -2410,7 +2410,7 @@ function fi(e = {}) {
|
|
|
2410
2410
|
}
|
|
2411
2411
|
})(), r = o(n), i = new URL("/v1/realtime/client-secrets", a).toString();
|
|
2412
2412
|
try {
|
|
2413
|
-
let { value: n } = await
|
|
2413
|
+
let { value: n } = await ye({
|
|
2414
2414
|
url: i,
|
|
2415
2415
|
headers: r,
|
|
2416
2416
|
body: {
|
|
@@ -2419,7 +2419,7 @@ function fi(e = {}) {
|
|
|
2419
2419
|
...t.expiresAfterSeconds != null && { expiresIn: t.expiresAfterSeconds }
|
|
2420
2420
|
},
|
|
2421
2421
|
successfulResponseHandler: p(di),
|
|
2422
|
-
failedResponseHandler:
|
|
2422
|
+
failedResponseHandler: G({
|
|
2423
2423
|
errorSchema: q.any(),
|
|
2424
2424
|
errorToMessage: (e) => T(e) ?? "unknown error"
|
|
2425
2425
|
}),
|
|
@@ -2433,16 +2433,16 @@ function fi(e = {}) {
|
|
|
2433
2433
|
throw await J(e, await Pn(r));
|
|
2434
2434
|
}
|
|
2435
2435
|
}, l = () => {
|
|
2436
|
-
let e =
|
|
2436
|
+
let e = L({
|
|
2437
2437
|
settingValue: void 0,
|
|
2438
2438
|
environmentVariableName: "VERCEL_DEPLOYMENT_ID"
|
|
2439
|
-
}), t =
|
|
2439
|
+
}), t = L({
|
|
2440
2440
|
settingValue: void 0,
|
|
2441
2441
|
environmentVariableName: "VERCEL_ENV"
|
|
2442
|
-
}), n =
|
|
2442
|
+
}), n = L({
|
|
2443
2443
|
settingValue: void 0,
|
|
2444
2444
|
environmentVariableName: "VERCEL_REGION"
|
|
2445
|
-
}), r =
|
|
2445
|
+
}), r = L({
|
|
2446
2446
|
settingValue: void 0,
|
|
2447
2447
|
environmentVariableName: "VERCEL_PROJECT_ID"
|
|
2448
2448
|
});
|
|
@@ -2583,7 +2583,7 @@ function fi(e = {}) {
|
|
|
2583
2583
|
}
|
|
2584
2584
|
var pi = fi();
|
|
2585
2585
|
async function mi(e) {
|
|
2586
|
-
let t =
|
|
2586
|
+
let t = L({
|
|
2587
2587
|
settingValue: e.apiKey,
|
|
2588
2588
|
environmentVariableName: "AI_GATEWAY_API_KEY"
|
|
2589
2589
|
});
|
|
@@ -2596,15 +2596,15 @@ async function mi(e) {
|
|
|
2596
2596
|
};
|
|
2597
2597
|
}
|
|
2598
2598
|
var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni, Pi, Fi, Ii, Li, Ri, zi, Bi, Vi, Hi, Ui, Wi, Gi, Ki, qi = e({
|
|
2599
|
-
AISDKError: () =>
|
|
2599
|
+
AISDKError: () => z,
|
|
2600
2600
|
AI_SDK_TELEMETRY_TRACING_CHANNEL: () => Cl,
|
|
2601
|
-
APICallError: () =>
|
|
2601
|
+
APICallError: () => pe,
|
|
2602
2602
|
AbstractChat: () => dm,
|
|
2603
2603
|
DefaultChatTransport: () => um,
|
|
2604
2604
|
DefaultGeneratedFile: () => Pc,
|
|
2605
2605
|
DirectChatTransport: () => fm,
|
|
2606
|
-
DownloadError: () =>
|
|
2607
|
-
EmptyResponseBodyError: () =>
|
|
2606
|
+
DownloadError: () => Ve,
|
|
2607
|
+
EmptyResponseBodyError: () => Je,
|
|
2608
2608
|
Experimental_AbstractRealtimeSession: () => zp,
|
|
2609
2609
|
Experimental_Agent: () => ld,
|
|
2610
2610
|
Experimental_EvaluationUnsupportedQuestionTypeError: () => $e,
|
|
@@ -2641,7 +2641,7 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2641
2641
|
SerialJobExecutor: () => Mf,
|
|
2642
2642
|
StreamProviderError: () => ro,
|
|
2643
2643
|
TextStreamChatTransport: () => hm,
|
|
2644
|
-
TooManyEmbeddingValuesForCallError: () =>
|
|
2644
|
+
TooManyEmbeddingValuesForCallError: () => Me,
|
|
2645
2645
|
ToolCallNotFoundForApprovalError: () => _a,
|
|
2646
2646
|
ToolCallRepairError: () => Co,
|
|
2647
2647
|
ToolChoiceViolationError: () => Do,
|
|
@@ -2649,10 +2649,10 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2649
2649
|
TypeValidationError: () => i,
|
|
2650
2650
|
UIMessageStreamError: () => Mo,
|
|
2651
2651
|
UI_MESSAGE_STREAM_HEADERS: () => cu,
|
|
2652
|
-
UnsupportedFunctionalityError: () =>
|
|
2652
|
+
UnsupportedFunctionalityError: () => V,
|
|
2653
2653
|
UnsupportedModelVersionError: () => Oo,
|
|
2654
2654
|
addToolInputExamplesMiddleware: () => pp,
|
|
2655
|
-
asSchema: () =>
|
|
2655
|
+
asSchema: () => qe,
|
|
2656
2656
|
assistantModelMessageSchema: () => vc,
|
|
2657
2657
|
callCompletionApi: () => sm,
|
|
2658
2658
|
consumeStream: () => Pu,
|
|
@@ -2730,11 +2730,11 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2730
2730
|
isTextUIPart: () => hu,
|
|
2731
2731
|
isToolOutputErrorUIPart: () => Cu,
|
|
2732
2732
|
isToolUIPart: () => Su,
|
|
2733
|
-
jsonSchema: () =>
|
|
2733
|
+
jsonSchema: () => _e,
|
|
2734
2734
|
lastAssistantMessageIsCompleteWithApprovalResponses: () => pm,
|
|
2735
2735
|
lastAssistantMessageIsCompleteWithToolCalls: () => mm,
|
|
2736
2736
|
modelMessageSchema: () => bc,
|
|
2737
|
-
parseJsonEventStream: () =>
|
|
2737
|
+
parseJsonEventStream: () => Ee,
|
|
2738
2738
|
parsePartialJson: () => $c,
|
|
2739
2739
|
pipeAgentUIStreamToResponse: () => Dd,
|
|
2740
2740
|
pipeTextStreamToResponse: () => au,
|
|
@@ -2768,7 +2768,7 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2768
2768
|
wrapLanguageModel: () => mp,
|
|
2769
2769
|
wrapProvider: () => bp,
|
|
2770
2770
|
zodSchema: () => s
|
|
2771
|
-
}), Ji = Object.defineProperty, Yi = "AI_InvalidArgumentError", Xi = `vercel.ai.error.${Yi}`, Zi = Symbol.for(Xi), Y = class extends (gi =
|
|
2771
|
+
}), Ji = Object.defineProperty, Yi = "AI_InvalidArgumentError", Xi = `vercel.ai.error.${Yi}`, Zi = Symbol.for(Xi), Y = class extends (gi = z, hi = Zi, gi) {
|
|
2772
2772
|
constructor({ parameter: e, value: t, message: n }) {
|
|
2773
2773
|
super({
|
|
2774
2774
|
name: Yi,
|
|
@@ -2776,9 +2776,9 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2776
2776
|
}), this[hi] = !0, this.parameter = e, this.value = t;
|
|
2777
2777
|
}
|
|
2778
2778
|
static isInstance(e) {
|
|
2779
|
-
return
|
|
2779
|
+
return z.hasMarker(e, Xi);
|
|
2780
2780
|
}
|
|
2781
|
-
}, Qi = "AI_InvalidStreamPartError", $i = `vercel.ai.error.${Qi}`, ea = Symbol.for($i), ta = class extends (vi =
|
|
2781
|
+
}, Qi = "AI_InvalidStreamPartError", $i = `vercel.ai.error.${Qi}`, ea = Symbol.for($i), ta = class extends (vi = z, _i = ea, vi) {
|
|
2782
2782
|
constructor({ chunk: e, message: t }) {
|
|
2783
2783
|
super({
|
|
2784
2784
|
name: Qi,
|
|
@@ -2786,9 +2786,9 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2786
2786
|
}), this[_i] = !0, this.chunk = e;
|
|
2787
2787
|
}
|
|
2788
2788
|
static isInstance(e) {
|
|
2789
|
-
return
|
|
2789
|
+
return z.hasMarker(e, $i);
|
|
2790
2790
|
}
|
|
2791
|
-
}, na = "AI_InvalidToolApprovalError", ra = `vercel.ai.error.${na}`, ia = Symbol.for(ra), aa = class extends (bi =
|
|
2791
|
+
}, na = "AI_InvalidToolApprovalError", ra = `vercel.ai.error.${na}`, ia = Symbol.for(ra), aa = class extends (bi = z, yi = ia, bi) {
|
|
2792
2792
|
constructor({ approvalId: e }) {
|
|
2793
2793
|
super({
|
|
2794
2794
|
name: na,
|
|
@@ -2796,9 +2796,9 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2796
2796
|
}), this[yi] = !0, this.approvalId = e;
|
|
2797
2797
|
}
|
|
2798
2798
|
static isInstance(e) {
|
|
2799
|
-
return
|
|
2799
|
+
return z.hasMarker(e, ra);
|
|
2800
2800
|
}
|
|
2801
|
-
}, oa = "AI_InvalidToolApprovalSignatureError", sa = `vercel.ai.error.${oa}`, ca = Symbol.for(sa), la = class extends (Si =
|
|
2801
|
+
}, oa = "AI_InvalidToolApprovalSignatureError", sa = `vercel.ai.error.${oa}`, ca = Symbol.for(sa), la = class extends (Si = z, xi = ca, Si) {
|
|
2802
2802
|
constructor({ approvalId: e, toolCallId: t, reason: n }) {
|
|
2803
2803
|
super({
|
|
2804
2804
|
name: oa,
|
|
@@ -2806,9 +2806,9 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2806
2806
|
}), this[xi] = !0, this.approvalId = e, this.toolCallId = t;
|
|
2807
2807
|
}
|
|
2808
2808
|
static isInstance(e) {
|
|
2809
|
-
return
|
|
2809
|
+
return z.hasMarker(e, sa);
|
|
2810
2810
|
}
|
|
2811
|
-
}, ua = "AI_InvalidToolInputError", da = `vercel.ai.error.${ua}`, fa = Symbol.for(da), pa = class extends (wi =
|
|
2811
|
+
}, ua = "AI_InvalidToolInputError", da = `vercel.ai.error.${ua}`, fa = Symbol.for(da), pa = class extends (wi = z, Ci = fa, wi) {
|
|
2812
2812
|
constructor({ toolInput: e, toolName: t, cause: n, message: r = `Invalid input for tool ${t}: ${T(n)}` }) {
|
|
2813
2813
|
super({
|
|
2814
2814
|
name: ua,
|
|
@@ -2817,9 +2817,9 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2817
2817
|
}), this[Ci] = !0, this.toolInput = e, this.toolName = t;
|
|
2818
2818
|
}
|
|
2819
2819
|
static isInstance(e) {
|
|
2820
|
-
return
|
|
2820
|
+
return z.hasMarker(e, da);
|
|
2821
2821
|
}
|
|
2822
|
-
}, ma = "AI_ToolCallNotFoundForApprovalError", ha = `vercel.ai.error.${ma}`, ga = Symbol.for(ha), _a = class extends (Ei =
|
|
2822
|
+
}, ma = "AI_ToolCallNotFoundForApprovalError", ha = `vercel.ai.error.${ma}`, ga = Symbol.for(ha), _a = class extends (Ei = z, Ti = ga, Ei) {
|
|
2823
2823
|
constructor({ toolCallId: e, approvalId: t }) {
|
|
2824
2824
|
super({
|
|
2825
2825
|
name: ma,
|
|
@@ -2827,9 +2827,9 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2827
2827
|
}), this[Ti] = !0, this.toolCallId = e, this.approvalId = t;
|
|
2828
2828
|
}
|
|
2829
2829
|
static isInstance(e) {
|
|
2830
|
-
return
|
|
2830
|
+
return z.hasMarker(e, ha);
|
|
2831
2831
|
}
|
|
2832
|
-
}, va = "AI_MissingToolResultsError", ya = `vercel.ai.error.${va}`, ba = Symbol.for(ya), xa = class extends (Oi =
|
|
2832
|
+
}, va = "AI_MissingToolResultsError", ya = `vercel.ai.error.${va}`, ba = Symbol.for(ya), xa = class extends (Oi = z, Di = ba, Oi) {
|
|
2833
2833
|
constructor({ toolCallIds: e }) {
|
|
2834
2834
|
super({
|
|
2835
2835
|
name: va,
|
|
@@ -2837,9 +2837,9 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2837
2837
|
}), this[Di] = !0, this.toolCallIds = e;
|
|
2838
2838
|
}
|
|
2839
2839
|
static isInstance(e) {
|
|
2840
|
-
return
|
|
2840
|
+
return z.hasMarker(e, ya);
|
|
2841
2841
|
}
|
|
2842
|
-
}, Sa = "AI_NoImageGeneratedError", Ca = `vercel.ai.error.${Sa}`, wa = Symbol.for(Ca), Ta = class extends (Ai =
|
|
2842
|
+
}, Sa = "AI_NoImageGeneratedError", Ca = `vercel.ai.error.${Sa}`, wa = Symbol.for(Ca), Ta = class extends (Ai = z, ki = wa, Ai) {
|
|
2843
2843
|
constructor({ message: e = "No image generated.", cause: t, calls: n, responses: r }) {
|
|
2844
2844
|
super({
|
|
2845
2845
|
name: Sa,
|
|
@@ -2848,9 +2848,9 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2848
2848
|
}), this[ki] = !0, this.calls = n, this.responses = r;
|
|
2849
2849
|
}
|
|
2850
2850
|
static isInstance(e) {
|
|
2851
|
-
return
|
|
2851
|
+
return z.hasMarker(e, Ca);
|
|
2852
2852
|
}
|
|
2853
|
-
}, Ea = "AI_NoObjectGeneratedError", Da = `vercel.ai.error.${Ea}`, Oa = Symbol.for(Da), ka = class extends (Mi =
|
|
2853
|
+
}, Ea = "AI_NoObjectGeneratedError", Da = `vercel.ai.error.${Ea}`, Oa = Symbol.for(Da), ka = class extends (Mi = z, ji = Oa, Mi) {
|
|
2854
2854
|
constructor({ message: e = "No object generated.", cause: t, text: n, response: r, usage: i, finishReason: a }) {
|
|
2855
2855
|
super({
|
|
2856
2856
|
name: Ea,
|
|
@@ -2859,9 +2859,9 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2859
2859
|
}), this[ji] = !0, this.text = n, this.response = r, this.usage = i, this.finishReason = a;
|
|
2860
2860
|
}
|
|
2861
2861
|
static isInstance(e) {
|
|
2862
|
-
return
|
|
2862
|
+
return z.hasMarker(e, Da);
|
|
2863
2863
|
}
|
|
2864
|
-
}, Aa = "AI_NoOutputGeneratedError", ja = `vercel.ai.error.${Aa}`, Ma = Symbol.for(ja), Na = class extends (Pi =
|
|
2864
|
+
}, Aa = "AI_NoOutputGeneratedError", ja = `vercel.ai.error.${Aa}`, Ma = Symbol.for(ja), Na = class extends (Pi = z, Ni = Ma, Pi) {
|
|
2865
2865
|
constructor({ message: e = "No output generated.", cause: t } = {}) {
|
|
2866
2866
|
super({
|
|
2867
2867
|
name: Aa,
|
|
@@ -2870,9 +2870,9 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2870
2870
|
}), this[Ni] = !0;
|
|
2871
2871
|
}
|
|
2872
2872
|
static isInstance(e) {
|
|
2873
|
-
return
|
|
2873
|
+
return z.hasMarker(e, ja);
|
|
2874
2874
|
}
|
|
2875
|
-
}, Pa = "AI_NoSpeechGeneratedError", Fa = `vercel.ai.error.${Pa}`, Ia = Symbol.for(Fa), La = class extends (Ii =
|
|
2875
|
+
}, Pa = "AI_NoSpeechGeneratedError", Fa = `vercel.ai.error.${Pa}`, Ia = Symbol.for(Fa), La = class extends (Ii = z, Fi = Ia, Ii) {
|
|
2876
2876
|
constructor(e) {
|
|
2877
2877
|
super({
|
|
2878
2878
|
name: Pa,
|
|
@@ -2880,9 +2880,9 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2880
2880
|
}), this[Fi] = !0, this.responses = e.responses;
|
|
2881
2881
|
}
|
|
2882
2882
|
static isInstance(e) {
|
|
2883
|
-
return
|
|
2883
|
+
return z.hasMarker(e, Fa);
|
|
2884
2884
|
}
|
|
2885
|
-
}, Ra = "AI_NoTranscriptGeneratedError", za = `vercel.ai.error.${Ra}`, Ba = Symbol.for(za), Va = class extends (Ri =
|
|
2885
|
+
}, Ra = "AI_NoTranscriptGeneratedError", za = `vercel.ai.error.${Ra}`, Ba = Symbol.for(za), Va = class extends (Ri = z, Li = Ba, Ri) {
|
|
2886
2886
|
constructor(e) {
|
|
2887
2887
|
super({
|
|
2888
2888
|
name: Ra,
|
|
@@ -2890,9 +2890,9 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2890
2890
|
}), this[Li] = !0, this.responses = e.responses;
|
|
2891
2891
|
}
|
|
2892
2892
|
static isInstance(e) {
|
|
2893
|
-
return
|
|
2893
|
+
return z.hasMarker(e, za);
|
|
2894
2894
|
}
|
|
2895
|
-
}, Ha = "AI_NoTranslationGeneratedError", Ua = `vercel.ai.error.${Ha}`, Wa = Symbol.for(Ua), Ga = class extends (Bi =
|
|
2895
|
+
}, Ha = "AI_NoTranslationGeneratedError", Ua = `vercel.ai.error.${Ha}`, Wa = Symbol.for(Ua), Ga = class extends (Bi = z, zi = Wa, Bi) {
|
|
2896
2896
|
constructor(e) {
|
|
2897
2897
|
super({
|
|
2898
2898
|
name: Ha,
|
|
@@ -2900,9 +2900,9 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2900
2900
|
}), this[zi] = !0, this.response = e.response;
|
|
2901
2901
|
}
|
|
2902
2902
|
static isInstance(e) {
|
|
2903
|
-
return
|
|
2903
|
+
return z.hasMarker(e, Ua);
|
|
2904
2904
|
}
|
|
2905
|
-
}, Ka = "AI_NoVideoGeneratedError", qa = `vercel.ai.error.${Ka}`, Ja = Symbol.for(qa), Ya = class extends (Hi =
|
|
2905
|
+
}, Ka = "AI_NoVideoGeneratedError", qa = `vercel.ai.error.${Ka}`, Ja = Symbol.for(qa), Ya = class extends (Hi = z, Vi = Ja, Hi) {
|
|
2906
2906
|
constructor({ message: e = "No video generated.", cause: t, responses: n }) {
|
|
2907
2907
|
super({
|
|
2908
2908
|
name: Ka,
|
|
@@ -2911,7 +2911,7 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2911
2911
|
}), this[Vi] = !0, this.responses = n;
|
|
2912
2912
|
}
|
|
2913
2913
|
static isInstance(e) {
|
|
2914
|
-
return
|
|
2914
|
+
return z.hasMarker(e, qa);
|
|
2915
2915
|
}
|
|
2916
2916
|
static isNoVideoGeneratedError(e) {
|
|
2917
2917
|
return e instanceof Error && e.name === Ka && e.responses !== void 0;
|
|
@@ -2925,7 +2925,7 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2925
2925
|
responses: this.responses
|
|
2926
2926
|
};
|
|
2927
2927
|
}
|
|
2928
|
-
}, Xa = "AI_NoSuchToolError", Za = `vercel.ai.error.${Xa}`, Qa = Symbol.for(Za), $a = class extends (Wi =
|
|
2928
|
+
}, Xa = "AI_NoSuchToolError", Za = `vercel.ai.error.${Xa}`, Qa = Symbol.for(Za), $a = class extends (Wi = z, Ui = Qa, Wi) {
|
|
2929
2929
|
constructor({ toolName: e, availableTools: t, message: n = `Model tried to call unavailable tool '${e}'. ${t === void 0 ? "No tools are available." : `Available tools: ${t.join(", ")}.`}` }) {
|
|
2930
2930
|
super({
|
|
2931
2931
|
name: Xa,
|
|
@@ -2933,9 +2933,9 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2933
2933
|
}), this[Ui] = !0, this.toolName = e, this.availableTools = t;
|
|
2934
2934
|
}
|
|
2935
2935
|
static isInstance(e) {
|
|
2936
|
-
return
|
|
2936
|
+
return z.hasMarker(e, Za);
|
|
2937
2937
|
}
|
|
2938
|
-
}, eo = "AI_StreamProviderError", to = `vercel.ai.error.${eo}`, no = Symbol.for(to), ro = class extends (Ki =
|
|
2938
|
+
}, eo = "AI_StreamProviderError", to = `vercel.ai.error.${eo}`, no = Symbol.for(to), ro = class extends (Ki = z, Gi = no, Ki) {
|
|
2939
2939
|
constructor({ message: e, type: t, code: n, statusCode: r, isRetryable: i = io(r), data: a, cause: o }) {
|
|
2940
2940
|
super({
|
|
2941
2941
|
name: eo,
|
|
@@ -2944,13 +2944,13 @@ var hi, gi, _i, vi, yi, bi, xi, Si, Ci, wi, Ti, Ei, Di, Oi, ki, Ai, ji, Mi, Ni,
|
|
|
2944
2944
|
}), this[Gi] = !0, this.type = t, this.code = n, this.statusCode = r, this.isRetryable = i, this.data = a;
|
|
2945
2945
|
}
|
|
2946
2946
|
static isInstance(e) {
|
|
2947
|
-
return
|
|
2947
|
+
return z.hasMarker(e, to);
|
|
2948
2948
|
}
|
|
2949
2949
|
};
|
|
2950
2950
|
function io(e) {
|
|
2951
2951
|
return e != null && (e === 408 || e === 409 || e === 429 || e >= 500);
|
|
2952
2952
|
}
|
|
2953
|
-
var ao, oo, so, co, lo, uo, fo, po, mo, ho, go, _o, vo, yo, bo = "AI_ToolCallRepairError", xo = `vercel.ai.error.${bo}`, So = Symbol.for(xo), Co = class extends (oo =
|
|
2953
|
+
var ao, oo, so, co, lo, uo, fo, po, mo, ho, go, _o, vo, yo, bo = "AI_ToolCallRepairError", xo = `vercel.ai.error.${bo}`, So = Symbol.for(xo), Co = class extends (oo = z, ao = So, oo) {
|
|
2954
2954
|
constructor({ cause: e, originalError: t, message: n = `Error repairing tool call: ${T(e)}` }) {
|
|
2955
2955
|
super({
|
|
2956
2956
|
name: bo,
|
|
@@ -2959,9 +2959,9 @@ var ao, oo, so, co, lo, uo, fo, po, mo, ho, go, _o, vo, yo, bo = "AI_ToolCallRep
|
|
|
2959
2959
|
}), this[ao] = !0, this.originalError = t;
|
|
2960
2960
|
}
|
|
2961
2961
|
static isInstance(e) {
|
|
2962
|
-
return
|
|
2962
|
+
return z.hasMarker(e, xo);
|
|
2963
2963
|
}
|
|
2964
|
-
}, wo = "AI_ToolChoiceViolationError", To = `vercel.ai.error.${wo}`, Eo = Symbol.for(To), Do = class extends (co =
|
|
2964
|
+
}, wo = "AI_ToolChoiceViolationError", To = `vercel.ai.error.${wo}`, Eo = Symbol.for(To), Do = class extends (co = z, so = Eo, co) {
|
|
2965
2965
|
constructor({ toolChoice: e, finishReason: t, provider: n, modelId: r, content: i, message: a = e.type === "required" ? "Model response did not contain a tool call even though tool choice was required." : `Model response did not contain a call to the required tool '${e.toolName}'.` }) {
|
|
2966
2966
|
super({
|
|
2967
2967
|
name: wo,
|
|
@@ -2969,16 +2969,16 @@ var ao, oo, so, co, lo, uo, fo, po, mo, ho, go, _o, vo, yo, bo = "AI_ToolCallRep
|
|
|
2969
2969
|
}), this[so] = !0, this.toolChoice = e, this.finishReason = t, this.provider = n, this.modelId = r, this.content = i;
|
|
2970
2970
|
}
|
|
2971
2971
|
static isInstance(e) {
|
|
2972
|
-
return
|
|
2972
|
+
return z.hasMarker(e, To);
|
|
2973
2973
|
}
|
|
2974
|
-
}, Oo = class extends
|
|
2974
|
+
}, Oo = class extends z {
|
|
2975
2975
|
constructor(e) {
|
|
2976
2976
|
super({
|
|
2977
2977
|
name: "AI_UnsupportedModelVersionError",
|
|
2978
2978
|
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".`
|
|
2979
2979
|
}), this.version = e.version, this.provider = e.provider, this.modelId = e.modelId;
|
|
2980
2980
|
}
|
|
2981
|
-
}, ko = "AI_UIMessageStreamError", Ao = `vercel.ai.error.${ko}`, jo = Symbol.for(Ao), Mo = class extends (uo =
|
|
2981
|
+
}, ko = "AI_UIMessageStreamError", Ao = `vercel.ai.error.${ko}`, jo = Symbol.for(Ao), Mo = class extends (uo = z, lo = jo, uo) {
|
|
2982
2982
|
constructor({ chunkType: e, chunkId: t, message: n }) {
|
|
2983
2983
|
super({
|
|
2984
2984
|
name: ko,
|
|
@@ -2986,9 +2986,9 @@ var ao, oo, so, co, lo, uo, fo, po, mo, ho, go, _o, vo, yo, bo = "AI_ToolCallRep
|
|
|
2986
2986
|
}), this[lo] = !0, this.chunkType = e, this.chunkId = t;
|
|
2987
2987
|
}
|
|
2988
2988
|
static isInstance(e) {
|
|
2989
|
-
return
|
|
2989
|
+
return z.hasMarker(e, Ao);
|
|
2990
2990
|
}
|
|
2991
|
-
}, No = "AI_InvalidDataContentError", Po = `vercel.ai.error.${No}`, Fo = Symbol.for(Po), Io = class extends (po =
|
|
2991
|
+
}, No = "AI_InvalidDataContentError", Po = `vercel.ai.error.${No}`, Fo = Symbol.for(Po), Io = class extends (po = z, fo = Fo, po) {
|
|
2992
2992
|
constructor({ content: e, cause: t, message: n = `Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof e}.` }) {
|
|
2993
2993
|
super({
|
|
2994
2994
|
name: No,
|
|
@@ -2997,9 +2997,9 @@ var ao, oo, so, co, lo, uo, fo, po, mo, ho, go, _o, vo, yo, bo = "AI_ToolCallRep
|
|
|
2997
2997
|
}), this[fo] = !0, this.content = e;
|
|
2998
2998
|
}
|
|
2999
2999
|
static isInstance(e) {
|
|
3000
|
-
return
|
|
3000
|
+
return z.hasMarker(e, Po);
|
|
3001
3001
|
}
|
|
3002
|
-
}, Lo = "AI_InvalidMessageRoleError", Ro = `vercel.ai.error.${Lo}`, zo = Symbol.for(Ro), Bo = class extends (ho =
|
|
3002
|
+
}, Lo = "AI_InvalidMessageRoleError", Ro = `vercel.ai.error.${Lo}`, zo = Symbol.for(Ro), Bo = class extends (ho = z, mo = zo, ho) {
|
|
3003
3003
|
constructor({ role: e, message: t = `Invalid message role: '${e}'. Must be one of: "system", "user", "assistant", "tool".` }) {
|
|
3004
3004
|
super({
|
|
3005
3005
|
name: Lo,
|
|
@@ -3007,9 +3007,9 @@ var ao, oo, so, co, lo, uo, fo, po, mo, ho, go, _o, vo, yo, bo = "AI_ToolCallRep
|
|
|
3007
3007
|
}), this[mo] = !0, this.role = e;
|
|
3008
3008
|
}
|
|
3009
3009
|
static isInstance(e) {
|
|
3010
|
-
return
|
|
3010
|
+
return z.hasMarker(e, Ro);
|
|
3011
3011
|
}
|
|
3012
|
-
}, Vo = "AI_MessageConversionError", Ho = `vercel.ai.error.${Vo}`, Uo = Symbol.for(Ho), Wo = class extends (_o =
|
|
3012
|
+
}, Vo = "AI_MessageConversionError", Ho = `vercel.ai.error.${Vo}`, Uo = Symbol.for(Ho), Wo = class extends (_o = z, go = Uo, _o) {
|
|
3013
3013
|
constructor({ originalMessage: e, message: t }) {
|
|
3014
3014
|
super({
|
|
3015
3015
|
name: Vo,
|
|
@@ -3017,9 +3017,9 @@ var ao, oo, so, co, lo, uo, fo, po, mo, ho, go, _o, vo, yo, bo = "AI_ToolCallRep
|
|
|
3017
3017
|
}), this[go] = !0, this.originalMessage = e;
|
|
3018
3018
|
}
|
|
3019
3019
|
static isInstance(e) {
|
|
3020
|
-
return
|
|
3020
|
+
return z.hasMarker(e, Ho);
|
|
3021
3021
|
}
|
|
3022
|
-
}, Go = "AI_RetryError", Ko = `vercel.ai.error.${Go}`, qo = Symbol.for(Ko), Jo = class extends (yo =
|
|
3022
|
+
}, Go = "AI_RetryError", Ko = `vercel.ai.error.${Go}`, qo = Symbol.for(Ko), Jo = class extends (yo = z, vo = qo, yo) {
|
|
3023
3023
|
constructor({ message: e, reason: t, errors: n }) {
|
|
3024
3024
|
super({
|
|
3025
3025
|
name: Go,
|
|
@@ -3027,7 +3027,7 @@ var ao, oo, so, co, lo, uo, fo, po, mo, ho, go, _o, vo, yo, bo = "AI_ToolCallRep
|
|
|
3027
3027
|
}), this[vo] = !0, this.reason = t, this.errors = n, this.lastError = n[n.length - 1];
|
|
3028
3028
|
}
|
|
3029
3029
|
static isInstance(e) {
|
|
3030
|
-
return
|
|
3030
|
+
return z.hasMarker(e, Ko);
|
|
3031
3031
|
}
|
|
3032
3032
|
};
|
|
3033
3033
|
function Yo({ warning: e, provider: t, model: n }) {
|
|
@@ -3456,12 +3456,12 @@ function Os(e) {
|
|
|
3456
3456
|
var ks = "7.0.122", As = async ({ url: e, maxBytes: t, abortSignal: n }) => {
|
|
3457
3457
|
let r = e.toString();
|
|
3458
3458
|
try {
|
|
3459
|
-
let e = j({}, `ai-sdk/${ks}`,
|
|
3459
|
+
let e = j({}, `ai-sdk/${ks}`, F()), i = await o({
|
|
3460
3460
|
url: r,
|
|
3461
3461
|
headers: e,
|
|
3462
3462
|
abortSignal: n
|
|
3463
3463
|
});
|
|
3464
|
-
if (!i.ok) throw await
|
|
3464
|
+
if (!i.ok) throw await xe(i), new Ve({
|
|
3465
3465
|
url: r,
|
|
3466
3466
|
statusCode: i.status,
|
|
3467
3467
|
statusText: i.statusText
|
|
@@ -3475,7 +3475,7 @@ var ks = "7.0.122", As = async ({ url: e, maxBytes: t, abortSignal: n }) => {
|
|
|
3475
3475
|
mediaType: i.headers.get("content-type") ?? void 0
|
|
3476
3476
|
};
|
|
3477
3477
|
} catch (e) {
|
|
3478
|
-
throw
|
|
3478
|
+
throw Ve.isInstance(e) ? e : new Ve({
|
|
3479
3479
|
url: r,
|
|
3480
3480
|
cause: e
|
|
3481
3481
|
});
|
|
@@ -3542,7 +3542,7 @@ function Fs(e) {
|
|
|
3542
3542
|
data: e
|
|
3543
3543
|
},
|
|
3544
3544
|
mediaType: void 0
|
|
3545
|
-
} : e instanceof ArrayBuffer ||
|
|
3545
|
+
} : e instanceof ArrayBuffer || I(e) ? {
|
|
3546
3546
|
data: {
|
|
3547
3547
|
type: "data",
|
|
3548
3548
|
data: new Uint8Array(e)
|
|
@@ -3593,7 +3593,7 @@ function Is(e) {
|
|
|
3593
3593
|
} catch {
|
|
3594
3594
|
return Fs(e);
|
|
3595
3595
|
}
|
|
3596
|
-
return
|
|
3596
|
+
return we(e) ? {
|
|
3597
3597
|
data: {
|
|
3598
3598
|
type: "reference",
|
|
3599
3599
|
reference: e
|
|
@@ -3624,7 +3624,7 @@ async function Ls({ prompt: e, supportedUrls: t, download: n, abortSignal: r, pr
|
|
|
3624
3624
|
};
|
|
3625
3625
|
}).filter((e) => e.data.type === "url").map((e) => ({
|
|
3626
3626
|
url: e.data.url,
|
|
3627
|
-
isUrlSupportedByModel: e.mediaType != null &&
|
|
3627
|
+
isUrlSupportedByModel: e.mediaType != null && ke({
|
|
3628
3628
|
url: e.data.url.toString(),
|
|
3629
3629
|
mediaType: e.mediaType,
|
|
3630
3630
|
supportedUrls: n
|
|
@@ -3646,7 +3646,7 @@ async function Ls({ prompt: e, supportedUrls: t, download: n, abortSignal: r, pr
|
|
|
3646
3646
|
let c = [...e.instructions == null ? [] : typeof e.instructions == "string" ? [{
|
|
3647
3647
|
role: "system",
|
|
3648
3648
|
content: e.instructions
|
|
3649
|
-
}] :
|
|
3649
|
+
}] : Ne(e.instructions).map((e) => ({
|
|
3650
3650
|
role: "system",
|
|
3651
3651
|
content: e.content,
|
|
3652
3652
|
providerOptions: e.providerOptions
|
|
@@ -4134,7 +4134,7 @@ async function qs({ tools: e, toolOrder: t, toolsContext: n = {}, experimental_s
|
|
|
4134
4134
|
a.push({
|
|
4135
4135
|
type: "function",
|
|
4136
4136
|
name: i,
|
|
4137
|
-
inputSchema: await
|
|
4137
|
+
inputSchema: await qe(o.inputSchema).jsonSchema,
|
|
4138
4138
|
...e == null ? {} : { description: e },
|
|
4139
4139
|
...s == null ? {} : { inputExamples: s },
|
|
4140
4140
|
...t == null ? {} : { providerOptions: t },
|
|
@@ -4178,22 +4178,22 @@ function $s(e, t) {
|
|
|
4178
4178
|
}
|
|
4179
4179
|
var X = {
|
|
4180
4180
|
array: S,
|
|
4181
|
-
boolean:
|
|
4182
|
-
custom:
|
|
4183
|
-
discriminatedUnion:
|
|
4184
|
-
enum:
|
|
4181
|
+
boolean: ue,
|
|
4182
|
+
custom: le,
|
|
4183
|
+
discriminatedUnion: fe,
|
|
4184
|
+
enum: ce,
|
|
4185
4185
|
instanceof: g,
|
|
4186
|
-
lazy:
|
|
4187
|
-
literal:
|
|
4188
|
-
looseObject:
|
|
4189
|
-
never:
|
|
4186
|
+
lazy: Ce,
|
|
4187
|
+
literal: Ge,
|
|
4188
|
+
looseObject: Le,
|
|
4189
|
+
never: He,
|
|
4190
4190
|
null: C,
|
|
4191
|
-
number:
|
|
4192
|
-
object:
|
|
4193
|
-
record:
|
|
4194
|
-
string:
|
|
4195
|
-
union:
|
|
4196
|
-
unknown:
|
|
4191
|
+
number: Oe,
|
|
4192
|
+
object: ge,
|
|
4193
|
+
record: We,
|
|
4194
|
+
string: Pe,
|
|
4195
|
+
union: Se,
|
|
4196
|
+
unknown: Te
|
|
4197
4197
|
}, ec = X.lazy(() => X.union([
|
|
4198
4198
|
X.null(),
|
|
4199
4199
|
X.string(),
|
|
@@ -4205,7 +4205,7 @@ var X = {
|
|
|
4205
4205
|
X.string(),
|
|
4206
4206
|
X.instanceof(Uint8Array),
|
|
4207
4207
|
X.instanceof(ArrayBuffer),
|
|
4208
|
-
X.custom(
|
|
4208
|
+
X.custom(I, { message: "Must be a Buffer" })
|
|
4209
4209
|
]), nc = X.record(X.string(), X.string()), rc = X.object({
|
|
4210
4210
|
type: X.literal("text"),
|
|
4211
4211
|
text: X.string(),
|
|
@@ -4431,7 +4431,7 @@ async function xc({ allowSystemInMessages: e = !1, system: t, instructions: n =
|
|
|
4431
4431
|
prompt: r,
|
|
4432
4432
|
message: "prompt and messages cannot be defined at the same time"
|
|
4433
4433
|
});
|
|
4434
|
-
if (typeof n != "string" && !
|
|
4434
|
+
if (typeof n != "string" && !Ne(n).every((e) => e.role === "system")) throw new Ze({
|
|
4435
4435
|
prompt: r,
|
|
4436
4436
|
message: "instructions must be a string, SystemModelMessage, or array of SystemModelMessage"
|
|
4437
4437
|
});
|
|
@@ -4452,7 +4452,7 @@ async function xc({ allowSystemInMessages: e = !1, system: t, instructions: n =
|
|
|
4452
4452
|
prompt: r,
|
|
4453
4453
|
message: "System messages are not allowed in the prompt or messages fields. Use the instructions option instead."
|
|
4454
4454
|
});
|
|
4455
|
-
let a = await
|
|
4455
|
+
let a = await H({
|
|
4456
4456
|
value: i,
|
|
4457
4457
|
schema: X.array(bc)
|
|
4458
4458
|
});
|
|
@@ -4469,7 +4469,7 @@ async function xc({ allowSystemInMessages: e = !1, system: t, instructions: n =
|
|
|
4469
4469
|
function Sc(e) {
|
|
4470
4470
|
if (!Bt.isInstance(e)) return e;
|
|
4471
4471
|
let t = "https://ai-sdk.dev/unauthenticated-ai-gateway";
|
|
4472
|
-
return process.env.NODE_ENV === "production" ? new
|
|
4472
|
+
return process.env.NODE_ENV === "production" ? new z({
|
|
4473
4473
|
name: "GatewayError",
|
|
4474
4474
|
message: `Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${t}`
|
|
4475
4475
|
}) : Object.assign(/* @__PURE__ */ Error(`[1m[31mUnauthenticated request to AI Gateway.[0m\n\nTo authenticate, set the [33mAI_GATEWAY_API_KEY[0m environment variable with your API key.\n\nAlternatively, you can use a provider module instead of the AI Gateway.\n\nLearn more: [34m${t}[0m\n\n`), { name: "GatewayAuthenticationError" });
|
|
@@ -4528,7 +4528,7 @@ function Oc() {
|
|
|
4528
4528
|
return globalThis?.performance?.now() ?? Date.now();
|
|
4529
4529
|
}
|
|
4530
4530
|
async function $(e) {
|
|
4531
|
-
await Promise.all(
|
|
4531
|
+
await Promise.all(Ne(e.callbacks).map(async (t) => {
|
|
4532
4532
|
try {
|
|
4533
4533
|
await t?.(e.event);
|
|
4534
4534
|
} catch {}
|
|
@@ -4539,9 +4539,9 @@ var kc = ({ maxRetries: e = 2, initialDelayInMs: t = 2e3, backoffFactor: n = 2,
|
|
|
4539
4539
|
initialDelayInMs: t,
|
|
4540
4540
|
backoffFactor: n,
|
|
4541
4541
|
abortSignal: r,
|
|
4542
|
-
shouldRetry: async (e) => e instanceof Error && (
|
|
4542
|
+
shouldRetry: async (e) => e instanceof Error && (pe.isInstance(e) && !0 === e.isRetryable || It.isInstance(e) && !0 === e.isRetryable) || i != null && await i(e),
|
|
4543
4543
|
getDelayInMs: ({ error: e, exponentialBackoffDelay: t }) => function({ error: e, exponentialBackoffDelay: t }) {
|
|
4544
|
-
let n =
|
|
4544
|
+
let n = pe.isInstance(e) ? e.responseHeaders : pe.isInstance(e.cause) ? e.cause.responseHeaders : void 0;
|
|
4545
4545
|
if (!n) return t;
|
|
4546
4546
|
let r, i = n["retry-after-ms"];
|
|
4547
4547
|
if (i) {
|
|
@@ -4645,7 +4645,7 @@ var Pc = class {
|
|
|
4645
4645
|
return this.base64Data ??= Qe(this.uint8ArrayData), this.base64Data;
|
|
4646
4646
|
}
|
|
4647
4647
|
get uint8Array() {
|
|
4648
|
-
return this.uint8ArrayData ??=
|
|
4648
|
+
return this.uint8ArrayData ??= B(this.base64Data), this.uint8ArrayData;
|
|
4649
4649
|
}
|
|
4650
4650
|
}, Fc = class extends Pc {
|
|
4651
4651
|
constructor() {
|
|
@@ -4853,7 +4853,7 @@ var Hc = Symbol.for("vercel.ai.toolSearch");
|
|
|
4853
4853
|
function Uc() {
|
|
4854
4854
|
return Object.assign(E({
|
|
4855
4855
|
description: "Search for tools by keywords in their names and descriptions. Returns up to five matching tools. Matches become available on the next model step, after this execution finishes. Wait for their tool definitions before calling the discovered tools. If no tools match, try different keywords.",
|
|
4856
|
-
inputSchema:
|
|
4856
|
+
inputSchema: _e({
|
|
4857
4857
|
type: "object",
|
|
4858
4858
|
properties: { query: {
|
|
4859
4859
|
type: "string",
|
|
@@ -4862,7 +4862,7 @@ function Uc() {
|
|
|
4862
4862
|
required: ["query"],
|
|
4863
4863
|
additionalProperties: !1
|
|
4864
4864
|
}),
|
|
4865
|
-
outputSchema:
|
|
4865
|
+
outputSchema: _e({
|
|
4866
4866
|
type: "object",
|
|
4867
4867
|
properties: { tools: {
|
|
4868
4868
|
type: "array",
|
|
@@ -4950,7 +4950,7 @@ async function qc({ toolName: e, context: t, contextSchema: n }) {
|
|
|
4950
4950
|
}
|
|
4951
4951
|
async function Jc({ toolCall: e, tools: t, toolsContext: n, callId: r, messages: i, abortSignal: a, timeout: o, experimental_sandbox: s, onPreliminaryToolResult: c, onToolExecutionStart: l, onToolExecutionEnd: u, executeToolInTelemetryContext: d = async ({ execute: e }) => await e(), runInTracingChannelSpan: f = async ({ execute: e }) => await e() }) {
|
|
4952
4952
|
let { toolName: p, toolCallId: m, input: h } = e, g = Q(t, p);
|
|
4953
|
-
if (!
|
|
4953
|
+
if (!de(g)) return;
|
|
4954
4954
|
let _ = await qc({
|
|
4955
4955
|
toolName: p,
|
|
4956
4956
|
context: Q(n, p),
|
|
@@ -5270,7 +5270,7 @@ var el = () => ({
|
|
|
5270
5270
|
parsePartialOutput: async ({ text: e }) => ({ partial: e }),
|
|
5271
5271
|
createElementStreamTransform() {}
|
|
5272
5272
|
}), tl = ({ schema: e, name: t, description: n }) => {
|
|
5273
|
-
let r =
|
|
5273
|
+
let r = qe(e);
|
|
5274
5274
|
return {
|
|
5275
5275
|
name: "object",
|
|
5276
5276
|
responseFormat: K(r.jsonSchema).then((e) => ({
|
|
@@ -5289,7 +5289,7 @@ var el = () => ({
|
|
|
5289
5289
|
usage: t.usage,
|
|
5290
5290
|
finishReason: t.finishReason
|
|
5291
5291
|
});
|
|
5292
|
-
let i = await
|
|
5292
|
+
let i = await H({
|
|
5293
5293
|
value: n.value,
|
|
5294
5294
|
schema: r
|
|
5295
5295
|
});
|
|
@@ -5326,7 +5326,7 @@ var el = () => ({
|
|
|
5326
5326
|
value: t,
|
|
5327
5327
|
message: "minItems must be less than or equal to maxItems"
|
|
5328
5328
|
});
|
|
5329
|
-
let o =
|
|
5329
|
+
let o = qe(e);
|
|
5330
5330
|
return {
|
|
5331
5331
|
name: "array",
|
|
5332
5332
|
responseFormat: K(o.jsonSchema).then((e) => {
|
|
@@ -5388,7 +5388,7 @@ var el = () => ({
|
|
|
5388
5388
|
});
|
|
5389
5389
|
let l = [];
|
|
5390
5390
|
for (let t of s.elements) {
|
|
5391
|
-
let n = await
|
|
5391
|
+
let n = await H({
|
|
5392
5392
|
value: t,
|
|
5393
5393
|
schema: o
|
|
5394
5394
|
});
|
|
@@ -5415,7 +5415,7 @@ var el = () => ({
|
|
|
5415
5415
|
if (typeof e != "object" || !e || !("elements" in e) || !Array.isArray(e.elements)) return;
|
|
5416
5416
|
let n = t.state === "repaired-parse" && e.elements.length > 0 ? e.elements.slice(0, -1) : e.elements, r = [];
|
|
5417
5417
|
for (let e of n) {
|
|
5418
|
-
let t = await
|
|
5418
|
+
let t = await H({
|
|
5419
5419
|
value: e,
|
|
5420
5420
|
schema: o
|
|
5421
5421
|
});
|
|
@@ -5594,7 +5594,7 @@ async function ul({ toolCall: e, tools: t, repairToolCall: n, refineToolInput: r
|
|
|
5594
5594
|
tools: t,
|
|
5595
5595
|
inputSchema: async ({ toolName: e }) => {
|
|
5596
5596
|
let n = Q(t, e)?.inputSchema;
|
|
5597
|
-
return await
|
|
5597
|
+
return await qe(n).jsonSchema;
|
|
5598
5598
|
},
|
|
5599
5599
|
instructions: a,
|
|
5600
5600
|
system: a,
|
|
@@ -5676,7 +5676,7 @@ async function pl({ toolCall: e, tools: t }) {
|
|
|
5676
5676
|
availableTools: Object.keys(t)
|
|
5677
5677
|
});
|
|
5678
5678
|
}
|
|
5679
|
-
let i =
|
|
5679
|
+
let i = qe(r.inputSchema), a = e.input.trim() === "" ? await H({
|
|
5680
5680
|
value: {},
|
|
5681
5681
|
schema: i
|
|
5682
5682
|
}) : await O({
|
|
@@ -5853,7 +5853,7 @@ function Ol(e, t, n = !1) {
|
|
|
5853
5853
|
}
|
|
5854
5854
|
function kl({ telemetry: e }) {
|
|
5855
5855
|
if (!1 === e?.isEnabled) return {};
|
|
5856
|
-
let t = e?.integrations, n = t == null ? globalThis.AI_SDK_TELEMETRY_INTEGRATIONS ?? [] :
|
|
5856
|
+
let t = e?.integrations, n = t == null ? globalThis.AI_SDK_TELEMETRY_INTEGRATIONS ?? [] : Ne(t), r = {
|
|
5857
5857
|
recordInputs: e?.recordInputs,
|
|
5858
5858
|
recordOutputs: e?.recordOutputs,
|
|
5859
5859
|
functionId: e?.functionId,
|
|
@@ -6320,7 +6320,7 @@ function ql(e, t, n, r) {
|
|
|
6320
6320
|
]));
|
|
6321
6321
|
}
|
|
6322
6322
|
async function Jl({ secret: e, signature: t, approvalId: n, toolCallId: r, toolName: i, input: a }) {
|
|
6323
|
-
let o = await Kl(e), s = await Wl(a), c =
|
|
6323
|
+
let o = await Kl(e), s = await Wl(a), c = B(t), l = ql(n, r, i, s);
|
|
6324
6324
|
if (await crypto.subtle.verify("HMAC", o, c, l)) return !0;
|
|
6325
6325
|
if (!n.includes("\n") && !r.includes("\n") && !i.includes("\n")) {
|
|
6326
6326
|
let e = function(e, t, n, r) {
|
|
@@ -6365,10 +6365,10 @@ async function Xl({ approvedToolApprovals: e, tools: t, toolApproval: n, message
|
|
|
6365
6365
|
reason: "invalid signature"
|
|
6366
6366
|
});
|
|
6367
6367
|
}
|
|
6368
|
-
if (
|
|
6369
|
-
let t = Object.prototype.hasOwnProperty.call(e, "inputSchemaInput"), n = await
|
|
6368
|
+
if (de(p) && p.inputSchema != null) {
|
|
6369
|
+
let t = Object.prototype.hasOwnProperty.call(e, "inputSchemaInput"), n = await H({
|
|
6370
6370
|
value: t ? e.inputSchemaInput : f.input,
|
|
6371
|
-
schema:
|
|
6371
|
+
schema: qe(p.inputSchema)
|
|
6372
6372
|
}), r;
|
|
6373
6373
|
if (n.success) try {
|
|
6374
6374
|
Rl((await dl({
|
|
@@ -6424,83 +6424,83 @@ var Zl = c({
|
|
|
6424
6424
|
prefix: "call",
|
|
6425
6425
|
size: 24
|
|
6426
6426
|
});
|
|
6427
|
-
async function $l({ model: e, tools: t, toolChoice: n, instructions: r, system: i, prompt: a, messages: o, allowSystemInMessages: s, maxRetries: c, abortSignal: l, timeout: u, headers: d, stopWhen: f = Nl(1), experimental_sandbox: p, output: m, toolApproval: h, experimental_toolCallers: g, experimental_toolApprovalSecret: _, experimental_telemetry: v, telemetry: y = v, providerOptions: b, activeTools: x, toolOrder: S, prepareStep: C, experimental_repairToolCall: w, repairToolCall: ee = w, experimental_refineToolInput: E, experimental_download: D, runtimeContext: O = {}, toolsContext: k = {}, experimental_include: A, include: te = A, _internal: { generateId: ne = Zl, generateCallId: re = Ql, now: ie = Oc } = {}, onStart: M, experimental_onStart: N, onStepStart: ae, experimental_onStepStart: P, onLanguageModelCallStart: oe, experimental_onLanguageModelCallStart:
|
|
6427
|
+
async function $l({ model: e, tools: t, toolChoice: n, instructions: r, system: i, prompt: a, messages: o, allowSystemInMessages: s, maxRetries: c, abortSignal: l, timeout: u, headers: d, stopWhen: f = Nl(1), experimental_sandbox: p, output: m, toolApproval: h, experimental_toolCallers: g, experimental_toolApprovalSecret: _, experimental_telemetry: v, telemetry: y = v, providerOptions: b, activeTools: x, toolOrder: S, prepareStep: C, experimental_repairToolCall: w, repairToolCall: ee = w, experimental_refineToolInput: E, experimental_download: D, runtimeContext: O = {}, toolsContext: k = {}, experimental_include: A, include: te = A, _internal: { generateId: ne = Zl, generateCallId: re = Ql, now: ie = Oc } = {}, onStart: M, experimental_onStart: N, onStepStart: ae, experimental_onStepStart: P, onLanguageModelCallStart: oe, experimental_onLanguageModelCallStart: se, onLanguageModelCallEnd: F, experimental_onLanguageModelCallEnd: ce, onToolExecutionStart: le, onToolExecutionEnd: I, experimental_onToolCallStart: ue, experimental_onToolCallFinish: de, onStepEnd: fe, onStepFinish: pe, onFinish: me, onEnd: he = me, ...ge }) {
|
|
6428
6428
|
te = {
|
|
6429
6429
|
requestBody: te?.requestBody ?? !1,
|
|
6430
6430
|
requestMessages: te?.requestMessages ?? !1,
|
|
6431
6431
|
responseBody: te?.responseBody ?? !1
|
|
6432
6432
|
};
|
|
6433
|
-
let
|
|
6433
|
+
let _e = vs(e), ve = zc({
|
|
6434
6434
|
tools: t,
|
|
6435
6435
|
toolCallers: g
|
|
6436
|
-
}),
|
|
6436
|
+
}), ye = Gc({
|
|
6437
6437
|
tools: t,
|
|
6438
|
-
toolCallers:
|
|
6439
|
-
}),
|
|
6440
|
-
Zs(u) != null &&
|
|
6438
|
+
toolCallers: ve
|
|
6439
|
+
}), be = Ne(f), L = M ?? N, xe = ae ?? P, Se = oe ?? se, Ce = F ?? ce, we = le ?? ue, R = I ?? de, Te = fe ?? pe, z = [];
|
|
6440
|
+
Zs(u) != null && z.push({
|
|
6441
6441
|
type: "unsupported",
|
|
6442
6442
|
feature: "timeout.firstChunkMs",
|
|
6443
6443
|
details: "The firstChunkMs timeout is only supported by streaming functions."
|
|
6444
|
-
}), Qs(u) != null &&
|
|
6444
|
+
}), Qs(u) != null && z.push({
|
|
6445
6445
|
type: "unsupported",
|
|
6446
6446
|
feature: "timeout.chunkMs",
|
|
6447
6447
|
details: "The chunkMs timeout is only supported by streaming functions."
|
|
6448
|
-
}),
|
|
6449
|
-
warnings:
|
|
6450
|
-
provider:
|
|
6451
|
-
model:
|
|
6448
|
+
}), z.length > 0 && Qo({
|
|
6449
|
+
warnings: z,
|
|
6450
|
+
provider: _e.provider,
|
|
6451
|
+
model: _e.modelId
|
|
6452
6452
|
});
|
|
6453
|
-
let
|
|
6453
|
+
let Ee = Ys(u), B = Xs(u), De = B == null ? void 0 : new AbortController(), Oe = Dc(l, Ee, De?.signal), { maxRetries: ke, retry: Ae } = Ac({
|
|
6454
6454
|
maxRetries: c,
|
|
6455
|
-
abortSignal:
|
|
6456
|
-
}),
|
|
6455
|
+
abortSignal: Oe
|
|
6456
|
+
}), V = Gs(ge), je = j(d ?? {}, `ai/${ks}`), Me = await xc({
|
|
6457
6457
|
instructions: r,
|
|
6458
6458
|
system: i,
|
|
6459
6459
|
prompt: a,
|
|
6460
6460
|
messages: o,
|
|
6461
6461
|
allowSystemInMessages: s
|
|
6462
|
-
}),
|
|
6462
|
+
}), H = re(), Pe = Ml({
|
|
6463
6463
|
telemetry: y,
|
|
6464
6464
|
includeRuntimeContext: y?.includeRuntimeContext,
|
|
6465
6465
|
includeToolsContext: y?.includeToolsContext
|
|
6466
|
-
}),
|
|
6467
|
-
callId:
|
|
6466
|
+
}), Fe = Pe.runInTracingChannelSpan ?? (async ({ execute: e }) => await e()), Ie = {
|
|
6467
|
+
callId: H,
|
|
6468
6468
|
operationId: "ai.generateText",
|
|
6469
|
-
provider:
|
|
6470
|
-
modelId:
|
|
6471
|
-
instructions:
|
|
6472
|
-
messages:
|
|
6469
|
+
provider: _e.provider,
|
|
6470
|
+
modelId: _e.modelId,
|
|
6471
|
+
instructions: Me.instructions,
|
|
6472
|
+
messages: Me.messages,
|
|
6473
6473
|
tools: t,
|
|
6474
6474
|
toolChoice: n,
|
|
6475
6475
|
activeTools: x,
|
|
6476
6476
|
toolOrder: S,
|
|
6477
|
-
maxOutputTokens:
|
|
6478
|
-
temperature:
|
|
6479
|
-
topP:
|
|
6480
|
-
topK:
|
|
6481
|
-
presencePenalty:
|
|
6482
|
-
frequencyPenalty:
|
|
6483
|
-
stopSequences:
|
|
6484
|
-
seed:
|
|
6485
|
-
reasoning:
|
|
6486
|
-
maxRetries:
|
|
6477
|
+
maxOutputTokens: V.maxOutputTokens,
|
|
6478
|
+
temperature: V.temperature,
|
|
6479
|
+
topP: V.topP,
|
|
6480
|
+
topK: V.topK,
|
|
6481
|
+
presencePenalty: V.presencePenalty,
|
|
6482
|
+
frequencyPenalty: V.frequencyPenalty,
|
|
6483
|
+
stopSequences: V.stopSequences,
|
|
6484
|
+
seed: V.seed,
|
|
6485
|
+
reasoning: V.reasoning,
|
|
6486
|
+
maxRetries: ke,
|
|
6487
6487
|
timeout: u,
|
|
6488
|
-
headers:
|
|
6488
|
+
headers: je,
|
|
6489
6489
|
providerOptions: b,
|
|
6490
6490
|
output: m,
|
|
6491
6491
|
runtimeContext: O,
|
|
6492
6492
|
toolsContext: k
|
|
6493
6493
|
};
|
|
6494
|
-
return await
|
|
6494
|
+
return await Fe({
|
|
6495
6495
|
type: "generateText",
|
|
6496
|
-
event:
|
|
6496
|
+
event: Ie,
|
|
6497
6497
|
execute: async () => {
|
|
6498
6498
|
await $({
|
|
6499
|
-
event:
|
|
6500
|
-
callbacks: [
|
|
6499
|
+
event: Ie,
|
|
6500
|
+
callbacks: [L, Pe.onStart]
|
|
6501
6501
|
});
|
|
6502
6502
|
try {
|
|
6503
|
-
let e =
|
|
6503
|
+
let e = Me.messages, r = [], { approvedToolApprovals: i, deniedToolApprovals: a } = Nc({ messages: e }), { approvedToolApprovals: o, deniedToolApprovals: s, invalidToolApprovals: c } = await Xl({
|
|
6504
6504
|
approvedToolApprovals: i.filter((e) => !e.toolCall.providerExecuted),
|
|
6505
6505
|
tools: t,
|
|
6506
6506
|
toolApproval: h,
|
|
@@ -6514,22 +6514,22 @@ async function $l({ model: e, tools: t, toolChoice: n, instructions: r, system:
|
|
|
6514
6514
|
let n = await eu({
|
|
6515
6515
|
toolCalls: o.map((e) => e.toolCall),
|
|
6516
6516
|
tools: t,
|
|
6517
|
-
callId:
|
|
6517
|
+
callId: H,
|
|
6518
6518
|
messages: e,
|
|
6519
|
-
abortSignal:
|
|
6519
|
+
abortSignal: Oe,
|
|
6520
6520
|
timeout: u,
|
|
6521
6521
|
experimental_sandbox: p,
|
|
6522
6522
|
toolsContext: k,
|
|
6523
6523
|
onToolExecutionStart: (e) => $({
|
|
6524
6524
|
event: e,
|
|
6525
|
-
callbacks: [
|
|
6525
|
+
callbacks: [we, Pe.onToolExecutionStart]
|
|
6526
6526
|
}),
|
|
6527
6527
|
onToolExecutionEnd: (e) => $({
|
|
6528
6528
|
event: e,
|
|
6529
|
-
callbacks: [
|
|
6529
|
+
callbacks: [R, Pe.onToolExecutionEnd]
|
|
6530
6530
|
}),
|
|
6531
|
-
executeToolInTelemetryContext:
|
|
6532
|
-
runInTracingChannelSpan:
|
|
6531
|
+
executeToolInTelemetryContext: Pe.executeTool,
|
|
6532
|
+
runInTracingChannelSpan: Fe
|
|
6533
6533
|
}), i = [];
|
|
6534
6534
|
for (let e of n) {
|
|
6535
6535
|
let n = e.output, r = await Us({
|
|
@@ -6573,117 +6573,117 @@ async function $l({ model: e, tools: t, toolChoice: n, instructions: r, system:
|
|
|
6573
6573
|
content: i
|
|
6574
6574
|
});
|
|
6575
6575
|
}
|
|
6576
|
-
let d = Gs(
|
|
6576
|
+
let d = Gs(ge), f, g = [], v = [], y = [], w = [], A = [], re = Me.instructions, j = [...e, ...r], M = /* @__PURE__ */ new Map();
|
|
6577
6577
|
do {
|
|
6578
|
-
A.length > 0 &&
|
|
6578
|
+
A.length > 0 && Oe?.throwIfAborted();
|
|
6579
6579
|
let i = jc({
|
|
6580
|
-
abortController:
|
|
6580
|
+
abortController: De,
|
|
6581
6581
|
label: "Step",
|
|
6582
|
-
timeoutMs:
|
|
6582
|
+
timeoutMs: B
|
|
6583
6583
|
}), a = A.length;
|
|
6584
6584
|
try {
|
|
6585
|
-
await
|
|
6585
|
+
await Fe({
|
|
6586
6586
|
type: "step",
|
|
6587
6587
|
event: {
|
|
6588
|
-
callId:
|
|
6588
|
+
callId: H,
|
|
6589
6589
|
stepNumber: a
|
|
6590
6590
|
},
|
|
6591
6591
|
execute: async () => {
|
|
6592
6592
|
let i = [...r, ...A.flatMap((e) => e.response.messages)], o = j, s = await C?.({
|
|
6593
|
-
model:
|
|
6593
|
+
model: _e,
|
|
6594
6594
|
steps: A,
|
|
6595
6595
|
stepNumber: A.length,
|
|
6596
6596
|
instructions: re,
|
|
6597
|
-
initialInstructions:
|
|
6597
|
+
initialInstructions: Me.instructions,
|
|
6598
6598
|
messages: o,
|
|
6599
6599
|
initialMessages: e,
|
|
6600
6600
|
responseMessages: i,
|
|
6601
6601
|
runtimeContext: O,
|
|
6602
6602
|
toolsContext: k,
|
|
6603
6603
|
experimental_sandbox: p
|
|
6604
|
-
}), c = s?.experimental_sandbox ?? p, l = vs(s?.model ??
|
|
6604
|
+
}), c = s?.experimental_sandbox ?? p, l = vs(s?.model ?? _e), N = s?.instructions ?? s?.system ?? re;
|
|
6605
6605
|
O = s?.runtimeContext ?? O, k = s?.toolsContext ?? k;
|
|
6606
6606
|
let ae = Yc({
|
|
6607
6607
|
tools: t,
|
|
6608
6608
|
activeTools: s?.activeTools ?? x
|
|
6609
|
-
}), { executionTools: P, modelTools: oe, toolCallerMessages:
|
|
6610
|
-
tools:
|
|
6609
|
+
}), { executionTools: P, modelTools: oe, toolCallerMessages: se } = Bc({
|
|
6610
|
+
tools: ye(ae, {
|
|
6611
6611
|
toolsContext: k,
|
|
6612
6612
|
experimental_sandbox: c
|
|
6613
6613
|
}),
|
|
6614
|
-
toolCallers:
|
|
6615
|
-
}),
|
|
6614
|
+
toolCallers: ve
|
|
6615
|
+
}), F = s?.toolOrder ?? S, ce = await qs({
|
|
6616
6616
|
tools: oe,
|
|
6617
|
-
toolOrder:
|
|
6617
|
+
toolOrder: F,
|
|
6618
6618
|
toolsContext: k,
|
|
6619
6619
|
experimental_sandbox: c
|
|
6620
|
-
}),
|
|
6620
|
+
}), le = Ks({ toolChoice: s?.toolChoice ?? n }), I = Vc({
|
|
6621
6621
|
messages: s?.messages ?? o,
|
|
6622
|
-
toolCallerMessages:
|
|
6623
|
-
}),
|
|
6622
|
+
toolCallerMessages: se
|
|
6623
|
+
}), ue = await Ls({
|
|
6624
6624
|
prompt: {
|
|
6625
6625
|
instructions: N,
|
|
6626
|
-
messages:
|
|
6626
|
+
messages: I
|
|
6627
6627
|
},
|
|
6628
6628
|
supportedUrls: await l.supportedUrls,
|
|
6629
6629
|
download: D,
|
|
6630
|
-
abortSignal:
|
|
6630
|
+
abortSignal: Oe,
|
|
6631
6631
|
provider: l.provider.split(".")[0]
|
|
6632
|
-
}),
|
|
6632
|
+
}), de = Ms(b, s?.providerOptions), fe = ml({
|
|
6633
6633
|
callSettings: d,
|
|
6634
6634
|
stepSettings: s
|
|
6635
6635
|
});
|
|
6636
6636
|
await $({
|
|
6637
6637
|
event: {
|
|
6638
|
-
callId:
|
|
6638
|
+
callId: H,
|
|
6639
6639
|
provider: l.provider,
|
|
6640
6640
|
modelId: l.modelId,
|
|
6641
6641
|
stepNumber: a,
|
|
6642
6642
|
instructions: N,
|
|
6643
|
-
messages:
|
|
6643
|
+
messages: I,
|
|
6644
6644
|
tools: t,
|
|
6645
6645
|
toolChoice: s?.toolChoice ?? n,
|
|
6646
6646
|
activeTools: s?.activeTools ?? x,
|
|
6647
|
-
toolOrder:
|
|
6647
|
+
toolOrder: F,
|
|
6648
6648
|
steps: [...A],
|
|
6649
|
-
providerOptions:
|
|
6649
|
+
providerOptions: de,
|
|
6650
6650
|
output: m,
|
|
6651
6651
|
runtimeContext: O,
|
|
6652
|
-
promptMessages:
|
|
6653
|
-
stepTools:
|
|
6654
|
-
stepToolChoice:
|
|
6652
|
+
promptMessages: ue,
|
|
6653
|
+
stepTools: ce,
|
|
6654
|
+
stepToolChoice: le,
|
|
6655
6655
|
toolsContext: k
|
|
6656
6656
|
},
|
|
6657
|
-
callbacks: [
|
|
6657
|
+
callbacks: [xe, Pe.onStepStart]
|
|
6658
6658
|
});
|
|
6659
|
-
let
|
|
6659
|
+
let pe = {
|
|
6660
6660
|
provider: l.provider,
|
|
6661
6661
|
modelId: l.modelId,
|
|
6662
6662
|
instructions: N,
|
|
6663
|
-
messages:
|
|
6664
|
-
tools:
|
|
6665
|
-
...de
|
|
6666
|
-
}, pe = {
|
|
6667
|
-
callId: U,
|
|
6663
|
+
messages: I,
|
|
6664
|
+
tools: ce,
|
|
6668
6665
|
...fe
|
|
6669
|
-
}, me =
|
|
6666
|
+
}, me = {
|
|
6667
|
+
callId: H,
|
|
6668
|
+
...pe
|
|
6669
|
+
}, he = ie();
|
|
6670
6670
|
await $({
|
|
6671
|
-
event:
|
|
6672
|
-
callbacks: [
|
|
6671
|
+
event: me,
|
|
6672
|
+
callbacks: [Se, Pe.onLanguageModelCallStart]
|
|
6673
6673
|
});
|
|
6674
|
-
let
|
|
6675
|
-
f = await
|
|
6676
|
-
let e = await
|
|
6677
|
-
...
|
|
6674
|
+
let ge = Pe.executeLanguageModelCall ?? (async ({ execute: e }) => await e());
|
|
6675
|
+
f = await Ae(async () => {
|
|
6676
|
+
let e = await ge({
|
|
6677
|
+
...me,
|
|
6678
6678
|
execute: async () => await l.doGenerate({
|
|
6679
|
-
...
|
|
6680
|
-
tools:
|
|
6681
|
-
toolChoice:
|
|
6679
|
+
...fe,
|
|
6680
|
+
tools: ce,
|
|
6681
|
+
toolChoice: le,
|
|
6682
6682
|
responseFormat: await m?.responseFormat,
|
|
6683
|
-
prompt:
|
|
6684
|
-
providerOptions:
|
|
6685
|
-
abortSignal:
|
|
6686
|
-
headers:
|
|
6683
|
+
prompt: ue,
|
|
6684
|
+
providerOptions: de,
|
|
6685
|
+
abortSignal: Oe,
|
|
6686
|
+
headers: je
|
|
6687
6687
|
})
|
|
6688
6688
|
}), t = {
|
|
6689
6689
|
id: e.response?.id ?? ne(),
|
|
@@ -6697,60 +6697,60 @@ async function $l({ model: e, tools: t, toolChoice: n, instructions: r, system:
|
|
|
6697
6697
|
response: t
|
|
6698
6698
|
};
|
|
6699
6699
|
});
|
|
6700
|
-
let
|
|
6700
|
+
let be = ie() - he, L = Cc(f.usage), z = await Promise.all(f.content.filter((e) => e.type === "tool-call").map((e) => ul({
|
|
6701
6701
|
toolCall: e,
|
|
6702
6702
|
tools: oe,
|
|
6703
6703
|
repairToolCall: ee,
|
|
6704
6704
|
refineToolInput: E,
|
|
6705
6705
|
instructions: N,
|
|
6706
|
-
messages:
|
|
6707
|
-
abortSignal:
|
|
6708
|
-
}))),
|
|
6706
|
+
messages: I,
|
|
6707
|
+
abortSignal: Oe
|
|
6708
|
+
}))), Ee = {}, B = {}, De = /* @__PURE__ */ new Set(), ke = /* @__PURE__ */ new WeakMap(), V = await Lc({
|
|
6709
6709
|
content: f.content,
|
|
6710
|
-
toolCalls:
|
|
6710
|
+
toolCalls: z,
|
|
6711
6711
|
toolOutputs: [],
|
|
6712
6712
|
toolApprovalRequests: [],
|
|
6713
6713
|
toolApprovalResponses: [],
|
|
6714
6714
|
tools: t,
|
|
6715
|
-
abortSignal:
|
|
6716
|
-
generatedFileDataCache:
|
|
6715
|
+
abortSignal: Oe,
|
|
6716
|
+
generatedFileDataCache: ke
|
|
6717
6717
|
});
|
|
6718
6718
|
await $({
|
|
6719
6719
|
event: {
|
|
6720
|
-
callId:
|
|
6720
|
+
callId: H,
|
|
6721
6721
|
provider: l.provider,
|
|
6722
6722
|
modelId: f.response.modelId,
|
|
6723
6723
|
finishReason: f.finishReason.unified,
|
|
6724
|
-
usage:
|
|
6725
|
-
content:
|
|
6724
|
+
usage: L,
|
|
6725
|
+
content: V,
|
|
6726
6726
|
responseId: f.response.id,
|
|
6727
6727
|
...f.providerMetadata == null ? {} : { providerMetadata: f.providerMetadata },
|
|
6728
6728
|
performance: {
|
|
6729
|
-
responseTimeMs:
|
|
6729
|
+
responseTimeMs: be,
|
|
6730
6730
|
effectiveOutputTokensPerSecond: Mc({
|
|
6731
|
-
tokens:
|
|
6732
|
-
durationMs:
|
|
6731
|
+
tokens: L.outputTokens,
|
|
6732
|
+
durationMs: be
|
|
6733
6733
|
}),
|
|
6734
6734
|
outputTokensPerSecond: void 0,
|
|
6735
6735
|
inputTokensPerSecond: void 0,
|
|
6736
6736
|
effectiveTotalTokensPerSecond: Mc({
|
|
6737
|
-
tokens: Ll(
|
|
6738
|
-
durationMs:
|
|
6737
|
+
tokens: Ll(L.inputTokens, L.outputTokens),
|
|
6738
|
+
durationMs: be
|
|
6739
6739
|
}),
|
|
6740
6740
|
timeToFirstOutputMs: void 0
|
|
6741
6741
|
}
|
|
6742
6742
|
},
|
|
6743
|
-
callbacks: [
|
|
6743
|
+
callbacks: [Ce, Pe.onLanguageModelCallEnd]
|
|
6744
6744
|
});
|
|
6745
|
-
let
|
|
6746
|
-
if (
|
|
6747
|
-
toolChoice:
|
|
6745
|
+
let Ne = le.type === "required" || le.type === "tool" ? le : void 0;
|
|
6746
|
+
if (Ne != null && !z.some((e) => Ne.type === "required" || e.toolName === Ne.toolName)) throw new Do({
|
|
6747
|
+
toolChoice: Ne,
|
|
6748
6748
|
finishReason: f.finishReason.unified,
|
|
6749
6749
|
provider: l.provider,
|
|
6750
6750
|
modelId: l.modelId,
|
|
6751
6751
|
content: f.content
|
|
6752
6752
|
});
|
|
6753
|
-
for (let e of
|
|
6753
|
+
for (let e of z) {
|
|
6754
6754
|
if (e.invalid) continue;
|
|
6755
6755
|
let t = Q(P, e.toolName);
|
|
6756
6756
|
if (t == null) continue;
|
|
@@ -6762,14 +6762,14 @@ async function $l({ model: e, tools: t, toolChoice: n, instructions: r, system:
|
|
|
6762
6762
|
});
|
|
6763
6763
|
t.onInputStart != null && await t.onInputStart({
|
|
6764
6764
|
toolCallId: e.toolCallId,
|
|
6765
|
-
messages:
|
|
6766
|
-
abortSignal:
|
|
6765
|
+
messages: I,
|
|
6766
|
+
abortSignal: Oe,
|
|
6767
6767
|
context: n
|
|
6768
6768
|
}), t.onInputAvailable != null && await t.onInputAvailable({
|
|
6769
6769
|
input: e.input,
|
|
6770
6770
|
toolCallId: e.toolCallId,
|
|
6771
|
-
messages:
|
|
6772
|
-
abortSignal:
|
|
6771
|
+
messages: I,
|
|
6772
|
+
abortSignal: Oe,
|
|
6773
6773
|
context: n
|
|
6774
6774
|
});
|
|
6775
6775
|
}
|
|
@@ -6777,7 +6777,7 @@ async function $l({ model: e, tools: t, toolChoice: n, instructions: r, system:
|
|
|
6777
6777
|
tools: P,
|
|
6778
6778
|
toolApproval: h,
|
|
6779
6779
|
toolCall: e,
|
|
6780
|
-
messages:
|
|
6780
|
+
messages: I,
|
|
6781
6781
|
toolsContext: k,
|
|
6782
6782
|
runtimeContext: O
|
|
6783
6783
|
});
|
|
@@ -6791,22 +6791,22 @@ async function $l({ model: e, tools: t, toolChoice: n, instructions: r, system:
|
|
|
6791
6791
|
});
|
|
6792
6792
|
switch (n.type) {
|
|
6793
6793
|
case "user-approval":
|
|
6794
|
-
|
|
6794
|
+
Ee[e.toolCallId] = {
|
|
6795
6795
|
type: "tool-approval-request",
|
|
6796
6796
|
approvalId: r,
|
|
6797
6797
|
toolCall: e,
|
|
6798
6798
|
...n.reason == null ? {} : { reason: n.reason },
|
|
6799
6799
|
...i == null ? {} : { signature: i }
|
|
6800
|
-
},
|
|
6800
|
+
}, De.add(e.toolCallId);
|
|
6801
6801
|
break;
|
|
6802
6802
|
case "approved":
|
|
6803
|
-
|
|
6803
|
+
Ee[e.toolCallId] = {
|
|
6804
6804
|
type: "tool-approval-request",
|
|
6805
6805
|
approvalId: r,
|
|
6806
6806
|
toolCall: e,
|
|
6807
6807
|
isAutomatic: !0,
|
|
6808
6808
|
...i == null ? {} : { signature: i }
|
|
6809
|
-
},
|
|
6809
|
+
}, B[e.toolCallId] = {
|
|
6810
6810
|
type: "tool-approval-response",
|
|
6811
6811
|
approvalId: r,
|
|
6812
6812
|
toolCall: e,
|
|
@@ -6815,25 +6815,25 @@ async function $l({ model: e, tools: t, toolChoice: n, instructions: r, system:
|
|
|
6815
6815
|
providerExecuted: e.providerExecuted
|
|
6816
6816
|
};
|
|
6817
6817
|
break;
|
|
6818
|
-
case "denied":
|
|
6818
|
+
case "denied": Ee[e.toolCallId] = {
|
|
6819
6819
|
type: "tool-approval-request",
|
|
6820
6820
|
approvalId: r,
|
|
6821
6821
|
toolCall: e,
|
|
6822
6822
|
isAutomatic: !0,
|
|
6823
6823
|
...i == null ? {} : { signature: i }
|
|
6824
|
-
},
|
|
6824
|
+
}, B[e.toolCallId] = {
|
|
6825
6825
|
type: "tool-approval-response",
|
|
6826
6826
|
approvalId: r,
|
|
6827
6827
|
toolCall: e,
|
|
6828
6828
|
approved: !1,
|
|
6829
6829
|
reason: n.reason,
|
|
6830
6830
|
providerExecuted: e.providerExecuted
|
|
6831
|
-
},
|
|
6831
|
+
}, De.add(e.toolCallId);
|
|
6832
6832
|
}
|
|
6833
6833
|
}
|
|
6834
|
-
let
|
|
6834
|
+
let Ie = z.filter((e) => e.invalid && e.dynamic && !e.providerExecuted);
|
|
6835
6835
|
v = [];
|
|
6836
|
-
for (let e of
|
|
6836
|
+
for (let e of Ie) v.push({
|
|
6837
6837
|
type: "tool-error",
|
|
6838
6838
|
toolCallId: e.toolCallId,
|
|
6839
6839
|
toolName: e.toolName,
|
|
@@ -6841,105 +6841,105 @@ async function $l({ model: e, tools: t, toolChoice: n, instructions: r, system:
|
|
|
6841
6841
|
error: T(e.error),
|
|
6842
6842
|
dynamic: !0
|
|
6843
6843
|
});
|
|
6844
|
-
g =
|
|
6845
|
-
let
|
|
6844
|
+
g = z.filter((e) => !e.providerExecuted), y = Object.values(B), w = y.filter((e) => !1 === e.approved);
|
|
6845
|
+
let U = {};
|
|
6846
6846
|
if (P != null && Xc(f.finishReason.unified)) {
|
|
6847
6847
|
let e = await eu({
|
|
6848
|
-
toolCalls: g.filter((e) => !e.invalid && !
|
|
6848
|
+
toolCalls: g.filter((e) => !e.invalid && !De.has(e.toolCallId)),
|
|
6849
6849
|
tools: P,
|
|
6850
|
-
callId:
|
|
6851
|
-
messages:
|
|
6852
|
-
abortSignal:
|
|
6850
|
+
callId: H,
|
|
6851
|
+
messages: I,
|
|
6852
|
+
abortSignal: Oe,
|
|
6853
6853
|
timeout: u,
|
|
6854
6854
|
experimental_sandbox: c,
|
|
6855
6855
|
toolsContext: k,
|
|
6856
6856
|
onToolExecutionStart: (e) => $({
|
|
6857
6857
|
event: e,
|
|
6858
|
-
callbacks: [
|
|
6858
|
+
callbacks: [we, Pe.onToolExecutionStart]
|
|
6859
6859
|
}),
|
|
6860
6860
|
onToolExecutionEnd: (e) => $({
|
|
6861
6861
|
event: e,
|
|
6862
|
-
callbacks: [
|
|
6862
|
+
callbacks: [R, Pe.onToolExecutionEnd]
|
|
6863
6863
|
}),
|
|
6864
|
-
executeToolInTelemetryContext:
|
|
6865
|
-
runInTracingChannelSpan:
|
|
6864
|
+
executeToolInTelemetryContext: Pe.executeTool,
|
|
6865
|
+
runInTracingChannelSpan: Fe
|
|
6866
6866
|
});
|
|
6867
|
-
for (let t of e)
|
|
6867
|
+
for (let t of e) U[t.output.toolCallId] = t.toolExecutionMs, v.push(t.output);
|
|
6868
6868
|
}
|
|
6869
|
-
let
|
|
6869
|
+
let Le = ie() - he, W = {
|
|
6870
6870
|
effectiveOutputTokensPerSecond: Mc({
|
|
6871
|
-
tokens:
|
|
6872
|
-
durationMs:
|
|
6871
|
+
tokens: L.outputTokens,
|
|
6872
|
+
durationMs: be
|
|
6873
6873
|
}),
|
|
6874
6874
|
outputTokensPerSecond: void 0,
|
|
6875
6875
|
inputTokensPerSecond: void 0,
|
|
6876
6876
|
effectiveTotalTokensPerSecond: Mc({
|
|
6877
|
-
tokens: Ll(
|
|
6878
|
-
durationMs:
|
|
6877
|
+
tokens: Ll(L.inputTokens, L.outputTokens),
|
|
6878
|
+
durationMs: be
|
|
6879
6879
|
}),
|
|
6880
|
-
stepTimeMs:
|
|
6881
|
-
responseTimeMs:
|
|
6882
|
-
toolExecutionMs:
|
|
6880
|
+
stepTimeMs: Le,
|
|
6881
|
+
responseTimeMs: be,
|
|
6882
|
+
toolExecutionMs: U,
|
|
6883
6883
|
timeToFirstOutputMs: void 0
|
|
6884
6884
|
};
|
|
6885
|
-
for (let e of
|
|
6885
|
+
for (let e of z) {
|
|
6886
6886
|
if (!e.providerExecuted) continue;
|
|
6887
6887
|
let t = Q(P, e.toolName);
|
|
6888
6888
|
t?.type === "provider" && t.supportsDeferredResults && (f.content.some((t) => t.type === "tool-result" && t.toolCallId === e.toolCallId) || M.set(e.toolCallId, { toolName: e.toolName }));
|
|
6889
6889
|
}
|
|
6890
6890
|
for (let e of f.content) e.type === "tool-result" && M.delete(e.toolCallId);
|
|
6891
|
-
let
|
|
6891
|
+
let Re = await Lc({
|
|
6892
6892
|
content: f.content,
|
|
6893
|
-
toolCalls:
|
|
6893
|
+
toolCalls: z,
|
|
6894
6894
|
toolOutputs: v,
|
|
6895
|
-
toolApprovalRequests: Object.values(
|
|
6895
|
+
toolApprovalRequests: Object.values(Ee),
|
|
6896
6896
|
toolApprovalResponses: y,
|
|
6897
6897
|
tools: t,
|
|
6898
|
-
abortSignal:
|
|
6899
|
-
generatedFileDataCache:
|
|
6900
|
-
}),
|
|
6901
|
-
content:
|
|
6898
|
+
abortSignal: Oe,
|
|
6899
|
+
generatedFileDataCache: ke
|
|
6900
|
+
}), ze = await zl({
|
|
6901
|
+
content: Re,
|
|
6902
6902
|
tools: t
|
|
6903
|
-
}),
|
|
6903
|
+
}), Be = {
|
|
6904
6904
|
...f.request,
|
|
6905
6905
|
body: te.requestBody ? f.request?.body : void 0,
|
|
6906
|
-
messages: te.requestMessages ? Ds(
|
|
6907
|
-
},
|
|
6906
|
+
messages: te.requestMessages ? Ds(I) : void 0
|
|
6907
|
+
}, Ve = {
|
|
6908
6908
|
...f.response,
|
|
6909
|
-
messages: Ds(
|
|
6909
|
+
messages: Ds(ze),
|
|
6910
6910
|
body: te.responseBody ? f.response?.body : void 0
|
|
6911
|
-
},
|
|
6912
|
-
callId:
|
|
6911
|
+
}, He = new Al({
|
|
6912
|
+
callId: H,
|
|
6913
6913
|
stepNumber: a,
|
|
6914
6914
|
provider: l.provider,
|
|
6915
6915
|
modelId: l.modelId,
|
|
6916
6916
|
runtimeContext: O,
|
|
6917
|
-
content:
|
|
6917
|
+
content: Re,
|
|
6918
6918
|
finishReason: f.finishReason.unified,
|
|
6919
6919
|
rawFinishReason: f.finishReason.raw,
|
|
6920
|
-
usage:
|
|
6921
|
-
performance:
|
|
6920
|
+
usage: L,
|
|
6921
|
+
performance: W,
|
|
6922
6922
|
warnings: f.warnings,
|
|
6923
6923
|
providerMetadata: f.providerMetadata,
|
|
6924
|
-
request:
|
|
6925
|
-
response:
|
|
6924
|
+
request: Be,
|
|
6925
|
+
response: Ve,
|
|
6926
6926
|
toolsContext: k
|
|
6927
6927
|
});
|
|
6928
6928
|
return Qo({
|
|
6929
6929
|
warnings: f.warnings ?? [],
|
|
6930
6930
|
provider: l.provider,
|
|
6931
6931
|
model: l.modelId
|
|
6932
|
-
}), A.push(
|
|
6933
|
-
event:
|
|
6934
|
-
callbacks: [
|
|
6935
|
-
}),
|
|
6932
|
+
}), A.push(He), re = N, j = [...I, ...ze], await $({
|
|
6933
|
+
event: He,
|
|
6934
|
+
callbacks: [Te, Pe.onStepEnd]
|
|
6935
|
+
}), He;
|
|
6936
6936
|
}
|
|
6937
6937
|
});
|
|
6938
6938
|
} finally {
|
|
6939
6939
|
i != null && clearTimeout(i);
|
|
6940
6940
|
}
|
|
6941
6941
|
} while (v.length + w.length === g.length && (g.length > 0 || M.size > 0) && !await Il({
|
|
6942
|
-
stopConditions:
|
|
6942
|
+
stopConditions: be,
|
|
6943
6943
|
steps: A
|
|
6944
6944
|
}));
|
|
6945
6945
|
let N = A[A.length - 1], ae = A.reduce((e, t) => wc(e, t.usage), {
|
|
@@ -6955,10 +6955,10 @@ async function $l({ model: e, tools: t, toolChoice: n, instructions: r, system:
|
|
|
6955
6955
|
reasoningTokens: void 0
|
|
6956
6956
|
},
|
|
6957
6957
|
totalTokens: void 0
|
|
6958
|
-
}), P = A.flatMap((e) => e.files), oe = A.flatMap((e) => e.sources),
|
|
6958
|
+
}), P = A.flatMap((e) => e.files), oe = A.flatMap((e) => e.sources), se = A.flatMap((e) => e.toolCalls), F = A.flatMap((e) => e.staticToolCalls), ce = A.flatMap((e) => e.dynamicToolCalls), le = A.flatMap((e) => e.toolResults), I = A.flatMap((e) => e.staticToolResults), ue = A.flatMap((e) => e.dynamicToolResults), de = A.flatMap((e) => e.warnings ?? []), fe;
|
|
6959
6959
|
return await $({
|
|
6960
6960
|
event: {
|
|
6961
|
-
callId:
|
|
6961
|
+
callId: H,
|
|
6962
6962
|
stepNumber: N.stepNumber,
|
|
6963
6963
|
model: N.model,
|
|
6964
6964
|
runtimeContext: N.runtimeContext,
|
|
@@ -6972,14 +6972,14 @@ async function $l({ model: e, tools: t, toolChoice: n, instructions: r, system:
|
|
|
6972
6972
|
reasoningText: N.reasoningText,
|
|
6973
6973
|
files: P,
|
|
6974
6974
|
sources: oe,
|
|
6975
|
-
toolCalls:
|
|
6976
|
-
staticToolCalls:
|
|
6977
|
-
dynamicToolCalls:
|
|
6978
|
-
toolResults:
|
|
6979
|
-
staticToolResults:
|
|
6980
|
-
dynamicToolResults:
|
|
6975
|
+
toolCalls: se,
|
|
6976
|
+
staticToolCalls: F,
|
|
6977
|
+
dynamicToolCalls: ce,
|
|
6978
|
+
toolResults: le,
|
|
6979
|
+
staticToolResults: I,
|
|
6980
|
+
dynamicToolResults: ue,
|
|
6981
6981
|
responseMessages: [...r, ...A.flatMap((e) => e.response.messages)],
|
|
6982
|
-
warnings:
|
|
6982
|
+
warnings: de,
|
|
6983
6983
|
request: N.request,
|
|
6984
6984
|
response: N.response,
|
|
6985
6985
|
providerMetadata: N.providerMetadata,
|
|
@@ -6987,8 +6987,8 @@ async function $l({ model: e, tools: t, toolChoice: n, instructions: r, system:
|
|
|
6987
6987
|
finalStep: N,
|
|
6988
6988
|
toolsContext: k
|
|
6989
6989
|
},
|
|
6990
|
-
callbacks: [
|
|
6991
|
-
}), (N.finishReason === "stop" || N.finishReason !== "tool-calls" && N.text.length > 0) && (
|
|
6990
|
+
callbacks: [he, Pe.onEnd]
|
|
6991
|
+
}), (N.finishReason === "stop" || N.finishReason !== "tool-calls" && N.text.length > 0) && (fe = await (m ?? el()).parseCompleteOutput({ text: N.text }, {
|
|
6992
6992
|
response: N.response,
|
|
6993
6993
|
usage: N.usage,
|
|
6994
6994
|
finishReason: N.finishReason
|
|
@@ -6996,11 +6996,11 @@ async function $l({ model: e, tools: t, toolChoice: n, instructions: r, system:
|
|
|
6996
6996
|
initialResponseMessages: r,
|
|
6997
6997
|
steps: A,
|
|
6998
6998
|
totalUsage: ae,
|
|
6999
|
-
output:
|
|
6999
|
+
output: fe
|
|
7000
7000
|
});
|
|
7001
7001
|
} catch (e) {
|
|
7002
|
-
throw await
|
|
7003
|
-
callId:
|
|
7002
|
+
throw await Pe.onError?.({
|
|
7003
|
+
callId: H,
|
|
7004
7004
|
error: e
|
|
7005
7005
|
}), Sc(e);
|
|
7006
7006
|
}
|
|
@@ -7186,7 +7186,7 @@ function uu({ response: e, status: t, statusText: n, headers: r, stream: i, cons
|
|
|
7186
7186
|
stream: o.pipeThrough(new TextEncoderStream())
|
|
7187
7187
|
});
|
|
7188
7188
|
}
|
|
7189
|
-
var du = X.record(X.string(), ec.optional()), fu =
|
|
7189
|
+
var du = X.record(X.string(), ec.optional()), fu = W(() => s(X.union([
|
|
7190
7190
|
X.looseObject({
|
|
7191
7191
|
type: X.literal("text-start"),
|
|
7192
7192
|
id: X.string(),
|
|
@@ -8302,11 +8302,11 @@ function zu(e) {
|
|
|
8302
8302
|
return typeof e == "object" && !!e && Lu in e;
|
|
8303
8303
|
}
|
|
8304
8304
|
function Bu(e) {
|
|
8305
|
-
if ((t = e) instanceof Error || Object.prototype.toString.call(t) === "[object Error]" ||
|
|
8305
|
+
if ((t = e) instanceof Error || Object.prototype.toString.call(t) === "[object Error]" || z.isInstance(e) || ro.isInstance(e)) return e;
|
|
8306
8306
|
var t;
|
|
8307
8307
|
let n = Hu(e);
|
|
8308
8308
|
if (n == null) return e;
|
|
8309
|
-
let r =
|
|
8309
|
+
let r = Ke(e), i = r ? n : Hu(Hu(n.response)?.error) ?? Hu(n.error) ?? n;
|
|
8310
8310
|
if (typeof i.message != "string") return e;
|
|
8311
8311
|
let a = Uu(i.type) ?? Uu(n.type), o = Wu(i.code) ?? Wu(n.code), s = Ku(i.statusCode) ?? Ku(n.statusCode) ?? Ku(i.status_code) ?? Ku(n.status_code) ?? Ku(i.status) ?? Ku(n.status) ?? Ku(i.code) ?? Ku(n.code), c = function(e) {
|
|
8312
8312
|
switch (e.trim().toLowerCase()) {
|
|
@@ -8788,22 +8788,22 @@ function rd(e) {
|
|
|
8788
8788
|
default: return !1;
|
|
8789
8789
|
}
|
|
8790
8790
|
}
|
|
8791
|
-
function id({ model: e, tools: t, toolChoice: n, instructions: r, system: i, prompt: a, messages: o, allowSystemInMessages: s, maxRetries: c, streamRetries: l, abortSignal: u, timeout: d, headers: f, stopWhen: p = Nl(1), experimental_sandbox: m, output: h, toolApproval: g, experimental_toolCallers: _, experimental_toolApprovalSecret: v, experimental_telemetry: y, telemetry: b = y, prepareStep: x, providerOptions: S, activeTools: C, toolOrder: w, experimental_repairToolCall: T, repairToolCall: ee = T, experimental_refineToolInput: E, experimental_transform: D, experimental_download: O, includeRawChunks: k, onChunk: A, onError: te, onFinish: ne, onEnd: re = ne, onAbort: j, onStepEnd: ie, onStepFinish: M, onStart: N, experimental_onStart: ae, onStepStart: P, experimental_onStepStart: oe, onLanguageModelCallStart:
|
|
8792
|
-
let
|
|
8791
|
+
function id({ model: e, tools: t, toolChoice: n, instructions: r, system: i, prompt: a, messages: o, allowSystemInMessages: s, maxRetries: c, streamRetries: l, abortSignal: u, timeout: d, headers: f, stopWhen: p = Nl(1), experimental_sandbox: m, output: h, toolApproval: g, experimental_toolCallers: _, experimental_toolApprovalSecret: v, experimental_telemetry: y, telemetry: b = y, prepareStep: x, providerOptions: S, activeTools: C, toolOrder: w, experimental_repairToolCall: T, repairToolCall: ee = T, experimental_refineToolInput: E, experimental_transform: D, experimental_download: O, includeRawChunks: k, onChunk: A, onError: te, onFinish: ne, onEnd: re = ne, onAbort: j, onStepEnd: ie, onStepFinish: M, onStart: N, experimental_onStart: ae, onStepStart: P, experimental_onStepStart: oe, onLanguageModelCallStart: se, experimental_onLanguageModelCallStart: F, onLanguageModelCallEnd: ce, experimental_onLanguageModelCallEnd: le, onToolExecutionStart: I, onToolExecutionEnd: ue, experimental_onToolCallStart: de, experimental_onToolCallFinish: fe, runtimeContext: pe = {}, toolsContext: me = {}, experimental_include: he, include: ge = he, _internal: { now: _e = Oc, generateId: ve = ed, generateCallId: ye = td } = {}, ...be }) {
|
|
8792
|
+
let L = Ys(d), xe = Xs(d), Se = Zs(d), Ce = Qs(d), we = xe == null ? void 0 : new AbortController(), R = Se == null ? void 0 : new AbortController(), Te = Ce == null ? void 0 : new AbortController(), z = te ?? (({ error: e }) => {}), Ee = N ?? ae, B = P ?? oe, De = se ?? F, Oe = ce ?? le, ke = I ?? de, Ae = ue ?? fe, V = ie ?? M;
|
|
8793
8793
|
return new cd({
|
|
8794
8794
|
model: vs(e),
|
|
8795
8795
|
telemetry: b,
|
|
8796
8796
|
headers: f,
|
|
8797
|
-
settings:
|
|
8797
|
+
settings: be,
|
|
8798
8798
|
maxRetries: c,
|
|
8799
8799
|
streamRetries: l,
|
|
8800
|
-
abortSignal: Dc(u,
|
|
8801
|
-
stepTimeoutMs:
|
|
8802
|
-
stepAbortController:
|
|
8803
|
-
firstChunkTimeoutMs:
|
|
8804
|
-
firstChunkAbortController:
|
|
8805
|
-
chunkTimeoutMs:
|
|
8806
|
-
chunkAbortController:
|
|
8800
|
+
abortSignal: Dc(u, L, we?.signal, R?.signal, Te?.signal),
|
|
8801
|
+
stepTimeoutMs: xe,
|
|
8802
|
+
stepAbortController: we,
|
|
8803
|
+
firstChunkTimeoutMs: Se,
|
|
8804
|
+
firstChunkAbortController: R,
|
|
8805
|
+
chunkTimeoutMs: Ce,
|
|
8806
|
+
chunkAbortController: Te,
|
|
8807
8807
|
instructions: r,
|
|
8808
8808
|
system: i,
|
|
8809
8809
|
prompt: a,
|
|
@@ -8811,15 +8811,15 @@ function id({ model: e, tools: t, toolChoice: n, instructions: r, system: i, pro
|
|
|
8811
8811
|
allowSystemInMessages: s,
|
|
8812
8812
|
experimental_sandbox: m,
|
|
8813
8813
|
tools: t,
|
|
8814
|
-
toolsContext:
|
|
8815
|
-
runtimeContext:
|
|
8814
|
+
toolsContext: me,
|
|
8815
|
+
runtimeContext: pe,
|
|
8816
8816
|
toolChoice: n,
|
|
8817
|
-
transforms:
|
|
8817
|
+
transforms: Ne(D),
|
|
8818
8818
|
activeTools: C,
|
|
8819
8819
|
toolOrder: w,
|
|
8820
8820
|
repairToolCall: ee,
|
|
8821
8821
|
refineToolInput: E,
|
|
8822
|
-
stopConditions:
|
|
8822
|
+
stopConditions: Ne(p),
|
|
8823
8823
|
output: h,
|
|
8824
8824
|
toolApproval: g,
|
|
8825
8825
|
experimental_toolCallers: _,
|
|
@@ -8828,25 +8828,25 @@ function id({ model: e, tools: t, toolChoice: n, instructions: r, system: i, pro
|
|
|
8828
8828
|
prepareStep: x,
|
|
8829
8829
|
timeout: d,
|
|
8830
8830
|
onChunk: A,
|
|
8831
|
-
onError:
|
|
8831
|
+
onError: z,
|
|
8832
8832
|
canRetryStreamViaOnError: l !== void 0 && te != null,
|
|
8833
8833
|
onEnd: re,
|
|
8834
8834
|
onAbort: j,
|
|
8835
|
-
onStepFinish:
|
|
8836
|
-
onStart:
|
|
8837
|
-
onStepStart:
|
|
8838
|
-
onLanguageModelCallStart:
|
|
8839
|
-
onLanguageModelCallEnd:
|
|
8840
|
-
onToolExecutionStart:
|
|
8841
|
-
onToolExecutionEnd:
|
|
8842
|
-
now:
|
|
8843
|
-
generateId:
|
|
8844
|
-
generateCallId:
|
|
8835
|
+
onStepFinish: V,
|
|
8836
|
+
onStart: Ee,
|
|
8837
|
+
onStepStart: B,
|
|
8838
|
+
onLanguageModelCallStart: De,
|
|
8839
|
+
onLanguageModelCallEnd: Oe,
|
|
8840
|
+
onToolExecutionStart: ke,
|
|
8841
|
+
onToolExecutionEnd: Ae,
|
|
8842
|
+
now: _e,
|
|
8843
|
+
generateId: ve,
|
|
8844
|
+
generateCallId: ye,
|
|
8845
8845
|
download: O,
|
|
8846
8846
|
include: {
|
|
8847
|
-
requestBody:
|
|
8848
|
-
requestMessages:
|
|
8849
|
-
rawChunks:
|
|
8847
|
+
requestBody: ge?.requestBody ?? !1,
|
|
8848
|
+
requestMessages: ge?.requestMessages ?? !1,
|
|
8849
|
+
rawChunks: ge?.rawChunks ?? k ?? !1
|
|
8850
8850
|
}
|
|
8851
8851
|
});
|
|
8852
8852
|
}
|
|
@@ -8860,19 +8860,19 @@ async function sd(e) {
|
|
|
8860
8860
|
} catch {}
|
|
8861
8861
|
}
|
|
8862
8862
|
var cd = class {
|
|
8863
|
-
constructor({ model: e, telemetry: t, headers: n, settings: r, maxRetries: i, streamRetries: a, abortSignal: o, stepTimeoutMs: s, stepAbortController: c, firstChunkTimeoutMs: l, firstChunkAbortController: u, chunkTimeoutMs: d, chunkAbortController: f, instructions: p, system: m, prompt: h, messages: g, allowSystemInMessages: _, experimental_sandbox: v, tools: y, toolChoice: b, transforms: S, activeTools: C, toolOrder: w, repairToolCall: ee, refineToolInput: E, stopConditions: D, output: O, toolApproval: k, experimental_toolCallers: A, experimental_toolApprovalSecret: te, providerOptions: ne, prepareStep: re, now: j, generateId: ie, generateCallId: M, timeout: N, onChunk: ae, onError: P, canRetryStreamViaOnError:
|
|
8864
|
-
this._totalUsage = new
|
|
8865
|
-
let
|
|
8863
|
+
constructor({ model: e, telemetry: t, headers: n, settings: r, maxRetries: i, streamRetries: a, abortSignal: o, stepTimeoutMs: s, stepAbortController: c, firstChunkTimeoutMs: l, firstChunkAbortController: u, chunkTimeoutMs: d, chunkAbortController: f, instructions: p, system: m, prompt: h, messages: g, allowSystemInMessages: _, experimental_sandbox: v, tools: y, toolChoice: b, transforms: S, activeTools: C, toolOrder: w, repairToolCall: ee, refineToolInput: E, stopConditions: D, output: O, toolApproval: k, experimental_toolCallers: A, experimental_toolApprovalSecret: te, providerOptions: ne, prepareStep: re, now: j, generateId: ie, generateCallId: M, timeout: N, onChunk: ae, onError: P, canRetryStreamViaOnError: se, onEnd: F, onAbort: ce, onStepFinish: le, onStart: I, onStepStart: ue, onLanguageModelCallStart: de, onLanguageModelCallEnd: fe, onToolExecutionStart: pe, onToolExecutionEnd: me, runtimeContext: he, toolsContext: ge, download: _e, include: ve }) {
|
|
8864
|
+
this._totalUsage = new U(), this._finishReason = new U(), this._rawFinishReason = new U(), this._steps = new U(), this._initialResponseMessages = new U(), this.outputSpecification = O, this.tools = y;
|
|
8865
|
+
let ye = zc({
|
|
8866
8866
|
tools: y,
|
|
8867
8867
|
toolCallers: A
|
|
8868
|
-
}),
|
|
8868
|
+
}), be = Gc({
|
|
8869
8869
|
tools: y,
|
|
8870
|
-
toolCallers:
|
|
8871
|
-
}),
|
|
8870
|
+
toolCallers: ye
|
|
8871
|
+
}), L = Ml({
|
|
8872
8872
|
telemetry: t,
|
|
8873
8873
|
includeRuntimeContext: t?.includeRuntimeContext,
|
|
8874
8874
|
includeToolsContext: t?.includeToolsContext
|
|
8875
|
-
}),
|
|
8875
|
+
}), xe, Se, Ce, we, R = [], Te = {}, z = [], Ee = [], B = [], De = [], Oe, ke = [], Ae = !1, V = e, je = () => {
|
|
8876
8876
|
let e = /* @__PURE__ */ new Set();
|
|
8877
8877
|
return (t) => {
|
|
8878
8878
|
if (!e.has(t)) return e.add(t), t;
|
|
@@ -8880,34 +8880,34 @@ var cd = class {
|
|
|
8880
8880
|
for (; e.has(r);) r = `${n}-${++i}`;
|
|
8881
8881
|
return e.add(r), r;
|
|
8882
8882
|
};
|
|
8883
|
-
},
|
|
8883
|
+
}, Me = je(), H = je(), Ne = /* @__PURE__ */ new Map(), Pe, Fe = pu(), Ie = pu(), Le = /* @__PURE__ */ new Set(), W = new TransformStream({
|
|
8884
8884
|
async transform(e, t) {
|
|
8885
8885
|
if (od(e)) {
|
|
8886
8886
|
let t = e[ad];
|
|
8887
|
-
|
|
8887
|
+
R = [], Ie = pu(), Fe = pu(), Te = t.request, z = t.request.messages ?? [], Ee = t.warnings;
|
|
8888
8888
|
return;
|
|
8889
8889
|
}
|
|
8890
8890
|
let { part: n } = e;
|
|
8891
8891
|
t.enqueue(e);
|
|
8892
|
-
let r = n.type === "error" &&
|
|
8892
|
+
let r = n.type === "error" && Le.has(n.error);
|
|
8893
8893
|
if (r || await $({
|
|
8894
8894
|
event: { chunk: n },
|
|
8895
8895
|
callbacks: ae
|
|
8896
8896
|
}), n.type === "error") {
|
|
8897
8897
|
let e = Sc(n.error);
|
|
8898
|
-
Na.isInstance(e) && (
|
|
8898
|
+
Na.isInstance(e) && (Pe = e), r ? Le.delete(n.error) : await $({
|
|
8899
8899
|
event: { error: e },
|
|
8900
8900
|
callbacks: async (e) => {
|
|
8901
8901
|
await P(e);
|
|
8902
8902
|
}
|
|
8903
8903
|
});
|
|
8904
8904
|
}
|
|
8905
|
-
if (n.type !== "custom" && n.type !== "source" && n.type !== "tool-call" && n.type !== "tool-approval-request" && n.type !== "tool-approval-response" && n.type !== "tool-error" ||
|
|
8905
|
+
if (n.type !== "custom" && n.type !== "source" && n.type !== "tool-call" && n.type !== "tool-approval-request" && n.type !== "tool-approval-response" && n.type !== "tool-error" || R.push(n), n.type === "text-start" && (Fe[n.id] = {
|
|
8906
8906
|
type: "text",
|
|
8907
8907
|
text: "",
|
|
8908
8908
|
providerMetadata: n.providerMetadata
|
|
8909
|
-
},
|
|
8910
|
-
let e =
|
|
8909
|
+
}, R.push(Fe[n.id])), n.type === "text-delta") {
|
|
8910
|
+
let e = Fe[n.id];
|
|
8911
8911
|
if (e == null) return void t.enqueue({
|
|
8912
8912
|
part: {
|
|
8913
8913
|
type: "error",
|
|
@@ -8918,7 +8918,7 @@ var cd = class {
|
|
|
8918
8918
|
e.text += n.text, e.providerMetadata = n.providerMetadata ?? e.providerMetadata;
|
|
8919
8919
|
}
|
|
8920
8920
|
if (n.type === "text-end") {
|
|
8921
|
-
let e =
|
|
8921
|
+
let e = Fe[n.id];
|
|
8922
8922
|
if (e == null) return void t.enqueue({
|
|
8923
8923
|
part: {
|
|
8924
8924
|
type: "error",
|
|
@@ -8926,14 +8926,14 @@ var cd = class {
|
|
|
8926
8926
|
},
|
|
8927
8927
|
partialOutput: void 0
|
|
8928
8928
|
});
|
|
8929
|
-
e.providerMetadata = n.providerMetadata ?? e.providerMetadata, delete
|
|
8929
|
+
e.providerMetadata = n.providerMetadata ?? e.providerMetadata, delete Fe[n.id];
|
|
8930
8930
|
}
|
|
8931
|
-
if (n.type === "reasoning-start" && (
|
|
8931
|
+
if (n.type === "reasoning-start" && (Ie[n.id] = {
|
|
8932
8932
|
type: "reasoning",
|
|
8933
8933
|
text: "",
|
|
8934
8934
|
providerMetadata: n.providerMetadata
|
|
8935
|
-
},
|
|
8936
|
-
let e =
|
|
8935
|
+
}, R.push(Ie[n.id])), n.type === "reasoning-delta") {
|
|
8936
|
+
let e = Ie[n.id];
|
|
8937
8937
|
if (e == null) return void t.enqueue({
|
|
8938
8938
|
part: {
|
|
8939
8939
|
type: "error",
|
|
@@ -8944,7 +8944,7 @@ var cd = class {
|
|
|
8944
8944
|
e.text += n.text, e.providerMetadata = n.providerMetadata ?? e.providerMetadata;
|
|
8945
8945
|
}
|
|
8946
8946
|
if (n.type === "reasoning-end") {
|
|
8947
|
-
let e =
|
|
8947
|
+
let e = Ie[n.id];
|
|
8948
8948
|
if (e == null) return void t.enqueue({
|
|
8949
8949
|
part: {
|
|
8950
8950
|
type: "error",
|
|
@@ -8952,32 +8952,32 @@ var cd = class {
|
|
|
8952
8952
|
},
|
|
8953
8953
|
partialOutput: void 0
|
|
8954
8954
|
});
|
|
8955
|
-
e.providerMetadata = n.providerMetadata ?? e.providerMetadata, delete
|
|
8955
|
+
e.providerMetadata = n.providerMetadata ?? e.providerMetadata, delete Ie[n.id];
|
|
8956
8956
|
}
|
|
8957
|
-
if (n.type !== "file" && n.type !== "reasoning-file" ||
|
|
8957
|
+
if (n.type !== "file" && n.type !== "reasoning-file" || R.push({
|
|
8958
8958
|
type: n.type,
|
|
8959
8959
|
file: n.file,
|
|
8960
8960
|
...n.providerMetadata == null ? {} : { providerMetadata: n.providerMetadata }
|
|
8961
|
-
}), n.type !== "tool-result" || n.preliminary ||
|
|
8961
|
+
}), n.type !== "tool-result" || n.preliminary || R.push(n), n.type === "start-step" && (R = [], Ie = pu(), Fe = pu(), Te = n.request, Ee = n.warnings), n.type === "finish-step") {
|
|
8962
8962
|
let e = await zl({
|
|
8963
|
-
content:
|
|
8963
|
+
content: R,
|
|
8964
8964
|
tools: y
|
|
8965
8965
|
}), t = new Al({
|
|
8966
|
-
callId:
|
|
8967
|
-
stepNumber:
|
|
8968
|
-
provider:
|
|
8969
|
-
modelId:
|
|
8970
|
-
runtimeContext:
|
|
8971
|
-
toolsContext:
|
|
8972
|
-
content:
|
|
8966
|
+
callId: Ke,
|
|
8967
|
+
stepNumber: B.length,
|
|
8968
|
+
provider: V.provider,
|
|
8969
|
+
modelId: V.modelId,
|
|
8970
|
+
runtimeContext: he,
|
|
8971
|
+
toolsContext: ge,
|
|
8972
|
+
content: R,
|
|
8973
8973
|
finishReason: n.finishReason,
|
|
8974
8974
|
rawFinishReason: n.rawFinishReason,
|
|
8975
8975
|
usage: n.usage,
|
|
8976
8976
|
performance: n.performance,
|
|
8977
|
-
warnings:
|
|
8977
|
+
warnings: Ee,
|
|
8978
8978
|
request: {
|
|
8979
|
-
...
|
|
8980
|
-
messages:
|
|
8979
|
+
...Te,
|
|
8980
|
+
messages: ve.requestMessages ? Ds(z) : void 0
|
|
8981
8981
|
},
|
|
8982
8982
|
response: {
|
|
8983
8983
|
...n.response,
|
|
@@ -8987,23 +8987,23 @@ var cd = class {
|
|
|
8987
8987
|
});
|
|
8988
8988
|
await $({
|
|
8989
8989
|
event: t,
|
|
8990
|
-
callbacks: [
|
|
8990
|
+
callbacks: [le, L.onStepEnd]
|
|
8991
8991
|
}), Qo({
|
|
8992
|
-
warnings:
|
|
8993
|
-
provider:
|
|
8994
|
-
model:
|
|
8995
|
-
}),
|
|
8992
|
+
warnings: Ee,
|
|
8993
|
+
provider: V.provider,
|
|
8994
|
+
model: V.modelId
|
|
8995
|
+
}), B.push(t), Oe = [...ke, ...e], xe.resolve();
|
|
8996
8996
|
}
|
|
8997
|
-
n.type === "finish" && (
|
|
8997
|
+
n.type === "finish" && (we = n.totalUsage, Se = n.finishReason, Ce = n.rawFinishReason);
|
|
8998
8998
|
},
|
|
8999
8999
|
async flush(e) {
|
|
9000
9000
|
try {
|
|
9001
|
-
if (
|
|
9002
|
-
let e = o?.aborted ? o.reason :
|
|
9003
|
-
|
|
9001
|
+
if (B.length === 0 || Pe != null) {
|
|
9002
|
+
let e = o?.aborted ? o.reason : Pe ?? new Na({ message: "No output generated. Check the stream for errors." });
|
|
9003
|
+
Ge.rejectResultPromises(e);
|
|
9004
9004
|
return;
|
|
9005
9005
|
}
|
|
9006
|
-
let e =
|
|
9006
|
+
let e = Se ?? "other", t = we ?? {
|
|
9007
9007
|
inputTokens: void 0,
|
|
9008
9008
|
inputTokenDetails: {
|
|
9009
9009
|
noCacheTokens: void 0,
|
|
@@ -9018,15 +9018,15 @@ var cd = class {
|
|
|
9018
9018
|
totalTokens: void 0,
|
|
9019
9019
|
raw: void 0
|
|
9020
9020
|
};
|
|
9021
|
-
if (
|
|
9022
|
-
let n =
|
|
9023
|
-
let t = O == null ? void 0 : await
|
|
9024
|
-
await
|
|
9021
|
+
if (Ge._finishReason.resolve(e), Ge._rawFinishReason.resolve(Ce), Ge._totalUsage.resolve(t), Ge._steps.resolve(B), Ae) return;
|
|
9022
|
+
let n = B[B.length - 1], r = B.flatMap((e) => e.content), i = B.flatMap((e) => e.files), a = B.flatMap((e) => e.sources), s = B.flatMap((e) => e.toolCalls), c = B.flatMap((e) => e.staticToolCalls), l = B.flatMap((e) => e.dynamicToolCalls), u = B.flatMap((e) => e.toolResults), d = B.flatMap((e) => e.staticToolResults), f = B.flatMap((e) => e.dynamicToolResults), p = B.flatMap((e) => e.warnings ?? []), m = F == null ? void 0 : async (e) => {
|
|
9023
|
+
let t = O == null ? void 0 : await Ge.getOutputPromise().catch(() => {});
|
|
9024
|
+
await F({
|
|
9025
9025
|
...e,
|
|
9026
9026
|
...O == null ? {} : { output: t }
|
|
9027
9027
|
});
|
|
9028
9028
|
}, h = {
|
|
9029
|
-
callId:
|
|
9029
|
+
callId: Ke,
|
|
9030
9030
|
toolsContext: n.toolsContext,
|
|
9031
9031
|
stepNumber: n.stepNumber,
|
|
9032
9032
|
model: n.model,
|
|
@@ -9047,12 +9047,12 @@ var cd = class {
|
|
|
9047
9047
|
toolResults: u,
|
|
9048
9048
|
staticToolResults: d,
|
|
9049
9049
|
dynamicToolResults: f,
|
|
9050
|
-
responseMessages: [...
|
|
9050
|
+
responseMessages: [...De, ...B.flatMap((e) => e.response.messages)],
|
|
9051
9051
|
warnings: p,
|
|
9052
9052
|
request: n.request,
|
|
9053
9053
|
response: n.response,
|
|
9054
9054
|
providerMetadata: n.providerMetadata,
|
|
9055
|
-
steps:
|
|
9055
|
+
steps: B,
|
|
9056
9056
|
finalStep: n
|
|
9057
9057
|
};
|
|
9058
9058
|
await Promise.all([$({
|
|
@@ -9060,49 +9060,49 @@ var cd = class {
|
|
|
9060
9060
|
callbacks: m
|
|
9061
9061
|
}), $({
|
|
9062
9062
|
event: h,
|
|
9063
|
-
callbacks:
|
|
9063
|
+
callbacks: L.onEnd
|
|
9064
9064
|
})]);
|
|
9065
9065
|
} catch (t) {
|
|
9066
9066
|
e.error(t);
|
|
9067
9067
|
}
|
|
9068
9068
|
}
|
|
9069
|
-
}),
|
|
9070
|
-
this.addStream =
|
|
9071
|
-
let
|
|
9069
|
+
}), Re = Iu();
|
|
9070
|
+
this.addStream = Re.addStream, this.closeStream = Re.close;
|
|
9071
|
+
let ze = Re.stream.getReader(), Be = new ReadableStream({
|
|
9072
9072
|
async start(e) {
|
|
9073
9073
|
e.enqueue({ type: "start" });
|
|
9074
9074
|
},
|
|
9075
9075
|
async pull(e) {
|
|
9076
9076
|
async function t() {
|
|
9077
|
-
|
|
9077
|
+
Ae = !0, await $({
|
|
9078
9078
|
event: {
|
|
9079
|
-
callId:
|
|
9080
|
-
steps:
|
|
9079
|
+
callId: Ke,
|
|
9080
|
+
steps: B,
|
|
9081
9081
|
...o?.reason === void 0 ? {} : { reason: o.reason }
|
|
9082
9082
|
},
|
|
9083
|
-
callbacks: [
|
|
9083
|
+
callbacks: [ce, L.onAbort]
|
|
9084
9084
|
}), e.enqueue({
|
|
9085
9085
|
type: "abort",
|
|
9086
9086
|
...o?.reason === void 0 ? {} : { reason: T(o.reason) }
|
|
9087
9087
|
}), e.close();
|
|
9088
9088
|
}
|
|
9089
9089
|
try {
|
|
9090
|
-
let { done: n, value: r } = await
|
|
9090
|
+
let { done: n, value: r } = await ze.read();
|
|
9091
9091
|
if (n) return void e.close();
|
|
9092
9092
|
if (o?.aborted) return void await t();
|
|
9093
9093
|
e.enqueue(r);
|
|
9094
9094
|
} catch (n) {
|
|
9095
|
-
x(n) && o?.aborted ? await t() : (await
|
|
9096
|
-
callId:
|
|
9095
|
+
x(n) && o?.aborted ? await t() : (await L.onError?.({
|
|
9096
|
+
callId: Ke,
|
|
9097
9097
|
error: n
|
|
9098
9098
|
}), e.error(n));
|
|
9099
9099
|
}
|
|
9100
9100
|
},
|
|
9101
|
-
cancel: (e) =>
|
|
9102
|
-
}),
|
|
9103
|
-
|
|
9104
|
-
|
|
9105
|
-
} })),
|
|
9101
|
+
cancel: (e) => Re.stream.cancel(e)
|
|
9102
|
+
}), Ve = !0;
|
|
9103
|
+
Be = Be.pipeThrough(new TransformStream({ async transform(e, t) {
|
|
9104
|
+
Ve && t.enqueue(e);
|
|
9105
|
+
} })), Be = function({ stream: e, transforms: t, tools: n, stopStream: r }) {
|
|
9106
9106
|
let i = e.getReader(), a, o, s = !1;
|
|
9107
9107
|
return new ReadableStream({
|
|
9108
9108
|
async pull(e) {
|
|
@@ -9131,13 +9131,13 @@ var cd = class {
|
|
|
9131
9131
|
}
|
|
9132
9132
|
});
|
|
9133
9133
|
}({
|
|
9134
|
-
stream:
|
|
9134
|
+
stream: Be,
|
|
9135
9135
|
transforms: S,
|
|
9136
9136
|
tools: y,
|
|
9137
9137
|
stopStream() {
|
|
9138
|
-
|
|
9138
|
+
Re.terminate(), Ve = !1;
|
|
9139
9139
|
}
|
|
9140
|
-
}), this.baseStream =
|
|
9140
|
+
}), this.baseStream = Be.pipeThrough(function(e) {
|
|
9141
9141
|
let t, n, r, i = "", a = "", o = !1;
|
|
9142
9142
|
function s() {
|
|
9143
9143
|
t = void 0, i = "", a = "", n = void 0, r = void 0, o = !1;
|
|
@@ -9206,16 +9206,16 @@ var cd = class {
|
|
|
9206
9206
|
}), r = e, o = !0);
|
|
9207
9207
|
}
|
|
9208
9208
|
} });
|
|
9209
|
-
}(O ?? el())).pipeThrough(
|
|
9210
|
-
let { maxRetries:
|
|
9209
|
+
}(O ?? el())).pipeThrough(W);
|
|
9210
|
+
let { maxRetries: He } = Ac({
|
|
9211
9211
|
maxRetries: i,
|
|
9212
9212
|
abortSignal: o
|
|
9213
|
-
}), { maxRetries:
|
|
9213
|
+
}), { maxRetries: Ue } = Ac({
|
|
9214
9214
|
maxRetries: a,
|
|
9215
9215
|
abortSignal: o,
|
|
9216
9216
|
parameter: "streamRetries",
|
|
9217
9217
|
defaultMaxRetries: 0
|
|
9218
|
-
}),
|
|
9218
|
+
}), We = Gs(r), Ge = this, Ke = M();
|
|
9219
9219
|
(async () => {
|
|
9220
9220
|
let t = await xc({
|
|
9221
9221
|
instructions: p,
|
|
@@ -9224,7 +9224,7 @@ var cd = class {
|
|
|
9224
9224
|
messages: g,
|
|
9225
9225
|
allowSystemInMessages: _
|
|
9226
9226
|
}), r = {
|
|
9227
|
-
callId:
|
|
9227
|
+
callId: Ke,
|
|
9228
9228
|
operationId: "ai.streamText",
|
|
9229
9229
|
provider: e.provider,
|
|
9230
9230
|
modelId: e.modelId,
|
|
@@ -9234,46 +9234,46 @@ var cd = class {
|
|
|
9234
9234
|
toolChoice: b,
|
|
9235
9235
|
activeTools: C,
|
|
9236
9236
|
toolOrder: w,
|
|
9237
|
-
maxOutputTokens:
|
|
9238
|
-
temperature:
|
|
9239
|
-
topP:
|
|
9240
|
-
topK:
|
|
9241
|
-
presencePenalty:
|
|
9242
|
-
frequencyPenalty:
|
|
9243
|
-
stopSequences:
|
|
9244
|
-
seed:
|
|
9245
|
-
reasoning:
|
|
9246
|
-
maxRetries:
|
|
9237
|
+
maxOutputTokens: We.maxOutputTokens,
|
|
9238
|
+
temperature: We.temperature,
|
|
9239
|
+
topP: We.topP,
|
|
9240
|
+
topK: We.topK,
|
|
9241
|
+
presencePenalty: We.presencePenalty,
|
|
9242
|
+
frequencyPenalty: We.frequencyPenalty,
|
|
9243
|
+
stopSequences: We.stopSequences,
|
|
9244
|
+
seed: We.seed,
|
|
9245
|
+
reasoning: We.reasoning,
|
|
9246
|
+
maxRetries: He,
|
|
9247
9247
|
timeout: N,
|
|
9248
9248
|
headers: n,
|
|
9249
9249
|
providerOptions: ne,
|
|
9250
9250
|
output: O,
|
|
9251
|
-
runtimeContext:
|
|
9252
|
-
toolsContext:
|
|
9253
|
-
}, i =
|
|
9251
|
+
runtimeContext: he,
|
|
9252
|
+
toolsContext: ge
|
|
9253
|
+
}, i = L.startTracingChannelContext?.({
|
|
9254
9254
|
type: "streamText",
|
|
9255
9255
|
event: r,
|
|
9256
|
-
completion:
|
|
9257
|
-
}), a = (e) => i?.run(e) ?? e(), x =
|
|
9256
|
+
completion: Ge._totalUsage.promise.then(() => {})
|
|
9257
|
+
}), a = (e) => i?.run(e) ?? e(), x = L.runInTracingChannelSpan == null ? void 0 : (e) => a(() => L.runInTracingChannelSpan(e));
|
|
9258
9258
|
await $({
|
|
9259
9259
|
event: r,
|
|
9260
|
-
callbacks: [
|
|
9260
|
+
callbacks: [I, L.onStart]
|
|
9261
9261
|
});
|
|
9262
|
-
let S = t.messages, A = t.instructions, { approvedToolApprovals: M, deniedToolApprovals:
|
|
9263
|
-
if (
|
|
9262
|
+
let S = t.messages, A = t.instructions, { approvedToolApprovals: M, deniedToolApprovals: F } = Nc({ messages: S });
|
|
9263
|
+
if (F.length > 0 || M.length > 0) {
|
|
9264
9264
|
let { approvedToolApprovals: e, deniedToolApprovals: t, invalidToolApprovals: n } = await Xl({
|
|
9265
9265
|
approvedToolApprovals: M.filter((e) => !e.toolCall.providerExecuted),
|
|
9266
9266
|
tools: y,
|
|
9267
9267
|
toolApproval: k,
|
|
9268
9268
|
messages: S,
|
|
9269
|
-
toolsContext:
|
|
9270
|
-
runtimeContext:
|
|
9269
|
+
toolsContext: ge,
|
|
9270
|
+
runtimeContext: he,
|
|
9271
9271
|
toolApprovalSecret: te,
|
|
9272
9272
|
refineToolInput: E
|
|
9273
|
-
}), r = [...
|
|
9273
|
+
}), r = [...F.filter((e) => !e.toolCall.providerExecuted), ...t], i = r.filter((e) => e.existingToolResult == null), a = F.filter((e) => e.toolCall.providerExecuted), s, c = new ReadableStream({ start(e) {
|
|
9274
9274
|
s = e;
|
|
9275
9275
|
} });
|
|
9276
|
-
|
|
9276
|
+
Ge.addStream(c);
|
|
9277
9277
|
try {
|
|
9278
9278
|
for (let e of [...r, ...a]) s?.enqueue({
|
|
9279
9279
|
type: "tool-output-denied",
|
|
@@ -9295,15 +9295,15 @@ var cd = class {
|
|
|
9295
9295
|
let n = await Jc({
|
|
9296
9296
|
toolCall: e.toolCall,
|
|
9297
9297
|
tools: y,
|
|
9298
|
-
callId:
|
|
9298
|
+
callId: Ke,
|
|
9299
9299
|
messages: S,
|
|
9300
9300
|
abortSignal: o,
|
|
9301
9301
|
timeout: N,
|
|
9302
9302
|
experimental_sandbox: v,
|
|
9303
|
-
toolsContext:
|
|
9304
|
-
onToolExecutionStart: oe(
|
|
9305
|
-
onToolExecutionEnd: oe(
|
|
9306
|
-
executeToolInTelemetryContext:
|
|
9303
|
+
toolsContext: ge,
|
|
9304
|
+
onToolExecutionStart: oe(pe, L.onToolExecutionStart),
|
|
9305
|
+
onToolExecutionEnd: oe(me, L.onToolExecutionEnd),
|
|
9306
|
+
executeToolInTelemetryContext: L.executeTool,
|
|
9307
9307
|
runInTracingChannelSpan: x,
|
|
9308
9308
|
onPreliminaryToolResult: (e) => {
|
|
9309
9309
|
s?.enqueue(e);
|
|
@@ -9345,7 +9345,7 @@ var cd = class {
|
|
|
9345
9345
|
reason: t.approvalResponse.reason
|
|
9346
9346
|
}
|
|
9347
9347
|
});
|
|
9348
|
-
|
|
9348
|
+
De.push({
|
|
9349
9349
|
role: "tool",
|
|
9350
9350
|
content: e
|
|
9351
9351
|
});
|
|
@@ -9354,7 +9354,7 @@ var cd = class {
|
|
|
9354
9354
|
s?.close();
|
|
9355
9355
|
}
|
|
9356
9356
|
}
|
|
9357
|
-
async function
|
|
9357
|
+
async function ce({ currentStep: r, usage: i }) {
|
|
9358
9358
|
let p = jc({
|
|
9359
9359
|
abortController: c,
|
|
9360
9360
|
label: "Step",
|
|
@@ -9375,107 +9375,107 @@ var cd = class {
|
|
|
9375
9375
|
}
|
|
9376
9376
|
o?.addEventListener("abort", T, { once: !0 });
|
|
9377
9377
|
try {
|
|
9378
|
-
|
|
9379
|
-
let s =
|
|
9378
|
+
xe = new U();
|
|
9379
|
+
let s = L.startTracingChannelContext?.({
|
|
9380
9380
|
type: "step",
|
|
9381
9381
|
event: {
|
|
9382
|
-
callId:
|
|
9382
|
+
callId: Ke,
|
|
9383
9383
|
stepNumber: r
|
|
9384
9384
|
},
|
|
9385
|
-
completion:
|
|
9386
|
-
}), c = (e) => s?.run(e) ?? e(), d =
|
|
9385
|
+
completion: xe.promise
|
|
9386
|
+
}), c = (e) => s?.run(e) ?? e(), d = B.flatMap((e) => e.response.messages), f = [...De, ...d], p = Oe ?? [...S, ...De], h = await re?.({
|
|
9387
9387
|
model: e,
|
|
9388
|
-
steps:
|
|
9389
|
-
stepNumber:
|
|
9388
|
+
steps: B,
|
|
9389
|
+
stepNumber: B.length,
|
|
9390
9390
|
instructions: A,
|
|
9391
9391
|
initialInstructions: t.instructions,
|
|
9392
9392
|
messages: p,
|
|
9393
9393
|
initialMessages: S,
|
|
9394
9394
|
responseMessages: f,
|
|
9395
|
-
toolsContext:
|
|
9396
|
-
runtimeContext:
|
|
9395
|
+
toolsContext: ge,
|
|
9396
|
+
runtimeContext: he,
|
|
9397
9397
|
experimental_sandbox: v
|
|
9398
9398
|
}), M = h?.experimental_sandbox ?? v;
|
|
9399
|
-
|
|
9400
|
-
let
|
|
9401
|
-
|
|
9402
|
-
let
|
|
9399
|
+
he = h?.runtimeContext ?? he, ge = h?.toolsContext ?? ge;
|
|
9400
|
+
let F = vs(h?.model ?? e);
|
|
9401
|
+
V = F;
|
|
9402
|
+
let le = Yc({
|
|
9403
9403
|
tools: y,
|
|
9404
9404
|
activeTools: h?.activeTools ?? C
|
|
9405
|
-
}), { executionTools:
|
|
9406
|
-
tools:
|
|
9407
|
-
toolsContext:
|
|
9405
|
+
}), { executionTools: I, modelTools: Se, toolCallerMessages: Ce } = Bc({
|
|
9406
|
+
tools: be(le, {
|
|
9407
|
+
toolsContext: ge,
|
|
9408
9408
|
experimental_sandbox: M
|
|
9409
9409
|
}),
|
|
9410
|
-
toolCallers:
|
|
9411
|
-
}),
|
|
9412
|
-
tools:
|
|
9413
|
-
toolOrder:
|
|
9414
|
-
toolsContext:
|
|
9410
|
+
toolCallers: ye
|
|
9411
|
+
}), we = h?.toolOrder ?? w, R = await qs({
|
|
9412
|
+
tools: Se,
|
|
9413
|
+
toolOrder: we,
|
|
9414
|
+
toolsContext: ge,
|
|
9415
9415
|
experimental_sandbox: M
|
|
9416
|
-
}),
|
|
9416
|
+
}), Te = Ks({ toolChoice: h?.toolChoice ?? b }), Ee = Vc({
|
|
9417
9417
|
messages: h?.messages ?? p,
|
|
9418
|
-
toolCallerMessages:
|
|
9418
|
+
toolCallerMessages: Ce
|
|
9419
9419
|
});
|
|
9420
|
-
|
|
9421
|
-
let
|
|
9422
|
-
A =
|
|
9423
|
-
let
|
|
9424
|
-
callSettings:
|
|
9420
|
+
ke = Ee;
|
|
9421
|
+
let Ae = h?.instructions ?? h?.system ?? A;
|
|
9422
|
+
A = Ae;
|
|
9423
|
+
let je = Ms(ne, h?.providerOptions), Pe = ml({
|
|
9424
|
+
callSettings: We,
|
|
9425
9425
|
stepSettings: h
|
|
9426
|
-
}),
|
|
9427
|
-
maxRetries:
|
|
9426
|
+
}), Fe = j(), { retry: Ie } = Ac({
|
|
9427
|
+
maxRetries: He,
|
|
9428
9428
|
abortSignal: o
|
|
9429
|
-
}),
|
|
9429
|
+
}), W = !1, Re = () => c(() => Ie(async () => Yu({
|
|
9430
9430
|
model: h?.model ?? e,
|
|
9431
|
-
tools:
|
|
9432
|
-
toolOrder:
|
|
9431
|
+
tools: Se,
|
|
9432
|
+
toolOrder: we,
|
|
9433
9433
|
toolChoice: h?.toolChoice ?? b,
|
|
9434
|
-
instructions:
|
|
9435
|
-
messages:
|
|
9434
|
+
instructions: Ae,
|
|
9435
|
+
messages: Ee,
|
|
9436
9436
|
allowSystemInMessages: _,
|
|
9437
9437
|
repairToolCall: ee,
|
|
9438
9438
|
refineToolInput: E,
|
|
9439
9439
|
abortSignal: o,
|
|
9440
9440
|
headers: n,
|
|
9441
|
-
includeRawChunks:
|
|
9442
|
-
providerOptions:
|
|
9443
|
-
download:
|
|
9441
|
+
includeRawChunks: ve.rawChunks,
|
|
9442
|
+
providerOptions: je,
|
|
9443
|
+
download: _e,
|
|
9444
9444
|
output: O,
|
|
9445
|
-
callId:
|
|
9446
|
-
executeLanguageModelCallInTelemetryContext:
|
|
9447
|
-
toolsContext:
|
|
9445
|
+
callId: Ke,
|
|
9446
|
+
executeLanguageModelCallInTelemetryContext: L.executeLanguageModelCall,
|
|
9447
|
+
toolsContext: ge,
|
|
9448
9448
|
experimental_sandbox: M,
|
|
9449
|
-
onLanguageModelCallStart: oe(
|
|
9450
|
-
onLanguageModelCallEnd: oe(
|
|
9449
|
+
onLanguageModelCallStart: oe(de, L.onLanguageModelCallStart),
|
|
9450
|
+
onLanguageModelCallEnd: oe(fe, L.onLanguageModelCallEnd),
|
|
9451
9451
|
onStart: async ({ promptMessages: e }) => {
|
|
9452
|
-
|
|
9452
|
+
W || (W = !0, await $({
|
|
9453
9453
|
event: {
|
|
9454
|
-
callId:
|
|
9455
|
-
provider:
|
|
9456
|
-
modelId:
|
|
9457
|
-
stepNumber:
|
|
9458
|
-
instructions:
|
|
9459
|
-
messages:
|
|
9454
|
+
callId: Ke,
|
|
9455
|
+
provider: F.provider,
|
|
9456
|
+
modelId: F.modelId,
|
|
9457
|
+
stepNumber: B.length,
|
|
9458
|
+
instructions: Ae,
|
|
9459
|
+
messages: Ee,
|
|
9460
9460
|
tools: y,
|
|
9461
9461
|
toolChoice: h?.toolChoice ?? b,
|
|
9462
9462
|
activeTools: h?.activeTools ?? C,
|
|
9463
|
-
toolOrder:
|
|
9464
|
-
steps: [...
|
|
9465
|
-
providerOptions:
|
|
9466
|
-
runtimeContext:
|
|
9467
|
-
toolsContext:
|
|
9463
|
+
toolOrder: we,
|
|
9464
|
+
steps: [...B],
|
|
9465
|
+
providerOptions: je,
|
|
9466
|
+
runtimeContext: he,
|
|
9467
|
+
toolsContext: ge,
|
|
9468
9468
|
output: O,
|
|
9469
9469
|
promptMessages: e,
|
|
9470
|
-
stepTools:
|
|
9471
|
-
stepToolChoice:
|
|
9470
|
+
stepTools: R,
|
|
9471
|
+
stepToolChoice: Te
|
|
9472
9472
|
},
|
|
9473
|
-
callbacks: [
|
|
9473
|
+
callbacks: [ue, L.onStepStart]
|
|
9474
9474
|
}));
|
|
9475
9475
|
},
|
|
9476
9476
|
_internal: { now: j },
|
|
9477
|
-
...
|
|
9478
|
-
}))),
|
|
9477
|
+
...Pe
|
|
9478
|
+
}))), ze = await Re(), Be = ze.request, Ve = ze.response, qe = ze.stream.getReader(), Je = 0, Ye = 0, G = [], Xe = /* @__PURE__ */ new WeakSet(), K = /* @__PURE__ */ new Set(), Ze = /* @__PURE__ */ new Set(), Qe = !1, $e = Ue > 0 || se, et = new ReadableStream({
|
|
9479
9479
|
async pull(e) {
|
|
9480
9480
|
let t = (t) => {
|
|
9481
9481
|
switch (t.type) {
|
|
@@ -9492,8 +9492,8 @@ var cd = class {
|
|
|
9492
9492
|
}
|
|
9493
9493
|
e.enqueue(t);
|
|
9494
9494
|
}, n = () => {
|
|
9495
|
-
for (let e of
|
|
9496
|
-
|
|
9495
|
+
for (let e of G) t(e);
|
|
9496
|
+
G = [];
|
|
9497
9497
|
}, r = () => {
|
|
9498
9498
|
for (let t of K) e.enqueue({
|
|
9499
9499
|
type: "text-end",
|
|
@@ -9507,12 +9507,12 @@ var cd = class {
|
|
|
9507
9507
|
Ze.clear();
|
|
9508
9508
|
};
|
|
9509
9509
|
for (;;) {
|
|
9510
|
-
let { done: i, value: a } = await
|
|
9510
|
+
let { done: i, value: a } = await qe.read();
|
|
9511
9511
|
if (Qe &&= (e.enqueue(Ru({ warnings: i || a.type !== "model-call-start" ? [] : a.warnings })), !1), i) return n(), void e.close();
|
|
9512
9512
|
let o = a.type === "tool-input-start" || a.type === "tool-input-delta" || a.type === "tool-input-end" || a.type === "tool-call" || a.type === "tool-approval-request" || a.type === "tool-approval-response" || a.type === "tool-result" || a.type === "tool-error";
|
|
9513
9513
|
if (a.type === "model-call-end") return n(), void t(a);
|
|
9514
|
-
if ($e && a.type !== "error" && (o ||
|
|
9515
|
-
rd(a) && (g(), x(), Xe.add(a)),
|
|
9514
|
+
if ($e && a.type !== "error" && (o || G.length > 0)) {
|
|
9515
|
+
rd(a) && (g(), x(), Xe.add(a)), G.push(a);
|
|
9516
9516
|
continue;
|
|
9517
9517
|
}
|
|
9518
9518
|
if (a.type !== "error") return void t(a);
|
|
@@ -9524,12 +9524,12 @@ var cd = class {
|
|
|
9524
9524
|
try {
|
|
9525
9525
|
l = await P({ error: s });
|
|
9526
9526
|
} catch {}
|
|
9527
|
-
let u =
|
|
9528
|
-
if (!d && (c || d || !u || !(
|
|
9527
|
+
let u = se && typeof l == "object" && !!l && "retry" in l && !0 === l.retry, d = !c && Je < Ue;
|
|
9528
|
+
if (!d && (c || d || !u || !(Ye < 1))) return n(), Le.add(a.error), void e.enqueue(a);
|
|
9529
9529
|
let f;
|
|
9530
|
-
d ?
|
|
9530
|
+
d ? Je++ : Ye++, await qe.cancel(s), G = [], r();
|
|
9531
9531
|
try {
|
|
9532
|
-
f = await
|
|
9532
|
+
f = await Re();
|
|
9533
9533
|
} catch (t) {
|
|
9534
9534
|
e.enqueue({
|
|
9535
9535
|
type: "error",
|
|
@@ -9537,10 +9537,10 @@ var cd = class {
|
|
|
9537
9537
|
}), e.close();
|
|
9538
9538
|
return;
|
|
9539
9539
|
}
|
|
9540
|
-
|
|
9540
|
+
Be = f.request, Ve = f.response, qe = f.stream.getReader(), Qe = !0;
|
|
9541
9541
|
}
|
|
9542
9542
|
},
|
|
9543
|
-
cancel: (e) =>
|
|
9543
|
+
cancel: (e) => qe.cancel(e)
|
|
9544
9544
|
});
|
|
9545
9545
|
o?.aborted || (m = jc({
|
|
9546
9546
|
abortController: u,
|
|
@@ -9614,11 +9614,11 @@ var cd = class {
|
|
|
9614
9614
|
} }));
|
|
9615
9615
|
}({
|
|
9616
9616
|
stream: et,
|
|
9617
|
-
tools:
|
|
9618
|
-
stepInputMessages:
|
|
9617
|
+
tools: I,
|
|
9618
|
+
stepInputMessages: Ee,
|
|
9619
9619
|
abortSignal: o,
|
|
9620
|
-
toolsContext:
|
|
9621
|
-
}), nt =
|
|
9620
|
+
toolsContext: ge
|
|
9621
|
+
}), nt = L.runInTracingChannelSpan == null ? void 0 : (e) => c(() => L.runInTracingChannelSpan(e)), rt = function({ stream: e, tools: t, callId: n, messages: r, abortSignal: i, timeout: a, experimental_sandbox: o, toolsContext: s, toolApproval: c, runtimeContext: l, toolApprovalSecret: u, generateId: d, onToolExecutionStart: f, onToolExecutionEnd: p, executeToolInTelemetryContext: m, runInTracingChannelSpan: h }) {
|
|
9622
9622
|
let g = [];
|
|
9623
9623
|
return e.pipeThrough(new TransformStream({ async transform(e, _) {
|
|
9624
9624
|
if (_.enqueue(e), zu(e)) g.length = 0;
|
|
@@ -9728,27 +9728,27 @@ var cd = class {
|
|
|
9728
9728
|
} }));
|
|
9729
9729
|
}({
|
|
9730
9730
|
stream: tt,
|
|
9731
|
-
tools:
|
|
9732
|
-
callId:
|
|
9733
|
-
messages:
|
|
9731
|
+
tools: I,
|
|
9732
|
+
callId: Ke,
|
|
9733
|
+
messages: Ee,
|
|
9734
9734
|
abortSignal: o,
|
|
9735
9735
|
timeout: N,
|
|
9736
9736
|
experimental_sandbox: M,
|
|
9737
|
-
toolsContext:
|
|
9737
|
+
toolsContext: ge,
|
|
9738
9738
|
toolApproval: k,
|
|
9739
|
-
runtimeContext:
|
|
9739
|
+
runtimeContext: he,
|
|
9740
9740
|
toolApprovalSecret: te,
|
|
9741
9741
|
generateId: ie,
|
|
9742
|
-
onToolExecutionStart: oe(
|
|
9743
|
-
onToolExecutionEnd: oe(
|
|
9744
|
-
executeToolInTelemetryContext:
|
|
9742
|
+
onToolExecutionStart: oe(pe, L.onToolExecutionStart),
|
|
9743
|
+
onToolExecutionEnd: oe(me, L.onToolExecutionEnd),
|
|
9744
|
+
executeToolInTelemetryContext: L.executeTool,
|
|
9745
9745
|
runInTracingChannelSpan: nt
|
|
9746
9746
|
}), it = () => ({
|
|
9747
|
-
...
|
|
9748
|
-
body:
|
|
9749
|
-
messages:
|
|
9747
|
+
...Be,
|
|
9748
|
+
body: ve.requestBody ? Be?.body : void 0,
|
|
9749
|
+
messages: ve.requestMessages ? Ds(Ee) : void 0
|
|
9750
9750
|
});
|
|
9751
|
-
|
|
9751
|
+
z = it().messages ?? [];
|
|
9752
9752
|
let at = [], ot = [], st = [], ct, lt, ut, dt = "other", ft = !1, pt = !1, mt = {
|
|
9753
9753
|
inputTokens: void 0,
|
|
9754
9754
|
inputTokenDetails: {
|
|
@@ -9774,11 +9774,11 @@ var cd = class {
|
|
|
9774
9774
|
}), _t = gt(), vt = {}, yt = () => ({
|
|
9775
9775
|
id: ie(),
|
|
9776
9776
|
timestamp: /* @__PURE__ */ new Date(),
|
|
9777
|
-
modelId:
|
|
9777
|
+
modelId: F.modelId
|
|
9778
9778
|
}), bt = yt(), xt = /* @__PURE__ */ new Map(), St = /* @__PURE__ */ new Map(), Ct = (e, t) => {
|
|
9779
9779
|
e.enqueue(t);
|
|
9780
9780
|
};
|
|
9781
|
-
|
|
9781
|
+
Ge.addStream(rt.pipeThrough(new TransformStream({
|
|
9782
9782
|
async transform(e, t) {
|
|
9783
9783
|
if (zu(e)) return ct = e.warnings, dt = "other", lt = void 0, ft = !1, pt = !1, mt = {
|
|
9784
9784
|
inputTokens: void 0,
|
|
@@ -9822,7 +9822,7 @@ var cd = class {
|
|
|
9822
9822
|
Ct(t, e);
|
|
9823
9823
|
break;
|
|
9824
9824
|
case "text-start": {
|
|
9825
|
-
let n =
|
|
9825
|
+
let n = Me(e.id);
|
|
9826
9826
|
xt.set(e.id, n), Ct(t, {
|
|
9827
9827
|
...e,
|
|
9828
9828
|
id: n
|
|
@@ -9842,7 +9842,7 @@ var cd = class {
|
|
|
9842
9842
|
}), xt.delete(e.id);
|
|
9843
9843
|
break;
|
|
9844
9844
|
case "reasoning-start": {
|
|
9845
|
-
let n =
|
|
9845
|
+
let n = H(e.id);
|
|
9846
9846
|
St.set(e.id, n), Ct(t, {
|
|
9847
9847
|
...e,
|
|
9848
9848
|
id: n
|
|
@@ -9890,7 +9890,7 @@ var cd = class {
|
|
|
9890
9890
|
ft = !0, Ct(t, e), dt = "error";
|
|
9891
9891
|
break;
|
|
9892
9892
|
case "raw":
|
|
9893
|
-
|
|
9893
|
+
ve.rawChunks && Ct(t, e);
|
|
9894
9894
|
break;
|
|
9895
9895
|
default: throw Error(`Unknown chunk type: ${n}`);
|
|
9896
9896
|
}
|
|
@@ -9899,8 +9899,8 @@ var cd = class {
|
|
|
9899
9899
|
if (!ft && !pt) return Ct(e, {
|
|
9900
9900
|
type: "error",
|
|
9901
9901
|
error: new Na({ message: "No output generated. The model stream ended without a finish chunk." })
|
|
9902
|
-
}), T(), void
|
|
9903
|
-
let t = j() -
|
|
9902
|
+
}), T(), void Ge.closeStream();
|
|
9903
|
+
let t = j() - Fe, n = {
|
|
9904
9904
|
type: "finish-step",
|
|
9905
9905
|
finishReason: dt,
|
|
9906
9906
|
rawFinishReason: lt,
|
|
@@ -9913,24 +9913,24 @@ var cd = class {
|
|
|
9913
9913
|
providerMetadata: ut,
|
|
9914
9914
|
response: {
|
|
9915
9915
|
...bt,
|
|
9916
|
-
headers:
|
|
9916
|
+
headers: Ve?.headers
|
|
9917
9917
|
}
|
|
9918
9918
|
};
|
|
9919
9919
|
Ct(e, n);
|
|
9920
9920
|
let o = wc(i, mt);
|
|
9921
|
-
await
|
|
9921
|
+
await xe.promise;
|
|
9922
9922
|
let s = at.filter((e) => !0 !== e.providerExecuted), c = ot.filter((e) => !0 !== e.providerExecuted), l = st.filter((e) => !1 === e.approved);
|
|
9923
9923
|
for (let e of at) {
|
|
9924
9924
|
if (!0 !== e.providerExecuted) continue;
|
|
9925
|
-
let t = Q(
|
|
9926
|
-
t?.type === "provider" && t.supportsDeferredResults && (ot.some((t) => (t.type === "tool-result" || t.type === "tool-error") && t.toolCallId === e.toolCallId) ||
|
|
9925
|
+
let t = Q(I, e.toolName);
|
|
9926
|
+
t?.type === "provider" && t.supportsDeferredResults && (ot.some((t) => (t.type === "tool-result" || t.type === "tool-error") && t.toolCallId === e.toolCallId) || Ne.set(e.toolCallId, { toolName: e.toolName }));
|
|
9927
9927
|
}
|
|
9928
|
-
for (let e of ot) e.type !== "tool-result" && e.type !== "tool-error" ||
|
|
9929
|
-
if (T(), s.length === c.length + l.length && (s.length > 0 ||
|
|
9928
|
+
for (let e of ot) e.type !== "tool-result" && e.type !== "tool-error" || Ne.delete(e.toolCallId);
|
|
9929
|
+
if (T(), s.length === c.length + l.length && (s.length > 0 || Ne.size > 0) && !await Il({
|
|
9930
9930
|
stopConditions: D,
|
|
9931
|
-
steps:
|
|
9931
|
+
steps: B
|
|
9932
9932
|
})) try {
|
|
9933
|
-
await a(() =>
|
|
9933
|
+
await a(() => ce({
|
|
9934
9934
|
currentStep: r + 1,
|
|
9935
9935
|
usage: o
|
|
9936
9936
|
}));
|
|
@@ -9938,14 +9938,14 @@ var cd = class {
|
|
|
9938
9938
|
Ct(e, {
|
|
9939
9939
|
type: "error",
|
|
9940
9940
|
error: t
|
|
9941
|
-
}),
|
|
9941
|
+
}), Ge.closeStream();
|
|
9942
9942
|
}
|
|
9943
9943
|
else Ct(e, {
|
|
9944
9944
|
type: "finish",
|
|
9945
9945
|
finishReason: dt,
|
|
9946
9946
|
rawFinishReason: lt,
|
|
9947
9947
|
totalUsage: o
|
|
9948
|
-
}),
|
|
9948
|
+
}), Ge.closeStream();
|
|
9949
9949
|
}
|
|
9950
9950
|
})), {
|
|
9951
9951
|
onError: T,
|
|
@@ -9955,7 +9955,7 @@ var cd = class {
|
|
|
9955
9955
|
throw T(), e;
|
|
9956
9956
|
}
|
|
9957
9957
|
}
|
|
9958
|
-
|
|
9958
|
+
Ge._initialResponseMessages.resolve(De), await a(() => ce({
|
|
9959
9959
|
currentStep: 0,
|
|
9960
9960
|
usage: {
|
|
9961
9961
|
inputTokens: void 0,
|
|
@@ -9974,15 +9974,15 @@ var cd = class {
|
|
|
9974
9974
|
}
|
|
9975
9975
|
}));
|
|
9976
9976
|
})().catch(async (e) => {
|
|
9977
|
-
await
|
|
9978
|
-
callId:
|
|
9977
|
+
await L.onError?.({
|
|
9978
|
+
callId: Ke,
|
|
9979
9979
|
error: e
|
|
9980
|
-
}),
|
|
9980
|
+
}), Ge._initialResponseMessages.reject(e), sd(Ge._initialResponseMessages.promise), Ge.addStream(new ReadableStream({ start(t) {
|
|
9981
9981
|
t.enqueue({
|
|
9982
9982
|
type: "error",
|
|
9983
9983
|
error: e
|
|
9984
9984
|
}), t.close();
|
|
9985
|
-
} })),
|
|
9985
|
+
} })), Ge.closeStream();
|
|
9986
9986
|
});
|
|
9987
9987
|
}
|
|
9988
9988
|
get steps() {
|
|
@@ -10112,7 +10112,7 @@ var cd = class {
|
|
|
10112
10112
|
}
|
|
10113
10113
|
get elementStream() {
|
|
10114
10114
|
let e = this.outputSpecification?.createElementStreamTransform();
|
|
10115
|
-
if (e == null) throw new
|
|
10115
|
+
if (e == null) throw new V({ functionality: `element streams in ${this.outputSpecification?.name ?? "text"} mode` });
|
|
10116
10116
|
return Mu(this.teeStream().pipeThrough(e));
|
|
10117
10117
|
}
|
|
10118
10118
|
getOutputPromise() {
|
|
@@ -10626,7 +10626,7 @@ function vd(e) {
|
|
|
10626
10626
|
function yd(e) {
|
|
10627
10627
|
return e.approval != null && Object.prototype.hasOwnProperty.call(e.approval, "inputSchemaInput") ? { value: e.approval.inputSchemaInput } : void 0;
|
|
10628
10628
|
}
|
|
10629
|
-
var bd =
|
|
10629
|
+
var bd = W(() => {
|
|
10630
10630
|
let e = X.object({
|
|
10631
10631
|
id: X.string(),
|
|
10632
10632
|
approved: X.never().optional(),
|
|
@@ -10986,7 +10986,7 @@ async function xd({ messages: e, metadataSchema: t, dataSchemas: n, tools: r, ex
|
|
|
10986
10986
|
entityId: n.toolCallId
|
|
10987
10987
|
}, p = yd(n), m = p == null ? n.input : p.value, h = !1;
|
|
10988
10988
|
if (n.state !== "input-streaming" && (n.state !== "output-error" || p != null || n.input !== void 0)) {
|
|
10989
|
-
let e = await
|
|
10989
|
+
let e = await H({
|
|
10990
10990
|
value: m,
|
|
10991
10991
|
schema: u.inputSchema,
|
|
10992
10992
|
context: f
|
|
@@ -11100,7 +11100,7 @@ function kd(e) {
|
|
|
11100
11100
|
function Ad(e) {
|
|
11101
11101
|
if (e instanceof Uint8Array) return e;
|
|
11102
11102
|
if (typeof e == "string") try {
|
|
11103
|
-
return
|
|
11103
|
+
return B(e);
|
|
11104
11104
|
} catch (t) {
|
|
11105
11105
|
throw new Io({
|
|
11106
11106
|
message: "Invalid data content. Content string is not a base64-encoded media.",
|
|
@@ -11257,7 +11257,7 @@ function Rd(e) {
|
|
|
11257
11257
|
if (typeof e == "string" && e.startsWith("data:")) {
|
|
11258
11258
|
let { mediaType: t, base64Content: n } = Ns(e);
|
|
11259
11259
|
if (n != null) {
|
|
11260
|
-
let e =
|
|
11260
|
+
let e = B(n);
|
|
11261
11261
|
return {
|
|
11262
11262
|
type: "file",
|
|
11263
11263
|
data: e,
|
|
@@ -11283,7 +11283,7 @@ async function zd({ provider: e, batch: t, providerOptions: n, abortSignal: r, h
|
|
|
11283
11283
|
if (Kd({
|
|
11284
11284
|
batchApi: o,
|
|
11285
11285
|
batch: t
|
|
11286
|
-
}), o.doCancelBatch == null) throw new
|
|
11286
|
+
}), o.doCancelBatch == null) throw new V({
|
|
11287
11287
|
functionality: "batch cancellation",
|
|
11288
11288
|
message: "The provider does not support batch cancellation."
|
|
11289
11289
|
});
|
|
@@ -11301,7 +11301,7 @@ async function zd({ provider: e, batch: t, providerOptions: n, abortSignal: r, h
|
|
|
11301
11301
|
}
|
|
11302
11302
|
async function Bd({ provider: e, providerOptions: t, limit: n, cursor: r, maxRetries: i, abortSignal: a, headers: o, timeout: s } = {}) {
|
|
11303
11303
|
let c = Gd(e), l = c.doListBatches?.bind(c);
|
|
11304
|
-
if (l == null) throw new
|
|
11304
|
+
if (l == null) throw new V({
|
|
11305
11305
|
functionality: "batch listing",
|
|
11306
11306
|
message: "The provider does not support listing batches."
|
|
11307
11307
|
});
|
|
@@ -11573,7 +11573,7 @@ function Gd(e) {
|
|
|
11573
11573
|
}(e)) return e;
|
|
11574
11574
|
if (!function(e) {
|
|
11575
11575
|
return typeof e.experimental_batch == "function";
|
|
11576
|
-
}(e)) throw new
|
|
11576
|
+
}(e)) throw new V({
|
|
11577
11577
|
functionality: "batch processing",
|
|
11578
11578
|
message: "The provider does not support batch processing. Make sure it exposes an experimental_batch() method."
|
|
11579
11579
|
});
|
|
@@ -11755,10 +11755,10 @@ var Zd = class {
|
|
|
11755
11755
|
}
|
|
11756
11756
|
};
|
|
11757
11757
|
function Qd(e) {
|
|
11758
|
-
return e[
|
|
11758
|
+
return e[De];
|
|
11759
11759
|
}
|
|
11760
11760
|
function $d(e) {
|
|
11761
|
-
return e[
|
|
11761
|
+
return e[he];
|
|
11762
11762
|
}
|
|
11763
11763
|
var ef = c({
|
|
11764
11764
|
prefix: "call",
|
|
@@ -12233,7 +12233,7 @@ var _f = {
|
|
|
12233
12233
|
value: e
|
|
12234
12234
|
},
|
|
12235
12235
|
createElementStream() {
|
|
12236
|
-
throw new
|
|
12236
|
+
throw new V({ functionality: "element streams in no-schema mode" });
|
|
12237
12237
|
}
|
|
12238
12238
|
}, vf = (e) => ({
|
|
12239
12239
|
type: "object",
|
|
@@ -12245,12 +12245,12 @@ var _f = {
|
|
|
12245
12245
|
textDelta: t
|
|
12246
12246
|
}
|
|
12247
12247
|
}),
|
|
12248
|
-
validateFinalResult: async (t) =>
|
|
12248
|
+
validateFinalResult: async (t) => H({
|
|
12249
12249
|
value: t,
|
|
12250
12250
|
schema: e
|
|
12251
12251
|
}),
|
|
12252
12252
|
createElementStream() {
|
|
12253
|
-
throw new
|
|
12253
|
+
throw new V({ functionality: "element streams in object mode" });
|
|
12254
12254
|
}
|
|
12255
12255
|
}), yf = (e) => ({
|
|
12256
12256
|
type: "array",
|
|
@@ -12279,7 +12279,7 @@ var _f = {
|
|
|
12279
12279
|
};
|
|
12280
12280
|
let o = t.elements, s = [];
|
|
12281
12281
|
for (let t = 0; t < o.length; t++) {
|
|
12282
|
-
let n = o[t], r = await
|
|
12282
|
+
let n = o[t], r = await H({
|
|
12283
12283
|
value: n,
|
|
12284
12284
|
schema: e
|
|
12285
12285
|
});
|
|
@@ -12307,7 +12307,7 @@ var _f = {
|
|
|
12307
12307
|
};
|
|
12308
12308
|
let n = t.elements, r = [];
|
|
12309
12309
|
for (let t of n) {
|
|
12310
|
-
let n = await
|
|
12310
|
+
let n = await H({
|
|
12311
12311
|
value: t,
|
|
12312
12312
|
schema: e
|
|
12313
12313
|
});
|
|
@@ -12391,13 +12391,13 @@ var _f = {
|
|
|
12391
12391
|
};
|
|
12392
12392
|
},
|
|
12393
12393
|
createElementStream() {
|
|
12394
|
-
throw new
|
|
12394
|
+
throw new V({ functionality: "element streams in enum mode" });
|
|
12395
12395
|
}
|
|
12396
12396
|
});
|
|
12397
12397
|
function xf({ output: e, schema: t, enumValues: n }) {
|
|
12398
12398
|
switch (e) {
|
|
12399
|
-
case "object": return vf(
|
|
12400
|
-
case "array": return yf(
|
|
12399
|
+
case "object": return vf(qe(t));
|
|
12400
|
+
case "array": return yf(qe(t));
|
|
12401
12401
|
case "enum": return bf(n);
|
|
12402
12402
|
case "no-schema": return _f;
|
|
12403
12403
|
default: throw Error(`Unsupported output: ${e}`);
|
|
@@ -12543,10 +12543,10 @@ async function Ef(e) {
|
|
|
12543
12543
|
output: n,
|
|
12544
12544
|
schema: O,
|
|
12545
12545
|
enumValues: D
|
|
12546
|
-
}), ie = Gs(ee), M = j(u ?? {}, `ai/${ks}`), N = kl({ telemetry: m }), ae = _ ?? v, P = y ?? b, oe = x ?? S,
|
|
12546
|
+
}), ie = Gs(ee), M = j(u ?? {}, `ai/${ks}`), N = kl({ telemetry: m }), ae = _ ?? v, P = y ?? b, oe = x ?? S, se = await re.jsonSchema(), F = w();
|
|
12547
12547
|
await $({
|
|
12548
12548
|
event: {
|
|
12549
|
-
callId:
|
|
12549
|
+
callId: F,
|
|
12550
12550
|
operationId: "ai.generateObject",
|
|
12551
12551
|
provider: E.provider,
|
|
12552
12552
|
modelId: E.modelId,
|
|
@@ -12564,7 +12564,7 @@ async function Ef(e) {
|
|
|
12564
12564
|
headers: M,
|
|
12565
12565
|
providerOptions: g,
|
|
12566
12566
|
output: re.type,
|
|
12567
|
-
schema:
|
|
12567
|
+
schema: se,
|
|
12568
12568
|
schemaName: A,
|
|
12569
12569
|
schemaDescription: k
|
|
12570
12570
|
},
|
|
@@ -12586,7 +12586,7 @@ async function Ef(e) {
|
|
|
12586
12586
|
});
|
|
12587
12587
|
await $({
|
|
12588
12588
|
event: {
|
|
12589
|
-
callId:
|
|
12589
|
+
callId: F,
|
|
12590
12590
|
stepNumber: 0,
|
|
12591
12591
|
provider: E.provider,
|
|
12592
12592
|
modelId: E.modelId,
|
|
@@ -12599,7 +12599,7 @@ async function Ef(e) {
|
|
|
12599
12599
|
let t = await ne(() => E.doGenerate({
|
|
12600
12600
|
responseFormat: {
|
|
12601
12601
|
type: "json",
|
|
12602
|
-
schema:
|
|
12602
|
+
schema: se,
|
|
12603
12603
|
name: A,
|
|
12604
12604
|
description: k
|
|
12605
12605
|
},
|
|
@@ -12634,7 +12634,7 @@ async function Ef(e) {
|
|
|
12634
12634
|
model: E.modelId
|
|
12635
12635
|
}), await $({
|
|
12636
12636
|
event: {
|
|
12637
|
-
callId:
|
|
12637
|
+
callId: F,
|
|
12638
12638
|
stepNumber: 0,
|
|
12639
12639
|
provider: E.provider,
|
|
12640
12640
|
modelId: E.modelId,
|
|
@@ -12657,7 +12657,7 @@ async function Ef(e) {
|
|
|
12657
12657
|
});
|
|
12658
12658
|
return await $({
|
|
12659
12659
|
event: {
|
|
12660
|
-
callId:
|
|
12660
|
+
callId: F,
|
|
12661
12661
|
object: b,
|
|
12662
12662
|
error: void 0,
|
|
12663
12663
|
reasoning: u,
|
|
@@ -12681,7 +12681,7 @@ async function Ef(e) {
|
|
|
12681
12681
|
});
|
|
12682
12682
|
} catch (e) {
|
|
12683
12683
|
throw await N.onError?.({
|
|
12684
|
-
callId:
|
|
12684
|
+
callId: F,
|
|
12685
12685
|
error: e
|
|
12686
12686
|
}), Sc(e);
|
|
12687
12687
|
}
|
|
@@ -12815,7 +12815,7 @@ function Ff(e) {
|
|
|
12815
12815
|
}
|
|
12816
12816
|
var If = class {
|
|
12817
12817
|
constructor({ model: e, headers: t, telemetry: n, settings: r, maxRetries: i, abortSignal: a, outputStrategy: o, instructions: s, system: c, prompt: l, messages: u, allowSystemInMessages: d, schemaName: f, schemaDescription: p, providerOptions: m, repairText: h, onStart: g, onStepStart: _, onStepFinish: v, onError: y, onFinish: b, download: x, generateId: S, currentDate: C, now: w }) {
|
|
12818
|
-
this._object = new
|
|
12818
|
+
this._object = new U(), this._usage = new U(), this._providerMetadata = new U(), this._warnings = new U(), this._request = new U(), this._response = new U(), this._finishReason = new U();
|
|
12819
12819
|
let T = vs(e), { maxRetries: ee, retry: E } = Ac({
|
|
12820
12820
|
maxRetries: i,
|
|
12821
12821
|
abortSignal: a
|
|
@@ -12895,7 +12895,7 @@ var If = class {
|
|
|
12895
12895
|
});
|
|
12896
12896
|
let te = w(), { stream: re, response: j, request: ie } = await E(() => T.doStream(i)), M;
|
|
12897
12897
|
k._request.resolve(ie ?? {});
|
|
12898
|
-
let N, ae, P, oe,
|
|
12898
|
+
let N, ae, P, oe, se, F, ce, le, I = {
|
|
12899
12899
|
inputTokens: void 0,
|
|
12900
12900
|
inputTokenDetails: {
|
|
12901
12901
|
noCacheTokens: void 0,
|
|
@@ -12909,11 +12909,11 @@ var If = class {
|
|
|
12909
12909
|
},
|
|
12910
12910
|
totalTokens: void 0,
|
|
12911
12911
|
raw: void 0
|
|
12912
|
-
},
|
|
12912
|
+
}, ue = "", de = "", fe = {
|
|
12913
12913
|
id: S(),
|
|
12914
12914
|
timestamp: C(),
|
|
12915
12915
|
modelId: T.modelId
|
|
12916
|
-
},
|
|
12916
|
+
}, pe = !0, me = !0, he = re.pipeThrough(new TransformStream({ transform: (e, t) => {
|
|
12917
12917
|
switch (e.type) {
|
|
12918
12918
|
case "text-delta":
|
|
12919
12919
|
t.enqueue(e.delta);
|
|
@@ -12926,64 +12926,64 @@ var If = class {
|
|
|
12926
12926
|
} })).pipeThrough(new TransformStream({
|
|
12927
12927
|
async transform(e, t) {
|
|
12928
12928
|
if (typeof e != "object" || e.type !== "stream-start") {
|
|
12929
|
-
if (
|
|
12930
|
-
|
|
12931
|
-
let { value: n, state: r } = await $c(
|
|
12932
|
-
if (n !== void 0 && !Rl(
|
|
12929
|
+
if (pe &&= (F = w() - te, !1), typeof e == "string") {
|
|
12930
|
+
ue += e, de += e;
|
|
12931
|
+
let { value: n, state: r } = await $c(ue);
|
|
12932
|
+
if (n !== void 0 && !Rl(ce, n)) {
|
|
12933
12933
|
let e = await o.validatePartialResult({
|
|
12934
12934
|
value: n,
|
|
12935
|
-
textDelta:
|
|
12936
|
-
latestObject:
|
|
12937
|
-
isFirstDelta:
|
|
12935
|
+
textDelta: de,
|
|
12936
|
+
latestObject: le,
|
|
12937
|
+
isFirstDelta: me,
|
|
12938
12938
|
isFinalDelta: r === "successful-parse"
|
|
12939
12939
|
});
|
|
12940
|
-
e.success && !Rl(
|
|
12940
|
+
e.success && !Rl(le, e.value.partial) && (ce = n, le = e.value.partial, t.enqueue({
|
|
12941
12941
|
type: "object",
|
|
12942
|
-
object:
|
|
12942
|
+
object: le
|
|
12943
12943
|
}), t.enqueue({
|
|
12944
12944
|
type: "text-delta",
|
|
12945
12945
|
textDelta: e.value.textDelta
|
|
12946
|
-
}),
|
|
12946
|
+
}), de = "", me = !1);
|
|
12947
12947
|
}
|
|
12948
12948
|
return;
|
|
12949
12949
|
}
|
|
12950
12950
|
switch (e.type) {
|
|
12951
12951
|
case "response-metadata":
|
|
12952
|
-
|
|
12953
|
-
id: e.id ??
|
|
12954
|
-
timestamp: e.timestamp ??
|
|
12955
|
-
modelId: e.modelId ??
|
|
12952
|
+
fe = {
|
|
12953
|
+
id: e.id ?? fe.id,
|
|
12954
|
+
timestamp: e.timestamp ?? fe.timestamp,
|
|
12955
|
+
modelId: e.modelId ?? fe.modelId
|
|
12956
12956
|
};
|
|
12957
12957
|
break;
|
|
12958
12958
|
case "error":
|
|
12959
|
-
if (
|
|
12959
|
+
if (se === void 0) {
|
|
12960
12960
|
let t = Sc(e.error);
|
|
12961
|
-
|
|
12961
|
+
se = { error: t }, oe = t, N = "error", k.rejectResultPromises(t);
|
|
12962
12962
|
}
|
|
12963
12963
|
t.enqueue(e);
|
|
12964
12964
|
break;
|
|
12965
12965
|
case "finish":
|
|
12966
|
-
if (
|
|
12966
|
+
if (de !== "" && t.enqueue({
|
|
12967
12967
|
type: "text-delta",
|
|
12968
|
-
textDelta:
|
|
12969
|
-
}), N =
|
|
12968
|
+
textDelta: de
|
|
12969
|
+
}), N = se === void 0 ? e.finishReason.unified : "error", I = Cc(e.usage), ae = e.providerMetadata, t.enqueue({
|
|
12970
12970
|
...e,
|
|
12971
12971
|
finishReason: N,
|
|
12972
|
-
usage:
|
|
12973
|
-
response:
|
|
12972
|
+
usage: I,
|
|
12973
|
+
response: fe
|
|
12974
12974
|
}), Qo({
|
|
12975
12975
|
warnings: M ?? [],
|
|
12976
12976
|
provider: T.provider,
|
|
12977
12977
|
model: T.modelId
|
|
12978
|
-
}),
|
|
12979
|
-
k._usage.resolve(
|
|
12980
|
-
...
|
|
12978
|
+
}), se !== void 0) break;
|
|
12979
|
+
k._usage.resolve(I), k._providerMetadata.resolve(ae), k._warnings.resolve(M), k._response.resolve({
|
|
12980
|
+
...fe,
|
|
12981
12981
|
headers: j?.headers
|
|
12982
12982
|
}), k._finishReason.resolve(N ?? "other");
|
|
12983
12983
|
try {
|
|
12984
|
-
P = await Cf(
|
|
12985
|
-
response:
|
|
12986
|
-
usage:
|
|
12984
|
+
P = await Cf(ue, o, h, {
|
|
12985
|
+
response: fe,
|
|
12986
|
+
usage: I,
|
|
12987
12987
|
finishReason: N
|
|
12988
12988
|
}), k._object.resolve(P);
|
|
12989
12989
|
} catch (e) {
|
|
@@ -12996,7 +12996,7 @@ var If = class {
|
|
|
12996
12996
|
},
|
|
12997
12997
|
async flush(e) {
|
|
12998
12998
|
try {
|
|
12999
|
-
let e =
|
|
12999
|
+
let e = I ?? {
|
|
13000
13000
|
promptTokens: NaN,
|
|
13001
13001
|
completionTokens: NaN,
|
|
13002
13002
|
totalTokens: NaN
|
|
@@ -13009,13 +13009,13 @@ var If = class {
|
|
|
13009
13009
|
modelId: T.modelId,
|
|
13010
13010
|
finishReason: N ?? "other",
|
|
13011
13011
|
usage: e,
|
|
13012
|
-
objectText:
|
|
13013
|
-
msToFirstChunk:
|
|
13012
|
+
objectText: ue,
|
|
13013
|
+
msToFirstChunk: F,
|
|
13014
13014
|
reasoning: void 0,
|
|
13015
13015
|
warnings: M,
|
|
13016
13016
|
request: ie ?? {},
|
|
13017
13017
|
response: {
|
|
13018
|
-
...
|
|
13018
|
+
...fe,
|
|
13019
13019
|
headers: j?.headers
|
|
13020
13020
|
},
|
|
13021
13021
|
providerMetadata: ae
|
|
@@ -13032,7 +13032,7 @@ var If = class {
|
|
|
13032
13032
|
warnings: M,
|
|
13033
13033
|
request: ie ?? {},
|
|
13034
13034
|
response: {
|
|
13035
|
-
...
|
|
13035
|
+
...fe,
|
|
13036
13036
|
headers: j?.headers
|
|
13037
13037
|
},
|
|
13038
13038
|
providerMetadata: ae
|
|
@@ -13047,7 +13047,7 @@ var If = class {
|
|
|
13047
13047
|
}
|
|
13048
13048
|
}
|
|
13049
13049
|
}));
|
|
13050
|
-
A.addStream(
|
|
13050
|
+
A.addStream(he, { onError(e) {
|
|
13051
13051
|
let t = Sc(e);
|
|
13052
13052
|
k.rejectResultPromises(t), $({
|
|
13053
13053
|
event: { error: t },
|
|
@@ -13296,7 +13296,7 @@ function Kf({ delayInMs: e = 10, chunking: t = "word", _internal: { delay: n = k
|
|
|
13296
13296
|
};
|
|
13297
13297
|
else {
|
|
13298
13298
|
let e = typeof t == "string" ? Wf[t] : t instanceof RegExp ? t : void 0;
|
|
13299
|
-
if (e == null) throw new
|
|
13299
|
+
if (e == null) throw new ve({
|
|
13300
13300
|
argument: "chunking",
|
|
13301
13301
|
message: `Chunking must be "word", "line", a RegExp, an Intl.Segmenter, or a ChunkDetector function. Received: ${t}`
|
|
13302
13302
|
});
|
|
@@ -13344,7 +13344,7 @@ async function qf(e) {
|
|
|
13344
13344
|
type: "string",
|
|
13345
13345
|
value: r
|
|
13346
13346
|
} : r == null ? { type: "none" } : { type: "function" }),
|
|
13347
|
-
inputSchema: await
|
|
13347
|
+
inputSchema: await qe(n.inputSchema).jsonSchema,
|
|
13348
13348
|
title: n.title
|
|
13349
13349
|
})];
|
|
13350
13350
|
var r;
|
|
@@ -13602,14 +13602,14 @@ function ep(e, { restrictToImages: t = !0 } = {}) {
|
|
|
13602
13602
|
url: e
|
|
13603
13603
|
};
|
|
13604
13604
|
if (e.startsWith("data:")) {
|
|
13605
|
-
let { mediaType: n, base64Content: r } = Ns(e), i =
|
|
13605
|
+
let { mediaType: n, base64Content: r } = Ns(e), i = B(r ?? "");
|
|
13606
13606
|
return {
|
|
13607
13607
|
type: "file",
|
|
13608
13608
|
mediaType: n ?? $f(i, t),
|
|
13609
13609
|
data: i
|
|
13610
13610
|
};
|
|
13611
13611
|
}
|
|
13612
|
-
let n =
|
|
13612
|
+
let n = B(e);
|
|
13613
13613
|
return {
|
|
13614
13614
|
type: "file",
|
|
13615
13615
|
mediaType: $f(n, t),
|
|
@@ -13688,7 +13688,7 @@ function ip({ instructions: e }) {
|
|
|
13688
13688
|
let t = typeof e == "string" ? [{
|
|
13689
13689
|
role: "system",
|
|
13690
13690
|
content: e
|
|
13691
|
-
}] :
|
|
13691
|
+
}] : Ne(e).map((e) => ({
|
|
13692
13692
|
role: "system",
|
|
13693
13693
|
content: e.content,
|
|
13694
13694
|
providerOptions: e.providerOptions
|
|
@@ -13978,7 +13978,7 @@ function pp({ prefix: e = "Input Examples:", format: t = fp, remove: n = !0 } =
|
|
|
13978
13978
|
}
|
|
13979
13979
|
var mp = ({ model: e, middleware: t, modelId: n, providerId: r }) => {
|
|
13980
13980
|
let i = ss(e);
|
|
13981
|
-
return [...
|
|
13981
|
+
return [...Ne(t)].reverse().reduce((e, t) => hp({
|
|
13982
13982
|
model: e,
|
|
13983
13983
|
middleware: t,
|
|
13984
13984
|
modelId: n,
|
|
@@ -14024,7 +14024,7 @@ var mp = ({ model: e, middleware: t, modelId: n, providerId: r }) => {
|
|
|
14024
14024
|
};
|
|
14025
14025
|
}, gp = ({ model: e, middleware: t, modelId: n, providerId: r }) => {
|
|
14026
14026
|
let i = ts(e);
|
|
14027
|
-
return [...
|
|
14027
|
+
return [...Ne(t)].reverse().reduce((e, t) => _p({
|
|
14028
14028
|
model: e,
|
|
14029
14029
|
middleware: t,
|
|
14030
14030
|
modelId: n,
|
|
@@ -14035,8 +14035,8 @@ var mp = ({ model: e, middleware: t, modelId: n, providerId: r }) => {
|
|
|
14035
14035
|
provider: c ?? r?.({ model: e }) ?? e.provider,
|
|
14036
14036
|
modelId: s ?? i?.({ model: e }) ?? e.modelId,
|
|
14037
14037
|
maxEmbeddingsPerCall: a?.({ model: e }) ?? e.maxEmbeddingsPerCall,
|
|
14038
|
-
[
|
|
14039
|
-
[
|
|
14038
|
+
[De]: Qd(e),
|
|
14039
|
+
[he]: $d(e),
|
|
14040
14040
|
supportsParallelCalls: o?.({ model: e }) ?? e.supportsParallelCalls,
|
|
14041
14041
|
async doEmbed(r) {
|
|
14042
14042
|
let i = await async function({ params: n }) {
|
|
@@ -14053,7 +14053,7 @@ var mp = ({ model: e, middleware: t, modelId: n, providerId: r }) => {
|
|
|
14053
14053
|
}
|
|
14054
14054
|
}), vp = ({ model: e, middleware: t, modelId: n, providerId: r }) => {
|
|
14055
14055
|
let i = rs(e);
|
|
14056
|
-
return [...
|
|
14056
|
+
return [...Ne(t)].reverse().reduce((e, t) => yp({
|
|
14057
14057
|
model: e,
|
|
14058
14058
|
middleware: t,
|
|
14059
14059
|
modelId: n,
|
|
@@ -14152,7 +14152,7 @@ async function wp({ tools: e, toolsContext: t = {} }) {
|
|
|
14152
14152
|
type: "function",
|
|
14153
14153
|
name: r,
|
|
14154
14154
|
description: e,
|
|
14155
|
-
parameters: await
|
|
14155
|
+
parameters: await qe(i.inputSchema).jsonSchema
|
|
14156
14156
|
});
|
|
14157
14157
|
break;
|
|
14158
14158
|
}
|
|
@@ -14550,7 +14550,7 @@ var Ep = class {
|
|
|
14550
14550
|
let t = this.generation + 1;
|
|
14551
14551
|
if (this.dispose(), t === this.generation) {
|
|
14552
14552
|
for (let e of [this.config.inputAudioFormat, this.config.outputAudioFormat]) {
|
|
14553
|
-
if (e?.type !== "audio/pcm") throw new
|
|
14553
|
+
if (e?.type !== "audio/pcm") throw new V({ functionality: "Continuous browser WebSocket audio supports PCM16 only" });
|
|
14554
14554
|
if (e.rate == null || !Number.isFinite(e.rate) || e.rate < 8e3 || e.rate > 96e3) throw Error("Invalid realtime PCM sample rate");
|
|
14555
14555
|
}
|
|
14556
14556
|
this.stream = e.stream, this.captureEnabled = !1 !== e.capture, this.audio.ensurePlaybackContext(), this.audio.resumePlayback().catch((e) => {
|
|
@@ -15539,7 +15539,7 @@ var Rp = class {
|
|
|
15539
15539
|
}
|
|
15540
15540
|
sendEvent(e) {
|
|
15541
15541
|
if (this.state.status === "error" || this.state.status === "closing" || this.attempt?.closing || !this.attempt?.active || this.sessionLifecycle && this.state.status !== "connected") throw Error("Realtime session is not accepting submissions");
|
|
15542
|
-
if (this.rtc != null && e.type === "input-audio-append" || (this.continuous || this.rtc != null) && (e.type === "input-audio-commit" || e.type === "input-audio-clear")) throw new
|
|
15542
|
+
if (this.rtc != null && e.type === "input-audio-append" || (this.continuous || this.rtc != null) && (e.type === "input-audio-commit" || e.type === "input-audio-clear")) throw new V({ functionality: "JSON audio commands unsupported for this session transport" });
|
|
15543
15543
|
if (e.type === "session-close") return this.close({ eventId: e.eventId });
|
|
15544
15544
|
if (e.type === "session-start" && this.sessionLifecycle) throw Error("Realtime session has already started");
|
|
15545
15545
|
if (!this.sessionLifecycle && this.state.session == null) {
|
|
@@ -15549,7 +15549,7 @@ var Rp = class {
|
|
|
15549
15549
|
return this.commands?.send(e) ?? this.sendTransport(e);
|
|
15550
15550
|
}
|
|
15551
15551
|
sendTextMessage(e) {
|
|
15552
|
-
if (this.continuous) throw new
|
|
15552
|
+
if (this.continuous) throw new V({ functionality: "sendTextMessage for continuous sessions; client-delegation text is application-owned, use context-append for context" });
|
|
15553
15553
|
this.sendEvent({
|
|
15554
15554
|
type: "conversation-item-create",
|
|
15555
15555
|
item: {
|
|
@@ -15598,7 +15598,7 @@ var Rp = class {
|
|
|
15598
15598
|
}
|
|
15599
15599
|
}
|
|
15600
15600
|
addToolOutput(e, t) {
|
|
15601
|
-
if (this.continuous) throw new
|
|
15601
|
+
if (this.continuous) throw new V({ functionality: "addToolOutput for continuous sessions; client delegation is application-owned" });
|
|
15602
15602
|
let n = this.attempt;
|
|
15603
15603
|
if (!n?.active || n.closing || n.cause != null) throw Error("Realtime session is not accepting submissions");
|
|
15604
15604
|
let { state: r, output: i } = this.reducer.addToolOutput(this.state, e, t);
|
|
@@ -15698,8 +15698,8 @@ var Rp = class {
|
|
|
15698
15698
|
async handleServerEvent(e, t) {
|
|
15699
15699
|
let n = () => this.attempt === t && t.active;
|
|
15700
15700
|
if (!n()) return;
|
|
15701
|
-
if (e.type === "session-started" && e.delegationMode === "provider") throw new
|
|
15702
|
-
if (this.continuous && e.type === "audio-delta") throw new
|
|
15701
|
+
if (e.type === "session-started" && e.delegationMode === "provider") throw new V({ functionality: "Provider delegation mode; this realtime runtime supports client delegation only" });
|
|
15702
|
+
if (this.continuous && e.type === "audio-delta") throw new V({ functionality: "Turn-based audio-delta in a continuous PCM session; use audio-chunk" });
|
|
15703
15703
|
let r = this.commands?.receive(e), i = await this.reducer.reduceServerEvent(this.state, e);
|
|
15704
15704
|
if (!n()) return;
|
|
15705
15705
|
let a = this.state.session ?? (e.type === "session-started" ? {
|
|
@@ -15862,7 +15862,7 @@ var Vp, Hp, Up = "AI_NoSuchProviderError", Wp = `vercel.ai.error.${Up}`, Gp = Sy
|
|
|
15862
15862
|
}), this[Vp] = !0, this.providerId = n, this.availableProviders = r;
|
|
15863
15863
|
}
|
|
15864
15864
|
static isInstance(e) {
|
|
15865
|
-
return
|
|
15865
|
+
return z.hasMarker(e, Wp);
|
|
15866
15866
|
}
|
|
15867
15867
|
};
|
|
15868
15868
|
function qp(e, { separator: t = ":", languageModelMiddleware: n, imageModelMiddleware: r } = {}) {
|
|
@@ -16237,11 +16237,11 @@ function nm({ model: e, audio: t, inputAudioFormat: n, providerOptions: r = {},
|
|
|
16237
16237
|
let c = bs(e);
|
|
16238
16238
|
if (!c) throw Error("Model could not be resolved");
|
|
16239
16239
|
let l = c.doStream?.bind(c);
|
|
16240
|
-
if (l == null) throw new
|
|
16240
|
+
if (l == null) throw new V({
|
|
16241
16241
|
functionality: "streaming transcription",
|
|
16242
16242
|
message: `The ${c.provider} model "${c.modelId}" does not support streaming transcription.` + (typeof e == "string" ? " String model IDs resolve through the global provider (AI Gateway by default). If that provider does not support streaming transcription, pass a provider model instance instead (e.g. openai.transcription('gpt-realtime-whisper')) or upgrade @ai-sdk/gateway to a version with streaming transcription support." : "")
|
|
16243
16243
|
});
|
|
16244
|
-
let u = j(a ?? {}, `ai/${ks}`), d = new
|
|
16244
|
+
let u = j(a ?? {}, `ai/${ks}`), d = new U(), f = new U(), p = new U(), m = new U(), h = new U(), g = new U(), _ = new U(), v = s(), y, b = () => y ?? {
|
|
16245
16245
|
timestamp: v,
|
|
16246
16246
|
modelId: c.modelId
|
|
16247
16247
|
}, x = (e) => {
|
|
@@ -16366,7 +16366,7 @@ function im({ model: e, audio: t, inputAudioFormat: n, targetLanguage: r, source
|
|
|
16366
16366
|
});
|
|
16367
16367
|
}
|
|
16368
16368
|
return e;
|
|
16369
|
-
}(e), f = d.doStream.bind(d), p = j(c ?? {}, `ai/${ks}`), m = new
|
|
16369
|
+
}(e), f = d.doStream.bind(d), p = j(c ?? {}, `ai/${ks}`), m = new U(), h = new U(), g = new U(), _ = new U(), v = new U(), y = new U(), b = new U(), x = u(), S, C = () => S ?? {
|
|
16370
16370
|
timestamp: x,
|
|
16371
16371
|
modelId: d.modelId
|
|
16372
16372
|
}, w = (e) => {
|
|
@@ -16486,7 +16486,7 @@ function im({ model: e, audio: t, inputAudioFormat: n, targetLanguage: r, source
|
|
|
16486
16486
|
}
|
|
16487
16487
|
async function am({ response: e, url: t, fallbackMessage: n }) {
|
|
16488
16488
|
let r = await e.text();
|
|
16489
|
-
return new
|
|
16489
|
+
return new pe({
|
|
16490
16490
|
message: r || n,
|
|
16491
16491
|
url: t,
|
|
16492
16492
|
requestBodyValues: void 0,
|
|
@@ -16509,7 +16509,7 @@ async function sm({ api: e, prompt: t, credentials: n, headers: r, body: i, stre
|
|
|
16509
16509
|
headers: j({
|
|
16510
16510
|
"Content-Type": "application/json",
|
|
16511
16511
|
...r
|
|
16512
|
-
}, `ai-sdk/${ks}`,
|
|
16512
|
+
}, `ai-sdk/${ks}`, F()),
|
|
16513
16513
|
signal: m.signal
|
|
16514
16514
|
}).catch((e) => {
|
|
16515
16515
|
throw e;
|
|
@@ -16519,7 +16519,7 @@ async function sm({ api: e, prompt: t, credentials: n, headers: r, body: i, stre
|
|
|
16519
16519
|
url: e,
|
|
16520
16520
|
fallbackMessage: "Failed to fetch the chat response."
|
|
16521
16521
|
});
|
|
16522
|
-
if (!u.body) throw new
|
|
16522
|
+
if (!u.body) throw new Je({ message: "The response body is empty." });
|
|
16523
16523
|
let f = "";
|
|
16524
16524
|
switch (a) {
|
|
16525
16525
|
case "text":
|
|
@@ -16539,7 +16539,7 @@ async function sm({ api: e, prompt: t, credentials: n, headers: r, body: i, stre
|
|
|
16539
16539
|
break;
|
|
16540
16540
|
case "data":
|
|
16541
16541
|
await Pu({
|
|
16542
|
-
stream:
|
|
16542
|
+
stream: Ee({
|
|
16543
16543
|
stream: u.body,
|
|
16544
16544
|
schema: fu
|
|
16545
16545
|
}).pipeThrough(new TransformStream({ async transform(e) {
|
|
@@ -16573,7 +16573,7 @@ async function sm({ api: e, prompt: t, credentials: n, headers: r, body: i, stre
|
|
|
16573
16573
|
}
|
|
16574
16574
|
async function cm(e) {
|
|
16575
16575
|
if (e == null) return [];
|
|
16576
|
-
if (!(globalThis.FileList && e instanceof globalThis.FileList)) throw new
|
|
16576
|
+
if (!(globalThis.FileList && e instanceof globalThis.FileList)) throw new V({
|
|
16577
16577
|
functionality: "FileList",
|
|
16578
16578
|
message: "FileList is not supported in the current environment"
|
|
16579
16579
|
});
|
|
@@ -16598,8 +16598,8 @@ var lm = class {
|
|
|
16598
16598
|
}
|
|
16599
16599
|
async sendMessages({ abortSignal: e, ...t }) {
|
|
16600
16600
|
let n = await K(this.body), r = await K(this.headers), i = await K(this.credentials), a = {
|
|
16601
|
-
...
|
|
16602
|
-
...
|
|
16601
|
+
...Ie(r),
|
|
16602
|
+
...Ie(t.headers)
|
|
16603
16603
|
}, o = await this.prepareSendMessagesRequest?.({
|
|
16604
16604
|
api: this.api,
|
|
16605
16605
|
id: t.chatId,
|
|
@@ -16613,7 +16613,7 @@ var lm = class {
|
|
|
16613
16613
|
requestMetadata: t.metadata,
|
|
16614
16614
|
trigger: t.trigger,
|
|
16615
16615
|
messageId: t.messageId
|
|
16616
|
-
}), s = o?.api ?? this.api, c = o?.headers === void 0 ? a :
|
|
16616
|
+
}), s = o?.api ?? this.api, c = o?.headers === void 0 ? a : Ie(o.headers), l = o?.body === void 0 ? {
|
|
16617
16617
|
...n,
|
|
16618
16618
|
...t.body,
|
|
16619
16619
|
id: t.chatId,
|
|
@@ -16635,13 +16635,13 @@ var lm = class {
|
|
|
16635
16635
|
url: s,
|
|
16636
16636
|
fallbackMessage: "Failed to fetch the chat response."
|
|
16637
16637
|
});
|
|
16638
|
-
if (!d.body) throw new
|
|
16638
|
+
if (!d.body) throw new Je({ message: "The response body is empty." });
|
|
16639
16639
|
return this.processResponseStream(d.body);
|
|
16640
16640
|
}
|
|
16641
16641
|
async reconnectToStream(e) {
|
|
16642
16642
|
let t = await K(this.body), n = await K(this.headers), r = await K(this.credentials), i = {
|
|
16643
|
-
...
|
|
16644
|
-
...
|
|
16643
|
+
...Ie(n),
|
|
16644
|
+
...Ie(e.headers)
|
|
16645
16645
|
}, a = await this.prepareReconnectToStreamRequest?.({
|
|
16646
16646
|
api: this.api,
|
|
16647
16647
|
id: e.chatId,
|
|
@@ -16664,7 +16664,7 @@ var lm = class {
|
|
|
16664
16664
|
return n === -1 ? `${e}${t}` : `${e.slice(0, n)}${t}${e.slice(n)}`;
|
|
16665
16665
|
}(this.api, `/${encodeURIComponent(e.chatId)}/stream`);
|
|
16666
16666
|
}
|
|
16667
|
-
let s = a?.headers === void 0 ? i :
|
|
16667
|
+
let s = a?.headers === void 0 ? i : Ie(a.headers), c = a?.credentials ?? r, l = await (this.fetch ?? globalThis.fetch)(o, {
|
|
16668
16668
|
method: "GET",
|
|
16669
16669
|
headers: s,
|
|
16670
16670
|
credentials: c,
|
|
@@ -16676,7 +16676,7 @@ var lm = class {
|
|
|
16676
16676
|
url: o,
|
|
16677
16677
|
fallbackMessage: "Failed to fetch the chat response."
|
|
16678
16678
|
});
|
|
16679
|
-
if (!l.body) throw new
|
|
16679
|
+
if (!l.body) throw new Je({ message: "The response body is empty." });
|
|
16680
16680
|
return this.processResponseStream(l.body);
|
|
16681
16681
|
}
|
|
16682
16682
|
}, um = class extends lm {
|
|
@@ -16684,7 +16684,7 @@ var lm = class {
|
|
|
16684
16684
|
super(e);
|
|
16685
16685
|
}
|
|
16686
16686
|
processResponseStream(e) {
|
|
16687
|
-
return
|
|
16687
|
+
return Ee({
|
|
16688
16688
|
stream: e,
|
|
16689
16689
|
schema: fu
|
|
16690
16690
|
}).pipeThrough(new TransformStream({ async transform(e, t) {
|
|
@@ -17033,7 +17033,7 @@ async function gm({ api: e, data: t, mediaType: n, filename: r, abortSignal: i,
|
|
|
17033
17033
|
type: "data",
|
|
17034
17034
|
data: t
|
|
17035
17035
|
} : t, c = n ?? (s.type === "text" ? "text/plain" : s.type === "stream" ? "application/octet-stream" : y({ data: s.data }) ?? (function(e) {
|
|
17036
|
-
let t = typeof e == "string" ?
|
|
17036
|
+
let t = typeof e == "string" ? B(e.substring(0, Math.min(e.length, 688))) : e, n = Math.min(t.length, 512);
|
|
17037
17037
|
if (n === 0) return !1;
|
|
17038
17038
|
for (let e = 0; e < n; e++) {
|
|
17039
17039
|
let n = t[e];
|
|
@@ -17119,14 +17119,20 @@ var ym = {
|
|
|
17119
17119
|
}), wm = (e) => `The turn reached its time limit of ${e / 6e4} minutes. Should I continue?`, Tm = "The step limit of this turn is reached: this answer cannot call a tool. Tell the user what you did and what is still open, say that the step limit of the turn was reached, and ask whether you should continue. The next message of the user starts a new turn, in which you can call tools again.", Em = (e, t) => e === 31 ? {
|
|
17120
17120
|
toolChoice: "none",
|
|
17121
17121
|
instructions: t ? `${t}\n\n${Tm}` : Tm
|
|
17122
|
-
} : {}, Dm = (e) => {
|
|
17122
|
+
} : {}, Dm = (e, t) => t ? {
|
|
17123
|
+
...e,
|
|
17124
|
+
...Object.fromEntries(Object.entries(t).map(([t, n]) => [t, {
|
|
17125
|
+
...e?.[t],
|
|
17126
|
+
...n
|
|
17127
|
+
}]))
|
|
17128
|
+
} : e, Om = (e) => {
|
|
17123
17129
|
if (e instanceof Error) return e.message;
|
|
17124
17130
|
try {
|
|
17125
17131
|
return typeof e == "string" ? e : JSON.stringify(e) ?? String(e);
|
|
17126
17132
|
} catch {
|
|
17127
17133
|
return Object.prototype.toString.call(e);
|
|
17128
17134
|
}
|
|
17129
|
-
},
|
|
17135
|
+
}, km = (e) => {
|
|
17130
17136
|
if (e?.structuredContent !== void 0) return e.structuredContent;
|
|
17131
17137
|
let t = e?.content?.filter((e) => e.type === "text").map((e) => e.text).join("\n");
|
|
17132
17138
|
if (t === void 0) return e;
|
|
@@ -17135,8 +17141,8 @@ var ym = {
|
|
|
17135
17141
|
} catch {
|
|
17136
17142
|
return t;
|
|
17137
17143
|
}
|
|
17138
|
-
},
|
|
17139
|
-
if (!e || typeof e != "object") return e == null ? [] : [
|
|
17144
|
+
}, Am = (e) => {
|
|
17145
|
+
if (!e || typeof e != "object") return e == null ? [] : [Om(e)];
|
|
17140
17146
|
let t = [];
|
|
17141
17147
|
for (let n of [
|
|
17142
17148
|
"applied",
|
|
@@ -17145,26 +17151,41 @@ var ym = {
|
|
|
17145
17151
|
"confirmed",
|
|
17146
17152
|
"canUndo",
|
|
17147
17153
|
"canRedo"
|
|
17148
|
-
]) e[n] !== void 0 && t.push(`${n}: ${
|
|
17149
|
-
return e.hint && t.push(
|
|
17150
|
-
},
|
|
17154
|
+
]) e[n] !== void 0 && t.push(`${n}: ${Om(e[n])}`);
|
|
17155
|
+
return e.hint && t.push(Om(e.hint)), t;
|
|
17156
|
+
}, jm = async (e) => {
|
|
17151
17157
|
if (typeof e.getConstructionAgentTools != "function" || typeof e.callConstructionAgentTool != "function") throw Error("Update the Rubens UI: fence agent tools are unavailable.");
|
|
17152
17158
|
return n(await e.getConstructionAgentTools(), (t, n) => e.callConstructionAgentTool(t, n), "fence-mcp");
|
|
17153
|
-
},
|
|
17159
|
+
}, Mm = (e, t, n) => (async (e, t, n, r, i) => {
|
|
17154
17160
|
let a = (t) => {
|
|
17155
17161
|
n.aborted || e.planningAssistantOutput(t);
|
|
17156
17162
|
};
|
|
17157
17163
|
try {
|
|
17158
|
-
let o = await ((e, t, n, r, i) => (async ({ config: e, signal: t, output: n, hostModel: r, assistantName: i, setupDomain: a, turnPolicy: o,
|
|
17159
|
-
let
|
|
17160
|
-
|
|
17161
|
-
|
|
17162
|
-
|
|
17163
|
-
|
|
17164
|
-
a((e, t, n) =>
|
|
17164
|
+
let o = await ((e, t, n, r, i) => (async ({ config: e, signal: t, output: n, hostModel: r, assistantName: i, setupDomain: a, turnPolicy: o, usageLine: s }) => {
|
|
17165
|
+
let c = [], l = bm, u = [], d = [], f = at(e), p = Promise.resolve().then(() => qi), m = nt(e, async (e) => {
|
|
17166
|
+
c.push(ct(e));
|
|
17167
|
+
}, r), [{ streamText: h, stepCountIs: g }, _, v] = await Promise.all([
|
|
17168
|
+
p,
|
|
17169
|
+
m,
|
|
17170
|
+
a((e, t, n) => l.tool(e, t, n), {
|
|
17171
|
+
images: () => u,
|
|
17172
|
+
ask: async ({ instructions: e, content: t, abortSignal: n }) => {
|
|
17173
|
+
let [{ generateText: r }, i] = await Promise.all([p, m]), { text: a, usage: o } = (performance.now(), await r({
|
|
17174
|
+
model: i.languageModel,
|
|
17175
|
+
providerOptions: f ? Dm(i.providerOptions, { [f]: { store: !1 } }) : i.providerOptions,
|
|
17176
|
+
instructions: e,
|
|
17177
|
+
messages: [{
|
|
17178
|
+
role: "user",
|
|
17179
|
+
content: t
|
|
17180
|
+
}],
|
|
17181
|
+
abortSignal: n
|
|
17182
|
+
})), s = it(o);
|
|
17183
|
+
return d.push(s), a;
|
|
17184
|
+
}
|
|
17185
|
+
})
|
|
17165
17186
|
]);
|
|
17166
17187
|
t.throwIfAborted();
|
|
17167
|
-
let
|
|
17188
|
+
let y = ((e, t) => {
|
|
17168
17189
|
let n = {
|
|
17169
17190
|
provider: e.provider,
|
|
17170
17191
|
model: e.model,
|
|
@@ -17237,19 +17258,19 @@ var ym = {
|
|
|
17237
17258
|
},
|
|
17238
17259
|
snapshot: () => structuredClone(n)
|
|
17239
17260
|
};
|
|
17240
|
-
})(e,
|
|
17241
|
-
return Object.assign(async ({ text: e, images: r, documents: a = [] },
|
|
17242
|
-
let
|
|
17243
|
-
var
|
|
17244
|
-
let C =
|
|
17261
|
+
})(e, v.toolDefinitions), b = (e) => f ? e?.providerMetadata?.[f]?.responseId ?? void 0 : void 0, x = [], S;
|
|
17262
|
+
return Object.assign(async ({ text: e, images: r, documents: a = [] }, s = t) => {
|
|
17263
|
+
let p = (m = [t, s], AbortSignal.any(m));
|
|
17264
|
+
var m;
|
|
17265
|
+
let C = y.startTurn({
|
|
17245
17266
|
text: e,
|
|
17246
17267
|
images: r,
|
|
17247
17268
|
documents: a
|
|
17248
17269
|
});
|
|
17249
|
-
|
|
17270
|
+
l = C;
|
|
17250
17271
|
let w = "done", T = null;
|
|
17251
|
-
|
|
17252
|
-
let ee = [], E = [], D, O = !1, k = !1, A = !1, te = !1, ne = !1, re = null, j = null, ie = performance.now(), M = null, N =
|
|
17272
|
+
c = [], d = [], r.length && (u = r);
|
|
17273
|
+
let ee = [], E = [], D, O = !1, k = !1, A = !1, te = !1, ne = !1, re = null, j = null, ie = performance.now(), M = null, N = v.turnDiagnostics?.(), ae = (t) => {
|
|
17253
17274
|
C.systemPrompt(t), re = ct(t.systemPrompt);
|
|
17254
17275
|
let { documentPrompt: n } = t, i = n === void 0 ? [] : a;
|
|
17255
17276
|
return {
|
|
@@ -17272,81 +17293,75 @@ var ym = {
|
|
|
17272
17293
|
}))
|
|
17273
17294
|
]
|
|
17274
17295
|
};
|
|
17275
|
-
}, P =
|
|
17276
|
-
|
|
17277
|
-
let
|
|
17296
|
+
}, P = v.staticPrompts ? ae(v.staticPrompts) : void 0, oe = o?.recovery(v.tools), se = new AbortController(), F = () => se.abort(p.reason);
|
|
17297
|
+
p.addEventListener("abort", F, { once: !0 }), p.aborted && F();
|
|
17298
|
+
let ce = o ? Error(wm(o.timeoutMs)) : void 0, le = o ? setTimeout(() => se.abort(ce), o.timeoutMs) : void 0;
|
|
17278
17299
|
try {
|
|
17279
|
-
let t = await
|
|
17280
|
-
stopSignal:
|
|
17281
|
-
abortSignal:
|
|
17300
|
+
let t = await v.readTurn({
|
|
17301
|
+
stopSignal: p,
|
|
17302
|
+
abortSignal: se.signal,
|
|
17282
17303
|
prompt: {
|
|
17283
17304
|
text: e,
|
|
17284
17305
|
images: r,
|
|
17285
17306
|
documents: a
|
|
17286
17307
|
}
|
|
17287
|
-
}), { prompts: i, context:
|
|
17288
|
-
...
|
|
17289
|
-
content: [...
|
|
17308
|
+
}), { prompts: i, context: s } = t, c = t.prefix ?? [], l = t.supplied ?? [], u = (I = P ?? ae(i), (ue = t.userNote) && Array.isArray(I.content) ? {
|
|
17309
|
+
...I,
|
|
17310
|
+
content: [...I.content, {
|
|
17290
17311
|
type: "text",
|
|
17291
|
-
text:
|
|
17312
|
+
text: ue
|
|
17292
17313
|
}]
|
|
17293
|
-
} :
|
|
17294
|
-
P =
|
|
17295
|
-
let
|
|
17296
|
-
...e,
|
|
17297
|
-
...Object.fromEntries(Object.entries(t).map(([t, n]) => [t, {
|
|
17298
|
-
...e?.[t],
|
|
17299
|
-
...n
|
|
17300
|
-
}]))
|
|
17301
|
-
} : e)(m.providerOptions, t.providerOptions), w = [
|
|
17302
|
-
...u,
|
|
17303
|
-
...y,
|
|
17314
|
+
} : I);
|
|
17315
|
+
P = u, j = t.configurationBytes, C.context([...c, ...s]);
|
|
17316
|
+
let d = Dm(_.providerOptions, t.providerOptions), m = [
|
|
17304
17317
|
...c,
|
|
17305
|
-
|
|
17306
|
-
...
|
|
17307
|
-
|
|
17308
|
-
|
|
17309
|
-
|
|
17318
|
+
...x,
|
|
17319
|
+
...s,
|
|
17320
|
+
u,
|
|
17321
|
+
...l
|
|
17322
|
+
], y, w = S && t.continuesStoredConversation && S.prompts === i ? S.responseId : void 0;
|
|
17323
|
+
A = w !== void 0;
|
|
17324
|
+
let T = [], ne, re, F = 0, ce = !1;
|
|
17310
17325
|
do {
|
|
17311
|
-
|
|
17312
|
-
let e =
|
|
17313
|
-
|
|
17314
|
-
model:
|
|
17315
|
-
providerOptions:
|
|
17326
|
+
ne = void 0;
|
|
17327
|
+
let e = F, t = w, r = [];
|
|
17328
|
+
re = h({
|
|
17329
|
+
model: _.languageModel,
|
|
17330
|
+
providerOptions: d,
|
|
17316
17331
|
instructions: i.systemPrompt,
|
|
17317
|
-
messages:
|
|
17318
|
-
tools: oe?.tools ??
|
|
17319
|
-
stopWhen:
|
|
17320
|
-
abortSignal: o ?
|
|
17332
|
+
messages: ce ? [...m, ...T].map(st) : [...m, ...T],
|
|
17333
|
+
tools: oe?.tools ?? v.tools,
|
|
17334
|
+
stopWhen: g(32 - e),
|
|
17335
|
+
abortSignal: o ? se.signal : p,
|
|
17321
17336
|
...N && { onLanguageModelCallEnd: (e) => N.modelCall(e) },
|
|
17322
17337
|
onStepEnd: (e) => {
|
|
17323
|
-
r.push(...e.response.messages),
|
|
17338
|
+
r.push(...e.response.messages), F++, y = b(e);
|
|
17324
17339
|
},
|
|
17325
17340
|
prepareStep: (n) => {
|
|
17326
17341
|
let r = e + n.stepNumber;
|
|
17327
17342
|
N?.request(r);
|
|
17328
17343
|
let a = Em(r, i.systemPrompt);
|
|
17329
|
-
if (!
|
|
17344
|
+
if (!f) return Object.keys(a).length ? a : void 0;
|
|
17330
17345
|
let o = (e, t) => ({
|
|
17331
17346
|
instructions: [],
|
|
17332
17347
|
...Em(r),
|
|
17333
17348
|
messages: t,
|
|
17334
|
-
providerOptions: { [
|
|
17349
|
+
providerOptions: { [f]: {
|
|
17335
17350
|
previousResponseId: e,
|
|
17336
17351
|
store: !0
|
|
17337
17352
|
} }
|
|
17338
17353
|
});
|
|
17339
17354
|
if (n.stepNumber === 0) return t ? o(t, [
|
|
17340
|
-
...
|
|
17341
|
-
|
|
17342
|
-
...
|
|
17355
|
+
...s,
|
|
17356
|
+
u,
|
|
17357
|
+
...l
|
|
17343
17358
|
]) : a;
|
|
17344
|
-
let
|
|
17345
|
-
if (!
|
|
17346
|
-
return o(
|
|
17359
|
+
let c = n.steps?.at(-1), d = b(c);
|
|
17360
|
+
if (!c || !d) throw Error("The previous model response has no continuation ID");
|
|
17361
|
+
return o(d, c.response.messages.filter(({ role: e }) => e === "tool"));
|
|
17347
17362
|
}
|
|
17348
17363
|
});
|
|
17349
|
-
for await (let e of
|
|
17364
|
+
for await (let e of re.stream) if (e.type === "text-delta") M ??= performance.now() - ie, C.text(e.text), n({
|
|
17350
17365
|
type: "text",
|
|
17351
17366
|
text: e.text
|
|
17352
17367
|
});
|
|
@@ -17357,62 +17372,65 @@ var ym = {
|
|
|
17357
17372
|
else {
|
|
17358
17373
|
if (e.type === "error") {
|
|
17359
17374
|
if ((r.length > 0 || t) && rt(e.error)) {
|
|
17360
|
-
|
|
17375
|
+
ne = e.error;
|
|
17361
17376
|
break;
|
|
17362
17377
|
}
|
|
17363
17378
|
throw e.error;
|
|
17364
17379
|
}
|
|
17365
17380
|
if (e.type === "finish-step") N?.step(e.usage), ee.push(it(e.usage)), E.push(e.usage?.inputTokenDetails?.cacheReadTokens ?? null);
|
|
17366
|
-
else if (e.type === "finish") D =
|
|
17367
|
-
else if (e.type === "abort" && (k = !0, o)) throw
|
|
17381
|
+
else if (e.type === "finish") D = T.length ? void 0 : it(e.totalUsage), O = !0;
|
|
17382
|
+
else if (e.type === "abort" && (k = !0, o)) throw se.signal.reason ?? /* @__PURE__ */ Error("Turn aborted");
|
|
17368
17383
|
}
|
|
17369
|
-
|
|
17370
|
-
} while (
|
|
17371
|
-
if (
|
|
17372
|
-
return te =
|
|
17373
|
-
responseId:
|
|
17384
|
+
ne && (T.push(...r), w = void 0, ce = !0);
|
|
17385
|
+
} while (ne);
|
|
17386
|
+
if (se.signal.aborted) throw se.signal.reason;
|
|
17387
|
+
return te = F >= 32, x.push(u, ...l, ...T, ...await re.responseMessages), S = y ? {
|
|
17388
|
+
responseId: y,
|
|
17374
17389
|
prompts: i
|
|
17375
17390
|
} : void 0, n({ type: "done" }), !0;
|
|
17376
17391
|
} catch (e) {
|
|
17377
|
-
|
|
17392
|
+
S = void 0;
|
|
17378
17393
|
let t = oe?.summary();
|
|
17379
|
-
if (o && t &&
|
|
17394
|
+
if (o && t && se.signal.reason === ce) {
|
|
17380
17395
|
ne = !0;
|
|
17381
17396
|
let e = ((e, t, n) => (n({ type: "time-limit" }), n({ type: "done" }), {
|
|
17382
17397
|
role: "assistant",
|
|
17383
17398
|
content: `${e}\n\n${wm(t)}`
|
|
17384
17399
|
}))(t, o.timeoutMs, n);
|
|
17385
|
-
return P &&
|
|
17400
|
+
return P && x.push(P, e), C.text(e.content), !0;
|
|
17386
17401
|
}
|
|
17387
|
-
return t && P &&
|
|
17402
|
+
return t && P && x.push(P, {
|
|
17388
17403
|
role: "assistant",
|
|
17389
17404
|
content: t
|
|
17390
|
-
}), w =
|
|
17405
|
+
}), w = se.signal.aborted ? "aborted" : "error", T = `The ${i} assistant failed: ${e instanceof Error ? e.message : String(e)}${t ? `\n\n${t}` : ""}`, n({
|
|
17391
17406
|
type: "error",
|
|
17392
|
-
...
|
|
17407
|
+
...pe.isInstance(e) && { statusCode: e.statusCode },
|
|
17393
17408
|
text: T
|
|
17394
17409
|
}), !1;
|
|
17395
17410
|
} finally {
|
|
17396
|
-
clearTimeout(
|
|
17397
|
-
let e = {
|
|
17398
|
-
|
|
17399
|
-
|
|
17400
|
-
|
|
17401
|
-
|
|
17402
|
-
|
|
17403
|
-
|
|
17411
|
+
clearTimeout(le), p.removeEventListener("abort", F);
|
|
17412
|
+
let e = (e) => {
|
|
17413
|
+
let t = D?.[e] ?? ot(ee.map((t) => t[e]));
|
|
17414
|
+
return d.length ? ot([t, ...d.map((t) => t[e])]) : t;
|
|
17415
|
+
}, t = {
|
|
17416
|
+
inputTokens: e("inputTokens"),
|
|
17417
|
+
outputTokens: e("outputTokens"),
|
|
17418
|
+
totalTokens: e("totalTokens")
|
|
17419
|
+
}, n = Object.values(t).some((e) => e !== null), r = O && !k && !se.signal.aborted && Object.values(t).every((e) => e !== null) && ee.every((e) => Object.values(e).every((e) => e !== null)), i = {
|
|
17420
|
+
status: n ? r ? "complete" : "partial" : "unavailable",
|
|
17421
|
+
...t,
|
|
17404
17422
|
promptBytes: re,
|
|
17405
17423
|
configurationBytes: j,
|
|
17406
|
-
requestBytes:
|
|
17424
|
+
requestBytes: c,
|
|
17407
17425
|
cachedInputTokens: ot(E),
|
|
17408
17426
|
chained: A,
|
|
17409
17427
|
stepLimitReached: te,
|
|
17410
17428
|
timeLimitReached: ne
|
|
17411
17429
|
};
|
|
17412
|
-
C.end(w, T,
|
|
17430
|
+
C.end(w, T, i);
|
|
17413
17431
|
}
|
|
17414
|
-
var
|
|
17415
|
-
}, { report:
|
|
17432
|
+
var I, ue;
|
|
17433
|
+
}, { report: y.snapshot });
|
|
17416
17434
|
})({
|
|
17417
17435
|
config: e,
|
|
17418
17436
|
signal: t,
|
|
@@ -17420,24 +17438,22 @@ var ym = {
|
|
|
17420
17438
|
hostModel: void 0,
|
|
17421
17439
|
assistantName: "planning",
|
|
17422
17440
|
turnPolicy: i,
|
|
17423
|
-
unchangedStep: {},
|
|
17424
17441
|
usageLine: ({ status: e, inputTokens: t, outputTokens: n, totalTokens: r }) => ({
|
|
17425
17442
|
status: e,
|
|
17426
17443
|
inputTokens: t,
|
|
17427
17444
|
outputTokens: n,
|
|
17428
17445
|
totalTokens: r
|
|
17429
17446
|
}),
|
|
17430
|
-
|
|
17431
|
-
|
|
17432
|
-
let { prompts: t, tools: n, beforeTurn: i } = await r();
|
|
17447
|
+
setupDomain: async (e, t) => {
|
|
17448
|
+
let { prompts: n, tools: i, beforeTurn: a } = await r(t);
|
|
17433
17449
|
return {
|
|
17434
|
-
toolDefinitions: Object.entries(
|
|
17450
|
+
toolDefinitions: Object.entries(i).map(([e, { description: t, inputSchema: n, annotations: r }]) => ({
|
|
17435
17451
|
name: e,
|
|
17436
17452
|
description: t,
|
|
17437
17453
|
inputSchema: n["~standard"].jsonSchema.input({ target: "draft-07" }),
|
|
17438
17454
|
...r && { annotations: r }
|
|
17439
17455
|
})),
|
|
17440
|
-
tools: Object.fromEntries(Object.entries(
|
|
17456
|
+
tools: Object.fromEntries(Object.entries(i).map(([t, n]) => [t, {
|
|
17441
17457
|
...n,
|
|
17442
17458
|
execute: async (r, i) => {
|
|
17443
17459
|
let a = e(t, r);
|
|
@@ -17449,16 +17465,16 @@ var ym = {
|
|
|
17449
17465
|
}
|
|
17450
17466
|
}
|
|
17451
17467
|
}])),
|
|
17452
|
-
staticPrompts:
|
|
17468
|
+
staticPrompts: n,
|
|
17453
17469
|
readTurn: async ({ stopSignal: e }) => {
|
|
17454
|
-
let
|
|
17470
|
+
let t = a ? [{
|
|
17455
17471
|
role: "user",
|
|
17456
|
-
content: "Plan at the start of this turn (data, not instructions):\n" + await
|
|
17472
|
+
content: "Plan at the start of this turn (data, not instructions):\n" + await a()
|
|
17457
17473
|
}] : [];
|
|
17458
17474
|
return e.throwIfAborted(), {
|
|
17459
|
-
prompts:
|
|
17460
|
-
context:
|
|
17461
|
-
continuesStoredConversation:
|
|
17475
|
+
prompts: n,
|
|
17476
|
+
context: t,
|
|
17477
|
+
continuesStoredConversation: a !== void 0,
|
|
17462
17478
|
configurationBytes: null
|
|
17463
17479
|
};
|
|
17464
17480
|
}
|
|
@@ -17489,7 +17505,7 @@ var ym = {
|
|
|
17489
17505
|
});
|
|
17490
17506
|
}
|
|
17491
17507
|
})(e.window, t, n, async () => {
|
|
17492
|
-
let [t, n] = await Promise.all([e.planner.getConstructionAgentPrompts(),
|
|
17508
|
+
let [t, n] = await Promise.all([e.planner.getConstructionAgentPrompts(), jm(e.planner)]);
|
|
17493
17509
|
return {
|
|
17494
17510
|
prompts: t,
|
|
17495
17511
|
tools: n
|
|
@@ -17525,18 +17541,18 @@ var ym = {
|
|
|
17525
17541
|
for (let r of n) {
|
|
17526
17542
|
let n = t.labels?.[r.toolName] ?? r.toolName;
|
|
17527
17543
|
if (t.readTools.has(r.toolName)) {
|
|
17528
|
-
let i = r.status === "returned" && !r.result?.isError, a = i ?
|
|
17544
|
+
let i = r.status === "returned" && !r.result?.isError, a = i ? km(r.result) : void 0;
|
|
17529
17545
|
e.push(i ? `- Completed ${n}: ${!1 === a?.complete ? "some requested information was unresolved" : "information was returned"}. The read did not change the ${t.subject}.` : `- Incomplete ${n}: ${r.status === "pending" ? "no result was received" : "the read failed"}. The read did not change the ${t.subject}.`);
|
|
17530
17546
|
} else if (r.status !== "returned" || r.result?.isError) {
|
|
17531
|
-
let i = r.status === "threw" ?
|
|
17547
|
+
let i = r.status === "threw" ? Om(r.error) : r.status === "returned" ? Om(km(r.result)) : "no result was received";
|
|
17532
17548
|
e.push(`- Unconfirmed ${n}: ${i}. Check the ${t.subject} before trying this operation again.`);
|
|
17533
17549
|
} else {
|
|
17534
|
-
let i =
|
|
17550
|
+
let i = km(r.result);
|
|
17535
17551
|
if (!1 === i?.confirmed) {
|
|
17536
17552
|
e.push(`- Unconfirmed ${n}: ${i?.hint ?? i?.unresolved?.join(" ") ?? `the SDK did not confirm the ${t.subject} change`}. Check the ${t.subject} before trying this operation again.`);
|
|
17537
17553
|
continue;
|
|
17538
17554
|
}
|
|
17539
|
-
let a =
|
|
17555
|
+
let a = Am(i);
|
|
17540
17556
|
e.push(`- Completed ${n}: ${a.length ? a.join("; ") : "the tool returned successfully."}`);
|
|
17541
17557
|
}
|
|
17542
17558
|
}
|
|
@@ -17552,4 +17568,4 @@ var ym = {
|
|
|
17552
17568
|
}
|
|
17553
17569
|
})
|
|
17554
17570
|
});
|
|
17555
|
-
export {
|
|
17571
|
+
export { jm as createConstructionMcpTools, nt as loadChatModel, Mm as startFencePlanningAssistant };
|