@8wave/ai-elements 0.112.0-beta.13 → 0.112.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/markdown-BRD-hDrH.js.map +1 -1
- package/dist/_chunks/{web-Dzr6HJ14.js → web-CEmtEYdH.js} +89 -65
- package/dist/_chunks/web-CEmtEYdH.js.map +1 -0
- package/dist/ai-elements.es.js +2816 -3040
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/PkChatbot.js +1 -1
- package/dist-vue/PkChatbotAuth.js +1 -1
- package/dist-vue/PkChatbotMessages.js +1 -1
- package/dist-vue/PkChatbotViewChat.js +1 -1
- package/dist-vue/PkChatbotViewConversations.js +1 -1
- package/dist-vue/PkChatbotViewFiles.js +1 -1
- package/dist-vue/PkChatbotViewProfile.js +1 -1
- package/dist-vue/_chunks/{Document-B6RpxFr9.js → Document-2X01-F4Z.js} +2 -2
- package/dist-vue/_chunks/Document-2X01-F4Z.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbot-C0pf6xeZ.js → PkChatbot-C11EVHnI.js} +6 -6
- package/dist-vue/_chunks/{PkChatbot-C0pf6xeZ.js.map → PkChatbot-C11EVHnI.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotAuth-AxAOI9t2.js → PkChatbotAuth-Bi508F1u.js} +57 -57
- package/dist-vue/_chunks/PkChatbotAuth-Bi508F1u.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotMessages-HbKhrhbg.js → PkChatbotMessages-BD-vUak6.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotMessages-HbKhrhbg.js.map → PkChatbotMessages-BD-vUak6.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-DdxvITNb.js → PkChatbotViewChat-DJnjuhjt.js} +5 -5
- package/dist-vue/_chunks/{PkChatbotViewChat-DdxvITNb.js.map → PkChatbotViewChat-DJnjuhjt.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewConversations-CWSrP36z.js → PkChatbotViewConversations-BCdolW0R.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewConversations-CWSrP36z.js.map → PkChatbotViewConversations-BCdolW0R.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewFiles-DzLp1WfU.js → PkChatbotViewFiles-Cudao8ew.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotViewFiles-DzLp1WfU.js.map → PkChatbotViewFiles-Cudao8ew.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewProfile-CHbn3W6F.js → PkChatbotViewProfile-DDsKOkcC.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewProfile-CHbn3W6F.js.map → PkChatbotViewProfile-DDsKOkcC.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-BWCBuXH8.js → PkToolShowDiagram-RtkI_sKL.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowDiagram-BWCBuXH8.js.map → PkToolShowDiagram-RtkI_sKL.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-Cc26LzRd.js → PkToolShowSources-gI947JOm.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSources-Cc26LzRd.js.map → PkToolShowSources-gI947JOm.js.map} +1 -1
- package/dist-vue/_chunks/{useChatbotStore-CMS2zFht.js → useChatbotStore-BwrBZJCq.js} +944 -1259
- package/dist-vue/_chunks/useChatbotStore-BwrBZJCq.js.map +1 -0
- package/dist-vue/_chunks/{web-Dzr6HJ14.js → web-CEmtEYdH.js} +89 -65
- package/dist-vue/_chunks/web-CEmtEYdH.js.map +1 -0
- package/dist-vue/apps/web-component/src/composables/useChatbotAuthForm.d.ts +0 -1
- package/dist-vue/composables.js +2809 -80
- package/dist-vue/composables.js.map +1 -1
- package/dist-vue/index.js +12 -12
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/locales.js +1 -1
- package/dist-vue/packages/models/src/schema/User.d.ts +10 -0
- package/dist-vue/packages/models/src/schema/constants.d.ts +1 -1
- package/dist-vue/style.css +1 -1
- package/package.json +3 -3
- package/dist/_chunks/web-Dzr6HJ14.js.map +0 -1
- package/dist-vue/_chunks/Document-B6RpxFr9.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotAuth-AxAOI9t2.js.map +0 -1
- package/dist-vue/_chunks/useChatbotStore-CMS2zFht.js.map +0 -1
- package/dist-vue/_chunks/web-Dzr6HJ14.js.map +0 -1
|
@@ -57,10 +57,10 @@ async function ge(e) {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
//#endregion
|
|
60
|
-
//#region ../../node_modules/.pnpm/@ai-sdk+provider@4.0.
|
|
61
|
-
var _e = "vercel.ai.error", ve = Symbol.for(_e), S
|
|
60
|
+
//#region ../../node_modules/.pnpm/@ai-sdk+provider@4.0.20/node_modules/@ai-sdk/provider/dist/index.js
|
|
61
|
+
var _e = "vercel.ai.error", ve = Symbol.for(_e), S = class e extends Error {
|
|
62
62
|
constructor({ name: e, message: t, cause: n }) {
|
|
63
|
-
super(t), this[
|
|
63
|
+
super(t), this[ve] = !0, this.name = e, this.cause = n;
|
|
64
64
|
}
|
|
65
65
|
static isInstance(t) {
|
|
66
66
|
return e.hasMarker(t, _e);
|
|
@@ -69,55 +69,54 @@ var _e = "vercel.ai.error", ve = Symbol.for(_e), S, C, w = class e extends (C =
|
|
|
69
69
|
let n = Symbol.for(t);
|
|
70
70
|
return typeof e == "object" && !!e && n in e && typeof e[n] == "boolean" && e[n] === !0;
|
|
71
71
|
}
|
|
72
|
-
},
|
|
72
|
+
}, C = "AI_APICallError", w = `vercel.ai.error.${C}`, ye = Symbol.for(w), be = class extends S {
|
|
73
73
|
constructor({ message: e, url: t, requestBodyValues: n, statusCode: r, responseHeaders: i, responseBody: a, cause: o, isRetryable: s = r != null && (r === 408 || r === 409 || r === 429 || r >= 500), data: c }) {
|
|
74
74
|
super({
|
|
75
|
-
name:
|
|
75
|
+
name: C,
|
|
76
76
|
message: e,
|
|
77
77
|
cause: o
|
|
78
|
-
}), this[
|
|
78
|
+
}), this[ye] = !0, this.url = t, this.requestBodyValues = n, this.statusCode = r, this.responseHeaders = i, this.responseBody = a, this.isRetryable = s, this.data = c;
|
|
79
79
|
}
|
|
80
80
|
static isInstance(e) {
|
|
81
|
-
return
|
|
81
|
+
return S.hasMarker(e, w);
|
|
82
82
|
}
|
|
83
|
-
},
|
|
83
|
+
}, xe = "AI_EmptyResponseBodyError", T = `vercel.ai.error.${xe}`, Se = Symbol.for(T), Ce = class extends S {
|
|
84
84
|
constructor({ message: e = "Empty response body" } = {}) {
|
|
85
85
|
super({
|
|
86
|
-
name:
|
|
86
|
+
name: xe,
|
|
87
87
|
message: e
|
|
88
|
-
}), this[
|
|
88
|
+
}), this[Se] = !0;
|
|
89
89
|
}
|
|
90
90
|
static isInstance(e) {
|
|
91
|
-
return
|
|
91
|
+
return S.hasMarker(e, T);
|
|
92
92
|
}
|
|
93
93
|
};
|
|
94
|
-
function
|
|
94
|
+
function E(e) {
|
|
95
95
|
return e == null ? "unknown error" : typeof e == "string" ? e : e instanceof Error ? e.toString() : JSON.stringify(e);
|
|
96
96
|
}
|
|
97
|
-
var
|
|
97
|
+
var we = "AI_InvalidArgumentError", Te = `vercel.ai.error.${we}`, Ee = Symbol.for(Te), De = class extends S {
|
|
98
98
|
constructor({ message: e, cause: t, argument: n }) {
|
|
99
99
|
super({
|
|
100
|
-
name:
|
|
100
|
+
name: we,
|
|
101
101
|
message: e,
|
|
102
102
|
cause: t
|
|
103
|
-
}), this[
|
|
103
|
+
}), this[Ee] = !0, this.argument = n;
|
|
104
104
|
}
|
|
105
105
|
static isInstance(e) {
|
|
106
|
-
return
|
|
106
|
+
return S.hasMarker(e, Te);
|
|
107
107
|
}
|
|
108
|
-
},
|
|
108
|
+
}, Oe = "AI_JSONParseError", D = `vercel.ai.error.${Oe}`, ke = Symbol.for(D), O = class extends S {
|
|
109
109
|
constructor({ text: e, cause: t }) {
|
|
110
110
|
super({
|
|
111
|
-
name:
|
|
112
|
-
message: `JSON parsing failed: Text: ${e}
|
|
113
|
-
Error message: ${D(t)}`,
|
|
111
|
+
name: Oe,
|
|
112
|
+
message: `JSON parsing failed: Text: ${e}.\nError message: ${E(t)}`,
|
|
114
113
|
cause: t
|
|
115
|
-
}), this[
|
|
114
|
+
}), this[ke] = !0, this.text = e;
|
|
116
115
|
}
|
|
117
116
|
static isInstance(e) {
|
|
118
|
-
return
|
|
117
|
+
return S.hasMarker(e, D);
|
|
119
118
|
}
|
|
120
|
-
},
|
|
119
|
+
}, Ae = "AI_TypeValidationError", je = `vercel.ai.error.${Ae}`, k = Symbol.for(je), A = class e extends S {
|
|
121
120
|
constructor({ value: e, cause: t, context: n }) {
|
|
122
121
|
let r = "Type validation failed";
|
|
123
122
|
if (n?.field && (r += ` for ${n.field}`), n?.entityName || n?.entityId) {
|
|
@@ -126,14 +125,13 @@ Error message: ${D(t)}`,
|
|
|
126
125
|
n.entityName && e.push(n.entityName), n.entityId && e.push(`id: "${n.entityId}"`), r += e.join(", "), r += ")";
|
|
127
126
|
}
|
|
128
127
|
super({
|
|
129
|
-
name:
|
|
130
|
-
message: `${r}: Value: ${JSON.stringify(e)}
|
|
131
|
-
Error message: ${D(t)}`,
|
|
128
|
+
name: Ae,
|
|
129
|
+
message: `${r}: Value: ${JSON.stringify(e)}.\nError message: ${E(t)}`,
|
|
132
130
|
cause: t
|
|
133
|
-
}), this[
|
|
131
|
+
}), this[k] = !0, this.value = e, this.context = n;
|
|
134
132
|
}
|
|
135
133
|
static isInstance(e) {
|
|
136
|
-
return
|
|
134
|
+
return S.hasMarker(e, je);
|
|
137
135
|
}
|
|
138
136
|
static wrap({ value: t, cause: n, context: r }) {
|
|
139
137
|
return e.isInstance(n) && n.value === t && n.context?.field === r?.field && n.context?.entityName === r?.entityName && n.context?.entityId === r?.entityId ? n : new e({
|
|
@@ -142,25 +140,25 @@ Error message: ${D(t)}`,
|
|
|
142
140
|
context: r
|
|
143
141
|
});
|
|
144
142
|
}
|
|
145
|
-
},
|
|
143
|
+
}, Me = "AI_UnsupportedFunctionalityError", j = `vercel.ai.error.${Me}`, Ne = Symbol.for(j), Pe = class extends S {
|
|
146
144
|
constructor({ functionality: e, message: t = `'${e}' functionality not supported.` }) {
|
|
147
145
|
super({
|
|
148
|
-
name:
|
|
146
|
+
name: Me,
|
|
149
147
|
message: t
|
|
150
|
-
}), this[
|
|
148
|
+
}), this[Ne] = !0, this.functionality = e;
|
|
151
149
|
}
|
|
152
150
|
static isInstance(e) {
|
|
153
|
-
return
|
|
151
|
+
return S.hasMarker(e, j);
|
|
154
152
|
}
|
|
155
|
-
},
|
|
153
|
+
}, M = class extends Error {
|
|
156
154
|
constructor(e, t) {
|
|
157
155
|
super(e), this.name = "ParseError", this.type = t.type, this.field = t.field, this.value = t.value, this.line = t.line;
|
|
158
156
|
}
|
|
159
|
-
},
|
|
160
|
-
function
|
|
161
|
-
function
|
|
157
|
+
}, Fe = 10, N = 13, P = 32;
|
|
158
|
+
function F(e) {}
|
|
159
|
+
function Ie(e) {
|
|
162
160
|
if (typeof e == "function") throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");
|
|
163
|
-
let { onEvent: t =
|
|
161
|
+
let { onEvent: t = F, onError: n = F, onRetry: r = F, onComment: i, maxBufferSize: a } = e, o = [], s = 0, c = !0, l, u = "", d = 0, f, p = !1;
|
|
164
162
|
function m(e) {
|
|
165
163
|
if (p) throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");
|
|
166
164
|
if (c && (c = !1, e.charCodeAt(0) === 239 && e.charCodeAt(1) === 187 && e.charCodeAt(2) === 191 && (e = e.slice(3))), o.length === 0) {
|
|
@@ -179,7 +177,7 @@ function Ze(e) {
|
|
|
179
177
|
n !== "" && (o.push(n), s = n.length), h();
|
|
180
178
|
}
|
|
181
179
|
function h() {
|
|
182
|
-
a !== void 0 && (s + u.length <= a || (p = !0, o.length = 0, s = 0, l = void 0, u = "", d = 0, f = void 0, n(new
|
|
180
|
+
a !== void 0 && (s + u.length <= a || (p = !0, o.length = 0, s = 0, l = void 0, u = "", d = 0, f = void 0, n(new M(`Buffered data exceeded max buffer size of ${a} characters`, { type: "max-buffer-size-exceeded" }))));
|
|
183
181
|
}
|
|
184
182
|
function g(e) {
|
|
185
183
|
let n = 0;
|
|
@@ -195,9 +193,9 @@ function Ze(e) {
|
|
|
195
193
|
continue;
|
|
196
194
|
}
|
|
197
195
|
let i = e.charCodeAt(n);
|
|
198
|
-
if (
|
|
196
|
+
if (I(e, n, i)) {
|
|
199
197
|
let i = e.charCodeAt(n + 5) === P ? n + 6 : n + 5, a = e.slice(i, r);
|
|
200
|
-
if (d === 0 && e.charCodeAt(r + 1) ===
|
|
198
|
+
if (d === 0 && e.charCodeAt(r + 1) === Fe) {
|
|
201
199
|
t({
|
|
202
200
|
id: l,
|
|
203
201
|
event: f,
|
|
@@ -207,7 +205,7 @@ function Ze(e) {
|
|
|
207
205
|
}
|
|
208
206
|
u = d === 0 ? a : `${u}
|
|
209
207
|
${a}`, d++;
|
|
210
|
-
} else
|
|
208
|
+
} else Le(e, n, i) ? f = e.slice(e.charCodeAt(n + 6) === P ? n + 7 : n + 6, r) || void 0 : _(e, n, r);
|
|
211
209
|
n = r + 1, r = e.indexOf("\n", n);
|
|
212
210
|
}
|
|
213
211
|
return e.slice(n);
|
|
@@ -215,7 +213,7 @@ ${a}`, d++;
|
|
|
215
213
|
for (; n < e.length;) {
|
|
216
214
|
let t = e.indexOf("\r", n), r = e.indexOf("\n", n), i = -1;
|
|
217
215
|
if (t !== -1 && r !== -1 ? i = t < r ? t : r : t === -1 ? r !== -1 && (i = r) : i = t === e.length - 1 ? -1 : t, i === -1) break;
|
|
218
|
-
_(e, n, i), n = i + 1, e.charCodeAt(n - 1) ===
|
|
216
|
+
_(e, n, i), n = i + 1, e.charCodeAt(n - 1) === N && e.charCodeAt(n) === Fe && n++;
|
|
219
217
|
}
|
|
220
218
|
return e.slice(n);
|
|
221
219
|
}
|
|
@@ -225,13 +223,13 @@ ${a}`, d++;
|
|
|
225
223
|
return;
|
|
226
224
|
}
|
|
227
225
|
let r = e.charCodeAt(t);
|
|
228
|
-
if (
|
|
226
|
+
if (I(e, t, r)) {
|
|
229
227
|
let r = e.charCodeAt(t + 5) === P ? t + 6 : t + 5, i = e.slice(r, n);
|
|
230
228
|
u = d === 0 ? i : `${u}
|
|
231
229
|
${i}`, d++;
|
|
232
230
|
return;
|
|
233
231
|
}
|
|
234
|
-
if (
|
|
232
|
+
if (Le(e, t, r)) {
|
|
235
233
|
f = e.slice(e.charCodeAt(t + 6) === P ? t + 7 : t + 6, n) || void 0;
|
|
236
234
|
return;
|
|
237
235
|
}
|
|
@@ -268,13 +266,13 @@ ${t}`, d++;
|
|
|
268
266
|
l = t.includes("\0") ? void 0 : t;
|
|
269
267
|
break;
|
|
270
268
|
case "retry":
|
|
271
|
-
/^\d+$/.test(t) ? r(parseInt(t, 10)) : n(new
|
|
269
|
+
/^\d+$/.test(t) ? r(parseInt(t, 10)) : n(new M(`Invalid \`retry\` value: "${t}"`, {
|
|
272
270
|
type: "invalid-retry",
|
|
273
271
|
value: t,
|
|
274
272
|
line: i
|
|
275
273
|
}));
|
|
276
274
|
break;
|
|
277
|
-
default: n(new
|
|
275
|
+
default: n(new M(`Unknown field "${e.length > 20 ? `${e.slice(0, 20)}\u2026` : e}"`, {
|
|
278
276
|
type: "unknown-field",
|
|
279
277
|
field: e,
|
|
280
278
|
value: t,
|
|
@@ -301,20 +299,20 @@ ${t}`, d++;
|
|
|
301
299
|
reset: te
|
|
302
300
|
};
|
|
303
301
|
}
|
|
304
|
-
function
|
|
302
|
+
function I(e, t, n) {
|
|
305
303
|
return n === 100 && e.charCodeAt(t + 1) === 97 && e.charCodeAt(t + 2) === 116 && e.charCodeAt(t + 3) === 97 && e.charCodeAt(t + 4) === 58;
|
|
306
304
|
}
|
|
307
|
-
function
|
|
305
|
+
function Le(e, t, n) {
|
|
308
306
|
return n === 101 && e.charCodeAt(t + 1) === 118 && e.charCodeAt(t + 2) === 101 && e.charCodeAt(t + 3) === 110 && e.charCodeAt(t + 4) === 116 && e.charCodeAt(t + 5) === 58;
|
|
309
307
|
}
|
|
310
308
|
//#endregion
|
|
311
309
|
//#region ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/stream.js
|
|
312
|
-
var
|
|
310
|
+
var Re = class extends TransformStream {
|
|
313
311
|
constructor({ onError: e, onRetry: t, onComment: n, maxBufferSize: r } = {}) {
|
|
314
312
|
let i;
|
|
315
313
|
super({
|
|
316
314
|
start(a) {
|
|
317
|
-
i =
|
|
315
|
+
i = Ie({
|
|
318
316
|
onEvent: (e) => {
|
|
319
317
|
a.enqueue(e);
|
|
320
318
|
},
|
|
@@ -333,8 +331,8 @@ var et = class extends TransformStream {
|
|
|
333
331
|
}
|
|
334
332
|
};
|
|
335
333
|
new TextDecoder();
|
|
336
|
-
var { btoa:
|
|
337
|
-
function
|
|
334
|
+
var { btoa: ze, atob: Be } = globalThis;
|
|
335
|
+
function L(e) {
|
|
338
336
|
if (e == null) return {};
|
|
339
337
|
let t = {};
|
|
340
338
|
if (e instanceof Headers) e.forEach((e, n) => {
|
|
@@ -346,28 +344,28 @@ function F(e) {
|
|
|
346
344
|
}
|
|
347
345
|
return t;
|
|
348
346
|
}
|
|
349
|
-
var
|
|
347
|
+
var R = ({ prefix: e, size: t = 16, alphabet: n = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", separator: r = "-" } = {}) => {
|
|
350
348
|
let i = () => {
|
|
351
349
|
let e = n.length, r = Array(t);
|
|
352
350
|
for (let i = 0; i < t; i++) r[i] = n[Math.random() * e | 0];
|
|
353
351
|
return r.join("");
|
|
354
352
|
};
|
|
355
353
|
if (e == null) return i;
|
|
356
|
-
if (n.includes(r)) throw new
|
|
354
|
+
if (n.includes(r)) throw new De({
|
|
357
355
|
argument: "separator",
|
|
358
356
|
message: `The separator "${r}" must not be part of the alphabet "${n}".`
|
|
359
357
|
});
|
|
360
358
|
return () => `${e}${r}${i()}`;
|
|
361
|
-
},
|
|
362
|
-
function
|
|
359
|
+
}, z = R();
|
|
360
|
+
function Ve(e) {
|
|
363
361
|
return globalThis.Buffer?.isBuffer(e) ?? !1;
|
|
364
362
|
}
|
|
365
|
-
var
|
|
366
|
-
function
|
|
363
|
+
var He = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, Ue = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
364
|
+
function We(e) {
|
|
367
365
|
let t = JSON.parse(e);
|
|
368
|
-
return typeof t != "object" || !t ||
|
|
366
|
+
return typeof t != "object" || !t || He.test(e) === !1 && Ue.test(e) === !1 ? t : Ge(t);
|
|
369
367
|
}
|
|
370
|
-
function
|
|
368
|
+
function Ge(e) {
|
|
371
369
|
let t = [e];
|
|
372
370
|
for (; t.length;) {
|
|
373
371
|
let e = t;
|
|
@@ -382,35 +380,35 @@ function st(e) {
|
|
|
382
380
|
}
|
|
383
381
|
return e;
|
|
384
382
|
}
|
|
385
|
-
function
|
|
383
|
+
function Ke(e) {
|
|
386
384
|
let { stackTraceLimit: t } = Error;
|
|
387
385
|
try {
|
|
388
386
|
Error.stackTraceLimit = 0;
|
|
389
387
|
} catch {
|
|
390
|
-
return
|
|
388
|
+
return We(e);
|
|
391
389
|
}
|
|
392
390
|
try {
|
|
393
|
-
return
|
|
391
|
+
return We(e);
|
|
394
392
|
} finally {
|
|
395
393
|
Error.stackTraceLimit = t;
|
|
396
394
|
}
|
|
397
395
|
}
|
|
398
|
-
function
|
|
396
|
+
function qe(e) {
|
|
399
397
|
if (e.type === "object" || Array.isArray(e.type) && e.type.includes("object")) {
|
|
400
398
|
let { additionalProperties: t } = e;
|
|
401
|
-
e.additionalProperties = t != null && typeof t != "boolean" &&
|
|
399
|
+
e.additionalProperties = t != null && typeof t != "boolean" && B(t);
|
|
402
400
|
let { properties: n } = e;
|
|
403
|
-
if (n != null) for (let e of Object.keys(n)) n[e] =
|
|
401
|
+
if (n != null) for (let e of Object.keys(n)) n[e] = B(n[e]);
|
|
404
402
|
}
|
|
405
|
-
e.items != null && (e.items = Array.isArray(e.items) ? e.items.map(
|
|
403
|
+
e.items != null && (e.items = Array.isArray(e.items) ? e.items.map(B) : B(e.items)), e.anyOf != null && (e.anyOf = e.anyOf.map(B)), e.allOf != null && (e.allOf = e.allOf.map(B)), e.oneOf != null && (e.oneOf = e.oneOf.map(B));
|
|
406
404
|
let { definitions: t } = e;
|
|
407
|
-
if (t != null) for (let e of Object.keys(t)) t[e] =
|
|
405
|
+
if (t != null) for (let e of Object.keys(t)) t[e] = B(t[e]);
|
|
408
406
|
return e;
|
|
409
407
|
}
|
|
410
|
-
function
|
|
411
|
-
return typeof e == "boolean" ? e :
|
|
408
|
+
function B(e) {
|
|
409
|
+
return typeof e == "boolean" ? e : qe(e);
|
|
412
410
|
}
|
|
413
|
-
var
|
|
411
|
+
var Je = Symbol("Let zodToJsonSchema decide on which parser to use"), Ye = {
|
|
414
412
|
name: void 0,
|
|
415
413
|
$refStrategy: "root",
|
|
416
414
|
basePath: ["#"],
|
|
@@ -430,24 +428,24 @@ var ut = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to u
|
|
|
430
428
|
emailStrategy: "format:email",
|
|
431
429
|
base64Strategy: "contentEncoding:base64",
|
|
432
430
|
nameStrategy: "ref"
|
|
433
|
-
},
|
|
434
|
-
...
|
|
431
|
+
}, Xe = (e) => typeof e == "string" ? {
|
|
432
|
+
...Ye,
|
|
435
433
|
name: e
|
|
436
434
|
} : {
|
|
437
|
-
...
|
|
435
|
+
...Ye,
|
|
438
436
|
...e
|
|
439
437
|
};
|
|
440
|
-
function
|
|
438
|
+
function V() {
|
|
441
439
|
return {};
|
|
442
440
|
}
|
|
443
|
-
function
|
|
441
|
+
function Ze(e, t) {
|
|
444
442
|
let n = { type: "array" };
|
|
445
|
-
return e.type?._def && e.type?._def?.typeName !== "ZodAny" && (n.items =
|
|
443
|
+
return e.type?._def && e.type?._def?.typeName !== "ZodAny" && (n.items = K(e.type._def, {
|
|
446
444
|
...t,
|
|
447
445
|
currentPath: [...t.currentPath, "items"]
|
|
448
446
|
})), e.minLength && (n.minItems = e.minLength.value), e.maxLength && (n.maxItems = e.maxLength.value), e.exactLength && (n.minItems = e.exactLength.value, n.maxItems = e.exactLength.value), n;
|
|
449
447
|
}
|
|
450
|
-
function
|
|
448
|
+
function Qe(e) {
|
|
451
449
|
let t = {
|
|
452
450
|
type: "integer",
|
|
453
451
|
format: "int64"
|
|
@@ -464,16 +462,16 @@ function mt(e) {
|
|
|
464
462
|
}
|
|
465
463
|
return t;
|
|
466
464
|
}
|
|
467
|
-
function
|
|
465
|
+
function $e() {
|
|
468
466
|
return { type: "boolean" };
|
|
469
467
|
}
|
|
470
|
-
function
|
|
471
|
-
return
|
|
468
|
+
function et(e, t) {
|
|
469
|
+
return K(e.type._def, t);
|
|
472
470
|
}
|
|
473
|
-
var
|
|
474
|
-
function
|
|
471
|
+
var tt = (e, t) => K(e.innerType._def, t);
|
|
472
|
+
function nt(e, t, n) {
|
|
475
473
|
let r = n ?? t.dateStrategy;
|
|
476
|
-
if (Array.isArray(r)) return { anyOf: r.map((n) =>
|
|
474
|
+
if (Array.isArray(r)) return { anyOf: r.map((n) => nt(e, t, n)) };
|
|
477
475
|
switch (r) {
|
|
478
476
|
case "string":
|
|
479
477
|
case "format:date-time": return {
|
|
@@ -484,10 +482,10 @@ function vt(e, t, n) {
|
|
|
484
482
|
type: "string",
|
|
485
483
|
format: "date"
|
|
486
484
|
};
|
|
487
|
-
case "integer": return
|
|
485
|
+
case "integer": return rt(e);
|
|
488
486
|
}
|
|
489
487
|
}
|
|
490
|
-
var
|
|
488
|
+
var rt = (e) => {
|
|
491
489
|
let t = {
|
|
492
490
|
type: "integer",
|
|
493
491
|
format: "unix-time"
|
|
@@ -500,31 +498,31 @@ var yt = (e) => {
|
|
|
500
498
|
}
|
|
501
499
|
return t;
|
|
502
500
|
};
|
|
503
|
-
function
|
|
501
|
+
function it(e, t) {
|
|
504
502
|
return {
|
|
505
|
-
...
|
|
503
|
+
...K(e.innerType._def, t),
|
|
506
504
|
default: e.defaultValue()
|
|
507
505
|
};
|
|
508
506
|
}
|
|
509
|
-
function
|
|
510
|
-
return t.effectStrategy === "input" ?
|
|
507
|
+
function at(e, t) {
|
|
508
|
+
return t.effectStrategy === "input" ? K(e.schema._def, t) : V();
|
|
511
509
|
}
|
|
512
|
-
function
|
|
510
|
+
function H(e) {
|
|
513
511
|
return {
|
|
514
512
|
type: "string",
|
|
515
513
|
enum: Array.from(e.values)
|
|
516
514
|
};
|
|
517
515
|
}
|
|
518
|
-
var
|
|
519
|
-
function
|
|
520
|
-
let n = [
|
|
516
|
+
var ot = (e) => "type" in e && e.type === "string" ? !1 : "allOf" in e;
|
|
517
|
+
function st(e, t) {
|
|
518
|
+
let n = [K(e.left._def, {
|
|
521
519
|
...t,
|
|
522
520
|
currentPath: [
|
|
523
521
|
...t.currentPath,
|
|
524
522
|
"allOf",
|
|
525
523
|
"0"
|
|
526
524
|
]
|
|
527
|
-
}),
|
|
525
|
+
}), K(e.right._def, {
|
|
528
526
|
...t,
|
|
529
527
|
currentPath: [
|
|
530
528
|
...t.currentPath,
|
|
@@ -533,7 +531,7 @@ function wt(e, t) {
|
|
|
533
531
|
]
|
|
534
532
|
})].filter((e) => !!e), r = [];
|
|
535
533
|
return n.forEach((e) => {
|
|
536
|
-
if (
|
|
534
|
+
if (ot(e)) r.push(...e.allOf);
|
|
537
535
|
else {
|
|
538
536
|
let t = e;
|
|
539
537
|
if ("additionalProperties" in e && e.additionalProperties === !1) {
|
|
@@ -544,19 +542,19 @@ function wt(e, t) {
|
|
|
544
542
|
}
|
|
545
543
|
}), r.length ? { allOf: r } : void 0;
|
|
546
544
|
}
|
|
547
|
-
function
|
|
545
|
+
function ct(e) {
|
|
548
546
|
let t = typeof e.value;
|
|
549
547
|
return t !== "bigint" && t !== "number" && t !== "boolean" && t !== "string" ? { type: Array.isArray(e.value) ? "array" : "object" } : {
|
|
550
548
|
type: t === "bigint" ? "integer" : t,
|
|
551
549
|
const: e.value
|
|
552
550
|
};
|
|
553
551
|
}
|
|
554
|
-
var
|
|
552
|
+
var lt = void 0, U = {
|
|
555
553
|
cuid: /^[cC][^\s-]{8,}$/,
|
|
556
554
|
cuid2: /^[0-9a-z]+$/,
|
|
557
555
|
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
558
556
|
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,
|
|
559
|
-
emoji: () => (
|
|
557
|
+
emoji: () => (lt === void 0 && (lt = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u")), lt),
|
|
560
558
|
uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
561
559
|
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
|
|
562
560
|
ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
|
|
@@ -567,7 +565,7 @@ var Et = void 0, B = {
|
|
|
567
565
|
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
568
566
|
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
569
567
|
};
|
|
570
|
-
function
|
|
568
|
+
function ut(e, t) {
|
|
571
569
|
let n = { type: "string" };
|
|
572
570
|
if (e.checks) for (let r of e.checks) switch (r.kind) {
|
|
573
571
|
case "min":
|
|
@@ -579,108 +577,108 @@ function Dt(e, t) {
|
|
|
579
577
|
case "email":
|
|
580
578
|
switch (t.emailStrategy) {
|
|
581
579
|
case "format:email":
|
|
582
|
-
|
|
580
|
+
W(n, "email", r.message, t);
|
|
583
581
|
break;
|
|
584
582
|
case "format:idn-email":
|
|
585
|
-
|
|
583
|
+
W(n, "idn-email", r.message, t);
|
|
586
584
|
break;
|
|
587
|
-
case "pattern:zod":
|
|
585
|
+
case "pattern:zod": G(n, U.email, r.message, t);
|
|
588
586
|
}
|
|
589
587
|
break;
|
|
590
588
|
case "url":
|
|
591
|
-
|
|
589
|
+
W(n, "uri", r.message, t);
|
|
592
590
|
break;
|
|
593
591
|
case "uuid":
|
|
594
|
-
|
|
592
|
+
W(n, "uuid", r.message, t);
|
|
595
593
|
break;
|
|
596
594
|
case "regex":
|
|
597
|
-
|
|
595
|
+
G(n, r.regex, r.message, t);
|
|
598
596
|
break;
|
|
599
597
|
case "cuid":
|
|
600
|
-
|
|
598
|
+
G(n, U.cuid, r.message, t);
|
|
601
599
|
break;
|
|
602
600
|
case "cuid2":
|
|
603
|
-
|
|
601
|
+
G(n, U.cuid2, r.message, t);
|
|
604
602
|
break;
|
|
605
603
|
case "startsWith":
|
|
606
|
-
|
|
604
|
+
G(n, RegExp(`^${dt(r.value, t)}`), r.message, t);
|
|
607
605
|
break;
|
|
608
606
|
case "endsWith":
|
|
609
|
-
|
|
607
|
+
G(n, RegExp(`${dt(r.value, t)}$`), r.message, t);
|
|
610
608
|
break;
|
|
611
609
|
case "datetime":
|
|
612
|
-
|
|
610
|
+
W(n, "date-time", r.message, t);
|
|
613
611
|
break;
|
|
614
612
|
case "date":
|
|
615
|
-
|
|
613
|
+
W(n, "date", r.message, t);
|
|
616
614
|
break;
|
|
617
615
|
case "time":
|
|
618
|
-
|
|
616
|
+
W(n, "time", r.message, t);
|
|
619
617
|
break;
|
|
620
618
|
case "duration":
|
|
621
|
-
|
|
619
|
+
W(n, "duration", r.message, t);
|
|
622
620
|
break;
|
|
623
621
|
case "length":
|
|
624
622
|
n.minLength = typeof n.minLength == "number" ? Math.max(n.minLength, r.value) : r.value, n.maxLength = typeof n.maxLength == "number" ? Math.min(n.maxLength, r.value) : r.value;
|
|
625
623
|
break;
|
|
626
624
|
case "includes":
|
|
627
|
-
|
|
625
|
+
G(n, RegExp(dt(r.value, t)), r.message, t);
|
|
628
626
|
break;
|
|
629
627
|
case "ip":
|
|
630
|
-
r.version !== "v6" &&
|
|
628
|
+
r.version !== "v6" && W(n, "ipv4", r.message, t), r.version !== "v4" && W(n, "ipv6", r.message, t);
|
|
631
629
|
break;
|
|
632
630
|
case "base64url":
|
|
633
|
-
|
|
631
|
+
G(n, U.base64url, r.message, t);
|
|
634
632
|
break;
|
|
635
633
|
case "jwt":
|
|
636
|
-
|
|
634
|
+
G(n, U.jwt, r.message, t);
|
|
637
635
|
break;
|
|
638
636
|
case "cidr":
|
|
639
|
-
r.version !== "v6" &&
|
|
637
|
+
r.version !== "v6" && G(n, U.ipv4Cidr, r.message, t), r.version !== "v4" && G(n, U.ipv6Cidr, r.message, t);
|
|
640
638
|
break;
|
|
641
639
|
case "emoji":
|
|
642
|
-
|
|
640
|
+
G(n, U.emoji(), r.message, t);
|
|
643
641
|
break;
|
|
644
642
|
case "ulid":
|
|
645
|
-
|
|
643
|
+
G(n, U.ulid, r.message, t);
|
|
646
644
|
break;
|
|
647
645
|
case "base64":
|
|
648
646
|
switch (t.base64Strategy) {
|
|
649
647
|
case "format:binary":
|
|
650
|
-
|
|
648
|
+
W(n, "binary", r.message, t);
|
|
651
649
|
break;
|
|
652
650
|
case "contentEncoding:base64":
|
|
653
651
|
n.contentEncoding = "base64";
|
|
654
652
|
break;
|
|
655
|
-
case "pattern:zod":
|
|
653
|
+
case "pattern:zod": G(n, U.base64, r.message, t);
|
|
656
654
|
}
|
|
657
655
|
break;
|
|
658
|
-
case "nanoid":
|
|
656
|
+
case "nanoid": G(n, U.nanoid, r.message, t);
|
|
659
657
|
}
|
|
660
658
|
return n;
|
|
661
659
|
}
|
|
662
|
-
function
|
|
663
|
-
return t.patternStrategy === "escape" ?
|
|
660
|
+
function dt(e, t) {
|
|
661
|
+
return t.patternStrategy === "escape" ? pt(e) : e;
|
|
664
662
|
}
|
|
665
|
-
var
|
|
666
|
-
function
|
|
663
|
+
var ft = /* @__PURE__ */ new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
664
|
+
function pt(e) {
|
|
667
665
|
let t = "";
|
|
668
|
-
for (let n = 0; n < e.length; n++)
|
|
666
|
+
for (let n = 0; n < e.length; n++) ft.has(e[n]) || (t += "\\"), t += e[n];
|
|
669
667
|
return t;
|
|
670
668
|
}
|
|
671
|
-
function
|
|
669
|
+
function W(e, t, n, r) {
|
|
672
670
|
e.format || e.anyOf?.some((e) => e.format) ? (e.anyOf ||= [], e.format && (e.anyOf.push({ format: e.format }), delete e.format), e.anyOf.push({
|
|
673
671
|
format: t,
|
|
674
672
|
...n && r.errorMessages && { errorMessage: { format: n } }
|
|
675
673
|
})) : e.format = t;
|
|
676
674
|
}
|
|
677
|
-
function
|
|
675
|
+
function G(e, t, n, r) {
|
|
678
676
|
e.pattern || e.allOf?.some((e) => e.pattern) ? (e.allOf ||= [], e.pattern && (e.allOf.push({ pattern: e.pattern }), delete e.pattern), e.allOf.push({
|
|
679
|
-
pattern:
|
|
677
|
+
pattern: mt(t, r),
|
|
680
678
|
...n && r.errorMessages && { errorMessage: { pattern: n } }
|
|
681
|
-
})) : e.pattern =
|
|
679
|
+
})) : e.pattern = mt(t, r);
|
|
682
680
|
}
|
|
683
|
-
function
|
|
681
|
+
function mt(e, t) {
|
|
684
682
|
if (!t.applyRegexFlags || !e.flags) return e.source;
|
|
685
683
|
let n = {
|
|
686
684
|
i: e.flags.includes("i"),
|
|
@@ -714,9 +712,7 @@ function jt(e, t) {
|
|
|
714
712
|
}
|
|
715
713
|
}
|
|
716
714
|
if (n.s && r[e] === ".") {
|
|
717
|
-
i += o ? `${r[e]}\r
|
|
718
|
-
` : `[${r[e]}\r
|
|
719
|
-
]`;
|
|
715
|
+
i += o ? `${r[e]}\r\n` : `[${r[e]}\r\n]`;
|
|
720
716
|
continue;
|
|
721
717
|
}
|
|
722
718
|
i += r[e], r[e] === "\\" ? a = !0 : o && r[e] === "]" ? o = !1 : !o && r[e] === "[" && (o = !0);
|
|
@@ -728,16 +724,16 @@ function jt(e, t) {
|
|
|
728
724
|
}
|
|
729
725
|
return i;
|
|
730
726
|
}
|
|
731
|
-
function
|
|
727
|
+
function ht(e, t) {
|
|
732
728
|
let n = {
|
|
733
729
|
type: "object",
|
|
734
|
-
additionalProperties:
|
|
730
|
+
additionalProperties: K(e.valueType._def, {
|
|
735
731
|
...t,
|
|
736
732
|
currentPath: [...t.currentPath, "additionalProperties"]
|
|
737
733
|
}) ?? t.allowedAdditionalProperties
|
|
738
734
|
};
|
|
739
735
|
if (e.keyType?._def.typeName === "ZodString" && e.keyType._def.checks?.length) {
|
|
740
|
-
let { type: r, ...i } =
|
|
736
|
+
let { type: r, ...i } = ut(e.keyType._def, t);
|
|
741
737
|
return {
|
|
742
738
|
...n,
|
|
743
739
|
propertyNames: i
|
|
@@ -748,7 +744,7 @@ function Mt(e, t) {
|
|
|
748
744
|
propertyNames: { enum: e.keyType._def.values }
|
|
749
745
|
};
|
|
750
746
|
if (e.keyType?._def.typeName === "ZodBranded" && e.keyType._def.type._def.typeName === "ZodString" && e.keyType._def.type._def.checks?.length) {
|
|
751
|
-
let { type: r, ...i } =
|
|
747
|
+
let { type: r, ...i } = et(e.keyType._def, t);
|
|
752
748
|
return {
|
|
753
749
|
...n,
|
|
754
750
|
propertyNames: i
|
|
@@ -756,13 +752,13 @@ function Mt(e, t) {
|
|
|
756
752
|
}
|
|
757
753
|
return n;
|
|
758
754
|
}
|
|
759
|
-
function
|
|
760
|
-
return t.mapStrategy === "record" ?
|
|
755
|
+
function gt(e, t) {
|
|
756
|
+
return t.mapStrategy === "record" ? ht(e, t) : {
|
|
761
757
|
type: "array",
|
|
762
758
|
maxItems: 125,
|
|
763
759
|
items: {
|
|
764
760
|
type: "array",
|
|
765
|
-
items: [
|
|
761
|
+
items: [K(e.keyType._def, {
|
|
766
762
|
...t,
|
|
767
763
|
currentPath: [
|
|
768
764
|
...t.currentPath,
|
|
@@ -770,7 +766,7 @@ function Nt(e, t) {
|
|
|
770
766
|
"items",
|
|
771
767
|
"0"
|
|
772
768
|
]
|
|
773
|
-
}) ||
|
|
769
|
+
}) || V(), K(e.valueType._def, {
|
|
774
770
|
...t,
|
|
775
771
|
currentPath: [
|
|
776
772
|
...t.currentPath,
|
|
@@ -778,37 +774,37 @@ function Nt(e, t) {
|
|
|
778
774
|
"items",
|
|
779
775
|
"1"
|
|
780
776
|
]
|
|
781
|
-
}) ||
|
|
777
|
+
}) || V()],
|
|
782
778
|
minItems: 2,
|
|
783
779
|
maxItems: 2
|
|
784
780
|
}
|
|
785
781
|
};
|
|
786
782
|
}
|
|
787
|
-
function
|
|
783
|
+
function _t(e) {
|
|
788
784
|
let t = e.values, n = Object.keys(e.values).filter((e) => typeof t[t[e]] != "number").map((e) => t[e]), r = Array.from(new Set(n.map((e) => typeof e)));
|
|
789
785
|
return {
|
|
790
786
|
type: r.length === 1 ? r[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
791
787
|
enum: n
|
|
792
788
|
};
|
|
793
789
|
}
|
|
794
|
-
function
|
|
795
|
-
return { not:
|
|
790
|
+
function vt() {
|
|
791
|
+
return { not: V() };
|
|
796
792
|
}
|
|
797
|
-
function
|
|
793
|
+
function yt() {
|
|
798
794
|
return { type: "null" };
|
|
799
795
|
}
|
|
800
|
-
var
|
|
796
|
+
var bt = {
|
|
801
797
|
ZodString: "string",
|
|
802
798
|
ZodNumber: "number",
|
|
803
799
|
ZodBigInt: "integer",
|
|
804
800
|
ZodBoolean: "boolean",
|
|
805
801
|
ZodNull: "null"
|
|
806
802
|
};
|
|
807
|
-
function
|
|
803
|
+
function xt(e, t) {
|
|
808
804
|
let n = e.options instanceof Map ? Array.from(e.options.values()) : e.options;
|
|
809
|
-
if (n.every((e) => e._def.typeName in
|
|
805
|
+
if (n.every((e) => e._def.typeName in bt && (!e._def.checks || !e._def.checks.length))) {
|
|
810
806
|
let e = n.reduce((e, t) => {
|
|
811
|
-
let n =
|
|
807
|
+
let n = bt[t._def.typeName];
|
|
812
808
|
return n && !e.includes(n) ? [...e, n] : e;
|
|
813
809
|
}, []);
|
|
814
810
|
return { type: e.length > 1 ? e : e[0] };
|
|
@@ -836,10 +832,10 @@ function Rt(e, t) {
|
|
|
836
832
|
type: "string",
|
|
837
833
|
enum: n.reduce((e, t) => [...e, ...t._def.values.filter((t) => !e.includes(t))], [])
|
|
838
834
|
};
|
|
839
|
-
return
|
|
835
|
+
return St(e, t);
|
|
840
836
|
}
|
|
841
|
-
var
|
|
842
|
-
let n = (e.options instanceof Map ? Array.from(e.options.values()) : e.options).map((e, n) =>
|
|
837
|
+
var St = (e, t) => {
|
|
838
|
+
let n = (e.options instanceof Map ? Array.from(e.options.values()) : e.options).map((e, n) => K(e._def, {
|
|
843
839
|
...t,
|
|
844
840
|
currentPath: [
|
|
845
841
|
...t.currentPath,
|
|
@@ -849,15 +845,15 @@ var zt = (e, t) => {
|
|
|
849
845
|
})).filter((e) => !!e && (!t.strictUnions || typeof e == "object" && Object.keys(e).length > 0));
|
|
850
846
|
return n.length ? { anyOf: n } : void 0;
|
|
851
847
|
};
|
|
852
|
-
function
|
|
848
|
+
function Ct(e, t) {
|
|
853
849
|
if ([
|
|
854
850
|
"ZodString",
|
|
855
851
|
"ZodNumber",
|
|
856
852
|
"ZodBigInt",
|
|
857
853
|
"ZodBoolean",
|
|
858
854
|
"ZodNull"
|
|
859
|
-
].includes(e.innerType._def.typeName) && (!e.innerType._def.checks || !e.innerType._def.checks.length)) return { type: [
|
|
860
|
-
let n =
|
|
855
|
+
].includes(e.innerType._def.typeName) && (!e.innerType._def.checks || !e.innerType._def.checks.length)) return { type: [bt[e.innerType._def.typeName], "null"] };
|
|
856
|
+
let n = K(e.innerType._def, {
|
|
861
857
|
...t,
|
|
862
858
|
currentPath: [
|
|
863
859
|
...t.currentPath,
|
|
@@ -867,7 +863,7 @@ function Bt(e, t) {
|
|
|
867
863
|
});
|
|
868
864
|
return n && { anyOf: [n, { type: "null" }] };
|
|
869
865
|
}
|
|
870
|
-
function
|
|
866
|
+
function wt(e) {
|
|
871
867
|
let t = { type: "number" };
|
|
872
868
|
if (!e.checks) return t;
|
|
873
869
|
for (let n of e.checks) switch (n.kind) {
|
|
@@ -884,7 +880,7 @@ function Vt(e) {
|
|
|
884
880
|
}
|
|
885
881
|
return t;
|
|
886
882
|
}
|
|
887
|
-
function
|
|
883
|
+
function Tt(e, t) {
|
|
888
884
|
let n = {
|
|
889
885
|
type: "object",
|
|
890
886
|
properties: {}
|
|
@@ -892,7 +888,7 @@ function Ht(e, t) {
|
|
|
892
888
|
for (let e in i) {
|
|
893
889
|
let a = i[e];
|
|
894
890
|
if (a === void 0 || a._def === void 0) continue;
|
|
895
|
-
let o =
|
|
891
|
+
let o = Dt(a), s = K(a._def, {
|
|
896
892
|
...t,
|
|
897
893
|
currentPath: [
|
|
898
894
|
...t.currentPath,
|
|
@@ -908,11 +904,11 @@ function Ht(e, t) {
|
|
|
908
904
|
s !== void 0 && (n.properties[e] = s, o || r.push(e));
|
|
909
905
|
}
|
|
910
906
|
r.length && (n.required = r);
|
|
911
|
-
let a =
|
|
907
|
+
let a = Et(e, t);
|
|
912
908
|
return a !== void 0 && (n.additionalProperties = a), n;
|
|
913
909
|
}
|
|
914
|
-
function
|
|
915
|
-
if (e.catchall._def.typeName !== "ZodNever") return
|
|
910
|
+
function Et(e, t) {
|
|
911
|
+
if (e.catchall._def.typeName !== "ZodNever") return K(e.catchall._def, {
|
|
916
912
|
...t,
|
|
917
913
|
currentPath: [...t.currentPath, "additionalProperties"]
|
|
918
914
|
});
|
|
@@ -922,16 +918,16 @@ function Ut(e, t) {
|
|
|
922
918
|
case "strip": return t.removeAdditionalStrategy === "strict" ? t.allowedAdditionalProperties : t.rejectedAdditionalProperties;
|
|
923
919
|
}
|
|
924
920
|
}
|
|
925
|
-
function
|
|
921
|
+
function Dt(e) {
|
|
926
922
|
try {
|
|
927
923
|
return e.isOptional();
|
|
928
924
|
} catch {
|
|
929
925
|
return !0;
|
|
930
926
|
}
|
|
931
927
|
}
|
|
932
|
-
var
|
|
933
|
-
if (t.currentPath.toString() === t.propertyPath?.toString()) return
|
|
934
|
-
let n =
|
|
928
|
+
var Ot = (e, t) => {
|
|
929
|
+
if (t.currentPath.toString() === t.propertyPath?.toString()) return K(e.innerType._def, t);
|
|
930
|
+
let n = K(e.innerType._def, {
|
|
935
931
|
...t,
|
|
936
932
|
currentPath: [
|
|
937
933
|
...t.currentPath,
|
|
@@ -939,11 +935,11 @@ var Gt = (e, t) => {
|
|
|
939
935
|
"1"
|
|
940
936
|
]
|
|
941
937
|
});
|
|
942
|
-
return n ? { anyOf: [{ not:
|
|
943
|
-
},
|
|
944
|
-
if (t.pipeStrategy === "input") return
|
|
945
|
-
if (t.pipeStrategy === "output") return
|
|
946
|
-
let n =
|
|
938
|
+
return n ? { anyOf: [{ not: V() }, n] } : V();
|
|
939
|
+
}, kt = (e, t) => {
|
|
940
|
+
if (t.pipeStrategy === "input") return K(e.in._def, t);
|
|
941
|
+
if (t.pipeStrategy === "output") return K(e.out._def, t);
|
|
942
|
+
let n = K(e.in._def, {
|
|
947
943
|
...t,
|
|
948
944
|
currentPath: [
|
|
949
945
|
...t.currentPath,
|
|
@@ -951,7 +947,7 @@ var Gt = (e, t) => {
|
|
|
951
947
|
"0"
|
|
952
948
|
]
|
|
953
949
|
});
|
|
954
|
-
return { allOf: [n,
|
|
950
|
+
return { allOf: [n, K(e.out._def, {
|
|
955
951
|
...t,
|
|
956
952
|
currentPath: [
|
|
957
953
|
...t.currentPath,
|
|
@@ -960,25 +956,25 @@ var Gt = (e, t) => {
|
|
|
960
956
|
]
|
|
961
957
|
})].filter((e) => e !== void 0) };
|
|
962
958
|
};
|
|
963
|
-
function
|
|
964
|
-
return
|
|
959
|
+
function At(e, t) {
|
|
960
|
+
return K(e.type._def, t);
|
|
965
961
|
}
|
|
966
|
-
function
|
|
962
|
+
function jt(e, t) {
|
|
967
963
|
let n = {
|
|
968
964
|
type: "array",
|
|
969
965
|
uniqueItems: !0,
|
|
970
|
-
items:
|
|
966
|
+
items: K(e.valueType._def, {
|
|
971
967
|
...t,
|
|
972
968
|
currentPath: [...t.currentPath, "items"]
|
|
973
969
|
})
|
|
974
970
|
};
|
|
975
971
|
return e.minSize && (n.minItems = e.minSize.value), e.maxSize && (n.maxItems = e.maxSize.value), n;
|
|
976
972
|
}
|
|
977
|
-
function
|
|
973
|
+
function Mt(e, t) {
|
|
978
974
|
return e.rest ? {
|
|
979
975
|
type: "array",
|
|
980
976
|
minItems: e.items.length,
|
|
981
|
-
items: e.items.map((e, n) =>
|
|
977
|
+
items: e.items.map((e, n) => K(e._def, {
|
|
982
978
|
...t,
|
|
983
979
|
currentPath: [
|
|
984
980
|
...t.currentPath,
|
|
@@ -986,7 +982,7 @@ function Yt(e, t) {
|
|
|
986
982
|
`${n}`
|
|
987
983
|
]
|
|
988
984
|
})).reduce((e, t) => t === void 0 ? e : [...e, t], []),
|
|
989
|
-
additionalItems:
|
|
985
|
+
additionalItems: K(e.rest._def, {
|
|
990
986
|
...t,
|
|
991
987
|
currentPath: [...t.currentPath, "additionalItems"]
|
|
992
988
|
})
|
|
@@ -994,7 +990,7 @@ function Yt(e, t) {
|
|
|
994
990
|
type: "array",
|
|
995
991
|
minItems: e.items.length,
|
|
996
992
|
maxItems: e.items.length,
|
|
997
|
-
items: e.items.map((e, n) =>
|
|
993
|
+
items: e.items.map((e, n) => K(e._def, {
|
|
998
994
|
...t,
|
|
999
995
|
currentPath: [
|
|
1000
996
|
...t.currentPath,
|
|
@@ -1004,65 +1000,67 @@ function Yt(e, t) {
|
|
|
1004
1000
|
})).reduce((e, t) => t === void 0 ? e : [...e, t], [])
|
|
1005
1001
|
};
|
|
1006
1002
|
}
|
|
1007
|
-
function
|
|
1008
|
-
return { not:
|
|
1003
|
+
function Nt() {
|
|
1004
|
+
return { not: V() };
|
|
1009
1005
|
}
|
|
1010
|
-
function
|
|
1011
|
-
return
|
|
1006
|
+
function Pt() {
|
|
1007
|
+
return V();
|
|
1012
1008
|
}
|
|
1013
|
-
var
|
|
1009
|
+
var Ft = (e, t) => K(e.innerType._def, t), It = (e, t, n) => {
|
|
1014
1010
|
switch (t) {
|
|
1015
|
-
case "ZodString": return
|
|
1016
|
-
case "ZodNumber": return
|
|
1017
|
-
case "ZodObject": return
|
|
1018
|
-
case "ZodBigInt": return
|
|
1019
|
-
case "ZodBoolean": return
|
|
1020
|
-
case "ZodDate": return
|
|
1021
|
-
case "ZodUndefined": return
|
|
1022
|
-
case "ZodNull": return
|
|
1023
|
-
case "ZodArray": return
|
|
1011
|
+
case "ZodString": return ut(e, n);
|
|
1012
|
+
case "ZodNumber": return wt(e);
|
|
1013
|
+
case "ZodObject": return Tt(e, n);
|
|
1014
|
+
case "ZodBigInt": return Qe(e);
|
|
1015
|
+
case "ZodBoolean": return $e();
|
|
1016
|
+
case "ZodDate": return nt(e, n);
|
|
1017
|
+
case "ZodUndefined": return Nt();
|
|
1018
|
+
case "ZodNull": return yt();
|
|
1019
|
+
case "ZodArray": return Ze(e, n);
|
|
1024
1020
|
case "ZodUnion":
|
|
1025
|
-
case "ZodDiscriminatedUnion": return
|
|
1026
|
-
case "ZodIntersection": return
|
|
1027
|
-
case "ZodTuple": return
|
|
1028
|
-
case "ZodRecord": return
|
|
1029
|
-
case "ZodLiteral": return
|
|
1030
|
-
case "ZodEnum": return
|
|
1031
|
-
case "ZodNativeEnum": return
|
|
1032
|
-
case "ZodNullable": return
|
|
1033
|
-
case "ZodOptional": return
|
|
1034
|
-
case "ZodMap": return
|
|
1035
|
-
case "ZodSet": return
|
|
1021
|
+
case "ZodDiscriminatedUnion": return xt(e, n);
|
|
1022
|
+
case "ZodIntersection": return st(e, n);
|
|
1023
|
+
case "ZodTuple": return Mt(e, n);
|
|
1024
|
+
case "ZodRecord": return ht(e, n);
|
|
1025
|
+
case "ZodLiteral": return ct(e);
|
|
1026
|
+
case "ZodEnum": return H(e);
|
|
1027
|
+
case "ZodNativeEnum": return _t(e);
|
|
1028
|
+
case "ZodNullable": return Ct(e, n);
|
|
1029
|
+
case "ZodOptional": return Ot(e, n);
|
|
1030
|
+
case "ZodMap": return gt(e, n);
|
|
1031
|
+
case "ZodSet": return jt(e, n);
|
|
1036
1032
|
case "ZodLazy": return () => e.getter()._def;
|
|
1037
|
-
case "ZodPromise": return
|
|
1033
|
+
case "ZodPromise": return At(e, n);
|
|
1038
1034
|
case "ZodNaN":
|
|
1039
|
-
case "ZodNever": return
|
|
1040
|
-
case "ZodEffects": return
|
|
1041
|
-
case "ZodAny": return
|
|
1042
|
-
case "ZodUnknown": return
|
|
1043
|
-
case "ZodDefault": return
|
|
1044
|
-
case "ZodBranded": return
|
|
1045
|
-
case "ZodReadonly": return
|
|
1046
|
-
case "ZodCatch": return
|
|
1047
|
-
case "ZodPipeline": return
|
|
1035
|
+
case "ZodNever": return vt();
|
|
1036
|
+
case "ZodEffects": return at(e, n);
|
|
1037
|
+
case "ZodAny": return V();
|
|
1038
|
+
case "ZodUnknown": return Pt();
|
|
1039
|
+
case "ZodDefault": return it(e, n);
|
|
1040
|
+
case "ZodBranded": return et(e, n);
|
|
1041
|
+
case "ZodReadonly": return Ft(e, n);
|
|
1042
|
+
case "ZodCatch": return tt(e, n);
|
|
1043
|
+
case "ZodPipeline": return kt(e, n);
|
|
1048
1044
|
case "ZodFunction":
|
|
1049
1045
|
case "ZodVoid":
|
|
1050
1046
|
case "ZodSymbol": return;
|
|
1051
|
-
default:
|
|
1047
|
+
default:
|
|
1048
|
+
/* c8 ignore next */
|
|
1049
|
+
return ((e) => void 0)(t);
|
|
1052
1050
|
}
|
|
1053
|
-
},
|
|
1051
|
+
}, Lt = (e, t) => {
|
|
1054
1052
|
let n = 0;
|
|
1055
1053
|
for (; n < e.length && n < t.length && e[n] === t[n]; n++);
|
|
1056
1054
|
return [(e.length - n).toString(), ...t.slice(n)].join("/");
|
|
1057
1055
|
};
|
|
1058
|
-
function
|
|
1056
|
+
function K(e, t, n = !1) {
|
|
1059
1057
|
let r = t.seen.get(e);
|
|
1060
1058
|
if (t.override) {
|
|
1061
1059
|
let i = t.override?.(e, t, r, n);
|
|
1062
|
-
if (i !==
|
|
1060
|
+
if (i !== Je) return i;
|
|
1063
1061
|
}
|
|
1064
1062
|
if (r && !n) {
|
|
1065
|
-
let e =
|
|
1063
|
+
let e = Rt(r, t);
|
|
1066
1064
|
if (e !== void 0) return e;
|
|
1067
1065
|
}
|
|
1068
1066
|
let i = {
|
|
@@ -1071,22 +1069,22 @@ function U(e, t, n = !1) {
|
|
|
1071
1069
|
jsonSchema: void 0
|
|
1072
1070
|
};
|
|
1073
1071
|
t.seen.set(e, i);
|
|
1074
|
-
let a =
|
|
1075
|
-
if (o &&
|
|
1072
|
+
let a = It(e, e.typeName, t), o = typeof a == "function" ? K(a(), t) : a;
|
|
1073
|
+
if (o && zt(e, t, o), t.postProcess) {
|
|
1076
1074
|
let n = t.postProcess(o, e, t);
|
|
1077
1075
|
return i.jsonSchema = o, n;
|
|
1078
1076
|
}
|
|
1079
1077
|
return i.jsonSchema = o, o;
|
|
1080
1078
|
}
|
|
1081
|
-
var
|
|
1079
|
+
var Rt = (e, t) => {
|
|
1082
1080
|
switch (t.$refStrategy) {
|
|
1083
1081
|
case "root": return { $ref: e.path.join("/") };
|
|
1084
|
-
case "relative": return { $ref:
|
|
1082
|
+
case "relative": return { $ref: Lt(t.currentPath, e.path) };
|
|
1085
1083
|
case "none":
|
|
1086
|
-
case "seen": return e.path.length < t.currentPath.length && e.path.every((e, n) => t.currentPath[n] === e) ? (console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),
|
|
1084
|
+
case "seen": return e.path.length < t.currentPath.length && e.path.every((e, n) => t.currentPath[n] === e) ? (console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`), V()) : t.$refStrategy === "seen" ? V() : void 0;
|
|
1087
1085
|
}
|
|
1088
|
-
},
|
|
1089
|
-
let t =
|
|
1086
|
+
}, zt = (e, t, n) => (e.description && (n.description = e.description), n), Bt = (e) => {
|
|
1087
|
+
let t = Xe(e), n = t.name === void 0 ? t.basePath : [
|
|
1090
1088
|
...t.basePath,
|
|
1091
1089
|
t.definitionPath,
|
|
1092
1090
|
t.name
|
|
@@ -1105,25 +1103,25 @@ var tn = (e, t) => {
|
|
|
1105
1103
|
jsonSchema: void 0
|
|
1106
1104
|
}]))
|
|
1107
1105
|
};
|
|
1108
|
-
},
|
|
1109
|
-
let n =
|
|
1106
|
+
}, Vt = (e, t) => {
|
|
1107
|
+
let n = Bt(t), r = typeof t == "object" && t.definitions ? Object.entries(t.definitions).reduce((e, [t, r]) => ({
|
|
1110
1108
|
...e,
|
|
1111
|
-
[t]:
|
|
1109
|
+
[t]: K(r._def, {
|
|
1112
1110
|
...n,
|
|
1113
1111
|
currentPath: [
|
|
1114
1112
|
...n.basePath,
|
|
1115
1113
|
n.definitionPath,
|
|
1116
1114
|
t
|
|
1117
1115
|
]
|
|
1118
|
-
}, !0) ??
|
|
1119
|
-
}), {}) : void 0, i = typeof t == "string" ? t : t?.nameStrategy === "title" ? void 0 : t?.name, a =
|
|
1116
|
+
}, !0) ?? V()
|
|
1117
|
+
}), {}) : void 0, i = typeof t == "string" ? t : t?.nameStrategy === "title" ? void 0 : t?.name, a = K(e._def, i === void 0 ? n : {
|
|
1120
1118
|
...n,
|
|
1121
1119
|
currentPath: [
|
|
1122
1120
|
...n.basePath,
|
|
1123
1121
|
n.definitionPath,
|
|
1124
1122
|
i
|
|
1125
1123
|
]
|
|
1126
|
-
}, !1) ??
|
|
1124
|
+
}, !1) ?? V(), o = typeof t == "object" && t.name !== void 0 && t.nameStrategy === "title" ? t.name : void 0;
|
|
1127
1125
|
o !== void 0 && (a.title = o);
|
|
1128
1126
|
let s = i === void 0 ? r ? {
|
|
1129
1127
|
...a,
|
|
@@ -1140,14 +1138,14 @@ var tn = (e, t) => {
|
|
|
1140
1138
|
}
|
|
1141
1139
|
};
|
|
1142
1140
|
return s.$schema = "http://json-schema.org/draft-07/schema#", s;
|
|
1143
|
-
},
|
|
1144
|
-
function
|
|
1141
|
+
}, Ht = Symbol.for("vercel.ai.schema");
|
|
1142
|
+
function Ut(e) {
|
|
1145
1143
|
let t;
|
|
1146
1144
|
return () => (t ??= e(), t);
|
|
1147
1145
|
}
|
|
1148
|
-
function
|
|
1146
|
+
function Wt(e, { validate: t } = {}) {
|
|
1149
1147
|
return {
|
|
1150
|
-
[
|
|
1148
|
+
[Ht]: !0,
|
|
1151
1149
|
_type: void 0,
|
|
1152
1150
|
get jsonSchema() {
|
|
1153
1151
|
return typeof e == "function" && (e = e()), e;
|
|
@@ -1155,20 +1153,20 @@ function cn(e, { validate: t } = {}) {
|
|
|
1155
1153
|
validate: t
|
|
1156
1154
|
};
|
|
1157
1155
|
}
|
|
1158
|
-
function
|
|
1159
|
-
return typeof e == "object" && !!e &&
|
|
1156
|
+
function Gt(e) {
|
|
1157
|
+
return typeof e == "object" && !!e && Ht in e && e[Ht] === !0 && "jsonSchema" in e && "validate" in e;
|
|
1160
1158
|
}
|
|
1161
|
-
function
|
|
1162
|
-
return e == null ?
|
|
1159
|
+
function Kt(e) {
|
|
1160
|
+
return e == null ? Wt({
|
|
1163
1161
|
type: "object",
|
|
1164
1162
|
properties: {},
|
|
1165
1163
|
additionalProperties: !1
|
|
1166
|
-
}) :
|
|
1164
|
+
}) : Gt(e) ? e : "~standard" in e ? e["~standard"].vendor === "zod" ? Qt(e) : qt(e) : e();
|
|
1167
1165
|
}
|
|
1168
|
-
function
|
|
1169
|
-
return
|
|
1170
|
-
if (!
|
|
1171
|
-
return
|
|
1166
|
+
function qt(e) {
|
|
1167
|
+
return Wt(() => {
|
|
1168
|
+
if (!Jt(e)) throw Error(`Standard schema vendor '${e["~standard"].vendor}' does not support JSON Schema conversion.`);
|
|
1169
|
+
return qe(e["~standard"].jsonSchema.input({ target: "draft-07" }));
|
|
1172
1170
|
}, { validate: async (t) => {
|
|
1173
1171
|
let n = await e["~standard"].validate(t);
|
|
1174
1172
|
return "value" in n ? {
|
|
@@ -1176,19 +1174,19 @@ function dn(e) {
|
|
|
1176
1174
|
value: n.value
|
|
1177
1175
|
} : {
|
|
1178
1176
|
success: !1,
|
|
1179
|
-
error: new
|
|
1177
|
+
error: new A({
|
|
1180
1178
|
value: t,
|
|
1181
1179
|
cause: n.issues
|
|
1182
1180
|
})
|
|
1183
1181
|
};
|
|
1184
1182
|
} });
|
|
1185
1183
|
}
|
|
1186
|
-
function
|
|
1184
|
+
function Jt(e) {
|
|
1187
1185
|
return e["~standard"].jsonSchema != null;
|
|
1188
1186
|
}
|
|
1189
|
-
function
|
|
1187
|
+
function Yt(e, t) {
|
|
1190
1188
|
let n = t?.useReferences ?? !1;
|
|
1191
|
-
return
|
|
1189
|
+
return Wt(() => Vt(e, { $refStrategy: n ? "root" : "none" }), { validate: async (t) => {
|
|
1192
1190
|
let n = await e.safeParseAsync(t);
|
|
1193
1191
|
return n.success ? {
|
|
1194
1192
|
success: !0,
|
|
@@ -1199,9 +1197,9 @@ function pn(e, t) {
|
|
|
1199
1197
|
};
|
|
1200
1198
|
} });
|
|
1201
1199
|
}
|
|
1202
|
-
function
|
|
1200
|
+
function Xt(t, r) {
|
|
1203
1201
|
let i = r?.useReferences ?? !1;
|
|
1204
|
-
return
|
|
1202
|
+
return Wt(() => qe(e(t, {
|
|
1205
1203
|
target: "draft-7",
|
|
1206
1204
|
io: "input",
|
|
1207
1205
|
reused: i ? "ref" : "inline"
|
|
@@ -1216,27 +1214,27 @@ function mn(t, r) {
|
|
|
1216
1214
|
};
|
|
1217
1215
|
} });
|
|
1218
1216
|
}
|
|
1219
|
-
function
|
|
1217
|
+
function Zt(e) {
|
|
1220
1218
|
return "_zod" in e;
|
|
1221
1219
|
}
|
|
1222
|
-
function
|
|
1223
|
-
return
|
|
1220
|
+
function Qt(e, t) {
|
|
1221
|
+
return Zt(e) ? Xt(e, t) : Yt(e, t);
|
|
1224
1222
|
}
|
|
1225
|
-
async function
|
|
1226
|
-
let r = await
|
|
1223
|
+
async function $t({ value: e, schema: t, context: n }) {
|
|
1224
|
+
let r = await en({
|
|
1227
1225
|
value: e,
|
|
1228
1226
|
schema: t,
|
|
1229
1227
|
context: n
|
|
1230
1228
|
});
|
|
1231
|
-
if (!r.success) throw
|
|
1229
|
+
if (!r.success) throw A.wrap({
|
|
1232
1230
|
value: e,
|
|
1233
1231
|
cause: r.error,
|
|
1234
1232
|
context: n
|
|
1235
1233
|
});
|
|
1236
1234
|
return r.value;
|
|
1237
1235
|
}
|
|
1238
|
-
async function
|
|
1239
|
-
let r =
|
|
1236
|
+
async function en({ value: e, schema: t, context: n }) {
|
|
1237
|
+
let r = Kt(t);
|
|
1240
1238
|
try {
|
|
1241
1239
|
if (r.validate == null) return {
|
|
1242
1240
|
success: !0,
|
|
@@ -1250,7 +1248,7 @@ async function vn({ value: e, schema: t, context: n }) {
|
|
|
1250
1248
|
rawValue: e
|
|
1251
1249
|
} : {
|
|
1252
1250
|
success: !1,
|
|
1253
|
-
error:
|
|
1251
|
+
error: A.wrap({
|
|
1254
1252
|
value: e,
|
|
1255
1253
|
cause: t.error,
|
|
1256
1254
|
context: n
|
|
@@ -1260,7 +1258,7 @@ async function vn({ value: e, schema: t, context: n }) {
|
|
|
1260
1258
|
} catch (t) {
|
|
1261
1259
|
return {
|
|
1262
1260
|
success: !1,
|
|
1263
|
-
error:
|
|
1261
|
+
error: A.wrap({
|
|
1264
1262
|
value: e,
|
|
1265
1263
|
cause: t,
|
|
1266
1264
|
context: n
|
|
@@ -1269,21 +1267,21 @@ async function vn({ value: e, schema: t, context: n }) {
|
|
|
1269
1267
|
};
|
|
1270
1268
|
}
|
|
1271
1269
|
}
|
|
1272
|
-
async function
|
|
1270
|
+
async function tn({ text: e, schema: t }) {
|
|
1273
1271
|
try {
|
|
1274
|
-
let n =
|
|
1272
|
+
let n = Ke(e);
|
|
1275
1273
|
return t == null ? {
|
|
1276
1274
|
success: !0,
|
|
1277
1275
|
value: n,
|
|
1278
1276
|
rawValue: n
|
|
1279
|
-
} : await
|
|
1277
|
+
} : await en({
|
|
1280
1278
|
value: n,
|
|
1281
1279
|
schema: t
|
|
1282
1280
|
});
|
|
1283
1281
|
} catch (t) {
|
|
1284
1282
|
return {
|
|
1285
1283
|
success: !1,
|
|
1286
|
-
error:
|
|
1284
|
+
error: O.isInstance(t) ? t : new O({
|
|
1287
1285
|
text: e,
|
|
1288
1286
|
cause: t
|
|
1289
1287
|
}),
|
|
@@ -1291,56 +1289,42 @@ async function W({ text: e, schema: t }) {
|
|
|
1291
1289
|
};
|
|
1292
1290
|
}
|
|
1293
1291
|
}
|
|
1294
|
-
function
|
|
1295
|
-
return e.pipeThrough(new TextDecoderStream()).pipeThrough(new
|
|
1296
|
-
e !== "[DONE]" && n.enqueue(await
|
|
1292
|
+
function nn({ stream: e, schema: t }) {
|
|
1293
|
+
return e.pipeThrough(new TextDecoderStream()).pipeThrough(new Re()).pipeThrough(new TransformStream({ async transform({ data: e }, n) {
|
|
1294
|
+
e !== "[DONE]" && n.enqueue(await tn({
|
|
1297
1295
|
text: e,
|
|
1298
1296
|
schema: t
|
|
1299
1297
|
}));
|
|
1300
1298
|
} }));
|
|
1301
1299
|
}
|
|
1302
|
-
async function
|
|
1300
|
+
async function rn(e) {
|
|
1303
1301
|
return typeof e == "function" && (e = e()), e;
|
|
1304
1302
|
}
|
|
1305
1303
|
new TextDecoder();
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
enumerable: !0
|
|
1310
|
-
});
|
|
1311
|
-
}, Sn = "AI_InvalidArgumentError", Cn = `vercel.ai.error.${Sn}`, wn = Symbol.for(Cn), Tn, En, K = class extends (En = w, Tn = wn, En) {
|
|
1304
|
+
//#endregion
|
|
1305
|
+
//#region ../../node_modules/.pnpm/ai@7.0.123_zod@4.6.5/node_modules/ai/dist/index.js
|
|
1306
|
+
var an = "AI_InvalidArgumentError", on = `vercel.ai.error.${an}`, sn = Symbol.for(on), cn = class extends S {
|
|
1312
1307
|
constructor({ parameter: e, value: t, message: n }) {
|
|
1313
1308
|
super({
|
|
1314
|
-
name:
|
|
1309
|
+
name: an,
|
|
1315
1310
|
message: `Invalid argument for parameter ${e}: ${n}`
|
|
1316
|
-
}), this[
|
|
1317
|
-
}
|
|
1318
|
-
static isInstance(e) {
|
|
1319
|
-
return w.hasMarker(e, Cn);
|
|
1320
|
-
}
|
|
1321
|
-
}, Dn = "AI_NoObjectGeneratedError", On = `vercel.ai.error.${Dn}`, kn = Symbol.for(On), An, jn, q = class extends (jn = w, An = kn, jn) {
|
|
1322
|
-
constructor({ message: e = "No object generated.", cause: t, text: n, response: r, usage: i, finishReason: a }) {
|
|
1323
|
-
super({
|
|
1324
|
-
name: Dn,
|
|
1325
|
-
message: e,
|
|
1326
|
-
cause: t
|
|
1327
|
-
}), this[An] = !0, this.text = n, this.response = r, this.usage = i, this.finishReason = a;
|
|
1311
|
+
}), this[sn] = !0, this.parameter = e, this.value = t;
|
|
1328
1312
|
}
|
|
1329
1313
|
static isInstance(e) {
|
|
1330
|
-
return
|
|
1314
|
+
return S.hasMarker(e, on);
|
|
1331
1315
|
}
|
|
1332
|
-
},
|
|
1316
|
+
}, ln = "AI_UIMessageStreamError", un = `vercel.ai.error.${ln}`, dn = Symbol.for(un), q = class extends S {
|
|
1333
1317
|
constructor({ chunkType: e, chunkId: t, message: n }) {
|
|
1334
1318
|
super({
|
|
1335
|
-
name:
|
|
1319
|
+
name: ln,
|
|
1336
1320
|
message: n
|
|
1337
|
-
}), this[
|
|
1321
|
+
}), this[dn] = !0, this.chunkType = e, this.chunkId = t;
|
|
1338
1322
|
}
|
|
1339
1323
|
static isInstance(e) {
|
|
1340
|
-
return
|
|
1324
|
+
return S.hasMarker(e, un);
|
|
1341
1325
|
}
|
|
1342
1326
|
};
|
|
1343
|
-
function
|
|
1327
|
+
function fn(e, t) {
|
|
1344
1328
|
if (e === void 0 && t === void 0) return;
|
|
1345
1329
|
if (e === void 0) return t;
|
|
1346
1330
|
if (t === void 0) return e;
|
|
@@ -1349,11 +1333,11 @@ function Ln(e, t) {
|
|
|
1349
1333
|
let i = t[r];
|
|
1350
1334
|
if (i === void 0) continue;
|
|
1351
1335
|
let a = r in e ? e[r] : void 0, o = typeof i == "object" && !!i && !Array.isArray(i) && !(i instanceof Date) && !(i instanceof RegExp), s = typeof a == "object" && !!a && !Array.isArray(a) && !(a instanceof Date) && !(a instanceof RegExp);
|
|
1352
|
-
n[r] = o && s ?
|
|
1336
|
+
n[r] = o && s ? fn(a, i) : i;
|
|
1353
1337
|
}
|
|
1354
1338
|
return n;
|
|
1355
1339
|
}
|
|
1356
|
-
var
|
|
1340
|
+
var J = {
|
|
1357
1341
|
array: i,
|
|
1358
1342
|
boolean: m,
|
|
1359
1343
|
custom: o,
|
|
@@ -1371,242 +1355,236 @@ var Y = {
|
|
|
1371
1355
|
string: a,
|
|
1372
1356
|
union: _,
|
|
1373
1357
|
unknown: t
|
|
1374
|
-
},
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
])),
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
]),
|
|
1387
|
-
type:
|
|
1388
|
-
text:
|
|
1389
|
-
providerOptions:
|
|
1390
|
-
}),
|
|
1391
|
-
type:
|
|
1392
|
-
image:
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1358
|
+
}, Y = J.lazy(() => J.union([
|
|
1359
|
+
J.null(),
|
|
1360
|
+
J.string(),
|
|
1361
|
+
J.number(),
|
|
1362
|
+
J.boolean(),
|
|
1363
|
+
J.record(J.string(), Y.optional()),
|
|
1364
|
+
J.array(Y)
|
|
1365
|
+
])), X = J.record(J.string(), J.record(J.string(), Y.optional())), pn = J.union([
|
|
1366
|
+
J.string(),
|
|
1367
|
+
J.instanceof(Uint8Array),
|
|
1368
|
+
J.instanceof(ArrayBuffer),
|
|
1369
|
+
J.custom(Ve, { message: "Must be a Buffer" })
|
|
1370
|
+
]), mn = J.record(J.string(), J.string()), hn = J.object({
|
|
1371
|
+
type: J.literal("text"),
|
|
1372
|
+
text: J.string(),
|
|
1373
|
+
providerOptions: X.optional()
|
|
1374
|
+
}), gn = J.object({
|
|
1375
|
+
type: J.literal("image"),
|
|
1376
|
+
image: J.union([
|
|
1377
|
+
pn,
|
|
1378
|
+
J.instanceof(URL),
|
|
1379
|
+
mn
|
|
1396
1380
|
]),
|
|
1397
|
-
mediaType:
|
|
1398
|
-
providerOptions:
|
|
1399
|
-
}),
|
|
1400
|
-
|
|
1401
|
-
type:
|
|
1402
|
-
data:
|
|
1381
|
+
mediaType: J.string().optional(),
|
|
1382
|
+
providerOptions: X.optional()
|
|
1383
|
+
}), _n = J.discriminatedUnion("type", [
|
|
1384
|
+
J.object({
|
|
1385
|
+
type: J.literal("data"),
|
|
1386
|
+
data: pn
|
|
1403
1387
|
}),
|
|
1404
|
-
|
|
1405
|
-
type:
|
|
1406
|
-
url:
|
|
1388
|
+
J.object({
|
|
1389
|
+
type: J.literal("url"),
|
|
1390
|
+
url: J.instanceof(URL)
|
|
1407
1391
|
}),
|
|
1408
|
-
|
|
1409
|
-
type:
|
|
1410
|
-
reference:
|
|
1392
|
+
J.object({
|
|
1393
|
+
type: J.literal("reference"),
|
|
1394
|
+
reference: mn
|
|
1411
1395
|
}),
|
|
1412
|
-
|
|
1413
|
-
type:
|
|
1414
|
-
text:
|
|
1396
|
+
J.object({
|
|
1397
|
+
type: J.literal("text"),
|
|
1398
|
+
text: J.string()
|
|
1415
1399
|
})
|
|
1416
|
-
]),
|
|
1417
|
-
type:
|
|
1418
|
-
data:
|
|
1419
|
-
}),
|
|
1420
|
-
type:
|
|
1421
|
-
url:
|
|
1422
|
-
})]),
|
|
1423
|
-
type:
|
|
1424
|
-
data:
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1400
|
+
]), vn = J.discriminatedUnion("type", [J.object({
|
|
1401
|
+
type: J.literal("data"),
|
|
1402
|
+
data: pn
|
|
1403
|
+
}), J.object({
|
|
1404
|
+
type: J.literal("url"),
|
|
1405
|
+
url: J.instanceof(URL)
|
|
1406
|
+
})]), yn = J.object({
|
|
1407
|
+
type: J.literal("file"),
|
|
1408
|
+
data: J.union([
|
|
1409
|
+
_n,
|
|
1410
|
+
pn,
|
|
1411
|
+
J.instanceof(URL),
|
|
1412
|
+
mn
|
|
1429
1413
|
]),
|
|
1430
|
-
filename:
|
|
1431
|
-
mediaType:
|
|
1432
|
-
providerOptions:
|
|
1433
|
-
}),
|
|
1434
|
-
type:
|
|
1435
|
-
text:
|
|
1436
|
-
providerOptions:
|
|
1437
|
-
}),
|
|
1438
|
-
type:
|
|
1439
|
-
kind:
|
|
1440
|
-
providerOptions:
|
|
1441
|
-
}),
|
|
1442
|
-
type:
|
|
1443
|
-
data:
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1414
|
+
filename: J.string().optional(),
|
|
1415
|
+
mediaType: J.string(),
|
|
1416
|
+
providerOptions: X.optional()
|
|
1417
|
+
}), bn = J.object({
|
|
1418
|
+
type: J.literal("reasoning"),
|
|
1419
|
+
text: J.string(),
|
|
1420
|
+
providerOptions: X.optional()
|
|
1421
|
+
}), xn = J.object({
|
|
1422
|
+
type: J.literal("custom"),
|
|
1423
|
+
kind: J.string().transform((e) => e),
|
|
1424
|
+
providerOptions: X.optional()
|
|
1425
|
+
}), Sn = J.object({
|
|
1426
|
+
type: J.literal("reasoning-file"),
|
|
1427
|
+
data: J.union([
|
|
1428
|
+
vn,
|
|
1429
|
+
pn,
|
|
1430
|
+
J.instanceof(URL)
|
|
1447
1431
|
]),
|
|
1448
|
-
mediaType:
|
|
1449
|
-
providerOptions:
|
|
1450
|
-
}),
|
|
1451
|
-
type:
|
|
1452
|
-
toolCallId:
|
|
1453
|
-
toolName:
|
|
1454
|
-
input:
|
|
1455
|
-
providerOptions:
|
|
1456
|
-
providerExecuted:
|
|
1457
|
-
}),
|
|
1458
|
-
|
|
1459
|
-
type:
|
|
1460
|
-
value:
|
|
1461
|
-
providerOptions:
|
|
1432
|
+
mediaType: J.string(),
|
|
1433
|
+
providerOptions: X.optional()
|
|
1434
|
+
}), Cn = J.object({
|
|
1435
|
+
type: J.literal("tool-call"),
|
|
1436
|
+
toolCallId: J.string(),
|
|
1437
|
+
toolName: J.string(),
|
|
1438
|
+
input: J.unknown(),
|
|
1439
|
+
providerOptions: X.optional(),
|
|
1440
|
+
providerExecuted: J.boolean().optional()
|
|
1441
|
+
}), wn = J.discriminatedUnion("type", [
|
|
1442
|
+
J.object({
|
|
1443
|
+
type: J.literal("text"),
|
|
1444
|
+
value: J.string(),
|
|
1445
|
+
providerOptions: X.optional()
|
|
1462
1446
|
}),
|
|
1463
|
-
|
|
1464
|
-
type:
|
|
1465
|
-
value:
|
|
1466
|
-
providerOptions:
|
|
1447
|
+
J.object({
|
|
1448
|
+
type: J.literal("json"),
|
|
1449
|
+
value: Y,
|
|
1450
|
+
providerOptions: X.optional()
|
|
1467
1451
|
}),
|
|
1468
|
-
|
|
1469
|
-
type:
|
|
1470
|
-
reason:
|
|
1471
|
-
providerOptions:
|
|
1452
|
+
J.object({
|
|
1453
|
+
type: J.literal("execution-denied"),
|
|
1454
|
+
reason: J.string().optional(),
|
|
1455
|
+
providerOptions: X.optional()
|
|
1472
1456
|
}),
|
|
1473
|
-
|
|
1474
|
-
type:
|
|
1475
|
-
value:
|
|
1476
|
-
providerOptions:
|
|
1457
|
+
J.object({
|
|
1458
|
+
type: J.literal("error-text"),
|
|
1459
|
+
value: J.string(),
|
|
1460
|
+
providerOptions: X.optional()
|
|
1477
1461
|
}),
|
|
1478
|
-
|
|
1479
|
-
type:
|
|
1480
|
-
value:
|
|
1481
|
-
providerOptions:
|
|
1462
|
+
J.object({
|
|
1463
|
+
type: J.literal("error-json"),
|
|
1464
|
+
value: Y,
|
|
1465
|
+
providerOptions: X.optional()
|
|
1482
1466
|
}),
|
|
1483
|
-
|
|
1484
|
-
type:
|
|
1485
|
-
value:
|
|
1486
|
-
|
|
1487
|
-
type:
|
|
1488
|
-
text:
|
|
1489
|
-
providerOptions:
|
|
1467
|
+
J.object({
|
|
1468
|
+
type: J.literal("content"),
|
|
1469
|
+
value: J.array(J.union([
|
|
1470
|
+
J.object({
|
|
1471
|
+
type: J.literal("text"),
|
|
1472
|
+
text: J.string(),
|
|
1473
|
+
providerOptions: X.optional()
|
|
1490
1474
|
}),
|
|
1491
|
-
|
|
1492
|
-
type:
|
|
1493
|
-
data:
|
|
1494
|
-
mediaType:
|
|
1495
|
-
filename:
|
|
1496
|
-
providerOptions:
|
|
1475
|
+
J.object({
|
|
1476
|
+
type: J.literal("file"),
|
|
1477
|
+
data: _n,
|
|
1478
|
+
mediaType: J.string(),
|
|
1479
|
+
filename: J.string().optional(),
|
|
1480
|
+
providerOptions: X.optional()
|
|
1497
1481
|
}),
|
|
1498
|
-
|
|
1499
|
-
type:
|
|
1500
|
-
data:
|
|
1501
|
-
mediaType:
|
|
1502
|
-
filename:
|
|
1503
|
-
providerOptions:
|
|
1482
|
+
J.object({
|
|
1483
|
+
type: J.literal("file-data"),
|
|
1484
|
+
data: J.string(),
|
|
1485
|
+
mediaType: J.string(),
|
|
1486
|
+
filename: J.string().optional(),
|
|
1487
|
+
providerOptions: X.optional()
|
|
1504
1488
|
}),
|
|
1505
|
-
|
|
1506
|
-
type:
|
|
1507
|
-
url:
|
|
1508
|
-
mediaType:
|
|
1509
|
-
providerOptions:
|
|
1489
|
+
J.object({
|
|
1490
|
+
type: J.literal("file-url"),
|
|
1491
|
+
url: J.string(),
|
|
1492
|
+
mediaType: J.string().optional(),
|
|
1493
|
+
providerOptions: X.optional()
|
|
1510
1494
|
}),
|
|
1511
|
-
|
|
1512
|
-
type:
|
|
1513
|
-
fileId:
|
|
1514
|
-
providerOptions:
|
|
1495
|
+
J.object({
|
|
1496
|
+
type: J.literal("file-id"),
|
|
1497
|
+
fileId: J.union([J.string(), J.record(J.string(), J.string())]),
|
|
1498
|
+
providerOptions: X.optional()
|
|
1515
1499
|
}),
|
|
1516
|
-
|
|
1517
|
-
type:
|
|
1518
|
-
providerReference:
|
|
1519
|
-
providerOptions:
|
|
1500
|
+
J.object({
|
|
1501
|
+
type: J.literal("file-reference"),
|
|
1502
|
+
providerReference: J.record(J.string(), J.string()),
|
|
1503
|
+
providerOptions: X.optional()
|
|
1520
1504
|
}),
|
|
1521
|
-
|
|
1522
|
-
type:
|
|
1523
|
-
data:
|
|
1524
|
-
mediaType:
|
|
1525
|
-
providerOptions:
|
|
1505
|
+
J.object({
|
|
1506
|
+
type: J.literal("image-data"),
|
|
1507
|
+
data: J.string(),
|
|
1508
|
+
mediaType: J.string(),
|
|
1509
|
+
providerOptions: X.optional()
|
|
1526
1510
|
}),
|
|
1527
|
-
|
|
1528
|
-
type:
|
|
1529
|
-
url:
|
|
1530
|
-
providerOptions:
|
|
1511
|
+
J.object({
|
|
1512
|
+
type: J.literal("image-url"),
|
|
1513
|
+
url: J.string(),
|
|
1514
|
+
providerOptions: X.optional()
|
|
1531
1515
|
}),
|
|
1532
|
-
|
|
1533
|
-
type:
|
|
1534
|
-
fileId:
|
|
1535
|
-
providerOptions:
|
|
1516
|
+
J.object({
|
|
1517
|
+
type: J.literal("image-file-id"),
|
|
1518
|
+
fileId: J.union([J.string(), J.record(J.string(), J.string())]),
|
|
1519
|
+
providerOptions: X.optional()
|
|
1536
1520
|
}),
|
|
1537
|
-
|
|
1538
|
-
type:
|
|
1539
|
-
providerReference:
|
|
1540
|
-
providerOptions:
|
|
1521
|
+
J.object({
|
|
1522
|
+
type: J.literal("image-file-reference"),
|
|
1523
|
+
providerReference: J.record(J.string(), J.string()),
|
|
1524
|
+
providerOptions: X.optional()
|
|
1541
1525
|
}),
|
|
1542
|
-
|
|
1543
|
-
type:
|
|
1544
|
-
providerOptions:
|
|
1526
|
+
J.object({
|
|
1527
|
+
type: J.literal("custom"),
|
|
1528
|
+
providerOptions: X.optional()
|
|
1545
1529
|
})
|
|
1546
1530
|
]))
|
|
1547
1531
|
})
|
|
1548
|
-
]),
|
|
1549
|
-
type:
|
|
1550
|
-
toolCallId:
|
|
1551
|
-
toolName:
|
|
1552
|
-
output:
|
|
1553
|
-
providerOptions:
|
|
1554
|
-
}),
|
|
1555
|
-
type:
|
|
1556
|
-
approvalId:
|
|
1557
|
-
toolCallId:
|
|
1558
|
-
reason:
|
|
1559
|
-
isAutomatic:
|
|
1560
|
-
signature:
|
|
1561
|
-
inputSchemaInput:
|
|
1562
|
-
}),
|
|
1563
|
-
type:
|
|
1564
|
-
approvalId:
|
|
1565
|
-
approved:
|
|
1566
|
-
reason:
|
|
1567
|
-
}),
|
|
1568
|
-
role:
|
|
1569
|
-
content:
|
|
1570
|
-
providerOptions:
|
|
1571
|
-
}),
|
|
1572
|
-
role:
|
|
1573
|
-
content:
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1532
|
+
]), Tn = J.object({
|
|
1533
|
+
type: J.literal("tool-result"),
|
|
1534
|
+
toolCallId: J.string(),
|
|
1535
|
+
toolName: J.string(),
|
|
1536
|
+
output: wn,
|
|
1537
|
+
providerOptions: X.optional()
|
|
1538
|
+
}), En = J.object({
|
|
1539
|
+
type: J.literal("tool-approval-request"),
|
|
1540
|
+
approvalId: J.string(),
|
|
1541
|
+
toolCallId: J.string(),
|
|
1542
|
+
reason: J.string().optional(),
|
|
1543
|
+
isAutomatic: J.boolean().optional(),
|
|
1544
|
+
signature: J.string().optional(),
|
|
1545
|
+
inputSchemaInput: J.unknown().optional()
|
|
1546
|
+
}), Dn = J.object({
|
|
1547
|
+
type: J.literal("tool-approval-response"),
|
|
1548
|
+
approvalId: J.string(),
|
|
1549
|
+
approved: J.boolean(),
|
|
1550
|
+
reason: J.string().optional()
|
|
1551
|
+
}), On = J.object({
|
|
1552
|
+
role: J.literal("system"),
|
|
1553
|
+
content: J.string(),
|
|
1554
|
+
providerOptions: X.optional()
|
|
1555
|
+
}), kn = J.object({
|
|
1556
|
+
role: J.literal("user"),
|
|
1557
|
+
content: J.union([J.string(), J.array(J.union([
|
|
1558
|
+
hn,
|
|
1559
|
+
gn,
|
|
1560
|
+
yn
|
|
1577
1561
|
]))]),
|
|
1578
|
-
providerOptions:
|
|
1579
|
-
}),
|
|
1580
|
-
role:
|
|
1581
|
-
content:
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1562
|
+
providerOptions: X.optional()
|
|
1563
|
+
}), An = J.object({
|
|
1564
|
+
role: J.literal("assistant"),
|
|
1565
|
+
content: J.union([J.string(), J.array(J.union([
|
|
1566
|
+
hn,
|
|
1567
|
+
xn,
|
|
1568
|
+
yn,
|
|
1569
|
+
bn,
|
|
1570
|
+
Sn,
|
|
1571
|
+
Cn,
|
|
1572
|
+
Tn,
|
|
1573
|
+
En
|
|
1590
1574
|
]))]),
|
|
1591
|
-
providerOptions:
|
|
1592
|
-
}),
|
|
1593
|
-
role:
|
|
1594
|
-
content:
|
|
1595
|
-
providerOptions:
|
|
1596
|
-
});
|
|
1597
|
-
Y.union([
|
|
1598
|
-
$n,
|
|
1599
|
-
er,
|
|
1600
|
-
tr,
|
|
1601
|
-
nr
|
|
1602
|
-
]), xn({}, {
|
|
1603
|
-
array: () => sr,
|
|
1604
|
-
choice: () => ur,
|
|
1605
|
-
json: () => dr,
|
|
1606
|
-
object: () => or,
|
|
1607
|
-
text: () => ar
|
|
1575
|
+
providerOptions: X.optional()
|
|
1576
|
+
}), jn = J.object({
|
|
1577
|
+
role: J.literal("tool"),
|
|
1578
|
+
content: J.array(J.union([Tn, Dn])),
|
|
1579
|
+
providerOptions: X.optional()
|
|
1608
1580
|
});
|
|
1609
|
-
|
|
1581
|
+
J.union([
|
|
1582
|
+
On,
|
|
1583
|
+
kn,
|
|
1584
|
+
An,
|
|
1585
|
+
jn
|
|
1586
|
+
]);
|
|
1587
|
+
function Mn(e) {
|
|
1610
1588
|
let t = ["ROOT"], n = -1, r = null, i = 0;
|
|
1611
1589
|
function a(e) {
|
|
1612
1590
|
return e >= "0" && e <= "9" || e >= "A" && e <= "F" || e >= "a" && e <= "f";
|
|
@@ -1788,16 +1766,16 @@ function rr(e) {
|
|
|
1788
1766
|
}
|
|
1789
1767
|
return l;
|
|
1790
1768
|
}
|
|
1791
|
-
async function
|
|
1769
|
+
async function Nn(e) {
|
|
1792
1770
|
if (e === void 0) return {
|
|
1793
1771
|
value: void 0,
|
|
1794
1772
|
state: "undefined-input"
|
|
1795
1773
|
};
|
|
1796
|
-
let t = await
|
|
1774
|
+
let t = await tn({ text: e });
|
|
1797
1775
|
return t.success ? {
|
|
1798
1776
|
value: t.value,
|
|
1799
1777
|
state: "successful-parse"
|
|
1800
|
-
} : (t = await
|
|
1778
|
+
} : (t = await tn({ text: Mn(e) }), t.success ? {
|
|
1801
1779
|
value: t.value,
|
|
1802
1780
|
state: "repaired-parse"
|
|
1803
1781
|
} : {
|
|
@@ -1805,471 +1783,178 @@ async function ir(e) {
|
|
|
1805
1783
|
state: "failed-parse"
|
|
1806
1784
|
});
|
|
1807
1785
|
}
|
|
1808
|
-
|
|
1809
|
-
name: "text",
|
|
1810
|
-
responseFormat: Promise.resolve({ type: "text" }),
|
|
1811
|
-
async parseCompleteOutput({ text: e }) {
|
|
1812
|
-
return e;
|
|
1813
|
-
},
|
|
1814
|
-
async parsePartialOutput({ text: e }) {
|
|
1815
|
-
return { partial: e };
|
|
1816
|
-
},
|
|
1817
|
-
createElementStreamTransform() {}
|
|
1818
|
-
}), or = ({ schema: e, name: t, description: n }) => {
|
|
1819
|
-
let r = un(e);
|
|
1820
|
-
return {
|
|
1821
|
-
name: "object",
|
|
1822
|
-
responseFormat: G(r.jsonSchema).then((e) => ({
|
|
1823
|
-
type: "json",
|
|
1824
|
-
schema: e,
|
|
1825
|
-
...t != null && { name: t },
|
|
1826
|
-
...n != null && { description: n }
|
|
1827
|
-
})),
|
|
1828
|
-
async parseCompleteOutput({ text: e }, t) {
|
|
1829
|
-
let n = await W({ text: e });
|
|
1830
|
-
if (!n.success) throw new q({
|
|
1831
|
-
message: "No object generated: could not parse the response.",
|
|
1832
|
-
cause: n.error,
|
|
1833
|
-
text: e,
|
|
1834
|
-
response: t.response,
|
|
1835
|
-
usage: t.usage,
|
|
1836
|
-
finishReason: t.finishReason
|
|
1837
|
-
});
|
|
1838
|
-
let i = await vn({
|
|
1839
|
-
value: n.value,
|
|
1840
|
-
schema: r
|
|
1841
|
-
});
|
|
1842
|
-
if (!i.success) throw new q({
|
|
1843
|
-
message: "No object generated: response did not match schema.",
|
|
1844
|
-
cause: i.error,
|
|
1845
|
-
text: e,
|
|
1846
|
-
response: t.response,
|
|
1847
|
-
usage: t.usage,
|
|
1848
|
-
finishReason: t.finishReason
|
|
1849
|
-
});
|
|
1850
|
-
return i.value;
|
|
1851
|
-
},
|
|
1852
|
-
async parsePartialOutput({ text: e }) {
|
|
1853
|
-
let t = await ir(e);
|
|
1854
|
-
switch (t.state) {
|
|
1855
|
-
case "failed-parse":
|
|
1856
|
-
case "undefined-input": return;
|
|
1857
|
-
case "repaired-parse":
|
|
1858
|
-
case "successful-parse": return { partial: t.value };
|
|
1859
|
-
}
|
|
1860
|
-
},
|
|
1861
|
-
createElementStreamTransform() {}
|
|
1862
|
-
};
|
|
1863
|
-
}, sr = ({ element: e, minItems: t, maxItems: n, name: r, description: i }) => {
|
|
1864
|
-
if (cr({
|
|
1865
|
-
name: "minItems",
|
|
1866
|
-
value: t
|
|
1867
|
-
}), cr({
|
|
1868
|
-
name: "maxItems",
|
|
1869
|
-
value: n
|
|
1870
|
-
}), t != null && n != null && t > n) throw new K({
|
|
1871
|
-
parameter: "minItems",
|
|
1872
|
-
value: t,
|
|
1873
|
-
message: "minItems must be less than or equal to maxItems"
|
|
1874
|
-
});
|
|
1875
|
-
let a = un(e);
|
|
1876
|
-
return {
|
|
1877
|
-
name: "array",
|
|
1878
|
-
responseFormat: G(a.jsonSchema).then((e) => {
|
|
1879
|
-
let { $schema: a, definitions: o, $defs: s, ...c } = e;
|
|
1880
|
-
return {
|
|
1881
|
-
type: "json",
|
|
1882
|
-
schema: {
|
|
1883
|
-
$schema: "http://json-schema.org/draft-07/schema#",
|
|
1884
|
-
...o != null && { definitions: o },
|
|
1885
|
-
...s != null && { $defs: s },
|
|
1886
|
-
type: "object",
|
|
1887
|
-
properties: { elements: {
|
|
1888
|
-
type: "array",
|
|
1889
|
-
items: c,
|
|
1890
|
-
...t != null && { minItems: t },
|
|
1891
|
-
...n != null && { maxItems: n }
|
|
1892
|
-
} },
|
|
1893
|
-
required: ["elements"],
|
|
1894
|
-
additionalProperties: !1
|
|
1895
|
-
},
|
|
1896
|
-
...r != null && { name: r },
|
|
1897
|
-
...i != null && { description: i }
|
|
1898
|
-
};
|
|
1899
|
-
}),
|
|
1900
|
-
async parseCompleteOutput({ text: e }, r) {
|
|
1901
|
-
let i = await W({ text: e });
|
|
1902
|
-
if (!i.success) throw new q({
|
|
1903
|
-
message: "No object generated: could not parse the response.",
|
|
1904
|
-
cause: i.error,
|
|
1905
|
-
text: e,
|
|
1906
|
-
response: r.response,
|
|
1907
|
-
usage: r.usage,
|
|
1908
|
-
finishReason: r.finishReason
|
|
1909
|
-
});
|
|
1910
|
-
let o = i.value;
|
|
1911
|
-
if (typeof o != "object" || !o || !("elements" in o) || !Array.isArray(o.elements)) throw new q({
|
|
1912
|
-
message: "No object generated: response did not match schema.",
|
|
1913
|
-
cause: new N({
|
|
1914
|
-
value: o,
|
|
1915
|
-
cause: "response must be an object with an elements array"
|
|
1916
|
-
}),
|
|
1917
|
-
text: e,
|
|
1918
|
-
response: r.response,
|
|
1919
|
-
usage: r.usage,
|
|
1920
|
-
finishReason: r.finishReason
|
|
1921
|
-
});
|
|
1922
|
-
let s = lr({
|
|
1923
|
-
value: o.elements,
|
|
1924
|
-
minItems: t,
|
|
1925
|
-
maxItems: n
|
|
1926
|
-
});
|
|
1927
|
-
if (s != null) throw new q({
|
|
1928
|
-
message: "No object generated: response did not match schema.",
|
|
1929
|
-
cause: s,
|
|
1930
|
-
text: e,
|
|
1931
|
-
response: r.response,
|
|
1932
|
-
usage: r.usage,
|
|
1933
|
-
finishReason: r.finishReason
|
|
1934
|
-
});
|
|
1935
|
-
let c = [];
|
|
1936
|
-
for (let t of o.elements) {
|
|
1937
|
-
let n = await vn({
|
|
1938
|
-
value: t,
|
|
1939
|
-
schema: a
|
|
1940
|
-
});
|
|
1941
|
-
if (!n.success) throw new q({
|
|
1942
|
-
message: "No object generated: response did not match schema.",
|
|
1943
|
-
cause: n.error,
|
|
1944
|
-
text: e,
|
|
1945
|
-
response: r.response,
|
|
1946
|
-
usage: r.usage,
|
|
1947
|
-
finishReason: r.finishReason
|
|
1948
|
-
});
|
|
1949
|
-
c.push(n.value);
|
|
1950
|
-
}
|
|
1951
|
-
return c;
|
|
1952
|
-
},
|
|
1953
|
-
async parsePartialOutput({ text: e }) {
|
|
1954
|
-
let t = await ir(e);
|
|
1955
|
-
switch (t.state) {
|
|
1956
|
-
case "failed-parse":
|
|
1957
|
-
case "undefined-input": return;
|
|
1958
|
-
case "repaired-parse":
|
|
1959
|
-
case "successful-parse": {
|
|
1960
|
-
let e = t.value;
|
|
1961
|
-
if (typeof e != "object" || !e || !("elements" in e) || !Array.isArray(e.elements)) return;
|
|
1962
|
-
let n = t.state === "repaired-parse" && e.elements.length > 0 ? e.elements.slice(0, -1) : e.elements, r = [];
|
|
1963
|
-
for (let e of n) {
|
|
1964
|
-
let t = await vn({
|
|
1965
|
-
value: e,
|
|
1966
|
-
schema: a
|
|
1967
|
-
});
|
|
1968
|
-
t.success && r.push(t.value);
|
|
1969
|
-
}
|
|
1970
|
-
return { partial: r };
|
|
1971
|
-
}
|
|
1972
|
-
}
|
|
1973
|
-
},
|
|
1974
|
-
createElementStreamTransform() {
|
|
1975
|
-
let e = 0;
|
|
1976
|
-
return new TransformStream({ transform({ partialOutput: t }, r) {
|
|
1977
|
-
if (t != null) for (; e < t.length; e++) {
|
|
1978
|
-
if (n != null && e >= n) {
|
|
1979
|
-
r.error(lr({
|
|
1980
|
-
value: t,
|
|
1981
|
-
maxItems: n
|
|
1982
|
-
}));
|
|
1983
|
-
return;
|
|
1984
|
-
}
|
|
1985
|
-
r.enqueue(t[e]);
|
|
1986
|
-
}
|
|
1987
|
-
} });
|
|
1988
|
-
}
|
|
1989
|
-
};
|
|
1990
|
-
};
|
|
1991
|
-
function cr({ name: e, value: t }) {
|
|
1992
|
-
if (t != null) {
|
|
1993
|
-
if (!Number.isInteger(t)) throw new K({
|
|
1994
|
-
parameter: e,
|
|
1995
|
-
value: t,
|
|
1996
|
-
message: `${e} must be an integer`
|
|
1997
|
-
});
|
|
1998
|
-
if (t < 0) throw new K({
|
|
1999
|
-
parameter: e,
|
|
2000
|
-
value: t,
|
|
2001
|
-
message: `${e} must be greater than or equal to 0`
|
|
2002
|
-
});
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
function lr({ value: e, minItems: t, maxItems: n }) {
|
|
2006
|
-
if (t != null && e.length < t) return new N({
|
|
2007
|
-
value: e,
|
|
2008
|
-
cause: `elements array must contain at least ${t} items`
|
|
2009
|
-
});
|
|
2010
|
-
if (n != null && e.length > n) return new N({
|
|
2011
|
-
value: e,
|
|
2012
|
-
cause: `elements array must contain at most ${n} items`
|
|
2013
|
-
});
|
|
2014
|
-
}
|
|
2015
|
-
var ur = ({ options: e, name: t, description: n }) => ({
|
|
2016
|
-
name: "choice",
|
|
2017
|
-
responseFormat: Promise.resolve({
|
|
2018
|
-
type: "json",
|
|
2019
|
-
schema: {
|
|
2020
|
-
$schema: "http://json-schema.org/draft-07/schema#",
|
|
2021
|
-
type: "object",
|
|
2022
|
-
properties: { result: {
|
|
2023
|
-
type: "string",
|
|
2024
|
-
enum: e
|
|
2025
|
-
} },
|
|
2026
|
-
required: ["result"],
|
|
2027
|
-
additionalProperties: !1
|
|
2028
|
-
},
|
|
2029
|
-
...t != null && { name: t },
|
|
2030
|
-
...n != null && { description: n }
|
|
2031
|
-
}),
|
|
2032
|
-
async parseCompleteOutput({ text: t }, n) {
|
|
2033
|
-
let r = await W({ text: t });
|
|
2034
|
-
if (!r.success) throw new q({
|
|
2035
|
-
message: "No object generated: could not parse the response.",
|
|
2036
|
-
cause: r.error,
|
|
2037
|
-
text: t,
|
|
2038
|
-
response: n.response,
|
|
2039
|
-
usage: n.usage,
|
|
2040
|
-
finishReason: n.finishReason
|
|
2041
|
-
});
|
|
2042
|
-
let i = r.value;
|
|
2043
|
-
if (typeof i != "object" || !i || !("result" in i) || typeof i.result != "string" || !e.includes(i.result)) throw new q({
|
|
2044
|
-
message: "No object generated: response did not match schema.",
|
|
2045
|
-
cause: new N({
|
|
2046
|
-
value: i,
|
|
2047
|
-
cause: "response must be an object that contains a choice value."
|
|
2048
|
-
}),
|
|
2049
|
-
text: t,
|
|
2050
|
-
response: n.response,
|
|
2051
|
-
usage: n.usage,
|
|
2052
|
-
finishReason: n.finishReason
|
|
2053
|
-
});
|
|
2054
|
-
return i.result;
|
|
2055
|
-
},
|
|
2056
|
-
async parsePartialOutput({ text: t }) {
|
|
2057
|
-
let n = await ir(t);
|
|
2058
|
-
switch (n.state) {
|
|
2059
|
-
case "failed-parse":
|
|
2060
|
-
case "undefined-input": return;
|
|
2061
|
-
case "repaired-parse":
|
|
2062
|
-
case "successful-parse": {
|
|
2063
|
-
let t = n.value;
|
|
2064
|
-
if (typeof t != "object" || !t || !("result" in t) || typeof t.result != "string") return;
|
|
2065
|
-
let r = e.filter((e) => e.startsWith(t.result));
|
|
2066
|
-
return n.state === "successful-parse" ? r.includes(t.result) ? { partial: t.result } : void 0 : r.length === 1 ? { partial: r[0] } : void 0;
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
},
|
|
2070
|
-
createElementStreamTransform() {}
|
|
2071
|
-
}), dr = ({ name: e, description: t } = {}) => ({
|
|
2072
|
-
name: "json",
|
|
2073
|
-
responseFormat: Promise.resolve({
|
|
2074
|
-
type: "json",
|
|
2075
|
-
...e != null && { name: e },
|
|
2076
|
-
...t != null && { description: t }
|
|
2077
|
-
}),
|
|
2078
|
-
async parseCompleteOutput({ text: e }, t) {
|
|
2079
|
-
let n = await W({ text: e });
|
|
2080
|
-
if (!n.success) throw new q({
|
|
2081
|
-
message: "No object generated: could not parse the response.",
|
|
2082
|
-
cause: n.error,
|
|
2083
|
-
text: e,
|
|
2084
|
-
response: t.response,
|
|
2085
|
-
usage: t.usage,
|
|
2086
|
-
finishReason: t.finishReason
|
|
2087
|
-
});
|
|
2088
|
-
return n.value;
|
|
2089
|
-
},
|
|
2090
|
-
async parsePartialOutput({ text: e }) {
|
|
2091
|
-
let t = await ir(e);
|
|
2092
|
-
switch (t.state) {
|
|
2093
|
-
case "failed-parse":
|
|
2094
|
-
case "undefined-input": return;
|
|
2095
|
-
case "repaired-parse":
|
|
2096
|
-
case "successful-parse": return t.value === void 0 ? void 0 : { partial: t.value };
|
|
2097
|
-
}
|
|
2098
|
-
},
|
|
2099
|
-
createElementStreamTransform() {}
|
|
2100
|
-
});
|
|
2101
|
-
new TextEncoder(), new TextEncoder(), I({
|
|
1786
|
+
new TextEncoder(), new TextEncoder(), R({
|
|
2102
1787
|
prefix: "aitxt",
|
|
2103
1788
|
size: 24
|
|
2104
|
-
}),
|
|
1789
|
+
}), R({
|
|
2105
1790
|
prefix: "call",
|
|
2106
1791
|
size: 24
|
|
2107
1792
|
}), TransformStream;
|
|
2108
|
-
var
|
|
2109
|
-
|
|
2110
|
-
type:
|
|
2111
|
-
id:
|
|
2112
|
-
providerMetadata:
|
|
1793
|
+
var Pn = J.record(J.string(), Y.optional()), Fn = Ut(() => Qt(J.union([
|
|
1794
|
+
J.looseObject({
|
|
1795
|
+
type: J.literal("text-start"),
|
|
1796
|
+
id: J.string(),
|
|
1797
|
+
providerMetadata: X.optional()
|
|
2113
1798
|
}),
|
|
2114
|
-
|
|
2115
|
-
type:
|
|
2116
|
-
id:
|
|
2117
|
-
delta:
|
|
2118
|
-
providerMetadata:
|
|
1799
|
+
J.looseObject({
|
|
1800
|
+
type: J.literal("text-delta"),
|
|
1801
|
+
id: J.string(),
|
|
1802
|
+
delta: J.string(),
|
|
1803
|
+
providerMetadata: X.optional()
|
|
2119
1804
|
}),
|
|
2120
|
-
|
|
2121
|
-
type:
|
|
2122
|
-
id:
|
|
2123
|
-
providerMetadata:
|
|
1805
|
+
J.looseObject({
|
|
1806
|
+
type: J.literal("text-end"),
|
|
1807
|
+
id: J.string(),
|
|
1808
|
+
providerMetadata: X.optional()
|
|
2124
1809
|
}),
|
|
2125
|
-
|
|
2126
|
-
type:
|
|
2127
|
-
errorText:
|
|
1810
|
+
J.looseObject({
|
|
1811
|
+
type: J.literal("error"),
|
|
1812
|
+
errorText: J.string()
|
|
2128
1813
|
}),
|
|
2129
|
-
|
|
2130
|
-
type:
|
|
2131
|
-
toolCallId:
|
|
2132
|
-
toolName:
|
|
2133
|
-
providerExecuted:
|
|
2134
|
-
providerMetadata:
|
|
2135
|
-
toolMetadata:
|
|
2136
|
-
dynamic:
|
|
2137
|
-
title:
|
|
1814
|
+
J.looseObject({
|
|
1815
|
+
type: J.literal("tool-input-start"),
|
|
1816
|
+
toolCallId: J.string(),
|
|
1817
|
+
toolName: J.string(),
|
|
1818
|
+
providerExecuted: J.boolean().optional(),
|
|
1819
|
+
providerMetadata: X.optional(),
|
|
1820
|
+
toolMetadata: Pn.optional(),
|
|
1821
|
+
dynamic: J.boolean().optional(),
|
|
1822
|
+
title: J.string().optional()
|
|
2138
1823
|
}),
|
|
2139
|
-
|
|
2140
|
-
type:
|
|
2141
|
-
toolCallId:
|
|
2142
|
-
inputTextDelta:
|
|
1824
|
+
J.looseObject({
|
|
1825
|
+
type: J.literal("tool-input-delta"),
|
|
1826
|
+
toolCallId: J.string(),
|
|
1827
|
+
inputTextDelta: J.string()
|
|
2143
1828
|
}),
|
|
2144
|
-
|
|
2145
|
-
type:
|
|
2146
|
-
toolCallId:
|
|
2147
|
-
toolName:
|
|
2148
|
-
input:
|
|
2149
|
-
providerExecuted:
|
|
2150
|
-
providerMetadata:
|
|
2151
|
-
toolMetadata:
|
|
2152
|
-
dynamic:
|
|
2153
|
-
title:
|
|
1829
|
+
J.looseObject({
|
|
1830
|
+
type: J.literal("tool-input-available"),
|
|
1831
|
+
toolCallId: J.string(),
|
|
1832
|
+
toolName: J.string(),
|
|
1833
|
+
input: J.unknown(),
|
|
1834
|
+
providerExecuted: J.boolean().optional(),
|
|
1835
|
+
providerMetadata: X.optional(),
|
|
1836
|
+
toolMetadata: Pn.optional(),
|
|
1837
|
+
dynamic: J.boolean().optional(),
|
|
1838
|
+
title: J.string().optional()
|
|
2154
1839
|
}),
|
|
2155
|
-
|
|
2156
|
-
type:
|
|
2157
|
-
toolCallId:
|
|
2158
|
-
toolName:
|
|
2159
|
-
input:
|
|
2160
|
-
providerExecuted:
|
|
2161
|
-
providerMetadata:
|
|
2162
|
-
toolMetadata:
|
|
2163
|
-
dynamic:
|
|
2164
|
-
errorText:
|
|
2165
|
-
title:
|
|
1840
|
+
J.looseObject({
|
|
1841
|
+
type: J.literal("tool-input-error"),
|
|
1842
|
+
toolCallId: J.string(),
|
|
1843
|
+
toolName: J.string(),
|
|
1844
|
+
input: J.unknown(),
|
|
1845
|
+
providerExecuted: J.boolean().optional(),
|
|
1846
|
+
providerMetadata: X.optional(),
|
|
1847
|
+
toolMetadata: Pn.optional(),
|
|
1848
|
+
dynamic: J.boolean().optional(),
|
|
1849
|
+
errorText: J.string(),
|
|
1850
|
+
title: J.string().optional()
|
|
2166
1851
|
}),
|
|
2167
|
-
|
|
2168
|
-
type:
|
|
2169
|
-
approvalId:
|
|
2170
|
-
toolCallId:
|
|
2171
|
-
approvalDescriptor:
|
|
2172
|
-
inputSchemaInput:
|
|
2173
|
-
reason:
|
|
2174
|
-
isAutomatic:
|
|
2175
|
-
signature:
|
|
1852
|
+
J.looseObject({
|
|
1853
|
+
type: J.literal("tool-approval-request"),
|
|
1854
|
+
approvalId: J.string(),
|
|
1855
|
+
toolCallId: J.string(),
|
|
1856
|
+
approvalDescriptor: J.unknown().optional(),
|
|
1857
|
+
inputSchemaInput: J.unknown().optional(),
|
|
1858
|
+
reason: J.string().optional(),
|
|
1859
|
+
isAutomatic: J.boolean().optional(),
|
|
1860
|
+
signature: J.string().optional()
|
|
2176
1861
|
}),
|
|
2177
|
-
|
|
2178
|
-
type:
|
|
2179
|
-
approvalId:
|
|
2180
|
-
approved:
|
|
2181
|
-
reason:
|
|
2182
|
-
providerExecuted:
|
|
2183
|
-
providerMetadata:
|
|
1862
|
+
J.looseObject({
|
|
1863
|
+
type: J.literal("tool-approval-response"),
|
|
1864
|
+
approvalId: J.string(),
|
|
1865
|
+
approved: J.boolean(),
|
|
1866
|
+
reason: J.string().optional(),
|
|
1867
|
+
providerExecuted: J.boolean().optional(),
|
|
1868
|
+
providerMetadata: X.optional()
|
|
2184
1869
|
}),
|
|
2185
|
-
|
|
2186
|
-
type:
|
|
2187
|
-
toolCallId:
|
|
2188
|
-
output:
|
|
2189
|
-
providerExecuted:
|
|
2190
|
-
providerMetadata:
|
|
2191
|
-
toolMetadata:
|
|
2192
|
-
dynamic:
|
|
2193
|
-
preliminary:
|
|
1870
|
+
J.looseObject({
|
|
1871
|
+
type: J.literal("tool-output-available"),
|
|
1872
|
+
toolCallId: J.string(),
|
|
1873
|
+
output: J.unknown(),
|
|
1874
|
+
providerExecuted: J.boolean().optional(),
|
|
1875
|
+
providerMetadata: X.optional(),
|
|
1876
|
+
toolMetadata: Pn.optional(),
|
|
1877
|
+
dynamic: J.boolean().optional(),
|
|
1878
|
+
preliminary: J.boolean().optional()
|
|
2194
1879
|
}),
|
|
2195
|
-
|
|
2196
|
-
type:
|
|
2197
|
-
toolCallId:
|
|
2198
|
-
errorText:
|
|
2199
|
-
providerExecuted:
|
|
2200
|
-
providerMetadata:
|
|
2201
|
-
toolMetadata:
|
|
2202
|
-
dynamic:
|
|
1880
|
+
J.looseObject({
|
|
1881
|
+
type: J.literal("tool-output-error"),
|
|
1882
|
+
toolCallId: J.string(),
|
|
1883
|
+
errorText: J.string(),
|
|
1884
|
+
providerExecuted: J.boolean().optional(),
|
|
1885
|
+
providerMetadata: X.optional(),
|
|
1886
|
+
toolMetadata: Pn.optional(),
|
|
1887
|
+
dynamic: J.boolean().optional()
|
|
2203
1888
|
}),
|
|
2204
|
-
|
|
2205
|
-
type:
|
|
2206
|
-
toolCallId:
|
|
1889
|
+
J.looseObject({
|
|
1890
|
+
type: J.literal("tool-output-denied"),
|
|
1891
|
+
toolCallId: J.string()
|
|
2207
1892
|
}),
|
|
2208
|
-
|
|
2209
|
-
type:
|
|
2210
|
-
id:
|
|
2211
|
-
providerMetadata:
|
|
1893
|
+
J.looseObject({
|
|
1894
|
+
type: J.literal("reasoning-start"),
|
|
1895
|
+
id: J.string(),
|
|
1896
|
+
providerMetadata: X.optional()
|
|
2212
1897
|
}),
|
|
2213
|
-
|
|
2214
|
-
type:
|
|
2215
|
-
id:
|
|
2216
|
-
delta:
|
|
2217
|
-
providerMetadata:
|
|
1898
|
+
J.looseObject({
|
|
1899
|
+
type: J.literal("reasoning-delta"),
|
|
1900
|
+
id: J.string(),
|
|
1901
|
+
delta: J.string(),
|
|
1902
|
+
providerMetadata: X.optional()
|
|
2218
1903
|
}),
|
|
2219
|
-
|
|
2220
|
-
type:
|
|
2221
|
-
id:
|
|
2222
|
-
providerMetadata:
|
|
1904
|
+
J.looseObject({
|
|
1905
|
+
type: J.literal("reasoning-end"),
|
|
1906
|
+
id: J.string(),
|
|
1907
|
+
providerMetadata: X.optional()
|
|
2223
1908
|
}),
|
|
2224
|
-
|
|
2225
|
-
type:
|
|
2226
|
-
kind:
|
|
2227
|
-
providerMetadata:
|
|
1909
|
+
J.looseObject({
|
|
1910
|
+
type: J.literal("custom"),
|
|
1911
|
+
kind: J.string().transform((e) => e),
|
|
1912
|
+
providerMetadata: X.optional()
|
|
2228
1913
|
}),
|
|
2229
|
-
|
|
2230
|
-
type:
|
|
2231
|
-
sourceId:
|
|
2232
|
-
url:
|
|
2233
|
-
title:
|
|
2234
|
-
providerMetadata:
|
|
1914
|
+
J.looseObject({
|
|
1915
|
+
type: J.literal("source-url"),
|
|
1916
|
+
sourceId: J.string(),
|
|
1917
|
+
url: J.string(),
|
|
1918
|
+
title: J.string().optional(),
|
|
1919
|
+
providerMetadata: X.optional()
|
|
2235
1920
|
}),
|
|
2236
|
-
|
|
2237
|
-
type:
|
|
2238
|
-
sourceId:
|
|
2239
|
-
mediaType:
|
|
2240
|
-
title:
|
|
2241
|
-
filename:
|
|
2242
|
-
providerMetadata:
|
|
1921
|
+
J.looseObject({
|
|
1922
|
+
type: J.literal("source-document"),
|
|
1923
|
+
sourceId: J.string(),
|
|
1924
|
+
mediaType: J.string(),
|
|
1925
|
+
title: J.string(),
|
|
1926
|
+
filename: J.string().optional(),
|
|
1927
|
+
providerMetadata: X.optional()
|
|
2243
1928
|
}),
|
|
2244
|
-
|
|
2245
|
-
type:
|
|
2246
|
-
url:
|
|
2247
|
-
mediaType:
|
|
2248
|
-
providerMetadata:
|
|
1929
|
+
J.looseObject({
|
|
1930
|
+
type: J.literal("file"),
|
|
1931
|
+
url: J.string(),
|
|
1932
|
+
mediaType: J.string(),
|
|
1933
|
+
providerMetadata: X.optional()
|
|
2249
1934
|
}),
|
|
2250
|
-
|
|
2251
|
-
type:
|
|
2252
|
-
url:
|
|
2253
|
-
mediaType:
|
|
2254
|
-
providerMetadata:
|
|
1935
|
+
J.looseObject({
|
|
1936
|
+
type: J.literal("reasoning-file"),
|
|
1937
|
+
url: J.string(),
|
|
1938
|
+
mediaType: J.string(),
|
|
1939
|
+
providerMetadata: X.optional()
|
|
2255
1940
|
}),
|
|
2256
|
-
|
|
2257
|
-
type:
|
|
2258
|
-
id:
|
|
2259
|
-
data:
|
|
2260
|
-
transient:
|
|
1941
|
+
J.looseObject({
|
|
1942
|
+
type: J.custom((e) => typeof e == "string" && e.startsWith("data-"), { message: "Type must start with \"data-\"" }),
|
|
1943
|
+
id: J.string().optional(),
|
|
1944
|
+
data: J.unknown(),
|
|
1945
|
+
transient: J.boolean().optional()
|
|
2261
1946
|
}),
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
type:
|
|
2267
|
-
messageId:
|
|
2268
|
-
messageMetadata:
|
|
1947
|
+
J.looseObject({ type: J.literal("start-step") }),
|
|
1948
|
+
J.looseObject({ type: J.literal("finish-step") }),
|
|
1949
|
+
J.looseObject({ type: J.literal("reset-step") }),
|
|
1950
|
+
J.looseObject({
|
|
1951
|
+
type: J.literal("start"),
|
|
1952
|
+
messageId: J.string().optional(),
|
|
1953
|
+
messageMetadata: J.unknown().optional()
|
|
2269
1954
|
}),
|
|
2270
|
-
|
|
2271
|
-
type:
|
|
2272
|
-
finishReason:
|
|
1955
|
+
J.looseObject({
|
|
1956
|
+
type: J.literal("finish"),
|
|
1957
|
+
finishReason: J.enum([
|
|
2273
1958
|
"stop",
|
|
2274
1959
|
"length",
|
|
2275
1960
|
"content-filter",
|
|
@@ -2277,49 +1962,49 @@ var fr = Y.record(Y.string(), X.optional()), pr = sn(() => gn(Y.union([
|
|
|
2277
1962
|
"error",
|
|
2278
1963
|
"other"
|
|
2279
1964
|
]).optional(),
|
|
2280
|
-
messageMetadata:
|
|
1965
|
+
messageMetadata: J.unknown().optional()
|
|
2281
1966
|
}),
|
|
2282
|
-
|
|
2283
|
-
type:
|
|
2284
|
-
reason:
|
|
1967
|
+
J.looseObject({
|
|
1968
|
+
type: J.literal("abort"),
|
|
1969
|
+
reason: J.string().optional()
|
|
2285
1970
|
}),
|
|
2286
|
-
|
|
2287
|
-
type:
|
|
2288
|
-
messageMetadata:
|
|
1971
|
+
J.looseObject({
|
|
1972
|
+
type: J.literal("message-metadata"),
|
|
1973
|
+
messageMetadata: J.unknown()
|
|
2289
1974
|
})
|
|
2290
1975
|
])));
|
|
2291
|
-
function
|
|
1976
|
+
function In(e) {
|
|
2292
1977
|
return e.type.startsWith("data-");
|
|
2293
1978
|
}
|
|
2294
|
-
function
|
|
2295
|
-
return
|
|
1979
|
+
function Ln() {
|
|
1980
|
+
return Object.create(null);
|
|
2296
1981
|
}
|
|
2297
|
-
function
|
|
1982
|
+
function Rn(e) {
|
|
2298
1983
|
return e.type.startsWith("tool-");
|
|
2299
1984
|
}
|
|
2300
|
-
function
|
|
1985
|
+
function zn(e) {
|
|
2301
1986
|
return e.type === "dynamic-tool";
|
|
2302
1987
|
}
|
|
2303
|
-
function
|
|
2304
|
-
return
|
|
1988
|
+
function Z(e) {
|
|
1989
|
+
return Rn(e) || zn(e);
|
|
2305
1990
|
}
|
|
2306
|
-
function
|
|
1991
|
+
function Bn(e) {
|
|
2307
1992
|
return e.type.split("-").slice(1).join("-");
|
|
2308
1993
|
}
|
|
2309
|
-
function
|
|
1994
|
+
function Vn({ lastMessage: e, messageId: t }) {
|
|
2310
1995
|
let n = e?.role === "assistant" ? e : {
|
|
2311
1996
|
id: t,
|
|
2312
1997
|
metadata: void 0,
|
|
2313
1998
|
role: "assistant",
|
|
2314
1999
|
parts: []
|
|
2315
|
-
}, r =
|
|
2000
|
+
}, r = Ln(), i = n.parts.findLastIndex((e) => e.type === "step-start"), a = 0;
|
|
2316
2001
|
for (let e of n.parts.slice(i + 1)) {
|
|
2317
|
-
if (!
|
|
2002
|
+
if (!Z(e)) continue;
|
|
2318
2003
|
let t = a;
|
|
2319
|
-
|
|
2004
|
+
Rn(e) && a++, e.state === "input-streaming" && (r[e.toolCallId] = {
|
|
2320
2005
|
text: e.rawInput ?? "",
|
|
2321
2006
|
index: t,
|
|
2322
|
-
toolName: e.type === "dynamic-tool" ? e.toolName :
|
|
2007
|
+
toolName: e.type === "dynamic-tool" ? e.toolName : Bn(e),
|
|
2323
2008
|
dynamic: e.type === "dynamic-tool",
|
|
2324
2009
|
title: e.title,
|
|
2325
2010
|
toolMetadata: e.toolMetadata
|
|
@@ -2327,12 +2012,12 @@ function yr({ lastMessage: e, messageId: t }) {
|
|
|
2327
2012
|
}
|
|
2328
2013
|
return {
|
|
2329
2014
|
message: n,
|
|
2330
|
-
activeTextParts:
|
|
2331
|
-
activeReasoningParts:
|
|
2015
|
+
activeTextParts: Ln(),
|
|
2016
|
+
activeReasoningParts: Ln(),
|
|
2332
2017
|
partialToolCalls: r
|
|
2333
2018
|
};
|
|
2334
2019
|
}
|
|
2335
|
-
function
|
|
2020
|
+
function Hn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdateMessageJob: r, onError: i, onToolCall: a, onData: o }) {
|
|
2336
2021
|
return e.pipeThrough(new TransformStream({ async transform(e, s) {
|
|
2337
2022
|
await r(async ({ state: r, write: c }) => {
|
|
2338
2023
|
function l() {
|
|
@@ -2341,7 +2026,7 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2341
2026
|
return e.slice(t + 1);
|
|
2342
2027
|
}
|
|
2343
2028
|
function u() {
|
|
2344
|
-
return l().filter(
|
|
2029
|
+
return l().filter(Z);
|
|
2345
2030
|
}
|
|
2346
2031
|
function d(e) {
|
|
2347
2032
|
let t = u().find((t) => t.toolCallId === e);
|
|
@@ -2349,13 +2034,13 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2349
2034
|
let n = r.message.parts;
|
|
2350
2035
|
for (let r = n.length - 1; r >= 0; r--) {
|
|
2351
2036
|
let i = n[r];
|
|
2352
|
-
if (
|
|
2037
|
+
if (Z(i) && i.toolCallId === e) {
|
|
2353
2038
|
t = i;
|
|
2354
2039
|
break;
|
|
2355
2040
|
}
|
|
2356
2041
|
}
|
|
2357
2042
|
}
|
|
2358
|
-
if (t == null) throw new
|
|
2043
|
+
if (t == null) throw new q({
|
|
2359
2044
|
chunkType: "tool-invocation",
|
|
2360
2045
|
chunkId: e,
|
|
2361
2046
|
message: `No tool invocation found for tool call ID "${e}".`
|
|
@@ -2363,8 +2048,8 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2363
2048
|
return t;
|
|
2364
2049
|
}
|
|
2365
2050
|
function f(e) {
|
|
2366
|
-
let t = r.message.parts.filter(
|
|
2367
|
-
if (t == null) throw new
|
|
2051
|
+
let t = r.message.parts.filter(Z).find((t) => t.approval?.id === e);
|
|
2052
|
+
if (t == null) throw new q({
|
|
2368
2053
|
chunkType: "tool-approval-response",
|
|
2369
2054
|
chunkId: e,
|
|
2370
2055
|
message: `No tool invocation found for approval ID "${e}".`
|
|
@@ -2372,7 +2057,7 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2372
2057
|
return t;
|
|
2373
2058
|
}
|
|
2374
2059
|
function p(e, t) {
|
|
2375
|
-
let n = t ?? l().find((t) =>
|
|
2060
|
+
let n = t ?? l().find((t) => Rn(t) && t.toolCallId === e.toolCallId), i = e, a = n;
|
|
2376
2061
|
if (n != null) {
|
|
2377
2062
|
n.state = e.state, a.input = i.input, a.output = i.output, a.errorText = i.errorText, a.rawInput = i.rawInput, a.preliminary = i.preliminary, e.title !== void 0 && (a.title = e.title), e.toolMetadata !== void 0 && (a.toolMetadata = e.toolMetadata), a.providerExecuted = i.providerExecuted ?? n.providerExecuted;
|
|
2378
2063
|
let t = i.providerMetadata;
|
|
@@ -2427,8 +2112,8 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2427
2112
|
}
|
|
2428
2113
|
async function h(e) {
|
|
2429
2114
|
if (e != null) {
|
|
2430
|
-
let n = r.message.metadata == null ? e :
|
|
2431
|
-
t != null && await
|
|
2115
|
+
let n = r.message.metadata == null ? e : fn(r.message.metadata, e);
|
|
2116
|
+
t != null && await $t({
|
|
2432
2117
|
value: n,
|
|
2433
2118
|
schema: t,
|
|
2434
2119
|
context: {
|
|
@@ -2451,7 +2136,7 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2451
2136
|
}
|
|
2452
2137
|
case "text-delta": {
|
|
2453
2138
|
let t = r.activeTextParts[e.id];
|
|
2454
|
-
if (t == null) throw new
|
|
2139
|
+
if (t == null) throw new q({
|
|
2455
2140
|
chunkType: "text-delta",
|
|
2456
2141
|
chunkId: e.id,
|
|
2457
2142
|
message: `Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`
|
|
@@ -2461,7 +2146,7 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2461
2146
|
}
|
|
2462
2147
|
case "text-end": {
|
|
2463
2148
|
let t = r.activeTextParts[e.id];
|
|
2464
|
-
if (t == null) throw new
|
|
2149
|
+
if (t == null) throw new q({
|
|
2465
2150
|
chunkType: "text-end",
|
|
2466
2151
|
chunkId: e.id,
|
|
2467
2152
|
message: `Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`
|
|
@@ -2491,7 +2176,7 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2491
2176
|
}
|
|
2492
2177
|
case "reasoning-delta": {
|
|
2493
2178
|
let t = r.activeReasoningParts[e.id];
|
|
2494
|
-
if (t == null) throw new
|
|
2179
|
+
if (t == null) throw new q({
|
|
2495
2180
|
chunkType: "reasoning-delta",
|
|
2496
2181
|
chunkId: e.id,
|
|
2497
2182
|
message: `Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`
|
|
@@ -2501,7 +2186,7 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2501
2186
|
}
|
|
2502
2187
|
case "reasoning-end": {
|
|
2503
2188
|
let t = r.activeReasoningParts[e.id];
|
|
2504
|
-
if (t == null) throw new
|
|
2189
|
+
if (t == null) throw new q({
|
|
2505
2190
|
chunkType: "reasoning-end",
|
|
2506
2191
|
chunkId: e.id,
|
|
2507
2192
|
message: `Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`
|
|
@@ -2538,7 +2223,7 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2538
2223
|
}), c();
|
|
2539
2224
|
break;
|
|
2540
2225
|
case "tool-input-start": {
|
|
2541
|
-
let t = l().filter(
|
|
2226
|
+
let t = l().filter(Rn);
|
|
2542
2227
|
r.partialToolCalls[e.toolCallId] = {
|
|
2543
2228
|
text: "",
|
|
2544
2229
|
toolName: e.toolName,
|
|
@@ -2569,13 +2254,13 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2569
2254
|
}
|
|
2570
2255
|
case "tool-input-delta": {
|
|
2571
2256
|
let t = r.partialToolCalls[e.toolCallId];
|
|
2572
|
-
if (t == null) throw new
|
|
2257
|
+
if (t == null) throw new q({
|
|
2573
2258
|
chunkType: "tool-input-delta",
|
|
2574
2259
|
chunkId: e.toolCallId,
|
|
2575
2260
|
message: `Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`
|
|
2576
2261
|
});
|
|
2577
2262
|
t.text += e.inputTextDelta;
|
|
2578
|
-
let { value: n } = await
|
|
2263
|
+
let { value: n } = await Nn(t.text);
|
|
2579
2264
|
t.dynamic ? m({
|
|
2580
2265
|
toolCallId: e.toolCallId,
|
|
2581
2266
|
toolName: t.toolName,
|
|
@@ -2617,7 +2302,7 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2617
2302
|
}), c(), a && !e.providerExecuted && await a({ toolCall: e });
|
|
2618
2303
|
break;
|
|
2619
2304
|
case "tool-input-error": {
|
|
2620
|
-
let t = l().filter(
|
|
2305
|
+
let t = l().filter(Z).find((t) => t.toolCallId === e.toolCallId);
|
|
2621
2306
|
(t == null ? e.dynamic : t.type === "dynamic-tool") ? m({
|
|
2622
2307
|
toolCallId: e.toolCallId,
|
|
2623
2308
|
toolName: e.toolName,
|
|
@@ -2681,7 +2366,7 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2681
2366
|
toolMetadata: e.toolMetadata ?? t.toolMetadata
|
|
2682
2367
|
}, t) : p({
|
|
2683
2368
|
toolCallId: e.toolCallId,
|
|
2684
|
-
toolName:
|
|
2369
|
+
toolName: Bn(t),
|
|
2685
2370
|
state: "output-available",
|
|
2686
2371
|
input: t.input,
|
|
2687
2372
|
output: e.output,
|
|
@@ -2707,7 +2392,7 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2707
2392
|
toolMetadata: e.toolMetadata ?? t.toolMetadata
|
|
2708
2393
|
}, t) : p({
|
|
2709
2394
|
toolCallId: e.toolCallId,
|
|
2710
|
-
toolName:
|
|
2395
|
+
toolName: Bn(t),
|
|
2711
2396
|
state: "output-error",
|
|
2712
2397
|
input: t.input,
|
|
2713
2398
|
rawInput: t.rawInput,
|
|
@@ -2725,7 +2410,7 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2725
2410
|
case "finish-step": break;
|
|
2726
2411
|
case "reset-step": {
|
|
2727
2412
|
let e = l();
|
|
2728
|
-
r.activeTextParts =
|
|
2413
|
+
r.activeTextParts = Ln(), r.activeReasoningParts = Ln(), r.partialToolCalls = Ln(), e.length > 0 && (r.message.parts.splice(r.message.parts.length - e.length, e.length), c());
|
|
2729
2414
|
break;
|
|
2730
2415
|
}
|
|
2731
2416
|
case "start":
|
|
@@ -2740,10 +2425,10 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2740
2425
|
case "error":
|
|
2741
2426
|
i?.(Error(e.errorText));
|
|
2742
2427
|
break;
|
|
2743
|
-
default: if (
|
|
2428
|
+
default: if (In(e)) {
|
|
2744
2429
|
if (n?.[e.type] != null) {
|
|
2745
2430
|
let t = r.message.parts.findIndex((t) => "id" in t && "data" in t && t.id === e.id && t.type === e.type), i = t >= 0 ? t : r.message.parts.length;
|
|
2746
|
-
await
|
|
2431
|
+
await $t({
|
|
2747
2432
|
value: e.data,
|
|
2748
2433
|
schema: n[e.type],
|
|
2749
2434
|
context: {
|
|
@@ -2766,7 +2451,7 @@ function br({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2766
2451
|
});
|
|
2767
2452
|
} }));
|
|
2768
2453
|
}
|
|
2769
|
-
async function
|
|
2454
|
+
async function Un({ stream: e, onError: t, abortSignal: n }) {
|
|
2770
2455
|
let r = e.getReader(), i = () => {
|
|
2771
2456
|
r.cancel().catch(() => {});
|
|
2772
2457
|
};
|
|
@@ -2782,32 +2467,32 @@ async function xr({ stream: e, onError: t, abortSignal: n }) {
|
|
|
2782
2467
|
n?.removeEventListener("abort", i), r.releaseLock();
|
|
2783
2468
|
}
|
|
2784
2469
|
}
|
|
2785
|
-
|
|
2470
|
+
R({
|
|
2786
2471
|
prefix: "aitxt",
|
|
2787
2472
|
size: 24
|
|
2788
|
-
}),
|
|
2473
|
+
}), R({
|
|
2789
2474
|
prefix: "call",
|
|
2790
2475
|
size: 24
|
|
2791
|
-
}),
|
|
2476
|
+
}), R({
|
|
2792
2477
|
prefix: "aitxt",
|
|
2793
2478
|
size: 24
|
|
2794
|
-
}),
|
|
2479
|
+
}), R({
|
|
2795
2480
|
prefix: "call",
|
|
2796
2481
|
size: 24
|
|
2797
|
-
}),
|
|
2482
|
+
}), J.record(J.string(), Y.optional()), J.record(J.string(), J.string()), R({
|
|
2798
2483
|
prefix: "call",
|
|
2799
2484
|
size: 24
|
|
2800
|
-
}),
|
|
2485
|
+
}), R({
|
|
2801
2486
|
prefix: "call",
|
|
2802
2487
|
size: 24
|
|
2803
|
-
}), new TextEncoder(),
|
|
2488
|
+
}), new TextEncoder(), R({
|
|
2804
2489
|
prefix: "call",
|
|
2805
2490
|
size: 24
|
|
2806
|
-
}),
|
|
2491
|
+
}), R({
|
|
2807
2492
|
prefix: "aiobj",
|
|
2808
2493
|
size: 24
|
|
2809
2494
|
});
|
|
2810
|
-
var { atob:
|
|
2495
|
+
var { atob: Wn } = globalThis, Gn = class {
|
|
2811
2496
|
constructor() {
|
|
2812
2497
|
this.queue = [], this.isProcessing = !1;
|
|
2813
2498
|
}
|
|
@@ -2829,12 +2514,12 @@ var { atob: Sr } = globalThis, Cr = class {
|
|
|
2829
2514
|
});
|
|
2830
2515
|
}
|
|
2831
2516
|
};
|
|
2832
|
-
|
|
2517
|
+
R({
|
|
2833
2518
|
prefix: "aiobj",
|
|
2834
2519
|
size: 24
|
|
2835
|
-
}),
|
|
2836
|
-
token:
|
|
2837
|
-
url:
|
|
2520
|
+
}), J.object({
|
|
2521
|
+
token: J.string().refine((e) => e.trim().length > 0),
|
|
2522
|
+
url: J.string().refine((e) => {
|
|
2838
2523
|
try {
|
|
2839
2524
|
let t = new URL(e);
|
|
2840
2525
|
return (t.protocol === "ws:" || t.protocol === "wss:") && t.hostname !== "";
|
|
@@ -2842,20 +2527,20 @@ I({
|
|
|
2842
2527
|
return !1;
|
|
2843
2528
|
}
|
|
2844
2529
|
}),
|
|
2845
|
-
expiresAt:
|
|
2846
|
-
tools:
|
|
2847
|
-
type:
|
|
2848
|
-
name:
|
|
2849
|
-
description:
|
|
2850
|
-
parameters:
|
|
2530
|
+
expiresAt: J.number().positive().max(2 ** 53 - 1).optional(),
|
|
2531
|
+
tools: J.array(J.object({
|
|
2532
|
+
type: J.literal("function"),
|
|
2533
|
+
name: J.string().min(1),
|
|
2534
|
+
description: J.string().optional(),
|
|
2535
|
+
parameters: J.record(J.string(), J.unknown())
|
|
2851
2536
|
})).optional()
|
|
2852
|
-
}),
|
|
2537
|
+
}), R({
|
|
2853
2538
|
prefix: "call",
|
|
2854
2539
|
size: 24
|
|
2855
2540
|
});
|
|
2856
|
-
async function
|
|
2541
|
+
async function Kn({ response: e, url: t, fallbackMessage: n }) {
|
|
2857
2542
|
let r = await e.text();
|
|
2858
|
-
return new
|
|
2543
|
+
return new be({
|
|
2859
2544
|
message: r || n,
|
|
2860
2545
|
url: t,
|
|
2861
2546
|
requestBodyValues: void 0,
|
|
@@ -2863,9 +2548,9 @@ async function wr({ response: e, url: t, fallbackMessage: n }) {
|
|
|
2863
2548
|
responseBody: r
|
|
2864
2549
|
});
|
|
2865
2550
|
}
|
|
2866
|
-
async function
|
|
2551
|
+
async function qn(e) {
|
|
2867
2552
|
if (e == null) return [];
|
|
2868
|
-
if (!globalThis.FileList || !(e instanceof globalThis.FileList)) throw new
|
|
2553
|
+
if (!globalThis.FileList || !(e instanceof globalThis.FileList)) throw new Pe({
|
|
2869
2554
|
functionality: "FileList",
|
|
2870
2555
|
message: "FileList is not supported in the current environment"
|
|
2871
2556
|
});
|
|
@@ -2884,18 +2569,18 @@ async function Tr(e) {
|
|
|
2884
2569
|
};
|
|
2885
2570
|
}));
|
|
2886
2571
|
}
|
|
2887
|
-
function
|
|
2572
|
+
function Jn(e, t) {
|
|
2888
2573
|
let n = e.search(/[?#]/);
|
|
2889
2574
|
return n === -1 ? `${e}${t}` : `${e.slice(0, n)}${t}${e.slice(n)}`;
|
|
2890
2575
|
}
|
|
2891
|
-
var
|
|
2576
|
+
var Yn = class {
|
|
2892
2577
|
constructor({ api: e = "/api/chat", credentials: t, headers: n, body: r, fetch: i, prepareSendMessagesRequest: a, prepareReconnectToStreamRequest: o }) {
|
|
2893
2578
|
this.api = e, this.credentials = t, this.headers = n, this.body = r, this.fetch = i, this.prepareSendMessagesRequest = a, this.prepareReconnectToStreamRequest = o;
|
|
2894
2579
|
}
|
|
2895
2580
|
async sendMessages({ abortSignal: e, ...t }) {
|
|
2896
|
-
let n = await
|
|
2897
|
-
...
|
|
2898
|
-
...
|
|
2581
|
+
let n = await rn(this.body), r = await rn(this.headers), i = await rn(this.credentials), a = {
|
|
2582
|
+
...L(r),
|
|
2583
|
+
...L(t.headers)
|
|
2899
2584
|
}, o = await this.prepareSendMessagesRequest?.({
|
|
2900
2585
|
api: this.api,
|
|
2901
2586
|
id: t.chatId,
|
|
@@ -2909,7 +2594,7 @@ var Dr = class {
|
|
|
2909
2594
|
requestMetadata: t.metadata,
|
|
2910
2595
|
trigger: t.trigger,
|
|
2911
2596
|
messageId: t.messageId
|
|
2912
|
-
}), s = o?.api ?? this.api, c = o?.headers === void 0 ? a :
|
|
2597
|
+
}), s = o?.api ?? this.api, c = o?.headers === void 0 ? a : L(o.headers), l = o?.body === void 0 ? {
|
|
2913
2598
|
...n,
|
|
2914
2599
|
...t.body,
|
|
2915
2600
|
id: t.chatId,
|
|
@@ -2926,18 +2611,18 @@ var Dr = class {
|
|
|
2926
2611
|
credentials: u,
|
|
2927
2612
|
signal: e
|
|
2928
2613
|
});
|
|
2929
|
-
if (!d.ok) throw await
|
|
2614
|
+
if (!d.ok) throw await Kn({
|
|
2930
2615
|
response: d,
|
|
2931
2616
|
url: s,
|
|
2932
2617
|
fallbackMessage: "Failed to fetch the chat response."
|
|
2933
2618
|
});
|
|
2934
|
-
if (!d.body) throw new
|
|
2619
|
+
if (!d.body) throw new Ce({ message: "The response body is empty." });
|
|
2935
2620
|
return this.processResponseStream(d.body);
|
|
2936
2621
|
}
|
|
2937
2622
|
async reconnectToStream(e) {
|
|
2938
|
-
let t = await
|
|
2939
|
-
...
|
|
2940
|
-
...
|
|
2623
|
+
let t = await rn(this.body), n = await rn(this.headers), r = await rn(this.credentials), i = {
|
|
2624
|
+
...L(n),
|
|
2625
|
+
...L(e.headers)
|
|
2941
2626
|
}, a = await this.prepareReconnectToStreamRequest?.({
|
|
2942
2627
|
api: this.api,
|
|
2943
2628
|
id: e.chatId,
|
|
@@ -2950,51 +2635,51 @@ var Dr = class {
|
|
|
2950
2635
|
requestMetadata: e.metadata
|
|
2951
2636
|
}), o = a?.api;
|
|
2952
2637
|
if (o == null) {
|
|
2953
|
-
if (e.chatId === "." || e.chatId === "..") throw new
|
|
2638
|
+
if (e.chatId === "." || e.chatId === "..") throw new cn({
|
|
2954
2639
|
parameter: "chatId",
|
|
2955
2640
|
value: e.chatId,
|
|
2956
2641
|
message: "Chat IDs must not be \".\" or \"..\" when using the default reconnect URL."
|
|
2957
2642
|
});
|
|
2958
|
-
o =
|
|
2643
|
+
o = Jn(this.api, `/${encodeURIComponent(e.chatId)}/stream`);
|
|
2959
2644
|
}
|
|
2960
|
-
let s = a?.headers === void 0 ? i :
|
|
2645
|
+
let s = a?.headers === void 0 ? i : L(a.headers), c = a?.credentials ?? r, l = await (this.fetch ?? globalThis.fetch)(o, {
|
|
2961
2646
|
method: "GET",
|
|
2962
2647
|
headers: s,
|
|
2963
2648
|
credentials: c,
|
|
2964
2649
|
signal: e.abortSignal
|
|
2965
2650
|
});
|
|
2966
2651
|
if (l.status === 204) return null;
|
|
2967
|
-
if (!l.ok) throw await
|
|
2652
|
+
if (!l.ok) throw await Kn({
|
|
2968
2653
|
response: l,
|
|
2969
2654
|
url: o,
|
|
2970
2655
|
fallbackMessage: "Failed to fetch the chat response."
|
|
2971
2656
|
});
|
|
2972
|
-
if (!l.body) throw new
|
|
2657
|
+
if (!l.body) throw new Ce({ message: "The response body is empty." });
|
|
2973
2658
|
return this.processResponseStream(l.body);
|
|
2974
2659
|
}
|
|
2975
|
-
},
|
|
2660
|
+
}, Xn = class extends Yn {
|
|
2976
2661
|
constructor(e = {}) {
|
|
2977
2662
|
super(e);
|
|
2978
2663
|
}
|
|
2979
2664
|
processResponseStream(e) {
|
|
2980
|
-
return
|
|
2665
|
+
return nn({
|
|
2981
2666
|
stream: e,
|
|
2982
|
-
schema:
|
|
2667
|
+
schema: Fn
|
|
2983
2668
|
}).pipeThrough(new TransformStream({ async transform(e, t) {
|
|
2984
2669
|
if (!e.success) throw e.error;
|
|
2985
2670
|
t.enqueue(e.value);
|
|
2986
2671
|
} }));
|
|
2987
2672
|
}
|
|
2988
|
-
},
|
|
2989
|
-
constructor({ generateId: e =
|
|
2990
|
-
this.pendingMessagePreparations = /* @__PURE__ */ new Set(), this.activeResponse = void 0, this.activeResumeRequest = void 0, this.resumableStreamState = void 0, this.jobExecutor = new
|
|
2673
|
+
}, Zn = class {
|
|
2674
|
+
constructor({ generateId: e = z, id: t = e(), transport: n = new Xn(), messageMetadataSchema: r, dataPartSchemas: i, state: a, onError: o, onToolCall: s, onFinish: c, onData: l, sendAutomaticallyWhen: u }) {
|
|
2675
|
+
this.pendingMessagePreparations = /* @__PURE__ */ new Set(), this.activeResponse = void 0, this.activeResumeRequest = void 0, this.resumableStreamState = void 0, this.jobExecutor = new Gn(), this.sendMessage = async (e, t) => {
|
|
2991
2676
|
if (e == null) {
|
|
2992
2677
|
let e = this.pendingApprovalMessageId;
|
|
2993
2678
|
if (e == null) {
|
|
2994
2679
|
e = this.lastMessage?.id;
|
|
2995
2680
|
for (let t = this.state.messages.length - 1; t >= 0; t--) {
|
|
2996
2681
|
let n = this.state.messages[t];
|
|
2997
|
-
if (n.role === "assistant" && n.parts.some((e) =>
|
|
2682
|
+
if (n.role === "assistant" && n.parts.some((e) => Z(e) && e.state === "approval-responded")) {
|
|
2998
2683
|
e = n.id;
|
|
2999
2684
|
break;
|
|
3000
2685
|
}
|
|
@@ -3014,7 +2699,7 @@ var Dr = class {
|
|
|
3014
2699
|
this.pendingMessagePreparations.add(t);
|
|
3015
2700
|
let r;
|
|
3016
2701
|
try {
|
|
3017
|
-
r = Array.isArray(e.files) ? e.files : await
|
|
2702
|
+
r = Array.isArray(e.files) ? e.files : await qn(e.files);
|
|
3018
2703
|
} finally {
|
|
3019
2704
|
this.pendingMessagePreparations.delete(t);
|
|
3020
2705
|
}
|
|
@@ -3026,12 +2711,12 @@ var Dr = class {
|
|
|
3026
2711
|
} else n = e;
|
|
3027
2712
|
if (e.messageId != null) {
|
|
3028
2713
|
let t = this.state.messages.findIndex((t) => t.id === e.messageId);
|
|
3029
|
-
if (t === -1) throw new
|
|
2714
|
+
if (t === -1) throw new cn({
|
|
3030
2715
|
parameter: "message.messageId",
|
|
3031
2716
|
value: e.messageId,
|
|
3032
2717
|
message: `message with id ${e.messageId} not found`
|
|
3033
2718
|
});
|
|
3034
|
-
if (this.state.messages[t].role !== "user") throw new
|
|
2719
|
+
if (this.state.messages[t].role !== "user") throw new cn({
|
|
3035
2720
|
parameter: "message.messageId",
|
|
3036
2721
|
value: e.messageId,
|
|
3037
2722
|
message: `message with id ${e.messageId} is not a user message`
|
|
@@ -3055,7 +2740,7 @@ var Dr = class {
|
|
|
3055
2740
|
});
|
|
3056
2741
|
}, this.regenerate = async ({ messageId: e, ...t } = {}) => {
|
|
3057
2742
|
let n = e == null ? this.state.messages.length - 1 : this.state.messages.findIndex((t) => t.id === e);
|
|
3058
|
-
if (n === -1) throw new
|
|
2743
|
+
if (n === -1) throw new cn({
|
|
3059
2744
|
parameter: "messageId",
|
|
3060
2745
|
value: e,
|
|
3061
2746
|
message: `message ${e} not found`
|
|
@@ -3073,7 +2758,7 @@ var Dr = class {
|
|
|
3073
2758
|
}, this.clearError = () => {
|
|
3074
2759
|
this.status === "error" && (this.state.error = void 0, this.setStatus({ status: "ready" }));
|
|
3075
2760
|
}, this.addToolApprovalResponse = async ({ id: e, approved: t, reason: n, options: r }) => this.jobExecutor.run(async () => {
|
|
3076
|
-
let i = this.state.messages, a = (r) =>
|
|
2761
|
+
let i = this.state.messages, a = (r) => Z(r) && r.state === "approval-requested" && r.approval.id === e ? {
|
|
3077
2762
|
...r,
|
|
3078
2763
|
state: "approval-responded",
|
|
3079
2764
|
approval: {
|
|
@@ -3082,7 +2767,7 @@ var Dr = class {
|
|
|
3082
2767
|
approved: t,
|
|
3083
2768
|
reason: n
|
|
3084
2769
|
}
|
|
3085
|
-
} : r, o = i.findIndex((t) => t.parts.some((t) =>
|
|
2770
|
+
} : r, o = i.findIndex((t) => t.parts.some((t) => Z(t) && t.state === "approval-requested" && t.approval.id === e));
|
|
3086
2771
|
if (o !== -1) {
|
|
3087
2772
|
let e = i[o];
|
|
3088
2773
|
this.state.replaceMessage(o, {
|
|
@@ -3101,7 +2786,7 @@ var Dr = class {
|
|
|
3101
2786
|
}
|
|
3102
2787
|
});
|
|
3103
2788
|
}), this.addToolOutput = async ({ state: e = "output-available", toolCallId: t, output: n, errorText: r, options: i }) => this.jobExecutor.run(async () => {
|
|
3104
|
-
let a = this.state.messages, o = a[a.length - 1], s = (i) =>
|
|
2789
|
+
let a = this.state.messages, o = a[a.length - 1], s = (i) => Z(i) && i.toolCallId === t ? {
|
|
3105
2790
|
...i,
|
|
3106
2791
|
state: e,
|
|
3107
2792
|
output: n,
|
|
@@ -3193,10 +2878,10 @@ var Dr = class {
|
|
|
3193
2878
|
status: "submitted",
|
|
3194
2879
|
error: void 0
|
|
3195
2880
|
});
|
|
3196
|
-
let u = this.lastMessage, d = e === "submit-message" && i != null ? this.state.messages.findIndex((e) => e.id === i) : this.state.messages.length - 1, f = d === -1 ? u : this.state.messages[d], p = e === "resume-stream" && f?.role === "assistant" && f.parts.some((e) =>
|
|
2881
|
+
let u = this.lastMessage, d = e === "submit-message" && i != null ? this.state.messages.findIndex((e) => e.id === i) : this.state.messages.length - 1, f = d === -1 ? u : this.state.messages[d], p = e === "resume-stream" && f?.role === "assistant" && f.parts.some((e) => Z(e) && e.state === "input-streaming") ? this.state.snapshot(f) : void 0, m = d !== -1 && d < this.state.messages.length - 1 && f?.role === "assistant", h = !1, g = !1, _ = !1, v;
|
|
3197
2882
|
try {
|
|
3198
2883
|
let o = {
|
|
3199
|
-
state: e === "resume-stream" && this.resumableStreamState != null ? this.resumableStreamState :
|
|
2884
|
+
state: e === "resume-stream" && this.resumableStreamState != null ? this.resumableStreamState : Vn({
|
|
3200
2885
|
lastMessage: e === "resume-stream" ? p : e === "regenerate-message" ? void 0 : this.state.snapshot(f),
|
|
3201
2886
|
messageId: this.generateId()
|
|
3202
2887
|
}),
|
|
@@ -3215,8 +2900,8 @@ var Dr = class {
|
|
|
3215
2900
|
body: r,
|
|
3216
2901
|
trigger: e,
|
|
3217
2902
|
messageId: i
|
|
3218
|
-
}), await
|
|
3219
|
-
stream:
|
|
2903
|
+
}), await Un({
|
|
2904
|
+
stream: Hn({
|
|
3220
2905
|
stream: c,
|
|
3221
2906
|
onToolCall: this.onToolCall,
|
|
3222
2907
|
onData: this.onData,
|
|
@@ -3268,39 +2953,39 @@ var Dr = class {
|
|
|
3268
2953
|
});
|
|
3269
2954
|
}
|
|
3270
2955
|
};
|
|
3271
|
-
function
|
|
2956
|
+
function Qn({ messages: e }) {
|
|
3272
2957
|
let t = e[e.length - 1];
|
|
3273
2958
|
if (!t || t.role !== "assistant") return !1;
|
|
3274
|
-
let n = t.parts.reduce((e, t, n) => t.type === "step-start" ? n : e, -1), r = t.parts.slice(n + 1).filter(
|
|
2959
|
+
let n = t.parts.reduce((e, t, n) => t.type === "step-start" ? n : e, -1), r = t.parts.slice(n + 1).filter(Z);
|
|
3275
2960
|
return r.filter((e) => e.state === "approval-responded").length > 0 && r.every((e) => e.state === "output-available" && e.preliminary !== !0 || e.state === "output-error" || e.state === "output-denied" || e.state === "approval-responded");
|
|
3276
2961
|
}
|
|
3277
2962
|
//#endregion
|
|
3278
2963
|
//#region ../../node_modules/.pnpm/swrv@1.2.0_vue@3.5.43_typescript@6.0.3_/node_modules/swrv/esm/lib/hash.js
|
|
3279
|
-
var
|
|
3280
|
-
function
|
|
2964
|
+
var $n = /* @__PURE__ */ new WeakMap(), er = 0;
|
|
2965
|
+
function tr(e) {
|
|
3281
2966
|
if (!e.length) return "";
|
|
3282
2967
|
for (var t = "arg", n = 0; n < e.length; ++n) {
|
|
3283
2968
|
var r = void 0;
|
|
3284
|
-
e[n] === null || typeof e[n] != "object" && typeof e[n] != "function" ? r = typeof e[n] == "string" ? "\"" + e[n] + "\"" : String(e[n]) :
|
|
2969
|
+
e[n] === null || typeof e[n] != "object" && typeof e[n] != "function" ? r = typeof e[n] == "string" ? "\"" + e[n] + "\"" : String(e[n]) : $n.has(e[n]) ? r = $n.get(e[n]) : (r = er, $n.set(e[n], er++)), t += "@" + r;
|
|
3285
2970
|
}
|
|
3286
2971
|
return t;
|
|
3287
2972
|
}
|
|
3288
2973
|
//#endregion
|
|
3289
2974
|
//#region ../../node_modules/.pnpm/swrv@1.2.0_vue@3.5.43_typescript@6.0.3_/node_modules/swrv/esm/cache/index.js
|
|
3290
|
-
function
|
|
2975
|
+
function nr(e) {
|
|
3291
2976
|
if (typeof e == "function") try {
|
|
3292
2977
|
e = e();
|
|
3293
2978
|
} catch {
|
|
3294
2979
|
e = "";
|
|
3295
2980
|
}
|
|
3296
|
-
return e = Array.isArray(e) ?
|
|
2981
|
+
return e = Array.isArray(e) ? tr(e) : String(e || ""), e;
|
|
3297
2982
|
}
|
|
3298
|
-
var
|
|
2983
|
+
var rr = function() {
|
|
3299
2984
|
function e(e) {
|
|
3300
2985
|
e === void 0 && (e = 0), this.items = /* @__PURE__ */ new Map(), this.ttl = e;
|
|
3301
2986
|
}
|
|
3302
2987
|
return e.prototype.serializeKey = function(e) {
|
|
3303
|
-
return
|
|
2988
|
+
return nr(e);
|
|
3304
2989
|
}, e.prototype.get = function(e) {
|
|
3305
2990
|
var t = this.serializeKey(e);
|
|
3306
2991
|
return this.items.get(t);
|
|
@@ -3322,26 +3007,26 @@ var Fr = function() {
|
|
|
3322
3007
|
}();
|
|
3323
3008
|
//#endregion
|
|
3324
3009
|
//#region ../../node_modules/.pnpm/swrv@1.2.0_vue@3.5.43_typescript@6.0.3_/node_modules/swrv/esm/lib/web-preset.js
|
|
3325
|
-
function
|
|
3010
|
+
function ir() {
|
|
3326
3011
|
return navigator.onLine === void 0 || navigator.onLine;
|
|
3327
3012
|
}
|
|
3328
|
-
function
|
|
3013
|
+
function ar() {
|
|
3329
3014
|
return typeof document < "u" && document.visibilityState !== void 0 ? document.visibilityState !== "hidden" : !0;
|
|
3330
3015
|
}
|
|
3331
|
-
var
|
|
3332
|
-
isOnline:
|
|
3333
|
-
isDocumentVisible:
|
|
3016
|
+
var or = {
|
|
3017
|
+
isOnline: ir,
|
|
3018
|
+
isDocumentVisible: ar,
|
|
3334
3019
|
fetcher: function(e) {
|
|
3335
3020
|
return fetch(e).then(function(e) {
|
|
3336
3021
|
return e.json();
|
|
3337
3022
|
});
|
|
3338
3023
|
}
|
|
3339
|
-
},
|
|
3340
|
-
return
|
|
3024
|
+
}, Q = function() {
|
|
3025
|
+
return Q = Object.assign || function(e) {
|
|
3341
3026
|
for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n], t) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
|
|
3342
3027
|
return e;
|
|
3343
|
-
},
|
|
3344
|
-
},
|
|
3028
|
+
}, Q.apply(this, arguments);
|
|
3029
|
+
}, sr = function(e, t, n, r) {
|
|
3345
3030
|
function i(e) {
|
|
3346
3031
|
return e instanceof n ? e : new n(function(t) {
|
|
3347
3032
|
t(e);
|
|
@@ -3367,7 +3052,7 @@ var Rr = {
|
|
|
3367
3052
|
}
|
|
3368
3053
|
c((r = r.apply(e, t || [])).next());
|
|
3369
3054
|
});
|
|
3370
|
-
},
|
|
3055
|
+
}, $ = function(e, t) {
|
|
3371
3056
|
var n = {
|
|
3372
3057
|
label: 0,
|
|
3373
3058
|
sent: function() {
|
|
@@ -3440,7 +3125,7 @@ var Rr = {
|
|
|
3440
3125
|
done: !0
|
|
3441
3126
|
};
|
|
3442
3127
|
}
|
|
3443
|
-
},
|
|
3128
|
+
}, cr = function(e, t) {
|
|
3444
3129
|
var n = typeof Symbol == "function" && e[Symbol.iterator];
|
|
3445
3130
|
if (!n) return e;
|
|
3446
3131
|
var r = n.call(e), i, a = [], o;
|
|
@@ -3456,11 +3141,11 @@ var Rr = {
|
|
|
3456
3141
|
}
|
|
3457
3142
|
}
|
|
3458
3143
|
return a;
|
|
3459
|
-
},
|
|
3144
|
+
}, lr = function(e, t, n) {
|
|
3460
3145
|
if (n || arguments.length === 2) for (var r = 0, i = t.length, a; r < i; r++) (a || !(r in t)) && (a ||= Array.prototype.slice.call(t, 0, r), a[r] = t[r]);
|
|
3461
3146
|
return e.concat(a || Array.prototype.slice.call(t));
|
|
3462
|
-
},
|
|
3463
|
-
cache:
|
|
3147
|
+
}, ur = new rr(), dr = new rr(), fr = new rr(), pr = {
|
|
3148
|
+
cache: ur,
|
|
3464
3149
|
refreshInterval: 0,
|
|
3465
3150
|
ttl: 0,
|
|
3466
3151
|
serverTTL: 1e3,
|
|
@@ -3470,15 +3155,15 @@ var Rr = {
|
|
|
3470
3155
|
shouldRetryOnError: !0,
|
|
3471
3156
|
errorRetryInterval: 5e3,
|
|
3472
3157
|
errorRetryCount: 5,
|
|
3473
|
-
fetcher:
|
|
3474
|
-
isOnline:
|
|
3475
|
-
isDocumentVisible:
|
|
3158
|
+
fetcher: or.fetcher,
|
|
3159
|
+
isOnline: or.isOnline,
|
|
3160
|
+
isDocumentVisible: or.isDocumentVisible
|
|
3476
3161
|
};
|
|
3477
|
-
function
|
|
3478
|
-
var r =
|
|
3479
|
-
r ? r.data.push(t) :
|
|
3162
|
+
function mr(e, t, n) {
|
|
3163
|
+
var r = dr.get(e);
|
|
3164
|
+
r ? r.data.push(t) : dr.set(e, [t], n > 0 ? n + 5e3 : n);
|
|
3480
3165
|
}
|
|
3481
|
-
function
|
|
3166
|
+
function hr(e, t, n) {
|
|
3482
3167
|
if (n.isDocumentVisible() && !(n.errorRetryCount !== void 0 && t > n.errorRetryCount)) {
|
|
3483
3168
|
var r = Math.min(t || 0, n.errorRetryCount), i = r * n.errorRetryInterval;
|
|
3484
3169
|
setTimeout(function() {
|
|
@@ -3489,17 +3174,17 @@ function Jr(e, t, n) {
|
|
|
3489
3174
|
}, i);
|
|
3490
3175
|
}
|
|
3491
3176
|
}
|
|
3492
|
-
function
|
|
3177
|
+
function gr(e) {
|
|
3493
3178
|
var t = e.shouldRetry, n = t === void 0 ? void 0 : t, r = e.error;
|
|
3494
|
-
return typeof n == "function" ? n(r) : typeof n == "boolean" ? n :
|
|
3179
|
+
return typeof n == "function" ? n(r) : typeof n == "boolean" ? n : pr.shouldRetryOnError;
|
|
3495
3180
|
}
|
|
3496
|
-
var
|
|
3497
|
-
return n === void 0 && (n =
|
|
3181
|
+
var _r = function(e, t, n, r) {
|
|
3182
|
+
return n === void 0 && (n = ur), r === void 0 && (r = pr.ttl), sr(void 0, void 0, void 0, function() {
|
|
3498
3183
|
var i, a, o, s, c, l, u;
|
|
3499
|
-
return
|
|
3184
|
+
return $(this, function(d) {
|
|
3500
3185
|
switch (d.label) {
|
|
3501
3186
|
case 0:
|
|
3502
|
-
if (!
|
|
3187
|
+
if (!yr(t)) return [3, 5];
|
|
3503
3188
|
d.label = 1;
|
|
3504
3189
|
case 1: return d.trys.push([
|
|
3505
3190
|
1,
|
|
@@ -3521,7 +3206,7 @@ var Xr = function(e, t, n, r) {
|
|
|
3521
3206
|
} catch (e) {
|
|
3522
3207
|
console.error("swrv(mutate): failed to set cache", e);
|
|
3523
3208
|
}
|
|
3524
|
-
return l =
|
|
3209
|
+
return l = dr.get(e), l && l.data.length && (u = l.data.filter(function(t) {
|
|
3525
3210
|
return t.key === e;
|
|
3526
3211
|
}), u.forEach(function(e, t) {
|
|
3527
3212
|
c.data !== void 0 && (e.data = c.data), e.error = c.error, e.isValidating = c.isValidating, e.isLoading = c.isValidating, t !== u.length - 1 && delete u[t];
|
|
@@ -3530,12 +3215,12 @@ var Xr = function(e, t, n, r) {
|
|
|
3530
3215
|
});
|
|
3531
3216
|
});
|
|
3532
3217
|
};
|
|
3533
|
-
function
|
|
3218
|
+
function vr() {
|
|
3534
3219
|
for (var e = this, t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n];
|
|
3535
|
-
var r, i, a =
|
|
3220
|
+
var r, i, a = Q({}, pr), o = !1, s = !1;
|
|
3536
3221
|
if (!oe()) return console.error("useSWRV must be called inside setup() or an active effectScope()."), null;
|
|
3537
3222
|
var c = typeof window > "u" || typeof document > "u";
|
|
3538
|
-
t.length >= 1 && (r = t[0]), t.length >= 2 && (i = t[1]), t.length > 2 && (a =
|
|
3223
|
+
t.length >= 1 && (r = t[0]), t.length >= 2 && (i = t[1]), t.length > 2 && (a = Q(Q({}, a), t[2]));
|
|
3539
3224
|
var l = c ? a.serverTTL : a.ttl, u = typeof r == "function" ? r : b(r);
|
|
3540
3225
|
i === void 0 && (i = a.fetcher);
|
|
3541
3226
|
var d = null;
|
|
@@ -3547,32 +3232,32 @@ function Zr() {
|
|
|
3547
3232
|
key: null
|
|
3548
3233
|
});
|
|
3549
3234
|
var f = function(t, n) {
|
|
3550
|
-
return
|
|
3235
|
+
return sr(e, void 0, void 0, function() {
|
|
3551
3236
|
var e, r, s, c, p, m, h, g = this;
|
|
3552
|
-
return
|
|
3237
|
+
return $(this, function(_) {
|
|
3553
3238
|
switch (_.label) {
|
|
3554
3239
|
case 0: return e = d.data === void 0, r = u.value, r ? (s = a.cache.get(r), c = s && s.data, d.isValidating = !0, d.isLoading = !c, c && (d.data = c.data, d.error = c.error), p = t || i, !p || !a.isDocumentVisible() && !e || n?.forceRevalidate !== void 0 && !n?.forceRevalidate || s && (m = !!(Date.now() - s.createdAt >= a.dedupingInterval || n?.forceRevalidate), !m) ? (d.isValidating = !1, d.isLoading = !1, [2]) : (h = function() {
|
|
3555
|
-
return
|
|
3240
|
+
return sr(g, void 0, void 0, function() {
|
|
3556
3241
|
var e, t, i, s, c, u;
|
|
3557
|
-
return
|
|
3242
|
+
return $(this, function(m) {
|
|
3558
3243
|
switch (m.label) {
|
|
3559
|
-
case 0: return e =
|
|
3244
|
+
case 0: return e = fr.get(r), e ? [3, 2] : (t = Array.isArray(r) ? r : [r], i = p.apply(void 0, lr([], cr(t), !1)), fr.set(r, i, a.dedupingInterval), [4, _r(r, i, a.cache, l)]);
|
|
3560
3245
|
case 1: return m.sent(), [3, 4];
|
|
3561
|
-
case 2: return [4,
|
|
3246
|
+
case 2: return [4, _r(r, e.data, a.cache, l)];
|
|
3562
3247
|
case 3: m.sent(), m.label = 4;
|
|
3563
|
-
case 4: return d.isValidating = !1, d.isLoading = !1,
|
|
3248
|
+
case 4: return d.isValidating = !1, d.isLoading = !1, fr.delete(r), d.error !== void 0 && (s = gr({
|
|
3564
3249
|
shouldRetry: a.shouldRetryOnError,
|
|
3565
3250
|
error: d.error
|
|
3566
|
-
}), c =
|
|
3251
|
+
}), c = gr({
|
|
3567
3252
|
shouldRetry: !n || n.shouldRetryOnError,
|
|
3568
3253
|
error: d.error
|
|
3569
|
-
}), u = !o && s && c, u &&
|
|
3254
|
+
}), u = !o && s && c, u && hr(f, n ? n.errorRetryCount : 1, a)), [2];
|
|
3570
3255
|
}
|
|
3571
3256
|
});
|
|
3572
3257
|
});
|
|
3573
3258
|
}, c && a.revalidateDebounce ? (setTimeout(function() {
|
|
3574
|
-
return
|
|
3575
|
-
return
|
|
3259
|
+
return sr(g, void 0, void 0, function() {
|
|
3260
|
+
return $(this, function(e) {
|
|
3576
3261
|
switch (e.label) {
|
|
3577
3262
|
case 0: return o ? [3, 2] : [4, h()];
|
|
3578
3263
|
case 1: e.sent(), e.label = 2;
|
|
@@ -3588,16 +3273,16 @@ function Zr() {
|
|
|
3588
3273
|
});
|
|
3589
3274
|
});
|
|
3590
3275
|
}, p = function() {
|
|
3591
|
-
return
|
|
3592
|
-
return
|
|
3276
|
+
return sr(e, void 0, void 0, function() {
|
|
3277
|
+
return $(this, function(e) {
|
|
3593
3278
|
return [2, f(null, { shouldRetryOnError: !1 })];
|
|
3594
3279
|
});
|
|
3595
3280
|
});
|
|
3596
3281
|
}, m = null;
|
|
3597
3282
|
if (!c) {
|
|
3598
3283
|
var h = function() {
|
|
3599
|
-
return
|
|
3600
|
-
return
|
|
3284
|
+
return sr(e, void 0, void 0, function() {
|
|
3285
|
+
return $(this, function(e) {
|
|
3601
3286
|
switch (e.label) {
|
|
3602
3287
|
case 0: return d.error || !a.isOnline() ? [3, 2] : [4, f()];
|
|
3603
3288
|
case 1: return e.sent(), [3, 3];
|
|
@@ -3611,28 +3296,28 @@ function Zr() {
|
|
|
3611
3296
|
}
|
|
3612
3297
|
ce(function() {
|
|
3613
3298
|
o = !0, m &&= (clearTimeout(m), null), !c && a.revalidateOnFocus && (document.removeEventListener("visibilitychange", p, !1), window.removeEventListener("focus", p, !1));
|
|
3614
|
-
var e =
|
|
3299
|
+
var e = dr.get(u.value);
|
|
3615
3300
|
e && (e.data = e.data.filter(function(e) {
|
|
3616
3301
|
return e !== d;
|
|
3617
3302
|
}));
|
|
3618
3303
|
});
|
|
3619
3304
|
try {
|
|
3620
3305
|
de(u, function(e) {
|
|
3621
|
-
se(u) || (u.value = e), d.key = e, d.isValidating = !!e,
|
|
3306
|
+
se(u) || (u.value = e), d.key = e, d.isValidating = !!e, mr(u.value, d, l), !c && !s && u.value && f(), s = !1;
|
|
3622
3307
|
}, { immediate: !0 });
|
|
3623
3308
|
} catch {}
|
|
3624
|
-
return
|
|
3625
|
-
return f(e,
|
|
3309
|
+
return Q(Q({}, ue(d)), { mutate: function(e, t) {
|
|
3310
|
+
return f(e, Q(Q({}, t), { forceRevalidate: !0 }));
|
|
3626
3311
|
} });
|
|
3627
3312
|
}
|
|
3628
|
-
function
|
|
3313
|
+
function yr(e) {
|
|
3629
3314
|
return typeof e == "object" && !!e && typeof e.then == "function";
|
|
3630
3315
|
}
|
|
3631
3316
|
//#endregion
|
|
3632
3317
|
//#region ../../node_modules/.pnpm/swrv@1.2.0_vue@3.5.43_typescript@6.0.3_/node_modules/swrv/esm/index.js
|
|
3633
|
-
var
|
|
3634
|
-
|
|
3635
|
-
var
|
|
3318
|
+
var br = vr;
|
|
3319
|
+
br.default, br.default;
|
|
3320
|
+
var xr = class {
|
|
3636
3321
|
constructor(e) {
|
|
3637
3322
|
this.statusRef = b("ready"), this.errorRef = b(void 0), this.pushMessage = (e) => {
|
|
3638
3323
|
this.messagesRef.value = [...this.messagesRef.value, e];
|
|
@@ -3660,33 +3345,33 @@ var ei = class {
|
|
|
3660
3345
|
set error(e) {
|
|
3661
3346
|
this.errorRef.value = e;
|
|
3662
3347
|
}
|
|
3663
|
-
},
|
|
3348
|
+
}, Sr = class extends Zn {
|
|
3664
3349
|
constructor({ messages: e, ...t }) {
|
|
3665
3350
|
super({
|
|
3666
3351
|
...t,
|
|
3667
|
-
state: new
|
|
3352
|
+
state: new xr(e)
|
|
3668
3353
|
});
|
|
3669
3354
|
}
|
|
3670
|
-
},
|
|
3355
|
+
}, Cr = "voice-", wr = (e) => e.replace(/\s+/g, " ").trim().toLowerCase(), Tr = (e) => wr(e.parts.filter((e) => e.type === "text").map((e) => "text" in e ? e.text : "").join(" ")), Er = 8, Dr = (e, t) => {
|
|
3671
3356
|
let n = e.filter((e) => e.role === "user").map((e) => ({
|
|
3672
|
-
text:
|
|
3357
|
+
text: Tr(e),
|
|
3673
3358
|
taken: !1
|
|
3674
3359
|
}));
|
|
3675
3360
|
return t.filter((e) => {
|
|
3676
3361
|
if (!e.id.startsWith("voice-") || e.role !== "user") return !1;
|
|
3677
|
-
let t =
|
|
3362
|
+
let t = Tr(e), r = n.find((e) => !e.taken && e.text.length > 0 && (e.text === t || e.text.length >= Er && t.endsWith(e.text)));
|
|
3678
3363
|
return !r || (r.taken = !0, !1);
|
|
3679
3364
|
});
|
|
3680
|
-
},
|
|
3365
|
+
}, Or = (e) => {
|
|
3681
3366
|
let t = e.type ?? "";
|
|
3682
3367
|
return t === "dynamic-tool" ? e.toolName ?? "" : t.startsWith("tool-") ? t.slice(5) : "";
|
|
3683
|
-
},
|
|
3368
|
+
}, kr = ({ messages: e }) => {
|
|
3684
3369
|
let t = e[e.length - 1];
|
|
3685
3370
|
if (!t || t.role !== "assistant") return !1;
|
|
3686
|
-
let n = t.parts.reduce((e, t, n) => t.type === "step-start" ? n : e, -1), r = t.parts.slice(n + 1).filter((e) => !e.providerExecuted && ee(
|
|
3371
|
+
let n = t.parts.reduce((e, t, n) => t.type === "step-start" ? n : e, -1), r = t.parts.slice(n + 1).filter((e) => !e.providerExecuted && ee(Or(e)));
|
|
3687
3372
|
return r.length > 0 && r.every((e) => te.has(e.state ?? ""));
|
|
3688
3373
|
};
|
|
3689
|
-
function
|
|
3374
|
+
function Ar(e) {
|
|
3690
3375
|
return x(`chatbot-${e}`, () => {
|
|
3691
3376
|
let { t, te: n, locale: r } = pe({ useScope: "global" }), i = b(""), a = b(), o = b(e), s = b(), c = b(), l = b(), u = b(), d = b(), f = b(), p = b(), m = b(), h = b(), g = b(), _ = b(), v = b(), ee = b(), te = b(), oe = b(), se = b(), ce = b(!1), le = me(), ue = y(() => {
|
|
3692
3377
|
let e = u.value?.theme;
|
|
@@ -3697,7 +3382,7 @@ function li(e) {
|
|
|
3697
3382
|
"feedback"
|
|
3698
3383
|
].includes(e)) : g.value), ve = ae(y(() => `${o.value}-chatId`), null);
|
|
3699
3384
|
fe(() => {
|
|
3700
|
-
ve.value ||=
|
|
3385
|
+
ve.value ||= z();
|
|
3701
3386
|
});
|
|
3702
3387
|
let S = y({
|
|
3703
3388
|
get: () => ve.value,
|
|
@@ -3716,7 +3401,7 @@ function li(e) {
|
|
|
3716
3401
|
function xe(e) {
|
|
3717
3402
|
if (be(e)) {
|
|
3718
3403
|
let e = E.value.messages.filter((e) => e.role === "user"), t = e[e.length - 1], n = t ? ie(t) : void 0;
|
|
3719
|
-
S.value =
|
|
3404
|
+
S.value = z(), E.value.clearError(), C.value = void 0, n && E.value.sendMessage({ text: n });
|
|
3720
3405
|
return;
|
|
3721
3406
|
}
|
|
3722
3407
|
re.error(e), C.value = e, ye.value && (w.value = !0);
|
|
@@ -3728,9 +3413,9 @@ function li(e) {
|
|
|
3728
3413
|
})), Se = b(null), Ce = () => ({
|
|
3729
3414
|
...he(),
|
|
3730
3415
|
...Se.value ?? {}
|
|
3731
|
-
}), E = y(() => new
|
|
3416
|
+
}), E = y(() => new Sr({
|
|
3732
3417
|
id: S.value,
|
|
3733
|
-
transport: new
|
|
3418
|
+
transport: new Xn({
|
|
3734
3419
|
api: T.value.getChatEndpoint(o.value, x.value ? "reasoning" : "chat"),
|
|
3735
3420
|
prepareSendMessagesRequest: ({ messages: e, id: t }) => ({ body: {
|
|
3736
3421
|
id: t,
|
|
@@ -3755,16 +3440,16 @@ function li(e) {
|
|
|
3755
3440
|
credentials: "include",
|
|
3756
3441
|
headers: () => p.value ?? {}
|
|
3757
3442
|
}),
|
|
3758
|
-
sendAutomaticallyWhen: (e) =>
|
|
3443
|
+
sendAutomaticallyWhen: (e) => kr(e) || Qn(e),
|
|
3759
3444
|
onError: xe,
|
|
3760
3445
|
onFinish: () => {
|
|
3761
3446
|
let e = S.value;
|
|
3762
|
-
!x.value && !D.value.some((t) => t.id === e) &&
|
|
3447
|
+
!x.value && !D.value.some((t) => t.id === e) && I(o.value);
|
|
3763
3448
|
}
|
|
3764
3449
|
})), we = y(() => {
|
|
3765
3450
|
let e = u.value?.initialMessage;
|
|
3766
3451
|
return e?.[r.value] ? e[r.value] : n("message.defaultAgentWelcome") ? t("message.defaultAgentWelcome") : "";
|
|
3767
|
-
}), Te =
|
|
3452
|
+
}), Te = z(), Ee = y(() => ({
|
|
3768
3453
|
id: Te,
|
|
3769
3454
|
role: "assistant",
|
|
3770
3455
|
parts: [{
|
|
@@ -3794,8 +3479,8 @@ function li(e) {
|
|
|
3794
3479
|
}), Oe = y(() => {
|
|
3795
3480
|
let e = u.value?.messagePlaceholder;
|
|
3796
3481
|
return e?.[r.value] ? e[r.value] : n("placeholder.askAnything") ? t("placeholder.askAnything") : "";
|
|
3797
|
-
}), D = b([]), ke = b(!1), O = b([]), Ae = b(!1), je = b("chat"), k = b([]),
|
|
3798
|
-
async function
|
|
3482
|
+
}), D = b([]), ke = b(!1), O = b([]), Ae = b(!1), je = b("chat"), k = b([]), A = b(), Me = b(!1), j = b(!1), Ne = b(), Pe = b(!1), M = b(!1), Fe = b(), N = b(""), P = b([]), F = b(""), Ie = b(0);
|
|
3483
|
+
async function I(e) {
|
|
3799
3484
|
if (x.value) {
|
|
3800
3485
|
D.value = [];
|
|
3801
3486
|
return;
|
|
@@ -3809,7 +3494,7 @@ function li(e) {
|
|
|
3809
3494
|
ke.value = !1;
|
|
3810
3495
|
}
|
|
3811
3496
|
}
|
|
3812
|
-
async function
|
|
3497
|
+
async function Le() {
|
|
3813
3498
|
let e = S.value;
|
|
3814
3499
|
if (!e) {
|
|
3815
3500
|
O.value = [];
|
|
@@ -3824,84 +3509,84 @@ function li(e) {
|
|
|
3824
3509
|
Ae.value = !1;
|
|
3825
3510
|
}
|
|
3826
3511
|
}
|
|
3827
|
-
function
|
|
3512
|
+
function Re(e, t = !1) {
|
|
3828
3513
|
return T.value.getChatFileDownloadUrl(e, t);
|
|
3829
3514
|
}
|
|
3830
|
-
function
|
|
3515
|
+
function ze(e) {
|
|
3831
3516
|
return T.value.getChatFilePreviewUrl(e);
|
|
3832
3517
|
}
|
|
3833
|
-
async function
|
|
3518
|
+
async function Be(e) {
|
|
3834
3519
|
await T.value.deleteChatFile(e), O.value = O.value.filter((t) => t.documentId !== e);
|
|
3835
3520
|
}
|
|
3836
|
-
async function
|
|
3521
|
+
async function L(e, t) {
|
|
3837
3522
|
if (!x.value) try {
|
|
3838
3523
|
let n = await T.value.getChat(e, t);
|
|
3839
3524
|
if (t !== S.value || E.value.status !== "ready" || E.value.messages.length > 0) return;
|
|
3840
3525
|
n && (E.value.messages = n.messages, w.value = n.blocked ?? !1);
|
|
3841
3526
|
} catch {}
|
|
3842
3527
|
}
|
|
3843
|
-
let
|
|
3528
|
+
let R = () => {
|
|
3844
3529
|
let e = E.value.status;
|
|
3845
3530
|
return e === "submitted" || e === "streaming";
|
|
3846
|
-
},
|
|
3847
|
-
async function
|
|
3848
|
-
if (x.value ||
|
|
3849
|
-
let e = S.value, t =
|
|
3531
|
+
}, Ve = 0, He = 0;
|
|
3532
|
+
async function Ue() {
|
|
3533
|
+
if (x.value || R()) return "indeterminate";
|
|
3534
|
+
let e = S.value, t = Ve += 1;
|
|
3850
3535
|
try {
|
|
3851
3536
|
let n = await T.value.getChat(o.value, e);
|
|
3852
|
-
if (!n || e !== S.value ||
|
|
3853
|
-
|
|
3854
|
-
let r = n.messages, i =
|
|
3537
|
+
if (!n || e !== S.value || R() || t <= He) return "indeterminate";
|
|
3538
|
+
He = t;
|
|
3539
|
+
let r = n.messages, i = Dr(r, E.value.messages);
|
|
3855
3540
|
return E.value.messages = [...r, ...i], w.value = n.blocked ?? !1, i.length > 0 ? "pending" : "caught-up";
|
|
3856
3541
|
} catch {}
|
|
3857
3542
|
return "indeterminate";
|
|
3858
3543
|
}
|
|
3859
|
-
function
|
|
3544
|
+
function We(e) {
|
|
3860
3545
|
E.value.messages = [...E.value.messages, e];
|
|
3861
3546
|
}
|
|
3862
|
-
async function
|
|
3547
|
+
async function Ge(e) {
|
|
3863
3548
|
try {
|
|
3864
3549
|
k.value = await T.value.getMessageFeedbacks(e);
|
|
3865
3550
|
} catch {
|
|
3866
3551
|
k.value = [];
|
|
3867
3552
|
}
|
|
3868
3553
|
}
|
|
3869
|
-
function
|
|
3554
|
+
function Ke(e) {
|
|
3870
3555
|
let t = k.value.findIndex((t) => t.messageId === e.messageId);
|
|
3871
3556
|
t >= 0 ? k.value[t] = e : k.value.push(e);
|
|
3872
3557
|
}
|
|
3873
|
-
function
|
|
3558
|
+
function qe(e) {
|
|
3874
3559
|
let t = De.value, n = t.findIndex((t) => t.id === e.id), r = ie(e) ?? "", i = t.slice(0, n).reverse().find((e) => e.role === "user");
|
|
3875
3560
|
return {
|
|
3876
3561
|
userQuestion: ie(i ?? e) ?? "",
|
|
3877
3562
|
assistantMessage: r
|
|
3878
3563
|
};
|
|
3879
3564
|
}
|
|
3880
|
-
async function
|
|
3565
|
+
async function B(e, t) {
|
|
3881
3566
|
await Promise.all([
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3567
|
+
L(e, t),
|
|
3568
|
+
I(e),
|
|
3569
|
+
Ge(t)
|
|
3885
3570
|
]), Se.value || ge((e, t) => T.value.reverseGeocode(e, t, r.value)).then((e) => {
|
|
3886
3571
|
e && (Se.value = e);
|
|
3887
3572
|
});
|
|
3888
3573
|
}
|
|
3889
|
-
async function
|
|
3890
|
-
let e =
|
|
3574
|
+
async function Je() {
|
|
3575
|
+
let e = N.value.trim(), t = P.value.filter((e) => e.state === "done" && e.mediaSource !== void 0).map((e) => ({
|
|
3891
3576
|
type: "file",
|
|
3892
3577
|
mediaType: e.mediaSource.mimeType,
|
|
3893
3578
|
url: e.localUrl,
|
|
3894
3579
|
filename: e.mediaSource.name,
|
|
3895
3580
|
providerMetadata: { "8bot": { media: e.mediaSource } }
|
|
3896
3581
|
}));
|
|
3897
|
-
x.value && De.value.length > 0 && await
|
|
3582
|
+
x.value && De.value.length > 0 && await Ze(), F.value = e, Ie.value = E.value.messages.length;
|
|
3898
3583
|
let n = E.value.sendMessage;
|
|
3899
3584
|
n({
|
|
3900
3585
|
text: e,
|
|
3901
3586
|
files: t.length > 0 ? t : void 0
|
|
3902
|
-
}),
|
|
3587
|
+
}), N.value = "", V();
|
|
3903
3588
|
}
|
|
3904
|
-
function
|
|
3589
|
+
function Ye(e) {
|
|
3905
3590
|
let t = e.trim();
|
|
3906
3591
|
if (!t) return;
|
|
3907
3592
|
if (E.value.status !== "ready") {
|
|
@@ -3911,24 +3596,24 @@ function li(e) {
|
|
|
3911
3596
|
let n = E.value.sendMessage;
|
|
3912
3597
|
n({ text: t });
|
|
3913
3598
|
}
|
|
3914
|
-
async function
|
|
3915
|
-
let e =
|
|
3916
|
-
await E.value.stop(), e && (
|
|
3599
|
+
async function Xe() {
|
|
3600
|
+
let e = F.value.length > 0;
|
|
3601
|
+
await E.value.stop(), e && (N.value = F.value, E.value.messages = E.value.messages.slice(0, Ie.value), F.value = "");
|
|
3917
3602
|
}
|
|
3918
3603
|
de(() => E.value.status, (e) => {
|
|
3919
|
-
e === "ready" &&
|
|
3604
|
+
e === "ready" && F.value.length > 0 && (F.value = "");
|
|
3920
3605
|
});
|
|
3921
|
-
function
|
|
3922
|
-
for (let t of
|
|
3923
|
-
|
|
3606
|
+
function V(e = !1) {
|
|
3607
|
+
for (let t of P.value) (e || t.state !== "done") && URL.revokeObjectURL(t.localUrl);
|
|
3608
|
+
P.value = [], H.value = null;
|
|
3924
3609
|
}
|
|
3925
|
-
async function
|
|
3926
|
-
return
|
|
3610
|
+
async function Ze() {
|
|
3611
|
+
return F.value = "", await Xe(), S.value = z(), E.value.clearError(), C.value = void 0, w.value = !1, V(!0), G("chat"), S.value;
|
|
3927
3612
|
}
|
|
3928
|
-
async function
|
|
3929
|
-
E.value.status !== "ready" && (
|
|
3613
|
+
async function Qe(e) {
|
|
3614
|
+
E.value.status !== "ready" && (F.value = "", await Xe()), await E.value.regenerate(e);
|
|
3930
3615
|
}
|
|
3931
|
-
function
|
|
3616
|
+
function $e(e) {
|
|
3932
3617
|
if (e.tool === "requestGeolocation") {
|
|
3933
3618
|
let t = e.output;
|
|
3934
3619
|
"latitude" in t && (Se.value = {
|
|
@@ -3940,52 +3625,52 @@ function li(e) {
|
|
|
3940
3625
|
}
|
|
3941
3626
|
E.value.addToolOutput(e);
|
|
3942
3627
|
}
|
|
3943
|
-
function
|
|
3628
|
+
function et(e) {
|
|
3944
3629
|
E.value.addToolApprovalResponse(e);
|
|
3945
3630
|
}
|
|
3946
|
-
let
|
|
3947
|
-
|
|
3631
|
+
let tt = y(() => E.value.messages.reduce((e, t) => e + t.parts.filter((e) => e.type === "file").length, 0)), nt = y(() => _.value?.maxFilesPerMessage ?? 5), rt = y(() => _.value?.maxFilesPerChat ?? 20), it = y(() => Math.max(0, Math.min(nt.value - P.value.length, rt.value - tt.value - P.value.length))), at = y(() => it.value <= 0), H = b(null), ot = () => {
|
|
3632
|
+
H.value = null;
|
|
3948
3633
|
};
|
|
3949
|
-
de(
|
|
3950
|
-
e || (
|
|
3634
|
+
de(at, (e) => {
|
|
3635
|
+
e || (H.value = null);
|
|
3951
3636
|
});
|
|
3952
|
-
async function
|
|
3953
|
-
if (
|
|
3954
|
-
|
|
3637
|
+
async function st(e) {
|
|
3638
|
+
if (at.value) {
|
|
3639
|
+
H.value = rt.value - tt.value - P.value.length <= nt.value - P.value.length ? {
|
|
3955
3640
|
reason: "per-chat",
|
|
3956
|
-
max:
|
|
3641
|
+
max: rt.value
|
|
3957
3642
|
} : {
|
|
3958
3643
|
reason: "per-message",
|
|
3959
|
-
max:
|
|
3644
|
+
max: nt.value
|
|
3960
3645
|
};
|
|
3961
3646
|
return;
|
|
3962
3647
|
}
|
|
3963
|
-
let t =
|
|
3648
|
+
let t = z(), n = {
|
|
3964
3649
|
id: t,
|
|
3965
3650
|
file: e,
|
|
3966
3651
|
localUrl: URL.createObjectURL(e),
|
|
3967
3652
|
state: "uploading"
|
|
3968
3653
|
};
|
|
3969
|
-
|
|
3654
|
+
P.value = [...P.value, n];
|
|
3970
3655
|
try {
|
|
3971
3656
|
let n = await T.value.uploadMedia(o.value, S.value, e);
|
|
3972
|
-
|
|
3657
|
+
P.value = P.value.map((e) => e.id === t ? {
|
|
3973
3658
|
...e,
|
|
3974
3659
|
state: "done",
|
|
3975
3660
|
mediaSource: n
|
|
3976
3661
|
} : e);
|
|
3977
3662
|
} catch (e) {
|
|
3978
3663
|
let n = e instanceof Error ? e.message : "Upload failed";
|
|
3979
|
-
|
|
3664
|
+
P.value = P.value.map((e) => e.id === t ? {
|
|
3980
3665
|
...e,
|
|
3981
3666
|
state: "error",
|
|
3982
3667
|
error: n
|
|
3983
3668
|
} : e);
|
|
3984
3669
|
}
|
|
3985
3670
|
}
|
|
3986
|
-
async function
|
|
3987
|
-
let { userQuestion: n, assistantMessage: r } =
|
|
3988
|
-
|
|
3671
|
+
async function ct(e, t) {
|
|
3672
|
+
let { userQuestion: n, assistantMessage: r } = qe(e);
|
|
3673
|
+
Ke(await T.value.submitMessageFeedback({
|
|
3989
3674
|
messageId: e.id,
|
|
3990
3675
|
chatId: S.value,
|
|
3991
3676
|
agentId: o.value,
|
|
@@ -3994,75 +3679,75 @@ function li(e) {
|
|
|
3994
3679
|
assistantMessage: r
|
|
3995
3680
|
}));
|
|
3996
3681
|
}
|
|
3997
|
-
async function
|
|
3998
|
-
await
|
|
3682
|
+
async function lt(e) {
|
|
3683
|
+
await ct(e, "upvote");
|
|
3999
3684
|
}
|
|
4000
|
-
async function
|
|
4001
|
-
await
|
|
3685
|
+
async function U(e) {
|
|
3686
|
+
await ct(e, "downvote");
|
|
4002
3687
|
}
|
|
4003
|
-
function
|
|
4004
|
-
|
|
3688
|
+
function ut(e) {
|
|
3689
|
+
j.value = !1, Ne.value = void 0, A.value = e;
|
|
4005
3690
|
}
|
|
4006
|
-
async function
|
|
4007
|
-
if (
|
|
4008
|
-
|
|
4009
|
-
let { userQuestion: t, assistantMessage: n } =
|
|
4010
|
-
|
|
4011
|
-
messageId:
|
|
3691
|
+
async function dt(e) {
|
|
3692
|
+
if (A.value) try {
|
|
3693
|
+
Me.value = !0, j.value = !1, Ne.value = void 0;
|
|
3694
|
+
let { userQuestion: t, assistantMessage: n } = qe(A.value);
|
|
3695
|
+
Ke(await T.value.submitMessageFeedback({
|
|
3696
|
+
messageId: A.value.id,
|
|
4012
3697
|
chatId: S.value,
|
|
4013
3698
|
agentId: o.value,
|
|
4014
3699
|
userQuestion: t,
|
|
4015
3700
|
assistantMessage: n,
|
|
4016
3701
|
comment: e
|
|
4017
|
-
})),
|
|
3702
|
+
})), j.value = !0, await Ge(S.value);
|
|
4018
3703
|
} catch {
|
|
4019
|
-
|
|
3704
|
+
Ne.value = n("message.feedbackSubmitError") ? t("message.feedbackSubmitError") : "Failed to submit feedback";
|
|
4020
3705
|
} finally {
|
|
4021
|
-
|
|
3706
|
+
Me.value = !1;
|
|
4022
3707
|
}
|
|
4023
3708
|
}
|
|
4024
|
-
async function
|
|
3709
|
+
async function ft(e) {
|
|
4025
3710
|
try {
|
|
4026
|
-
|
|
3711
|
+
M.value = !0, Pe.value = !1, Fe.value = void 0, await T.value.submitLead({
|
|
4027
3712
|
agentId: o.value,
|
|
4028
3713
|
chatId: S.value,
|
|
4029
3714
|
...e
|
|
4030
|
-
}),
|
|
3715
|
+
}), Pe.value = !0;
|
|
4031
3716
|
} catch {
|
|
4032
|
-
|
|
3717
|
+
Fe.value = n("message.leadSubmitError") ? t("message.leadSubmitError") : "Failed to submit lead";
|
|
4033
3718
|
} finally {
|
|
4034
|
-
|
|
3719
|
+
M.value = !1;
|
|
4035
3720
|
}
|
|
4036
3721
|
}
|
|
4037
|
-
async function
|
|
3722
|
+
async function pt(e, t) {
|
|
4038
3723
|
let n = await T.value.updateChatTitle(o.value, e, t);
|
|
4039
3724
|
D.value = D.value.map((t) => t.id === e ? {
|
|
4040
3725
|
...t,
|
|
4041
3726
|
title: n.title
|
|
4042
3727
|
} : t);
|
|
4043
3728
|
}
|
|
4044
|
-
async function
|
|
4045
|
-
await T.value.deleteChat(o.value, e), D.value = D.value.filter((t) => t.id !== e), S.value === e && await
|
|
3729
|
+
async function W(e) {
|
|
3730
|
+
await T.value.deleteChat(o.value, e), D.value = D.value.filter((t) => t.id !== e), S.value === e && await Ze();
|
|
4046
3731
|
}
|
|
4047
|
-
function
|
|
3732
|
+
function G(e) {
|
|
4048
3733
|
je.value = e;
|
|
4049
3734
|
}
|
|
4050
|
-
let
|
|
4051
|
-
function
|
|
3735
|
+
let mt;
|
|
3736
|
+
function ht(e) {
|
|
4052
3737
|
let t = () => T.value.getChat(o.value, e).then((e) => e !== null);
|
|
4053
3738
|
return t().catch(() => t().catch(() => !1));
|
|
4054
3739
|
}
|
|
4055
3740
|
return de(l, async (e) => {
|
|
4056
|
-
if (!e || e ===
|
|
4057
|
-
let t =
|
|
4058
|
-
if (
|
|
4059
|
-
let n = S.value, r = !x.value && await
|
|
3741
|
+
if (!e || e === mt) return;
|
|
3742
|
+
let t = mt;
|
|
3743
|
+
if (mt = e, t === void 0) return;
|
|
3744
|
+
let n = S.value, r = !x.value && await ht(n);
|
|
4060
3745
|
if (l.value === e && S.value === n) {
|
|
4061
3746
|
if (r) {
|
|
4062
|
-
|
|
3747
|
+
I(o.value);
|
|
4063
3748
|
return;
|
|
4064
3749
|
}
|
|
4065
|
-
D.value = [], k.value = [], O.value = [], await
|
|
3750
|
+
D.value = [], k.value = [], O.value = [], await Ze(), N.value = "";
|
|
4066
3751
|
}
|
|
4067
3752
|
}), {
|
|
4068
3753
|
apiClient: T,
|
|
@@ -4094,54 +3779,54 @@ function li(e) {
|
|
|
4094
3779
|
isLoadingConversations: ke,
|
|
4095
3780
|
chatFiles: O,
|
|
4096
3781
|
isLoadingChatFiles: Ae,
|
|
4097
|
-
input:
|
|
4098
|
-
pendingAttachments:
|
|
4099
|
-
isAttachmentLimitReached:
|
|
4100
|
-
fileLimitError:
|
|
3782
|
+
input: N,
|
|
3783
|
+
pendingAttachments: P,
|
|
3784
|
+
isAttachmentLimitReached: at,
|
|
3785
|
+
fileLimitError: H,
|
|
4101
3786
|
localChatId: S,
|
|
4102
3787
|
isConversationBlocked: w,
|
|
4103
3788
|
inputMessagePlaceholder: Oe,
|
|
4104
3789
|
chatError: C,
|
|
4105
3790
|
activeView: je,
|
|
4106
3791
|
messageFeedbacks: k,
|
|
4107
|
-
feedbackDialogMessage:
|
|
4108
|
-
isFeedbackSubmitting:
|
|
4109
|
-
isFeedbackSubmitted:
|
|
4110
|
-
feedbackSubmitError:
|
|
4111
|
-
isLeadSubmitted:
|
|
4112
|
-
isLoadingSubmitLead:
|
|
4113
|
-
submitLeadError:
|
|
3792
|
+
feedbackDialogMessage: A,
|
|
3793
|
+
isFeedbackSubmitting: Me,
|
|
3794
|
+
isFeedbackSubmitted: j,
|
|
3795
|
+
feedbackSubmitError: Ne,
|
|
3796
|
+
isLeadSubmitted: Pe,
|
|
3797
|
+
isLoadingSubmitLead: M,
|
|
3798
|
+
submitLeadError: Fe,
|
|
4114
3799
|
buildDeviceContext: Ce,
|
|
4115
|
-
initialize:
|
|
4116
|
-
loadConversations:
|
|
4117
|
-
loadChatFiles:
|
|
4118
|
-
refreshMessages:
|
|
4119
|
-
appendMessage:
|
|
4120
|
-
getChatFileUrl:
|
|
4121
|
-
getChatFilePreviewUrl:
|
|
4122
|
-
deleteChatFile:
|
|
4123
|
-
handleSubmit:
|
|
4124
|
-
sendMessage:
|
|
4125
|
-
stopGeneration:
|
|
4126
|
-
startNewChat:
|
|
4127
|
-
regenerate:
|
|
4128
|
-
addToolOutput:
|
|
4129
|
-
addToolApprovalResponse:
|
|
4130
|
-
handleFileSelect:
|
|
4131
|
-
clearFileLimitError:
|
|
4132
|
-
clearPendingAttachments:
|
|
4133
|
-
onUpvote:
|
|
4134
|
-
onDownvote:
|
|
4135
|
-
onFeedback:
|
|
4136
|
-
onFeedbackSubmit:
|
|
4137
|
-
onLeadSubmit:
|
|
4138
|
-
navigate:
|
|
4139
|
-
renameChatTitle:
|
|
4140
|
-
deleteChat:
|
|
3800
|
+
initialize: B,
|
|
3801
|
+
loadConversations: I,
|
|
3802
|
+
loadChatFiles: Le,
|
|
3803
|
+
refreshMessages: Ue,
|
|
3804
|
+
appendMessage: We,
|
|
3805
|
+
getChatFileUrl: Re,
|
|
3806
|
+
getChatFilePreviewUrl: ze,
|
|
3807
|
+
deleteChatFile: Be,
|
|
3808
|
+
handleSubmit: Je,
|
|
3809
|
+
sendMessage: Ye,
|
|
3810
|
+
stopGeneration: Xe,
|
|
3811
|
+
startNewChat: Ze,
|
|
3812
|
+
regenerate: Qe,
|
|
3813
|
+
addToolOutput: $e,
|
|
3814
|
+
addToolApprovalResponse: et,
|
|
3815
|
+
handleFileSelect: st,
|
|
3816
|
+
clearFileLimitError: ot,
|
|
3817
|
+
clearPendingAttachments: V,
|
|
3818
|
+
onUpvote: lt,
|
|
3819
|
+
onDownvote: U,
|
|
3820
|
+
onFeedback: ut,
|
|
3821
|
+
onFeedbackSubmit: dt,
|
|
3822
|
+
onLeadSubmit: ft,
|
|
3823
|
+
navigate: G,
|
|
3824
|
+
renameChatTitle: pt,
|
|
3825
|
+
deleteChat: W
|
|
4141
3826
|
};
|
|
4142
3827
|
})();
|
|
4143
3828
|
}
|
|
4144
3829
|
//#endregion
|
|
4145
|
-
export {
|
|
3830
|
+
export { z as a, Xn as i, Ar as n, Sr as r, Cr as t };
|
|
4146
3831
|
|
|
4147
|
-
//# sourceMappingURL=useChatbotStore-
|
|
3832
|
+
//# sourceMappingURL=useChatbotStore-BwrBZJCq.js.map
|