@teodorruskvi/chat-core 0.1.27 → 0.1.29
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.esm.js +527 -512
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +7 -7
- package/dist/index.umd.js.map +1 -1
- package/dist/shared/core/api/utils/http.d.ts +8 -2
- package/dist/types/core.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var Un = Object.defineProperty;
|
|
2
|
+
var Fn = (e, t, n) => t in e ? Un(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var Bt = (e, t, n) => Fn(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { jsx as Me } from "react/jsx-runtime";
|
|
5
|
-
import * as
|
|
6
|
-
import { createContext as
|
|
7
|
-
import
|
|
8
|
-
function
|
|
5
|
+
import * as Dt from "react";
|
|
6
|
+
import { createContext as Ge, useContext as at, useState as H, useRef as K, useEffect as oe, useCallback as E, useMemo as pe, useReducer as jn } from "react";
|
|
7
|
+
import On, { isCancel as Vt } from "axios";
|
|
8
|
+
function sn(e) {
|
|
9
9
|
var t, n, r = "";
|
|
10
10
|
if (typeof e == "string" || typeof e == "number") r += e;
|
|
11
11
|
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
12
12
|
var s = e.length;
|
|
13
|
-
for (t = 0; t < s; t++) e[t] && (n =
|
|
13
|
+
for (t = 0; t < s; t++) e[t] && (n = sn(e[t])) && (r && (r += " "), r += n);
|
|
14
14
|
} else for (n in e) e[n] && (r && (r += " "), r += n);
|
|
15
15
|
return r;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
for (var e, t, n = 0, r = "", s = arguments.length; n < s; n++) (e = arguments[n]) && (t =
|
|
17
|
+
function $n() {
|
|
18
|
+
for (var e, t, n = 0, r = "", s = arguments.length; n < s; n++) (e = arguments[n]) && (t = sn(e)) && (r && (r += " "), r += t);
|
|
19
19
|
return r;
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
const t =
|
|
21
|
+
const zt = "-", Bn = (e) => {
|
|
22
|
+
const t = Vn(e), {
|
|
23
23
|
conflictingClassGroups: n,
|
|
24
24
|
conflictingClassGroupModifiers: r
|
|
25
25
|
} = e;
|
|
26
26
|
return {
|
|
27
27
|
getClassGroupId: (a) => {
|
|
28
|
-
const i = a.split(
|
|
29
|
-
return i[0] === "" && i.length !== 1 && i.shift(),
|
|
28
|
+
const i = a.split(zt);
|
|
29
|
+
return i[0] === "" && i.length !== 1 && i.shift(), on(i, t) || Dn(a);
|
|
30
30
|
},
|
|
31
31
|
getConflictingClassGroupIds: (a, i) => {
|
|
32
32
|
const f = n[a] || [];
|
|
33
33
|
return i && r[a] ? [...f, ...r[a]] : f;
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
},
|
|
36
|
+
}, on = (e, t) => {
|
|
37
37
|
var a;
|
|
38
38
|
if (e.length === 0)
|
|
39
39
|
return t.classGroupId;
|
|
40
|
-
const n = e[0], r = t.nextPart.get(n), s = r ?
|
|
40
|
+
const n = e[0], r = t.nextPart.get(n), s = r ? on(e.slice(1), r) : void 0;
|
|
41
41
|
if (s)
|
|
42
42
|
return s;
|
|
43
43
|
if (t.validators.length === 0)
|
|
44
44
|
return;
|
|
45
|
-
const o = e.join(
|
|
45
|
+
const o = e.join(zt);
|
|
46
46
|
return (a = t.validators.find(({
|
|
47
47
|
validator: i
|
|
48
48
|
}) => i(o))) == null ? void 0 : a.classGroupId;
|
|
49
|
-
},
|
|
50
|
-
if (
|
|
51
|
-
const t =
|
|
49
|
+
}, Kt = /^\[(.+)\]$/, Dn = (e) => {
|
|
50
|
+
if (Kt.test(e)) {
|
|
51
|
+
const t = Kt.exec(e)[1], n = t == null ? void 0 : t.substring(0, t.indexOf(":"));
|
|
52
52
|
if (n)
|
|
53
53
|
return "arbitrary.." + n;
|
|
54
54
|
}
|
|
55
|
-
},
|
|
55
|
+
}, Vn = (e) => {
|
|
56
56
|
const {
|
|
57
57
|
theme: t,
|
|
58
58
|
prefix: n
|
|
@@ -60,18 +60,18 @@ const Lt = "-", jn = (e) => {
|
|
|
60
60
|
nextPart: /* @__PURE__ */ new Map(),
|
|
61
61
|
validators: []
|
|
62
62
|
};
|
|
63
|
-
return
|
|
63
|
+
return Hn(Object.entries(e.classGroups), n).forEach(([o, a]) => {
|
|
64
64
|
Nt(a, r, o, t);
|
|
65
65
|
}), r;
|
|
66
66
|
}, Nt = (e, t, n, r) => {
|
|
67
67
|
e.forEach((s) => {
|
|
68
68
|
if (typeof s == "string") {
|
|
69
|
-
const o = s === "" ? t :
|
|
69
|
+
const o = s === "" ? t : Ht(t, s);
|
|
70
70
|
o.classGroupId = n;
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
if (typeof s == "function") {
|
|
74
|
-
if (
|
|
74
|
+
if (Kn(s)) {
|
|
75
75
|
Nt(s(r), t, n, r);
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
@@ -82,21 +82,21 @@ const Lt = "-", jn = (e) => {
|
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
84
|
Object.entries(s).forEach(([o, a]) => {
|
|
85
|
-
Nt(a,
|
|
85
|
+
Nt(a, Ht(t, o), n, r);
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
|
-
},
|
|
88
|
+
}, Ht = (e, t) => {
|
|
89
89
|
let n = e;
|
|
90
|
-
return t.split(
|
|
90
|
+
return t.split(zt).forEach((r) => {
|
|
91
91
|
n.nextPart.has(r) || n.nextPart.set(r, {
|
|
92
92
|
nextPart: /* @__PURE__ */ new Map(),
|
|
93
93
|
validators: []
|
|
94
94
|
}), n = n.nextPart.get(r);
|
|
95
95
|
}), n;
|
|
96
|
-
},
|
|
96
|
+
}, Kn = (e) => e.isThemeGetter, Hn = (e, t) => t ? e.map(([n, r]) => {
|
|
97
97
|
const s = r.map((o) => typeof o == "string" ? t + o : typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([a, i]) => [t + a, i])) : o);
|
|
98
98
|
return [n, s];
|
|
99
|
-
}) : e,
|
|
99
|
+
}) : e, qn = (e) => {
|
|
100
100
|
if (e < 1)
|
|
101
101
|
return {
|
|
102
102
|
get: () => {
|
|
@@ -120,7 +120,7 @@ const Lt = "-", jn = (e) => {
|
|
|
120
120
|
n.has(o) ? n.set(o, a) : s(o, a);
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
|
-
},
|
|
123
|
+
}, an = "!", Wn = (e) => {
|
|
124
124
|
const {
|
|
125
125
|
separator: t,
|
|
126
126
|
experimentalParseClassName: n
|
|
@@ -141,7 +141,7 @@ const Lt = "-", jn = (e) => {
|
|
|
141
141
|
}
|
|
142
142
|
I === "[" ? l++ : I === "]" && l--;
|
|
143
143
|
}
|
|
144
|
-
const g = f.length === 0 ? i : i.substring(c), h = g.startsWith(
|
|
144
|
+
const g = f.length === 0 ? i : i.substring(c), h = g.startsWith(an), v = h ? g.substring(1) : g, m = d && d > c ? d - c : void 0;
|
|
145
145
|
return {
|
|
146
146
|
modifiers: f,
|
|
147
147
|
hasImportantModifier: h,
|
|
@@ -153,7 +153,7 @@ const Lt = "-", jn = (e) => {
|
|
|
153
153
|
className: i,
|
|
154
154
|
parseClassName: a
|
|
155
155
|
}) : a;
|
|
156
|
-
},
|
|
156
|
+
}, Gn = (e) => {
|
|
157
157
|
if (e.length <= 1)
|
|
158
158
|
return e;
|
|
159
159
|
const t = [];
|
|
@@ -161,16 +161,16 @@ const Lt = "-", jn = (e) => {
|
|
|
161
161
|
return e.forEach((r) => {
|
|
162
162
|
r[0] === "[" ? (t.push(...n.sort(), r), n = []) : n.push(r);
|
|
163
163
|
}), t.push(...n.sort()), t;
|
|
164
|
-
},
|
|
165
|
-
cache:
|
|
166
|
-
parseClassName:
|
|
167
|
-
...
|
|
168
|
-
}),
|
|
164
|
+
}, Jn = (e) => ({
|
|
165
|
+
cache: qn(e.cacheSize),
|
|
166
|
+
parseClassName: Wn(e),
|
|
167
|
+
...Bn(e)
|
|
168
|
+
}), Xn = /\s+/, Qn = (e, t) => {
|
|
169
169
|
const {
|
|
170
170
|
parseClassName: n,
|
|
171
171
|
getClassGroupId: r,
|
|
172
172
|
getConflictingClassGroupIds: s
|
|
173
|
-
} = t, o = [], a = e.trim().split(
|
|
173
|
+
} = t, o = [], a = e.trim().split(Xn);
|
|
174
174
|
let i = "";
|
|
175
175
|
for (let f = a.length - 1; f >= 0; f -= 1) {
|
|
176
176
|
const l = a[f], {
|
|
@@ -191,7 +191,7 @@ const Lt = "-", jn = (e) => {
|
|
|
191
191
|
}
|
|
192
192
|
v = !1;
|
|
193
193
|
}
|
|
194
|
-
const y =
|
|
194
|
+
const y = Gn(c).join(":"), I = d ? y + an : y, A = I + m;
|
|
195
195
|
if (o.includes(A))
|
|
196
196
|
continue;
|
|
197
197
|
o.push(A);
|
|
@@ -204,56 +204,56 @@ const Lt = "-", jn = (e) => {
|
|
|
204
204
|
}
|
|
205
205
|
return i;
|
|
206
206
|
};
|
|
207
|
-
function
|
|
207
|
+
function Yn() {
|
|
208
208
|
let e = 0, t, n, r = "";
|
|
209
209
|
for (; e < arguments.length; )
|
|
210
|
-
(t = arguments[e++]) && (n =
|
|
210
|
+
(t = arguments[e++]) && (n = cn(t)) && (r && (r += " "), r += n);
|
|
211
211
|
return r;
|
|
212
212
|
}
|
|
213
|
-
const
|
|
213
|
+
const cn = (e) => {
|
|
214
214
|
if (typeof e == "string")
|
|
215
215
|
return e;
|
|
216
216
|
let t, n = "";
|
|
217
217
|
for (let r = 0; r < e.length; r++)
|
|
218
|
-
e[r] && (t =
|
|
218
|
+
e[r] && (t = cn(e[r])) && (n && (n += " "), n += t);
|
|
219
219
|
return n;
|
|
220
220
|
};
|
|
221
|
-
function
|
|
221
|
+
function Zn(e, ...t) {
|
|
222
222
|
let n, r, s, o = a;
|
|
223
223
|
function a(f) {
|
|
224
224
|
const l = t.reduce((c, d) => d(c), e());
|
|
225
|
-
return n =
|
|
225
|
+
return n = Jn(l), r = n.cache.get, s = n.cache.set, o = i, i(f);
|
|
226
226
|
}
|
|
227
227
|
function i(f) {
|
|
228
228
|
const l = r(f);
|
|
229
229
|
if (l)
|
|
230
230
|
return l;
|
|
231
|
-
const c =
|
|
231
|
+
const c = Qn(f, n);
|
|
232
232
|
return s(f, c), c;
|
|
233
233
|
}
|
|
234
234
|
return function() {
|
|
235
|
-
return o(
|
|
235
|
+
return o(Yn.apply(null, arguments));
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
238
|
const Z = (e) => {
|
|
239
239
|
const t = (n) => n[e] || [];
|
|
240
240
|
return t.isThemeGetter = !0, t;
|
|
241
|
-
},
|
|
242
|
-
const r =
|
|
241
|
+
}, ln = /^\[(?:([a-z-]+):)?(.+)\]$/i, er = /^\d+\/\d+$/, tr = /* @__PURE__ */ new Set(["px", "full", "screen"]), nr = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, rr = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/, sr = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, or = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, ar = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, _e = (e) => qe(e) || tr.has(e) || er.test(e), Ue = (e) => Je(e, "length", gr), qe = (e) => !!e && !Number.isNaN(Number(e)), xt = (e) => Je(e, "number", qe), Ze = (e) => !!e && Number.isInteger(Number(e)), ir = (e) => e.endsWith("%") && qe(e.slice(0, -1)), F = (e) => ln.test(e), Fe = (e) => nr.test(e), cr = /* @__PURE__ */ new Set(["length", "size", "percentage"]), lr = (e) => Je(e, cr, un), ur = (e) => Je(e, "position", un), dr = /* @__PURE__ */ new Set(["image", "url"]), fr = (e) => Je(e, dr, hr), pr = (e) => Je(e, "", mr), et = () => !0, Je = (e, t, n) => {
|
|
242
|
+
const r = ln.exec(e);
|
|
243
243
|
return r ? r[1] ? typeof t == "string" ? r[1] === t : t.has(r[1]) : n(r[2]) : !1;
|
|
244
|
-
},
|
|
244
|
+
}, gr = (e) => (
|
|
245
245
|
// `colorFunctionRegex` check is necessary because color functions can have percentages in them which which would be incorrectly classified as lengths.
|
|
246
246
|
// For example, `hsl(0 0% 0%)` would be classified as a length without this check.
|
|
247
247
|
// I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough.
|
|
248
|
-
|
|
249
|
-
),
|
|
250
|
-
const e = Z("colors"), t = Z("spacing"), n = Z("blur"), r = Z("brightness"), s = Z("borderColor"), o = Z("borderRadius"), a = Z("borderSpacing"), i = Z("borderWidth"), f = Z("contrast"), l = Z("grayscale"), c = Z("hueRotate"), d = Z("invert"), g = Z("gap"), h = Z("gradientColorStops"), v = Z("gradientColorStopPositions"), m = Z("inset"), y = Z("margin"), I = Z("opacity"), A = Z("padding"), x = Z("saturate"), N = Z("scale"), _ = Z("sepia"), k = Z("skew"), T = Z("space"), L = Z("translate"), j = () => ["auto", "contain", "none"], O = () => ["auto", "hidden", "clip", "visible", "scroll"], $ = () => ["auto", F, t], C = () => [F, t], J = () => ["", _e,
|
|
248
|
+
rr.test(e) && !sr.test(e)
|
|
249
|
+
), un = () => !1, mr = (e) => or.test(e), hr = (e) => ar.test(e), yr = () => {
|
|
250
|
+
const e = Z("colors"), t = Z("spacing"), n = Z("blur"), r = Z("brightness"), s = Z("borderColor"), o = Z("borderRadius"), a = Z("borderSpacing"), i = Z("borderWidth"), f = Z("contrast"), l = Z("grayscale"), c = Z("hueRotate"), d = Z("invert"), g = Z("gap"), h = Z("gradientColorStops"), v = Z("gradientColorStopPositions"), m = Z("inset"), y = Z("margin"), I = Z("opacity"), A = Z("padding"), x = Z("saturate"), N = Z("scale"), _ = Z("sepia"), k = Z("skew"), T = Z("space"), L = Z("translate"), j = () => ["auto", "contain", "none"], O = () => ["auto", "hidden", "clip", "visible", "scroll"], $ = () => ["auto", F, t], C = () => [F, t], J = () => ["", _e, Ue], G = () => ["auto", qe, F], X = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], te = () => ["solid", "dashed", "dotted", "double", "none"], ne = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], S = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], P = () => ["", "0", F], D = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], V = () => [qe, F];
|
|
251
251
|
return {
|
|
252
252
|
cacheSize: 500,
|
|
253
253
|
separator: ":",
|
|
254
254
|
theme: {
|
|
255
255
|
colors: [et],
|
|
256
|
-
spacing: [_e,
|
|
256
|
+
spacing: [_e, Ue],
|
|
257
257
|
blur: ["none", "", Fe, F],
|
|
258
258
|
brightness: V(),
|
|
259
259
|
borderColor: [e],
|
|
@@ -266,7 +266,7 @@ const Z = (e) => {
|
|
|
266
266
|
invert: P(),
|
|
267
267
|
gap: C(),
|
|
268
268
|
gradientColorStops: [e],
|
|
269
|
-
gradientColorStopPositions: [
|
|
269
|
+
gradientColorStopPositions: [ir, Ue],
|
|
270
270
|
inset: $(),
|
|
271
271
|
margin: $(),
|
|
272
272
|
opacity: V(),
|
|
@@ -565,14 +565,14 @@ const Z = (e) => {
|
|
|
565
565
|
* @see https://tailwindcss.com/docs/grid-column
|
|
566
566
|
*/
|
|
567
567
|
"col-start": [{
|
|
568
|
-
"col-start":
|
|
568
|
+
"col-start": G()
|
|
569
569
|
}],
|
|
570
570
|
/**
|
|
571
571
|
* Grid Column End
|
|
572
572
|
* @see https://tailwindcss.com/docs/grid-column
|
|
573
573
|
*/
|
|
574
574
|
"col-end": [{
|
|
575
|
-
"col-end":
|
|
575
|
+
"col-end": G()
|
|
576
576
|
}],
|
|
577
577
|
/**
|
|
578
578
|
* Grid Template Rows
|
|
@@ -595,14 +595,14 @@ const Z = (e) => {
|
|
|
595
595
|
* @see https://tailwindcss.com/docs/grid-row
|
|
596
596
|
*/
|
|
597
597
|
"row-start": [{
|
|
598
|
-
"row-start":
|
|
598
|
+
"row-start": G()
|
|
599
599
|
}],
|
|
600
600
|
/**
|
|
601
601
|
* Grid Row End
|
|
602
602
|
* @see https://tailwindcss.com/docs/grid-row
|
|
603
603
|
*/
|
|
604
604
|
"row-end": [{
|
|
605
|
-
"row-end":
|
|
605
|
+
"row-end": G()
|
|
606
606
|
}],
|
|
607
607
|
/**
|
|
608
608
|
* Grid Auto Flow
|
|
@@ -918,7 +918,7 @@ const Z = (e) => {
|
|
|
918
918
|
* @see https://tailwindcss.com/docs/font-size
|
|
919
919
|
*/
|
|
920
920
|
"font-size": [{
|
|
921
|
-
text: ["base", Fe,
|
|
921
|
+
text: ["base", Fe, Ue]
|
|
922
922
|
}],
|
|
923
923
|
/**
|
|
924
924
|
* Font Smoothing
|
|
@@ -986,7 +986,7 @@ const Z = (e) => {
|
|
|
986
986
|
* @see https://tailwindcss.com/docs/line-clamp
|
|
987
987
|
*/
|
|
988
988
|
"line-clamp": [{
|
|
989
|
-
"line-clamp": ["none",
|
|
989
|
+
"line-clamp": ["none", qe, xt]
|
|
990
990
|
}],
|
|
991
991
|
/**
|
|
992
992
|
* Line Height
|
|
@@ -1069,7 +1069,7 @@ const Z = (e) => {
|
|
|
1069
1069
|
* @see https://tailwindcss.com/docs/text-decoration-thickness
|
|
1070
1070
|
*/
|
|
1071
1071
|
"text-decoration-thickness": [{
|
|
1072
|
-
decoration: ["auto", "from-font", _e,
|
|
1072
|
+
decoration: ["auto", "from-font", _e, Ue]
|
|
1073
1073
|
}],
|
|
1074
1074
|
/**
|
|
1075
1075
|
* Text Underline Offset
|
|
@@ -1179,7 +1179,7 @@ const Z = (e) => {
|
|
|
1179
1179
|
* @see https://tailwindcss.com/docs/background-position
|
|
1180
1180
|
*/
|
|
1181
1181
|
"bg-position": [{
|
|
1182
|
-
bg: [...X(),
|
|
1182
|
+
bg: [...X(), ur]
|
|
1183
1183
|
}],
|
|
1184
1184
|
/**
|
|
1185
1185
|
* Background Repeat
|
|
@@ -1195,7 +1195,7 @@ const Z = (e) => {
|
|
|
1195
1195
|
* @see https://tailwindcss.com/docs/background-size
|
|
1196
1196
|
*/
|
|
1197
1197
|
"bg-size": [{
|
|
1198
|
-
bg: ["auto", "cover", "contain",
|
|
1198
|
+
bg: ["auto", "cover", "contain", lr]
|
|
1199
1199
|
}],
|
|
1200
1200
|
/**
|
|
1201
1201
|
* Background Image
|
|
@@ -1204,7 +1204,7 @@ const Z = (e) => {
|
|
|
1204
1204
|
"bg-image": [{
|
|
1205
1205
|
bg: ["none", {
|
|
1206
1206
|
"gradient-to": ["t", "tr", "r", "br", "b", "bl", "l", "tl"]
|
|
1207
|
-
},
|
|
1207
|
+
}, fr]
|
|
1208
1208
|
}],
|
|
1209
1209
|
/**
|
|
1210
1210
|
* Background Color
|
|
@@ -1565,7 +1565,7 @@ const Z = (e) => {
|
|
|
1565
1565
|
* @see https://tailwindcss.com/docs/outline-width
|
|
1566
1566
|
*/
|
|
1567
1567
|
"outline-w": [{
|
|
1568
|
-
outline: [_e,
|
|
1568
|
+
outline: [_e, Ue]
|
|
1569
1569
|
}],
|
|
1570
1570
|
/**
|
|
1571
1571
|
* Outline Color
|
|
@@ -1605,7 +1605,7 @@ const Z = (e) => {
|
|
|
1605
1605
|
* @see https://tailwindcss.com/docs/ring-offset-width
|
|
1606
1606
|
*/
|
|
1607
1607
|
"ring-offset-w": [{
|
|
1608
|
-
"ring-offset": [_e,
|
|
1608
|
+
"ring-offset": [_e, Ue]
|
|
1609
1609
|
}],
|
|
1610
1610
|
/**
|
|
1611
1611
|
* Ring Offset Color
|
|
@@ -1620,7 +1620,7 @@ const Z = (e) => {
|
|
|
1620
1620
|
* @see https://tailwindcss.com/docs/box-shadow
|
|
1621
1621
|
*/
|
|
1622
1622
|
shadow: [{
|
|
1623
|
-
shadow: ["", "inner", "none", Fe,
|
|
1623
|
+
shadow: ["", "inner", "none", Fe, pr]
|
|
1624
1624
|
}],
|
|
1625
1625
|
/**
|
|
1626
1626
|
* Box Shadow Color
|
|
@@ -2200,7 +2200,7 @@ const Z = (e) => {
|
|
|
2200
2200
|
* @see https://tailwindcss.com/docs/stroke-width
|
|
2201
2201
|
*/
|
|
2202
2202
|
"stroke-w": [{
|
|
2203
|
-
stroke: [_e,
|
|
2203
|
+
stroke: [_e, Ue, xt]
|
|
2204
2204
|
}],
|
|
2205
2205
|
/**
|
|
2206
2206
|
* Stroke
|
|
@@ -2275,11 +2275,11 @@ const Z = (e) => {
|
|
|
2275
2275
|
"font-size": ["leading"]
|
|
2276
2276
|
}
|
|
2277
2277
|
};
|
|
2278
|
-
},
|
|
2279
|
-
function
|
|
2280
|
-
return
|
|
2278
|
+
}, br = /* @__PURE__ */ Zn(yr);
|
|
2279
|
+
function Ks(...e) {
|
|
2280
|
+
return br($n(e));
|
|
2281
2281
|
}
|
|
2282
|
-
function
|
|
2282
|
+
function wr(e) {
|
|
2283
2283
|
let t = !1, n = "";
|
|
2284
2284
|
for (const s of e) {
|
|
2285
2285
|
if (s === "\\") {
|
|
@@ -2300,7 +2300,7 @@ function Ut(e) {
|
|
|
2300
2300
|
try {
|
|
2301
2301
|
return JSON.parse(t);
|
|
2302
2302
|
} catch {
|
|
2303
|
-
const n =
|
|
2303
|
+
const n = wr(t);
|
|
2304
2304
|
if (n)
|
|
2305
2305
|
try {
|
|
2306
2306
|
return JSON.parse(n);
|
|
@@ -2310,29 +2310,29 @@ function Ut(e) {
|
|
|
2310
2310
|
return null;
|
|
2311
2311
|
}
|
|
2312
2312
|
}
|
|
2313
|
-
function
|
|
2313
|
+
function kr(e) {
|
|
2314
2314
|
return typeof e != "string" ? !1 : /^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e);
|
|
2315
2315
|
}
|
|
2316
|
-
function
|
|
2316
|
+
function vr(e) {
|
|
2317
2317
|
return e.type === "image_url";
|
|
2318
2318
|
}
|
|
2319
|
-
function
|
|
2319
|
+
function Ir(e) {
|
|
2320
2320
|
return e.type === "file";
|
|
2321
2321
|
}
|
|
2322
|
-
function
|
|
2322
|
+
function Tr(e) {
|
|
2323
2323
|
return Array.isArray(e.content) ? e.content.filter((t) => t.type === "text").map((t) => t.text).join(`
|
|
2324
2324
|
`).trim() : typeof e.content == "string" ? e.content : "";
|
|
2325
2325
|
}
|
|
2326
|
-
function
|
|
2327
|
-
return e.content.filter(
|
|
2326
|
+
function Ar(e) {
|
|
2327
|
+
return e.content.filter(vr);
|
|
2328
2328
|
}
|
|
2329
|
-
function
|
|
2330
|
-
return e.content.filter(
|
|
2329
|
+
function Sr(e) {
|
|
2330
|
+
return e.content.filter(Ir);
|
|
2331
2331
|
}
|
|
2332
|
-
function
|
|
2332
|
+
function dn(e) {
|
|
2333
2333
|
return Array.isArray(e.toolCalls) ? e.toolCalls : [];
|
|
2334
2334
|
}
|
|
2335
|
-
function
|
|
2335
|
+
function xr(e) {
|
|
2336
2336
|
const t = [];
|
|
2337
2337
|
return e.forEach((n) => {
|
|
2338
2338
|
n.artifact && t.push(n.artifact), Array.isArray(n.toolCalls) && n.toolCalls.forEach((r) => {
|
|
@@ -2340,7 +2340,7 @@ function Tr(e) {
|
|
|
2340
2340
|
});
|
|
2341
2341
|
}), t;
|
|
2342
2342
|
}
|
|
2343
|
-
function
|
|
2343
|
+
function fn(e) {
|
|
2344
2344
|
return !!(e && typeof e == "object" && (e.type === "file" || e.mimeType || e.filename || e.sourceType === "base64"));
|
|
2345
2345
|
}
|
|
2346
2346
|
function yt(e) {
|
|
@@ -2355,7 +2355,7 @@ function yt(e) {
|
|
|
2355
2355
|
}
|
|
2356
2356
|
return n;
|
|
2357
2357
|
}
|
|
2358
|
-
if (
|
|
2358
|
+
if (fn(e)) {
|
|
2359
2359
|
try {
|
|
2360
2360
|
console.debug("[message-utils] sanitizeForDisplay - dropping file-like object", {
|
|
2361
2361
|
sampleFilename: e && (e.filename || e.name) ? e.filename || e.name : void 0,
|
|
@@ -2387,9 +2387,9 @@ function yt(e) {
|
|
|
2387
2387
|
}
|
|
2388
2388
|
return e;
|
|
2389
2389
|
}
|
|
2390
|
-
function
|
|
2390
|
+
function pn(e) {
|
|
2391
2391
|
if (typeof e == "string") return e;
|
|
2392
|
-
if (
|
|
2392
|
+
if (fn(e)) return "";
|
|
2393
2393
|
try {
|
|
2394
2394
|
const t = yt(e);
|
|
2395
2395
|
return t === void 0 ? "" : typeof t == "string" ? t : JSON.stringify(t, null, 2);
|
|
@@ -2397,11 +2397,11 @@ function dn(e) {
|
|
|
2397
2397
|
return "";
|
|
2398
2398
|
}
|
|
2399
2399
|
}
|
|
2400
|
-
function
|
|
2401
|
-
const t =
|
|
2402
|
-
return typeof e == "string" &&
|
|
2400
|
+
function Hs(e) {
|
|
2401
|
+
const t = pn(e);
|
|
2402
|
+
return typeof e == "string" && kr(e) ? { content: e, isMarkdown: !0 } : { content: t, isMarkdown: !1 };
|
|
2403
2403
|
}
|
|
2404
|
-
function
|
|
2404
|
+
function Cr(e) {
|
|
2405
2405
|
const t = (r) => {
|
|
2406
2406
|
try {
|
|
2407
2407
|
const s = yt(r);
|
|
@@ -2413,7 +2413,7 @@ function Ar(e) {
|
|
|
2413
2413
|
return n.length ? t(n.map((r) => r.text).join(`
|
|
2414
2414
|
`)) : t(e);
|
|
2415
2415
|
}
|
|
2416
|
-
function
|
|
2416
|
+
function qs(e) {
|
|
2417
2417
|
return e.content.some((t) => t.type === "text" ? t.text.trim().length > 0 : t.type === "image_url" || t.type === "file");
|
|
2418
2418
|
}
|
|
2419
2419
|
function Ee(e) {
|
|
@@ -2436,13 +2436,13 @@ function Ee(e) {
|
|
|
2436
2436
|
}
|
|
2437
2437
|
return typeof e == "object" && !Array.isArray(e) && (e.type === "text" && typeof e.text == "string" || typeof e.text == "string") ? e.text : Array.isArray(e) && e.length > 0 ? Ee(e[0]) : e;
|
|
2438
2438
|
}
|
|
2439
|
-
function
|
|
2439
|
+
function Mr(e) {
|
|
2440
2440
|
return e.replace(/[_-](\w)/g, (t, n) => n ? n.toUpperCase() : "").replace(/^\w/, (t) => t.toLowerCase());
|
|
2441
2441
|
}
|
|
2442
2442
|
function Pe(e) {
|
|
2443
2443
|
return !e || typeof e != "object" ? e : Array.isArray(e) ? e.map(Pe) : Object.fromEntries(
|
|
2444
2444
|
Object.entries(e).map(([t, n]) => [
|
|
2445
|
-
|
|
2445
|
+
Mr(t),
|
|
2446
2446
|
Pe(n)
|
|
2447
2447
|
])
|
|
2448
2448
|
);
|
|
@@ -2450,10 +2450,10 @@ function Pe(e) {
|
|
|
2450
2450
|
function bt(e) {
|
|
2451
2451
|
var y, I, A, x, N, _;
|
|
2452
2452
|
if (!e || typeof e != "object") return null;
|
|
2453
|
-
const t = Pe(e), n =
|
|
2453
|
+
const t = Pe(e), n = Rr(t);
|
|
2454
2454
|
if (!n)
|
|
2455
2455
|
return null;
|
|
2456
|
-
const r = Array.isArray(t.toolCalls) ? t.toolCalls.map(
|
|
2456
|
+
const r = Array.isArray(t.toolCalls) ? t.toolCalls.map(Ft) : void 0, s = Pr(t.content ?? t.parts, !!(r != null && r.length)), o = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, a = t.createdAt ?? ((y = t.additionalKwargs) == null ? void 0 : y.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), i = t.name ?? ((I = t.additionalKwargs) == null ? void 0 : I.agentName) ?? void 0, f = t.model ?? ((A = t.additionalKwargs) == null ? void 0 : A.model) ?? void 0, l = t.toolCallId ?? void 0, c = t.additionalKwargs ?? void 0, d = t.responseMetadata ?? void 0, g = t.checkpointId ?? ((x = t.additionalKwargs) == null ? void 0 : x.checkpointId) ?? void 0, h = t.checkpointNs ?? ((N = t.additionalKwargs) == null ? void 0 : N.checkpointNs) ?? void 0, v = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((_ = t.additionalKwargs) != null && _.toolStreaming);
|
|
2457
2457
|
return {
|
|
2458
2458
|
...t,
|
|
2459
2459
|
id: o,
|
|
@@ -2472,7 +2472,7 @@ function bt(e) {
|
|
|
2472
2472
|
artifact: t.artifact ?? void 0
|
|
2473
2473
|
};
|
|
2474
2474
|
}
|
|
2475
|
-
function
|
|
2475
|
+
function Er(e) {
|
|
2476
2476
|
if (!e || typeof e != "object") return e;
|
|
2477
2477
|
const t = Pe(e);
|
|
2478
2478
|
if (t.tool && !t.name && (t.name = t.tool), t.type === "artifact.update" && t.artifact && typeof t.artifact == "object") {
|
|
@@ -2481,7 +2481,7 @@ function xr(e) {
|
|
|
2481
2481
|
}
|
|
2482
2482
|
return t;
|
|
2483
2483
|
}
|
|
2484
|
-
function
|
|
2484
|
+
function Ft(e) {
|
|
2485
2485
|
const t = Pe(e), n = t.content ?? t.output ?? void 0;
|
|
2486
2486
|
return {
|
|
2487
2487
|
...t,
|
|
@@ -2492,35 +2492,35 @@ function zt(e) {
|
|
|
2492
2492
|
content: typeof n == "string" ? n : n ? JSON.stringify(n) : void 0
|
|
2493
2493
|
};
|
|
2494
2494
|
}
|
|
2495
|
-
function
|
|
2496
|
-
return Array.isArray(e) ? e.map((n) => n.type === "tool_call" || n.type === "tool" ? t ? null :
|
|
2495
|
+
function Pr(e, t) {
|
|
2496
|
+
return Array.isArray(e) ? e.map((n) => n.type === "tool_call" || n.type === "tool" ? t ? null : Ft(Pe(n)) : n).filter(
|
|
2497
2497
|
(n) => !!(n && typeof n == "object" && typeof n.type == "string")
|
|
2498
2498
|
) : [];
|
|
2499
2499
|
}
|
|
2500
|
-
function
|
|
2500
|
+
function Rr(e) {
|
|
2501
2501
|
const t = Pe(e), n = t.role;
|
|
2502
2502
|
if (n && (n === "assistant" || n === "user" || n === "system" || n === "tool" || n === "interrupt"))
|
|
2503
2503
|
return n;
|
|
2504
2504
|
const r = t.type;
|
|
2505
2505
|
return r === "human" ? "user" : r === "ai" ? "assistant" : r === "tool" ? "tool" : r === "system" ? "system" : null;
|
|
2506
2506
|
}
|
|
2507
|
-
function
|
|
2507
|
+
function qt(e) {
|
|
2508
2508
|
if (!e) return null;
|
|
2509
2509
|
const t = String(e).toLowerCase();
|
|
2510
2510
|
return t === "running" || t === "pending" ? "pending" : t === "completed" || t === "success" ? "completed" : t === "error" || t === "failed" || t === "failure" ? "error" : null;
|
|
2511
2511
|
}
|
|
2512
2512
|
function Wt(e) {
|
|
2513
|
-
return (Array.isArray(e.toolCalls) ? e.toolCalls :
|
|
2513
|
+
return (Array.isArray(e.toolCalls) ? e.toolCalls : dn(e)).map(Ft);
|
|
2514
2514
|
}
|
|
2515
2515
|
function Ct(e, t) {
|
|
2516
2516
|
return t.find(
|
|
2517
2517
|
(n) => n.role === "tool" && (n.toolCallId === e || n.id === e)
|
|
2518
2518
|
);
|
|
2519
2519
|
}
|
|
2520
|
-
function
|
|
2520
|
+
function Nr(e, t) {
|
|
2521
2521
|
const n = t.response ?? t.content;
|
|
2522
2522
|
if (!n) return;
|
|
2523
|
-
const r = typeof n == "string" ? n :
|
|
2523
|
+
const r = typeof n == "string" ? n : pn(n);
|
|
2524
2524
|
if (!r.trim()) return;
|
|
2525
2525
|
const s = [{ type: "text", text: r }];
|
|
2526
2526
|
return {
|
|
@@ -2533,12 +2533,12 @@ function Er(e, t) {
|
|
|
2533
2533
|
createdAt: e.createdAt
|
|
2534
2534
|
};
|
|
2535
2535
|
}
|
|
2536
|
-
function
|
|
2536
|
+
function _r(e, t = []) {
|
|
2537
2537
|
if (Array.isArray(e)) {
|
|
2538
2538
|
const s = e.filter((a) => a.role === "assistant").flatMap((a) => Wt(a)), o = /* @__PURE__ */ new Map();
|
|
2539
2539
|
return s.forEach((a) => o.set(a.id, a)), Array.from(o.values()).map((a) => {
|
|
2540
2540
|
var d, g, h;
|
|
2541
|
-
const i = Ct(a.id, e) || Ct(a.id, t), f = Array.isArray((d = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : d.toolProgress) ? (g = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : g.toolProgress : void 0, l = (i == null ? void 0 : i.artifact) ?? a.artifact, c =
|
|
2541
|
+
const i = Ct(a.id, e) || Ct(a.id, t), f = Array.isArray((d = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : d.toolProgress) ? (g = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : g.toolProgress : void 0, l = (i == null ? void 0 : i.artifact) ?? a.artifact, c = qt(a.status) ?? ((h = i == null ? void 0 : i.additionalKwargs) != null && h.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
|
|
2542
2542
|
if (i && !a.content && c === "completed") {
|
|
2543
2543
|
const v = Ee(i);
|
|
2544
2544
|
typeof v == "string" && (a.content = v);
|
|
@@ -2556,7 +2556,7 @@ function Pr(e, t = []) {
|
|
|
2556
2556
|
const n = Wt(e);
|
|
2557
2557
|
return n.length === 0 ? [] : n.map((r) => {
|
|
2558
2558
|
var f, l, c;
|
|
2559
|
-
const s = Ct(r.id, t) ??
|
|
2559
|
+
const s = Ct(r.id, t) ?? Nr(e, r), o = Array.isArray((f = s == null ? void 0 : s.additionalKwargs) == null ? void 0 : f.toolProgress) ? (l = s == null ? void 0 : s.additionalKwargs) == null ? void 0 : l.toolProgress : void 0, a = (s == null ? void 0 : s.artifact) ?? r.artifact, i = qt(r.status) ?? ((c = s == null ? void 0 : s.additionalKwargs) != null && c.toolStreaming ? "pending" : null) ?? (s ? "completed" : "pending");
|
|
2560
2560
|
if (s && !r.content && i === "completed") {
|
|
2561
2561
|
const d = Ee(s);
|
|
2562
2562
|
typeof d == "string" && (r.content = d);
|
|
@@ -2570,8 +2570,8 @@ function Pr(e, t = []) {
|
|
|
2570
2570
|
};
|
|
2571
2571
|
});
|
|
2572
2572
|
}
|
|
2573
|
-
function
|
|
2574
|
-
return
|
|
2573
|
+
function Ws(e, t = []) {
|
|
2574
|
+
return _r(e, t).map((n) => n.artifact).filter((n) => !!n);
|
|
2575
2575
|
}
|
|
2576
2576
|
const nt = {
|
|
2577
2577
|
authToken: "authToken",
|
|
@@ -2587,22 +2587,34 @@ function Mt(e) {
|
|
|
2587
2587
|
}
|
|
2588
2588
|
let wt = null;
|
|
2589
2589
|
const _t = /* @__PURE__ */ new Set();
|
|
2590
|
-
function
|
|
2590
|
+
function gn() {
|
|
2591
2591
|
return wt;
|
|
2592
2592
|
}
|
|
2593
2593
|
function Ve(e) {
|
|
2594
2594
|
wt = e, _t.forEach((t) => t(e));
|
|
2595
2595
|
}
|
|
2596
|
-
function
|
|
2596
|
+
function mn(e) {
|
|
2597
2597
|
return _t.add(e), () => _t.delete(e);
|
|
2598
2598
|
}
|
|
2599
|
-
const
|
|
2599
|
+
const Lr = 12e4, zr = 12e4;
|
|
2600
|
+
let Lt = Lr, hn = zr;
|
|
2601
|
+
const ye = On.create({
|
|
2600
2602
|
// BaseURL is set dynamically via ApiProvider -> api.updateConfig
|
|
2601
|
-
timeout:
|
|
2603
|
+
timeout: Lt,
|
|
2602
2604
|
withCredentials: !0
|
|
2603
2605
|
});
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
+
function Gt(e) {
|
|
2607
|
+
return typeof e != "number" || !Number.isFinite(e) || e <= 0 ? null : Math.floor(e);
|
|
2608
|
+
}
|
|
2609
|
+
function Ur(e) {
|
|
2610
|
+
const t = Gt(e.requestTimeoutMs), n = Gt(e.historyTimeoutMs);
|
|
2611
|
+
t !== null && (Lt = t, ye.defaults.timeout = Lt), n !== null && (hn = n);
|
|
2612
|
+
}
|
|
2613
|
+
function Fr() {
|
|
2614
|
+
return hn;
|
|
2615
|
+
}
|
|
2616
|
+
ye.interceptors.request.use((e) => (wt && (e.headers.Authorization = `Bearer ${wt}`), e));
|
|
2617
|
+
ye.interceptors.response.use(
|
|
2606
2618
|
(e) => {
|
|
2607
2619
|
if (typeof window < "u" && (e != null && e.data))
|
|
2608
2620
|
try {
|
|
@@ -2620,53 +2632,56 @@ ke.interceptors.response.use(
|
|
|
2620
2632
|
(e) => Promise.reject(e)
|
|
2621
2633
|
);
|
|
2622
2634
|
async function Ie(e, t) {
|
|
2623
|
-
return
|
|
2635
|
+
return ye.defaults.baseURL ? (await ye.get(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2624
2636
|
}
|
|
2625
2637
|
async function ft(e, t, n) {
|
|
2626
|
-
return
|
|
2638
|
+
return ye.defaults.baseURL ? (await ye.post(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2627
2639
|
}
|
|
2628
|
-
async function
|
|
2629
|
-
return
|
|
2640
|
+
async function jr(e, t, n) {
|
|
2641
|
+
return ye.defaults.baseURL ? (await ye.put(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2630
2642
|
}
|
|
2631
|
-
async function
|
|
2632
|
-
return
|
|
2643
|
+
async function Jt(e, t) {
|
|
2644
|
+
return ye.defaults.baseURL ? (await ye.delete(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2633
2645
|
}
|
|
2634
|
-
function
|
|
2646
|
+
function ke(e) {
|
|
2635
2647
|
return e && typeof e == "object" && "data" in e ? e.data : e;
|
|
2636
2648
|
}
|
|
2637
|
-
class
|
|
2649
|
+
class Or {
|
|
2638
2650
|
// ---- Configuration ----
|
|
2639
2651
|
// Chat client uses the default httpClient baseURL, no need for internal tracking
|
|
2640
2652
|
// unless we want to support multiple instances with different URLs in the future.
|
|
2641
2653
|
get baseUrl() {
|
|
2642
|
-
return
|
|
2654
|
+
return ye.defaults.baseURL || "";
|
|
2643
2655
|
}
|
|
2644
2656
|
updateConfig(t) {
|
|
2645
2657
|
if (t.chatBaseUrl)
|
|
2646
|
-
|
|
2658
|
+
ye.defaults.baseURL = t.chatBaseUrl;
|
|
2647
2659
|
else if (t.baseUrl) {
|
|
2648
2660
|
const n = t.baseUrl.replace(/\/+$/, "");
|
|
2649
|
-
n.endsWith("/chat") ?
|
|
2661
|
+
n.endsWith("/chat") ? ye.defaults.baseURL = n : ye.defaults.baseURL = `${n}/chat`;
|
|
2650
2662
|
}
|
|
2651
|
-
t.apiKey !== void 0 ? Ve(t.apiKey) : t.getToken && Ve(t.getToken())
|
|
2663
|
+
t.apiKey !== void 0 ? Ve(t.apiKey) : t.getToken && Ve(t.getToken()), (t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0) && Ur({
|
|
2664
|
+
requestTimeoutMs: t.requestTimeoutMs,
|
|
2665
|
+
historyTimeoutMs: t.historyTimeoutMs
|
|
2666
|
+
});
|
|
2652
2667
|
}
|
|
2653
2668
|
// ---- Token Management ----
|
|
2654
2669
|
getAuthToken() {
|
|
2655
|
-
return
|
|
2670
|
+
return gn();
|
|
2656
2671
|
}
|
|
2657
2672
|
setAuthToken(t) {
|
|
2658
2673
|
Ve(t);
|
|
2659
2674
|
}
|
|
2660
2675
|
onTokenChange(t) {
|
|
2661
|
-
return
|
|
2676
|
+
return mn(t);
|
|
2662
2677
|
}
|
|
2663
2678
|
// ---- Thread Management ----
|
|
2664
2679
|
async listThreads() {
|
|
2665
|
-
const t = await Ie("/threads"), n =
|
|
2680
|
+
const t = await Ie("/threads"), n = ke(t);
|
|
2666
2681
|
return (n == null ? void 0 : n.items) ?? (t == null ? void 0 : t.items) ?? [];
|
|
2667
2682
|
}
|
|
2668
2683
|
async listSharedThreads() {
|
|
2669
|
-
const t = await Ie("/threads/shared"), n =
|
|
2684
|
+
const t = await Ie("/threads/shared"), n = ke(t);
|
|
2670
2685
|
return (n == null ? void 0 : n.items) ?? (t == null ? void 0 : t.items) ?? [];
|
|
2671
2686
|
}
|
|
2672
2687
|
// listUsers moved to AuthApi
|
|
@@ -2674,38 +2689,38 @@ class Lr {
|
|
|
2674
2689
|
const r = {};
|
|
2675
2690
|
t && (r.title = t), n && (r.project = n);
|
|
2676
2691
|
const s = await ft("/threads", Object.keys(r).length ? r : void 0);
|
|
2677
|
-
return
|
|
2692
|
+
return ke(s);
|
|
2678
2693
|
}
|
|
2679
2694
|
async updateThread(t, n) {
|
|
2680
|
-
const r = await
|
|
2681
|
-
return
|
|
2695
|
+
const r = await jr(`/threads/${t}`, { title: n });
|
|
2696
|
+
return ke(r);
|
|
2682
2697
|
}
|
|
2683
2698
|
async deleteThread(t) {
|
|
2684
|
-
const n = await
|
|
2685
|
-
return
|
|
2699
|
+
const n = await Jt(`/threads/${t}`);
|
|
2700
|
+
return ke(n);
|
|
2686
2701
|
}
|
|
2687
2702
|
async shareThread(t, n) {
|
|
2688
2703
|
const r = await ft(`/threads/${t}/share`, {
|
|
2689
2704
|
shared_with_user_id: n
|
|
2690
2705
|
});
|
|
2691
|
-
return
|
|
2706
|
+
return ke(r);
|
|
2692
2707
|
}
|
|
2693
2708
|
async threadInfo(t) {
|
|
2694
2709
|
const n = await Ie(`/threads/${t}/info`);
|
|
2695
|
-
return
|
|
2710
|
+
return ke(n);
|
|
2696
2711
|
}
|
|
2697
2712
|
// ---- Agents ----
|
|
2698
2713
|
async listAgents() {
|
|
2699
|
-
const t = await Ie("/agents"), n =
|
|
2714
|
+
const t = await Ie("/agents"), n = ke(t);
|
|
2700
2715
|
return (n == null ? void 0 : n.items) ?? [];
|
|
2701
2716
|
}
|
|
2702
2717
|
async getAgent(t) {
|
|
2703
2718
|
const n = await Ie(`/agents/${t}`);
|
|
2704
|
-
return
|
|
2719
|
+
return ke(n);
|
|
2705
2720
|
}
|
|
2706
2721
|
async getAgentSchema(t) {
|
|
2707
2722
|
const n = await Ie(`/agents/${t}/schema`);
|
|
2708
|
-
return
|
|
2723
|
+
return ke(n);
|
|
2709
2724
|
}
|
|
2710
2725
|
async getState(t) {
|
|
2711
2726
|
const n = await Ie(`/threads/${t.threadId}/state`, {
|
|
@@ -2714,7 +2729,7 @@ class Lr {
|
|
|
2714
2729
|
checkpoint_ns: t.checkpointNs
|
|
2715
2730
|
}
|
|
2716
2731
|
});
|
|
2717
|
-
return
|
|
2732
|
+
return ke(n);
|
|
2718
2733
|
}
|
|
2719
2734
|
async getStateHistory(t) {
|
|
2720
2735
|
const n = await Ie(`/threads/${t.threadId}/state`, {
|
|
@@ -2722,9 +2737,9 @@ class Lr {
|
|
|
2722
2737
|
checkpoint_id: t.checkpointId,
|
|
2723
2738
|
checkpoint_ns: t.checkpointNs
|
|
2724
2739
|
},
|
|
2725
|
-
timeout:
|
|
2740
|
+
timeout: Fr(),
|
|
2726
2741
|
signal: t.signal
|
|
2727
|
-
}), r =
|
|
2742
|
+
}), r = ke(n);
|
|
2728
2743
|
return r && "checkpoints" in r ? r : {
|
|
2729
2744
|
version: "values@1",
|
|
2730
2745
|
threadId: t.threadId,
|
|
@@ -2734,15 +2749,15 @@ class Lr {
|
|
|
2734
2749
|
// ---- Run Management ----
|
|
2735
2750
|
async cancelRun(t) {
|
|
2736
2751
|
const n = await ft("/stream/cancel", { threadId: t });
|
|
2737
|
-
return
|
|
2752
|
+
return ke(n);
|
|
2738
2753
|
}
|
|
2739
2754
|
async unshareThread(t, n) {
|
|
2740
|
-
const r = await
|
|
2741
|
-
return
|
|
2755
|
+
const r = await Jt(`/threads/${t}/share/${n}`);
|
|
2756
|
+
return ke(r);
|
|
2742
2757
|
}
|
|
2743
2758
|
}
|
|
2744
|
-
const
|
|
2745
|
-
class
|
|
2759
|
+
const yn = new Or();
|
|
2760
|
+
class $r {
|
|
2746
2761
|
// Config logic could go here if files ever need a distinct base URL from chat
|
|
2747
2762
|
// For now, it shares the chatBaseUrl via the shared httpClient
|
|
2748
2763
|
async fetchFileBlob(t, n) {
|
|
@@ -2804,11 +2819,11 @@ class Ur {
|
|
|
2804
2819
|
});
|
|
2805
2820
|
}
|
|
2806
2821
|
}
|
|
2807
|
-
const
|
|
2808
|
-
class
|
|
2822
|
+
const bn = new $r();
|
|
2823
|
+
class Br {
|
|
2809
2824
|
constructor() {
|
|
2810
2825
|
// ---- Configuration ----
|
|
2811
|
-
|
|
2826
|
+
Bt(this, "_authBaseUrl", "");
|
|
2812
2827
|
}
|
|
2813
2828
|
get baseUrl() {
|
|
2814
2829
|
return this._authBaseUrl;
|
|
@@ -2824,13 +2839,13 @@ class zr {
|
|
|
2824
2839
|
}
|
|
2825
2840
|
// ---- Token Management ----
|
|
2826
2841
|
getAuthToken() {
|
|
2827
|
-
return
|
|
2842
|
+
return gn();
|
|
2828
2843
|
}
|
|
2829
2844
|
setAuthToken(t) {
|
|
2830
2845
|
Ve(t);
|
|
2831
2846
|
}
|
|
2832
2847
|
onTokenChange(t) {
|
|
2833
|
-
return
|
|
2848
|
+
return mn(t);
|
|
2834
2849
|
}
|
|
2835
2850
|
// ---- User Management ----
|
|
2836
2851
|
async listUsers() {
|
|
@@ -2838,12 +2853,12 @@ class zr {
|
|
|
2838
2853
|
return (t == null ? void 0 : t.users) ?? [];
|
|
2839
2854
|
}
|
|
2840
2855
|
}
|
|
2841
|
-
const
|
|
2842
|
-
function
|
|
2843
|
-
const n =
|
|
2856
|
+
const Dr = new Br(), wn = Ge(null);
|
|
2857
|
+
function Vr({ children: e, apiConfig: t }) {
|
|
2858
|
+
const n = yn, r = Dr;
|
|
2844
2859
|
if (t) {
|
|
2845
|
-
const o = n.baseUrl, a = r.baseUrl, i = n.getAuthToken();
|
|
2846
|
-
(t.baseUrl || t.chatBaseUrl) && (t.chatBaseUrl && t.chatBaseUrl !== o || t.baseUrl && !o.startsWith(t.baseUrl)) && n.updateConfig(t), (t.baseUrl || t.authBaseUrl) && (t.authBaseUrl && t.authBaseUrl !== a || t.baseUrl && !a.startsWith(t.baseUrl)) && r.updateConfig(t), t.apiKey !== void 0 && t.apiKey !== i && (n.updateConfig({ apiKey: t.apiKey }), r.updateConfig({ apiKey: t.apiKey }));
|
|
2860
|
+
const o = n.baseUrl, a = r.baseUrl, i = n.getAuthToken(), f = t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0;
|
|
2861
|
+
(t.baseUrl || t.chatBaseUrl || f) && (f || t.chatBaseUrl && t.chatBaseUrl !== o || t.baseUrl && !o.startsWith(t.baseUrl)) && n.updateConfig(t), (t.baseUrl || t.authBaseUrl) && (t.authBaseUrl && t.authBaseUrl !== a || t.baseUrl && !a.startsWith(t.baseUrl)) && r.updateConfig(t), t.apiKey !== void 0 && t.apiKey !== i && (n.updateConfig({ apiKey: t.apiKey }), r.updateConfig({ apiKey: t.apiKey }));
|
|
2847
2862
|
}
|
|
2848
2863
|
const s = {
|
|
2849
2864
|
token: n.getAuthToken(),
|
|
@@ -2852,12 +2867,12 @@ function jr({ children: e, apiConfig: t }) {
|
|
|
2852
2867
|
},
|
|
2853
2868
|
chatApi: n,
|
|
2854
2869
|
authApi: r,
|
|
2855
|
-
fileApi:
|
|
2870
|
+
fileApi: bn,
|
|
2856
2871
|
baseUrl: n.baseUrl
|
|
2857
2872
|
};
|
|
2858
|
-
return /* @__PURE__ */ Me(
|
|
2873
|
+
return /* @__PURE__ */ Me(wn.Provider, { value: s, children: e });
|
|
2859
2874
|
}
|
|
2860
|
-
async function
|
|
2875
|
+
async function Kr(e) {
|
|
2861
2876
|
return await new Promise((t, n) => {
|
|
2862
2877
|
const r = new FileReader();
|
|
2863
2878
|
r.onload = () => {
|
|
@@ -2873,11 +2888,11 @@ async function Or(e) {
|
|
|
2873
2888
|
}, r.onerror = (s) => n(s), r.readAsArrayBuffer(e);
|
|
2874
2889
|
});
|
|
2875
2890
|
}
|
|
2876
|
-
async function
|
|
2891
|
+
async function Hr(e = []) {
|
|
2877
2892
|
const t = [], n = [];
|
|
2878
2893
|
for (const r of e)
|
|
2879
2894
|
try {
|
|
2880
|
-
const s = await
|
|
2895
|
+
const s = await Kr(r), o = r.type || "application/octet-stream";
|
|
2881
2896
|
n.push({
|
|
2882
2897
|
filename: r.name,
|
|
2883
2898
|
data: s,
|
|
@@ -2896,28 +2911,28 @@ async function $r(e = []) {
|
|
|
2896
2911
|
}
|
|
2897
2912
|
return { contentParts: t, filesInfo: n };
|
|
2898
2913
|
}
|
|
2899
|
-
function
|
|
2914
|
+
function qr(e) {
|
|
2900
2915
|
return e.filter((t) => t.type === "text").map((t) => t.text).join("");
|
|
2901
2916
|
}
|
|
2902
|
-
function
|
|
2917
|
+
function Gs(e) {
|
|
2903
2918
|
if (e == null) return null;
|
|
2904
2919
|
const t = String(e).trim();
|
|
2905
2920
|
return t.length > 0 ? t : null;
|
|
2906
2921
|
}
|
|
2907
|
-
function
|
|
2922
|
+
function Wr(e) {
|
|
2908
2923
|
const t = e.toolCallId ?? (e.role === "tool" ? e.id : void 0);
|
|
2909
2924
|
return e.role === "tool" && !t && console.error("[meta-utils] CRITICAL: Tool message missing toolCallId!", e), {
|
|
2910
2925
|
toolCallId: t ?? void 0,
|
|
2911
2926
|
name: e.name ?? void 0
|
|
2912
2927
|
};
|
|
2913
2928
|
}
|
|
2914
|
-
function
|
|
2929
|
+
function Js(e) {
|
|
2915
2930
|
var n;
|
|
2916
2931
|
if (e.name && e.name.trim()) return e.name;
|
|
2917
2932
|
const t = (n = e.additionalKwargs) == null ? void 0 : n.agentName;
|
|
2918
2933
|
return typeof t == "string" && t.trim() ? t : e.model && e.model.includes("/") ? e.model.split("/").pop() || null : e.model || null;
|
|
2919
2934
|
}
|
|
2920
|
-
function
|
|
2935
|
+
function Xs(e) {
|
|
2921
2936
|
const t = e.updatedAt ?? e.createdAt ?? "", n = Array.isArray(e.content) ? e.content.map((a) => {
|
|
2922
2937
|
switch (a.type) {
|
|
2923
2938
|
case "text":
|
|
@@ -2930,12 +2945,12 @@ function Hs(e) {
|
|
|
2930
2945
|
}).join("|") : "", r = "checkpointId" in e && e.checkpointId ? `cp:${e.checkpointId}` : "", s = "checkpointNs" in e && e.checkpointNs ? `ns:${e.checkpointNs}` : "", o = [r, s].filter(Boolean).join("|");
|
|
2931
2946
|
return `${e.id}:${t}:${n}${o ? `:${o}` : ""}`;
|
|
2932
2947
|
}
|
|
2933
|
-
function
|
|
2934
|
-
const e = at(
|
|
2948
|
+
function We() {
|
|
2949
|
+
const e = at(wn);
|
|
2935
2950
|
if (!e) throw new Error("useApi must be used within ApiProvider");
|
|
2936
2951
|
return e;
|
|
2937
2952
|
}
|
|
2938
|
-
function
|
|
2953
|
+
function Gr(e, t, n) {
|
|
2939
2954
|
const r = typeof t == "string" ? [{ type: "text", text: t }] : t;
|
|
2940
2955
|
return {
|
|
2941
2956
|
id: `msg-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
|
|
@@ -2945,8 +2960,8 @@ function Vr(e, t, n) {
|
|
|
2945
2960
|
...n
|
|
2946
2961
|
};
|
|
2947
2962
|
}
|
|
2948
|
-
function
|
|
2949
|
-
return typeof e == "string" ?
|
|
2963
|
+
function kn(e, t = "user") {
|
|
2964
|
+
return typeof e == "string" ? Gr(t, e) : e;
|
|
2950
2965
|
}
|
|
2951
2966
|
function rt(e) {
|
|
2952
2967
|
if (!(!e || typeof e != "object" || Array.isArray(e)))
|
|
@@ -2960,7 +2975,7 @@ function dt(e, t) {
|
|
|
2960
2975
|
return r.trim();
|
|
2961
2976
|
}
|
|
2962
2977
|
}
|
|
2963
|
-
function
|
|
2978
|
+
function Jr(e, t) {
|
|
2964
2979
|
if (!e) return null;
|
|
2965
2980
|
for (const n of t) {
|
|
2966
2981
|
const r = e[n];
|
|
@@ -2969,7 +2984,7 @@ function Kr(e, t) {
|
|
|
2969
2984
|
}
|
|
2970
2985
|
return null;
|
|
2971
2986
|
}
|
|
2972
|
-
function
|
|
2987
|
+
function Xt(e) {
|
|
2973
2988
|
const t = rt(e);
|
|
2974
2989
|
if (t)
|
|
2975
2990
|
return rt(t.configurable) ?? t;
|
|
@@ -3021,7 +3036,7 @@ async function Et(e, t) {
|
|
|
3021
3036
|
return n;
|
|
3022
3037
|
}
|
|
3023
3038
|
function tt(e) {
|
|
3024
|
-
const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((o, a) =>
|
|
3039
|
+
const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((o, a) => Xr(Pe(o), a)).filter((o) => !!o)].sort((o, a) => Qt(a.createdAt) - Qt(o.createdAt)), s = r[0] ?? null;
|
|
3025
3040
|
return {
|
|
3026
3041
|
threadId: (e == null ? void 0 : e.threadId) ?? "",
|
|
3027
3042
|
latest: s,
|
|
@@ -3029,12 +3044,12 @@ function tt(e) {
|
|
|
3029
3044
|
interrupt: (s == null ? void 0 : s.interrupt) ?? null
|
|
3030
3045
|
};
|
|
3031
3046
|
}
|
|
3032
|
-
function
|
|
3047
|
+
function Xr(e, t) {
|
|
3033
3048
|
var _, k;
|
|
3034
3049
|
if (!e) return null;
|
|
3035
|
-
const n = ((_ = e.values) == null ? void 0 : _.activeAgent) ?? null, r = (k = e.values) == null ? void 0 : k.messages, o = (Array.isArray(r) ? r : []).map((T) =>
|
|
3050
|
+
const n = ((_ = e.values) == null ? void 0 : _.activeAgent) ?? null, r = (k = e.values) == null ? void 0 : k.messages, o = (Array.isArray(r) ? r : []).map((T) => Qr(T, n)).filter((T) => !!T), a = rt(e.metadata) ?? {}, i = Xt(e.config), f = rt(e.parentConfig), l = Xt(f), c = dt(i, ["checkpointId"]), d = dt(i, ["checkpointNs"]), g = dt(l, ["checkpointId"]), h = rt(e.config), v = Array.isArray(e.tasks) ? e.tasks.map((T) => ({ ...T })) : e.tasks ?? null, m = Array.isArray(e.next) ? [...e.next] : e.next ?? null, y = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), I = {
|
|
3036
3051
|
...a,
|
|
3037
|
-
step:
|
|
3052
|
+
step: Jr(a, ["step"]) ?? 0,
|
|
3038
3053
|
source: dt(a, ["source"]) ?? null
|
|
3039
3054
|
}, A = o.map((T) => ({
|
|
3040
3055
|
...T,
|
|
@@ -3047,7 +3062,7 @@ function Hr(e, t) {
|
|
|
3047
3062
|
createdAt: y,
|
|
3048
3063
|
parentId: g ?? null,
|
|
3049
3064
|
messages: A,
|
|
3050
|
-
interrupt:
|
|
3065
|
+
interrupt: Yr(
|
|
3051
3066
|
N,
|
|
3052
3067
|
t,
|
|
3053
3068
|
c ?? null
|
|
@@ -3060,11 +3075,11 @@ function Hr(e, t) {
|
|
|
3060
3075
|
values: e.values ?? {}
|
|
3061
3076
|
};
|
|
3062
3077
|
}
|
|
3063
|
-
function
|
|
3078
|
+
function Qr(e, t) {
|
|
3064
3079
|
const n = bt(e);
|
|
3065
3080
|
return n ? (n.role === "assistant" && !n.name && t && (n.name = t), n) : null;
|
|
3066
3081
|
}
|
|
3067
|
-
function
|
|
3082
|
+
function Yr(e, t, n) {
|
|
3068
3083
|
const r = e.length;
|
|
3069
3084
|
for (let s = r - 1; s >= 0; s -= 1) {
|
|
3070
3085
|
const o = e[s];
|
|
@@ -3080,29 +3095,29 @@ function Gr(e, t, n) {
|
|
|
3080
3095
|
}
|
|
3081
3096
|
return null;
|
|
3082
3097
|
}
|
|
3083
|
-
function
|
|
3098
|
+
function Qt(e) {
|
|
3084
3099
|
if (!e) return 0;
|
|
3085
3100
|
const t = Date.parse(e);
|
|
3086
3101
|
return Number.isFinite(t) ? t : 0;
|
|
3087
3102
|
}
|
|
3088
|
-
function
|
|
3103
|
+
function Zr(e) {
|
|
3089
3104
|
return !!e && typeof e == "object" && "data" in e;
|
|
3090
3105
|
}
|
|
3091
|
-
function
|
|
3106
|
+
function es(e = {}) {
|
|
3092
3107
|
const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, s] = H(e.token ?? null), o = K(e.headers ?? {}), a = e.credentials ?? "include", i = K(e);
|
|
3093
3108
|
oe(() => {
|
|
3094
3109
|
i.current = e;
|
|
3095
3110
|
}, [e]);
|
|
3096
3111
|
const f = E((p) => {
|
|
3097
|
-
var
|
|
3112
|
+
var U, q, B, ee, Q, re, W, se, ge, be;
|
|
3098
3113
|
const b = i.current;
|
|
3099
3114
|
if (!b) return;
|
|
3100
3115
|
if (p.type === "thread_info") {
|
|
3101
|
-
(
|
|
3116
|
+
(U = b.onThreadInfo) == null || U.call(b, p);
|
|
3102
3117
|
return;
|
|
3103
3118
|
}
|
|
3104
3119
|
if (p.type === "values" && Array.isArray(p.checkpoints)) {
|
|
3105
|
-
(
|
|
3120
|
+
(q = b.handleValuesEvent) == null || q.call(b, p);
|
|
3106
3121
|
return;
|
|
3107
3122
|
}
|
|
3108
3123
|
if (p.type === "metadata") {
|
|
@@ -3113,8 +3128,8 @@ function Jr(e = {}) {
|
|
|
3113
3128
|
(ee = b.onCustomEvent) == null || ee.call(b, p);
|
|
3114
3129
|
return;
|
|
3115
3130
|
}
|
|
3116
|
-
(Q = b.onEvent) == null || Q.call(b, p), p.type === "updates" && ((re = b.onUpdateEvent) == null || re.call(b, p)), p.type === "tool.end" ? (
|
|
3117
|
-
}, []), [l, c] = H(!1), [d, g] = H(null), [h, v] = H(""), [m, y] = H(null), [I, A] = H(0), [x, N] = H(!1), [_, k] = H({}), [T, L] = H(null), [j, O] = H({}), $ = K(null), C = K(!0), J = K(0),
|
|
3131
|
+
(Q = b.onEvent) == null || Q.call(b, p), p.type === "updates" && ((re = b.onUpdateEvent) == null || re.call(b, p)), p.type === "tool.end" ? (W = b.onToolEnd) == null || W.call(b, p) : p.type === "tool.start" && ((se = b.onToolStart) == null || se.call(b, p)), p.type === "heartbeat" && ((ge = b.onHeartbeat) == null || ge.call(b, p)), p.type === "token" && ((be = b.onToken) == null || be.call(b, p.token));
|
|
3132
|
+
}, []), [l, c] = H(!1), [d, g] = H(null), [h, v] = H(""), [m, y] = H(null), [I, A] = H(0), [x, N] = H(!1), [_, k] = H({}), [T, L] = H(null), [j, O] = H({}), $ = K(null), C = K(!0), J = K(0), G = K(null), X = K(null), te = K(null), ne = K(null), S = K([]), P = K(/* @__PURE__ */ new Set()), D = K({
|
|
3118
3133
|
messageId: null,
|
|
3119
3134
|
lastSeq: null,
|
|
3120
3135
|
lastText: ""
|
|
@@ -3127,14 +3142,14 @@ function Jr(e = {}) {
|
|
|
3127
3142
|
lastText: ""
|
|
3128
3143
|
};
|
|
3129
3144
|
}, []), R = E(() => {
|
|
3130
|
-
var
|
|
3145
|
+
var U;
|
|
3131
3146
|
console.debug("[use-chat] stop() invoked - aborting stream");
|
|
3132
|
-
const p = (
|
|
3133
|
-
var
|
|
3134
|
-
(
|
|
3147
|
+
const p = (U = G.current) == null ? void 0 : U.threadId, b = () => {
|
|
3148
|
+
var q;
|
|
3149
|
+
(q = $.current) == null || q.abort(), $.current = null, G.current = null, c(!1), N(!1), J.current = 0, A(0);
|
|
3135
3150
|
};
|
|
3136
|
-
(p ?
|
|
3137
|
-
console.warn("[use-chat] cancel run failed:",
|
|
3151
|
+
(p ? yn.cancelRun(p).catch((q) => {
|
|
3152
|
+
console.warn("[use-chat] cancel run failed:", q);
|
|
3138
3153
|
}) : Promise.resolve()).finally(b);
|
|
3139
3154
|
}, []), M = E(
|
|
3140
3155
|
(p) => {
|
|
@@ -3155,22 +3170,22 @@ function Jr(e = {}) {
|
|
|
3155
3170
|
lastSeq: null,
|
|
3156
3171
|
lastText: ""
|
|
3157
3172
|
};
|
|
3158
|
-
const
|
|
3159
|
-
$.current =
|
|
3160
|
-
let
|
|
3173
|
+
const z = new AbortController();
|
|
3174
|
+
$.current = z;
|
|
3175
|
+
let U = null, q = !1;
|
|
3161
3176
|
const B = (ee) => {
|
|
3162
3177
|
if (P.current.has(ee)) return;
|
|
3163
3178
|
const Q = S.current[0];
|
|
3164
3179
|
Q && k((re) => {
|
|
3165
|
-
let
|
|
3166
|
-
if (!
|
|
3180
|
+
let W = T;
|
|
3181
|
+
if (!W) {
|
|
3167
3182
|
const de = Object.values(re).filter((je) => je.role === "assistant");
|
|
3168
|
-
de.length > 0 && (
|
|
3183
|
+
de.length > 0 && (W = de[de.length - 1].id);
|
|
3169
3184
|
}
|
|
3170
|
-
if (!
|
|
3171
|
-
const se = re[
|
|
3172
|
-
return ge.some((de) => de.id ===
|
|
3173
|
-
id:
|
|
3185
|
+
if (!W || !re[W]) return re;
|
|
3186
|
+
const se = re[W], ge = [...se.toolCalls || []], be = Q.id ?? `task-${ee}`;
|
|
3187
|
+
return ge.some((de) => de.id === be && de.name === "task" && de.scope === ee) || ge.push({
|
|
3188
|
+
id: be,
|
|
3174
3189
|
name: "task",
|
|
3175
3190
|
args: {
|
|
3176
3191
|
description: Q.description,
|
|
@@ -3179,15 +3194,15 @@ function Jr(e = {}) {
|
|
|
3179
3194
|
status: "running",
|
|
3180
3195
|
content: Q.description,
|
|
3181
3196
|
scope: ee
|
|
3182
|
-
}), P.current.add(ee), S.current.shift(), { ...re, [
|
|
3197
|
+
}), P.current.add(ee), S.current.shift(), { ...re, [W]: { ...se, toolCalls: ge } };
|
|
3183
3198
|
});
|
|
3184
3199
|
};
|
|
3185
|
-
return
|
|
3200
|
+
return G.current = {
|
|
3186
3201
|
threadId: b.threadId ?? null,
|
|
3187
3202
|
headers: {},
|
|
3188
3203
|
isStreaming: !0
|
|
3189
3204
|
}, (async () => {
|
|
3190
|
-
var ee, Q, re,
|
|
3205
|
+
var ee, Q, re, W, se, ge, be, ue, de, je, Oe, Xe;
|
|
3191
3206
|
try {
|
|
3192
3207
|
let Ae = {};
|
|
3193
3208
|
try {
|
|
@@ -3210,7 +3225,7 @@ function Jr(e = {}) {
|
|
|
3210
3225
|
let Se = {};
|
|
3211
3226
|
if (typeof window < "u")
|
|
3212
3227
|
try {
|
|
3213
|
-
const fe = (
|
|
3228
|
+
const fe = (W = window.localStorage) == null ? void 0 : W.getItem(nt.authSessionId);
|
|
3214
3229
|
fe && (Se = { "X-Session-Id": fe });
|
|
3215
3230
|
} catch {
|
|
3216
3231
|
}
|
|
@@ -3226,10 +3241,10 @@ function Jr(e = {}) {
|
|
|
3226
3241
|
method: "POST",
|
|
3227
3242
|
headers: vt,
|
|
3228
3243
|
body: JSON.stringify(b),
|
|
3229
|
-
signal:
|
|
3244
|
+
signal: z.signal,
|
|
3230
3245
|
credentials: a
|
|
3231
3246
|
});
|
|
3232
|
-
if (
|
|
3247
|
+
if (G.current && (G.current.headers = Ke), !Te.ok || !Te.body) {
|
|
3233
3248
|
const fe = await Te.text().catch(() => "");
|
|
3234
3249
|
console.debug(
|
|
3235
3250
|
"[use-chat] non-OK response",
|
|
@@ -3237,10 +3252,10 @@ function Jr(e = {}) {
|
|
|
3237
3252
|
fe == null ? void 0 : fe.slice(0, 500)
|
|
3238
3253
|
);
|
|
3239
3254
|
const xe = `stream ${Te.status}${fe ? ": " + fe : ""}`;
|
|
3240
|
-
throw xe && (g(xe),
|
|
3255
|
+
throw xe && (g(xe), U = "error"), new Error(xe);
|
|
3241
3256
|
}
|
|
3242
3257
|
N(!0);
|
|
3243
|
-
const Qe = Te.body.getReader(),
|
|
3258
|
+
const Qe = Te.body.getReader(), En = new TextDecoder();
|
|
3244
3259
|
let $e = "", ct = [];
|
|
3245
3260
|
J.current = 0, A(0);
|
|
3246
3261
|
let Ye = 0, Be = null;
|
|
@@ -3250,31 +3265,31 @@ function Jr(e = {}) {
|
|
|
3250
3265
|
ct = [], C.current && v((xe) => xe + fe);
|
|
3251
3266
|
}
|
|
3252
3267
|
Be = null;
|
|
3253
|
-
},
|
|
3268
|
+
}, Pn = () => {
|
|
3254
3269
|
typeof window < "u" && Be == null && (Be = requestAnimationFrame(It));
|
|
3255
3270
|
};
|
|
3256
|
-
let
|
|
3257
|
-
const
|
|
3258
|
-
Date.now() -
|
|
3259
|
-
}, 5e3),
|
|
3271
|
+
let jt = Date.now();
|
|
3272
|
+
const Rn = setInterval(() => {
|
|
3273
|
+
Date.now() - jt > 18e5 && (g("Stream idle timeout"), U = "error", z.abort());
|
|
3274
|
+
}, 5e3), Nn = 1024 * 1024;
|
|
3260
3275
|
try {
|
|
3261
3276
|
const xe = (Te.headers.get("X-Thread-Id") || Te.headers.get("x-thread-id")) ?? null;
|
|
3262
|
-
for (
|
|
3263
|
-
...
|
|
3277
|
+
for (G.current && !G.current.threadId && (G.current = {
|
|
3278
|
+
...G.current,
|
|
3264
3279
|
threadId: xe
|
|
3265
3280
|
}); ; ) {
|
|
3266
3281
|
const { value: Tt, done: lt } = await Qe.read();
|
|
3267
3282
|
if (lt) break;
|
|
3268
|
-
$e +=
|
|
3283
|
+
$e += En.decode(Tt, { stream: !0 }), $e.length > Nn && ($e = "", console.warn("Stream buffer reset: exceeded 1MB"));
|
|
3269
3284
|
let He;
|
|
3270
3285
|
for (; (He = $e.indexOf(`
|
|
3271
3286
|
|
|
3272
3287
|
`)) >= 0; ) {
|
|
3273
3288
|
const ut = $e.slice(0, He);
|
|
3274
3289
|
$e = $e.slice(He + 2);
|
|
3275
|
-
const
|
|
3290
|
+
const _n = ut.split(/\r?\n/), Ot = [];
|
|
3276
3291
|
let At = null;
|
|
3277
|
-
for (const w of
|
|
3292
|
+
for (const w of _n) {
|
|
3278
3293
|
if (w.startsWith(":")) {
|
|
3279
3294
|
w.startsWith(": heartbeat") && console.debug("[use-chat] SSE heartbeat comment received");
|
|
3280
3295
|
continue;
|
|
@@ -3287,11 +3302,11 @@ function Jr(e = {}) {
|
|
|
3287
3302
|
}
|
|
3288
3303
|
if (w.startsWith("data:")) {
|
|
3289
3304
|
const ce = w.slice(5);
|
|
3290
|
-
|
|
3305
|
+
Ot.push(ce.startsWith(" ") ? ce.slice(1) : ce);
|
|
3291
3306
|
}
|
|
3292
3307
|
}
|
|
3293
3308
|
}
|
|
3294
|
-
const St =
|
|
3309
|
+
const St = Ot.join(`
|
|
3295
3310
|
`);
|
|
3296
3311
|
if (!St) continue;
|
|
3297
3312
|
let Re;
|
|
@@ -3302,13 +3317,13 @@ function Jr(e = {}) {
|
|
|
3302
3317
|
continue;
|
|
3303
3318
|
}
|
|
3304
3319
|
At && typeof Re == "object" && Re !== null && !("type" in Re) && (Re.type = At);
|
|
3305
|
-
const
|
|
3306
|
-
if (
|
|
3320
|
+
const $t = Zr(Re) ? Re.data : Re;
|
|
3321
|
+
if (!$t) {
|
|
3307
3322
|
console.warn("[use-chat] dropped envelope event without payload", Re);
|
|
3308
3323
|
continue;
|
|
3309
3324
|
}
|
|
3310
|
-
const ae =
|
|
3311
|
-
|
|
3325
|
+
const ae = Er($t);
|
|
3326
|
+
jt = Date.now();
|
|
3312
3327
|
const De = ae.seq;
|
|
3313
3328
|
if (De !== void 0) {
|
|
3314
3329
|
if (De <= Ye) {
|
|
@@ -3317,9 +3332,9 @@ function Jr(e = {}) {
|
|
|
3317
3332
|
}
|
|
3318
3333
|
Ye > 0 && De > Ye + 1, Ye = De, J.current = De, A(De);
|
|
3319
3334
|
}
|
|
3320
|
-
const
|
|
3335
|
+
const Ln = ["messages/partial", "metadata", "checkpoint", "values", "heartbeat", "token", "status", "error", "interrupt", "tool.start", "tool.progress", "tool.end", "task.start"];
|
|
3321
3336
|
let ve = ae.type || "unknown";
|
|
3322
|
-
if (
|
|
3337
|
+
if (Ln.includes(ve) || (ae.messages || ae.content !== void 0 && ae.id) && (ve = "messages/partial"), ve === "checkpoint") {
|
|
3323
3338
|
const w = ae;
|
|
3324
3339
|
X.current = w.checkpointId ?? null, te.current = w.checkpointNs ?? null, y(w.checkpointId ?? null);
|
|
3325
3340
|
} else if (ve === "values") {
|
|
@@ -3359,10 +3374,10 @@ function Jr(e = {}) {
|
|
|
3359
3374
|
}
|
|
3360
3375
|
if (Y && me[Y]) {
|
|
3361
3376
|
const le = me[Y], he = [...le.toolCalls || []], Ce = he.findIndex((Ne) => Ne.id === ce);
|
|
3362
|
-
let
|
|
3363
|
-
return ae.type === "tool.start" ?
|
|
3377
|
+
let we = w.content || w.status || "Processing...";
|
|
3378
|
+
return ae.type === "tool.start" ? we = `Starting ${w.name || w.tool || "tool"}...` : ae.type === "tool.end" && w.error && (we = `Error: ${w.error}`), Ce >= 0 ? he[Ce] = {
|
|
3364
3379
|
...he[Ce],
|
|
3365
|
-
content:
|
|
3380
|
+
content: we,
|
|
3366
3381
|
status: ae.type === "tool.start" ? "running" : ae.type === "tool.end" ? w.error ? "failed" : "completed" : he[Ce].status,
|
|
3367
3382
|
artifact: w.artifact || he[Ce].artifact,
|
|
3368
3383
|
scope: ie ?? he[Ce].scope
|
|
@@ -3371,7 +3386,7 @@ function Jr(e = {}) {
|
|
|
3371
3386
|
name: w.name || w.tool || "tool",
|
|
3372
3387
|
args: w.args || {},
|
|
3373
3388
|
status: ae.type === "tool.end" ? w.error ? "failed" : "completed" : "running",
|
|
3374
|
-
content:
|
|
3389
|
+
content: we,
|
|
3375
3390
|
artifact: w.artifact,
|
|
3376
3391
|
scope: ie
|
|
3377
3392
|
}), { ...me, [Y]: { ...le, toolCalls: he } };
|
|
@@ -3385,7 +3400,7 @@ function Jr(e = {}) {
|
|
|
3385
3400
|
if (ie) {
|
|
3386
3401
|
const Y = ie.id, le = ie.content ?? "", he = !1, Ce = he ? (D.current.lastText || "") + le : le;
|
|
3387
3402
|
if (D.current.messageId !== Y) {
|
|
3388
|
-
const
|
|
3403
|
+
const we = ie.name ?? ie.agentName ?? "assistant";
|
|
3389
3404
|
D.current = {
|
|
3390
3405
|
messageId: Y,
|
|
3391
3406
|
lastSeq: null,
|
|
@@ -3394,30 +3409,30 @@ function Jr(e = {}) {
|
|
|
3394
3409
|
const Ne = bt({
|
|
3395
3410
|
id: Y,
|
|
3396
3411
|
role: "assistant",
|
|
3397
|
-
name:
|
|
3398
|
-
model:
|
|
3412
|
+
name: we,
|
|
3413
|
+
model: we,
|
|
3399
3414
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3400
3415
|
content: [{ type: "text", text: Ce }]
|
|
3401
3416
|
});
|
|
3402
|
-
k((
|
|
3417
|
+
k((zn) => ({ ...zn, [Y]: Ne })), L(Y), D.current.lastText = Ce;
|
|
3403
3418
|
} else
|
|
3404
|
-
k((
|
|
3405
|
-
const Ne =
|
|
3419
|
+
k((we) => {
|
|
3420
|
+
const Ne = we[Y];
|
|
3406
3421
|
return Ne ? {
|
|
3407
|
-
...
|
|
3422
|
+
...we,
|
|
3408
3423
|
[Y]: {
|
|
3409
3424
|
...Ne,
|
|
3410
3425
|
content: [{ type: "text", text: Ce }],
|
|
3411
3426
|
// Preserve existing metadata if the chunk doesn't have it
|
|
3412
3427
|
responseMetadata: ie.responseMetadata ?? Ne.responseMetadata
|
|
3413
3428
|
}
|
|
3414
|
-
} :
|
|
3429
|
+
} : we;
|
|
3415
3430
|
}), D.current.lastText = Ce;
|
|
3416
3431
|
if (!he) {
|
|
3417
|
-
const
|
|
3418
|
-
if (le.length >
|
|
3419
|
-
const Ne = le.slice(
|
|
3420
|
-
ct.push(Ne),
|
|
3432
|
+
const we = D.current.lastText || "";
|
|
3433
|
+
if (le.length > we.length) {
|
|
3434
|
+
const Ne = le.slice(we.length);
|
|
3435
|
+
ct.push(Ne), Pn();
|
|
3421
3436
|
}
|
|
3422
3437
|
}
|
|
3423
3438
|
}
|
|
@@ -3441,29 +3456,29 @@ function Jr(e = {}) {
|
|
|
3441
3456
|
y(ae.checkpointId ?? null);
|
|
3442
3457
|
else if (ve === "error") {
|
|
3443
3458
|
const w = ae;
|
|
3444
|
-
if (g(w.message),
|
|
3459
|
+
if (g(w.message), U = "error", w.error_type === "auth_error" || w.code === "TOKEN_EXPIRED" || ((ge = w.message) == null ? void 0 : ge.includes("token")) || ((be = w.message) == null ? void 0 : be.includes("401")) || ((ue = w.message) == null ? void 0 : ue.includes("unauthorized")) || ((de = w.message) == null ? void 0 : de.includes("Unauthorized"))) {
|
|
3445
3460
|
console.error("[use-chat] Auth error detected:", w.message);
|
|
3446
3461
|
try {
|
|
3447
3462
|
(je = e.onAuthError) == null || je.call(e, w.message);
|
|
3448
3463
|
} catch (ie) {
|
|
3449
3464
|
console.warn("[use-chat] onAuthError handler failed", ie);
|
|
3450
3465
|
}
|
|
3451
|
-
|
|
3466
|
+
z.abort();
|
|
3452
3467
|
}
|
|
3453
3468
|
} else if (ve === "status") {
|
|
3454
3469
|
const w = ae;
|
|
3455
|
-
(w.status === "completed" || w.status === "interrupted" || w.status === "error") && c(!1);
|
|
3470
|
+
(w.status === "completed" || w.status === "interrupted" || w.status === "error") && (c(!1), console.log("[use-chat] Status event received:", w));
|
|
3456
3471
|
}
|
|
3457
3472
|
f(ae);
|
|
3458
3473
|
}
|
|
3459
3474
|
}
|
|
3460
|
-
It(),
|
|
3475
|
+
It(), U === null && !z.signal.aborted && (U = "complete");
|
|
3461
3476
|
} catch (fe) {
|
|
3462
3477
|
if (fe.name === "AbortError")
|
|
3463
|
-
|
|
3478
|
+
U = U ?? "aborted";
|
|
3464
3479
|
else {
|
|
3465
3480
|
const xe = fe.message || String(fe);
|
|
3466
|
-
|
|
3481
|
+
U = "error", g(xe);
|
|
3467
3482
|
}
|
|
3468
3483
|
} finally {
|
|
3469
3484
|
try {
|
|
@@ -3472,14 +3487,14 @@ function Jr(e = {}) {
|
|
|
3472
3487
|
} finally {
|
|
3473
3488
|
(Oe = Qe.releaseLock) == null || Oe.call(Qe);
|
|
3474
3489
|
}
|
|
3475
|
-
Be !== null && typeof window < "u" && window.cancelAnimationFrame(Be), clearInterval(
|
|
3490
|
+
Be !== null && typeof window < "u" && window.cancelAnimationFrame(Be), clearInterval(Rn);
|
|
3476
3491
|
}
|
|
3477
3492
|
} catch (Ae) {
|
|
3478
3493
|
if (Ae.name === "AbortError")
|
|
3479
|
-
|
|
3494
|
+
U = U ?? "aborted";
|
|
3480
3495
|
else {
|
|
3481
3496
|
const Se = Ae.message || String(Ae);
|
|
3482
|
-
|
|
3497
|
+
U = "error", g(Se), q || (q = !0, (Xe = e.onConnectionError) == null || Xe.call(e, Se));
|
|
3483
3498
|
}
|
|
3484
3499
|
} finally {
|
|
3485
3500
|
const Ae = J.current, Se = X.current, Ke = te.current, vt = ne.current;
|
|
@@ -3496,7 +3511,7 @@ function Jr(e = {}) {
|
|
|
3496
3511
|
} catch (Te) {
|
|
3497
3512
|
console.warn("[use-chat] onClosed callback failed", Te);
|
|
3498
3513
|
}
|
|
3499
|
-
c(!1), N(!1), $.current = null, J.current = 0, A(0),
|
|
3514
|
+
c(!1), N(!1), $.current = null, J.current = 0, A(0), G.current = null;
|
|
3500
3515
|
}
|
|
3501
3516
|
})(), Promise.resolve();
|
|
3502
3517
|
},
|
|
@@ -3528,7 +3543,7 @@ function Jr(e = {}) {
|
|
|
3528
3543
|
submit: M
|
|
3529
3544
|
};
|
|
3530
3545
|
}
|
|
3531
|
-
const
|
|
3546
|
+
const ts = ["detail", "message", "error", "description", "title"];
|
|
3532
3547
|
function pt(e) {
|
|
3533
3548
|
if (!e) return null;
|
|
3534
3549
|
if (typeof e == "string") {
|
|
@@ -3545,7 +3560,7 @@ function pt(e) {
|
|
|
3545
3560
|
}
|
|
3546
3561
|
if (typeof e == "object") {
|
|
3547
3562
|
const t = e;
|
|
3548
|
-
for (const n of
|
|
3563
|
+
for (const n of ts) {
|
|
3549
3564
|
const r = pt(t[n]);
|
|
3550
3565
|
if (r)
|
|
3551
3566
|
return r;
|
|
@@ -3557,7 +3572,7 @@ function pt(e) {
|
|
|
3557
3572
|
}
|
|
3558
3573
|
return null;
|
|
3559
3574
|
}
|
|
3560
|
-
function
|
|
3575
|
+
function ns(e) {
|
|
3561
3576
|
if (!e) return "Request failed";
|
|
3562
3577
|
const t = e.response, n = pt(t == null ? void 0 : t.data);
|
|
3563
3578
|
if (n) return n;
|
|
@@ -3571,7 +3586,7 @@ function Qr(e) {
|
|
|
3571
3586
|
}
|
|
3572
3587
|
return t != null && t.status ? `Request failed with status code ${t.status}` : "Request failed";
|
|
3573
3588
|
}
|
|
3574
|
-
function
|
|
3589
|
+
function rs({
|
|
3575
3590
|
api: e,
|
|
3576
3591
|
initialThreadId: t = null,
|
|
3577
3592
|
onError: n,
|
|
@@ -3657,14 +3672,14 @@ function Yr({
|
|
|
3657
3672
|
try {
|
|
3658
3673
|
await e.shareThread(S, P), await j(), x("Shared successfully");
|
|
3659
3674
|
} catch (D) {
|
|
3660
|
-
const V =
|
|
3675
|
+
const V = ns(D);
|
|
3661
3676
|
throw n == null || n(V), x(`Failed to share: ${V}`), new Error(V);
|
|
3662
3677
|
} finally {
|
|
3663
3678
|
_(!1);
|
|
3664
3679
|
}
|
|
3665
3680
|
},
|
|
3666
3681
|
[e, n, j]
|
|
3667
|
-
),
|
|
3682
|
+
), G = E(
|
|
3668
3683
|
async (S, P) => {
|
|
3669
3684
|
try {
|
|
3670
3685
|
await e.unshareThread(S, P), await j();
|
|
@@ -3682,9 +3697,9 @@ function Yr({
|
|
|
3682
3697
|
refreshThreads: L,
|
|
3683
3698
|
refreshSharedThreads: j,
|
|
3684
3699
|
shareThread: J,
|
|
3685
|
-
unshareThread:
|
|
3700
|
+
unshareThread: G
|
|
3686
3701
|
}),
|
|
3687
|
-
[O, $, C, L, j, J,
|
|
3702
|
+
[O, $, C, L, j, J, G]
|
|
3688
3703
|
), te = E((S) => {
|
|
3689
3704
|
if (!(S != null && S.threadId)) return;
|
|
3690
3705
|
const P = {
|
|
@@ -3723,14 +3738,14 @@ function Yr({
|
|
|
3723
3738
|
clearShareStatus: ne
|
|
3724
3739
|
};
|
|
3725
3740
|
}
|
|
3726
|
-
const
|
|
3727
|
-
function
|
|
3741
|
+
const vn = Ge(null);
|
|
3742
|
+
function ss({
|
|
3728
3743
|
children: e,
|
|
3729
3744
|
initialThreadId: t = null,
|
|
3730
3745
|
onError: n,
|
|
3731
3746
|
onThreadChange: r
|
|
3732
3747
|
}) {
|
|
3733
|
-
const { chatApi: s } =
|
|
3748
|
+
const { chatApi: s } = We(), {
|
|
3734
3749
|
threads: o,
|
|
3735
3750
|
currentThreadId: a,
|
|
3736
3751
|
setCurrentThreadId: i,
|
|
@@ -3744,7 +3759,7 @@ function Zr({
|
|
|
3744
3759
|
shareInFlight: m,
|
|
3745
3760
|
shareStatus: y,
|
|
3746
3761
|
clearShareStatus: I
|
|
3747
|
-
} =
|
|
3762
|
+
} = rs({
|
|
3748
3763
|
api: s,
|
|
3749
3764
|
initialThreadId: t,
|
|
3750
3765
|
onError: n,
|
|
@@ -3781,14 +3796,14 @@ function Zr({
|
|
|
3781
3796
|
v
|
|
3782
3797
|
]
|
|
3783
3798
|
);
|
|
3784
|
-
return /* @__PURE__ */ Me(
|
|
3799
|
+
return /* @__PURE__ */ Me(vn.Provider, { value: A, children: e });
|
|
3785
3800
|
}
|
|
3786
3801
|
function st() {
|
|
3787
|
-
const e = at(
|
|
3802
|
+
const e = at(vn);
|
|
3788
3803
|
if (!e) throw new Error("useThreads must be used within a ThreadsProvider");
|
|
3789
3804
|
return e;
|
|
3790
3805
|
}
|
|
3791
|
-
function
|
|
3806
|
+
function In(e) {
|
|
3792
3807
|
const t = e.artifact;
|
|
3793
3808
|
return !t || typeof t != "object" ? null : "metadata" in t && t.metadata ? t.metadata : {
|
|
3794
3809
|
id: t.id ?? e.id ?? `artifact-${Date.now()}`,
|
|
@@ -3798,8 +3813,8 @@ function wn(e) {
|
|
|
3798
3813
|
progress: t.progress ?? void 0
|
|
3799
3814
|
};
|
|
3800
3815
|
}
|
|
3801
|
-
function
|
|
3802
|
-
const n =
|
|
3816
|
+
function os(e, t) {
|
|
3817
|
+
const n = In(e);
|
|
3803
3818
|
if (!n) return e;
|
|
3804
3819
|
const r = {
|
|
3805
3820
|
...n,
|
|
@@ -3814,9 +3829,9 @@ function es(e, t) {
|
|
|
3814
3829
|
}
|
|
3815
3830
|
};
|
|
3816
3831
|
}
|
|
3817
|
-
function
|
|
3832
|
+
function as(e, t, n) {
|
|
3818
3833
|
return e.find((r) => {
|
|
3819
|
-
const s =
|
|
3834
|
+
const s = In(r);
|
|
3820
3835
|
return !!((s == null ? void 0 : s.id) === t || n && r.toolCallId === n);
|
|
3821
3836
|
}) ?? null;
|
|
3822
3837
|
}
|
|
@@ -3826,7 +3841,7 @@ function gt(e) {
|
|
|
3826
3841
|
function it(e, t, n) {
|
|
3827
3842
|
return t < 0 || t >= e.length ? e : [...e.slice(0, t), n, ...e.slice(t + 1)];
|
|
3828
3843
|
}
|
|
3829
|
-
function
|
|
3844
|
+
function is(e, t, n) {
|
|
3830
3845
|
for (let r = e.length - 1; r >= 0; r--)
|
|
3831
3846
|
if (e[r].role === "assistant") {
|
|
3832
3847
|
const o = { ...e[r], checkpointId: t, checkpointNs: n ?? void 0 };
|
|
@@ -3834,7 +3849,7 @@ function ns(e, t, n) {
|
|
|
3834
3849
|
}
|
|
3835
3850
|
return e;
|
|
3836
3851
|
}
|
|
3837
|
-
function
|
|
3852
|
+
function cs(e) {
|
|
3838
3853
|
const t = /* @__PURE__ */ new Set();
|
|
3839
3854
|
return e.map((n) => {
|
|
3840
3855
|
var o;
|
|
@@ -3850,7 +3865,7 @@ function rs(e) {
|
|
|
3850
3865
|
return s ? t.has(s) ? !1 : (t.add(s), !0) : !0;
|
|
3851
3866
|
});
|
|
3852
3867
|
}
|
|
3853
|
-
const
|
|
3868
|
+
const ls = {
|
|
3854
3869
|
messages: [],
|
|
3855
3870
|
taskMessagesByScope: {},
|
|
3856
3871
|
assemblingId: null,
|
|
@@ -3860,7 +3875,7 @@ const ss = {
|
|
|
3860
3875
|
pendingInterrupt: null,
|
|
3861
3876
|
values: {}
|
|
3862
3877
|
};
|
|
3863
|
-
function
|
|
3878
|
+
function us(e, t) {
|
|
3864
3879
|
var n;
|
|
3865
3880
|
switch (t.type) {
|
|
3866
3881
|
case "reset":
|
|
@@ -3901,17 +3916,17 @@ function os(e, t) {
|
|
|
3901
3916
|
return { ...e, messages: a };
|
|
3902
3917
|
}
|
|
3903
3918
|
case "event":
|
|
3904
|
-
return
|
|
3919
|
+
return Yt(e, t.payload.ev);
|
|
3905
3920
|
case "batch": {
|
|
3906
3921
|
const { events: r } = t.payload;
|
|
3907
|
-
return r.length ? r.reduce((s, o) =>
|
|
3922
|
+
return r.length ? r.reduce((s, o) => Yt(s, o), e) : e;
|
|
3908
3923
|
}
|
|
3909
3924
|
default:
|
|
3910
3925
|
return e;
|
|
3911
3926
|
}
|
|
3912
3927
|
}
|
|
3913
|
-
function
|
|
3914
|
-
const [t, n] =
|
|
3928
|
+
function ds(e = []) {
|
|
3929
|
+
const [t, n] = jn(us, { ...ls, messages: e }), r = K([]), s = K(null), o = K(null), a = E(() => {
|
|
3915
3930
|
s.current !== null && typeof window < "u" && window.cancelAnimationFrame(s.current), o.current !== null && clearTimeout(o.current), s.current = null, o.current = null;
|
|
3916
3931
|
const c = r.current;
|
|
3917
3932
|
c.length && (r.current = [], n({ type: "batch", payload: { events: c } }));
|
|
@@ -3932,19 +3947,19 @@ function as(e = []) {
|
|
|
3932
3947
|
}), [f]);
|
|
3933
3948
|
return { state: t, dispatch: n, ...l };
|
|
3934
3949
|
}
|
|
3935
|
-
function
|
|
3950
|
+
function Yt(e, t) {
|
|
3936
3951
|
var a;
|
|
3937
3952
|
const n = t, r = n == null ? void 0 : n.origin, s = n == null ? void 0 : n.scope, o = r === "task" || typeof s == "string" && s.startsWith("tools:");
|
|
3938
3953
|
if (t.type === "tool.start")
|
|
3939
|
-
return o ? e :
|
|
3954
|
+
return o ? e : gs(e, t);
|
|
3940
3955
|
if (t.type === "tool.progress")
|
|
3941
|
-
return o ? e :
|
|
3956
|
+
return o ? e : ms(e, t);
|
|
3942
3957
|
if (t.type === "tool.end")
|
|
3943
|
-
return o ? e :
|
|
3958
|
+
return o ? e : hs(e, t);
|
|
3944
3959
|
if (t.type === "artifact.update")
|
|
3945
|
-
return
|
|
3960
|
+
return ys(e, t);
|
|
3946
3961
|
if (t.type === "checkpoint") {
|
|
3947
|
-
const i = t.checkpointNs ?? e.lastCheckpointNs ?? null, f =
|
|
3962
|
+
const i = t.checkpointNs ?? e.lastCheckpointNs ?? null, f = is(e.messages, t.checkpointId, i);
|
|
3948
3963
|
return { ...e, lastCheckpointId: t.checkpointId, lastCheckpointNs: i, messages: f };
|
|
3949
3964
|
}
|
|
3950
3965
|
if (t.type === "error") {
|
|
@@ -3957,7 +3972,7 @@ function Xt(e, t) {
|
|
|
3957
3972
|
return { ...e, messages: [...e.messages, i] };
|
|
3958
3973
|
}
|
|
3959
3974
|
if (t.type === "values" && ((a = t.values) != null && a.messages)) {
|
|
3960
|
-
const i = t.values, f = Array.isArray(i.messages) ? i.messages : [], l =
|
|
3975
|
+
const i = t.values, f = Array.isArray(i.messages) ? i.messages : [], l = cs(gt(f)), { messages: c, ...d } = i;
|
|
3961
3976
|
if (o) {
|
|
3962
3977
|
const g = typeof s == "string" && s.length > 0 ? s : "task";
|
|
3963
3978
|
return {
|
|
@@ -3979,7 +3994,7 @@ function Xt(e, t) {
|
|
|
3979
3994
|
}
|
|
3980
3995
|
return t.type === "thread_info", e;
|
|
3981
3996
|
}
|
|
3982
|
-
function
|
|
3997
|
+
function Tn(e) {
|
|
3983
3998
|
return e.id ?? void 0;
|
|
3984
3999
|
}
|
|
3985
4000
|
function kt(e, t) {
|
|
@@ -3992,12 +4007,12 @@ function kt(e, t) {
|
|
|
3992
4007
|
}
|
|
3993
4008
|
return -1;
|
|
3994
4009
|
}
|
|
3995
|
-
function
|
|
4010
|
+
function fs(e) {
|
|
3996
4011
|
for (let t = e.length - 1; t >= 0; t--)
|
|
3997
4012
|
if (e[t].role === "user") return t;
|
|
3998
4013
|
return -1;
|
|
3999
4014
|
}
|
|
4000
|
-
function
|
|
4015
|
+
function ps(e, t, n) {
|
|
4001
4016
|
const r = kt(e, t);
|
|
4002
4017
|
if (r === -1) return e;
|
|
4003
4018
|
const s = e[r], o = (s.toolCalls ?? []).map(
|
|
@@ -4005,13 +4020,13 @@ function cs(e, t, n) {
|
|
|
4005
4020
|
);
|
|
4006
4021
|
return it(e, r, { ...s, toolCalls: o });
|
|
4007
4022
|
}
|
|
4008
|
-
function
|
|
4023
|
+
function gs(e, t) {
|
|
4009
4024
|
const n = t, r = n.id || n.callId, s = n.name ?? void 0, o = n.scope ?? void 0, a = `Starting ${s ?? "tool"}...`;
|
|
4010
4025
|
let i = e.messages;
|
|
4011
4026
|
if (r) {
|
|
4012
4027
|
let f = kt(i, r);
|
|
4013
4028
|
if (f === -1) {
|
|
4014
|
-
const l =
|
|
4029
|
+
const l = fs(i);
|
|
4015
4030
|
for (let c = i.length - 1; c > l; c--)
|
|
4016
4031
|
if (i[c].role === "assistant") {
|
|
4017
4032
|
f = c;
|
|
@@ -4049,8 +4064,8 @@ function ls(e, t) {
|
|
|
4049
4064
|
}
|
|
4050
4065
|
return { ...e, messages: i };
|
|
4051
4066
|
}
|
|
4052
|
-
function
|
|
4053
|
-
const n = t.id ??
|
|
4067
|
+
function ms(e, t) {
|
|
4068
|
+
const n = t.id ?? Tn(t);
|
|
4054
4069
|
if (!n) return e;
|
|
4055
4070
|
const r = t.content ?? void 0, s = t.scope ?? void 0;
|
|
4056
4071
|
let o = e.messages;
|
|
@@ -4063,13 +4078,13 @@ function us(e, t) {
|
|
|
4063
4078
|
}
|
|
4064
4079
|
return { ...e, messages: o };
|
|
4065
4080
|
}
|
|
4066
|
-
function
|
|
4067
|
-
const n =
|
|
4081
|
+
function hs(e, t) {
|
|
4082
|
+
const n = Tn(t);
|
|
4068
4083
|
let r = e.messages;
|
|
4069
4084
|
const s = t.scope ?? void 0, o = t.content ?? t.error ?? null, a = typeof o == "string" ? o : JSON.stringify(o), i = Ee(o), f = typeof i == "string" ? i : a;
|
|
4070
4085
|
if (n)
|
|
4071
4086
|
if (kt(r, n) !== -1)
|
|
4072
|
-
r =
|
|
4087
|
+
r = ps(r, n, {
|
|
4073
4088
|
status: "completed",
|
|
4074
4089
|
content: f,
|
|
4075
4090
|
artifact: t.artifact,
|
|
@@ -4105,8 +4120,8 @@ function ds(e, t) {
|
|
|
4105
4120
|
};
|
|
4106
4121
|
return { ...e, messages: [...r, l] };
|
|
4107
4122
|
}
|
|
4108
|
-
function
|
|
4109
|
-
const n = t.artifactId, r = t.callId, s =
|
|
4123
|
+
function ys(e, t) {
|
|
4124
|
+
const n = t.artifactId, r = t.callId, s = as(e.messages, n, r);
|
|
4110
4125
|
if (!s) {
|
|
4111
4126
|
const i = {
|
|
4112
4127
|
id: `artifact-${n}`,
|
|
@@ -4131,7 +4146,7 @@ function fs(e, t) {
|
|
|
4131
4146
|
messages: [...e.messages, i]
|
|
4132
4147
|
};
|
|
4133
4148
|
}
|
|
4134
|
-
const o = e.messages.indexOf(s), a =
|
|
4149
|
+
const o = e.messages.indexOf(s), a = os(s, {
|
|
4135
4150
|
status: t.status,
|
|
4136
4151
|
progress: t.progress,
|
|
4137
4152
|
error: t.error
|
|
@@ -4144,20 +4159,20 @@ function fs(e, t) {
|
|
|
4144
4159
|
messages: it(e.messages, o, a)
|
|
4145
4160
|
};
|
|
4146
4161
|
}
|
|
4147
|
-
const
|
|
4148
|
-
function
|
|
4162
|
+
const Zt = 120;
|
|
4163
|
+
function bs(e) {
|
|
4149
4164
|
if (!Array.isArray(e))
|
|
4150
4165
|
return "";
|
|
4151
4166
|
const t = e.filter((r) => !!(r && r.type === "text")).map((r) => (r.text ?? "").trim()).filter(Boolean);
|
|
4152
4167
|
if (!t.length)
|
|
4153
4168
|
return "";
|
|
4154
4169
|
const n = t.join(" ").replace(/\s+/g, " ").trim();
|
|
4155
|
-
return n ? n.length >
|
|
4170
|
+
return n ? n.length > Zt ? `${n.slice(0, Zt - 3)}…` : n : "";
|
|
4156
4171
|
}
|
|
4157
|
-
function
|
|
4158
|
-
return
|
|
4172
|
+
function ws(e) {
|
|
4173
|
+
return bs(e.content) || "";
|
|
4159
4174
|
}
|
|
4160
|
-
function
|
|
4175
|
+
function ks(e) {
|
|
4161
4176
|
const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), s = [];
|
|
4162
4177
|
for (let l = 0; l < e.length; l++) {
|
|
4163
4178
|
const c = e[l], d = c.checkpointId, g = d ?? `cp-${l}`, h = c.metadata ?? {}, v = typeof h.step == "number" ? h.step : null, m = typeof h.source == "string" ? h.source : null;
|
|
@@ -4177,7 +4192,7 @@ function ms(e) {
|
|
|
4177
4192
|
userMessageId: y
|
|
4178
4193
|
};
|
|
4179
4194
|
if (s.push(_), d && t.set(d, _), d && I) {
|
|
4180
|
-
const k =
|
|
4195
|
+
const k = ws(I);
|
|
4181
4196
|
k && r.set(d, k);
|
|
4182
4197
|
}
|
|
4183
4198
|
n.push({
|
|
@@ -4230,7 +4245,7 @@ function ms(e) {
|
|
|
4230
4245
|
}
|
|
4231
4246
|
};
|
|
4232
4247
|
}
|
|
4233
|
-
function
|
|
4248
|
+
function Qs(e, t, n) {
|
|
4234
4249
|
if (!e)
|
|
4235
4250
|
return { attemptCount: 1, attemptIndex: 0, attempts: [] };
|
|
4236
4251
|
const r = n.getMessageAttempts(e);
|
|
@@ -4247,17 +4262,17 @@ function Ws(e, t, n) {
|
|
|
4247
4262
|
attempts: r
|
|
4248
4263
|
};
|
|
4249
4264
|
}
|
|
4250
|
-
function
|
|
4251
|
-
return pe(() =>
|
|
4265
|
+
function vs(e) {
|
|
4266
|
+
return pe(() => ks(e), [e]);
|
|
4252
4267
|
}
|
|
4253
|
-
function
|
|
4268
|
+
function en(e, t) {
|
|
4254
4269
|
return {
|
|
4255
4270
|
version: "values@1",
|
|
4256
4271
|
threadId: e,
|
|
4257
4272
|
checkpoints: t ? [t] : []
|
|
4258
4273
|
};
|
|
4259
4274
|
}
|
|
4260
|
-
function
|
|
4275
|
+
function An({
|
|
4261
4276
|
api: e,
|
|
4262
4277
|
fileApi: t,
|
|
4263
4278
|
seed: n,
|
|
@@ -4273,24 +4288,24 @@ function vn({
|
|
|
4273
4288
|
const [d, g] = H(null), v = pe(
|
|
4274
4289
|
() => tt(d),
|
|
4275
4290
|
[d]
|
|
4276
|
-
).checkpoints, m =
|
|
4291
|
+
).checkpoints, m = vs(v), y = m.timeline, [I, A] = H(!1), [x, N] = H(!1), [_, k] = H(null), T = K(s), L = K(null), j = K(null), O = K(null), $ = K(null), C = K(null), J = K(/* @__PURE__ */ new Map()), G = K(null);
|
|
4277
4292
|
oe(() => {
|
|
4278
4293
|
T.current = s;
|
|
4279
4294
|
}, [s]);
|
|
4280
4295
|
const X = E(
|
|
4281
4296
|
async (p) => {
|
|
4282
|
-
var
|
|
4297
|
+
var z, U;
|
|
4283
4298
|
if (!p.threadId) return;
|
|
4284
4299
|
const b = p.threadId;
|
|
4285
|
-
(
|
|
4300
|
+
(z = p.onStart) == null || z.call(p), p.setLoading(!0);
|
|
4286
4301
|
try {
|
|
4287
4302
|
await p.action(b);
|
|
4288
|
-
} catch (
|
|
4289
|
-
if (!
|
|
4290
|
-
const ee = String(
|
|
4291
|
-
(
|
|
4303
|
+
} catch (q) {
|
|
4304
|
+
if (!Vt(q) && T.current === b) {
|
|
4305
|
+
const ee = String(q);
|
|
4306
|
+
(U = p.handleError) == null || U.call(p, ee), r == null || r(ee);
|
|
4292
4307
|
}
|
|
4293
|
-
throw
|
|
4308
|
+
throw q;
|
|
4294
4309
|
} finally {
|
|
4295
4310
|
p.setLoading(!1);
|
|
4296
4311
|
}
|
|
@@ -4300,12 +4315,12 @@ function vn({
|
|
|
4300
4315
|
async (p, b) => {
|
|
4301
4316
|
var ee;
|
|
4302
4317
|
if (!p) return;
|
|
4303
|
-
const
|
|
4304
|
-
if (
|
|
4305
|
-
return
|
|
4306
|
-
(ee =
|
|
4307
|
-
const
|
|
4308
|
-
|
|
4318
|
+
const z = `${p}:${b ?? "latest"}`, U = J.current.get(z);
|
|
4319
|
+
if (U)
|
|
4320
|
+
return U;
|
|
4321
|
+
(ee = G.current) == null || ee.abort();
|
|
4322
|
+
const q = new AbortController();
|
|
4323
|
+
G.current = q;
|
|
4309
4324
|
const B = X({
|
|
4310
4325
|
threadId: p,
|
|
4311
4326
|
setLoading: A,
|
|
@@ -4315,14 +4330,14 @@ function vn({
|
|
|
4315
4330
|
const re = await e.getState({
|
|
4316
4331
|
threadId: Q,
|
|
4317
4332
|
checkpointId: b ?? void 0
|
|
4318
|
-
}),
|
|
4333
|
+
}), W = en(Q, re), se = t ? await Et(W, t) : W;
|
|
4319
4334
|
if (T.current !== Q) {
|
|
4320
4335
|
console.log(
|
|
4321
4336
|
`[useThreadHistoryState] Thread changed during load (was ${Q}, now ${T.current}), discarding stale data`
|
|
4322
4337
|
);
|
|
4323
4338
|
return;
|
|
4324
4339
|
}
|
|
4325
|
-
const { checkpoints: ge, latest:
|
|
4340
|
+
const { checkpoints: ge, latest: be } = tt(se), ue = b ? ge.find((de) => de.checkpointId === b) ?? be : be;
|
|
4326
4341
|
n((ue == null ? void 0 : ue.messages) ?? [], {
|
|
4327
4342
|
checkpointId: (ue == null ? void 0 : ue.checkpointId) ?? null,
|
|
4328
4343
|
checkpointNs: (ue == null ? void 0 : ue.checkpointNs) ?? null,
|
|
@@ -4330,13 +4345,13 @@ function vn({
|
|
|
4330
4345
|
}), g(se);
|
|
4331
4346
|
}
|
|
4332
4347
|
});
|
|
4333
|
-
J.current.set(
|
|
4348
|
+
J.current.set(z, B);
|
|
4334
4349
|
try {
|
|
4335
4350
|
await B;
|
|
4336
4351
|
} finally {
|
|
4337
|
-
J.current.delete(
|
|
4352
|
+
J.current.delete(z), G.current === q && (G.current = null);
|
|
4338
4353
|
}
|
|
4339
|
-
return T.current === p && (C.current =
|
|
4354
|
+
return T.current === p && (C.current = z), B;
|
|
4340
4355
|
},
|
|
4341
4356
|
[e, n, X, t]
|
|
4342
4357
|
), ne = E(
|
|
@@ -4344,9 +4359,9 @@ function vn({
|
|
|
4344
4359
|
$.current = p;
|
|
4345
4360
|
try {
|
|
4346
4361
|
await te(p, b);
|
|
4347
|
-
} catch (
|
|
4348
|
-
if (!
|
|
4349
|
-
throw
|
|
4362
|
+
} catch (z) {
|
|
4363
|
+
if (!Vt(z))
|
|
4364
|
+
throw z;
|
|
4350
4365
|
} finally {
|
|
4351
4366
|
$.current === p && ($.current = null);
|
|
4352
4367
|
}
|
|
@@ -4361,34 +4376,34 @@ function vn({
|
|
|
4361
4376
|
const b = p.threadId ?? T.current;
|
|
4362
4377
|
if (!b || T.current && T.current !== b && O.current !== b)
|
|
4363
4378
|
return;
|
|
4364
|
-
const
|
|
4365
|
-
if (!
|
|
4379
|
+
const z = t ? await Et(p, t) : p, { checkpoints: U, latest: q } = tt(z);
|
|
4380
|
+
if (!U.length)
|
|
4366
4381
|
return;
|
|
4367
|
-
const B =
|
|
4382
|
+
const B = q;
|
|
4368
4383
|
n((B == null ? void 0 : B.messages) ?? [], {
|
|
4369
4384
|
checkpointId: (B == null ? void 0 : B.checkpointId) ?? null,
|
|
4370
4385
|
checkpointNs: (B == null ? void 0 : B.checkpointNs) ?? null,
|
|
4371
4386
|
pendingInterrupt: (B == null ? void 0 : B.interrupt) ?? null,
|
|
4372
4387
|
values: B == null ? void 0 : B.values
|
|
4373
|
-
}), g(
|
|
4388
|
+
}), g(z), C.current = `${b}:latest`, j.current = null, O.current === b && (O.current = null);
|
|
4374
4389
|
},
|
|
4375
4390
|
[n, l, t]
|
|
4376
4391
|
), V = E(
|
|
4377
4392
|
async (p, b) => {
|
|
4378
|
-
const
|
|
4393
|
+
const z = T.current;
|
|
4379
4394
|
await X({
|
|
4380
|
-
threadId:
|
|
4395
|
+
threadId: z,
|
|
4381
4396
|
setLoading: N,
|
|
4382
|
-
action: async (
|
|
4383
|
-
const
|
|
4384
|
-
threadId:
|
|
4397
|
+
action: async (U) => {
|
|
4398
|
+
const q = await e.getState({
|
|
4399
|
+
threadId: U,
|
|
4385
4400
|
checkpointId: p,
|
|
4386
4401
|
checkpointNs: b ?? void 0
|
|
4387
|
-
}), B =
|
|
4388
|
-
if (T.current !==
|
|
4402
|
+
}), B = en(U, q), ee = t ? await Et(B, t) : B;
|
|
4403
|
+
if (T.current !== U)
|
|
4389
4404
|
return;
|
|
4390
4405
|
const { checkpoints: Q } = tt(ee), re = Q.find(
|
|
4391
|
-
(
|
|
4406
|
+
(W) => W.checkpointId === p && (b ? W.checkpointNs === b : !0)
|
|
4392
4407
|
);
|
|
4393
4408
|
if (!re) {
|
|
4394
4409
|
console.warn("[useThreadHistoryState] Requested checkpoint not found:", { checkpointId: p, checkpointNs: b });
|
|
@@ -4466,19 +4481,19 @@ function vn({
|
|
|
4466
4481
|
clearState: M
|
|
4467
4482
|
};
|
|
4468
4483
|
}
|
|
4469
|
-
const
|
|
4470
|
-
function
|
|
4471
|
-
const t = at(
|
|
4484
|
+
const Sn = Ge(null), xn = Ge(null);
|
|
4485
|
+
function Cn(e) {
|
|
4486
|
+
const t = at(Sn);
|
|
4472
4487
|
if (!t && !(e != null && e.optional)) throw new Error("useThreadState must be used within a ThreadStateProvider");
|
|
4473
4488
|
return t;
|
|
4474
4489
|
}
|
|
4475
|
-
function
|
|
4476
|
-
const e = at(
|
|
4490
|
+
function Is() {
|
|
4491
|
+
const e = at(xn);
|
|
4477
4492
|
if (!e)
|
|
4478
4493
|
throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");
|
|
4479
4494
|
return e;
|
|
4480
4495
|
}
|
|
4481
|
-
function
|
|
4496
|
+
function Ts({
|
|
4482
4497
|
children: e,
|
|
4483
4498
|
initialThreadId: t = null,
|
|
4484
4499
|
initialCheckpointId: n = null,
|
|
@@ -4487,7 +4502,7 @@ function bs({
|
|
|
4487
4502
|
isStreaming: o,
|
|
4488
4503
|
onError: a
|
|
4489
4504
|
}) {
|
|
4490
|
-
const { chatApi: i, fileApi: f } =
|
|
4505
|
+
const { chatApi: i, fileApi: f } = We(), { currentThreadId: l } = st(), { state: c, seed: d, onEvent: g, dispatch: h } = ds(), {
|
|
4491
4506
|
threadCheckpoints: v,
|
|
4492
4507
|
threadTimeline: m,
|
|
4493
4508
|
checkpointIndex: y,
|
|
@@ -4502,7 +4517,7 @@ function bs({
|
|
|
4502
4517
|
markSkipNextLoad: j,
|
|
4503
4518
|
markStreamPendingThread: O,
|
|
4504
4519
|
resetHistoryState: $
|
|
4505
|
-
} =
|
|
4520
|
+
} = An({
|
|
4506
4521
|
api: i,
|
|
4507
4522
|
fileApi: f,
|
|
4508
4523
|
seed: d,
|
|
@@ -4523,14 +4538,14 @@ function bs({
|
|
|
4523
4538
|
C.current = u;
|
|
4524
4539
|
},
|
|
4525
4540
|
[]
|
|
4526
|
-
),
|
|
4541
|
+
), G = K(null), X = E(
|
|
4527
4542
|
(u) => {
|
|
4528
|
-
|
|
4543
|
+
G.current = u;
|
|
4529
4544
|
},
|
|
4530
4545
|
[]
|
|
4531
4546
|
), te = pe(() => ({ assemblingMessageId: c.assemblingId ?? null }), [c.assemblingId]), ne = E(
|
|
4532
4547
|
(u, R) => {
|
|
4533
|
-
const M =
|
|
4548
|
+
const M = kn(u, "user");
|
|
4534
4549
|
return h({
|
|
4535
4550
|
type: "user_message",
|
|
4536
4551
|
payload: {
|
|
@@ -4542,7 +4557,7 @@ function bs({
|
|
|
4542
4557
|
[h]
|
|
4543
4558
|
), S = E(async () => {
|
|
4544
4559
|
C.current ? await C.current() : (d([], {}), $());
|
|
4545
|
-
}, [d, $]), P = pe(() =>
|
|
4560
|
+
}, [d, $]), P = pe(() => xr(c.messages), [c.messages]), D = pe(
|
|
4546
4561
|
() => ({
|
|
4547
4562
|
threadId: l,
|
|
4548
4563
|
messages: c.messages,
|
|
@@ -4580,7 +4595,7 @@ function bs({
|
|
|
4580
4595
|
},
|
|
4581
4596
|
clearThread: S,
|
|
4582
4597
|
respondToInterrupt: async (u, R, M) => {
|
|
4583
|
-
|
|
4598
|
+
G.current && await G.current(u, R, M);
|
|
4584
4599
|
},
|
|
4585
4600
|
messagePreviews: y.messagePreviews,
|
|
4586
4601
|
handleValuesEvent: L,
|
|
@@ -4626,10 +4641,10 @@ function bs({
|
|
|
4626
4641
|
}),
|
|
4627
4642
|
[J, X]
|
|
4628
4643
|
);
|
|
4629
|
-
return /* @__PURE__ */ Me(
|
|
4644
|
+
return /* @__PURE__ */ Me(xn.Provider, { value: V, children: /* @__PURE__ */ Me(Sn.Provider, { value: D, children: e }) });
|
|
4630
4645
|
}
|
|
4631
|
-
const
|
|
4632
|
-
function
|
|
4646
|
+
const Mn = Ge(null), As = Ge(!1);
|
|
4647
|
+
function Ss({
|
|
4633
4648
|
children: e,
|
|
4634
4649
|
onError: t,
|
|
4635
4650
|
onAuthError: n,
|
|
@@ -4641,7 +4656,7 @@ function ks({
|
|
|
4641
4656
|
onFinish: f,
|
|
4642
4657
|
onStreamingChange: l
|
|
4643
4658
|
}) {
|
|
4644
|
-
const { chatApi: c, baseUrl: d } =
|
|
4659
|
+
const { chatApi: c, baseUrl: d } = We(), g = d, h = Le(t), v = Le(n), m = Le(r), y = Le(s), I = Le(o), A = Le(a), x = Le(i), N = Le(f), _ = Le(l), k = pe(
|
|
4645
4660
|
() => ({
|
|
4646
4661
|
onError: h,
|
|
4647
4662
|
onAuthError: v,
|
|
@@ -4663,8 +4678,8 @@ function ks({
|
|
|
4663
4678
|
N
|
|
4664
4679
|
]
|
|
4665
4680
|
);
|
|
4666
|
-
return /* @__PURE__ */ Me(
|
|
4667
|
-
|
|
4681
|
+
return /* @__PURE__ */ Me(As.Provider, { value: !0, children: /* @__PURE__ */ Me(
|
|
4682
|
+
xs,
|
|
4668
4683
|
{
|
|
4669
4684
|
api: c,
|
|
4670
4685
|
streamBaseUrl: g,
|
|
@@ -4674,7 +4689,7 @@ function ks({
|
|
|
4674
4689
|
}
|
|
4675
4690
|
) });
|
|
4676
4691
|
}
|
|
4677
|
-
function
|
|
4692
|
+
function xs({
|
|
4678
4693
|
children: e,
|
|
4679
4694
|
api: t,
|
|
4680
4695
|
streamBaseUrl: n,
|
|
@@ -4692,12 +4707,12 @@ function vs({
|
|
|
4692
4707
|
pushUser: y,
|
|
4693
4708
|
onEvent: I,
|
|
4694
4709
|
messages: A
|
|
4695
|
-
} =
|
|
4710
|
+
} = Cn(), { registerClearThread: x, registerRespondToInterrupt: N } = Is(), _ = E(
|
|
4696
4711
|
(u) => {
|
|
4697
4712
|
i(u), v(u.threadId), a.current !== u.threadId && ((u.created ?? !a.current) && h(u.threadId), o(u.threadId));
|
|
4698
4713
|
},
|
|
4699
4714
|
[i, h, v, o, a]
|
|
4700
|
-
), k =
|
|
4715
|
+
), k = es({
|
|
4701
4716
|
baseUrl: n,
|
|
4702
4717
|
onEvent: I,
|
|
4703
4718
|
onError: (u) => {
|
|
@@ -4717,7 +4732,7 @@ function vs({
|
|
|
4717
4732
|
oe(() => {
|
|
4718
4733
|
s == null || s(k.isStreaming);
|
|
4719
4734
|
}, [k.isStreaming, s]);
|
|
4720
|
-
const { stream: T, stop: L, clear: j, isStreaming: O, error: $, connected: C, streamedMessages: J, activeMessageId:
|
|
4735
|
+
const { stream: T, stop: L, clear: j, isStreaming: O, error: $, connected: C, streamedMessages: J, activeMessageId: G } = k;
|
|
4721
4736
|
oe(() => {
|
|
4722
4737
|
f !== void 0 && j();
|
|
4723
4738
|
}, [f, j]);
|
|
@@ -4735,10 +4750,10 @@ function vs({
|
|
|
4735
4750
|
const p = a.current;
|
|
4736
4751
|
if (!p)
|
|
4737
4752
|
throw new Error("No active thread to handle interrupt");
|
|
4738
|
-
const b = u ? R ?? !0 : !1,
|
|
4753
|
+
const b = u ? R ?? !0 : !1, z = te.current, U = (M == null ? void 0 : M.checkpointId) ?? z.id ?? void 0, q = (M == null ? void 0 : M.checkpointNs) ?? z.namespace ?? void 0, B = {
|
|
4739
4754
|
threadId: p,
|
|
4740
|
-
checkpointId:
|
|
4741
|
-
checkpointNs:
|
|
4755
|
+
checkpointId: U,
|
|
4756
|
+
checkpointNs: q,
|
|
4742
4757
|
command: { kind: "resume", value: b },
|
|
4743
4758
|
payload: M == null ? void 0 : M.payload
|
|
4744
4759
|
};
|
|
@@ -4759,32 +4774,32 @@ function vs({
|
|
|
4759
4774
|
async (u, R) => {
|
|
4760
4775
|
O && L();
|
|
4761
4776
|
let M = a.current;
|
|
4762
|
-
const p = (u == null ? void 0 : u.text) ?? "", b = (u == null ? void 0 : u.attachments) ?? [],
|
|
4763
|
-
|
|
4764
|
-
const B = !!(
|
|
4765
|
-
if (!M && !
|
|
4777
|
+
const p = (u == null ? void 0 : u.text) ?? "", b = (u == null ? void 0 : u.attachments) ?? [], z = (p == null ? void 0 : p.trim()) ?? "", U = { ...(u == null ? void 0 : u.payload) ?? {} }, q = Array.isArray(U.messages) ? U.messages : void 0;
|
|
4778
|
+
q && delete U.messages;
|
|
4779
|
+
const B = !!(q && q.length), ee = !!(u.contentParts && u.contentParts.length > 0);
|
|
4780
|
+
if (!M && !z && b.length === 0 && !B && !ee) return;
|
|
4766
4781
|
if (!M) {
|
|
4767
4782
|
const Se = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), Ke = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
|
|
4768
4783
|
M = `${Se}${Ke}`, h(M), o(M);
|
|
4769
4784
|
}
|
|
4770
4785
|
let Q = null;
|
|
4771
4786
|
u.contentParts && u.contentParts.length > 0 && (Q = u.contentParts);
|
|
4772
|
-
const { contentParts: re, filesInfo:
|
|
4773
|
-
|
|
4774
|
-
const ge = u == null ? void 0 : u.originalMessageId,
|
|
4787
|
+
const { contentParts: re, filesInfo: W } = Q ? { contentParts: Q, filesInfo: [] } : await Hr(b), se = [...re];
|
|
4788
|
+
z && se.push({ type: "text", text: p });
|
|
4789
|
+
const ge = u == null ? void 0 : u.originalMessageId, be = !!(u != null && u.edit && ge), ue = !B && se.length > 0;
|
|
4775
4790
|
let de = null;
|
|
4776
4791
|
if (ue) {
|
|
4777
|
-
const Se =
|
|
4778
|
-
de =
|
|
4792
|
+
const Se = be ? ge : `msg-${Date.now()}`;
|
|
4793
|
+
de = kn({
|
|
4779
4794
|
id: Se,
|
|
4780
4795
|
role: "user",
|
|
4781
4796
|
content: se,
|
|
4782
4797
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4783
|
-
}, "user"),
|
|
4798
|
+
}, "user"), be ? y(de, { editingMessageId: ge }) : y(de);
|
|
4784
4799
|
}
|
|
4785
|
-
const je = B ?
|
|
4786
|
-
...
|
|
4787
|
-
...
|
|
4800
|
+
const je = B ? q : de ? [de] : [], Oe = {
|
|
4801
|
+
...U,
|
|
4802
|
+
...W.length ? { files_info: W } : {}
|
|
4788
4803
|
};
|
|
4789
4804
|
je.length ? Oe.messages = je : "messages" in Oe || (Oe.messages = []);
|
|
4790
4805
|
const Xe = (u == null ? void 0 : u.checkpointId) ?? c.id ?? void 0;
|
|
@@ -4818,7 +4833,7 @@ function vs({
|
|
|
4818
4833
|
error: $,
|
|
4819
4834
|
connectionState: $ ? "error" : O ? C ? "connected" : "connecting" : "idle",
|
|
4820
4835
|
messages: D,
|
|
4821
|
-
activeMessageId:
|
|
4836
|
+
activeMessageId: G,
|
|
4822
4837
|
submit: P,
|
|
4823
4838
|
stop: L,
|
|
4824
4839
|
interrupt: l,
|
|
@@ -4830,7 +4845,7 @@ function vs({
|
|
|
4830
4845
|
}),
|
|
4831
4846
|
[O, $, P, L, l, C, D]
|
|
4832
4847
|
);
|
|
4833
|
-
return /* @__PURE__ */ Me(
|
|
4848
|
+
return /* @__PURE__ */ Me(Mn.Provider, { value: V, children: e });
|
|
4834
4849
|
}
|
|
4835
4850
|
function Le(e) {
|
|
4836
4851
|
const t = K(e);
|
|
@@ -4842,17 +4857,17 @@ function Le(e) {
|
|
|
4842
4857
|
return r(...n);
|
|
4843
4858
|
}, []);
|
|
4844
4859
|
}
|
|
4845
|
-
function
|
|
4846
|
-
const e = at(
|
|
4860
|
+
function Cs() {
|
|
4861
|
+
const e = at(Mn);
|
|
4847
4862
|
if (!e) throw new Error("useStream must be used within StreamingProvider");
|
|
4848
4863
|
return e;
|
|
4849
4864
|
}
|
|
4850
|
-
function
|
|
4865
|
+
function tn(e) {
|
|
4851
4866
|
return typeof e == "object" && e !== null;
|
|
4852
4867
|
}
|
|
4853
|
-
function
|
|
4868
|
+
function Ms(e, t) {
|
|
4854
4869
|
if (Object.is(e, t)) return !0;
|
|
4855
|
-
if (!
|
|
4870
|
+
if (!tn(e) || !tn(t)) return !1;
|
|
4856
4871
|
const n = Object.keys(e), r = Object.keys(t);
|
|
4857
4872
|
if (n.length !== r.length)
|
|
4858
4873
|
return !1;
|
|
@@ -4861,22 +4876,22 @@ function Ts(e, t) {
|
|
|
4861
4876
|
return !1;
|
|
4862
4877
|
return !0;
|
|
4863
4878
|
}
|
|
4864
|
-
function
|
|
4879
|
+
function Es(e) {
|
|
4865
4880
|
const t = K(e), n = K(e);
|
|
4866
|
-
return
|
|
4881
|
+
return Ms(t.current, e) || (t.current = e, n.current = e), n.current;
|
|
4867
4882
|
}
|
|
4868
|
-
function
|
|
4883
|
+
function Ps(e) {
|
|
4869
4884
|
const t = e.artifact && typeof e.artifact == "object" ? e.artifact : null, n = !t && e.content && typeof e.content == "object" ? e.content : null, r = t ?? n, s = (r == null ? void 0 : r.task_id) ?? (r == null ? void 0 : r.taskId) ?? null;
|
|
4870
4885
|
return typeof s == "string" ? s : null;
|
|
4871
4886
|
}
|
|
4872
|
-
function
|
|
4887
|
+
function Ys(e) {
|
|
4873
4888
|
const { setCurrentTaskId: t, getCurrentTaskId: n, onToolEnd: r } = e;
|
|
4874
4889
|
return (s) => {
|
|
4875
|
-
const o =
|
|
4890
|
+
const o = Ps(s), a = (n == null ? void 0 : n()) ?? null;
|
|
4876
4891
|
o && o !== a && t(o), r == null || r(s);
|
|
4877
4892
|
};
|
|
4878
4893
|
}
|
|
4879
|
-
function
|
|
4894
|
+
function Zs({
|
|
4880
4895
|
children: e,
|
|
4881
4896
|
apiConfig: t,
|
|
4882
4897
|
initialThreadId: n = null,
|
|
@@ -4893,7 +4908,7 @@ function qs({
|
|
|
4893
4908
|
onMetadataEvent: h,
|
|
4894
4909
|
onFinish: v
|
|
4895
4910
|
}) {
|
|
4896
|
-
const m =
|
|
4911
|
+
const m = Es(t), [y, I] = H(!1), A = ze(i), x = ze(f), N = ze(a), _ = ze(l), k = ze(c), T = ze(d), L = ze(g), j = ze(h), O = ze(v), $ = pe(
|
|
4897
4912
|
() => ({
|
|
4898
4913
|
onError: A,
|
|
4899
4914
|
onAuthError: x,
|
|
@@ -4915,14 +4930,14 @@ function qs({
|
|
|
4915
4930
|
O
|
|
4916
4931
|
]
|
|
4917
4932
|
);
|
|
4918
|
-
return /* @__PURE__ */ Me(
|
|
4919
|
-
|
|
4933
|
+
return /* @__PURE__ */ Me(Vr, { apiConfig: m, children: /* @__PURE__ */ Me(
|
|
4934
|
+
ss,
|
|
4920
4935
|
{
|
|
4921
4936
|
initialThreadId: n,
|
|
4922
4937
|
onError: A,
|
|
4923
4938
|
onThreadChange: _,
|
|
4924
4939
|
children: /* @__PURE__ */ Me(
|
|
4925
|
-
|
|
4940
|
+
Ts,
|
|
4926
4941
|
{
|
|
4927
4942
|
initialThreadId: n,
|
|
4928
4943
|
initialCheckpointId: r,
|
|
@@ -4931,7 +4946,7 @@ function qs({
|
|
|
4931
4946
|
onError: A,
|
|
4932
4947
|
isStreaming: y,
|
|
4933
4948
|
children: /* @__PURE__ */ Me(
|
|
4934
|
-
|
|
4949
|
+
Ss,
|
|
4935
4950
|
{
|
|
4936
4951
|
...$,
|
|
4937
4952
|
onStreamingChange: I,
|
|
@@ -4943,7 +4958,7 @@ function qs({
|
|
|
4943
4958
|
}
|
|
4944
4959
|
) });
|
|
4945
4960
|
}
|
|
4946
|
-
function
|
|
4961
|
+
function ze(e) {
|
|
4947
4962
|
const t = K(e);
|
|
4948
4963
|
return t.current = e, E((...n) => {
|
|
4949
4964
|
const r = t.current;
|
|
@@ -4951,12 +4966,12 @@ function Ue(e) {
|
|
|
4951
4966
|
return r(...n);
|
|
4952
4967
|
}, []);
|
|
4953
4968
|
}
|
|
4954
|
-
const
|
|
4969
|
+
const Rs = 1, Ns = 1e6;
|
|
4955
4970
|
let Pt = 0;
|
|
4956
|
-
function
|
|
4971
|
+
function _s() {
|
|
4957
4972
|
return Pt = (Pt + 1) % Number.MAX_SAFE_INTEGER, Pt.toString();
|
|
4958
4973
|
}
|
|
4959
|
-
const Rt = /* @__PURE__ */ new Map(),
|
|
4974
|
+
const Rt = /* @__PURE__ */ new Map(), nn = (e) => {
|
|
4960
4975
|
if (Rt.has(e))
|
|
4961
4976
|
return;
|
|
4962
4977
|
const t = setTimeout(() => {
|
|
@@ -4964,14 +4979,14 @@ const Rt = /* @__PURE__ */ new Map(), en = (e) => {
|
|
|
4964
4979
|
type: "REMOVE_TOAST",
|
|
4965
4980
|
toastId: e
|
|
4966
4981
|
});
|
|
4967
|
-
},
|
|
4982
|
+
}, Ns);
|
|
4968
4983
|
Rt.set(e, t);
|
|
4969
|
-
},
|
|
4984
|
+
}, Ls = (e, t) => {
|
|
4970
4985
|
switch (t.type) {
|
|
4971
4986
|
case "ADD_TOAST":
|
|
4972
4987
|
return {
|
|
4973
4988
|
...e,
|
|
4974
|
-
toasts: [t.toast, ...e.toasts].slice(0,
|
|
4989
|
+
toasts: [t.toast, ...e.toasts].slice(0, Rs)
|
|
4975
4990
|
};
|
|
4976
4991
|
case "UPDATE_TOAST":
|
|
4977
4992
|
return {
|
|
@@ -4982,8 +4997,8 @@ const Rt = /* @__PURE__ */ new Map(), en = (e) => {
|
|
|
4982
4997
|
};
|
|
4983
4998
|
case "DISMISS_TOAST": {
|
|
4984
4999
|
const { toastId: n } = t;
|
|
4985
|
-
return n ?
|
|
4986
|
-
|
|
5000
|
+
return n ? nn(n) : e.toasts.forEach((r) => {
|
|
5001
|
+
nn(r.id);
|
|
4987
5002
|
}), {
|
|
4988
5003
|
...e,
|
|
4989
5004
|
toasts: e.toasts.map(
|
|
@@ -5006,12 +5021,12 @@ const Rt = /* @__PURE__ */ new Map(), en = (e) => {
|
|
|
5006
5021
|
}, mt = [];
|
|
5007
5022
|
let ht = { toasts: [] };
|
|
5008
5023
|
function ot(e) {
|
|
5009
|
-
ht =
|
|
5024
|
+
ht = Ls(ht, e), mt.forEach((t) => {
|
|
5010
5025
|
t(ht);
|
|
5011
5026
|
});
|
|
5012
5027
|
}
|
|
5013
|
-
function
|
|
5014
|
-
const t =
|
|
5028
|
+
function zs({ ...e }) {
|
|
5029
|
+
const t = _s(), n = (s) => ot({
|
|
5015
5030
|
type: "UPDATE_TOAST",
|
|
5016
5031
|
toast: { ...s, id: t }
|
|
5017
5032
|
}), r = () => ot({ type: "DISMISS_TOAST", toastId: t });
|
|
@@ -5031,19 +5046,19 @@ function Ps({ ...e }) {
|
|
|
5031
5046
|
update: n
|
|
5032
5047
|
};
|
|
5033
5048
|
}
|
|
5034
|
-
function
|
|
5035
|
-
const [e, t] =
|
|
5036
|
-
return
|
|
5049
|
+
function Us() {
|
|
5050
|
+
const [e, t] = Dt.useState(ht);
|
|
5051
|
+
return Dt.useEffect(() => (mt.push(t), () => {
|
|
5037
5052
|
const n = mt.indexOf(t);
|
|
5038
5053
|
n > -1 && mt.splice(n, 1);
|
|
5039
5054
|
}), [e]), {
|
|
5040
5055
|
...e,
|
|
5041
|
-
toast:
|
|
5056
|
+
toast: zs,
|
|
5042
5057
|
dismiss: (n) => ot({ type: "DISMISS_TOAST", toastId: n })
|
|
5043
5058
|
};
|
|
5044
5059
|
}
|
|
5045
|
-
function
|
|
5046
|
-
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } =
|
|
5060
|
+
function eo(e) {
|
|
5061
|
+
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = We(), { toast: s } = Us(), [o, a] = H({}), [i, f] = H(null), [l, c] = H(!1), d = E(() => {
|
|
5047
5062
|
c(!1), f(null);
|
|
5048
5063
|
}, []), g = E((v) => {
|
|
5049
5064
|
f(v), c(!0);
|
|
@@ -5114,30 +5129,30 @@ function Js(e) {
|
|
|
5114
5129
|
closeFileViewer: d
|
|
5115
5130
|
};
|
|
5116
5131
|
}
|
|
5117
|
-
function
|
|
5132
|
+
function to(e) {
|
|
5118
5133
|
return pe(() => {
|
|
5119
5134
|
const t = e;
|
|
5120
5135
|
let n = Array.isArray(t.content) ? t.content : [];
|
|
5121
5136
|
return typeof t.content == "string" && (n = [{ type: "text", text: t.content }]), {
|
|
5122
5137
|
contentParts: n,
|
|
5123
|
-
textContent:
|
|
5124
|
-
toolMeta:
|
|
5138
|
+
textContent: qr(n),
|
|
5139
|
+
toolMeta: Wr(t),
|
|
5125
5140
|
imageParts: n.filter((r) => r.type === "image_url"),
|
|
5126
5141
|
fileParts: n.filter((r) => r.type === "file"),
|
|
5127
|
-
toolRaw:
|
|
5142
|
+
toolRaw: Cr(n),
|
|
5128
5143
|
isToolStreaming: !!t.toolStreaming
|
|
5129
5144
|
};
|
|
5130
5145
|
}, [e]);
|
|
5131
5146
|
}
|
|
5132
|
-
const
|
|
5133
|
-
function
|
|
5147
|
+
const rn = "data:";
|
|
5148
|
+
function Fs(e) {
|
|
5134
5149
|
if (!e) return [];
|
|
5135
5150
|
const t = [], n = e.split(/\r?\n/);
|
|
5136
5151
|
for (const r of n) {
|
|
5137
5152
|
const s = r.trim();
|
|
5138
|
-
if (!s || !s.startsWith(
|
|
5153
|
+
if (!s || !s.startsWith(rn))
|
|
5139
5154
|
continue;
|
|
5140
|
-
const o = s.slice(
|
|
5155
|
+
const o = s.slice(rn.length).trim();
|
|
5141
5156
|
if (!o || o.toLowerCase() === "[done]")
|
|
5142
5157
|
continue;
|
|
5143
5158
|
const a = Ut(o);
|
|
@@ -5145,7 +5160,7 @@ function Ns(e) {
|
|
|
5145
5160
|
}
|
|
5146
5161
|
return t;
|
|
5147
5162
|
}
|
|
5148
|
-
function
|
|
5163
|
+
function js(e) {
|
|
5149
5164
|
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
5150
5165
|
const n = e[t];
|
|
5151
5166
|
if (n && typeof n == "object" && n.type === "tool.end")
|
|
@@ -5153,7 +5168,7 @@ function _s(e) {
|
|
|
5153
5168
|
}
|
|
5154
5169
|
return null;
|
|
5155
5170
|
}
|
|
5156
|
-
function
|
|
5171
|
+
function no(e) {
|
|
5157
5172
|
return pe(() => {
|
|
5158
5173
|
const t = e.content.filter(
|
|
5159
5174
|
(f) => f.type === "text"
|
|
@@ -5161,7 +5176,7 @@ function Qs(e) {
|
|
|
5161
5176
|
if (!t.length)
|
|
5162
5177
|
return null;
|
|
5163
5178
|
let r = t.flatMap(
|
|
5164
|
-
(f) =>
|
|
5179
|
+
(f) => Fs(f.text ?? "")
|
|
5165
5180
|
);
|
|
5166
5181
|
if (!r.length) {
|
|
5167
5182
|
const f = t.map((c) => c.text ?? "").join(`
|
|
@@ -5170,7 +5185,7 @@ function Qs(e) {
|
|
|
5170
5185
|
}
|
|
5171
5186
|
if (!r.length)
|
|
5172
5187
|
return null;
|
|
5173
|
-
const o =
|
|
5188
|
+
const o = js(r) ?? r[r.length - 1];
|
|
5174
5189
|
if (!o)
|
|
5175
5190
|
return null;
|
|
5176
5191
|
const a = o.output ?? o.payload ?? o, i = Ee(a);
|
|
@@ -5186,17 +5201,17 @@ function Qs(e) {
|
|
|
5186
5201
|
};
|
|
5187
5202
|
}, [e]);
|
|
5188
5203
|
}
|
|
5189
|
-
function
|
|
5204
|
+
function Os(e) {
|
|
5190
5205
|
var _;
|
|
5191
|
-
const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, { currentThreadId: n, setCurrentThreadId: r, actions: s } = st(), o =
|
|
5206
|
+
const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, { currentThreadId: n, setCurrentThreadId: r, actions: s } = st(), o = Cn({ optional: !0 }), a = Cs(), i = !!t && t !== n, [f, l] = H([]), c = E((k) => {
|
|
5192
5207
|
l(k);
|
|
5193
5208
|
}, []), {
|
|
5194
5209
|
isLoadingThread: d,
|
|
5195
5210
|
threadStateError: g,
|
|
5196
5211
|
threadCheckpoints: h
|
|
5197
|
-
} =
|
|
5198
|
-
api:
|
|
5199
|
-
fileApi:
|
|
5212
|
+
} = An({
|
|
5213
|
+
api: We().chatApi,
|
|
5214
|
+
fileApi: We().fileApi,
|
|
5200
5215
|
seed: c,
|
|
5201
5216
|
currentThreadId: i ? t : null,
|
|
5202
5217
|
initialThreadId: i ? t : null,
|
|
@@ -5252,7 +5267,7 @@ function Ls(e) {
|
|
|
5252
5267
|
isThreadsLoading: st().isLoading
|
|
5253
5268
|
};
|
|
5254
5269
|
}
|
|
5255
|
-
function
|
|
5270
|
+
function ro({
|
|
5256
5271
|
submit: e,
|
|
5257
5272
|
chatRequest: t,
|
|
5258
5273
|
lastCheckpointId: n,
|
|
@@ -5268,7 +5283,7 @@ function Ys({
|
|
|
5268
5283
|
threadId: g,
|
|
5269
5284
|
clearComposerOnSend: h = !0
|
|
5270
5285
|
}) {
|
|
5271
|
-
const { messages: v } =
|
|
5286
|
+
const { messages: v } = Os(), [m, y] = H(null), [I, A] = H(""), [x, N] = H(null), [_, k] = H(null), [T, L] = H(!1), [j, O] = H(""), $ = K(j), C = K(null);
|
|
5272
5287
|
oe(() => {
|
|
5273
5288
|
if (!m)
|
|
5274
5289
|
if (g) {
|
|
@@ -5289,38 +5304,38 @@ function Ys({
|
|
|
5289
5304
|
}
|
|
5290
5305
|
C.current === null && (C.current = $.current), J(I ?? "");
|
|
5291
5306
|
}, [I, m, J]);
|
|
5292
|
-
const
|
|
5307
|
+
const G = E(
|
|
5293
5308
|
(u) => {
|
|
5294
5309
|
J(u);
|
|
5295
5310
|
},
|
|
5296
5311
|
[J]
|
|
5297
5312
|
), X = async (u, R) => {
|
|
5298
|
-
const M = Array.isArray(R) ? { files: R } : R ?? {}, p = M.files ?? [], b = M.contentParts ?? [],
|
|
5299
|
-
if (!(!
|
|
5313
|
+
const M = Array.isArray(R) ? { files: R } : R ?? {}, p = M.files ?? [], b = M.contentParts ?? [], z = u.trim();
|
|
5314
|
+
if (!(!z && p.length === 0 && b.length === 0))
|
|
5300
5315
|
try {
|
|
5301
|
-
const
|
|
5316
|
+
const U = p.map(async (W) => {
|
|
5302
5317
|
try {
|
|
5303
|
-
const se = await
|
|
5304
|
-
return { file:
|
|
5318
|
+
const se = await bn.uploadFile(W);
|
|
5319
|
+
return { file: W, record: se };
|
|
5305
5320
|
} catch (se) {
|
|
5306
|
-
throw console.error("Failed to upload file",
|
|
5321
|
+
throw console.error("Failed to upload file", W.name, se), new Error(`Failed to upload ${W.name}`);
|
|
5307
5322
|
}
|
|
5308
|
-
}), B = (await Promise.all(
|
|
5309
|
-
const se =
|
|
5323
|
+
}), B = (await Promise.all(U)).map(({ record: W }) => {
|
|
5324
|
+
const se = W.mime_type;
|
|
5310
5325
|
return se.startsWith("image/") ? {
|
|
5311
5326
|
type: "image_url",
|
|
5312
|
-
image_url: { url:
|
|
5327
|
+
image_url: { url: W.content_url }
|
|
5313
5328
|
} : {
|
|
5314
5329
|
type: "file",
|
|
5315
|
-
url:
|
|
5330
|
+
url: W.content_url,
|
|
5316
5331
|
mimeType: se,
|
|
5317
|
-
name:
|
|
5318
|
-
size:
|
|
5332
|
+
name: W.filename,
|
|
5333
|
+
size: W.size
|
|
5319
5334
|
};
|
|
5320
5335
|
}), ee = [...b, ...B], Q = m ? (x == null ? void 0 : x.checkpointId) ?? n ?? void 0 : n ?? void 0, re = m ? (x == null ? void 0 : x.checkpointNs) ?? r ?? void 0 : r ?? void 0;
|
|
5321
5336
|
await e(
|
|
5322
5337
|
{
|
|
5323
|
-
text:
|
|
5338
|
+
text: z || "",
|
|
5324
5339
|
contentParts: ee,
|
|
5325
5340
|
attachments: p,
|
|
5326
5341
|
payload: t.payload,
|
|
@@ -5332,10 +5347,10 @@ function Ys({
|
|
|
5332
5347
|
config: t.config
|
|
5333
5348
|
},
|
|
5334
5349
|
d ? { onEvent: d } : void 0
|
|
5335
|
-
), s == null || s(
|
|
5336
|
-
} catch (
|
|
5337
|
-
const
|
|
5338
|
-
k(
|
|
5350
|
+
), s == null || s(z), l(!0), h && (g && localStorage.removeItem(Mt(g)), J("")), k(null), y(null), A(""), N(null);
|
|
5351
|
+
} catch (U) {
|
|
5352
|
+
const q = (U == null ? void 0 : U.message) || "Failed to send message";
|
|
5353
|
+
k(q), a == null || a(q), l(!1);
|
|
5339
5354
|
}
|
|
5340
5355
|
}, te = (u, R) => {
|
|
5341
5356
|
R || X(u, { files: [] });
|
|
@@ -5368,13 +5383,13 @@ function Ys({
|
|
|
5368
5383
|
u !== null && O(u), C.current = null;
|
|
5369
5384
|
}, []), D = E((u) => {
|
|
5370
5385
|
let R = null;
|
|
5371
|
-
for (let
|
|
5372
|
-
if (f[
|
|
5373
|
-
R = f[
|
|
5386
|
+
for (let z = u - 1; z >= 0; z--)
|
|
5387
|
+
if (f[z].role === "user") {
|
|
5388
|
+
R = f[z];
|
|
5374
5389
|
break;
|
|
5375
5390
|
}
|
|
5376
5391
|
if (!R) return;
|
|
5377
|
-
const M = Array.isArray(R.content) ? R.content : [], b = M.filter((
|
|
5392
|
+
const M = Array.isArray(R.content) ? R.content : [], b = M.filter((z) => (z == null ? void 0 : z.type) === "text").map((z) => z.text).join("") || (() => {
|
|
5378
5393
|
try {
|
|
5379
5394
|
return JSON.stringify(M, null, 2);
|
|
5380
5395
|
} catch {
|
|
@@ -5402,7 +5417,7 @@ function Ys({
|
|
|
5402
5417
|
dismissError: T,
|
|
5403
5418
|
setDismissError: L,
|
|
5404
5419
|
composerValue: j,
|
|
5405
|
-
handleComposerChange:
|
|
5420
|
+
handleComposerChange: G,
|
|
5406
5421
|
handleSendMessage: X,
|
|
5407
5422
|
handleQuickPrompt: te,
|
|
5408
5423
|
handleExcelUpload: ne,
|
|
@@ -5412,12 +5427,12 @@ function Ys({
|
|
|
5412
5427
|
displayMessages: v
|
|
5413
5428
|
};
|
|
5414
5429
|
}
|
|
5415
|
-
function
|
|
5430
|
+
function so(e) {
|
|
5416
5431
|
return pe(() => e ? {
|
|
5417
|
-
textContent:
|
|
5418
|
-
imageParts:
|
|
5419
|
-
fileParts:
|
|
5420
|
-
toolCalls:
|
|
5432
|
+
textContent: Tr(e),
|
|
5433
|
+
imageParts: Ar(e),
|
|
5434
|
+
fileParts: Sr(e),
|
|
5435
|
+
toolCalls: dn(e),
|
|
5421
5436
|
contentParts: e.content
|
|
5422
5437
|
} : {
|
|
5423
5438
|
textContent: "",
|
|
@@ -5427,7 +5442,7 @@ function Zs(e) {
|
|
|
5427
5442
|
contentParts: []
|
|
5428
5443
|
}, [e]);
|
|
5429
5444
|
}
|
|
5430
|
-
function
|
|
5445
|
+
function oo(e, t, n) {
|
|
5431
5446
|
const [r, s] = H(e), o = K(e), a = K(null);
|
|
5432
5447
|
return oe(() => {
|
|
5433
5448
|
o.current = e;
|
|
@@ -5446,46 +5461,46 @@ function eo(e, t, n) {
|
|
|
5446
5461
|
}, [e, t, n]), r;
|
|
5447
5462
|
}
|
|
5448
5463
|
export {
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
+
Zs as ChatProviders,
|
|
5465
|
+
Ts as ThreadStateProvider,
|
|
5466
|
+
ss as ThreadsProvider,
|
|
5467
|
+
Ks as cn,
|
|
5468
|
+
qr as collectText,
|
|
5469
|
+
Ys as createTaskSyncToolEndHandler,
|
|
5470
|
+
Ps as extractTaskIdFromToolEnd,
|
|
5471
|
+
Wr as extractToolMeta,
|
|
5472
|
+
Hs as formatToolOutput,
|
|
5473
|
+
Js as getAgentNameFromMessage,
|
|
5474
|
+
gn as getChatToken,
|
|
5475
|
+
Qs as getMessageAttemptInfo,
|
|
5476
|
+
Ws as getToolCallArtifacts,
|
|
5477
|
+
_r as getToolCalls,
|
|
5478
|
+
qs as hasContent,
|
|
5464
5479
|
tt as hydrateHistorySnapshots,
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5480
|
+
fn as isFileLike,
|
|
5481
|
+
kr as looksLikeMarkdown,
|
|
5482
|
+
Xs as messageSignature,
|
|
5483
|
+
Gs as normalizeInterruptId,
|
|
5484
|
+
mn as onChatTokenChanged,
|
|
5470
5485
|
Ut as parseJsonSafe,
|
|
5471
|
-
|
|
5486
|
+
pn as pretty,
|
|
5472
5487
|
Et as refreshHistoryFileUrls,
|
|
5473
5488
|
yt as sanitizeForDisplay,
|
|
5474
5489
|
Ve as setChatToken,
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5490
|
+
Cr as stringifyTool,
|
|
5491
|
+
We as useApi,
|
|
5492
|
+
ro as useChatController,
|
|
5493
|
+
Os as useChatSession,
|
|
5494
|
+
eo as useFilePreview,
|
|
5495
|
+
so as useMessageContent,
|
|
5496
|
+
to as useParsedMessageContent,
|
|
5497
|
+
es as useStream,
|
|
5498
|
+
oo as useStreamingMarkdownBuffer,
|
|
5499
|
+
An as useThreadHistoryState,
|
|
5500
|
+
Cn as useThreadState,
|
|
5501
|
+
Is as useThreadStateUpdater,
|
|
5487
5502
|
st as useThreads,
|
|
5488
|
-
|
|
5489
|
-
|
|
5503
|
+
rs as useThreadsState,
|
|
5504
|
+
no as useToolPayload
|
|
5490
5505
|
};
|
|
5491
5506
|
//# sourceMappingURL=index.esm.js.map
|