@opencx/widget-react-headless 5.0.0-beta.3 → 5.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +15 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1023 -1081
- package/dist/index.js.map +1 -1
- package/dist/package.json.d.ts +4 -3
- package/dist/src/agent-chat/__tests__/use-agent-chat.follow-up.spec.d.ts +2 -0
- package/dist/src/agent-chat/__tests__/use-agent-chat.follow-up.spec.d.ts.map +1 -0
- package/dist/src/agent-chat/useAgentChat.d.ts +3 -10
- package/dist/src/agent-chat/useAgentChat.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/src/agent-chat/__tests__/use-agent-chat.steer.spec.d.ts +0 -2
- package/dist/src/agent-chat/__tests__/use-agent-chat.steer.spec.d.ts.map +0 -1
- package/dist/src/agent-chat/steer-into-live-turn.d.ts +0 -35
- package/dist/src/agent-chat/steer-into-live-turn.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { isAgentStreamKeepalive as
|
|
3
|
-
import * as
|
|
1
|
+
import F, { useSyncExternalStore as De, useRef as D, useCallback as q, useEffect as Z, useMemo as B, useState as V, createContext as Fe, useContext as $e } from "react";
|
|
2
|
+
import { isAgentStreamKeepalive as Jr, isRecord as Kr, buildSendMessageBody as Yr, log as ne, genUuid as xt, resolveClientPresentation as Hr, PrimitiveState as Qt, WidgetCtx as Gr, resolveSidebarMode as Qr, resolveSidebarSide as Xr, normalizeCompanionLayouts as ea, resolveCompanionDefaultLayout as ta } from "@opencx/widget-core";
|
|
3
|
+
import * as At from "zod/v4";
|
|
4
4
|
import { z as o } from "zod/v4";
|
|
5
|
-
import { ZodFirstPartyTypeKind as
|
|
5
|
+
import { ZodFirstPartyTypeKind as T } from "zod/v3";
|
|
6
6
|
import "react/jsx-runtime";
|
|
7
|
-
import { z
|
|
8
|
-
const
|
|
9
|
-
function
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
const ra = "5.0.0-beta.5";
|
|
9
|
+
function $(e) {
|
|
10
10
|
return De(e.subscribe, e.get, e.get);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function aa({
|
|
13
13
|
turnSources: e,
|
|
14
14
|
liveItems: t,
|
|
15
15
|
isStreaming: r,
|
|
@@ -18,16 +18,16 @@ function oa({
|
|
|
18
18
|
var i;
|
|
19
19
|
if (r || a) return null;
|
|
20
20
|
const s = t.length > 0 ? t : (i = e.at(-1)) == null ? void 0 : i.items;
|
|
21
|
-
return s ?
|
|
21
|
+
return s ? sa(s) : null;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function sa(e) {
|
|
24
24
|
for (let t = e.length - 1; t >= 0; t--) {
|
|
25
25
|
const r = e[t];
|
|
26
26
|
if ((r == null ? void 0 : r.kind) === "questions") return r.request;
|
|
27
27
|
}
|
|
28
28
|
return null;
|
|
29
29
|
}
|
|
30
|
-
var
|
|
30
|
+
var Xt = "vercel.ai.error", na = Symbol.for(Xt), Mt, Tt, ae = class er extends (Tt = Error, Mt = na, Tt) {
|
|
31
31
|
/**
|
|
32
32
|
* Creates an AI SDK Error.
|
|
33
33
|
*
|
|
@@ -41,7 +41,7 @@ var ar = "vercel.ai.error", ua = Symbol.for(ar), Ot, Nt, se = class sr extends (
|
|
|
41
41
|
message: r,
|
|
42
42
|
cause: a
|
|
43
43
|
}) {
|
|
44
|
-
super(r), this[
|
|
44
|
+
super(r), this[Mt] = !0, this.name = t, this.cause = a;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* Checks if the given error is an AI SDK Error.
|
|
@@ -49,40 +49,40 @@ var ar = "vercel.ai.error", ua = Symbol.for(ar), Ot, Nt, se = class sr extends (
|
|
|
49
49
|
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
50
50
|
*/
|
|
51
51
|
static isInstance(t) {
|
|
52
|
-
return
|
|
52
|
+
return er.hasMarker(t, Xt);
|
|
53
53
|
}
|
|
54
54
|
static hasMarker(t, r) {
|
|
55
55
|
const a = Symbol.for(r);
|
|
56
56
|
return t != null && typeof t == "object" && a in t && typeof t[a] == "boolean" && t[a] === !0;
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
-
function
|
|
59
|
+
function tr(e) {
|
|
60
60
|
return e == null ? "unknown error" : typeof e == "string" ? e : e instanceof Error ? e.toString() : JSON.stringify(e);
|
|
61
61
|
}
|
|
62
|
-
var
|
|
62
|
+
var rr = "AI_InvalidArgumentError", ar = `vercel.ai.error.${rr}`, ia = Symbol.for(ar), Rt, Pt, oa = class extends (Pt = ae, Rt = ia, Pt) {
|
|
63
63
|
constructor({
|
|
64
64
|
message: e,
|
|
65
65
|
cause: t,
|
|
66
66
|
argument: r
|
|
67
67
|
}) {
|
|
68
|
-
super({ name:
|
|
68
|
+
super({ name: rr, message: e, cause: t }), this[Rt] = !0, this.argument = r;
|
|
69
69
|
}
|
|
70
70
|
static isInstance(e) {
|
|
71
|
-
return
|
|
71
|
+
return ae.hasMarker(e, ar);
|
|
72
72
|
}
|
|
73
|
-
},
|
|
73
|
+
}, sr = "AI_JSONParseError", nr = `vercel.ai.error.${sr}`, la = Symbol.for(nr), Ot, Nt, jt = class extends (Nt = ae, Ot = la, Nt) {
|
|
74
74
|
constructor({ text: e, cause: t }) {
|
|
75
75
|
super({
|
|
76
|
-
name:
|
|
76
|
+
name: sr,
|
|
77
77
|
message: `JSON parsing failed: Text: ${e}.
|
|
78
|
-
Error message: ${
|
|
78
|
+
Error message: ${tr(t)}`,
|
|
79
79
|
cause: t
|
|
80
|
-
}), this[
|
|
80
|
+
}), this[Ot] = !0, this.text = e;
|
|
81
81
|
}
|
|
82
82
|
static isInstance(e) {
|
|
83
|
-
return
|
|
83
|
+
return ae.hasMarker(e, nr);
|
|
84
84
|
}
|
|
85
|
-
},
|
|
85
|
+
}, ir = "AI_TypeValidationError", or = `vercel.ai.error.${ir}`, ua = Symbol.for(or), Dt, kt, Ae = class lt extends (kt = ae, Dt = ua, kt) {
|
|
86
86
|
constructor({
|
|
87
87
|
value: t,
|
|
88
88
|
cause: r,
|
|
@@ -95,14 +95,14 @@ Error message: ${nr(t)}`,
|
|
|
95
95
|
a.entityName && i.push(a.entityName), a.entityId && i.push(`id: "${a.entityId}"`), s += i.join(", "), s += ")";
|
|
96
96
|
}
|
|
97
97
|
super({
|
|
98
|
-
name:
|
|
98
|
+
name: ir,
|
|
99
99
|
message: `${s}: Value: ${JSON.stringify(t)}.
|
|
100
|
-
Error message: ${
|
|
100
|
+
Error message: ${tr(r)}`,
|
|
101
101
|
cause: r
|
|
102
|
-
}), this[
|
|
102
|
+
}), this[Dt] = !0, this.value = t, this.context = a;
|
|
103
103
|
}
|
|
104
104
|
static isInstance(t) {
|
|
105
|
-
return
|
|
105
|
+
return ae.hasMarker(t, or);
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Wraps an error into a TypeValidationError.
|
|
@@ -121,25 +121,25 @@ Error message: ${nr(r)}`,
|
|
|
121
121
|
context: a
|
|
122
122
|
}) {
|
|
123
123
|
var s, i, l;
|
|
124
|
-
return
|
|
124
|
+
return lt.isInstance(r) && r.value === t && ((s = r.context) == null ? void 0 : s.field) === (a == null ? void 0 : a.field) && ((i = r.context) == null ? void 0 : i.entityName) === (a == null ? void 0 : a.entityName) && ((l = r.context) == null ? void 0 : l.entityId) === (a == null ? void 0 : a.entityId) ? r : new lt({ value: t, cause: r, context: a });
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
|
-
class
|
|
127
|
+
class rt extends Error {
|
|
128
128
|
constructor(t, r) {
|
|
129
129
|
super(t), this.name = "ParseError", this.type = r.type, this.field = r.field, this.value = r.value, this.line = r.line;
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
const
|
|
133
|
-
function
|
|
132
|
+
const Lt = 10, ca = 13, ge = 32;
|
|
133
|
+
function at(e) {
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function da(e) {
|
|
136
136
|
if (typeof e == "function")
|
|
137
137
|
throw new TypeError(
|
|
138
138
|
"`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
|
|
139
139
|
);
|
|
140
|
-
const { onEvent: t =
|
|
140
|
+
const { onEvent: t = at, onError: r = at, onRetry: a = at, onComment: s, maxBufferSize: i } = e, l = [];
|
|
141
141
|
let n = 0, f = !0, u, c = "", p = 0, v, h = !1;
|
|
142
|
-
function
|
|
142
|
+
function _(g) {
|
|
143
143
|
if (h)
|
|
144
144
|
throw new Error(
|
|
145
145
|
"Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
|
|
@@ -157,12 +157,12 @@ function ga(e) {
|
|
|
157
157
|
l.push(g);
|
|
158
158
|
const m = l.join("");
|
|
159
159
|
l.length = 0, n = 0;
|
|
160
|
-
const
|
|
161
|
-
|
|
160
|
+
const b = E(m);
|
|
161
|
+
b !== "" && (l.push(b), n = b.length), M();
|
|
162
162
|
}
|
|
163
163
|
function M() {
|
|
164
164
|
i !== void 0 && (n + c.length <= i || (h = !0, l.length = 0, n = 0, u = void 0, c = "", p = 0, v = void 0, r(
|
|
165
|
-
new
|
|
165
|
+
new rt(`Buffered data exceeded max buffer size of ${i} characters`, {
|
|
166
166
|
type: "max-buffer-size-exceeded"
|
|
167
167
|
})
|
|
168
168
|
)));
|
|
@@ -170,80 +170,80 @@ function ga(e) {
|
|
|
170
170
|
function E(g) {
|
|
171
171
|
let m = 0;
|
|
172
172
|
if (g.indexOf("\r") === -1) {
|
|
173
|
-
let
|
|
173
|
+
let b = g.indexOf(`
|
|
174
174
|
`, m);
|
|
175
|
-
for (;
|
|
176
|
-
if (m ===
|
|
177
|
-
p > 0 && t({ id: u, event: v, data: c }), u = void 0, c = "", p = 0, v = void 0, m =
|
|
175
|
+
for (; b !== -1; ) {
|
|
176
|
+
if (m === b) {
|
|
177
|
+
p > 0 && t({ id: u, event: v, data: c }), u = void 0, c = "", p = 0, v = void 0, m = b + 1, b = g.indexOf(`
|
|
178
178
|
`, m);
|
|
179
179
|
continue;
|
|
180
180
|
}
|
|
181
181
|
const y = g.charCodeAt(m);
|
|
182
|
-
if (
|
|
183
|
-
const
|
|
184
|
-
if (p === 0 && g.charCodeAt(
|
|
185
|
-
t({ id: u, event: v, data:
|
|
182
|
+
if (Ft(g, m, y)) {
|
|
183
|
+
const I = g.charCodeAt(m + 5) === ge ? m + 6 : m + 5, k = g.slice(I, b);
|
|
184
|
+
if (p === 0 && g.charCodeAt(b + 1) === Lt) {
|
|
185
|
+
t({ id: u, event: v, data: k }), u = void 0, c = "", v = void 0, m = b + 2, b = g.indexOf(`
|
|
186
186
|
`, m);
|
|
187
187
|
continue;
|
|
188
188
|
}
|
|
189
|
-
c = p === 0 ?
|
|
190
|
-
${
|
|
191
|
-
} else
|
|
189
|
+
c = p === 0 ? k : `${c}
|
|
190
|
+
${k}`, p++;
|
|
191
|
+
} else $t(g, m, y) ? v = g.slice(
|
|
192
192
|
g.charCodeAt(m + 6) === ge ? m + 7 : m + 6,
|
|
193
|
-
|
|
194
|
-
) || void 0 : C(g, m,
|
|
195
|
-
m =
|
|
193
|
+
b
|
|
194
|
+
) || void 0 : C(g, m, b);
|
|
195
|
+
m = b + 1, b = g.indexOf(`
|
|
196
196
|
`, m);
|
|
197
197
|
}
|
|
198
198
|
return g.slice(m);
|
|
199
199
|
}
|
|
200
200
|
for (; m < g.length; ) {
|
|
201
|
-
const
|
|
201
|
+
const b = g.indexOf("\r", m), y = g.indexOf(`
|
|
202
202
|
`, m);
|
|
203
|
-
let
|
|
204
|
-
if (
|
|
203
|
+
let I = -1;
|
|
204
|
+
if (b !== -1 && y !== -1 ? I = b < y ? b : y : b !== -1 ? b === g.length - 1 ? I = -1 : I = b : y !== -1 && (I = y), I === -1)
|
|
205
205
|
break;
|
|
206
|
-
C(g, m,
|
|
206
|
+
C(g, m, I), m = I + 1, g.charCodeAt(m - 1) === ca && g.charCodeAt(m) === Lt && m++;
|
|
207
207
|
}
|
|
208
208
|
return g.slice(m);
|
|
209
209
|
}
|
|
210
|
-
function C(g, m,
|
|
211
|
-
if (m ===
|
|
212
|
-
|
|
210
|
+
function C(g, m, b) {
|
|
211
|
+
if (m === b) {
|
|
212
|
+
N();
|
|
213
213
|
return;
|
|
214
214
|
}
|
|
215
215
|
const y = g.charCodeAt(m);
|
|
216
|
-
if (
|
|
217
|
-
const
|
|
218
|
-
c = p === 0 ?
|
|
219
|
-
${
|
|
216
|
+
if (Ft(g, m, y)) {
|
|
217
|
+
const Q = g.charCodeAt(m + 5) === ge ? m + 6 : m + 5, Me = g.slice(Q, b);
|
|
218
|
+
c = p === 0 ? Me : `${c}
|
|
219
|
+
${Me}`, p++;
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
|
-
if (
|
|
223
|
-
v = g.slice(g.charCodeAt(m + 6) === ge ? m + 7 : m + 6,
|
|
222
|
+
if ($t(g, m, y)) {
|
|
223
|
+
v = g.slice(g.charCodeAt(m + 6) === ge ? m + 7 : m + 6, b) || void 0;
|
|
224
224
|
return;
|
|
225
225
|
}
|
|
226
226
|
if (y === 105 && g.charCodeAt(m + 1) === 100 && g.charCodeAt(m + 2) === 58) {
|
|
227
|
-
const
|
|
228
|
-
u =
|
|
227
|
+
const Q = g.slice(g.charCodeAt(m + 3) === ge ? m + 4 : m + 3, b);
|
|
228
|
+
u = Q.includes("\0") ? void 0 : Q;
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
231
|
if (y === 58) {
|
|
232
232
|
if (s) {
|
|
233
|
-
const
|
|
234
|
-
s(
|
|
233
|
+
const Q = g.slice(m, b);
|
|
234
|
+
s(Q.slice(g.charCodeAt(m + 1) === ge ? 2 : 1));
|
|
235
235
|
}
|
|
236
236
|
return;
|
|
237
237
|
}
|
|
238
|
-
const
|
|
239
|
-
if (
|
|
240
|
-
w(
|
|
238
|
+
const I = g.slice(m, b), k = I.indexOf(":");
|
|
239
|
+
if (k === -1) {
|
|
240
|
+
w(I, "", I);
|
|
241
241
|
return;
|
|
242
242
|
}
|
|
243
|
-
const
|
|
244
|
-
w(
|
|
243
|
+
const Y = I.slice(0, k), te = I.charCodeAt(k + 1) === ge ? 2 : 1, ie = I.slice(k + te);
|
|
244
|
+
w(Y, ie, I);
|
|
245
245
|
}
|
|
246
|
-
function w(g, m,
|
|
246
|
+
function w(g, m, b) {
|
|
247
247
|
switch (g) {
|
|
248
248
|
case "event":
|
|
249
249
|
v = m || void 0;
|
|
@@ -257,24 +257,24 @@ ${m}`, p++;
|
|
|
257
257
|
break;
|
|
258
258
|
case "retry":
|
|
259
259
|
/^\d+$/.test(m) ? a(parseInt(m, 10)) : r(
|
|
260
|
-
new
|
|
260
|
+
new rt(`Invalid \`retry\` value: "${m}"`, {
|
|
261
261
|
type: "invalid-retry",
|
|
262
262
|
value: m,
|
|
263
|
-
line:
|
|
263
|
+
line: b
|
|
264
264
|
})
|
|
265
265
|
);
|
|
266
266
|
break;
|
|
267
267
|
default:
|
|
268
268
|
r(
|
|
269
|
-
new
|
|
269
|
+
new rt(
|
|
270
270
|
`Unknown field "${g.length > 20 ? `${g.slice(0, 20)}…` : g}"`,
|
|
271
|
-
{ type: "unknown-field", field: g, value: m, line:
|
|
271
|
+
{ type: "unknown-field", field: g, value: m, line: b }
|
|
272
272
|
)
|
|
273
273
|
);
|
|
274
274
|
break;
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function N() {
|
|
278
278
|
p > 0 && t({
|
|
279
279
|
id: u,
|
|
280
280
|
event: v,
|
|
@@ -288,20 +288,20 @@ ${m}`, p++;
|
|
|
288
288
|
}
|
|
289
289
|
f = !0, u = void 0, c = "", p = 0, v = void 0, l.length = 0, n = 0, h = !1;
|
|
290
290
|
}
|
|
291
|
-
return { feed:
|
|
291
|
+
return { feed: _, reset: d };
|
|
292
292
|
}
|
|
293
|
-
function
|
|
293
|
+
function Ft(e, t, r) {
|
|
294
294
|
return r === 100 && e.charCodeAt(t + 1) === 97 && e.charCodeAt(t + 2) === 116 && e.charCodeAt(t + 3) === 97 && e.charCodeAt(t + 4) === 58;
|
|
295
295
|
}
|
|
296
|
-
function
|
|
296
|
+
function $t(e, t, r) {
|
|
297
297
|
return r === 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;
|
|
298
298
|
}
|
|
299
|
-
class
|
|
299
|
+
class pa extends TransformStream {
|
|
300
300
|
constructor({ onError: t, onRetry: r, onComment: a, maxBufferSize: s } = {}) {
|
|
301
301
|
let i;
|
|
302
302
|
super({
|
|
303
303
|
start(l) {
|
|
304
|
-
i =
|
|
304
|
+
i = da({
|
|
305
305
|
onEvent: (n) => {
|
|
306
306
|
l.enqueue(n);
|
|
307
307
|
},
|
|
@@ -320,7 +320,7 @@ class ha extends TransformStream {
|
|
|
320
320
|
}
|
|
321
321
|
}
|
|
322
322
|
new TextDecoder();
|
|
323
|
-
var
|
|
323
|
+
var G = ({
|
|
324
324
|
prefix: e,
|
|
325
325
|
size: t = 16,
|
|
326
326
|
alphabet: r = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
@@ -335,13 +335,13 @@ var Q = ({
|
|
|
335
335
|
if (e == null)
|
|
336
336
|
return s;
|
|
337
337
|
if (r.includes(a))
|
|
338
|
-
throw new
|
|
338
|
+
throw new oa({
|
|
339
339
|
argument: "separator",
|
|
340
340
|
message: `The separator "${a}" must not be part of the alphabet "${r}".`
|
|
341
341
|
});
|
|
342
342
|
return () => `${e}${a}${s()}`;
|
|
343
|
-
},
|
|
344
|
-
function
|
|
343
|
+
}, fa = G();
|
|
344
|
+
function Ie(e) {
|
|
345
345
|
if (e == null)
|
|
346
346
|
return {};
|
|
347
347
|
const t = {};
|
|
@@ -356,16 +356,16 @@ function we(e) {
|
|
|
356
356
|
}
|
|
357
357
|
return t;
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function ma(e) {
|
|
360
360
|
var t, r;
|
|
361
361
|
return (r = (t = globalThis.Buffer) == null ? void 0 : t.isBuffer(e)) != null ? r : !1;
|
|
362
362
|
}
|
|
363
|
-
var
|
|
364
|
-
function
|
|
363
|
+
var ga = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, ha = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
364
|
+
function Ut(e) {
|
|
365
365
|
const t = JSON.parse(e);
|
|
366
|
-
return t === null || typeof t != "object" ||
|
|
366
|
+
return t === null || typeof t != "object" || ga.test(e) === !1 && ha.test(e) === !1 ? t : va(t);
|
|
367
367
|
}
|
|
368
|
-
function
|
|
368
|
+
function va(e) {
|
|
369
369
|
let t = [e];
|
|
370
370
|
for (; t.length; ) {
|
|
371
371
|
const r = t;
|
|
@@ -383,20 +383,20 @@ function Ea(e) {
|
|
|
383
383
|
}
|
|
384
384
|
return e;
|
|
385
385
|
}
|
|
386
|
-
function
|
|
386
|
+
function ya(e) {
|
|
387
387
|
const { stackTraceLimit: t } = Error;
|
|
388
388
|
try {
|
|
389
389
|
Error.stackTraceLimit = 0;
|
|
390
390
|
} catch {
|
|
391
|
-
return
|
|
391
|
+
return Ut(e);
|
|
392
392
|
}
|
|
393
393
|
try {
|
|
394
|
-
return
|
|
394
|
+
return Ut(e);
|
|
395
395
|
} finally {
|
|
396
396
|
Error.stackTraceLimit = t;
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
|
-
function
|
|
399
|
+
function gt(e) {
|
|
400
400
|
if (e.type === "object" || Array.isArray(e.type) && e.type.includes("object")) {
|
|
401
401
|
e.additionalProperties = !1;
|
|
402
402
|
const { properties: r } = e;
|
|
@@ -412,11 +412,11 @@ function vt(e) {
|
|
|
412
412
|
return e;
|
|
413
413
|
}
|
|
414
414
|
function he(e) {
|
|
415
|
-
return typeof e == "boolean" ? e :
|
|
415
|
+
return typeof e == "boolean" ? e : gt(e);
|
|
416
416
|
}
|
|
417
|
-
var
|
|
417
|
+
var ba = /* @__PURE__ */ Symbol(
|
|
418
418
|
"Let zodToJsonSchema decide on which parser to use"
|
|
419
|
-
),
|
|
419
|
+
), qt = {
|
|
420
420
|
name: void 0,
|
|
421
421
|
$refStrategy: "root",
|
|
422
422
|
basePath: ["#"],
|
|
@@ -436,27 +436,27 @@ var Ia = /* @__PURE__ */ Symbol(
|
|
|
436
436
|
emailStrategy: "format:email",
|
|
437
437
|
base64Strategy: "contentEncoding:base64",
|
|
438
438
|
nameStrategy: "ref"
|
|
439
|
-
},
|
|
440
|
-
...
|
|
439
|
+
}, Sa = (e) => typeof e == "string" ? {
|
|
440
|
+
...qt,
|
|
441
441
|
name: e
|
|
442
442
|
} : {
|
|
443
|
-
...
|
|
443
|
+
...qt,
|
|
444
444
|
...e
|
|
445
445
|
};
|
|
446
|
-
function
|
|
446
|
+
function J() {
|
|
447
447
|
return {};
|
|
448
448
|
}
|
|
449
|
-
function
|
|
449
|
+
function Ea(e, t) {
|
|
450
450
|
var r, a, s;
|
|
451
451
|
const i = {
|
|
452
452
|
type: "array"
|
|
453
453
|
};
|
|
454
|
-
return (r = e.type) != null && r._def && ((s = (a = e.type) == null ? void 0 : a._def) == null ? void 0 : s.typeName) !==
|
|
454
|
+
return (r = e.type) != null && r._def && ((s = (a = e.type) == null ? void 0 : a._def) == null ? void 0 : s.typeName) !== T.ZodAny && (i.items = O(e.type._def, {
|
|
455
455
|
...t,
|
|
456
456
|
currentPath: [...t.currentPath, "items"]
|
|
457
457
|
})), e.minLength && (i.minItems = e.minLength.value), e.maxLength && (i.maxItems = e.maxLength.value), e.exactLength && (i.minItems = e.exactLength.value, i.maxItems = e.exactLength.value), i;
|
|
458
458
|
}
|
|
459
|
-
function
|
|
459
|
+
function Ca(e) {
|
|
460
460
|
const t = {
|
|
461
461
|
type: "integer",
|
|
462
462
|
format: "int64"
|
|
@@ -476,18 +476,18 @@ function xa(e) {
|
|
|
476
476
|
}
|
|
477
477
|
return t;
|
|
478
478
|
}
|
|
479
|
-
function
|
|
479
|
+
function Ia() {
|
|
480
480
|
return { type: "boolean" };
|
|
481
481
|
}
|
|
482
|
-
function
|
|
483
|
-
return
|
|
482
|
+
function lr(e, t) {
|
|
483
|
+
return O(e.type._def, t);
|
|
484
484
|
}
|
|
485
|
-
var
|
|
486
|
-
function
|
|
485
|
+
var wa = (e, t) => O(e.innerType._def, t);
|
|
486
|
+
function ur(e, t, r) {
|
|
487
487
|
const a = r ?? t.dateStrategy;
|
|
488
488
|
if (Array.isArray(a))
|
|
489
489
|
return {
|
|
490
|
-
anyOf: a.map((s) =>
|
|
490
|
+
anyOf: a.map((s) => ur(e, t, s))
|
|
491
491
|
};
|
|
492
492
|
switch (a) {
|
|
493
493
|
case "string":
|
|
@@ -502,10 +502,10 @@ function fr(e, t, r) {
|
|
|
502
502
|
format: "date"
|
|
503
503
|
};
|
|
504
504
|
case "integer":
|
|
505
|
-
return
|
|
505
|
+
return _a(e);
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
|
-
var
|
|
508
|
+
var _a = (e) => {
|
|
509
509
|
const t = {
|
|
510
510
|
type: "integer",
|
|
511
511
|
format: "unix-time"
|
|
@@ -521,35 +521,35 @@ var Ta = (e) => {
|
|
|
521
521
|
}
|
|
522
522
|
return t;
|
|
523
523
|
};
|
|
524
|
-
function
|
|
524
|
+
function xa(e, t) {
|
|
525
525
|
return {
|
|
526
|
-
...
|
|
526
|
+
...O(e.innerType._def, t),
|
|
527
527
|
default: e.defaultValue()
|
|
528
528
|
};
|
|
529
529
|
}
|
|
530
|
-
function
|
|
531
|
-
return t.effectStrategy === "input" ?
|
|
530
|
+
function Aa(e, t) {
|
|
531
|
+
return t.effectStrategy === "input" ? O(e.schema._def, t) : J();
|
|
532
532
|
}
|
|
533
|
-
function
|
|
533
|
+
function Ma(e) {
|
|
534
534
|
return {
|
|
535
535
|
type: "string",
|
|
536
536
|
enum: Array.from(e.values)
|
|
537
537
|
};
|
|
538
538
|
}
|
|
539
|
-
var
|
|
540
|
-
function
|
|
539
|
+
var Ta = (e) => "type" in e && e.type === "string" ? !1 : "allOf" in e;
|
|
540
|
+
function Ra(e, t) {
|
|
541
541
|
const r = [
|
|
542
|
-
|
|
542
|
+
O(e.left._def, {
|
|
543
543
|
...t,
|
|
544
544
|
currentPath: [...t.currentPath, "allOf", "0"]
|
|
545
545
|
}),
|
|
546
|
-
|
|
546
|
+
O(e.right._def, {
|
|
547
547
|
...t,
|
|
548
548
|
currentPath: [...t.currentPath, "allOf", "1"]
|
|
549
549
|
})
|
|
550
550
|
].filter((s) => !!s), a = [];
|
|
551
551
|
return r.forEach((s) => {
|
|
552
|
-
if (
|
|
552
|
+
if (Ta(s))
|
|
553
553
|
a.push(...s.allOf);
|
|
554
554
|
else {
|
|
555
555
|
let i = s;
|
|
@@ -561,7 +561,7 @@ function ja(e, t) {
|
|
|
561
561
|
}
|
|
562
562
|
}), a.length ? { allOf: a } : void 0;
|
|
563
563
|
}
|
|
564
|
-
function
|
|
564
|
+
function Pa(e) {
|
|
565
565
|
const t = typeof e.value;
|
|
566
566
|
return t !== "bigint" && t !== "number" && t !== "boolean" && t !== "string" ? {
|
|
567
567
|
type: Array.isArray(e.value) ? "array" : "object"
|
|
@@ -570,7 +570,7 @@ function Da(e) {
|
|
|
570
570
|
const: e.value
|
|
571
571
|
};
|
|
572
572
|
}
|
|
573
|
-
var
|
|
573
|
+
var st = void 0, X = {
|
|
574
574
|
/**
|
|
575
575
|
* `c` was changed to `[cC]` to replicate /i flag
|
|
576
576
|
*/
|
|
@@ -592,10 +592,10 @@ var it = void 0, ee = {
|
|
|
592
592
|
* Fix in Zod:
|
|
593
593
|
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
|
594
594
|
*/
|
|
595
|
-
emoji: () => (
|
|
595
|
+
emoji: () => (st === void 0 && (st = RegExp(
|
|
596
596
|
"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",
|
|
597
597
|
"u"
|
|
598
|
-
)),
|
|
598
|
+
)), st),
|
|
599
599
|
/**
|
|
600
600
|
* Unused
|
|
601
601
|
*/
|
|
@@ -615,7 +615,7 @@ var it = void 0, ee = {
|
|
|
615
615
|
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
616
616
|
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
617
617
|
};
|
|
618
|
-
function
|
|
618
|
+
function cr(e, t) {
|
|
619
619
|
const r = {
|
|
620
620
|
type: "string"
|
|
621
621
|
};
|
|
@@ -631,96 +631,96 @@ function mr(e, t) {
|
|
|
631
631
|
case "email":
|
|
632
632
|
switch (t.emailStrategy) {
|
|
633
633
|
case "format:email":
|
|
634
|
-
|
|
634
|
+
ee(r, "email", a.message, t);
|
|
635
635
|
break;
|
|
636
636
|
case "format:idn-email":
|
|
637
|
-
|
|
637
|
+
ee(r, "idn-email", a.message, t);
|
|
638
638
|
break;
|
|
639
639
|
case "pattern:zod":
|
|
640
|
-
|
|
640
|
+
W(r, X.email, a.message, t);
|
|
641
641
|
break;
|
|
642
642
|
}
|
|
643
643
|
break;
|
|
644
644
|
case "url":
|
|
645
|
-
|
|
645
|
+
ee(r, "uri", a.message, t);
|
|
646
646
|
break;
|
|
647
647
|
case "uuid":
|
|
648
|
-
|
|
648
|
+
ee(r, "uuid", a.message, t);
|
|
649
649
|
break;
|
|
650
650
|
case "regex":
|
|
651
|
-
|
|
651
|
+
W(r, a.regex, a.message, t);
|
|
652
652
|
break;
|
|
653
653
|
case "cuid":
|
|
654
|
-
|
|
654
|
+
W(r, X.cuid, a.message, t);
|
|
655
655
|
break;
|
|
656
656
|
case "cuid2":
|
|
657
|
-
|
|
657
|
+
W(r, X.cuid2, a.message, t);
|
|
658
658
|
break;
|
|
659
659
|
case "startsWith":
|
|
660
|
-
|
|
660
|
+
W(
|
|
661
661
|
r,
|
|
662
|
-
RegExp(`^${
|
|
662
|
+
RegExp(`^${nt(a.value, t)}`),
|
|
663
663
|
a.message,
|
|
664
664
|
t
|
|
665
665
|
);
|
|
666
666
|
break;
|
|
667
667
|
case "endsWith":
|
|
668
|
-
|
|
668
|
+
W(
|
|
669
669
|
r,
|
|
670
|
-
RegExp(`${
|
|
670
|
+
RegExp(`${nt(a.value, t)}$`),
|
|
671
671
|
a.message,
|
|
672
672
|
t
|
|
673
673
|
);
|
|
674
674
|
break;
|
|
675
675
|
case "datetime":
|
|
676
|
-
|
|
676
|
+
ee(r, "date-time", a.message, t);
|
|
677
677
|
break;
|
|
678
678
|
case "date":
|
|
679
|
-
|
|
679
|
+
ee(r, "date", a.message, t);
|
|
680
680
|
break;
|
|
681
681
|
case "time":
|
|
682
|
-
|
|
682
|
+
ee(r, "time", a.message, t);
|
|
683
683
|
break;
|
|
684
684
|
case "duration":
|
|
685
|
-
|
|
685
|
+
ee(r, "duration", a.message, t);
|
|
686
686
|
break;
|
|
687
687
|
case "length":
|
|
688
688
|
r.minLength = typeof r.minLength == "number" ? Math.max(r.minLength, a.value) : a.value, r.maxLength = typeof r.maxLength == "number" ? Math.min(r.maxLength, a.value) : a.value;
|
|
689
689
|
break;
|
|
690
690
|
case "includes": {
|
|
691
|
-
|
|
691
|
+
W(
|
|
692
692
|
r,
|
|
693
|
-
RegExp(
|
|
693
|
+
RegExp(nt(a.value, t)),
|
|
694
694
|
a.message,
|
|
695
695
|
t
|
|
696
696
|
);
|
|
697
697
|
break;
|
|
698
698
|
}
|
|
699
699
|
case "ip": {
|
|
700
|
-
a.version !== "v6" &&
|
|
700
|
+
a.version !== "v6" && ee(r, "ipv4", a.message, t), a.version !== "v4" && ee(r, "ipv6", a.message, t);
|
|
701
701
|
break;
|
|
702
702
|
}
|
|
703
703
|
case "base64url":
|
|
704
|
-
|
|
704
|
+
W(r, X.base64url, a.message, t);
|
|
705
705
|
break;
|
|
706
706
|
case "jwt":
|
|
707
|
-
|
|
707
|
+
W(r, X.jwt, a.message, t);
|
|
708
708
|
break;
|
|
709
709
|
case "cidr": {
|
|
710
|
-
a.version !== "v6" &&
|
|
710
|
+
a.version !== "v6" && W(r, X.ipv4Cidr, a.message, t), a.version !== "v4" && W(r, X.ipv6Cidr, a.message, t);
|
|
711
711
|
break;
|
|
712
712
|
}
|
|
713
713
|
case "emoji":
|
|
714
|
-
|
|
714
|
+
W(r, X.emoji(), a.message, t);
|
|
715
715
|
break;
|
|
716
716
|
case "ulid": {
|
|
717
|
-
|
|
717
|
+
W(r, X.ulid, a.message, t);
|
|
718
718
|
break;
|
|
719
719
|
}
|
|
720
720
|
case "base64": {
|
|
721
721
|
switch (t.base64Strategy) {
|
|
722
722
|
case "format:binary": {
|
|
723
|
-
|
|
723
|
+
ee(r, "binary", a.message, t);
|
|
724
724
|
break;
|
|
725
725
|
}
|
|
726
726
|
case "contentEncoding:base64": {
|
|
@@ -728,30 +728,30 @@ function mr(e, t) {
|
|
|
728
728
|
break;
|
|
729
729
|
}
|
|
730
730
|
case "pattern:zod": {
|
|
731
|
-
|
|
731
|
+
W(r, X.base64, a.message, t);
|
|
732
732
|
break;
|
|
733
733
|
}
|
|
734
734
|
}
|
|
735
735
|
break;
|
|
736
736
|
}
|
|
737
737
|
case "nanoid":
|
|
738
|
-
|
|
738
|
+
W(r, X.nanoid, a.message, t);
|
|
739
739
|
}
|
|
740
740
|
return r;
|
|
741
741
|
}
|
|
742
|
-
function
|
|
743
|
-
return t.patternStrategy === "escape" ?
|
|
742
|
+
function nt(e, t) {
|
|
743
|
+
return t.patternStrategy === "escape" ? Na(e) : e;
|
|
744
744
|
}
|
|
745
|
-
var
|
|
745
|
+
var Oa = new Set(
|
|
746
746
|
"ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789"
|
|
747
747
|
);
|
|
748
|
-
function
|
|
748
|
+
function Na(e) {
|
|
749
749
|
let t = "";
|
|
750
750
|
for (let r = 0; r < e.length; r++)
|
|
751
|
-
|
|
751
|
+
Oa.has(e[r]) || (t += "\\"), t += e[r];
|
|
752
752
|
return t;
|
|
753
753
|
}
|
|
754
|
-
function
|
|
754
|
+
function ee(e, t, r, a) {
|
|
755
755
|
var s;
|
|
756
756
|
e.format || (s = e.anyOf) != null && s.some((i) => i.format) ? (e.anyOf || (e.anyOf = []), e.format && (e.anyOf.push({
|
|
757
757
|
format: e.format
|
|
@@ -760,16 +760,16 @@ function te(e, t, r, a) {
|
|
|
760
760
|
...r && a.errorMessages && { errorMessage: { format: r } }
|
|
761
761
|
})) : e.format = t;
|
|
762
762
|
}
|
|
763
|
-
function
|
|
763
|
+
function W(e, t, r, a) {
|
|
764
764
|
var s;
|
|
765
765
|
e.pattern || (s = e.allOf) != null && s.some((i) => i.pattern) ? (e.allOf || (e.allOf = []), e.pattern && (e.allOf.push({
|
|
766
766
|
pattern: e.pattern
|
|
767
767
|
}), delete e.pattern), e.allOf.push({
|
|
768
|
-
pattern:
|
|
768
|
+
pattern: Zt(t, a),
|
|
769
769
|
...r && a.errorMessages && { errorMessage: { pattern: r } }
|
|
770
|
-
})) : e.pattern =
|
|
770
|
+
})) : e.pattern = Zt(t, a);
|
|
771
771
|
}
|
|
772
|
-
function
|
|
772
|
+
function Zt(e, t) {
|
|
773
773
|
var r;
|
|
774
774
|
if (!t.applyRegexFlags || !e.flags)
|
|
775
775
|
return e.source;
|
|
@@ -828,31 +828,31 @@ function Vt(e, t) {
|
|
|
828
828
|
}
|
|
829
829
|
return i;
|
|
830
830
|
}
|
|
831
|
-
function
|
|
831
|
+
function dr(e, t) {
|
|
832
832
|
var r, a, s, i, l, n;
|
|
833
833
|
const f = {
|
|
834
834
|
type: "object",
|
|
835
|
-
additionalProperties: (r =
|
|
835
|
+
additionalProperties: (r = O(e.valueType._def, {
|
|
836
836
|
...t,
|
|
837
837
|
currentPath: [...t.currentPath, "additionalProperties"]
|
|
838
838
|
})) != null ? r : t.allowedAdditionalProperties
|
|
839
839
|
};
|
|
840
|
-
if (((a = e.keyType) == null ? void 0 : a._def.typeName) ===
|
|
841
|
-
const { type: u, ...c } =
|
|
840
|
+
if (((a = e.keyType) == null ? void 0 : a._def.typeName) === T.ZodString && ((s = e.keyType._def.checks) != null && s.length)) {
|
|
841
|
+
const { type: u, ...c } = cr(e.keyType._def, t);
|
|
842
842
|
return {
|
|
843
843
|
...f,
|
|
844
844
|
propertyNames: c
|
|
845
845
|
};
|
|
846
846
|
} else {
|
|
847
|
-
if (((i = e.keyType) == null ? void 0 : i._def.typeName) ===
|
|
847
|
+
if (((i = e.keyType) == null ? void 0 : i._def.typeName) === T.ZodEnum)
|
|
848
848
|
return {
|
|
849
849
|
...f,
|
|
850
850
|
propertyNames: {
|
|
851
851
|
enum: e.keyType._def.values
|
|
852
852
|
}
|
|
853
853
|
};
|
|
854
|
-
if (((l = e.keyType) == null ? void 0 : l._def.typeName) ===
|
|
855
|
-
const { type: u, ...c } =
|
|
854
|
+
if (((l = e.keyType) == null ? void 0 : l._def.typeName) === T.ZodBranded && e.keyType._def.type._def.typeName === T.ZodString && ((n = e.keyType._def.type._def.checks) != null && n.length)) {
|
|
855
|
+
const { type: u, ...c } = lr(
|
|
856
856
|
e.keyType._def,
|
|
857
857
|
t
|
|
858
858
|
);
|
|
@@ -864,16 +864,16 @@ function gr(e, t) {
|
|
|
864
864
|
}
|
|
865
865
|
return f;
|
|
866
866
|
}
|
|
867
|
-
function
|
|
867
|
+
function ja(e, t) {
|
|
868
868
|
if (t.mapStrategy === "record")
|
|
869
|
-
return
|
|
870
|
-
const r =
|
|
869
|
+
return dr(e, t);
|
|
870
|
+
const r = O(e.keyType._def, {
|
|
871
871
|
...t,
|
|
872
872
|
currentPath: [...t.currentPath, "items", "items", "0"]
|
|
873
|
-
}) ||
|
|
873
|
+
}) || J(), a = O(e.valueType._def, {
|
|
874
874
|
...t,
|
|
875
875
|
currentPath: [...t.currentPath, "items", "items", "1"]
|
|
876
|
-
}) ||
|
|
876
|
+
}) || J();
|
|
877
877
|
return {
|
|
878
878
|
type: "array",
|
|
879
879
|
maxItems: 125,
|
|
@@ -885,7 +885,7 @@ function Fa(e, t) {
|
|
|
885
885
|
}
|
|
886
886
|
};
|
|
887
887
|
}
|
|
888
|
-
function
|
|
888
|
+
function Da(e) {
|
|
889
889
|
const t = e.values, a = Object.keys(e.values).filter((i) => typeof t[t[i]] != "number").map((i) => t[i]), s = Array.from(
|
|
890
890
|
new Set(a.map((i) => typeof i))
|
|
891
891
|
);
|
|
@@ -894,28 +894,28 @@ function $a(e) {
|
|
|
894
894
|
enum: a
|
|
895
895
|
};
|
|
896
896
|
}
|
|
897
|
-
function
|
|
898
|
-
return { not:
|
|
897
|
+
function ka() {
|
|
898
|
+
return { not: J() };
|
|
899
899
|
}
|
|
900
|
-
function
|
|
900
|
+
function La() {
|
|
901
901
|
return {
|
|
902
902
|
type: "null"
|
|
903
903
|
};
|
|
904
904
|
}
|
|
905
|
-
var
|
|
905
|
+
var ut = {
|
|
906
906
|
ZodString: "string",
|
|
907
907
|
ZodNumber: "number",
|
|
908
908
|
ZodBigInt: "integer",
|
|
909
909
|
ZodBoolean: "boolean",
|
|
910
910
|
ZodNull: "null"
|
|
911
911
|
};
|
|
912
|
-
function
|
|
912
|
+
function Fa(e, t) {
|
|
913
913
|
const r = e.options instanceof Map ? Array.from(e.options.values()) : e.options;
|
|
914
914
|
if (r.every(
|
|
915
|
-
(a) => a._def.typeName in
|
|
915
|
+
(a) => a._def.typeName in ut && (!a._def.checks || !a._def.checks.length)
|
|
916
916
|
)) {
|
|
917
917
|
const a = r.reduce((s, i) => {
|
|
918
|
-
const l =
|
|
918
|
+
const l = ut[i._def.typeName];
|
|
919
919
|
return l && !s.includes(l) ? [...s, l] : s;
|
|
920
920
|
}, []);
|
|
921
921
|
return {
|
|
@@ -964,11 +964,11 @@ function Za(e, t) {
|
|
|
964
964
|
[]
|
|
965
965
|
)
|
|
966
966
|
};
|
|
967
|
-
return
|
|
967
|
+
return $a(e, t);
|
|
968
968
|
}
|
|
969
|
-
var
|
|
969
|
+
var $a = (e, t) => {
|
|
970
970
|
const r = (e.options instanceof Map ? Array.from(e.options.values()) : e.options).map(
|
|
971
|
-
(a, s) =>
|
|
971
|
+
(a, s) => O(a._def, {
|
|
972
972
|
...t,
|
|
973
973
|
currentPath: [...t.currentPath, "anyOf", `${s}`]
|
|
974
974
|
})
|
|
@@ -977,23 +977,23 @@ var za = (e, t) => {
|
|
|
977
977
|
);
|
|
978
978
|
return r.length ? { anyOf: r } : void 0;
|
|
979
979
|
};
|
|
980
|
-
function
|
|
980
|
+
function Ua(e, t) {
|
|
981
981
|
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(
|
|
982
982
|
e.innerType._def.typeName
|
|
983
983
|
) && (!e.innerType._def.checks || !e.innerType._def.checks.length))
|
|
984
984
|
return {
|
|
985
985
|
type: [
|
|
986
|
-
|
|
986
|
+
ut[e.innerType._def.typeName],
|
|
987
987
|
"null"
|
|
988
988
|
]
|
|
989
989
|
};
|
|
990
|
-
const r =
|
|
990
|
+
const r = O(e.innerType._def, {
|
|
991
991
|
...t,
|
|
992
992
|
currentPath: [...t.currentPath, "anyOf", "0"]
|
|
993
993
|
});
|
|
994
994
|
return r && { anyOf: [r, { type: "null" }] };
|
|
995
995
|
}
|
|
996
|
-
function
|
|
996
|
+
function qa(e) {
|
|
997
997
|
const t = {
|
|
998
998
|
type: "number"
|
|
999
999
|
};
|
|
@@ -1015,7 +1015,7 @@ function Ba(e) {
|
|
|
1015
1015
|
}
|
|
1016
1016
|
return t;
|
|
1017
1017
|
}
|
|
1018
|
-
function
|
|
1018
|
+
function Za(e, t) {
|
|
1019
1019
|
const r = {
|
|
1020
1020
|
type: "object",
|
|
1021
1021
|
properties: {}
|
|
@@ -1024,7 +1024,7 @@ function Va(e, t) {
|
|
|
1024
1024
|
let n = s[l];
|
|
1025
1025
|
if (n === void 0 || n._def === void 0)
|
|
1026
1026
|
continue;
|
|
1027
|
-
const f =
|
|
1027
|
+
const f = Wa(n), u = O(n._def, {
|
|
1028
1028
|
...t,
|
|
1029
1029
|
currentPath: [...t.currentPath, "properties", l],
|
|
1030
1030
|
propertyPath: [...t.currentPath, "properties", l]
|
|
@@ -1032,12 +1032,12 @@ function Va(e, t) {
|
|
|
1032
1032
|
u !== void 0 && (r.properties[l] = u, f || a.push(l));
|
|
1033
1033
|
}
|
|
1034
1034
|
a.length && (r.required = a);
|
|
1035
|
-
const i =
|
|
1035
|
+
const i = za(e, t);
|
|
1036
1036
|
return i !== void 0 && (r.additionalProperties = i), r;
|
|
1037
1037
|
}
|
|
1038
|
-
function
|
|
1038
|
+
function za(e, t) {
|
|
1039
1039
|
if (e.catchall._def.typeName !== "ZodNever")
|
|
1040
|
-
return
|
|
1040
|
+
return O(e.catchall._def, {
|
|
1041
1041
|
...t,
|
|
1042
1042
|
currentPath: [...t.currentPath, "additionalProperties"]
|
|
1043
1043
|
});
|
|
@@ -1050,31 +1050,31 @@ function Ja(e, t) {
|
|
|
1050
1050
|
return t.removeAdditionalStrategy === "strict" ? t.allowedAdditionalProperties : t.rejectedAdditionalProperties;
|
|
1051
1051
|
}
|
|
1052
1052
|
}
|
|
1053
|
-
function
|
|
1053
|
+
function Wa(e) {
|
|
1054
1054
|
try {
|
|
1055
1055
|
return e.isOptional();
|
|
1056
1056
|
} catch {
|
|
1057
1057
|
return !0;
|
|
1058
1058
|
}
|
|
1059
1059
|
}
|
|
1060
|
-
var
|
|
1060
|
+
var Ba = (e, t) => {
|
|
1061
1061
|
var r;
|
|
1062
1062
|
if (t.currentPath.toString() === ((r = t.propertyPath) == null ? void 0 : r.toString()))
|
|
1063
|
-
return
|
|
1064
|
-
const a =
|
|
1063
|
+
return O(e.innerType._def, t);
|
|
1064
|
+
const a = O(e.innerType._def, {
|
|
1065
1065
|
...t,
|
|
1066
1066
|
currentPath: [...t.currentPath, "anyOf", "1"]
|
|
1067
1067
|
});
|
|
1068
|
-
return a ? { anyOf: [{ not:
|
|
1069
|
-
},
|
|
1068
|
+
return a ? { anyOf: [{ not: J() }, a] } : J();
|
|
1069
|
+
}, Va = (e, t) => {
|
|
1070
1070
|
if (t.pipeStrategy === "input")
|
|
1071
|
-
return
|
|
1071
|
+
return O(e.in._def, t);
|
|
1072
1072
|
if (t.pipeStrategy === "output")
|
|
1073
|
-
return
|
|
1074
|
-
const r =
|
|
1073
|
+
return O(e.out._def, t);
|
|
1074
|
+
const r = O(e.in._def, {
|
|
1075
1075
|
...t,
|
|
1076
1076
|
currentPath: [...t.currentPath, "allOf", "0"]
|
|
1077
|
-
}), a =
|
|
1077
|
+
}), a = O(e.out._def, {
|
|
1078
1078
|
...t,
|
|
1079
1079
|
currentPath: [...t.currentPath, "allOf", r ? "1" : "0"]
|
|
1080
1080
|
});
|
|
@@ -1084,26 +1084,26 @@ var Ya = (e, t) => {
|
|
|
1084
1084
|
)
|
|
1085
1085
|
};
|
|
1086
1086
|
};
|
|
1087
|
-
function
|
|
1088
|
-
return
|
|
1087
|
+
function Ja(e, t) {
|
|
1088
|
+
return O(e.type._def, t);
|
|
1089
1089
|
}
|
|
1090
|
-
function
|
|
1090
|
+
function Ka(e, t) {
|
|
1091
1091
|
const a = {
|
|
1092
1092
|
type: "array",
|
|
1093
1093
|
uniqueItems: !0,
|
|
1094
|
-
items:
|
|
1094
|
+
items: O(e.valueType._def, {
|
|
1095
1095
|
...t,
|
|
1096
1096
|
currentPath: [...t.currentPath, "items"]
|
|
1097
1097
|
})
|
|
1098
1098
|
};
|
|
1099
1099
|
return e.minSize && (a.minItems = e.minSize.value), e.maxSize && (a.maxItems = e.maxSize.value), a;
|
|
1100
1100
|
}
|
|
1101
|
-
function
|
|
1101
|
+
function Ya(e, t) {
|
|
1102
1102
|
return e.rest ? {
|
|
1103
1103
|
type: "array",
|
|
1104
1104
|
minItems: e.items.length,
|
|
1105
1105
|
items: e.items.map(
|
|
1106
|
-
(r, a) =>
|
|
1106
|
+
(r, a) => O(r._def, {
|
|
1107
1107
|
...t,
|
|
1108
1108
|
currentPath: [...t.currentPath, "items", `${a}`]
|
|
1109
1109
|
})
|
|
@@ -1111,7 +1111,7 @@ function Xa(e, t) {
|
|
|
1111
1111
|
(r, a) => a === void 0 ? r : [...r, a],
|
|
1112
1112
|
[]
|
|
1113
1113
|
),
|
|
1114
|
-
additionalItems:
|
|
1114
|
+
additionalItems: O(e.rest._def, {
|
|
1115
1115
|
...t,
|
|
1116
1116
|
currentPath: [...t.currentPath, "additionalItems"]
|
|
1117
1117
|
})
|
|
@@ -1120,7 +1120,7 @@ function Xa(e, t) {
|
|
|
1120
1120
|
minItems: e.items.length,
|
|
1121
1121
|
maxItems: e.items.length,
|
|
1122
1122
|
items: e.items.map(
|
|
1123
|
-
(r, a) =>
|
|
1123
|
+
(r, a) => O(r._def, {
|
|
1124
1124
|
...t,
|
|
1125
1125
|
currentPath: [...t.currentPath, "items", `${a}`]
|
|
1126
1126
|
})
|
|
@@ -1130,95 +1130,95 @@ function Xa(e, t) {
|
|
|
1130
1130
|
)
|
|
1131
1131
|
};
|
|
1132
1132
|
}
|
|
1133
|
-
function
|
|
1133
|
+
function Ha() {
|
|
1134
1134
|
return {
|
|
1135
|
-
not:
|
|
1135
|
+
not: J()
|
|
1136
1136
|
};
|
|
1137
1137
|
}
|
|
1138
|
-
function
|
|
1139
|
-
return
|
|
1138
|
+
function Ga() {
|
|
1139
|
+
return J();
|
|
1140
1140
|
}
|
|
1141
|
-
var
|
|
1141
|
+
var Qa = (e, t) => O(e.innerType._def, t), Xa = (e, t, r) => {
|
|
1142
1142
|
switch (t) {
|
|
1143
|
-
case
|
|
1144
|
-
return
|
|
1145
|
-
case
|
|
1146
|
-
return
|
|
1147
|
-
case
|
|
1148
|
-
return Va(e, r);
|
|
1149
|
-
case R.ZodBigInt:
|
|
1150
|
-
return xa(e);
|
|
1151
|
-
case R.ZodBoolean:
|
|
1152
|
-
return Aa();
|
|
1153
|
-
case R.ZodDate:
|
|
1154
|
-
return fr(e, r);
|
|
1155
|
-
case R.ZodUndefined:
|
|
1156
|
-
return es();
|
|
1157
|
-
case R.ZodNull:
|
|
1158
|
-
return qa();
|
|
1159
|
-
case R.ZodArray:
|
|
1160
|
-
return _a(e, r);
|
|
1161
|
-
case R.ZodUnion:
|
|
1162
|
-
case R.ZodDiscriminatedUnion:
|
|
1143
|
+
case T.ZodString:
|
|
1144
|
+
return cr(e, r);
|
|
1145
|
+
case T.ZodNumber:
|
|
1146
|
+
return qa(e);
|
|
1147
|
+
case T.ZodObject:
|
|
1163
1148
|
return Za(e, r);
|
|
1164
|
-
case
|
|
1165
|
-
return
|
|
1166
|
-
case
|
|
1167
|
-
return
|
|
1168
|
-
case
|
|
1169
|
-
return
|
|
1170
|
-
case
|
|
1171
|
-
return
|
|
1172
|
-
case
|
|
1173
|
-
return
|
|
1174
|
-
case
|
|
1175
|
-
return
|
|
1176
|
-
case
|
|
1177
|
-
|
|
1178
|
-
case R.ZodOptional:
|
|
1179
|
-
return Ya(e, r);
|
|
1180
|
-
case R.ZodMap:
|
|
1149
|
+
case T.ZodBigInt:
|
|
1150
|
+
return Ca(e);
|
|
1151
|
+
case T.ZodBoolean:
|
|
1152
|
+
return Ia();
|
|
1153
|
+
case T.ZodDate:
|
|
1154
|
+
return ur(e, r);
|
|
1155
|
+
case T.ZodUndefined:
|
|
1156
|
+
return Ha();
|
|
1157
|
+
case T.ZodNull:
|
|
1158
|
+
return La();
|
|
1159
|
+
case T.ZodArray:
|
|
1160
|
+
return Ea(e, r);
|
|
1161
|
+
case T.ZodUnion:
|
|
1162
|
+
case T.ZodDiscriminatedUnion:
|
|
1181
1163
|
return Fa(e, r);
|
|
1182
|
-
case
|
|
1183
|
-
return Qa(e, r);
|
|
1184
|
-
case R.ZodLazy:
|
|
1185
|
-
return () => e.getter()._def;
|
|
1186
|
-
case R.ZodPromise:
|
|
1187
|
-
return Ga(e, r);
|
|
1188
|
-
case R.ZodNaN:
|
|
1189
|
-
case R.ZodNever:
|
|
1190
|
-
return Ua();
|
|
1191
|
-
case R.ZodEffects:
|
|
1192
|
-
return Pa(e, r);
|
|
1193
|
-
case R.ZodAny:
|
|
1194
|
-
return Y();
|
|
1195
|
-
case R.ZodUnknown:
|
|
1196
|
-
return ts();
|
|
1197
|
-
case R.ZodDefault:
|
|
1164
|
+
case T.ZodIntersection:
|
|
1198
1165
|
return Ra(e, r);
|
|
1199
|
-
case
|
|
1200
|
-
return
|
|
1201
|
-
case
|
|
1202
|
-
return
|
|
1203
|
-
case
|
|
1204
|
-
return
|
|
1205
|
-
case
|
|
1206
|
-
return
|
|
1207
|
-
case
|
|
1208
|
-
|
|
1209
|
-
case
|
|
1166
|
+
case T.ZodTuple:
|
|
1167
|
+
return Ya(e, r);
|
|
1168
|
+
case T.ZodRecord:
|
|
1169
|
+
return dr(e, r);
|
|
1170
|
+
case T.ZodLiteral:
|
|
1171
|
+
return Pa(e);
|
|
1172
|
+
case T.ZodEnum:
|
|
1173
|
+
return Ma(e);
|
|
1174
|
+
case T.ZodNativeEnum:
|
|
1175
|
+
return Da(e);
|
|
1176
|
+
case T.ZodNullable:
|
|
1177
|
+
return Ua(e, r);
|
|
1178
|
+
case T.ZodOptional:
|
|
1179
|
+
return Ba(e, r);
|
|
1180
|
+
case T.ZodMap:
|
|
1181
|
+
return ja(e, r);
|
|
1182
|
+
case T.ZodSet:
|
|
1183
|
+
return Ka(e, r);
|
|
1184
|
+
case T.ZodLazy:
|
|
1185
|
+
return () => e.getter()._def;
|
|
1186
|
+
case T.ZodPromise:
|
|
1187
|
+
return Ja(e, r);
|
|
1188
|
+
case T.ZodNaN:
|
|
1189
|
+
case T.ZodNever:
|
|
1190
|
+
return ka();
|
|
1191
|
+
case T.ZodEffects:
|
|
1192
|
+
return Aa(e, r);
|
|
1193
|
+
case T.ZodAny:
|
|
1194
|
+
return J();
|
|
1195
|
+
case T.ZodUnknown:
|
|
1196
|
+
return Ga();
|
|
1197
|
+
case T.ZodDefault:
|
|
1198
|
+
return xa(e, r);
|
|
1199
|
+
case T.ZodBranded:
|
|
1200
|
+
return lr(e, r);
|
|
1201
|
+
case T.ZodReadonly:
|
|
1202
|
+
return Qa(e, r);
|
|
1203
|
+
case T.ZodCatch:
|
|
1204
|
+
return wa(e, r);
|
|
1205
|
+
case T.ZodPipeline:
|
|
1206
|
+
return Va(e, r);
|
|
1207
|
+
case T.ZodFunction:
|
|
1208
|
+
case T.ZodVoid:
|
|
1209
|
+
case T.ZodSymbol:
|
|
1210
1210
|
return;
|
|
1211
1211
|
default:
|
|
1212
1212
|
return /* @__PURE__ */ ((a) => {
|
|
1213
1213
|
})();
|
|
1214
1214
|
}
|
|
1215
|
-
},
|
|
1215
|
+
}, es = (e, t) => {
|
|
1216
1216
|
let r = 0;
|
|
1217
1217
|
for (; r < e.length && r < t.length && e[r] === t[r]; r++)
|
|
1218
1218
|
;
|
|
1219
1219
|
return [(e.length - r).toString(), ...t.slice(r)].join("/");
|
|
1220
1220
|
};
|
|
1221
|
-
function
|
|
1221
|
+
function O(e, t, r = !1) {
|
|
1222
1222
|
var a;
|
|
1223
1223
|
const s = t.seen.get(e);
|
|
1224
1224
|
if (t.override) {
|
|
@@ -1229,39 +1229,39 @@ function N(e, t, r = !1) {
|
|
|
1229
1229
|
s,
|
|
1230
1230
|
r
|
|
1231
1231
|
);
|
|
1232
|
-
if (f !==
|
|
1232
|
+
if (f !== ba)
|
|
1233
1233
|
return f;
|
|
1234
1234
|
}
|
|
1235
1235
|
if (s && !r) {
|
|
1236
|
-
const f =
|
|
1236
|
+
const f = ts(s, t);
|
|
1237
1237
|
if (f !== void 0)
|
|
1238
1238
|
return f;
|
|
1239
1239
|
}
|
|
1240
1240
|
const i = { def: e, path: t.currentPath, jsonSchema: void 0 };
|
|
1241
1241
|
t.seen.set(e, i);
|
|
1242
|
-
const l =
|
|
1243
|
-
if (n &&
|
|
1242
|
+
const l = Xa(e, e.typeName, t), n = typeof l == "function" ? O(l(), t) : l;
|
|
1243
|
+
if (n && rs(e, t, n), t.postProcess) {
|
|
1244
1244
|
const f = t.postProcess(n, e, t);
|
|
1245
1245
|
return i.jsonSchema = n, f;
|
|
1246
1246
|
}
|
|
1247
1247
|
return i.jsonSchema = n, n;
|
|
1248
1248
|
}
|
|
1249
|
-
var
|
|
1249
|
+
var ts = (e, t) => {
|
|
1250
1250
|
switch (t.$refStrategy) {
|
|
1251
1251
|
case "root":
|
|
1252
1252
|
return { $ref: e.path.join("/") };
|
|
1253
1253
|
case "relative":
|
|
1254
|
-
return { $ref:
|
|
1254
|
+
return { $ref: es(t.currentPath, e.path) };
|
|
1255
1255
|
case "none":
|
|
1256
1256
|
case "seen":
|
|
1257
1257
|
return e.path.length < t.currentPath.length && e.path.every((r, a) => t.currentPath[a] === r) ? (console.warn(
|
|
1258
1258
|
`Recursive reference detected at ${t.currentPath.join(
|
|
1259
1259
|
"/"
|
|
1260
1260
|
)}! Defaulting to any`
|
|
1261
|
-
),
|
|
1261
|
+
), J()) : t.$refStrategy === "seen" ? J() : void 0;
|
|
1262
1262
|
}
|
|
1263
|
-
},
|
|
1264
|
-
const t =
|
|
1263
|
+
}, rs = (e, t, r) => (e.description && (r.description = e.description), r), as = (e) => {
|
|
1264
|
+
const t = Sa(e), r = t.name !== void 0 ? [...t.basePath, t.definitionPath, t.name] : t.basePath;
|
|
1265
1265
|
return {
|
|
1266
1266
|
...t,
|
|
1267
1267
|
currentPath: r,
|
|
@@ -1278,34 +1278,34 @@ var ns = (e, t) => {
|
|
|
1278
1278
|
])
|
|
1279
1279
|
)
|
|
1280
1280
|
};
|
|
1281
|
-
},
|
|
1281
|
+
}, ss = (e, t) => {
|
|
1282
1282
|
var r;
|
|
1283
|
-
const a =
|
|
1283
|
+
const a = as(t);
|
|
1284
1284
|
let s = typeof t == "object" && t.definitions ? Object.entries(t.definitions).reduce(
|
|
1285
1285
|
(u, [c, p]) => {
|
|
1286
1286
|
var v;
|
|
1287
1287
|
return {
|
|
1288
1288
|
...u,
|
|
1289
|
-
[c]: (v =
|
|
1289
|
+
[c]: (v = O(
|
|
1290
1290
|
p._def,
|
|
1291
1291
|
{
|
|
1292
1292
|
...a,
|
|
1293
1293
|
currentPath: [...a.basePath, a.definitionPath, c]
|
|
1294
1294
|
},
|
|
1295
1295
|
!0
|
|
1296
|
-
)) != null ? v :
|
|
1296
|
+
)) != null ? v : J()
|
|
1297
1297
|
};
|
|
1298
1298
|
},
|
|
1299
1299
|
{}
|
|
1300
1300
|
) : void 0;
|
|
1301
|
-
const i = typeof t == "string" ? t : (t == null ? void 0 : t.nameStrategy) === "title" || t == null ? void 0 : t.name, l = (r =
|
|
1301
|
+
const i = typeof t == "string" ? t : (t == null ? void 0 : t.nameStrategy) === "title" || t == null ? void 0 : t.name, l = (r = O(
|
|
1302
1302
|
e._def,
|
|
1303
1303
|
i === void 0 ? a : {
|
|
1304
1304
|
...a,
|
|
1305
1305
|
currentPath: [...a.basePath, a.definitionPath, i]
|
|
1306
1306
|
},
|
|
1307
1307
|
!1
|
|
1308
|
-
)) != null ? r :
|
|
1308
|
+
)) != null ? r : J(), n = typeof t == "object" && t.name !== void 0 && t.nameStrategy === "title" ? t.name : void 0;
|
|
1309
1309
|
n !== void 0 && (l.title = n);
|
|
1310
1310
|
const f = i === void 0 ? s ? {
|
|
1311
1311
|
...l,
|
|
@@ -1322,16 +1322,16 @@ var ns = (e, t) => {
|
|
|
1322
1322
|
}
|
|
1323
1323
|
};
|
|
1324
1324
|
return f.$schema = "http://json-schema.org/draft-07/schema#", f;
|
|
1325
|
-
},
|
|
1326
|
-
function
|
|
1325
|
+
}, ct = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
|
|
1326
|
+
function ns(e) {
|
|
1327
1327
|
let t;
|
|
1328
1328
|
return () => (t == null && (t = e()), t);
|
|
1329
1329
|
}
|
|
1330
|
-
function
|
|
1330
|
+
function Ge(e, {
|
|
1331
1331
|
validate: t
|
|
1332
1332
|
} = {}) {
|
|
1333
1333
|
return {
|
|
1334
|
-
[
|
|
1334
|
+
[ct]: !0,
|
|
1335
1335
|
_type: void 0,
|
|
1336
1336
|
// should never be used directly
|
|
1337
1337
|
get jsonSchema() {
|
|
@@ -1340,24 +1340,24 @@ function Qe(e, {
|
|
|
1340
1340
|
validate: t
|
|
1341
1341
|
};
|
|
1342
1342
|
}
|
|
1343
|
-
function
|
|
1344
|
-
return typeof e == "object" && e !== null &&
|
|
1343
|
+
function is(e) {
|
|
1344
|
+
return typeof e == "object" && e !== null && ct in e && e[ct] === !0 && "jsonSchema" in e && "validate" in e;
|
|
1345
1345
|
}
|
|
1346
|
-
function
|
|
1347
|
-
return e == null ?
|
|
1346
|
+
function ht(e) {
|
|
1347
|
+
return e == null ? Ge({
|
|
1348
1348
|
type: "object",
|
|
1349
1349
|
properties: {},
|
|
1350
1350
|
additionalProperties: !1
|
|
1351
|
-
}) :
|
|
1351
|
+
}) : is(e) ? e : "~standard" in e ? e["~standard"].vendor === "zod" ? pr(e) : os(e) : e();
|
|
1352
1352
|
}
|
|
1353
|
-
function
|
|
1354
|
-
return
|
|
1353
|
+
function os(e) {
|
|
1354
|
+
return Ge(
|
|
1355
1355
|
() => {
|
|
1356
|
-
if (!
|
|
1356
|
+
if (!ls(e))
|
|
1357
1357
|
throw new Error(
|
|
1358
1358
|
`Standard schema vendor '${e["~standard"].vendor}' does not support JSON Schema conversion.`
|
|
1359
1359
|
);
|
|
1360
|
-
return
|
|
1360
|
+
return gt(
|
|
1361
1361
|
e["~standard"].jsonSchema.input({
|
|
1362
1362
|
target: "draft-07"
|
|
1363
1363
|
})
|
|
@@ -1368,7 +1368,7 @@ function ds(e) {
|
|
|
1368
1368
|
const r = await e["~standard"].validate(t);
|
|
1369
1369
|
return "value" in r ? { success: !0, value: r.value } : {
|
|
1370
1370
|
success: !1,
|
|
1371
|
-
error: new
|
|
1371
|
+
error: new Ae({
|
|
1372
1372
|
value: t,
|
|
1373
1373
|
cause: r.issues
|
|
1374
1374
|
})
|
|
@@ -1377,15 +1377,15 @@ function ds(e) {
|
|
|
1377
1377
|
}
|
|
1378
1378
|
);
|
|
1379
1379
|
}
|
|
1380
|
-
function
|
|
1380
|
+
function ls(e) {
|
|
1381
1381
|
return e["~standard"].jsonSchema != null;
|
|
1382
1382
|
}
|
|
1383
|
-
function
|
|
1383
|
+
function us(e, t) {
|
|
1384
1384
|
var r;
|
|
1385
1385
|
const a = (r = void 0) != null ? r : !1;
|
|
1386
|
-
return
|
|
1386
|
+
return Ge(
|
|
1387
1387
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
1388
|
-
() =>
|
|
1388
|
+
() => ss(e, {
|
|
1389
1389
|
$refStrategy: a ? "root" : "none"
|
|
1390
1390
|
}),
|
|
1391
1391
|
{
|
|
@@ -1396,13 +1396,13 @@ function fs(e, t) {
|
|
|
1396
1396
|
}
|
|
1397
1397
|
);
|
|
1398
1398
|
}
|
|
1399
|
-
function
|
|
1399
|
+
function cs(e, t) {
|
|
1400
1400
|
var r;
|
|
1401
1401
|
const a = (r = void 0) != null ? r : !1;
|
|
1402
|
-
return
|
|
1402
|
+
return Ge(
|
|
1403
1403
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
1404
|
-
() =>
|
|
1405
|
-
|
|
1404
|
+
() => gt(
|
|
1405
|
+
At.toJSONSchema(e, {
|
|
1406
1406
|
target: "draft-7",
|
|
1407
1407
|
io: "input",
|
|
1408
1408
|
reused: a ? "ref" : "inline"
|
|
@@ -1410,26 +1410,26 @@ function ms(e, t) {
|
|
|
1410
1410
|
),
|
|
1411
1411
|
{
|
|
1412
1412
|
validate: async (s) => {
|
|
1413
|
-
const i = await
|
|
1413
|
+
const i = await At.safeParseAsync(e, s);
|
|
1414
1414
|
return i.success ? { success: !0, value: i.data } : { success: !1, error: i.error };
|
|
1415
1415
|
}
|
|
1416
1416
|
}
|
|
1417
1417
|
);
|
|
1418
1418
|
}
|
|
1419
|
-
function
|
|
1419
|
+
function ds(e) {
|
|
1420
1420
|
return "_zod" in e;
|
|
1421
1421
|
}
|
|
1422
|
-
function
|
|
1423
|
-
return
|
|
1422
|
+
function pr(e, t) {
|
|
1423
|
+
return ds(e) ? cs(e) : us(e);
|
|
1424
1424
|
}
|
|
1425
|
-
async function
|
|
1425
|
+
async function zt({
|
|
1426
1426
|
value: e,
|
|
1427
1427
|
schema: t,
|
|
1428
1428
|
context: r
|
|
1429
1429
|
}) {
|
|
1430
1430
|
const a = await Le({ value: e, schema: t, context: r });
|
|
1431
1431
|
if (!a.success)
|
|
1432
|
-
throw
|
|
1432
|
+
throw Ae.wrap({ value: e, cause: a.error, context: r });
|
|
1433
1433
|
return a.value;
|
|
1434
1434
|
}
|
|
1435
1435
|
async function Le({
|
|
@@ -1437,20 +1437,20 @@ async function Le({
|
|
|
1437
1437
|
schema: t,
|
|
1438
1438
|
context: r
|
|
1439
1439
|
}) {
|
|
1440
|
-
const a =
|
|
1440
|
+
const a = ht(t);
|
|
1441
1441
|
try {
|
|
1442
1442
|
if (a.validate == null)
|
|
1443
1443
|
return { success: !0, value: e, rawValue: e };
|
|
1444
1444
|
const s = await a.validate(e);
|
|
1445
1445
|
return s.success ? { success: !0, value: s.value, rawValue: e } : {
|
|
1446
1446
|
success: !1,
|
|
1447
|
-
error:
|
|
1447
|
+
error: Ae.wrap({ value: e, cause: s.error, context: r }),
|
|
1448
1448
|
rawValue: e
|
|
1449
1449
|
};
|
|
1450
1450
|
} catch (s) {
|
|
1451
1451
|
return {
|
|
1452
1452
|
success: !1,
|
|
1453
|
-
error:
|
|
1453
|
+
error: Ae.wrap({ value: e, cause: s, context: r }),
|
|
1454
1454
|
rawValue: e
|
|
1455
1455
|
};
|
|
1456
1456
|
}
|
|
@@ -1460,21 +1460,21 @@ async function ye({
|
|
|
1460
1460
|
schema: t
|
|
1461
1461
|
}) {
|
|
1462
1462
|
try {
|
|
1463
|
-
const r =
|
|
1463
|
+
const r = ya(e);
|
|
1464
1464
|
return t == null ? { success: !0, value: r, rawValue: r } : await Le({ value: r, schema: t });
|
|
1465
1465
|
} catch (r) {
|
|
1466
1466
|
return {
|
|
1467
1467
|
success: !1,
|
|
1468
|
-
error:
|
|
1468
|
+
error: jt.isInstance(r) ? r : new jt({ text: e, cause: r }),
|
|
1469
1469
|
rawValue: void 0
|
|
1470
1470
|
};
|
|
1471
1471
|
}
|
|
1472
1472
|
}
|
|
1473
|
-
function
|
|
1473
|
+
function ps({
|
|
1474
1474
|
stream: e,
|
|
1475
1475
|
schema: t
|
|
1476
1476
|
}) {
|
|
1477
|
-
return e.pipeThrough(new TextDecoderStream()).pipeThrough(new
|
|
1477
|
+
return e.pipeThrough(new TextDecoderStream()).pipeThrough(new pa()).pipeThrough(
|
|
1478
1478
|
new TransformStream({
|
|
1479
1479
|
async transform({ data: r }, a) {
|
|
1480
1480
|
r !== "[DONE]" && a.enqueue(await ye({ text: r, schema: t }));
|
|
@@ -1482,17 +1482,17 @@ function hs({
|
|
|
1482
1482
|
})
|
|
1483
1483
|
);
|
|
1484
1484
|
}
|
|
1485
|
-
async function
|
|
1485
|
+
async function pe(e) {
|
|
1486
1486
|
return typeof e == "function" && (e = e()), Promise.resolve(e);
|
|
1487
1487
|
}
|
|
1488
1488
|
new TextDecoder();
|
|
1489
|
-
function
|
|
1489
|
+
function fs(e) {
|
|
1490
1490
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
1491
1491
|
}
|
|
1492
|
-
var
|
|
1492
|
+
var ms = Object.defineProperty, gs = (e, t) => {
|
|
1493
1493
|
for (var r in t)
|
|
1494
|
-
|
|
1495
|
-
},
|
|
1494
|
+
ms(e, r, { get: t[r], enumerable: !0 });
|
|
1495
|
+
}, fr = "AI_NoObjectGeneratedError", mr = `vercel.ai.error.${fr}`, hs = Symbol.for(mr), gr, fe = class extends ae {
|
|
1496
1496
|
constructor({
|
|
1497
1497
|
message: e = "No object generated.",
|
|
1498
1498
|
cause: t,
|
|
@@ -1501,26 +1501,26 @@ var ys = Object.defineProperty, bs = (e, t) => {
|
|
|
1501
1501
|
usage: s,
|
|
1502
1502
|
finishReason: i
|
|
1503
1503
|
}) {
|
|
1504
|
-
super({ name:
|
|
1504
|
+
super({ name: fr, message: e, cause: t }), this[gr] = !0, this.text = r, this.response = a, this.usage = s, this.finishReason = i;
|
|
1505
1505
|
}
|
|
1506
1506
|
static isInstance(e) {
|
|
1507
|
-
return
|
|
1507
|
+
return ae.hasMarker(e, mr);
|
|
1508
1508
|
}
|
|
1509
1509
|
};
|
|
1510
|
-
|
|
1511
|
-
var
|
|
1510
|
+
gr = hs;
|
|
1511
|
+
var hr = "AI_UIMessageStreamError", vr = `vercel.ai.error.${hr}`, vs = Symbol.for(vr), yr, ve = class extends ae {
|
|
1512
1512
|
constructor({
|
|
1513
1513
|
chunkType: e,
|
|
1514
1514
|
chunkId: t,
|
|
1515
1515
|
message: r
|
|
1516
1516
|
}) {
|
|
1517
|
-
super({ name:
|
|
1517
|
+
super({ name: hr, message: r }), this[yr] = !0, this.chunkType = e, this.chunkId = t;
|
|
1518
1518
|
}
|
|
1519
1519
|
static isInstance(e) {
|
|
1520
|
-
return
|
|
1520
|
+
return ae.hasMarker(e, vr);
|
|
1521
1521
|
}
|
|
1522
1522
|
};
|
|
1523
|
-
|
|
1523
|
+
yr = vs;
|
|
1524
1524
|
var be = o.lazy(
|
|
1525
1525
|
() => o.union([
|
|
1526
1526
|
o.null(),
|
|
@@ -1537,67 +1537,67 @@ var be = o.lazy(
|
|
|
1537
1537
|
o.string(),
|
|
1538
1538
|
o.instanceof(Uint8Array),
|
|
1539
1539
|
o.instanceof(ArrayBuffer),
|
|
1540
|
-
o.custom(
|
|
1541
|
-
]),
|
|
1540
|
+
o.custom(ma, { message: "Must be a Buffer" })
|
|
1541
|
+
]), vt = o.record(o.string(), o.string()), br = o.object({
|
|
1542
1542
|
type: o.literal("text"),
|
|
1543
1543
|
text: o.string(),
|
|
1544
1544
|
providerOptions: A.optional()
|
|
1545
|
-
}),
|
|
1545
|
+
}), ys = o.object({
|
|
1546
1546
|
type: o.literal("image"),
|
|
1547
1547
|
image: o.union([
|
|
1548
1548
|
Ue,
|
|
1549
1549
|
o.instanceof(URL),
|
|
1550
|
-
|
|
1550
|
+
vt
|
|
1551
1551
|
]),
|
|
1552
1552
|
mediaType: o.string().optional(),
|
|
1553
1553
|
providerOptions: A.optional()
|
|
1554
|
-
}),
|
|
1554
|
+
}), Sr = o.discriminatedUnion("type", [
|
|
1555
1555
|
o.object({ type: o.literal("data"), data: Ue }),
|
|
1556
1556
|
o.object({ type: o.literal("url"), url: o.instanceof(URL) }),
|
|
1557
1557
|
o.object({
|
|
1558
1558
|
type: o.literal("reference"),
|
|
1559
|
-
reference:
|
|
1559
|
+
reference: vt
|
|
1560
1560
|
}),
|
|
1561
1561
|
o.object({ type: o.literal("text"), text: o.string() })
|
|
1562
|
-
]),
|
|
1562
|
+
]), bs = o.discriminatedUnion("type", [
|
|
1563
1563
|
o.object({ type: o.literal("data"), data: Ue }),
|
|
1564
1564
|
o.object({ type: o.literal("url"), url: o.instanceof(URL) })
|
|
1565
|
-
]),
|
|
1565
|
+
]), Er = o.object({
|
|
1566
1566
|
type: o.literal("file"),
|
|
1567
1567
|
data: o.union([
|
|
1568
|
-
|
|
1568
|
+
Sr,
|
|
1569
1569
|
Ue,
|
|
1570
1570
|
o.instanceof(URL),
|
|
1571
|
-
|
|
1571
|
+
vt
|
|
1572
1572
|
]),
|
|
1573
1573
|
filename: o.string().optional(),
|
|
1574
1574
|
mediaType: o.string(),
|
|
1575
1575
|
providerOptions: A.optional()
|
|
1576
|
-
}),
|
|
1576
|
+
}), Ss = o.object({
|
|
1577
1577
|
type: o.literal("reasoning"),
|
|
1578
1578
|
text: o.string(),
|
|
1579
1579
|
providerOptions: A.optional()
|
|
1580
|
-
}),
|
|
1580
|
+
}), Es = o.object({
|
|
1581
1581
|
type: o.literal("custom"),
|
|
1582
1582
|
kind: o.string().transform((e) => e),
|
|
1583
1583
|
providerOptions: A.optional()
|
|
1584
|
-
}),
|
|
1584
|
+
}), Cs = o.object({
|
|
1585
1585
|
type: o.literal("reasoning-file"),
|
|
1586
1586
|
data: o.union([
|
|
1587
|
-
|
|
1587
|
+
bs,
|
|
1588
1588
|
Ue,
|
|
1589
1589
|
o.instanceof(URL)
|
|
1590
1590
|
]),
|
|
1591
1591
|
mediaType: o.string(),
|
|
1592
1592
|
providerOptions: A.optional()
|
|
1593
|
-
}),
|
|
1593
|
+
}), Is = o.object({
|
|
1594
1594
|
type: o.literal("tool-call"),
|
|
1595
1595
|
toolCallId: o.string(),
|
|
1596
1596
|
toolName: o.string(),
|
|
1597
1597
|
input: o.unknown(),
|
|
1598
1598
|
providerOptions: A.optional(),
|
|
1599
1599
|
providerExecuted: o.boolean().optional()
|
|
1600
|
-
}),
|
|
1600
|
+
}), ws = o.discriminatedUnion(
|
|
1601
1601
|
"type",
|
|
1602
1602
|
[
|
|
1603
1603
|
o.object({
|
|
@@ -1636,7 +1636,7 @@ var be = o.lazy(
|
|
|
1636
1636
|
}),
|
|
1637
1637
|
o.object({
|
|
1638
1638
|
type: o.literal("file"),
|
|
1639
|
-
data:
|
|
1639
|
+
data: Sr,
|
|
1640
1640
|
mediaType: o.string(),
|
|
1641
1641
|
filename: o.string().optional(),
|
|
1642
1642
|
providerOptions: A.optional()
|
|
@@ -1701,64 +1701,64 @@ var be = o.lazy(
|
|
|
1701
1701
|
)
|
|
1702
1702
|
})
|
|
1703
1703
|
]
|
|
1704
|
-
),
|
|
1704
|
+
), Cr = o.object({
|
|
1705
1705
|
type: o.literal("tool-result"),
|
|
1706
1706
|
toolCallId: o.string(),
|
|
1707
1707
|
toolName: o.string(),
|
|
1708
|
-
output:
|
|
1708
|
+
output: ws,
|
|
1709
1709
|
providerOptions: A.optional()
|
|
1710
|
-
}),
|
|
1710
|
+
}), _s = o.object({
|
|
1711
1711
|
type: o.literal("tool-approval-request"),
|
|
1712
1712
|
approvalId: o.string(),
|
|
1713
1713
|
toolCallId: o.string()
|
|
1714
|
-
}),
|
|
1714
|
+
}), xs = o.object({
|
|
1715
1715
|
type: o.literal("tool-approval-response"),
|
|
1716
1716
|
approvalId: o.string(),
|
|
1717
1717
|
approved: o.boolean(),
|
|
1718
1718
|
reason: o.string().optional()
|
|
1719
|
-
}),
|
|
1719
|
+
}), As = o.object(
|
|
1720
1720
|
{
|
|
1721
1721
|
role: o.literal("system"),
|
|
1722
1722
|
content: o.string(),
|
|
1723
1723
|
providerOptions: A.optional()
|
|
1724
1724
|
}
|
|
1725
|
-
),
|
|
1725
|
+
), Ms = o.object({
|
|
1726
1726
|
role: o.literal("user"),
|
|
1727
1727
|
content: o.union([
|
|
1728
1728
|
o.string(),
|
|
1729
|
-
o.array(o.union([
|
|
1729
|
+
o.array(o.union([br, ys, Er]))
|
|
1730
1730
|
]),
|
|
1731
1731
|
providerOptions: A.optional()
|
|
1732
|
-
}),
|
|
1732
|
+
}), Ts = o.object({
|
|
1733
1733
|
role: o.literal("assistant"),
|
|
1734
1734
|
content: o.union([
|
|
1735
1735
|
o.string(),
|
|
1736
1736
|
o.array(
|
|
1737
1737
|
o.union([
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1738
|
+
br,
|
|
1739
|
+
Es,
|
|
1740
|
+
Er,
|
|
1741
|
+
Ss,
|
|
1742
|
+
Cs,
|
|
1743
|
+
Is,
|
|
1744
|
+
Cr,
|
|
1745
|
+
_s
|
|
1746
1746
|
])
|
|
1747
1747
|
)
|
|
1748
1748
|
]),
|
|
1749
1749
|
providerOptions: A.optional()
|
|
1750
|
-
}),
|
|
1750
|
+
}), Rs = o.object({
|
|
1751
1751
|
role: o.literal("tool"),
|
|
1752
|
-
content: o.array(o.union([
|
|
1752
|
+
content: o.array(o.union([Cr, xs])),
|
|
1753
1753
|
providerOptions: A.optional()
|
|
1754
1754
|
});
|
|
1755
1755
|
o.union([
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1756
|
+
As,
|
|
1757
|
+
Ms,
|
|
1758
|
+
Ts,
|
|
1759
|
+
Rs
|
|
1760
1760
|
]);
|
|
1761
|
-
function
|
|
1761
|
+
function Ir(e, t) {
|
|
1762
1762
|
if (e === void 0 && t === void 0)
|
|
1763
1763
|
return;
|
|
1764
1764
|
if (e === void 0)
|
|
@@ -1772,22 +1772,22 @@ function Ar(e, t) {
|
|
|
1772
1772
|
if (s === void 0)
|
|
1773
1773
|
continue;
|
|
1774
1774
|
const i = a in e ? e[a] : void 0, l = s !== null && typeof s == "object" && !Array.isArray(s) && !(s instanceof Date) && !(s instanceof RegExp), n = i != null && typeof i == "object" && !Array.isArray(i) && !(i instanceof Date) && !(i instanceof RegExp);
|
|
1775
|
-
l && n ? r[a] =
|
|
1775
|
+
l && n ? r[a] = Ir(
|
|
1776
1776
|
i,
|
|
1777
1777
|
s
|
|
1778
1778
|
) : r[a] = s;
|
|
1779
1779
|
}
|
|
1780
1780
|
return r;
|
|
1781
1781
|
}
|
|
1782
|
-
var
|
|
1783
|
-
|
|
1784
|
-
array: () =>
|
|
1785
|
-
choice: () =>
|
|
1786
|
-
json: () =>
|
|
1787
|
-
object: () =>
|
|
1788
|
-
text: () =>
|
|
1782
|
+
var Ps = {};
|
|
1783
|
+
gs(Ps, {
|
|
1784
|
+
array: () => Ds,
|
|
1785
|
+
choice: () => ks,
|
|
1786
|
+
json: () => Ls,
|
|
1787
|
+
object: () => js,
|
|
1788
|
+
text: () => Ns
|
|
1789
1789
|
});
|
|
1790
|
-
function
|
|
1790
|
+
function Os(e) {
|
|
1791
1791
|
const t = ["ROOT"];
|
|
1792
1792
|
let r = -1, a = null, s = 0;
|
|
1793
1793
|
function i(c) {
|
|
@@ -2046,9 +2046,9 @@ async function qe(e) {
|
|
|
2046
2046
|
if (e === void 0)
|
|
2047
2047
|
return { value: void 0, state: "undefined-input" };
|
|
2048
2048
|
let t = await ye({ text: e });
|
|
2049
|
-
return t.success ? { value: t.value, state: "successful-parse" } : (t = await ye({ text:
|
|
2049
|
+
return t.success ? { value: t.value, state: "successful-parse" } : (t = await ye({ text: Os(e) }), t.success ? { value: t.value, state: "repaired-parse" } : { value: void 0, state: "failed-parse" });
|
|
2050
2050
|
}
|
|
2051
|
-
var
|
|
2051
|
+
var Ns = () => ({
|
|
2052
2052
|
name: "text",
|
|
2053
2053
|
responseFormat: Promise.resolve({ type: "text" }),
|
|
2054
2054
|
async parseCompleteOutput({ text: e }) {
|
|
@@ -2059,15 +2059,15 @@ var Ls = () => ({
|
|
|
2059
2059
|
},
|
|
2060
2060
|
createElementStreamTransform() {
|
|
2061
2061
|
}
|
|
2062
|
-
}),
|
|
2062
|
+
}), js = ({
|
|
2063
2063
|
schema: e,
|
|
2064
2064
|
name: t,
|
|
2065
2065
|
description: r
|
|
2066
2066
|
}) => {
|
|
2067
|
-
const a =
|
|
2067
|
+
const a = ht(e);
|
|
2068
2068
|
return {
|
|
2069
2069
|
name: "object",
|
|
2070
|
-
responseFormat:
|
|
2070
|
+
responseFormat: pe(a.jsonSchema).then((s) => ({
|
|
2071
2071
|
type: "json",
|
|
2072
2072
|
schema: s,
|
|
2073
2073
|
...t != null && { name: t },
|
|
@@ -2076,7 +2076,7 @@ var Ls = () => ({
|
|
|
2076
2076
|
async parseCompleteOutput({ text: s }, i) {
|
|
2077
2077
|
const l = await ye({ text: s });
|
|
2078
2078
|
if (!l.success)
|
|
2079
|
-
throw new
|
|
2079
|
+
throw new fe({
|
|
2080
2080
|
message: "No object generated: could not parse the response.",
|
|
2081
2081
|
cause: l.error,
|
|
2082
2082
|
text: s,
|
|
@@ -2089,7 +2089,7 @@ var Ls = () => ({
|
|
|
2089
2089
|
schema: a
|
|
2090
2090
|
});
|
|
2091
2091
|
if (!n.success)
|
|
2092
|
-
throw new
|
|
2092
|
+
throw new fe({
|
|
2093
2093
|
message: "No object generated: response did not match schema.",
|
|
2094
2094
|
cause: n.error,
|
|
2095
2095
|
text: s,
|
|
@@ -2116,16 +2116,16 @@ var Ls = () => ({
|
|
|
2116
2116
|
createElementStreamTransform() {
|
|
2117
2117
|
}
|
|
2118
2118
|
};
|
|
2119
|
-
},
|
|
2119
|
+
}, Ds = ({
|
|
2120
2120
|
element: e,
|
|
2121
2121
|
name: t,
|
|
2122
2122
|
description: r
|
|
2123
2123
|
}) => {
|
|
2124
|
-
const a =
|
|
2124
|
+
const a = ht(e);
|
|
2125
2125
|
return {
|
|
2126
2126
|
name: "array",
|
|
2127
2127
|
// JSON schema that describes an array of elements:
|
|
2128
|
-
responseFormat:
|
|
2128
|
+
responseFormat: pe(a.jsonSchema).then((s) => {
|
|
2129
2129
|
const { $schema: i, ...l } = s;
|
|
2130
2130
|
return {
|
|
2131
2131
|
type: "json",
|
|
@@ -2145,7 +2145,7 @@ var Ls = () => ({
|
|
|
2145
2145
|
async parseCompleteOutput({ text: s }, i) {
|
|
2146
2146
|
const l = await ye({ text: s });
|
|
2147
2147
|
if (!l.success)
|
|
2148
|
-
throw new
|
|
2148
|
+
throw new fe({
|
|
2149
2149
|
message: "No object generated: could not parse the response.",
|
|
2150
2150
|
cause: l.error,
|
|
2151
2151
|
text: s,
|
|
@@ -2155,9 +2155,9 @@ var Ls = () => ({
|
|
|
2155
2155
|
});
|
|
2156
2156
|
const n = l.value;
|
|
2157
2157
|
if (n == null || typeof n != "object" || !("elements" in n) || !Array.isArray(n.elements))
|
|
2158
|
-
throw new
|
|
2158
|
+
throw new fe({
|
|
2159
2159
|
message: "No object generated: response did not match schema.",
|
|
2160
|
-
cause: new
|
|
2160
|
+
cause: new Ae({
|
|
2161
2161
|
value: n,
|
|
2162
2162
|
cause: "response must be an object with an elements array"
|
|
2163
2163
|
}),
|
|
@@ -2173,7 +2173,7 @@ var Ls = () => ({
|
|
|
2173
2173
|
schema: a
|
|
2174
2174
|
});
|
|
2175
2175
|
if (!c.success)
|
|
2176
|
-
throw new
|
|
2176
|
+
throw new fe({
|
|
2177
2177
|
message: "No object generated: response did not match schema.",
|
|
2178
2178
|
cause: c.error,
|
|
2179
2179
|
text: s,
|
|
@@ -2219,7 +2219,7 @@ var Ls = () => ({
|
|
|
2219
2219
|
});
|
|
2220
2220
|
}
|
|
2221
2221
|
};
|
|
2222
|
-
},
|
|
2222
|
+
}, ks = ({
|
|
2223
2223
|
options: e,
|
|
2224
2224
|
name: t,
|
|
2225
2225
|
description: r
|
|
@@ -2243,7 +2243,7 @@ var Ls = () => ({
|
|
|
2243
2243
|
async parseCompleteOutput({ text: a }, s) {
|
|
2244
2244
|
const i = await ye({ text: a });
|
|
2245
2245
|
if (!i.success)
|
|
2246
|
-
throw new
|
|
2246
|
+
throw new fe({
|
|
2247
2247
|
message: "No object generated: could not parse the response.",
|
|
2248
2248
|
cause: i.error,
|
|
2249
2249
|
text: a,
|
|
@@ -2253,9 +2253,9 @@ var Ls = () => ({
|
|
|
2253
2253
|
});
|
|
2254
2254
|
const l = i.value;
|
|
2255
2255
|
if (l == null || typeof l != "object" || !("result" in l) || typeof l.result != "string" || !e.includes(l.result))
|
|
2256
|
-
throw new
|
|
2256
|
+
throw new fe({
|
|
2257
2257
|
message: "No object generated: response did not match schema.",
|
|
2258
|
-
cause: new
|
|
2258
|
+
cause: new Ae({
|
|
2259
2259
|
value: l,
|
|
2260
2260
|
cause: "response must be an object that contains a choice value."
|
|
2261
2261
|
}),
|
|
@@ -2286,7 +2286,7 @@ var Ls = () => ({
|
|
|
2286
2286
|
},
|
|
2287
2287
|
createElementStreamTransform() {
|
|
2288
2288
|
}
|
|
2289
|
-
}),
|
|
2289
|
+
}), Ls = ({
|
|
2290
2290
|
name: e,
|
|
2291
2291
|
description: t
|
|
2292
2292
|
} = {}) => ({
|
|
@@ -2299,7 +2299,7 @@ var Ls = () => ({
|
|
|
2299
2299
|
async parseCompleteOutput({ text: r }, a) {
|
|
2300
2300
|
const s = await ye({ text: r });
|
|
2301
2301
|
if (!s.success)
|
|
2302
|
-
throw new
|
|
2302
|
+
throw new fe({
|
|
2303
2303
|
message: "No object generated: could not parse the response.",
|
|
2304
2304
|
cause: s.error,
|
|
2305
2305
|
text: r,
|
|
@@ -2325,11 +2325,11 @@ var Ls = () => ({
|
|
|
2325
2325
|
});
|
|
2326
2326
|
new TextEncoder();
|
|
2327
2327
|
new TextEncoder();
|
|
2328
|
-
|
|
2328
|
+
G({
|
|
2329
2329
|
prefix: "aitxt",
|
|
2330
2330
|
size: 24
|
|
2331
2331
|
});
|
|
2332
|
-
|
|
2332
|
+
G({
|
|
2333
2333
|
prefix: "call",
|
|
2334
2334
|
size: 24
|
|
2335
2335
|
});
|
|
@@ -2352,8 +2352,8 @@ Q({
|
|
|
2352
2352
|
var Pe = o.record(
|
|
2353
2353
|
o.string(),
|
|
2354
2354
|
be.optional()
|
|
2355
|
-
),
|
|
2356
|
-
() =>
|
|
2355
|
+
), Fs = ns(
|
|
2356
|
+
() => pr(
|
|
2357
2357
|
o.union([
|
|
2358
2358
|
o.strictObject({
|
|
2359
2359
|
type: o.literal("text-start"),
|
|
@@ -2542,28 +2542,28 @@ var Pe = o.record(
|
|
|
2542
2542
|
])
|
|
2543
2543
|
)
|
|
2544
2544
|
);
|
|
2545
|
-
function
|
|
2545
|
+
function $s(e) {
|
|
2546
2546
|
return e.type.startsWith("data-");
|
|
2547
2547
|
}
|
|
2548
2548
|
function ke() {
|
|
2549
2549
|
return /* @__PURE__ */ Object.create(null);
|
|
2550
2550
|
}
|
|
2551
|
-
function
|
|
2551
|
+
function dt(e) {
|
|
2552
2552
|
return e.type.startsWith("tool-");
|
|
2553
2553
|
}
|
|
2554
|
-
function
|
|
2554
|
+
function wr(e) {
|
|
2555
2555
|
return e.type === "dynamic-tool";
|
|
2556
2556
|
}
|
|
2557
|
-
function
|
|
2558
|
-
return
|
|
2557
|
+
function xe(e) {
|
|
2558
|
+
return dt(e) || wr(e);
|
|
2559
2559
|
}
|
|
2560
|
-
function
|
|
2560
|
+
function pt(e) {
|
|
2561
2561
|
return e.type.split("-").slice(1).join("-");
|
|
2562
2562
|
}
|
|
2563
|
-
function
|
|
2564
|
-
return
|
|
2563
|
+
function Us(e) {
|
|
2564
|
+
return wr(e) ? e.toolName : pt(e);
|
|
2565
2565
|
}
|
|
2566
|
-
function
|
|
2566
|
+
function qs({
|
|
2567
2567
|
lastMessage: e,
|
|
2568
2568
|
messageId: t
|
|
2569
2569
|
}) {
|
|
@@ -2579,7 +2579,7 @@ function Bs({
|
|
|
2579
2579
|
partialToolCalls: ke()
|
|
2580
2580
|
};
|
|
2581
2581
|
}
|
|
2582
|
-
function
|
|
2582
|
+
function Zs({
|
|
2583
2583
|
stream: e,
|
|
2584
2584
|
messageMetadataSchema: t,
|
|
2585
2585
|
dataPartSchemas: r,
|
|
@@ -2592,10 +2592,10 @@ function Vs({
|
|
|
2592
2592
|
new TransformStream({
|
|
2593
2593
|
async transform(n, f) {
|
|
2594
2594
|
await a(async ({ state: u, write: c }) => {
|
|
2595
|
-
var p, v, h,
|
|
2595
|
+
var p, v, h, _;
|
|
2596
2596
|
function M(d) {
|
|
2597
|
-
const m = u.message.parts.filter(
|
|
2598
|
-
(
|
|
2597
|
+
const m = u.message.parts.filter(xe).find(
|
|
2598
|
+
(b) => b.toolCallId === d
|
|
2599
2599
|
);
|
|
2600
2600
|
if (m == null)
|
|
2601
2601
|
throw new ve({
|
|
@@ -2606,10 +2606,10 @@ function Vs({
|
|
|
2606
2606
|
return m;
|
|
2607
2607
|
}
|
|
2608
2608
|
function E(d) {
|
|
2609
|
-
const m = u.message.parts.filter(
|
|
2610
|
-
(
|
|
2609
|
+
const m = u.message.parts.filter(xe).find(
|
|
2610
|
+
(b) => {
|
|
2611
2611
|
var y;
|
|
2612
|
-
return ((y =
|
|
2612
|
+
return ((y = b.approval) == null ? void 0 : y.id) === d;
|
|
2613
2613
|
}
|
|
2614
2614
|
);
|
|
2615
2615
|
if (m == null)
|
|
@@ -2623,17 +2623,17 @@ function Vs({
|
|
|
2623
2623
|
function C(d) {
|
|
2624
2624
|
var g;
|
|
2625
2625
|
const m = u.message.parts.find(
|
|
2626
|
-
(
|
|
2627
|
-
),
|
|
2626
|
+
(I) => dt(I) && I.toolCallId === d.toolCallId
|
|
2627
|
+
), b = d, y = m;
|
|
2628
2628
|
if (m != null) {
|
|
2629
|
-
m.state = d.state, y.input =
|
|
2630
|
-
const
|
|
2631
|
-
if (
|
|
2629
|
+
m.state = d.state, y.input = b.input, y.output = b.output, y.errorText = b.errorText, y.rawInput = b.rawInput, y.preliminary = b.preliminary, d.title !== void 0 && (y.title = d.title), d.toolMetadata !== void 0 && (y.toolMetadata = d.toolMetadata), y.providerExecuted = (g = b.providerExecuted) != null ? g : m.providerExecuted;
|
|
2630
|
+
const I = b.providerMetadata;
|
|
2631
|
+
if (I != null)
|
|
2632
2632
|
if (d.state === "output-available" || d.state === "output-error") {
|
|
2633
|
-
const
|
|
2634
|
-
|
|
2633
|
+
const k = m;
|
|
2634
|
+
k.resultProviderMetadata = I;
|
|
2635
2635
|
} else
|
|
2636
|
-
m.callProviderMetadata =
|
|
2636
|
+
m.callProviderMetadata = I;
|
|
2637
2637
|
} else
|
|
2638
2638
|
u.message.parts.push({
|
|
2639
2639
|
type: `tool-${d.toolName}`,
|
|
@@ -2641,30 +2641,30 @@ function Vs({
|
|
|
2641
2641
|
state: d.state,
|
|
2642
2642
|
title: d.title,
|
|
2643
2643
|
...d.toolMetadata !== void 0 ? { toolMetadata: d.toolMetadata } : {},
|
|
2644
|
-
input:
|
|
2645
|
-
output:
|
|
2646
|
-
rawInput:
|
|
2647
|
-
errorText:
|
|
2648
|
-
providerExecuted:
|
|
2649
|
-
preliminary:
|
|
2650
|
-
...
|
|
2651
|
-
...
|
|
2644
|
+
input: b.input,
|
|
2645
|
+
output: b.output,
|
|
2646
|
+
rawInput: b.rawInput,
|
|
2647
|
+
errorText: b.errorText,
|
|
2648
|
+
providerExecuted: b.providerExecuted,
|
|
2649
|
+
preliminary: b.preliminary,
|
|
2650
|
+
...b.providerMetadata != null && (d.state === "output-available" || d.state === "output-error") ? { resultProviderMetadata: b.providerMetadata } : {},
|
|
2651
|
+
...b.providerMetadata != null && !(d.state === "output-available" || d.state === "output-error") ? { callProviderMetadata: b.providerMetadata } : {}
|
|
2652
2652
|
});
|
|
2653
2653
|
}
|
|
2654
2654
|
function w(d) {
|
|
2655
2655
|
var g, m;
|
|
2656
|
-
const
|
|
2657
|
-
(
|
|
2658
|
-
), y = d,
|
|
2659
|
-
if (
|
|
2660
|
-
|
|
2661
|
-
const
|
|
2662
|
-
if (
|
|
2656
|
+
const b = u.message.parts.find(
|
|
2657
|
+
(k) => k.type === "dynamic-tool" && k.toolCallId === d.toolCallId
|
|
2658
|
+
), y = d, I = b;
|
|
2659
|
+
if (b != null) {
|
|
2660
|
+
b.state = d.state, I.toolName = d.toolName, I.input = y.input, I.output = y.output, I.errorText = y.errorText, I.rawInput = (g = y.rawInput) != null ? g : I.rawInput, I.preliminary = y.preliminary, d.title !== void 0 && (I.title = d.title), d.toolMetadata !== void 0 && (I.toolMetadata = d.toolMetadata), I.providerExecuted = (m = y.providerExecuted) != null ? m : b.providerExecuted;
|
|
2661
|
+
const k = y.providerMetadata;
|
|
2662
|
+
if (k != null)
|
|
2663
2663
|
if (d.state === "output-available" || d.state === "output-error") {
|
|
2664
|
-
const
|
|
2665
|
-
|
|
2664
|
+
const Y = b;
|
|
2665
|
+
Y.resultProviderMetadata = k;
|
|
2666
2666
|
} else
|
|
2667
|
-
|
|
2667
|
+
b.callProviderMetadata = k;
|
|
2668
2668
|
} else
|
|
2669
2669
|
u.message.parts.push({
|
|
2670
2670
|
type: "dynamic-tool",
|
|
@@ -2682,10 +2682,10 @@ function Vs({
|
|
|
2682
2682
|
...y.providerMetadata != null && !(d.state === "output-available" || d.state === "output-error") ? { callProviderMetadata: y.providerMetadata } : {}
|
|
2683
2683
|
});
|
|
2684
2684
|
}
|
|
2685
|
-
async function
|
|
2685
|
+
async function N(d) {
|
|
2686
2686
|
if (d != null) {
|
|
2687
|
-
const g = u.message.metadata != null ?
|
|
2688
|
-
t != null && await
|
|
2687
|
+
const g = u.message.metadata != null ? Ir(u.message.metadata, d) : d;
|
|
2688
|
+
t != null && await zt({
|
|
2689
2689
|
value: g,
|
|
2690
2690
|
schema: t,
|
|
2691
2691
|
context: {
|
|
@@ -2766,7 +2766,7 @@ function Vs({
|
|
|
2766
2766
|
chunkId: n.id,
|
|
2767
2767
|
message: `Received reasoning-end for missing reasoning part with ID "${n.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`
|
|
2768
2768
|
});
|
|
2769
|
-
d.providerMetadata = (
|
|
2769
|
+
d.providerMetadata = (_ = n.providerMetadata) != null ? _ : d.providerMetadata, d.state = "done", delete u.activeReasoningParts[n.id], c();
|
|
2770
2770
|
break;
|
|
2771
2771
|
}
|
|
2772
2772
|
case "file":
|
|
@@ -2801,7 +2801,7 @@ function Vs({
|
|
|
2801
2801
|
break;
|
|
2802
2802
|
}
|
|
2803
2803
|
case "tool-input-start": {
|
|
2804
|
-
const d = u.message.parts.filter(
|
|
2804
|
+
const d = u.message.parts.filter(dt);
|
|
2805
2805
|
u.partialToolCalls[n.toolCallId] = {
|
|
2806
2806
|
text: "",
|
|
2807
2807
|
toolName: n.toolName,
|
|
@@ -2884,7 +2884,7 @@ function Vs({
|
|
|
2884
2884
|
break;
|
|
2885
2885
|
}
|
|
2886
2886
|
case "tool-input-error": {
|
|
2887
|
-
const d = u.message.parts.filter(
|
|
2887
|
+
const d = u.message.parts.filter(xe).find((m) => m.toolCallId === n.toolCallId);
|
|
2888
2888
|
(d != null ? d.type === "dynamic-tool" : !!n.dynamic) ? w({
|
|
2889
2889
|
toolCallId: n.toolCallId,
|
|
2890
2890
|
toolName: n.toolName,
|
|
@@ -2949,7 +2949,7 @@ function Vs({
|
|
|
2949
2949
|
toolMetadata: d.toolMetadata
|
|
2950
2950
|
}) : C({
|
|
2951
2951
|
toolCallId: n.toolCallId,
|
|
2952
|
-
toolName:
|
|
2952
|
+
toolName: pt(d),
|
|
2953
2953
|
state: "output-available",
|
|
2954
2954
|
input: d.input,
|
|
2955
2955
|
output: n.output,
|
|
@@ -2975,7 +2975,7 @@ function Vs({
|
|
|
2975
2975
|
toolMetadata: d.toolMetadata
|
|
2976
2976
|
}) : C({
|
|
2977
2977
|
toolCallId: n.toolCallId,
|
|
2978
|
-
toolName:
|
|
2978
|
+
toolName: pt(d),
|
|
2979
2979
|
state: "output-error",
|
|
2980
2980
|
input: d.input,
|
|
2981
2981
|
rawInput: d.rawInput,
|
|
@@ -2996,15 +2996,15 @@ function Vs({
|
|
|
2996
2996
|
break;
|
|
2997
2997
|
}
|
|
2998
2998
|
case "start": {
|
|
2999
|
-
n.messageId != null && (u.message.id = n.messageId), await
|
|
2999
|
+
n.messageId != null && (u.message.id = n.messageId), await N(n.messageMetadata), (n.messageId != null || n.messageMetadata != null) && c();
|
|
3000
3000
|
break;
|
|
3001
3001
|
}
|
|
3002
3002
|
case "finish": {
|
|
3003
|
-
n.finishReason != null && (u.finishReason = n.finishReason), await
|
|
3003
|
+
n.finishReason != null && (u.finishReason = n.finishReason), await N(n.messageMetadata), n.messageMetadata != null && c();
|
|
3004
3004
|
break;
|
|
3005
3005
|
}
|
|
3006
3006
|
case "message-metadata": {
|
|
3007
|
-
await
|
|
3007
|
+
await N(n.messageMetadata), n.messageMetadata != null && c();
|
|
3008
3008
|
break;
|
|
3009
3009
|
}
|
|
3010
3010
|
case "error": {
|
|
@@ -3012,16 +3012,16 @@ function Vs({
|
|
|
3012
3012
|
break;
|
|
3013
3013
|
}
|
|
3014
3014
|
default:
|
|
3015
|
-
if (
|
|
3015
|
+
if ($s(n)) {
|
|
3016
3016
|
if ((r == null ? void 0 : r[n.type]) != null) {
|
|
3017
3017
|
const m = u.message.parts.findIndex(
|
|
3018
3018
|
(y) => "id" in y && "data" in y && y.id === n.id && y.type === n.type
|
|
3019
|
-
),
|
|
3020
|
-
await
|
|
3019
|
+
), b = m >= 0 ? m : u.message.parts.length;
|
|
3020
|
+
await zt({
|
|
3021
3021
|
value: n.data,
|
|
3022
3022
|
schema: r[n.type],
|
|
3023
3023
|
context: {
|
|
3024
|
-
field: `message.parts[${
|
|
3024
|
+
field: `message.parts[${b}].data`,
|
|
3025
3025
|
entityName: n.type,
|
|
3026
3026
|
entityId: n.id
|
|
3027
3027
|
}
|
|
@@ -3044,7 +3044,7 @@ function Vs({
|
|
|
3044
3044
|
})
|
|
3045
3045
|
);
|
|
3046
3046
|
}
|
|
3047
|
-
async function
|
|
3047
|
+
async function zs({
|
|
3048
3048
|
stream: e,
|
|
3049
3049
|
onError: t
|
|
3050
3050
|
}) {
|
|
@@ -3061,19 +3061,19 @@ async function Js({
|
|
|
3061
3061
|
r.releaseLock();
|
|
3062
3062
|
}
|
|
3063
3063
|
}
|
|
3064
|
-
|
|
3064
|
+
G({
|
|
3065
3065
|
prefix: "aitxt",
|
|
3066
3066
|
size: 24
|
|
3067
3067
|
});
|
|
3068
|
-
|
|
3068
|
+
G({
|
|
3069
3069
|
prefix: "call",
|
|
3070
3070
|
size: 24
|
|
3071
3071
|
});
|
|
3072
|
-
|
|
3072
|
+
G({
|
|
3073
3073
|
prefix: "aitxt",
|
|
3074
3074
|
size: 24
|
|
3075
3075
|
});
|
|
3076
|
-
|
|
3076
|
+
G({
|
|
3077
3077
|
prefix: "call",
|
|
3078
3078
|
size: 24
|
|
3079
3079
|
});
|
|
@@ -3082,16 +3082,16 @@ o.record(
|
|
|
3082
3082
|
be.optional()
|
|
3083
3083
|
);
|
|
3084
3084
|
o.record(o.string(), o.string());
|
|
3085
|
-
|
|
3085
|
+
G({
|
|
3086
3086
|
prefix: "call",
|
|
3087
3087
|
size: 24
|
|
3088
3088
|
});
|
|
3089
|
-
|
|
3089
|
+
G({
|
|
3090
3090
|
prefix: "call",
|
|
3091
3091
|
size: 24
|
|
3092
3092
|
});
|
|
3093
|
-
|
|
3094
|
-
var
|
|
3093
|
+
G({ prefix: "aiobj", size: 24 });
|
|
3094
|
+
var Ws = class {
|
|
3095
3095
|
constructor() {
|
|
3096
3096
|
this.queue = [], this.isProcessing = !1;
|
|
3097
3097
|
}
|
|
@@ -3114,12 +3114,12 @@ var Ks = class {
|
|
|
3114
3114
|
});
|
|
3115
3115
|
}
|
|
3116
3116
|
};
|
|
3117
|
-
|
|
3118
|
-
|
|
3117
|
+
G({ prefix: "aiobj", size: 24 });
|
|
3118
|
+
G({
|
|
3119
3119
|
prefix: "call",
|
|
3120
3120
|
size: 24
|
|
3121
3121
|
});
|
|
3122
|
-
async function
|
|
3122
|
+
async function Bs(e) {
|
|
3123
3123
|
if (e == null)
|
|
3124
3124
|
return [];
|
|
3125
3125
|
if (!globalThis.FileList || !(e instanceof globalThis.FileList))
|
|
@@ -3142,7 +3142,7 @@ async function Ys(e) {
|
|
|
3142
3142
|
})
|
|
3143
3143
|
);
|
|
3144
3144
|
}
|
|
3145
|
-
var
|
|
3145
|
+
var Vs = class {
|
|
3146
3146
|
constructor({
|
|
3147
3147
|
api: e = "/api/chat",
|
|
3148
3148
|
credentials: t,
|
|
@@ -3159,9 +3159,9 @@ var Hs = class {
|
|
|
3159
3159
|
...t
|
|
3160
3160
|
}) {
|
|
3161
3161
|
var r, a, s, i, l;
|
|
3162
|
-
const n = await
|
|
3163
|
-
...
|
|
3164
|
-
...
|
|
3162
|
+
const n = await pe(this.body), f = await pe(this.headers), u = await pe(this.credentials), c = {
|
|
3163
|
+
...Ie(f),
|
|
3164
|
+
...Ie(t.headers)
|
|
3165
3165
|
}, p = await ((r = this.prepareSendMessagesRequest) == null ? void 0 : r.call(this, {
|
|
3166
3166
|
api: this.api,
|
|
3167
3167
|
id: t.chatId,
|
|
@@ -3172,7 +3172,7 @@ var Hs = class {
|
|
|
3172
3172
|
requestMetadata: t.metadata,
|
|
3173
3173
|
trigger: t.trigger,
|
|
3174
3174
|
messageId: t.messageId
|
|
3175
|
-
})), v = (a = p == null ? void 0 : p.api) != null ? a : this.api, h = (p == null ? void 0 : p.headers) !== void 0 ?
|
|
3175
|
+
})), v = (a = p == null ? void 0 : p.api) != null ? a : this.api, h = (p == null ? void 0 : p.headers) !== void 0 ? Ie(p.headers) : c, _ = (p == null ? void 0 : p.body) !== void 0 ? p.body : {
|
|
3176
3176
|
...n,
|
|
3177
3177
|
...t.body,
|
|
3178
3178
|
id: t.chatId,
|
|
@@ -3185,7 +3185,7 @@ var Hs = class {
|
|
|
3185
3185
|
"Content-Type": "application/json",
|
|
3186
3186
|
...h
|
|
3187
3187
|
},
|
|
3188
|
-
body: JSON.stringify(
|
|
3188
|
+
body: JSON.stringify(_),
|
|
3189
3189
|
credentials: M,
|
|
3190
3190
|
signal: e
|
|
3191
3191
|
});
|
|
@@ -3199,9 +3199,9 @@ var Hs = class {
|
|
|
3199
3199
|
}
|
|
3200
3200
|
async reconnectToStream(e) {
|
|
3201
3201
|
var t, r, a, s, i;
|
|
3202
|
-
const l = await
|
|
3203
|
-
...
|
|
3204
|
-
...
|
|
3202
|
+
const l = await pe(this.body), n = await pe(this.headers), f = await pe(this.credentials), u = {
|
|
3203
|
+
...Ie(n),
|
|
3204
|
+
...Ie(e.headers)
|
|
3205
3205
|
}, c = await ((t = this.prepareReconnectToStreamRequest) == null ? void 0 : t.call(this, {
|
|
3206
3206
|
api: this.api,
|
|
3207
3207
|
id: e.chatId,
|
|
@@ -3209,7 +3209,7 @@ var Hs = class {
|
|
|
3209
3209
|
headers: u,
|
|
3210
3210
|
credentials: f,
|
|
3211
3211
|
requestMetadata: e.metadata
|
|
3212
|
-
})), p = (r = c == null ? void 0 : c.api) != null ? r : `${this.api}/${e.chatId}/stream`, v = (c == null ? void 0 : c.headers) !== void 0 ?
|
|
3212
|
+
})), p = (r = c == null ? void 0 : c.api) != null ? r : `${this.api}/${e.chatId}/stream`, v = (c == null ? void 0 : c.headers) !== void 0 ? Ie(c.headers) : u, h = (a = c == null ? void 0 : c.credentials) != null ? a : f, M = await ((s = this.fetch) != null ? s : globalThis.fetch)(p, {
|
|
3213
3213
|
method: "GET",
|
|
3214
3214
|
headers: v,
|
|
3215
3215
|
credentials: h
|
|
@@ -3224,14 +3224,14 @@ var Hs = class {
|
|
|
3224
3224
|
throw new Error("The response body is empty.");
|
|
3225
3225
|
return this.processResponseStream(M.body);
|
|
3226
3226
|
}
|
|
3227
|
-
},
|
|
3227
|
+
}, yt = class extends Vs {
|
|
3228
3228
|
constructor(e = {}) {
|
|
3229
3229
|
super(e);
|
|
3230
3230
|
}
|
|
3231
3231
|
processResponseStream(e) {
|
|
3232
|
-
return
|
|
3232
|
+
return ps({
|
|
3233
3233
|
stream: e,
|
|
3234
|
-
schema:
|
|
3234
|
+
schema: Fs
|
|
3235
3235
|
}).pipeThrough(
|
|
3236
3236
|
new TransformStream({
|
|
3237
3237
|
async transform(t, r) {
|
|
@@ -3242,11 +3242,11 @@ var Hs = class {
|
|
|
3242
3242
|
})
|
|
3243
3243
|
);
|
|
3244
3244
|
}
|
|
3245
|
-
},
|
|
3245
|
+
}, Js = class {
|
|
3246
3246
|
constructor({
|
|
3247
|
-
generateId: e =
|
|
3247
|
+
generateId: e = fa,
|
|
3248
3248
|
id: t = e(),
|
|
3249
|
-
transport: r = new
|
|
3249
|
+
transport: r = new yt(),
|
|
3250
3250
|
messageMetadataSchema: a,
|
|
3251
3251
|
dataPartSchemas: s,
|
|
3252
3252
|
state: i,
|
|
@@ -3256,8 +3256,8 @@ var Hs = class {
|
|
|
3256
3256
|
onData: u,
|
|
3257
3257
|
sendAutomaticallyWhen: c
|
|
3258
3258
|
}) {
|
|
3259
|
-
this.activeResponse = void 0, this.jobExecutor = new
|
|
3260
|
-
var h,
|
|
3259
|
+
this.activeResponse = void 0, this.jobExecutor = new Ws(), this.sendMessage = async (p, v) => {
|
|
3260
|
+
var h, _, M, E;
|
|
3261
3261
|
if (p == null) {
|
|
3262
3262
|
await this.makeRequest({
|
|
3263
3263
|
trigger: "submit-message",
|
|
@@ -3269,12 +3269,12 @@ var Hs = class {
|
|
|
3269
3269
|
let C;
|
|
3270
3270
|
if ("text" in p || "files" in p ? C = {
|
|
3271
3271
|
parts: [
|
|
3272
|
-
...Array.isArray(p.files) ? p.files : await
|
|
3272
|
+
...Array.isArray(p.files) ? p.files : await Bs(p.files),
|
|
3273
3273
|
..."text" in p && p.text != null ? [{ type: "text", text: p.text }] : []
|
|
3274
3274
|
]
|
|
3275
3275
|
} : C = p, p.messageId != null) {
|
|
3276
3276
|
const w = this.state.messages.findIndex(
|
|
3277
|
-
(
|
|
3277
|
+
(N) => N.id === p.messageId
|
|
3278
3278
|
);
|
|
3279
3279
|
if (w === -1)
|
|
3280
3280
|
throw new Error(`message with id ${p.messageId} not found`);
|
|
@@ -3285,7 +3285,7 @@ var Hs = class {
|
|
|
3285
3285
|
this.state.messages = this.state.messages.slice(0, w + 1), this.state.replaceMessage(w, {
|
|
3286
3286
|
...C,
|
|
3287
3287
|
id: p.messageId,
|
|
3288
|
-
role: (
|
|
3288
|
+
role: (_ = C.role) != null ? _ : "user",
|
|
3289
3289
|
metadata: p.metadata
|
|
3290
3290
|
});
|
|
3291
3291
|
} else
|
|
@@ -3304,7 +3304,7 @@ var Hs = class {
|
|
|
3304
3304
|
messageId: p,
|
|
3305
3305
|
...v
|
|
3306
3306
|
} = {}) => {
|
|
3307
|
-
const h = p == null ? this.state.messages.length - 1 : this.state.messages.findIndex((
|
|
3307
|
+
const h = p == null ? this.state.messages.length - 1 : this.state.messages.findIndex((_) => _.id === p);
|
|
3308
3308
|
if (h === -1)
|
|
3309
3309
|
throw new Error(`message ${p} not found`);
|
|
3310
3310
|
this.state.messages = this.state.messages.slice(
|
|
@@ -3324,9 +3324,9 @@ var Hs = class {
|
|
|
3324
3324
|
id: p,
|
|
3325
3325
|
approved: v,
|
|
3326
3326
|
reason: h,
|
|
3327
|
-
options:
|
|
3327
|
+
options: _
|
|
3328
3328
|
}) => this.jobExecutor.run(async () => {
|
|
3329
|
-
const M = this.state.messages, E = M[M.length - 1], C = (w) =>
|
|
3329
|
+
const M = this.state.messages, E = M[M.length - 1], C = (w) => xe(w) && w.state === "approval-requested" && w.approval.id === p ? {
|
|
3330
3330
|
...w,
|
|
3331
3331
|
state: "approval-responded",
|
|
3332
3332
|
approval: { ...w.approval, id: p, approved: v, reason: h }
|
|
@@ -3335,27 +3335,27 @@ var Hs = class {
|
|
|
3335
3335
|
...E,
|
|
3336
3336
|
parts: E.parts.map(C)
|
|
3337
3337
|
}), this.activeResponse && (this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(C)), this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen && this.shouldSendAutomatically().then((w) => {
|
|
3338
|
-
var
|
|
3338
|
+
var N;
|
|
3339
3339
|
w && this.makeRequest({
|
|
3340
3340
|
trigger: "submit-message",
|
|
3341
|
-
messageId: (
|
|
3342
|
-
...
|
|
3341
|
+
messageId: (N = this.lastMessage) == null ? void 0 : N.id,
|
|
3342
|
+
..._
|
|
3343
3343
|
});
|
|
3344
3344
|
});
|
|
3345
3345
|
}), this.addToolOutput = async ({
|
|
3346
3346
|
state: p = "output-available",
|
|
3347
3347
|
toolCallId: v,
|
|
3348
3348
|
output: h,
|
|
3349
|
-
errorText:
|
|
3349
|
+
errorText: _,
|
|
3350
3350
|
options: M
|
|
3351
3351
|
}) => this.jobExecutor.run(async () => {
|
|
3352
|
-
const E = this.state.messages, C = E[E.length - 1], w = (
|
|
3352
|
+
const E = this.state.messages, C = E[E.length - 1], w = (N) => xe(N) && N.toolCallId === v ? { ...N, state: p, output: h, errorText: _ } : N;
|
|
3353
3353
|
this.state.replaceMessage(E.length - 1, {
|
|
3354
3354
|
...C,
|
|
3355
3355
|
parts: C.parts.map(w)
|
|
3356
|
-
}), this.activeResponse && (this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(w)), this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen && this.shouldSendAutomatically().then((
|
|
3356
|
+
}), this.activeResponse && (this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(w)), this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen && this.shouldSendAutomatically().then((N) => {
|
|
3357
3357
|
var d;
|
|
3358
|
-
|
|
3358
|
+
N && this.makeRequest({
|
|
3359
3359
|
trigger: "submit-message",
|
|
3360
3360
|
messageId: (d = this.lastMessage) == null ? void 0 : d.id,
|
|
3361
3361
|
...M
|
|
@@ -3432,7 +3432,7 @@ var Hs = class {
|
|
|
3432
3432
|
let u = !1, c = !1, p = !1, v;
|
|
3433
3433
|
try {
|
|
3434
3434
|
const h = {
|
|
3435
|
-
state:
|
|
3435
|
+
state: qs({
|
|
3436
3436
|
lastMessage: this.state.snapshot(f),
|
|
3437
3437
|
messageId: this.generateId()
|
|
3438
3438
|
}),
|
|
@@ -3441,8 +3441,8 @@ var Hs = class {
|
|
|
3441
3441
|
v = h, h.abortController.signal.addEventListener("abort", () => {
|
|
3442
3442
|
u = !0;
|
|
3443
3443
|
}), this.activeResponse = h;
|
|
3444
|
-
let
|
|
3445
|
-
e === "resume-stream" ?
|
|
3444
|
+
let _;
|
|
3445
|
+
e === "resume-stream" ? _ = n : _ = await this.transport.sendMessages({
|
|
3446
3446
|
chatId: this.id,
|
|
3447
3447
|
messages: this.state.messages,
|
|
3448
3448
|
abortSignal: h.abortController.signal,
|
|
@@ -3467,9 +3467,9 @@ var Hs = class {
|
|
|
3467
3467
|
})
|
|
3468
3468
|
)
|
|
3469
3469
|
);
|
|
3470
|
-
await
|
|
3471
|
-
stream:
|
|
3472
|
-
stream:
|
|
3470
|
+
await zs({
|
|
3471
|
+
stream: Zs({
|
|
3472
|
+
stream: _,
|
|
3473
3473
|
onToolCall: this.onToolCall,
|
|
3474
3474
|
onData: this.onData,
|
|
3475
3475
|
messageMetadataSchema: this.messageMetadataSchema,
|
|
@@ -3511,7 +3511,7 @@ var Hs = class {
|
|
|
3511
3511
|
});
|
|
3512
3512
|
}
|
|
3513
3513
|
};
|
|
3514
|
-
function
|
|
3514
|
+
function Ks(e, t) {
|
|
3515
3515
|
if (typeof e != "function")
|
|
3516
3516
|
throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);
|
|
3517
3517
|
let r, a = 0;
|
|
@@ -3523,91 +3523,91 @@ function Qs(e, t) {
|
|
|
3523
3523
|
}, f);
|
|
3524
3524
|
};
|
|
3525
3525
|
}
|
|
3526
|
-
var
|
|
3527
|
-
const
|
|
3528
|
-
var
|
|
3526
|
+
var Ys = Ks;
|
|
3527
|
+
const Hs = /* @__PURE__ */ fs(Ys);
|
|
3528
|
+
var _r = (e, t, r) => {
|
|
3529
3529
|
if (!t.has(e))
|
|
3530
3530
|
throw TypeError("Cannot " + r);
|
|
3531
|
-
},
|
|
3531
|
+
}, j = (e, t, r) => (_r(e, t, "read from private field"), r ? r.call(e) : t.get(e)), re = (e, t, r) => {
|
|
3532
3532
|
if (t.has(e))
|
|
3533
3533
|
throw TypeError("Cannot add the same private member more than once");
|
|
3534
3534
|
t instanceof WeakSet ? t.add(e) : t.set(e, r);
|
|
3535
|
-
},
|
|
3536
|
-
function
|
|
3537
|
-
return t != null ?
|
|
3535
|
+
}, de = (e, t, r, a) => (_r(e, t, "write to private field"), t.set(e, r), r);
|
|
3536
|
+
function Gs(e, t) {
|
|
3537
|
+
return t != null ? Hs(e, t) : e;
|
|
3538
3538
|
}
|
|
3539
|
-
var
|
|
3539
|
+
var H, Ke, Ye, Oe, Ne, je, we, ft, mt, Qs = class {
|
|
3540
3540
|
constructor(e = []) {
|
|
3541
|
-
|
|
3542
|
-
|
|
3541
|
+
re(this, H, void 0), re(this, Ke, "ready"), re(this, Ye, void 0), re(this, Oe, /* @__PURE__ */ new Set()), re(this, Ne, /* @__PURE__ */ new Set()), re(this, je, /* @__PURE__ */ new Set()), this.pushMessage = (t) => {
|
|
3542
|
+
de(this, H, j(this, H).concat(t)), j(this, we).call(this);
|
|
3543
3543
|
}, this.popMessage = () => {
|
|
3544
|
-
|
|
3544
|
+
de(this, H, j(this, H).slice(0, -1)), j(this, we).call(this);
|
|
3545
3545
|
}, this.replaceMessage = (t, r) => {
|
|
3546
|
-
|
|
3547
|
-
...
|
|
3546
|
+
de(this, H, [
|
|
3547
|
+
...j(this, H).slice(0, t),
|
|
3548
3548
|
// We deep clone the message here to ensure the new React Compiler (currently in RC) detects deeply nested parts/metadata changes:
|
|
3549
3549
|
this.snapshot(r),
|
|
3550
|
-
...
|
|
3551
|
-
]),
|
|
3550
|
+
...j(this, H).slice(t + 1)
|
|
3551
|
+
]), j(this, we).call(this);
|
|
3552
3552
|
}, this.snapshot = (t) => structuredClone(t), this["~registerMessagesCallback"] = (t, r) => {
|
|
3553
|
-
const a = r ?
|
|
3554
|
-
return
|
|
3555
|
-
|
|
3553
|
+
const a = r ? Gs(t, r) : t;
|
|
3554
|
+
return j(this, Oe).add(a), () => {
|
|
3555
|
+
j(this, Oe).delete(a);
|
|
3556
3556
|
};
|
|
3557
|
-
}, this["~registerStatusCallback"] = (t) => (
|
|
3558
|
-
|
|
3559
|
-
}), this["~registerErrorCallback"] = (t) => (
|
|
3560
|
-
|
|
3561
|
-
}),
|
|
3562
|
-
|
|
3563
|
-
}),
|
|
3564
|
-
|
|
3565
|
-
}),
|
|
3566
|
-
|
|
3567
|
-
}),
|
|
3557
|
+
}, this["~registerStatusCallback"] = (t) => (j(this, Ne).add(t), () => {
|
|
3558
|
+
j(this, Ne).delete(t);
|
|
3559
|
+
}), this["~registerErrorCallback"] = (t) => (j(this, je).add(t), () => {
|
|
3560
|
+
j(this, je).delete(t);
|
|
3561
|
+
}), re(this, we, () => {
|
|
3562
|
+
j(this, Oe).forEach((t) => t());
|
|
3563
|
+
}), re(this, ft, () => {
|
|
3564
|
+
j(this, Ne).forEach((t) => t());
|
|
3565
|
+
}), re(this, mt, () => {
|
|
3566
|
+
j(this, je).forEach((t) => t());
|
|
3567
|
+
}), de(this, H, e);
|
|
3568
3568
|
}
|
|
3569
3569
|
get status() {
|
|
3570
|
-
return
|
|
3570
|
+
return j(this, Ke);
|
|
3571
3571
|
}
|
|
3572
3572
|
set status(e) {
|
|
3573
|
-
|
|
3573
|
+
de(this, Ke, e), j(this, ft).call(this);
|
|
3574
3574
|
}
|
|
3575
3575
|
get error() {
|
|
3576
|
-
return
|
|
3576
|
+
return j(this, Ye);
|
|
3577
3577
|
}
|
|
3578
3578
|
set error(e) {
|
|
3579
|
-
|
|
3579
|
+
de(this, Ye, e), j(this, mt).call(this);
|
|
3580
3580
|
}
|
|
3581
3581
|
get messages() {
|
|
3582
|
-
return
|
|
3582
|
+
return j(this, H);
|
|
3583
3583
|
}
|
|
3584
3584
|
set messages(e) {
|
|
3585
|
-
|
|
3585
|
+
de(this, H, [...e]), j(this, we).call(this);
|
|
3586
3586
|
}
|
|
3587
3587
|
};
|
|
3588
|
-
|
|
3588
|
+
H = /* @__PURE__ */ new WeakMap();
|
|
3589
|
+
Ke = /* @__PURE__ */ new WeakMap();
|
|
3589
3590
|
Ye = /* @__PURE__ */ new WeakMap();
|
|
3590
|
-
He = /* @__PURE__ */ new WeakMap();
|
|
3591
3591
|
Oe = /* @__PURE__ */ new WeakMap();
|
|
3592
3592
|
Ne = /* @__PURE__ */ new WeakMap();
|
|
3593
3593
|
je = /* @__PURE__ */ new WeakMap();
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
var
|
|
3594
|
+
we = /* @__PURE__ */ new WeakMap();
|
|
3595
|
+
ft = /* @__PURE__ */ new WeakMap();
|
|
3596
|
+
mt = /* @__PURE__ */ new WeakMap();
|
|
3597
|
+
var _e, Wt = class extends Js {
|
|
3598
3598
|
constructor({ messages: e, ...t }) {
|
|
3599
|
-
const r = new
|
|
3600
|
-
super({ ...t, state: r }),
|
|
3599
|
+
const r = new Qs(e);
|
|
3600
|
+
super({ ...t, state: r }), re(this, _e, void 0), this["~registerMessagesCallback"] = (a, s) => j(this, _e)["~registerMessagesCallback"](a, s), this["~registerStatusCallback"] = (a) => j(this, _e)["~registerStatusCallback"](a), this["~registerErrorCallback"] = (a) => j(this, _e)["~registerErrorCallback"](a), de(this, _e, r);
|
|
3601
3601
|
}
|
|
3602
3602
|
};
|
|
3603
|
-
|
|
3604
|
-
function
|
|
3603
|
+
_e = /* @__PURE__ */ new WeakMap();
|
|
3604
|
+
function Xs({
|
|
3605
3605
|
throttle: e,
|
|
3606
3606
|
experimental_throttle: t,
|
|
3607
3607
|
resume: r = !1,
|
|
3608
3608
|
...a
|
|
3609
3609
|
} = {}) {
|
|
3610
|
-
const s = e ?? t, i =
|
|
3610
|
+
const s = e ?? t, i = D({});
|
|
3611
3611
|
"chat" in a || (i.current = {
|
|
3612
3612
|
onToolCall: a.onToolCall,
|
|
3613
3613
|
onData: a.onData,
|
|
@@ -3619,7 +3619,7 @@ function an({
|
|
|
3619
3619
|
let l;
|
|
3620
3620
|
const n = () => {
|
|
3621
3621
|
var E;
|
|
3622
|
-
return (E = i.current.transport) != null ? E : l ?? (l = new
|
|
3622
|
+
return (E = i.current.transport) != null ? E : l ?? (l = new yt());
|
|
3623
3623
|
}, f = {
|
|
3624
3624
|
...a,
|
|
3625
3625
|
transport: {
|
|
@@ -3643,14 +3643,14 @@ function an({
|
|
|
3643
3643
|
return (w = (C = i.current).onError) == null ? void 0 : w.call(C, E);
|
|
3644
3644
|
},
|
|
3645
3645
|
sendAutomaticallyWhen: (E) => {
|
|
3646
|
-
var C, w,
|
|
3647
|
-
return (
|
|
3646
|
+
var C, w, N;
|
|
3647
|
+
return (N = (w = (C = i.current).sendAutomaticallyWhen) == null ? void 0 : w.call(C, E)) != null ? N : !1;
|
|
3648
3648
|
}
|
|
3649
|
-
}, u =
|
|
3650
|
-
"chat" in a ? a.chat : new
|
|
3649
|
+
}, u = D(
|
|
3650
|
+
"chat" in a ? a.chat : new Wt(f)
|
|
3651
3651
|
);
|
|
3652
|
-
("chat" in a && a.chat !== u.current || "id" in a && a.id != null && u.current.id !== a.id) && (u.current = "chat" in a ? a.chat : new
|
|
3653
|
-
const p =
|
|
3652
|
+
("chat" in a && a.chat !== u.current || "id" in a && a.id != null && u.current.id !== a.id) && (u.current = "chat" in a ? a.chat : new Wt(f));
|
|
3653
|
+
const p = q(
|
|
3654
3654
|
(E) => u.current["~registerMessagesCallback"](E, s),
|
|
3655
3655
|
// `chatRef.current.id` is required to trigger re-subscription when the chat ID changes
|
|
3656
3656
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -3663,17 +3663,17 @@ function an({
|
|
|
3663
3663
|
u.current["~registerStatusCallback"],
|
|
3664
3664
|
() => u.current.status,
|
|
3665
3665
|
() => u.current.status
|
|
3666
|
-
),
|
|
3666
|
+
), _ = De(
|
|
3667
3667
|
u.current["~registerErrorCallback"],
|
|
3668
3668
|
() => u.current.error,
|
|
3669
3669
|
() => u.current.error
|
|
3670
|
-
), M =
|
|
3670
|
+
), M = q(
|
|
3671
3671
|
(E) => {
|
|
3672
3672
|
typeof E == "function" && (E = E(u.current.messages)), u.current.messages = E;
|
|
3673
3673
|
},
|
|
3674
3674
|
[u]
|
|
3675
3675
|
);
|
|
3676
|
-
return
|
|
3676
|
+
return Z(() => {
|
|
3677
3677
|
r && u.current.resumeStream();
|
|
3678
3678
|
}, [r, u]), {
|
|
3679
3679
|
id: u.current.id,
|
|
@@ -3683,7 +3683,7 @@ function an({
|
|
|
3683
3683
|
regenerate: u.current.regenerate,
|
|
3684
3684
|
clearError: u.current.clearError,
|
|
3685
3685
|
stop: u.current.stop,
|
|
3686
|
-
error:
|
|
3686
|
+
error: _,
|
|
3687
3687
|
resumeStream: u.current.resumeStream,
|
|
3688
3688
|
status: h,
|
|
3689
3689
|
/**
|
|
@@ -3694,7 +3694,7 @@ function an({
|
|
|
3694
3694
|
addToolApprovalResponse: u.current.addToolApprovalResponse
|
|
3695
3695
|
};
|
|
3696
3696
|
}
|
|
3697
|
-
class
|
|
3697
|
+
class Bt {
|
|
3698
3698
|
constructor(t) {
|
|
3699
3699
|
this.buffer = [], this.cap = Math.max(1, Math.floor(t));
|
|
3700
3700
|
}
|
|
@@ -3727,7 +3727,7 @@ class Yt {
|
|
|
3727
3727
|
return a ?? null;
|
|
3728
3728
|
}
|
|
3729
3729
|
}
|
|
3730
|
-
function
|
|
3730
|
+
function Vt(e, t) {
|
|
3731
3731
|
const r = e.flatMap((a) => {
|
|
3732
3732
|
if (a.kind !== "steps") return [a];
|
|
3733
3733
|
const s = a.steps.flatMap((i) => i.kind === "reasoning" ? (t == null ? void 0 : t.reasoning) === !1 ? [] : [i] : (t == null ? void 0 : t.toolActivity) === "hidden" ? [] : (t == null ? void 0 : t.toolActivity) === "status" && ("input" in i || "output" in i) ? [{ kind: i.kind, label: i.label, done: i.done }] : [i]);
|
|
@@ -3737,30 +3737,30 @@ function Ht(e, t) {
|
|
|
3737
3737
|
});
|
|
3738
3738
|
return r.length === e.length && r.every((a, s) => a === e[s]) ? e : r;
|
|
3739
3739
|
}
|
|
3740
|
-
const
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
]),
|
|
3744
|
-
id:
|
|
3745
|
-
prompt:
|
|
3746
|
-
selection:
|
|
3747
|
-
options:
|
|
3748
|
-
}),
|
|
3749
|
-
request_id:
|
|
3750
|
-
questions:
|
|
3740
|
+
const en = z.union([
|
|
3741
|
+
z.string(),
|
|
3742
|
+
z.looseObject({ id: z.string().optional(), label: z.string() })
|
|
3743
|
+
]), tn = z.looseObject({
|
|
3744
|
+
id: z.string().optional(),
|
|
3745
|
+
prompt: z.string(),
|
|
3746
|
+
selection: z.enum(["single", "multiple"]).default("single"),
|
|
3747
|
+
options: z.array(en).min(1)
|
|
3748
|
+
}), rn = z.looseObject({
|
|
3749
|
+
request_id: z.string().optional(),
|
|
3750
|
+
questions: z.array(tn).min(1)
|
|
3751
3751
|
});
|
|
3752
|
-
function
|
|
3752
|
+
function an(e) {
|
|
3753
3753
|
return !!(e != null && e.includes("ask_questions"));
|
|
3754
3754
|
}
|
|
3755
|
-
const
|
|
3755
|
+
const sn = [
|
|
3756
3756
|
/\bi[’'ʼ‘]?ll\s+(type|describe|enter|write|tell)\b/i,
|
|
3757
3757
|
/\b(type|describe|enter|write|tell)\s+(it|my\s+own|manually)\b/i,
|
|
3758
3758
|
/^\s*(other|custom|none\s+of\s+the\s+above|something\s+else)\s*\.?\s*$/i
|
|
3759
3759
|
];
|
|
3760
|
-
function
|
|
3761
|
-
return
|
|
3760
|
+
function nn(e) {
|
|
3761
|
+
return sn.some((t) => t.test(e));
|
|
3762
3762
|
}
|
|
3763
|
-
function
|
|
3763
|
+
function on(e, t) {
|
|
3764
3764
|
return {
|
|
3765
3765
|
request_id: e.request_id ?? t ?? "req-clarification",
|
|
3766
3766
|
questions: e.questions.map((r, a) => ({
|
|
@@ -3772,44 +3772,44 @@ function dn(e, t) {
|
|
|
3772
3772
|
id: s.id ?? `q${a}-o${i}`,
|
|
3773
3773
|
label: s.label
|
|
3774
3774
|
}
|
|
3775
|
-
).filter((s) => !
|
|
3775
|
+
).filter((s) => !nn(s.label))
|
|
3776
3776
|
}))
|
|
3777
3777
|
};
|
|
3778
3778
|
}
|
|
3779
|
-
function
|
|
3779
|
+
function it(e) {
|
|
3780
3780
|
try {
|
|
3781
3781
|
return JSON.parse(e);
|
|
3782
3782
|
} catch {
|
|
3783
3783
|
return null;
|
|
3784
3784
|
}
|
|
3785
3785
|
}
|
|
3786
|
-
function
|
|
3786
|
+
function ln(e) {
|
|
3787
3787
|
if (e == null) return null;
|
|
3788
|
-
if (typeof e == "string") return
|
|
3788
|
+
if (typeof e == "string") return it(e);
|
|
3789
3789
|
if (Array.isArray(e)) {
|
|
3790
3790
|
for (const t of e)
|
|
3791
3791
|
if (t && typeof t == "object" && "text" in t) {
|
|
3792
3792
|
const r = t.text;
|
|
3793
|
-
if (typeof r == "string") return
|
|
3793
|
+
if (typeof r == "string") return it(r);
|
|
3794
3794
|
}
|
|
3795
3795
|
return null;
|
|
3796
3796
|
}
|
|
3797
3797
|
if (typeof e == "object") {
|
|
3798
3798
|
if ("text" in e) {
|
|
3799
3799
|
const t = e.text;
|
|
3800
|
-
if (typeof t == "string") return
|
|
3800
|
+
if (typeof t == "string") return it(t);
|
|
3801
3801
|
}
|
|
3802
3802
|
return e;
|
|
3803
3803
|
}
|
|
3804
3804
|
return null;
|
|
3805
3805
|
}
|
|
3806
|
-
function
|
|
3807
|
-
const r =
|
|
3806
|
+
function Jt(e, t) {
|
|
3807
|
+
const r = ln(e);
|
|
3808
3808
|
if (r == null) return null;
|
|
3809
|
-
const a =
|
|
3810
|
-
return a.success ?
|
|
3809
|
+
const a = rn.safeParse(r);
|
|
3810
|
+
return a.success ? on(a.data, t) : null;
|
|
3811
3811
|
}
|
|
3812
|
-
function
|
|
3812
|
+
function $n(e, t) {
|
|
3813
3813
|
const r = [];
|
|
3814
3814
|
for (const a of e.questions) {
|
|
3815
3815
|
const s = t.get(a.id);
|
|
@@ -3820,29 +3820,29 @@ A: ${s.trim()}`);
|
|
|
3820
3820
|
|
|
3821
3821
|
`);
|
|
3822
3822
|
}
|
|
3823
|
-
const
|
|
3824
|
-
function
|
|
3823
|
+
const Kt = "data-spec", un = z.object({ label: z.string(), done: z.boolean() });
|
|
3824
|
+
function He(e) {
|
|
3825
3825
|
const t = [], r = (i) => {
|
|
3826
3826
|
const l = t.at(-1);
|
|
3827
3827
|
(l == null ? void 0 : l.kind) === "steps" ? l.steps.push(i) : t.push({ kind: "steps", steps: [i] });
|
|
3828
3828
|
}, a = (i) => i === "output-available" || i === "output-error";
|
|
3829
3829
|
let s = null;
|
|
3830
3830
|
for (const i of e)
|
|
3831
|
-
if (!
|
|
3832
|
-
if (
|
|
3833
|
-
const l =
|
|
3831
|
+
if (!Jr(i) && xr(i) !== "highlight_element") {
|
|
3832
|
+
if (cn(i)) {
|
|
3833
|
+
const l = dn(i);
|
|
3834
3834
|
l && t.push(l);
|
|
3835
3835
|
continue;
|
|
3836
3836
|
}
|
|
3837
3837
|
if (i.type === "data-tool-activity") {
|
|
3838
|
-
const l =
|
|
3838
|
+
const l = un.safeParse(i.data);
|
|
3839
3839
|
l.success && r({
|
|
3840
3840
|
kind: "tool",
|
|
3841
3841
|
label: l.data.label,
|
|
3842
3842
|
done: l.data.done
|
|
3843
3843
|
});
|
|
3844
|
-
} else if (i.type ===
|
|
3845
|
-
s || (s = { kind: "spec", parts: [] }, t.push(s)), s.parts.push({ type:
|
|
3844
|
+
} else if (i.type === Kt)
|
|
3845
|
+
s || (s = { kind: "spec", parts: [] }, t.push(s)), s.parts.push({ type: Kt, data: i.data });
|
|
3846
3846
|
else if (i.type === "text") {
|
|
3847
3847
|
const l = typeof i.text == "string" ? i.text : "";
|
|
3848
3848
|
l.trim().length > 0 && t.push({ kind: "text", text: l });
|
|
@@ -3854,49 +3854,49 @@ function Ge(e) {
|
|
|
3854
3854
|
kind: "tool",
|
|
3855
3855
|
label: typeof i.toolName == "string" ? i.toolName : "tool",
|
|
3856
3856
|
done: a(i.state),
|
|
3857
|
-
...
|
|
3857
|
+
...Yt(i)
|
|
3858
3858
|
}) : i.type.startsWith("tool-") && r({
|
|
3859
3859
|
kind: "tool",
|
|
3860
3860
|
label: i.type.slice(5),
|
|
3861
3861
|
done: a(i.state),
|
|
3862
|
-
...
|
|
3862
|
+
...Yt(i)
|
|
3863
3863
|
});
|
|
3864
3864
|
}
|
|
3865
3865
|
return t;
|
|
3866
3866
|
}
|
|
3867
|
-
function
|
|
3867
|
+
function xr(e) {
|
|
3868
3868
|
return e.type === "dynamic-tool" ? typeof e.toolName == "string" ? e.toolName : void 0 : e.type.startsWith("tool-") ? e.type.slice(5) : void 0;
|
|
3869
3869
|
}
|
|
3870
|
-
function
|
|
3871
|
-
return
|
|
3870
|
+
function cn(e) {
|
|
3871
|
+
return an(xr(e));
|
|
3872
3872
|
}
|
|
3873
|
-
function
|
|
3874
|
-
const t = typeof e.toolCallId == "string" ? e.toolCallId : void 0, r =
|
|
3873
|
+
function dn(e) {
|
|
3874
|
+
const t = typeof e.toolCallId == "string" ? e.toolCallId : void 0, r = Jt(e.output, t) ?? Jt(e.input, t);
|
|
3875
3875
|
return r ? { kind: "questions", request: r } : null;
|
|
3876
3876
|
}
|
|
3877
|
-
function
|
|
3877
|
+
function Yt(e) {
|
|
3878
3878
|
return {
|
|
3879
3879
|
...e.input === void 0 ? {} : { input: e.input },
|
|
3880
3880
|
...e.output === void 0 ? {} : { output: e.output }
|
|
3881
3881
|
};
|
|
3882
3882
|
}
|
|
3883
|
-
function
|
|
3883
|
+
function pn(e) {
|
|
3884
3884
|
return ({ id: t }) => ({
|
|
3885
3885
|
api: e.reconnectApi(t),
|
|
3886
3886
|
headers: e.headers()
|
|
3887
3887
|
});
|
|
3888
3888
|
}
|
|
3889
|
-
function
|
|
3890
|
-
return new
|
|
3889
|
+
function fn(e) {
|
|
3890
|
+
return new yt({
|
|
3891
3891
|
api: e.api,
|
|
3892
3892
|
headers: () => e.headers(),
|
|
3893
3893
|
// Every send carries its full body; a send without one is a programming
|
|
3894
3894
|
// error, and an empty body would be rejected server-side just as loudly.
|
|
3895
3895
|
prepareSendMessagesRequest: ({ body: t }) => ({ body: t ?? {} }),
|
|
3896
|
-
prepareReconnectToStreamRequest:
|
|
3896
|
+
prepareReconnectToStreamRequest: pn(e)
|
|
3897
3897
|
});
|
|
3898
3898
|
}
|
|
3899
|
-
function
|
|
3899
|
+
function mn({
|
|
3900
3900
|
existing: e,
|
|
3901
3901
|
fetched: t,
|
|
3902
3902
|
refreshItems: r = !1
|
|
@@ -3908,11 +3908,11 @@ function yn({
|
|
|
3908
3908
|
if (s.add(n.turn_id), n.message_uuids.length === 0) continue;
|
|
3909
3909
|
const f = a.get(n.turn_id);
|
|
3910
3910
|
if (f && !r) {
|
|
3911
|
-
|
|
3911
|
+
gn(f.rowIds, n.message_uuids) ? i.push(f) : i.push({ ...f, rowIds: n.message_uuids });
|
|
3912
3912
|
continue;
|
|
3913
3913
|
}
|
|
3914
3914
|
if (n.ui_parts !== null) {
|
|
3915
|
-
const u =
|
|
3915
|
+
const u = He(n.ui_parts);
|
|
3916
3916
|
if (u.length === 0) continue;
|
|
3917
3917
|
i.push({
|
|
3918
3918
|
key: (f == null ? void 0 : f.key) ?? `turn-${n.turn_id}`,
|
|
@@ -3926,30 +3926,16 @@ function yn({
|
|
|
3926
3926
|
s.has(n.turnId) || i.push(n);
|
|
3927
3927
|
return i.length === e.length && i.every((n, f) => n === e[f]) ? e : i;
|
|
3928
3928
|
}
|
|
3929
|
-
const
|
|
3930
|
-
function
|
|
3929
|
+
const gn = (e, t) => e.length === t.length && e.every((r, a) => r === t[a]), hn = (e) => Array.isArray(e) && e.every((t) => typeof t == "string");
|
|
3930
|
+
function Ht(e) {
|
|
3931
3931
|
for (const t of e) {
|
|
3932
3932
|
if (t.type !== "data-turn-settled") continue;
|
|
3933
3933
|
const r = t.data;
|
|
3934
|
-
return !
|
|
3934
|
+
return !Kr(r) || typeof r.turn_id != "string" || !hn(r.message_uuids) ? null : { turnId: r.turn_id, rowIds: r.message_uuids };
|
|
3935
3935
|
}
|
|
3936
3936
|
return null;
|
|
3937
3937
|
}
|
|
3938
|
-
async function
|
|
3939
|
-
const t = e.getReader();
|
|
3940
|
-
try {
|
|
3941
|
-
for (; ; ) {
|
|
3942
|
-
const { value: r, done: a } = await t.read();
|
|
3943
|
-
if (a || r === void 0) return { kind: "silent" };
|
|
3944
|
-
if (!tr(r))
|
|
3945
|
-
return Qr(r) ? { kind: "steered" } : r.type === "error" ? { kind: "failed", errorText: r.errorText } : { kind: "turn" };
|
|
3946
|
-
}
|
|
3947
|
-
} finally {
|
|
3948
|
-
await t.cancel().catch(() => {
|
|
3949
|
-
});
|
|
3950
|
-
}
|
|
3951
|
-
}
|
|
3952
|
-
async function In({
|
|
3938
|
+
async function vn({
|
|
3953
3939
|
api: e,
|
|
3954
3940
|
sessionId: t,
|
|
3955
3941
|
chatStop: r
|
|
@@ -3960,35 +3946,35 @@ async function In({
|
|
|
3960
3946
|
t && await e.stopStream(t);
|
|
3961
3947
|
}
|
|
3962
3948
|
}
|
|
3963
|
-
const
|
|
3964
|
-
function
|
|
3949
|
+
const Gt = 20, yn = "highlight_element";
|
|
3950
|
+
function bn({
|
|
3965
3951
|
widgetCtx: e,
|
|
3966
3952
|
config: t,
|
|
3967
3953
|
sessionId: r,
|
|
3968
3954
|
persistedMessages: a
|
|
3969
3955
|
}) {
|
|
3970
|
-
var
|
|
3971
|
-
const { api: s, messageCtx: i } = e, l =
|
|
3956
|
+
var wt, _t;
|
|
3957
|
+
const { api: s, messageCtx: i } = e, l = D(t);
|
|
3972
3958
|
l.current = t;
|
|
3973
|
-
const { pageContext: n, clientTools: f } = e.features, u =
|
|
3974
|
-
() =>
|
|
3959
|
+
const { pageContext: n, clientTools: f } = e.features, u = B(
|
|
3960
|
+
() => fn({
|
|
3975
3961
|
...s.getStreamTransportOptions(),
|
|
3976
3962
|
headers: () => s.getStreamTransportOptions().headers,
|
|
3977
|
-
reconnectApi: (
|
|
3978
|
-
const
|
|
3979
|
-
return
|
|
3963
|
+
reconnectApi: (S) => {
|
|
3964
|
+
const x = new URL(s.getStreamTransportOptions().reconnectApi(S)), R = l.current.presentation;
|
|
3965
|
+
return R != null && R.toolActivity && x.searchParams.set("toolActivity", R.toolActivity), (R == null ? void 0 : R.reasoning) !== void 0 && x.searchParams.set("reasoning", String(R.reasoning)), x.toString();
|
|
3980
3966
|
}
|
|
3981
3967
|
}),
|
|
3982
3968
|
[s]
|
|
3983
|
-
), [c, p] =
|
|
3969
|
+
), [c, p] = V(null), v = D(!1), {
|
|
3984
3970
|
status: h,
|
|
3985
|
-
messages:
|
|
3971
|
+
messages: _,
|
|
3986
3972
|
sendMessage: M,
|
|
3987
3973
|
stop: E,
|
|
3988
3974
|
error: C,
|
|
3989
3975
|
clearError: w,
|
|
3990
|
-
resumeStream:
|
|
3991
|
-
} =
|
|
3976
|
+
resumeStream: N
|
|
3977
|
+
} = Xs({
|
|
3992
3978
|
id: r ?? void 0,
|
|
3993
3979
|
// Reattach to a still-live turn (reload, tab switch) — but only once a
|
|
3994
3980
|
// session actually exists. A fresh visitor has nothing to resume, and the
|
|
@@ -4000,351 +3986,307 @@ function _n({
|
|
|
4000
3986
|
// whole chat surface (transcript + composer), which stutters on long
|
|
4001
3987
|
// replies inside customer pages.
|
|
4002
3988
|
throttle: 50,
|
|
4003
|
-
onError: (
|
|
3989
|
+
onError: (S) => ne.error("agent chat stream error", S),
|
|
4004
3990
|
onFinish: p
|
|
4005
|
-
}), d =
|
|
4006
|
-
d.current =
|
|
4007
|
-
const g =
|
|
4008
|
-
|
|
4009
|
-
const [
|
|
4010
|
-
|
|
4011
|
-
}, []), Se =
|
|
4012
|
-
|
|
4013
|
-
const ze =
|
|
4014
|
-
const
|
|
4015
|
-
if (!
|
|
4016
|
-
const
|
|
4017
|
-
|
|
4018
|
-
(L) => L.some((le) => le.turnId ===
|
|
3991
|
+
}), d = D(_);
|
|
3992
|
+
d.current = _;
|
|
3993
|
+
const g = D(new Bt(Gt)), m = D("idle"), b = D(Promise.resolve()), y = D(0), I = D(0), [k, Y] = V(0), [te, ie] = V(!1), Q = D(te);
|
|
3994
|
+
Q.current = te;
|
|
3995
|
+
const [Me, Ze] = V([]), [Fr, $r] = V(null), Te = D(null), me = q((S) => {
|
|
3996
|
+
Te.current = S, $r(S);
|
|
3997
|
+
}, []), Se = D(null), Re = D(null), Ee = D(h), St = D(r), et = D(null), tt = D(null), Et = D(E), oe = D(h);
|
|
3998
|
+
oe.current = h;
|
|
3999
|
+
const ze = q((S, x) => {
|
|
4000
|
+
const R = Ht(S.parts);
|
|
4001
|
+
if (!R || R.rowIds.length === 0) return;
|
|
4002
|
+
const P = He(S.parts);
|
|
4003
|
+
P.length !== 0 && Ze(
|
|
4004
|
+
(L) => L.some((le) => le.turnId === R.turnId) ? L : [
|
|
4019
4005
|
...L,
|
|
4020
|
-
{ key:
|
|
4006
|
+
{ key: x, turnId: R.turnId, rowIds: R.rowIds, items: P }
|
|
4021
4007
|
]
|
|
4022
4008
|
);
|
|
4023
|
-
}, []),
|
|
4024
|
-
(
|
|
4009
|
+
}, []), Ct = q(
|
|
4010
|
+
(S) => Yr({
|
|
4025
4011
|
config: l.current,
|
|
4026
|
-
input:
|
|
4027
|
-
uuid:
|
|
4028
|
-
sessionId:
|
|
4029
|
-
content:
|
|
4030
|
-
initialMessages:
|
|
4012
|
+
input: S.input,
|
|
4013
|
+
uuid: S.retryUuid ?? S.userMessage.id,
|
|
4014
|
+
sessionId: S.sessionId,
|
|
4015
|
+
content: S.userMessage.content,
|
|
4016
|
+
initialMessages: S.initialMessages,
|
|
4031
4017
|
sendsPageContext: n
|
|
4032
4018
|
}),
|
|
4033
4019
|
[n]
|
|
4034
|
-
)
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
chatId: b.sessionId,
|
|
4042
|
-
messageId: void 0,
|
|
4043
|
-
messages: [],
|
|
4044
|
-
abortSignal: T.signal,
|
|
4045
|
-
body: We(b)
|
|
4046
|
-
});
|
|
4047
|
-
k = await Cn(L);
|
|
4048
|
-
} catch (L) {
|
|
4049
|
-
B.error("agent chat steer failed", L);
|
|
4050
|
-
return;
|
|
4051
|
-
} finally {
|
|
4052
|
-
T.abort();
|
|
4053
|
-
}
|
|
4054
|
-
if (I === P.current) {
|
|
4055
|
-
switch (k.kind) {
|
|
4056
|
-
case "steered":
|
|
4057
|
-
i.markUserMessageDelivered(b.userMessage.id);
|
|
4058
|
-
return;
|
|
4059
|
-
case "turn":
|
|
4060
|
-
Ee.current = b;
|
|
4061
|
-
try {
|
|
4062
|
-
await E();
|
|
4063
|
-
} catch (L) {
|
|
4064
|
-
B.error("agent chat steer fallback: client stop failed", L);
|
|
4065
|
-
}
|
|
4066
|
-
if (I !== P.current) return;
|
|
4067
|
-
await O();
|
|
4068
|
-
return;
|
|
4069
|
-
case "failed":
|
|
4070
|
-
B.error("agent chat steer: the turn failed", {
|
|
4071
|
-
errorText: k.errorText
|
|
4072
|
-
});
|
|
4073
|
-
break;
|
|
4074
|
-
case "silent":
|
|
4075
|
-
i.markUserMessageDelivered(b.userMessage.id);
|
|
4076
|
-
break;
|
|
4077
|
-
}
|
|
4078
|
-
await e.reconcileAfterStream(b.sessionId).catch((L) => {
|
|
4079
|
-
B.error("agent chat post-steer reconcile failed", L);
|
|
4080
|
-
});
|
|
4081
|
-
}
|
|
4082
|
-
},
|
|
4083
|
-
[u, We, i, E, O, e]
|
|
4084
|
-
), xt = j(_t);
|
|
4085
|
-
xt.current = _t, q(() => {
|
|
4086
|
-
const b = wt.current;
|
|
4087
|
-
wt.current = E;
|
|
4088
|
-
const I = It.current;
|
|
4089
|
-
if (I === r) return;
|
|
4090
|
-
if (It.current = r, I === null) {
|
|
4020
|
+
);
|
|
4021
|
+
Z(() => {
|
|
4022
|
+
const S = Et.current;
|
|
4023
|
+
Et.current = E;
|
|
4024
|
+
const x = St.current;
|
|
4025
|
+
if (x === r) return;
|
|
4026
|
+
if (St.current = r, x === null) {
|
|
4091
4027
|
Ze([]);
|
|
4092
4028
|
return;
|
|
4093
4029
|
}
|
|
4094
|
-
const
|
|
4095
|
-
|
|
4096
|
-
|
|
4030
|
+
const R = oe.current === "submitted" || oe.current === "streaming" || Ee.current === "submitted" || Ee.current === "streaming" || m.current === "in-flight";
|
|
4031
|
+
I.current += 1, y.current = 0, b.current = Promise.resolve(), g.current = new Bt(Gt), m.current = "idle", Re.current = null, Se.current = null, p(null), v.current = !1, tt.current = null, et.current = h === "submitted" || h === "streaming" ? h : null, Ee.current = "ready", oe.current = "ready", w(), Y((P) => P + 1), ie(!1), Ze([]), me(null), R && Promise.resolve().then(() => S()).catch((P) => {
|
|
4032
|
+
ne.error("agent chat client stream cancel failed", P);
|
|
4097
4033
|
});
|
|
4098
|
-
}, [r, h, E, w, me]),
|
|
4034
|
+
}, [r, h, E, w, me]), Z(() => {
|
|
4099
4035
|
var L, le;
|
|
4100
|
-
const
|
|
4101
|
-
if (
|
|
4102
|
-
|
|
4036
|
+
const S = et.current;
|
|
4037
|
+
if (S !== null && h === S) {
|
|
4038
|
+
Ee.current = "ready";
|
|
4103
4039
|
return;
|
|
4104
4040
|
}
|
|
4105
|
-
|
|
4106
|
-
const
|
|
4107
|
-
if (
|
|
4108
|
-
const
|
|
4109
|
-
|
|
4041
|
+
et.current = null;
|
|
4042
|
+
const x = Ee.current;
|
|
4043
|
+
if (Ee.current = h, (h === "submitted" || h === "streaming") && (x !== "submitted" && x !== "streaming" && Te.current === null && me(`turn-resumed-${xt()}`), ie(!0)), h === "streaming") {
|
|
4044
|
+
const U = (L = Re.current) == null ? void 0 : L.userMessage.id;
|
|
4045
|
+
U && i.markUserMessageDelivered(U);
|
|
4110
4046
|
return;
|
|
4111
4047
|
}
|
|
4112
4048
|
if (h !== "ready" && h !== "error") return;
|
|
4113
|
-
if (
|
|
4049
|
+
if (x === "streaming" || x === "submitted" || // An empty response can finish before React observes an active status.
|
|
4114
4050
|
m.current === "in-flight" && (c == null ? void 0 : c.messages) === d.current) {
|
|
4115
|
-
|
|
4116
|
-
const
|
|
4117
|
-
if (Se.current = ue, ue !== null &&
|
|
4118
|
-
const
|
|
4119
|
-
|
|
4051
|
+
ie(!0), m.current === "in-flight" && (m.current = "idle");
|
|
4052
|
+
const U = d.current.at(-1), ue = Te.current;
|
|
4053
|
+
if (Se.current = ue, ue !== null && U && U.role === "assistant" && ze(U, ue), h === "ready") {
|
|
4054
|
+
const ce = (le = Re.current) == null ? void 0 : le.userMessage.id;
|
|
4055
|
+
ce && i.markUserMessageDelivered(ce);
|
|
4120
4056
|
}
|
|
4121
|
-
m.current === "stopping" || (r ? (m.current = "reconciling", e.reconcileAfterStream(r).catch((
|
|
4122
|
-
|
|
4057
|
+
m.current === "stopping" || (r ? (m.current = "reconciling", e.reconcileAfterStream(r).catch((ce) => {
|
|
4058
|
+
ne.error("agent chat post-turn reconcile failed", ce);
|
|
4123
4059
|
}).finally(() => {
|
|
4124
|
-
m.current === "reconciling" && (m.current = "idle"),
|
|
4125
|
-
})) :
|
|
4060
|
+
m.current === "reconciling" && (m.current = "idle"), Y((ce) => ce + 1);
|
|
4061
|
+
})) : ie(!1));
|
|
4126
4062
|
}
|
|
4127
|
-
if (m.current !== "idle" || !r) return;
|
|
4128
|
-
const
|
|
4129
|
-
|
|
4130
|
-
{ text:
|
|
4131
|
-
{ body:
|
|
4063
|
+
if (m.current !== "idle" || !r || Q.current && h !== "error") return;
|
|
4064
|
+
const P = g.current.dequeueNext();
|
|
4065
|
+
P && (m.current = "in-flight", Re.current = P, p(null), v.current = !1, me(`turn-${P.userMessage.id}`), i.appendUserMessageIfAbsent(P.userMessage), Y((U) => U + 1), M(
|
|
4066
|
+
{ text: P.userMessage.content },
|
|
4067
|
+
{ body: Ct(P) }
|
|
4132
4068
|
));
|
|
4133
4069
|
}, [
|
|
4134
4070
|
h,
|
|
4135
4071
|
r,
|
|
4136
|
-
|
|
4072
|
+
k,
|
|
4137
4073
|
M,
|
|
4138
4074
|
i,
|
|
4139
4075
|
e,
|
|
4140
|
-
|
|
4076
|
+
Ct,
|
|
4141
4077
|
ze,
|
|
4142
4078
|
me,
|
|
4143
4079
|
c
|
|
4144
4080
|
]);
|
|
4145
|
-
const
|
|
4146
|
-
(
|
|
4147
|
-
const
|
|
4081
|
+
const It = q(
|
|
4082
|
+
(S) => {
|
|
4083
|
+
const x = I.current;
|
|
4148
4084
|
y.current++;
|
|
4149
|
-
const
|
|
4085
|
+
const P = b.current.then(
|
|
4150
4086
|
async () => {
|
|
4151
|
-
if (
|
|
4152
|
-
const L = m.current,
|
|
4153
|
-
if (!
|
|
4154
|
-
const
|
|
4155
|
-
if (
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
).finally(() => {
|
|
4159
|
-
I === P.current && _.current--;
|
|
4160
|
-
});
|
|
4161
|
-
return;
|
|
4162
|
-
}
|
|
4163
|
-
if (!g.current.enqueue(X)) {
|
|
4164
|
-
B.warn("agent chat queue full; rejecting newest send", {
|
|
4165
|
-
rejectedMessageId: X.userMessage.id
|
|
4087
|
+
if (x !== I.current) return;
|
|
4088
|
+
const L = m.current, U = oe.current === "submitted" || oe.current === "streaming" || L !== "idle" || Q.current || g.current.size > 0 ? Sn(i.buildQueuedUserMessage(S)) : await i.stageUserTurn(S, { pending: !0 });
|
|
4089
|
+
if (!U || x !== I.current) return;
|
|
4090
|
+
const ue = { ...U, input: S };
|
|
4091
|
+
if (!g.current.enqueue(ue)) {
|
|
4092
|
+
ne.warn("agent chat queue full; rejecting newest send", {
|
|
4093
|
+
rejectedMessageId: ue.userMessage.id
|
|
4166
4094
|
});
|
|
4167
4095
|
return;
|
|
4168
4096
|
}
|
|
4169
|
-
|
|
4097
|
+
Y((ce) => ce + 1), i.notifySendAccepted(S);
|
|
4170
4098
|
}
|
|
4171
4099
|
).finally(() => {
|
|
4172
|
-
|
|
4100
|
+
x === I.current && y.current--;
|
|
4173
4101
|
});
|
|
4174
|
-
return
|
|
4102
|
+
return b.current = P.then(
|
|
4175
4103
|
() => {
|
|
4176
4104
|
},
|
|
4177
4105
|
() => {
|
|
4178
4106
|
}
|
|
4179
|
-
),
|
|
4107
|
+
), P;
|
|
4180
4108
|
},
|
|
4181
4109
|
[i]
|
|
4182
|
-
),
|
|
4183
|
-
const
|
|
4184
|
-
if (!
|
|
4110
|
+
), Ur = q(() => {
|
|
4111
|
+
const S = Re.current;
|
|
4112
|
+
if (!S) return;
|
|
4185
4113
|
if (!g.current.enqueue({
|
|
4186
|
-
...
|
|
4187
|
-
retryUuid:
|
|
4114
|
+
...S,
|
|
4115
|
+
retryUuid: xt()
|
|
4188
4116
|
})) {
|
|
4189
|
-
|
|
4117
|
+
ne.warn("agent chat queue full; retry not enqueued");
|
|
4190
4118
|
return;
|
|
4191
4119
|
}
|
|
4192
|
-
w(),
|
|
4193
|
-
}, [w]),
|
|
4120
|
+
w(), Y((R) => R + 1);
|
|
4121
|
+
}, [w]), qr = q((S) => {
|
|
4194
4122
|
g.current.removeWhere(
|
|
4195
|
-
(
|
|
4196
|
-
) &&
|
|
4197
|
-
}, []),
|
|
4123
|
+
(R) => R.userMessage.id === S
|
|
4124
|
+
) && Y((R) => R + 1);
|
|
4125
|
+
}, []), Zr = q(() => {
|
|
4198
4126
|
m.current = "stopping", v.current = !1;
|
|
4199
|
-
const
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
}).catch((
|
|
4203
|
-
|
|
4127
|
+
const S = I.current;
|
|
4128
|
+
vn({ api: s, sessionId: r, chatStop: E }).then(() => {
|
|
4129
|
+
S === I.current && (v.current = !0);
|
|
4130
|
+
}).catch((x) => {
|
|
4131
|
+
ne.error("agent chat stop failed", x);
|
|
4204
4132
|
}).then(() => {
|
|
4205
|
-
if (
|
|
4133
|
+
if (S === I.current) {
|
|
4206
4134
|
if (!r) {
|
|
4207
|
-
|
|
4135
|
+
ie(!1);
|
|
4208
4136
|
return;
|
|
4209
4137
|
}
|
|
4210
|
-
return e.reconcileAfterStream(r).catch((
|
|
4211
|
-
|
|
4138
|
+
return e.reconcileAfterStream(r).catch((x) => {
|
|
4139
|
+
ne.error("agent chat post-stop reconcile failed", x);
|
|
4212
4140
|
});
|
|
4213
4141
|
}
|
|
4214
4142
|
}).finally(() => {
|
|
4215
|
-
|
|
4143
|
+
S === I.current && (m.current = "idle", Y((x) => x + 1));
|
|
4216
4144
|
});
|
|
4217
4145
|
}, [s, r, E, e]);
|
|
4218
|
-
|
|
4219
|
-
const
|
|
4220
|
-
send:
|
|
4221
|
-
hasPendingWork: () => y.current > 0 ||
|
|
4146
|
+
Z(() => {
|
|
4147
|
+
const S = {
|
|
4148
|
+
send: It,
|
|
4149
|
+
hasPendingWork: () => y.current > 0 || Q.current || g.current.size > 0 || m.current !== "idle" || oe.current === "submitted" || oe.current === "streaming"
|
|
4222
4150
|
};
|
|
4223
|
-
return i.registerAgentHandlers(
|
|
4224
|
-
}, [i,
|
|
4225
|
-
const
|
|
4226
|
-
|
|
4151
|
+
return i.registerAgentHandlers(S), () => i.unregisterAgentHandlers(S);
|
|
4152
|
+
}, [i, It]);
|
|
4153
|
+
const We = (wt = t.presentation) == null ? void 0 : wt.toolActivity, Be = (_t = t.presentation) == null ? void 0 : _t.reasoning;
|
|
4154
|
+
Z(() => {
|
|
4227
4155
|
var L, le;
|
|
4228
4156
|
if (!r) return;
|
|
4229
|
-
const
|
|
4230
|
-
|
|
4231
|
-
let
|
|
4157
|
+
const S = We === void 0 && Be === void 0 ? void 0 : { toolActivity: We, reasoning: Be }, x = tt.current, R = (x == null ? void 0 : x.sessionId) === r && (((L = x.presentation) == null ? void 0 : L.toolActivity) !== We || ((le = x.presentation) == null ? void 0 : le.reasoning) !== Be);
|
|
4158
|
+
tt.current = { sessionId: r, presentation: S };
|
|
4159
|
+
let P = !1;
|
|
4232
4160
|
return (async () => {
|
|
4233
4161
|
try {
|
|
4234
|
-
const
|
|
4235
|
-
if (!
|
|
4162
|
+
const U = S === void 0 ? await s.getAgentTurnMessages(r) : await s.getAgentTurnMessages(r, S);
|
|
4163
|
+
if (!U || P) return;
|
|
4236
4164
|
Ze(
|
|
4237
|
-
(ue) =>
|
|
4165
|
+
(ue) => mn({ existing: ue, fetched: U, refreshItems: R })
|
|
4238
4166
|
);
|
|
4239
|
-
} catch (
|
|
4240
|
-
|
|
4167
|
+
} catch (U) {
|
|
4168
|
+
ne.error("agent chat turn sources fetch failed", U);
|
|
4241
4169
|
}
|
|
4242
4170
|
})(), () => {
|
|
4243
|
-
|
|
4171
|
+
P = !0;
|
|
4244
4172
|
};
|
|
4245
|
-
}, [r, s,
|
|
4246
|
-
const
|
|
4173
|
+
}, [r, s, We, Be]);
|
|
4174
|
+
const zr = B(() => {
|
|
4247
4175
|
if (!f) return [];
|
|
4248
|
-
const
|
|
4249
|
-
if (!
|
|
4250
|
-
const
|
|
4251
|
-
for (const
|
|
4252
|
-
|
|
4253
|
-
key: `${r ?? "pending"}:${
|
|
4176
|
+
const S = _.at(-1);
|
|
4177
|
+
if (!S || S.role !== "assistant") return [];
|
|
4178
|
+
const x = [];
|
|
4179
|
+
for (const R of S.parts)
|
|
4180
|
+
xe(R) && Us(R) === yn && (R.state !== "input-available" && R.state !== "output-available" || x.push({
|
|
4181
|
+
key: `${r ?? "pending"}:${R.toolCallId}`,
|
|
4254
4182
|
type: "highlight-element",
|
|
4255
|
-
input:
|
|
4183
|
+
input: R.input
|
|
4256
4184
|
}));
|
|
4257
|
-
return
|
|
4258
|
-
}, [
|
|
4259
|
-
|
|
4260
|
-
if (
|
|
4261
|
-
const
|
|
4262
|
-
if (
|
|
4263
|
-
const
|
|
4264
|
-
|
|
4265
|
-
}, [
|
|
4266
|
-
const
|
|
4267
|
-
document.visibilityState === "visible" && r && (
|
|
4185
|
+
return x;
|
|
4186
|
+
}, [_, r, f]), se = h === "submitted" || h === "streaming";
|
|
4187
|
+
Z(() => {
|
|
4188
|
+
if (se) return;
|
|
4189
|
+
const S = Se.current;
|
|
4190
|
+
if (S === null) return;
|
|
4191
|
+
const x = _.at(-1);
|
|
4192
|
+
x && x.role === "assistant" && ze(x, S);
|
|
4193
|
+
}, [_, se, ze]), Z(() => {
|
|
4194
|
+
const S = () => {
|
|
4195
|
+
document.visibilityState === "visible" && r && (se || C === void 0 && !te || N());
|
|
4268
4196
|
};
|
|
4269
|
-
return document.addEventListener("visibilitychange",
|
|
4270
|
-
document.removeEventListener("visibilitychange",
|
|
4197
|
+
return document.addEventListener("visibilitychange", S), window.addEventListener("online", S), () => {
|
|
4198
|
+
document.removeEventListener("visibilitychange", S), window.removeEventListener("online", S);
|
|
4271
4199
|
};
|
|
4272
|
-
}, [r,
|
|
4273
|
-
if (
|
|
4274
|
-
const
|
|
4275
|
-
|
|
4200
|
+
}, [r, se, te, C, N]), Z(() => {
|
|
4201
|
+
if (se || !te) return;
|
|
4202
|
+
const S = () => {
|
|
4203
|
+
ie(!1), Y((P) => P + 1), Te.current === Se.current && me(null), Se.current = null;
|
|
4276
4204
|
};
|
|
4277
|
-
if (
|
|
4278
|
-
(
|
|
4205
|
+
if (Te.current === Se.current && (c == null ? void 0 : c.messages) === _ && !c.isError && !c.isDisconnect && (!c.isAbort || v.current) && !He(c.message.parts).some(
|
|
4206
|
+
(P) => P.kind !== "steps"
|
|
4279
4207
|
)) {
|
|
4280
|
-
const
|
|
4281
|
-
|
|
4208
|
+
const P = a.findLast((L) => L.type === "USER");
|
|
4209
|
+
P && i.state.setPartial({ settledAgentUserMessageId: P.id }), S();
|
|
4282
4210
|
return;
|
|
4283
4211
|
}
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4212
|
+
if (c && c.messages !== _) return;
|
|
4213
|
+
const x = _.at(-1), R = (x == null ? void 0 : x.role) === "assistant" ? Ht(x.parts) : null;
|
|
4214
|
+
if (R && R.rowIds.length > 0) {
|
|
4215
|
+
const P = new Set(a.map((L) => L.id));
|
|
4216
|
+
R.rowIds.every((L) => P.has(L)) && S();
|
|
4217
|
+
return;
|
|
4218
|
+
}
|
|
4219
|
+
for (let P = a.length - 1; P >= 0; P -= 1) {
|
|
4220
|
+
const L = a[P];
|
|
4221
|
+
if (L) {
|
|
4222
|
+
if (L.type === "USER") return;
|
|
4223
|
+
if (!(L.type !== "AI" && L.type !== "AGENT")) {
|
|
4224
|
+
S();
|
|
4290
4225
|
return;
|
|
4291
4226
|
}
|
|
4292
4227
|
}
|
|
4293
4228
|
}
|
|
4294
4229
|
}, [
|
|
4295
|
-
|
|
4296
|
-
|
|
4230
|
+
se,
|
|
4231
|
+
te,
|
|
4297
4232
|
a,
|
|
4298
4233
|
me,
|
|
4299
4234
|
c,
|
|
4300
|
-
|
|
4235
|
+
_,
|
|
4301
4236
|
i,
|
|
4302
|
-
|
|
4237
|
+
k
|
|
4303
4238
|
]);
|
|
4304
|
-
const
|
|
4239
|
+
const Ce = Hr(
|
|
4305
4240
|
e.agent.presentation,
|
|
4306
4241
|
t.presentation
|
|
4307
|
-
),
|
|
4308
|
-
if (!
|
|
4309
|
-
const
|
|
4310
|
-
return !
|
|
4311
|
-
toolActivity:
|
|
4312
|
-
reasoning:
|
|
4242
|
+
), Ve = Ce == null ? void 0 : Ce.toolActivity, Je = Ce == null ? void 0 : Ce.reasoning, Wr = B(() => {
|
|
4243
|
+
if (h === "submitted" || !se && !te) return [];
|
|
4244
|
+
const S = _.at(-1);
|
|
4245
|
+
return !S || S.role !== "assistant" ? [] : Vt(He(S.parts), {
|
|
4246
|
+
toolActivity: Ve,
|
|
4247
|
+
reasoning: Je
|
|
4313
4248
|
});
|
|
4314
|
-
}, [
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4249
|
+
}, [
|
|
4250
|
+
_,
|
|
4251
|
+
h,
|
|
4252
|
+
se,
|
|
4253
|
+
te,
|
|
4254
|
+
Ve,
|
|
4255
|
+
Je
|
|
4256
|
+
]), Br = B(
|
|
4257
|
+
() => Me.flatMap((S) => {
|
|
4258
|
+
const x = Vt(S.items, {
|
|
4259
|
+
toolActivity: Ve,
|
|
4260
|
+
reasoning: Je
|
|
4319
4261
|
});
|
|
4320
|
-
return
|
|
4262
|
+
return x.length === 0 ? [] : [x === S.items ? S : { ...S, items: x }];
|
|
4321
4263
|
}),
|
|
4322
|
-
[
|
|
4323
|
-
),
|
|
4324
|
-
() => g.current.items.map((
|
|
4264
|
+
[Me, Ve, Je]
|
|
4265
|
+
), Vr = B(
|
|
4266
|
+
() => g.current.items.map((S) => S.userMessage),
|
|
4325
4267
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- queueRef is mutable; queueVersion is the signal
|
|
4326
|
-
[
|
|
4268
|
+
[k]
|
|
4327
4269
|
);
|
|
4328
4270
|
return {
|
|
4329
|
-
isStreaming:
|
|
4330
|
-
liveItems:
|
|
4271
|
+
isStreaming: se,
|
|
4272
|
+
liveItems: Wr,
|
|
4331
4273
|
/** Finished turns' render sources — see `TurnRenderSource`. */
|
|
4332
|
-
turnSources:
|
|
4274
|
+
turnSources: Br,
|
|
4333
4275
|
/** The live turn's node key (stable through the retained promotion). */
|
|
4334
|
-
liveTurnKey:
|
|
4276
|
+
liveTurnKey: Fr,
|
|
4335
4277
|
/** The last turn failed — the transcript renders a visible error row. */
|
|
4336
4278
|
turnFailed: C !== void 0,
|
|
4337
|
-
retryFailedTurn:
|
|
4338
|
-
queuedUserMessages:
|
|
4339
|
-
removeQueued:
|
|
4340
|
-
stop:
|
|
4341
|
-
pageEffects:
|
|
4279
|
+
retryFailedTurn: Ur,
|
|
4280
|
+
queuedUserMessages: Vr,
|
|
4281
|
+
removeQueued: qr,
|
|
4282
|
+
stop: Zr,
|
|
4283
|
+
pageEffects: zr
|
|
4342
4284
|
};
|
|
4343
4285
|
}
|
|
4344
|
-
function
|
|
4286
|
+
function Sn(e) {
|
|
4345
4287
|
return e ? { ...e, initialMessages: [] } : null;
|
|
4346
4288
|
}
|
|
4347
|
-
const
|
|
4289
|
+
const bt = {
|
|
4348
4290
|
isStreaming: !1,
|
|
4349
4291
|
liveItems: [],
|
|
4350
4292
|
turnSources: [],
|
|
@@ -4359,17 +4301,17 @@ const Et = {
|
|
|
4359
4301
|
},
|
|
4360
4302
|
pageEffects: [],
|
|
4361
4303
|
pendingClarification: null
|
|
4362
|
-
},
|
|
4363
|
-
function
|
|
4364
|
-
return $e(
|
|
4304
|
+
}, Qe = Fe(null);
|
|
4305
|
+
function Ar() {
|
|
4306
|
+
return $e(Qe) ?? bt;
|
|
4365
4307
|
}
|
|
4366
|
-
function
|
|
4308
|
+
function En({
|
|
4367
4309
|
children: e,
|
|
4368
4310
|
widgetCtx: t,
|
|
4369
4311
|
config: r
|
|
4370
4312
|
}) {
|
|
4371
4313
|
var C, w;
|
|
4372
|
-
const a =
|
|
4314
|
+
const a = $(t.sessionCtx.sessionState), s = $(t.messageCtx.state), {
|
|
4373
4315
|
isStreaming: i,
|
|
4374
4316
|
liveItems: l,
|
|
4375
4317
|
turnSources: n,
|
|
@@ -4379,13 +4321,13 @@ function An({
|
|
|
4379
4321
|
queuedUserMessages: p,
|
|
4380
4322
|
removeQueued: v,
|
|
4381
4323
|
stop: h,
|
|
4382
|
-
pageEffects:
|
|
4383
|
-
} =
|
|
4324
|
+
pageEffects: _
|
|
4325
|
+
} = bn({
|
|
4384
4326
|
widgetCtx: t,
|
|
4385
4327
|
config: r,
|
|
4386
4328
|
sessionId: ((C = a.session) == null ? void 0 : C.id) ?? null,
|
|
4387
4329
|
persistedMessages: s.messages
|
|
4388
|
-
}), M = ((w = s.messages.at(-1)) == null ? void 0 : w.type) === "USER", E =
|
|
4330
|
+
}), M = ((w = s.messages.at(-1)) == null ? void 0 : w.type) === "USER", E = B(
|
|
4389
4331
|
() => ({
|
|
4390
4332
|
isStreaming: i,
|
|
4391
4333
|
liveItems: l,
|
|
@@ -4396,8 +4338,8 @@ function An({
|
|
|
4396
4338
|
queuedUserMessages: p,
|
|
4397
4339
|
removeQueued: v,
|
|
4398
4340
|
stop: h,
|
|
4399
|
-
pageEffects:
|
|
4400
|
-
pendingClarification:
|
|
4341
|
+
pageEffects: _,
|
|
4342
|
+
pendingClarification: aa({
|
|
4401
4343
|
turnSources: n,
|
|
4402
4344
|
liveItems: l,
|
|
4403
4345
|
isStreaming: i,
|
|
@@ -4414,20 +4356,20 @@ function An({
|
|
|
4414
4356
|
p,
|
|
4415
4357
|
v,
|
|
4416
4358
|
h,
|
|
4417
|
-
|
|
4359
|
+
_,
|
|
4418
4360
|
M
|
|
4419
4361
|
]
|
|
4420
4362
|
);
|
|
4421
|
-
return /* @__PURE__ */
|
|
4363
|
+
return /* @__PURE__ */ F.createElement(Qe.Provider, { value: E }, e);
|
|
4422
4364
|
}
|
|
4423
|
-
function
|
|
4365
|
+
function Mr({
|
|
4424
4366
|
children: e,
|
|
4425
4367
|
widgetCtx: t,
|
|
4426
4368
|
config: r
|
|
4427
4369
|
}) {
|
|
4428
|
-
return
|
|
4370
|
+
return $(t.messageCtx.state), t.streaming ? /* @__PURE__ */ F.createElement(En, { widgetCtx: t, config: r }, e) : /* @__PURE__ */ F.createElement(Qe.Provider, { value: bt }, e);
|
|
4429
4371
|
}
|
|
4430
|
-
class
|
|
4372
|
+
class Cn {
|
|
4431
4373
|
constructor(t) {
|
|
4432
4374
|
this.root = t, this.nextId = 1, this.mountVersion = 0, this.disposed = !1, this.mount = () => {
|
|
4433
4375
|
const a = ++this.mountVersion;
|
|
@@ -4500,7 +4442,7 @@ class Mn {
|
|
|
4500
4442
|
});
|
|
4501
4443
|
};
|
|
4502
4444
|
const r = this.makeChat(t);
|
|
4503
|
-
this.state = new
|
|
4445
|
+
this.state = new Qt({ chats: [r], activeId: r.id });
|
|
4504
4446
|
}
|
|
4505
4447
|
makeChat(t) {
|
|
4506
4448
|
return {
|
|
@@ -4510,7 +4452,7 @@ class Mn {
|
|
|
4510
4452
|
working: !1,
|
|
4511
4453
|
hasSession: !1,
|
|
4512
4454
|
hasDraft: !1,
|
|
4513
|
-
ui:
|
|
4455
|
+
ui: bt
|
|
4514
4456
|
};
|
|
4515
4457
|
}
|
|
4516
4458
|
releaseChat(t) {
|
|
@@ -4524,15 +4466,15 @@ class Mn {
|
|
|
4524
4466
|
return !t.closed && !r && !this.isWorking(t) && !t.ctx.messageCtx.state.get().messages.length && !a && !s.length && !t.ctx.uploadCtx.state.get().length;
|
|
4525
4467
|
}
|
|
4526
4468
|
}
|
|
4527
|
-
const
|
|
4528
|
-
function
|
|
4529
|
-
const e = $e(
|
|
4469
|
+
const Tr = Fe(null), In = new Qt({ chats: [], activeId: 0 });
|
|
4470
|
+
function Rr() {
|
|
4471
|
+
const e = $e(Tr), t = $((e == null ? void 0 : e.state) ?? In), r = t.chats.filter((s) => !s.closed), a = r.filter(
|
|
4530
4472
|
(s) => s.hasSession || s.working || s.hasDraft || s.title
|
|
4531
4473
|
);
|
|
4532
4474
|
return { workspace: e, chats: r, openChats: a, activeId: t.activeId };
|
|
4533
4475
|
}
|
|
4534
|
-
function
|
|
4535
|
-
const { workspace: e, ...t } =
|
|
4476
|
+
function Un() {
|
|
4477
|
+
const { workspace: e, ...t } = Rr();
|
|
4536
4478
|
if (!e)
|
|
4537
4479
|
throw new Error("Companion chats require a conversation workspace");
|
|
4538
4480
|
return {
|
|
@@ -4542,35 +4484,35 @@ function Vn() {
|
|
|
4542
4484
|
newChat: e.open
|
|
4543
4485
|
};
|
|
4544
4486
|
}
|
|
4545
|
-
function
|
|
4487
|
+
function wn({
|
|
4546
4488
|
chat: e,
|
|
4547
4489
|
workspace: t
|
|
4548
4490
|
}) {
|
|
4549
|
-
const r =
|
|
4491
|
+
const r = Ar(), a = $(e.ctx.messageCtx.state), s = $(e.ctx.sessionCtx.sessionState), i = $(e.ctx.messageCtx.draftState), l = $(e.ctx.uploadCtx.state), n = a.messages.find(
|
|
4550
4492
|
(v) => v.type === "USER"
|
|
4551
4493
|
), f = (n == null ? void 0 : n.type) === "USER" ? n.content.slice(0, 60) : "", u = r.isStreaming || a.isSendingMessage || s.isCreatingSession, c = !!s.session, p = !!i.text || i.mentions.length > 0 || l.length > 0;
|
|
4552
|
-
return
|
|
4494
|
+
return Z(
|
|
4553
4495
|
() => t.update(e.id, { title: f, working: u, hasSession: c, hasDraft: p, ui: r }),
|
|
4554
4496
|
[t, e.id, f, u, c, p, r]
|
|
4555
4497
|
), null;
|
|
4556
4498
|
}
|
|
4557
|
-
function
|
|
4499
|
+
function _n({
|
|
4558
4500
|
widgetCtx: e,
|
|
4559
4501
|
config: t = e.config,
|
|
4560
4502
|
children: r
|
|
4561
4503
|
}) {
|
|
4562
|
-
const a =
|
|
4563
|
-
() => new
|
|
4504
|
+
const a = B(
|
|
4505
|
+
() => new Cn(e),
|
|
4564
4506
|
[e]
|
|
4565
4507
|
);
|
|
4566
|
-
|
|
4567
|
-
const { chats: s, activeId: i } =
|
|
4568
|
-
() => s.map((f) => /* @__PURE__ */
|
|
4508
|
+
Z(() => a.mount(), [a]);
|
|
4509
|
+
const { chats: s, activeId: i } = $(a.state), l = s.find((f) => f.id === i), n = B(
|
|
4510
|
+
() => s.map((f) => /* @__PURE__ */ F.createElement(Mr, { key: f.id, widgetCtx: f.ctx, config: t }, /* @__PURE__ */ F.createElement(wn, { chat: f, workspace: a }))),
|
|
4569
4511
|
[s, t, a]
|
|
4570
4512
|
);
|
|
4571
|
-
return /* @__PURE__ */
|
|
4513
|
+
return /* @__PURE__ */ F.createElement(Tr.Provider, { value: a }, n, /* @__PURE__ */ F.createElement(Qe.Provider, { value: l.ui }, r(l.ctx)));
|
|
4572
4514
|
}
|
|
4573
|
-
class
|
|
4515
|
+
class xn {
|
|
4574
4516
|
constructor(t) {
|
|
4575
4517
|
this.components = [];
|
|
4576
4518
|
const { components: r } = t;
|
|
@@ -4596,8 +4538,8 @@ class On {
|
|
|
4596
4538
|
return (r = this.get(t)) == null ? void 0 : r.component;
|
|
4597
4539
|
}
|
|
4598
4540
|
}
|
|
4599
|
-
const
|
|
4600
|
-
function
|
|
4541
|
+
const Pr = Fe(null);
|
|
4542
|
+
function qn({
|
|
4601
4543
|
options: e,
|
|
4602
4544
|
children: t,
|
|
4603
4545
|
components: r,
|
|
@@ -4605,65 +4547,65 @@ function Jn({
|
|
|
4605
4547
|
loadingComponent: s,
|
|
4606
4548
|
errorComponent: i
|
|
4607
4549
|
}) {
|
|
4608
|
-
const l =
|
|
4550
|
+
const l = D(e);
|
|
4609
4551
|
l.current = e;
|
|
4610
|
-
const n =
|
|
4611
|
-
() => new
|
|
4552
|
+
const n = D(null), f = D(null), [u, c] = V({ status: "loading" }), p = B(
|
|
4553
|
+
() => new xn({
|
|
4612
4554
|
components: r
|
|
4613
4555
|
}),
|
|
4614
4556
|
[r]
|
|
4615
4557
|
);
|
|
4616
|
-
if (
|
|
4617
|
-
const
|
|
4558
|
+
if (Z(() => {
|
|
4559
|
+
const _ = f.current ?? (f.current = Gr.initialize({
|
|
4618
4560
|
config: e,
|
|
4619
4561
|
storage: a,
|
|
4620
4562
|
getClientCapabilities: () => l.current.capabilities,
|
|
4621
4563
|
getRequestConfig: () => l.current
|
|
4622
4564
|
}));
|
|
4623
4565
|
let M = !0;
|
|
4624
|
-
return
|
|
4566
|
+
return _.then(
|
|
4625
4567
|
(E) => {
|
|
4626
4568
|
M && c({ status: "ready", widgetCtx: E });
|
|
4627
4569
|
},
|
|
4628
4570
|
(E) => {
|
|
4629
4571
|
const C = E instanceof Error ? E : new Error("Widget initialization failed", { cause: E });
|
|
4630
|
-
|
|
4572
|
+
ne.error("widget initialization failed", C), M && c({ status: "error", error: C });
|
|
4631
4573
|
}
|
|
4632
4574
|
), () => {
|
|
4633
4575
|
M = !1;
|
|
4634
4576
|
};
|
|
4635
4577
|
}, []), u.status === "loading")
|
|
4636
|
-
return s ? /* @__PURE__ */
|
|
4578
|
+
return s ? /* @__PURE__ */ F.createElement(F.Fragment, null, s) : null;
|
|
4637
4579
|
if (u.status === "error")
|
|
4638
|
-
return i ? /* @__PURE__ */
|
|
4639
|
-
const { widgetCtx: v } = u, h = (
|
|
4640
|
-
|
|
4580
|
+
return i ? /* @__PURE__ */ F.createElement(F.Fragment, null, i(u.error)) : null;
|
|
4581
|
+
const { widgetCtx: v } = u, h = (_, M) => /* @__PURE__ */ F.createElement(
|
|
4582
|
+
Pr.Provider,
|
|
4641
4583
|
{
|
|
4642
4584
|
value: {
|
|
4643
|
-
widgetCtx:
|
|
4585
|
+
widgetCtx: _,
|
|
4644
4586
|
config: e,
|
|
4645
4587
|
components: r,
|
|
4646
4588
|
componentStore: p,
|
|
4647
|
-
version:
|
|
4589
|
+
version: ra,
|
|
4648
4590
|
contentIframeRef: n
|
|
4649
4591
|
}
|
|
4650
4592
|
},
|
|
4651
4593
|
M
|
|
4652
4594
|
);
|
|
4653
|
-
return e.displayMode === "companion" && !e.inline ? /* @__PURE__ */
|
|
4595
|
+
return e.displayMode === "companion" && !e.inline ? /* @__PURE__ */ F.createElement(_n, { widgetCtx: v, config: e }, (_) => h(_, t)) : h(
|
|
4654
4596
|
v,
|
|
4655
|
-
/* @__PURE__ */
|
|
4597
|
+
/* @__PURE__ */ F.createElement(Mr, { widgetCtx: v, config: e }, t)
|
|
4656
4598
|
);
|
|
4657
4599
|
}
|
|
4658
|
-
function
|
|
4659
|
-
const e = $e(
|
|
4600
|
+
function K() {
|
|
4601
|
+
const e = $e(Pr);
|
|
4660
4602
|
if (!e)
|
|
4661
4603
|
throw new Error("useWidget must be used within a WidgetProvider");
|
|
4662
4604
|
return e;
|
|
4663
4605
|
}
|
|
4664
|
-
function
|
|
4665
|
-
const { config: e, widgetCtx: t } =
|
|
4666
|
-
return
|
|
4606
|
+
function Zn() {
|
|
4607
|
+
const { config: e, widgetCtx: t } = K(), { name: r, avatarUrl: a } = t.agent, s = e.bot;
|
|
4608
|
+
return B(
|
|
4667
4609
|
() => ({
|
|
4668
4610
|
isAi: !0,
|
|
4669
4611
|
id: null,
|
|
@@ -4674,24 +4616,24 @@ function Kn() {
|
|
|
4674
4616
|
[s == null ? void 0 : s.name, s == null ? void 0 : s.avatarUrl, s == null ? void 0 : s.avatar, r, a]
|
|
4675
4617
|
);
|
|
4676
4618
|
}
|
|
4677
|
-
function
|
|
4678
|
-
const { config: e } =
|
|
4619
|
+
function Xe() {
|
|
4620
|
+
const { config: e } = K();
|
|
4679
4621
|
return e;
|
|
4680
4622
|
}
|
|
4681
|
-
function
|
|
4682
|
-
const { config: e } =
|
|
4623
|
+
function zn() {
|
|
4624
|
+
const { config: e } = K();
|
|
4683
4625
|
return e.displayMode ?? "popover";
|
|
4684
4626
|
}
|
|
4685
|
-
function
|
|
4686
|
-
const { widgetCtx: e } =
|
|
4627
|
+
function Wn() {
|
|
4628
|
+
const { widgetCtx: e } = K();
|
|
4687
4629
|
return {
|
|
4688
|
-
contactState:
|
|
4630
|
+
contactState: $(e.contactCtx.state),
|
|
4689
4631
|
createUnverifiedContact: e.contactCtx.createUnverifiedContact
|
|
4690
4632
|
};
|
|
4691
4633
|
}
|
|
4692
|
-
function
|
|
4693
|
-
const [e, t] =
|
|
4694
|
-
return
|
|
4634
|
+
function An() {
|
|
4635
|
+
const [e, t] = V("ltr");
|
|
4636
|
+
return Z(() => {
|
|
4695
4637
|
const r = () => {
|
|
4696
4638
|
typeof document > "u" || t(
|
|
4697
4639
|
window.getComputedStyle((window.top || window).document.body).direction
|
|
@@ -4710,8 +4652,8 @@ function Nn() {
|
|
|
4710
4652
|
};
|
|
4711
4653
|
}, []), { dir: e };
|
|
4712
4654
|
}
|
|
4713
|
-
const
|
|
4714
|
-
function
|
|
4655
|
+
const Mn = 500, ot = "opencx:context-changed";
|
|
4656
|
+
function Or() {
|
|
4715
4657
|
if (typeof window > "u") return null;
|
|
4716
4658
|
try {
|
|
4717
4659
|
const e = window.top ?? window;
|
|
@@ -4720,29 +4662,29 @@ function kr() {
|
|
|
4720
4662
|
return null;
|
|
4721
4663
|
}
|
|
4722
4664
|
}
|
|
4723
|
-
function
|
|
4724
|
-
const t =
|
|
4665
|
+
function Tn(e) {
|
|
4666
|
+
const t = Or();
|
|
4725
4667
|
if (!t) return () => {
|
|
4726
4668
|
};
|
|
4727
4669
|
const r = (s) => {
|
|
4728
|
-
(s == null ? void 0 : s.type) ===
|
|
4670
|
+
(s == null ? void 0 : s.type) === ot && (Nr += 1), e();
|
|
4729
4671
|
};
|
|
4730
|
-
t.addEventListener("popstate", r), t.addEventListener("hashchange", r), t.addEventListener(
|
|
4731
|
-
const a = t.setInterval(r,
|
|
4672
|
+
t.addEventListener("popstate", r), t.addEventListener("hashchange", r), t.addEventListener(ot, r);
|
|
4673
|
+
const a = t.setInterval(r, Mn);
|
|
4732
4674
|
return () => {
|
|
4733
|
-
t.removeEventListener("popstate", r), t.removeEventListener("hashchange", r), t.removeEventListener(
|
|
4675
|
+
t.removeEventListener("popstate", r), t.removeEventListener("hashchange", r), t.removeEventListener(ot, r), t.clearInterval(a);
|
|
4734
4676
|
};
|
|
4735
4677
|
}
|
|
4736
|
-
let
|
|
4737
|
-
function
|
|
4678
|
+
let Nr = 0;
|
|
4679
|
+
function Rn() {
|
|
4738
4680
|
var e;
|
|
4739
|
-
return `${
|
|
4681
|
+
return `${Nr}|${((e = Or()) == null ? void 0 : e.location.href) ?? ""}`;
|
|
4740
4682
|
}
|
|
4741
|
-
function
|
|
4742
|
-
return De(
|
|
4683
|
+
function Bn() {
|
|
4684
|
+
return De(Tn, Rn, () => "");
|
|
4743
4685
|
}
|
|
4744
|
-
function
|
|
4745
|
-
const { widgetCtx: e } =
|
|
4686
|
+
function jr() {
|
|
4687
|
+
const { widgetCtx: e } = K(), t = $(e.messageCtx.state), { isStreaming: r } = Ar();
|
|
4746
4688
|
return {
|
|
4747
4689
|
messagesState: r ? { ...t, isSendingMessage: !0, isSendingMessageToAI: !0 } : t,
|
|
4748
4690
|
sendMessage: e.messageCtx.sendMessage,
|
|
@@ -4752,12 +4694,12 @@ function Fr() {
|
|
|
4752
4694
|
getSentTextHistory: e.messageCtx.getSentTextHistory
|
|
4753
4695
|
};
|
|
4754
4696
|
}
|
|
4755
|
-
function
|
|
4697
|
+
function Dr() {
|
|
4756
4698
|
var f;
|
|
4757
|
-
const { widgetCtx: e } =
|
|
4699
|
+
const { widgetCtx: e } = K(), { oneOpenSessionAllowed: t } = Xe(), r = $(e.sessionCtx.sessionState), a = $(e.sessionCtx.sessionsState), { openSessions: s, closedSessions: i } = B(() => ({
|
|
4758
4700
|
openSessions: a.data.filter((u) => u.isOpened === !0),
|
|
4759
4701
|
closedSessions: a.data.filter((u) => u.isOpened === !1)
|
|
4760
|
-
}), [a.data]), { workspace: l } =
|
|
4702
|
+
}), [a.data]), { workspace: l } = Rr(), n = l ? l.canCreateChat() : !t || s.length === 0 && !r.isCreatingSession && !((f = r.session) != null && f.isOpened);
|
|
4761
4703
|
return {
|
|
4762
4704
|
sessionState: r,
|
|
4763
4705
|
sessionsState: a,
|
|
@@ -4769,23 +4711,23 @@ function $r() {
|
|
|
4769
4711
|
canCreateNewSession: n
|
|
4770
4712
|
};
|
|
4771
4713
|
}
|
|
4772
|
-
function
|
|
4714
|
+
function Vn() {
|
|
4773
4715
|
var l, n;
|
|
4774
|
-
const { sessionState: e } =
|
|
4716
|
+
const { sessionState: e } = Dr(), { messagesState: t } = jr(), r = ((l = e.session) == null ? void 0 : l.assignee.kind) === "ai", a = (n = t.messages) == null ? void 0 : n.at(-1), s = (a == null ? void 0 : a.type) === "USER" && a.id !== t.settledAgentUserMessageId;
|
|
4775
4717
|
return { isAwaitingBotReply: !!(t.isSendingMessageToAI || (r || e.isCreatingSession) && (t.isSendingMessage || s)) };
|
|
4776
4718
|
}
|
|
4777
|
-
function
|
|
4778
|
-
const { widgetCtx: e } =
|
|
4719
|
+
function Jn() {
|
|
4720
|
+
const { widgetCtx: e } = K();
|
|
4779
4721
|
return {
|
|
4780
|
-
routerState:
|
|
4722
|
+
routerState: $(e.routerCtx.state),
|
|
4781
4723
|
toSessionsScreen: e.routerCtx.toSessionsScreen,
|
|
4782
4724
|
toChatScreen: e.routerCtx.toChatScreen
|
|
4783
4725
|
};
|
|
4784
4726
|
}
|
|
4785
|
-
function
|
|
4727
|
+
function Kn() {
|
|
4786
4728
|
const {
|
|
4787
4729
|
widgetCtx: { uploadCtx: e }
|
|
4788
|
-
} =
|
|
4730
|
+
} = K(), t = $(e.state), r = B(
|
|
4789
4731
|
() => t.filter((a) => a.status === "success" && a.fileUrl),
|
|
4790
4732
|
[t]
|
|
4791
4733
|
);
|
|
@@ -4808,47 +4750,47 @@ function ei() {
|
|
|
4808
4750
|
isUploading: t.some((a) => a.status === "uploading")
|
|
4809
4751
|
};
|
|
4810
4752
|
}
|
|
4811
|
-
const
|
|
4812
|
-
function
|
|
4813
|
-
const t =
|
|
4814
|
-
return
|
|
4753
|
+
const kr = Fe(null);
|
|
4754
|
+
function Yn({ children: e }) {
|
|
4755
|
+
const t = Xe(), [r, a] = V(() => t.inline ? !0 : t.isOpen ?? !1);
|
|
4756
|
+
return Z(() => {
|
|
4815
4757
|
a((s) => t.isOpen ?? s);
|
|
4816
|
-
}, [t.isOpen]),
|
|
4758
|
+
}, [t.isOpen]), Z(() => {
|
|
4817
4759
|
const s = t.openAfterNSeconds;
|
|
4818
4760
|
if (typeof s != "number" || isNaN(s))
|
|
4819
4761
|
return;
|
|
4820
4762
|
const i = setTimeout(() => a(!0), s * 1e3);
|
|
4821
4763
|
return () => clearTimeout(i);
|
|
4822
|
-
}, [t.openAfterNSeconds]), /* @__PURE__ */
|
|
4764
|
+
}, [t.openAfterNSeconds]), /* @__PURE__ */ F.createElement(kr.Provider, { value: { isOpen: r, setIsOpen: a } }, e);
|
|
4823
4765
|
}
|
|
4824
|
-
function
|
|
4825
|
-
const e = $e(
|
|
4766
|
+
function Hn() {
|
|
4767
|
+
const e = $e(kr);
|
|
4826
4768
|
if (!e)
|
|
4827
4769
|
throw new Error(
|
|
4828
4770
|
"useWidgetTrigger must be used within a WidgetTriggerProvider"
|
|
4829
4771
|
);
|
|
4830
4772
|
return e;
|
|
4831
4773
|
}
|
|
4832
|
-
function
|
|
4774
|
+
function Pn(e) {
|
|
4833
4775
|
return e !== "fullscreen";
|
|
4834
4776
|
}
|
|
4835
|
-
const
|
|
4836
|
-
function
|
|
4777
|
+
const Lr = Fe(null);
|
|
4778
|
+
function Gn({ children: e }) {
|
|
4837
4779
|
var s, i;
|
|
4838
|
-
const { companion: t } =
|
|
4839
|
-
return /* @__PURE__ */
|
|
4840
|
-
|
|
4780
|
+
const { companion: t } = Xe(), { dir: r } = An(), { widgetCtx: a } = K();
|
|
4781
|
+
return /* @__PURE__ */ F.createElement(
|
|
4782
|
+
On,
|
|
4841
4783
|
{
|
|
4842
4784
|
configuredDefaultLayout: t == null ? void 0 : t.defaultLayout,
|
|
4843
4785
|
configuredLayouts: t == null ? void 0 : t.layouts,
|
|
4844
|
-
configuredSidebarSide:
|
|
4845
|
-
configuredSidebarMode:
|
|
4786
|
+
configuredSidebarSide: Xr((s = t == null ? void 0 : t.sidebar) == null ? void 0 : s.side, r),
|
|
4787
|
+
configuredSidebarMode: Qr((i = t == null ? void 0 : t.sidebar) == null ? void 0 : i.mode),
|
|
4846
4788
|
storage: a.storageCtx
|
|
4847
4789
|
},
|
|
4848
4790
|
e
|
|
4849
4791
|
);
|
|
4850
4792
|
}
|
|
4851
|
-
function
|
|
4793
|
+
function On({
|
|
4852
4794
|
configuredDefaultLayout: e,
|
|
4853
4795
|
configuredLayouts: t,
|
|
4854
4796
|
configuredSidebarSide: r,
|
|
@@ -4856,62 +4798,62 @@ function Fn({
|
|
|
4856
4798
|
storage: s,
|
|
4857
4799
|
children: i
|
|
4858
4800
|
}) {
|
|
4859
|
-
const l =
|
|
4801
|
+
const l = ea(t), n = ta(
|
|
4860
4802
|
e,
|
|
4861
4803
|
l
|
|
4862
|
-
), f = l.join("|"), [u, c] =
|
|
4804
|
+
), f = l.join("|"), [u, c] = V(n), [p, v] = V({
|
|
4863
4805
|
defaultLayout: n,
|
|
4864
4806
|
allowedLayoutsKey: f
|
|
4865
4807
|
});
|
|
4866
4808
|
(p.defaultLayout !== n || p.allowedLayoutsKey !== f) && (v({ defaultLayout: n, allowedLayoutsKey: f }), (p.defaultLayout !== n || !l.includes(u)) && c(n));
|
|
4867
4809
|
const h = (y) => {
|
|
4868
|
-
c((
|
|
4869
|
-
const
|
|
4870
|
-
return l.includes(
|
|
4810
|
+
c((I) => {
|
|
4811
|
+
const k = typeof y == "function" ? y(I) : y;
|
|
4812
|
+
return l.includes(k) ? k : I;
|
|
4871
4813
|
});
|
|
4872
|
-
},
|
|
4873
|
-
|
|
4814
|
+
}, _ = D(l);
|
|
4815
|
+
_.current = l;
|
|
4874
4816
|
const M = (y) => {
|
|
4875
|
-
h(y),
|
|
4817
|
+
h(y), _.current.includes(y) && Pn(y) && (s == null || s.setCompanionLayout(y).catch(() => {
|
|
4876
4818
|
}));
|
|
4877
|
-
}, [E, C] =
|
|
4819
|
+
}, [E, C] = V(r), [w, N] = V(a), [d, g] = V({
|
|
4878
4820
|
side: r,
|
|
4879
4821
|
mode: a
|
|
4880
4822
|
});
|
|
4881
4823
|
(d.side !== r || d.mode !== a) && (g({
|
|
4882
4824
|
side: r,
|
|
4883
4825
|
mode: a
|
|
4884
|
-
}), d.side !== r && C(r), d.mode !== a &&
|
|
4826
|
+
}), d.side !== r && C(r), d.mode !== a && N(a)), Z(() => {
|
|
4885
4827
|
if (!s) return;
|
|
4886
4828
|
let y = !1;
|
|
4887
|
-
return s.getCompanionLayout().then((
|
|
4888
|
-
y || !
|
|
4829
|
+
return s.getCompanionLayout().then((I) => {
|
|
4830
|
+
y || !I || _.current.includes(I) && c(I);
|
|
4889
4831
|
}).catch(() => {
|
|
4890
|
-
}), s.getCompanionSidebarSide().then((
|
|
4891
|
-
!y &&
|
|
4832
|
+
}), s.getCompanionSidebarSide().then((I) => {
|
|
4833
|
+
!y && I && C(I);
|
|
4892
4834
|
}).catch(() => {
|
|
4893
|
-
}), s.getCompanionSidebarMode().then((
|
|
4894
|
-
!y &&
|
|
4835
|
+
}), s.getCompanionSidebarMode().then((I) => {
|
|
4836
|
+
!y && I && N(I);
|
|
4895
4837
|
}).catch(() => {
|
|
4896
4838
|
}), () => {
|
|
4897
4839
|
y = !0;
|
|
4898
4840
|
};
|
|
4899
4841
|
}, [s]);
|
|
4900
|
-
const m =
|
|
4842
|
+
const m = q(
|
|
4901
4843
|
(y) => {
|
|
4902
4844
|
C(y), s == null || s.setCompanionSidebarSide(y).catch(() => {
|
|
4903
4845
|
});
|
|
4904
4846
|
},
|
|
4905
4847
|
[s]
|
|
4906
|
-
),
|
|
4848
|
+
), b = q(
|
|
4907
4849
|
(y) => {
|
|
4908
|
-
|
|
4850
|
+
N(y), s == null || s.setCompanionSidebarMode(y).catch(() => {
|
|
4909
4851
|
});
|
|
4910
4852
|
},
|
|
4911
4853
|
[s]
|
|
4912
4854
|
);
|
|
4913
|
-
return /* @__PURE__ */
|
|
4914
|
-
|
|
4855
|
+
return /* @__PURE__ */ F.createElement(
|
|
4856
|
+
Lr.Provider,
|
|
4915
4857
|
{
|
|
4916
4858
|
value: {
|
|
4917
4859
|
layout: u,
|
|
@@ -4922,23 +4864,23 @@ function Fn({
|
|
|
4922
4864
|
sidebarSide: E,
|
|
4923
4865
|
setSidebarSide: m,
|
|
4924
4866
|
sidebarMode: w,
|
|
4925
|
-
setSidebarMode:
|
|
4867
|
+
setSidebarMode: b
|
|
4926
4868
|
}
|
|
4927
4869
|
},
|
|
4928
4870
|
i
|
|
4929
4871
|
);
|
|
4930
4872
|
}
|
|
4931
|
-
function
|
|
4932
|
-
const e = $e(
|
|
4873
|
+
function Qn() {
|
|
4874
|
+
const e = $e(Lr);
|
|
4933
4875
|
if (!e)
|
|
4934
4876
|
throw new Error(
|
|
4935
4877
|
"useWidgetLayout must be used within a WidgetLayoutProvider"
|
|
4936
4878
|
);
|
|
4937
4879
|
return e;
|
|
4938
4880
|
}
|
|
4939
|
-
function
|
|
4881
|
+
function Xn() {
|
|
4940
4882
|
var n, f;
|
|
4941
|
-
const { widgetCtx: e } =
|
|
4883
|
+
const { widgetCtx: e } = K(), { modesComponents: t } = Xe(), { sessionState: r } = Dr(), a = e.modes, s = (n = r.session) == null ? void 0 : n.modeId, i = a.find((u) => u.id === s), l = (f = t == null ? void 0 : t.find(
|
|
4942
4884
|
(u) => {
|
|
4943
4885
|
var c, p;
|
|
4944
4886
|
return [
|
|
@@ -4956,17 +4898,17 @@ function ni() {
|
|
|
4956
4898
|
Component: l
|
|
4957
4899
|
};
|
|
4958
4900
|
}
|
|
4959
|
-
function
|
|
4960
|
-
const { widgetCtx: e } =
|
|
4901
|
+
function ei() {
|
|
4902
|
+
const { widgetCtx: e } = K(), {
|
|
4961
4903
|
messagesState: { messages: t }
|
|
4962
|
-
} =
|
|
4904
|
+
} = jr(), {
|
|
4963
4905
|
csatRequestedMessage: r,
|
|
4964
4906
|
isCsatRequested: a,
|
|
4965
4907
|
csatSubmittedMessage: s,
|
|
4966
4908
|
isCsatSubmitted: i,
|
|
4967
4909
|
submittedScore: l,
|
|
4968
4910
|
submittedFeedback: n
|
|
4969
|
-
} =
|
|
4911
|
+
} = B(() => {
|
|
4970
4912
|
const f = t.find(
|
|
4971
4913
|
(c) => c.type === "SYSTEM" && c.subtype === "csat_requested"
|
|
4972
4914
|
), u = t.findLast(
|
|
@@ -4991,10 +4933,10 @@ function ii() {
|
|
|
4991
4933
|
submittedFeedback: n
|
|
4992
4934
|
};
|
|
4993
4935
|
}
|
|
4994
|
-
function
|
|
4995
|
-
const { widgetCtx: t } =
|
|
4936
|
+
function ti(e) {
|
|
4937
|
+
const { widgetCtx: t } = K(), r = t.dictationCtx, a = $(r.state), s = D(e);
|
|
4996
4938
|
s.current = e;
|
|
4997
|
-
const i =
|
|
4939
|
+
const i = q(() => {
|
|
4998
4940
|
r.start({
|
|
4999
4941
|
getValue: () => s.current.getValue(),
|
|
5000
4942
|
setValue: (n) => s.current.setValue(n),
|
|
@@ -5003,10 +4945,10 @@ function oi(e) {
|
|
|
5003
4945
|
return (f = (n = s.current).onSend) == null ? void 0 : f.call(n);
|
|
5004
4946
|
}
|
|
5005
4947
|
});
|
|
5006
|
-
}, [r]), l =
|
|
4948
|
+
}, [r]), l = q(() => {
|
|
5007
4949
|
r.isActive() ? r.stop() : i();
|
|
5008
4950
|
}, [r, i]);
|
|
5009
|
-
return
|
|
4951
|
+
return Z(() => () => r.stop(), [r]), {
|
|
5010
4952
|
enabled: t.features.dictation,
|
|
5011
4953
|
status: a.status,
|
|
5012
4954
|
error: a.error,
|
|
@@ -5019,51 +4961,51 @@ function oi(e) {
|
|
|
5019
4961
|
prewarm: r.prewarm
|
|
5020
4962
|
};
|
|
5021
4963
|
}
|
|
5022
|
-
function
|
|
5023
|
-
const { widgetCtx: e } =
|
|
4964
|
+
function ri() {
|
|
4965
|
+
const { widgetCtx: e } = K(), t = e.messageCtx.draftState, r = $(t), a = q(
|
|
5024
4966
|
(l) => {
|
|
5025
4967
|
t.setPartial({
|
|
5026
4968
|
text: typeof l == "function" ? l(t.get().text) : l
|
|
5027
4969
|
});
|
|
5028
4970
|
},
|
|
5029
4971
|
[t]
|
|
5030
|
-
), s =
|
|
4972
|
+
), s = q(
|
|
5031
4973
|
(l) => {
|
|
5032
4974
|
t.setPartial({
|
|
5033
4975
|
mentions: typeof l == "function" ? l(t.get().mentions) : l
|
|
5034
4976
|
});
|
|
5035
4977
|
},
|
|
5036
4978
|
[t]
|
|
5037
|
-
), i =
|
|
4979
|
+
), i = q(() => t.get() !== r ? !1 : (t.reset(), !0), [t, r]);
|
|
5038
4980
|
return { ...r, setText: a, setMentions: s, clearSubmitted: i };
|
|
5039
4981
|
}
|
|
5040
4982
|
export {
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
4983
|
+
ot as HOST_CONTEXT_CHANGED_EVENT,
|
|
4984
|
+
Gn as WidgetLayoutProvider,
|
|
4985
|
+
qn as WidgetProvider,
|
|
4986
|
+
Yn as WidgetTriggerProvider,
|
|
4987
|
+
Vt as applyPresentation,
|
|
4988
|
+
$n as formatAskQuestionsAnswers,
|
|
4989
|
+
Ar as useAgentChatUi,
|
|
4990
|
+
Zn as useBot,
|
|
4991
|
+
Un as useCompanionChats,
|
|
4992
|
+
ri as useComposerDraft,
|
|
4993
|
+
Xe as useConfig,
|
|
4994
|
+
Wn as useContact,
|
|
4995
|
+
ei as useCsat,
|
|
4996
|
+
ti as useDictation,
|
|
4997
|
+
zn as useDisplayMode,
|
|
4998
|
+
An as useDocumentDir,
|
|
4999
|
+
Bn as useHostLocation,
|
|
5000
|
+
Vn as useIsAwaitingBotReply,
|
|
5001
|
+
jr as useMessages,
|
|
5002
|
+
Xn as useModes,
|
|
5003
|
+
$ as usePrimitiveState,
|
|
5004
|
+
Dr as useSessions,
|
|
5005
|
+
Kn as useUploadFiles,
|
|
5006
|
+
K as useWidget,
|
|
5007
|
+
Qn as useWidgetLayout,
|
|
5008
|
+
Jn as useWidgetRouter,
|
|
5009
|
+
Hn as useWidgetTrigger
|
|
5068
5010
|
};
|
|
5069
5011
|
//# sourceMappingURL=index.js.map
|