@8wave/ai-elements 0.101.0 → 0.102.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{Agent-DMCeO6o-.js → Agent-Cq-9OZHI.js} +77 -65
- package/dist/_chunks/Agent-Cq-9OZHI.js.map +1 -0
- package/dist/_chunks/{Document-C1Fp99qu.js → Document-s7Ct8xXa.js} +2 -2
- package/dist/_chunks/{Document-C1Fp99qu.js.map → Document-s7Ct8xXa.js.map} +1 -1
- package/dist/_chunks/{Media-c-RubI3_.js → Media-CMWDdtLL.js} +2 -2
- package/dist/_chunks/Media-CMWDdtLL.js.map +1 -0
- package/dist/_chunks/{PkToolRequestGeolocation-OZYwTIls.js → PkToolRequestGeolocation-hAaQJW-t.js} +2 -2
- package/dist/_chunks/{PkToolRequestGeolocation-OZYwTIls.js.map → PkToolRequestGeolocation-hAaQJW-t.js.map} +1 -1
- package/dist/_chunks/{PkToolRequestOAuthConnection-HmWtu2b3.js → PkToolRequestOAuthConnection-Bf_zoT2r.js} +2 -2
- package/dist/_chunks/{PkToolRequestOAuthConnection-HmWtu2b3.js.map → PkToolRequestOAuthConnection-Bf_zoT2r.js.map} +1 -1
- package/dist/_chunks/{PkToolShowForm-BzopoW7z.js → PkToolShowForm-CdUUAjPc.js} +2 -2
- package/dist/_chunks/{PkToolShowForm-BzopoW7z.js.map → PkToolShowForm-CdUUAjPc.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSources-Blw5XOA7.js → PkToolShowSources-U7etupUP.js} +2 -2
- package/dist/_chunks/{PkToolShowSources-Blw5XOA7.js.map → PkToolShowSources-U7etupUP.js.map} +1 -1
- package/dist/_chunks/{PkToolShowSuggestedReply-nsXsvLUW.js → PkToolShowSuggestedReply-BvHgjMQ4.js} +2 -2
- package/dist/_chunks/{PkToolShowSuggestedReply-nsXsvLUW.js.map → PkToolShowSuggestedReply-BvHgjMQ4.js.map} +1 -1
- package/dist/ai-elements.es.js +6006 -5923
- package/dist/ai-elements.es.js.map +1 -1
- package/dist-vue/PkChatbot.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/{Agent-WEwgRwnY.js → Agent-Cy-XE9N1.js} +77 -66
- package/dist-vue/_chunks/Agent-Cy-XE9N1.js.map +1 -0
- package/dist-vue/_chunks/{Document-Vx3oKWp3.js → Document-B6xVkCfQ.js} +8 -8
- package/dist-vue/_chunks/{Document-Vx3oKWp3.js.map → Document-B6xVkCfQ.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbot-1Y7fGR-C.js → PkChatbot-CHe6t-LR.js} +6 -6
- package/dist-vue/_chunks/{PkChatbot-1Y7fGR-C.js.map → PkChatbot-CHe6t-LR.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotMessages-C6X92Igt.js → PkChatbotMessages-CWPSx2ce.js} +8 -8
- package/dist-vue/_chunks/{PkChatbotMessages-C6X92Igt.js.map → PkChatbotMessages-CWPSx2ce.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewChat-CBvcSg0J.js → PkChatbotViewChat-DeeGCFJf.js} +2674 -2651
- package/dist-vue/_chunks/PkChatbotViewChat-DeeGCFJf.js.map +1 -0
- package/dist-vue/_chunks/{PkChatbotViewConversations-BT5ojZEm.js → PkChatbotViewConversations-DXwqumyn.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewConversations-BT5ojZEm.js.map → PkChatbotViewConversations-DXwqumyn.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewFiles-DHzFAQZP.js → PkChatbotViewFiles-B4u87oH6.js} +3 -3
- package/dist-vue/_chunks/{PkChatbotViewFiles-DHzFAQZP.js.map → PkChatbotViewFiles-B4u87oH6.js.map} +1 -1
- package/dist-vue/_chunks/{PkChatbotViewProfile-DgN0Pydw.js → PkChatbotViewProfile-C_A0AP8x.js} +2 -2
- package/dist-vue/_chunks/{PkChatbotViewProfile-DgN0Pydw.js.map → PkChatbotViewProfile-C_A0AP8x.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolRequestGeolocation-B1K2fN7U.js → PkToolRequestGeolocation-CaHo_418.js} +2 -2
- package/dist-vue/_chunks/{PkToolRequestGeolocation-B1K2fN7U.js.map → PkToolRequestGeolocation-CaHo_418.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolRequestOAuthConnection-D-qoxuPc.js → PkToolRequestOAuthConnection-URjYDFhm.js} +2 -2
- package/dist-vue/_chunks/{PkToolRequestOAuthConnection-D-qoxuPc.js.map → PkToolRequestOAuthConnection-URjYDFhm.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowDiagram-BvOy4aeQ.js → PkToolShowDiagram-CuQyY0uv.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowDiagram-BvOy4aeQ.js.map → PkToolShowDiagram-CuQyY0uv.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowForm-BzzeoKss.js → PkToolShowForm-vXgu3bZO.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowForm-BzzeoKss.js.map → PkToolShowForm-vXgu3bZO.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSources-DdfHFaPA.js → PkToolShowSources-Die_j1bn.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSources-DdfHFaPA.js.map → PkToolShowSources-Die_j1bn.js.map} +1 -1
- package/dist-vue/_chunks/{PkToolShowSuggestedReply-DSd1dnZM.js → PkToolShowSuggestedReply-CryAdy6t.js} +2 -2
- package/dist-vue/_chunks/{PkToolShowSuggestedReply-DSd1dnZM.js.map → PkToolShowSuggestedReply-CryAdy6t.js.map} +1 -1
- package/dist-vue/_chunks/{createChatbotApiClient-xbpuy6e1.js → createChatbotApiClient-CoTSUkuj.js} +107 -99
- package/dist-vue/_chunks/createChatbotApiClient-CoTSUkuj.js.map +1 -0
- package/dist-vue/_chunks/{useChatbotStore-DWLLr7sg.js → useChatbotStore-BcLvyaIV.js} +1043 -1014
- package/dist-vue/_chunks/{useChatbotStore-DWLLr7sg.js.map → useChatbotStore-BcLvyaIV.js.map} +1 -1
- package/dist-vue/api.js +1 -1
- package/dist-vue/composables.js +2 -2
- package/dist-vue/index.js +63 -63
- package/dist-vue/index.js.map +1 -1
- package/dist-vue/locales.js +2 -0
- package/dist-vue/packages/components/src/chat/PkAgentSettingsPanel.d.ts +2 -2
- package/dist-vue/packages/components/src/chat/PkReasoningSettings.d.ts +2 -2
- package/dist-vue/packages/components/src/chat/PkVoiceSession.d.ts +12 -0
- package/dist-vue/packages/components/src/chat/useVoiceSession.d.ts +7 -0
- package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +40 -10
- package/dist-vue/packages/models/src/schema/Agent.d.ts +39 -7
- package/dist-vue/packages/models/src/schema/AgentChatStatistics.d.ts +42 -0
- package/dist-vue/packages/models/src/schema/Chat.d.ts +46 -1
- package/dist-vue/packages/models/src/schema/ReasoningChat.d.ts +2 -2
- package/dist-vue/packages/models/src/schema/SubAgent.d.ts +2 -2
- package/dist-vue/packages/models/src/schema/constants.d.ts +7 -3
- package/package.json +1 -1
- package/dist/_chunks/Agent-DMCeO6o-.js.map +0 -1
- package/dist/_chunks/Media-c-RubI3_.js.map +0 -1
- package/dist-vue/_chunks/Agent-WEwgRwnY.js.map +0 -1
- package/dist-vue/_chunks/PkChatbotViewChat-CBvcSg0J.js.map +0 -1
- package/dist-vue/_chunks/createChatbotApiClient-xbpuy6e1.js.map +0 -1
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { C as e, _ as t, a as n, b as r, c as i, d as a, f as o, g as s, h as c, i as l, l as u, m as d, n as f, o as p, p as m, r as h, v as g, w as _, y as ee } from "./schemas-COkEQ0wM.js";
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
2
|
+
import { D as te, y as ne } from "./Agent-Cy-XE9N1.js";
|
|
3
|
+
import { r as re, t as ie } from "./createChatbotApiClient-CoTSUkuj.js";
|
|
4
|
+
import { t as ae } from "./src-BbpxM17m.js";
|
|
5
|
+
import { n as oe } from "./message-RohfrdWS.js";
|
|
6
|
+
import { t as se } from "./useSafeLocalStorage-D5Aa7nQY.js";
|
|
7
|
+
import { computed as v, getCurrentScope as ce, isReadonly as le, onScopeDispose as ue, reactive as de, ref as y, toRefs as b, watch as fe, watchEffect as pe } from "vue";
|
|
8
|
+
import { useI18n as me } from "vue-i18n";
|
|
9
|
+
import { usePreferredDark as he } from "@vueuse/core";
|
|
10
|
+
import { defineStore as ge } from "pinia";
|
|
10
11
|
//#region ../../packages/utils/src/device-context.ts
|
|
11
|
-
function
|
|
12
|
+
function _e() {
|
|
12
13
|
let e = navigator.connection, t = navigator.userAgentData;
|
|
13
14
|
return {
|
|
14
15
|
dateTime: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -38,7 +39,7 @@ function he() {
|
|
|
38
39
|
historyLength: window.history.length
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
|
-
async function
|
|
42
|
+
async function ve(e) {
|
|
42
43
|
if (!navigator.geolocation || !navigator.permissions) return null;
|
|
43
44
|
try {
|
|
44
45
|
if ((await navigator.permissions.query({ name: "geolocation" })).state !== "granted") return null;
|
|
@@ -57,12 +58,12 @@ async function ge(e) {
|
|
|
57
58
|
}
|
|
58
59
|
//#endregion
|
|
59
60
|
//#region ../../node_modules/.pnpm/@ai-sdk+provider@4.0.7/node_modules/@ai-sdk/provider/dist/index.js
|
|
60
|
-
var
|
|
61
|
+
var ye = "vercel.ai.error", x = Symbol.for(ye), S, C, w = class e extends (C = Error, S = x, C) {
|
|
61
62
|
constructor({ name: e, message: t, cause: n }) {
|
|
62
|
-
super(t), this[
|
|
63
|
+
super(t), this[S] = !0, this.name = e, this.cause = n;
|
|
63
64
|
}
|
|
64
65
|
static isInstance(t) {
|
|
65
|
-
return e.hasMarker(t,
|
|
66
|
+
return e.hasMarker(t, ye);
|
|
66
67
|
}
|
|
67
68
|
static hasMarker(e, t) {
|
|
68
69
|
let n = Symbol.for(t);
|
|
@@ -72,30 +73,30 @@ var _e = "vercel.ai.error", b = Symbol.for(_e), ve, ye, x = class e extends (ye
|
|
|
72
73
|
function be(e) {
|
|
73
74
|
return e == null ? "unknown error" : typeof e == "string" ? e : e instanceof Error ? e.toString() : JSON.stringify(e);
|
|
74
75
|
}
|
|
75
|
-
var
|
|
76
|
+
var xe = "AI_InvalidArgumentError", T = `vercel.ai.error.${xe}`, Se = Symbol.for(T), Ce, E, we = class extends (E = w, Ce = Se, E) {
|
|
76
77
|
constructor({ message: e, cause: t, argument: n }) {
|
|
77
78
|
super({
|
|
78
|
-
name:
|
|
79
|
+
name: xe,
|
|
79
80
|
message: e,
|
|
80
81
|
cause: t
|
|
81
82
|
}), this[Ce] = !0, this.argument = n;
|
|
82
83
|
}
|
|
83
84
|
static isInstance(e) {
|
|
84
|
-
return
|
|
85
|
+
return w.hasMarker(e, T);
|
|
85
86
|
}
|
|
86
|
-
}, Te = "AI_JSONParseError",
|
|
87
|
+
}, Te = "AI_JSONParseError", Ee = `vercel.ai.error.${Te}`, De = Symbol.for(Ee), Oe, D, ke = class extends (D = w, Oe = De, D) {
|
|
87
88
|
constructor({ text: e, cause: t }) {
|
|
88
89
|
super({
|
|
89
90
|
name: Te,
|
|
90
91
|
message: `JSON parsing failed: Text: ${e}.
|
|
91
92
|
Error message: ${be(t)}`,
|
|
92
93
|
cause: t
|
|
93
|
-
}), this[
|
|
94
|
+
}), this[Oe] = !0, this.text = e;
|
|
94
95
|
}
|
|
95
96
|
static isInstance(e) {
|
|
96
|
-
return
|
|
97
|
+
return w.hasMarker(e, Ee);
|
|
97
98
|
}
|
|
98
|
-
},
|
|
99
|
+
}, O = "AI_TypeValidationError", Ae = `vercel.ai.error.${O}`, je = Symbol.for(Ae), k, A, j = class e extends (A = w, k = je, A) {
|
|
99
100
|
constructor({ value: e, cause: t, context: n }) {
|
|
100
101
|
let r = "Type validation failed";
|
|
101
102
|
if (n?.field && (r += ` for ${n.field}`), n?.entityName || n?.entityId) {
|
|
@@ -104,14 +105,14 @@ Error message: ${be(t)}`,
|
|
|
104
105
|
n.entityName && e.push(n.entityName), n.entityId && e.push(`id: "${n.entityId}"`), r += e.join(", "), r += ")";
|
|
105
106
|
}
|
|
106
107
|
super({
|
|
107
|
-
name:
|
|
108
|
+
name: O,
|
|
108
109
|
message: `${r}: Value: ${JSON.stringify(e)}.
|
|
109
110
|
Error message: ${be(t)}`,
|
|
110
111
|
cause: t
|
|
111
|
-
}), this[
|
|
112
|
+
}), this[k] = !0, this.value = e, this.context = n;
|
|
112
113
|
}
|
|
113
114
|
static isInstance(e) {
|
|
114
|
-
return
|
|
115
|
+
return w.hasMarker(e, Ae);
|
|
115
116
|
}
|
|
116
117
|
static wrap({ value: t, cause: n, context: r }) {
|
|
117
118
|
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({
|
|
@@ -120,15 +121,15 @@ Error message: ${be(t)}`,
|
|
|
120
121
|
context: r
|
|
121
122
|
});
|
|
122
123
|
}
|
|
123
|
-
},
|
|
124
|
+
}, M = class extends Error {
|
|
124
125
|
constructor(e, t) {
|
|
125
126
|
super(e), this.name = "ParseError", this.type = t.type, this.field = t.field, this.value = t.value, this.line = t.line;
|
|
126
127
|
}
|
|
127
|
-
},
|
|
128
|
-
function
|
|
129
|
-
function
|
|
128
|
+
}, Me = 10, Ne = 13, N = 32;
|
|
129
|
+
function Pe(e) {}
|
|
130
|
+
function Fe(e) {
|
|
130
131
|
if (typeof e == "function") throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");
|
|
131
|
-
let { onEvent: t =
|
|
132
|
+
let { onEvent: t = Pe, onError: n = Pe, onRetry: r = Pe, onComment: i, maxBufferSize: a } = e, o = [], s = 0, c = !0, l, u = "", d = 0, f, p = !1;
|
|
132
133
|
function m(e) {
|
|
133
134
|
if (p) throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");
|
|
134
135
|
if (c && (c = !1, e.charCodeAt(0) === 239 && e.charCodeAt(1) === 187 && e.charCodeAt(2) === 191 && (e = e.slice(3))), o.length === 0) {
|
|
@@ -147,7 +148,7 @@ function Pe(e) {
|
|
|
147
148
|
n !== "" && (o.push(n), s = n.length), h();
|
|
148
149
|
}
|
|
149
150
|
function h() {
|
|
150
|
-
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
|
|
151
|
+
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" }))));
|
|
151
152
|
}
|
|
152
153
|
function g(e) {
|
|
153
154
|
let n = 0;
|
|
@@ -163,9 +164,9 @@ function Pe(e) {
|
|
|
163
164
|
continue;
|
|
164
165
|
}
|
|
165
166
|
let i = e.charCodeAt(n);
|
|
166
|
-
if (
|
|
167
|
-
let i = e.charCodeAt(n + 5) ===
|
|
168
|
-
if (d === 0 && e.charCodeAt(r + 1) ===
|
|
167
|
+
if (P(e, n, i)) {
|
|
168
|
+
let i = e.charCodeAt(n + 5) === N ? n + 6 : n + 5, a = e.slice(i, r);
|
|
169
|
+
if (d === 0 && e.charCodeAt(r + 1) === Me) {
|
|
169
170
|
t({
|
|
170
171
|
id: l,
|
|
171
172
|
event: f,
|
|
@@ -175,7 +176,7 @@ function Pe(e) {
|
|
|
175
176
|
}
|
|
176
177
|
u = d === 0 ? a : `${u}
|
|
177
178
|
${a}`, d++;
|
|
178
|
-
} else
|
|
179
|
+
} else F(e, n, i) ? f = e.slice(e.charCodeAt(n + 6) === N ? n + 7 : n + 6, r) || void 0 : _(e, n, r);
|
|
179
180
|
n = r + 1, r = e.indexOf("\n", n);
|
|
180
181
|
}
|
|
181
182
|
return e.slice(n);
|
|
@@ -183,7 +184,7 @@ ${a}`, d++;
|
|
|
183
184
|
for (; n < e.length;) {
|
|
184
185
|
let t = e.indexOf("\r", n), r = e.indexOf("\n", n), i = -1;
|
|
185
186
|
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;
|
|
186
|
-
_(e, n, i), n = i + 1, e.charCodeAt(n - 1) === Ne && e.charCodeAt(n) ===
|
|
187
|
+
_(e, n, i), n = i + 1, e.charCodeAt(n - 1) === Ne && e.charCodeAt(n) === Me && n++;
|
|
187
188
|
}
|
|
188
189
|
return e.slice(n);
|
|
189
190
|
}
|
|
@@ -193,25 +194,25 @@ ${a}`, d++;
|
|
|
193
194
|
return;
|
|
194
195
|
}
|
|
195
196
|
let r = e.charCodeAt(t);
|
|
196
|
-
if (
|
|
197
|
-
let r = e.charCodeAt(t + 5) ===
|
|
197
|
+
if (P(e, t, r)) {
|
|
198
|
+
let r = e.charCodeAt(t + 5) === N ? t + 6 : t + 5, i = e.slice(r, n);
|
|
198
199
|
u = d === 0 ? i : `${u}
|
|
199
200
|
${i}`, d++;
|
|
200
201
|
return;
|
|
201
202
|
}
|
|
202
|
-
if (
|
|
203
|
-
f = e.slice(e.charCodeAt(t + 6) ===
|
|
203
|
+
if (F(e, t, r)) {
|
|
204
|
+
f = e.slice(e.charCodeAt(t + 6) === N ? t + 7 : t + 6, n) || void 0;
|
|
204
205
|
return;
|
|
205
206
|
}
|
|
206
207
|
if (r === 105 && e.charCodeAt(t + 1) === 100 && e.charCodeAt(t + 2) === 58) {
|
|
207
|
-
let r = e.slice(e.charCodeAt(t + 3) ===
|
|
208
|
+
let r = e.slice(e.charCodeAt(t + 3) === N ? t + 4 : t + 3, n);
|
|
208
209
|
l = r.includes("\0") ? void 0 : r;
|
|
209
210
|
return;
|
|
210
211
|
}
|
|
211
212
|
if (r === 58) {
|
|
212
213
|
if (i) {
|
|
213
214
|
let r = e.slice(t, n);
|
|
214
|
-
i(r.slice(e.charCodeAt(t + 1) ===
|
|
215
|
+
i(r.slice(e.charCodeAt(t + 1) === N ? 2 : 1));
|
|
215
216
|
}
|
|
216
217
|
return;
|
|
217
218
|
}
|
|
@@ -220,7 +221,7 @@ ${i}`, d++;
|
|
|
220
221
|
ee(a, "", a);
|
|
221
222
|
return;
|
|
222
223
|
}
|
|
223
|
-
let s = a.slice(0, o), c = a.charCodeAt(o + 1) ===
|
|
224
|
+
let s = a.slice(0, o), c = a.charCodeAt(o + 1) === N ? 2 : 1;
|
|
224
225
|
ee(s, a.slice(o + c), a);
|
|
225
226
|
}
|
|
226
227
|
function ee(e, t, i) {
|
|
@@ -236,13 +237,13 @@ ${t}`, d++;
|
|
|
236
237
|
l = t.includes("\0") ? void 0 : t;
|
|
237
238
|
break;
|
|
238
239
|
case "retry":
|
|
239
|
-
/^\d+$/.test(t) ? r(parseInt(t, 10)) : n(new
|
|
240
|
+
/^\d+$/.test(t) ? r(parseInt(t, 10)) : n(new M(`Invalid \`retry\` value: "${t}"`, {
|
|
240
241
|
type: "invalid-retry",
|
|
241
242
|
value: t,
|
|
242
243
|
line: i
|
|
243
244
|
}));
|
|
244
245
|
break;
|
|
245
|
-
default: n(new
|
|
246
|
+
default: n(new M(`Unknown field "${e.length > 20 ? `${e.slice(0, 20)}\u2026` : e}"`, {
|
|
246
247
|
type: "unknown-field",
|
|
247
248
|
field: e,
|
|
248
249
|
value: t,
|
|
@@ -269,20 +270,20 @@ ${t}`, d++;
|
|
|
269
270
|
reset: ne
|
|
270
271
|
};
|
|
271
272
|
}
|
|
272
|
-
function
|
|
273
|
+
function P(e, t, n) {
|
|
273
274
|
return n === 100 && e.charCodeAt(t + 1) === 97 && e.charCodeAt(t + 2) === 116 && e.charCodeAt(t + 3) === 97 && e.charCodeAt(t + 4) === 58;
|
|
274
275
|
}
|
|
275
|
-
function
|
|
276
|
+
function F(e, t, n) {
|
|
276
277
|
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;
|
|
277
278
|
}
|
|
278
279
|
//#endregion
|
|
279
280
|
//#region ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/stream.js
|
|
280
|
-
var
|
|
281
|
+
var Ie = class extends TransformStream {
|
|
281
282
|
constructor({ onError: e, onRetry: t, onComment: n, maxBufferSize: r } = {}) {
|
|
282
283
|
let i;
|
|
283
284
|
super({
|
|
284
285
|
start(a) {
|
|
285
|
-
i =
|
|
286
|
+
i = Fe({
|
|
286
287
|
onEvent: (e) => {
|
|
287
288
|
a.enqueue(e);
|
|
288
289
|
},
|
|
@@ -301,14 +302,14 @@ var Le = class extends TransformStream {
|
|
|
301
302
|
}
|
|
302
303
|
};
|
|
303
304
|
new TextDecoder();
|
|
304
|
-
var { btoa:
|
|
305
|
-
ze
|
|
306
|
-
function
|
|
305
|
+
var { btoa: Le, atob: Re } = globalThis, ze = globalThis.fetch;
|
|
306
|
+
Be(ze);
|
|
307
|
+
function Be(e) {
|
|
307
308
|
if (typeof e != "function") return !1;
|
|
308
309
|
let t = Function.prototype.toString.call(e);
|
|
309
310
|
return t.includes("internal/deps/undici") || t.includes("lazy loading of undici");
|
|
310
311
|
}
|
|
311
|
-
var
|
|
312
|
+
var I = ({ prefix: e, size: t = 16, alphabet: n = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", separator: r = "-" } = {}) => {
|
|
312
313
|
let i = () => {
|
|
313
314
|
let e = n.length, r = Array(t);
|
|
314
315
|
for (let i = 0; i < t; i++) r[i] = n[Math.random() * e | 0];
|
|
@@ -320,8 +321,8 @@ var P = ({ prefix: e, size: t = 16, alphabet: n = "0123456789ABCDEFGHIJKLMNOPQRS
|
|
|
320
321
|
message: `The separator "${r}" must not be part of the alphabet "${n}".`
|
|
321
322
|
});
|
|
322
323
|
return () => `${e}${r}${i()}`;
|
|
323
|
-
},
|
|
324
|
-
function
|
|
324
|
+
}, L = I();
|
|
325
|
+
function R(e) {
|
|
325
326
|
if (e == null) return {};
|
|
326
327
|
let t = {};
|
|
327
328
|
if (e instanceof Headers) e.forEach((e, n) => {
|
|
@@ -333,15 +334,15 @@ function I(e) {
|
|
|
333
334
|
}
|
|
334
335
|
return t;
|
|
335
336
|
}
|
|
336
|
-
function
|
|
337
|
+
function Ve(e) {
|
|
337
338
|
return globalThis.Buffer?.isBuffer(e) ?? !1;
|
|
338
339
|
}
|
|
339
|
-
var
|
|
340
|
-
function
|
|
340
|
+
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*:/;
|
|
341
|
+
function We(e) {
|
|
341
342
|
let t = JSON.parse(e);
|
|
342
|
-
return typeof t != "object" || !t ||
|
|
343
|
+
return typeof t != "object" || !t || He.test(e) === !1 && Ue.test(e) === !1 ? t : Ge(t);
|
|
343
344
|
}
|
|
344
|
-
function
|
|
345
|
+
function Ge(e) {
|
|
345
346
|
let t = [e];
|
|
346
347
|
for (; t.length;) {
|
|
347
348
|
let e = t;
|
|
@@ -356,35 +357,35 @@ function We(e) {
|
|
|
356
357
|
}
|
|
357
358
|
return e;
|
|
358
359
|
}
|
|
359
|
-
function
|
|
360
|
+
function Ke(e) {
|
|
360
361
|
let { stackTraceLimit: t } = Error;
|
|
361
362
|
try {
|
|
362
363
|
Error.stackTraceLimit = 0;
|
|
363
364
|
} catch {
|
|
364
|
-
return
|
|
365
|
+
return We(e);
|
|
365
366
|
}
|
|
366
367
|
try {
|
|
367
|
-
return
|
|
368
|
+
return We(e);
|
|
368
369
|
} finally {
|
|
369
370
|
Error.stackTraceLimit = t;
|
|
370
371
|
}
|
|
371
372
|
}
|
|
372
|
-
function
|
|
373
|
+
function qe(e) {
|
|
373
374
|
if (e.type === "object" || Array.isArray(e.type) && e.type.includes("object")) {
|
|
374
375
|
let { additionalProperties: t } = e;
|
|
375
|
-
e.additionalProperties = t != null && typeof t != "boolean" &&
|
|
376
|
+
e.additionalProperties = t != null && typeof t != "boolean" && z(t);
|
|
376
377
|
let { properties: n } = e;
|
|
377
|
-
if (n != null) for (let e of Object.keys(n)) n[e] =
|
|
378
|
+
if (n != null) for (let e of Object.keys(n)) n[e] = z(n[e]);
|
|
378
379
|
}
|
|
379
|
-
e.items != null && (e.items = Array.isArray(e.items) ? e.items.map(
|
|
380
|
+
e.items != null && (e.items = Array.isArray(e.items) ? e.items.map(z) : z(e.items)), e.anyOf != null && (e.anyOf = e.anyOf.map(z)), e.allOf != null && (e.allOf = e.allOf.map(z)), e.oneOf != null && (e.oneOf = e.oneOf.map(z));
|
|
380
381
|
let { definitions: t } = e;
|
|
381
|
-
if (t != null) for (let e of Object.keys(t)) t[e] =
|
|
382
|
+
if (t != null) for (let e of Object.keys(t)) t[e] = z(t[e]);
|
|
382
383
|
return e;
|
|
383
384
|
}
|
|
384
|
-
function
|
|
385
|
-
return typeof e == "boolean" ? e :
|
|
385
|
+
function z(e) {
|
|
386
|
+
return typeof e == "boolean" ? e : qe(e);
|
|
386
387
|
}
|
|
387
|
-
var
|
|
388
|
+
var Je = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use"), Ye = {
|
|
388
389
|
name: void 0,
|
|
389
390
|
$refStrategy: "root",
|
|
390
391
|
basePath: ["#"],
|
|
@@ -404,24 +405,24 @@ var qe = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to u
|
|
|
404
405
|
emailStrategy: "format:email",
|
|
405
406
|
base64Strategy: "contentEncoding:base64",
|
|
406
407
|
nameStrategy: "ref"
|
|
407
|
-
},
|
|
408
|
-
...
|
|
408
|
+
}, Xe = (e) => typeof e == "string" ? {
|
|
409
|
+
...Ye,
|
|
409
410
|
name: e
|
|
410
411
|
} : {
|
|
411
|
-
...
|
|
412
|
+
...Ye,
|
|
412
413
|
...e
|
|
413
414
|
};
|
|
414
|
-
function
|
|
415
|
+
function B() {
|
|
415
416
|
return {};
|
|
416
417
|
}
|
|
417
|
-
function
|
|
418
|
+
function Ze(e, t) {
|
|
418
419
|
let n = { type: "array" };
|
|
419
|
-
return e.type?._def && e.type?._def?.typeName !== "ZodAny" && (n.items =
|
|
420
|
+
return e.type?._def && e.type?._def?.typeName !== "ZodAny" && (n.items = W(e.type._def, {
|
|
420
421
|
...t,
|
|
421
422
|
currentPath: [...t.currentPath, "items"]
|
|
422
423
|
})), 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;
|
|
423
424
|
}
|
|
424
|
-
function
|
|
425
|
+
function Qe(e) {
|
|
425
426
|
let t = {
|
|
426
427
|
type: "integer",
|
|
427
428
|
format: "int64"
|
|
@@ -438,16 +439,16 @@ function Ze(e) {
|
|
|
438
439
|
}
|
|
439
440
|
return t;
|
|
440
441
|
}
|
|
441
|
-
function
|
|
442
|
+
function $e() {
|
|
442
443
|
return { type: "boolean" };
|
|
443
444
|
}
|
|
444
|
-
function
|
|
445
|
-
return
|
|
445
|
+
function et(e, t) {
|
|
446
|
+
return W(e.type._def, t);
|
|
446
447
|
}
|
|
447
|
-
var
|
|
448
|
-
function
|
|
448
|
+
var tt = (e, t) => W(e.innerType._def, t);
|
|
449
|
+
function nt(e, t, n) {
|
|
449
450
|
let r = n ?? t.dateStrategy;
|
|
450
|
-
if (Array.isArray(r)) return { anyOf: r.map((n) =>
|
|
451
|
+
if (Array.isArray(r)) return { anyOf: r.map((n) => nt(e, t, n)) };
|
|
451
452
|
switch (r) {
|
|
452
453
|
case "string":
|
|
453
454
|
case "format:date-time": return {
|
|
@@ -458,10 +459,10 @@ function tt(e, t, n) {
|
|
|
458
459
|
type: "string",
|
|
459
460
|
format: "date"
|
|
460
461
|
};
|
|
461
|
-
case "integer": return
|
|
462
|
+
case "integer": return rt(e);
|
|
462
463
|
}
|
|
463
464
|
}
|
|
464
|
-
var
|
|
465
|
+
var rt = (e) => {
|
|
465
466
|
let t = {
|
|
466
467
|
type: "integer",
|
|
467
468
|
format: "unix-time"
|
|
@@ -474,31 +475,31 @@ var nt = (e) => {
|
|
|
474
475
|
}
|
|
475
476
|
return t;
|
|
476
477
|
};
|
|
477
|
-
function
|
|
478
|
+
function it(e, t) {
|
|
478
479
|
return {
|
|
479
|
-
...
|
|
480
|
+
...W(e.innerType._def, t),
|
|
480
481
|
default: e.defaultValue()
|
|
481
482
|
};
|
|
482
483
|
}
|
|
483
|
-
function
|
|
484
|
-
return t.effectStrategy === "input" ?
|
|
484
|
+
function at(e, t) {
|
|
485
|
+
return t.effectStrategy === "input" ? W(e.schema._def, t) : B();
|
|
485
486
|
}
|
|
486
|
-
function
|
|
487
|
+
function ot(e) {
|
|
487
488
|
return {
|
|
488
489
|
type: "string",
|
|
489
490
|
enum: Array.from(e.values)
|
|
490
491
|
};
|
|
491
492
|
}
|
|
492
|
-
var
|
|
493
|
-
function
|
|
494
|
-
let n = [
|
|
493
|
+
var st = (e) => "type" in e && e.type === "string" ? !1 : "allOf" in e;
|
|
494
|
+
function ct(e, t) {
|
|
495
|
+
let n = [W(e.left._def, {
|
|
495
496
|
...t,
|
|
496
497
|
currentPath: [
|
|
497
498
|
...t.currentPath,
|
|
498
499
|
"allOf",
|
|
499
500
|
"0"
|
|
500
501
|
]
|
|
501
|
-
}),
|
|
502
|
+
}), W(e.right._def, {
|
|
502
503
|
...t,
|
|
503
504
|
currentPath: [
|
|
504
505
|
...t.currentPath,
|
|
@@ -507,7 +508,7 @@ function st(e, t) {
|
|
|
507
508
|
]
|
|
508
509
|
})].filter((e) => !!e), r = [];
|
|
509
510
|
return n.forEach((e) => {
|
|
510
|
-
if (
|
|
511
|
+
if (st(e)) r.push(...e.allOf);
|
|
511
512
|
else {
|
|
512
513
|
let t = e;
|
|
513
514
|
if ("additionalProperties" in e && e.additionalProperties === !1) {
|
|
@@ -518,19 +519,19 @@ function st(e, t) {
|
|
|
518
519
|
}
|
|
519
520
|
}), r.length ? { allOf: r } : void 0;
|
|
520
521
|
}
|
|
521
|
-
function
|
|
522
|
+
function lt(e) {
|
|
522
523
|
let t = typeof e.value;
|
|
523
524
|
return t !== "bigint" && t !== "number" && t !== "boolean" && t !== "string" ? { type: Array.isArray(e.value) ? "array" : "object" } : {
|
|
524
525
|
type: t === "bigint" ? "integer" : t,
|
|
525
526
|
const: e.value
|
|
526
527
|
};
|
|
527
528
|
}
|
|
528
|
-
var
|
|
529
|
+
var ut = void 0, V = {
|
|
529
530
|
cuid: /^[cC][^\s-]{8,}$/,
|
|
530
531
|
cuid2: /^[0-9a-z]+$/,
|
|
531
532
|
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
532
533
|
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
533
|
-
emoji: () => (
|
|
534
|
+
emoji: () => (ut === void 0 && (ut = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u")), ut),
|
|
534
535
|
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}$/,
|
|
535
536
|
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])$/,
|
|
536
537
|
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])$/,
|
|
@@ -541,7 +542,7 @@ var z = void 0, B = {
|
|
|
541
542
|
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
542
543
|
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
543
544
|
};
|
|
544
|
-
function
|
|
545
|
+
function dt(e, t) {
|
|
545
546
|
let n = { type: "string" };
|
|
546
547
|
if (e.checks) for (let r of e.checks) switch (r.kind) {
|
|
547
548
|
case "min":
|
|
@@ -553,108 +554,108 @@ function lt(e, t) {
|
|
|
553
554
|
case "email":
|
|
554
555
|
switch (t.emailStrategy) {
|
|
555
556
|
case "format:email":
|
|
556
|
-
|
|
557
|
+
H(n, "email", r.message, t);
|
|
557
558
|
break;
|
|
558
559
|
case "format:idn-email":
|
|
559
|
-
|
|
560
|
+
H(n, "idn-email", r.message, t);
|
|
560
561
|
break;
|
|
561
|
-
case "pattern:zod":
|
|
562
|
+
case "pattern:zod": U(n, V.email, r.message, t);
|
|
562
563
|
}
|
|
563
564
|
break;
|
|
564
565
|
case "url":
|
|
565
|
-
|
|
566
|
+
H(n, "uri", r.message, t);
|
|
566
567
|
break;
|
|
567
568
|
case "uuid":
|
|
568
|
-
|
|
569
|
+
H(n, "uuid", r.message, t);
|
|
569
570
|
break;
|
|
570
571
|
case "regex":
|
|
571
|
-
|
|
572
|
+
U(n, r.regex, r.message, t);
|
|
572
573
|
break;
|
|
573
574
|
case "cuid":
|
|
574
|
-
|
|
575
|
+
U(n, V.cuid, r.message, t);
|
|
575
576
|
break;
|
|
576
577
|
case "cuid2":
|
|
577
|
-
|
|
578
|
+
U(n, V.cuid2, r.message, t);
|
|
578
579
|
break;
|
|
579
580
|
case "startsWith":
|
|
580
|
-
|
|
581
|
+
U(n, RegExp(`^${ft(r.value, t)}`), r.message, t);
|
|
581
582
|
break;
|
|
582
583
|
case "endsWith":
|
|
583
|
-
|
|
584
|
+
U(n, RegExp(`${ft(r.value, t)}$`), r.message, t);
|
|
584
585
|
break;
|
|
585
586
|
case "datetime":
|
|
586
|
-
|
|
587
|
+
H(n, "date-time", r.message, t);
|
|
587
588
|
break;
|
|
588
589
|
case "date":
|
|
589
|
-
|
|
590
|
+
H(n, "date", r.message, t);
|
|
590
591
|
break;
|
|
591
592
|
case "time":
|
|
592
|
-
|
|
593
|
+
H(n, "time", r.message, t);
|
|
593
594
|
break;
|
|
594
595
|
case "duration":
|
|
595
|
-
|
|
596
|
+
H(n, "duration", r.message, t);
|
|
596
597
|
break;
|
|
597
598
|
case "length":
|
|
598
599
|
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;
|
|
599
600
|
break;
|
|
600
601
|
case "includes":
|
|
601
|
-
|
|
602
|
+
U(n, RegExp(ft(r.value, t)), r.message, t);
|
|
602
603
|
break;
|
|
603
604
|
case "ip":
|
|
604
|
-
r.version !== "v6" &&
|
|
605
|
+
r.version !== "v6" && H(n, "ipv4", r.message, t), r.version !== "v4" && H(n, "ipv6", r.message, t);
|
|
605
606
|
break;
|
|
606
607
|
case "base64url":
|
|
607
|
-
|
|
608
|
+
U(n, V.base64url, r.message, t);
|
|
608
609
|
break;
|
|
609
610
|
case "jwt":
|
|
610
|
-
|
|
611
|
+
U(n, V.jwt, r.message, t);
|
|
611
612
|
break;
|
|
612
613
|
case "cidr":
|
|
613
|
-
r.version !== "v6" &&
|
|
614
|
+
r.version !== "v6" && U(n, V.ipv4Cidr, r.message, t), r.version !== "v4" && U(n, V.ipv6Cidr, r.message, t);
|
|
614
615
|
break;
|
|
615
616
|
case "emoji":
|
|
616
|
-
|
|
617
|
+
U(n, V.emoji(), r.message, t);
|
|
617
618
|
break;
|
|
618
619
|
case "ulid":
|
|
619
|
-
|
|
620
|
+
U(n, V.ulid, r.message, t);
|
|
620
621
|
break;
|
|
621
622
|
case "base64":
|
|
622
623
|
switch (t.base64Strategy) {
|
|
623
624
|
case "format:binary":
|
|
624
|
-
|
|
625
|
+
H(n, "binary", r.message, t);
|
|
625
626
|
break;
|
|
626
627
|
case "contentEncoding:base64":
|
|
627
628
|
n.contentEncoding = "base64";
|
|
628
629
|
break;
|
|
629
|
-
case "pattern:zod":
|
|
630
|
+
case "pattern:zod": U(n, V.base64, r.message, t);
|
|
630
631
|
}
|
|
631
632
|
break;
|
|
632
|
-
case "nanoid":
|
|
633
|
+
case "nanoid": U(n, V.nanoid, r.message, t);
|
|
633
634
|
}
|
|
634
635
|
return n;
|
|
635
636
|
}
|
|
636
|
-
function
|
|
637
|
-
return t.patternStrategy === "escape" ?
|
|
637
|
+
function ft(e, t) {
|
|
638
|
+
return t.patternStrategy === "escape" ? mt(e) : e;
|
|
638
639
|
}
|
|
639
|
-
var
|
|
640
|
-
function
|
|
640
|
+
var pt = /* @__PURE__ */ new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
641
|
+
function mt(e) {
|
|
641
642
|
let t = "";
|
|
642
|
-
for (let n = 0; n < e.length; n++)
|
|
643
|
+
for (let n = 0; n < e.length; n++) pt.has(e[n]) || (t += "\\"), t += e[n];
|
|
643
644
|
return t;
|
|
644
645
|
}
|
|
645
|
-
function
|
|
646
|
+
function H(e, t, n, r) {
|
|
646
647
|
e.format || e.anyOf?.some((e) => e.format) ? (e.anyOf ||= [], e.format && (e.anyOf.push({ format: e.format }), delete e.format), e.anyOf.push({
|
|
647
648
|
format: t,
|
|
648
649
|
...n && r.errorMessages && { errorMessage: { format: n } }
|
|
649
650
|
})) : e.format = t;
|
|
650
651
|
}
|
|
651
|
-
function
|
|
652
|
+
function U(e, t, n, r) {
|
|
652
653
|
e.pattern || e.allOf?.some((e) => e.pattern) ? (e.allOf ||= [], e.pattern && (e.allOf.push({ pattern: e.pattern }), delete e.pattern), e.allOf.push({
|
|
653
|
-
pattern:
|
|
654
|
+
pattern: ht(t, r),
|
|
654
655
|
...n && r.errorMessages && { errorMessage: { pattern: n } }
|
|
655
|
-
})) : e.pattern =
|
|
656
|
+
})) : e.pattern = ht(t, r);
|
|
656
657
|
}
|
|
657
|
-
function
|
|
658
|
+
function ht(e, t) {
|
|
658
659
|
if (!t.applyRegexFlags || !e.flags) return e.source;
|
|
659
660
|
let n = {
|
|
660
661
|
i: e.flags.includes("i"),
|
|
@@ -702,16 +703,16 @@ function pt(e, t) {
|
|
|
702
703
|
}
|
|
703
704
|
return i;
|
|
704
705
|
}
|
|
705
|
-
function
|
|
706
|
+
function gt(e, t) {
|
|
706
707
|
let n = {
|
|
707
708
|
type: "object",
|
|
708
|
-
additionalProperties:
|
|
709
|
+
additionalProperties: W(e.valueType._def, {
|
|
709
710
|
...t,
|
|
710
711
|
currentPath: [...t.currentPath, "additionalProperties"]
|
|
711
712
|
}) ?? t.allowedAdditionalProperties
|
|
712
713
|
};
|
|
713
714
|
if (e.keyType?._def.typeName === "ZodString" && e.keyType._def.checks?.length) {
|
|
714
|
-
let { type: r, ...i } =
|
|
715
|
+
let { type: r, ...i } = dt(e.keyType._def, t);
|
|
715
716
|
return {
|
|
716
717
|
...n,
|
|
717
718
|
propertyNames: i
|
|
@@ -722,7 +723,7 @@ function mt(e, t) {
|
|
|
722
723
|
propertyNames: { enum: e.keyType._def.values }
|
|
723
724
|
};
|
|
724
725
|
if (e.keyType?._def.typeName === "ZodBranded" && e.keyType._def.type._def.typeName === "ZodString" && e.keyType._def.type._def.checks?.length) {
|
|
725
|
-
let { type: r, ...i } =
|
|
726
|
+
let { type: r, ...i } = et(e.keyType._def, t);
|
|
726
727
|
return {
|
|
727
728
|
...n,
|
|
728
729
|
propertyNames: i
|
|
@@ -730,13 +731,13 @@ function mt(e, t) {
|
|
|
730
731
|
}
|
|
731
732
|
return n;
|
|
732
733
|
}
|
|
733
|
-
function
|
|
734
|
-
return t.mapStrategy === "record" ?
|
|
734
|
+
function _t(e, t) {
|
|
735
|
+
return t.mapStrategy === "record" ? gt(e, t) : {
|
|
735
736
|
type: "array",
|
|
736
737
|
maxItems: 125,
|
|
737
738
|
items: {
|
|
738
739
|
type: "array",
|
|
739
|
-
items: [
|
|
740
|
+
items: [W(e.keyType._def, {
|
|
740
741
|
...t,
|
|
741
742
|
currentPath: [
|
|
742
743
|
...t.currentPath,
|
|
@@ -744,7 +745,7 @@ function ht(e, t) {
|
|
|
744
745
|
"items",
|
|
745
746
|
"0"
|
|
746
747
|
]
|
|
747
|
-
}) ||
|
|
748
|
+
}) || B(), W(e.valueType._def, {
|
|
748
749
|
...t,
|
|
749
750
|
currentPath: [
|
|
750
751
|
...t.currentPath,
|
|
@@ -752,37 +753,37 @@ function ht(e, t) {
|
|
|
752
753
|
"items",
|
|
753
754
|
"1"
|
|
754
755
|
]
|
|
755
|
-
}) ||
|
|
756
|
+
}) || B()],
|
|
756
757
|
minItems: 2,
|
|
757
758
|
maxItems: 2
|
|
758
759
|
}
|
|
759
760
|
};
|
|
760
761
|
}
|
|
761
|
-
function
|
|
762
|
+
function vt(e) {
|
|
762
763
|
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)));
|
|
763
764
|
return {
|
|
764
765
|
type: r.length === 1 ? r[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
765
766
|
enum: n
|
|
766
767
|
};
|
|
767
768
|
}
|
|
768
|
-
function
|
|
769
|
-
return { not:
|
|
769
|
+
function yt() {
|
|
770
|
+
return { not: B() };
|
|
770
771
|
}
|
|
771
|
-
function
|
|
772
|
+
function bt() {
|
|
772
773
|
return { type: "null" };
|
|
773
774
|
}
|
|
774
|
-
var
|
|
775
|
+
var xt = {
|
|
775
776
|
ZodString: "string",
|
|
776
777
|
ZodNumber: "number",
|
|
777
778
|
ZodBigInt: "integer",
|
|
778
779
|
ZodBoolean: "boolean",
|
|
779
780
|
ZodNull: "null"
|
|
780
781
|
};
|
|
781
|
-
function
|
|
782
|
+
function St(e, t) {
|
|
782
783
|
let n = e.options instanceof Map ? Array.from(e.options.values()) : e.options;
|
|
783
|
-
if (n.every((e) => e._def.typeName in
|
|
784
|
+
if (n.every((e) => e._def.typeName in xt && (!e._def.checks || !e._def.checks.length))) {
|
|
784
785
|
let e = n.reduce((e, t) => {
|
|
785
|
-
let n =
|
|
786
|
+
let n = xt[t._def.typeName];
|
|
786
787
|
return n && !e.includes(n) ? [...e, n] : e;
|
|
787
788
|
}, []);
|
|
788
789
|
return { type: e.length > 1 ? e : e[0] };
|
|
@@ -810,10 +811,10 @@ function bt(e, t) {
|
|
|
810
811
|
type: "string",
|
|
811
812
|
enum: n.reduce((e, t) => [...e, ...t._def.values.filter((t) => !e.includes(t))], [])
|
|
812
813
|
};
|
|
813
|
-
return
|
|
814
|
+
return Ct(e, t);
|
|
814
815
|
}
|
|
815
|
-
var
|
|
816
|
-
let n = (e.options instanceof Map ? Array.from(e.options.values()) : e.options).map((e, n) =>
|
|
816
|
+
var Ct = (e, t) => {
|
|
817
|
+
let n = (e.options instanceof Map ? Array.from(e.options.values()) : e.options).map((e, n) => W(e._def, {
|
|
817
818
|
...t,
|
|
818
819
|
currentPath: [
|
|
819
820
|
...t.currentPath,
|
|
@@ -823,15 +824,15 @@ var xt = (e, t) => {
|
|
|
823
824
|
})).filter((e) => !!e && (!t.strictUnions || typeof e == "object" && Object.keys(e).length > 0));
|
|
824
825
|
return n.length ? { anyOf: n } : void 0;
|
|
825
826
|
};
|
|
826
|
-
function
|
|
827
|
+
function wt(e, t) {
|
|
827
828
|
if ([
|
|
828
829
|
"ZodString",
|
|
829
830
|
"ZodNumber",
|
|
830
831
|
"ZodBigInt",
|
|
831
832
|
"ZodBoolean",
|
|
832
833
|
"ZodNull"
|
|
833
|
-
].includes(e.innerType._def.typeName) && (!e.innerType._def.checks || !e.innerType._def.checks.length)) return { type: [
|
|
834
|
-
let n =
|
|
834
|
+
].includes(e.innerType._def.typeName) && (!e.innerType._def.checks || !e.innerType._def.checks.length)) return { type: [xt[e.innerType._def.typeName], "null"] };
|
|
835
|
+
let n = W(e.innerType._def, {
|
|
835
836
|
...t,
|
|
836
837
|
currentPath: [
|
|
837
838
|
...t.currentPath,
|
|
@@ -841,7 +842,7 @@ function St(e, t) {
|
|
|
841
842
|
});
|
|
842
843
|
return n && { anyOf: [n, { type: "null" }] };
|
|
843
844
|
}
|
|
844
|
-
function
|
|
845
|
+
function Tt(e) {
|
|
845
846
|
let t = { type: "number" };
|
|
846
847
|
if (!e.checks) return t;
|
|
847
848
|
for (let n of e.checks) switch (n.kind) {
|
|
@@ -858,7 +859,7 @@ function Ct(e) {
|
|
|
858
859
|
}
|
|
859
860
|
return t;
|
|
860
861
|
}
|
|
861
|
-
function
|
|
862
|
+
function Et(e, t) {
|
|
862
863
|
let n = {
|
|
863
864
|
type: "object",
|
|
864
865
|
properties: {}
|
|
@@ -866,7 +867,7 @@ function wt(e, t) {
|
|
|
866
867
|
for (let e in i) {
|
|
867
868
|
let a = i[e];
|
|
868
869
|
if (a === void 0 || a._def === void 0) continue;
|
|
869
|
-
let o =
|
|
870
|
+
let o = Ot(a), s = W(a._def, {
|
|
870
871
|
...t,
|
|
871
872
|
currentPath: [
|
|
872
873
|
...t.currentPath,
|
|
@@ -882,11 +883,11 @@ function wt(e, t) {
|
|
|
882
883
|
s !== void 0 && (n.properties[e] = s, o || r.push(e));
|
|
883
884
|
}
|
|
884
885
|
r.length && (n.required = r);
|
|
885
|
-
let a =
|
|
886
|
+
let a = Dt(e, t);
|
|
886
887
|
return a !== void 0 && (n.additionalProperties = a), n;
|
|
887
888
|
}
|
|
888
|
-
function
|
|
889
|
-
if (e.catchall._def.typeName !== "ZodNever") return
|
|
889
|
+
function Dt(e, t) {
|
|
890
|
+
if (e.catchall._def.typeName !== "ZodNever") return W(e.catchall._def, {
|
|
890
891
|
...t,
|
|
891
892
|
currentPath: [...t.currentPath, "additionalProperties"]
|
|
892
893
|
});
|
|
@@ -896,16 +897,16 @@ function Tt(e, t) {
|
|
|
896
897
|
case "strip": return t.removeAdditionalStrategy === "strict" ? t.allowedAdditionalProperties : t.rejectedAdditionalProperties;
|
|
897
898
|
}
|
|
898
899
|
}
|
|
899
|
-
function
|
|
900
|
+
function Ot(e) {
|
|
900
901
|
try {
|
|
901
902
|
return e.isOptional();
|
|
902
903
|
} catch {
|
|
903
904
|
return !0;
|
|
904
905
|
}
|
|
905
906
|
}
|
|
906
|
-
var
|
|
907
|
-
if (t.currentPath.toString() === t.propertyPath?.toString()) return
|
|
908
|
-
let n =
|
|
907
|
+
var kt = (e, t) => {
|
|
908
|
+
if (t.currentPath.toString() === t.propertyPath?.toString()) return W(e.innerType._def, t);
|
|
909
|
+
let n = W(e.innerType._def, {
|
|
909
910
|
...t,
|
|
910
911
|
currentPath: [
|
|
911
912
|
...t.currentPath,
|
|
@@ -913,11 +914,11 @@ var Dt = (e, t) => {
|
|
|
913
914
|
"1"
|
|
914
915
|
]
|
|
915
916
|
});
|
|
916
|
-
return n ? { anyOf: [{ not:
|
|
917
|
-
},
|
|
918
|
-
if (t.pipeStrategy === "input") return
|
|
919
|
-
if (t.pipeStrategy === "output") return
|
|
920
|
-
let n =
|
|
917
|
+
return n ? { anyOf: [{ not: B() }, n] } : B();
|
|
918
|
+
}, At = (e, t) => {
|
|
919
|
+
if (t.pipeStrategy === "input") return W(e.in._def, t);
|
|
920
|
+
if (t.pipeStrategy === "output") return W(e.out._def, t);
|
|
921
|
+
let n = W(e.in._def, {
|
|
921
922
|
...t,
|
|
922
923
|
currentPath: [
|
|
923
924
|
...t.currentPath,
|
|
@@ -925,7 +926,7 @@ var Dt = (e, t) => {
|
|
|
925
926
|
"0"
|
|
926
927
|
]
|
|
927
928
|
});
|
|
928
|
-
return { allOf: [n,
|
|
929
|
+
return { allOf: [n, W(e.out._def, {
|
|
929
930
|
...t,
|
|
930
931
|
currentPath: [
|
|
931
932
|
...t.currentPath,
|
|
@@ -934,25 +935,25 @@ var Dt = (e, t) => {
|
|
|
934
935
|
]
|
|
935
936
|
})].filter((e) => e !== void 0) };
|
|
936
937
|
};
|
|
937
|
-
function
|
|
938
|
-
return
|
|
938
|
+
function jt(e, t) {
|
|
939
|
+
return W(e.type._def, t);
|
|
939
940
|
}
|
|
940
|
-
function
|
|
941
|
+
function Mt(e, t) {
|
|
941
942
|
let n = {
|
|
942
943
|
type: "array",
|
|
943
944
|
uniqueItems: !0,
|
|
944
|
-
items:
|
|
945
|
+
items: W(e.valueType._def, {
|
|
945
946
|
...t,
|
|
946
947
|
currentPath: [...t.currentPath, "items"]
|
|
947
948
|
})
|
|
948
949
|
};
|
|
949
950
|
return e.minSize && (n.minItems = e.minSize.value), e.maxSize && (n.maxItems = e.maxSize.value), n;
|
|
950
951
|
}
|
|
951
|
-
function
|
|
952
|
+
function Nt(e, t) {
|
|
952
953
|
return e.rest ? {
|
|
953
954
|
type: "array",
|
|
954
955
|
minItems: e.items.length,
|
|
955
|
-
items: e.items.map((e, n) =>
|
|
956
|
+
items: e.items.map((e, n) => W(e._def, {
|
|
956
957
|
...t,
|
|
957
958
|
currentPath: [
|
|
958
959
|
...t.currentPath,
|
|
@@ -960,7 +961,7 @@ function jt(e, t) {
|
|
|
960
961
|
`${n}`
|
|
961
962
|
]
|
|
962
963
|
})).reduce((e, t) => t === void 0 ? e : [...e, t], []),
|
|
963
|
-
additionalItems:
|
|
964
|
+
additionalItems: W(e.rest._def, {
|
|
964
965
|
...t,
|
|
965
966
|
currentPath: [...t.currentPath, "additionalItems"]
|
|
966
967
|
})
|
|
@@ -968,7 +969,7 @@ function jt(e, t) {
|
|
|
968
969
|
type: "array",
|
|
969
970
|
minItems: e.items.length,
|
|
970
971
|
maxItems: e.items.length,
|
|
971
|
-
items: e.items.map((e, n) =>
|
|
972
|
+
items: e.items.map((e, n) => W(e._def, {
|
|
972
973
|
...t,
|
|
973
974
|
currentPath: [
|
|
974
975
|
...t.currentPath,
|
|
@@ -978,65 +979,65 @@ function jt(e, t) {
|
|
|
978
979
|
})).reduce((e, t) => t === void 0 ? e : [...e, t], [])
|
|
979
980
|
};
|
|
980
981
|
}
|
|
981
|
-
function
|
|
982
|
-
return { not:
|
|
982
|
+
function Pt() {
|
|
983
|
+
return { not: B() };
|
|
983
984
|
}
|
|
984
|
-
function
|
|
985
|
-
return
|
|
985
|
+
function Ft() {
|
|
986
|
+
return B();
|
|
986
987
|
}
|
|
987
|
-
var
|
|
988
|
+
var It = (e, t) => W(e.innerType._def, t), Lt = (e, t, n) => {
|
|
988
989
|
switch (t) {
|
|
989
|
-
case "ZodString": return
|
|
990
|
-
case "ZodNumber": return
|
|
991
|
-
case "ZodObject": return
|
|
992
|
-
case "ZodBigInt": return
|
|
993
|
-
case "ZodBoolean": return
|
|
994
|
-
case "ZodDate": return
|
|
995
|
-
case "ZodUndefined": return
|
|
996
|
-
case "ZodNull": return
|
|
997
|
-
case "ZodArray": return
|
|
990
|
+
case "ZodString": return dt(e, n);
|
|
991
|
+
case "ZodNumber": return Tt(e);
|
|
992
|
+
case "ZodObject": return Et(e, n);
|
|
993
|
+
case "ZodBigInt": return Qe(e);
|
|
994
|
+
case "ZodBoolean": return $e();
|
|
995
|
+
case "ZodDate": return nt(e, n);
|
|
996
|
+
case "ZodUndefined": return Pt();
|
|
997
|
+
case "ZodNull": return bt();
|
|
998
|
+
case "ZodArray": return Ze(e, n);
|
|
998
999
|
case "ZodUnion":
|
|
999
|
-
case "ZodDiscriminatedUnion": return
|
|
1000
|
-
case "ZodIntersection": return
|
|
1001
|
-
case "ZodTuple": return
|
|
1002
|
-
case "ZodRecord": return
|
|
1003
|
-
case "ZodLiteral": return
|
|
1004
|
-
case "ZodEnum": return
|
|
1005
|
-
case "ZodNativeEnum": return
|
|
1006
|
-
case "ZodNullable": return
|
|
1007
|
-
case "ZodOptional": return
|
|
1008
|
-
case "ZodMap": return
|
|
1009
|
-
case "ZodSet": return
|
|
1000
|
+
case "ZodDiscriminatedUnion": return St(e, n);
|
|
1001
|
+
case "ZodIntersection": return ct(e, n);
|
|
1002
|
+
case "ZodTuple": return Nt(e, n);
|
|
1003
|
+
case "ZodRecord": return gt(e, n);
|
|
1004
|
+
case "ZodLiteral": return lt(e);
|
|
1005
|
+
case "ZodEnum": return ot(e);
|
|
1006
|
+
case "ZodNativeEnum": return vt(e);
|
|
1007
|
+
case "ZodNullable": return wt(e, n);
|
|
1008
|
+
case "ZodOptional": return kt(e, n);
|
|
1009
|
+
case "ZodMap": return _t(e, n);
|
|
1010
|
+
case "ZodSet": return Mt(e, n);
|
|
1010
1011
|
case "ZodLazy": return () => e.getter()._def;
|
|
1011
|
-
case "ZodPromise": return
|
|
1012
|
+
case "ZodPromise": return jt(e, n);
|
|
1012
1013
|
case "ZodNaN":
|
|
1013
|
-
case "ZodNever": return
|
|
1014
|
-
case "ZodEffects": return
|
|
1015
|
-
case "ZodAny": return
|
|
1016
|
-
case "ZodUnknown": return
|
|
1017
|
-
case "ZodDefault": return
|
|
1018
|
-
case "ZodBranded": return
|
|
1019
|
-
case "ZodReadonly": return
|
|
1020
|
-
case "ZodCatch": return
|
|
1021
|
-
case "ZodPipeline": return
|
|
1014
|
+
case "ZodNever": return yt();
|
|
1015
|
+
case "ZodEffects": return at(e, n);
|
|
1016
|
+
case "ZodAny": return B();
|
|
1017
|
+
case "ZodUnknown": return Ft();
|
|
1018
|
+
case "ZodDefault": return it(e, n);
|
|
1019
|
+
case "ZodBranded": return et(e, n);
|
|
1020
|
+
case "ZodReadonly": return It(e, n);
|
|
1021
|
+
case "ZodCatch": return tt(e, n);
|
|
1022
|
+
case "ZodPipeline": return At(e, n);
|
|
1022
1023
|
case "ZodFunction":
|
|
1023
1024
|
case "ZodVoid":
|
|
1024
1025
|
case "ZodSymbol": return;
|
|
1025
1026
|
default: return /* @__PURE__ */ ((e) => void 0)(t);
|
|
1026
1027
|
}
|
|
1027
|
-
},
|
|
1028
|
+
}, Rt = (e, t) => {
|
|
1028
1029
|
let n = 0;
|
|
1029
1030
|
for (; n < e.length && n < t.length && e[n] === t[n]; n++);
|
|
1030
1031
|
return [(e.length - n).toString(), ...t.slice(n)].join("/");
|
|
1031
1032
|
};
|
|
1032
|
-
function
|
|
1033
|
+
function W(e, t, n = !1) {
|
|
1033
1034
|
let r = t.seen.get(e);
|
|
1034
1035
|
if (t.override) {
|
|
1035
1036
|
let i = t.override?.call(t, e, t, r, n);
|
|
1036
|
-
if (i !==
|
|
1037
|
+
if (i !== Je) return i;
|
|
1037
1038
|
}
|
|
1038
1039
|
if (r && !n) {
|
|
1039
|
-
let e =
|
|
1040
|
+
let e = zt(r, t);
|
|
1040
1041
|
if (e !== void 0) return e;
|
|
1041
1042
|
}
|
|
1042
1043
|
let i = {
|
|
@@ -1045,22 +1046,22 @@ function U(e, t, n = !1) {
|
|
|
1045
1046
|
jsonSchema: void 0
|
|
1046
1047
|
};
|
|
1047
1048
|
t.seen.set(e, i);
|
|
1048
|
-
let a =
|
|
1049
|
-
if (o &&
|
|
1049
|
+
let a = Lt(e, e.typeName, t), o = typeof a == "function" ? W(a(), t) : a;
|
|
1050
|
+
if (o && Bt(e, t, o), t.postProcess) {
|
|
1050
1051
|
let n = t.postProcess(o, e, t);
|
|
1051
1052
|
return i.jsonSchema = o, n;
|
|
1052
1053
|
}
|
|
1053
1054
|
return i.jsonSchema = o, o;
|
|
1054
1055
|
}
|
|
1055
|
-
var
|
|
1056
|
+
var zt = (e, t) => {
|
|
1056
1057
|
switch (t.$refStrategy) {
|
|
1057
1058
|
case "root": return { $ref: e.path.join("/") };
|
|
1058
|
-
case "relative": return { $ref:
|
|
1059
|
+
case "relative": return { $ref: Rt(t.currentPath, e.path) };
|
|
1059
1060
|
case "none":
|
|
1060
|
-
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`),
|
|
1061
|
+
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`), B()) : t.$refStrategy === "seen" ? B() : void 0;
|
|
1061
1062
|
}
|
|
1062
|
-
},
|
|
1063
|
-
let t =
|
|
1063
|
+
}, Bt = (e, t, n) => (e.description && (n.description = e.description), n), Vt = (e) => {
|
|
1064
|
+
let t = Xe(e), n = t.name === void 0 ? t.basePath : [
|
|
1064
1065
|
...t.basePath,
|
|
1065
1066
|
t.definitionPath,
|
|
1066
1067
|
t.name
|
|
@@ -1079,25 +1080,25 @@ var Lt = (e, t) => {
|
|
|
1079
1080
|
jsonSchema: void 0
|
|
1080
1081
|
}]))
|
|
1081
1082
|
};
|
|
1082
|
-
},
|
|
1083
|
-
let n =
|
|
1083
|
+
}, Ht = (e, t) => {
|
|
1084
|
+
let n = Vt(t), r = typeof t == "object" && t.definitions ? Object.entries(t.definitions).reduce((e, [t, r]) => ({
|
|
1084
1085
|
...e,
|
|
1085
|
-
[t]:
|
|
1086
|
+
[t]: W(r._def, {
|
|
1086
1087
|
...n,
|
|
1087
1088
|
currentPath: [
|
|
1088
1089
|
...n.basePath,
|
|
1089
1090
|
n.definitionPath,
|
|
1090
1091
|
t
|
|
1091
1092
|
]
|
|
1092
|
-
}, !0) ??
|
|
1093
|
-
}), {}) : void 0, i = typeof t == "string" ? t : t?.nameStrategy === "title" ? void 0 : t?.name, a =
|
|
1093
|
+
}, !0) ?? B()
|
|
1094
|
+
}), {}) : void 0, i = typeof t == "string" ? t : t?.nameStrategy === "title" ? void 0 : t?.name, a = W(e._def, i === void 0 ? n : {
|
|
1094
1095
|
...n,
|
|
1095
1096
|
currentPath: [
|
|
1096
1097
|
...n.basePath,
|
|
1097
1098
|
n.definitionPath,
|
|
1098
1099
|
i
|
|
1099
1100
|
]
|
|
1100
|
-
}, !1) ??
|
|
1101
|
+
}, !1) ?? B(), o = typeof t == "object" && t.name !== void 0 && t.nameStrategy === "title" ? t.name : void 0;
|
|
1101
1102
|
o !== void 0 && (a.title = o);
|
|
1102
1103
|
let s = i === void 0 ? r ? {
|
|
1103
1104
|
...a,
|
|
@@ -1114,14 +1115,14 @@ var Lt = (e, t) => {
|
|
|
1114
1115
|
}
|
|
1115
1116
|
};
|
|
1116
1117
|
return s.$schema = "http://json-schema.org/draft-07/schema#", s;
|
|
1117
|
-
},
|
|
1118
|
-
function
|
|
1118
|
+
}, Ut = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
|
|
1119
|
+
function Wt(e) {
|
|
1119
1120
|
let t;
|
|
1120
1121
|
return () => (t ??= e(), t);
|
|
1121
1122
|
}
|
|
1122
|
-
function
|
|
1123
|
+
function Gt(e, { validate: t } = {}) {
|
|
1123
1124
|
return {
|
|
1124
|
-
[
|
|
1125
|
+
[Ut]: !0,
|
|
1125
1126
|
_type: void 0,
|
|
1126
1127
|
get jsonSchema() {
|
|
1127
1128
|
return typeof e == "function" && (e = e()), e;
|
|
@@ -1129,20 +1130,20 @@ function Ut(e, { validate: t } = {}) {
|
|
|
1129
1130
|
validate: t
|
|
1130
1131
|
};
|
|
1131
1132
|
}
|
|
1132
|
-
function
|
|
1133
|
-
return typeof e == "object" && !!e &&
|
|
1133
|
+
function Kt(e) {
|
|
1134
|
+
return typeof e == "object" && !!e && Ut in e && e[Ut] === !0 && "jsonSchema" in e && "validate" in e;
|
|
1134
1135
|
}
|
|
1135
|
-
function
|
|
1136
|
-
return e == null ?
|
|
1136
|
+
function qt(e) {
|
|
1137
|
+
return e == null ? Gt({
|
|
1137
1138
|
type: "object",
|
|
1138
1139
|
properties: {},
|
|
1139
1140
|
additionalProperties: !1
|
|
1140
|
-
}) :
|
|
1141
|
+
}) : Kt(e) ? e : "~standard" in e ? e["~standard"].vendor === "zod" ? $t(e) : Jt(e) : e();
|
|
1141
1142
|
}
|
|
1142
|
-
function
|
|
1143
|
-
return
|
|
1144
|
-
if (!
|
|
1145
|
-
return
|
|
1143
|
+
function Jt(e) {
|
|
1144
|
+
return Gt(() => {
|
|
1145
|
+
if (!Yt(e)) throw Error(`Standard schema vendor '${e["~standard"].vendor}' does not support JSON Schema conversion.`);
|
|
1146
|
+
return qe(e["~standard"].jsonSchema.input({ target: "draft-07" }));
|
|
1146
1147
|
}, { validate: async (t) => {
|
|
1147
1148
|
let n = await e["~standard"].validate(t);
|
|
1148
1149
|
return "value" in n ? {
|
|
@@ -1150,19 +1151,19 @@ function Kt(e) {
|
|
|
1150
1151
|
value: n.value
|
|
1151
1152
|
} : {
|
|
1152
1153
|
success: !1,
|
|
1153
|
-
error: new
|
|
1154
|
+
error: new j({
|
|
1154
1155
|
value: t,
|
|
1155
1156
|
cause: n.issues
|
|
1156
1157
|
})
|
|
1157
1158
|
};
|
|
1158
1159
|
} });
|
|
1159
1160
|
}
|
|
1160
|
-
function
|
|
1161
|
+
function Yt(e) {
|
|
1161
1162
|
return e["~standard"].jsonSchema != null;
|
|
1162
1163
|
}
|
|
1163
|
-
function
|
|
1164
|
+
function Xt(e, t) {
|
|
1164
1165
|
let n = t?.useReferences ?? !1;
|
|
1165
|
-
return
|
|
1166
|
+
return Gt(() => Ht(e, { $refStrategy: n ? "root" : "none" }), { validate: async (t) => {
|
|
1166
1167
|
let n = await e.safeParseAsync(t);
|
|
1167
1168
|
return n.success ? {
|
|
1168
1169
|
success: !0,
|
|
@@ -1173,9 +1174,9 @@ function Jt(e, t) {
|
|
|
1173
1174
|
};
|
|
1174
1175
|
} });
|
|
1175
1176
|
}
|
|
1176
|
-
function
|
|
1177
|
+
function Zt(t, n) {
|
|
1177
1178
|
let r = n?.useReferences ?? !1;
|
|
1178
|
-
return
|
|
1179
|
+
return Gt(() => qe(_(t, {
|
|
1179
1180
|
target: "draft-7",
|
|
1180
1181
|
io: "input",
|
|
1181
1182
|
reused: r ? "ref" : "inline"
|
|
@@ -1190,27 +1191,27 @@ function Yt(t, n) {
|
|
|
1190
1191
|
};
|
|
1191
1192
|
} });
|
|
1192
1193
|
}
|
|
1193
|
-
function
|
|
1194
|
+
function Qt(e) {
|
|
1194
1195
|
return "_zod" in e;
|
|
1195
1196
|
}
|
|
1196
|
-
function
|
|
1197
|
-
return
|
|
1197
|
+
function $t(e, t) {
|
|
1198
|
+
return Qt(e) ? Zt(e, t) : Xt(e, t);
|
|
1198
1199
|
}
|
|
1199
|
-
async function
|
|
1200
|
-
let r = await
|
|
1200
|
+
async function en({ value: e, schema: t, context: n }) {
|
|
1201
|
+
let r = await tn({
|
|
1201
1202
|
value: e,
|
|
1202
1203
|
schema: t,
|
|
1203
1204
|
context: n
|
|
1204
1205
|
});
|
|
1205
|
-
if (!r.success) throw
|
|
1206
|
+
if (!r.success) throw j.wrap({
|
|
1206
1207
|
value: e,
|
|
1207
1208
|
cause: r.error,
|
|
1208
1209
|
context: n
|
|
1209
1210
|
});
|
|
1210
1211
|
return r.value;
|
|
1211
1212
|
}
|
|
1212
|
-
async function
|
|
1213
|
-
let r =
|
|
1213
|
+
async function tn({ value: e, schema: t, context: n }) {
|
|
1214
|
+
let r = qt(t);
|
|
1214
1215
|
try {
|
|
1215
1216
|
if (r.validate == null) return {
|
|
1216
1217
|
success: !0,
|
|
@@ -1224,7 +1225,7 @@ async function $t({ value: e, schema: t, context: n }) {
|
|
|
1224
1225
|
rawValue: e
|
|
1225
1226
|
} : {
|
|
1226
1227
|
success: !1,
|
|
1227
|
-
error:
|
|
1228
|
+
error: j.wrap({
|
|
1228
1229
|
value: e,
|
|
1229
1230
|
cause: t.error,
|
|
1230
1231
|
context: n
|
|
@@ -1234,7 +1235,7 @@ async function $t({ value: e, schema: t, context: n }) {
|
|
|
1234
1235
|
} catch (t) {
|
|
1235
1236
|
return {
|
|
1236
1237
|
success: !1,
|
|
1237
|
-
error:
|
|
1238
|
+
error: j.wrap({
|
|
1238
1239
|
value: e,
|
|
1239
1240
|
cause: t,
|
|
1240
1241
|
context: n
|
|
@@ -1243,14 +1244,14 @@ async function $t({ value: e, schema: t, context: n }) {
|
|
|
1243
1244
|
};
|
|
1244
1245
|
}
|
|
1245
1246
|
}
|
|
1246
|
-
async function
|
|
1247
|
+
async function G({ text: e, schema: t }) {
|
|
1247
1248
|
try {
|
|
1248
|
-
let n =
|
|
1249
|
+
let n = Ke(e);
|
|
1249
1250
|
return t == null ? {
|
|
1250
1251
|
success: !0,
|
|
1251
1252
|
value: n,
|
|
1252
1253
|
rawValue: n
|
|
1253
|
-
} : await
|
|
1254
|
+
} : await tn({
|
|
1254
1255
|
value: n,
|
|
1255
1256
|
schema: t
|
|
1256
1257
|
});
|
|
@@ -1265,49 +1266,49 @@ async function W({ text: e, schema: t }) {
|
|
|
1265
1266
|
};
|
|
1266
1267
|
}
|
|
1267
1268
|
}
|
|
1268
|
-
function
|
|
1269
|
-
return e.pipeThrough(new TextDecoderStream()).pipeThrough(new
|
|
1270
|
-
e !== "[DONE]" && n.enqueue(await
|
|
1269
|
+
function nn({ stream: e, schema: t }) {
|
|
1270
|
+
return e.pipeThrough(new TextDecoderStream()).pipeThrough(new Ie()).pipeThrough(new TransformStream({ async transform({ data: e }, n) {
|
|
1271
|
+
e !== "[DONE]" && n.enqueue(await G({
|
|
1271
1272
|
text: e,
|
|
1272
1273
|
schema: t
|
|
1273
1274
|
}));
|
|
1274
1275
|
} }));
|
|
1275
1276
|
}
|
|
1276
|
-
async function
|
|
1277
|
+
async function K(e) {
|
|
1277
1278
|
return typeof e == "function" && (e = e()), Promise.resolve(e);
|
|
1278
1279
|
}
|
|
1279
1280
|
new TextDecoder();
|
|
1280
|
-
var
|
|
1281
|
-
for (var n in t)
|
|
1281
|
+
var rn = Object.defineProperty, an = (e, t) => {
|
|
1282
|
+
for (var n in t) rn(e, n, {
|
|
1282
1283
|
get: t[n],
|
|
1283
1284
|
enumerable: !0
|
|
1284
1285
|
});
|
|
1285
|
-
},
|
|
1286
|
+
}, on = "AI_NoObjectGeneratedError", sn = `vercel.ai.error.${on}`, cn = Symbol.for(sn), ln, q = class extends w {
|
|
1286
1287
|
constructor({ message: e = "No object generated.", cause: t, text: n, response: r, usage: i, finishReason: a }) {
|
|
1287
1288
|
super({
|
|
1288
|
-
name:
|
|
1289
|
+
name: on,
|
|
1289
1290
|
message: e,
|
|
1290
1291
|
cause: t
|
|
1291
|
-
}), this[
|
|
1292
|
+
}), this[ln] = !0, this.text = n, this.response = r, this.usage = i, this.finishReason = a;
|
|
1292
1293
|
}
|
|
1293
1294
|
static isInstance(e) {
|
|
1294
|
-
return
|
|
1295
|
+
return w.hasMarker(e, sn);
|
|
1295
1296
|
}
|
|
1296
1297
|
};
|
|
1297
|
-
|
|
1298
|
-
var
|
|
1298
|
+
ln = cn;
|
|
1299
|
+
var un = "AI_UIMessageStreamError", dn = `vercel.ai.error.${un}`, fn = Symbol.for(dn), pn, J = class extends w {
|
|
1299
1300
|
constructor({ chunkType: e, chunkId: t, message: n }) {
|
|
1300
1301
|
super({
|
|
1301
|
-
name:
|
|
1302
|
+
name: un,
|
|
1302
1303
|
message: n
|
|
1303
|
-
}), this[
|
|
1304
|
+
}), this[pn] = !0, this.chunkType = e, this.chunkId = t;
|
|
1304
1305
|
}
|
|
1305
1306
|
static isInstance(e) {
|
|
1306
|
-
return
|
|
1307
|
+
return w.hasMarker(e, dn);
|
|
1307
1308
|
}
|
|
1308
1309
|
};
|
|
1309
|
-
|
|
1310
|
-
function
|
|
1310
|
+
pn = fn;
|
|
1311
|
+
function mn(e, t) {
|
|
1311
1312
|
if (e === void 0 && t === void 0) return;
|
|
1312
1313
|
if (e === void 0) return t;
|
|
1313
1314
|
if (t === void 0) return e;
|
|
@@ -1316,11 +1317,11 @@ function fn(e, t) {
|
|
|
1316
1317
|
let i = t[r];
|
|
1317
1318
|
if (i === void 0) continue;
|
|
1318
1319
|
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);
|
|
1319
|
-
n[r] = o && s ?
|
|
1320
|
+
n[r] = o && s ? mn(a, i) : i;
|
|
1320
1321
|
}
|
|
1321
1322
|
return n;
|
|
1322
1323
|
}
|
|
1323
|
-
var
|
|
1324
|
+
var Y = {
|
|
1324
1325
|
array: n,
|
|
1325
1326
|
boolean: p,
|
|
1326
1327
|
custom: i,
|
|
@@ -1338,238 +1339,238 @@ var J = {
|
|
|
1338
1339
|
string: g,
|
|
1339
1340
|
union: ee,
|
|
1340
1341
|
unknown: r
|
|
1341
|
-
},
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
])),
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
]),
|
|
1354
|
-
type:
|
|
1355
|
-
text:
|
|
1356
|
-
providerOptions:
|
|
1357
|
-
}),
|
|
1358
|
-
type:
|
|
1359
|
-
image:
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1342
|
+
}, X = Y.lazy(() => Y.union([
|
|
1343
|
+
Y.null(),
|
|
1344
|
+
Y.string(),
|
|
1345
|
+
Y.number(),
|
|
1346
|
+
Y.boolean(),
|
|
1347
|
+
Y.record(Y.string(), X.optional()),
|
|
1348
|
+
Y.array(X)
|
|
1349
|
+
])), Z = Y.record(Y.string(), Y.record(Y.string(), X.optional())), hn = Y.union([
|
|
1350
|
+
Y.string(),
|
|
1351
|
+
Y.instanceof(Uint8Array),
|
|
1352
|
+
Y.instanceof(ArrayBuffer),
|
|
1353
|
+
Y.custom(Ve, { message: "Must be a Buffer" })
|
|
1354
|
+
]), gn = Y.record(Y.string(), Y.string()), _n = Y.object({
|
|
1355
|
+
type: Y.literal("text"),
|
|
1356
|
+
text: Y.string(),
|
|
1357
|
+
providerOptions: Z.optional()
|
|
1358
|
+
}), vn = Y.object({
|
|
1359
|
+
type: Y.literal("image"),
|
|
1360
|
+
image: Y.union([
|
|
1361
|
+
hn,
|
|
1362
|
+
Y.instanceof(URL),
|
|
1363
|
+
gn
|
|
1363
1364
|
]),
|
|
1364
|
-
mediaType:
|
|
1365
|
-
providerOptions:
|
|
1366
|
-
}),
|
|
1367
|
-
|
|
1368
|
-
type:
|
|
1369
|
-
data:
|
|
1365
|
+
mediaType: Y.string().optional(),
|
|
1366
|
+
providerOptions: Z.optional()
|
|
1367
|
+
}), yn = Y.discriminatedUnion("type", [
|
|
1368
|
+
Y.object({
|
|
1369
|
+
type: Y.literal("data"),
|
|
1370
|
+
data: hn
|
|
1370
1371
|
}),
|
|
1371
|
-
|
|
1372
|
-
type:
|
|
1373
|
-
url:
|
|
1372
|
+
Y.object({
|
|
1373
|
+
type: Y.literal("url"),
|
|
1374
|
+
url: Y.instanceof(URL)
|
|
1374
1375
|
}),
|
|
1375
|
-
|
|
1376
|
-
type:
|
|
1377
|
-
reference:
|
|
1376
|
+
Y.object({
|
|
1377
|
+
type: Y.literal("reference"),
|
|
1378
|
+
reference: gn
|
|
1378
1379
|
}),
|
|
1379
|
-
|
|
1380
|
-
type:
|
|
1381
|
-
text:
|
|
1380
|
+
Y.object({
|
|
1381
|
+
type: Y.literal("text"),
|
|
1382
|
+
text: Y.string()
|
|
1382
1383
|
})
|
|
1383
|
-
]),
|
|
1384
|
-
type:
|
|
1385
|
-
data:
|
|
1386
|
-
}),
|
|
1387
|
-
type:
|
|
1388
|
-
url:
|
|
1389
|
-
})]),
|
|
1390
|
-
type:
|
|
1391
|
-
data:
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1384
|
+
]), bn = Y.discriminatedUnion("type", [Y.object({
|
|
1385
|
+
type: Y.literal("data"),
|
|
1386
|
+
data: hn
|
|
1387
|
+
}), Y.object({
|
|
1388
|
+
type: Y.literal("url"),
|
|
1389
|
+
url: Y.instanceof(URL)
|
|
1390
|
+
})]), xn = Y.object({
|
|
1391
|
+
type: Y.literal("file"),
|
|
1392
|
+
data: Y.union([
|
|
1393
|
+
yn,
|
|
1394
|
+
hn,
|
|
1395
|
+
Y.instanceof(URL),
|
|
1396
|
+
gn
|
|
1396
1397
|
]),
|
|
1397
|
-
filename:
|
|
1398
|
-
mediaType:
|
|
1399
|
-
providerOptions:
|
|
1400
|
-
}),
|
|
1401
|
-
type:
|
|
1402
|
-
text:
|
|
1403
|
-
providerOptions:
|
|
1404
|
-
}),
|
|
1405
|
-
type:
|
|
1406
|
-
kind:
|
|
1407
|
-
providerOptions:
|
|
1408
|
-
}),
|
|
1409
|
-
type:
|
|
1410
|
-
data:
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1398
|
+
filename: Y.string().optional(),
|
|
1399
|
+
mediaType: Y.string(),
|
|
1400
|
+
providerOptions: Z.optional()
|
|
1401
|
+
}), Sn = Y.object({
|
|
1402
|
+
type: Y.literal("reasoning"),
|
|
1403
|
+
text: Y.string(),
|
|
1404
|
+
providerOptions: Z.optional()
|
|
1405
|
+
}), Cn = Y.object({
|
|
1406
|
+
type: Y.literal("custom"),
|
|
1407
|
+
kind: Y.string().transform((e) => e),
|
|
1408
|
+
providerOptions: Z.optional()
|
|
1409
|
+
}), wn = Y.object({
|
|
1410
|
+
type: Y.literal("reasoning-file"),
|
|
1411
|
+
data: Y.union([
|
|
1412
|
+
bn,
|
|
1413
|
+
hn,
|
|
1414
|
+
Y.instanceof(URL)
|
|
1414
1415
|
]),
|
|
1415
|
-
mediaType:
|
|
1416
|
-
providerOptions:
|
|
1417
|
-
}),
|
|
1418
|
-
type:
|
|
1419
|
-
toolCallId:
|
|
1420
|
-
toolName:
|
|
1421
|
-
input:
|
|
1422
|
-
providerOptions:
|
|
1423
|
-
providerExecuted:
|
|
1424
|
-
}),
|
|
1425
|
-
|
|
1426
|
-
type:
|
|
1427
|
-
value:
|
|
1428
|
-
providerOptions:
|
|
1416
|
+
mediaType: Y.string(),
|
|
1417
|
+
providerOptions: Z.optional()
|
|
1418
|
+
}), Tn = Y.object({
|
|
1419
|
+
type: Y.literal("tool-call"),
|
|
1420
|
+
toolCallId: Y.string(),
|
|
1421
|
+
toolName: Y.string(),
|
|
1422
|
+
input: Y.unknown(),
|
|
1423
|
+
providerOptions: Z.optional(),
|
|
1424
|
+
providerExecuted: Y.boolean().optional()
|
|
1425
|
+
}), En = Y.discriminatedUnion("type", [
|
|
1426
|
+
Y.object({
|
|
1427
|
+
type: Y.literal("text"),
|
|
1428
|
+
value: Y.string(),
|
|
1429
|
+
providerOptions: Z.optional()
|
|
1429
1430
|
}),
|
|
1430
|
-
|
|
1431
|
-
type:
|
|
1432
|
-
value:
|
|
1433
|
-
providerOptions:
|
|
1431
|
+
Y.object({
|
|
1432
|
+
type: Y.literal("json"),
|
|
1433
|
+
value: X,
|
|
1434
|
+
providerOptions: Z.optional()
|
|
1434
1435
|
}),
|
|
1435
|
-
|
|
1436
|
-
type:
|
|
1437
|
-
reason:
|
|
1438
|
-
providerOptions:
|
|
1436
|
+
Y.object({
|
|
1437
|
+
type: Y.literal("execution-denied"),
|
|
1438
|
+
reason: Y.string().optional(),
|
|
1439
|
+
providerOptions: Z.optional()
|
|
1439
1440
|
}),
|
|
1440
|
-
|
|
1441
|
-
type:
|
|
1442
|
-
value:
|
|
1443
|
-
providerOptions:
|
|
1441
|
+
Y.object({
|
|
1442
|
+
type: Y.literal("error-text"),
|
|
1443
|
+
value: Y.string(),
|
|
1444
|
+
providerOptions: Z.optional()
|
|
1444
1445
|
}),
|
|
1445
|
-
|
|
1446
|
-
type:
|
|
1447
|
-
value:
|
|
1448
|
-
providerOptions:
|
|
1446
|
+
Y.object({
|
|
1447
|
+
type: Y.literal("error-json"),
|
|
1448
|
+
value: X,
|
|
1449
|
+
providerOptions: Z.optional()
|
|
1449
1450
|
}),
|
|
1450
|
-
|
|
1451
|
-
type:
|
|
1452
|
-
value:
|
|
1453
|
-
|
|
1454
|
-
type:
|
|
1455
|
-
text:
|
|
1456
|
-
providerOptions:
|
|
1451
|
+
Y.object({
|
|
1452
|
+
type: Y.literal("content"),
|
|
1453
|
+
value: Y.array(Y.union([
|
|
1454
|
+
Y.object({
|
|
1455
|
+
type: Y.literal("text"),
|
|
1456
|
+
text: Y.string(),
|
|
1457
|
+
providerOptions: Z.optional()
|
|
1457
1458
|
}),
|
|
1458
|
-
|
|
1459
|
-
type:
|
|
1460
|
-
data:
|
|
1461
|
-
mediaType:
|
|
1462
|
-
filename:
|
|
1463
|
-
providerOptions:
|
|
1459
|
+
Y.object({
|
|
1460
|
+
type: Y.literal("file"),
|
|
1461
|
+
data: yn,
|
|
1462
|
+
mediaType: Y.string(),
|
|
1463
|
+
filename: Y.string().optional(),
|
|
1464
|
+
providerOptions: Z.optional()
|
|
1464
1465
|
}),
|
|
1465
|
-
|
|
1466
|
-
type:
|
|
1467
|
-
data:
|
|
1468
|
-
mediaType:
|
|
1469
|
-
filename:
|
|
1470
|
-
providerOptions:
|
|
1466
|
+
Y.object({
|
|
1467
|
+
type: Y.literal("file-data"),
|
|
1468
|
+
data: Y.string(),
|
|
1469
|
+
mediaType: Y.string(),
|
|
1470
|
+
filename: Y.string().optional(),
|
|
1471
|
+
providerOptions: Z.optional()
|
|
1471
1472
|
}),
|
|
1472
|
-
|
|
1473
|
-
type:
|
|
1474
|
-
url:
|
|
1475
|
-
mediaType:
|
|
1476
|
-
providerOptions:
|
|
1473
|
+
Y.object({
|
|
1474
|
+
type: Y.literal("file-url"),
|
|
1475
|
+
url: Y.string(),
|
|
1476
|
+
mediaType: Y.string().optional(),
|
|
1477
|
+
providerOptions: Z.optional()
|
|
1477
1478
|
}),
|
|
1478
|
-
|
|
1479
|
-
type:
|
|
1480
|
-
fileId:
|
|
1481
|
-
providerOptions:
|
|
1479
|
+
Y.object({
|
|
1480
|
+
type: Y.literal("file-id"),
|
|
1481
|
+
fileId: Y.union([Y.string(), Y.record(Y.string(), Y.string())]),
|
|
1482
|
+
providerOptions: Z.optional()
|
|
1482
1483
|
}),
|
|
1483
|
-
|
|
1484
|
-
type:
|
|
1485
|
-
providerReference:
|
|
1486
|
-
providerOptions:
|
|
1484
|
+
Y.object({
|
|
1485
|
+
type: Y.literal("file-reference"),
|
|
1486
|
+
providerReference: Y.record(Y.string(), Y.string()),
|
|
1487
|
+
providerOptions: Z.optional()
|
|
1487
1488
|
}),
|
|
1488
|
-
|
|
1489
|
-
type:
|
|
1490
|
-
data:
|
|
1491
|
-
mediaType:
|
|
1492
|
-
providerOptions:
|
|
1489
|
+
Y.object({
|
|
1490
|
+
type: Y.literal("image-data"),
|
|
1491
|
+
data: Y.string(),
|
|
1492
|
+
mediaType: Y.string(),
|
|
1493
|
+
providerOptions: Z.optional()
|
|
1493
1494
|
}),
|
|
1494
|
-
|
|
1495
|
-
type:
|
|
1496
|
-
url:
|
|
1497
|
-
providerOptions:
|
|
1495
|
+
Y.object({
|
|
1496
|
+
type: Y.literal("image-url"),
|
|
1497
|
+
url: Y.string(),
|
|
1498
|
+
providerOptions: Z.optional()
|
|
1498
1499
|
}),
|
|
1499
|
-
|
|
1500
|
-
type:
|
|
1501
|
-
fileId:
|
|
1502
|
-
providerOptions:
|
|
1500
|
+
Y.object({
|
|
1501
|
+
type: Y.literal("image-file-id"),
|
|
1502
|
+
fileId: Y.union([Y.string(), Y.record(Y.string(), Y.string())]),
|
|
1503
|
+
providerOptions: Z.optional()
|
|
1503
1504
|
}),
|
|
1504
|
-
|
|
1505
|
-
type:
|
|
1506
|
-
providerReference:
|
|
1507
|
-
providerOptions:
|
|
1505
|
+
Y.object({
|
|
1506
|
+
type: Y.literal("image-file-reference"),
|
|
1507
|
+
providerReference: Y.record(Y.string(), Y.string()),
|
|
1508
|
+
providerOptions: Z.optional()
|
|
1508
1509
|
}),
|
|
1509
|
-
|
|
1510
|
-
type:
|
|
1511
|
-
providerOptions:
|
|
1510
|
+
Y.object({
|
|
1511
|
+
type: Y.literal("custom"),
|
|
1512
|
+
providerOptions: Z.optional()
|
|
1512
1513
|
})
|
|
1513
1514
|
]))
|
|
1514
1515
|
})
|
|
1515
|
-
]),
|
|
1516
|
-
type:
|
|
1517
|
-
toolCallId:
|
|
1518
|
-
toolName:
|
|
1519
|
-
output:
|
|
1520
|
-
providerOptions:
|
|
1521
|
-
}),
|
|
1522
|
-
type:
|
|
1523
|
-
approvalId:
|
|
1524
|
-
toolCallId:
|
|
1525
|
-
}),
|
|
1526
|
-
type:
|
|
1527
|
-
approvalId:
|
|
1528
|
-
approved:
|
|
1529
|
-
reason:
|
|
1530
|
-
}),
|
|
1531
|
-
role:
|
|
1532
|
-
content:
|
|
1533
|
-
providerOptions:
|
|
1534
|
-
}),
|
|
1535
|
-
role:
|
|
1536
|
-
content:
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1516
|
+
]), Dn = Y.object({
|
|
1517
|
+
type: Y.literal("tool-result"),
|
|
1518
|
+
toolCallId: Y.string(),
|
|
1519
|
+
toolName: Y.string(),
|
|
1520
|
+
output: En,
|
|
1521
|
+
providerOptions: Z.optional()
|
|
1522
|
+
}), On = Y.object({
|
|
1523
|
+
type: Y.literal("tool-approval-request"),
|
|
1524
|
+
approvalId: Y.string(),
|
|
1525
|
+
toolCallId: Y.string()
|
|
1526
|
+
}), kn = Y.object({
|
|
1527
|
+
type: Y.literal("tool-approval-response"),
|
|
1528
|
+
approvalId: Y.string(),
|
|
1529
|
+
approved: Y.boolean(),
|
|
1530
|
+
reason: Y.string().optional()
|
|
1531
|
+
}), An = Y.object({
|
|
1532
|
+
role: Y.literal("system"),
|
|
1533
|
+
content: Y.string(),
|
|
1534
|
+
providerOptions: Z.optional()
|
|
1535
|
+
}), jn = Y.object({
|
|
1536
|
+
role: Y.literal("user"),
|
|
1537
|
+
content: Y.union([Y.string(), Y.array(Y.union([
|
|
1538
|
+
_n,
|
|
1539
|
+
vn,
|
|
1540
|
+
xn
|
|
1540
1541
|
]))]),
|
|
1541
|
-
providerOptions:
|
|
1542
|
-
}),
|
|
1543
|
-
role:
|
|
1544
|
-
content:
|
|
1545
|
-
|
|
1542
|
+
providerOptions: Z.optional()
|
|
1543
|
+
}), Mn = Y.object({
|
|
1544
|
+
role: Y.literal("assistant"),
|
|
1545
|
+
content: Y.union([Y.string(), Y.array(Y.union([
|
|
1546
|
+
_n,
|
|
1547
|
+
Cn,
|
|
1546
1548
|
xn,
|
|
1547
|
-
yn,
|
|
1548
|
-
bn,
|
|
1549
1549
|
Sn,
|
|
1550
|
-
|
|
1550
|
+
wn,
|
|
1551
1551
|
Tn,
|
|
1552
|
-
|
|
1552
|
+
Dn,
|
|
1553
|
+
On
|
|
1553
1554
|
]))]),
|
|
1554
|
-
providerOptions:
|
|
1555
|
-
}),
|
|
1556
|
-
role:
|
|
1557
|
-
content:
|
|
1558
|
-
providerOptions:
|
|
1555
|
+
providerOptions: Z.optional()
|
|
1556
|
+
}), Nn = Y.object({
|
|
1557
|
+
role: Y.literal("tool"),
|
|
1558
|
+
content: Y.array(Y.union([Dn, kn])),
|
|
1559
|
+
providerOptions: Z.optional()
|
|
1559
1560
|
});
|
|
1560
|
-
|
|
1561
|
-
On,
|
|
1562
|
-
kn,
|
|
1561
|
+
Y.union([
|
|
1563
1562
|
An,
|
|
1564
|
-
jn
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1563
|
+
jn,
|
|
1564
|
+
Mn,
|
|
1565
|
+
Nn
|
|
1566
|
+
]), an({}, {
|
|
1567
|
+
array: () => Rn,
|
|
1568
|
+
choice: () => zn,
|
|
1569
|
+
json: () => Bn,
|
|
1570
|
+
object: () => Ln,
|
|
1571
|
+
text: () => In
|
|
1571
1572
|
});
|
|
1572
|
-
function
|
|
1573
|
+
function Pn(e) {
|
|
1573
1574
|
let t = ["ROOT"], n = -1, r = null, i = 0;
|
|
1574
1575
|
function a(e) {
|
|
1575
1576
|
return e >= "0" && e <= "9" || e >= "A" && e <= "F" || e >= "a" && e <= "f";
|
|
@@ -1751,16 +1752,16 @@ function Mn(e) {
|
|
|
1751
1752
|
}
|
|
1752
1753
|
return l;
|
|
1753
1754
|
}
|
|
1754
|
-
async function
|
|
1755
|
+
async function Fn(e) {
|
|
1755
1756
|
if (e === void 0) return {
|
|
1756
1757
|
value: void 0,
|
|
1757
1758
|
state: "undefined-input"
|
|
1758
1759
|
};
|
|
1759
|
-
let t = await
|
|
1760
|
+
let t = await G({ text: e });
|
|
1760
1761
|
return t.success ? {
|
|
1761
1762
|
value: t.value,
|
|
1762
1763
|
state: "successful-parse"
|
|
1763
|
-
} : (t = await
|
|
1764
|
+
} : (t = await G({ text: Pn(e) }), t.success ? {
|
|
1764
1765
|
value: t.value,
|
|
1765
1766
|
state: "repaired-parse"
|
|
1766
1767
|
} : {
|
|
@@ -1768,7 +1769,7 @@ async function Nn(e) {
|
|
|
1768
1769
|
state: "failed-parse"
|
|
1769
1770
|
});
|
|
1770
1771
|
}
|
|
1771
|
-
var
|
|
1772
|
+
var In = () => ({
|
|
1772
1773
|
name: "text",
|
|
1773
1774
|
responseFormat: Promise.resolve({ type: "text" }),
|
|
1774
1775
|
async parseCompleteOutput({ text: e }) {
|
|
@@ -1778,19 +1779,19 @@ var Pn = () => ({
|
|
|
1778
1779
|
return { partial: e };
|
|
1779
1780
|
},
|
|
1780
1781
|
createElementStreamTransform() {}
|
|
1781
|
-
}),
|
|
1782
|
-
let r =
|
|
1782
|
+
}), Ln = ({ schema: e, name: t, description: n }) => {
|
|
1783
|
+
let r = qt(e);
|
|
1783
1784
|
return {
|
|
1784
1785
|
name: "object",
|
|
1785
|
-
responseFormat:
|
|
1786
|
+
responseFormat: K(r.jsonSchema).then((e) => ({
|
|
1786
1787
|
type: "json",
|
|
1787
1788
|
schema: e,
|
|
1788
1789
|
...t != null && { name: t },
|
|
1789
1790
|
...n != null && { description: n }
|
|
1790
1791
|
})),
|
|
1791
1792
|
async parseCompleteOutput({ text: e }, t) {
|
|
1792
|
-
let n = await
|
|
1793
|
-
if (!n.success) throw new
|
|
1793
|
+
let n = await G({ text: e });
|
|
1794
|
+
if (!n.success) throw new q({
|
|
1794
1795
|
message: "No object generated: could not parse the response.",
|
|
1795
1796
|
cause: n.error,
|
|
1796
1797
|
text: e,
|
|
@@ -1798,11 +1799,11 @@ var Pn = () => ({
|
|
|
1798
1799
|
usage: t.usage,
|
|
1799
1800
|
finishReason: t.finishReason
|
|
1800
1801
|
});
|
|
1801
|
-
let i = await
|
|
1802
|
+
let i = await tn({
|
|
1802
1803
|
value: n.value,
|
|
1803
1804
|
schema: r
|
|
1804
1805
|
});
|
|
1805
|
-
if (!i.success) throw new
|
|
1806
|
+
if (!i.success) throw new q({
|
|
1806
1807
|
message: "No object generated: response did not match schema.",
|
|
1807
1808
|
cause: i.error,
|
|
1808
1809
|
text: e,
|
|
@@ -1813,7 +1814,7 @@ var Pn = () => ({
|
|
|
1813
1814
|
return i.value;
|
|
1814
1815
|
},
|
|
1815
1816
|
async parsePartialOutput({ text: e }) {
|
|
1816
|
-
let t = await
|
|
1817
|
+
let t = await Fn(e);
|
|
1817
1818
|
switch (t.state) {
|
|
1818
1819
|
case "failed-parse":
|
|
1819
1820
|
case "undefined-input": return;
|
|
@@ -1823,11 +1824,11 @@ var Pn = () => ({
|
|
|
1823
1824
|
},
|
|
1824
1825
|
createElementStreamTransform() {}
|
|
1825
1826
|
};
|
|
1826
|
-
},
|
|
1827
|
-
let r =
|
|
1827
|
+
}, Rn = ({ element: e, name: t, description: n }) => {
|
|
1828
|
+
let r = qt(e);
|
|
1828
1829
|
return {
|
|
1829
1830
|
name: "array",
|
|
1830
|
-
responseFormat:
|
|
1831
|
+
responseFormat: K(r.jsonSchema).then((e) => {
|
|
1831
1832
|
let { $schema: r, definitions: i, $defs: a, ...o } = e;
|
|
1832
1833
|
return {
|
|
1833
1834
|
type: "json",
|
|
@@ -1848,8 +1849,8 @@ var Pn = () => ({
|
|
|
1848
1849
|
};
|
|
1849
1850
|
}),
|
|
1850
1851
|
async parseCompleteOutput({ text: e }, t) {
|
|
1851
|
-
let n = await
|
|
1852
|
-
if (!n.success) throw new
|
|
1852
|
+
let n = await G({ text: e });
|
|
1853
|
+
if (!n.success) throw new q({
|
|
1853
1854
|
message: "No object generated: could not parse the response.",
|
|
1854
1855
|
cause: n.error,
|
|
1855
1856
|
text: e,
|
|
@@ -1858,9 +1859,9 @@ var Pn = () => ({
|
|
|
1858
1859
|
finishReason: t.finishReason
|
|
1859
1860
|
});
|
|
1860
1861
|
let i = n.value;
|
|
1861
|
-
if (typeof i != "object" || !i || !("elements" in i) || !Array.isArray(i.elements)) throw new
|
|
1862
|
+
if (typeof i != "object" || !i || !("elements" in i) || !Array.isArray(i.elements)) throw new q({
|
|
1862
1863
|
message: "No object generated: response did not match schema.",
|
|
1863
|
-
cause: new
|
|
1864
|
+
cause: new j({
|
|
1864
1865
|
value: i,
|
|
1865
1866
|
cause: "response must be an object with an elements array"
|
|
1866
1867
|
}),
|
|
@@ -1871,11 +1872,11 @@ var Pn = () => ({
|
|
|
1871
1872
|
});
|
|
1872
1873
|
let a = [];
|
|
1873
1874
|
for (let n of i.elements) {
|
|
1874
|
-
let i = await
|
|
1875
|
+
let i = await tn({
|
|
1875
1876
|
value: n,
|
|
1876
1877
|
schema: r
|
|
1877
1878
|
});
|
|
1878
|
-
if (!i.success) throw new
|
|
1879
|
+
if (!i.success) throw new q({
|
|
1879
1880
|
message: "No object generated: response did not match schema.",
|
|
1880
1881
|
cause: i.error,
|
|
1881
1882
|
text: e,
|
|
@@ -1888,7 +1889,7 @@ var Pn = () => ({
|
|
|
1888
1889
|
return a;
|
|
1889
1890
|
},
|
|
1890
1891
|
async parsePartialOutput({ text: e }) {
|
|
1891
|
-
let t = await
|
|
1892
|
+
let t = await Fn(e);
|
|
1892
1893
|
switch (t.state) {
|
|
1893
1894
|
case "failed-parse":
|
|
1894
1895
|
case "undefined-input": return;
|
|
@@ -1898,7 +1899,7 @@ var Pn = () => ({
|
|
|
1898
1899
|
if (typeof e != "object" || !e || !("elements" in e) || !Array.isArray(e.elements)) return;
|
|
1899
1900
|
let n = t.state === "repaired-parse" && e.elements.length > 0 ? e.elements.slice(0, -1) : e.elements, i = [];
|
|
1900
1901
|
for (let e of n) {
|
|
1901
|
-
let t = await
|
|
1902
|
+
let t = await tn({
|
|
1902
1903
|
value: e,
|
|
1903
1904
|
schema: r
|
|
1904
1905
|
});
|
|
@@ -1915,7 +1916,7 @@ var Pn = () => ({
|
|
|
1915
1916
|
} });
|
|
1916
1917
|
}
|
|
1917
1918
|
};
|
|
1918
|
-
},
|
|
1919
|
+
}, zn = ({ options: e, name: t, description: n }) => ({
|
|
1919
1920
|
name: "choice",
|
|
1920
1921
|
responseFormat: Promise.resolve({
|
|
1921
1922
|
type: "json",
|
|
@@ -1933,8 +1934,8 @@ var Pn = () => ({
|
|
|
1933
1934
|
...n != null && { description: n }
|
|
1934
1935
|
}),
|
|
1935
1936
|
async parseCompleteOutput({ text: t }, n) {
|
|
1936
|
-
let r = await
|
|
1937
|
-
if (!r.success) throw new
|
|
1937
|
+
let r = await G({ text: t });
|
|
1938
|
+
if (!r.success) throw new q({
|
|
1938
1939
|
message: "No object generated: could not parse the response.",
|
|
1939
1940
|
cause: r.error,
|
|
1940
1941
|
text: t,
|
|
@@ -1943,9 +1944,9 @@ var Pn = () => ({
|
|
|
1943
1944
|
finishReason: n.finishReason
|
|
1944
1945
|
});
|
|
1945
1946
|
let i = r.value;
|
|
1946
|
-
if (typeof i != "object" || !i || !("result" in i) || typeof i.result != "string" || !e.includes(i.result)) throw new
|
|
1947
|
+
if (typeof i != "object" || !i || !("result" in i) || typeof i.result != "string" || !e.includes(i.result)) throw new q({
|
|
1947
1948
|
message: "No object generated: response did not match schema.",
|
|
1948
|
-
cause: new
|
|
1949
|
+
cause: new j({
|
|
1949
1950
|
value: i,
|
|
1950
1951
|
cause: "response must be an object that contains a choice value."
|
|
1951
1952
|
}),
|
|
@@ -1957,7 +1958,7 @@ var Pn = () => ({
|
|
|
1957
1958
|
return i.result;
|
|
1958
1959
|
},
|
|
1959
1960
|
async parsePartialOutput({ text: t }) {
|
|
1960
|
-
let n = await
|
|
1961
|
+
let n = await Fn(t);
|
|
1961
1962
|
switch (n.state) {
|
|
1962
1963
|
case "failed-parse":
|
|
1963
1964
|
case "undefined-input": return;
|
|
@@ -1971,7 +1972,7 @@ var Pn = () => ({
|
|
|
1971
1972
|
}
|
|
1972
1973
|
},
|
|
1973
1974
|
createElementStreamTransform() {}
|
|
1974
|
-
}),
|
|
1975
|
+
}), Bn = ({ name: e, description: t } = {}) => ({
|
|
1975
1976
|
name: "json",
|
|
1976
1977
|
responseFormat: Promise.resolve({
|
|
1977
1978
|
type: "json",
|
|
@@ -1979,8 +1980,8 @@ var Pn = () => ({
|
|
|
1979
1980
|
...t != null && { description: t }
|
|
1980
1981
|
}),
|
|
1981
1982
|
async parseCompleteOutput({ text: e }, t) {
|
|
1982
|
-
let n = await
|
|
1983
|
-
if (!n.success) throw new
|
|
1983
|
+
let n = await G({ text: e });
|
|
1984
|
+
if (!n.success) throw new q({
|
|
1984
1985
|
message: "No object generated: could not parse the response.",
|
|
1985
1986
|
cause: n.error,
|
|
1986
1987
|
text: e,
|
|
@@ -1991,7 +1992,7 @@ var Pn = () => ({
|
|
|
1991
1992
|
return n.value;
|
|
1992
1993
|
},
|
|
1993
1994
|
async parsePartialOutput({ text: e }) {
|
|
1994
|
-
let t = await
|
|
1995
|
+
let t = await Fn(e);
|
|
1995
1996
|
switch (t.state) {
|
|
1996
1997
|
case "failed-parse":
|
|
1997
1998
|
case "undefined-input": return;
|
|
@@ -2001,175 +2002,175 @@ var Pn = () => ({
|
|
|
2001
2002
|
},
|
|
2002
2003
|
createElementStreamTransform() {}
|
|
2003
2004
|
});
|
|
2004
|
-
new TextEncoder(), new TextEncoder(),
|
|
2005
|
+
new TextEncoder(), new TextEncoder(), I({
|
|
2005
2006
|
prefix: "aitxt",
|
|
2006
2007
|
size: 24
|
|
2007
|
-
}),
|
|
2008
|
+
}), I({
|
|
2008
2009
|
prefix: "call",
|
|
2009
2010
|
size: 24
|
|
2010
2011
|
}), TransformStream;
|
|
2011
|
-
var
|
|
2012
|
-
|
|
2013
|
-
type:
|
|
2014
|
-
id:
|
|
2015
|
-
providerMetadata:
|
|
2012
|
+
var Vn = Y.record(Y.string(), X.optional()), Hn = Wt(() => $t(Y.union([
|
|
2013
|
+
Y.looseObject({
|
|
2014
|
+
type: Y.literal("text-start"),
|
|
2015
|
+
id: Y.string(),
|
|
2016
|
+
providerMetadata: Z.optional()
|
|
2016
2017
|
}),
|
|
2017
|
-
|
|
2018
|
-
type:
|
|
2019
|
-
id:
|
|
2020
|
-
delta:
|
|
2021
|
-
providerMetadata:
|
|
2018
|
+
Y.looseObject({
|
|
2019
|
+
type: Y.literal("text-delta"),
|
|
2020
|
+
id: Y.string(),
|
|
2021
|
+
delta: Y.string(),
|
|
2022
|
+
providerMetadata: Z.optional()
|
|
2022
2023
|
}),
|
|
2023
|
-
|
|
2024
|
-
type:
|
|
2025
|
-
id:
|
|
2026
|
-
providerMetadata:
|
|
2024
|
+
Y.looseObject({
|
|
2025
|
+
type: Y.literal("text-end"),
|
|
2026
|
+
id: Y.string(),
|
|
2027
|
+
providerMetadata: Z.optional()
|
|
2027
2028
|
}),
|
|
2028
|
-
|
|
2029
|
-
type:
|
|
2030
|
-
errorText:
|
|
2029
|
+
Y.looseObject({
|
|
2030
|
+
type: Y.literal("error"),
|
|
2031
|
+
errorText: Y.string()
|
|
2031
2032
|
}),
|
|
2032
|
-
|
|
2033
|
-
type:
|
|
2034
|
-
toolCallId:
|
|
2035
|
-
toolName:
|
|
2036
|
-
providerExecuted:
|
|
2037
|
-
providerMetadata:
|
|
2038
|
-
toolMetadata:
|
|
2039
|
-
dynamic:
|
|
2040
|
-
title:
|
|
2033
|
+
Y.looseObject({
|
|
2034
|
+
type: Y.literal("tool-input-start"),
|
|
2035
|
+
toolCallId: Y.string(),
|
|
2036
|
+
toolName: Y.string(),
|
|
2037
|
+
providerExecuted: Y.boolean().optional(),
|
|
2038
|
+
providerMetadata: Z.optional(),
|
|
2039
|
+
toolMetadata: Vn.optional(),
|
|
2040
|
+
dynamic: Y.boolean().optional(),
|
|
2041
|
+
title: Y.string().optional()
|
|
2041
2042
|
}),
|
|
2042
|
-
|
|
2043
|
-
type:
|
|
2044
|
-
toolCallId:
|
|
2045
|
-
inputTextDelta:
|
|
2043
|
+
Y.looseObject({
|
|
2044
|
+
type: Y.literal("tool-input-delta"),
|
|
2045
|
+
toolCallId: Y.string(),
|
|
2046
|
+
inputTextDelta: Y.string()
|
|
2046
2047
|
}),
|
|
2047
|
-
|
|
2048
|
-
type:
|
|
2049
|
-
toolCallId:
|
|
2050
|
-
toolName:
|
|
2051
|
-
input:
|
|
2052
|
-
providerExecuted:
|
|
2053
|
-
providerMetadata:
|
|
2054
|
-
toolMetadata:
|
|
2055
|
-
dynamic:
|
|
2056
|
-
title:
|
|
2048
|
+
Y.looseObject({
|
|
2049
|
+
type: Y.literal("tool-input-available"),
|
|
2050
|
+
toolCallId: Y.string(),
|
|
2051
|
+
toolName: Y.string(),
|
|
2052
|
+
input: Y.unknown(),
|
|
2053
|
+
providerExecuted: Y.boolean().optional(),
|
|
2054
|
+
providerMetadata: Z.optional(),
|
|
2055
|
+
toolMetadata: Vn.optional(),
|
|
2056
|
+
dynamic: Y.boolean().optional(),
|
|
2057
|
+
title: Y.string().optional()
|
|
2057
2058
|
}),
|
|
2058
|
-
|
|
2059
|
-
type:
|
|
2060
|
-
toolCallId:
|
|
2061
|
-
toolName:
|
|
2062
|
-
input:
|
|
2063
|
-
providerExecuted:
|
|
2064
|
-
providerMetadata:
|
|
2065
|
-
toolMetadata:
|
|
2066
|
-
dynamic:
|
|
2067
|
-
errorText:
|
|
2068
|
-
title:
|
|
2059
|
+
Y.looseObject({
|
|
2060
|
+
type: Y.literal("tool-input-error"),
|
|
2061
|
+
toolCallId: Y.string(),
|
|
2062
|
+
toolName: Y.string(),
|
|
2063
|
+
input: Y.unknown(),
|
|
2064
|
+
providerExecuted: Y.boolean().optional(),
|
|
2065
|
+
providerMetadata: Z.optional(),
|
|
2066
|
+
toolMetadata: Vn.optional(),
|
|
2067
|
+
dynamic: Y.boolean().optional(),
|
|
2068
|
+
errorText: Y.string(),
|
|
2069
|
+
title: Y.string().optional()
|
|
2069
2070
|
}),
|
|
2070
|
-
|
|
2071
|
-
type:
|
|
2072
|
-
approvalId:
|
|
2073
|
-
toolCallId:
|
|
2074
|
-
isAutomatic:
|
|
2075
|
-
signature:
|
|
2071
|
+
Y.looseObject({
|
|
2072
|
+
type: Y.literal("tool-approval-request"),
|
|
2073
|
+
approvalId: Y.string(),
|
|
2074
|
+
toolCallId: Y.string(),
|
|
2075
|
+
isAutomatic: Y.boolean().optional(),
|
|
2076
|
+
signature: Y.string().optional()
|
|
2076
2077
|
}),
|
|
2077
|
-
|
|
2078
|
-
type:
|
|
2079
|
-
approvalId:
|
|
2080
|
-
approved:
|
|
2081
|
-
reason:
|
|
2082
|
-
providerExecuted:
|
|
2083
|
-
providerMetadata:
|
|
2078
|
+
Y.looseObject({
|
|
2079
|
+
type: Y.literal("tool-approval-response"),
|
|
2080
|
+
approvalId: Y.string(),
|
|
2081
|
+
approved: Y.boolean(),
|
|
2082
|
+
reason: Y.string().optional(),
|
|
2083
|
+
providerExecuted: Y.boolean().optional(),
|
|
2084
|
+
providerMetadata: Z.optional()
|
|
2084
2085
|
}),
|
|
2085
|
-
|
|
2086
|
-
type:
|
|
2087
|
-
toolCallId:
|
|
2088
|
-
output:
|
|
2089
|
-
providerExecuted:
|
|
2090
|
-
providerMetadata:
|
|
2091
|
-
toolMetadata:
|
|
2092
|
-
dynamic:
|
|
2093
|
-
preliminary:
|
|
2086
|
+
Y.looseObject({
|
|
2087
|
+
type: Y.literal("tool-output-available"),
|
|
2088
|
+
toolCallId: Y.string(),
|
|
2089
|
+
output: Y.unknown(),
|
|
2090
|
+
providerExecuted: Y.boolean().optional(),
|
|
2091
|
+
providerMetadata: Z.optional(),
|
|
2092
|
+
toolMetadata: Vn.optional(),
|
|
2093
|
+
dynamic: Y.boolean().optional(),
|
|
2094
|
+
preliminary: Y.boolean().optional()
|
|
2094
2095
|
}),
|
|
2095
|
-
|
|
2096
|
-
type:
|
|
2097
|
-
toolCallId:
|
|
2098
|
-
errorText:
|
|
2099
|
-
providerExecuted:
|
|
2100
|
-
providerMetadata:
|
|
2101
|
-
toolMetadata:
|
|
2102
|
-
dynamic:
|
|
2096
|
+
Y.looseObject({
|
|
2097
|
+
type: Y.literal("tool-output-error"),
|
|
2098
|
+
toolCallId: Y.string(),
|
|
2099
|
+
errorText: Y.string(),
|
|
2100
|
+
providerExecuted: Y.boolean().optional(),
|
|
2101
|
+
providerMetadata: Z.optional(),
|
|
2102
|
+
toolMetadata: Vn.optional(),
|
|
2103
|
+
dynamic: Y.boolean().optional()
|
|
2103
2104
|
}),
|
|
2104
|
-
|
|
2105
|
-
type:
|
|
2106
|
-
toolCallId:
|
|
2105
|
+
Y.looseObject({
|
|
2106
|
+
type: Y.literal("tool-output-denied"),
|
|
2107
|
+
toolCallId: Y.string()
|
|
2107
2108
|
}),
|
|
2108
|
-
|
|
2109
|
-
type:
|
|
2110
|
-
id:
|
|
2111
|
-
providerMetadata:
|
|
2109
|
+
Y.looseObject({
|
|
2110
|
+
type: Y.literal("reasoning-start"),
|
|
2111
|
+
id: Y.string(),
|
|
2112
|
+
providerMetadata: Z.optional()
|
|
2112
2113
|
}),
|
|
2113
|
-
|
|
2114
|
-
type:
|
|
2115
|
-
id:
|
|
2116
|
-
delta:
|
|
2117
|
-
providerMetadata:
|
|
2114
|
+
Y.looseObject({
|
|
2115
|
+
type: Y.literal("reasoning-delta"),
|
|
2116
|
+
id: Y.string(),
|
|
2117
|
+
delta: Y.string(),
|
|
2118
|
+
providerMetadata: Z.optional()
|
|
2118
2119
|
}),
|
|
2119
|
-
|
|
2120
|
-
type:
|
|
2121
|
-
id:
|
|
2122
|
-
providerMetadata:
|
|
2120
|
+
Y.looseObject({
|
|
2121
|
+
type: Y.literal("reasoning-end"),
|
|
2122
|
+
id: Y.string(),
|
|
2123
|
+
providerMetadata: Z.optional()
|
|
2123
2124
|
}),
|
|
2124
|
-
|
|
2125
|
-
type:
|
|
2126
|
-
kind:
|
|
2127
|
-
providerMetadata:
|
|
2125
|
+
Y.looseObject({
|
|
2126
|
+
type: Y.literal("custom"),
|
|
2127
|
+
kind: Y.string().transform((e) => e),
|
|
2128
|
+
providerMetadata: Z.optional()
|
|
2128
2129
|
}),
|
|
2129
|
-
|
|
2130
|
-
type:
|
|
2131
|
-
sourceId:
|
|
2132
|
-
url:
|
|
2133
|
-
title:
|
|
2134
|
-
providerMetadata:
|
|
2130
|
+
Y.looseObject({
|
|
2131
|
+
type: Y.literal("source-url"),
|
|
2132
|
+
sourceId: Y.string(),
|
|
2133
|
+
url: Y.string(),
|
|
2134
|
+
title: Y.string().optional(),
|
|
2135
|
+
providerMetadata: Z.optional()
|
|
2135
2136
|
}),
|
|
2136
|
-
|
|
2137
|
-
type:
|
|
2138
|
-
sourceId:
|
|
2139
|
-
mediaType:
|
|
2140
|
-
title:
|
|
2141
|
-
filename:
|
|
2142
|
-
providerMetadata:
|
|
2137
|
+
Y.looseObject({
|
|
2138
|
+
type: Y.literal("source-document"),
|
|
2139
|
+
sourceId: Y.string(),
|
|
2140
|
+
mediaType: Y.string(),
|
|
2141
|
+
title: Y.string(),
|
|
2142
|
+
filename: Y.string().optional(),
|
|
2143
|
+
providerMetadata: Z.optional()
|
|
2143
2144
|
}),
|
|
2144
|
-
|
|
2145
|
-
type:
|
|
2146
|
-
url:
|
|
2147
|
-
mediaType:
|
|
2148
|
-
providerMetadata:
|
|
2145
|
+
Y.looseObject({
|
|
2146
|
+
type: Y.literal("file"),
|
|
2147
|
+
url: Y.string(),
|
|
2148
|
+
mediaType: Y.string(),
|
|
2149
|
+
providerMetadata: Z.optional()
|
|
2149
2150
|
}),
|
|
2150
|
-
|
|
2151
|
-
type:
|
|
2152
|
-
url:
|
|
2153
|
-
mediaType:
|
|
2154
|
-
providerMetadata:
|
|
2151
|
+
Y.looseObject({
|
|
2152
|
+
type: Y.literal("reasoning-file"),
|
|
2153
|
+
url: Y.string(),
|
|
2154
|
+
mediaType: Y.string(),
|
|
2155
|
+
providerMetadata: Z.optional()
|
|
2155
2156
|
}),
|
|
2156
|
-
|
|
2157
|
-
type:
|
|
2158
|
-
id:
|
|
2159
|
-
data:
|
|
2160
|
-
transient:
|
|
2157
|
+
Y.looseObject({
|
|
2158
|
+
type: Y.custom((e) => typeof e == "string" && e.startsWith("data-"), { message: "Type must start with \"data-\"" }),
|
|
2159
|
+
id: Y.string().optional(),
|
|
2160
|
+
data: Y.unknown(),
|
|
2161
|
+
transient: Y.boolean().optional()
|
|
2161
2162
|
}),
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
type:
|
|
2167
|
-
messageId:
|
|
2168
|
-
messageMetadata:
|
|
2163
|
+
Y.looseObject({ type: Y.literal("start-step") }),
|
|
2164
|
+
Y.looseObject({ type: Y.literal("finish-step") }),
|
|
2165
|
+
Y.looseObject({ type: Y.literal("reset-step") }),
|
|
2166
|
+
Y.looseObject({
|
|
2167
|
+
type: Y.literal("start"),
|
|
2168
|
+
messageId: Y.string().optional(),
|
|
2169
|
+
messageMetadata: Y.unknown().optional()
|
|
2169
2170
|
}),
|
|
2170
|
-
|
|
2171
|
-
type:
|
|
2172
|
-
finishReason:
|
|
2171
|
+
Y.looseObject({
|
|
2172
|
+
type: Y.literal("finish"),
|
|
2173
|
+
finishReason: Y.enum([
|
|
2173
2174
|
"stop",
|
|
2174
2175
|
"length",
|
|
2175
2176
|
"content-filter",
|
|
@@ -2177,36 +2178,36 @@ var zn = J.record(J.string(), Y.optional()), Bn = Ht(() => Zt(J.union([
|
|
|
2177
2178
|
"error",
|
|
2178
2179
|
"other"
|
|
2179
2180
|
]).optional(),
|
|
2180
|
-
messageMetadata:
|
|
2181
|
+
messageMetadata: Y.unknown().optional()
|
|
2181
2182
|
}),
|
|
2182
|
-
|
|
2183
|
-
type:
|
|
2184
|
-
reason:
|
|
2183
|
+
Y.looseObject({
|
|
2184
|
+
type: Y.literal("abort"),
|
|
2185
|
+
reason: Y.string().optional()
|
|
2185
2186
|
}),
|
|
2186
|
-
|
|
2187
|
-
type:
|
|
2188
|
-
messageMetadata:
|
|
2187
|
+
Y.looseObject({
|
|
2188
|
+
type: Y.literal("message-metadata"),
|
|
2189
|
+
messageMetadata: Y.unknown()
|
|
2189
2190
|
})
|
|
2190
2191
|
])));
|
|
2191
|
-
function
|
|
2192
|
+
function Un(e) {
|
|
2192
2193
|
return e.type.startsWith("data-");
|
|
2193
2194
|
}
|
|
2194
|
-
function
|
|
2195
|
+
function Q() {
|
|
2195
2196
|
return /* @__PURE__ */ Object.create(null);
|
|
2196
2197
|
}
|
|
2197
|
-
function
|
|
2198
|
+
function Wn(e) {
|
|
2198
2199
|
return e.type.startsWith("tool-");
|
|
2199
2200
|
}
|
|
2200
|
-
function
|
|
2201
|
+
function Gn(e) {
|
|
2201
2202
|
return e.type === "dynamic-tool";
|
|
2202
2203
|
}
|
|
2203
|
-
function
|
|
2204
|
-
return
|
|
2204
|
+
function Kn(e) {
|
|
2205
|
+
return Wn(e) || Gn(e);
|
|
2205
2206
|
}
|
|
2206
|
-
function
|
|
2207
|
+
function qn(e) {
|
|
2207
2208
|
return e.type.split("-").slice(1).join("-");
|
|
2208
2209
|
}
|
|
2209
|
-
function
|
|
2210
|
+
function Jn({ lastMessage: e, messageId: t }) {
|
|
2210
2211
|
return {
|
|
2211
2212
|
message: e?.role === "assistant" ? e : {
|
|
2212
2213
|
id: t,
|
|
@@ -2214,12 +2215,12 @@ function Gn({ lastMessage: e, messageId: t }) {
|
|
|
2214
2215
|
role: "assistant",
|
|
2215
2216
|
parts: []
|
|
2216
2217
|
},
|
|
2217
|
-
activeTextParts:
|
|
2218
|
-
activeReasoningParts:
|
|
2219
|
-
partialToolCalls:
|
|
2218
|
+
activeTextParts: Q(),
|
|
2219
|
+
activeReasoningParts: Q(),
|
|
2220
|
+
partialToolCalls: Q()
|
|
2220
2221
|
};
|
|
2221
2222
|
}
|
|
2222
|
-
function
|
|
2223
|
+
function Yn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdateMessageJob: r, onError: i, onToolCall: a, onData: o }) {
|
|
2223
2224
|
return e.pipeThrough(new TransformStream({ async transform(e, s) {
|
|
2224
2225
|
await r(async ({ state: r, write: c }) => {
|
|
2225
2226
|
function l() {
|
|
@@ -2228,7 +2229,7 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2228
2229
|
return e.slice(t + 1);
|
|
2229
2230
|
}
|
|
2230
2231
|
function u() {
|
|
2231
|
-
return l().filter(
|
|
2232
|
+
return l().filter(Kn);
|
|
2232
2233
|
}
|
|
2233
2234
|
function d(e) {
|
|
2234
2235
|
let t = u().find((t) => t.toolCallId === e);
|
|
@@ -2236,13 +2237,13 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2236
2237
|
let n = r.message.parts;
|
|
2237
2238
|
for (let r = n.length - 1; r >= 0; r--) {
|
|
2238
2239
|
let i = n[r];
|
|
2239
|
-
if (
|
|
2240
|
+
if (Kn(i) && i.toolCallId === e) {
|
|
2240
2241
|
t = i;
|
|
2241
2242
|
break;
|
|
2242
2243
|
}
|
|
2243
2244
|
}
|
|
2244
2245
|
}
|
|
2245
|
-
if (t == null) throw new
|
|
2246
|
+
if (t == null) throw new J({
|
|
2246
2247
|
chunkType: "tool-invocation",
|
|
2247
2248
|
chunkId: e,
|
|
2248
2249
|
message: `No tool invocation found for tool call ID "${e}".`
|
|
@@ -2250,8 +2251,8 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2250
2251
|
return t;
|
|
2251
2252
|
}
|
|
2252
2253
|
function f(e) {
|
|
2253
|
-
let t = r.message.parts.filter(
|
|
2254
|
-
if (t == null) throw new
|
|
2254
|
+
let t = r.message.parts.filter(Kn).find((t) => t.approval?.id === e);
|
|
2255
|
+
if (t == null) throw new J({
|
|
2255
2256
|
chunkType: "tool-approval-response",
|
|
2256
2257
|
chunkId: e,
|
|
2257
2258
|
message: `No tool invocation found for approval ID "${e}".`
|
|
@@ -2259,7 +2260,7 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2259
2260
|
return t;
|
|
2260
2261
|
}
|
|
2261
2262
|
function p(e, t) {
|
|
2262
|
-
let n = t ?? l().find((t) =>
|
|
2263
|
+
let n = t ?? l().find((t) => Wn(t) && t.toolCallId === e.toolCallId), i = e, a = n;
|
|
2263
2264
|
if (n != null) {
|
|
2264
2265
|
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;
|
|
2265
2266
|
let t = i.providerMetadata;
|
|
@@ -2314,8 +2315,8 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2314
2315
|
}
|
|
2315
2316
|
async function h(e) {
|
|
2316
2317
|
if (e != null) {
|
|
2317
|
-
let n = r.message.metadata == null ? e :
|
|
2318
|
-
t != null && await
|
|
2318
|
+
let n = r.message.metadata == null ? e : mn(r.message.metadata, e);
|
|
2319
|
+
t != null && await en({
|
|
2319
2320
|
value: n,
|
|
2320
2321
|
schema: t,
|
|
2321
2322
|
context: {
|
|
@@ -2338,7 +2339,7 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2338
2339
|
}
|
|
2339
2340
|
case "text-delta": {
|
|
2340
2341
|
let t = r.activeTextParts[e.id];
|
|
2341
|
-
if (t == null) throw new
|
|
2342
|
+
if (t == null) throw new J({
|
|
2342
2343
|
chunkType: "text-delta",
|
|
2343
2344
|
chunkId: e.id,
|
|
2344
2345
|
message: `Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`
|
|
@@ -2348,7 +2349,7 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2348
2349
|
}
|
|
2349
2350
|
case "text-end": {
|
|
2350
2351
|
let t = r.activeTextParts[e.id];
|
|
2351
|
-
if (t == null) throw new
|
|
2352
|
+
if (t == null) throw new J({
|
|
2352
2353
|
chunkType: "text-end",
|
|
2353
2354
|
chunkId: e.id,
|
|
2354
2355
|
message: `Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`
|
|
@@ -2378,7 +2379,7 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2378
2379
|
}
|
|
2379
2380
|
case "reasoning-delta": {
|
|
2380
2381
|
let t = r.activeReasoningParts[e.id];
|
|
2381
|
-
if (t == null) throw new
|
|
2382
|
+
if (t == null) throw new J({
|
|
2382
2383
|
chunkType: "reasoning-delta",
|
|
2383
2384
|
chunkId: e.id,
|
|
2384
2385
|
message: `Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`
|
|
@@ -2388,7 +2389,7 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2388
2389
|
}
|
|
2389
2390
|
case "reasoning-end": {
|
|
2390
2391
|
let t = r.activeReasoningParts[e.id];
|
|
2391
|
-
if (t == null) throw new
|
|
2392
|
+
if (t == null) throw new J({
|
|
2392
2393
|
chunkType: "reasoning-end",
|
|
2393
2394
|
chunkId: e.id,
|
|
2394
2395
|
message: `Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`
|
|
@@ -2425,7 +2426,7 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2425
2426
|
}), c();
|
|
2426
2427
|
break;
|
|
2427
2428
|
case "tool-input-start": {
|
|
2428
|
-
let t = l().filter(
|
|
2429
|
+
let t = l().filter(Wn);
|
|
2429
2430
|
r.partialToolCalls[e.toolCallId] = {
|
|
2430
2431
|
text: "",
|
|
2431
2432
|
toolName: e.toolName,
|
|
@@ -2456,13 +2457,13 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2456
2457
|
}
|
|
2457
2458
|
case "tool-input-delta": {
|
|
2458
2459
|
let t = r.partialToolCalls[e.toolCallId];
|
|
2459
|
-
if (t == null) throw new
|
|
2460
|
+
if (t == null) throw new J({
|
|
2460
2461
|
chunkType: "tool-input-delta",
|
|
2461
2462
|
chunkId: e.toolCallId,
|
|
2462
2463
|
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.`
|
|
2463
2464
|
});
|
|
2464
2465
|
t.text += e.inputTextDelta;
|
|
2465
|
-
let { value: n } = await
|
|
2466
|
+
let { value: n } = await Fn(t.text);
|
|
2466
2467
|
t.dynamic ? m({
|
|
2467
2468
|
toolCallId: e.toolCallId,
|
|
2468
2469
|
toolName: t.toolName,
|
|
@@ -2502,7 +2503,7 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2502
2503
|
}), c(), a && !e.providerExecuted && await a({ toolCall: e });
|
|
2503
2504
|
break;
|
|
2504
2505
|
case "tool-input-error": {
|
|
2505
|
-
let t = l().filter(
|
|
2506
|
+
let t = l().filter(Kn).find((t) => t.toolCallId === e.toolCallId);
|
|
2506
2507
|
(t == null ? e.dynamic : t.type === "dynamic-tool") ? m({
|
|
2507
2508
|
toolCallId: e.toolCallId,
|
|
2508
2509
|
toolName: e.toolName,
|
|
@@ -2565,7 +2566,7 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2565
2566
|
toolMetadata: t.toolMetadata
|
|
2566
2567
|
}, t) : p({
|
|
2567
2568
|
toolCallId: e.toolCallId,
|
|
2568
|
-
toolName:
|
|
2569
|
+
toolName: qn(t),
|
|
2569
2570
|
state: "output-available",
|
|
2570
2571
|
input: t.input,
|
|
2571
2572
|
output: e.output,
|
|
@@ -2591,7 +2592,7 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2591
2592
|
toolMetadata: t.toolMetadata
|
|
2592
2593
|
}, t) : p({
|
|
2593
2594
|
toolCallId: e.toolCallId,
|
|
2594
|
-
toolName:
|
|
2595
|
+
toolName: qn(t),
|
|
2595
2596
|
state: "output-error",
|
|
2596
2597
|
input: t.input,
|
|
2597
2598
|
rawInput: t.rawInput,
|
|
@@ -2607,11 +2608,11 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2607
2608
|
r.message.parts.push({ type: "step-start" });
|
|
2608
2609
|
break;
|
|
2609
2610
|
case "finish-step":
|
|
2610
|
-
r.activeTextParts =
|
|
2611
|
+
r.activeTextParts = Q(), r.activeReasoningParts = Q();
|
|
2611
2612
|
break;
|
|
2612
2613
|
case "reset-step": {
|
|
2613
2614
|
let e = l();
|
|
2614
|
-
r.activeTextParts =
|
|
2615
|
+
r.activeTextParts = Q(), r.activeReasoningParts = Q(), r.partialToolCalls = Q(), e.length > 0 && (r.message.parts.splice(r.message.parts.length - e.length, e.length), c());
|
|
2615
2616
|
break;
|
|
2616
2617
|
}
|
|
2617
2618
|
case "start":
|
|
@@ -2626,10 +2627,10 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2626
2627
|
case "error":
|
|
2627
2628
|
i?.(Error(e.errorText));
|
|
2628
2629
|
break;
|
|
2629
|
-
default: if (
|
|
2630
|
+
default: if (Un(e)) {
|
|
2630
2631
|
if (n?.[e.type] != null) {
|
|
2631
2632
|
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;
|
|
2632
|
-
await
|
|
2633
|
+
await en({
|
|
2633
2634
|
value: e.data,
|
|
2634
2635
|
schema: n[e.type],
|
|
2635
2636
|
context: {
|
|
@@ -2652,7 +2653,7 @@ function Kn({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
|
|
|
2652
2653
|
});
|
|
2653
2654
|
} }));
|
|
2654
2655
|
}
|
|
2655
|
-
async function
|
|
2656
|
+
async function Xn({ stream: e, onError: t, abortSignal: n }) {
|
|
2656
2657
|
let r = e.getReader(), i = () => {
|
|
2657
2658
|
r.cancel().catch(() => {});
|
|
2658
2659
|
};
|
|
@@ -2668,29 +2669,29 @@ async function qn({ stream: e, onError: t, abortSignal: n }) {
|
|
|
2668
2669
|
n?.removeEventListener("abort", i), r.releaseLock();
|
|
2669
2670
|
}
|
|
2670
2671
|
}
|
|
2671
|
-
|
|
2672
|
+
I({
|
|
2672
2673
|
prefix: "aitxt",
|
|
2673
2674
|
size: 24
|
|
2674
|
-
}),
|
|
2675
|
+
}), I({
|
|
2675
2676
|
prefix: "call",
|
|
2676
2677
|
size: 24
|
|
2677
|
-
}),
|
|
2678
|
+
}), I({
|
|
2678
2679
|
prefix: "aitxt",
|
|
2679
2680
|
size: 24
|
|
2680
|
-
}),
|
|
2681
|
+
}), I({
|
|
2681
2682
|
prefix: "call",
|
|
2682
2683
|
size: 24
|
|
2683
|
-
}),
|
|
2684
|
+
}), Y.record(Y.string(), X.optional()), Y.record(Y.string(), Y.string()), I({
|
|
2684
2685
|
prefix: "call",
|
|
2685
2686
|
size: 24
|
|
2686
|
-
}),
|
|
2687
|
+
}), I({
|
|
2687
2688
|
prefix: "call",
|
|
2688
2689
|
size: 24
|
|
2689
|
-
}),
|
|
2690
|
+
}), I({
|
|
2690
2691
|
prefix: "aiobj",
|
|
2691
2692
|
size: 24
|
|
2692
2693
|
});
|
|
2693
|
-
var
|
|
2694
|
+
var Zn = class {
|
|
2694
2695
|
constructor() {
|
|
2695
2696
|
this.queue = [], this.isProcessing = !1;
|
|
2696
2697
|
}
|
|
@@ -2712,14 +2713,14 @@ var Jn = class {
|
|
|
2712
2713
|
});
|
|
2713
2714
|
}
|
|
2714
2715
|
};
|
|
2715
|
-
|
|
2716
|
+
I({
|
|
2716
2717
|
prefix: "aiobj",
|
|
2717
2718
|
size: 24
|
|
2718
|
-
}),
|
|
2719
|
+
}), I({
|
|
2719
2720
|
prefix: "call",
|
|
2720
2721
|
size: 24
|
|
2721
2722
|
});
|
|
2722
|
-
async function
|
|
2723
|
+
async function Qn(e) {
|
|
2723
2724
|
if (e == null) return [];
|
|
2724
2725
|
if (!globalThis.FileList || !(e instanceof globalThis.FileList)) throw Error("FileList is not supported in the current environment");
|
|
2725
2726
|
return Promise.all(Array.from(e).map(async (e) => {
|
|
@@ -2737,14 +2738,14 @@ async function Yn(e) {
|
|
|
2737
2738
|
};
|
|
2738
2739
|
}));
|
|
2739
2740
|
}
|
|
2740
|
-
var
|
|
2741
|
+
var $n = class {
|
|
2741
2742
|
constructor({ api: e = "/api/chat", credentials: t, headers: n, body: r, fetch: i, prepareSendMessagesRequest: a, prepareReconnectToStreamRequest: o }) {
|
|
2742
2743
|
this.api = e, this.credentials = t, this.headers = n, this.body = r, this.fetch = i, this.prepareSendMessagesRequest = a, this.prepareReconnectToStreamRequest = o;
|
|
2743
2744
|
}
|
|
2744
2745
|
async sendMessages({ abortSignal: e, ...t }) {
|
|
2745
|
-
let n = await
|
|
2746
|
-
...
|
|
2747
|
-
...
|
|
2746
|
+
let n = await K(this.body), r = await K(this.headers), i = await K(this.credentials), a = {
|
|
2747
|
+
...R(r),
|
|
2748
|
+
...R(t.headers)
|
|
2748
2749
|
}, o = await this.prepareSendMessagesRequest?.call(this, {
|
|
2749
2750
|
api: this.api,
|
|
2750
2751
|
id: t.chatId,
|
|
@@ -2758,7 +2759,7 @@ var Xn = class {
|
|
|
2758
2759
|
requestMetadata: t.metadata,
|
|
2759
2760
|
trigger: t.trigger,
|
|
2760
2761
|
messageId: t.messageId
|
|
2761
|
-
}), s = o?.api ?? this.api, c = o?.headers === void 0 ? a :
|
|
2762
|
+
}), s = o?.api ?? this.api, c = o?.headers === void 0 ? a : R(o.headers), l = o?.body === void 0 ? {
|
|
2762
2763
|
...n,
|
|
2763
2764
|
...t.body,
|
|
2764
2765
|
id: t.chatId,
|
|
@@ -2780,9 +2781,9 @@ var Xn = class {
|
|
|
2780
2781
|
return this.processResponseStream(d.body);
|
|
2781
2782
|
}
|
|
2782
2783
|
async reconnectToStream(e) {
|
|
2783
|
-
let t = await
|
|
2784
|
-
...
|
|
2785
|
-
...
|
|
2784
|
+
let t = await K(this.body), n = await K(this.headers), r = await K(this.credentials), i = {
|
|
2785
|
+
...R(n),
|
|
2786
|
+
...R(e.headers)
|
|
2786
2787
|
}, a = await this.prepareReconnectToStreamRequest?.call(this, {
|
|
2787
2788
|
api: this.api,
|
|
2788
2789
|
id: e.chatId,
|
|
@@ -2793,7 +2794,7 @@ var Xn = class {
|
|
|
2793
2794
|
headers: i,
|
|
2794
2795
|
credentials: r,
|
|
2795
2796
|
requestMetadata: e.metadata
|
|
2796
|
-
}), o = a?.api ?? `${this.api}/${e.chatId}/stream`, s = a?.headers === void 0 ? i :
|
|
2797
|
+
}), o = a?.api ?? `${this.api}/${e.chatId}/stream`, s = a?.headers === void 0 ? i : R(a.headers), c = a?.credentials ?? r, l = await (this.fetch ?? globalThis.fetch)(o, {
|
|
2797
2798
|
method: "GET",
|
|
2798
2799
|
headers: s,
|
|
2799
2800
|
credentials: c,
|
|
@@ -2804,22 +2805,22 @@ var Xn = class {
|
|
|
2804
2805
|
if (!l.body) throw Error("The response body is empty.");
|
|
2805
2806
|
return this.processResponseStream(l.body);
|
|
2806
2807
|
}
|
|
2807
|
-
},
|
|
2808
|
+
}, er = class extends $n {
|
|
2808
2809
|
constructor(e = {}) {
|
|
2809
2810
|
super(e);
|
|
2810
2811
|
}
|
|
2811
2812
|
processResponseStream(e) {
|
|
2812
|
-
return
|
|
2813
|
+
return nn({
|
|
2813
2814
|
stream: e,
|
|
2814
|
-
schema:
|
|
2815
|
+
schema: Hn
|
|
2815
2816
|
}).pipeThrough(new TransformStream({ async transform(e, t) {
|
|
2816
2817
|
if (!e.success) throw e.error;
|
|
2817
2818
|
t.enqueue(e.value);
|
|
2818
2819
|
} }));
|
|
2819
2820
|
}
|
|
2820
|
-
},
|
|
2821
|
-
constructor({ generateId: e =
|
|
2822
|
-
this.pendingMessagePreparations = /* @__PURE__ */ new Set(), this.activeResponse = void 0, this.activeResumeRequest = void 0, this.jobExecutor = new
|
|
2821
|
+
}, tr = class {
|
|
2822
|
+
constructor({ generateId: e = L, id: t = e(), transport: n = new er(), messageMetadataSchema: r, dataPartSchemas: i, state: a, onError: o, onToolCall: s, onFinish: c, onData: l, sendAutomaticallyWhen: u }) {
|
|
2823
|
+
this.pendingMessagePreparations = /* @__PURE__ */ new Set(), this.activeResponse = void 0, this.activeResumeRequest = void 0, this.jobExecutor = new Zn(), this.sendMessage = async (e, t) => {
|
|
2823
2824
|
if (e == null) {
|
|
2824
2825
|
await this.makeRequest({
|
|
2825
2826
|
trigger: "submit-message",
|
|
@@ -2834,7 +2835,7 @@ var Xn = class {
|
|
|
2834
2835
|
this.pendingMessagePreparations.add(t);
|
|
2835
2836
|
let r;
|
|
2836
2837
|
try {
|
|
2837
|
-
r = Array.isArray(e.files) ? e.files : await
|
|
2838
|
+
r = Array.isArray(e.files) ? e.files : await Qn(e.files);
|
|
2838
2839
|
} finally {
|
|
2839
2840
|
this.pendingMessagePreparations.delete(t);
|
|
2840
2841
|
}
|
|
@@ -2881,7 +2882,7 @@ var Xn = class {
|
|
|
2881
2882
|
}, this.clearError = () => {
|
|
2882
2883
|
this.status === "error" && (this.state.error = void 0, this.setStatus({ status: "ready" }));
|
|
2883
2884
|
}, this.addToolApprovalResponse = async ({ id: e, approved: t, reason: n, options: r }) => this.jobExecutor.run(async () => {
|
|
2884
|
-
let i = this.state.messages, a = i[i.length - 1], o = (r) =>
|
|
2885
|
+
let i = this.state.messages, a = i[i.length - 1], o = (r) => Kn(r) && r.state === "approval-requested" && r.approval.id === e ? {
|
|
2885
2886
|
...r,
|
|
2886
2887
|
state: "approval-responded",
|
|
2887
2888
|
approval: {
|
|
@@ -2902,7 +2903,7 @@ var Xn = class {
|
|
|
2902
2903
|
});
|
|
2903
2904
|
});
|
|
2904
2905
|
}), this.addToolOutput = async ({ state: e = "output-available", toolCallId: t, output: n, errorText: r, options: i }) => this.jobExecutor.run(async () => {
|
|
2905
|
-
let a = this.state.messages, o = a[a.length - 1], s = (i) =>
|
|
2906
|
+
let a = this.state.messages, o = a[a.length - 1], s = (i) => Kn(i) && i.toolCallId === t ? {
|
|
2906
2907
|
...i,
|
|
2907
2908
|
state: e,
|
|
2908
2909
|
output: n,
|
|
@@ -2990,7 +2991,7 @@ var Xn = class {
|
|
|
2990
2991
|
let f = this.lastMessage, p = !1, m = !1, h = !1, g;
|
|
2991
2992
|
try {
|
|
2992
2993
|
let a = {
|
|
2993
|
-
state:
|
|
2994
|
+
state: Jn({
|
|
2994
2995
|
lastMessage: e === "resume-stream" || e === "regenerate-message" ? void 0 : this.state.snapshot(f),
|
|
2995
2996
|
messageId: this.generateId()
|
|
2996
2997
|
}),
|
|
@@ -3009,8 +3010,8 @@ var Xn = class {
|
|
|
3009
3010
|
body: r,
|
|
3010
3011
|
trigger: e,
|
|
3011
3012
|
messageId: i
|
|
3012
|
-
}), await
|
|
3013
|
-
stream:
|
|
3013
|
+
}), await Xn({
|
|
3014
|
+
stream: Yn({
|
|
3014
3015
|
stream: o,
|
|
3015
3016
|
onToolCall: this.onToolCall,
|
|
3016
3017
|
onData: this.onData,
|
|
@@ -3062,45 +3063,39 @@ var Xn = class {
|
|
|
3062
3063
|
});
|
|
3063
3064
|
}
|
|
3064
3065
|
};
|
|
3065
|
-
function
|
|
3066
|
+
function nr({ messages: e }) {
|
|
3066
3067
|
let t = e[e.length - 1];
|
|
3067
3068
|
if (!t || t.role !== "assistant") return !1;
|
|
3068
|
-
let n = t.parts.reduce((e, t, n) => t.type === "step-start" ? n : e, -1), r = t.parts.slice(n + 1).filter(
|
|
3069
|
+
let n = t.parts.reduce((e, t, n) => t.type === "step-start" ? n : e, -1), r = t.parts.slice(n + 1).filter(Kn);
|
|
3069
3070
|
return r.filter((e) => e.state === "approval-responded").length > 0 && r.every((e) => e.state === "output-available" || e.state === "output-error" || e.state === "approval-responded");
|
|
3070
3071
|
}
|
|
3071
|
-
function er({ messages: e }) {
|
|
3072
|
-
let t = e[e.length - 1];
|
|
3073
|
-
if (!t || t.role !== "assistant") return !1;
|
|
3074
|
-
let n = t.parts.reduce((e, t, n) => t.type === "step-start" ? n : e, -1), r = t.parts.slice(n + 1).filter(Q).filter((e) => !e.providerExecuted);
|
|
3075
|
-
return r.length > 0 && r.every((e) => e.state === "output-available" || e.state === "output-error");
|
|
3076
|
-
}
|
|
3077
3072
|
//#endregion
|
|
3078
3073
|
//#region ../../node_modules/.pnpm/swrv@1.2.0_vue@3.5.41_typescript@6.0.3_/node_modules/swrv/esm/lib/hash.js
|
|
3079
|
-
var
|
|
3080
|
-
function
|
|
3074
|
+
var rr = /* @__PURE__ */ new WeakMap(), ir = 0;
|
|
3075
|
+
function ar(e) {
|
|
3081
3076
|
if (!e.length) return "";
|
|
3082
3077
|
for (var t = "arg", n = 0; n < e.length; ++n) {
|
|
3083
3078
|
var r = void 0;
|
|
3084
|
-
e[n] === null || typeof e[n] != "object" && typeof e[n] != "function" ? r = typeof e[n] == "string" ? "\"" + e[n] + "\"" : String(e[n]) :
|
|
3079
|
+
e[n] === null || typeof e[n] != "object" && typeof e[n] != "function" ? r = typeof e[n] == "string" ? "\"" + e[n] + "\"" : String(e[n]) : rr.has(e[n]) ? r = rr.get(e[n]) : (r = ir, rr.set(e[n], ir++)), t += "@" + r;
|
|
3085
3080
|
}
|
|
3086
3081
|
return t;
|
|
3087
3082
|
}
|
|
3088
3083
|
//#endregion
|
|
3089
3084
|
//#region ../../node_modules/.pnpm/swrv@1.2.0_vue@3.5.41_typescript@6.0.3_/node_modules/swrv/esm/cache/index.js
|
|
3090
|
-
function
|
|
3085
|
+
function or(e) {
|
|
3091
3086
|
if (typeof e == "function") try {
|
|
3092
3087
|
e = e();
|
|
3093
3088
|
} catch {
|
|
3094
3089
|
e = "";
|
|
3095
3090
|
}
|
|
3096
|
-
return e = Array.isArray(e) ?
|
|
3091
|
+
return e = Array.isArray(e) ? ar(e) : String(e || ""), e;
|
|
3097
3092
|
}
|
|
3098
|
-
var
|
|
3093
|
+
var sr = function() {
|
|
3099
3094
|
function e(e) {
|
|
3100
3095
|
e === void 0 && (e = 0), this.items = /* @__PURE__ */ new Map(), this.ttl = e;
|
|
3101
3096
|
}
|
|
3102
3097
|
return e.prototype.serializeKey = function(e) {
|
|
3103
|
-
return
|
|
3098
|
+
return or(e);
|
|
3104
3099
|
}, e.prototype.get = function(e) {
|
|
3105
3100
|
var t = this.serializeKey(e);
|
|
3106
3101
|
return this.items.get(t);
|
|
@@ -3122,15 +3117,15 @@ var ar = function() {
|
|
|
3122
3117
|
}();
|
|
3123
3118
|
//#endregion
|
|
3124
3119
|
//#region ../../node_modules/.pnpm/swrv@1.2.0_vue@3.5.41_typescript@6.0.3_/node_modules/swrv/esm/lib/web-preset.js
|
|
3125
|
-
function
|
|
3120
|
+
function cr() {
|
|
3126
3121
|
return navigator.onLine === void 0 || navigator.onLine;
|
|
3127
3122
|
}
|
|
3128
|
-
function
|
|
3123
|
+
function lr() {
|
|
3129
3124
|
return typeof document < "u" && document.visibilityState !== void 0 ? document.visibilityState !== "hidden" : !0;
|
|
3130
3125
|
}
|
|
3131
|
-
var
|
|
3132
|
-
isOnline:
|
|
3133
|
-
isDocumentVisible:
|
|
3126
|
+
var ur = {
|
|
3127
|
+
isOnline: cr,
|
|
3128
|
+
isDocumentVisible: lr,
|
|
3134
3129
|
fetcher: function(e) {
|
|
3135
3130
|
return fetch(e).then(function(e) {
|
|
3136
3131
|
return e.json();
|
|
@@ -3141,7 +3136,7 @@ var cr = {
|
|
|
3141
3136
|
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]);
|
|
3142
3137
|
return e;
|
|
3143
3138
|
}, $.apply(this, arguments);
|
|
3144
|
-
},
|
|
3139
|
+
}, dr = function(e, t, n, r) {
|
|
3145
3140
|
function i(e) {
|
|
3146
3141
|
return e instanceof n ? e : new n(function(t) {
|
|
3147
3142
|
t(e);
|
|
@@ -3167,7 +3162,7 @@ var cr = {
|
|
|
3167
3162
|
}
|
|
3168
3163
|
c((r = r.apply(e, t || [])).next());
|
|
3169
3164
|
});
|
|
3170
|
-
},
|
|
3165
|
+
}, fr = function(e, t) {
|
|
3171
3166
|
var n = {
|
|
3172
3167
|
label: 0,
|
|
3173
3168
|
sent: function() {
|
|
@@ -3240,7 +3235,7 @@ var cr = {
|
|
|
3240
3235
|
done: !0
|
|
3241
3236
|
};
|
|
3242
3237
|
}
|
|
3243
|
-
},
|
|
3238
|
+
}, pr = function(e, t) {
|
|
3244
3239
|
var n = typeof Symbol == "function" && e[Symbol.iterator];
|
|
3245
3240
|
if (!n) return e;
|
|
3246
3241
|
var r = n.call(e), i, a = [], o;
|
|
@@ -3256,11 +3251,11 @@ var cr = {
|
|
|
3256
3251
|
}
|
|
3257
3252
|
}
|
|
3258
3253
|
return a;
|
|
3259
|
-
},
|
|
3254
|
+
}, mr = function(e, t, n) {
|
|
3260
3255
|
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]);
|
|
3261
3256
|
return e.concat(a || Array.prototype.slice.call(t));
|
|
3262
|
-
},
|
|
3263
|
-
cache:
|
|
3257
|
+
}, hr = new sr(), gr = new sr(), _r = new sr(), vr = {
|
|
3258
|
+
cache: hr,
|
|
3264
3259
|
refreshInterval: 0,
|
|
3265
3260
|
ttl: 0,
|
|
3266
3261
|
serverTTL: 1e3,
|
|
@@ -3270,15 +3265,15 @@ var cr = {
|
|
|
3270
3265
|
shouldRetryOnError: !0,
|
|
3271
3266
|
errorRetryInterval: 5e3,
|
|
3272
3267
|
errorRetryCount: 5,
|
|
3273
|
-
fetcher:
|
|
3274
|
-
isOnline:
|
|
3275
|
-
isDocumentVisible:
|
|
3268
|
+
fetcher: ur.fetcher,
|
|
3269
|
+
isOnline: ur.isOnline,
|
|
3270
|
+
isDocumentVisible: ur.isDocumentVisible
|
|
3276
3271
|
};
|
|
3277
|
-
function
|
|
3278
|
-
var r =
|
|
3279
|
-
r ? r.data.push(t) :
|
|
3272
|
+
function yr(e, t, n) {
|
|
3273
|
+
var r = gr.get(e);
|
|
3274
|
+
r ? r.data.push(t) : gr.set(e, [t], n > 0 ? n + 5e3 : n);
|
|
3280
3275
|
}
|
|
3281
|
-
function
|
|
3276
|
+
function br(e, t, n) {
|
|
3282
3277
|
if (n.isDocumentVisible() && !(n.errorRetryCount !== void 0 && t > n.errorRetryCount)) {
|
|
3283
3278
|
var r = Math.min(t || 0, n.errorRetryCount), i = r * n.errorRetryInterval;
|
|
3284
3279
|
setTimeout(function() {
|
|
@@ -3289,17 +3284,17 @@ function vr(e, t, n) {
|
|
|
3289
3284
|
}, i);
|
|
3290
3285
|
}
|
|
3291
3286
|
}
|
|
3292
|
-
function
|
|
3287
|
+
function xr(e) {
|
|
3293
3288
|
var t = e.shouldRetry, n = t === void 0 ? void 0 : t, r = e.error;
|
|
3294
|
-
return typeof n == "function" ? n(r) : typeof n == "boolean" ? n :
|
|
3289
|
+
return typeof n == "function" ? n(r) : typeof n == "boolean" ? n : vr.shouldRetryOnError;
|
|
3295
3290
|
}
|
|
3296
|
-
var
|
|
3297
|
-
return n === void 0 && (n =
|
|
3291
|
+
var Sr = function(e, t, n, r) {
|
|
3292
|
+
return n === void 0 && (n = hr), r === void 0 && (r = vr.ttl), dr(void 0, void 0, void 0, function() {
|
|
3298
3293
|
var i, a, o, s, c, l, u;
|
|
3299
|
-
return
|
|
3294
|
+
return fr(this, function(d) {
|
|
3300
3295
|
switch (d.label) {
|
|
3301
3296
|
case 0:
|
|
3302
|
-
if (!
|
|
3297
|
+
if (!wr(t)) return [3, 5];
|
|
3303
3298
|
d.label = 1;
|
|
3304
3299
|
case 1: return d.trys.push([
|
|
3305
3300
|
1,
|
|
@@ -3321,7 +3316,7 @@ var br = function(e, t, n, r) {
|
|
|
3321
3316
|
} catch (e) {
|
|
3322
3317
|
console.error("swrv(mutate): failed to set cache", e);
|
|
3323
3318
|
}
|
|
3324
|
-
return l =
|
|
3319
|
+
return l = gr.get(e), l && l.data.length && (u = l.data.filter(function(t) {
|
|
3325
3320
|
return t.key === e;
|
|
3326
3321
|
}), u.forEach(function(e, t) {
|
|
3327
3322
|
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];
|
|
@@ -3330,16 +3325,16 @@ var br = function(e, t, n, r) {
|
|
|
3330
3325
|
});
|
|
3331
3326
|
});
|
|
3332
3327
|
};
|
|
3333
|
-
function
|
|
3328
|
+
function Cr() {
|
|
3334
3329
|
for (var e = this, t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n];
|
|
3335
|
-
var r, i, a = $({},
|
|
3336
|
-
if (!
|
|
3330
|
+
var r, i, a = $({}, vr), o = !1, s = !1;
|
|
3331
|
+
if (!ce()) return console.error("useSWRV must be called inside setup() or an active effectScope()."), null;
|
|
3337
3332
|
var c = typeof window > "u" || typeof document > "u";
|
|
3338
3333
|
t.length >= 1 && (r = t[0]), t.length >= 2 && (i = t[1]), t.length > 2 && (a = $($({}, a), t[2]));
|
|
3339
3334
|
var l = c ? a.serverTTL : a.ttl, u = typeof r == "function" ? r : y(r);
|
|
3340
3335
|
i === void 0 && (i = a.fetcher);
|
|
3341
3336
|
var d = null;
|
|
3342
|
-
d ||=
|
|
3337
|
+
d ||= de({
|
|
3343
3338
|
data: void 0,
|
|
3344
3339
|
error: void 0,
|
|
3345
3340
|
isValidating: !0,
|
|
@@ -3347,32 +3342,32 @@ function xr() {
|
|
|
3347
3342
|
key: null
|
|
3348
3343
|
});
|
|
3349
3344
|
var f = function(t, n) {
|
|
3350
|
-
return
|
|
3345
|
+
return dr(e, void 0, void 0, function() {
|
|
3351
3346
|
var e, r, s, c, p, m, h, g = this;
|
|
3352
|
-
return
|
|
3347
|
+
return fr(this, function(_) {
|
|
3353
3348
|
switch (_.label) {
|
|
3354
3349
|
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() {
|
|
3355
|
-
return
|
|
3350
|
+
return dr(g, void 0, void 0, function() {
|
|
3356
3351
|
var e, t, i, s, c, u;
|
|
3357
|
-
return
|
|
3352
|
+
return fr(this, function(m) {
|
|
3358
3353
|
switch (m.label) {
|
|
3359
|
-
case 0: return e =
|
|
3354
|
+
case 0: return e = _r.get(r), e ? [3, 2] : (t = Array.isArray(r) ? r : [r], i = p.apply(void 0, mr([], pr(t), !1)), _r.set(r, i, a.dedupingInterval), [4, Sr(r, i, a.cache, l)]);
|
|
3360
3355
|
case 1: return m.sent(), [3, 4];
|
|
3361
|
-
case 2: return [4,
|
|
3356
|
+
case 2: return [4, Sr(r, e.data, a.cache, l)];
|
|
3362
3357
|
case 3: m.sent(), m.label = 4;
|
|
3363
|
-
case 4: return d.isValidating = !1, d.isLoading = !1,
|
|
3358
|
+
case 4: return d.isValidating = !1, d.isLoading = !1, _r.delete(r), d.error !== void 0 && (s = xr({
|
|
3364
3359
|
shouldRetry: a.shouldRetryOnError,
|
|
3365
3360
|
error: d.error
|
|
3366
|
-
}), c =
|
|
3361
|
+
}), c = xr({
|
|
3367
3362
|
shouldRetry: !n || n.shouldRetryOnError,
|
|
3368
3363
|
error: d.error
|
|
3369
|
-
}), u = !o && s && c, u &&
|
|
3364
|
+
}), u = !o && s && c, u && br(f, n ? n.errorRetryCount : 1, a)), [2];
|
|
3370
3365
|
}
|
|
3371
3366
|
});
|
|
3372
3367
|
});
|
|
3373
3368
|
}, c && a.revalidateDebounce ? (setTimeout(function() {
|
|
3374
|
-
return
|
|
3375
|
-
return
|
|
3369
|
+
return dr(g, void 0, void 0, function() {
|
|
3370
|
+
return fr(this, function(e) {
|
|
3376
3371
|
switch (e.label) {
|
|
3377
3372
|
case 0: return o ? [3, 2] : [4, h()];
|
|
3378
3373
|
case 1: e.sent(), e.label = 2;
|
|
@@ -3388,16 +3383,16 @@ function xr() {
|
|
|
3388
3383
|
});
|
|
3389
3384
|
});
|
|
3390
3385
|
}, p = function() {
|
|
3391
|
-
return
|
|
3392
|
-
return
|
|
3386
|
+
return dr(e, void 0, void 0, function() {
|
|
3387
|
+
return fr(this, function(e) {
|
|
3393
3388
|
return [2, f(null, { shouldRetryOnError: !1 })];
|
|
3394
3389
|
});
|
|
3395
3390
|
});
|
|
3396
3391
|
}, m = null;
|
|
3397
3392
|
if (!c) {
|
|
3398
3393
|
var h = function() {
|
|
3399
|
-
return
|
|
3400
|
-
return
|
|
3394
|
+
return dr(e, void 0, void 0, function() {
|
|
3395
|
+
return fr(this, function(e) {
|
|
3401
3396
|
switch (e.label) {
|
|
3402
3397
|
case 0: return !d.error && a.isOnline() ? [4, f()] : [3, 2];
|
|
3403
3398
|
case 1: return e.sent(), [3, 3];
|
|
@@ -3409,30 +3404,30 @@ function xr() {
|
|
|
3409
3404
|
};
|
|
3410
3405
|
a.refreshInterval && (m = setTimeout(h, a.refreshInterval)), a.revalidateOnFocus && (document.addEventListener("visibilitychange", p, !1), window.addEventListener("focus", p, !1));
|
|
3411
3406
|
}
|
|
3412
|
-
|
|
3407
|
+
ue(function() {
|
|
3413
3408
|
o = !0, m &&= (clearTimeout(m), null), !c && a.revalidateOnFocus && (document.removeEventListener("visibilitychange", p, !1), window.removeEventListener("focus", p, !1));
|
|
3414
|
-
var e =
|
|
3409
|
+
var e = gr.get(u.value);
|
|
3415
3410
|
e && (e.data = e.data.filter(function(e) {
|
|
3416
3411
|
return e !== d;
|
|
3417
3412
|
}));
|
|
3418
3413
|
});
|
|
3419
3414
|
try {
|
|
3420
|
-
|
|
3421
|
-
|
|
3415
|
+
fe(u, function(e) {
|
|
3416
|
+
le(u) || (u.value = e), d.key = e, d.isValidating = !!e, yr(u.value, d, l), !c && !s && u.value && f(), s = !1;
|
|
3422
3417
|
}, { immediate: !0 });
|
|
3423
3418
|
} catch {}
|
|
3424
|
-
return $($({},
|
|
3419
|
+
return $($({}, b(d)), { mutate: function(e, t) {
|
|
3425
3420
|
return f(e, $($({}, t), { forceRevalidate: !0 }));
|
|
3426
3421
|
} });
|
|
3427
3422
|
}
|
|
3428
|
-
function
|
|
3423
|
+
function wr(e) {
|
|
3429
3424
|
return typeof e == "object" && !!e && typeof e.then == "function";
|
|
3430
3425
|
}
|
|
3431
3426
|
//#endregion
|
|
3432
3427
|
//#region ../../node_modules/.pnpm/swrv@1.2.0_vue@3.5.41_typescript@6.0.3_/node_modules/swrv/esm/index.js
|
|
3433
|
-
var
|
|
3434
|
-
|
|
3435
|
-
var
|
|
3428
|
+
var Tr = Cr;
|
|
3429
|
+
Tr.default, Tr.default;
|
|
3430
|
+
var Er = class {
|
|
3436
3431
|
constructor(e) {
|
|
3437
3432
|
this.statusRef = y("ready"), this.errorRef = y(void 0), this.pushMessage = (e) => {
|
|
3438
3433
|
this.messagesRef.value = [...this.messagesRef.value, e];
|
|
@@ -3460,45 +3455,78 @@ var wr = class {
|
|
|
3460
3455
|
set error(e) {
|
|
3461
3456
|
this.errorRef.value = e;
|
|
3462
3457
|
}
|
|
3463
|
-
},
|
|
3458
|
+
}, Dr = class extends tr {
|
|
3464
3459
|
constructor({ messages: e, ...t }) {
|
|
3465
3460
|
super({
|
|
3466
3461
|
...t,
|
|
3467
|
-
state: new
|
|
3462
|
+
state: new Er(e)
|
|
3468
3463
|
});
|
|
3469
3464
|
}
|
|
3470
|
-
},
|
|
3471
|
-
let n = e
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3465
|
+
}, Or = "voice-", kr = (e) => e.replace(/\s+/g, " ").trim().toLowerCase(), Ar = (e) => kr(e.parts.filter((e) => e.type === "text").map((e) => "text" in e ? e.text : "").join(" ")), jr = `tool-${ne}`, Mr = (e) => e.parts.find((e) => e.type === jr)?.input?.message, Nr = (e) => e.map(kr).filter((e) => e.length > 0).sort((e, t) => t.length - e.length), Pr = (e, t) => {
|
|
3466
|
+
let n = e;
|
|
3467
|
+
for (;;) {
|
|
3468
|
+
let e = t.find((e) => n.startsWith(e));
|
|
3469
|
+
if (!e) return n;
|
|
3470
|
+
n = n.slice(e.length).trim();
|
|
3471
|
+
}
|
|
3472
|
+
}, Fr = (e, t) => Pr(kr(e), Nr(t)).length === 0, Ir = 8, Lr = (e, t, n = []) => {
|
|
3473
|
+
let r = Nr(n), i = e.flatMap((e) => {
|
|
3474
|
+
let t = [{
|
|
3475
|
+
role: e.role,
|
|
3476
|
+
text: Ar(e),
|
|
3477
|
+
isNewestAgentLine: !1,
|
|
3478
|
+
taken: !1
|
|
3479
|
+
}], n = e.role === "assistant" ? Mr(e) : void 0;
|
|
3480
|
+
return n && t.push({
|
|
3481
|
+
role: e.role,
|
|
3482
|
+
text: kr(n),
|
|
3483
|
+
isNewestAgentLine: !1,
|
|
3484
|
+
taken: !1
|
|
3485
|
+
}), t;
|
|
3486
|
+
});
|
|
3487
|
+
for (let e = i.length - 1; e >= 0; --e) {
|
|
3488
|
+
let t = i[e];
|
|
3489
|
+
if (t.role === "assistant" && t.text.length > 0) {
|
|
3490
|
+
t.isNewestAgentLine = !0;
|
|
3491
|
+
break;
|
|
3492
|
+
}
|
|
3493
|
+
}
|
|
3476
3494
|
return t.filter((e) => {
|
|
3477
3495
|
if (!e.id.startsWith("voice-")) return !1;
|
|
3478
|
-
let t =
|
|
3479
|
-
|
|
3496
|
+
let t = Ar(e), n = e.role === "assistant", a = n ? Pr(t, r) : t;
|
|
3497
|
+
if (n && a.length === 0) return !1;
|
|
3498
|
+
let o = i.find((r) => !r.taken && r.role === e.role && r.text.length > 0 && (r.text === t || r.text.length >= Ir && t.endsWith(r.text) || n && (r.text === a || r.isNewestAgentLine && a.length >= Ir && r.text.startsWith(a))));
|
|
3499
|
+
return !o || (o.taken = !0, !1);
|
|
3480
3500
|
});
|
|
3501
|
+
}, Rr = (e) => {
|
|
3502
|
+
let t = e.type ?? "";
|
|
3503
|
+
return t === "dynamic-tool" ? e.toolName ?? "" : t.startsWith("tool-") ? t.slice(5) : "";
|
|
3504
|
+
}, zr = ({ messages: e }) => {
|
|
3505
|
+
let t = e[e.length - 1];
|
|
3506
|
+
if (!t || t.role !== "assistant") return !1;
|
|
3507
|
+
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 && te(Rr(e)));
|
|
3508
|
+
return r.length > 0 && r.every((e) => re.has(e.state ?? ""));
|
|
3481
3509
|
};
|
|
3482
|
-
function
|
|
3483
|
-
return
|
|
3484
|
-
let { t, te: n, locale: r } =
|
|
3510
|
+
function Br(e) {
|
|
3511
|
+
return ge(`chatbot-${e}`, () => {
|
|
3512
|
+
let { t, te: n, locale: r } = me({ useScope: "global" }), i = y(""), a = y(), o = y(e), s = y(), c = y(), l = y(), u = y(), d = y(), f = y(), p = y(), m = y(), h = y(), g = y(), _ = y(), ee = y(), te = y(), ne = y(), re = y(), ce = y(), le = y(!1), ue = he(), de = v(() => {
|
|
3485
3513
|
let e = u.value?.theme;
|
|
3486
|
-
return (!e || e === "auto") && (e = ce.value), e ? e === "dark" :
|
|
3487
|
-
}), b = v(() => c.value === "reasoning"),
|
|
3514
|
+
return (!e || e === "auto") && (e = ce.value), e ? e === "dark" : ue.value;
|
|
3515
|
+
}), b = v(() => c.value === "reasoning"), ge = v(() => b.value ? g.value?.filter((e) => ![
|
|
3488
3516
|
"upvote",
|
|
3489
3517
|
"downvote",
|
|
3490
3518
|
"feedback"
|
|
3491
|
-
].includes(e)) : g.value), ye =
|
|
3492
|
-
|
|
3493
|
-
ye.value ||=
|
|
3519
|
+
].includes(e)) : g.value), ye = se(v(() => `${o.value}-chatId`), null);
|
|
3520
|
+
pe(() => {
|
|
3521
|
+
ye.value ||= L();
|
|
3494
3522
|
});
|
|
3495
3523
|
let x = v({
|
|
3496
3524
|
get: () => ye.value,
|
|
3497
3525
|
set: (e) => {
|
|
3498
3526
|
ye.value = e;
|
|
3499
3527
|
}
|
|
3500
|
-
}),
|
|
3501
|
-
function
|
|
3528
|
+
}), S = y(), C = y(!1), w = v(() => S.value?.message?.toLowerCase().includes("conversation-blocked") ?? !1);
|
|
3529
|
+
function be(e) {
|
|
3502
3530
|
try {
|
|
3503
3531
|
let t = JSON.parse(e.message);
|
|
3504
3532
|
return t.status === 404 || t.type?.includes("entity-not-found");
|
|
@@ -3506,25 +3534,25 @@ function Ar(e) {
|
|
|
3506
3534
|
return !1;
|
|
3507
3535
|
}
|
|
3508
3536
|
}
|
|
3509
|
-
function
|
|
3510
|
-
if (
|
|
3511
|
-
let e =
|
|
3512
|
-
x.value =
|
|
3537
|
+
function xe(e) {
|
|
3538
|
+
if (be(e)) {
|
|
3539
|
+
let e = E.value.messages.filter((e) => e.role === "user"), t = e[e.length - 1], n = t ? oe(t) : void 0;
|
|
3540
|
+
x.value = L(), E.value.clearError(), S.value = void 0, n && E.value.sendMessage({ text: n });
|
|
3513
3541
|
return;
|
|
3514
3542
|
}
|
|
3515
|
-
|
|
3543
|
+
ae.error(e), S.value = e, w.value && (C.value = !0);
|
|
3516
3544
|
}
|
|
3517
|
-
let
|
|
3545
|
+
let T = v(() => ie({
|
|
3518
3546
|
baseUrl: i.value,
|
|
3519
3547
|
basePath: a.value,
|
|
3520
3548
|
headers: () => p.value
|
|
3521
|
-
})),
|
|
3522
|
-
...
|
|
3523
|
-
...
|
|
3524
|
-
}),
|
|
3549
|
+
})), Se = y(null), Ce = () => ({
|
|
3550
|
+
..._e(),
|
|
3551
|
+
...Se.value ?? {}
|
|
3552
|
+
}), E = v(() => new Dr({
|
|
3525
3553
|
id: x.value,
|
|
3526
|
-
transport: new
|
|
3527
|
-
api:
|
|
3554
|
+
transport: new er({
|
|
3555
|
+
api: T.value.getChatEndpoint(o.value, b.value ? "reasoning" : "chat"),
|
|
3528
3556
|
prepareSendMessagesRequest: ({ messages: e, id: t }) => ({ body: {
|
|
3529
3557
|
id: t,
|
|
3530
3558
|
messages: [e[e.length - 1]],
|
|
@@ -3539,32 +3567,32 @@ function Ar(e) {
|
|
|
3539
3567
|
reasoning: d.value?.reasoning,
|
|
3540
3568
|
webSearch: f.value?.webSearch,
|
|
3541
3569
|
smoothStream: u.value?.smoothStream,
|
|
3542
|
-
deviceContext:
|
|
3543
|
-
externalContext:
|
|
3570
|
+
deviceContext: Ce(),
|
|
3571
|
+
externalContext: re.value,
|
|
3544
3572
|
disabledTools: f.value?.disabled,
|
|
3545
|
-
fallbackModels:
|
|
3546
|
-
gatewayOptions:
|
|
3573
|
+
fallbackModels: te.value,
|
|
3574
|
+
gatewayOptions: ne.value
|
|
3547
3575
|
} }),
|
|
3548
3576
|
credentials: "include",
|
|
3549
3577
|
headers: () => p.value ?? {}
|
|
3550
3578
|
}),
|
|
3551
|
-
sendAutomaticallyWhen: (e) =>
|
|
3552
|
-
onError:
|
|
3579
|
+
sendAutomaticallyWhen: (e) => zr(e) || nr(e),
|
|
3580
|
+
onError: xe,
|
|
3553
3581
|
onFinish: () => {
|
|
3554
3582
|
let e = x.value;
|
|
3555
|
-
!b.value && !
|
|
3583
|
+
!b.value && !D.value.some((t) => t.id === e) && Le(o.value);
|
|
3556
3584
|
}
|
|
3557
|
-
})),
|
|
3585
|
+
})), we = v(() => {
|
|
3558
3586
|
let e = u.value?.initialMessage;
|
|
3559
3587
|
return e?.[r.value] ? e[r.value] : n("message.defaultAgentWelcome") ? t("message.defaultAgentWelcome") : "";
|
|
3560
|
-
}),
|
|
3561
|
-
id:
|
|
3588
|
+
}), Te = L(), Ee = v(() => ({
|
|
3589
|
+
id: Te,
|
|
3562
3590
|
role: "assistant",
|
|
3563
3591
|
parts: [{
|
|
3564
3592
|
type: "text",
|
|
3565
|
-
text:
|
|
3593
|
+
text: we.value
|
|
3566
3594
|
}]
|
|
3567
|
-
})),
|
|
3595
|
+
})), De = v(() => {
|
|
3568
3596
|
let e = (e) => e.map((e) => e.role !== "user" || !e.parts.some((e) => e.type === "file") ? e : {
|
|
3569
3597
|
...e,
|
|
3570
3598
|
parts: e.parts.map((e) => {
|
|
@@ -3574,211 +3602,211 @@ function Ar(e) {
|
|
|
3574
3602
|
let e = t.url.slice(13);
|
|
3575
3603
|
return {
|
|
3576
3604
|
...t,
|
|
3577
|
-
url:
|
|
3605
|
+
url: T.value.getMediaUrl(o.value, x.value, e)
|
|
3578
3606
|
};
|
|
3579
3607
|
}
|
|
3580
3608
|
return t.url.startsWith("blob:") ? t : {
|
|
3581
3609
|
...t,
|
|
3582
|
-
url:
|
|
3610
|
+
url: T.value.appendAuthToken(t.url)
|
|
3583
3611
|
};
|
|
3584
3612
|
})
|
|
3585
3613
|
});
|
|
3586
|
-
return b.value ? e(
|
|
3587
|
-
}),
|
|
3614
|
+
return b.value ? e(E.value.messages) : !le.value && E.value.messages?.[0]?.role !== "assistant" ? [Ee.value, ...e(E.value.messages)] : e(E.value.messages);
|
|
3615
|
+
}), Oe = v(() => {
|
|
3588
3616
|
let e = u.value?.messagePlaceholder;
|
|
3589
3617
|
return e?.[r.value] ? e[r.value] : n("placeholder.askAnything") ? t("placeholder.askAnything") : "";
|
|
3590
|
-
}),
|
|
3591
|
-
async function
|
|
3618
|
+
}), D = y([]), ke = y(!1), O = y([]), Ae = y(!1), je = y("chat"), k = y([]), A = y(), j = y(!1), M = y(!1), Me = y(), Ne = y(!1), N = y(!1), Pe = y(), Fe = y(""), P = y([]), F = y(""), Ie = y(0);
|
|
3619
|
+
async function Le(e) {
|
|
3592
3620
|
if (b.value) {
|
|
3593
|
-
|
|
3621
|
+
D.value = [];
|
|
3594
3622
|
return;
|
|
3595
3623
|
}
|
|
3596
|
-
|
|
3624
|
+
ke.value = !0;
|
|
3597
3625
|
try {
|
|
3598
|
-
|
|
3626
|
+
D.value = await T.value.getConversations(e, l.value);
|
|
3599
3627
|
} catch {
|
|
3600
|
-
|
|
3628
|
+
D.value = [];
|
|
3601
3629
|
} finally {
|
|
3602
|
-
|
|
3630
|
+
ke.value = !1;
|
|
3603
3631
|
}
|
|
3604
3632
|
}
|
|
3605
|
-
async function
|
|
3633
|
+
async function Re() {
|
|
3606
3634
|
let e = x.value;
|
|
3607
3635
|
if (!e) {
|
|
3608
|
-
|
|
3636
|
+
O.value = [];
|
|
3609
3637
|
return;
|
|
3610
3638
|
}
|
|
3611
|
-
|
|
3639
|
+
Ae.value = !0;
|
|
3612
3640
|
try {
|
|
3613
|
-
|
|
3641
|
+
O.value = await T.value.getChatFiles(e);
|
|
3614
3642
|
} catch {
|
|
3615
|
-
|
|
3643
|
+
O.value = [];
|
|
3616
3644
|
} finally {
|
|
3617
|
-
|
|
3645
|
+
Ae.value = !1;
|
|
3618
3646
|
}
|
|
3619
3647
|
}
|
|
3620
|
-
function
|
|
3621
|
-
return
|
|
3648
|
+
function ze(e, t = !1) {
|
|
3649
|
+
return T.value.getChatFileDownloadUrl(e, t);
|
|
3622
3650
|
}
|
|
3623
3651
|
function Be(e) {
|
|
3624
|
-
return
|
|
3652
|
+
return T.value.getChatFilePreviewUrl(e);
|
|
3625
3653
|
}
|
|
3626
|
-
async function
|
|
3627
|
-
await
|
|
3654
|
+
async function I(e) {
|
|
3655
|
+
await T.value.deleteChatFile(e), O.value = O.value.filter((t) => t.documentId !== e);
|
|
3628
3656
|
}
|
|
3629
|
-
async function
|
|
3657
|
+
async function R(e, t) {
|
|
3630
3658
|
if (!b.value) try {
|
|
3631
|
-
let n = await
|
|
3632
|
-
if (t !== x.value ||
|
|
3633
|
-
n && (
|
|
3659
|
+
let n = await T.value.getChat(e, t);
|
|
3660
|
+
if (t !== x.value || E.value.status !== "ready" || E.value.messages.length > 0) return;
|
|
3661
|
+
n && (E.value.messages = n.messages, C.value = n.blocked ?? !1);
|
|
3634
3662
|
} catch {}
|
|
3635
3663
|
}
|
|
3636
|
-
let
|
|
3637
|
-
let e =
|
|
3664
|
+
let Ve = () => {
|
|
3665
|
+
let e = E.value.status;
|
|
3638
3666
|
return e === "submitted" || e === "streaming";
|
|
3639
|
-
},
|
|
3640
|
-
async function
|
|
3641
|
-
if (b.value ||
|
|
3642
|
-
let e = x.value, t =
|
|
3667
|
+
}, He = 0, Ue = 0, We = y([]);
|
|
3668
|
+
async function Ge() {
|
|
3669
|
+
if (b.value || Ve()) return "indeterminate";
|
|
3670
|
+
let e = x.value, t = He += 1;
|
|
3643
3671
|
try {
|
|
3644
|
-
let n = await
|
|
3645
|
-
if (!n || e !== x.value ||
|
|
3646
|
-
|
|
3647
|
-
let r = n.messages, i =
|
|
3648
|
-
return
|
|
3672
|
+
let n = await T.value.getChat(o.value, e);
|
|
3673
|
+
if (!n || e !== x.value || Ve() || t <= Ue) return "indeterminate";
|
|
3674
|
+
Ue = t;
|
|
3675
|
+
let r = n.messages, i = Lr(r, E.value.messages, We.value);
|
|
3676
|
+
return E.value.messages = [...r, ...i], C.value = n.blocked ?? !1, i.some((e) => e.role === "user") ? "pending" : "caught-up";
|
|
3649
3677
|
} catch {}
|
|
3650
|
-
return
|
|
3678
|
+
return "indeterminate";
|
|
3651
3679
|
}
|
|
3652
|
-
function
|
|
3653
|
-
|
|
3680
|
+
function Ke(e) {
|
|
3681
|
+
E.value.messages = [...E.value.messages, e];
|
|
3654
3682
|
}
|
|
3655
3683
|
async function qe(e) {
|
|
3656
3684
|
try {
|
|
3657
|
-
|
|
3685
|
+
k.value = await T.value.getMessageFeedbacks(e);
|
|
3658
3686
|
} catch {
|
|
3659
|
-
|
|
3687
|
+
k.value = [];
|
|
3660
3688
|
}
|
|
3661
3689
|
}
|
|
3662
|
-
function
|
|
3663
|
-
let t =
|
|
3664
|
-
t >= 0 ?
|
|
3690
|
+
function z(e) {
|
|
3691
|
+
let t = k.value.findIndex((t) => t.messageId === e.messageId);
|
|
3692
|
+
t >= 0 ? k.value[t] = e : k.value.push(e);
|
|
3665
3693
|
}
|
|
3666
|
-
function
|
|
3667
|
-
let t =
|
|
3694
|
+
function Je(e) {
|
|
3695
|
+
let t = De.value, n = t.findIndex((t) => t.id === e.id), r = oe(e) ?? "", i = t.slice(0, n).reverse().find((e) => e.role === "user");
|
|
3668
3696
|
return {
|
|
3669
|
-
userQuestion:
|
|
3697
|
+
userQuestion: oe(i ?? e) ?? "",
|
|
3670
3698
|
assistantMessage: r
|
|
3671
3699
|
};
|
|
3672
3700
|
}
|
|
3673
|
-
async function
|
|
3701
|
+
async function Ye(e, t) {
|
|
3674
3702
|
await Promise.all([
|
|
3675
|
-
|
|
3676
|
-
|
|
3703
|
+
R(e, t),
|
|
3704
|
+
Le(e),
|
|
3677
3705
|
qe(t)
|
|
3678
|
-
]),
|
|
3679
|
-
e && (
|
|
3706
|
+
]), Se.value || ve((e, t) => T.value.reverseGeocode(e, t, r.value)).then((e) => {
|
|
3707
|
+
e && (Se.value = e);
|
|
3680
3708
|
});
|
|
3681
3709
|
}
|
|
3682
3710
|
async function Xe() {
|
|
3683
|
-
let e =
|
|
3711
|
+
let e = Fe.value.trim(), t = P.value.filter((e) => e.state === "done" && e.mediaSource !== void 0).map((e) => ({
|
|
3684
3712
|
type: "file",
|
|
3685
3713
|
mediaType: e.mediaSource.mimeType,
|
|
3686
3714
|
url: e.localUrl,
|
|
3687
3715
|
filename: e.mediaSource.name,
|
|
3688
3716
|
providerMetadata: { "8bot": { media: e.mediaSource } }
|
|
3689
3717
|
}));
|
|
3690
|
-
b.value &&
|
|
3691
|
-
let n =
|
|
3718
|
+
b.value && De.value.length > 0 && await $e(), F.value = e, Ie.value = E.value.messages.length;
|
|
3719
|
+
let n = E.value.sendMessage;
|
|
3692
3720
|
n({
|
|
3693
3721
|
text: e,
|
|
3694
3722
|
files: t.length > 0 ? t : void 0
|
|
3695
|
-
}),
|
|
3723
|
+
}), Fe.value = "", Qe();
|
|
3696
3724
|
}
|
|
3697
|
-
function
|
|
3725
|
+
function B(e) {
|
|
3698
3726
|
let t = e.trim();
|
|
3699
3727
|
if (!t) return;
|
|
3700
|
-
if (
|
|
3701
|
-
|
|
3728
|
+
if (E.value.status !== "ready") {
|
|
3729
|
+
ae.warn("[useChatbotStore] sendMessage called before chat is ready. Listen for the \"ready\" event on the widget element.");
|
|
3702
3730
|
return;
|
|
3703
3731
|
}
|
|
3704
|
-
let n =
|
|
3732
|
+
let n = E.value.sendMessage;
|
|
3705
3733
|
n({ text: t });
|
|
3706
3734
|
}
|
|
3707
|
-
async function
|
|
3708
|
-
let e =
|
|
3709
|
-
await
|
|
3735
|
+
async function Ze() {
|
|
3736
|
+
let e = F.value.length > 0;
|
|
3737
|
+
await E.value.stop(), e && (Fe.value = F.value, E.value.messages = E.value.messages.slice(0, Ie.value), F.value = "");
|
|
3710
3738
|
}
|
|
3711
|
-
|
|
3712
|
-
e === "ready" &&
|
|
3739
|
+
fe(() => E.value.status, (e) => {
|
|
3740
|
+
e === "ready" && F.value.length > 0 && (F.value = "");
|
|
3713
3741
|
});
|
|
3714
|
-
function
|
|
3715
|
-
for (let t of
|
|
3716
|
-
|
|
3742
|
+
function Qe(e = !1) {
|
|
3743
|
+
for (let t of P.value) (e || t.state !== "done") && URL.revokeObjectURL(t.localUrl);
|
|
3744
|
+
P.value = [], ct.value = null;
|
|
3717
3745
|
}
|
|
3718
|
-
async function
|
|
3719
|
-
return
|
|
3746
|
+
async function $e() {
|
|
3747
|
+
return F.value = "", await Ze(), x.value = L(), E.value.clearError(), S.value = void 0, C.value = !1, Qe(!0), gt("chat"), x.value;
|
|
3720
3748
|
}
|
|
3721
|
-
async function
|
|
3722
|
-
|
|
3749
|
+
async function et(e) {
|
|
3750
|
+
E.value.status !== "ready" && (F.value = "", await Ze()), await E.value.regenerate(e);
|
|
3723
3751
|
}
|
|
3724
|
-
function
|
|
3752
|
+
function tt(e) {
|
|
3725
3753
|
if (e.tool === "requestGeolocation") {
|
|
3726
3754
|
let t = e.output;
|
|
3727
|
-
"latitude" in t && (
|
|
3755
|
+
"latitude" in t && (Se.value = {
|
|
3728
3756
|
geolocationLatitude: t.latitude,
|
|
3729
3757
|
geolocationLongitude: t.longitude,
|
|
3730
3758
|
geolocationAccuracy: t.accuracy,
|
|
3731
3759
|
geolocationCity: t.city
|
|
3732
3760
|
});
|
|
3733
3761
|
}
|
|
3734
|
-
|
|
3762
|
+
E.value.addToolOutput(e);
|
|
3735
3763
|
}
|
|
3736
|
-
function
|
|
3737
|
-
|
|
3764
|
+
function nt(e) {
|
|
3765
|
+
E.value.addToolApprovalResponse(e);
|
|
3738
3766
|
}
|
|
3739
|
-
let
|
|
3740
|
-
|
|
3767
|
+
let rt = v(() => E.value.messages.reduce((e, t) => e + t.parts.filter((e) => e.type === "file").length, 0)), it = v(() => _.value?.maxFilesPerMessage ?? 5), at = v(() => _.value?.maxFilesPerChat ?? 20), ot = v(() => Math.max(0, Math.min(it.value - P.value.length, at.value - rt.value - P.value.length))), st = v(() => ot.value <= 0), ct = y(null), lt = () => {
|
|
3768
|
+
ct.value = null;
|
|
3741
3769
|
};
|
|
3742
|
-
|
|
3743
|
-
e || (
|
|
3770
|
+
fe(st, (e) => {
|
|
3771
|
+
e || (ct.value = null);
|
|
3744
3772
|
});
|
|
3745
|
-
async function
|
|
3746
|
-
if (
|
|
3747
|
-
|
|
3773
|
+
async function ut(e) {
|
|
3774
|
+
if (st.value) {
|
|
3775
|
+
ct.value = at.value - rt.value - P.value.length <= it.value - P.value.length ? {
|
|
3748
3776
|
reason: "per-chat",
|
|
3749
|
-
max:
|
|
3777
|
+
max: at.value
|
|
3750
3778
|
} : {
|
|
3751
3779
|
reason: "per-message",
|
|
3752
|
-
max:
|
|
3780
|
+
max: it.value
|
|
3753
3781
|
};
|
|
3754
3782
|
return;
|
|
3755
3783
|
}
|
|
3756
|
-
let t =
|
|
3784
|
+
let t = L(), n = {
|
|
3757
3785
|
id: t,
|
|
3758
3786
|
file: e,
|
|
3759
3787
|
localUrl: URL.createObjectURL(e),
|
|
3760
3788
|
state: "uploading"
|
|
3761
3789
|
};
|
|
3762
|
-
|
|
3790
|
+
P.value = [...P.value, n];
|
|
3763
3791
|
try {
|
|
3764
|
-
let n = await
|
|
3765
|
-
|
|
3792
|
+
let n = await T.value.uploadMedia(o.value, x.value, e);
|
|
3793
|
+
P.value = P.value.map((e) => e.id === t ? {
|
|
3766
3794
|
...e,
|
|
3767
3795
|
state: "done",
|
|
3768
3796
|
mediaSource: n
|
|
3769
3797
|
} : e);
|
|
3770
3798
|
} catch (e) {
|
|
3771
3799
|
let n = e instanceof Error ? e.message : "Upload failed";
|
|
3772
|
-
|
|
3800
|
+
P.value = P.value.map((e) => e.id === t ? {
|
|
3773
3801
|
...e,
|
|
3774
3802
|
state: "error",
|
|
3775
3803
|
error: n
|
|
3776
3804
|
} : e);
|
|
3777
3805
|
}
|
|
3778
3806
|
}
|
|
3779
|
-
async function
|
|
3780
|
-
let { userQuestion: n, assistantMessage: r } =
|
|
3781
|
-
|
|
3807
|
+
async function V(e, t) {
|
|
3808
|
+
let { userQuestion: n, assistantMessage: r } = Je(e);
|
|
3809
|
+
z(await T.value.submitMessageFeedback({
|
|
3782
3810
|
messageId: e.id,
|
|
3783
3811
|
chatId: x.value,
|
|
3784
3812
|
agentId: o.value,
|
|
@@ -3788,77 +3816,77 @@ function Ar(e) {
|
|
|
3788
3816
|
}));
|
|
3789
3817
|
}
|
|
3790
3818
|
async function dt(e) {
|
|
3791
|
-
await
|
|
3819
|
+
await V(e, "upvote");
|
|
3792
3820
|
}
|
|
3793
3821
|
async function ft(e) {
|
|
3794
|
-
await
|
|
3822
|
+
await V(e, "downvote");
|
|
3795
3823
|
}
|
|
3796
|
-
function
|
|
3797
|
-
|
|
3824
|
+
function pt(e) {
|
|
3825
|
+
M.value = !1, Me.value = void 0, A.value = e;
|
|
3798
3826
|
}
|
|
3799
|
-
async function
|
|
3800
|
-
if (
|
|
3801
|
-
|
|
3802
|
-
let { userQuestion: t, assistantMessage: n } =
|
|
3803
|
-
|
|
3804
|
-
messageId:
|
|
3827
|
+
async function mt(e) {
|
|
3828
|
+
if (A.value) try {
|
|
3829
|
+
j.value = !0, M.value = !1, Me.value = void 0;
|
|
3830
|
+
let { userQuestion: t, assistantMessage: n } = Je(A.value);
|
|
3831
|
+
z(await T.value.submitMessageFeedback({
|
|
3832
|
+
messageId: A.value.id,
|
|
3805
3833
|
chatId: x.value,
|
|
3806
3834
|
agentId: o.value,
|
|
3807
3835
|
userQuestion: t,
|
|
3808
3836
|
assistantMessage: n,
|
|
3809
3837
|
comment: e
|
|
3810
|
-
})),
|
|
3838
|
+
})), M.value = !0, await qe(x.value);
|
|
3811
3839
|
} catch {
|
|
3812
|
-
|
|
3840
|
+
Me.value = n("message.feedbackSubmitError") ? t("message.feedbackSubmitError") : "Failed to submit feedback";
|
|
3813
3841
|
} finally {
|
|
3814
|
-
|
|
3842
|
+
j.value = !1;
|
|
3815
3843
|
}
|
|
3816
3844
|
}
|
|
3817
|
-
async function
|
|
3845
|
+
async function H(e) {
|
|
3818
3846
|
try {
|
|
3819
|
-
|
|
3847
|
+
N.value = !0, Ne.value = !1, Pe.value = void 0, await T.value.submitLead({
|
|
3820
3848
|
agentId: o.value,
|
|
3821
3849
|
chatId: x.value,
|
|
3822
3850
|
...e
|
|
3823
|
-
}),
|
|
3851
|
+
}), Ne.value = !0;
|
|
3824
3852
|
} catch {
|
|
3825
|
-
|
|
3853
|
+
Pe.value = n("message.leadSubmitError") ? t("message.leadSubmitError") : "Failed to submit lead";
|
|
3826
3854
|
} finally {
|
|
3827
|
-
|
|
3855
|
+
N.value = !1;
|
|
3828
3856
|
}
|
|
3829
3857
|
}
|
|
3830
|
-
async function
|
|
3831
|
-
let n = await
|
|
3832
|
-
|
|
3858
|
+
async function U(e, t) {
|
|
3859
|
+
let n = await T.value.updateChatTitle(o.value, e, t);
|
|
3860
|
+
D.value = D.value.map((t) => t.id === e ? {
|
|
3833
3861
|
...t,
|
|
3834
3862
|
title: n.title
|
|
3835
3863
|
} : t);
|
|
3836
3864
|
}
|
|
3837
3865
|
async function ht(e) {
|
|
3838
|
-
await
|
|
3866
|
+
await T.value.deleteChat(o.value, e), D.value = D.value.filter((t) => t.id !== e), x.value === e && await $e();
|
|
3839
3867
|
}
|
|
3840
3868
|
function gt(e) {
|
|
3841
|
-
|
|
3869
|
+
je.value = e;
|
|
3842
3870
|
}
|
|
3843
3871
|
let _t;
|
|
3844
3872
|
function vt(e) {
|
|
3845
|
-
let t = () =>
|
|
3873
|
+
let t = () => T.value.getChat(o.value, e).then((e) => e !== null);
|
|
3846
3874
|
return t().catch(() => t().catch(() => !1));
|
|
3847
3875
|
}
|
|
3848
|
-
return
|
|
3876
|
+
return fe(l, async (e) => {
|
|
3849
3877
|
if (!e || e === _t) return;
|
|
3850
3878
|
let t = _t;
|
|
3851
3879
|
if (_t = e, t === void 0) return;
|
|
3852
3880
|
let n = x.value, r = !b.value && await vt(n);
|
|
3853
3881
|
if (l.value === e && x.value === n) {
|
|
3854
3882
|
if (r) {
|
|
3855
|
-
|
|
3883
|
+
Le(o.value);
|
|
3856
3884
|
return;
|
|
3857
3885
|
}
|
|
3858
|
-
|
|
3886
|
+
D.value = [], k.value = [], O.value = [], await $e(), Fe.value = "";
|
|
3859
3887
|
}
|
|
3860
3888
|
}), {
|
|
3861
|
-
apiClient:
|
|
3889
|
+
apiClient: T,
|
|
3862
3890
|
baseUrl: i,
|
|
3863
3891
|
basePath: a,
|
|
3864
3892
|
agentId: o,
|
|
@@ -3872,69 +3900,70 @@ function Ar(e) {
|
|
|
3872
3900
|
revisedAnswers: m,
|
|
3873
3901
|
model: h,
|
|
3874
3902
|
actionsInput: g,
|
|
3875
|
-
actions:
|
|
3903
|
+
actions: ge,
|
|
3876
3904
|
agentFileUpload: _,
|
|
3877
3905
|
agentVoice: ee,
|
|
3878
|
-
fallbackModels:
|
|
3879
|
-
gatewayOptions:
|
|
3880
|
-
externalContext:
|
|
3906
|
+
fallbackModels: te,
|
|
3907
|
+
gatewayOptions: ne,
|
|
3908
|
+
externalContext: re,
|
|
3881
3909
|
systemTheme: ce,
|
|
3882
3910
|
hideWelcomeMessage: le,
|
|
3883
|
-
isDark:
|
|
3884
|
-
chat:
|
|
3885
|
-
messages:
|
|
3886
|
-
conversations:
|
|
3887
|
-
isLoadingConversations:
|
|
3888
|
-
chatFiles:
|
|
3889
|
-
isLoadingChatFiles:
|
|
3890
|
-
input:
|
|
3891
|
-
pendingAttachments:
|
|
3892
|
-
isAttachmentLimitReached:
|
|
3893
|
-
fileLimitError:
|
|
3911
|
+
isDark: de,
|
|
3912
|
+
chat: E,
|
|
3913
|
+
messages: De,
|
|
3914
|
+
conversations: D,
|
|
3915
|
+
isLoadingConversations: ke,
|
|
3916
|
+
chatFiles: O,
|
|
3917
|
+
isLoadingChatFiles: Ae,
|
|
3918
|
+
input: Fe,
|
|
3919
|
+
pendingAttachments: P,
|
|
3920
|
+
isAttachmentLimitReached: st,
|
|
3921
|
+
fileLimitError: ct,
|
|
3894
3922
|
localChatId: x,
|
|
3895
|
-
isConversationBlocked:
|
|
3896
|
-
inputMessagePlaceholder:
|
|
3897
|
-
chatError:
|
|
3898
|
-
activeView:
|
|
3899
|
-
messageFeedbacks:
|
|
3900
|
-
feedbackDialogMessage:
|
|
3901
|
-
isFeedbackSubmitting:
|
|
3902
|
-
isFeedbackSubmitted:
|
|
3903
|
-
feedbackSubmitError:
|
|
3904
|
-
isLeadSubmitted:
|
|
3905
|
-
isLoadingSubmitLead:
|
|
3906
|
-
submitLeadError:
|
|
3907
|
-
buildDeviceContext:
|
|
3908
|
-
initialize:
|
|
3909
|
-
loadConversations:
|
|
3910
|
-
loadChatFiles:
|
|
3911
|
-
refreshMessages:
|
|
3912
|
-
appendMessage:
|
|
3913
|
-
|
|
3923
|
+
isConversationBlocked: C,
|
|
3924
|
+
inputMessagePlaceholder: Oe,
|
|
3925
|
+
chatError: S,
|
|
3926
|
+
activeView: je,
|
|
3927
|
+
messageFeedbacks: k,
|
|
3928
|
+
feedbackDialogMessage: A,
|
|
3929
|
+
isFeedbackSubmitting: j,
|
|
3930
|
+
isFeedbackSubmitted: M,
|
|
3931
|
+
feedbackSubmitError: Me,
|
|
3932
|
+
isLeadSubmitted: Ne,
|
|
3933
|
+
isLoadingSubmitLead: N,
|
|
3934
|
+
submitLeadError: Pe,
|
|
3935
|
+
buildDeviceContext: Ce,
|
|
3936
|
+
initialize: Ye,
|
|
3937
|
+
loadConversations: Le,
|
|
3938
|
+
loadChatFiles: Re,
|
|
3939
|
+
refreshMessages: Ge,
|
|
3940
|
+
appendMessage: Ke,
|
|
3941
|
+
voiceProviderSentences: We,
|
|
3942
|
+
getChatFileUrl: ze,
|
|
3914
3943
|
getChatFilePreviewUrl: Be,
|
|
3915
|
-
deleteChatFile:
|
|
3944
|
+
deleteChatFile: I,
|
|
3916
3945
|
handleSubmit: Xe,
|
|
3917
|
-
sendMessage:
|
|
3918
|
-
stopGeneration:
|
|
3919
|
-
startNewChat:
|
|
3920
|
-
regenerate:
|
|
3921
|
-
addToolOutput:
|
|
3922
|
-
addToolApprovalResponse:
|
|
3923
|
-
handleFileSelect:
|
|
3924
|
-
clearFileLimitError:
|
|
3925
|
-
clearPendingAttachments:
|
|
3946
|
+
sendMessage: B,
|
|
3947
|
+
stopGeneration: Ze,
|
|
3948
|
+
startNewChat: $e,
|
|
3949
|
+
regenerate: et,
|
|
3950
|
+
addToolOutput: tt,
|
|
3951
|
+
addToolApprovalResponse: nt,
|
|
3952
|
+
handleFileSelect: ut,
|
|
3953
|
+
clearFileLimitError: lt,
|
|
3954
|
+
clearPendingAttachments: Qe,
|
|
3926
3955
|
onUpvote: dt,
|
|
3927
3956
|
onDownvote: ft,
|
|
3928
|
-
onFeedback:
|
|
3929
|
-
onFeedbackSubmit:
|
|
3930
|
-
onLeadSubmit:
|
|
3957
|
+
onFeedback: pt,
|
|
3958
|
+
onFeedbackSubmit: mt,
|
|
3959
|
+
onLeadSubmit: H,
|
|
3931
3960
|
navigate: gt,
|
|
3932
|
-
renameChatTitle:
|
|
3961
|
+
renameChatTitle: U,
|
|
3933
3962
|
deleteChat: ht
|
|
3934
3963
|
};
|
|
3935
3964
|
})();
|
|
3936
3965
|
}
|
|
3937
3966
|
//#endregion
|
|
3938
|
-
export {
|
|
3967
|
+
export { er as a, Dr as i, Fr as n, L as o, Br as r, Or as t };
|
|
3939
3968
|
|
|
3940
|
-
//# sourceMappingURL=useChatbotStore-
|
|
3969
|
+
//# sourceMappingURL=useChatbotStore-BcLvyaIV.js.map
|