@opencx/widget-react-headless 5.7.1 → 5.7.2
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 +11 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +986 -982
- package/dist/index.js.map +1 -1
- package/dist/package.json.d.ts +1 -1
- package/dist/src/agent-chat/useAgentChat.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
var
|
|
1
|
+
var tr = (t) => {
|
|
2
2
|
throw TypeError(t);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var V = (t, e, r) => (
|
|
6
|
-
import
|
|
7
|
-
import { isAgentStreamKeepalive as
|
|
8
|
-
import { safeParseAsync as
|
|
9
|
-
import { toJSONSchema as
|
|
4
|
+
var rr = (t, e, r) => e.has(t) || tr("Cannot " + r);
|
|
5
|
+
var V = (t, e, r) => (rr(t, e, "read from private field"), r ? r.call(t) : e.get(t)), ge = (t, e, r) => e.has(t) ? tr("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, r), Q = (t, e, r, n) => (rr(t, e, "write to private field"), n ? n.call(t, r) : e.set(t, r), r);
|
|
6
|
+
import Y, { useSyncExternalStore as zt, useRef as R, useMemo as X, useEffect as F, useState as J, useCallback as z, createContext as Ye, useContext as Fe, memo as jn, useLayoutEffect as kn } from "react";
|
|
7
|
+
import { isAgentStreamKeepalive as $n, log as le, isRecord as Mr, genUuid as Rt, buildSendMessageBody as Fn, isAgentOrAiMessage as Un, resolveClientPresentation as qn, ConnectionRequestExpiredError as zn, ConnectionAttemptUnavailableError as Zn, PrimitiveState as _r, WidgetCtx as Vn, resolveSidebarMode as Bn, resolveSidebarSide as Wn, normalizeCompanionLayouts as Jn, resolveCompanionDefaultLayout as Yn } from "@opencx/widget-core";
|
|
8
|
+
import { safeParseAsync as Kn, lazy as Hn, unknown as Gn, union as Qn, string as Xn, record as es, object as ts, number as rs, null as ns, never as ss, looseObject as as, literal as is, instanceof as os, enum as ls, discriminatedUnion as cs, custom as us, boolean as ds, array as ps } from "zod/v4";
|
|
9
|
+
import { toJSONSchema as fs } from "zod/v4/core";
|
|
10
10
|
import "react/jsx-runtime";
|
|
11
11
|
import { z as L } from "zod";
|
|
12
|
-
const
|
|
12
|
+
const Rr = "5.7.2";
|
|
13
13
|
function H(t) {
|
|
14
14
|
return zt(t.subscribe, t.get, t.get);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function ms({
|
|
17
17
|
turnSources: t,
|
|
18
18
|
liveItems: e,
|
|
19
19
|
isStreaming: r,
|
|
@@ -22,17 +22,17 @@ function ps({
|
|
|
22
22
|
var o;
|
|
23
23
|
if (r || n) return null;
|
|
24
24
|
const s = e.length > 0 ? e : (o = t.at(-1)) == null ? void 0 : o.items;
|
|
25
|
-
return s ?
|
|
25
|
+
return s ? gs(s) : null;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function gs(t) {
|
|
28
28
|
for (let e = t.length - 1; e >= 0; e--) {
|
|
29
29
|
const r = t[e];
|
|
30
30
|
if ((r == null ? void 0 : r.kind) === "questions") return r.request;
|
|
31
31
|
}
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
|
-
const Pr = "vercel.ai.error",
|
|
35
|
-
var ee = class
|
|
34
|
+
const Pr = "vercel.ai.error", hs = Symbol.for(Pr);
|
|
35
|
+
var ee = class Or extends Error {
|
|
36
36
|
/**
|
|
37
37
|
* Creates an AI SDK Error.
|
|
38
38
|
*
|
|
@@ -42,7 +42,7 @@ var ee = class Rr extends Error {
|
|
|
42
42
|
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
43
43
|
*/
|
|
44
44
|
constructor({ name: e, message: r, cause: n }) {
|
|
45
|
-
super(r), this[
|
|
45
|
+
super(r), this[hs] = !0, this.name = e, this.cause = n;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Checks if the given error is an AI SDK Error.
|
|
@@ -50,69 +50,69 @@ var ee = class Rr extends Error {
|
|
|
50
50
|
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
|
|
51
51
|
*/
|
|
52
52
|
static isInstance(e) {
|
|
53
|
-
return
|
|
53
|
+
return Or.hasMarker(e, Pr);
|
|
54
54
|
}
|
|
55
55
|
static hasMarker(e, r) {
|
|
56
56
|
const n = Symbol.for(r);
|
|
57
57
|
return e != null && typeof e == "object" && n in e && typeof e[n] == "boolean" && e[n] === !0;
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
|
-
const
|
|
61
|
-
var
|
|
60
|
+
const Nr = "AI_APICallError", Dr = `vercel.ai.error.${Nr}`, ys = Symbol.for(Dr);
|
|
61
|
+
var Lr = class extends ee {
|
|
62
62
|
constructor({ message: t, url: e, requestBodyValues: r, statusCode: n, responseHeaders: s, responseBody: o, cause: l, isRetryable: u = n != null && (n === 408 || n === 409 || n === 429 || n >= 500), data: y }) {
|
|
63
63
|
super({
|
|
64
|
-
name:
|
|
64
|
+
name: Nr,
|
|
65
65
|
message: t,
|
|
66
66
|
cause: l
|
|
67
|
-
}), this[
|
|
67
|
+
}), this[ys] = !0, this.url = e, this.requestBodyValues = r, this.statusCode = n, this.responseHeaders = s, this.responseBody = o, this.isRetryable = u, this.data = y;
|
|
68
68
|
}
|
|
69
69
|
static isInstance(t) {
|
|
70
|
-
return ee.hasMarker(t,
|
|
70
|
+
return ee.hasMarker(t, Dr);
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
|
-
const
|
|
73
|
+
const jr = "AI_EmptyResponseBodyError", kr = `vercel.ai.error.${jr}`, vs = Symbol.for(kr);
|
|
74
74
|
var ft = class extends ee {
|
|
75
75
|
constructor({ message: t = "Empty response body" } = {}) {
|
|
76
76
|
super({
|
|
77
|
-
name:
|
|
77
|
+
name: jr,
|
|
78
78
|
message: t
|
|
79
|
-
}), this[
|
|
79
|
+
}), this[vs] = !0;
|
|
80
80
|
}
|
|
81
81
|
static isInstance(t) {
|
|
82
|
-
return ee.hasMarker(t,
|
|
82
|
+
return ee.hasMarker(t, kr);
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
|
-
function
|
|
85
|
+
function $r(t) {
|
|
86
86
|
return t == null ? "unknown error" : typeof t == "string" ? t : t instanceof Error ? t.toString() : JSON.stringify(t);
|
|
87
87
|
}
|
|
88
|
-
const
|
|
89
|
-
var
|
|
88
|
+
const Fr = "AI_InvalidArgumentError", Ur = `vercel.ai.error.${Fr}`, bs = Symbol.for(Ur);
|
|
89
|
+
var Ss = class extends ee {
|
|
90
90
|
constructor({ message: e, cause: r, argument: n }) {
|
|
91
91
|
super({
|
|
92
|
-
name:
|
|
92
|
+
name: Fr,
|
|
93
93
|
message: e,
|
|
94
94
|
cause: r
|
|
95
|
-
}), this[
|
|
95
|
+
}), this[bs] = !0, this.argument = n;
|
|
96
96
|
}
|
|
97
97
|
static isInstance(e) {
|
|
98
|
-
return ee.hasMarker(e,
|
|
98
|
+
return ee.hasMarker(e, Ur);
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
|
-
const
|
|
102
|
-
var
|
|
101
|
+
const qr = "AI_JSONParseError", zr = `vercel.ai.error.${qr}`, Is = Symbol.for(zr);
|
|
102
|
+
var nr = class extends ee {
|
|
103
103
|
constructor({ text: t, cause: e }) {
|
|
104
104
|
super({
|
|
105
|
-
name:
|
|
105
|
+
name: qr,
|
|
106
106
|
message: `JSON parsing failed: Text: ${t}.
|
|
107
|
-
Error message: ${
|
|
107
|
+
Error message: ${$r(e)}`,
|
|
108
108
|
cause: e
|
|
109
|
-
}), this[
|
|
109
|
+
}), this[Is] = !0, this.text = t;
|
|
110
110
|
}
|
|
111
111
|
static isInstance(t) {
|
|
112
|
-
return ee.hasMarker(t,
|
|
112
|
+
return ee.hasMarker(t, zr);
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
|
-
const
|
|
115
|
+
const Zr = "AI_TypeValidationError", Vr = `vercel.ai.error.${Zr}`, Es = Symbol.for(Vr);
|
|
116
116
|
var mt = class $t extends ee {
|
|
117
117
|
constructor({ value: e, cause: r, context: n }) {
|
|
118
118
|
let s = "Type validation failed";
|
|
@@ -122,14 +122,14 @@ var mt = class $t extends ee {
|
|
|
122
122
|
n.entityName && o.push(n.entityName), n.entityId && o.push(`id: "${n.entityId}"`), s += o.join(", "), s += ")";
|
|
123
123
|
}
|
|
124
124
|
super({
|
|
125
|
-
name:
|
|
125
|
+
name: Zr,
|
|
126
126
|
message: `${s}: Value: ${JSON.stringify(e)}.
|
|
127
|
-
Error message: ${
|
|
127
|
+
Error message: ${$r(r)}`,
|
|
128
128
|
cause: r
|
|
129
|
-
}), this[
|
|
129
|
+
}), this[Es] = !0, this.value = e, this.context = n;
|
|
130
130
|
}
|
|
131
131
|
static isInstance(e) {
|
|
132
|
-
return ee.hasMarker(e,
|
|
132
|
+
return ee.hasMarker(e, Vr);
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
135
|
* Wraps an error into a TypeValidationError.
|
|
@@ -151,34 +151,34 @@ Error message: ${kr(r)}`,
|
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
};
|
|
154
|
-
const
|
|
155
|
-
var
|
|
154
|
+
const Br = "AI_UnsupportedFunctionalityError", Wr = `vercel.ai.error.${Br}`, Cs = Symbol.for(Wr);
|
|
155
|
+
var ws = class extends ee {
|
|
156
156
|
constructor({ functionality: t, message: e = `'${t}' functionality not supported.` }) {
|
|
157
157
|
super({
|
|
158
|
-
name:
|
|
158
|
+
name: Br,
|
|
159
159
|
message: e
|
|
160
|
-
}), this[
|
|
160
|
+
}), this[Cs] = !0, this.functionality = t;
|
|
161
161
|
}
|
|
162
162
|
static isInstance(t) {
|
|
163
|
-
return ee.hasMarker(t,
|
|
163
|
+
return ee.hasMarker(t, Wr);
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
|
-
class
|
|
166
|
+
class Pt extends Error {
|
|
167
167
|
constructor(e, r) {
|
|
168
168
|
super(e), this.name = "ParseError", this.type = r.type, this.field = r.field, this.value = r.value, this.line = r.line;
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
|
-
const
|
|
171
|
+
const sr = 10, As = 13, Oe = 32;
|
|
172
172
|
function Ot(t) {
|
|
173
173
|
}
|
|
174
|
-
function
|
|
174
|
+
function xs(t) {
|
|
175
175
|
if (typeof t == "function")
|
|
176
176
|
throw new TypeError(
|
|
177
177
|
"`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
|
|
178
178
|
);
|
|
179
179
|
const { onEvent: e = Ot, onError: r = Ot, onRetry: n = Ot, onComment: s, maxBufferSize: o } = t, l = [];
|
|
180
180
|
let u = 0, y = !0, g, i = "", d = 0, p, b = !1;
|
|
181
|
-
function
|
|
181
|
+
function P(c) {
|
|
182
182
|
if (b)
|
|
183
183
|
throw new Error(
|
|
184
184
|
"Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
|
|
@@ -201,7 +201,7 @@ function ws(t) {
|
|
|
201
201
|
}
|
|
202
202
|
function M() {
|
|
203
203
|
o !== void 0 && (u + i.length <= o || (b = !0, l.length = 0, u = 0, g = void 0, i = "", d = 0, p = void 0, r(
|
|
204
|
-
new
|
|
204
|
+
new Pt(`Buffered data exceeded max buffer size of ${o} characters`, {
|
|
205
205
|
type: "max-buffer-size-exceeded"
|
|
206
206
|
})
|
|
207
207
|
)));
|
|
@@ -218,19 +218,19 @@ function ws(t) {
|
|
|
218
218
|
continue;
|
|
219
219
|
}
|
|
220
220
|
const h = c.charCodeAt(m);
|
|
221
|
-
if (
|
|
222
|
-
const S = c.charCodeAt(m + 5) ===
|
|
223
|
-
if (d === 0 && c.charCodeAt(f + 1) ===
|
|
221
|
+
if (ar(c, m, h)) {
|
|
222
|
+
const S = c.charCodeAt(m + 5) === Oe ? m + 6 : m + 5, N = c.slice(S, f);
|
|
223
|
+
if (d === 0 && c.charCodeAt(f + 1) === sr) {
|
|
224
224
|
e({ id: g, event: p, data: N }), g = void 0, i = "", p = void 0, m = f + 2, f = c.indexOf(`
|
|
225
225
|
`, m);
|
|
226
226
|
continue;
|
|
227
227
|
}
|
|
228
228
|
i = d === 0 ? N : `${i}
|
|
229
229
|
${N}`, d++;
|
|
230
|
-
} else
|
|
231
|
-
c.charCodeAt(m + 6) ===
|
|
230
|
+
} else ir(c, m, h) ? p = c.slice(
|
|
231
|
+
c.charCodeAt(m + 6) === Oe ? m + 7 : m + 6,
|
|
232
232
|
f
|
|
233
|
-
) || void 0 :
|
|
233
|
+
) || void 0 : x(c, m, f);
|
|
234
234
|
m = f + 1, f = c.indexOf(`
|
|
235
235
|
`, m);
|
|
236
236
|
}
|
|
@@ -242,35 +242,35 @@ ${N}`, d++;
|
|
|
242
242
|
let S = -1;
|
|
243
243
|
if (f !== -1 && h !== -1 ? S = f < h ? f : h : f !== -1 ? f === c.length - 1 ? S = -1 : S = f : h !== -1 && (S = h), S === -1)
|
|
244
244
|
break;
|
|
245
|
-
|
|
245
|
+
x(c, m, S), m = S + 1, c.charCodeAt(m - 1) === As && c.charCodeAt(m) === sr && m++;
|
|
246
246
|
}
|
|
247
247
|
return c.slice(m);
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function x(c, m, f) {
|
|
250
250
|
if (m === f) {
|
|
251
251
|
I();
|
|
252
252
|
return;
|
|
253
253
|
}
|
|
254
254
|
const h = c.charCodeAt(m);
|
|
255
|
-
if (
|
|
256
|
-
const j = c.charCodeAt(m + 5) ===
|
|
257
|
-
i = d === 0 ?
|
|
258
|
-
${
|
|
255
|
+
if (ar(c, m, h)) {
|
|
256
|
+
const j = c.charCodeAt(m + 5) === Oe ? m + 6 : m + 5, $ = c.slice(j, f);
|
|
257
|
+
i = d === 0 ? $ : `${i}
|
|
258
|
+
${$}`, d++;
|
|
259
259
|
return;
|
|
260
260
|
}
|
|
261
|
-
if (
|
|
262
|
-
p = c.slice(c.charCodeAt(m + 6) ===
|
|
261
|
+
if (ir(c, m, h)) {
|
|
262
|
+
p = c.slice(c.charCodeAt(m + 6) === Oe ? m + 7 : m + 6, f) || void 0;
|
|
263
263
|
return;
|
|
264
264
|
}
|
|
265
265
|
if (h === 105 && c.charCodeAt(m + 1) === 100 && c.charCodeAt(m + 2) === 58) {
|
|
266
|
-
const j = c.slice(c.charCodeAt(m + 3) ===
|
|
266
|
+
const j = c.slice(c.charCodeAt(m + 3) === Oe ? m + 4 : m + 3, f);
|
|
267
267
|
g = j.includes("\0") ? void 0 : j;
|
|
268
268
|
return;
|
|
269
269
|
}
|
|
270
270
|
if (h === 58) {
|
|
271
271
|
if (s) {
|
|
272
272
|
const j = c.slice(m, f);
|
|
273
|
-
s(j.slice(c.charCodeAt(m + 1) ===
|
|
273
|
+
s(j.slice(c.charCodeAt(m + 1) === Oe ? 2 : 1));
|
|
274
274
|
}
|
|
275
275
|
return;
|
|
276
276
|
}
|
|
@@ -279,7 +279,7 @@ ${k}`, d++;
|
|
|
279
279
|
w(S, "", S);
|
|
280
280
|
return;
|
|
281
281
|
}
|
|
282
|
-
const D = S.slice(0, N), B = S.charCodeAt(N + 1) ===
|
|
282
|
+
const D = S.slice(0, N), B = S.charCodeAt(N + 1) === Oe ? 2 : 1, W = S.slice(N + B);
|
|
283
283
|
w(D, W, S);
|
|
284
284
|
}
|
|
285
285
|
function w(c, m, f) {
|
|
@@ -296,7 +296,7 @@ ${m}`, d++;
|
|
|
296
296
|
break;
|
|
297
297
|
case "retry":
|
|
298
298
|
/^\d+$/.test(m) ? n(parseInt(m, 10)) : r(
|
|
299
|
-
new
|
|
299
|
+
new Pt(`Invalid \`retry\` value: "${m}"`, {
|
|
300
300
|
type: "invalid-retry",
|
|
301
301
|
value: m,
|
|
302
302
|
line: f
|
|
@@ -305,7 +305,7 @@ ${m}`, d++;
|
|
|
305
305
|
break;
|
|
306
306
|
default:
|
|
307
307
|
r(
|
|
308
|
-
new
|
|
308
|
+
new Pt(
|
|
309
309
|
`Unknown field "${c.length > 20 ? `${c.slice(0, 20)}…` : c}"`,
|
|
310
310
|
{ type: "unknown-field", field: c, value: m, line: f }
|
|
311
311
|
)
|
|
@@ -323,24 +323,24 @@ ${m}`, d++;
|
|
|
323
323
|
function C(c = {}) {
|
|
324
324
|
if (c.consume && l.length > 0) {
|
|
325
325
|
const m = l.join("");
|
|
326
|
-
|
|
326
|
+
x(m, 0, m.length);
|
|
327
327
|
}
|
|
328
328
|
y = !0, g = void 0, i = "", d = 0, p = void 0, l.length = 0, u = 0, b = !1;
|
|
329
329
|
}
|
|
330
|
-
return { feed:
|
|
330
|
+
return { feed: P, reset: C };
|
|
331
331
|
}
|
|
332
|
-
function
|
|
332
|
+
function ar(t, e, r) {
|
|
333
333
|
return r === 100 && t.charCodeAt(e + 1) === 97 && t.charCodeAt(e + 2) === 116 && t.charCodeAt(e + 3) === 97 && t.charCodeAt(e + 4) === 58;
|
|
334
334
|
}
|
|
335
|
-
function
|
|
335
|
+
function ir(t, e, r) {
|
|
336
336
|
return r === 101 && t.charCodeAt(e + 1) === 118 && t.charCodeAt(e + 2) === 101 && t.charCodeAt(e + 3) === 110 && t.charCodeAt(e + 4) === 116 && t.charCodeAt(e + 5) === 58;
|
|
337
337
|
}
|
|
338
|
-
class
|
|
338
|
+
class Ts extends TransformStream {
|
|
339
339
|
constructor({ onError: e, onRetry: r, onComment: n, maxBufferSize: s } = {}) {
|
|
340
340
|
let o;
|
|
341
341
|
super({
|
|
342
342
|
start(l) {
|
|
343
|
-
o =
|
|
343
|
+
o = xs({
|
|
344
344
|
onEvent: (u) => {
|
|
345
345
|
l.enqueue(u);
|
|
346
346
|
},
|
|
@@ -378,22 +378,22 @@ const te = ({ prefix: t, size: e = 16, alphabet: r = "0123456789ABCDEFGHIJKLMNOP
|
|
|
378
378
|
return l.join("");
|
|
379
379
|
};
|
|
380
380
|
if (t == null) return s;
|
|
381
|
-
if (r.includes(n)) throw new
|
|
381
|
+
if (r.includes(n)) throw new Ss({
|
|
382
382
|
argument: "separator",
|
|
383
383
|
message: `The separator "${n}" must not be part of the alphabet "${r}".`
|
|
384
384
|
});
|
|
385
385
|
return () => `${t}${n}${s()}`;
|
|
386
|
-
},
|
|
387
|
-
function
|
|
386
|
+
}, Ms = te();
|
|
387
|
+
function _s(t) {
|
|
388
388
|
var e;
|
|
389
389
|
return ((e = globalThis.Buffer) == null ? void 0 : e.isBuffer(t)) ?? !1;
|
|
390
390
|
}
|
|
391
|
-
const
|
|
392
|
-
function
|
|
391
|
+
const Rs = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, Ps = /"(?: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*:/;
|
|
392
|
+
function or(t) {
|
|
393
393
|
const e = JSON.parse(t);
|
|
394
|
-
return e === null || typeof e != "object" ||
|
|
394
|
+
return e === null || typeof e != "object" || Rs.test(t) === !1 && Ps.test(t) === !1 ? e : Os(e);
|
|
395
395
|
}
|
|
396
|
-
function
|
|
396
|
+
function Os(t) {
|
|
397
397
|
let e = [t];
|
|
398
398
|
for (; e.length; ) {
|
|
399
399
|
const r = e;
|
|
@@ -409,15 +409,15 @@ function Ps(t) {
|
|
|
409
409
|
}
|
|
410
410
|
return t;
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function Ns(t) {
|
|
413
413
|
const { stackTraceLimit: e } = Error;
|
|
414
414
|
try {
|
|
415
415
|
Error.stackTraceLimit = 0;
|
|
416
416
|
} catch {
|
|
417
|
-
return
|
|
417
|
+
return or(t);
|
|
418
418
|
}
|
|
419
419
|
try {
|
|
420
|
-
return
|
|
420
|
+
return or(t);
|
|
421
421
|
} finally {
|
|
422
422
|
Error.stackTraceLimit = e;
|
|
423
423
|
}
|
|
@@ -437,7 +437,7 @@ function Zt(t) {
|
|
|
437
437
|
function Me(t) {
|
|
438
438
|
return typeof t == "boolean" ? t : Zt(t);
|
|
439
439
|
}
|
|
440
|
-
const
|
|
440
|
+
const Ds = Symbol("Let zodToJsonSchema decide on which parser to use"), lr = {
|
|
441
441
|
name: void 0,
|
|
442
442
|
$refStrategy: "root",
|
|
443
443
|
basePath: ["#"],
|
|
@@ -457,17 +457,17 @@ const Os = Symbol("Let zodToJsonSchema decide on which parser to use"), or = {
|
|
|
457
457
|
emailStrategy: "format:email",
|
|
458
458
|
base64Strategy: "contentEncoding:base64",
|
|
459
459
|
nameStrategy: "ref"
|
|
460
|
-
},
|
|
461
|
-
...
|
|
460
|
+
}, Ls = (t) => typeof t == "string" ? {
|
|
461
|
+
...lr,
|
|
462
462
|
name: t
|
|
463
463
|
} : {
|
|
464
|
-
...
|
|
464
|
+
...lr,
|
|
465
465
|
...t
|
|
466
466
|
};
|
|
467
|
-
function
|
|
467
|
+
function ue() {
|
|
468
468
|
return {};
|
|
469
469
|
}
|
|
470
|
-
function
|
|
470
|
+
function js(t, e) {
|
|
471
471
|
var n, s, o;
|
|
472
472
|
const r = { type: "array" };
|
|
473
473
|
return (n = t.type) != null && n._def && ((o = (s = t.type) == null ? void 0 : s._def) == null ? void 0 : o.typeName) !== "ZodAny" && (r.items = q(t.type._def, {
|
|
@@ -475,7 +475,7 @@ function Ds(t, e) {
|
|
|
475
475
|
currentPath: [...e.currentPath, "items"]
|
|
476
476
|
})), t.minLength && (r.minItems = t.minLength.value), t.maxLength && (r.maxItems = t.maxLength.value), t.exactLength && (r.minItems = t.exactLength.value, r.maxItems = t.exactLength.value), r;
|
|
477
477
|
}
|
|
478
|
-
function
|
|
478
|
+
function ks(t) {
|
|
479
479
|
const e = {
|
|
480
480
|
type: "integer",
|
|
481
481
|
format: "int64"
|
|
@@ -493,16 +493,16 @@ function Ls(t) {
|
|
|
493
493
|
}
|
|
494
494
|
return e;
|
|
495
495
|
}
|
|
496
|
-
function
|
|
496
|
+
function $s() {
|
|
497
497
|
return { type: "boolean" };
|
|
498
498
|
}
|
|
499
|
-
function
|
|
499
|
+
function Jr(t, e) {
|
|
500
500
|
return q(t.type._def, e);
|
|
501
501
|
}
|
|
502
|
-
const
|
|
503
|
-
function
|
|
502
|
+
const Fs = (t, e) => q(t.innerType._def, e);
|
|
503
|
+
function Yr(t, e, r) {
|
|
504
504
|
const n = r ?? e.dateStrategy;
|
|
505
|
-
if (Array.isArray(n)) return { anyOf: n.map((s) =>
|
|
505
|
+
if (Array.isArray(n)) return { anyOf: n.map((s) => Yr(t, e, s)) };
|
|
506
506
|
switch (n) {
|
|
507
507
|
case "string":
|
|
508
508
|
case "format:date-time":
|
|
@@ -516,10 +516,10 @@ function Jr(t, e, r) {
|
|
|
516
516
|
format: "date"
|
|
517
517
|
};
|
|
518
518
|
case "integer":
|
|
519
|
-
return
|
|
519
|
+
return Us(t);
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
|
-
const
|
|
522
|
+
const Us = (t) => {
|
|
523
523
|
const e = {
|
|
524
524
|
type: "integer",
|
|
525
525
|
format: "unix-time"
|
|
@@ -533,23 +533,23 @@ const $s = (t) => {
|
|
|
533
533
|
}
|
|
534
534
|
return e;
|
|
535
535
|
};
|
|
536
|
-
function
|
|
536
|
+
function qs(t, e) {
|
|
537
537
|
return {
|
|
538
538
|
...q(t.innerType._def, e),
|
|
539
539
|
default: t.defaultValue()
|
|
540
540
|
};
|
|
541
541
|
}
|
|
542
|
-
function
|
|
543
|
-
return e.effectStrategy === "input" ? q(t.schema._def, e) :
|
|
542
|
+
function zs(t, e) {
|
|
543
|
+
return e.effectStrategy === "input" ? q(t.schema._def, e) : ue();
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function Zs(t) {
|
|
546
546
|
return {
|
|
547
547
|
type: "string",
|
|
548
548
|
enum: Array.from(t.values)
|
|
549
549
|
};
|
|
550
550
|
}
|
|
551
|
-
const
|
|
552
|
-
function
|
|
551
|
+
const Vs = (t) => "type" in t && t.type === "string" ? !1 : "allOf" in t;
|
|
552
|
+
function Bs(t, e) {
|
|
553
553
|
const r = [q(t.left._def, {
|
|
554
554
|
...e,
|
|
555
555
|
currentPath: [
|
|
@@ -566,7 +566,7 @@ function Zs(t, e) {
|
|
|
566
566
|
]
|
|
567
567
|
})].filter((s) => !!s), n = [];
|
|
568
568
|
return r.forEach((s) => {
|
|
569
|
-
if (
|
|
569
|
+
if (Vs(s)) n.push(...s.allOf);
|
|
570
570
|
else {
|
|
571
571
|
let o = s;
|
|
572
572
|
if ("additionalProperties" in s && s.additionalProperties === !1) {
|
|
@@ -577,7 +577,7 @@ function Zs(t, e) {
|
|
|
577
577
|
}
|
|
578
578
|
}), n.length ? { allOf: n } : void 0;
|
|
579
579
|
}
|
|
580
|
-
function
|
|
580
|
+
function Ws(t) {
|
|
581
581
|
const e = typeof t.value;
|
|
582
582
|
return e !== "bigint" && e !== "number" && e !== "boolean" && e !== "string" ? { type: Array.isArray(t.value) ? "array" : "object" } : {
|
|
583
583
|
type: e === "bigint" ? "integer" : e,
|
|
@@ -585,7 +585,7 @@ function Vs(t) {
|
|
|
585
585
|
};
|
|
586
586
|
}
|
|
587
587
|
let Nt;
|
|
588
|
-
const
|
|
588
|
+
const he = {
|
|
589
589
|
/**
|
|
590
590
|
* `c` was changed to `[cC]` to replicate /i flag
|
|
591
591
|
*/
|
|
@@ -627,7 +627,7 @@ const ge = {
|
|
|
627
627
|
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
628
628
|
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
629
629
|
};
|
|
630
|
-
function
|
|
630
|
+
function Kr(t, e) {
|
|
631
631
|
const r = { type: "string" };
|
|
632
632
|
if (t.checks) for (const n of t.checks) switch (n.kind) {
|
|
633
633
|
case "min":
|
|
@@ -639,114 +639,114 @@ function Yr(t, e) {
|
|
|
639
639
|
case "email":
|
|
640
640
|
switch (e.emailStrategy) {
|
|
641
641
|
case "format:email":
|
|
642
|
-
|
|
642
|
+
ye(r, "email", n.message, e);
|
|
643
643
|
break;
|
|
644
644
|
case "format:idn-email":
|
|
645
|
-
|
|
645
|
+
ye(r, "idn-email", n.message, e);
|
|
646
646
|
break;
|
|
647
647
|
case "pattern:zod":
|
|
648
|
-
|
|
648
|
+
ne(r, he.email, n.message, e);
|
|
649
649
|
}
|
|
650
650
|
break;
|
|
651
651
|
case "url":
|
|
652
|
-
|
|
652
|
+
ye(r, "uri", n.message, e);
|
|
653
653
|
break;
|
|
654
654
|
case "uuid":
|
|
655
|
-
|
|
655
|
+
ye(r, "uuid", n.message, e);
|
|
656
656
|
break;
|
|
657
657
|
case "regex":
|
|
658
|
-
|
|
658
|
+
ne(r, n.regex, n.message, e);
|
|
659
659
|
break;
|
|
660
660
|
case "cuid":
|
|
661
|
-
|
|
661
|
+
ne(r, he.cuid, n.message, e);
|
|
662
662
|
break;
|
|
663
663
|
case "cuid2":
|
|
664
|
-
|
|
664
|
+
ne(r, he.cuid2, n.message, e);
|
|
665
665
|
break;
|
|
666
666
|
case "startsWith":
|
|
667
|
-
|
|
667
|
+
ne(r, RegExp(`^${Dt(n.value, e)}`), n.message, e);
|
|
668
668
|
break;
|
|
669
669
|
case "endsWith":
|
|
670
|
-
|
|
670
|
+
ne(r, RegExp(`${Dt(n.value, e)}$`), n.message, e);
|
|
671
671
|
break;
|
|
672
672
|
case "datetime":
|
|
673
|
-
|
|
673
|
+
ye(r, "date-time", n.message, e);
|
|
674
674
|
break;
|
|
675
675
|
case "date":
|
|
676
|
-
|
|
676
|
+
ye(r, "date", n.message, e);
|
|
677
677
|
break;
|
|
678
678
|
case "time":
|
|
679
|
-
|
|
679
|
+
ye(r, "time", n.message, e);
|
|
680
680
|
break;
|
|
681
681
|
case "duration":
|
|
682
|
-
|
|
682
|
+
ye(r, "duration", n.message, e);
|
|
683
683
|
break;
|
|
684
684
|
case "length":
|
|
685
685
|
r.minLength = typeof r.minLength == "number" ? Math.max(r.minLength, n.value) : n.value, r.maxLength = typeof r.maxLength == "number" ? Math.min(r.maxLength, n.value) : n.value;
|
|
686
686
|
break;
|
|
687
687
|
case "includes":
|
|
688
|
-
|
|
688
|
+
ne(r, RegExp(Dt(n.value, e)), n.message, e);
|
|
689
689
|
break;
|
|
690
690
|
case "ip":
|
|
691
|
-
n.version !== "v6" &&
|
|
691
|
+
n.version !== "v6" && ye(r, "ipv4", n.message, e), n.version !== "v4" && ye(r, "ipv6", n.message, e);
|
|
692
692
|
break;
|
|
693
693
|
case "base64url":
|
|
694
|
-
|
|
694
|
+
ne(r, he.base64url, n.message, e);
|
|
695
695
|
break;
|
|
696
696
|
case "jwt":
|
|
697
|
-
|
|
697
|
+
ne(r, he.jwt, n.message, e);
|
|
698
698
|
break;
|
|
699
699
|
case "cidr":
|
|
700
|
-
n.version !== "v6" &&
|
|
700
|
+
n.version !== "v6" && ne(r, he.ipv4Cidr, n.message, e), n.version !== "v4" && ne(r, he.ipv6Cidr, n.message, e);
|
|
701
701
|
break;
|
|
702
702
|
case "emoji":
|
|
703
|
-
|
|
703
|
+
ne(r, he.emoji(), n.message, e);
|
|
704
704
|
break;
|
|
705
705
|
case "ulid":
|
|
706
|
-
|
|
706
|
+
ne(r, he.ulid, n.message, e);
|
|
707
707
|
break;
|
|
708
708
|
case "base64":
|
|
709
709
|
switch (e.base64Strategy) {
|
|
710
710
|
case "format:binary":
|
|
711
|
-
|
|
711
|
+
ye(r, "binary", n.message, e);
|
|
712
712
|
break;
|
|
713
713
|
case "contentEncoding:base64":
|
|
714
714
|
r.contentEncoding = "base64";
|
|
715
715
|
break;
|
|
716
716
|
case "pattern:zod":
|
|
717
|
-
|
|
717
|
+
ne(r, he.base64, n.message, e);
|
|
718
718
|
}
|
|
719
719
|
break;
|
|
720
720
|
case "nanoid":
|
|
721
|
-
|
|
721
|
+
ne(r, he.nanoid, n.message, e);
|
|
722
722
|
}
|
|
723
723
|
return r;
|
|
724
724
|
}
|
|
725
725
|
function Dt(t, e) {
|
|
726
|
-
return e.patternStrategy === "escape" ?
|
|
726
|
+
return e.patternStrategy === "escape" ? Ys(t) : t;
|
|
727
727
|
}
|
|
728
|
-
const
|
|
729
|
-
function
|
|
728
|
+
const Js = /* @__PURE__ */ new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
729
|
+
function Ys(t) {
|
|
730
730
|
let e = "";
|
|
731
731
|
for (let r = 0; r < t.length; r++)
|
|
732
|
-
|
|
732
|
+
Js.has(t[r]) || (e += "\\"), e += t[r];
|
|
733
733
|
return e;
|
|
734
734
|
}
|
|
735
|
-
function
|
|
735
|
+
function ye(t, e, r, n) {
|
|
736
736
|
var s;
|
|
737
737
|
t.format || (s = t.anyOf) != null && s.some((o) => o.format) ? (t.anyOf || (t.anyOf = []), t.format && (t.anyOf.push({ format: t.format }), delete t.format), t.anyOf.push({
|
|
738
738
|
format: e,
|
|
739
739
|
...r && n.errorMessages && { errorMessage: { format: r } }
|
|
740
740
|
})) : t.format = e;
|
|
741
741
|
}
|
|
742
|
-
function
|
|
742
|
+
function ne(t, e, r, n) {
|
|
743
743
|
var s;
|
|
744
744
|
t.pattern || (s = t.allOf) != null && s.some((o) => o.pattern) ? (t.allOf || (t.allOf = []), t.pattern && (t.allOf.push({ pattern: t.pattern }), delete t.pattern), t.allOf.push({
|
|
745
|
-
pattern:
|
|
745
|
+
pattern: cr(e, n),
|
|
746
746
|
...r && n.errorMessages && { errorMessage: { pattern: r } }
|
|
747
|
-
})) : t.pattern =
|
|
747
|
+
})) : t.pattern = cr(e, n);
|
|
748
748
|
}
|
|
749
|
-
function
|
|
749
|
+
function cr(t, e) {
|
|
750
750
|
var y;
|
|
751
751
|
if (!e.applyRegexFlags || !t.flags) return t.source;
|
|
752
752
|
const r = {
|
|
@@ -797,7 +797,7 @@ function lr(t, e) {
|
|
|
797
797
|
}
|
|
798
798
|
return s;
|
|
799
799
|
}
|
|
800
|
-
function
|
|
800
|
+
function Hr(t, e) {
|
|
801
801
|
var n, s, o, l, u;
|
|
802
802
|
const r = {
|
|
803
803
|
type: "object",
|
|
@@ -807,7 +807,7 @@ function Kr(t, e) {
|
|
|
807
807
|
}) ?? e.allowedAdditionalProperties
|
|
808
808
|
};
|
|
809
809
|
if (((n = t.keyType) == null ? void 0 : n._def.typeName) === "ZodString" && ((s = t.keyType._def.checks) != null && s.length)) {
|
|
810
|
-
const { type: y, ...g } =
|
|
810
|
+
const { type: y, ...g } = Kr(t.keyType._def, e);
|
|
811
811
|
return {
|
|
812
812
|
...r,
|
|
813
813
|
propertyNames: g
|
|
@@ -818,7 +818,7 @@ function Kr(t, e) {
|
|
|
818
818
|
propertyNames: { enum: t.keyType._def.values }
|
|
819
819
|
};
|
|
820
820
|
if (((l = t.keyType) == null ? void 0 : l._def.typeName) === "ZodBranded" && t.keyType._def.type._def.typeName === "ZodString" && ((u = t.keyType._def.type._def.checks) != null && u.length)) {
|
|
821
|
-
const { type: y, ...g } =
|
|
821
|
+
const { type: y, ...g } = Jr(t.keyType._def, e);
|
|
822
822
|
return {
|
|
823
823
|
...r,
|
|
824
824
|
propertyNames: g
|
|
@@ -827,8 +827,8 @@ function Kr(t, e) {
|
|
|
827
827
|
}
|
|
828
828
|
return r;
|
|
829
829
|
}
|
|
830
|
-
function
|
|
831
|
-
return e.mapStrategy === "record" ?
|
|
830
|
+
function Ks(t, e) {
|
|
831
|
+
return e.mapStrategy === "record" ? Hr(t, e) : {
|
|
832
832
|
type: "array",
|
|
833
833
|
maxItems: 125,
|
|
834
834
|
items: {
|
|
@@ -841,7 +841,7 @@ function Js(t, e) {
|
|
|
841
841
|
"items",
|
|
842
842
|
"0"
|
|
843
843
|
]
|
|
844
|
-
}) ||
|
|
844
|
+
}) || ue(), q(t.valueType._def, {
|
|
845
845
|
...e,
|
|
846
846
|
currentPath: [
|
|
847
847
|
...e.currentPath,
|
|
@@ -849,23 +849,23 @@ function Js(t, e) {
|
|
|
849
849
|
"items",
|
|
850
850
|
"1"
|
|
851
851
|
]
|
|
852
|
-
}) ||
|
|
852
|
+
}) || ue()],
|
|
853
853
|
minItems: 2,
|
|
854
854
|
maxItems: 2
|
|
855
855
|
}
|
|
856
856
|
};
|
|
857
857
|
}
|
|
858
|
-
function
|
|
858
|
+
function Hs(t) {
|
|
859
859
|
const e = t.values, r = Object.keys(t.values).filter((s) => typeof e[e[s]] != "number").map((s) => e[s]), n = Array.from(new Set(r.map((s) => typeof s)));
|
|
860
860
|
return {
|
|
861
861
|
type: n.length === 1 ? n[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
862
862
|
enum: r
|
|
863
863
|
};
|
|
864
864
|
}
|
|
865
|
-
function
|
|
866
|
-
return { not:
|
|
865
|
+
function Gs() {
|
|
866
|
+
return { not: ue() };
|
|
867
867
|
}
|
|
868
|
-
function
|
|
868
|
+
function Qs() {
|
|
869
869
|
return { type: "null" };
|
|
870
870
|
}
|
|
871
871
|
const Ft = {
|
|
@@ -875,7 +875,7 @@ const Ft = {
|
|
|
875
875
|
ZodBoolean: "boolean",
|
|
876
876
|
ZodNull: "null"
|
|
877
877
|
};
|
|
878
|
-
function
|
|
878
|
+
function Xs(t, e) {
|
|
879
879
|
const r = t.options instanceof Map ? Array.from(t.options.values()) : t.options;
|
|
880
880
|
if (r.every((n) => n._def.typeName in Ft && (!n._def.checks || !n._def.checks.length))) {
|
|
881
881
|
const n = r.reduce((s, o) => {
|
|
@@ -910,9 +910,9 @@ function Gs(t, e) {
|
|
|
910
910
|
type: "string",
|
|
911
911
|
enum: r.reduce((n, s) => [...n, ...s._def.values.filter((o) => !n.includes(o))], [])
|
|
912
912
|
};
|
|
913
|
-
return
|
|
913
|
+
return ea(t, e);
|
|
914
914
|
}
|
|
915
|
-
const
|
|
915
|
+
const ea = (t, e) => {
|
|
916
916
|
const r = (t.options instanceof Map ? Array.from(t.options.values()) : t.options).map((n, s) => q(n._def, {
|
|
917
917
|
...e,
|
|
918
918
|
currentPath: [
|
|
@@ -923,7 +923,7 @@ const Qs = (t, e) => {
|
|
|
923
923
|
})).filter((n) => !!n && (!e.strictUnions || typeof n == "object" && Object.keys(n).length > 0));
|
|
924
924
|
return r.length ? { anyOf: r } : void 0;
|
|
925
925
|
};
|
|
926
|
-
function
|
|
926
|
+
function ta(t, e) {
|
|
927
927
|
if ([
|
|
928
928
|
"ZodString",
|
|
929
929
|
"ZodNumber",
|
|
@@ -941,7 +941,7 @@ function Xs(t, e) {
|
|
|
941
941
|
});
|
|
942
942
|
return r && { anyOf: [r, { type: "null" }] };
|
|
943
943
|
}
|
|
944
|
-
function
|
|
944
|
+
function ra(t) {
|
|
945
945
|
const e = { type: "number" };
|
|
946
946
|
if (!t.checks) return e;
|
|
947
947
|
for (const r of t.checks) switch (r.kind) {
|
|
@@ -959,7 +959,7 @@ function ea(t) {
|
|
|
959
959
|
}
|
|
960
960
|
return e;
|
|
961
961
|
}
|
|
962
|
-
function
|
|
962
|
+
function na(t, e) {
|
|
963
963
|
const r = {
|
|
964
964
|
type: "object",
|
|
965
965
|
properties: {}
|
|
@@ -967,7 +967,7 @@ function ta(t, e) {
|
|
|
967
967
|
for (const l in s) {
|
|
968
968
|
let u = s[l];
|
|
969
969
|
if (u === void 0 || u._def === void 0) continue;
|
|
970
|
-
const y =
|
|
970
|
+
const y = aa(u), g = q(u._def, {
|
|
971
971
|
...e,
|
|
972
972
|
currentPath: [
|
|
973
973
|
...e.currentPath,
|
|
@@ -983,10 +983,10 @@ function ta(t, e) {
|
|
|
983
983
|
g !== void 0 && (r.properties[l] = g, y || n.push(l));
|
|
984
984
|
}
|
|
985
985
|
n.length && (r.required = n);
|
|
986
|
-
const o =
|
|
986
|
+
const o = sa(t, e);
|
|
987
987
|
return o !== void 0 && (r.additionalProperties = o), r;
|
|
988
988
|
}
|
|
989
|
-
function
|
|
989
|
+
function sa(t, e) {
|
|
990
990
|
if (t.catchall._def.typeName !== "ZodNever") return q(t.catchall._def, {
|
|
991
991
|
...e,
|
|
992
992
|
currentPath: [...e.currentPath, "additionalProperties"]
|
|
@@ -1000,14 +1000,14 @@ function ra(t, e) {
|
|
|
1000
1000
|
return e.removeAdditionalStrategy === "strict" ? e.allowedAdditionalProperties : e.rejectedAdditionalProperties;
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
|
-
function
|
|
1003
|
+
function aa(t) {
|
|
1004
1004
|
try {
|
|
1005
1005
|
return t.isOptional();
|
|
1006
1006
|
} catch {
|
|
1007
1007
|
return !0;
|
|
1008
1008
|
}
|
|
1009
1009
|
}
|
|
1010
|
-
const
|
|
1010
|
+
const ia = (t, e) => {
|
|
1011
1011
|
var n;
|
|
1012
1012
|
if (e.currentPath.toString() === ((n = e.propertyPath) == null ? void 0 : n.toString())) return q(t.innerType._def, e);
|
|
1013
1013
|
const r = q(t.innerType._def, {
|
|
@@ -1018,8 +1018,8 @@ const sa = (t, e) => {
|
|
|
1018
1018
|
"1"
|
|
1019
1019
|
]
|
|
1020
1020
|
});
|
|
1021
|
-
return r ? { anyOf: [{ not:
|
|
1022
|
-
},
|
|
1021
|
+
return r ? { anyOf: [{ not: ue() }, r] } : ue();
|
|
1022
|
+
}, oa = (t, e) => {
|
|
1023
1023
|
if (e.pipeStrategy === "input") return q(t.in._def, e);
|
|
1024
1024
|
if (e.pipeStrategy === "output") return q(t.out._def, e);
|
|
1025
1025
|
const r = q(t.in._def, {
|
|
@@ -1039,10 +1039,10 @@ const sa = (t, e) => {
|
|
|
1039
1039
|
]
|
|
1040
1040
|
})].filter((n) => n !== void 0) };
|
|
1041
1041
|
};
|
|
1042
|
-
function
|
|
1042
|
+
function la(t, e) {
|
|
1043
1043
|
return q(t.type._def, e);
|
|
1044
1044
|
}
|
|
1045
|
-
function
|
|
1045
|
+
function ca(t, e) {
|
|
1046
1046
|
const r = {
|
|
1047
1047
|
type: "array",
|
|
1048
1048
|
uniqueItems: !0,
|
|
@@ -1053,7 +1053,7 @@ function oa(t, e) {
|
|
|
1053
1053
|
};
|
|
1054
1054
|
return t.minSize && (r.minItems = t.minSize.value), t.maxSize && (r.maxItems = t.maxSize.value), r;
|
|
1055
1055
|
}
|
|
1056
|
-
function
|
|
1056
|
+
function ua(t, e) {
|
|
1057
1057
|
return t.rest ? {
|
|
1058
1058
|
type: "array",
|
|
1059
1059
|
minItems: t.items.length,
|
|
@@ -1083,78 +1083,78 @@ function la(t, e) {
|
|
|
1083
1083
|
})).reduce((r, n) => n === void 0 ? r : [...r, n], [])
|
|
1084
1084
|
};
|
|
1085
1085
|
}
|
|
1086
|
-
function
|
|
1087
|
-
return { not:
|
|
1086
|
+
function da() {
|
|
1087
|
+
return { not: ue() };
|
|
1088
1088
|
}
|
|
1089
|
-
function
|
|
1090
|
-
return
|
|
1089
|
+
function pa() {
|
|
1090
|
+
return ue();
|
|
1091
1091
|
}
|
|
1092
|
-
const
|
|
1092
|
+
const fa = (t, e) => q(t.innerType._def, e), ma = (t, e, r) => {
|
|
1093
1093
|
switch (e) {
|
|
1094
1094
|
case "ZodString":
|
|
1095
|
-
return
|
|
1095
|
+
return Kr(t, r);
|
|
1096
1096
|
case "ZodNumber":
|
|
1097
|
-
return
|
|
1097
|
+
return ra(t);
|
|
1098
1098
|
case "ZodObject":
|
|
1099
|
-
return
|
|
1099
|
+
return na(t, r);
|
|
1100
1100
|
case "ZodBigInt":
|
|
1101
|
-
return
|
|
1101
|
+
return ks(t);
|
|
1102
1102
|
case "ZodBoolean":
|
|
1103
|
-
return
|
|
1103
|
+
return $s();
|
|
1104
1104
|
case "ZodDate":
|
|
1105
|
-
return
|
|
1105
|
+
return Yr(t, r);
|
|
1106
1106
|
case "ZodUndefined":
|
|
1107
|
-
return
|
|
1107
|
+
return da();
|
|
1108
1108
|
case "ZodNull":
|
|
1109
|
-
return
|
|
1109
|
+
return Qs();
|
|
1110
1110
|
case "ZodArray":
|
|
1111
|
-
return
|
|
1111
|
+
return js(t, r);
|
|
1112
1112
|
case "ZodUnion":
|
|
1113
1113
|
case "ZodDiscriminatedUnion":
|
|
1114
|
-
return
|
|
1114
|
+
return Xs(t, r);
|
|
1115
1115
|
case "ZodIntersection":
|
|
1116
|
-
return
|
|
1116
|
+
return Bs(t, r);
|
|
1117
1117
|
case "ZodTuple":
|
|
1118
|
-
return
|
|
1118
|
+
return ua(t, r);
|
|
1119
1119
|
case "ZodRecord":
|
|
1120
|
-
return
|
|
1120
|
+
return Hr(t, r);
|
|
1121
1121
|
case "ZodLiteral":
|
|
1122
|
-
return
|
|
1122
|
+
return Ws(t);
|
|
1123
1123
|
case "ZodEnum":
|
|
1124
|
-
return
|
|
1124
|
+
return Zs(t);
|
|
1125
1125
|
case "ZodNativeEnum":
|
|
1126
|
-
return
|
|
1126
|
+
return Hs(t);
|
|
1127
1127
|
case "ZodNullable":
|
|
1128
|
-
return
|
|
1128
|
+
return ta(t, r);
|
|
1129
1129
|
case "ZodOptional":
|
|
1130
|
-
return
|
|
1130
|
+
return ia(t, r);
|
|
1131
1131
|
case "ZodMap":
|
|
1132
|
-
return
|
|
1132
|
+
return Ks(t, r);
|
|
1133
1133
|
case "ZodSet":
|
|
1134
|
-
return
|
|
1134
|
+
return ca(t, r);
|
|
1135
1135
|
case "ZodLazy":
|
|
1136
1136
|
return () => t.getter()._def;
|
|
1137
1137
|
case "ZodPromise":
|
|
1138
|
-
return
|
|
1138
|
+
return la(t, r);
|
|
1139
1139
|
case "ZodNaN":
|
|
1140
1140
|
case "ZodNever":
|
|
1141
|
-
return
|
|
1141
|
+
return Gs();
|
|
1142
1142
|
case "ZodEffects":
|
|
1143
|
-
return
|
|
1143
|
+
return zs(t, r);
|
|
1144
1144
|
case "ZodAny":
|
|
1145
|
-
return
|
|
1145
|
+
return ue();
|
|
1146
1146
|
case "ZodUnknown":
|
|
1147
|
-
return
|
|
1147
|
+
return pa();
|
|
1148
1148
|
case "ZodDefault":
|
|
1149
|
-
return
|
|
1149
|
+
return qs(t, r);
|
|
1150
1150
|
case "ZodBranded":
|
|
1151
|
-
return
|
|
1151
|
+
return Jr(t, r);
|
|
1152
1152
|
case "ZodReadonly":
|
|
1153
|
-
return
|
|
1153
|
+
return fa(t, r);
|
|
1154
1154
|
case "ZodCatch":
|
|
1155
|
-
return
|
|
1155
|
+
return Fs(t, r);
|
|
1156
1156
|
case "ZodPipeline":
|
|
1157
|
-
return
|
|
1157
|
+
return oa(t, r);
|
|
1158
1158
|
case "ZodFunction":
|
|
1159
1159
|
case "ZodVoid":
|
|
1160
1160
|
case "ZodSymbol":
|
|
@@ -1163,7 +1163,7 @@ const da = (t, e) => q(t.innerType._def, e), pa = (t, e, r) => {
|
|
|
1163
1163
|
return /* @__PURE__ */ ((n) => {
|
|
1164
1164
|
})();
|
|
1165
1165
|
}
|
|
1166
|
-
},
|
|
1166
|
+
}, ga = (t, e) => {
|
|
1167
1167
|
let r = 0;
|
|
1168
1168
|
for (; r < t.length && r < e.length && t[r] === e[r]; r++) ;
|
|
1169
1169
|
return [(t.length - r).toString(), ...e.slice(r)].join("/");
|
|
@@ -1173,10 +1173,10 @@ function q(t, e, r = !1) {
|
|
|
1173
1173
|
const n = e.seen.get(t);
|
|
1174
1174
|
if (e.override) {
|
|
1175
1175
|
const y = (u = e.override) == null ? void 0 : u.call(e, t, e, n, r);
|
|
1176
|
-
if (y !==
|
|
1176
|
+
if (y !== Ds) return y;
|
|
1177
1177
|
}
|
|
1178
1178
|
if (n && !r) {
|
|
1179
|
-
const y =
|
|
1179
|
+
const y = ha(n, e);
|
|
1180
1180
|
if (y !== void 0) return y;
|
|
1181
1181
|
}
|
|
1182
1182
|
const s = {
|
|
@@ -1185,25 +1185,25 @@ function q(t, e, r = !1) {
|
|
|
1185
1185
|
jsonSchema: void 0
|
|
1186
1186
|
};
|
|
1187
1187
|
e.seen.set(t, s);
|
|
1188
|
-
const o =
|
|
1189
|
-
if (l &&
|
|
1188
|
+
const o = ma(t, t.typeName, e), l = typeof o == "function" ? q(o(), e) : o;
|
|
1189
|
+
if (l && ya(t, e, l), e.postProcess) {
|
|
1190
1190
|
const y = e.postProcess(l, t, e);
|
|
1191
1191
|
return s.jsonSchema = l, y;
|
|
1192
1192
|
}
|
|
1193
1193
|
return s.jsonSchema = l, l;
|
|
1194
1194
|
}
|
|
1195
|
-
const
|
|
1195
|
+
const ha = (t, e) => {
|
|
1196
1196
|
switch (e.$refStrategy) {
|
|
1197
1197
|
case "root":
|
|
1198
1198
|
return { $ref: t.path.join("/") };
|
|
1199
1199
|
case "relative":
|
|
1200
|
-
return { $ref:
|
|
1200
|
+
return { $ref: ga(e.currentPath, t.path) };
|
|
1201
1201
|
case "none":
|
|
1202
1202
|
case "seen":
|
|
1203
|
-
return t.path.length < e.currentPath.length && t.path.every((r, n) => e.currentPath[n] === r) ? (console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),
|
|
1203
|
+
return t.path.length < e.currentPath.length && t.path.every((r, n) => e.currentPath[n] === r) ? (console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`), ue()) : e.$refStrategy === "seen" ? ue() : void 0;
|
|
1204
1204
|
}
|
|
1205
|
-
},
|
|
1206
|
-
const e =
|
|
1205
|
+
}, ya = (t, e, r) => (t.description && (r.description = t.description), r), va = (t) => {
|
|
1206
|
+
const e = Ls(t), r = e.name !== void 0 ? [
|
|
1207
1207
|
...e.basePath,
|
|
1208
1208
|
e.definitionPath,
|
|
1209
1209
|
e.name
|
|
@@ -1222,8 +1222,8 @@ const ma = (t, e) => {
|
|
|
1222
1222
|
jsonSchema: void 0
|
|
1223
1223
|
}]))
|
|
1224
1224
|
};
|
|
1225
|
-
},
|
|
1226
|
-
const r =
|
|
1225
|
+
}, ba = (t, e) => {
|
|
1226
|
+
const r = va(e);
|
|
1227
1227
|
let n = typeof e == "object" && e.definitions ? Object.entries(e.definitions).reduce((y, [g, i]) => ({
|
|
1228
1228
|
...y,
|
|
1229
1229
|
[g]: q(i._def, {
|
|
@@ -1233,7 +1233,7 @@ const ma = (t, e) => {
|
|
|
1233
1233
|
r.definitionPath,
|
|
1234
1234
|
g
|
|
1235
1235
|
]
|
|
1236
|
-
}, !0) ??
|
|
1236
|
+
}, !0) ?? ue()
|
|
1237
1237
|
}), {}) : void 0;
|
|
1238
1238
|
const s = typeof e == "string" ? e : (e == null ? void 0 : e.nameStrategy) === "title" || e == null ? void 0 : e.name, o = q(t._def, s === void 0 ? r : {
|
|
1239
1239
|
...r,
|
|
@@ -1242,7 +1242,7 @@ const ma = (t, e) => {
|
|
|
1242
1242
|
r.definitionPath,
|
|
1243
1243
|
s
|
|
1244
1244
|
]
|
|
1245
|
-
}, !1) ??
|
|
1245
|
+
}, !1) ?? ue(), l = typeof e == "object" && e.name !== void 0 && e.nameStrategy === "title" ? e.name : void 0;
|
|
1246
1246
|
l !== void 0 && (o.title = l);
|
|
1247
1247
|
const u = s === void 0 ? n ? {
|
|
1248
1248
|
...o,
|
|
@@ -1260,7 +1260,7 @@ const ma = (t, e) => {
|
|
|
1260
1260
|
};
|
|
1261
1261
|
return u.$schema = "http://json-schema.org/draft-07/schema#", u;
|
|
1262
1262
|
}, Ut = Symbol.for("vercel.ai.schema");
|
|
1263
|
-
function
|
|
1263
|
+
function Sa(t) {
|
|
1264
1264
|
let e;
|
|
1265
1265
|
return () => (e == null && (e = t()), e);
|
|
1266
1266
|
}
|
|
@@ -1274,19 +1274,19 @@ function vt(t, { validate: e } = {}) {
|
|
|
1274
1274
|
validate: e
|
|
1275
1275
|
};
|
|
1276
1276
|
}
|
|
1277
|
-
function
|
|
1277
|
+
function Ia(t) {
|
|
1278
1278
|
return typeof t == "object" && t !== null && Ut in t && t[Ut] === !0 && "jsonSchema" in t && "validate" in t;
|
|
1279
1279
|
}
|
|
1280
|
-
function
|
|
1280
|
+
function Ea(t) {
|
|
1281
1281
|
return t == null ? vt({
|
|
1282
1282
|
type: "object",
|
|
1283
1283
|
properties: {},
|
|
1284
1284
|
additionalProperties: !1
|
|
1285
|
-
}) :
|
|
1285
|
+
}) : Ia(t) ? t : "~standard" in t ? t["~standard"].vendor === "zod" ? Gr(t) : Ca(t) : t();
|
|
1286
1286
|
}
|
|
1287
|
-
function
|
|
1287
|
+
function Ca(t) {
|
|
1288
1288
|
return vt(() => {
|
|
1289
|
-
if (!
|
|
1289
|
+
if (!wa(t)) throw new Error(`Standard schema vendor '${t["~standard"].vendor}' does not support JSON Schema conversion.`);
|
|
1290
1290
|
return Zt(t["~standard"].jsonSchema.input({ target: "draft-07" }));
|
|
1291
1291
|
}, { validate: async (e) => {
|
|
1292
1292
|
const r = await t["~standard"].validate(e);
|
|
@@ -1302,11 +1302,11 @@ function Ia(t) {
|
|
|
1302
1302
|
};
|
|
1303
1303
|
} });
|
|
1304
1304
|
}
|
|
1305
|
-
function
|
|
1305
|
+
function wa(t) {
|
|
1306
1306
|
return t["~standard"].jsonSchema != null;
|
|
1307
1307
|
}
|
|
1308
|
-
function
|
|
1309
|
-
return vt(() =>
|
|
1308
|
+
function Aa(t, e) {
|
|
1309
|
+
return vt(() => ba(t, { $refStrategy: "none" }), { validate: async (r) => {
|
|
1310
1310
|
const n = await t.safeParseAsync(r);
|
|
1311
1311
|
return n.success ? {
|
|
1312
1312
|
success: !0,
|
|
@@ -1317,13 +1317,13 @@ function Ca(t, e) {
|
|
|
1317
1317
|
};
|
|
1318
1318
|
} });
|
|
1319
1319
|
}
|
|
1320
|
-
function
|
|
1321
|
-
return vt(() => Zt(
|
|
1320
|
+
function xa(t, e) {
|
|
1321
|
+
return vt(() => Zt(fs(t, {
|
|
1322
1322
|
target: "draft-7",
|
|
1323
1323
|
io: "input",
|
|
1324
1324
|
reused: "inline"
|
|
1325
1325
|
})), { validate: async (r) => {
|
|
1326
|
-
const n = await
|
|
1326
|
+
const n = await Kn(t, r);
|
|
1327
1327
|
return n.success ? {
|
|
1328
1328
|
success: !0,
|
|
1329
1329
|
value: n.data
|
|
@@ -1333,14 +1333,14 @@ function wa(t, e) {
|
|
|
1333
1333
|
};
|
|
1334
1334
|
} });
|
|
1335
1335
|
}
|
|
1336
|
-
function
|
|
1336
|
+
function Ta(t) {
|
|
1337
1337
|
return "_zod" in t;
|
|
1338
1338
|
}
|
|
1339
|
-
function
|
|
1340
|
-
return
|
|
1339
|
+
function Gr(t, e) {
|
|
1340
|
+
return Ta(t) ? xa(t) : Aa(t);
|
|
1341
1341
|
}
|
|
1342
|
-
async function
|
|
1343
|
-
const n = await
|
|
1342
|
+
async function ur({ value: t, schema: e, context: r }) {
|
|
1343
|
+
const n = await Qr({
|
|
1344
1344
|
value: t,
|
|
1345
1345
|
schema: e,
|
|
1346
1346
|
context: r
|
|
@@ -1352,8 +1352,8 @@ async function cr({ value: t, schema: e, context: r }) {
|
|
|
1352
1352
|
});
|
|
1353
1353
|
return n.value;
|
|
1354
1354
|
}
|
|
1355
|
-
async function
|
|
1356
|
-
const n =
|
|
1355
|
+
async function Qr({ value: t, schema: e, context: r }) {
|
|
1356
|
+
const n = Ea(e);
|
|
1357
1357
|
try {
|
|
1358
1358
|
if (n.validate == null) return {
|
|
1359
1359
|
success: !0,
|
|
@@ -1388,19 +1388,19 @@ async function Gr({ value: t, schema: e, context: r }) {
|
|
|
1388
1388
|
}
|
|
1389
1389
|
async function qt({ text: t, schema: e }) {
|
|
1390
1390
|
try {
|
|
1391
|
-
const r =
|
|
1391
|
+
const r = Ns(t);
|
|
1392
1392
|
return e == null ? {
|
|
1393
1393
|
success: !0,
|
|
1394
1394
|
value: r,
|
|
1395
1395
|
rawValue: r
|
|
1396
|
-
} : await
|
|
1396
|
+
} : await Qr({
|
|
1397
1397
|
value: r,
|
|
1398
1398
|
schema: e
|
|
1399
1399
|
});
|
|
1400
1400
|
} catch (r) {
|
|
1401
1401
|
return {
|
|
1402
1402
|
success: !1,
|
|
1403
|
-
error:
|
|
1403
|
+
error: nr.isInstance(r) ? r : new nr({
|
|
1404
1404
|
text: t,
|
|
1405
1405
|
cause: r
|
|
1406
1406
|
}),
|
|
@@ -1408,8 +1408,8 @@ async function qt({ text: t, schema: e }) {
|
|
|
1408
1408
|
};
|
|
1409
1409
|
}
|
|
1410
1410
|
}
|
|
1411
|
-
function
|
|
1412
|
-
return t.pipeThrough(new TextDecoderStream()).pipeThrough(new
|
|
1411
|
+
function Ma({ stream: t, schema: e }) {
|
|
1412
|
+
return t.pipeThrough(new TextDecoderStream()).pipeThrough(new Ts()).pipeThrough(new TransformStream({ async transform({ data: r }, n) {
|
|
1413
1413
|
r !== "[DONE]" && n.enqueue(await qt({
|
|
1414
1414
|
text: r,
|
|
1415
1415
|
schema: e
|
|
@@ -1420,34 +1420,34 @@ async function Ve(t) {
|
|
|
1420
1420
|
return typeof t == "function" && (t = t()), t;
|
|
1421
1421
|
}
|
|
1422
1422
|
new TextDecoder();
|
|
1423
|
-
function
|
|
1423
|
+
function _a(t) {
|
|
1424
1424
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
1425
1425
|
}
|
|
1426
|
-
const
|
|
1426
|
+
const Xr = "AI_InvalidArgumentError", en = `vercel.ai.error.${Xr}`, Ra = Symbol.for(en);
|
|
1427
1427
|
var ut = class extends ee {
|
|
1428
1428
|
constructor({ parameter: t, value: e, message: r }) {
|
|
1429
1429
|
super({
|
|
1430
|
-
name:
|
|
1430
|
+
name: Xr,
|
|
1431
1431
|
message: `Invalid argument for parameter ${t}: ${r}`
|
|
1432
|
-
}), this[
|
|
1432
|
+
}), this[Ra] = !0, this.parameter = t, this.value = e;
|
|
1433
1433
|
}
|
|
1434
1434
|
static isInstance(t) {
|
|
1435
|
-
return ee.hasMarker(t,
|
|
1435
|
+
return ee.hasMarker(t, en);
|
|
1436
1436
|
}
|
|
1437
1437
|
};
|
|
1438
|
-
const
|
|
1439
|
-
var
|
|
1438
|
+
const tn = "AI_UIMessageStreamError", rn = `vercel.ai.error.${tn}`, Pa = Symbol.for(rn);
|
|
1439
|
+
var Ne = class extends ee {
|
|
1440
1440
|
constructor({ chunkType: t, chunkId: e, message: r }) {
|
|
1441
1441
|
super({
|
|
1442
|
-
name:
|
|
1442
|
+
name: tn,
|
|
1443
1443
|
message: r
|
|
1444
|
-
}), this[
|
|
1444
|
+
}), this[Pa] = !0, this.chunkType = t, this.chunkId = e;
|
|
1445
1445
|
}
|
|
1446
1446
|
static isInstance(t) {
|
|
1447
|
-
return ee.hasMarker(t,
|
|
1447
|
+
return ee.hasMarker(t, rn);
|
|
1448
1448
|
}
|
|
1449
1449
|
};
|
|
1450
|
-
function
|
|
1450
|
+
function nn(t, e) {
|
|
1451
1451
|
if (t === void 0 && e === void 0) return;
|
|
1452
1452
|
if (t === void 0) return e;
|
|
1453
1453
|
if (e === void 0) return t;
|
|
@@ -1457,45 +1457,45 @@ function rn(t, e) {
|
|
|
1457
1457
|
const s = e[n];
|
|
1458
1458
|
if (s === void 0) continue;
|
|
1459
1459
|
const o = n in t ? t[n] : void 0, l = s !== null && typeof s == "object" && !Array.isArray(s) && !(s instanceof Date) && !(s instanceof RegExp), u = o != null && typeof o == "object" && !Array.isArray(o) && !(o instanceof Date) && !(o instanceof RegExp);
|
|
1460
|
-
l && u ? r[n] =
|
|
1460
|
+
l && u ? r[n] = nn(o, s) : r[n] = s;
|
|
1461
1461
|
}
|
|
1462
1462
|
return r;
|
|
1463
1463
|
}
|
|
1464
1464
|
const a = {
|
|
1465
|
-
array:
|
|
1466
|
-
boolean:
|
|
1467
|
-
custom:
|
|
1468
|
-
discriminatedUnion:
|
|
1469
|
-
enum:
|
|
1470
|
-
instanceof:
|
|
1471
|
-
lazy:
|
|
1472
|
-
literal:
|
|
1473
|
-
looseObject:
|
|
1474
|
-
never:
|
|
1475
|
-
null:
|
|
1476
|
-
number:
|
|
1477
|
-
object:
|
|
1478
|
-
record:
|
|
1479
|
-
string:
|
|
1480
|
-
union:
|
|
1481
|
-
unknown:
|
|
1482
|
-
},
|
|
1465
|
+
array: ps,
|
|
1466
|
+
boolean: ds,
|
|
1467
|
+
custom: us,
|
|
1468
|
+
discriminatedUnion: cs,
|
|
1469
|
+
enum: ls,
|
|
1470
|
+
instanceof: os,
|
|
1471
|
+
lazy: Hn,
|
|
1472
|
+
literal: is,
|
|
1473
|
+
looseObject: as,
|
|
1474
|
+
never: ss,
|
|
1475
|
+
null: ns,
|
|
1476
|
+
number: rs,
|
|
1477
|
+
object: ts,
|
|
1478
|
+
record: es,
|
|
1479
|
+
string: Xn,
|
|
1480
|
+
union: Qn,
|
|
1481
|
+
unknown: Gn
|
|
1482
|
+
}, $e = a.lazy(() => a.union([
|
|
1483
1483
|
a.null(),
|
|
1484
1484
|
a.string(),
|
|
1485
1485
|
a.number(),
|
|
1486
1486
|
a.boolean(),
|
|
1487
|
-
a.record(a.string(),
|
|
1488
|
-
a.array(
|
|
1489
|
-
])), _ = a.record(a.string(), a.record(a.string(),
|
|
1487
|
+
a.record(a.string(), $e.optional()),
|
|
1488
|
+
a.array($e)
|
|
1489
|
+
])), _ = a.record(a.string(), a.record(a.string(), $e.optional())), et = a.union([
|
|
1490
1490
|
a.string(),
|
|
1491
1491
|
a.instanceof(Uint8Array),
|
|
1492
1492
|
a.instanceof(ArrayBuffer),
|
|
1493
|
-
a.custom(
|
|
1494
|
-
]), Vt = a.record(a.string(), a.string()),
|
|
1493
|
+
a.custom(_s, { message: "Must be a Buffer" })
|
|
1494
|
+
]), Vt = a.record(a.string(), a.string()), sn = a.object({
|
|
1495
1495
|
type: a.literal("text"),
|
|
1496
1496
|
text: a.string(),
|
|
1497
1497
|
providerOptions: _.optional()
|
|
1498
|
-
}),
|
|
1498
|
+
}), Oa = a.object({
|
|
1499
1499
|
type: a.literal("image"),
|
|
1500
1500
|
image: a.union([
|
|
1501
1501
|
et,
|
|
@@ -1504,7 +1504,7 @@ const a = {
|
|
|
1504
1504
|
]),
|
|
1505
1505
|
mediaType: a.string().optional(),
|
|
1506
1506
|
providerOptions: _.optional()
|
|
1507
|
-
}),
|
|
1507
|
+
}), an = a.discriminatedUnion("type", [
|
|
1508
1508
|
a.object({
|
|
1509
1509
|
type: a.literal("data"),
|
|
1510
1510
|
data: et
|
|
@@ -1521,16 +1521,16 @@ const a = {
|
|
|
1521
1521
|
type: a.literal("text"),
|
|
1522
1522
|
text: a.string()
|
|
1523
1523
|
})
|
|
1524
|
-
]),
|
|
1524
|
+
]), Na = a.discriminatedUnion("type", [a.object({
|
|
1525
1525
|
type: a.literal("data"),
|
|
1526
1526
|
data: et
|
|
1527
1527
|
}), a.object({
|
|
1528
1528
|
type: a.literal("url"),
|
|
1529
1529
|
url: a.instanceof(URL)
|
|
1530
|
-
})]),
|
|
1530
|
+
})]), on = a.object({
|
|
1531
1531
|
type: a.literal("file"),
|
|
1532
1532
|
data: a.union([
|
|
1533
|
-
|
|
1533
|
+
an,
|
|
1534
1534
|
et,
|
|
1535
1535
|
a.instanceof(URL),
|
|
1536
1536
|
Vt
|
|
@@ -1538,31 +1538,31 @@ const a = {
|
|
|
1538
1538
|
filename: a.string().optional(),
|
|
1539
1539
|
mediaType: a.string(),
|
|
1540
1540
|
providerOptions: _.optional()
|
|
1541
|
-
}),
|
|
1541
|
+
}), Da = a.object({
|
|
1542
1542
|
type: a.literal("reasoning"),
|
|
1543
1543
|
text: a.string(),
|
|
1544
1544
|
providerOptions: _.optional()
|
|
1545
|
-
}),
|
|
1545
|
+
}), La = a.object({
|
|
1546
1546
|
type: a.literal("custom"),
|
|
1547
1547
|
kind: a.string().transform((t) => t),
|
|
1548
1548
|
providerOptions: _.optional()
|
|
1549
|
-
}),
|
|
1549
|
+
}), ja = a.object({
|
|
1550
1550
|
type: a.literal("reasoning-file"),
|
|
1551
1551
|
data: a.union([
|
|
1552
|
-
|
|
1552
|
+
Na,
|
|
1553
1553
|
et,
|
|
1554
1554
|
a.instanceof(URL)
|
|
1555
1555
|
]),
|
|
1556
1556
|
mediaType: a.string(),
|
|
1557
1557
|
providerOptions: _.optional()
|
|
1558
|
-
}),
|
|
1558
|
+
}), ka = a.object({
|
|
1559
1559
|
type: a.literal("tool-call"),
|
|
1560
1560
|
toolCallId: a.string(),
|
|
1561
1561
|
toolName: a.string(),
|
|
1562
1562
|
input: a.unknown(),
|
|
1563
1563
|
providerOptions: _.optional(),
|
|
1564
1564
|
providerExecuted: a.boolean().optional()
|
|
1565
|
-
}),
|
|
1565
|
+
}), $a = a.discriminatedUnion("type", [
|
|
1566
1566
|
a.object({
|
|
1567
1567
|
type: a.literal("text"),
|
|
1568
1568
|
value: a.string(),
|
|
@@ -1570,7 +1570,7 @@ const a = {
|
|
|
1570
1570
|
}),
|
|
1571
1571
|
a.object({
|
|
1572
1572
|
type: a.literal("json"),
|
|
1573
|
-
value:
|
|
1573
|
+
value: $e,
|
|
1574
1574
|
providerOptions: _.optional()
|
|
1575
1575
|
}),
|
|
1576
1576
|
a.object({
|
|
@@ -1585,7 +1585,7 @@ const a = {
|
|
|
1585
1585
|
}),
|
|
1586
1586
|
a.object({
|
|
1587
1587
|
type: a.literal("error-json"),
|
|
1588
|
-
value:
|
|
1588
|
+
value: $e,
|
|
1589
1589
|
providerOptions: _.optional()
|
|
1590
1590
|
}),
|
|
1591
1591
|
a.object({
|
|
@@ -1598,7 +1598,7 @@ const a = {
|
|
|
1598
1598
|
}),
|
|
1599
1599
|
a.object({
|
|
1600
1600
|
type: a.literal("file"),
|
|
1601
|
-
data:
|
|
1601
|
+
data: an,
|
|
1602
1602
|
mediaType: a.string(),
|
|
1603
1603
|
filename: a.string().optional(),
|
|
1604
1604
|
providerOptions: _.optional()
|
|
@@ -1653,13 +1653,13 @@ const a = {
|
|
|
1653
1653
|
})
|
|
1654
1654
|
]))
|
|
1655
1655
|
})
|
|
1656
|
-
]),
|
|
1656
|
+
]), ln = a.object({
|
|
1657
1657
|
type: a.literal("tool-result"),
|
|
1658
1658
|
toolCallId: a.string(),
|
|
1659
1659
|
toolName: a.string(),
|
|
1660
|
-
output:
|
|
1660
|
+
output: $a,
|
|
1661
1661
|
providerOptions: _.optional()
|
|
1662
|
-
}),
|
|
1662
|
+
}), Fa = a.object({
|
|
1663
1663
|
type: a.literal("tool-approval-request"),
|
|
1664
1664
|
approvalId: a.string(),
|
|
1665
1665
|
toolCallId: a.string(),
|
|
@@ -1667,48 +1667,48 @@ const a = {
|
|
|
1667
1667
|
isAutomatic: a.boolean().optional(),
|
|
1668
1668
|
signature: a.string().optional(),
|
|
1669
1669
|
inputSchemaInput: a.unknown().optional()
|
|
1670
|
-
}),
|
|
1670
|
+
}), Ua = a.object({
|
|
1671
1671
|
type: a.literal("tool-approval-response"),
|
|
1672
1672
|
approvalId: a.string(),
|
|
1673
1673
|
approved: a.boolean(),
|
|
1674
1674
|
reason: a.string().optional()
|
|
1675
|
-
}),
|
|
1675
|
+
}), qa = a.object({
|
|
1676
1676
|
role: a.literal("system"),
|
|
1677
1677
|
content: a.string(),
|
|
1678
1678
|
providerOptions: _.optional()
|
|
1679
|
-
}),
|
|
1679
|
+
}), za = a.object({
|
|
1680
1680
|
role: a.literal("user"),
|
|
1681
1681
|
content: a.union([a.string(), a.array(a.union([
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1682
|
+
sn,
|
|
1683
|
+
Oa,
|
|
1684
|
+
on
|
|
1685
1685
|
]))]),
|
|
1686
1686
|
providerOptions: _.optional()
|
|
1687
|
-
}),
|
|
1687
|
+
}), Za = a.object({
|
|
1688
1688
|
role: a.literal("assistant"),
|
|
1689
1689
|
content: a.union([a.string(), a.array(a.union([
|
|
1690
|
-
|
|
1691
|
-
Na,
|
|
1692
|
-
an,
|
|
1693
|
-
Oa,
|
|
1694
|
-
Da,
|
|
1690
|
+
sn,
|
|
1695
1691
|
La,
|
|
1696
1692
|
on,
|
|
1697
|
-
|
|
1693
|
+
Da,
|
|
1694
|
+
ja,
|
|
1695
|
+
ka,
|
|
1696
|
+
ln,
|
|
1697
|
+
Fa
|
|
1698
1698
|
]))]),
|
|
1699
1699
|
providerOptions: _.optional()
|
|
1700
|
-
}),
|
|
1700
|
+
}), Va = a.object({
|
|
1701
1701
|
role: a.literal("tool"),
|
|
1702
|
-
content: a.array(a.union([
|
|
1702
|
+
content: a.array(a.union([ln, Ua])),
|
|
1703
1703
|
providerOptions: _.optional()
|
|
1704
1704
|
});
|
|
1705
1705
|
a.union([
|
|
1706
|
-
Fa,
|
|
1707
|
-
Ua,
|
|
1708
1706
|
qa,
|
|
1709
|
-
za
|
|
1707
|
+
za,
|
|
1708
|
+
Za,
|
|
1709
|
+
Va
|
|
1710
1710
|
]);
|
|
1711
|
-
function
|
|
1711
|
+
function Ba(t) {
|
|
1712
1712
|
const e = ["ROOT"];
|
|
1713
1713
|
let r = -1, n = null, s = 0;
|
|
1714
1714
|
function o(i) {
|
|
@@ -1909,7 +1909,7 @@ function Za(t) {
|
|
|
1909
1909
|
}
|
|
1910
1910
|
return g;
|
|
1911
1911
|
}
|
|
1912
|
-
async function
|
|
1912
|
+
async function Wa(t) {
|
|
1913
1913
|
if (t === void 0) return {
|
|
1914
1914
|
value: void 0,
|
|
1915
1915
|
state: "undefined-input"
|
|
@@ -1918,7 +1918,7 @@ async function Va(t) {
|
|
|
1918
1918
|
return e.success ? {
|
|
1919
1919
|
value: e.value,
|
|
1920
1920
|
state: "successful-parse"
|
|
1921
|
-
} : (e = await qt({ text:
|
|
1921
|
+
} : (e = await qt({ text: Ba(t) }), e.success ? {
|
|
1922
1922
|
value: e.value,
|
|
1923
1923
|
state: "repaired-parse"
|
|
1924
1924
|
} : {
|
|
@@ -1952,7 +1952,7 @@ te({
|
|
|
1952
1952
|
});
|
|
1953
1953
|
}
|
|
1954
1954
|
});
|
|
1955
|
-
const
|
|
1955
|
+
const Ja = a.object({
|
|
1956
1956
|
source: a.discriminatedUnion("sourceType", [a.object({
|
|
1957
1957
|
type: a.literal("source"),
|
|
1958
1958
|
sourceType: a.literal("url"),
|
|
@@ -1972,7 +1972,7 @@ const Ba = a.object({
|
|
|
1972
1972
|
startIndex: a.number().int().nonnegative().optional(),
|
|
1973
1973
|
endIndex: a.number().int().nonnegative().optional(),
|
|
1974
1974
|
citedText: a.string().optional()
|
|
1975
|
-
}), Ge = a.record(a.string(),
|
|
1975
|
+
}), Ge = a.record(a.string(), $e.optional()), Ya = Sa(() => Gr(a.union([
|
|
1976
1976
|
a.looseObject({
|
|
1977
1977
|
type: a.literal("text-start"),
|
|
1978
1978
|
id: a.string(),
|
|
@@ -1987,7 +1987,7 @@ const Ba = a.object({
|
|
|
1987
1987
|
a.looseObject({
|
|
1988
1988
|
type: a.literal("text-end"),
|
|
1989
1989
|
id: a.string(),
|
|
1990
|
-
citations: a.array(
|
|
1990
|
+
citations: a.array(Ja).optional(),
|
|
1991
1991
|
providerMetadata: _.optional()
|
|
1992
1992
|
}),
|
|
1993
1993
|
a.looseObject({
|
|
@@ -2158,7 +2158,7 @@ const Ba = a.object({
|
|
|
2158
2158
|
messageMetadata: a.unknown()
|
|
2159
2159
|
})
|
|
2160
2160
|
])));
|
|
2161
|
-
function
|
|
2161
|
+
function Ka(t) {
|
|
2162
2162
|
return t.type.startsWith("data-");
|
|
2163
2163
|
}
|
|
2164
2164
|
function Be() {
|
|
@@ -2167,19 +2167,19 @@ function Be() {
|
|
|
2167
2167
|
function gt(t) {
|
|
2168
2168
|
return t.type.startsWith("tool-");
|
|
2169
2169
|
}
|
|
2170
|
-
function
|
|
2170
|
+
function cn(t) {
|
|
2171
2171
|
return t.type === "dynamic-tool";
|
|
2172
2172
|
}
|
|
2173
|
-
function
|
|
2174
|
-
return gt(t) ||
|
|
2173
|
+
function pe(t) {
|
|
2174
|
+
return gt(t) || cn(t);
|
|
2175
2175
|
}
|
|
2176
2176
|
function ht(t) {
|
|
2177
2177
|
return t.type.split("-").slice(1).join("-");
|
|
2178
2178
|
}
|
|
2179
|
-
function
|
|
2180
|
-
return
|
|
2179
|
+
function Ha(t) {
|
|
2180
|
+
return cn(t) ? t.toolName : ht(t);
|
|
2181
2181
|
}
|
|
2182
|
-
function
|
|
2182
|
+
function un({ lastMessage: t, messageId: e }) {
|
|
2183
2183
|
const r = (t == null ? void 0 : t.role) === "assistant" ? t : {
|
|
2184
2184
|
id: e,
|
|
2185
2185
|
metadata: void 0,
|
|
@@ -2188,7 +2188,7 @@ function cn({ lastMessage: t, messageId: e }) {
|
|
|
2188
2188
|
}, n = Be(), s = r.parts.findLastIndex((l) => l.type === "step-start");
|
|
2189
2189
|
let o = 0;
|
|
2190
2190
|
for (const l of r.parts.slice(s + 1)) {
|
|
2191
|
-
if (!
|
|
2191
|
+
if (!pe(l)) continue;
|
|
2192
2192
|
const u = o;
|
|
2193
2193
|
gt(l) && o++, l.state === "input-streaming" && (n[l.toolCallId] = {
|
|
2194
2194
|
text: l.rawInput ?? "",
|
|
@@ -2207,18 +2207,18 @@ function cn({ lastMessage: t, messageId: e }) {
|
|
|
2207
2207
|
partialToolCalls: n
|
|
2208
2208
|
};
|
|
2209
2209
|
}
|
|
2210
|
-
function
|
|
2210
|
+
function Ga({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdateMessageJob: n, onError: s, onToolCall: o, onData: l, resetStateOnMessageIdChange: u = !1, resetStateOnFirstMessageStart: y = !1 }) {
|
|
2211
2211
|
let g = !0;
|
|
2212
2212
|
return t.pipeThrough(new TransformStream({ async transform(i, d) {
|
|
2213
2213
|
await n(async ({ state: p, write: b }) => {
|
|
2214
|
-
function
|
|
2214
|
+
function P() {
|
|
2215
2215
|
const c = p.message.parts;
|
|
2216
2216
|
let m = c.length - 1;
|
|
2217
2217
|
for (; m >= 0 && c[m].type !== "step-start"; ) m--;
|
|
2218
2218
|
return c.slice(m + 1);
|
|
2219
2219
|
}
|
|
2220
2220
|
function M() {
|
|
2221
|
-
return
|
|
2221
|
+
return P().filter(pe);
|
|
2222
2222
|
}
|
|
2223
2223
|
function O(c) {
|
|
2224
2224
|
let m = M().find((f) => f.toolCallId === c);
|
|
@@ -2226,25 +2226,25 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
|
|
|
2226
2226
|
const f = p.message.parts;
|
|
2227
2227
|
for (let h = f.length - 1; h >= 0; h--) {
|
|
2228
2228
|
const S = f[h];
|
|
2229
|
-
if (
|
|
2229
|
+
if (pe(S) && S.toolCallId === c) {
|
|
2230
2230
|
m = S;
|
|
2231
2231
|
break;
|
|
2232
2232
|
}
|
|
2233
2233
|
}
|
|
2234
2234
|
}
|
|
2235
|
-
if (m == null) throw new
|
|
2235
|
+
if (m == null) throw new Ne({
|
|
2236
2236
|
chunkType: "tool-invocation",
|
|
2237
2237
|
chunkId: c,
|
|
2238
2238
|
message: `No tool invocation found for tool call ID "${c}".`
|
|
2239
2239
|
});
|
|
2240
2240
|
return m;
|
|
2241
2241
|
}
|
|
2242
|
-
function
|
|
2243
|
-
const m = p.message.parts.filter(
|
|
2242
|
+
function x(c) {
|
|
2243
|
+
const m = p.message.parts.filter(pe).find((f) => {
|
|
2244
2244
|
var h;
|
|
2245
2245
|
return ((h = f.approval) == null ? void 0 : h.id) === c;
|
|
2246
2246
|
});
|
|
2247
|
-
if (m == null) throw new
|
|
2247
|
+
if (m == null) throw new Ne({
|
|
2248
2248
|
chunkType: "tool-approval-response",
|
|
2249
2249
|
chunkId: c,
|
|
2250
2250
|
message: `No tool invocation found for approval ID "${c}".`
|
|
@@ -2252,7 +2252,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
|
|
|
2252
2252
|
return m;
|
|
2253
2253
|
}
|
|
2254
2254
|
function w(c, m) {
|
|
2255
|
-
const f = m ??
|
|
2255
|
+
const f = m ?? P().find((N) => gt(N) && N.toolCallId === c.toolCallId), h = c, S = f;
|
|
2256
2256
|
if (f != null) {
|
|
2257
2257
|
f.state = c.state, S.type = `tool-${c.toolName}`, S.input = h.input, S.output = h.output, S.errorText = h.errorText, S.rawInput = h.rawInput, h.inputEncoding != null ? S.inputEncoding = h.inputEncoding : delete S.inputEncoding, S.preliminary = h.preliminary, c.title !== void 0 && (S.title = c.title), c.toolMetadata !== void 0 && (S.toolMetadata = c.toolMetadata), S.providerExecuted = h.providerExecuted ?? f.providerExecuted;
|
|
2258
2258
|
const N = h.providerMetadata;
|
|
@@ -2279,7 +2279,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
|
|
|
2279
2279
|
});
|
|
2280
2280
|
}
|
|
2281
2281
|
function I(c, m) {
|
|
2282
|
-
const f = m ??
|
|
2282
|
+
const f = m ?? P().find((N) => N.type === "dynamic-tool" && N.toolCallId === c.toolCallId), h = c, S = f;
|
|
2283
2283
|
if (f != null) {
|
|
2284
2284
|
f.state = c.state, S.toolName = c.toolName, S.input = h.input, S.output = h.output, S.errorText = h.errorText, S.rawInput = h.rawInput, h.inputEncoding != null ? S.inputEncoding = h.inputEncoding : delete S.inputEncoding, S.preliminary = h.preliminary, c.title !== void 0 && (S.title = c.title), c.toolMetadata !== void 0 && (S.toolMetadata = c.toolMetadata), S.providerExecuted = h.providerExecuted ?? f.providerExecuted;
|
|
2285
2285
|
const N = h.providerMetadata;
|
|
@@ -2307,8 +2307,8 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
|
|
|
2307
2307
|
}
|
|
2308
2308
|
async function C(c) {
|
|
2309
2309
|
if (c != null) {
|
|
2310
|
-
const m = p.message.metadata != null ?
|
|
2311
|
-
e != null && await
|
|
2310
|
+
const m = p.message.metadata != null ? nn(p.message.metadata, c) : c;
|
|
2311
|
+
e != null && await ur({
|
|
2312
2312
|
value: m,
|
|
2313
2313
|
schema: e,
|
|
2314
2314
|
context: {
|
|
@@ -2331,7 +2331,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
|
|
|
2331
2331
|
}
|
|
2332
2332
|
case "text-delta": {
|
|
2333
2333
|
const c = p.activeTextParts[i.id];
|
|
2334
|
-
if (c == null) throw new
|
|
2334
|
+
if (c == null) throw new Ne({
|
|
2335
2335
|
chunkType: "text-delta",
|
|
2336
2336
|
chunkId: i.id,
|
|
2337
2337
|
message: `Received text-delta for missing text part with ID "${i.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`
|
|
@@ -2341,7 +2341,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
|
|
|
2341
2341
|
}
|
|
2342
2342
|
case "text-end": {
|
|
2343
2343
|
const c = p.activeTextParts[i.id];
|
|
2344
|
-
if (c == null) throw new
|
|
2344
|
+
if (c == null) throw new Ne({
|
|
2345
2345
|
chunkType: "text-end",
|
|
2346
2346
|
chunkId: i.id,
|
|
2347
2347
|
message: `Received text-end for missing text part with ID "${i.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`
|
|
@@ -2371,7 +2371,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
|
|
|
2371
2371
|
}
|
|
2372
2372
|
case "reasoning-delta": {
|
|
2373
2373
|
const c = p.activeReasoningParts[i.id];
|
|
2374
|
-
if (c == null) throw new
|
|
2374
|
+
if (c == null) throw new Ne({
|
|
2375
2375
|
chunkType: "reasoning-delta",
|
|
2376
2376
|
chunkId: i.id,
|
|
2377
2377
|
message: `Received reasoning-delta for missing reasoning part with ID "${i.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`
|
|
@@ -2381,7 +2381,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
|
|
|
2381
2381
|
}
|
|
2382
2382
|
case "reasoning-end": {
|
|
2383
2383
|
const c = p.activeReasoningParts[i.id];
|
|
2384
|
-
if (c == null) throw new
|
|
2384
|
+
if (c == null) throw new Ne({
|
|
2385
2385
|
chunkType: "reasoning-end",
|
|
2386
2386
|
chunkId: i.id,
|
|
2387
2387
|
message: `Received reasoning-end for missing reasoning part with ID "${i.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`
|
|
@@ -2418,7 +2418,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
|
|
|
2418
2418
|
}), b();
|
|
2419
2419
|
break;
|
|
2420
2420
|
case "tool-input-start": {
|
|
2421
|
-
const c =
|
|
2421
|
+
const c = P().filter(gt);
|
|
2422
2422
|
p.partialToolCalls[i.toolCallId] = {
|
|
2423
2423
|
text: "",
|
|
2424
2424
|
inputEncoding: i.inputEncoding,
|
|
@@ -2452,13 +2452,13 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
|
|
|
2452
2452
|
}
|
|
2453
2453
|
case "tool-input-delta": {
|
|
2454
2454
|
const c = p.partialToolCalls[i.toolCallId];
|
|
2455
|
-
if (c == null) throw new
|
|
2455
|
+
if (c == null) throw new Ne({
|
|
2456
2456
|
chunkType: "tool-input-delta",
|
|
2457
2457
|
chunkId: i.toolCallId,
|
|
2458
2458
|
message: `Received tool-input-delta for missing tool call with ID "${i.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`
|
|
2459
2459
|
});
|
|
2460
2460
|
c.text += i.inputTextDelta;
|
|
2461
|
-
const m = c.inputEncoding === "text" ? c.text : (await
|
|
2461
|
+
const m = c.inputEncoding === "text" ? c.text : (await Wa(c.text)).value;
|
|
2462
2462
|
c.dynamic ? I({
|
|
2463
2463
|
toolCallId: i.toolCallId,
|
|
2464
2464
|
toolName: c.toolName,
|
|
@@ -2502,7 +2502,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
|
|
|
2502
2502
|
}), b(), o && !i.providerExecuted && await o({ toolCall: i });
|
|
2503
2503
|
break;
|
|
2504
2504
|
case "tool-input-error": {
|
|
2505
|
-
const c =
|
|
2505
|
+
const c = P().filter(pe).find((m) => m.toolCallId === i.toolCallId);
|
|
2506
2506
|
(c != null ? c.type === "dynamic-tool" : i.dynamic) ? I({
|
|
2507
2507
|
toolCallId: i.toolCallId,
|
|
2508
2508
|
toolName: i.toolName,
|
|
@@ -2537,7 +2537,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
|
|
|
2537
2537
|
break;
|
|
2538
2538
|
}
|
|
2539
2539
|
case "tool-approval-response": {
|
|
2540
|
-
const c =
|
|
2540
|
+
const c = x(i.approvalId), m = c.approval == null ? { id: i.approvalId } : c.approval;
|
|
2541
2541
|
c.state = "approval-responded", c.approval = {
|
|
2542
2542
|
...m,
|
|
2543
2543
|
id: i.approvalId,
|
|
@@ -2610,13 +2610,13 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
|
|
|
2610
2610
|
case "finish-step":
|
|
2611
2611
|
break;
|
|
2612
2612
|
case "reset-step": {
|
|
2613
|
-
const c =
|
|
2613
|
+
const c = P();
|
|
2614
2614
|
p.activeTextParts = Be(), p.activeReasoningParts = Be(), p.partialToolCalls = Be(), c.length > 0 && (p.message.parts.splice(p.message.parts.length - c.length, c.length), b());
|
|
2615
2615
|
break;
|
|
2616
2616
|
}
|
|
2617
2617
|
case "start": {
|
|
2618
2618
|
const c = y && g || u && i.messageId != null && i.messageId !== p.message.id;
|
|
2619
|
-
g = !1, c && Object.assign(p,
|
|
2619
|
+
g = !1, c && Object.assign(p, un({
|
|
2620
2620
|
lastMessage: void 0,
|
|
2621
2621
|
messageId: i.messageId ?? p.message.id
|
|
2622
2622
|
}), { finishReason: void 0 }), i.messageId != null && (p.message.id = i.messageId), await C(i.messageMetadata), (c || i.messageId != null || i.messageMetadata != null) && b({ updateStatus: !1 });
|
|
@@ -2632,10 +2632,10 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
|
|
|
2632
2632
|
s == null || s(new Error(i.errorText));
|
|
2633
2633
|
break;
|
|
2634
2634
|
default:
|
|
2635
|
-
if (
|
|
2635
|
+
if (Ka(i)) {
|
|
2636
2636
|
if ((r == null ? void 0 : r[i.type]) != null) {
|
|
2637
2637
|
const f = p.message.parts.findIndex((S) => "id" in S && "data" in S && S.id === i.id && S.type === i.type), h = f >= 0 ? f : p.message.parts.length;
|
|
2638
|
-
await
|
|
2638
|
+
await ur({
|
|
2639
2639
|
value: i.data,
|
|
2640
2640
|
schema: r[i.type],
|
|
2641
2641
|
context: {
|
|
@@ -2658,7 +2658,7 @@ function Ka({ stream: t, messageMetadataSchema: e, dataPartSchemas: r, runUpdate
|
|
|
2658
2658
|
});
|
|
2659
2659
|
} }));
|
|
2660
2660
|
}
|
|
2661
|
-
async function
|
|
2661
|
+
async function Qa({ stream: t, onError: e, abortSignal: r }) {
|
|
2662
2662
|
const n = t.getReader(), s = () => {
|
|
2663
2663
|
n.cancel().catch(() => {
|
|
2664
2664
|
});
|
|
@@ -2675,7 +2675,7 @@ async function Ha({ stream: t, onError: e, abortSignal: r }) {
|
|
|
2675
2675
|
r == null || r.removeEventListener("abort", s), n.releaseLock();
|
|
2676
2676
|
}
|
|
2677
2677
|
}
|
|
2678
|
-
function
|
|
2678
|
+
function Xa() {
|
|
2679
2679
|
let t, e;
|
|
2680
2680
|
return {
|
|
2681
2681
|
promise: new Promise((r, n) => {
|
|
@@ -2701,7 +2701,7 @@ te({
|
|
|
2701
2701
|
prefix: "call",
|
|
2702
2702
|
size: 24
|
|
2703
2703
|
});
|
|
2704
|
-
a.record(a.string(),
|
|
2704
|
+
a.record(a.string(), $e.optional());
|
|
2705
2705
|
a.record(a.string(), a.string());
|
|
2706
2706
|
te({
|
|
2707
2707
|
prefix: "call",
|
|
@@ -2720,7 +2720,7 @@ te({
|
|
|
2720
2720
|
prefix: "aiobj",
|
|
2721
2721
|
size: 24
|
|
2722
2722
|
});
|
|
2723
|
-
var
|
|
2723
|
+
var ei = class {
|
|
2724
2724
|
constructor() {
|
|
2725
2725
|
this.queue = [], this.isProcessing = !1, this.idleWaiters = [];
|
|
2726
2726
|
}
|
|
@@ -2791,9 +2791,9 @@ te({
|
|
|
2791
2791
|
prefix: "call",
|
|
2792
2792
|
size: 24
|
|
2793
2793
|
});
|
|
2794
|
-
async function
|
|
2794
|
+
async function dr({ response: t, url: e, fallbackMessage: r }) {
|
|
2795
2795
|
const n = await t.text();
|
|
2796
|
-
return new
|
|
2796
|
+
return new Lr({
|
|
2797
2797
|
message: n || r,
|
|
2798
2798
|
url: e,
|
|
2799
2799
|
requestBodyValues: void 0,
|
|
@@ -2801,9 +2801,9 @@ async function ur({ response: t, url: e, fallbackMessage: r }) {
|
|
|
2801
2801
|
responseBody: n
|
|
2802
2802
|
});
|
|
2803
2803
|
}
|
|
2804
|
-
async function
|
|
2804
|
+
async function ti(t) {
|
|
2805
2805
|
if (t == null) return [];
|
|
2806
|
-
if (!globalThis.FileList || !(t instanceof globalThis.FileList)) throw new
|
|
2806
|
+
if (!globalThis.FileList || !(t instanceof globalThis.FileList)) throw new ws({
|
|
2807
2807
|
functionality: "FileList",
|
|
2808
2808
|
message: "FileList is not supported in the current environment"
|
|
2809
2809
|
});
|
|
@@ -2823,11 +2823,11 @@ async function Xa(t) {
|
|
|
2823
2823
|
};
|
|
2824
2824
|
}));
|
|
2825
2825
|
}
|
|
2826
|
-
function
|
|
2826
|
+
function ri(t, e) {
|
|
2827
2827
|
const r = t.search(/[?#]/), n = r === -1 ? t : t.slice(0, r), s = r === -1 ? "" : t.slice(r);
|
|
2828
2828
|
return `${n.endsWith("/") && e.startsWith("/") ? n.slice(0, -1) : n}${e}${s}`;
|
|
2829
2829
|
}
|
|
2830
|
-
var
|
|
2830
|
+
var ni = class {
|
|
2831
2831
|
constructor({ api: t = "/api/chat", credentials: e, headers: r, body: n, fetch: s, prepareSendMessagesRequest: o, prepareReconnectToStreamRequest: l }) {
|
|
2832
2832
|
this.api = t, this.credentials = e, this.headers = r, this.body = n, this.fetch = s, this.prepareSendMessagesRequest = o, this.prepareReconnectToStreamRequest = l;
|
|
2833
2833
|
}
|
|
@@ -2866,7 +2866,7 @@ var ti = class {
|
|
|
2866
2866
|
credentials: i,
|
|
2867
2867
|
signal: t
|
|
2868
2868
|
});
|
|
2869
|
-
if (!d.ok) throw await
|
|
2869
|
+
if (!d.ok) throw await dr({
|
|
2870
2870
|
response: d,
|
|
2871
2871
|
url: u,
|
|
2872
2872
|
fallbackMessage: "Failed to fetch the chat response."
|
|
@@ -2897,7 +2897,7 @@ var ti = class {
|
|
|
2897
2897
|
value: t.chatId,
|
|
2898
2898
|
message: 'Chat IDs must not be "." or ".." when using the default reconnect URL.'
|
|
2899
2899
|
});
|
|
2900
|
-
l =
|
|
2900
|
+
l = ri(this.api, `/${encodeURIComponent(t.chatId)}/stream`);
|
|
2901
2901
|
}
|
|
2902
2902
|
const u = (o == null ? void 0 : o.headers) !== void 0 ? Ze(o.headers) : s, y = (o == null ? void 0 : o.credentials) ?? n, g = await (this.fetch ?? globalThis.fetch)(l, {
|
|
2903
2903
|
method: "GET",
|
|
@@ -2906,7 +2906,7 @@ var ti = class {
|
|
|
2906
2906
|
signal: t.abortSignal
|
|
2907
2907
|
});
|
|
2908
2908
|
if (g.status === 204) return null;
|
|
2909
|
-
if (!g.ok) throw await
|
|
2909
|
+
if (!g.ok) throw await dr({
|
|
2910
2910
|
response: g,
|
|
2911
2911
|
url: l,
|
|
2912
2912
|
fallbackMessage: "Failed to fetch the chat response."
|
|
@@ -2914,39 +2914,39 @@ var ti = class {
|
|
|
2914
2914
|
if (!g.body) throw new ft({ message: "The response body is empty." });
|
|
2915
2915
|
return this.processResponseStream(g.body);
|
|
2916
2916
|
}
|
|
2917
|
-
}, yt = class extends
|
|
2917
|
+
}, yt = class extends ni {
|
|
2918
2918
|
constructor({ resumeStreamIsReplay: t = !0, ...e } = {}) {
|
|
2919
2919
|
super(e), this.resumeStreamIsReplay = t;
|
|
2920
2920
|
}
|
|
2921
2921
|
processResponseStream(t) {
|
|
2922
|
-
return
|
|
2922
|
+
return Ma({
|
|
2923
2923
|
stream: t,
|
|
2924
|
-
schema:
|
|
2924
|
+
schema: Ya
|
|
2925
2925
|
}).pipeThrough(new TransformStream({ async transform(e, r) {
|
|
2926
2926
|
if (!e.success) throw e.error;
|
|
2927
2927
|
r.enqueue(e.value);
|
|
2928
2928
|
} }));
|
|
2929
2929
|
}
|
|
2930
|
-
},
|
|
2930
|
+
}, si = class {
|
|
2931
2931
|
get id() {
|
|
2932
2932
|
return this._id ?? (this._id = this.generateId());
|
|
2933
2933
|
}
|
|
2934
|
-
constructor({ generateId: t =
|
|
2935
|
-
this.pendingMessagePreparations = /* @__PURE__ */ new Set(), this.interruptedMessageIds = /* @__PURE__ */ new Set(), this.activeResponse = void 0, this.activeResumeRequest = void 0, this.resumableStreamState = void 0, this.jobExecutor = new
|
|
2936
|
-
var
|
|
2934
|
+
constructor({ generateId: t = Ms, id: e, transport: r = new yt(), messageMetadataSchema: n, dataPartSchemas: s, state: o, onError: l, onToolCall: u, onFinish: y, onData: g, sendAutomaticallyWhen: i }) {
|
|
2935
|
+
this.pendingMessagePreparations = /* @__PURE__ */ new Set(), this.interruptedMessageIds = /* @__PURE__ */ new Set(), this.activeResponse = void 0, this.activeResumeRequest = void 0, this.resumableStreamState = void 0, this.jobExecutor = new ei(), this.activeStopCount = 0, this.stopGeneration = 0, this.sendMessage = async (d, p) => {
|
|
2936
|
+
var P;
|
|
2937
2937
|
if (d == null) {
|
|
2938
2938
|
let M = this.pendingApprovalMessageId;
|
|
2939
2939
|
if (M == null) {
|
|
2940
|
-
M = (
|
|
2941
|
-
for (let
|
|
2942
|
-
const w = this.state.messages[
|
|
2943
|
-
if (w.role === "assistant" && w.parts.some((I) =>
|
|
2940
|
+
M = (P = this.lastMessage) == null ? void 0 : P.id;
|
|
2941
|
+
for (let x = this.state.messages.length - 1; x >= 0; x--) {
|
|
2942
|
+
const w = this.state.messages[x];
|
|
2943
|
+
if (w.role === "assistant" && w.parts.some((I) => pe(I) && I.state === "approval-responded")) {
|
|
2944
2944
|
M = w.id;
|
|
2945
2945
|
break;
|
|
2946
2946
|
}
|
|
2947
2947
|
}
|
|
2948
2948
|
}
|
|
2949
|
-
const O = M != null && M === this.pendingApprovalMessageId ? this.state.messages.findIndex((
|
|
2949
|
+
const O = M != null && M === this.pendingApprovalMessageId ? this.state.messages.findIndex((x) => x.id === M) : -1;
|
|
2950
2950
|
await this.makeRequestForToolApproval({
|
|
2951
2951
|
messageId: M,
|
|
2952
2952
|
messageIndex: O,
|
|
@@ -2960,7 +2960,7 @@ var ti = class {
|
|
|
2960
2960
|
this.pendingMessagePreparations.add(M);
|
|
2961
2961
|
let O;
|
|
2962
2962
|
try {
|
|
2963
|
-
O = Array.isArray(d.files) ? d.files : await
|
|
2963
|
+
O = Array.isArray(d.files) ? d.files : await ti(d.files);
|
|
2964
2964
|
} finally {
|
|
2965
2965
|
this.pendingMessagePreparations.delete(M);
|
|
2966
2966
|
}
|
|
@@ -3000,7 +3000,7 @@ var ti = class {
|
|
|
3000
3000
|
...p
|
|
3001
3001
|
});
|
|
3002
3002
|
}, this.regenerate = async ({ messageId: d, ...p } = {}) => {
|
|
3003
|
-
const b = d == null ? this.state.messages.length - 1 : this.state.messages.findIndex((
|
|
3003
|
+
const b = d == null ? this.state.messages.length - 1 : this.state.messages.findIndex((P) => P.id === d);
|
|
3004
3004
|
if (b === -1) throw new ut({
|
|
3005
3005
|
parameter: "messageId",
|
|
3006
3006
|
value: d,
|
|
@@ -3021,8 +3021,8 @@ var ti = class {
|
|
|
3021
3021
|
this.resumableStreamState == null && p != null && (await p.completionPromise, this.resumableStreamState !== p.state) || this.resumableStreamState != null && d() && await this.resumeStream();
|
|
3022
3022
|
}, this.clearError = () => {
|
|
3023
3023
|
this.status === "error" && (this.state.error = void 0, this.setStatus({ status: "ready" }));
|
|
3024
|
-
}, this.addToolApprovalResponse = async ({ id: d, approved: p, reason: b, options:
|
|
3025
|
-
const M = this.state.messages, O = (w) =>
|
|
3024
|
+
}, this.addToolApprovalResponse = async ({ id: d, approved: p, reason: b, options: P }) => this.jobExecutor.run(async () => {
|
|
3025
|
+
const M = this.state.messages, O = (w) => pe(w) && w.state === "approval-requested" && w.approval.id === d ? {
|
|
3026
3026
|
...w,
|
|
3027
3027
|
state: "approval-responded",
|
|
3028
3028
|
approval: {
|
|
@@ -3031,29 +3031,29 @@ var ti = class {
|
|
|
3031
3031
|
approved: p,
|
|
3032
3032
|
reason: b
|
|
3033
3033
|
}
|
|
3034
|
-
} : w,
|
|
3035
|
-
if (
|
|
3036
|
-
const w = M[
|
|
3037
|
-
this.state.replaceMessage(
|
|
3034
|
+
} : w, x = M.findIndex((w) => w.parts.some((I) => pe(I) && I.state === "approval-requested" && I.approval.id === d));
|
|
3035
|
+
if (x !== -1) {
|
|
3036
|
+
const w = M[x];
|
|
3037
|
+
this.state.replaceMessage(x, {
|
|
3038
3038
|
...w,
|
|
3039
3039
|
parts: w.parts.map(O)
|
|
3040
3040
|
}), this.pendingApprovalMessageId = w.id;
|
|
3041
3041
|
}
|
|
3042
|
-
if (this.activeResponse && (this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(O)),
|
|
3043
|
-
const w = await this.shouldSendAutomatically(M[
|
|
3042
|
+
if (this.activeResponse && (this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(O)), x !== -1 && this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
|
|
3043
|
+
const w = await this.shouldSendAutomatically(M[x].id);
|
|
3044
3044
|
w && this.runAutomaticRequest(() => {
|
|
3045
3045
|
var C;
|
|
3046
|
-
const I =
|
|
3046
|
+
const I = x === -1 ? (C = this.lastMessage) == null ? void 0 : C.id : M[x].id;
|
|
3047
3047
|
return this.makeRequestForToolApproval({
|
|
3048
3048
|
messageId: I,
|
|
3049
|
-
messageIndex:
|
|
3050
|
-
...
|
|
3049
|
+
messageIndex: x,
|
|
3050
|
+
...P
|
|
3051
3051
|
});
|
|
3052
3052
|
}, w);
|
|
3053
3053
|
}
|
|
3054
|
-
}), this.addToolOutput = async ({ state: d, toolCallId: p, output: b, errorText:
|
|
3055
|
-
const O = this.state.messages,
|
|
3056
|
-
if (!
|
|
3054
|
+
}), this.addToolOutput = async ({ state: d, toolCallId: p, output: b, errorText: P, options: M }) => this.jobExecutor.run(async () => {
|
|
3055
|
+
const O = this.state.messages, x = (I) => {
|
|
3056
|
+
if (!pe(I) || I.toolCallId !== p) return I;
|
|
3057
3057
|
const { approval: C, ...c } = I, m = (C == null ? void 0 : C.approved) === !0 ? { approval: {
|
|
3058
3058
|
...C,
|
|
3059
3059
|
approved: C.approved
|
|
@@ -3064,7 +3064,7 @@ var ti = class {
|
|
|
3064
3064
|
state: d,
|
|
3065
3065
|
input: I.input,
|
|
3066
3066
|
output: void 0,
|
|
3067
|
-
errorText:
|
|
3067
|
+
errorText: P
|
|
3068
3068
|
} : {
|
|
3069
3069
|
...c,
|
|
3070
3070
|
...m,
|
|
@@ -3073,15 +3073,15 @@ var ti = class {
|
|
|
3073
3073
|
output: b,
|
|
3074
3074
|
errorText: void 0
|
|
3075
3075
|
};
|
|
3076
|
-
}, w = O.findIndex((I) => I.parts.some((C) =>
|
|
3076
|
+
}, w = O.findIndex((I) => I.parts.some((C) => pe(C) && C.toolCallId === p));
|
|
3077
3077
|
if (w !== -1) {
|
|
3078
3078
|
const I = O[w];
|
|
3079
3079
|
this.state.replaceMessage(w, {
|
|
3080
3080
|
...I,
|
|
3081
|
-
parts: I.parts.map(
|
|
3081
|
+
parts: I.parts.map(x)
|
|
3082
3082
|
});
|
|
3083
3083
|
}
|
|
3084
|
-
if (this.activeResponse && (this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(
|
|
3084
|
+
if (this.activeResponse && (this.activeResponse.state.message.parts = this.activeResponse.state.message.parts.map(x)), w !== -1 && this.status !== "streaming" && this.status !== "submitted" && this.sendAutomaticallyWhen) {
|
|
3085
3085
|
const I = await this.shouldSendAutomatically(O[w].id);
|
|
3086
3086
|
I && this.runAutomaticRequest(() => this.makeRequest({
|
|
3087
3087
|
trigger: "submit-message",
|
|
@@ -3152,7 +3152,7 @@ var ti = class {
|
|
|
3152
3152
|
}), n && this.status === "error" && this.pendingApprovalMessageId == null && (this.pendingApprovalMessageId = ((s = this.state.messages[e]) == null ? void 0 : s.id) ?? t);
|
|
3153
3153
|
}
|
|
3154
3154
|
async makeRequest(t) {
|
|
3155
|
-
const e =
|
|
3155
|
+
const e = Xa();
|
|
3156
3156
|
try {
|
|
3157
3157
|
await this.makeRequestImpl({
|
|
3158
3158
|
...t,
|
|
@@ -3208,11 +3208,11 @@ var ti = class {
|
|
|
3208
3208
|
status: "submitted",
|
|
3209
3209
|
error: void 0
|
|
3210
3210
|
});
|
|
3211
|
-
const d = this.lastMessage, p = t === "submit-message" && s != null ? this.state.messages.findIndex((f) => f.id === s) : this.state.messages.length - 1, b = p === -1 ? d : this.state.messages[p],
|
|
3212
|
-
let
|
|
3211
|
+
const d = this.lastMessage, p = t === "submit-message" && s != null ? this.state.messages.findIndex((f) => f.id === s) : this.state.messages.length - 1, b = p === -1 ? d : this.state.messages[p], P = b == null ? void 0 : b.id, M = t === "resume-stream" && (b == null ? void 0 : b.role) === "assistant" && b.parts.some((f) => pe(f) && (f.state === "input-streaming" || f.state === "input-available" && f.providerExecuted || f.state === "approval-responded")) ? this.state.snapshot(b) : void 0, O = p !== -1 && p < this.state.messages.length - 1 && (b == null ? void 0 : b.role) === "assistant";
|
|
3212
|
+
let x = !1, w = !1, I = !1, C;
|
|
3213
3213
|
try {
|
|
3214
3214
|
const f = {
|
|
3215
|
-
state: t === "resume-stream" && this.resumableStreamState != null ? this.resumableStreamState :
|
|
3215
|
+
state: t === "resume-stream" && this.resumableStreamState != null ? this.resumableStreamState : un({
|
|
3216
3216
|
lastMessage: t === "resume-stream" ? M : t === "regenerate-message" ? void 0 : this.state.snapshot(b),
|
|
3217
3217
|
messageId: this.generateId()
|
|
3218
3218
|
}),
|
|
@@ -3220,7 +3220,7 @@ var ti = class {
|
|
|
3220
3220
|
completionPromise: o
|
|
3221
3221
|
};
|
|
3222
3222
|
C = f, f.abortController.signal.addEventListener("abort", () => {
|
|
3223
|
-
|
|
3223
|
+
x = !0;
|
|
3224
3224
|
}), this.activeResponse = f;
|
|
3225
3225
|
let h;
|
|
3226
3226
|
t === "resume-stream" ? h = i : h = await this.transport.sendMessages({
|
|
@@ -3241,13 +3241,13 @@ var ti = class {
|
|
|
3241
3241
|
const B = this.state.messages.findLastIndex((W) => W.id === f.state.message.id);
|
|
3242
3242
|
if (B !== -1) this.state.replaceMessage(B, f.state.message);
|
|
3243
3243
|
else if (O) {
|
|
3244
|
-
const W = this.state.messages.findLastIndex((j) => j.id ===
|
|
3244
|
+
const W = this.state.messages.findLastIndex((j) => j.id === P);
|
|
3245
3245
|
W !== -1 ? this.state.replaceMessage(W, f.state.message) : this.state.pushMessage(f.state.message);
|
|
3246
3246
|
} else this.state.pushMessage(f.state.message);
|
|
3247
3247
|
}
|
|
3248
3248
|
}));
|
|
3249
|
-
if (await
|
|
3250
|
-
stream:
|
|
3249
|
+
if (await Qa({
|
|
3250
|
+
stream: Ga({
|
|
3251
3251
|
stream: h,
|
|
3252
3252
|
resetStateOnMessageIdChange: t === "resume-stream",
|
|
3253
3253
|
resetStateOnFirstMessageStart: t === "resume-stream" && this.transport.resumeStreamIsReplay,
|
|
@@ -3264,12 +3264,12 @@ var ti = class {
|
|
|
3264
3264
|
onError: (N) => {
|
|
3265
3265
|
throw N;
|
|
3266
3266
|
}
|
|
3267
|
-
}),
|
|
3267
|
+
}), x)
|
|
3268
3268
|
return y() && (this.setStatus({ status: "ready" }), this.resumableStreamState === f.state && (this.resumableStreamState = void 0)), null;
|
|
3269
3269
|
y() && (this.setStatus({ status: "ready" }), this.resumableStreamState === f.state && (this.resumableStreamState = void 0));
|
|
3270
3270
|
} catch (f) {
|
|
3271
|
-
if (
|
|
3272
|
-
return
|
|
3271
|
+
if (x || f.name === "AbortError")
|
|
3272
|
+
return x = !0, y() && (this.setStatus({ status: "ready" }), this.resumableStreamState === (C == null ? void 0 : C.state) && (this.resumableStreamState = void 0)), null;
|
|
3273
3273
|
if (!y()) return null;
|
|
3274
3274
|
if (I = !0, f instanceof TypeError) {
|
|
3275
3275
|
const h = f.message.toLowerCase();
|
|
@@ -3283,10 +3283,10 @@ var ti = class {
|
|
|
3283
3283
|
try {
|
|
3284
3284
|
if (C) {
|
|
3285
3285
|
const { message: f, finishReason: h } = C.state;
|
|
3286
|
-
h === "interrupted" ? this.interruptedMessageIds.add(f.id) : !
|
|
3286
|
+
h === "interrupted" ? this.interruptedMessageIds.add(f.id) : !x && !I && this.interruptedMessageIds.delete(f.id), (m = this.onFinish) == null || m.call(this, {
|
|
3287
3287
|
message: C.state.message,
|
|
3288
3288
|
messages: this.state.messages,
|
|
3289
|
-
isAbort:
|
|
3289
|
+
isAbort: x,
|
|
3290
3290
|
isDisconnect: w,
|
|
3291
3291
|
isError: I,
|
|
3292
3292
|
finishReason: C.state.finishReason
|
|
@@ -3296,7 +3296,7 @@ var ti = class {
|
|
|
3296
3296
|
this.activeResponse === C && (this.activeResponse = void 0), g();
|
|
3297
3297
|
}
|
|
3298
3298
|
}
|
|
3299
|
-
!
|
|
3299
|
+
!x && !I && (C == null ? void 0 : C.state.finishReason) !== "interrupted" && await this.runAutomaticRequest(() => {
|
|
3300
3300
|
var f;
|
|
3301
3301
|
return this.makeRequest({
|
|
3302
3302
|
trigger: "submit-message",
|
|
@@ -3307,10 +3307,10 @@ var ti = class {
|
|
|
3307
3307
|
});
|
|
3308
3308
|
});
|
|
3309
3309
|
}
|
|
3310
|
-
}, Lt,
|
|
3311
|
-
function
|
|
3312
|
-
if (
|
|
3313
|
-
|
|
3310
|
+
}, Lt, pr;
|
|
3311
|
+
function ai() {
|
|
3312
|
+
if (pr) return Lt;
|
|
3313
|
+
pr = 1;
|
|
3314
3314
|
function t(e, r) {
|
|
3315
3315
|
if (typeof e != "function")
|
|
3316
3316
|
throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);
|
|
@@ -3325,34 +3325,34 @@ function ni() {
|
|
|
3325
3325
|
}
|
|
3326
3326
|
return Lt = t, Lt;
|
|
3327
3327
|
}
|
|
3328
|
-
var
|
|
3329
|
-
const
|
|
3330
|
-
function
|
|
3331
|
-
return e != null ?
|
|
3328
|
+
var ii = /* @__PURE__ */ ai();
|
|
3329
|
+
const oi = /* @__PURE__ */ _a(ii);
|
|
3330
|
+
function li(t, e) {
|
|
3331
|
+
return e != null ? oi(t, e) : t;
|
|
3332
3332
|
}
|
|
3333
|
-
function
|
|
3333
|
+
function ci(t) {
|
|
3334
3334
|
return Array.isArray(t) ? [...t] : t != null && typeof t == "object" && (Object.getPrototypeOf(t) === Object.prototype || Object.getPrototypeOf(t) === null) ? { ...t } : t;
|
|
3335
3335
|
}
|
|
3336
|
-
var
|
|
3336
|
+
var ce, We, Je, De, Le, je, _e, Qe, Xe, xr, ui = (xr = class {
|
|
3337
3337
|
constructor(t = []) {
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
Q(this, We, "ready"), Q(this, Je, void 0), Q(this,
|
|
3348
|
-
Q(this,
|
|
3338
|
+
ge(this, ce);
|
|
3339
|
+
ge(this, We);
|
|
3340
|
+
ge(this, Je);
|
|
3341
|
+
ge(this, De);
|
|
3342
|
+
ge(this, Le);
|
|
3343
|
+
ge(this, je);
|
|
3344
|
+
ge(this, _e);
|
|
3345
|
+
ge(this, Qe);
|
|
3346
|
+
ge(this, Xe);
|
|
3347
|
+
Q(this, We, "ready"), Q(this, Je, void 0), Q(this, De, /* @__PURE__ */ new Set()), Q(this, Le, /* @__PURE__ */ new Set()), Q(this, je, /* @__PURE__ */ new Set()), this.pushMessage = (e) => {
|
|
3348
|
+
Q(this, ce, V(this, ce).concat(e)), V(this, _e).call(this);
|
|
3349
3349
|
}, this.popMessage = () => {
|
|
3350
|
-
Q(this,
|
|
3350
|
+
Q(this, ce, V(this, ce).slice(0, -1)), V(this, _e).call(this);
|
|
3351
3351
|
}, this.replaceMessage = (e, r) => {
|
|
3352
|
-
Q(this,
|
|
3353
|
-
...V(this,
|
|
3352
|
+
Q(this, ce, [
|
|
3353
|
+
...V(this, ce).slice(0, e),
|
|
3354
3354
|
this.snapshot(r),
|
|
3355
|
-
...V(this,
|
|
3355
|
+
...V(this, ce).slice(e + 1)
|
|
3356
3356
|
]), V(this, _e).call(this);
|
|
3357
3357
|
}, this.snapshot = (e) => {
|
|
3358
3358
|
if (e == null || typeof e != "object" || !("parts" in e) || !Array.isArray(e.parts)) return e;
|
|
@@ -3360,23 +3360,23 @@ var le, We, Je, Ne, De, Le, _e, Qe, Xe, Ar, li = (Ar = class {
|
|
|
3360
3360
|
...r,
|
|
3361
3361
|
parts: r.parts.map((s) => ({ ...s }))
|
|
3362
3362
|
};
|
|
3363
|
-
return "metadata" in r && (n.metadata =
|
|
3363
|
+
return "metadata" in r && (n.metadata = ci(r.metadata)), n;
|
|
3364
3364
|
}, this["~registerMessagesCallback"] = (e, r) => {
|
|
3365
|
-
const n = r ?
|
|
3366
|
-
return V(this,
|
|
3367
|
-
V(this,
|
|
3365
|
+
const n = r ? li(e, r) : e;
|
|
3366
|
+
return V(this, De).add(n), () => {
|
|
3367
|
+
V(this, De).delete(n);
|
|
3368
3368
|
};
|
|
3369
|
-
}, this["~registerStatusCallback"] = (e) => (V(this,
|
|
3370
|
-
V(this, De).delete(e);
|
|
3371
|
-
}), this["~registerErrorCallback"] = (e) => (V(this, Le).add(e), () => {
|
|
3369
|
+
}, this["~registerStatusCallback"] = (e) => (V(this, Le).add(e), () => {
|
|
3372
3370
|
V(this, Le).delete(e);
|
|
3371
|
+
}), this["~registerErrorCallback"] = (e) => (V(this, je).add(e), () => {
|
|
3372
|
+
V(this, je).delete(e);
|
|
3373
3373
|
}), Q(this, _e, () => {
|
|
3374
|
-
V(this, Ne).forEach((e) => e());
|
|
3375
|
-
}), Q(this, Qe, () => {
|
|
3376
3374
|
V(this, De).forEach((e) => e());
|
|
3377
|
-
}), Q(this,
|
|
3375
|
+
}), Q(this, Qe, () => {
|
|
3378
3376
|
V(this, Le).forEach((e) => e());
|
|
3379
|
-
}), Q(this,
|
|
3377
|
+
}), Q(this, Xe, () => {
|
|
3378
|
+
V(this, je).forEach((e) => e());
|
|
3379
|
+
}), Q(this, ce, t);
|
|
3380
3380
|
}
|
|
3381
3381
|
get status() {
|
|
3382
3382
|
return V(this, We);
|
|
@@ -3391,36 +3391,36 @@ var le, We, Je, Ne, De, Le, _e, Qe, Xe, Ar, li = (Ar = class {
|
|
|
3391
3391
|
Q(this, Je, t), V(this, Xe).call(this);
|
|
3392
3392
|
}
|
|
3393
3393
|
get messages() {
|
|
3394
|
-
return V(this,
|
|
3394
|
+
return V(this, ce);
|
|
3395
3395
|
}
|
|
3396
3396
|
set messages(t) {
|
|
3397
|
-
Q(this,
|
|
3397
|
+
Q(this, ce, [...t]), V(this, _e).call(this);
|
|
3398
3398
|
}
|
|
3399
|
-
},
|
|
3399
|
+
}, ce = new WeakMap(), We = new WeakMap(), Je = new WeakMap(), De = new WeakMap(), Le = new WeakMap(), je = new WeakMap(), _e = new WeakMap(), Qe = new WeakMap(), Xe = new WeakMap(), xr), ke, Tr, di = (Tr = class extends si {
|
|
3400
3400
|
constructor({ messages: e, ...r }) {
|
|
3401
|
-
const n = new
|
|
3401
|
+
const n = new ui(e);
|
|
3402
3402
|
super({
|
|
3403
3403
|
...r,
|
|
3404
3404
|
state: n
|
|
3405
3405
|
});
|
|
3406
|
-
|
|
3407
|
-
this["~registerMessagesCallback"] = (s, o) => V(this,
|
|
3406
|
+
ge(this, ke);
|
|
3407
|
+
this["~registerMessagesCallback"] = (s, o) => V(this, ke)["~registerMessagesCallback"](s, o), this["~registerStatusCallback"] = (s) => V(this, ke)["~registerStatusCallback"](s), this["~registerErrorCallback"] = (s) => V(this, ke)["~registerErrorCallback"](s), Q(this, ke, n);
|
|
3408
3408
|
}
|
|
3409
|
-
},
|
|
3409
|
+
}, ke = new WeakMap(), Tr);
|
|
3410
3410
|
const dt = /* @__PURE__ */ new WeakMap();
|
|
3411
|
-
function
|
|
3411
|
+
function pi({ chat: t, state: e }) {
|
|
3412
3412
|
if (document.visibilityState !== "visible" || e.pendingVisibilityResume != null) return;
|
|
3413
3413
|
const r = () => dt.get(t) === e && e.registrations.size > 0, n = () => {
|
|
3414
3414
|
e.pendingVisibilityResume = void 0;
|
|
3415
3415
|
};
|
|
3416
3416
|
e.pendingVisibilityResume = t["~resumeStreamIfDisconnected"]({ shouldResume: () => r() && document.visibilityState === "visible" }).then(n, n);
|
|
3417
3417
|
}
|
|
3418
|
-
function
|
|
3418
|
+
function fi({ chat: t, registration: e }) {
|
|
3419
3419
|
let r = dt.get(t);
|
|
3420
3420
|
if (r == null) {
|
|
3421
3421
|
const o = { registrations: /* @__PURE__ */ new Set() };
|
|
3422
3422
|
if (dt.set(t, o), r = o, typeof document < "u") {
|
|
3423
|
-
const l = () =>
|
|
3423
|
+
const l = () => pi({
|
|
3424
3424
|
chat: t,
|
|
3425
3425
|
state: o
|
|
3426
3426
|
});
|
|
@@ -3443,11 +3443,11 @@ function ct(t) {
|
|
|
3443
3443
|
error: t.error
|
|
3444
3444
|
};
|
|
3445
3445
|
}
|
|
3446
|
-
function
|
|
3446
|
+
function fr(t, e) {
|
|
3447
3447
|
return t.chat === e.chat && t.messages === e.messages && t.status === e.status && t.error === e.error;
|
|
3448
3448
|
}
|
|
3449
|
-
function
|
|
3450
|
-
const s = t ?? e, o =
|
|
3449
|
+
function mi({ throttle: t, experimental_throttle: e, resume: r = !1, ...n } = {}) {
|
|
3450
|
+
const s = t ?? e, o = R({}), l = R({});
|
|
3451
3451
|
"chat" in n || (l.current = {
|
|
3452
3452
|
onToolCall: n.onToolCall,
|
|
3453
3453
|
onData: n.onData,
|
|
@@ -3487,7 +3487,7 @@ function pi({ throttle: t, experimental_throttle: e, resume: r = !1, ...n } = {}
|
|
|
3487
3487
|
return ((c = (C = l.current).sendAutomaticallyWhen) == null ? void 0 : c.call(C, I)) ?? !1;
|
|
3488
3488
|
}
|
|
3489
3489
|
}, i = "chat" in n ? n.chat : n.id, { chat: d, isExternallyManaged: p } = X(() => ({
|
|
3490
|
-
chat: "chat" in n ? n.chat : new
|
|
3490
|
+
chat: "chat" in n ? n.chat : new di(g),
|
|
3491
3491
|
isExternallyManaged: "chat" in n
|
|
3492
3492
|
}), [i]);
|
|
3493
3493
|
F(() => {
|
|
@@ -3496,27 +3496,27 @@ function pi({ throttle: t, experimental_throttle: e, resume: r = !1, ...n } = {}
|
|
|
3496
3496
|
d.stop();
|
|
3497
3497
|
};
|
|
3498
3498
|
}, [d, p]);
|
|
3499
|
-
const [b,
|
|
3500
|
-
b.chat !== d &&
|
|
3499
|
+
const [b, P] = J(() => ct(d));
|
|
3500
|
+
b.chat !== d && P(ct(d)), F(() => {
|
|
3501
3501
|
let I = !0;
|
|
3502
3502
|
const C = () => {
|
|
3503
3503
|
if (!I) return;
|
|
3504
3504
|
const f = ct(d);
|
|
3505
|
-
|
|
3505
|
+
P((h) => h.chat !== d || fr(h, f) ? h : f);
|
|
3506
3506
|
}, c = [
|
|
3507
3507
|
d["~registerMessagesCallback"](C, s),
|
|
3508
3508
|
d["~registerStatusCallback"](C),
|
|
3509
3509
|
d["~registerErrorCallback"](C)
|
|
3510
3510
|
], m = ct(d);
|
|
3511
|
-
return
|
|
3511
|
+
return P((f) => fr(f, m) ? f : m), () => {
|
|
3512
3512
|
I = !1, c.forEach((f) => f());
|
|
3513
3513
|
};
|
|
3514
3514
|
}, [d, s]);
|
|
3515
|
-
const { messages: M, status: O, error:
|
|
3515
|
+
const { messages: M, status: O, error: x } = b, w = z((I) => {
|
|
3516
3516
|
typeof I == "function" && (I = I(d.messages)), d.messages = I;
|
|
3517
3517
|
}, [d]);
|
|
3518
3518
|
return F(() => {
|
|
3519
|
-
if (r) return
|
|
3519
|
+
if (r) return fi({
|
|
3520
3520
|
chat: d,
|
|
3521
3521
|
registration: o.current
|
|
3522
3522
|
});
|
|
@@ -3530,7 +3530,7 @@ function pi({ throttle: t, experimental_throttle: e, resume: r = !1, ...n } = {}
|
|
|
3530
3530
|
regenerate: d.regenerate,
|
|
3531
3531
|
clearError: d.clearError,
|
|
3532
3532
|
stop: d.stop,
|
|
3533
|
-
error:
|
|
3533
|
+
error: x,
|
|
3534
3534
|
resumeStream: d.resumeStream,
|
|
3535
3535
|
status: O,
|
|
3536
3536
|
/**
|
|
@@ -3541,7 +3541,7 @@ function pi({ throttle: t, experimental_throttle: e, resume: r = !1, ...n } = {}
|
|
|
3541
3541
|
addToolApprovalResponse: d.addToolApprovalResponse
|
|
3542
3542
|
};
|
|
3543
3543
|
}
|
|
3544
|
-
class
|
|
3544
|
+
class mr {
|
|
3545
3545
|
constructor(e) {
|
|
3546
3546
|
this.buffer = [], this.cap = Math.max(1, Math.floor(e));
|
|
3547
3547
|
}
|
|
@@ -3574,7 +3574,7 @@ class fr {
|
|
|
3574
3574
|
return n ?? null;
|
|
3575
3575
|
}
|
|
3576
3576
|
}
|
|
3577
|
-
function
|
|
3577
|
+
function gr(t, e) {
|
|
3578
3578
|
const r = t.flatMap((n) => {
|
|
3579
3579
|
if (n.kind === "text" && n.streaming && (e == null ? void 0 : e.streaming) === !1)
|
|
3580
3580
|
return [];
|
|
@@ -3586,30 +3586,30 @@ function mr(t, e) {
|
|
|
3586
3586
|
});
|
|
3587
3587
|
return r.length === t.length && r.every((n, s) => n === t[s]) ? t : r;
|
|
3588
3588
|
}
|
|
3589
|
-
const
|
|
3589
|
+
const gi = L.union([
|
|
3590
3590
|
L.string(),
|
|
3591
3591
|
L.looseObject({ id: L.string().optional(), label: L.string() })
|
|
3592
|
-
]),
|
|
3592
|
+
]), hi = L.looseObject({
|
|
3593
3593
|
id: L.string().optional(),
|
|
3594
3594
|
prompt: L.string(),
|
|
3595
3595
|
selection: L.enum(["single", "multiple"]).default("single"),
|
|
3596
|
-
options: L.array(
|
|
3597
|
-
}),
|
|
3596
|
+
options: L.array(gi).min(1)
|
|
3597
|
+
}), yi = L.looseObject({
|
|
3598
3598
|
request_id: L.string().optional(),
|
|
3599
|
-
questions: L.array(
|
|
3599
|
+
questions: L.array(hi).min(1)
|
|
3600
3600
|
});
|
|
3601
|
-
function
|
|
3601
|
+
function vi(t) {
|
|
3602
3602
|
return !!(t != null && t.includes("ask_questions"));
|
|
3603
3603
|
}
|
|
3604
|
-
const
|
|
3604
|
+
const bi = [
|
|
3605
3605
|
/\bi[’'ʼ‘]?ll\s+(type|describe|enter|write|tell)\b/i,
|
|
3606
3606
|
/\b(type|describe|enter|write|tell)\s+(it|my\s+own|manually)\b/i,
|
|
3607
3607
|
/^\s*(other|custom|none\s+of\s+the\s+above|something\s+else)\s*\.?\s*$/i
|
|
3608
3608
|
];
|
|
3609
|
-
function
|
|
3610
|
-
return
|
|
3609
|
+
function Si(t) {
|
|
3610
|
+
return bi.some((e) => e.test(t));
|
|
3611
3611
|
}
|
|
3612
|
-
function
|
|
3612
|
+
function Ii(t, e) {
|
|
3613
3613
|
return {
|
|
3614
3614
|
request_id: t.request_id ?? e ?? "req-clarification",
|
|
3615
3615
|
questions: t.questions.map((r, n) => ({
|
|
@@ -3621,7 +3621,7 @@ function bi(t, e) {
|
|
|
3621
3621
|
id: s.id ?? `q${n}-o${o}`,
|
|
3622
3622
|
label: s.label
|
|
3623
3623
|
}
|
|
3624
|
-
).filter((s) => !
|
|
3624
|
+
).filter((s) => !Si(s.label))
|
|
3625
3625
|
}))
|
|
3626
3626
|
};
|
|
3627
3627
|
}
|
|
@@ -3632,7 +3632,7 @@ function jt(t) {
|
|
|
3632
3632
|
return null;
|
|
3633
3633
|
}
|
|
3634
3634
|
}
|
|
3635
|
-
function
|
|
3635
|
+
function Ei(t) {
|
|
3636
3636
|
if (t == null) return null;
|
|
3637
3637
|
if (typeof t == "string") return jt(t);
|
|
3638
3638
|
if (Array.isArray(t)) {
|
|
@@ -3652,13 +3652,13 @@ function Si(t) {
|
|
|
3652
3652
|
}
|
|
3653
3653
|
return null;
|
|
3654
3654
|
}
|
|
3655
|
-
function
|
|
3656
|
-
const r =
|
|
3655
|
+
function hr(t, e) {
|
|
3656
|
+
const r = Ei(t);
|
|
3657
3657
|
if (r == null) return null;
|
|
3658
|
-
const n =
|
|
3659
|
-
return n.success ?
|
|
3658
|
+
const n = yi.safeParse(r);
|
|
3659
|
+
return n.success ? Ii(n.data, e) : null;
|
|
3660
3660
|
}
|
|
3661
|
-
function
|
|
3661
|
+
function xo(t, e) {
|
|
3662
3662
|
const r = [];
|
|
3663
3663
|
for (const n of t.questions) {
|
|
3664
3664
|
const s = e.get(n.id);
|
|
@@ -3669,13 +3669,13 @@ A: ${s.trim()}`);
|
|
|
3669
3669
|
|
|
3670
3670
|
`);
|
|
3671
3671
|
}
|
|
3672
|
-
const
|
|
3672
|
+
const Ci = L.object({
|
|
3673
3673
|
request_id: L.string().uuid(),
|
|
3674
3674
|
server_id: L.string().uuid(),
|
|
3675
3675
|
name: L.string().min(1).max(120)
|
|
3676
|
-
}),
|
|
3677
|
-
connection_required:
|
|
3678
|
-
}),
|
|
3676
|
+
}), wi = L.object({
|
|
3677
|
+
connection_required: Ci
|
|
3678
|
+
}), yr = "data-spec", Ai = L.object({ label: L.string(), done: L.boolean() }), xi = L.object({
|
|
3679
3679
|
plan: L.array(
|
|
3680
3680
|
L.object({
|
|
3681
3681
|
step: L.string(),
|
|
@@ -3690,9 +3690,9 @@ function pt(t) {
|
|
|
3690
3690
|
}, n = (l) => l === "output-available" || l === "output-error";
|
|
3691
3691
|
let s = null, o;
|
|
3692
3692
|
for (const l of t)
|
|
3693
|
-
if (
|
|
3693
|
+
if (!$n(l) && dn(l) !== "highlight_element") {
|
|
3694
3694
|
if (l.state === "output-available" && (l.type === "dynamic-tool" || l.type.startsWith("tool-"))) {
|
|
3695
|
-
const u =
|
|
3695
|
+
const u = wi.safeParse(l.output);
|
|
3696
3696
|
if (u.success) {
|
|
3697
3697
|
e.push({
|
|
3698
3698
|
kind: "connection",
|
|
@@ -3701,23 +3701,23 @@ function pt(t) {
|
|
|
3701
3701
|
continue;
|
|
3702
3702
|
}
|
|
3703
3703
|
}
|
|
3704
|
-
if (
|
|
3705
|
-
const u =
|
|
3704
|
+
if (Ti(l)) {
|
|
3705
|
+
const u = Mi(l);
|
|
3706
3706
|
u && e.push(u);
|
|
3707
3707
|
continue;
|
|
3708
3708
|
}
|
|
3709
3709
|
if (l.type === "data-plan") {
|
|
3710
|
-
const u =
|
|
3710
|
+
const u = xi.safeParse(l.data);
|
|
3711
3711
|
u.success && (o ? o.plan = u.data.plan : (o = { kind: "plan", plan: u.data.plan }, e.push(o)));
|
|
3712
3712
|
} else if (l.type === "data-tool-activity") {
|
|
3713
|
-
const u =
|
|
3713
|
+
const u = Ai.safeParse(l.data);
|
|
3714
3714
|
u.success && r({
|
|
3715
3715
|
kind: "tool",
|
|
3716
3716
|
label: u.data.label,
|
|
3717
3717
|
done: u.data.done
|
|
3718
3718
|
});
|
|
3719
|
-
} else if (l.type ===
|
|
3720
|
-
s || (s = { kind: "spec", parts: [] }, e.push(s)), s.parts.push({ type:
|
|
3719
|
+
} else if (l.type === yr)
|
|
3720
|
+
s || (s = { kind: "spec", parts: [] }, e.push(s)), s.parts.push({ type: yr, data: l.data });
|
|
3721
3721
|
else if (l.type === "text") {
|
|
3722
3722
|
const u = typeof l.text == "string" ? l.text : "";
|
|
3723
3723
|
u.trim().length > 0 && e.push({
|
|
@@ -3733,46 +3733,46 @@ function pt(t) {
|
|
|
3733
3733
|
kind: "tool",
|
|
3734
3734
|
label: typeof l.toolName == "string" ? l.toolName : "tool",
|
|
3735
3735
|
done: n(l.state),
|
|
3736
|
-
...
|
|
3736
|
+
...vr(l)
|
|
3737
3737
|
}) : l.type.startsWith("tool-") && r({
|
|
3738
3738
|
kind: "tool",
|
|
3739
3739
|
label: l.type.slice(5),
|
|
3740
3740
|
done: n(l.state),
|
|
3741
|
-
...
|
|
3741
|
+
...vr(l)
|
|
3742
3742
|
});
|
|
3743
3743
|
}
|
|
3744
3744
|
return e;
|
|
3745
3745
|
}
|
|
3746
|
-
function
|
|
3746
|
+
function dn(t) {
|
|
3747
3747
|
return t.type === "dynamic-tool" ? typeof t.toolName == "string" ? t.toolName : void 0 : t.type.startsWith("tool-") ? t.type.slice(5) : void 0;
|
|
3748
3748
|
}
|
|
3749
|
-
function
|
|
3750
|
-
return
|
|
3749
|
+
function Ti(t) {
|
|
3750
|
+
return vi(dn(t));
|
|
3751
3751
|
}
|
|
3752
|
-
function
|
|
3753
|
-
const e = typeof t.toolCallId == "string" ? t.toolCallId : void 0, r =
|
|
3752
|
+
function Mi(t) {
|
|
3753
|
+
const e = typeof t.toolCallId == "string" ? t.toolCallId : void 0, r = hr(t.output, e) ?? hr(t.input, e);
|
|
3754
3754
|
return r ? { kind: "questions", request: r } : null;
|
|
3755
3755
|
}
|
|
3756
|
-
function
|
|
3756
|
+
function vr(t) {
|
|
3757
3757
|
return {
|
|
3758
3758
|
...t.input === void 0 ? {} : { input: t.input },
|
|
3759
3759
|
...t.output === void 0 ? {} : { output: t.output }
|
|
3760
3760
|
};
|
|
3761
3761
|
}
|
|
3762
|
-
function
|
|
3762
|
+
function _i(t, e) {
|
|
3763
3763
|
const r = [];
|
|
3764
3764
|
return e != null && e.toolActivity && r.push(
|
|
3765
3765
|
`toolActivity=${encodeURIComponent(e.toolActivity)}`
|
|
3766
3766
|
), (e == null ? void 0 : e.reasoning) !== void 0 && r.push(`reasoning=${String(e.reasoning)}`), r.length === 0 ? t : `${t}${t.includes("?") ? "&" : "?"}${r.join("&")}`;
|
|
3767
3767
|
}
|
|
3768
|
-
function
|
|
3768
|
+
function br(t) {
|
|
3769
3769
|
return ({ id: e }) => ({
|
|
3770
3770
|
api: t.reconnectApi(e),
|
|
3771
3771
|
headers: t.headers()
|
|
3772
3772
|
});
|
|
3773
3773
|
}
|
|
3774
|
-
const
|
|
3775
|
-
function
|
|
3774
|
+
const Ri = [0, 500, 1500];
|
|
3775
|
+
function Pi(t, e) {
|
|
3776
3776
|
return new Promise((r) => {
|
|
3777
3777
|
if (t === 0 || e != null && e.aborted) {
|
|
3778
3778
|
r();
|
|
@@ -3784,10 +3784,10 @@ function _i(t, e) {
|
|
|
3784
3784
|
e == null || e.addEventListener("abort", n);
|
|
3785
3785
|
});
|
|
3786
3786
|
}
|
|
3787
|
-
function
|
|
3787
|
+
function Oi(t) {
|
|
3788
3788
|
return t && "session_id" in t && typeof t.session_id == "string" ? t.session_id : void 0;
|
|
3789
3789
|
}
|
|
3790
|
-
class
|
|
3790
|
+
class Ni extends yt {
|
|
3791
3791
|
constructor(e) {
|
|
3792
3792
|
super({
|
|
3793
3793
|
api: e.api,
|
|
@@ -3796,14 +3796,14 @@ class Ri extends yt {
|
|
|
3796
3796
|
// Every send carries its full body; a send without one is a programming
|
|
3797
3797
|
// error, and an empty body would be rejected server-side just as loudly.
|
|
3798
3798
|
prepareSendMessagesRequest: ({ body: r }) => ({ body: r ?? {} }),
|
|
3799
|
-
prepareReconnectToStreamRequest:
|
|
3799
|
+
prepareReconnectToStreamRequest: br(e)
|
|
3800
3800
|
}), this.agentOptions = e;
|
|
3801
3801
|
}
|
|
3802
3802
|
async sendMessages(e) {
|
|
3803
3803
|
try {
|
|
3804
3804
|
return await super.sendMessages(e);
|
|
3805
3805
|
} catch (r) {
|
|
3806
|
-
const n =
|
|
3806
|
+
const n = Oi(e.body);
|
|
3807
3807
|
if (n === void 0) throw r;
|
|
3808
3808
|
return this.readThroughRecoveryFetch(r, "send", {
|
|
3809
3809
|
chatId: n,
|
|
@@ -3830,17 +3830,17 @@ class Ri extends yt {
|
|
|
3830
3830
|
api: this.agentOptions.api,
|
|
3831
3831
|
headers: () => this.agentOptions.headers(),
|
|
3832
3832
|
fetch: s,
|
|
3833
|
-
prepareReconnectToStreamRequest:
|
|
3833
|
+
prepareReconnectToStreamRequest: br(
|
|
3834
3834
|
this.agentOptions
|
|
3835
3835
|
)
|
|
3836
3836
|
});
|
|
3837
|
-
for (const d of
|
|
3838
|
-
if (await
|
|
3837
|
+
for (const d of Ri) {
|
|
3838
|
+
if (await Pi(d, n.abortSignal), (y = n.abortSignal) != null && y.aborted) throw e;
|
|
3839
3839
|
let p;
|
|
3840
3840
|
try {
|
|
3841
3841
|
p = await o.reconnectToStream(n);
|
|
3842
3842
|
} catch (b) {
|
|
3843
|
-
throw
|
|
3843
|
+
throw le.warn("agent chat recovery read failed", b), e;
|
|
3844
3844
|
}
|
|
3845
3845
|
if (p)
|
|
3846
3846
|
return (i = (g = this.agentOptions).onRecovered) == null || i.call(g, r, e), p;
|
|
@@ -3848,10 +3848,10 @@ class Ri extends yt {
|
|
|
3848
3848
|
throw e;
|
|
3849
3849
|
}
|
|
3850
3850
|
}
|
|
3851
|
-
function
|
|
3852
|
-
return new
|
|
3851
|
+
function Di(t) {
|
|
3852
|
+
return new Ni(t);
|
|
3853
3853
|
}
|
|
3854
|
-
function
|
|
3854
|
+
function Li({
|
|
3855
3855
|
existing: t,
|
|
3856
3856
|
fetched: e,
|
|
3857
3857
|
refreshItems: r = !1
|
|
@@ -3863,7 +3863,7 @@ function Ni({
|
|
|
3863
3863
|
if (s.add(u.turn_id), u.message_uuids.length === 0) continue;
|
|
3864
3864
|
const y = n.get(u.turn_id);
|
|
3865
3865
|
if (y && !r) {
|
|
3866
|
-
|
|
3866
|
+
ji(y.rowIds, u.message_uuids) ? o.push(y) : o.push({ ...y, rowIds: u.message_uuids });
|
|
3867
3867
|
continue;
|
|
3868
3868
|
}
|
|
3869
3869
|
if (u.ui_parts !== null) {
|
|
@@ -3881,16 +3881,16 @@ function Ni({
|
|
|
3881
3881
|
s.has(u.turnId) || o.push(u);
|
|
3882
3882
|
return o.length === t.length && o.every((u, y) => u === t[y]) ? t : o;
|
|
3883
3883
|
}
|
|
3884
|
-
const
|
|
3885
|
-
function
|
|
3884
|
+
const ji = (t, e) => t.length === e.length && t.every((r, n) => r === e[n]), ki = (t) => Array.isArray(t) && t.every((e) => typeof e == "string");
|
|
3885
|
+
function Sr(t) {
|
|
3886
3886
|
for (const e of t) {
|
|
3887
3887
|
if (e.type !== "data-turn-settled") continue;
|
|
3888
3888
|
const r = e.data;
|
|
3889
|
-
return !
|
|
3889
|
+
return !Mr(r) || typeof r.turn_id != "string" || !ki(r.message_uuids) ? null : { turnId: r.turn_id, rowIds: r.message_uuids };
|
|
3890
3890
|
}
|
|
3891
3891
|
return null;
|
|
3892
3892
|
}
|
|
3893
|
-
function
|
|
3893
|
+
function $i(t) {
|
|
3894
3894
|
if (typeof document > "u" || typeof window > "u" || typeof window.addEventListener != "function")
|
|
3895
3895
|
return () => {
|
|
3896
3896
|
};
|
|
@@ -3901,7 +3901,7 @@ function ji(t) {
|
|
|
3901
3901
|
document.removeEventListener("visibilitychange", e), window.removeEventListener("online", e);
|
|
3902
3902
|
};
|
|
3903
3903
|
}
|
|
3904
|
-
async function
|
|
3904
|
+
async function Fi({
|
|
3905
3905
|
api: t,
|
|
3906
3906
|
sessionId: e,
|
|
3907
3907
|
chatStop: r
|
|
@@ -3912,12 +3912,12 @@ async function ki({
|
|
|
3912
3912
|
e && await t.stopStream(e);
|
|
3913
3913
|
}
|
|
3914
3914
|
}
|
|
3915
|
-
const
|
|
3916
|
-
function
|
|
3917
|
-
const e =
|
|
3915
|
+
const Ui = /^[A-Za-z0-9_$.]{1,100}$/;
|
|
3916
|
+
function Ir(t) {
|
|
3917
|
+
const e = Ui.test(t.name) ? t.name : "Error";
|
|
3918
3918
|
if (ft.isInstance(t))
|
|
3919
3919
|
return { kind: "empty_body", error_name: e };
|
|
3920
|
-
if (
|
|
3920
|
+
if (Lr.isInstance(t)) {
|
|
3921
3921
|
const r = t.statusCode;
|
|
3922
3922
|
return r !== void 0 && r >= 100 && r <= 599 ? { kind: "http_error", error_name: e, http_status: r } : { kind: "http_error", error_name: e };
|
|
3923
3923
|
}
|
|
@@ -3928,26 +3928,26 @@ function Sr(t) {
|
|
|
3928
3928
|
}
|
|
3929
3929
|
return { kind: "other", error_name: e };
|
|
3930
3930
|
}
|
|
3931
|
-
const
|
|
3932
|
-
function
|
|
3931
|
+
const Er = 20, qi = [1e3, 3e3, 8e3], zi = "highlight_element", Zi = "act_on_page";
|
|
3932
|
+
function Vi({
|
|
3933
3933
|
widgetCtx: t,
|
|
3934
3934
|
config: e,
|
|
3935
3935
|
sessionId: r,
|
|
3936
3936
|
persistedMessages: n
|
|
3937
3937
|
}) {
|
|
3938
3938
|
var Qt, Xt;
|
|
3939
|
-
const { api: s, messageCtx: o } = t, l =
|
|
3939
|
+
const { api: s, messageCtx: o } = t, l = R(e);
|
|
3940
3940
|
l.current = e;
|
|
3941
3941
|
const {
|
|
3942
3942
|
pageContext: u,
|
|
3943
3943
|
clientTools: y,
|
|
3944
3944
|
pageActions: g
|
|
3945
|
-
} = t.features, i =
|
|
3945
|
+
} = t.features, i = R(() => {
|
|
3946
3946
|
}), d = X(
|
|
3947
|
-
() =>
|
|
3947
|
+
() => Di({
|
|
3948
3948
|
...s.getStreamTransportOptions(),
|
|
3949
3949
|
headers: () => s.getStreamTransportOptions().headers,
|
|
3950
|
-
reconnectApi: (v) =>
|
|
3950
|
+
reconnectApi: (v) => _i(
|
|
3951
3951
|
s.getStreamTransportOptions().reconnectApi(v),
|
|
3952
3952
|
l.current.presentation
|
|
3953
3953
|
),
|
|
@@ -3960,15 +3960,15 @@ function zi({
|
|
|
3960
3960
|
// fetch already failed, so there is nothing else to try.
|
|
3961
3961
|
recoveryFetch: () => {
|
|
3962
3962
|
const v = l.current.streamingFetch;
|
|
3963
|
-
return v && v !== globalThis.fetch ? (E,
|
|
3963
|
+
return v && v !== globalThis.fetch ? (E, T) => globalThis.fetch(E, T) : void 0;
|
|
3964
3964
|
},
|
|
3965
3965
|
onRecovered: (v, E) => i.current(v, E)
|
|
3966
3966
|
}),
|
|
3967
3967
|
[s]
|
|
3968
|
-
), [p, b] = J(null),
|
|
3969
|
-
() => r !== null && !(I.current === null &&
|
|
3968
|
+
), [p, b] = J(null), P = R(!1), [M] = J(Rt), O = R(Promise.resolve()), x = R(0), w = R(0), I = R(r), C = X(
|
|
3969
|
+
() => r !== null && !(I.current === null && x.current > 0),
|
|
3970
3970
|
[r]
|
|
3971
|
-
), c =
|
|
3971
|
+
), c = R(() => {
|
|
3972
3972
|
}), {
|
|
3973
3973
|
status: m,
|
|
3974
3974
|
messages: f,
|
|
@@ -3977,7 +3977,7 @@ function zi({
|
|
|
3977
3977
|
error: N,
|
|
3978
3978
|
clearError: D,
|
|
3979
3979
|
resumeStream: B
|
|
3980
|
-
} =
|
|
3980
|
+
} = mi({
|
|
3981
3981
|
id: r ?? M,
|
|
3982
3982
|
resume: C,
|
|
3983
3983
|
transport: d,
|
|
@@ -3987,64 +3987,63 @@ function zi({
|
|
|
3987
3987
|
throttle: 50,
|
|
3988
3988
|
onError: (v) => c.current(v),
|
|
3989
3989
|
onFinish: b
|
|
3990
|
-
}), W =
|
|
3990
|
+
}), W = R(f);
|
|
3991
3991
|
W.current = f;
|
|
3992
|
-
const j =
|
|
3992
|
+
const j = R(new mr(Er));
|
|
3993
3993
|
F(() => {
|
|
3994
3994
|
if (!p || p.messages !== f) return;
|
|
3995
|
-
const { isAbort: v, isDisconnect: E, isError:
|
|
3996
|
-
v || E ||
|
|
3997
|
-
lastAIResMightSolveUserIssue:
|
|
3995
|
+
const { isAbort: v, isDisconnect: E, isError: T, message: A } = p;
|
|
3996
|
+
v || E || T || j.current.size > 0 || o.state.setPartial({
|
|
3997
|
+
lastAIResMightSolveUserIssue: Mr(A.metadata) && A.metadata.mightSolveUserIssue === !0
|
|
3998
3998
|
});
|
|
3999
3999
|
}, [p, f, o]);
|
|
4000
|
-
const
|
|
4001
|
-
|
|
4002
|
-
const [
|
|
4003
|
-
Ke.current = v,
|
|
4004
|
-
}, []),
|
|
4005
|
-
null
|
|
4006
|
-
), Wt = P(r);
|
|
4000
|
+
const $ = R("idle"), [Se, Ie] = J(!1), [ve, ae] = J(0), [G, de] = J(!1), fe = R(G);
|
|
4001
|
+
fe.current = G;
|
|
4002
|
+
const [Ee, U] = J([]), [ie, Ce] = J([]), [me, Cn] = J(null), Ke = R(null), Re = z((v) => {
|
|
4003
|
+
Ke.current = v, Cn(v);
|
|
4004
|
+
}, []), Ue = R(null), we = R(null), Ae = R(null), Wt = R(r);
|
|
4007
4005
|
Wt.current = r;
|
|
4008
|
-
const Jt = (v, E,
|
|
4006
|
+
const Jt = (v, E, T) => {
|
|
4009
4007
|
const A = Wt.current;
|
|
4010
4008
|
A && s.reportClientStreamError(A, {
|
|
4011
|
-
...
|
|
4009
|
+
...Ir(v),
|
|
4012
4010
|
phase: E,
|
|
4013
|
-
recovered:
|
|
4014
|
-
widget_version:
|
|
4011
|
+
recovered: T,
|
|
4012
|
+
widget_version: Rr,
|
|
4015
4013
|
platform: typeof navigator < "u" && navigator.product === "ReactNative" ? "react-native" : "web"
|
|
4016
4014
|
});
|
|
4017
4015
|
};
|
|
4018
4016
|
c.current = (v) => {
|
|
4019
|
-
|
|
4017
|
+
le.error("agent chat stream error", v), Ir(v).kind === "empty_body" && le.error(
|
|
4020
4018
|
"the streaming response has no readable body. In React Native, pass `streamingFetch` from `expo/fetch` and return its response unchanged: React Native's global Response cannot stream."
|
|
4021
4019
|
);
|
|
4022
|
-
const E =
|
|
4023
|
-
E === "send" &&
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4020
|
+
const E = $.current === "in-flight" ? "send" : "resume", T = we.current;
|
|
4021
|
+
E === "send" && T ? Ae.current = {
|
|
4022
|
+
kind: "send",
|
|
4023
|
+
wireId: T.retryUuid ?? T.userMessage.id,
|
|
4024
|
+
bubbleId: T.userMessage.id
|
|
4025
|
+
} : E === "resume" && Ae.current === null && (Ae.current = { kind: "resume" }), Jt(v, E, !1);
|
|
4027
4026
|
};
|
|
4028
|
-
const Yt =
|
|
4027
|
+
const Yt = R(!1);
|
|
4029
4028
|
i.current = (v, E) => {
|
|
4030
|
-
Yt.current || (Yt.current = !0,
|
|
4029
|
+
Yt.current || (Yt.current = !0, le.warn(
|
|
4031
4030
|
"the `streamingFetch` response has no readable body, so replies are read through the global fetch instead. Return the `expo/fetch` response unchanged to stream it directly."
|
|
4032
4031
|
)), Jt(E, v, !0);
|
|
4033
4032
|
};
|
|
4034
|
-
const qe =
|
|
4035
|
-
|
|
4036
|
-
const tt =
|
|
4037
|
-
const
|
|
4038
|
-
if (!
|
|
4033
|
+
const qe = R(m), He = I.current === r, Et = R(null), Ct = R(null), Kt = R(S), xe = R(m);
|
|
4034
|
+
xe.current = m;
|
|
4035
|
+
const tt = z((v, E) => {
|
|
4036
|
+
const T = Sr(v.parts);
|
|
4037
|
+
if (!T || T.rowIds.length === 0) return;
|
|
4039
4038
|
const A = pt(v.parts);
|
|
4040
4039
|
A.length !== 0 && U(
|
|
4041
|
-
(
|
|
4042
|
-
|
|
4043
|
-
{ key: E, turnId:
|
|
4040
|
+
(k) => k.some((K) => K.turnId === T.turnId) ? k : [
|
|
4041
|
+
...k,
|
|
4042
|
+
{ key: E, turnId: T.turnId, rowIds: T.rowIds, items: A }
|
|
4044
4043
|
]
|
|
4045
4044
|
);
|
|
4046
|
-
}, []), Ht =
|
|
4047
|
-
(v) =>
|
|
4045
|
+
}, []), Ht = z(
|
|
4046
|
+
(v) => Fn({
|
|
4048
4047
|
config: l.current,
|
|
4049
4048
|
input: v.input,
|
|
4050
4049
|
uuid: v.retryUuid ?? v.userMessage.id,
|
|
@@ -4064,12 +4063,12 @@ function zi({
|
|
|
4064
4063
|
U([]);
|
|
4065
4064
|
return;
|
|
4066
4065
|
}
|
|
4067
|
-
const
|
|
4068
|
-
w.current += 1,
|
|
4069
|
-
|
|
4066
|
+
const T = xe.current === "submitted" || xe.current === "streaming" || qe.current === "submitted" || qe.current === "streaming" || $.current === "in-flight";
|
|
4067
|
+
w.current += 1, x.current = 0, O.current = Promise.resolve(), j.current = new mr(Er), $.current = "idle", Ie(!1), we.current = null, Ae.current = null, Ue.current = null, b(null), P.current = !1, Ct.current = null, Et.current = m === "submitted" || m === "streaming" ? m : null, qe.current = "ready", xe.current = "ready", D(), ae((A) => A + 1), de(!1), U([]), Re(null), T && Promise.resolve().then(() => v()).catch((A) => {
|
|
4068
|
+
le.error("agent chat client stream cancel failed", A);
|
|
4070
4069
|
});
|
|
4071
|
-
}, [r, m, S, D,
|
|
4072
|
-
var
|
|
4070
|
+
}, [r, m, S, D, Re]), F(() => {
|
|
4071
|
+
var k, K;
|
|
4073
4072
|
const v = Et.current;
|
|
4074
4073
|
if (v !== null && m === v) {
|
|
4075
4074
|
qe.current = "ready";
|
|
@@ -4077,66 +4076,66 @@ function zi({
|
|
|
4077
4076
|
}
|
|
4078
4077
|
Et.current = null;
|
|
4079
4078
|
const E = qe.current;
|
|
4080
|
-
if (qe.current = m, (m === "submitted" || m === "streaming") && (E !== "submitted" && E !== "streaming" && Ke.current === null &&
|
|
4081
|
-
const
|
|
4082
|
-
|
|
4079
|
+
if (qe.current = m, (m === "submitted" || m === "streaming") && (E !== "submitted" && E !== "streaming" && Ke.current === null && Re(`turn-resumed-${Rt()}`), de(!0)), m === "streaming") {
|
|
4080
|
+
const Z = (k = we.current) == null ? void 0 : k.userMessage.id;
|
|
4081
|
+
Z && o.markUserMessageDelivered(Z);
|
|
4083
4082
|
return;
|
|
4084
4083
|
}
|
|
4085
4084
|
if (m !== "ready" && m !== "error") return;
|
|
4086
4085
|
if (E === "streaming" || E === "submitted" || // An empty response can finish before React observes an active status.
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
const
|
|
4090
|
-
|
|
4091
|
-
const
|
|
4092
|
-
if (
|
|
4093
|
-
const
|
|
4094
|
-
|
|
4095
|
-
} else
|
|
4096
|
-
|
|
4097
|
-
|
|
4086
|
+
$.current === "in-flight" && (p == null ? void 0 : p.messages) === W.current) {
|
|
4087
|
+
de(!0);
|
|
4088
|
+
const Z = $.current === "in-flight";
|
|
4089
|
+
Z && ($.current = "idle");
|
|
4090
|
+
const re = W.current.at(-1), be = Ke.current;
|
|
4091
|
+
if (Ue.current = be, be !== null && re && re.role === "assistant" && tt(re, be), m === "ready") {
|
|
4092
|
+
const Pe = (K = we.current) == null ? void 0 : K.userMessage.id;
|
|
4093
|
+
Pe && o.markUserMessageDelivered(Pe);
|
|
4094
|
+
} else Z && E !== "streaming" && we.current && o.releaseUnsentOptionPick(we.current.input);
|
|
4095
|
+
$.current === "stopping" || (r ? ($.current = "reconciling", t.reconcileAfterStream(r).catch((Pe) => {
|
|
4096
|
+
le.error("agent chat post-turn reconcile failed", Pe);
|
|
4098
4097
|
}).finally(() => {
|
|
4099
|
-
|
|
4100
|
-
})) :
|
|
4098
|
+
$.current === "reconciling" && ($.current = "idle"), ae((Pe) => Pe + 1);
|
|
4099
|
+
})) : de(!1));
|
|
4101
4100
|
}
|
|
4102
|
-
if (
|
|
4101
|
+
if ($.current !== "idle" || !r || fe.current && m !== "error") return;
|
|
4103
4102
|
const A = j.current.dequeueNext();
|
|
4104
|
-
A && (
|
|
4103
|
+
A && ($.current = "in-flight", Ie(!1), we.current = A, Ae.current = null, b(null), P.current = !1, Re(`turn-${A.userMessage.id}`), o.appendUserMessageIfAbsent(A.userMessage), ae((Z) => Z + 1), h(
|
|
4105
4104
|
{ text: A.userMessage.content },
|
|
4106
4105
|
{ body: Ht(A) }
|
|
4107
4106
|
));
|
|
4108
4107
|
}, [
|
|
4109
4108
|
m,
|
|
4110
4109
|
r,
|
|
4111
|
-
|
|
4110
|
+
ve,
|
|
4112
4111
|
h,
|
|
4113
4112
|
o,
|
|
4114
4113
|
t,
|
|
4115
4114
|
Ht,
|
|
4116
4115
|
tt,
|
|
4117
|
-
|
|
4116
|
+
Re,
|
|
4118
4117
|
p
|
|
4119
4118
|
]);
|
|
4120
|
-
const Gt =
|
|
4119
|
+
const Gt = z(
|
|
4121
4120
|
(v) => {
|
|
4122
4121
|
const E = w.current;
|
|
4123
|
-
|
|
4122
|
+
x.current++;
|
|
4124
4123
|
const A = O.current.then(
|
|
4125
4124
|
async () => {
|
|
4126
4125
|
if (E !== w.current) return;
|
|
4127
|
-
const
|
|
4128
|
-
if (!
|
|
4129
|
-
const
|
|
4130
|
-
if (!j.current.enqueue(
|
|
4131
|
-
|
|
4132
|
-
rejectedMessageId:
|
|
4126
|
+
const k = $.current, Z = xe.current === "submitted" || xe.current === "streaming" || k !== "idle" || fe.current || j.current.size > 0 ? Bi(o.buildQueuedUserMessage(v)) : await o.stageUserTurn(v, { pending: !0 });
|
|
4127
|
+
if (!Z || E !== w.current) return;
|
|
4128
|
+
const re = { ...Z, input: v };
|
|
4129
|
+
if (!j.current.enqueue(re)) {
|
|
4130
|
+
le.warn("agent chat queue full; rejecting newest send", {
|
|
4131
|
+
rejectedMessageId: re.userMessage.id
|
|
4133
4132
|
});
|
|
4134
4133
|
return;
|
|
4135
4134
|
}
|
|
4136
|
-
|
|
4135
|
+
ae((be) => be + 1), o.notifySendAccepted(v);
|
|
4137
4136
|
}
|
|
4138
4137
|
).finally(() => {
|
|
4139
|
-
E === w.current &&
|
|
4138
|
+
E === w.current && x.current--;
|
|
4140
4139
|
});
|
|
4141
4140
|
return O.current = A.then(
|
|
4142
4141
|
() => {
|
|
@@ -4146,95 +4145,95 @@ function zi({
|
|
|
4146
4145
|
), A;
|
|
4147
4146
|
},
|
|
4148
4147
|
[o]
|
|
4149
|
-
),
|
|
4150
|
-
var
|
|
4151
|
-
const v =
|
|
4148
|
+
), wn = z(() => {
|
|
4149
|
+
var K;
|
|
4150
|
+
const v = we.current;
|
|
4152
4151
|
if (!v) return;
|
|
4153
|
-
const E = v.input.optionReply,
|
|
4152
|
+
const E = v.input.optionReply, T = E ? n.find((Z) => Z.id === E.messageId) : void 0, A = T && Un(T) ? (K = T.messageOptions) == null ? void 0 : K.pickedOptionId : null;
|
|
4154
4153
|
if (E && A && A !== E.optionId) return;
|
|
4155
4154
|
if (!j.current.enqueue({
|
|
4156
4155
|
...v,
|
|
4157
|
-
retryUuid:
|
|
4156
|
+
retryUuid: Rt()
|
|
4158
4157
|
})) {
|
|
4159
|
-
|
|
4158
|
+
le.warn("agent chat queue full; retry not enqueued");
|
|
4160
4159
|
return;
|
|
4161
4160
|
}
|
|
4162
|
-
E && o.setMessageOptionPick(E.messageId, E.optionId), D(),
|
|
4163
|
-
}, [D, o, n]),
|
|
4161
|
+
E && o.setMessageOptionPick(E.messageId, E.optionId), D(), ae((Z) => Z + 1);
|
|
4162
|
+
}, [D, o, n]), An = z(
|
|
4164
4163
|
(v) => {
|
|
4165
4164
|
const E = j.current.removeWhere(
|
|
4166
|
-
(
|
|
4165
|
+
(T) => T.userMessage.id === v
|
|
4167
4166
|
);
|
|
4168
|
-
E && (o.releaseUnsentOptionPick(E.input),
|
|
4167
|
+
E && (o.releaseUnsentOptionPick(E.input), ae((T) => T + 1));
|
|
4169
4168
|
},
|
|
4170
4169
|
[o]
|
|
4171
|
-
),
|
|
4172
|
-
|
|
4170
|
+
), xn = z(() => {
|
|
4171
|
+
$.current = "stopping", Ie(!0), P.current = !1;
|
|
4173
4172
|
const v = w.current;
|
|
4174
|
-
|
|
4175
|
-
v === w.current && (
|
|
4173
|
+
Fi({ api: s, sessionId: r, chatStop: S }).then(() => {
|
|
4174
|
+
v === w.current && (P.current = !0);
|
|
4176
4175
|
}).catch((E) => {
|
|
4177
|
-
|
|
4176
|
+
le.error("agent chat stop failed", E);
|
|
4178
4177
|
}).then(() => {
|
|
4179
4178
|
if (v === w.current) {
|
|
4180
4179
|
if (!r) {
|
|
4181
|
-
|
|
4180
|
+
de(!1);
|
|
4182
4181
|
return;
|
|
4183
4182
|
}
|
|
4184
4183
|
return t.reconcileAfterStream(r).catch((E) => {
|
|
4185
|
-
|
|
4184
|
+
le.error("agent chat post-stop reconcile failed", E);
|
|
4186
4185
|
});
|
|
4187
4186
|
}
|
|
4188
4187
|
}).finally(() => {
|
|
4189
|
-
v === w.current && (
|
|
4188
|
+
v === w.current && ($.current = "idle", ae((E) => E + 1));
|
|
4190
4189
|
});
|
|
4191
4190
|
}, [s, r, S, t]);
|
|
4192
4191
|
F(() => {
|
|
4193
4192
|
const v = {
|
|
4194
4193
|
send: Gt,
|
|
4195
|
-
hasPendingWork: () =>
|
|
4194
|
+
hasPendingWork: () => x.current > 0 || fe.current || j.current.size > 0 || $.current !== "idle" || xe.current === "submitted" || xe.current === "streaming"
|
|
4196
4195
|
};
|
|
4197
4196
|
return o.registerAgentHandlers(v), () => o.unregisterAgentHandlers(v);
|
|
4198
4197
|
}, [o, Gt]);
|
|
4199
4198
|
const rt = (Qt = e.presentation) == null ? void 0 : Qt.toolActivity, nt = (Xt = e.presentation) == null ? void 0 : Xt.reasoning;
|
|
4200
|
-
F(() =>
|
|
4201
|
-
var
|
|
4199
|
+
F(() => Ce([]), [r]), F(() => {
|
|
4200
|
+
var k, K;
|
|
4202
4201
|
if (!r) return;
|
|
4203
|
-
const v = rt === void 0 && nt === void 0 ? void 0 : { toolActivity: rt, reasoning: nt }, E = Ct.current,
|
|
4202
|
+
const v = rt === void 0 && nt === void 0 ? void 0 : { toolActivity: rt, reasoning: nt }, E = Ct.current, T = (E == null ? void 0 : E.sessionId) === r && (((k = E.presentation) == null ? void 0 : k.toolActivity) !== rt || ((K = E.presentation) == null ? void 0 : K.reasoning) !== nt);
|
|
4204
4203
|
Ct.current = { sessionId: r, presentation: v };
|
|
4205
4204
|
let A = !1;
|
|
4206
4205
|
return (async () => {
|
|
4207
4206
|
try {
|
|
4208
|
-
const
|
|
4209
|
-
if (!
|
|
4210
|
-
|
|
4211
|
-
(
|
|
4207
|
+
const Z = v === void 0 ? await s.getAgentTurnMessages(r) : await s.getAgentTurnMessages(r, v);
|
|
4208
|
+
if (!Z || A) return;
|
|
4209
|
+
Ce(Z.handled_connection_request_ids), U(
|
|
4210
|
+
(re) => Li({ existing: re, fetched: Z, refreshItems: T })
|
|
4212
4211
|
);
|
|
4213
|
-
} catch (
|
|
4214
|
-
|
|
4212
|
+
} catch (Z) {
|
|
4213
|
+
le.error("agent chat turn sources fetch failed", Z);
|
|
4215
4214
|
}
|
|
4216
4215
|
})(), () => {
|
|
4217
4216
|
A = !0;
|
|
4218
4217
|
};
|
|
4219
4218
|
}, [r, s, rt, nt]);
|
|
4220
|
-
const [wt,
|
|
4221
|
-
if (
|
|
4219
|
+
const [wt, Tn] = J(() => /* @__PURE__ */ new Set()), st = R(wt), At = R(/* @__PURE__ */ new Set()), at = X(() => {
|
|
4220
|
+
if (Se || m !== "streaming" && m !== "submitted")
|
|
4222
4221
|
return [];
|
|
4223
4222
|
const v = f.at(-1);
|
|
4224
4223
|
if (!v || v.role !== "assistant") return [];
|
|
4225
4224
|
const E = [];
|
|
4226
|
-
for (const
|
|
4227
|
-
if (!
|
|
4228
|
-
const A =
|
|
4229
|
-
|
|
4230
|
-
key: `${r ?? "pending"}:${
|
|
4231
|
-
type:
|
|
4232
|
-
input:
|
|
4233
|
-
callId:
|
|
4225
|
+
for (const T of v.parts) {
|
|
4226
|
+
if (!pe(T)) continue;
|
|
4227
|
+
const A = Ha(T), k = A === zi ? "highlight-element" : A === Zi ? "act-on-page" : null;
|
|
4228
|
+
k && T.state === "input-available" && E.push({
|
|
4229
|
+
key: `${r ?? "pending"}:${T.toolCallId}`,
|
|
4230
|
+
type: k,
|
|
4231
|
+
input: T.input,
|
|
4232
|
+
callId: T.toolCallId
|
|
4234
4233
|
});
|
|
4235
4234
|
}
|
|
4236
4235
|
return E;
|
|
4237
|
-
}, [f, r, m,
|
|
4236
|
+
}, [f, r, m, Se]), Mn = X(
|
|
4238
4237
|
() => at.filter(
|
|
4239
4238
|
(v) => u && y && (v.type !== "act-on-page" || g) && !wt.has(v.key)
|
|
4240
4239
|
),
|
|
@@ -4245,21 +4244,21 @@ function zi({
|
|
|
4245
4244
|
g,
|
|
4246
4245
|
wt
|
|
4247
4246
|
]
|
|
4248
|
-
), xt =
|
|
4249
|
-
(v, E,
|
|
4247
|
+
), xt = z(
|
|
4248
|
+
(v, E, T, A) => {
|
|
4250
4249
|
if (!r) return;
|
|
4251
|
-
const
|
|
4252
|
-
if (st.current.has(
|
|
4253
|
-
At.current.delete(
|
|
4254
|
-
const
|
|
4255
|
-
if (
|
|
4256
|
-
const
|
|
4257
|
-
|
|
4250
|
+
const k = `${r}:${v}`;
|
|
4251
|
+
if (st.current.has(k)) return;
|
|
4252
|
+
At.current.delete(k);
|
|
4253
|
+
const K = new Set(st.current);
|
|
4254
|
+
if (K.add(k), K.size > 200) {
|
|
4255
|
+
const Z = K.values().next().value;
|
|
4256
|
+
Z !== void 0 && K.delete(Z);
|
|
4258
4257
|
}
|
|
4259
|
-
st.current =
|
|
4258
|
+
st.current = K, Tn(K), s.sendPageReply(r, {
|
|
4260
4259
|
callId: v,
|
|
4261
4260
|
outcome: E,
|
|
4262
|
-
...
|
|
4261
|
+
...T ? { detail: T } : {},
|
|
4263
4262
|
// The page as it is after the action. Without it a flow that
|
|
4264
4263
|
// crosses screens stops dead: the agent is holding refs to the
|
|
4265
4264
|
// screen it just left.
|
|
@@ -4267,23 +4266,23 @@ function zi({
|
|
|
4267
4266
|
});
|
|
4268
4267
|
},
|
|
4269
4268
|
[s, r, t]
|
|
4270
|
-
), [
|
|
4269
|
+
), [_n, Tt] = J(null), Te = R(
|
|
4271
4270
|
/* @__PURE__ */ new Map()
|
|
4272
|
-
),
|
|
4271
|
+
), Rn = z(
|
|
4273
4272
|
(v) => new Promise((E) => {
|
|
4274
|
-
const
|
|
4275
|
-
if (st.current.has(
|
|
4273
|
+
const T = `${r ?? "pending"}:${v.callId}`;
|
|
4274
|
+
if (st.current.has(T)) {
|
|
4276
4275
|
E(!1);
|
|
4277
4276
|
return;
|
|
4278
4277
|
}
|
|
4279
|
-
At.current.add(
|
|
4278
|
+
At.current.add(T), Te.current.forEach((A) => A(!1)), Te.current.clear(), Te.current.set(v.callId, E), Tt(v);
|
|
4280
4279
|
}),
|
|
4281
4280
|
[r]
|
|
4282
|
-
), Mt =
|
|
4283
|
-
const
|
|
4284
|
-
|
|
4281
|
+
), Mt = z((v, E) => {
|
|
4282
|
+
const T = Te.current.get(v);
|
|
4283
|
+
Te.current.delete(v), Tt(
|
|
4285
4284
|
(A) => (A == null ? void 0 : A.callId) === v ? null : A
|
|
4286
|
-
),
|
|
4285
|
+
), T == null || T(E);
|
|
4287
4286
|
}, []);
|
|
4288
4287
|
F(() => {
|
|
4289
4288
|
for (const v of at)
|
|
@@ -4296,36 +4295,41 @@ function zi({
|
|
|
4296
4295
|
Mt,
|
|
4297
4296
|
xt
|
|
4298
4297
|
]);
|
|
4299
|
-
const
|
|
4298
|
+
const oe = m === "submitted" || m === "streaming";
|
|
4300
4299
|
F(() => {
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4300
|
+
var Z;
|
|
4301
|
+
const v = Ae.current;
|
|
4302
|
+
if (N === void 0 || oe || !v || !r) return;
|
|
4303
|
+
const E = v.kind === "send" ? v.wireId : (Z = n.findLast(
|
|
4304
|
+
(re) => re.type === "USER" && !re.pending
|
|
4305
|
+
)) == null ? void 0 : Z.id;
|
|
4306
|
+
if (E === void 0) return;
|
|
4307
|
+
const T = new Set(n.map((re) => re.id));
|
|
4308
|
+
let A = !1, k;
|
|
4309
|
+
const K = async (re) => {
|
|
4310
|
+
let be;
|
|
4307
4311
|
try {
|
|
4308
|
-
|
|
4312
|
+
be = await s.getAgentTurnMessages(r);
|
|
4309
4313
|
} catch (lt) {
|
|
4310
|
-
|
|
4314
|
+
le.warn("agent chat failed-turn check failed", lt);
|
|
4311
4315
|
return;
|
|
4312
4316
|
}
|
|
4313
|
-
if (
|
|
4314
|
-
if (
|
|
4315
|
-
(lt) => (lt.input_message_uuids ?? []).includes(
|
|
4317
|
+
if (A || Ae.current !== v) return;
|
|
4318
|
+
if (be == null ? void 0 : be.turns.some(
|
|
4319
|
+
(lt) => (lt.input_message_uuids ?? []).includes(E) && lt.message_uuids.some((Ln) => T.has(Ln))
|
|
4316
4320
|
)) {
|
|
4317
|
-
|
|
4321
|
+
Ae.current = null, v.kind === "send" && o.markUserMessageDelivered(v.bubbleId), D();
|
|
4318
4322
|
return;
|
|
4319
4323
|
}
|
|
4320
|
-
const [
|
|
4321
|
-
|
|
4324
|
+
const [er, ...Dn] = re;
|
|
4325
|
+
er !== void 0 && (k = setTimeout(() => void K(Dn), er));
|
|
4322
4326
|
};
|
|
4323
|
-
return
|
|
4324
|
-
|
|
4327
|
+
return K(qi), () => {
|
|
4328
|
+
A = !0, k !== void 0 && clearTimeout(k);
|
|
4325
4329
|
};
|
|
4326
4330
|
}, [
|
|
4327
4331
|
N,
|
|
4328
|
-
|
|
4332
|
+
oe,
|
|
4329
4333
|
n,
|
|
4330
4334
|
r,
|
|
4331
4335
|
s,
|
|
@@ -4333,126 +4337,126 @@ function zi({
|
|
|
4333
4337
|
D
|
|
4334
4338
|
]), F(
|
|
4335
4339
|
() => () => {
|
|
4336
|
-
|
|
4340
|
+
Te.current.forEach((v) => v(!1)), Te.current.clear();
|
|
4337
4341
|
},
|
|
4338
4342
|
[r]
|
|
4339
4343
|
), F(() => {
|
|
4340
|
-
if (
|
|
4341
|
-
const v =
|
|
4344
|
+
if (oe && !Se) return;
|
|
4345
|
+
const v = Te.current;
|
|
4342
4346
|
v.size !== 0 && (v.forEach((E) => E(!1)), v.clear(), Tt(null));
|
|
4343
|
-
}, [
|
|
4344
|
-
if (
|
|
4345
|
-
const v =
|
|
4347
|
+
}, [oe, Se]), F(() => {
|
|
4348
|
+
if (oe) return;
|
|
4349
|
+
const v = Ue.current;
|
|
4346
4350
|
if (v === null) return;
|
|
4347
4351
|
const E = f.at(-1);
|
|
4348
4352
|
E && E.role === "assistant" && tt(E, v);
|
|
4349
|
-
}, [f,
|
|
4350
|
-
const _t =
|
|
4351
|
-
r && (
|
|
4352
|
-
}, [r,
|
|
4353
|
+
}, [f, oe, tt]);
|
|
4354
|
+
const _t = z(() => {
|
|
4355
|
+
r && (oe || N === void 0 && !G || B());
|
|
4356
|
+
}, [r, oe, G, N, B]);
|
|
4353
4357
|
F(
|
|
4354
|
-
() =>
|
|
4358
|
+
() => $i(_t),
|
|
4355
4359
|
[_t]
|
|
4356
4360
|
), F(() => {
|
|
4357
|
-
if (
|
|
4361
|
+
if (oe || !G) return;
|
|
4358
4362
|
const v = () => {
|
|
4359
|
-
|
|
4363
|
+
de(!1), ae((A) => A + 1), Ke.current === Ue.current && Re(null), Ue.current = null;
|
|
4360
4364
|
};
|
|
4361
|
-
if (Ke.current ===
|
|
4365
|
+
if (Ke.current === Ue.current && (p == null ? void 0 : p.messages) === f && !p.isError && !p.isDisconnect && (!p.isAbort || P.current) && !pt(p.message.parts).some(
|
|
4362
4366
|
(A) => A.kind !== "steps"
|
|
4363
4367
|
)) {
|
|
4364
|
-
const A = n.findLast((
|
|
4368
|
+
const A = n.findLast((k) => k.type === "USER");
|
|
4365
4369
|
A && o.state.setPartial({ settledAgentUserMessageId: A.id }), v();
|
|
4366
4370
|
return;
|
|
4367
4371
|
}
|
|
4368
4372
|
if (p && p.messages !== f) return;
|
|
4369
|
-
const E = f.at(-1),
|
|
4370
|
-
if (
|
|
4371
|
-
const A = new Set(n.map((
|
|
4372
|
-
|
|
4373
|
+
const E = f.at(-1), T = (E == null ? void 0 : E.role) === "assistant" ? Sr(E.parts) : null;
|
|
4374
|
+
if (T && T.rowIds.length > 0) {
|
|
4375
|
+
const A = new Set(n.map((k) => k.id));
|
|
4376
|
+
T.rowIds.every((k) => A.has(k)) && v();
|
|
4373
4377
|
return;
|
|
4374
4378
|
}
|
|
4375
4379
|
for (let A = n.length - 1; A >= 0; A -= 1) {
|
|
4376
|
-
const
|
|
4377
|
-
if (
|
|
4378
|
-
if (
|
|
4379
|
-
if (!(
|
|
4380
|
+
const k = n[A];
|
|
4381
|
+
if (k) {
|
|
4382
|
+
if (k.type === "USER") return;
|
|
4383
|
+
if (!(k.type !== "AI" && k.type !== "AGENT")) {
|
|
4380
4384
|
v();
|
|
4381
4385
|
return;
|
|
4382
4386
|
}
|
|
4383
4387
|
}
|
|
4384
4388
|
}
|
|
4385
4389
|
}, [
|
|
4386
|
-
|
|
4390
|
+
oe,
|
|
4387
4391
|
G,
|
|
4388
4392
|
n,
|
|
4389
|
-
|
|
4393
|
+
Re,
|
|
4390
4394
|
p,
|
|
4391
4395
|
f,
|
|
4392
4396
|
o,
|
|
4393
|
-
|
|
4397
|
+
ve
|
|
4394
4398
|
]);
|
|
4395
|
-
const ze =
|
|
4399
|
+
const ze = qn(
|
|
4396
4400
|
t.agent.presentation,
|
|
4397
4401
|
e.presentation
|
|
4398
4402
|
), it = ze == null ? void 0 : ze.toolActivity, ot = ze == null ? void 0 : ze.reasoning, Pn = X(() => {
|
|
4399
|
-
if (!He ||
|
|
4403
|
+
if (!He || me === null || m === "submitted" || !oe && !G)
|
|
4400
4404
|
return [];
|
|
4401
4405
|
const v = f.at(-1);
|
|
4402
|
-
return !v || v.role !== "assistant" ? [] :
|
|
4406
|
+
return !v || v.role !== "assistant" ? [] : gr(pt(v.parts), {
|
|
4403
4407
|
toolActivity: it,
|
|
4404
4408
|
reasoning: ot
|
|
4405
4409
|
});
|
|
4406
4410
|
}, [
|
|
4407
4411
|
f,
|
|
4408
4412
|
m,
|
|
4409
|
-
|
|
4413
|
+
oe,
|
|
4410
4414
|
G,
|
|
4411
4415
|
it,
|
|
4412
4416
|
ot,
|
|
4413
4417
|
He,
|
|
4414
|
-
|
|
4415
|
-
]),
|
|
4416
|
-
() => He ?
|
|
4417
|
-
const E =
|
|
4418
|
+
me
|
|
4419
|
+
]), On = X(
|
|
4420
|
+
() => He ? Ee.flatMap((v) => {
|
|
4421
|
+
const E = gr(v.items, {
|
|
4418
4422
|
toolActivity: it,
|
|
4419
4423
|
reasoning: ot
|
|
4420
4424
|
});
|
|
4421
4425
|
return E.length === 0 ? [] : [E === v.items ? v : { ...v, items: E }];
|
|
4422
4426
|
}) : [],
|
|
4423
|
-
[
|
|
4424
|
-
),
|
|
4427
|
+
[Ee, it, ot, He]
|
|
4428
|
+
), Nn = X(
|
|
4425
4429
|
() => j.current.items.filter((v) => !v.input.background).map((v) => v.userMessage),
|
|
4426
4430
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- queueRef is mutable; queueVersion is the signal
|
|
4427
|
-
[
|
|
4431
|
+
[ve]
|
|
4428
4432
|
);
|
|
4429
4433
|
return {
|
|
4430
|
-
isStreaming:
|
|
4434
|
+
isStreaming: oe,
|
|
4431
4435
|
liveItems: Pn,
|
|
4432
4436
|
/** Finished turns' render sources — see `TurnRenderSource`. */
|
|
4433
|
-
turnSources:
|
|
4437
|
+
turnSources: On,
|
|
4434
4438
|
/** The live turn's node key (stable through the retained promotion). */
|
|
4435
|
-
liveTurnKey:
|
|
4439
|
+
liveTurnKey: me,
|
|
4436
4440
|
/** The last turn failed — the transcript renders a visible error row. */
|
|
4437
4441
|
turnFailed: N !== void 0,
|
|
4438
|
-
retryFailedTurn:
|
|
4442
|
+
retryFailedTurn: wn,
|
|
4439
4443
|
resumeInterruptedTurn: _t,
|
|
4440
|
-
queuedUserMessages:
|
|
4441
|
-
removeQueued:
|
|
4442
|
-
stop:
|
|
4443
|
-
pageEffects:
|
|
4444
|
+
queuedUserMessages: Nn,
|
|
4445
|
+
removeQueued: An,
|
|
4446
|
+
stop: xn,
|
|
4447
|
+
pageEffects: Mn,
|
|
4444
4448
|
replyToPageCall: xt,
|
|
4445
|
-
pendingPageAction:
|
|
4446
|
-
requestPageActionConsent:
|
|
4449
|
+
pendingPageAction: _n,
|
|
4450
|
+
requestPageActionConsent: Rn,
|
|
4447
4451
|
resolvePageAction: Mt,
|
|
4448
|
-
handledConnectionRequestIds:
|
|
4452
|
+
handledConnectionRequestIds: ie,
|
|
4449
4453
|
sourceSessionId: He ? r : null
|
|
4450
4454
|
};
|
|
4451
4455
|
}
|
|
4452
|
-
function
|
|
4456
|
+
function Bi(t) {
|
|
4453
4457
|
return t ? { ...t, initialMessages: [] } : null;
|
|
4454
4458
|
}
|
|
4455
|
-
const
|
|
4459
|
+
const Cr = 2e3, wr = 6e5, Wi = 1e4, bt = Ye(null), Ji = (t, e) => e === "dismiss" ? {
|
|
4456
4460
|
content: `Continue without connecting ${t.name}.`,
|
|
4457
4461
|
connectionRequestId: t.request_id
|
|
4458
4462
|
} : e === "renew" ? {
|
|
@@ -4468,7 +4472,7 @@ const Er = 2e3, Cr = 6e5, Vi = 1e4, bt = Ye(null), Bi = (t, e) => e === "dismiss
|
|
|
4468
4472
|
connectionRequestId: t.request_id,
|
|
4469
4473
|
content: `The connection to ${t.name} is ready. Please use its tools to continue my previous request.`
|
|
4470
4474
|
};
|
|
4471
|
-
function
|
|
4475
|
+
function Yi({
|
|
4472
4476
|
children: t,
|
|
4473
4477
|
request: e,
|
|
4474
4478
|
widgetCtx: r,
|
|
@@ -4476,25 +4480,25 @@ function Wi({
|
|
|
4476
4480
|
}) {
|
|
4477
4481
|
const [s, o] = J("idle"), [l, u] = J(null), [y, g] = J(
|
|
4478
4482
|
null
|
|
4479
|
-
), [i, d] = J(null), p =
|
|
4483
|
+
), [i, d] = J(null), p = R(new AbortController()), b = R(null), P = R(/* @__PURE__ */ new Set()), M = R(null), O = R(null), x = R(null), w = R(!0), I = R((e == null ? void 0 : e.request_id) ?? null);
|
|
4480
4484
|
I.current = (e == null ? void 0 : e.request_id) ?? null;
|
|
4481
|
-
const C =
|
|
4485
|
+
const C = z(() => {
|
|
4482
4486
|
var D;
|
|
4483
4487
|
p.current.abort(), (D = b.current) == null || D.close(), b.current = null;
|
|
4484
4488
|
}, []);
|
|
4485
|
-
F(() => (C(),
|
|
4489
|
+
F(() => (C(), x.current = null, O.current = null, M.current = null, o("idle"), u(null), g(null), d(null), C), [C, e == null ? void 0 : e.request_id, e == null ? void 0 : e.server_id, r]), F(() => (w.current = !0, () => {
|
|
4486
4490
|
w.current = !1, C();
|
|
4487
4491
|
}), [C]);
|
|
4488
|
-
const c =
|
|
4492
|
+
const c = z(
|
|
4489
4493
|
async (D) => {
|
|
4490
4494
|
if (!e) return;
|
|
4491
4495
|
const B = e.request_id;
|
|
4492
|
-
if (
|
|
4493
|
-
|
|
4496
|
+
if (P.current.has(B)) return;
|
|
4497
|
+
P.current.add(B), M.current = D, g(D), d(null);
|
|
4494
4498
|
let W = !1;
|
|
4495
4499
|
try {
|
|
4496
4500
|
await r.messageCtx.sendMessage({
|
|
4497
|
-
...
|
|
4501
|
+
...Ji(e, D),
|
|
4498
4502
|
onAccepted: () => {
|
|
4499
4503
|
W = !0, n(e.request_id);
|
|
4500
4504
|
}
|
|
@@ -4506,14 +4510,14 @@ function Wi({
|
|
|
4506
4510
|
D === "renew" ? "Could not request a new connection. Try again." : "Could not continue your request. Try again."
|
|
4507
4511
|
);
|
|
4508
4512
|
} finally {
|
|
4509
|
-
|
|
4513
|
+
P.current.delete(B), w.current && I.current === B && g(null);
|
|
4510
4514
|
}
|
|
4511
4515
|
},
|
|
4512
4516
|
[n, e, r]
|
|
4513
|
-
), m =
|
|
4517
|
+
), m = z(async () => {
|
|
4514
4518
|
var B, W;
|
|
4515
4519
|
if (!e) return;
|
|
4516
|
-
C(),
|
|
4520
|
+
C(), x.current = e.request_id, p.current = new AbortController();
|
|
4517
4521
|
const { signal: D } = p.current;
|
|
4518
4522
|
o("loading"), M.current = null, u(null), d(null);
|
|
4519
4523
|
try {
|
|
@@ -4524,18 +4528,18 @@ function Wi({
|
|
|
4524
4528
|
D
|
|
4525
4529
|
);
|
|
4526
4530
|
if (D.aborted) return;
|
|
4527
|
-
const
|
|
4528
|
-
if (!(
|
|
4531
|
+
const $ = new URL(j.authorization_url);
|
|
4532
|
+
if (!($.protocol === "https:" || $.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes($.hostname)) || $.username || $.password)
|
|
4529
4533
|
throw new Error("Invalid connection page");
|
|
4530
4534
|
u({
|
|
4531
|
-
url:
|
|
4532
|
-
host:
|
|
4535
|
+
url: $.href,
|
|
4536
|
+
host: $.host,
|
|
4533
4537
|
completion: j.completion,
|
|
4534
4538
|
...j.completion === "oauth" ? { attemptId: j.attempt_id } : {}
|
|
4535
|
-
}), O.current = Date.now() +
|
|
4539
|
+
}), O.current = Date.now() + wr, (B = b.current) != null && B.closed ? (b.current = null, o("ready")) : b.current ? (b.current.location.replace($.href), o("waiting")) : o("ready");
|
|
4536
4540
|
} catch (j) {
|
|
4537
4541
|
if (D.aborted) return;
|
|
4538
|
-
if ((W = b.current) == null || W.close(), b.current = null, u(null), o("idle"), j instanceof
|
|
4542
|
+
if ((W = b.current) == null || W.close(), b.current = null, u(null), o("idle"), j instanceof zn) {
|
|
4539
4543
|
await c("renew");
|
|
4540
4544
|
return;
|
|
4541
4545
|
}
|
|
@@ -4549,35 +4553,35 @@ function Wi({
|
|
|
4549
4553
|
return;
|
|
4550
4554
|
const D = new AbortController();
|
|
4551
4555
|
let B;
|
|
4552
|
-
const W = O.current ?? Date.now() +
|
|
4556
|
+
const W = O.current ?? Date.now() + wr;
|
|
4553
4557
|
O.current = W;
|
|
4554
|
-
let j = 0,
|
|
4555
|
-
const
|
|
4556
|
-
|
|
4557
|
-
},
|
|
4558
|
-
|
|
4559
|
-
},
|
|
4560
|
-
window.addEventListener("blur",
|
|
4558
|
+
let j = 0, $ = document.hidden || !document.hasFocus(), Se = !1;
|
|
4559
|
+
const Ie = () => {
|
|
4560
|
+
$ = !0;
|
|
4561
|
+
}, ve = () => {
|
|
4562
|
+
$ && (Se = !0);
|
|
4563
|
+
}, ae = () => document.hidden ? Ie() : ve();
|
|
4564
|
+
window.addEventListener("blur", Ie), window.addEventListener("focus", ve), document.addEventListener("visibilitychange", ae);
|
|
4561
4565
|
const G = (U) => {
|
|
4562
|
-
var
|
|
4563
|
-
D.abort(), (
|
|
4564
|
-
},
|
|
4566
|
+
var ie;
|
|
4567
|
+
D.abort(), (ie = b.current) == null || ie.close(), b.current = null, d(U), o("idle");
|
|
4568
|
+
}, de = setTimeout(
|
|
4565
4569
|
() => G("Connection timed out. Try again."),
|
|
4566
4570
|
Math.max(0, W - Date.now())
|
|
4567
|
-
),
|
|
4568
|
-
B = setTimeout(
|
|
4569
|
-
},
|
|
4570
|
-
var U,
|
|
4571
|
+
), fe = (U = Cr) => {
|
|
4572
|
+
B = setTimeout(Ee, U);
|
|
4573
|
+
}, Ee = async () => {
|
|
4574
|
+
var U, ie, Ce;
|
|
4571
4575
|
if (Date.now() >= W) {
|
|
4572
4576
|
G("Connection timed out. Try again.");
|
|
4573
4577
|
return;
|
|
4574
4578
|
}
|
|
4575
4579
|
if (l.completion === "external") {
|
|
4576
|
-
if (s === "waiting" && ((U = b.current) != null && U.closed ||
|
|
4580
|
+
if (s === "waiting" && ((U = b.current) != null && U.closed || Se)) {
|
|
4577
4581
|
o("external");
|
|
4578
4582
|
return;
|
|
4579
4583
|
}
|
|
4580
|
-
|
|
4584
|
+
fe();
|
|
4581
4585
|
return;
|
|
4582
4586
|
}
|
|
4583
4587
|
if (!l.attemptId) {
|
|
@@ -4585,52 +4589,52 @@ function Wi({
|
|
|
4585
4589
|
return;
|
|
4586
4590
|
}
|
|
4587
4591
|
try {
|
|
4588
|
-
const
|
|
4592
|
+
const me = await r.api.getConnectionAttempt(
|
|
4589
4593
|
e.server_id,
|
|
4590
4594
|
l.attemptId,
|
|
4591
4595
|
D.signal
|
|
4592
4596
|
);
|
|
4593
4597
|
if (D.signal.aborted) return;
|
|
4594
|
-
if (j = 0,
|
|
4595
|
-
(
|
|
4598
|
+
if (j = 0, me === "connected") {
|
|
4599
|
+
(ie = b.current) == null || ie.close(), b.current = null, o("connected");
|
|
4596
4600
|
return;
|
|
4597
4601
|
}
|
|
4598
|
-
if (
|
|
4602
|
+
if (me === "canceled") {
|
|
4599
4603
|
G("Connection was canceled. Try again.");
|
|
4600
4604
|
return;
|
|
4601
4605
|
}
|
|
4602
|
-
if (
|
|
4606
|
+
if (me === "failed") {
|
|
4603
4607
|
G("Connection approval failed. Try again.");
|
|
4604
4608
|
return;
|
|
4605
4609
|
}
|
|
4606
|
-
if (
|
|
4610
|
+
if (me === "expired") {
|
|
4607
4611
|
G("Connection attempt expired. Try again.");
|
|
4608
4612
|
return;
|
|
4609
4613
|
}
|
|
4610
|
-
(
|
|
4611
|
-
} catch (
|
|
4614
|
+
(Ce = b.current) != null && Ce.closed && (b.current = null, o("ready")), fe();
|
|
4615
|
+
} catch (me) {
|
|
4612
4616
|
if (D.signal.aborted) return;
|
|
4613
|
-
if (
|
|
4614
|
-
G(
|
|
4617
|
+
if (me instanceof Zn) {
|
|
4618
|
+
G(me.message);
|
|
4615
4619
|
return;
|
|
4616
4620
|
}
|
|
4617
|
-
j += 1,
|
|
4621
|
+
j += 1, fe(
|
|
4618
4622
|
Math.min(
|
|
4619
|
-
|
|
4620
|
-
|
|
4623
|
+
Cr * 2 ** (j - 1),
|
|
4624
|
+
Wi
|
|
4621
4625
|
)
|
|
4622
4626
|
);
|
|
4623
4627
|
}
|
|
4624
4628
|
};
|
|
4625
|
-
return
|
|
4626
|
-
D.abort(), B && clearTimeout(B),
|
|
4629
|
+
return Ee(), () => {
|
|
4630
|
+
D.abort(), B && clearTimeout(B), de && clearTimeout(de), window.removeEventListener("blur", Ie), window.removeEventListener("focus", ve), document.removeEventListener("visibilitychange", ae);
|
|
4627
4631
|
};
|
|
4628
4632
|
}, [l, s, e, r]), F(() => {
|
|
4629
|
-
s !== "connected" && s !== "external" ||
|
|
4633
|
+
s !== "connected" && s !== "external" || x.current !== (e == null ? void 0 : e.request_id) || c(s === "external" ? "external" : "resume");
|
|
4630
4634
|
}, [s, e == null ? void 0 : e.request_id, c]);
|
|
4631
|
-
const f =
|
|
4635
|
+
const f = z(() => o("waiting"), []), h = z(async () => {
|
|
4632
4636
|
C(), u(null), o("idle"), await c("dismiss");
|
|
4633
|
-
}, [C, c]), S =
|
|
4637
|
+
}, [C, c]), S = z(async () => {
|
|
4634
4638
|
const D = M.current;
|
|
4635
4639
|
if (D) {
|
|
4636
4640
|
await c(D);
|
|
@@ -4661,7 +4665,7 @@ function Wi({
|
|
|
4661
4665
|
m
|
|
4662
4666
|
]
|
|
4663
4667
|
);
|
|
4664
|
-
return
|
|
4668
|
+
return Y.createElement(
|
|
4665
4669
|
bt.Provider,
|
|
4666
4670
|
{
|
|
4667
4671
|
value: N
|
|
@@ -4669,21 +4673,21 @@ function Wi({
|
|
|
4669
4673
|
t
|
|
4670
4674
|
);
|
|
4671
4675
|
}
|
|
4672
|
-
function
|
|
4676
|
+
function Ki({
|
|
4673
4677
|
children: t,
|
|
4674
4678
|
connection: e
|
|
4675
4679
|
}) {
|
|
4676
|
-
return
|
|
4680
|
+
return Y.createElement(
|
|
4677
4681
|
bt.Provider,
|
|
4678
4682
|
{ value: e },
|
|
4679
4683
|
t
|
|
4680
4684
|
);
|
|
4681
4685
|
}
|
|
4682
|
-
function
|
|
4683
|
-
return
|
|
4686
|
+
function Hi() {
|
|
4687
|
+
return Fe(bt);
|
|
4684
4688
|
}
|
|
4685
|
-
function
|
|
4686
|
-
const e =
|
|
4689
|
+
function To(t) {
|
|
4690
|
+
const e = Fe(bt);
|
|
4687
4691
|
if (!e || e.request.request_id !== t.request_id)
|
|
4688
4692
|
throw new Error(
|
|
4689
4693
|
"useConnection must be used for the active ConnectionAttemptProvider request"
|
|
@@ -4715,15 +4719,15 @@ const Bt = {
|
|
|
4715
4719
|
pendingClarification: null,
|
|
4716
4720
|
pendingConnection: null
|
|
4717
4721
|
}, St = Ye(null);
|
|
4718
|
-
function
|
|
4719
|
-
return
|
|
4722
|
+
function pn() {
|
|
4723
|
+
return Fe(St) ?? Bt;
|
|
4720
4724
|
}
|
|
4721
|
-
function
|
|
4725
|
+
function Gi({
|
|
4722
4726
|
children: t,
|
|
4723
4727
|
widgetCtx: e,
|
|
4724
4728
|
config: r
|
|
4725
4729
|
}) {
|
|
4726
|
-
var
|
|
4730
|
+
var ve, ae, G, de, fe, Ee;
|
|
4727
4731
|
const n = H(e.sessionCtx.sessionState), s = H(e.messageCtx.state), {
|
|
4728
4732
|
isStreaming: o,
|
|
4729
4733
|
liveItems: l,
|
|
@@ -4734,33 +4738,33 @@ function Ki({
|
|
|
4734
4738
|
resumeInterruptedTurn: d,
|
|
4735
4739
|
queuedUserMessages: p,
|
|
4736
4740
|
removeQueued: b,
|
|
4737
|
-
stop:
|
|
4741
|
+
stop: P,
|
|
4738
4742
|
pageEffects: M,
|
|
4739
4743
|
replyToPageCall: O,
|
|
4740
|
-
pendingPageAction:
|
|
4744
|
+
pendingPageAction: x,
|
|
4741
4745
|
requestPageActionConsent: w,
|
|
4742
4746
|
resolvePageAction: I,
|
|
4743
4747
|
handledConnectionRequestIds: C,
|
|
4744
4748
|
sourceSessionId: c
|
|
4745
|
-
} =
|
|
4749
|
+
} = Vi({
|
|
4746
4750
|
widgetCtx: e,
|
|
4747
4751
|
config: r,
|
|
4748
|
-
sessionId: ((
|
|
4752
|
+
sessionId: ((ve = n.session) == null ? void 0 : ve.id) ?? null,
|
|
4749
4753
|
persistedMessages: s.messages
|
|
4750
|
-
}), m = ((
|
|
4754
|
+
}), m = ((ae = s.messages.at(-1)) == null ? void 0 : ae.type) === "USER", f = R(/* @__PURE__ */ new Set()), h = R(((G = n.session) == null ? void 0 : G.id) ?? null), S = ((de = n.session) == null ? void 0 : de.id) ?? null;
|
|
4751
4755
|
h.current !== S && (h.current = S, f.current.clear()), C.forEach(
|
|
4752
4756
|
(U) => f.current.add(U)
|
|
4753
4757
|
);
|
|
4754
|
-
const N = (
|
|
4758
|
+
const N = (fe = [
|
|
4755
4759
|
...u.flatMap((U) => U.items),
|
|
4756
4760
|
...l
|
|
4757
4761
|
].findLast(
|
|
4758
4762
|
(U) => U.kind === "connection" && !f.current.has(U.request.request_id)
|
|
4759
|
-
)) == null ? void 0 :
|
|
4763
|
+
)) == null ? void 0 : fe.request, [D, B] = J({ sessionId: S, request: null }), W = ((Ee = r.capabilities) == null ? void 0 : Ee.connections) === !0, j = W && S !== null && D.sessionId === S ? D.request : null;
|
|
4760
4764
|
F(() => {
|
|
4761
4765
|
!W || S === null || c !== S || B((U) => {
|
|
4762
|
-
const
|
|
4763
|
-
return U.sessionId === S && U.request ===
|
|
4766
|
+
const ie = U.sessionId === S && U.request && !f.current.has(U.request.request_id) ? U.request : N ?? null;
|
|
4767
|
+
return U.sessionId === S && U.request === ie ? U : { sessionId: S, request: ie };
|
|
4764
4768
|
});
|
|
4765
4769
|
}, [
|
|
4766
4770
|
S,
|
|
@@ -4770,14 +4774,14 @@ function Ki({
|
|
|
4770
4774
|
W,
|
|
4771
4775
|
j
|
|
4772
4776
|
]);
|
|
4773
|
-
const
|
|
4777
|
+
const $ = z((U) => {
|
|
4774
4778
|
f.current.add(U), B(
|
|
4775
|
-
(
|
|
4776
|
-
var
|
|
4777
|
-
return ((
|
|
4779
|
+
(ie) => {
|
|
4780
|
+
var Ce;
|
|
4781
|
+
return ((Ce = ie.request) == null ? void 0 : Ce.request_id) === U ? { ...ie, request: null } : ie;
|
|
4778
4782
|
}
|
|
4779
4783
|
);
|
|
4780
|
-
}, []),
|
|
4784
|
+
}, []), Se = X(
|
|
4781
4785
|
() => ({
|
|
4782
4786
|
isStreaming: o,
|
|
4783
4787
|
liveItems: l,
|
|
@@ -4788,14 +4792,14 @@ function Ki({
|
|
|
4788
4792
|
resumeInterruptedTurn: d,
|
|
4789
4793
|
queuedUserMessages: p,
|
|
4790
4794
|
removeQueued: b,
|
|
4791
|
-
stop:
|
|
4795
|
+
stop: P,
|
|
4792
4796
|
pageEffects: M,
|
|
4793
4797
|
replyToPageCall: O,
|
|
4794
|
-
pendingPageAction:
|
|
4798
|
+
pendingPageAction: x,
|
|
4795
4799
|
requestPageActionConsent: w,
|
|
4796
4800
|
resolvePageAction: I,
|
|
4797
4801
|
pendingConnection: j,
|
|
4798
|
-
pendingClarification:
|
|
4802
|
+
pendingClarification: ms({
|
|
4799
4803
|
turnSources: u,
|
|
4800
4804
|
liveItems: l,
|
|
4801
4805
|
isStreaming: o,
|
|
@@ -4812,34 +4816,34 @@ function Ki({
|
|
|
4812
4816
|
d,
|
|
4813
4817
|
p,
|
|
4814
4818
|
b,
|
|
4815
|
-
|
|
4819
|
+
P,
|
|
4816
4820
|
M,
|
|
4817
4821
|
O,
|
|
4818
|
-
|
|
4822
|
+
x,
|
|
4819
4823
|
w,
|
|
4820
4824
|
I,
|
|
4821
4825
|
m,
|
|
4822
4826
|
j
|
|
4823
4827
|
]
|
|
4824
|
-
),
|
|
4825
|
-
return /* @__PURE__ */
|
|
4826
|
-
|
|
4828
|
+
), Ie = /* @__PURE__ */ Y.createElement(St.Provider, { value: Se }, t);
|
|
4829
|
+
return /* @__PURE__ */ Y.createElement(
|
|
4830
|
+
Yi,
|
|
4827
4831
|
{
|
|
4828
4832
|
request: j,
|
|
4829
4833
|
widgetCtx: e,
|
|
4830
|
-
onHandled:
|
|
4834
|
+
onHandled: $
|
|
4831
4835
|
},
|
|
4832
|
-
|
|
4836
|
+
Ie
|
|
4833
4837
|
);
|
|
4834
4838
|
}
|
|
4835
|
-
function
|
|
4839
|
+
function fn({
|
|
4836
4840
|
children: t,
|
|
4837
4841
|
widgetCtx: e,
|
|
4838
4842
|
config: r
|
|
4839
4843
|
}) {
|
|
4840
|
-
return H(e.messageCtx.state), e.streaming ? /* @__PURE__ */
|
|
4844
|
+
return H(e.messageCtx.state), e.streaming ? /* @__PURE__ */ Y.createElement(Gi, { widgetCtx: e, config: r }, t) : /* @__PURE__ */ Y.createElement(St.Provider, { value: Bt }, t);
|
|
4841
4845
|
}
|
|
4842
|
-
class
|
|
4846
|
+
class Qi {
|
|
4843
4847
|
constructor(e) {
|
|
4844
4848
|
this.root = e, this.nextId = 1, this.mountVersion = 0, this.disposed = !1, this.mount = () => {
|
|
4845
4849
|
const n = ++this.mountVersion;
|
|
@@ -4912,7 +4916,7 @@ class Hi {
|
|
|
4912
4916
|
});
|
|
4913
4917
|
};
|
|
4914
4918
|
const r = this.makeChat(e);
|
|
4915
|
-
this.state = new
|
|
4919
|
+
this.state = new _r({ chats: [r], activeId: r.id });
|
|
4916
4920
|
}
|
|
4917
4921
|
makeChat(e) {
|
|
4918
4922
|
return {
|
|
@@ -4937,15 +4941,15 @@ class Hi {
|
|
|
4937
4941
|
return !e.closed && !r && !this.isWorking(e) && !e.ctx.messageCtx.state.get().messages.length && !n && !s.length && !e.ctx.uploadCtx.state.get().length;
|
|
4938
4942
|
}
|
|
4939
4943
|
}
|
|
4940
|
-
const
|
|
4941
|
-
function
|
|
4942
|
-
const t =
|
|
4944
|
+
const mn = Ye(null), Xi = new _r({ chats: [], activeId: 0 });
|
|
4945
|
+
function gn() {
|
|
4946
|
+
const t = Fe(mn), e = H((t == null ? void 0 : t.state) ?? Xi), r = e.chats.filter((s) => !s.closed), n = r.filter(
|
|
4943
4947
|
(s) => s.hasSession || s.working || s.hasDraft || s.title
|
|
4944
4948
|
);
|
|
4945
4949
|
return { workspace: t, chats: r, openChats: n, activeId: e.activeId };
|
|
4946
4950
|
}
|
|
4947
|
-
function
|
|
4948
|
-
const { workspace: t, ...e } =
|
|
4951
|
+
function Mo() {
|
|
4952
|
+
const { workspace: t, ...e } = gn();
|
|
4949
4953
|
if (!t)
|
|
4950
4954
|
throw new Error("Companion chats require a conversation workspace");
|
|
4951
4955
|
return {
|
|
@@ -4955,13 +4959,13 @@ function xo() {
|
|
|
4955
4959
|
newChat: t.open
|
|
4956
4960
|
};
|
|
4957
4961
|
}
|
|
4958
|
-
function
|
|
4962
|
+
function eo({
|
|
4959
4963
|
chatId: t,
|
|
4960
4964
|
ctx: e,
|
|
4961
4965
|
workspace: r
|
|
4962
4966
|
}) {
|
|
4963
|
-
const n =
|
|
4964
|
-
(
|
|
4967
|
+
const n = pn(), s = Hi(), o = H(e.messageCtx.state), l = H(e.sessionCtx.sessionState), u = H(e.messageCtx.draftState), y = H(e.uploadCtx.state), g = o.messages.find(
|
|
4968
|
+
(P) => P.type === "USER"
|
|
4965
4969
|
), i = (g == null ? void 0 : g.type) === "USER" ? g.content.slice(0, 60) : "", d = n.isStreaming || o.isSendingMessage || l.isCreatingSession, p = !!l.session, b = !!u.text || u.mentions.length > 0 || y.length > 0;
|
|
4966
4970
|
return F(
|
|
4967
4971
|
() => r.update(t, {
|
|
@@ -4975,27 +4979,27 @@ function Qi({
|
|
|
4975
4979
|
[r, t, i, d, p, b, n, s]
|
|
4976
4980
|
), null;
|
|
4977
4981
|
}
|
|
4978
|
-
const
|
|
4982
|
+
const to = jn(function({
|
|
4979
4983
|
chatId: e,
|
|
4980
4984
|
ctx: r,
|
|
4981
4985
|
config: n,
|
|
4982
4986
|
workspace: s
|
|
4983
4987
|
}) {
|
|
4984
|
-
return /* @__PURE__ */
|
|
4988
|
+
return /* @__PURE__ */ Y.createElement(fn, { widgetCtx: r, config: n }, /* @__PURE__ */ Y.createElement(eo, { chatId: e, ctx: r, workspace: s }));
|
|
4985
4989
|
});
|
|
4986
|
-
function
|
|
4990
|
+
function ro({
|
|
4987
4991
|
widgetCtx: t,
|
|
4988
4992
|
config: e = t.config,
|
|
4989
4993
|
children: r
|
|
4990
4994
|
}) {
|
|
4991
4995
|
const n = X(
|
|
4992
|
-
() => new
|
|
4996
|
+
() => new Qi(t),
|
|
4993
4997
|
[t]
|
|
4994
4998
|
);
|
|
4995
4999
|
F(() => n.mount(), [n]);
|
|
4996
5000
|
const { chats: s, activeId: o } = H(n.state), l = s.find((y) => y.id === o), u = X(
|
|
4997
|
-
() => s.map((y) => /* @__PURE__ */
|
|
4998
|
-
|
|
5001
|
+
() => s.map((y) => /* @__PURE__ */ Y.createElement(
|
|
5002
|
+
to,
|
|
4999
5003
|
{
|
|
5000
5004
|
key: y.id,
|
|
5001
5005
|
chatId: y.id,
|
|
@@ -5006,9 +5010,9 @@ function eo({
|
|
|
5006
5010
|
)),
|
|
5007
5011
|
[s, e, n]
|
|
5008
5012
|
);
|
|
5009
|
-
return /* @__PURE__ */
|
|
5013
|
+
return /* @__PURE__ */ Y.createElement(mn.Provider, { value: n }, u, /* @__PURE__ */ Y.createElement(Ki, { connection: l.connection }, /* @__PURE__ */ Y.createElement(St.Provider, { value: l.ui }, r(l.ctx))));
|
|
5010
5014
|
}
|
|
5011
|
-
class
|
|
5015
|
+
class no {
|
|
5012
5016
|
constructor(e) {
|
|
5013
5017
|
this.components = [];
|
|
5014
5018
|
const { components: r } = e;
|
|
@@ -5034,22 +5038,22 @@ class to {
|
|
|
5034
5038
|
return (r = this.get(e)) == null ? void 0 : r.component;
|
|
5035
5039
|
}
|
|
5036
5040
|
}
|
|
5037
|
-
const
|
|
5041
|
+
const Ar = L.object({
|
|
5038
5042
|
org_id: L.string(),
|
|
5039
5043
|
contact: L.object({ id: L.string(), verified: L.boolean() }),
|
|
5040
5044
|
mcp_access: L.object({
|
|
5041
5045
|
server_ids: L.array(L.string()),
|
|
5042
5046
|
account_id: L.string().optional()
|
|
5043
5047
|
}).optional()
|
|
5044
|
-
}),
|
|
5048
|
+
}), so = L.union([
|
|
5045
5049
|
L.object({
|
|
5046
5050
|
sub: L.object({
|
|
5047
5051
|
type: L.literal("widget-contact"),
|
|
5048
|
-
payload:
|
|
5052
|
+
payload: Ar
|
|
5049
5053
|
})
|
|
5050
5054
|
}).transform(({ sub: t }) => t.payload),
|
|
5051
|
-
|
|
5052
|
-
]),
|
|
5055
|
+
Ar
|
|
5056
|
+
]), ao = (t) => {
|
|
5053
5057
|
const e = t.split(".")[1];
|
|
5054
5058
|
if (!e) return null;
|
|
5055
5059
|
try {
|
|
@@ -5061,7 +5065,7 @@ const wr = L.object({
|
|
|
5061
5065
|
} catch {
|
|
5062
5066
|
return null;
|
|
5063
5067
|
}
|
|
5064
|
-
},
|
|
5068
|
+
}, io = (t) => {
|
|
5065
5069
|
var s, o;
|
|
5066
5070
|
const e = t.user, r = e == null ? void 0 : e.token;
|
|
5067
5071
|
if (!r)
|
|
@@ -5071,7 +5075,7 @@ const wr = L.object({
|
|
|
5071
5075
|
externalId: (e == null ? void 0 : e.externalId) ?? null,
|
|
5072
5076
|
verifiedOwner: null
|
|
5073
5077
|
});
|
|
5074
|
-
const n =
|
|
5078
|
+
const n = so.safeParse(ao(r));
|
|
5075
5079
|
return n.success ? JSON.stringify({
|
|
5076
5080
|
apiUrl: t.apiUrl ?? null,
|
|
5077
5081
|
botToken: t.token,
|
|
@@ -5089,8 +5093,8 @@ const wr = L.object({
|
|
|
5089
5093
|
externalId: e.externalId ?? null,
|
|
5090
5094
|
opaqueToken: r
|
|
5091
5095
|
});
|
|
5092
|
-
},
|
|
5093
|
-
function
|
|
5096
|
+
}, hn = Ye(null);
|
|
5097
|
+
function _o({
|
|
5094
5098
|
options: t,
|
|
5095
5099
|
children: e,
|
|
5096
5100
|
components: r,
|
|
@@ -5098,11 +5102,11 @@ function To({
|
|
|
5098
5102
|
loadingComponent: s,
|
|
5099
5103
|
errorComponent: o
|
|
5100
5104
|
}) {
|
|
5101
|
-
var
|
|
5102
|
-
const l =
|
|
5105
|
+
var x;
|
|
5106
|
+
const l = R(Promise.resolve()), u = R(t);
|
|
5103
5107
|
u.current = t;
|
|
5104
|
-
const y =
|
|
5105
|
-
() => new
|
|
5108
|
+
const y = io(t), g = R(null), i = R(null), d = R(null), [p, b] = J({ status: "loading" }), P = X(
|
|
5109
|
+
() => new no({
|
|
5106
5110
|
components: r
|
|
5107
5111
|
}),
|
|
5108
5112
|
[r]
|
|
@@ -5121,7 +5125,7 @@ function To({
|
|
|
5121
5125
|
((m = i.current) == null ? void 0 : m.identity) !== y && (b({ status: "loading" }), i.current = {
|
|
5122
5126
|
identity: y,
|
|
5123
5127
|
request: l.current.then(
|
|
5124
|
-
() =>
|
|
5128
|
+
() => Vn.initialize({
|
|
5125
5129
|
config: t,
|
|
5126
5130
|
storage: n,
|
|
5127
5131
|
getClientCapabilities: () => u.current.capabilities,
|
|
@@ -5147,7 +5151,7 @@ function To({
|
|
|
5147
5151
|
var S;
|
|
5148
5152
|
if (((S = i.current) == null ? void 0 : S.request) !== w) return;
|
|
5149
5153
|
const h = f instanceof Error ? f : new Error("Widget initialization failed", { cause: f });
|
|
5150
|
-
|
|
5154
|
+
le.error("widget initialization failed", h), b({
|
|
5151
5155
|
status: "error",
|
|
5152
5156
|
identity: I,
|
|
5153
5157
|
error: h
|
|
@@ -5160,39 +5164,39 @@ function To({
|
|
|
5160
5164
|
i.current = null, (w = d.current) == null || w.widgetCtx.dispose(), d.current = null;
|
|
5161
5165
|
},
|
|
5162
5166
|
[]
|
|
5163
|
-
),
|
|
5167
|
+
), kn(() => {
|
|
5164
5168
|
var w;
|
|
5165
5169
|
p.status !== "ready" || p.identity !== y || (w = t.user) != null && w.token && p.widgetCtx.api.setAuthToken(t.user.token);
|
|
5166
|
-
}, [(
|
|
5167
|
-
return s ? /* @__PURE__ */
|
|
5170
|
+
}, [(x = t.user) == null ? void 0 : x.token, y, p]), p.status === "loading" || "identity" in p && p.identity !== y)
|
|
5171
|
+
return s ? /* @__PURE__ */ Y.createElement(Y.Fragment, null, s) : null;
|
|
5168
5172
|
if (p.status === "error")
|
|
5169
|
-
return o ? /* @__PURE__ */
|
|
5170
|
-
const { widgetCtx: M } = p, O = (w, I) => /* @__PURE__ */
|
|
5171
|
-
|
|
5173
|
+
return o ? /* @__PURE__ */ Y.createElement(Y.Fragment, null, o(p.error)) : null;
|
|
5174
|
+
const { widgetCtx: M } = p, O = (w, I) => /* @__PURE__ */ Y.createElement(
|
|
5175
|
+
hn.Provider,
|
|
5172
5176
|
{
|
|
5173
5177
|
value: {
|
|
5174
5178
|
widgetCtx: w,
|
|
5175
5179
|
config: t,
|
|
5176
5180
|
components: r,
|
|
5177
|
-
componentStore:
|
|
5178
|
-
version:
|
|
5181
|
+
componentStore: P,
|
|
5182
|
+
version: Rr,
|
|
5179
5183
|
contentIframeRef: g
|
|
5180
5184
|
}
|
|
5181
5185
|
},
|
|
5182
5186
|
I
|
|
5183
5187
|
);
|
|
5184
|
-
return t.displayMode === "companion" && !t.inline ? /* @__PURE__ */
|
|
5188
|
+
return t.displayMode === "companion" && !t.inline ? /* @__PURE__ */ Y.createElement(ro, { widgetCtx: M, config: t }, (w) => O(w, e)) : O(
|
|
5185
5189
|
M,
|
|
5186
|
-
/* @__PURE__ */
|
|
5190
|
+
/* @__PURE__ */ Y.createElement(fn, { key: y, widgetCtx: M, config: t }, e)
|
|
5187
5191
|
);
|
|
5188
5192
|
}
|
|
5189
|
-
function
|
|
5190
|
-
const t =
|
|
5193
|
+
function se() {
|
|
5194
|
+
const t = Fe(hn);
|
|
5191
5195
|
if (!t)
|
|
5192
5196
|
throw new Error("useWidget must be used within a WidgetProvider");
|
|
5193
5197
|
return t;
|
|
5194
5198
|
}
|
|
5195
|
-
function
|
|
5199
|
+
function Ro({
|
|
5196
5200
|
liveItems: t,
|
|
5197
5201
|
turnSources: e
|
|
5198
5202
|
}) {
|
|
@@ -5206,8 +5210,8 @@ function Mo({
|
|
|
5206
5210
|
if (o) return o.plan;
|
|
5207
5211
|
}
|
|
5208
5212
|
}
|
|
5209
|
-
function
|
|
5210
|
-
const { config: t, widgetCtx: e } =
|
|
5213
|
+
function Po() {
|
|
5214
|
+
const { config: t, widgetCtx: e } = se(), { name: r, avatarUrl: n } = e.agent, s = t.bot;
|
|
5211
5215
|
return X(
|
|
5212
5216
|
() => ({
|
|
5213
5217
|
isAi: !0,
|
|
@@ -5220,21 +5224,21 @@ function _o() {
|
|
|
5220
5224
|
);
|
|
5221
5225
|
}
|
|
5222
5226
|
function It() {
|
|
5223
|
-
const { config: t } =
|
|
5227
|
+
const { config: t } = se();
|
|
5224
5228
|
return t;
|
|
5225
5229
|
}
|
|
5226
|
-
function
|
|
5227
|
-
const { config: t } =
|
|
5230
|
+
function Oo() {
|
|
5231
|
+
const { config: t } = se();
|
|
5228
5232
|
return t.displayMode ?? "popover";
|
|
5229
5233
|
}
|
|
5230
|
-
function
|
|
5231
|
-
const { widgetCtx: t } =
|
|
5234
|
+
function No() {
|
|
5235
|
+
const { widgetCtx: t } = se();
|
|
5232
5236
|
return {
|
|
5233
5237
|
contactState: H(t.contactCtx.state),
|
|
5234
5238
|
createUnverifiedContact: t.contactCtx.createUnverifiedContact
|
|
5235
5239
|
};
|
|
5236
5240
|
}
|
|
5237
|
-
function
|
|
5241
|
+
function oo() {
|
|
5238
5242
|
const [t, e] = J("ltr");
|
|
5239
5243
|
return F(() => {
|
|
5240
5244
|
const r = () => {
|
|
@@ -5255,8 +5259,8 @@ function ao() {
|
|
|
5255
5259
|
};
|
|
5256
5260
|
}, []), { dir: t };
|
|
5257
5261
|
}
|
|
5258
|
-
const
|
|
5259
|
-
function
|
|
5262
|
+
const lo = 500, kt = "opencx:context-changed";
|
|
5263
|
+
function yn() {
|
|
5260
5264
|
if (typeof window > "u") return null;
|
|
5261
5265
|
try {
|
|
5262
5266
|
const t = window.top ?? window;
|
|
@@ -5265,29 +5269,29 @@ function hn() {
|
|
|
5265
5269
|
return null;
|
|
5266
5270
|
}
|
|
5267
5271
|
}
|
|
5268
|
-
function
|
|
5269
|
-
const e =
|
|
5272
|
+
function co(t) {
|
|
5273
|
+
const e = yn();
|
|
5270
5274
|
if (!e) return () => {
|
|
5271
5275
|
};
|
|
5272
5276
|
const r = (s) => {
|
|
5273
|
-
(s == null ? void 0 : s.type) === kt && (
|
|
5277
|
+
(s == null ? void 0 : s.type) === kt && (vn += 1), t();
|
|
5274
5278
|
};
|
|
5275
5279
|
e.addEventListener("popstate", r), e.addEventListener("hashchange", r), e.addEventListener(kt, r);
|
|
5276
|
-
const n = e.setInterval(r,
|
|
5280
|
+
const n = e.setInterval(r, lo);
|
|
5277
5281
|
return () => {
|
|
5278
5282
|
e.removeEventListener("popstate", r), e.removeEventListener("hashchange", r), e.removeEventListener(kt, r), e.clearInterval(n);
|
|
5279
5283
|
};
|
|
5280
5284
|
}
|
|
5281
|
-
let
|
|
5282
|
-
function
|
|
5285
|
+
let vn = 0;
|
|
5286
|
+
function uo() {
|
|
5283
5287
|
var t;
|
|
5284
|
-
return `${
|
|
5288
|
+
return `${vn}|${((t = yn()) == null ? void 0 : t.location.href) ?? ""}`;
|
|
5285
5289
|
}
|
|
5286
|
-
function
|
|
5287
|
-
return zt(
|
|
5290
|
+
function Do() {
|
|
5291
|
+
return zt(co, uo, () => "");
|
|
5288
5292
|
}
|
|
5289
|
-
function
|
|
5290
|
-
const { widgetCtx: t } =
|
|
5293
|
+
function bn() {
|
|
5294
|
+
const { widgetCtx: t } = se(), e = H(t.messageCtx.state), { isStreaming: r } = pn();
|
|
5291
5295
|
return {
|
|
5292
5296
|
messagesState: r ? { ...e, isSendingMessage: !0, isSendingMessageToAI: !0 } : e,
|
|
5293
5297
|
sendMessage: t.messageCtx.sendMessage,
|
|
@@ -5297,12 +5301,12 @@ function vn() {
|
|
|
5297
5301
|
getSentTextHistory: t.messageCtx.getSentTextHistory
|
|
5298
5302
|
};
|
|
5299
5303
|
}
|
|
5300
|
-
function
|
|
5304
|
+
function Sn() {
|
|
5301
5305
|
var y;
|
|
5302
|
-
const { widgetCtx: t } =
|
|
5306
|
+
const { widgetCtx: t } = se(), { oneOpenSessionAllowed: e } = It(), r = H(t.sessionCtx.sessionState), n = H(t.sessionCtx.sessionsState), { openSessions: s, closedSessions: o } = X(() => ({
|
|
5303
5307
|
openSessions: n.data.filter((g) => g.isOpened === !0),
|
|
5304
5308
|
closedSessions: n.data.filter((g) => g.isOpened === !1)
|
|
5305
|
-
}), [n.data]), { workspace: l } =
|
|
5309
|
+
}), [n.data]), { workspace: l } = gn(), u = l ? l.canCreateChat() : !e || s.length === 0 && !r.isCreatingSession && !((y = r.session) != null && y.isOpened);
|
|
5306
5310
|
return {
|
|
5307
5311
|
sessionState: r,
|
|
5308
5312
|
sessionsState: n,
|
|
@@ -5314,30 +5318,30 @@ function bn() {
|
|
|
5314
5318
|
canCreateNewSession: u
|
|
5315
5319
|
};
|
|
5316
5320
|
}
|
|
5317
|
-
function
|
|
5321
|
+
function Lo() {
|
|
5318
5322
|
var l, u;
|
|
5319
|
-
const { sessionState: t } =
|
|
5323
|
+
const { sessionState: t } = Sn(), { messagesState: e } = bn(), r = ((l = t.session) == null ? void 0 : l.assignee.kind) === "ai", n = (u = e.messages) == null ? void 0 : u.at(-1), s = (n == null ? void 0 : n.type) === "USER" && n.id !== e.settledAgentUserMessageId;
|
|
5320
5324
|
return { isAwaitingBotReply: !!(e.isSendingMessageToAI || (r || t.isCreatingSession) && (e.isSendingMessage || s)) };
|
|
5321
5325
|
}
|
|
5322
|
-
function
|
|
5323
|
-
const { widgetCtx: t } =
|
|
5326
|
+
function po() {
|
|
5327
|
+
const { widgetCtx: t } = se();
|
|
5324
5328
|
return {
|
|
5325
5329
|
routerState: H(t.routerCtx.state),
|
|
5326
5330
|
toSessionsScreen: t.routerCtx.toSessionsScreen,
|
|
5327
5331
|
toChatScreen: t.routerCtx.toChatScreen
|
|
5328
5332
|
};
|
|
5329
5333
|
}
|
|
5330
|
-
function
|
|
5331
|
-
const { widgetCtx: t } =
|
|
5334
|
+
function jo() {
|
|
5335
|
+
const { widgetCtx: t } = se(), { unreadSessionIds: e, count: r } = H(
|
|
5332
5336
|
t.unreadCtx.state
|
|
5333
|
-
), n =
|
|
5337
|
+
), n = z(
|
|
5334
5338
|
(s) => e.includes(s),
|
|
5335
5339
|
[e]
|
|
5336
5340
|
);
|
|
5337
5341
|
return { count: r, hasUnread: r > 0, unreadSessionIds: e, isUnread: n };
|
|
5338
5342
|
}
|
|
5339
|
-
const
|
|
5340
|
-
function
|
|
5343
|
+
const In = Ye(null);
|
|
5344
|
+
function ko({ children: t }) {
|
|
5341
5345
|
const e = It(), [r, n] = J(() => e.inline ? !0 : e.isOpen ?? !1);
|
|
5342
5346
|
return F(() => {
|
|
5343
5347
|
n((s) => e.isOpen ?? s);
|
|
@@ -5347,25 +5351,25 @@ function Lo({ children: t }) {
|
|
|
5347
5351
|
return;
|
|
5348
5352
|
const o = setTimeout(() => n(!0), s * 1e3);
|
|
5349
5353
|
return () => clearTimeout(o);
|
|
5350
|
-
}, [e.openAfterNSeconds]), /* @__PURE__ */
|
|
5354
|
+
}, [e.openAfterNSeconds]), /* @__PURE__ */ Y.createElement(In.Provider, { value: { isOpen: r, setIsOpen: n } }, t);
|
|
5351
5355
|
}
|
|
5352
|
-
function
|
|
5353
|
-
const t =
|
|
5356
|
+
function fo() {
|
|
5357
|
+
const t = Fe(In);
|
|
5354
5358
|
if (!t)
|
|
5355
5359
|
throw new Error(
|
|
5356
5360
|
"useWidgetTrigger must be used within a WidgetTriggerProvider"
|
|
5357
5361
|
);
|
|
5358
5362
|
return t;
|
|
5359
5363
|
}
|
|
5360
|
-
const
|
|
5361
|
-
function
|
|
5364
|
+
const mo = (t) => (document.addEventListener("visibilitychange", t), () => document.removeEventListener("visibilitychange", t)), go = () => document.visibilityState !== "hidden";
|
|
5365
|
+
function $o({
|
|
5362
5366
|
transcriptVisible: t = !0
|
|
5363
5367
|
} = {}) {
|
|
5364
|
-
const { widgetCtx: e } =
|
|
5368
|
+
const { widgetCtx: e } = se(), { isOpen: r } = fo(), { routerState: n } = po(), { session: s } = H(e.sessionCtx.sessionState), { isInitialFetchLoading: o } = H(
|
|
5365
5369
|
e.messageCtx.state
|
|
5366
5370
|
), l = zt(
|
|
5367
|
-
|
|
5368
|
-
|
|
5371
|
+
mo,
|
|
5372
|
+
go,
|
|
5369
5373
|
() => !0
|
|
5370
5374
|
), u = r && l && t && n.screen === "chat" && !o ? (s == null ? void 0 : s.id) ?? null : null;
|
|
5371
5375
|
F(() => {
|
|
@@ -5375,10 +5379,10 @@ function jo({
|
|
|
5375
5379
|
[e]
|
|
5376
5380
|
);
|
|
5377
5381
|
}
|
|
5378
|
-
function
|
|
5382
|
+
function Fo() {
|
|
5379
5383
|
const {
|
|
5380
5384
|
widgetCtx: { uploadCtx: t }
|
|
5381
|
-
} =
|
|
5385
|
+
} = se(), e = H(t.state), r = X(
|
|
5382
5386
|
() => e.filter((n) => n.status === "success" && n.fileUrl),
|
|
5383
5387
|
[e]
|
|
5384
5388
|
);
|
|
@@ -5401,26 +5405,26 @@ function ko() {
|
|
|
5401
5405
|
isUploading: e.some((n) => n.status === "uploading")
|
|
5402
5406
|
};
|
|
5403
5407
|
}
|
|
5404
|
-
function
|
|
5408
|
+
function ho(t) {
|
|
5405
5409
|
return t !== "fullscreen";
|
|
5406
5410
|
}
|
|
5407
|
-
const
|
|
5408
|
-
function
|
|
5411
|
+
const En = Ye(null);
|
|
5412
|
+
function Uo({ children: t }) {
|
|
5409
5413
|
var s, o;
|
|
5410
|
-
const { companion: e } = It(), { dir: r } =
|
|
5411
|
-
return /* @__PURE__ */
|
|
5412
|
-
|
|
5414
|
+
const { companion: e } = It(), { dir: r } = oo(), { widgetCtx: n } = se();
|
|
5415
|
+
return /* @__PURE__ */ Y.createElement(
|
|
5416
|
+
yo,
|
|
5413
5417
|
{
|
|
5414
5418
|
configuredDefaultLayout: e == null ? void 0 : e.defaultLayout,
|
|
5415
5419
|
configuredLayouts: e == null ? void 0 : e.layouts,
|
|
5416
|
-
configuredSidebarSide:
|
|
5417
|
-
configuredSidebarMode:
|
|
5420
|
+
configuredSidebarSide: Wn((s = e == null ? void 0 : e.sidebar) == null ? void 0 : s.side, r),
|
|
5421
|
+
configuredSidebarMode: Bn((o = e == null ? void 0 : e.sidebar) == null ? void 0 : o.mode),
|
|
5418
5422
|
storage: n.storageCtx
|
|
5419
5423
|
},
|
|
5420
5424
|
t
|
|
5421
5425
|
);
|
|
5422
5426
|
}
|
|
5423
|
-
function
|
|
5427
|
+
function yo({
|
|
5424
5428
|
configuredDefaultLayout: t,
|
|
5425
5429
|
configuredLayouts: e,
|
|
5426
5430
|
configuredSidebarSide: r,
|
|
@@ -5428,7 +5432,7 @@ function go({
|
|
|
5428
5432
|
storage: s,
|
|
5429
5433
|
children: o
|
|
5430
5434
|
}) {
|
|
5431
|
-
const l =
|
|
5435
|
+
const l = Jn(e), u = Yn(
|
|
5432
5436
|
t,
|
|
5433
5437
|
l
|
|
5434
5438
|
), y = l.join("|"), [g, i] = J(u), [d, p] = J({
|
|
@@ -5441,26 +5445,26 @@ function go({
|
|
|
5441
5445
|
const N = typeof h == "function" ? h(S) : h;
|
|
5442
5446
|
return l.includes(N) ? N : S;
|
|
5443
5447
|
});
|
|
5444
|
-
},
|
|
5445
|
-
|
|
5448
|
+
}, P = R(l);
|
|
5449
|
+
P.current = l;
|
|
5446
5450
|
const M = (h) => {
|
|
5447
|
-
b(h),
|
|
5451
|
+
b(h), P.current.includes(h) && ho(h) && (s == null || s.setCompanionLayout(h).catch(() => {
|
|
5448
5452
|
}));
|
|
5449
|
-
}, [O,
|
|
5453
|
+
}, [O, x] = J(r), [w, I] = J(n), [C, c] = J({
|
|
5450
5454
|
side: r,
|
|
5451
5455
|
mode: n
|
|
5452
5456
|
});
|
|
5453
5457
|
(C.side !== r || C.mode !== n) && (c({
|
|
5454
5458
|
side: r,
|
|
5455
5459
|
mode: n
|
|
5456
|
-
}), C.side !== r &&
|
|
5460
|
+
}), C.side !== r && x(r), C.mode !== n && I(n)), F(() => {
|
|
5457
5461
|
if (!s) return;
|
|
5458
5462
|
let h = !1;
|
|
5459
5463
|
return s.getCompanionLayout().then((S) => {
|
|
5460
|
-
h || !S ||
|
|
5464
|
+
h || !S || P.current.includes(S) && i(S);
|
|
5461
5465
|
}).catch(() => {
|
|
5462
5466
|
}), s.getCompanionSidebarSide().then((S) => {
|
|
5463
|
-
!h && S &&
|
|
5467
|
+
!h && S && x(S);
|
|
5464
5468
|
}).catch(() => {
|
|
5465
5469
|
}), s.getCompanionSidebarMode().then((S) => {
|
|
5466
5470
|
!h && S && I(S);
|
|
@@ -5469,21 +5473,21 @@ function go({
|
|
|
5469
5473
|
h = !0;
|
|
5470
5474
|
};
|
|
5471
5475
|
}, [s]);
|
|
5472
|
-
const m =
|
|
5476
|
+
const m = z(
|
|
5473
5477
|
(h) => {
|
|
5474
|
-
|
|
5478
|
+
x(h), s == null || s.setCompanionSidebarSide(h).catch(() => {
|
|
5475
5479
|
});
|
|
5476
5480
|
},
|
|
5477
5481
|
[s]
|
|
5478
|
-
), f =
|
|
5482
|
+
), f = z(
|
|
5479
5483
|
(h) => {
|
|
5480
5484
|
I(h), s == null || s.setCompanionSidebarMode(h).catch(() => {
|
|
5481
5485
|
});
|
|
5482
5486
|
},
|
|
5483
5487
|
[s]
|
|
5484
5488
|
);
|
|
5485
|
-
return /* @__PURE__ */
|
|
5486
|
-
|
|
5489
|
+
return /* @__PURE__ */ Y.createElement(
|
|
5490
|
+
En.Provider,
|
|
5487
5491
|
{
|
|
5488
5492
|
value: {
|
|
5489
5493
|
layout: g,
|
|
@@ -5500,17 +5504,17 @@ function go({
|
|
|
5500
5504
|
o
|
|
5501
5505
|
);
|
|
5502
5506
|
}
|
|
5503
|
-
function
|
|
5504
|
-
const t =
|
|
5507
|
+
function qo() {
|
|
5508
|
+
const t = Fe(En);
|
|
5505
5509
|
if (!t)
|
|
5506
5510
|
throw new Error(
|
|
5507
5511
|
"useWidgetLayout must be used within a WidgetLayoutProvider"
|
|
5508
5512
|
);
|
|
5509
5513
|
return t;
|
|
5510
5514
|
}
|
|
5511
|
-
function
|
|
5515
|
+
function zo() {
|
|
5512
5516
|
var u, y;
|
|
5513
|
-
const { widgetCtx: t } =
|
|
5517
|
+
const { widgetCtx: t } = se(), { modesComponents: e } = It(), { sessionState: r } = Sn(), n = t.modes, s = (u = r.session) == null ? void 0 : u.modeId, o = n.find((g) => g.id === s), l = (y = e == null ? void 0 : e.find(
|
|
5514
5518
|
(g) => {
|
|
5515
5519
|
var i, d;
|
|
5516
5520
|
return [
|
|
@@ -5528,10 +5532,10 @@ function Uo() {
|
|
|
5528
5532
|
Component: l
|
|
5529
5533
|
};
|
|
5530
5534
|
}
|
|
5531
|
-
function
|
|
5532
|
-
const { widgetCtx: t } =
|
|
5535
|
+
function Zo() {
|
|
5536
|
+
const { widgetCtx: t } = se(), {
|
|
5533
5537
|
messagesState: { messages: e }
|
|
5534
|
-
} =
|
|
5538
|
+
} = bn(), {
|
|
5535
5539
|
csatRequestedMessage: r,
|
|
5536
5540
|
isCsatRequested: n,
|
|
5537
5541
|
csatSubmittedMessage: s,
|
|
@@ -5563,10 +5567,10 @@ function qo() {
|
|
|
5563
5567
|
submittedFeedback: u
|
|
5564
5568
|
};
|
|
5565
5569
|
}
|
|
5566
|
-
function
|
|
5567
|
-
const { widgetCtx: e } =
|
|
5570
|
+
function Vo(t) {
|
|
5571
|
+
const { widgetCtx: e } = se(), r = e.dictationCtx, n = H(r.state), s = R(t);
|
|
5568
5572
|
s.current = t;
|
|
5569
|
-
const o =
|
|
5573
|
+
const o = z(() => {
|
|
5570
5574
|
r.start({
|
|
5571
5575
|
getValue: () => s.current.getValue(),
|
|
5572
5576
|
setValue: (u) => s.current.setValue(u),
|
|
@@ -5575,7 +5579,7 @@ function zo(t) {
|
|
|
5575
5579
|
return (y = (u = s.current).onSend) == null ? void 0 : y.call(u);
|
|
5576
5580
|
}
|
|
5577
5581
|
});
|
|
5578
|
-
}, [r]), l =
|
|
5582
|
+
}, [r]), l = z(() => {
|
|
5579
5583
|
r.isActive() ? r.stop() : o();
|
|
5580
5584
|
}, [r, o]);
|
|
5581
5585
|
return F(() => () => r.stop({ executeFinalCommand: !1 }), [r]), {
|
|
@@ -5591,22 +5595,22 @@ function zo(t) {
|
|
|
5591
5595
|
prewarm: r.prewarm
|
|
5592
5596
|
};
|
|
5593
5597
|
}
|
|
5594
|
-
function
|
|
5595
|
-
const { widgetCtx: t } =
|
|
5598
|
+
function Bo() {
|
|
5599
|
+
const { widgetCtx: t } = se(), e = t.messageCtx.draftState, r = H(e), n = z(
|
|
5596
5600
|
(l) => {
|
|
5597
5601
|
e.setPartial({
|
|
5598
5602
|
text: typeof l == "function" ? l(e.get().text) : l
|
|
5599
5603
|
});
|
|
5600
5604
|
},
|
|
5601
5605
|
[e]
|
|
5602
|
-
), s =
|
|
5606
|
+
), s = z(
|
|
5603
5607
|
(l) => {
|
|
5604
5608
|
e.setPartial({
|
|
5605
5609
|
mentions: typeof l == "function" ? l(e.get().mentions) : l
|
|
5606
5610
|
});
|
|
5607
5611
|
},
|
|
5608
5612
|
[e]
|
|
5609
|
-
), o =
|
|
5613
|
+
), o = z(
|
|
5610
5614
|
(l = r) => e.get() !== l ? !1 : (e.reset(), !0),
|
|
5611
5615
|
[e, r]
|
|
5612
5616
|
);
|
|
@@ -5614,35 +5618,35 @@ function Zo() {
|
|
|
5614
5618
|
}
|
|
5615
5619
|
export {
|
|
5616
5620
|
kt as HOST_CONTEXT_CHANGED_EVENT,
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5621
|
+
Uo as WidgetLayoutProvider,
|
|
5622
|
+
_o as WidgetProvider,
|
|
5623
|
+
ko as WidgetTriggerProvider,
|
|
5624
|
+
gr as applyPresentation,
|
|
5625
|
+
xo as formatAskQuestionsAnswers,
|
|
5626
|
+
Ro as sessionPlan,
|
|
5627
|
+
pn as useAgentChatUi,
|
|
5628
|
+
Po as useBot,
|
|
5629
|
+
Mo as useCompanionChats,
|
|
5630
|
+
Bo as useComposerDraft,
|
|
5627
5631
|
It as useConfig,
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5632
|
+
To as useConnection,
|
|
5633
|
+
No as useContact,
|
|
5634
|
+
Zo as useCsat,
|
|
5635
|
+
Vo as useDictation,
|
|
5636
|
+
Oo as useDisplayMode,
|
|
5637
|
+
oo as useDocumentDir,
|
|
5638
|
+
Do as useHostLocation,
|
|
5639
|
+
Lo as useIsAwaitingBotReply,
|
|
5640
|
+
bn as useMessages,
|
|
5641
|
+
zo as useModes,
|
|
5638
5642
|
H as usePrimitiveState,
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5643
|
+
Sn as useSessions,
|
|
5644
|
+
jo as useUnread,
|
|
5645
|
+
$o as useUnreadViewing,
|
|
5646
|
+
Fo as useUploadFiles,
|
|
5647
|
+
se as useWidget,
|
|
5648
|
+
qo as useWidgetLayout,
|
|
5649
|
+
po as useWidgetRouter,
|
|
5650
|
+
fo as useWidgetTrigger
|
|
5647
5651
|
};
|
|
5648
5652
|
//# sourceMappingURL=index.js.map
|