@teodorruskvi/chat-core 0.1.30 → 0.1.31
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 +1276 -1254
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +7 -7
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var Ln = Object.defineProperty;
|
|
2
|
+
var zn = (e, t, n) => t in e ? Ln(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var $t = (e, t, n) => zn(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { jsx as Ce } from "react/jsx-runtime";
|
|
5
|
-
import * as
|
|
6
|
-
import { createContext as
|
|
7
|
-
import
|
|
8
|
-
function
|
|
5
|
+
import * as Bt from "react";
|
|
6
|
+
import { createContext as We, useContext as ot, useState as W, useRef as H, useEffect as se, useCallback as E, useMemo as de, useReducer as Un } from "react";
|
|
7
|
+
import Fn, { isCancel as Dt } from "axios";
|
|
8
|
+
function nn(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 = nn(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 jn() {
|
|
18
|
+
for (var e, t, n = 0, r = "", s = arguments.length; n < s; n++) (e = arguments[n]) && (t = nn(e)) && (r && (r += " "), r += t);
|
|
19
19
|
return r;
|
|
20
20
|
}
|
|
21
|
-
const
|
|
22
|
-
const t =
|
|
21
|
+
const Lt = "-", On = (e) => {
|
|
22
|
+
const t = Bn(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(Lt);
|
|
29
|
+
return i[0] === "" && i.length !== 1 && i.shift(), rn(i, t) || $n(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
|
+
}, rn = (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 ? rn(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(Lt);
|
|
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
|
+
}, Vt = /^\[(.+)\]$/, $n = (e) => {
|
|
50
|
+
if (Vt.test(e)) {
|
|
51
|
+
const t = Vt.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
|
+
}, Bn = (e) => {
|
|
56
56
|
const {
|
|
57
57
|
theme: t,
|
|
58
58
|
prefix: n
|
|
@@ -60,19 +60,19 @@ const zt = "-", $n = (e) => {
|
|
|
60
60
|
nextPart: /* @__PURE__ */ new Map(),
|
|
61
61
|
validators: []
|
|
62
62
|
};
|
|
63
|
-
return
|
|
64
|
-
|
|
63
|
+
return Vn(Object.entries(e.classGroups), n).forEach(([o, a]) => {
|
|
64
|
+
Rt(a, r, o, t);
|
|
65
65
|
}), r;
|
|
66
|
-
},
|
|
66
|
+
}, Rt = (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 : Kt(t, s);
|
|
70
70
|
o.classGroupId = n;
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
if (typeof s == "function") {
|
|
74
|
-
if (
|
|
75
|
-
|
|
74
|
+
if (Dn(s)) {
|
|
75
|
+
Rt(s(r), t, n, r);
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
t.validators.push({
|
|
@@ -82,21 +82,21 @@ const zt = "-", $n = (e) => {
|
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
84
|
Object.entries(s).forEach(([o, a]) => {
|
|
85
|
-
|
|
85
|
+
Rt(a, Kt(t, o), n, r);
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
|
-
},
|
|
88
|
+
}, Kt = (e, t) => {
|
|
89
89
|
let n = e;
|
|
90
|
-
return t.split(
|
|
90
|
+
return t.split(Lt).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
|
+
}, Dn = (e) => e.isThemeGetter, Vn = (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, Kn = (e) => {
|
|
100
100
|
if (e < 1)
|
|
101
101
|
return {
|
|
102
102
|
get: () => {
|
|
@@ -120,7 +120,7 @@ const zt = "-", $n = (e) => {
|
|
|
120
120
|
n.has(o) ? n.set(o, a) : s(o, a);
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
|
-
},
|
|
123
|
+
}, sn = "!", Hn = (e) => {
|
|
124
124
|
const {
|
|
125
125
|
separator: t,
|
|
126
126
|
experimentalParseClassName: n
|
|
@@ -141,11 +141,11 @@ const zt = "-", $n = (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(sn), k = h ? g.substring(1) : g, m = d && d > c ? d - c : void 0;
|
|
145
145
|
return {
|
|
146
146
|
modifiers: f,
|
|
147
147
|
hasImportantModifier: h,
|
|
148
|
-
baseClassName:
|
|
148
|
+
baseClassName: k,
|
|
149
149
|
maybePostfixModifierPosition: m
|
|
150
150
|
};
|
|
151
151
|
};
|
|
@@ -153,7 +153,7 @@ const zt = "-", $n = (e) => {
|
|
|
153
153
|
className: i,
|
|
154
154
|
parseClassName: a
|
|
155
155
|
}) : a;
|
|
156
|
-
},
|
|
156
|
+
}, qn = (e) => {
|
|
157
157
|
if (e.length <= 1)
|
|
158
158
|
return e;
|
|
159
159
|
const t = [];
|
|
@@ -161,16 +161,16 @@ const zt = "-", $n = (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
|
+
}, Wn = (e) => ({
|
|
165
|
+
cache: Kn(e.cacheSize),
|
|
166
|
+
parseClassName: Hn(e),
|
|
167
|
+
...On(e)
|
|
168
|
+
}), Gn = /\s+/, Jn = (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(Gn);
|
|
174
174
|
let i = "";
|
|
175
175
|
for (let f = a.length - 1; f >= 0; f -= 1) {
|
|
176
176
|
const l = a[f], {
|
|
@@ -179,9 +179,9 @@ const zt = "-", $n = (e) => {
|
|
|
179
179
|
baseClassName: g,
|
|
180
180
|
maybePostfixModifierPosition: h
|
|
181
181
|
} = n(l);
|
|
182
|
-
let
|
|
182
|
+
let k = !!h, m = r(k ? g.substring(0, h) : g);
|
|
183
183
|
if (!m) {
|
|
184
|
-
if (!
|
|
184
|
+
if (!k) {
|
|
185
185
|
i = l + (i.length > 0 ? " " + i : i);
|
|
186
186
|
continue;
|
|
187
187
|
}
|
|
@@ -189,94 +189,94 @@ const zt = "-", $n = (e) => {
|
|
|
189
189
|
i = l + (i.length > 0 ? " " + i : i);
|
|
190
190
|
continue;
|
|
191
191
|
}
|
|
192
|
-
|
|
192
|
+
k = !1;
|
|
193
193
|
}
|
|
194
|
-
const y =
|
|
195
|
-
if (o.includes(
|
|
194
|
+
const y = qn(c).join(":"), I = d ? y + sn : y, S = I + m;
|
|
195
|
+
if (o.includes(S))
|
|
196
196
|
continue;
|
|
197
|
-
o.push(
|
|
198
|
-
const
|
|
199
|
-
for (let
|
|
200
|
-
const
|
|
201
|
-
o.push(I +
|
|
197
|
+
o.push(S);
|
|
198
|
+
const C = s(m, k);
|
|
199
|
+
for (let L = 0; L < C.length; ++L) {
|
|
200
|
+
const z = C[L];
|
|
201
|
+
o.push(I + z);
|
|
202
202
|
}
|
|
203
203
|
i = l + (i.length > 0 ? " " + i : i);
|
|
204
204
|
}
|
|
205
205
|
return i;
|
|
206
206
|
};
|
|
207
|
-
function
|
|
207
|
+
function Xn() {
|
|
208
208
|
let e = 0, t, n, r = "";
|
|
209
209
|
for (; e < arguments.length; )
|
|
210
|
-
(t = arguments[e++]) && (n =
|
|
210
|
+
(t = arguments[e++]) && (n = on(t)) && (r && (r += " "), r += n);
|
|
211
211
|
return r;
|
|
212
212
|
}
|
|
213
|
-
const
|
|
213
|
+
const on = (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 = on(e[r])) && (n && (n += " "), n += t);
|
|
219
219
|
return n;
|
|
220
220
|
};
|
|
221
|
-
function
|
|
221
|
+
function Qn(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 = Wn(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 = Jn(f, n);
|
|
232
232
|
return s(f, c), c;
|
|
233
233
|
}
|
|
234
234
|
return function() {
|
|
235
|
-
return o(
|
|
235
|
+
return o(Xn.apply(null, arguments));
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
|
-
const
|
|
238
|
+
const te = (e) => {
|
|
239
239
|
const t = (n) => n[e] || [];
|
|
240
240
|
return t.isThemeGetter = !0, t;
|
|
241
|
-
},
|
|
242
|
-
const r =
|
|
241
|
+
}, an = /^\[(?:([a-z-]+):)?(.+)\]$/i, Yn = /^\d+\/\d+$/, Zn = /* @__PURE__ */ new Set(["px", "full", "screen"]), er = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, tr = /\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$/, nr = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, rr = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, sr = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, Ne = (e) => He(e) || Zn.has(e) || Yn.test(e), ze = (e) => Ge(e, "length", fr), He = (e) => !!e && !Number.isNaN(Number(e)), xt = (e) => Ge(e, "number", He), Ze = (e) => !!e && Number.isInteger(Number(e)), or = (e) => e.endsWith("%") && He(e.slice(0, -1)), O = (e) => an.test(e), Ue = (e) => er.test(e), ar = /* @__PURE__ */ new Set(["length", "size", "percentage"]), ir = (e) => Ge(e, ar, cn), cr = (e) => Ge(e, "position", cn), lr = /* @__PURE__ */ new Set(["image", "url"]), ur = (e) => Ge(e, lr, gr), dr = (e) => Ge(e, "", pr), et = () => !0, Ge = (e, t, n) => {
|
|
242
|
+
const r = an.exec(e);
|
|
243
243
|
return r ? r[1] ? typeof t == "string" ? r[1] === t : t.has(r[1]) : n(r[2]) : !1;
|
|
244
|
-
},
|
|
244
|
+
}, fr = (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 =
|
|
248
|
+
tr.test(e) && !nr.test(e)
|
|
249
|
+
), cn = () => !1, pr = (e) => rr.test(e), gr = (e) => sr.test(e), mr = () => {
|
|
250
|
+
const e = te("colors"), t = te("spacing"), n = te("blur"), r = te("brightness"), s = te("borderColor"), o = te("borderRadius"), a = te("borderSpacing"), i = te("borderWidth"), f = te("contrast"), l = te("grayscale"), c = te("hueRotate"), d = te("invert"), g = te("gap"), h = te("gradientColorStops"), k = te("gradientColorStopPositions"), m = te("inset"), y = te("margin"), I = te("opacity"), S = te("padding"), C = te("saturate"), L = te("scale"), z = te("sepia"), w = te("skew"), v = te("space"), F = te("translate"), $ = () => ["auto", "contain", "none"], B = () => ["auto", "hidden", "clip", "visible", "scroll"], D = () => ["auto", O, t], P = () => [O, t], J = () => ["", Ne, ze], G = () => ["auto", He, O], Q = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], X = () => ["solid", "dashed", "dotted", "double", "none"], oe = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], A = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], R = () => ["", "0", O], V = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], K = () => [He, O];
|
|
251
251
|
return {
|
|
252
252
|
cacheSize: 500,
|
|
253
253
|
separator: ":",
|
|
254
254
|
theme: {
|
|
255
255
|
colors: [et],
|
|
256
256
|
spacing: [Ne, ze],
|
|
257
|
-
blur: ["none", "", Ue,
|
|
258
|
-
brightness:
|
|
257
|
+
blur: ["none", "", Ue, O],
|
|
258
|
+
brightness: K(),
|
|
259
259
|
borderColor: [e],
|
|
260
|
-
borderRadius: ["none", "", "full", Ue,
|
|
261
|
-
borderSpacing:
|
|
260
|
+
borderRadius: ["none", "", "full", Ue, O],
|
|
261
|
+
borderSpacing: P(),
|
|
262
262
|
borderWidth: J(),
|
|
263
|
-
contrast:
|
|
264
|
-
grayscale:
|
|
265
|
-
hueRotate:
|
|
266
|
-
invert:
|
|
267
|
-
gap:
|
|
263
|
+
contrast: K(),
|
|
264
|
+
grayscale: R(),
|
|
265
|
+
hueRotate: K(),
|
|
266
|
+
invert: R(),
|
|
267
|
+
gap: P(),
|
|
268
268
|
gradientColorStops: [e],
|
|
269
|
-
gradientColorStopPositions: [
|
|
270
|
-
inset:
|
|
271
|
-
margin:
|
|
272
|
-
opacity:
|
|
273
|
-
padding:
|
|
274
|
-
saturate:
|
|
275
|
-
scale:
|
|
276
|
-
sepia:
|
|
277
|
-
skew:
|
|
278
|
-
space:
|
|
279
|
-
translate:
|
|
269
|
+
gradientColorStopPositions: [or, ze],
|
|
270
|
+
inset: D(),
|
|
271
|
+
margin: D(),
|
|
272
|
+
opacity: K(),
|
|
273
|
+
padding: P(),
|
|
274
|
+
saturate: K(),
|
|
275
|
+
scale: K(),
|
|
276
|
+
sepia: R(),
|
|
277
|
+
skew: K(),
|
|
278
|
+
space: P(),
|
|
279
|
+
translate: P()
|
|
280
280
|
},
|
|
281
281
|
classGroups: {
|
|
282
282
|
// Layout
|
|
@@ -285,7 +285,7 @@ const Z = (e) => {
|
|
|
285
285
|
* @see https://tailwindcss.com/docs/aspect-ratio
|
|
286
286
|
*/
|
|
287
287
|
aspect: [{
|
|
288
|
-
aspect: ["auto", "square", "video",
|
|
288
|
+
aspect: ["auto", "square", "video", O]
|
|
289
289
|
}],
|
|
290
290
|
/**
|
|
291
291
|
* Container
|
|
@@ -304,14 +304,14 @@ const Z = (e) => {
|
|
|
304
304
|
* @see https://tailwindcss.com/docs/break-after
|
|
305
305
|
*/
|
|
306
306
|
"break-after": [{
|
|
307
|
-
"break-after":
|
|
307
|
+
"break-after": V()
|
|
308
308
|
}],
|
|
309
309
|
/**
|
|
310
310
|
* Break Before
|
|
311
311
|
* @see https://tailwindcss.com/docs/break-before
|
|
312
312
|
*/
|
|
313
313
|
"break-before": [{
|
|
314
|
-
"break-before":
|
|
314
|
+
"break-before": V()
|
|
315
315
|
}],
|
|
316
316
|
/**
|
|
317
317
|
* Break Inside
|
|
@@ -370,49 +370,49 @@ const Z = (e) => {
|
|
|
370
370
|
* @see https://tailwindcss.com/docs/object-position
|
|
371
371
|
*/
|
|
372
372
|
"object-position": [{
|
|
373
|
-
object: [...Q(),
|
|
373
|
+
object: [...Q(), O]
|
|
374
374
|
}],
|
|
375
375
|
/**
|
|
376
376
|
* Overflow
|
|
377
377
|
* @see https://tailwindcss.com/docs/overflow
|
|
378
378
|
*/
|
|
379
379
|
overflow: [{
|
|
380
|
-
overflow:
|
|
380
|
+
overflow: B()
|
|
381
381
|
}],
|
|
382
382
|
/**
|
|
383
383
|
* Overflow X
|
|
384
384
|
* @see https://tailwindcss.com/docs/overflow
|
|
385
385
|
*/
|
|
386
386
|
"overflow-x": [{
|
|
387
|
-
"overflow-x":
|
|
387
|
+
"overflow-x": B()
|
|
388
388
|
}],
|
|
389
389
|
/**
|
|
390
390
|
* Overflow Y
|
|
391
391
|
* @see https://tailwindcss.com/docs/overflow
|
|
392
392
|
*/
|
|
393
393
|
"overflow-y": [{
|
|
394
|
-
"overflow-y":
|
|
394
|
+
"overflow-y": B()
|
|
395
395
|
}],
|
|
396
396
|
/**
|
|
397
397
|
* Overscroll Behavior
|
|
398
398
|
* @see https://tailwindcss.com/docs/overscroll-behavior
|
|
399
399
|
*/
|
|
400
400
|
overscroll: [{
|
|
401
|
-
overscroll:
|
|
401
|
+
overscroll: $()
|
|
402
402
|
}],
|
|
403
403
|
/**
|
|
404
404
|
* Overscroll Behavior X
|
|
405
405
|
* @see https://tailwindcss.com/docs/overscroll-behavior
|
|
406
406
|
*/
|
|
407
407
|
"overscroll-x": [{
|
|
408
|
-
"overscroll-x":
|
|
408
|
+
"overscroll-x": $()
|
|
409
409
|
}],
|
|
410
410
|
/**
|
|
411
411
|
* Overscroll Behavior Y
|
|
412
412
|
* @see https://tailwindcss.com/docs/overscroll-behavior
|
|
413
413
|
*/
|
|
414
414
|
"overscroll-y": [{
|
|
415
|
-
"overscroll-y":
|
|
415
|
+
"overscroll-y": $()
|
|
416
416
|
}],
|
|
417
417
|
/**
|
|
418
418
|
* Position
|
|
@@ -492,7 +492,7 @@ const Z = (e) => {
|
|
|
492
492
|
* @see https://tailwindcss.com/docs/z-index
|
|
493
493
|
*/
|
|
494
494
|
z: [{
|
|
495
|
-
z: ["auto", Ze,
|
|
495
|
+
z: ["auto", Ze, O]
|
|
496
496
|
}],
|
|
497
497
|
// Flexbox and Grid
|
|
498
498
|
/**
|
|
@@ -500,7 +500,7 @@ const Z = (e) => {
|
|
|
500
500
|
* @see https://tailwindcss.com/docs/flex-basis
|
|
501
501
|
*/
|
|
502
502
|
basis: [{
|
|
503
|
-
basis:
|
|
503
|
+
basis: D()
|
|
504
504
|
}],
|
|
505
505
|
/**
|
|
506
506
|
* Flex Direction
|
|
@@ -521,28 +521,28 @@ const Z = (e) => {
|
|
|
521
521
|
* @see https://tailwindcss.com/docs/flex
|
|
522
522
|
*/
|
|
523
523
|
flex: [{
|
|
524
|
-
flex: ["1", "auto", "initial", "none",
|
|
524
|
+
flex: ["1", "auto", "initial", "none", O]
|
|
525
525
|
}],
|
|
526
526
|
/**
|
|
527
527
|
* Flex Grow
|
|
528
528
|
* @see https://tailwindcss.com/docs/flex-grow
|
|
529
529
|
*/
|
|
530
530
|
grow: [{
|
|
531
|
-
grow:
|
|
531
|
+
grow: R()
|
|
532
532
|
}],
|
|
533
533
|
/**
|
|
534
534
|
* Flex Shrink
|
|
535
535
|
* @see https://tailwindcss.com/docs/flex-shrink
|
|
536
536
|
*/
|
|
537
537
|
shrink: [{
|
|
538
|
-
shrink:
|
|
538
|
+
shrink: R()
|
|
539
539
|
}],
|
|
540
540
|
/**
|
|
541
541
|
* Order
|
|
542
542
|
* @see https://tailwindcss.com/docs/order
|
|
543
543
|
*/
|
|
544
544
|
order: [{
|
|
545
|
-
order: ["first", "last", "none", Ze,
|
|
545
|
+
order: ["first", "last", "none", Ze, O]
|
|
546
546
|
}],
|
|
547
547
|
/**
|
|
548
548
|
* Grid Template Columns
|
|
@@ -557,22 +557,22 @@ const Z = (e) => {
|
|
|
557
557
|
*/
|
|
558
558
|
"col-start-end": [{
|
|
559
559
|
col: ["auto", {
|
|
560
|
-
span: ["full", Ze,
|
|
561
|
-
},
|
|
560
|
+
span: ["full", Ze, O]
|
|
561
|
+
}, O]
|
|
562
562
|
}],
|
|
563
563
|
/**
|
|
564
564
|
* Grid Column Start
|
|
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
|
|
@@ -587,22 +587,22 @@ const Z = (e) => {
|
|
|
587
587
|
*/
|
|
588
588
|
"row-start-end": [{
|
|
589
589
|
row: ["auto", {
|
|
590
|
-
span: [Ze,
|
|
591
|
-
},
|
|
590
|
+
span: [Ze, O]
|
|
591
|
+
}, O]
|
|
592
592
|
}],
|
|
593
593
|
/**
|
|
594
594
|
* Grid Row Start
|
|
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
|
|
@@ -616,14 +616,14 @@ const Z = (e) => {
|
|
|
616
616
|
* @see https://tailwindcss.com/docs/grid-auto-columns
|
|
617
617
|
*/
|
|
618
618
|
"auto-cols": [{
|
|
619
|
-
"auto-cols": ["auto", "min", "max", "fr",
|
|
619
|
+
"auto-cols": ["auto", "min", "max", "fr", O]
|
|
620
620
|
}],
|
|
621
621
|
/**
|
|
622
622
|
* Grid Auto Rows
|
|
623
623
|
* @see https://tailwindcss.com/docs/grid-auto-rows
|
|
624
624
|
*/
|
|
625
625
|
"auto-rows": [{
|
|
626
|
-
"auto-rows": ["auto", "min", "max", "fr",
|
|
626
|
+
"auto-rows": ["auto", "min", "max", "fr", O]
|
|
627
627
|
}],
|
|
628
628
|
/**
|
|
629
629
|
* Gap
|
|
@@ -651,7 +651,7 @@ const Z = (e) => {
|
|
|
651
651
|
* @see https://tailwindcss.com/docs/justify-content
|
|
652
652
|
*/
|
|
653
653
|
"justify-content": [{
|
|
654
|
-
justify: ["normal", ...
|
|
654
|
+
justify: ["normal", ...A()]
|
|
655
655
|
}],
|
|
656
656
|
/**
|
|
657
657
|
* Justify Items
|
|
@@ -672,7 +672,7 @@ const Z = (e) => {
|
|
|
672
672
|
* @see https://tailwindcss.com/docs/align-content
|
|
673
673
|
*/
|
|
674
674
|
"align-content": [{
|
|
675
|
-
content: ["normal", ...
|
|
675
|
+
content: ["normal", ...A(), "baseline"]
|
|
676
676
|
}],
|
|
677
677
|
/**
|
|
678
678
|
* Align Items
|
|
@@ -693,7 +693,7 @@ const Z = (e) => {
|
|
|
693
693
|
* @see https://tailwindcss.com/docs/place-content
|
|
694
694
|
*/
|
|
695
695
|
"place-content": [{
|
|
696
|
-
"place-content": [...
|
|
696
|
+
"place-content": [...A(), "baseline"]
|
|
697
697
|
}],
|
|
698
698
|
/**
|
|
699
699
|
* Place Items
|
|
@@ -715,63 +715,63 @@ const Z = (e) => {
|
|
|
715
715
|
* @see https://tailwindcss.com/docs/padding
|
|
716
716
|
*/
|
|
717
717
|
p: [{
|
|
718
|
-
p: [
|
|
718
|
+
p: [S]
|
|
719
719
|
}],
|
|
720
720
|
/**
|
|
721
721
|
* Padding X
|
|
722
722
|
* @see https://tailwindcss.com/docs/padding
|
|
723
723
|
*/
|
|
724
724
|
px: [{
|
|
725
|
-
px: [
|
|
725
|
+
px: [S]
|
|
726
726
|
}],
|
|
727
727
|
/**
|
|
728
728
|
* Padding Y
|
|
729
729
|
* @see https://tailwindcss.com/docs/padding
|
|
730
730
|
*/
|
|
731
731
|
py: [{
|
|
732
|
-
py: [
|
|
732
|
+
py: [S]
|
|
733
733
|
}],
|
|
734
734
|
/**
|
|
735
735
|
* Padding Start
|
|
736
736
|
* @see https://tailwindcss.com/docs/padding
|
|
737
737
|
*/
|
|
738
738
|
ps: [{
|
|
739
|
-
ps: [
|
|
739
|
+
ps: [S]
|
|
740
740
|
}],
|
|
741
741
|
/**
|
|
742
742
|
* Padding End
|
|
743
743
|
* @see https://tailwindcss.com/docs/padding
|
|
744
744
|
*/
|
|
745
745
|
pe: [{
|
|
746
|
-
pe: [
|
|
746
|
+
pe: [S]
|
|
747
747
|
}],
|
|
748
748
|
/**
|
|
749
749
|
* Padding Top
|
|
750
750
|
* @see https://tailwindcss.com/docs/padding
|
|
751
751
|
*/
|
|
752
752
|
pt: [{
|
|
753
|
-
pt: [
|
|
753
|
+
pt: [S]
|
|
754
754
|
}],
|
|
755
755
|
/**
|
|
756
756
|
* Padding Right
|
|
757
757
|
* @see https://tailwindcss.com/docs/padding
|
|
758
758
|
*/
|
|
759
759
|
pr: [{
|
|
760
|
-
pr: [
|
|
760
|
+
pr: [S]
|
|
761
761
|
}],
|
|
762
762
|
/**
|
|
763
763
|
* Padding Bottom
|
|
764
764
|
* @see https://tailwindcss.com/docs/padding
|
|
765
765
|
*/
|
|
766
766
|
pb: [{
|
|
767
|
-
pb: [
|
|
767
|
+
pb: [S]
|
|
768
768
|
}],
|
|
769
769
|
/**
|
|
770
770
|
* Padding Left
|
|
771
771
|
* @see https://tailwindcss.com/docs/padding
|
|
772
772
|
*/
|
|
773
773
|
pl: [{
|
|
774
|
-
pl: [
|
|
774
|
+
pl: [S]
|
|
775
775
|
}],
|
|
776
776
|
/**
|
|
777
777
|
* Margin
|
|
@@ -841,7 +841,7 @@ const Z = (e) => {
|
|
|
841
841
|
* @see https://tailwindcss.com/docs/space
|
|
842
842
|
*/
|
|
843
843
|
"space-x": [{
|
|
844
|
-
"space-x": [
|
|
844
|
+
"space-x": [v]
|
|
845
845
|
}],
|
|
846
846
|
/**
|
|
847
847
|
* Space Between X Reverse
|
|
@@ -853,7 +853,7 @@ const Z = (e) => {
|
|
|
853
853
|
* @see https://tailwindcss.com/docs/space
|
|
854
854
|
*/
|
|
855
855
|
"space-y": [{
|
|
856
|
-
"space-y": [
|
|
856
|
+
"space-y": [v]
|
|
857
857
|
}],
|
|
858
858
|
/**
|
|
859
859
|
* Space Between Y Reverse
|
|
@@ -866,21 +866,21 @@ const Z = (e) => {
|
|
|
866
866
|
* @see https://tailwindcss.com/docs/width
|
|
867
867
|
*/
|
|
868
868
|
w: [{
|
|
869
|
-
w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw",
|
|
869
|
+
w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", O, t]
|
|
870
870
|
}],
|
|
871
871
|
/**
|
|
872
872
|
* Min-Width
|
|
873
873
|
* @see https://tailwindcss.com/docs/min-width
|
|
874
874
|
*/
|
|
875
875
|
"min-w": [{
|
|
876
|
-
"min-w": [
|
|
876
|
+
"min-w": [O, t, "min", "max", "fit"]
|
|
877
877
|
}],
|
|
878
878
|
/**
|
|
879
879
|
* Max-Width
|
|
880
880
|
* @see https://tailwindcss.com/docs/max-width
|
|
881
881
|
*/
|
|
882
882
|
"max-w": [{
|
|
883
|
-
"max-w": [
|
|
883
|
+
"max-w": [O, t, "none", "full", "min", "max", "fit", "prose", {
|
|
884
884
|
screen: [Ue]
|
|
885
885
|
}, Ue]
|
|
886
886
|
}],
|
|
@@ -889,28 +889,28 @@ const Z = (e) => {
|
|
|
889
889
|
* @see https://tailwindcss.com/docs/height
|
|
890
890
|
*/
|
|
891
891
|
h: [{
|
|
892
|
-
h: [
|
|
892
|
+
h: [O, t, "auto", "min", "max", "fit", "svh", "lvh", "dvh"]
|
|
893
893
|
}],
|
|
894
894
|
/**
|
|
895
895
|
* Min-Height
|
|
896
896
|
* @see https://tailwindcss.com/docs/min-height
|
|
897
897
|
*/
|
|
898
898
|
"min-h": [{
|
|
899
|
-
"min-h": [
|
|
899
|
+
"min-h": [O, t, "min", "max", "fit", "svh", "lvh", "dvh"]
|
|
900
900
|
}],
|
|
901
901
|
/**
|
|
902
902
|
* Max-Height
|
|
903
903
|
* @see https://tailwindcss.com/docs/max-height
|
|
904
904
|
*/
|
|
905
905
|
"max-h": [{
|
|
906
|
-
"max-h": [
|
|
906
|
+
"max-h": [O, t, "min", "max", "fit", "svh", "lvh", "dvh"]
|
|
907
907
|
}],
|
|
908
908
|
/**
|
|
909
909
|
* Size
|
|
910
910
|
* @see https://tailwindcss.com/docs/size
|
|
911
911
|
*/
|
|
912
912
|
size: [{
|
|
913
|
-
size: [
|
|
913
|
+
size: [O, t, "auto", "min", "max", "fit"]
|
|
914
914
|
}],
|
|
915
915
|
// Typography
|
|
916
916
|
/**
|
|
@@ -979,35 +979,35 @@ const Z = (e) => {
|
|
|
979
979
|
* @see https://tailwindcss.com/docs/letter-spacing
|
|
980
980
|
*/
|
|
981
981
|
tracking: [{
|
|
982
|
-
tracking: ["tighter", "tight", "normal", "wide", "wider", "widest",
|
|
982
|
+
tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", O]
|
|
983
983
|
}],
|
|
984
984
|
/**
|
|
985
985
|
* Line Clamp
|
|
986
986
|
* @see https://tailwindcss.com/docs/line-clamp
|
|
987
987
|
*/
|
|
988
988
|
"line-clamp": [{
|
|
989
|
-
"line-clamp": ["none",
|
|
989
|
+
"line-clamp": ["none", He, xt]
|
|
990
990
|
}],
|
|
991
991
|
/**
|
|
992
992
|
* Line Height
|
|
993
993
|
* @see https://tailwindcss.com/docs/line-height
|
|
994
994
|
*/
|
|
995
995
|
leading: [{
|
|
996
|
-
leading: ["none", "tight", "snug", "normal", "relaxed", "loose", Ne,
|
|
996
|
+
leading: ["none", "tight", "snug", "normal", "relaxed", "loose", Ne, O]
|
|
997
997
|
}],
|
|
998
998
|
/**
|
|
999
999
|
* List Style Image
|
|
1000
1000
|
* @see https://tailwindcss.com/docs/list-style-image
|
|
1001
1001
|
*/
|
|
1002
1002
|
"list-image": [{
|
|
1003
|
-
"list-image": ["none",
|
|
1003
|
+
"list-image": ["none", O]
|
|
1004
1004
|
}],
|
|
1005
1005
|
/**
|
|
1006
1006
|
* List Style Type
|
|
1007
1007
|
* @see https://tailwindcss.com/docs/list-style-type
|
|
1008
1008
|
*/
|
|
1009
1009
|
"list-style-type": [{
|
|
1010
|
-
list: ["none", "disc", "decimal",
|
|
1010
|
+
list: ["none", "disc", "decimal", O]
|
|
1011
1011
|
}],
|
|
1012
1012
|
/**
|
|
1013
1013
|
* List Style Position
|
|
@@ -1062,7 +1062,7 @@ const Z = (e) => {
|
|
|
1062
1062
|
* @see https://tailwindcss.com/docs/text-decoration-style
|
|
1063
1063
|
*/
|
|
1064
1064
|
"text-decoration-style": [{
|
|
1065
|
-
decoration: [...
|
|
1065
|
+
decoration: [...X(), "wavy"]
|
|
1066
1066
|
}],
|
|
1067
1067
|
/**
|
|
1068
1068
|
* Text Decoration Thickness
|
|
@@ -1076,7 +1076,7 @@ const Z = (e) => {
|
|
|
1076
1076
|
* @see https://tailwindcss.com/docs/text-underline-offset
|
|
1077
1077
|
*/
|
|
1078
1078
|
"underline-offset": [{
|
|
1079
|
-
"underline-offset": ["auto", Ne,
|
|
1079
|
+
"underline-offset": ["auto", Ne, O]
|
|
1080
1080
|
}],
|
|
1081
1081
|
/**
|
|
1082
1082
|
* Text Decoration Color
|
|
@@ -1107,14 +1107,14 @@ const Z = (e) => {
|
|
|
1107
1107
|
* @see https://tailwindcss.com/docs/text-indent
|
|
1108
1108
|
*/
|
|
1109
1109
|
indent: [{
|
|
1110
|
-
indent:
|
|
1110
|
+
indent: P()
|
|
1111
1111
|
}],
|
|
1112
1112
|
/**
|
|
1113
1113
|
* Vertical Alignment
|
|
1114
1114
|
* @see https://tailwindcss.com/docs/vertical-align
|
|
1115
1115
|
*/
|
|
1116
1116
|
"vertical-align": [{
|
|
1117
|
-
align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super",
|
|
1117
|
+
align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super", O]
|
|
1118
1118
|
}],
|
|
1119
1119
|
/**
|
|
1120
1120
|
* Whitespace
|
|
@@ -1142,7 +1142,7 @@ const Z = (e) => {
|
|
|
1142
1142
|
* @see https://tailwindcss.com/docs/content
|
|
1143
1143
|
*/
|
|
1144
1144
|
content: [{
|
|
1145
|
-
content: ["none",
|
|
1145
|
+
content: ["none", O]
|
|
1146
1146
|
}],
|
|
1147
1147
|
// Backgrounds
|
|
1148
1148
|
/**
|
|
@@ -1179,7 +1179,7 @@ const Z = (e) => {
|
|
|
1179
1179
|
* @see https://tailwindcss.com/docs/background-position
|
|
1180
1180
|
*/
|
|
1181
1181
|
"bg-position": [{
|
|
1182
|
-
bg: [...Q(),
|
|
1182
|
+
bg: [...Q(), cr]
|
|
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", ir]
|
|
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
|
+
}, ur]
|
|
1208
1208
|
}],
|
|
1209
1209
|
/**
|
|
1210
1210
|
* Background Color
|
|
@@ -1218,21 +1218,21 @@ const Z = (e) => {
|
|
|
1218
1218
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
1219
1219
|
*/
|
|
1220
1220
|
"gradient-from-pos": [{
|
|
1221
|
-
from: [
|
|
1221
|
+
from: [k]
|
|
1222
1222
|
}],
|
|
1223
1223
|
/**
|
|
1224
1224
|
* Gradient Color Stops Via Position
|
|
1225
1225
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
1226
1226
|
*/
|
|
1227
1227
|
"gradient-via-pos": [{
|
|
1228
|
-
via: [
|
|
1228
|
+
via: [k]
|
|
1229
1229
|
}],
|
|
1230
1230
|
/**
|
|
1231
1231
|
* Gradient Color Stops To Position
|
|
1232
1232
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
1233
1233
|
*/
|
|
1234
1234
|
"gradient-to-pos": [{
|
|
1235
|
-
to: [
|
|
1235
|
+
to: [k]
|
|
1236
1236
|
}],
|
|
1237
1237
|
/**
|
|
1238
1238
|
* Gradient Color Stops From
|
|
@@ -1436,7 +1436,7 @@ const Z = (e) => {
|
|
|
1436
1436
|
* @see https://tailwindcss.com/docs/border-style
|
|
1437
1437
|
*/
|
|
1438
1438
|
"border-style": [{
|
|
1439
|
-
border: [...
|
|
1439
|
+
border: [...X(), "hidden"]
|
|
1440
1440
|
}],
|
|
1441
1441
|
/**
|
|
1442
1442
|
* Divide Width X
|
|
@@ -1474,7 +1474,7 @@ const Z = (e) => {
|
|
|
1474
1474
|
* @see https://tailwindcss.com/docs/divide-style
|
|
1475
1475
|
*/
|
|
1476
1476
|
"divide-style": [{
|
|
1477
|
-
divide:
|
|
1477
|
+
divide: X()
|
|
1478
1478
|
}],
|
|
1479
1479
|
/**
|
|
1480
1480
|
* Border Color
|
|
@@ -1551,14 +1551,14 @@ const Z = (e) => {
|
|
|
1551
1551
|
* @see https://tailwindcss.com/docs/outline-style
|
|
1552
1552
|
*/
|
|
1553
1553
|
"outline-style": [{
|
|
1554
|
-
outline: ["", ...
|
|
1554
|
+
outline: ["", ...X()]
|
|
1555
1555
|
}],
|
|
1556
1556
|
/**
|
|
1557
1557
|
* Outline Offset
|
|
1558
1558
|
* @see https://tailwindcss.com/docs/outline-offset
|
|
1559
1559
|
*/
|
|
1560
1560
|
"outline-offset": [{
|
|
1561
|
-
"outline-offset": [Ne,
|
|
1561
|
+
"outline-offset": [Ne, O]
|
|
1562
1562
|
}],
|
|
1563
1563
|
/**
|
|
1564
1564
|
* Outline Width
|
|
@@ -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", Ue,
|
|
1623
|
+
shadow: ["", "inner", "none", Ue, dr]
|
|
1624
1624
|
}],
|
|
1625
1625
|
/**
|
|
1626
1626
|
* Box Shadow Color
|
|
@@ -1641,14 +1641,14 @@ const Z = (e) => {
|
|
|
1641
1641
|
* @see https://tailwindcss.com/docs/mix-blend-mode
|
|
1642
1642
|
*/
|
|
1643
1643
|
"mix-blend": [{
|
|
1644
|
-
"mix-blend": [...
|
|
1644
|
+
"mix-blend": [...oe(), "plus-lighter", "plus-darker"]
|
|
1645
1645
|
}],
|
|
1646
1646
|
/**
|
|
1647
1647
|
* Background Blend Mode
|
|
1648
1648
|
* @see https://tailwindcss.com/docs/background-blend-mode
|
|
1649
1649
|
*/
|
|
1650
1650
|
"bg-blend": [{
|
|
1651
|
-
"bg-blend":
|
|
1651
|
+
"bg-blend": oe()
|
|
1652
1652
|
}],
|
|
1653
1653
|
// Filters
|
|
1654
1654
|
/**
|
|
@@ -1685,7 +1685,7 @@ const Z = (e) => {
|
|
|
1685
1685
|
* @see https://tailwindcss.com/docs/drop-shadow
|
|
1686
1686
|
*/
|
|
1687
1687
|
"drop-shadow": [{
|
|
1688
|
-
"drop-shadow": ["", "none", Ue,
|
|
1688
|
+
"drop-shadow": ["", "none", Ue, O]
|
|
1689
1689
|
}],
|
|
1690
1690
|
/**
|
|
1691
1691
|
* Grayscale
|
|
@@ -1713,14 +1713,14 @@ const Z = (e) => {
|
|
|
1713
1713
|
* @see https://tailwindcss.com/docs/saturate
|
|
1714
1714
|
*/
|
|
1715
1715
|
saturate: [{
|
|
1716
|
-
saturate: [
|
|
1716
|
+
saturate: [C]
|
|
1717
1717
|
}],
|
|
1718
1718
|
/**
|
|
1719
1719
|
* Sepia
|
|
1720
1720
|
* @see https://tailwindcss.com/docs/sepia
|
|
1721
1721
|
*/
|
|
1722
1722
|
sepia: [{
|
|
1723
|
-
sepia: [
|
|
1723
|
+
sepia: [z]
|
|
1724
1724
|
}],
|
|
1725
1725
|
/**
|
|
1726
1726
|
* Backdrop Filter
|
|
@@ -1784,14 +1784,14 @@ const Z = (e) => {
|
|
|
1784
1784
|
* @see https://tailwindcss.com/docs/backdrop-saturate
|
|
1785
1785
|
*/
|
|
1786
1786
|
"backdrop-saturate": [{
|
|
1787
|
-
"backdrop-saturate": [
|
|
1787
|
+
"backdrop-saturate": [C]
|
|
1788
1788
|
}],
|
|
1789
1789
|
/**
|
|
1790
1790
|
* Backdrop Sepia
|
|
1791
1791
|
* @see https://tailwindcss.com/docs/backdrop-sepia
|
|
1792
1792
|
*/
|
|
1793
1793
|
"backdrop-sepia": [{
|
|
1794
|
-
"backdrop-sepia": [
|
|
1794
|
+
"backdrop-sepia": [z]
|
|
1795
1795
|
}],
|
|
1796
1796
|
// Tables
|
|
1797
1797
|
/**
|
|
@@ -1842,35 +1842,35 @@ const Z = (e) => {
|
|
|
1842
1842
|
* @see https://tailwindcss.com/docs/transition-property
|
|
1843
1843
|
*/
|
|
1844
1844
|
transition: [{
|
|
1845
|
-
transition: ["none", "all", "", "colors", "opacity", "shadow", "transform",
|
|
1845
|
+
transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", O]
|
|
1846
1846
|
}],
|
|
1847
1847
|
/**
|
|
1848
1848
|
* Transition Duration
|
|
1849
1849
|
* @see https://tailwindcss.com/docs/transition-duration
|
|
1850
1850
|
*/
|
|
1851
1851
|
duration: [{
|
|
1852
|
-
duration:
|
|
1852
|
+
duration: K()
|
|
1853
1853
|
}],
|
|
1854
1854
|
/**
|
|
1855
1855
|
* Transition Timing Function
|
|
1856
1856
|
* @see https://tailwindcss.com/docs/transition-timing-function
|
|
1857
1857
|
*/
|
|
1858
1858
|
ease: [{
|
|
1859
|
-
ease: ["linear", "in", "out", "in-out",
|
|
1859
|
+
ease: ["linear", "in", "out", "in-out", O]
|
|
1860
1860
|
}],
|
|
1861
1861
|
/**
|
|
1862
1862
|
* Transition Delay
|
|
1863
1863
|
* @see https://tailwindcss.com/docs/transition-delay
|
|
1864
1864
|
*/
|
|
1865
1865
|
delay: [{
|
|
1866
|
-
delay:
|
|
1866
|
+
delay: K()
|
|
1867
1867
|
}],
|
|
1868
1868
|
/**
|
|
1869
1869
|
* Animation
|
|
1870
1870
|
* @see https://tailwindcss.com/docs/animation
|
|
1871
1871
|
*/
|
|
1872
1872
|
animate: [{
|
|
1873
|
-
animate: ["none", "spin", "ping", "pulse", "bounce",
|
|
1873
|
+
animate: ["none", "spin", "ping", "pulse", "bounce", O]
|
|
1874
1874
|
}],
|
|
1875
1875
|
// Transforms
|
|
1876
1876
|
/**
|
|
@@ -1885,63 +1885,63 @@ const Z = (e) => {
|
|
|
1885
1885
|
* @see https://tailwindcss.com/docs/scale
|
|
1886
1886
|
*/
|
|
1887
1887
|
scale: [{
|
|
1888
|
-
scale: [
|
|
1888
|
+
scale: [L]
|
|
1889
1889
|
}],
|
|
1890
1890
|
/**
|
|
1891
1891
|
* Scale X
|
|
1892
1892
|
* @see https://tailwindcss.com/docs/scale
|
|
1893
1893
|
*/
|
|
1894
1894
|
"scale-x": [{
|
|
1895
|
-
"scale-x": [
|
|
1895
|
+
"scale-x": [L]
|
|
1896
1896
|
}],
|
|
1897
1897
|
/**
|
|
1898
1898
|
* Scale Y
|
|
1899
1899
|
* @see https://tailwindcss.com/docs/scale
|
|
1900
1900
|
*/
|
|
1901
1901
|
"scale-y": [{
|
|
1902
|
-
"scale-y": [
|
|
1902
|
+
"scale-y": [L]
|
|
1903
1903
|
}],
|
|
1904
1904
|
/**
|
|
1905
1905
|
* Rotate
|
|
1906
1906
|
* @see https://tailwindcss.com/docs/rotate
|
|
1907
1907
|
*/
|
|
1908
1908
|
rotate: [{
|
|
1909
|
-
rotate: [Ze,
|
|
1909
|
+
rotate: [Ze, O]
|
|
1910
1910
|
}],
|
|
1911
1911
|
/**
|
|
1912
1912
|
* Translate X
|
|
1913
1913
|
* @see https://tailwindcss.com/docs/translate
|
|
1914
1914
|
*/
|
|
1915
1915
|
"translate-x": [{
|
|
1916
|
-
"translate-x": [
|
|
1916
|
+
"translate-x": [F]
|
|
1917
1917
|
}],
|
|
1918
1918
|
/**
|
|
1919
1919
|
* Translate Y
|
|
1920
1920
|
* @see https://tailwindcss.com/docs/translate
|
|
1921
1921
|
*/
|
|
1922
1922
|
"translate-y": [{
|
|
1923
|
-
"translate-y": [
|
|
1923
|
+
"translate-y": [F]
|
|
1924
1924
|
}],
|
|
1925
1925
|
/**
|
|
1926
1926
|
* Skew X
|
|
1927
1927
|
* @see https://tailwindcss.com/docs/skew
|
|
1928
1928
|
*/
|
|
1929
1929
|
"skew-x": [{
|
|
1930
|
-
"skew-x": [
|
|
1930
|
+
"skew-x": [w]
|
|
1931
1931
|
}],
|
|
1932
1932
|
/**
|
|
1933
1933
|
* Skew Y
|
|
1934
1934
|
* @see https://tailwindcss.com/docs/skew
|
|
1935
1935
|
*/
|
|
1936
1936
|
"skew-y": [{
|
|
1937
|
-
"skew-y": [
|
|
1937
|
+
"skew-y": [w]
|
|
1938
1938
|
}],
|
|
1939
1939
|
/**
|
|
1940
1940
|
* Transform Origin
|
|
1941
1941
|
* @see https://tailwindcss.com/docs/transform-origin
|
|
1942
1942
|
*/
|
|
1943
1943
|
"transform-origin": [{
|
|
1944
|
-
origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left",
|
|
1944
|
+
origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", O]
|
|
1945
1945
|
}],
|
|
1946
1946
|
// Interactivity
|
|
1947
1947
|
/**
|
|
@@ -1963,7 +1963,7 @@ const Z = (e) => {
|
|
|
1963
1963
|
* @see https://tailwindcss.com/docs/cursor
|
|
1964
1964
|
*/
|
|
1965
1965
|
cursor: [{
|
|
1966
|
-
cursor: ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", "none", "context-menu", "progress", "cell", "crosshair", "vertical-text", "alias", "copy", "no-drop", "grab", "grabbing", "all-scroll", "col-resize", "row-resize", "n-resize", "e-resize", "s-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize", "ew-resize", "ns-resize", "nesw-resize", "nwse-resize", "zoom-in", "zoom-out",
|
|
1966
|
+
cursor: ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", "none", "context-menu", "progress", "cell", "crosshair", "vertical-text", "alias", "copy", "no-drop", "grab", "grabbing", "all-scroll", "col-resize", "row-resize", "n-resize", "e-resize", "s-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize", "ew-resize", "ns-resize", "nesw-resize", "nwse-resize", "zoom-in", "zoom-out", O]
|
|
1967
1967
|
}],
|
|
1968
1968
|
/**
|
|
1969
1969
|
* Caret Color
|
|
@@ -1998,126 +1998,126 @@ const Z = (e) => {
|
|
|
1998
1998
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
1999
1999
|
*/
|
|
2000
2000
|
"scroll-m": [{
|
|
2001
|
-
"scroll-m":
|
|
2001
|
+
"scroll-m": P()
|
|
2002
2002
|
}],
|
|
2003
2003
|
/**
|
|
2004
2004
|
* Scroll Margin X
|
|
2005
2005
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2006
2006
|
*/
|
|
2007
2007
|
"scroll-mx": [{
|
|
2008
|
-
"scroll-mx":
|
|
2008
|
+
"scroll-mx": P()
|
|
2009
2009
|
}],
|
|
2010
2010
|
/**
|
|
2011
2011
|
* Scroll Margin Y
|
|
2012
2012
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2013
2013
|
*/
|
|
2014
2014
|
"scroll-my": [{
|
|
2015
|
-
"scroll-my":
|
|
2015
|
+
"scroll-my": P()
|
|
2016
2016
|
}],
|
|
2017
2017
|
/**
|
|
2018
2018
|
* Scroll Margin Start
|
|
2019
2019
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2020
2020
|
*/
|
|
2021
2021
|
"scroll-ms": [{
|
|
2022
|
-
"scroll-ms":
|
|
2022
|
+
"scroll-ms": P()
|
|
2023
2023
|
}],
|
|
2024
2024
|
/**
|
|
2025
2025
|
* Scroll Margin End
|
|
2026
2026
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2027
2027
|
*/
|
|
2028
2028
|
"scroll-me": [{
|
|
2029
|
-
"scroll-me":
|
|
2029
|
+
"scroll-me": P()
|
|
2030
2030
|
}],
|
|
2031
2031
|
/**
|
|
2032
2032
|
* Scroll Margin Top
|
|
2033
2033
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2034
2034
|
*/
|
|
2035
2035
|
"scroll-mt": [{
|
|
2036
|
-
"scroll-mt":
|
|
2036
|
+
"scroll-mt": P()
|
|
2037
2037
|
}],
|
|
2038
2038
|
/**
|
|
2039
2039
|
* Scroll Margin Right
|
|
2040
2040
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2041
2041
|
*/
|
|
2042
2042
|
"scroll-mr": [{
|
|
2043
|
-
"scroll-mr":
|
|
2043
|
+
"scroll-mr": P()
|
|
2044
2044
|
}],
|
|
2045
2045
|
/**
|
|
2046
2046
|
* Scroll Margin Bottom
|
|
2047
2047
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2048
2048
|
*/
|
|
2049
2049
|
"scroll-mb": [{
|
|
2050
|
-
"scroll-mb":
|
|
2050
|
+
"scroll-mb": P()
|
|
2051
2051
|
}],
|
|
2052
2052
|
/**
|
|
2053
2053
|
* Scroll Margin Left
|
|
2054
2054
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2055
2055
|
*/
|
|
2056
2056
|
"scroll-ml": [{
|
|
2057
|
-
"scroll-ml":
|
|
2057
|
+
"scroll-ml": P()
|
|
2058
2058
|
}],
|
|
2059
2059
|
/**
|
|
2060
2060
|
* Scroll Padding
|
|
2061
2061
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2062
2062
|
*/
|
|
2063
2063
|
"scroll-p": [{
|
|
2064
|
-
"scroll-p":
|
|
2064
|
+
"scroll-p": P()
|
|
2065
2065
|
}],
|
|
2066
2066
|
/**
|
|
2067
2067
|
* Scroll Padding X
|
|
2068
2068
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2069
2069
|
*/
|
|
2070
2070
|
"scroll-px": [{
|
|
2071
|
-
"scroll-px":
|
|
2071
|
+
"scroll-px": P()
|
|
2072
2072
|
}],
|
|
2073
2073
|
/**
|
|
2074
2074
|
* Scroll Padding Y
|
|
2075
2075
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2076
2076
|
*/
|
|
2077
2077
|
"scroll-py": [{
|
|
2078
|
-
"scroll-py":
|
|
2078
|
+
"scroll-py": P()
|
|
2079
2079
|
}],
|
|
2080
2080
|
/**
|
|
2081
2081
|
* Scroll Padding Start
|
|
2082
2082
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2083
2083
|
*/
|
|
2084
2084
|
"scroll-ps": [{
|
|
2085
|
-
"scroll-ps":
|
|
2085
|
+
"scroll-ps": P()
|
|
2086
2086
|
}],
|
|
2087
2087
|
/**
|
|
2088
2088
|
* Scroll Padding End
|
|
2089
2089
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2090
2090
|
*/
|
|
2091
2091
|
"scroll-pe": [{
|
|
2092
|
-
"scroll-pe":
|
|
2092
|
+
"scroll-pe": P()
|
|
2093
2093
|
}],
|
|
2094
2094
|
/**
|
|
2095
2095
|
* Scroll Padding Top
|
|
2096
2096
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2097
2097
|
*/
|
|
2098
2098
|
"scroll-pt": [{
|
|
2099
|
-
"scroll-pt":
|
|
2099
|
+
"scroll-pt": P()
|
|
2100
2100
|
}],
|
|
2101
2101
|
/**
|
|
2102
2102
|
* Scroll Padding Right
|
|
2103
2103
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2104
2104
|
*/
|
|
2105
2105
|
"scroll-pr": [{
|
|
2106
|
-
"scroll-pr":
|
|
2106
|
+
"scroll-pr": P()
|
|
2107
2107
|
}],
|
|
2108
2108
|
/**
|
|
2109
2109
|
* Scroll Padding Bottom
|
|
2110
2110
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2111
2111
|
*/
|
|
2112
2112
|
"scroll-pb": [{
|
|
2113
|
-
"scroll-pb":
|
|
2113
|
+
"scroll-pb": P()
|
|
2114
2114
|
}],
|
|
2115
2115
|
/**
|
|
2116
2116
|
* Scroll Padding Left
|
|
2117
2117
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2118
2118
|
*/
|
|
2119
2119
|
"scroll-pl": [{
|
|
2120
|
-
"scroll-pl":
|
|
2120
|
+
"scroll-pl": P()
|
|
2121
2121
|
}],
|
|
2122
2122
|
/**
|
|
2123
2123
|
* Scroll Snap Align
|
|
@@ -2185,7 +2185,7 @@ const Z = (e) => {
|
|
|
2185
2185
|
* @see https://tailwindcss.com/docs/will-change
|
|
2186
2186
|
*/
|
|
2187
2187
|
"will-change": [{
|
|
2188
|
-
"will-change": ["auto", "scroll", "contents", "transform",
|
|
2188
|
+
"will-change": ["auto", "scroll", "contents", "transform", O]
|
|
2189
2189
|
}],
|
|
2190
2190
|
// SVG
|
|
2191
2191
|
/**
|
|
@@ -2275,11 +2275,11 @@ const Z = (e) => {
|
|
|
2275
2275
|
"font-size": ["leading"]
|
|
2276
2276
|
}
|
|
2277
2277
|
};
|
|
2278
|
-
},
|
|
2278
|
+
}, hr = /* @__PURE__ */ Qn(mr);
|
|
2279
2279
|
function Vs(...e) {
|
|
2280
|
-
return
|
|
2280
|
+
return hr(jn(e));
|
|
2281
2281
|
}
|
|
2282
|
-
function
|
|
2282
|
+
function yr(e) {
|
|
2283
2283
|
let t = !1, n = "";
|
|
2284
2284
|
for (const s of e) {
|
|
2285
2285
|
if (s === "\\") {
|
|
@@ -2294,13 +2294,13 @@ function br(e) {
|
|
|
2294
2294
|
}
|
|
2295
2295
|
return n.replace(/\bTrue\b/g, "true").replace(/\bFalse\b/g, "false").replace(/\bNone\b/g, "null");
|
|
2296
2296
|
}
|
|
2297
|
-
function
|
|
2297
|
+
function zt(e) {
|
|
2298
2298
|
const t = e == null ? void 0 : e.trim();
|
|
2299
2299
|
if (!t || !(t.startsWith("{") || t.startsWith("["))) return null;
|
|
2300
2300
|
try {
|
|
2301
2301
|
return JSON.parse(t);
|
|
2302
2302
|
} catch {
|
|
2303
|
-
const n =
|
|
2303
|
+
const n = yr(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 br(e) {
|
|
2314
2314
|
return typeof e != "string" ? !1 : /^[\s\n]*[-*]\s|^[\s\n]*#+\s|```|^\s*\[.*\]\(|^>\s/.test(e);
|
|
2315
2315
|
}
|
|
2316
|
-
function
|
|
2316
|
+
function wr(e) {
|
|
2317
2317
|
return e.type === "image_url";
|
|
2318
2318
|
}
|
|
2319
|
-
function
|
|
2319
|
+
function kr(e) {
|
|
2320
2320
|
return e.type === "file";
|
|
2321
2321
|
}
|
|
2322
2322
|
function Ir(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 vr(e) {
|
|
2327
|
+
return e.content.filter(wr);
|
|
2328
|
+
}
|
|
2326
2329
|
function Tr(e) {
|
|
2327
2330
|
return e.content.filter(kr);
|
|
2328
2331
|
}
|
|
2329
|
-
function
|
|
2330
|
-
return e.content.filter(vr);
|
|
2331
|
-
}
|
|
2332
|
-
function un(e) {
|
|
2332
|
+
function ln(e) {
|
|
2333
2333
|
return Array.isArray(e.toolCalls) ? e.toolCalls : [];
|
|
2334
2334
|
}
|
|
2335
|
-
function
|
|
2335
|
+
function Ar(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 Sr(e) {
|
|
|
2340
2340
|
});
|
|
2341
2341
|
}), t;
|
|
2342
2342
|
}
|
|
2343
|
-
function
|
|
2343
|
+
function un(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 (un(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 dn(e) {
|
|
2391
2391
|
if (typeof e == "string") return e;
|
|
2392
|
-
if (
|
|
2392
|
+
if (un(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);
|
|
@@ -2398,10 +2398,10 @@ function fn(e) {
|
|
|
2398
2398
|
}
|
|
2399
2399
|
}
|
|
2400
2400
|
function Ks(e) {
|
|
2401
|
-
const t =
|
|
2402
|
-
return typeof e == "string" &&
|
|
2401
|
+
const t = dn(e);
|
|
2402
|
+
return typeof e == "string" && br(e) ? { content: e, isMarkdown: !0 } : { content: t, isMarkdown: !1 };
|
|
2403
2403
|
}
|
|
2404
|
-
function
|
|
2404
|
+
function Sr(e) {
|
|
2405
2405
|
const t = (r) => {
|
|
2406
2406
|
try {
|
|
2407
2407
|
const s = yt(r);
|
|
@@ -2421,7 +2421,7 @@ function Me(e) {
|
|
|
2421
2421
|
if (typeof e == "string") {
|
|
2422
2422
|
const t = e.trim();
|
|
2423
2423
|
if (t.startsWith("{") || t.startsWith("[")) {
|
|
2424
|
-
const n =
|
|
2424
|
+
const n = zt(t);
|
|
2425
2425
|
if (n !== null)
|
|
2426
2426
|
return Me(n);
|
|
2427
2427
|
}
|
|
@@ -2436,24 +2436,24 @@ function Me(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 ? Me(e[0]) : e;
|
|
2438
2438
|
}
|
|
2439
|
-
function
|
|
2439
|
+
function xr(e) {
|
|
2440
2440
|
return e.replace(/[_-](\w)/g, (t, n) => n ? n.toUpperCase() : "").replace(/^\w/, (t) => t.toLowerCase());
|
|
2441
2441
|
}
|
|
2442
2442
|
function Ee(e) {
|
|
2443
2443
|
return !e || typeof e != "object" ? e : Array.isArray(e) ? e.map(Ee) : Object.fromEntries(
|
|
2444
2444
|
Object.entries(e).map(([t, n]) => [
|
|
2445
|
-
|
|
2445
|
+
xr(t),
|
|
2446
2446
|
Ee(n)
|
|
2447
2447
|
])
|
|
2448
2448
|
);
|
|
2449
2449
|
}
|
|
2450
2450
|
function bt(e) {
|
|
2451
|
-
var y, I,
|
|
2451
|
+
var y, I, S, C, L, z;
|
|
2452
2452
|
if (!e || typeof e != "object") return null;
|
|
2453
|
-
const t = Ee(e), n =
|
|
2453
|
+
const t = Ee(e), n = Er(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(Ut) : void 0, s = Mr(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 ?? ((S = t.additionalKwargs) == null ? void 0 : S.model) ?? void 0, l = t.toolCallId ?? void 0, c = t.additionalKwargs ?? void 0, d = t.responseMetadata ?? void 0, g = t.checkpointId ?? ((C = t.additionalKwargs) == null ? void 0 : C.checkpointId) ?? void 0, h = t.checkpointNs ?? ((L = t.additionalKwargs) == null ? void 0 : L.checkpointNs) ?? void 0, k = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((z = t.additionalKwargs) != null && z.toolStreaming);
|
|
2457
2457
|
return {
|
|
2458
2458
|
...t,
|
|
2459
2459
|
id: o,
|
|
@@ -2466,13 +2466,13 @@ function bt(e) {
|
|
|
2466
2466
|
toolCalls: r,
|
|
2467
2467
|
checkpointId: g,
|
|
2468
2468
|
checkpointNs: h,
|
|
2469
|
-
toolStreaming:
|
|
2469
|
+
toolStreaming: k,
|
|
2470
2470
|
additionalKwargs: c,
|
|
2471
2471
|
responseMetadata: d,
|
|
2472
2472
|
artifact: t.artifact ?? void 0
|
|
2473
2473
|
};
|
|
2474
2474
|
}
|
|
2475
|
-
function
|
|
2475
|
+
function Cr(e) {
|
|
2476
2476
|
if (!e || typeof e != "object") return e;
|
|
2477
2477
|
const t = Ee(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 Mr(e) {
|
|
|
2481
2481
|
}
|
|
2482
2482
|
return t;
|
|
2483
2483
|
}
|
|
2484
|
-
function
|
|
2484
|
+
function Ut(e) {
|
|
2485
2485
|
const t = Ee(e), n = t.content ?? t.output ?? void 0;
|
|
2486
2486
|
return {
|
|
2487
2487
|
...t,
|
|
@@ -2492,35 +2492,35 @@ function Ft(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 Mr(e, t) {
|
|
2496
|
+
return Array.isArray(e) ? e.map((n) => n.type === "tool_call" || n.type === "tool" ? t ? null : Ut(Ee(n)) : n).filter(
|
|
2497
2497
|
(n) => !!(n && typeof n == "object" && typeof n.type == "string")
|
|
2498
2498
|
) : [];
|
|
2499
2499
|
}
|
|
2500
|
-
function
|
|
2500
|
+
function Er(e) {
|
|
2501
2501
|
const t = Ee(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 Ht(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
|
-
function
|
|
2513
|
-
return (Array.isArray(e.toolCalls) ? e.toolCalls :
|
|
2512
|
+
function qt(e) {
|
|
2513
|
+
return (Array.isArray(e.toolCalls) ? e.toolCalls : ln(e)).map(Ut);
|
|
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 Pr(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 : dn(n);
|
|
2524
2524
|
if (!r.trim()) return;
|
|
2525
2525
|
const s = [{ type: "text", text: r }];
|
|
2526
2526
|
return {
|
|
@@ -2533,15 +2533,15 @@ function Rr(e, t) {
|
|
|
2533
2533
|
createdAt: e.createdAt
|
|
2534
2534
|
};
|
|
2535
2535
|
}
|
|
2536
|
-
function
|
|
2536
|
+
function Rr(e, t = []) {
|
|
2537
2537
|
if (Array.isArray(e)) {
|
|
2538
|
-
const s = e.filter((a) => a.role === "assistant").flatMap((a) =>
|
|
2538
|
+
const s = e.filter((a) => a.role === "assistant").flatMap((a) => qt(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 = Ht(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
|
-
const
|
|
2544
|
-
typeof
|
|
2543
|
+
const k = Me(i);
|
|
2544
|
+
typeof k == "string" && (a.content = k);
|
|
2545
2545
|
}
|
|
2546
2546
|
return {
|
|
2547
2547
|
call: a,
|
|
@@ -2553,10 +2553,10 @@ function Nr(e, t = []) {
|
|
|
2553
2553
|
});
|
|
2554
2554
|
}
|
|
2555
2555
|
if (e.role !== "assistant") return [];
|
|
2556
|
-
const n =
|
|
2556
|
+
const n = qt(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) ?? Pr(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 = Ht(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 = Me(s);
|
|
2562
2562
|
typeof d == "string" && (r.content = d);
|
|
@@ -2571,9 +2571,9 @@ function Nr(e, t = []) {
|
|
|
2571
2571
|
});
|
|
2572
2572
|
}
|
|
2573
2573
|
function qs(e, t = []) {
|
|
2574
|
-
return
|
|
2574
|
+
return Rr(e, t).map((n) => n.artifact).filter((n) => !!n);
|
|
2575
2575
|
}
|
|
2576
|
-
const
|
|
2576
|
+
const tt = {
|
|
2577
2577
|
authToken: "authToken",
|
|
2578
2578
|
authTokenExpiresAt: "authTokenExpiresAt",
|
|
2579
2579
|
authSessionId: "authSessionId",
|
|
@@ -2586,40 +2586,40 @@ function Mt(e) {
|
|
|
2586
2586
|
return `draft:${e}`;
|
|
2587
2587
|
}
|
|
2588
2588
|
let wt = null;
|
|
2589
|
-
const
|
|
2590
|
-
function
|
|
2589
|
+
const Nt = /* @__PURE__ */ new Set();
|
|
2590
|
+
function fn() {
|
|
2591
2591
|
return wt;
|
|
2592
2592
|
}
|
|
2593
|
-
function
|
|
2594
|
-
wt = e,
|
|
2593
|
+
function De(e) {
|
|
2594
|
+
wt = e, Nt.forEach((t) => t(e));
|
|
2595
2595
|
}
|
|
2596
|
-
function
|
|
2597
|
-
return
|
|
2596
|
+
function pn(e) {
|
|
2597
|
+
return Nt.add(e), () => Nt.delete(e);
|
|
2598
2598
|
}
|
|
2599
|
-
const
|
|
2600
|
-
let
|
|
2601
|
-
const
|
|
2599
|
+
const Nr = 12e4, _r = 12e4;
|
|
2600
|
+
let _t = Nr, gn = _r;
|
|
2601
|
+
const me = Fn.create({
|
|
2602
2602
|
// BaseURL is set dynamically via ApiProvider -> api.updateConfig
|
|
2603
|
-
timeout:
|
|
2603
|
+
timeout: _t,
|
|
2604
2604
|
withCredentials: !0
|
|
2605
2605
|
});
|
|
2606
|
-
function
|
|
2606
|
+
function Wt(e) {
|
|
2607
2607
|
return typeof e != "number" || !Number.isFinite(e) || e <= 0 ? null : Math.floor(e);
|
|
2608
2608
|
}
|
|
2609
|
-
function
|
|
2610
|
-
const t =
|
|
2611
|
-
t !== null && (
|
|
2609
|
+
function Lr(e) {
|
|
2610
|
+
const t = Wt(e.requestTimeoutMs), n = Wt(e.historyTimeoutMs);
|
|
2611
|
+
t !== null && (_t = t, me.defaults.timeout = _t), n !== null && (gn = n);
|
|
2612
2612
|
}
|
|
2613
|
-
function
|
|
2614
|
-
return
|
|
2613
|
+
function zr() {
|
|
2614
|
+
return gn;
|
|
2615
2615
|
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2616
|
+
me.interceptors.request.use((e) => (wt && (e.headers.Authorization = `Bearer ${wt}`), e));
|
|
2617
|
+
me.interceptors.response.use(
|
|
2618
2618
|
(e) => {
|
|
2619
2619
|
if (typeof window < "u" && (e != null && e.data))
|
|
2620
2620
|
try {
|
|
2621
2621
|
const t = e.data, n = t.data || {}, r = typeof t.token == "string" && t.token || typeof n.token == "string" && n.token || null, s = typeof t.expires_at == "number" && t.expires_at || typeof n.expires_at == "number" && n.expires_at || typeof t.expiresAt == "number" && t.expiresAt || typeof n.expiresAt == "number" && n.expiresAt || null;
|
|
2622
|
-
r && (localStorage.setItem(
|
|
2622
|
+
r && (localStorage.setItem(tt.authToken, r), De(r)), s && localStorage.setItem(tt.authTokenExpiresAt, s.toString()), (r || s) && window.dispatchEvent(
|
|
2623
2623
|
new CustomEvent("smartorg:chat-token-updated", {
|
|
2624
2624
|
detail: { token: r, expiresAt: s }
|
|
2625
2625
|
})
|
|
@@ -2631,108 +2631,108 @@ ye.interceptors.response.use(
|
|
|
2631
2631
|
},
|
|
2632
2632
|
(e) => Promise.reject(e)
|
|
2633
2633
|
);
|
|
2634
|
-
async function
|
|
2635
|
-
return
|
|
2634
|
+
async function ke(e, t) {
|
|
2635
|
+
return me.defaults.baseURL ? (await me.get(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2636
2636
|
}
|
|
2637
|
-
async function
|
|
2638
|
-
return
|
|
2637
|
+
async function dt(e, t, n) {
|
|
2638
|
+
return me.defaults.baseURL ? (await me.post(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2639
2639
|
}
|
|
2640
|
-
async function
|
|
2641
|
-
return
|
|
2640
|
+
async function Ur(e, t, n) {
|
|
2641
|
+
return me.defaults.baseURL ? (await me.put(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2642
2642
|
}
|
|
2643
|
-
async function
|
|
2644
|
-
return
|
|
2643
|
+
async function Gt(e, t) {
|
|
2644
|
+
return me.defaults.baseURL ? (await me.delete(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2645
2645
|
}
|
|
2646
|
-
function
|
|
2646
|
+
function ye(e) {
|
|
2647
2647
|
return e && typeof e == "object" && "data" in e ? e.data : e;
|
|
2648
2648
|
}
|
|
2649
|
-
class
|
|
2649
|
+
class Fr {
|
|
2650
2650
|
// ---- Configuration ----
|
|
2651
2651
|
// Chat client uses the default httpClient baseURL, no need for internal tracking
|
|
2652
2652
|
// unless we want to support multiple instances with different URLs in the future.
|
|
2653
2653
|
get baseUrl() {
|
|
2654
|
-
return
|
|
2654
|
+
return me.defaults.baseURL || "";
|
|
2655
2655
|
}
|
|
2656
2656
|
updateConfig(t) {
|
|
2657
2657
|
if (t.chatBaseUrl)
|
|
2658
|
-
|
|
2658
|
+
me.defaults.baseURL = t.chatBaseUrl;
|
|
2659
2659
|
else if (t.baseUrl) {
|
|
2660
2660
|
const n = t.baseUrl.replace(/\/+$/, "");
|
|
2661
|
-
n.endsWith("/chat") ?
|
|
2661
|
+
n.endsWith("/chat") ? me.defaults.baseURL = n : me.defaults.baseURL = `${n}/chat`;
|
|
2662
2662
|
}
|
|
2663
|
-
t.apiKey !== void 0 ?
|
|
2663
|
+
t.apiKey !== void 0 ? De(t.apiKey) : t.getToken && De(t.getToken()), (t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0) && Lr({
|
|
2664
2664
|
requestTimeoutMs: t.requestTimeoutMs,
|
|
2665
2665
|
historyTimeoutMs: t.historyTimeoutMs
|
|
2666
2666
|
});
|
|
2667
2667
|
}
|
|
2668
2668
|
// ---- Token Management ----
|
|
2669
2669
|
getAuthToken() {
|
|
2670
|
-
return
|
|
2670
|
+
return fn();
|
|
2671
2671
|
}
|
|
2672
2672
|
setAuthToken(t) {
|
|
2673
|
-
|
|
2673
|
+
De(t);
|
|
2674
2674
|
}
|
|
2675
2675
|
onTokenChange(t) {
|
|
2676
|
-
return
|
|
2676
|
+
return pn(t);
|
|
2677
2677
|
}
|
|
2678
2678
|
// ---- Thread Management ----
|
|
2679
2679
|
async listThreads() {
|
|
2680
|
-
const t = await
|
|
2680
|
+
const t = await ke("/threads"), n = ye(t);
|
|
2681
2681
|
return (n == null ? void 0 : n.items) ?? (t == null ? void 0 : t.items) ?? [];
|
|
2682
2682
|
}
|
|
2683
2683
|
async listSharedThreads() {
|
|
2684
|
-
const t = await
|
|
2684
|
+
const t = await ke("/threads/shared"), n = ye(t);
|
|
2685
2685
|
return (n == null ? void 0 : n.items) ?? (t == null ? void 0 : t.items) ?? [];
|
|
2686
2686
|
}
|
|
2687
2687
|
// listUsers moved to AuthApi
|
|
2688
2688
|
async createThread(t, n) {
|
|
2689
2689
|
const r = {};
|
|
2690
2690
|
t && (r.title = t), n && (r.project = n);
|
|
2691
|
-
const s = await
|
|
2692
|
-
return
|
|
2691
|
+
const s = await dt("/threads", Object.keys(r).length ? r : void 0);
|
|
2692
|
+
return ye(s);
|
|
2693
2693
|
}
|
|
2694
2694
|
async updateThread(t, n) {
|
|
2695
|
-
const r = await
|
|
2696
|
-
return
|
|
2695
|
+
const r = await Ur(`/threads/${t}`, { title: n });
|
|
2696
|
+
return ye(r);
|
|
2697
2697
|
}
|
|
2698
2698
|
async deleteThread(t) {
|
|
2699
|
-
const n = await
|
|
2700
|
-
return
|
|
2699
|
+
const n = await Gt(`/threads/${t}`);
|
|
2700
|
+
return ye(n);
|
|
2701
2701
|
}
|
|
2702
2702
|
async shareThread(t, n) {
|
|
2703
|
-
const r = await
|
|
2703
|
+
const r = await dt(`/threads/${t}/share`, {
|
|
2704
2704
|
shared_with_user_id: n
|
|
2705
2705
|
});
|
|
2706
|
-
return
|
|
2706
|
+
return ye(r);
|
|
2707
2707
|
}
|
|
2708
2708
|
async threadInfo(t) {
|
|
2709
|
-
const n = await
|
|
2710
|
-
return
|
|
2709
|
+
const n = await ke(`/threads/${t}/info`);
|
|
2710
|
+
return ye(n);
|
|
2711
2711
|
}
|
|
2712
2712
|
// ---- Agents ----
|
|
2713
2713
|
async listAgents() {
|
|
2714
|
-
const t = await
|
|
2714
|
+
const t = await ke("/agents"), n = ye(t);
|
|
2715
2715
|
return (n == null ? void 0 : n.items) ?? [];
|
|
2716
2716
|
}
|
|
2717
2717
|
async getAgent(t) {
|
|
2718
|
-
const n = await
|
|
2719
|
-
return
|
|
2718
|
+
const n = await ke(`/agents/${t}`);
|
|
2719
|
+
return ye(n);
|
|
2720
2720
|
}
|
|
2721
2721
|
async getAgentSchema(t) {
|
|
2722
|
-
const n = await
|
|
2723
|
-
return
|
|
2722
|
+
const n = await ke(`/agents/${t}/schema`);
|
|
2723
|
+
return ye(n);
|
|
2724
2724
|
}
|
|
2725
2725
|
async getState(t) {
|
|
2726
|
-
const n = await
|
|
2726
|
+
const n = await ke(`/threads/${t.threadId}/state`, {
|
|
2727
2727
|
params: {
|
|
2728
2728
|
checkpoint_id: t.checkpointId,
|
|
2729
2729
|
checkpoint_ns: t.checkpointNs
|
|
2730
2730
|
}
|
|
2731
2731
|
});
|
|
2732
|
-
return
|
|
2732
|
+
return ye(n);
|
|
2733
2733
|
}
|
|
2734
2734
|
async getStateHistory(t) {
|
|
2735
|
-
const n = await
|
|
2735
|
+
const n = await ke(`/threads/${t.threadId}/state/history`, {
|
|
2736
2736
|
params: {
|
|
2737
2737
|
checkpoint_id: t.checkpointId,
|
|
2738
2738
|
checkpoint_ns: t.checkpointNs,
|
|
@@ -2740,27 +2740,27 @@ class jr {
|
|
|
2740
2740
|
offset: t.offset ?? 0,
|
|
2741
2741
|
include_messages: t.includeMessages ?? !0
|
|
2742
2742
|
},
|
|
2743
|
-
timeout:
|
|
2743
|
+
timeout: zr(),
|
|
2744
2744
|
signal: t.signal
|
|
2745
2745
|
});
|
|
2746
|
-
return
|
|
2746
|
+
return ye(n);
|
|
2747
2747
|
}
|
|
2748
2748
|
// ---- Run Management ----
|
|
2749
2749
|
async cancelRun(t) {
|
|
2750
|
-
const n = await
|
|
2751
|
-
return
|
|
2750
|
+
const n = await dt("/stream/cancel", { threadId: t });
|
|
2751
|
+
return ye(n);
|
|
2752
2752
|
}
|
|
2753
2753
|
async unshareThread(t, n) {
|
|
2754
|
-
const r = await
|
|
2755
|
-
return
|
|
2754
|
+
const r = await Gt(`/threads/${t}/share/${n}`);
|
|
2755
|
+
return ye(r);
|
|
2756
2756
|
}
|
|
2757
2757
|
}
|
|
2758
|
-
const
|
|
2759
|
-
class
|
|
2758
|
+
const mn = new Fr();
|
|
2759
|
+
class jr {
|
|
2760
2760
|
// Config logic could go here if files ever need a distinct base URL from chat
|
|
2761
2761
|
// For now, it shares the chatBaseUrl via the shared httpClient
|
|
2762
2762
|
async fetchFileBlob(t, n) {
|
|
2763
|
-
return await
|
|
2763
|
+
return await ke(t, {
|
|
2764
2764
|
responseType: "blob",
|
|
2765
2765
|
onDownloadProgress: (s) => {
|
|
2766
2766
|
try {
|
|
@@ -2789,7 +2789,7 @@ class Or {
|
|
|
2789
2789
|
const r = await this.fetchFileBlob(`/files/${t}/download`, n), s = URL.createObjectURL(r);
|
|
2790
2790
|
let o = `file_${t}`;
|
|
2791
2791
|
try {
|
|
2792
|
-
const i = await
|
|
2792
|
+
const i = await ke(`/files/${t}`);
|
|
2793
2793
|
o = (i == null ? void 0 : i.filename) ?? o;
|
|
2794
2794
|
} catch {
|
|
2795
2795
|
}
|
|
@@ -2797,15 +2797,15 @@ class Or {
|
|
|
2797
2797
|
a.href = s, a.download = o, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(s), 6e4);
|
|
2798
2798
|
}
|
|
2799
2799
|
async getFileInfo(t) {
|
|
2800
|
-
return await
|
|
2800
|
+
return await ke(`/files/${t}`);
|
|
2801
2801
|
}
|
|
2802
2802
|
async listFiles(t, n = 50, r = 0) {
|
|
2803
2803
|
const s = { limit: n, offset: r };
|
|
2804
|
-
return t && (s.thread_id = t), await
|
|
2804
|
+
return t && (s.thread_id = t), await ke("/files", { params: s });
|
|
2805
2805
|
}
|
|
2806
2806
|
async uploadFile(t, n, r) {
|
|
2807
2807
|
const s = new FormData();
|
|
2808
|
-
return s.append("file", t), n && s.append("thread_id", n), await
|
|
2808
|
+
return s.append("file", t), n && s.append("thread_id", n), await dt("/files/upload-form", s, {
|
|
2809
2809
|
onUploadProgress: (o) => {
|
|
2810
2810
|
try {
|
|
2811
2811
|
if (r && o.lengthComputable) {
|
|
@@ -2818,11 +2818,11 @@ class Or {
|
|
|
2818
2818
|
});
|
|
2819
2819
|
}
|
|
2820
2820
|
}
|
|
2821
|
-
const
|
|
2822
|
-
class
|
|
2821
|
+
const hn = new jr();
|
|
2822
|
+
class Or {
|
|
2823
2823
|
constructor() {
|
|
2824
2824
|
// ---- Configuration ----
|
|
2825
|
-
|
|
2825
|
+
$t(this, "_authBaseUrl", "");
|
|
2826
2826
|
}
|
|
2827
2827
|
get baseUrl() {
|
|
2828
2828
|
return this._authBaseUrl;
|
|
@@ -2834,27 +2834,27 @@ class $r {
|
|
|
2834
2834
|
const n = t.baseUrl.replace(/\/+$/, "");
|
|
2835
2835
|
this._authBaseUrl = `${n}/auth`;
|
|
2836
2836
|
}
|
|
2837
|
-
t.apiKey !== void 0 ?
|
|
2837
|
+
t.apiKey !== void 0 ? De(t.apiKey) : t.getToken && De(t.getToken());
|
|
2838
2838
|
}
|
|
2839
2839
|
// ---- Token Management ----
|
|
2840
2840
|
getAuthToken() {
|
|
2841
|
-
return
|
|
2841
|
+
return fn();
|
|
2842
2842
|
}
|
|
2843
2843
|
setAuthToken(t) {
|
|
2844
|
-
|
|
2844
|
+
De(t);
|
|
2845
2845
|
}
|
|
2846
2846
|
onTokenChange(t) {
|
|
2847
|
-
return
|
|
2847
|
+
return pn(t);
|
|
2848
2848
|
}
|
|
2849
2849
|
// ---- User Management ----
|
|
2850
2850
|
async listUsers() {
|
|
2851
|
-
const t = await
|
|
2851
|
+
const t = await ke("/users", { baseURL: this.baseUrl });
|
|
2852
2852
|
return (t == null ? void 0 : t.users) ?? [];
|
|
2853
2853
|
}
|
|
2854
2854
|
}
|
|
2855
|
-
const
|
|
2856
|
-
function
|
|
2857
|
-
const n =
|
|
2855
|
+
const $r = new Or(), yn = We(null);
|
|
2856
|
+
function Br({ children: e, apiConfig: t }) {
|
|
2857
|
+
const n = mn, r = $r;
|
|
2858
2858
|
if (t) {
|
|
2859
2859
|
const o = n.baseUrl, a = r.baseUrl, i = n.getAuthToken(), f = t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0;
|
|
2860
2860
|
(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 }));
|
|
@@ -2866,12 +2866,12 @@ function Dr({ children: e, apiConfig: t }) {
|
|
|
2866
2866
|
},
|
|
2867
2867
|
chatApi: n,
|
|
2868
2868
|
authApi: r,
|
|
2869
|
-
fileApi:
|
|
2869
|
+
fileApi: hn,
|
|
2870
2870
|
baseUrl: n.baseUrl
|
|
2871
2871
|
};
|
|
2872
|
-
return /* @__PURE__ */ Ce(
|
|
2872
|
+
return /* @__PURE__ */ Ce(yn.Provider, { value: s, children: e });
|
|
2873
2873
|
}
|
|
2874
|
-
async function
|
|
2874
|
+
async function Dr(e) {
|
|
2875
2875
|
return await new Promise((t, n) => {
|
|
2876
2876
|
const r = new FileReader();
|
|
2877
2877
|
r.onload = () => {
|
|
@@ -2887,11 +2887,11 @@ async function Vr(e) {
|
|
|
2887
2887
|
}, r.onerror = (s) => n(s), r.readAsArrayBuffer(e);
|
|
2888
2888
|
});
|
|
2889
2889
|
}
|
|
2890
|
-
async function
|
|
2890
|
+
async function Vr(e = []) {
|
|
2891
2891
|
const t = [], n = [];
|
|
2892
2892
|
for (const r of e)
|
|
2893
2893
|
try {
|
|
2894
|
-
const s = await
|
|
2894
|
+
const s = await Dr(r), o = r.type || "application/octet-stream";
|
|
2895
2895
|
n.push({
|
|
2896
2896
|
filename: r.name,
|
|
2897
2897
|
data: s,
|
|
@@ -2910,7 +2910,7 @@ async function Kr(e = []) {
|
|
|
2910
2910
|
}
|
|
2911
2911
|
return { contentParts: t, filesInfo: n };
|
|
2912
2912
|
}
|
|
2913
|
-
function
|
|
2913
|
+
function Kr(e) {
|
|
2914
2914
|
return e.filter((t) => t.type === "text").map((t) => t.text).join("");
|
|
2915
2915
|
}
|
|
2916
2916
|
function Ws(e) {
|
|
@@ -2918,7 +2918,7 @@ function Ws(e) {
|
|
|
2918
2918
|
const t = String(e).trim();
|
|
2919
2919
|
return t.length > 0 ? t : null;
|
|
2920
2920
|
}
|
|
2921
|
-
function
|
|
2921
|
+
function Hr(e) {
|
|
2922
2922
|
const t = e.toolCallId ?? (e.role === "tool" ? e.id : void 0);
|
|
2923
2923
|
return e.role === "tool" && !t && console.error("[meta-utils] CRITICAL: Tool message missing toolCallId!", e), {
|
|
2924
2924
|
toolCallId: t ?? void 0,
|
|
@@ -2944,12 +2944,12 @@ function Js(e) {
|
|
|
2944
2944
|
}).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("|");
|
|
2945
2945
|
return `${e.id}:${t}:${n}${o ? `:${o}` : ""}`;
|
|
2946
2946
|
}
|
|
2947
|
-
function
|
|
2948
|
-
const e =
|
|
2947
|
+
function qe() {
|
|
2948
|
+
const e = ot(yn);
|
|
2949
2949
|
if (!e) throw new Error("useApi must be used within ApiProvider");
|
|
2950
2950
|
return e;
|
|
2951
2951
|
}
|
|
2952
|
-
function
|
|
2952
|
+
function qr(e, t, n) {
|
|
2953
2953
|
const r = typeof t == "string" ? [{ type: "text", text: t }] : t;
|
|
2954
2954
|
return {
|
|
2955
2955
|
id: `msg-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
|
|
@@ -2959,14 +2959,14 @@ function Wr(e, t, n) {
|
|
|
2959
2959
|
...n
|
|
2960
2960
|
};
|
|
2961
2961
|
}
|
|
2962
|
-
function
|
|
2963
|
-
return typeof e == "string" ?
|
|
2962
|
+
function bn(e, t = "user") {
|
|
2963
|
+
return typeof e == "string" ? qr(t, e) : e;
|
|
2964
2964
|
}
|
|
2965
|
-
function
|
|
2965
|
+
function nt(e) {
|
|
2966
2966
|
if (!(!e || typeof e != "object" || Array.isArray(e)))
|
|
2967
2967
|
return { ...e };
|
|
2968
2968
|
}
|
|
2969
|
-
function
|
|
2969
|
+
function ut(e, t) {
|
|
2970
2970
|
if (e)
|
|
2971
2971
|
for (const n of t) {
|
|
2972
2972
|
const r = e[n];
|
|
@@ -2974,7 +2974,7 @@ function dt(e, t) {
|
|
|
2974
2974
|
return r.trim();
|
|
2975
2975
|
}
|
|
2976
2976
|
}
|
|
2977
|
-
function
|
|
2977
|
+
function Wr(e, t) {
|
|
2978
2978
|
if (!e) return null;
|
|
2979
2979
|
for (const n of t) {
|
|
2980
2980
|
const r = e[n];
|
|
@@ -2983,12 +2983,12 @@ function Gr(e, t) {
|
|
|
2983
2983
|
}
|
|
2984
2984
|
return null;
|
|
2985
2985
|
}
|
|
2986
|
-
function
|
|
2987
|
-
const t =
|
|
2986
|
+
function Jt(e) {
|
|
2987
|
+
const t = nt(e);
|
|
2988
2988
|
if (t)
|
|
2989
|
-
return
|
|
2989
|
+
return nt(t.configurable) ?? t;
|
|
2990
2990
|
}
|
|
2991
|
-
async function
|
|
2991
|
+
async function Gr(e, t) {
|
|
2992
2992
|
var i, f;
|
|
2993
2993
|
if (!e) return e ?? null;
|
|
2994
2994
|
const n = Ee(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], s = /* @__PURE__ */ new Set();
|
|
@@ -3000,8 +3000,8 @@ async function Et(e, t) {
|
|
|
3000
3000
|
if (Array.isArray(g))
|
|
3001
3001
|
for (const h of g) {
|
|
3002
3002
|
if (!h || typeof h != "object" || h.type !== "image_url" && h.type !== "file") continue;
|
|
3003
|
-
const
|
|
3004
|
-
typeof
|
|
3003
|
+
const k = h.fileId || h.file_id;
|
|
3004
|
+
typeof k == "string" && k.trim() && s.add(k);
|
|
3005
3005
|
}
|
|
3006
3006
|
}
|
|
3007
3007
|
}
|
|
@@ -3025,17 +3025,17 @@ async function Et(e, t) {
|
|
|
3025
3025
|
if (Array.isArray(g))
|
|
3026
3026
|
for (const h of g) {
|
|
3027
3027
|
if (!h || typeof h != "object" || h.type !== "image_url" && h.type !== "file") continue;
|
|
3028
|
-
const
|
|
3029
|
-
if (!
|
|
3030
|
-
const m = a.get(
|
|
3028
|
+
const k = h.fileId || h.file_id;
|
|
3029
|
+
if (!k) continue;
|
|
3030
|
+
const m = a.get(k), y = (m == null ? void 0 : m.contentUrl) || (m == null ? void 0 : m.content_url);
|
|
3031
3031
|
y && (h.type === "image_url" ? (h.imageUrl = h.imageUrl || {}, h.imageUrl.url = y) : h.type === "file" && (h.url = y, !h.name && (m != null && m.filename || m != null && m.name) && (h.name = (m == null ? void 0 : m.filename) || (m == null ? void 0 : m.name))));
|
|
3032
3032
|
}
|
|
3033
3033
|
}
|
|
3034
3034
|
}
|
|
3035
3035
|
return n;
|
|
3036
3036
|
}
|
|
3037
|
-
function
|
|
3038
|
-
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) => Jr(Ee(o), a)).filter((o) => !!o)].sort((o, a) =>
|
|
3037
|
+
function ft(e) {
|
|
3038
|
+
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) => Jr(Ee(o), a)).filter((o) => !!o)].sort((o, a) => Xt(a.createdAt) - Xt(o.createdAt)), s = r[0] ?? null;
|
|
3039
3039
|
return {
|
|
3040
3040
|
threadId: (e == null ? void 0 : e.threadId) ?? "",
|
|
3041
3041
|
latest: s,
|
|
@@ -3044,25 +3044,25 @@ function tt(e) {
|
|
|
3044
3044
|
};
|
|
3045
3045
|
}
|
|
3046
3046
|
function Jr(e, t) {
|
|
3047
|
-
var
|
|
3047
|
+
var z, w;
|
|
3048
3048
|
if (!e) return null;
|
|
3049
|
-
const n = ((
|
|
3049
|
+
const n = ((z = e.values) == null ? void 0 : z.activeAgent) ?? null, r = (w = e.values) == null ? void 0 : w.messages, o = (Array.isArray(r) ? r : []).map((v) => Xr(v, n)).filter((v) => !!v), a = nt(e.metadata) ?? {}, i = Jt(e.config), f = nt(e.parentConfig), l = Jt(f), c = ut(i, ["checkpointId"]), d = ut(i, ["checkpointNs"]), g = ut(l, ["checkpointId"]), h = nt(e.config), k = Array.isArray(e.tasks) ? e.tasks.map((v) => ({ ...v })) : 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 = {
|
|
3050
3050
|
...a,
|
|
3051
|
-
step:
|
|
3052
|
-
source:
|
|
3053
|
-
},
|
|
3054
|
-
...
|
|
3055
|
-
checkpointId:
|
|
3056
|
-
checkpointNs:
|
|
3057
|
-
})),
|
|
3051
|
+
step: Wr(a, ["step"]) ?? 0,
|
|
3052
|
+
source: ut(a, ["source"]) ?? null
|
|
3053
|
+
}, S = o.map((v) => ({
|
|
3054
|
+
...v,
|
|
3055
|
+
checkpointId: v.checkpointId ?? c ?? null,
|
|
3056
|
+
checkpointNs: v.checkpointNs ?? d ?? null
|
|
3057
|
+
})), C = e.values, L = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(C == null ? void 0 : C.interrupts) ? C.interrupts : [];
|
|
3058
3058
|
return {
|
|
3059
3059
|
checkpointId: c ?? null,
|
|
3060
3060
|
checkpointNs: d ?? null,
|
|
3061
3061
|
createdAt: y,
|
|
3062
3062
|
parentId: g ?? null,
|
|
3063
|
-
messages:
|
|
3063
|
+
messages: S,
|
|
3064
3064
|
interrupt: Qr(
|
|
3065
|
-
|
|
3065
|
+
L,
|
|
3066
3066
|
t,
|
|
3067
3067
|
c ?? null
|
|
3068
3068
|
),
|
|
@@ -3070,7 +3070,7 @@ function Jr(e, t) {
|
|
|
3070
3070
|
config: h ?? null,
|
|
3071
3071
|
parentConfig: f ?? null,
|
|
3072
3072
|
next: m,
|
|
3073
|
-
tasks:
|
|
3073
|
+
tasks: k,
|
|
3074
3074
|
values: e.values ?? {}
|
|
3075
3075
|
};
|
|
3076
3076
|
}
|
|
@@ -3094,7 +3094,7 @@ function Qr(e, t, n) {
|
|
|
3094
3094
|
}
|
|
3095
3095
|
return null;
|
|
3096
3096
|
}
|
|
3097
|
-
function
|
|
3097
|
+
function Xt(e) {
|
|
3098
3098
|
if (!e) return 0;
|
|
3099
3099
|
const t = Date.parse(e);
|
|
3100
3100
|
return Number.isFinite(t) ? t : 0;
|
|
@@ -3103,120 +3103,120 @@ function Yr(e) {
|
|
|
3103
3103
|
return !!e && typeof e == "object" && "data" in e;
|
|
3104
3104
|
}
|
|
3105
3105
|
function Zr(e = {}) {
|
|
3106
|
-
const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, s] =
|
|
3107
|
-
|
|
3106
|
+
const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, s] = W(e.token ?? null), o = H(e.headers ?? {}), a = e.credentials ?? "include", i = H(e);
|
|
3107
|
+
se(() => {
|
|
3108
3108
|
i.current = e;
|
|
3109
3109
|
}, [e]);
|
|
3110
|
-
const f = E((
|
|
3111
|
-
var
|
|
3112
|
-
const
|
|
3113
|
-
if (!
|
|
3114
|
-
if (
|
|
3115
|
-
(
|
|
3110
|
+
const f = E((T) => {
|
|
3111
|
+
var x, q, U, ne, ee, Y, j, re, be, ve;
|
|
3112
|
+
const p = i.current;
|
|
3113
|
+
if (!p) return;
|
|
3114
|
+
if (T.type === "thread_info") {
|
|
3115
|
+
(x = p.onThreadInfo) == null || x.call(p, T);
|
|
3116
3116
|
return;
|
|
3117
3117
|
}
|
|
3118
|
-
if (
|
|
3119
|
-
(q =
|
|
3118
|
+
if (T.type === "values" && Array.isArray(T.checkpoints)) {
|
|
3119
|
+
(q = p.handleValuesEvent) == null || q.call(p, T);
|
|
3120
3120
|
return;
|
|
3121
3121
|
}
|
|
3122
|
-
if (
|
|
3123
|
-
(
|
|
3122
|
+
if (T.type === "metadata") {
|
|
3123
|
+
(U = p.onMetadataEvent) == null || U.call(p, T);
|
|
3124
3124
|
return;
|
|
3125
3125
|
}
|
|
3126
|
-
if (typeof
|
|
3127
|
-
(
|
|
3126
|
+
if (typeof T.type == "string" && (T.type === "custom" || T.type.startsWith("custom."))) {
|
|
3127
|
+
(ne = p.onCustomEvent) == null || ne.call(p, T);
|
|
3128
3128
|
return;
|
|
3129
3129
|
}
|
|
3130
|
-
(
|
|
3131
|
-
}, []), [l, c] =
|
|
3130
|
+
(ee = p.onEvent) == null || ee.call(p, T), T.type === "updates" && ((Y = p.onUpdateEvent) == null || Y.call(p, T)), T.type === "tool.end" ? (j = p.onToolEnd) == null || j.call(p, T) : T.type === "tool.start" && ((re = p.onToolStart) == null || re.call(p, T)), T.type === "heartbeat" && ((be = p.onHeartbeat) == null || be.call(p, T)), T.type === "token" && ((ve = p.onToken) == null || ve.call(p, T.token));
|
|
3131
|
+
}, []), [l, c] = W(!1), [d, g] = W(null), [h, k] = W(""), [m, y] = W(null), [I, S] = W(0), [C, L] = W(!1), [z, w] = W({}), [v, F] = W(null), [$, B] = W({}), D = H(null), P = H(!0), J = H(0), G = H(null), Q = H(null), X = H(null), oe = H(null), A = H([]), R = H(/* @__PURE__ */ new Set()), V = H({
|
|
3132
3132
|
messageId: null,
|
|
3133
3133
|
lastSeq: null,
|
|
3134
3134
|
lastText: ""
|
|
3135
|
-
}),
|
|
3136
|
-
s(
|
|
3135
|
+
}), K = E((T) => {
|
|
3136
|
+
s(T);
|
|
3137
3137
|
}, []), u = E(() => {
|
|
3138
|
-
|
|
3138
|
+
k(""), y(null), g(null), Q.current = null, X.current = null, oe.current = null, A.current = [], R.current = /* @__PURE__ */ new Set(), w({}), F(null), B({}), V.current = {
|
|
3139
3139
|
messageId: null,
|
|
3140
3140
|
lastSeq: null,
|
|
3141
3141
|
lastText: ""
|
|
3142
3142
|
};
|
|
3143
|
-
}, []),
|
|
3144
|
-
var
|
|
3143
|
+
}, []), N = E(() => {
|
|
3144
|
+
var x;
|
|
3145
3145
|
console.debug("[use-chat] stop() invoked - aborting stream");
|
|
3146
|
-
const
|
|
3146
|
+
const T = (x = G.current) == null ? void 0 : x.threadId, p = () => {
|
|
3147
3147
|
var q;
|
|
3148
|
-
(q =
|
|
3148
|
+
(q = D.current) == null || q.abort(), D.current = null, G.current = null, c(!1), L(!1), J.current = 0, S(0);
|
|
3149
3149
|
};
|
|
3150
|
-
(
|
|
3150
|
+
(T ? mn.cancelRun(T).catch((q) => {
|
|
3151
3151
|
console.warn("[use-chat] cancel run failed:", q);
|
|
3152
|
-
}) : Promise.resolve()).finally(
|
|
3153
|
-
}, []),
|
|
3154
|
-
(
|
|
3155
|
-
|
|
3156
|
-
const
|
|
3157
|
-
text: typeof
|
|
3158
|
-
threadId:
|
|
3159
|
-
attachments:
|
|
3160
|
-
payload:
|
|
3161
|
-
config:
|
|
3162
|
-
checkpointId:
|
|
3163
|
-
checkpointNs:
|
|
3164
|
-
edit:
|
|
3165
|
-
command:
|
|
3152
|
+
}) : Promise.resolve()).finally(p);
|
|
3153
|
+
}, []), _ = E(
|
|
3154
|
+
(T) => {
|
|
3155
|
+
D.current && (D.current.abort(), D.current = null);
|
|
3156
|
+
const p = {
|
|
3157
|
+
text: typeof T.content == "string" ? T.content : T.text,
|
|
3158
|
+
threadId: T.threadId,
|
|
3159
|
+
attachments: T.attachments,
|
|
3160
|
+
payload: T.payload,
|
|
3161
|
+
config: T.config,
|
|
3162
|
+
checkpointId: T.checkpointId,
|
|
3163
|
+
checkpointNs: T.checkpointNs || void 0,
|
|
3164
|
+
edit: T.edit,
|
|
3165
|
+
command: T.command
|
|
3166
3166
|
};
|
|
3167
|
-
c(!0), g(null),
|
|
3167
|
+
c(!0), g(null), k(""), y(null), Q.current = null, X.current = null, oe.current = null, A.current = [], R.current = /* @__PURE__ */ new Set(), w({}), F(null), B({}), V.current = {
|
|
3168
3168
|
messageId: null,
|
|
3169
3169
|
lastSeq: null,
|
|
3170
3170
|
lastText: ""
|
|
3171
3171
|
};
|
|
3172
|
-
const
|
|
3173
|
-
|
|
3174
|
-
let
|
|
3175
|
-
const
|
|
3176
|
-
if (
|
|
3177
|
-
const
|
|
3178
|
-
|
|
3179
|
-
let
|
|
3180
|
-
if (!
|
|
3181
|
-
const
|
|
3182
|
-
|
|
3172
|
+
const M = new AbortController();
|
|
3173
|
+
D.current = M;
|
|
3174
|
+
let x = null, q = !1;
|
|
3175
|
+
const U = (ne) => {
|
|
3176
|
+
if (R.current.has(ne)) return;
|
|
3177
|
+
const ee = A.current[0];
|
|
3178
|
+
ee && w((Y) => {
|
|
3179
|
+
let j = v;
|
|
3180
|
+
if (!j) {
|
|
3181
|
+
const fe = Object.values(Y).filter((Fe) => Fe.role === "assistant");
|
|
3182
|
+
fe.length > 0 && (j = fe[fe.length - 1].id);
|
|
3183
3183
|
}
|
|
3184
|
-
if (!
|
|
3185
|
-
const
|
|
3186
|
-
return
|
|
3187
|
-
id:
|
|
3184
|
+
if (!j || !Y[j]) return Y;
|
|
3185
|
+
const re = Y[j], be = [...re.toolCalls || []], ve = ee.id ?? `task-${ne}`;
|
|
3186
|
+
return be.some((fe) => fe.id === ve && fe.name === "task" && fe.scope === ne) || be.push({
|
|
3187
|
+
id: ve,
|
|
3188
3188
|
name: "task",
|
|
3189
3189
|
args: {
|
|
3190
|
-
description:
|
|
3191
|
-
subagentType:
|
|
3190
|
+
description: ee.description,
|
|
3191
|
+
subagentType: ee.subagentType
|
|
3192
3192
|
},
|
|
3193
3193
|
status: "running",
|
|
3194
|
-
content:
|
|
3195
|
-
scope:
|
|
3196
|
-
}),
|
|
3194
|
+
content: ee.description,
|
|
3195
|
+
scope: ne
|
|
3196
|
+
}), R.current.add(ne), A.current.shift(), { ...Y, [j]: { ...re, toolCalls: be } };
|
|
3197
3197
|
});
|
|
3198
3198
|
};
|
|
3199
|
-
return
|
|
3200
|
-
threadId:
|
|
3199
|
+
return G.current = {
|
|
3200
|
+
threadId: p.threadId ?? null,
|
|
3201
3201
|
headers: {},
|
|
3202
3202
|
isStreaming: !0
|
|
3203
3203
|
}, (async () => {
|
|
3204
|
-
var
|
|
3204
|
+
var ne, ee, Y, j, re, be, ve, Je, fe, Fe, je, Xe;
|
|
3205
3205
|
try {
|
|
3206
3206
|
let Te = {};
|
|
3207
3207
|
try {
|
|
3208
3208
|
if (r)
|
|
3209
3209
|
Te = { Authorization: `Bearer ${r}` };
|
|
3210
3210
|
else if (typeof window < "u") {
|
|
3211
|
-
const Se = window.__AUTH_TOKEN__, Tt = ((
|
|
3212
|
-
let
|
|
3211
|
+
const Se = window.__AUTH_TOKEN__, Tt = ((ne = window.localStorage) == null ? void 0 : ne.getItem(tt.authToken)) || null;
|
|
3212
|
+
let ct = null;
|
|
3213
3213
|
try {
|
|
3214
|
-
const
|
|
3215
|
-
|
|
3214
|
+
const lt = (ee = window.localStorage) == null ? void 0 : ee.getItem(tt.chatSettings);
|
|
3215
|
+
lt && (ct = ((Y = JSON.parse(lt)) == null ? void 0 : Y.apiKey) || null);
|
|
3216
3216
|
} catch {
|
|
3217
3217
|
}
|
|
3218
|
-
const
|
|
3219
|
-
|
|
3218
|
+
const Ke = Se || Tt || ct || null;
|
|
3219
|
+
Ke && (Te = { Authorization: `Bearer ${Ke}` });
|
|
3220
3220
|
}
|
|
3221
3221
|
} catch {
|
|
3222
3222
|
}
|
|
@@ -3224,88 +3224,88 @@ function Zr(e = {}) {
|
|
|
3224
3224
|
let Ae = {};
|
|
3225
3225
|
if (typeof window < "u")
|
|
3226
3226
|
try {
|
|
3227
|
-
const
|
|
3228
|
-
|
|
3227
|
+
const ue = (j = window.localStorage) == null ? void 0 : j.getItem(tt.authSessionId);
|
|
3228
|
+
ue && (Ae = { "X-Session-Id": ue });
|
|
3229
3229
|
} catch {
|
|
3230
3230
|
}
|
|
3231
|
-
const
|
|
3231
|
+
const Ve = {
|
|
3232
3232
|
...Te,
|
|
3233
3233
|
...Ae,
|
|
3234
3234
|
...o.current
|
|
3235
|
-
},
|
|
3235
|
+
}, It = {
|
|
3236
3236
|
"Content-Type": "application/json",
|
|
3237
3237
|
Accept: "text/event-stream",
|
|
3238
|
-
...
|
|
3238
|
+
...Ve
|
|
3239
3239
|
}, Ie = await fetch(t + n, {
|
|
3240
3240
|
method: "POST",
|
|
3241
|
-
headers:
|
|
3242
|
-
body: JSON.stringify(
|
|
3243
|
-
signal:
|
|
3241
|
+
headers: It,
|
|
3242
|
+
body: JSON.stringify(p),
|
|
3243
|
+
signal: M.signal,
|
|
3244
3244
|
credentials: a
|
|
3245
3245
|
});
|
|
3246
|
-
if (
|
|
3247
|
-
const
|
|
3246
|
+
if (G.current && (G.current.headers = Ve), !Ie.ok || !Ie.body) {
|
|
3247
|
+
const ue = await Ie.text().catch(() => "");
|
|
3248
3248
|
console.debug(
|
|
3249
3249
|
"[use-chat] non-OK response",
|
|
3250
3250
|
Ie.status,
|
|
3251
|
-
|
|
3251
|
+
ue == null ? void 0 : ue.slice(0, 500)
|
|
3252
3252
|
);
|
|
3253
|
-
const Se = `stream ${Ie.status}${
|
|
3254
|
-
throw Se && (g(Se),
|
|
3253
|
+
const Se = `stream ${Ie.status}${ue ? ": " + ue : ""}`;
|
|
3254
|
+
throw Se && (g(Se), x = "error"), new Error(Se);
|
|
3255
3255
|
}
|
|
3256
|
-
|
|
3257
|
-
const Qe = Ie.body.getReader(),
|
|
3258
|
-
let
|
|
3259
|
-
J.current = 0,
|
|
3260
|
-
let Ye = 0,
|
|
3261
|
-
const
|
|
3262
|
-
if (
|
|
3263
|
-
const
|
|
3264
|
-
|
|
3256
|
+
L(!0);
|
|
3257
|
+
const Qe = Ie.body.getReader(), Cn = new TextDecoder();
|
|
3258
|
+
let Oe = "", it = [];
|
|
3259
|
+
J.current = 0, S(0);
|
|
3260
|
+
let Ye = 0, $e = null;
|
|
3261
|
+
const vt = () => {
|
|
3262
|
+
if (it.length) {
|
|
3263
|
+
const ue = it.join("");
|
|
3264
|
+
it = [], P.current && k((Se) => Se + ue);
|
|
3265
3265
|
}
|
|
3266
|
-
|
|
3267
|
-
},
|
|
3268
|
-
typeof window < "u" &&
|
|
3266
|
+
$e = null;
|
|
3267
|
+
}, Mn = () => {
|
|
3268
|
+
typeof window < "u" && $e == null && ($e = requestAnimationFrame(vt));
|
|
3269
3269
|
};
|
|
3270
|
-
let
|
|
3271
|
-
const
|
|
3272
|
-
Date.now() -
|
|
3273
|
-
}, 5e3),
|
|
3270
|
+
let Ft = Date.now();
|
|
3271
|
+
const En = setInterval(() => {
|
|
3272
|
+
Date.now() - Ft > 18e5 && (g("Stream idle timeout"), x = "error", M.abort());
|
|
3273
|
+
}, 5e3), Pn = 1024 * 1024;
|
|
3274
3274
|
try {
|
|
3275
3275
|
const Se = (Ie.headers.get("X-Thread-Id") || Ie.headers.get("x-thread-id")) ?? null;
|
|
3276
|
-
for (
|
|
3277
|
-
...
|
|
3276
|
+
for (G.current && !G.current.threadId && (G.current = {
|
|
3277
|
+
...G.current,
|
|
3278
3278
|
threadId: Se
|
|
3279
3279
|
}); ; ) {
|
|
3280
|
-
const { value: Tt, done:
|
|
3281
|
-
if (
|
|
3282
|
-
|
|
3283
|
-
let
|
|
3284
|
-
for (; (
|
|
3280
|
+
const { value: Tt, done: ct } = await Qe.read();
|
|
3281
|
+
if (ct) break;
|
|
3282
|
+
Oe += Cn.decode(Tt, { stream: !0 }), Oe.length > Pn && (Oe = "", console.warn("Stream buffer reset: exceeded 1MB"));
|
|
3283
|
+
let Ke;
|
|
3284
|
+
for (; (Ke = Oe.indexOf(`
|
|
3285
3285
|
|
|
3286
3286
|
`)) >= 0; ) {
|
|
3287
|
-
const
|
|
3288
|
-
|
|
3289
|
-
const
|
|
3287
|
+
const lt = Oe.slice(0, Ke);
|
|
3288
|
+
Oe = Oe.slice(Ke + 2);
|
|
3289
|
+
const Rn = lt.split(/\r?\n/), jt = [];
|
|
3290
3290
|
let At = null;
|
|
3291
|
-
for (const
|
|
3292
|
-
if (
|
|
3293
|
-
|
|
3291
|
+
for (const b of Rn) {
|
|
3292
|
+
if (b.startsWith(":")) {
|
|
3293
|
+
b.startsWith(": heartbeat") && console.debug("[use-chat] SSE heartbeat comment received");
|
|
3294
3294
|
continue;
|
|
3295
3295
|
}
|
|
3296
|
-
if (
|
|
3297
|
-
if (
|
|
3298
|
-
const
|
|
3299
|
-
|
|
3296
|
+
if (b) {
|
|
3297
|
+
if (b.startsWith("event:")) {
|
|
3298
|
+
const ce = b.slice(6).trim();
|
|
3299
|
+
ce && (At = ce);
|
|
3300
3300
|
continue;
|
|
3301
3301
|
}
|
|
3302
|
-
if (
|
|
3303
|
-
const
|
|
3304
|
-
|
|
3302
|
+
if (b.startsWith("data:")) {
|
|
3303
|
+
const ce = b.slice(5);
|
|
3304
|
+
jt.push(ce.startsWith(" ") ? ce.slice(1) : ce);
|
|
3305
3305
|
}
|
|
3306
3306
|
}
|
|
3307
3307
|
}
|
|
3308
|
-
const St =
|
|
3308
|
+
const St = jt.join(`
|
|
3309
3309
|
`);
|
|
3310
3310
|
if (!St) continue;
|
|
3311
3311
|
let Pe;
|
|
@@ -3316,230 +3316,230 @@ function Zr(e = {}) {
|
|
|
3316
3316
|
continue;
|
|
3317
3317
|
}
|
|
3318
3318
|
At && typeof Pe == "object" && Pe !== null && !("type" in Pe) && (Pe.type = At);
|
|
3319
|
-
const
|
|
3320
|
-
if (
|
|
3319
|
+
const Ot = Yr(Pe) ? Pe.data : Pe;
|
|
3320
|
+
if (!Ot) {
|
|
3321
3321
|
console.warn("[use-chat] dropped envelope event without payload", Pe);
|
|
3322
3322
|
continue;
|
|
3323
3323
|
}
|
|
3324
|
-
const
|
|
3325
|
-
|
|
3326
|
-
const
|
|
3327
|
-
if (
|
|
3328
|
-
if (
|
|
3329
|
-
console.debug("[use-chat] drop duplicate/out-of-order event", { seq:
|
|
3324
|
+
const ae = Cr(Ot);
|
|
3325
|
+
Ft = Date.now();
|
|
3326
|
+
const Be = ae.seq;
|
|
3327
|
+
if (Be !== void 0) {
|
|
3328
|
+
if (Be <= Ye) {
|
|
3329
|
+
console.debug("[use-chat] drop duplicate/out-of-order event", { seq: Be, lastProcessedSeq: Ye, type: ae.type });
|
|
3330
3330
|
continue;
|
|
3331
3331
|
}
|
|
3332
|
-
Ye > 0 &&
|
|
3332
|
+
Ye > 0 && Be > Ye + 1, Ye = Be, J.current = Be, S(Be);
|
|
3333
3333
|
}
|
|
3334
|
-
const
|
|
3335
|
-
let
|
|
3336
|
-
if (
|
|
3337
|
-
const
|
|
3338
|
-
Q.current =
|
|
3339
|
-
} else if (
|
|
3340
|
-
const
|
|
3341
|
-
|
|
3342
|
-
const
|
|
3343
|
-
if (Array.isArray(
|
|
3344
|
-
|
|
3334
|
+
const Nn = ["messages/partial", "metadata", "checkpoint", "values", "heartbeat", "token", "status", "error", "interrupt", "tool.start", "tool.progress", "tool.end", "task.start"];
|
|
3335
|
+
let we = ae.type || "unknown";
|
|
3336
|
+
if (Nn.includes(we) || (ae.messages || ae.content !== void 0 && ae.id) && (we = "messages/partial"), we === "checkpoint") {
|
|
3337
|
+
const b = ae;
|
|
3338
|
+
Q.current = b.checkpointId ?? null, X.current = b.checkpointNs ?? null, y(b.checkpointId ?? null);
|
|
3339
|
+
} else if (we === "values") {
|
|
3340
|
+
const b = ae, ce = b == null ? void 0 : b.origin, ie = b == null ? void 0 : b.scope;
|
|
3341
|
+
ce === "task" && typeof ie == "string" && ie.startsWith("tools:") && U(ie);
|
|
3342
|
+
const pe = ce === "task" || typeof ie == "string" && ie.startsWith("tools:");
|
|
3343
|
+
if (Array.isArray(b.checkpoints)) {
|
|
3344
|
+
oe.current = b;
|
|
3345
3345
|
try {
|
|
3346
|
-
const
|
|
3347
|
-
|
|
3348
|
-
} catch (
|
|
3349
|
-
console.warn("[use-chat] Failed to hydrate values payload",
|
|
3346
|
+
const le = ft(b).latest;
|
|
3347
|
+
le && (Q.current = le.checkpointId ?? null, X.current = le.checkpointNs ?? null, y(le.checkpointId ?? null), pe || B(le.values ?? {})), pe || (w({}), F(null));
|
|
3348
|
+
} catch (Z) {
|
|
3349
|
+
console.warn("[use-chat] Failed to hydrate values payload", Z);
|
|
3350
3350
|
}
|
|
3351
|
-
} else if ((
|
|
3352
|
-
|
|
3351
|
+
} else if ((re = b.values) != null && re.messages)
|
|
3352
|
+
pe || (w({}), F(null)), pe || B(b.values ?? {});
|
|
3353
3353
|
else {
|
|
3354
|
-
const
|
|
3355
|
-
|
|
3354
|
+
const Z = b.values && typeof b.values == "object" ? b.values : b;
|
|
3355
|
+
pe || B(Z ?? {});
|
|
3356
3356
|
}
|
|
3357
3357
|
}
|
|
3358
|
-
if (
|
|
3359
|
-
const
|
|
3360
|
-
|
|
3361
|
-
id:
|
|
3362
|
-
description:
|
|
3363
|
-
subagentType:
|
|
3358
|
+
if (we === "task.start") {
|
|
3359
|
+
const b = ae;
|
|
3360
|
+
A.current.push({
|
|
3361
|
+
id: b.id ?? b.callId,
|
|
3362
|
+
description: b.description,
|
|
3363
|
+
subagentType: b.subagentType ?? b.subagent_type
|
|
3364
3364
|
});
|
|
3365
3365
|
}
|
|
3366
|
-
if (
|
|
3367
|
-
const
|
|
3368
|
-
|
|
3369
|
-
let
|
|
3370
|
-
if (!
|
|
3371
|
-
const
|
|
3372
|
-
|
|
3366
|
+
if (we === "tool.start" || we === "tool.progress" || we === "tool.end") {
|
|
3367
|
+
const b = ae, ce = b.id || b.callId, ie = b.scope;
|
|
3368
|
+
b.origin === "task" && typeof ie == "string" && ie.startsWith("tools:") && U(ie), ce && w((pe) => {
|
|
3369
|
+
let Z = v;
|
|
3370
|
+
if (!Z) {
|
|
3371
|
+
const le = Object.values(pe).filter((ge) => ge.role === "assistant");
|
|
3372
|
+
le.length > 0 && (Z = le[le.length - 1].id);
|
|
3373
3373
|
}
|
|
3374
|
-
if (
|
|
3375
|
-
const
|
|
3376
|
-
let
|
|
3377
|
-
return
|
|
3378
|
-
...
|
|
3379
|
-
content:
|
|
3380
|
-
status:
|
|
3381
|
-
artifact:
|
|
3382
|
-
scope:
|
|
3383
|
-
} :
|
|
3384
|
-
id:
|
|
3385
|
-
name:
|
|
3386
|
-
args:
|
|
3387
|
-
status:
|
|
3388
|
-
content:
|
|
3389
|
-
artifact:
|
|
3390
|
-
scope:
|
|
3391
|
-
}), { ...
|
|
3374
|
+
if (Z && pe[Z]) {
|
|
3375
|
+
const le = pe[Z], ge = [...le.toolCalls || []], xe = ge.findIndex((Re) => Re.id === ce);
|
|
3376
|
+
let he = b.content || b.status || "Processing...";
|
|
3377
|
+
return ae.type === "tool.start" ? he = `Starting ${b.name || b.tool || "tool"}...` : ae.type === "tool.end" && b.error && (he = `Error: ${b.error}`), xe >= 0 ? ge[xe] = {
|
|
3378
|
+
...ge[xe],
|
|
3379
|
+
content: he,
|
|
3380
|
+
status: ae.type === "tool.start" ? "running" : ae.type === "tool.end" ? b.error ? "failed" : "completed" : ge[xe].status,
|
|
3381
|
+
artifact: b.artifact || ge[xe].artifact,
|
|
3382
|
+
scope: ie ?? ge[xe].scope
|
|
3383
|
+
} : ge.push({
|
|
3384
|
+
id: ce,
|
|
3385
|
+
name: b.name || b.tool || "tool",
|
|
3386
|
+
args: b.args || {},
|
|
3387
|
+
status: ae.type === "tool.end" ? b.error ? "failed" : "completed" : "running",
|
|
3388
|
+
content: he,
|
|
3389
|
+
artifact: b.artifact,
|
|
3390
|
+
scope: ie
|
|
3391
|
+
}), { ...pe, [Z]: { ...le, toolCalls: ge } };
|
|
3392
3392
|
}
|
|
3393
|
-
return
|
|
3393
|
+
return pe;
|
|
3394
3394
|
});
|
|
3395
|
-
} else if (
|
|
3396
|
-
const
|
|
3397
|
-
if (Array.isArray(
|
|
3398
|
-
const
|
|
3399
|
-
if (
|
|
3400
|
-
const
|
|
3401
|
-
if (
|
|
3402
|
-
const
|
|
3403
|
-
|
|
3404
|
-
messageId:
|
|
3395
|
+
} else if (we === "messages/partial") {
|
|
3396
|
+
const b = ae, ce = b.messages || [b];
|
|
3397
|
+
if (Array.isArray(ce) && ce.length > 0) {
|
|
3398
|
+
const ie = ce.find((Z) => Z.type === "ai"), pe = ce.find((Z) => Z.type === "tool");
|
|
3399
|
+
if (ie) {
|
|
3400
|
+
const Z = ie.id, le = ie.content ?? "", ge = !1, xe = ge ? (V.current.lastText || "") + le : le;
|
|
3401
|
+
if (V.current.messageId !== Z) {
|
|
3402
|
+
const he = ie.name ?? ie.agentName ?? "assistant";
|
|
3403
|
+
V.current = {
|
|
3404
|
+
messageId: Z,
|
|
3405
3405
|
lastSeq: null,
|
|
3406
3406
|
lastText: ""
|
|
3407
3407
|
};
|
|
3408
3408
|
const Re = bt({
|
|
3409
|
-
id:
|
|
3409
|
+
id: Z,
|
|
3410
3410
|
role: "assistant",
|
|
3411
|
-
name:
|
|
3412
|
-
model:
|
|
3411
|
+
name: he,
|
|
3412
|
+
model: he,
|
|
3413
3413
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3414
3414
|
content: [{ type: "text", text: xe }]
|
|
3415
3415
|
});
|
|
3416
|
-
|
|
3416
|
+
w((_n) => ({ ..._n, [Z]: Re })), F(Z), V.current.lastText = xe;
|
|
3417
3417
|
} else
|
|
3418
|
-
|
|
3419
|
-
const Re =
|
|
3418
|
+
w((he) => {
|
|
3419
|
+
const Re = he[Z];
|
|
3420
3420
|
return Re ? {
|
|
3421
|
-
...
|
|
3422
|
-
[
|
|
3421
|
+
...he,
|
|
3422
|
+
[Z]: {
|
|
3423
3423
|
...Re,
|
|
3424
3424
|
content: [{ type: "text", text: xe }],
|
|
3425
3425
|
// Preserve existing metadata if the chunk doesn't have it
|
|
3426
|
-
responseMetadata:
|
|
3426
|
+
responseMetadata: ie.responseMetadata ?? Re.responseMetadata
|
|
3427
3427
|
}
|
|
3428
|
-
} :
|
|
3429
|
-
}),
|
|
3430
|
-
if (!
|
|
3431
|
-
const
|
|
3432
|
-
if (
|
|
3433
|
-
const Re =
|
|
3434
|
-
|
|
3428
|
+
} : he;
|
|
3429
|
+
}), V.current.lastText = xe;
|
|
3430
|
+
if (!ge) {
|
|
3431
|
+
const he = V.current.lastText || "";
|
|
3432
|
+
if (le.length > he.length) {
|
|
3433
|
+
const Re = le.slice(he.length);
|
|
3434
|
+
it.push(Re), Mn();
|
|
3435
3435
|
}
|
|
3436
3436
|
}
|
|
3437
3437
|
}
|
|
3438
|
-
if (
|
|
3439
|
-
const
|
|
3440
|
-
...
|
|
3441
|
-
id:
|
|
3438
|
+
if (pe) {
|
|
3439
|
+
const Z = pe.id || `tool-${Date.now()}`, le = bt({
|
|
3440
|
+
...pe,
|
|
3441
|
+
id: Z,
|
|
3442
3442
|
role: "tool",
|
|
3443
3443
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3444
3444
|
});
|
|
3445
|
-
|
|
3445
|
+
w((ge) => ({ ...ge, [Z]: le }));
|
|
3446
3446
|
}
|
|
3447
3447
|
}
|
|
3448
|
-
} else if (
|
|
3448
|
+
} else if (we === "heartbeat") {
|
|
3449
3449
|
console.debug("[use-chat] heartbeat received");
|
|
3450
3450
|
try {
|
|
3451
|
-
} catch (
|
|
3452
|
-
console.warn("[use-chat] heartbeat callback failed",
|
|
3451
|
+
} catch (b) {
|
|
3452
|
+
console.warn("[use-chat] heartbeat callback failed", b);
|
|
3453
3453
|
}
|
|
3454
|
-
} else if (
|
|
3455
|
-
y(
|
|
3456
|
-
else if (
|
|
3457
|
-
const
|
|
3458
|
-
if (g(
|
|
3459
|
-
console.error("[use-chat] Auth error detected:",
|
|
3454
|
+
} else if ($e !== null && cancelAnimationFrame($e), vt(), we === "checkpoint")
|
|
3455
|
+
y(ae.checkpointId ?? null);
|
|
3456
|
+
else if (we === "error") {
|
|
3457
|
+
const b = ae;
|
|
3458
|
+
if (g(b.message), x = "error", b.error_type === "auth_error" || b.code === "TOKEN_EXPIRED" || ((be = b.message) == null ? void 0 : be.includes("token")) || ((ve = b.message) == null ? void 0 : ve.includes("401")) || ((Je = b.message) == null ? void 0 : Je.includes("unauthorized")) || ((fe = b.message) == null ? void 0 : fe.includes("Unauthorized"))) {
|
|
3459
|
+
console.error("[use-chat] Auth error detected:", b.message);
|
|
3460
3460
|
try {
|
|
3461
|
-
(
|
|
3462
|
-
} catch (
|
|
3463
|
-
console.warn("[use-chat] onAuthError handler failed",
|
|
3461
|
+
(Fe = e.onAuthError) == null || Fe.call(e, b.message);
|
|
3462
|
+
} catch (ie) {
|
|
3463
|
+
console.warn("[use-chat] onAuthError handler failed", ie);
|
|
3464
3464
|
}
|
|
3465
|
-
|
|
3465
|
+
M.abort();
|
|
3466
3466
|
}
|
|
3467
|
-
} else if (
|
|
3468
|
-
const
|
|
3469
|
-
(
|
|
3467
|
+
} else if (we === "status") {
|
|
3468
|
+
const b = ae;
|
|
3469
|
+
(b.status === "completed" || b.status === "interrupted" || b.status === "error") && (c(!1), console.log("[use-chat] Status event received:", b));
|
|
3470
3470
|
}
|
|
3471
|
-
f(
|
|
3471
|
+
f(ae);
|
|
3472
3472
|
}
|
|
3473
3473
|
}
|
|
3474
|
-
|
|
3475
|
-
} catch (
|
|
3476
|
-
if (
|
|
3477
|
-
|
|
3474
|
+
vt(), x === null && !M.signal.aborted && (x = "complete");
|
|
3475
|
+
} catch (ue) {
|
|
3476
|
+
if (ue.name === "AbortError")
|
|
3477
|
+
x = x ?? "aborted";
|
|
3478
3478
|
else {
|
|
3479
|
-
const Se =
|
|
3480
|
-
|
|
3479
|
+
const Se = ue.message || String(ue);
|
|
3480
|
+
x = "error", g(Se);
|
|
3481
3481
|
}
|
|
3482
3482
|
} finally {
|
|
3483
3483
|
try {
|
|
3484
3484
|
await Qe.cancel();
|
|
3485
3485
|
} catch {
|
|
3486
3486
|
} finally {
|
|
3487
|
-
(
|
|
3487
|
+
(je = Qe.releaseLock) == null || je.call(Qe);
|
|
3488
3488
|
}
|
|
3489
|
-
|
|
3489
|
+
$e !== null && typeof window < "u" && window.cancelAnimationFrame($e), clearInterval(En);
|
|
3490
3490
|
}
|
|
3491
3491
|
} catch (Te) {
|
|
3492
3492
|
if (Te.name === "AbortError")
|
|
3493
|
-
|
|
3493
|
+
x = x ?? "aborted";
|
|
3494
3494
|
else {
|
|
3495
3495
|
const Ae = Te.message || String(Te);
|
|
3496
|
-
|
|
3496
|
+
x = "error", g(Ae), q || (q = !0, (Xe = e.onConnectionError) == null || Xe.call(e, Ae));
|
|
3497
3497
|
}
|
|
3498
3498
|
} finally {
|
|
3499
|
-
const Te = J.current, Ae = Q.current,
|
|
3499
|
+
const Te = J.current, Ae = Q.current, Ve = X.current, It = oe.current;
|
|
3500
3500
|
try {
|
|
3501
3501
|
if (e.onFinish) {
|
|
3502
3502
|
const Ie = {
|
|
3503
3503
|
lastSeq: Te,
|
|
3504
3504
|
lastCheckpointId: Ae,
|
|
3505
|
-
lastCheckpointNs:
|
|
3506
|
-
lastValues:
|
|
3505
|
+
lastCheckpointNs: Ve,
|
|
3506
|
+
lastValues: It
|
|
3507
3507
|
};
|
|
3508
3508
|
e.onFinish(Ie);
|
|
3509
3509
|
}
|
|
3510
3510
|
} catch (Ie) {
|
|
3511
3511
|
console.warn("[use-chat] onClosed callback failed", Ie);
|
|
3512
3512
|
}
|
|
3513
|
-
c(!1),
|
|
3513
|
+
c(!1), L(!1), D.current = null, J.current = 0, S(0), G.current = null;
|
|
3514
3514
|
}
|
|
3515
3515
|
})(), Promise.resolve();
|
|
3516
3516
|
},
|
|
3517
3517
|
[t, n, r, e]
|
|
3518
3518
|
);
|
|
3519
|
-
return
|
|
3520
|
-
var
|
|
3521
|
-
|
|
3519
|
+
return se(() => () => {
|
|
3520
|
+
var T;
|
|
3521
|
+
P.current = !1, (T = D.current) == null || T.abort();
|
|
3522
3522
|
}, []), {
|
|
3523
3523
|
isStreaming: l,
|
|
3524
3524
|
error: d,
|
|
3525
3525
|
assistantText: h,
|
|
3526
|
-
activeMessageId:
|
|
3527
|
-
streamedMessages:
|
|
3526
|
+
activeMessageId: v,
|
|
3527
|
+
streamedMessages: z,
|
|
3528
3528
|
lastCheckpointId: m,
|
|
3529
3529
|
lastSeq: I,
|
|
3530
|
-
connected:
|
|
3531
|
-
stream:
|
|
3532
|
-
stop:
|
|
3530
|
+
connected: C,
|
|
3531
|
+
stream: _,
|
|
3532
|
+
stop: N,
|
|
3533
3533
|
clear: u,
|
|
3534
|
-
setToken:
|
|
3535
|
-
values:
|
|
3534
|
+
setToken: K,
|
|
3535
|
+
values: $,
|
|
3536
3536
|
interrupt: () => Promise.resolve(),
|
|
3537
3537
|
resume: () => Promise.resolve(),
|
|
3538
3538
|
goto: () => Promise.resolve(),
|
|
3539
|
-
connectionState: d ? "error" : l ?
|
|
3539
|
+
connectionState: d ? "error" : l ? C ? "connected" : "connecting" : "idle",
|
|
3540
3540
|
messages: [],
|
|
3541
3541
|
// useStream doesn't maintain messages, use useChatSession instead
|
|
3542
|
-
submit:
|
|
3542
|
+
submit: _
|
|
3543
3543
|
};
|
|
3544
3544
|
}
|
|
3545
3545
|
const es = ["detail", "message", "error", "description", "title"];
|
|
@@ -3592,159 +3592,159 @@ function ns({
|
|
|
3592
3592
|
onThreadChange: r,
|
|
3593
3593
|
onCurrentThreadDeleted: s
|
|
3594
3594
|
}) {
|
|
3595
|
-
const [o, a] =
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
}, [i]),
|
|
3599
|
-
t !== void 0 && t !==
|
|
3595
|
+
const [o, a] = W([]), [i, f] = W(t), [l, c] = W(!1), [d, g] = W(null), [h, k] = W([]), [m, y] = W(!1), [, I] = W(null), [S, C] = W(null), [L, z] = W(!1), w = H(i), v = H(/* @__PURE__ */ new Map());
|
|
3596
|
+
se(() => {
|
|
3597
|
+
w.current = i;
|
|
3598
|
+
}, [i]), se(() => {
|
|
3599
|
+
t !== void 0 && t !== w.current && f(t);
|
|
3600
3600
|
}, [t]);
|
|
3601
|
-
const
|
|
3601
|
+
const F = E(async () => {
|
|
3602
3602
|
c(!0), g(null);
|
|
3603
3603
|
try {
|
|
3604
|
-
const
|
|
3605
|
-
a(
|
|
3606
|
-
} catch (
|
|
3607
|
-
const
|
|
3608
|
-
g(
|
|
3604
|
+
const A = await e.listThreads();
|
|
3605
|
+
a(A ?? []);
|
|
3606
|
+
} catch (A) {
|
|
3607
|
+
const R = String(A);
|
|
3608
|
+
g(R), n == null || n(R);
|
|
3609
3609
|
} finally {
|
|
3610
3610
|
c(!1);
|
|
3611
3611
|
}
|
|
3612
|
-
}, [e, n]),
|
|
3612
|
+
}, [e, n]), $ = E(async () => {
|
|
3613
3613
|
y(!0), I(null);
|
|
3614
3614
|
try {
|
|
3615
|
-
const
|
|
3616
|
-
|
|
3617
|
-
} catch (
|
|
3618
|
-
const
|
|
3619
|
-
I(
|
|
3615
|
+
const A = await e.listSharedThreads();
|
|
3616
|
+
k(A ?? []);
|
|
3617
|
+
} catch (A) {
|
|
3618
|
+
const R = String(A);
|
|
3619
|
+
I(R), n == null || n(R);
|
|
3620
3620
|
} finally {
|
|
3621
3621
|
y(!1);
|
|
3622
3622
|
}
|
|
3623
3623
|
}, [e, n]);
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
}, [
|
|
3627
|
-
|
|
3628
|
-
}, [
|
|
3624
|
+
se(() => {
|
|
3625
|
+
F();
|
|
3626
|
+
}, [F]), se(() => {
|
|
3627
|
+
$();
|
|
3628
|
+
}, [$]), se(() => {
|
|
3629
3629
|
r == null || r(i);
|
|
3630
3630
|
}, [i, r]);
|
|
3631
|
-
const
|
|
3632
|
-
async (
|
|
3631
|
+
const B = E(
|
|
3632
|
+
async (A, R) => {
|
|
3633
3633
|
try {
|
|
3634
|
-
const
|
|
3635
|
-
return f(
|
|
3636
|
-
} catch (
|
|
3637
|
-
const
|
|
3638
|
-
return n == null || n(
|
|
3634
|
+
const V = R && typeof R == "object" ? { id: R.id, name: R.name ?? "" } : void 0, K = await e.createThread(A, V);
|
|
3635
|
+
return f(K.threadId), await F(), K.threadId;
|
|
3636
|
+
} catch (V) {
|
|
3637
|
+
const K = String(V);
|
|
3638
|
+
return n == null || n(K), null;
|
|
3639
3639
|
}
|
|
3640
3640
|
},
|
|
3641
|
-
[e, n,
|
|
3642
|
-
),
|
|
3643
|
-
async (
|
|
3644
|
-
const
|
|
3645
|
-
a((
|
|
3646
|
-
const
|
|
3647
|
-
|
|
3641
|
+
[e, n, F]
|
|
3642
|
+
), D = E(
|
|
3643
|
+
async (A) => {
|
|
3644
|
+
const R = o;
|
|
3645
|
+
a((K) => K.filter((u) => u.threadId !== A));
|
|
3646
|
+
const V = new AbortController();
|
|
3647
|
+
v.current.set(A, V);
|
|
3648
3648
|
try {
|
|
3649
|
-
await e.deleteThread(
|
|
3650
|
-
} catch (
|
|
3651
|
-
a(
|
|
3652
|
-
const u = String(
|
|
3649
|
+
await e.deleteThread(A), w.current === A && (f(null), s == null || s());
|
|
3650
|
+
} catch (K) {
|
|
3651
|
+
a(R);
|
|
3652
|
+
const u = String(K);
|
|
3653
3653
|
n == null || n(u);
|
|
3654
3654
|
} finally {
|
|
3655
|
-
|
|
3655
|
+
v.current.delete(A);
|
|
3656
3656
|
}
|
|
3657
3657
|
},
|
|
3658
3658
|
[e, s, n, o]
|
|
3659
|
-
),
|
|
3660
|
-
async (
|
|
3659
|
+
), P = E(
|
|
3660
|
+
async (A, R) => {
|
|
3661
3661
|
try {
|
|
3662
|
-
await e.updateThread(
|
|
3663
|
-
} catch (
|
|
3664
|
-
n == null || n(String(
|
|
3662
|
+
await e.updateThread(A, R), await F();
|
|
3663
|
+
} catch (V) {
|
|
3664
|
+
n == null || n(String(V));
|
|
3665
3665
|
}
|
|
3666
3666
|
},
|
|
3667
|
-
[e, n,
|
|
3667
|
+
[e, n, F]
|
|
3668
3668
|
), J = E(
|
|
3669
|
-
async (
|
|
3670
|
-
|
|
3669
|
+
async (A, R) => {
|
|
3670
|
+
z(!0), C("Sharing thread…");
|
|
3671
3671
|
try {
|
|
3672
|
-
await e.shareThread(
|
|
3673
|
-
} catch (
|
|
3674
|
-
const
|
|
3675
|
-
throw n == null || n(
|
|
3672
|
+
await e.shareThread(A, R), await $(), C("Shared successfully");
|
|
3673
|
+
} catch (V) {
|
|
3674
|
+
const K = ts(V);
|
|
3675
|
+
throw n == null || n(K), C(`Failed to share: ${K}`), new Error(K);
|
|
3676
3676
|
} finally {
|
|
3677
|
-
|
|
3677
|
+
z(!1);
|
|
3678
3678
|
}
|
|
3679
3679
|
},
|
|
3680
|
-
[e, n,
|
|
3681
|
-
),
|
|
3682
|
-
async (
|
|
3680
|
+
[e, n, $]
|
|
3681
|
+
), G = E(
|
|
3682
|
+
async (A, R) => {
|
|
3683
3683
|
try {
|
|
3684
|
-
await e.unshareThread(
|
|
3685
|
-
} catch (
|
|
3686
|
-
const
|
|
3687
|
-
throw n == null || n(
|
|
3684
|
+
await e.unshareThread(A, R), await $();
|
|
3685
|
+
} catch (V) {
|
|
3686
|
+
const K = String(V);
|
|
3687
|
+
throw n == null || n(K), V;
|
|
3688
3688
|
}
|
|
3689
3689
|
},
|
|
3690
|
-
[e, n,
|
|
3691
|
-
), Q =
|
|
3690
|
+
[e, n, $]
|
|
3691
|
+
), Q = de(
|
|
3692
3692
|
() => ({
|
|
3693
|
-
createThread:
|
|
3694
|
-
deleteThread:
|
|
3695
|
-
renameThread:
|
|
3696
|
-
refreshThreads:
|
|
3697
|
-
refreshSharedThreads:
|
|
3693
|
+
createThread: B,
|
|
3694
|
+
deleteThread: D,
|
|
3695
|
+
renameThread: P,
|
|
3696
|
+
refreshThreads: F,
|
|
3697
|
+
refreshSharedThreads: $,
|
|
3698
3698
|
shareThread: J,
|
|
3699
|
-
unshareThread:
|
|
3699
|
+
unshareThread: G
|
|
3700
3700
|
}),
|
|
3701
|
-
[
|
|
3702
|
-
),
|
|
3703
|
-
if (!(
|
|
3704
|
-
const
|
|
3705
|
-
threadId:
|
|
3706
|
-
title:
|
|
3707
|
-
project:
|
|
3708
|
-
createdAt:
|
|
3709
|
-
updatedAt:
|
|
3710
|
-
messageCount:
|
|
3701
|
+
[B, D, P, F, $, J, G]
|
|
3702
|
+
), X = E((A) => {
|
|
3703
|
+
if (!(A != null && A.threadId)) return;
|
|
3704
|
+
const R = {
|
|
3705
|
+
threadId: A.threadId,
|
|
3706
|
+
title: A.title || `Thread ${A.threadId.slice(0, 8)}`,
|
|
3707
|
+
project: A.project,
|
|
3708
|
+
createdAt: A.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
3709
|
+
updatedAt: A.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
3710
|
+
messageCount: A.messageCount ?? 1
|
|
3711
3711
|
};
|
|
3712
|
-
a((
|
|
3713
|
-
let
|
|
3714
|
-
const u =
|
|
3715
|
-
...
|
|
3716
|
-
title:
|
|
3717
|
-
project:
|
|
3718
|
-
updatedAt:
|
|
3719
|
-
messageCount:
|
|
3720
|
-
}) :
|
|
3721
|
-
return
|
|
3712
|
+
a((V) => {
|
|
3713
|
+
let K = !1;
|
|
3714
|
+
const u = V.map((N) => N.threadId === R.threadId ? (K = !0, console.debug("[useThreadsState] thread_info: updating existing thread", R.threadId), {
|
|
3715
|
+
...N,
|
|
3716
|
+
title: R.title ?? N.title,
|
|
3717
|
+
project: R.project ?? N.project,
|
|
3718
|
+
updatedAt: R.updatedAt ?? N.updatedAt,
|
|
3719
|
+
messageCount: R.messageCount ?? N.messageCount
|
|
3720
|
+
}) : N);
|
|
3721
|
+
return K ? u : (console.debug("[useThreadsState] thread_info: adding thread to list", R.threadId), [R, ...V]);
|
|
3722
3722
|
});
|
|
3723
|
-
}, []),
|
|
3723
|
+
}, []), oe = E(() => C(null), []);
|
|
3724
3724
|
return {
|
|
3725
3725
|
threads: o,
|
|
3726
3726
|
currentThreadId: i,
|
|
3727
|
-
currentThreadIdRef:
|
|
3727
|
+
currentThreadIdRef: w,
|
|
3728
3728
|
setCurrentThreadId: f,
|
|
3729
3729
|
isLoadingThreads: l,
|
|
3730
3730
|
threadsError: d,
|
|
3731
3731
|
sharedThreads: h,
|
|
3732
3732
|
isLoadingSharedThreads: m,
|
|
3733
3733
|
actions: Q,
|
|
3734
|
-
addThreadFromEvent:
|
|
3735
|
-
shareInFlight:
|
|
3736
|
-
shareStatus:
|
|
3737
|
-
clearShareStatus:
|
|
3734
|
+
addThreadFromEvent: X,
|
|
3735
|
+
shareInFlight: L,
|
|
3736
|
+
shareStatus: S,
|
|
3737
|
+
clearShareStatus: oe
|
|
3738
3738
|
};
|
|
3739
3739
|
}
|
|
3740
|
-
const
|
|
3740
|
+
const wn = We(null);
|
|
3741
3741
|
function rs({
|
|
3742
3742
|
children: e,
|
|
3743
3743
|
initialThreadId: t = null,
|
|
3744
3744
|
onError: n,
|
|
3745
3745
|
onThreadChange: r
|
|
3746
3746
|
}) {
|
|
3747
|
-
const { chatApi: s } =
|
|
3747
|
+
const { chatApi: s } = qe(), {
|
|
3748
3748
|
threads: o,
|
|
3749
3749
|
currentThreadId: a,
|
|
3750
3750
|
setCurrentThreadId: i,
|
|
@@ -3754,7 +3754,7 @@ function rs({
|
|
|
3754
3754
|
sharedThreads: d,
|
|
3755
3755
|
isLoadingSharedThreads: g,
|
|
3756
3756
|
actions: h,
|
|
3757
|
-
addThreadFromEvent:
|
|
3757
|
+
addThreadFromEvent: k,
|
|
3758
3758
|
shareInFlight: m,
|
|
3759
3759
|
shareStatus: y,
|
|
3760
3760
|
clearShareStatus: I
|
|
@@ -3763,7 +3763,7 @@ function rs({
|
|
|
3763
3763
|
initialThreadId: t,
|
|
3764
3764
|
onError: n,
|
|
3765
3765
|
onThreadChange: r
|
|
3766
|
-
}),
|
|
3766
|
+
}), S = de(
|
|
3767
3767
|
() => ({
|
|
3768
3768
|
threads: o,
|
|
3769
3769
|
currentThreadId: a,
|
|
@@ -3777,7 +3777,7 @@ function rs({
|
|
|
3777
3777
|
shareInFlight: m,
|
|
3778
3778
|
shareStatus: y,
|
|
3779
3779
|
clearShareStatus: I,
|
|
3780
|
-
addThreadFromEvent:
|
|
3780
|
+
addThreadFromEvent: k
|
|
3781
3781
|
}),
|
|
3782
3782
|
[
|
|
3783
3783
|
o,
|
|
@@ -3792,17 +3792,17 @@ function rs({
|
|
|
3792
3792
|
m,
|
|
3793
3793
|
y,
|
|
3794
3794
|
I,
|
|
3795
|
-
|
|
3795
|
+
k
|
|
3796
3796
|
]
|
|
3797
3797
|
);
|
|
3798
|
-
return /* @__PURE__ */ Ce(
|
|
3798
|
+
return /* @__PURE__ */ Ce(wn.Provider, { value: S, children: e });
|
|
3799
3799
|
}
|
|
3800
|
-
function
|
|
3801
|
-
const e =
|
|
3800
|
+
function rt() {
|
|
3801
|
+
const e = ot(wn);
|
|
3802
3802
|
if (!e) throw new Error("useThreads must be used within a ThreadsProvider");
|
|
3803
3803
|
return e;
|
|
3804
3804
|
}
|
|
3805
|
-
function
|
|
3805
|
+
function kn(e) {
|
|
3806
3806
|
const t = e.artifact;
|
|
3807
3807
|
return !t || typeof t != "object" ? null : "metadata" in t && t.metadata ? t.metadata : {
|
|
3808
3808
|
id: t.id ?? e.id ?? `artifact-${Date.now()}`,
|
|
@@ -3813,7 +3813,7 @@ function vn(e) {
|
|
|
3813
3813
|
};
|
|
3814
3814
|
}
|
|
3815
3815
|
function ss(e, t) {
|
|
3816
|
-
const n =
|
|
3816
|
+
const n = kn(e);
|
|
3817
3817
|
if (!n) return e;
|
|
3818
3818
|
const r = {
|
|
3819
3819
|
...n,
|
|
@@ -3830,21 +3830,21 @@ function ss(e, t) {
|
|
|
3830
3830
|
}
|
|
3831
3831
|
function os(e, t, n) {
|
|
3832
3832
|
return e.find((r) => {
|
|
3833
|
-
const s =
|
|
3833
|
+
const s = kn(r);
|
|
3834
3834
|
return !!((s == null ? void 0 : s.id) === t || n && r.toolCallId === n);
|
|
3835
3835
|
}) ?? null;
|
|
3836
3836
|
}
|
|
3837
3837
|
function gt(e) {
|
|
3838
3838
|
return e.map((t) => bt(t)).filter((t) => !!t);
|
|
3839
3839
|
}
|
|
3840
|
-
function
|
|
3840
|
+
function at(e, t, n) {
|
|
3841
3841
|
return t < 0 || t >= e.length ? e : [...e.slice(0, t), n, ...e.slice(t + 1)];
|
|
3842
3842
|
}
|
|
3843
3843
|
function as(e, t, n) {
|
|
3844
3844
|
for (let r = e.length - 1; r >= 0; r--)
|
|
3845
3845
|
if (e[r].role === "assistant") {
|
|
3846
3846
|
const o = { ...e[r], checkpointId: t, checkpointNs: n ?? void 0 };
|
|
3847
|
-
return
|
|
3847
|
+
return at(e, r, o);
|
|
3848
3848
|
}
|
|
3849
3849
|
return e;
|
|
3850
3850
|
}
|
|
@@ -3915,17 +3915,17 @@ function ls(e, t) {
|
|
|
3915
3915
|
return { ...e, messages: a };
|
|
3916
3916
|
}
|
|
3917
3917
|
case "event":
|
|
3918
|
-
return
|
|
3918
|
+
return Qt(e, t.payload.ev);
|
|
3919
3919
|
case "batch": {
|
|
3920
3920
|
const { events: r } = t.payload;
|
|
3921
|
-
return r.length ? r.reduce((s, o) =>
|
|
3921
|
+
return r.length ? r.reduce((s, o) => Qt(s, o), e) : e;
|
|
3922
3922
|
}
|
|
3923
3923
|
default:
|
|
3924
3924
|
return e;
|
|
3925
3925
|
}
|
|
3926
3926
|
}
|
|
3927
3927
|
function us(e = []) {
|
|
3928
|
-
const [t, n] =
|
|
3928
|
+
const [t, n] = Un(ls, { ...cs, messages: e }), r = H([]), s = H(null), o = H(null), a = E(() => {
|
|
3929
3929
|
s.current !== null && typeof window < "u" && window.cancelAnimationFrame(s.current), o.current !== null && clearTimeout(o.current), s.current = null, o.current = null;
|
|
3930
3930
|
const c = r.current;
|
|
3931
3931
|
c.length && (r.current = [], n({ type: "batch", payload: { events: c } }));
|
|
@@ -3934,10 +3934,10 @@ function us(e = []) {
|
|
|
3934
3934
|
}, [a]), f = E((c) => {
|
|
3935
3935
|
r.current.push(c), i();
|
|
3936
3936
|
}, [i]);
|
|
3937
|
-
|
|
3937
|
+
se(() => () => {
|
|
3938
3938
|
s.current !== null && typeof window < "u" && window.cancelAnimationFrame(s.current), o.current !== null && clearTimeout(o.current), r.current = [];
|
|
3939
3939
|
}, []);
|
|
3940
|
-
const l =
|
|
3940
|
+
const l = de(() => ({
|
|
3941
3941
|
reset: (c) => n({ type: "reset", payload: { messages: c } }),
|
|
3942
3942
|
seed: (c, d) => n({ type: "seed", payload: { messages: c, ...d ?? {} } }),
|
|
3943
3943
|
prepend: (c) => n({ type: "prepend", payload: { messages: c } }),
|
|
@@ -3946,7 +3946,7 @@ function us(e = []) {
|
|
|
3946
3946
|
}), [f]);
|
|
3947
3947
|
return { state: t, dispatch: n, ...l };
|
|
3948
3948
|
}
|
|
3949
|
-
function
|
|
3949
|
+
function Qt(e, t) {
|
|
3950
3950
|
var a;
|
|
3951
3951
|
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:");
|
|
3952
3952
|
if (t.type === "tool.start")
|
|
@@ -4017,7 +4017,7 @@ function fs(e, t, n) {
|
|
|
4017
4017
|
const s = e[r], o = (s.toolCalls ?? []).map(
|
|
4018
4018
|
(a) => a.id === t ? { ...a, ...n } : a
|
|
4019
4019
|
);
|
|
4020
|
-
return
|
|
4020
|
+
return at(e, r, { ...s, toolCalls: o });
|
|
4021
4021
|
}
|
|
4022
4022
|
function ps(e, t) {
|
|
4023
4023
|
const n = t, r = n.id || n.callId, s = n.name ?? void 0, o = n.scope ?? void 0, a = `Starting ${s ?? "tool"}...`;
|
|
@@ -4041,7 +4041,7 @@ function ps(e, t) {
|
|
|
4041
4041
|
status: "running",
|
|
4042
4042
|
content: a,
|
|
4043
4043
|
scope: o
|
|
4044
|
-
}), i =
|
|
4044
|
+
}), i = at(i, f, { ...l, toolCalls: c });
|
|
4045
4045
|
} else {
|
|
4046
4046
|
const l = n.agentName ?? "assistant", c = {
|
|
4047
4047
|
id: `ai-${Date.now()}`,
|
|
@@ -4073,7 +4073,7 @@ function gs(e, t) {
|
|
|
4073
4073
|
const i = o[a], f = r ?? null, l = typeof f == "string" ? f : JSON.stringify(f), c = Me(f), d = typeof c == "string" ? c : l, g = (i.toolCalls ?? []).map(
|
|
4074
4074
|
(h) => h.id === n ? { ...h, content: d, scope: s ?? h.scope } : h
|
|
4075
4075
|
);
|
|
4076
|
-
o =
|
|
4076
|
+
o = at(o, a, { ...i, toolCalls: g });
|
|
4077
4077
|
}
|
|
4078
4078
|
return { ...e, messages: o };
|
|
4079
4079
|
}
|
|
@@ -4155,10 +4155,10 @@ function hs(e, t) {
|
|
|
4155
4155
|
...t.partial_data
|
|
4156
4156
|
}), {
|
|
4157
4157
|
...e,
|
|
4158
|
-
messages:
|
|
4158
|
+
messages: at(e.messages, o, a)
|
|
4159
4159
|
};
|
|
4160
4160
|
}
|
|
4161
|
-
const
|
|
4161
|
+
const Yt = 120;
|
|
4162
4162
|
function ys(e) {
|
|
4163
4163
|
if (!Array.isArray(e))
|
|
4164
4164
|
return "";
|
|
@@ -4166,7 +4166,7 @@ function ys(e) {
|
|
|
4166
4166
|
if (!t.length)
|
|
4167
4167
|
return "";
|
|
4168
4168
|
const n = t.join(" ").replace(/\s+/g, " ").trim();
|
|
4169
|
-
return n ? n.length >
|
|
4169
|
+
return n ? n.length > Yt ? `${n.slice(0, Yt - 3)}…` : n : "";
|
|
4170
4170
|
}
|
|
4171
4171
|
function bs(e) {
|
|
4172
4172
|
return ys(e.content) || "";
|
|
@@ -4174,34 +4174,34 @@ function bs(e) {
|
|
|
4174
4174
|
function ws(e) {
|
|
4175
4175
|
const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), s = [];
|
|
4176
4176
|
for (let l = 0; l < e.length; l++) {
|
|
4177
|
-
const c = e[l], d = c.checkpointId, g = d ?? `cp-${l}`, h = c.metadata ?? {},
|
|
4177
|
+
const c = e[l], d = c.checkpointId, g = d ?? `cp-${l}`, h = c.metadata ?? {}, k = typeof h.step == "number" ? h.step : null, m = typeof h.source == "string" ? h.source : null;
|
|
4178
4178
|
let y = null, I = null;
|
|
4179
|
-
const
|
|
4180
|
-
for (const
|
|
4181
|
-
|
|
4182
|
-
const
|
|
4179
|
+
const S = Array.isArray(c.messages) ? c.messages : [];
|
|
4180
|
+
for (const w of S)
|
|
4181
|
+
w.role === "user" && (I || (I = w), w.id && (y = w.id));
|
|
4182
|
+
const C = c.next && c.next.length > 0 ? String(c.next[0]) : null, L = c.parentConfig ?? null, z = {
|
|
4183
4183
|
id: g,
|
|
4184
|
-
step:
|
|
4184
|
+
step: k,
|
|
4185
4185
|
source: m,
|
|
4186
4186
|
createdAt: c.createdAt ?? null,
|
|
4187
4187
|
namespace: c.checkpointNs ?? null,
|
|
4188
4188
|
parentId: c.parentId ?? null,
|
|
4189
|
-
next:
|
|
4190
|
-
parentConfig:
|
|
4189
|
+
next: C,
|
|
4190
|
+
parentConfig: L,
|
|
4191
4191
|
userMessageId: y
|
|
4192
4192
|
};
|
|
4193
|
-
if (s.push(
|
|
4194
|
-
const
|
|
4195
|
-
|
|
4193
|
+
if (s.push(z), d && t.set(d, z), d && I) {
|
|
4194
|
+
const w = bs(I);
|
|
4195
|
+
w && r.set(d, w);
|
|
4196
4196
|
}
|
|
4197
4197
|
n.push({
|
|
4198
4198
|
id: g,
|
|
4199
4199
|
messageId: y,
|
|
4200
|
-
step:
|
|
4200
|
+
step: k,
|
|
4201
4201
|
source: m,
|
|
4202
4202
|
createdAt: c.createdAt ?? null,
|
|
4203
|
-
next:
|
|
4204
|
-
parentConfig:
|
|
4203
|
+
next: C,
|
|
4204
|
+
parentConfig: L
|
|
4205
4205
|
});
|
|
4206
4206
|
}
|
|
4207
4207
|
const o = /* @__PURE__ */ new Map();
|
|
@@ -4238,8 +4238,8 @@ function ws(e) {
|
|
|
4238
4238
|
for (const d of t.values())
|
|
4239
4239
|
d.userMessageId === l && c.push(d);
|
|
4240
4240
|
return c.length ? (c.sort((d, g) => {
|
|
4241
|
-
const h = typeof d.attemptIndex == "number" ? d.attemptIndex : Number.MAX_SAFE_INTEGER,
|
|
4242
|
-
return h -
|
|
4241
|
+
const h = typeof d.attemptIndex == "number" ? d.attemptIndex : Number.MAX_SAFE_INTEGER, k = typeof g.attemptIndex == "number" ? g.attemptIndex : Number.MAX_SAFE_INTEGER;
|
|
4242
|
+
return h - k;
|
|
4243
4243
|
}), c) : [];
|
|
4244
4244
|
}
|
|
4245
4245
|
};
|
|
@@ -4262,9 +4262,9 @@ function Xs(e, t, n) {
|
|
|
4262
4262
|
};
|
|
4263
4263
|
}
|
|
4264
4264
|
function ks(e) {
|
|
4265
|
-
return
|
|
4265
|
+
return de(() => ws(e), [e]);
|
|
4266
4266
|
}
|
|
4267
|
-
function
|
|
4267
|
+
function vn({
|
|
4268
4268
|
api: e,
|
|
4269
4269
|
fileApi: t,
|
|
4270
4270
|
seed: n,
|
|
@@ -4277,176 +4277,198 @@ function Tn({
|
|
|
4277
4277
|
isStreaming: l,
|
|
4278
4278
|
getMessages: c
|
|
4279
4279
|
}) {
|
|
4280
|
-
const [d, g] =
|
|
4281
|
-
() =>
|
|
4280
|
+
const [d, g] = W(null), k = de(
|
|
4281
|
+
() => ft(d),
|
|
4282
4282
|
[d]
|
|
4283
|
-
).checkpoints, m = ks(
|
|
4284
|
-
|
|
4285
|
-
|
|
4283
|
+
).checkpoints, m = ks(k), y = m.timeline, [I, S] = W(!1), [C, L] = W(!1), [z, w] = W(null), v = H(s), F = H(null), $ = H(null), B = H(null), D = H(null), P = H(null), J = H(/* @__PURE__ */ new Map()), G = H(null);
|
|
4284
|
+
se(() => {
|
|
4285
|
+
v.current = s;
|
|
4286
4286
|
}, [s]);
|
|
4287
4287
|
const Q = E(
|
|
4288
4288
|
async (p) => {
|
|
4289
|
-
var
|
|
4289
|
+
var x, q;
|
|
4290
4290
|
if (!p.threadId) return;
|
|
4291
|
-
const
|
|
4292
|
-
(
|
|
4291
|
+
const M = p.threadId;
|
|
4292
|
+
(x = p.onStart) == null || x.call(p), p.setLoading(!0);
|
|
4293
4293
|
try {
|
|
4294
|
-
await p.action(
|
|
4295
|
-
} catch (
|
|
4296
|
-
if (!
|
|
4297
|
-
const
|
|
4298
|
-
(
|
|
4294
|
+
await p.action(M);
|
|
4295
|
+
} catch (U) {
|
|
4296
|
+
if (!Dt(U) && v.current === M) {
|
|
4297
|
+
const ee = String(U);
|
|
4298
|
+
(q = p.handleError) == null || q.call(p, ee), r == null || r(ee);
|
|
4299
4299
|
}
|
|
4300
|
-
throw
|
|
4300
|
+
throw U;
|
|
4301
4301
|
} finally {
|
|
4302
4302
|
p.setLoading(!1);
|
|
4303
4303
|
}
|
|
4304
4304
|
},
|
|
4305
4305
|
[r]
|
|
4306
|
-
),
|
|
4307
|
-
async (p
|
|
4308
|
-
|
|
4306
|
+
), X = E(
|
|
4307
|
+
async (p) => {
|
|
4308
|
+
const M = await e.getState({
|
|
4309
|
+
threadId: p.threadId,
|
|
4310
|
+
checkpointId: p.checkpointId,
|
|
4311
|
+
checkpointNs: p.checkpointNs
|
|
4312
|
+
}), x = p.forTimelineHistory ?? {
|
|
4313
|
+
version: "values@1",
|
|
4314
|
+
threadId: p.threadId,
|
|
4315
|
+
checkpoints: [M]
|
|
4316
|
+
}, q = t ? await Gr(x, t) : x, { latest: U } = ft(q);
|
|
4317
|
+
return U;
|
|
4318
|
+
},
|
|
4319
|
+
[e, t]
|
|
4320
|
+
), oe = E(
|
|
4321
|
+
async (p, M) => {
|
|
4322
|
+
var ee;
|
|
4309
4323
|
if (!p) return;
|
|
4310
|
-
const
|
|
4311
|
-
if (
|
|
4312
|
-
return
|
|
4313
|
-
(
|
|
4314
|
-
const
|
|
4315
|
-
|
|
4316
|
-
const
|
|
4324
|
+
const x = `${p}:${M ?? "latest"}`, q = J.current.get(x);
|
|
4325
|
+
if (q)
|
|
4326
|
+
return q;
|
|
4327
|
+
(ee = G.current) == null || ee.abort();
|
|
4328
|
+
const U = new AbortController();
|
|
4329
|
+
G.current = U;
|
|
4330
|
+
const ne = Q({
|
|
4317
4331
|
threadId: p,
|
|
4318
|
-
setLoading:
|
|
4319
|
-
onStart: () =>
|
|
4320
|
-
handleError: (
|
|
4321
|
-
action: async (
|
|
4322
|
-
const
|
|
4323
|
-
threadId:
|
|
4324
|
-
checkpointId:
|
|
4325
|
-
|
|
4332
|
+
setLoading: S,
|
|
4333
|
+
onStart: () => w(null),
|
|
4334
|
+
handleError: (Y) => w(Y),
|
|
4335
|
+
action: async (Y) => {
|
|
4336
|
+
const j = await X({
|
|
4337
|
+
threadId: Y,
|
|
4338
|
+
checkpointId: M ?? void 0
|
|
4339
|
+
}), re = await e.getStateHistory({
|
|
4340
|
+
threadId: Y,
|
|
4341
|
+
checkpointId: M ?? void 0,
|
|
4342
|
+
signal: U.signal,
|
|
4326
4343
|
limit: 100,
|
|
4327
|
-
includeMessages: !
|
|
4328
|
-
})
|
|
4329
|
-
if (
|
|
4344
|
+
includeMessages: !1
|
|
4345
|
+
});
|
|
4346
|
+
if (v.current !== Y) {
|
|
4330
4347
|
console.log(
|
|
4331
|
-
`[useThreadHistoryState] Thread changed during load (was ${
|
|
4348
|
+
`[useThreadHistoryState] Thread changed during load (was ${Y}, now ${v.current}), discarding stale data`
|
|
4332
4349
|
);
|
|
4333
4350
|
return;
|
|
4334
4351
|
}
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
}), g(
|
|
4352
|
+
n((j == null ? void 0 : j.messages) ?? [], {
|
|
4353
|
+
checkpointId: (j == null ? void 0 : j.checkpointId) ?? null,
|
|
4354
|
+
checkpointNs: (j == null ? void 0 : j.checkpointNs) ?? null,
|
|
4355
|
+
pendingInterrupt: (j == null ? void 0 : j.interrupt) ?? null,
|
|
4356
|
+
values: j == null ? void 0 : j.values
|
|
4357
|
+
}), g(re);
|
|
4341
4358
|
}
|
|
4342
4359
|
});
|
|
4343
|
-
J.current.set(
|
|
4360
|
+
J.current.set(x, ne);
|
|
4344
4361
|
try {
|
|
4345
|
-
await
|
|
4362
|
+
await ne;
|
|
4346
4363
|
} finally {
|
|
4347
|
-
J.current.delete(
|
|
4364
|
+
J.current.delete(x), G.current === U && (G.current = null);
|
|
4348
4365
|
}
|
|
4349
|
-
return
|
|
4366
|
+
return v.current === p && (P.current = x), ne;
|
|
4350
4367
|
},
|
|
4351
|
-
[e, n, Q,
|
|
4352
|
-
),
|
|
4353
|
-
async (p,
|
|
4354
|
-
|
|
4368
|
+
[e, n, Q, X]
|
|
4369
|
+
), A = E(
|
|
4370
|
+
async (p, M) => {
|
|
4371
|
+
D.current = p;
|
|
4355
4372
|
try {
|
|
4356
|
-
await
|
|
4357
|
-
} catch (
|
|
4358
|
-
if (!
|
|
4359
|
-
throw
|
|
4373
|
+
await oe(p, M);
|
|
4374
|
+
} catch (x) {
|
|
4375
|
+
if (!Dt(x))
|
|
4376
|
+
throw x;
|
|
4360
4377
|
} finally {
|
|
4361
|
-
|
|
4378
|
+
D.current === p && (D.current = null);
|
|
4362
4379
|
}
|
|
4363
4380
|
},
|
|
4364
|
-
[
|
|
4365
|
-
),
|
|
4366
|
-
|
|
4367
|
-
}, []),
|
|
4368
|
-
|
|
4369
|
-
}, []),
|
|
4381
|
+
[oe]
|
|
4382
|
+
), R = E((p) => {
|
|
4383
|
+
$.current = p;
|
|
4384
|
+
}, []), V = E((p) => {
|
|
4385
|
+
B.current = p;
|
|
4386
|
+
}, []), K = E(
|
|
4370
4387
|
async (p) => {
|
|
4371
|
-
const
|
|
4372
|
-
if (!
|
|
4373
|
-
return;
|
|
4374
|
-
const z = t ? await Et(p, t) : p, { checkpoints: U, latest: q } = tt(z);
|
|
4375
|
-
if (!U.length)
|
|
4388
|
+
const M = p == null ? void 0 : p.threadId, x = typeof M == "string" ? M : v.current;
|
|
4389
|
+
if (!x || v.current && v.current !== x && B.current !== x)
|
|
4376
4390
|
return;
|
|
4377
|
-
const
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4391
|
+
const q = p, U = await X({
|
|
4392
|
+
threadId: x
|
|
4393
|
+
});
|
|
4394
|
+
U && (n(U.messages ?? [], {
|
|
4395
|
+
checkpointId: U.checkpointId ?? null,
|
|
4396
|
+
checkpointNs: U.checkpointNs ?? null,
|
|
4397
|
+
pendingInterrupt: U.interrupt ?? null,
|
|
4398
|
+
values: U.values
|
|
4399
|
+
}), g(q), P.current = `${x}:latest`, $.current = null, B.current === x && (B.current = null));
|
|
4384
4400
|
},
|
|
4385
|
-
[n, l,
|
|
4386
|
-
),
|
|
4387
|
-
async (p,
|
|
4388
|
-
const
|
|
4401
|
+
[n, l, X]
|
|
4402
|
+
), u = E(
|
|
4403
|
+
async (p, M) => {
|
|
4404
|
+
const x = v.current;
|
|
4389
4405
|
await Q({
|
|
4390
|
-
threadId:
|
|
4391
|
-
setLoading:
|
|
4392
|
-
action: async (
|
|
4393
|
-
const
|
|
4394
|
-
threadId:
|
|
4406
|
+
threadId: x,
|
|
4407
|
+
setLoading: L,
|
|
4408
|
+
action: async (q) => {
|
|
4409
|
+
const U = await X({
|
|
4410
|
+
threadId: q,
|
|
4395
4411
|
checkpointId: p,
|
|
4396
|
-
checkpointNs:
|
|
4412
|
+
checkpointNs: M ?? void 0
|
|
4413
|
+
}), ne = await e.getStateHistory({
|
|
4414
|
+
threadId: q,
|
|
4415
|
+
checkpointId: p,
|
|
4416
|
+
checkpointNs: M ?? void 0,
|
|
4397
4417
|
limit: 100,
|
|
4398
|
-
includeMessages: !
|
|
4399
|
-
})
|
|
4400
|
-
if (
|
|
4418
|
+
includeMessages: !1
|
|
4419
|
+
});
|
|
4420
|
+
if (v.current !== q)
|
|
4401
4421
|
return;
|
|
4402
|
-
const { checkpoints:
|
|
4403
|
-
(
|
|
4422
|
+
const { checkpoints: ee } = ft(ne), Y = ee.find(
|
|
4423
|
+
(j) => j.checkpointId === p && (M ? j.checkpointNs === M : !0)
|
|
4404
4424
|
);
|
|
4405
|
-
if (!
|
|
4406
|
-
console.warn("[useThreadHistoryState] Requested checkpoint not found:", { checkpointId: p, checkpointNs:
|
|
4425
|
+
if (!Y) {
|
|
4426
|
+
console.warn("[useThreadHistoryState] Requested checkpoint not found:", { checkpointId: p, checkpointNs: M });
|
|
4407
4427
|
return;
|
|
4408
4428
|
}
|
|
4409
|
-
g(
|
|
4410
|
-
checkpointId:
|
|
4411
|
-
checkpointNs:
|
|
4429
|
+
g(ne), n((U == null ? void 0 : U.messages) ?? [], {
|
|
4430
|
+
checkpointId: (U == null ? void 0 : U.checkpointId) ?? Y.checkpointId ?? null,
|
|
4431
|
+
checkpointNs: (U == null ? void 0 : U.checkpointNs) ?? Y.checkpointNs ?? null,
|
|
4432
|
+
pendingInterrupt: (U == null ? void 0 : U.interrupt) ?? null,
|
|
4433
|
+
values: U == null ? void 0 : U.values
|
|
4412
4434
|
});
|
|
4413
4435
|
}
|
|
4414
4436
|
}).catch(() => {
|
|
4415
4437
|
});
|
|
4416
4438
|
},
|
|
4417
|
-
[e, n, Q,
|
|
4418
|
-
),
|
|
4419
|
-
(p,
|
|
4439
|
+
[e, n, Q, X]
|
|
4440
|
+
), N = E(
|
|
4441
|
+
(p, M) => {
|
|
4420
4442
|
n(c(), {
|
|
4421
4443
|
checkpointId: p ?? null,
|
|
4422
|
-
checkpointNs:
|
|
4444
|
+
checkpointNs: M ?? null
|
|
4423
4445
|
});
|
|
4424
4446
|
},
|
|
4425
4447
|
[c, n]
|
|
4426
|
-
),
|
|
4427
|
-
|
|
4428
|
-
}, [
|
|
4429
|
-
|
|
4448
|
+
), _ = E(async () => {
|
|
4449
|
+
v.current && await A(v.current);
|
|
4450
|
+
}, [A]);
|
|
4451
|
+
se(() => {
|
|
4430
4452
|
if (!f || !s || I || l)
|
|
4431
4453
|
return;
|
|
4432
|
-
if (
|
|
4433
|
-
|
|
4454
|
+
if ($.current === s) {
|
|
4455
|
+
$.current = null, F.current = s;
|
|
4434
4456
|
return;
|
|
4435
4457
|
}
|
|
4436
|
-
if (
|
|
4437
|
-
|
|
4458
|
+
if (B.current === s) {
|
|
4459
|
+
F.current = s;
|
|
4438
4460
|
return;
|
|
4439
4461
|
}
|
|
4440
|
-
if (
|
|
4441
|
-
|
|
4462
|
+
if (D.current === s) {
|
|
4463
|
+
D.current = null, F.current = s;
|
|
4442
4464
|
return;
|
|
4443
4465
|
}
|
|
4444
|
-
if (
|
|
4466
|
+
if (F.current === s)
|
|
4445
4467
|
return;
|
|
4446
|
-
|
|
4468
|
+
F.current = s;
|
|
4447
4469
|
let p;
|
|
4448
|
-
const
|
|
4449
|
-
|
|
4470
|
+
const M = `${s}:latest`;
|
|
4471
|
+
P.current !== M && A(s, p);
|
|
4450
4472
|
}, [
|
|
4451
4473
|
f,
|
|
4452
4474
|
s,
|
|
@@ -4455,42 +4477,42 @@ function Tn({
|
|
|
4455
4477
|
o,
|
|
4456
4478
|
I,
|
|
4457
4479
|
l,
|
|
4458
|
-
|
|
4480
|
+
A
|
|
4459
4481
|
]);
|
|
4460
|
-
const
|
|
4461
|
-
g(null),
|
|
4482
|
+
const T = E(() => {
|
|
4483
|
+
g(null), S(!1), L(!1), w(null), $.current = null, B.current = null, F.current = null, P.current = null, D.current = null;
|
|
4462
4484
|
}, []);
|
|
4463
4485
|
return {
|
|
4464
|
-
threadCheckpoints:
|
|
4486
|
+
threadCheckpoints: k,
|
|
4465
4487
|
threadTimeline: y,
|
|
4466
4488
|
checkpointIndex: m,
|
|
4467
4489
|
isLoadingThread: I,
|
|
4468
|
-
isLoadingCheckpoint:
|
|
4469
|
-
threadStateError:
|
|
4470
|
-
loadThread:
|
|
4471
|
-
navigateToCheckpoint:
|
|
4472
|
-
setCurrentCheckpointId:
|
|
4473
|
-
returnToLatest:
|
|
4474
|
-
handleValuesEvent:
|
|
4475
|
-
markSkipNextLoad:
|
|
4476
|
-
markStreamPendingThread:
|
|
4477
|
-
resetHistoryState:
|
|
4478
|
-
clearState:
|
|
4490
|
+
isLoadingCheckpoint: C,
|
|
4491
|
+
threadStateError: z,
|
|
4492
|
+
loadThread: A,
|
|
4493
|
+
navigateToCheckpoint: u,
|
|
4494
|
+
setCurrentCheckpointId: N,
|
|
4495
|
+
returnToLatest: _,
|
|
4496
|
+
handleValuesEvent: K,
|
|
4497
|
+
markSkipNextLoad: R,
|
|
4498
|
+
markStreamPendingThread: V,
|
|
4499
|
+
resetHistoryState: T,
|
|
4500
|
+
clearState: T
|
|
4479
4501
|
};
|
|
4480
4502
|
}
|
|
4481
|
-
const
|
|
4482
|
-
function
|
|
4483
|
-
const t =
|
|
4503
|
+
const Tn = We(null), An = We(null);
|
|
4504
|
+
function Sn(e) {
|
|
4505
|
+
const t = ot(Tn);
|
|
4484
4506
|
if (!t && !(e != null && e.optional)) throw new Error("useThreadState must be used within a ThreadStateProvider");
|
|
4485
4507
|
return t;
|
|
4486
4508
|
}
|
|
4487
|
-
function
|
|
4488
|
-
const e =
|
|
4509
|
+
function Is() {
|
|
4510
|
+
const e = ot(An);
|
|
4489
4511
|
if (!e)
|
|
4490
4512
|
throw new Error("useThreadStateUpdater must be used within a ThreadStateProvider");
|
|
4491
4513
|
return e;
|
|
4492
4514
|
}
|
|
4493
|
-
function
|
|
4515
|
+
function vs({
|
|
4494
4516
|
children: e,
|
|
4495
4517
|
initialThreadId: t = null,
|
|
4496
4518
|
initialCheckpointId: n = null,
|
|
@@ -4499,22 +4521,22 @@ function Is({
|
|
|
4499
4521
|
isStreaming: o,
|
|
4500
4522
|
onError: a
|
|
4501
4523
|
}) {
|
|
4502
|
-
const { chatApi: i, fileApi: f } =
|
|
4503
|
-
threadCheckpoints:
|
|
4524
|
+
const { chatApi: i, fileApi: f } = qe(), { currentThreadId: l } = rt(), { state: c, seed: d, onEvent: g, dispatch: h } = us(), {
|
|
4525
|
+
threadCheckpoints: k,
|
|
4504
4526
|
threadTimeline: m,
|
|
4505
4527
|
checkpointIndex: y,
|
|
4506
4528
|
isLoadingThread: I,
|
|
4507
|
-
isLoadingCheckpoint:
|
|
4508
|
-
threadStateError:
|
|
4509
|
-
loadThread:
|
|
4510
|
-
navigateToCheckpoint:
|
|
4511
|
-
setCurrentCheckpointId:
|
|
4512
|
-
returnToLatest:
|
|
4513
|
-
handleValuesEvent:
|
|
4514
|
-
markSkipNextLoad:
|
|
4515
|
-
markStreamPendingThread:
|
|
4516
|
-
resetHistoryState:
|
|
4517
|
-
} =
|
|
4529
|
+
isLoadingCheckpoint: S,
|
|
4530
|
+
threadStateError: C,
|
|
4531
|
+
loadThread: L,
|
|
4532
|
+
navigateToCheckpoint: z,
|
|
4533
|
+
setCurrentCheckpointId: w,
|
|
4534
|
+
returnToLatest: v,
|
|
4535
|
+
handleValuesEvent: F,
|
|
4536
|
+
markSkipNextLoad: $,
|
|
4537
|
+
markStreamPendingThread: B,
|
|
4538
|
+
resetHistoryState: D
|
|
4539
|
+
} = vn({
|
|
4518
4540
|
api: i,
|
|
4519
4541
|
fileApi: f,
|
|
4520
4542
|
seed: d,
|
|
@@ -4527,34 +4549,34 @@ function Is({
|
|
|
4527
4549
|
isStreaming: o,
|
|
4528
4550
|
getMessages: E(() => c.messages, [c.messages])
|
|
4529
4551
|
});
|
|
4530
|
-
|
|
4531
|
-
l || (d([], {}),
|
|
4532
|
-
}, [l, d,
|
|
4533
|
-
const
|
|
4552
|
+
se(() => {
|
|
4553
|
+
l || (d([], {}), D());
|
|
4554
|
+
}, [l, d, D]);
|
|
4555
|
+
const P = H(null), J = E(
|
|
4534
4556
|
(u) => {
|
|
4535
|
-
|
|
4557
|
+
P.current = u;
|
|
4536
4558
|
},
|
|
4537
4559
|
[]
|
|
4538
|
-
),
|
|
4560
|
+
), G = H(null), Q = E(
|
|
4539
4561
|
(u) => {
|
|
4540
|
-
|
|
4562
|
+
G.current = u;
|
|
4541
4563
|
},
|
|
4542
4564
|
[]
|
|
4543
|
-
),
|
|
4544
|
-
(u,
|
|
4545
|
-
const
|
|
4565
|
+
), X = de(() => ({ assemblingMessageId: c.assemblingId ?? null }), [c.assemblingId]), oe = E(
|
|
4566
|
+
(u, N) => {
|
|
4567
|
+
const _ = bn(u, "user");
|
|
4546
4568
|
return h({
|
|
4547
4569
|
type: "user_message",
|
|
4548
4570
|
payload: {
|
|
4549
|
-
message:
|
|
4550
|
-
editingMessageId:
|
|
4571
|
+
message: _,
|
|
4572
|
+
editingMessageId: N == null ? void 0 : N.editingMessageId
|
|
4551
4573
|
}
|
|
4552
|
-
}),
|
|
4574
|
+
}), _;
|
|
4553
4575
|
},
|
|
4554
4576
|
[h]
|
|
4555
|
-
),
|
|
4556
|
-
|
|
4557
|
-
}, [d,
|
|
4577
|
+
), A = E(async () => {
|
|
4578
|
+
P.current ? await P.current() : (d([], {}), D());
|
|
4579
|
+
}, [d, D]), R = de(() => Ar(c.messages), [c.messages]), V = de(
|
|
4558
4580
|
() => ({
|
|
4559
4581
|
threadId: l,
|
|
4560
4582
|
messages: c.messages,
|
|
@@ -4564,14 +4586,14 @@ function Is({
|
|
|
4564
4586
|
id: c.lastCheckpointId ?? null,
|
|
4565
4587
|
namespace: c.lastCheckpointNs ?? null
|
|
4566
4588
|
},
|
|
4567
|
-
checkpoints:
|
|
4589
|
+
checkpoints: k,
|
|
4568
4590
|
checkpointIndex: y,
|
|
4569
4591
|
timelineCheckpoints: m,
|
|
4570
|
-
metadata:
|
|
4592
|
+
metadata: X,
|
|
4571
4593
|
values: c.values ?? {},
|
|
4572
4594
|
isLoading: I,
|
|
4573
|
-
isLoadingCheckpoint:
|
|
4574
|
-
error:
|
|
4595
|
+
isLoadingCheckpoint: S,
|
|
4596
|
+
error: C,
|
|
4575
4597
|
loadOlder: async () => {
|
|
4576
4598
|
},
|
|
4577
4599
|
// Placeholder
|
|
@@ -4583,25 +4605,25 @@ function Is({
|
|
|
4583
4605
|
values: u.values
|
|
4584
4606
|
});
|
|
4585
4607
|
},
|
|
4586
|
-
clearState:
|
|
4587
|
-
navigateToCheckpoint:
|
|
4588
|
-
setCurrentCheckpointId:
|
|
4589
|
-
returnToLatest:
|
|
4590
|
-
loadThread: async (u,
|
|
4591
|
-
await
|
|
4608
|
+
clearState: A,
|
|
4609
|
+
navigateToCheckpoint: z,
|
|
4610
|
+
setCurrentCheckpointId: w,
|
|
4611
|
+
returnToLatest: v,
|
|
4612
|
+
loadThread: async (u, N, _) => {
|
|
4613
|
+
await L(u, N, { clearProgress: !1 });
|
|
4592
4614
|
},
|
|
4593
|
-
clearThread:
|
|
4594
|
-
respondToInterrupt: async (u,
|
|
4595
|
-
|
|
4615
|
+
clearThread: A,
|
|
4616
|
+
respondToInterrupt: async (u, N, _) => {
|
|
4617
|
+
G.current && await G.current(u, N, _);
|
|
4596
4618
|
},
|
|
4597
4619
|
messagePreviews: y.messagePreviews,
|
|
4598
|
-
handleValuesEvent:
|
|
4599
|
-
markSkipNextLoad:
|
|
4600
|
-
markStreamPendingThread:
|
|
4601
|
-
resetHistoryState:
|
|
4602
|
-
pushUser:
|
|
4620
|
+
handleValuesEvent: F,
|
|
4621
|
+
markSkipNextLoad: $,
|
|
4622
|
+
markStreamPendingThread: B,
|
|
4623
|
+
resetHistoryState: D,
|
|
4624
|
+
pushUser: oe,
|
|
4603
4625
|
onEvent: g,
|
|
4604
|
-
artifacts:
|
|
4626
|
+
artifacts: R
|
|
4605
4627
|
}),
|
|
4606
4628
|
[
|
|
4607
4629
|
l,
|
|
@@ -4611,36 +4633,36 @@ function Is({
|
|
|
4611
4633
|
c.lastCheckpointId,
|
|
4612
4634
|
c.lastCheckpointNs,
|
|
4613
4635
|
c.values,
|
|
4614
|
-
|
|
4636
|
+
k,
|
|
4615
4637
|
m,
|
|
4616
4638
|
y,
|
|
4617
|
-
|
|
4639
|
+
X,
|
|
4618
4640
|
I,
|
|
4619
|
-
A,
|
|
4620
|
-
x,
|
|
4621
|
-
d,
|
|
4622
4641
|
S,
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4642
|
+
C,
|
|
4643
|
+
d,
|
|
4644
|
+
A,
|
|
4645
|
+
z,
|
|
4646
|
+
w,
|
|
4647
|
+
v,
|
|
4627
4648
|
L,
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4649
|
+
F,
|
|
4650
|
+
$,
|
|
4651
|
+
B,
|
|
4652
|
+
oe,
|
|
4631
4653
|
g,
|
|
4632
|
-
|
|
4654
|
+
R
|
|
4633
4655
|
]
|
|
4634
|
-
),
|
|
4656
|
+
), K = de(
|
|
4635
4657
|
() => ({
|
|
4636
4658
|
registerClearThread: J,
|
|
4637
4659
|
registerRespondToInterrupt: Q
|
|
4638
4660
|
}),
|
|
4639
4661
|
[J, Q]
|
|
4640
4662
|
);
|
|
4641
|
-
return /* @__PURE__ */ Ce(
|
|
4663
|
+
return /* @__PURE__ */ Ce(An.Provider, { value: K, children: /* @__PURE__ */ Ce(Tn.Provider, { value: V, children: e }) });
|
|
4642
4664
|
}
|
|
4643
|
-
const
|
|
4665
|
+
const xn = We(null), Ts = We(!1);
|
|
4644
4666
|
function As({
|
|
4645
4667
|
children: e,
|
|
4646
4668
|
onError: t,
|
|
@@ -4653,26 +4675,26 @@ function As({
|
|
|
4653
4675
|
onFinish: f,
|
|
4654
4676
|
onStreamingChange: l
|
|
4655
4677
|
}) {
|
|
4656
|
-
const { chatApi: c, baseUrl: d } =
|
|
4678
|
+
const { chatApi: c, baseUrl: d } = qe(), g = d, h = _e(t), k = _e(n), m = _e(r), y = _e(s), I = _e(o), S = _e(a), C = _e(i), L = _e(f), z = _e(l), w = de(
|
|
4657
4679
|
() => ({
|
|
4658
4680
|
onError: h,
|
|
4659
|
-
onAuthError:
|
|
4681
|
+
onAuthError: k,
|
|
4660
4682
|
onConnectionError: m,
|
|
4661
|
-
onMetadataEvent:
|
|
4662
|
-
onCustomEvent:
|
|
4683
|
+
onMetadataEvent: C,
|
|
4684
|
+
onCustomEvent: S,
|
|
4663
4685
|
onUpdateEvent: I,
|
|
4664
4686
|
onToolEnd: y,
|
|
4665
|
-
onFinish:
|
|
4687
|
+
onFinish: L
|
|
4666
4688
|
}),
|
|
4667
4689
|
[
|
|
4668
4690
|
h,
|
|
4669
|
-
|
|
4691
|
+
k,
|
|
4670
4692
|
m,
|
|
4671
|
-
|
|
4672
|
-
|
|
4693
|
+
C,
|
|
4694
|
+
S,
|
|
4673
4695
|
I,
|
|
4674
4696
|
y,
|
|
4675
|
-
|
|
4697
|
+
L
|
|
4676
4698
|
]
|
|
4677
4699
|
);
|
|
4678
4700
|
return /* @__PURE__ */ Ce(Ts.Provider, { value: !0, children: /* @__PURE__ */ Ce(
|
|
@@ -4680,8 +4702,8 @@ function As({
|
|
|
4680
4702
|
{
|
|
4681
4703
|
api: c,
|
|
4682
4704
|
streamBaseUrl: g,
|
|
4683
|
-
handlers:
|
|
4684
|
-
onStreamingChange:
|
|
4705
|
+
handlers: w,
|
|
4706
|
+
onStreamingChange: z,
|
|
4685
4707
|
children: e
|
|
4686
4708
|
}
|
|
4687
4709
|
) });
|
|
@@ -4693,160 +4715,160 @@ function Ss({
|
|
|
4693
4715
|
handlers: r,
|
|
4694
4716
|
onStreamingChange: s
|
|
4695
4717
|
}) {
|
|
4696
|
-
const { setCurrentThreadId: o, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: f } =
|
|
4718
|
+
const { setCurrentThreadId: o, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: f } = rt(), {
|
|
4697
4719
|
interrupt: l,
|
|
4698
4720
|
checkpoint: c,
|
|
4699
4721
|
timelineCheckpoints: d,
|
|
4700
4722
|
handleValuesEvent: g,
|
|
4701
4723
|
markSkipNextLoad: h,
|
|
4702
|
-
markStreamPendingThread:
|
|
4724
|
+
markStreamPendingThread: k,
|
|
4703
4725
|
resetHistoryState: m,
|
|
4704
4726
|
pushUser: y,
|
|
4705
4727
|
onEvent: I,
|
|
4706
|
-
messages:
|
|
4707
|
-
} =
|
|
4728
|
+
messages: S
|
|
4729
|
+
} = Sn(), { registerClearThread: C, registerRespondToInterrupt: L } = Is(), z = E(
|
|
4708
4730
|
(u) => {
|
|
4709
|
-
i(u),
|
|
4731
|
+
i(u), k(u.threadId), a.current !== u.threadId && ((u.created ?? !a.current) && h(u.threadId), o(u.threadId));
|
|
4710
4732
|
},
|
|
4711
|
-
[i, h,
|
|
4712
|
-
),
|
|
4733
|
+
[i, h, k, o, a]
|
|
4734
|
+
), w = Zr({
|
|
4713
4735
|
baseUrl: n,
|
|
4714
4736
|
onEvent: I,
|
|
4715
4737
|
onError: (u) => {
|
|
4716
|
-
var
|
|
4717
|
-
(
|
|
4738
|
+
var N;
|
|
4739
|
+
(N = r.onError) == null || N.call(r, (u == null ? void 0 : u.message) ?? String(u));
|
|
4718
4740
|
},
|
|
4719
4741
|
onAuthError: r.onAuthError,
|
|
4720
4742
|
onConnectionError: r.onConnectionError,
|
|
4721
4743
|
onFinish: r.onFinish,
|
|
4722
|
-
onThreadInfo:
|
|
4744
|
+
onThreadInfo: z,
|
|
4723
4745
|
onMetadataEvent: r.onMetadataEvent,
|
|
4724
4746
|
onCustomEvent: r.onCustomEvent,
|
|
4725
4747
|
onUpdateEvent: r.onUpdateEvent,
|
|
4726
4748
|
onToolEnd: r.onToolEnd,
|
|
4727
4749
|
handleValuesEvent: g
|
|
4728
4750
|
});
|
|
4729
|
-
|
|
4730
|
-
s == null || s(
|
|
4731
|
-
}, [
|
|
4732
|
-
const { stream:
|
|
4733
|
-
|
|
4734
|
-
f !== void 0 &&
|
|
4735
|
-
}, [f,
|
|
4751
|
+
se(() => {
|
|
4752
|
+
s == null || s(w.isStreaming);
|
|
4753
|
+
}, [w.isStreaming, s]);
|
|
4754
|
+
const { stream: v, stop: F, clear: $, isStreaming: B, error: D, connected: P, streamedMessages: J, activeMessageId: G } = w;
|
|
4755
|
+
se(() => {
|
|
4756
|
+
f !== void 0 && $();
|
|
4757
|
+
}, [f, $]);
|
|
4736
4758
|
const Q = E(
|
|
4737
|
-
async (u,
|
|
4738
|
-
await
|
|
4759
|
+
async (u, N) => {
|
|
4760
|
+
await v(u, N);
|
|
4739
4761
|
},
|
|
4740
|
-
[
|
|
4741
|
-
),
|
|
4742
|
-
|
|
4743
|
-
|
|
4762
|
+
[v]
|
|
4763
|
+
), X = H(c);
|
|
4764
|
+
se(() => {
|
|
4765
|
+
X.current = c;
|
|
4744
4766
|
}, [c]);
|
|
4745
|
-
const
|
|
4746
|
-
async (u,
|
|
4747
|
-
const
|
|
4748
|
-
if (!
|
|
4767
|
+
const oe = E(
|
|
4768
|
+
async (u, N, _) => {
|
|
4769
|
+
const T = a.current;
|
|
4770
|
+
if (!T)
|
|
4749
4771
|
throw new Error("No active thread to handle interrupt");
|
|
4750
|
-
const
|
|
4751
|
-
threadId:
|
|
4752
|
-
checkpointId:
|
|
4772
|
+
const p = u ? N ?? !0 : !1, M = X.current, x = (_ == null ? void 0 : _.checkpointId) ?? M.id ?? void 0, q = (_ == null ? void 0 : _.checkpointNs) ?? M.namespace ?? void 0, U = {
|
|
4773
|
+
threadId: T,
|
|
4774
|
+
checkpointId: x,
|
|
4753
4775
|
checkpointNs: q,
|
|
4754
|
-
command: { kind: "resume", value:
|
|
4755
|
-
payload:
|
|
4776
|
+
command: { kind: "resume", value: p },
|
|
4777
|
+
payload: _ == null ? void 0 : _.payload
|
|
4756
4778
|
};
|
|
4757
|
-
Q(
|
|
4779
|
+
Q(U);
|
|
4758
4780
|
},
|
|
4759
4781
|
[a, Q]
|
|
4760
4782
|
);
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
}, [
|
|
4764
|
-
const
|
|
4765
|
-
|
|
4766
|
-
}, [
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
}, [
|
|
4770
|
-
const
|
|
4771
|
-
async (u,
|
|
4772
|
-
|
|
4773
|
-
let
|
|
4774
|
-
const
|
|
4775
|
-
q && delete
|
|
4776
|
-
const
|
|
4777
|
-
if (!
|
|
4778
|
-
if (!
|
|
4779
|
-
const Ae = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"),
|
|
4780
|
-
|
|
4783
|
+
se(() => {
|
|
4784
|
+
L(oe);
|
|
4785
|
+
}, [oe, L]);
|
|
4786
|
+
const A = E(async () => {
|
|
4787
|
+
F(), $(), m(), o(null);
|
|
4788
|
+
}, [$, m, o, F]);
|
|
4789
|
+
se(() => {
|
|
4790
|
+
C(A);
|
|
4791
|
+
}, [A, C]);
|
|
4792
|
+
const R = E(
|
|
4793
|
+
async (u, N) => {
|
|
4794
|
+
B && F();
|
|
4795
|
+
let _ = a.current;
|
|
4796
|
+
const T = (u == null ? void 0 : u.text) ?? "", p = (u == null ? void 0 : u.attachments) ?? [], M = (T == null ? void 0 : T.trim()) ?? "", x = { ...(u == null ? void 0 : u.payload) ?? {} }, q = Array.isArray(x.messages) ? x.messages : void 0;
|
|
4797
|
+
q && delete x.messages;
|
|
4798
|
+
const U = !!(q && q.length), ne = !!(u.contentParts && u.contentParts.length > 0);
|
|
4799
|
+
if (!_ && !M && p.length === 0 && !U && !ne) return;
|
|
4800
|
+
if (!_) {
|
|
4801
|
+
const Ae = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), Ve = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
|
|
4802
|
+
_ = `${Ae}${Ve}`, h(_), o(_);
|
|
4781
4803
|
}
|
|
4782
|
-
let
|
|
4783
|
-
u.contentParts && u.contentParts.length > 0 && (
|
|
4784
|
-
const { contentParts:
|
|
4785
|
-
|
|
4786
|
-
const
|
|
4787
|
-
let
|
|
4788
|
-
if (
|
|
4789
|
-
const Ae =
|
|
4790
|
-
|
|
4804
|
+
let ee = null;
|
|
4805
|
+
u.contentParts && u.contentParts.length > 0 && (ee = u.contentParts);
|
|
4806
|
+
const { contentParts: Y, filesInfo: j } = ee ? { contentParts: ee, filesInfo: [] } : await Vr(p), re = [...Y];
|
|
4807
|
+
M && re.push({ type: "text", text: T });
|
|
4808
|
+
const be = u == null ? void 0 : u.originalMessageId, ve = !!(u != null && u.edit && be), Je = !U && re.length > 0;
|
|
4809
|
+
let fe = null;
|
|
4810
|
+
if (Je) {
|
|
4811
|
+
const Ae = ve ? be : `msg-${Date.now()}`;
|
|
4812
|
+
fe = bn({
|
|
4791
4813
|
id: Ae,
|
|
4792
4814
|
role: "user",
|
|
4793
|
-
content:
|
|
4815
|
+
content: re,
|
|
4794
4816
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4795
|
-
}, "user"),
|
|
4817
|
+
}, "user"), ve ? y(fe, { editingMessageId: be }) : y(fe);
|
|
4796
4818
|
}
|
|
4797
|
-
const
|
|
4798
|
-
...
|
|
4799
|
-
...
|
|
4819
|
+
const Fe = U ? q : fe ? [fe] : [], je = {
|
|
4820
|
+
...x,
|
|
4821
|
+
...j.length ? { files_info: j } : {}
|
|
4800
4822
|
};
|
|
4801
|
-
|
|
4823
|
+
Fe.length ? je.messages = Fe : "messages" in je || (je.messages = []);
|
|
4802
4824
|
const Xe = (u == null ? void 0 : u.checkpointId) ?? c.id ?? void 0;
|
|
4803
4825
|
if (u != null && u.edit && !Xe)
|
|
4804
4826
|
throw new Error(
|
|
4805
|
-
`[streaming] Missing checkpointId for edit submit. threadId=${
|
|
4827
|
+
`[streaming] Missing checkpointId for edit submit. threadId=${_ ?? "null"}`
|
|
4806
4828
|
);
|
|
4807
4829
|
const Te = {
|
|
4808
|
-
threadId:
|
|
4830
|
+
threadId: _,
|
|
4809
4831
|
content: u == null ? void 0 : u.text,
|
|
4810
|
-
payload:
|
|
4832
|
+
payload: je,
|
|
4811
4833
|
config: u == null ? void 0 : u.config,
|
|
4812
4834
|
checkpointId: Xe,
|
|
4813
4835
|
command: u == null ? void 0 : u.command,
|
|
4814
4836
|
edit: u == null ? void 0 : u.edit
|
|
4815
4837
|
};
|
|
4816
|
-
return Q(Te,
|
|
4838
|
+
return Q(Te, N);
|
|
4817
4839
|
},
|
|
4818
|
-
[c, a,
|
|
4819
|
-
),
|
|
4840
|
+
[c, a, B, h, y, Q, F, d]
|
|
4841
|
+
), V = de(() => {
|
|
4820
4842
|
const u = Object.keys(J).length > 0;
|
|
4821
|
-
if (!
|
|
4822
|
-
return
|
|
4823
|
-
const
|
|
4824
|
-
return
|
|
4825
|
-
|
|
4826
|
-
}), Array.from(
|
|
4827
|
-
}, [
|
|
4843
|
+
if (!B && !u)
|
|
4844
|
+
return S;
|
|
4845
|
+
const N = /* @__PURE__ */ new Map();
|
|
4846
|
+
return S.forEach((_) => N.set(_.id, _)), Object.values(J).forEach((_) => {
|
|
4847
|
+
N.set(_.id, _);
|
|
4848
|
+
}), Array.from(N.values());
|
|
4849
|
+
}, [B, J, S]), K = de(
|
|
4828
4850
|
() => ({
|
|
4829
|
-
isStreaming:
|
|
4830
|
-
error:
|
|
4831
|
-
connectionState:
|
|
4832
|
-
messages:
|
|
4833
|
-
activeMessageId:
|
|
4834
|
-
submit:
|
|
4835
|
-
stop:
|
|
4851
|
+
isStreaming: B,
|
|
4852
|
+
error: D,
|
|
4853
|
+
connectionState: D ? "error" : B ? P ? "connected" : "connecting" : "idle",
|
|
4854
|
+
messages: V,
|
|
4855
|
+
activeMessageId: G,
|
|
4856
|
+
submit: R,
|
|
4857
|
+
stop: F,
|
|
4836
4858
|
interrupt: l,
|
|
4837
4859
|
resume: () => Promise.resolve(),
|
|
4838
|
-
goto: (u,
|
|
4860
|
+
goto: (u, N) => Promise.resolve(),
|
|
4839
4861
|
clearError: () => {
|
|
4840
4862
|
}
|
|
4841
4863
|
// TODO: Implement error clearing
|
|
4842
4864
|
}),
|
|
4843
|
-
[
|
|
4865
|
+
[B, D, R, F, l, P, V]
|
|
4844
4866
|
);
|
|
4845
|
-
return /* @__PURE__ */ Ce(
|
|
4867
|
+
return /* @__PURE__ */ Ce(xn.Provider, { value: K, children: e });
|
|
4846
4868
|
}
|
|
4847
4869
|
function _e(e) {
|
|
4848
|
-
const t =
|
|
4849
|
-
return
|
|
4870
|
+
const t = H(e);
|
|
4871
|
+
return se(() => {
|
|
4850
4872
|
t.current = e;
|
|
4851
4873
|
}, [e]), E((...n) => {
|
|
4852
4874
|
const r = t.current;
|
|
@@ -4855,16 +4877,16 @@ function _e(e) {
|
|
|
4855
4877
|
}, []);
|
|
4856
4878
|
}
|
|
4857
4879
|
function xs() {
|
|
4858
|
-
const e =
|
|
4880
|
+
const e = ot(xn);
|
|
4859
4881
|
if (!e) throw new Error("useStream must be used within StreamingProvider");
|
|
4860
4882
|
return e;
|
|
4861
4883
|
}
|
|
4862
|
-
function
|
|
4884
|
+
function Zt(e) {
|
|
4863
4885
|
return typeof e == "object" && e !== null;
|
|
4864
4886
|
}
|
|
4865
4887
|
function Cs(e, t) {
|
|
4866
4888
|
if (Object.is(e, t)) return !0;
|
|
4867
|
-
if (!
|
|
4889
|
+
if (!Zt(e) || !Zt(t)) return !1;
|
|
4868
4890
|
const n = Object.keys(e), r = Object.keys(t);
|
|
4869
4891
|
if (n.length !== r.length)
|
|
4870
4892
|
return !1;
|
|
@@ -4874,7 +4896,7 @@ function Cs(e, t) {
|
|
|
4874
4896
|
return !0;
|
|
4875
4897
|
}
|
|
4876
4898
|
function Ms(e) {
|
|
4877
|
-
const t =
|
|
4899
|
+
const t = H(e), n = H(e);
|
|
4878
4900
|
return Cs(t.current, e) || (t.current = e, n.current = e), n.current;
|
|
4879
4901
|
}
|
|
4880
4902
|
function Es(e) {
|
|
@@ -4903,49 +4925,49 @@ function Ys({
|
|
|
4903
4925
|
onUpdateEvent: d,
|
|
4904
4926
|
onCustomEvent: g,
|
|
4905
4927
|
onMetadataEvent: h,
|
|
4906
|
-
onFinish:
|
|
4928
|
+
onFinish: k
|
|
4907
4929
|
}) {
|
|
4908
|
-
const m = Ms(t), [y, I] =
|
|
4930
|
+
const m = Ms(t), [y, I] = W(!1), S = Le(i), C = Le(f), L = Le(a), z = Le(l), w = Le(c), v = Le(d), F = Le(g), $ = Le(h), B = Le(k), D = de(
|
|
4909
4931
|
() => ({
|
|
4910
|
-
onError:
|
|
4911
|
-
onAuthError:
|
|
4912
|
-
onConnectionError:
|
|
4913
|
-
onToolEnd:
|
|
4914
|
-
onUpdateEvent:
|
|
4915
|
-
onCustomEvent:
|
|
4916
|
-
onMetadataEvent:
|
|
4917
|
-
onFinish:
|
|
4932
|
+
onError: S,
|
|
4933
|
+
onAuthError: C,
|
|
4934
|
+
onConnectionError: L,
|
|
4935
|
+
onToolEnd: w,
|
|
4936
|
+
onUpdateEvent: v,
|
|
4937
|
+
onCustomEvent: F,
|
|
4938
|
+
onMetadataEvent: $,
|
|
4939
|
+
onFinish: B
|
|
4918
4940
|
}),
|
|
4919
4941
|
[
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
N,
|
|
4923
|
-
k,
|
|
4924
|
-
T,
|
|
4942
|
+
S,
|
|
4943
|
+
C,
|
|
4925
4944
|
L,
|
|
4926
|
-
|
|
4927
|
-
|
|
4945
|
+
w,
|
|
4946
|
+
v,
|
|
4947
|
+
F,
|
|
4948
|
+
$,
|
|
4949
|
+
B
|
|
4928
4950
|
]
|
|
4929
4951
|
);
|
|
4930
|
-
return /* @__PURE__ */ Ce(
|
|
4952
|
+
return /* @__PURE__ */ Ce(Br, { apiConfig: m, children: /* @__PURE__ */ Ce(
|
|
4931
4953
|
rs,
|
|
4932
4954
|
{
|
|
4933
4955
|
initialThreadId: n,
|
|
4934
|
-
onError:
|
|
4935
|
-
onThreadChange:
|
|
4956
|
+
onError: S,
|
|
4957
|
+
onThreadChange: z,
|
|
4936
4958
|
children: /* @__PURE__ */ Ce(
|
|
4937
|
-
|
|
4959
|
+
vs,
|
|
4938
4960
|
{
|
|
4939
4961
|
initialThreadId: n,
|
|
4940
4962
|
initialCheckpointId: r,
|
|
4941
4963
|
initialCheckpointNs: s,
|
|
4942
4964
|
autoLoadInitial: o,
|
|
4943
|
-
onError:
|
|
4965
|
+
onError: S,
|
|
4944
4966
|
isStreaming: y,
|
|
4945
4967
|
children: /* @__PURE__ */ Ce(
|
|
4946
4968
|
As,
|
|
4947
4969
|
{
|
|
4948
|
-
|
|
4970
|
+
...D,
|
|
4949
4971
|
onStreamingChange: I,
|
|
4950
4972
|
children: e
|
|
4951
4973
|
}
|
|
@@ -4956,7 +4978,7 @@ function Ys({
|
|
|
4956
4978
|
) });
|
|
4957
4979
|
}
|
|
4958
4980
|
function Le(e) {
|
|
4959
|
-
const t =
|
|
4981
|
+
const t = H(e);
|
|
4960
4982
|
return t.current = e, E((...n) => {
|
|
4961
4983
|
const r = t.current;
|
|
4962
4984
|
if (r)
|
|
@@ -4964,20 +4986,20 @@ function Le(e) {
|
|
|
4964
4986
|
}, []);
|
|
4965
4987
|
}
|
|
4966
4988
|
const Ps = 1, Rs = 1e6;
|
|
4967
|
-
let
|
|
4989
|
+
let Et = 0;
|
|
4968
4990
|
function Ns() {
|
|
4969
|
-
return
|
|
4991
|
+
return Et = (Et + 1) % Number.MAX_SAFE_INTEGER, Et.toString();
|
|
4970
4992
|
}
|
|
4971
|
-
const
|
|
4972
|
-
if (
|
|
4993
|
+
const Pt = /* @__PURE__ */ new Map(), en = (e) => {
|
|
4994
|
+
if (Pt.has(e))
|
|
4973
4995
|
return;
|
|
4974
4996
|
const t = setTimeout(() => {
|
|
4975
|
-
|
|
4997
|
+
Pt.delete(e), st({
|
|
4976
4998
|
type: "REMOVE_TOAST",
|
|
4977
4999
|
toastId: e
|
|
4978
5000
|
});
|
|
4979
5001
|
}, Rs);
|
|
4980
|
-
|
|
5002
|
+
Pt.set(e, t);
|
|
4981
5003
|
}, _s = (e, t) => {
|
|
4982
5004
|
switch (t.type) {
|
|
4983
5005
|
case "ADD_TOAST":
|
|
@@ -4994,8 +5016,8 @@ const Rt = /* @__PURE__ */ new Map(), tn = (e) => {
|
|
|
4994
5016
|
};
|
|
4995
5017
|
case "DISMISS_TOAST": {
|
|
4996
5018
|
const { toastId: n } = t;
|
|
4997
|
-
return n ?
|
|
4998
|
-
|
|
5019
|
+
return n ? en(n) : e.toasts.forEach((r) => {
|
|
5020
|
+
en(r.id);
|
|
4999
5021
|
}), {
|
|
5000
5022
|
...e,
|
|
5001
5023
|
toasts: e.toasts.map(
|
|
@@ -5017,17 +5039,17 @@ const Rt = /* @__PURE__ */ new Map(), tn = (e) => {
|
|
|
5017
5039
|
}
|
|
5018
5040
|
}, mt = [];
|
|
5019
5041
|
let ht = { toasts: [] };
|
|
5020
|
-
function
|
|
5042
|
+
function st(e) {
|
|
5021
5043
|
ht = _s(ht, e), mt.forEach((t) => {
|
|
5022
5044
|
t(ht);
|
|
5023
5045
|
});
|
|
5024
5046
|
}
|
|
5025
5047
|
function Ls({ ...e }) {
|
|
5026
|
-
const t = Ns(), n = (s) =>
|
|
5048
|
+
const t = Ns(), n = (s) => st({
|
|
5027
5049
|
type: "UPDATE_TOAST",
|
|
5028
5050
|
toast: { ...s, id: t }
|
|
5029
|
-
}), r = () =>
|
|
5030
|
-
return
|
|
5051
|
+
}), r = () => st({ type: "DISMISS_TOAST", toastId: t });
|
|
5052
|
+
return st({
|
|
5031
5053
|
type: "ADD_TOAST",
|
|
5032
5054
|
toast: {
|
|
5033
5055
|
...e,
|
|
@@ -5044,76 +5066,76 @@ function Ls({ ...e }) {
|
|
|
5044
5066
|
};
|
|
5045
5067
|
}
|
|
5046
5068
|
function zs() {
|
|
5047
|
-
const [e, t] =
|
|
5048
|
-
return
|
|
5069
|
+
const [e, t] = Bt.useState(ht);
|
|
5070
|
+
return Bt.useEffect(() => (mt.push(t), () => {
|
|
5049
5071
|
const n = mt.indexOf(t);
|
|
5050
5072
|
n > -1 && mt.splice(n, 1);
|
|
5051
5073
|
}), [e]), {
|
|
5052
5074
|
...e,
|
|
5053
5075
|
toast: Ls,
|
|
5054
|
-
dismiss: (n) =>
|
|
5076
|
+
dismiss: (n) => st({ type: "DISMISS_TOAST", toastId: n })
|
|
5055
5077
|
};
|
|
5056
5078
|
}
|
|
5057
5079
|
function Zs(e) {
|
|
5058
|
-
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } =
|
|
5080
|
+
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = qe(), { toast: s } = zs(), [o, a] = W({}), [i, f] = W(null), [l, c] = W(!1), d = E(() => {
|
|
5059
5081
|
c(!1), f(null);
|
|
5060
|
-
}, []), g = E((
|
|
5061
|
-
f(
|
|
5082
|
+
}, []), g = E((k) => {
|
|
5083
|
+
f(k), c(!0);
|
|
5062
5084
|
}, []), h = E(
|
|
5063
|
-
async (
|
|
5064
|
-
var I,
|
|
5085
|
+
async (k, m, y) => {
|
|
5086
|
+
var I, S;
|
|
5065
5087
|
if (!t) {
|
|
5066
|
-
|
|
5088
|
+
k.preventDefault();
|
|
5067
5089
|
return;
|
|
5068
5090
|
}
|
|
5069
5091
|
if (o[y]) {
|
|
5070
|
-
|
|
5092
|
+
k.preventDefault();
|
|
5071
5093
|
return;
|
|
5072
5094
|
}
|
|
5073
5095
|
try {
|
|
5074
|
-
const
|
|
5075
|
-
if (
|
|
5076
|
-
|
|
5077
|
-
const
|
|
5078
|
-
g({ id:
|
|
5096
|
+
const C = String(m.url ?? ""), L = C.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
|
|
5097
|
+
if (L) {
|
|
5098
|
+
k.preventDefault();
|
|
5099
|
+
const z = L[1], w = m.name || `file_${z}`, v = m.mimeType || "application/octet-stream";
|
|
5100
|
+
g({ id: z, name: w, mimeType: v });
|
|
5079
5101
|
return;
|
|
5080
5102
|
}
|
|
5081
|
-
if (
|
|
5082
|
-
|
|
5083
|
-
const
|
|
5103
|
+
if (C.startsWith("data:")) {
|
|
5104
|
+
k.preventDefault(), a((w) => ({ ...w, [y]: !0 }));
|
|
5105
|
+
const z = s({ title: "Fetching file...", description: "", open: !0 });
|
|
5084
5106
|
try {
|
|
5085
|
-
const
|
|
5086
|
-
if (!
|
|
5107
|
+
const w = await r.listFiles(n ?? void 0);
|
|
5108
|
+
if (!w || !Array.isArray(w))
|
|
5087
5109
|
throw new Error("Invalid file list response");
|
|
5088
|
-
const
|
|
5089
|
-
if (!(
|
|
5110
|
+
const v = w.find((F) => !F || typeof F != "object" || !((F.filename ?? "") === (m.name ?? "")) ? !1 : typeof m.size == "number" && typeof F.size == "number" ? F.size === m.size : !0);
|
|
5111
|
+
if (!(v != null && v.id))
|
|
5090
5112
|
throw new Error(`File "${m.name}" is not yet available on the server`);
|
|
5091
|
-
if (!
|
|
5113
|
+
if (!v.id || !v.filename)
|
|
5092
5114
|
throw new Error("Invalid file data received from server");
|
|
5093
5115
|
g({
|
|
5094
|
-
id:
|
|
5095
|
-
name: m.name ||
|
|
5096
|
-
mimeType: m.mimeType ||
|
|
5097
|
-
}), (I =
|
|
5098
|
-
id:
|
|
5116
|
+
id: v.id,
|
|
5117
|
+
name: m.name || v.filename || `file_${v.id}`,
|
|
5118
|
+
mimeType: m.mimeType || v.mime_type || "application/octet-stream"
|
|
5119
|
+
}), (I = z.update) == null || I.call(z, {
|
|
5120
|
+
id: z.id,
|
|
5099
5121
|
title: "Success",
|
|
5100
5122
|
description: `Opened ${m.name}`,
|
|
5101
5123
|
open: !0
|
|
5102
5124
|
});
|
|
5103
|
-
} catch (
|
|
5104
|
-
console.error("Failed to fetch server file:",
|
|
5105
|
-
const
|
|
5106
|
-
(
|
|
5125
|
+
} catch (w) {
|
|
5126
|
+
console.error("Failed to fetch server file:", w);
|
|
5127
|
+
const v = w instanceof Error ? w.message : "Unknown error occurred";
|
|
5128
|
+
(S = z.update) == null || S.call(z, { id: z.id, title: "Failed", description: v }), s({
|
|
5107
5129
|
title: "Failed to fetch file",
|
|
5108
|
-
description:
|
|
5130
|
+
description: v,
|
|
5109
5131
|
open: !0
|
|
5110
5132
|
});
|
|
5111
5133
|
} finally {
|
|
5112
|
-
a((
|
|
5134
|
+
a((w) => ({ ...w, [y]: !1 }));
|
|
5113
5135
|
}
|
|
5114
5136
|
}
|
|
5115
|
-
} catch (
|
|
5116
|
-
console.error("File click error:",
|
|
5137
|
+
} catch (C) {
|
|
5138
|
+
console.error("File click error:", C), a((L) => ({ ...L, [y]: !1 }));
|
|
5117
5139
|
}
|
|
5118
5140
|
},
|
|
5119
5141
|
[t, o, s, n, g]
|
|
@@ -5127,32 +5149,32 @@ function Zs(e) {
|
|
|
5127
5149
|
};
|
|
5128
5150
|
}
|
|
5129
5151
|
function eo(e) {
|
|
5130
|
-
return
|
|
5152
|
+
return de(() => {
|
|
5131
5153
|
const t = e;
|
|
5132
5154
|
let n = Array.isArray(t.content) ? t.content : [];
|
|
5133
5155
|
return typeof t.content == "string" && (n = [{ type: "text", text: t.content }]), {
|
|
5134
5156
|
contentParts: n,
|
|
5135
|
-
textContent:
|
|
5136
|
-
toolMeta:
|
|
5157
|
+
textContent: Kr(n),
|
|
5158
|
+
toolMeta: Hr(t),
|
|
5137
5159
|
imageParts: n.filter((r) => r.type === "image_url"),
|
|
5138
5160
|
fileParts: n.filter((r) => r.type === "file"),
|
|
5139
|
-
toolRaw:
|
|
5161
|
+
toolRaw: Sr(n),
|
|
5140
5162
|
isToolStreaming: !!t.toolStreaming
|
|
5141
5163
|
};
|
|
5142
5164
|
}, [e]);
|
|
5143
5165
|
}
|
|
5144
|
-
const
|
|
5166
|
+
const tn = "data:";
|
|
5145
5167
|
function Us(e) {
|
|
5146
5168
|
if (!e) return [];
|
|
5147
5169
|
const t = [], n = e.split(/\r?\n/);
|
|
5148
5170
|
for (const r of n) {
|
|
5149
5171
|
const s = r.trim();
|
|
5150
|
-
if (!s || !s.startsWith(
|
|
5172
|
+
if (!s || !s.startsWith(tn))
|
|
5151
5173
|
continue;
|
|
5152
|
-
const o = s.slice(
|
|
5174
|
+
const o = s.slice(tn.length).trim();
|
|
5153
5175
|
if (!o || o.toLowerCase() === "[done]")
|
|
5154
5176
|
continue;
|
|
5155
|
-
const a =
|
|
5177
|
+
const a = zt(o);
|
|
5156
5178
|
a && typeof a == "object" && t.push(a);
|
|
5157
5179
|
}
|
|
5158
5180
|
return t;
|
|
@@ -5166,7 +5188,7 @@ function Fs(e) {
|
|
|
5166
5188
|
return null;
|
|
5167
5189
|
}
|
|
5168
5190
|
function to(e) {
|
|
5169
|
-
return
|
|
5191
|
+
return de(() => {
|
|
5170
5192
|
const t = e.content.filter(
|
|
5171
5193
|
(f) => f.type === "text"
|
|
5172
5194
|
);
|
|
@@ -5177,7 +5199,7 @@ function to(e) {
|
|
|
5177
5199
|
);
|
|
5178
5200
|
if (!r.length) {
|
|
5179
5201
|
const f = t.map((c) => c.text ?? "").join(`
|
|
5180
|
-
`), l =
|
|
5202
|
+
`), l = zt(f);
|
|
5181
5203
|
l && typeof l == "object" && (r = [l]);
|
|
5182
5204
|
}
|
|
5183
5205
|
if (!r.length)
|
|
@@ -5199,36 +5221,36 @@ function to(e) {
|
|
|
5199
5221
|
}, [e]);
|
|
5200
5222
|
}
|
|
5201
5223
|
function js(e) {
|
|
5202
|
-
var
|
|
5203
|
-
const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, { currentThreadId: n, setCurrentThreadId: r, actions: s } =
|
|
5204
|
-
l(
|
|
5224
|
+
var z;
|
|
5225
|
+
const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, { currentThreadId: n, setCurrentThreadId: r, actions: s } = rt(), o = Sn({ optional: !0 }), a = xs(), i = !!t && t !== n, [f, l] = W([]), c = E((w) => {
|
|
5226
|
+
l(w);
|
|
5205
5227
|
}, []), {
|
|
5206
5228
|
isLoadingThread: d,
|
|
5207
5229
|
threadStateError: g,
|
|
5208
5230
|
threadCheckpoints: h
|
|
5209
|
-
} =
|
|
5210
|
-
api:
|
|
5211
|
-
fileApi:
|
|
5231
|
+
} = vn({
|
|
5232
|
+
api: qe().chatApi,
|
|
5233
|
+
fileApi: qe().fileApi,
|
|
5212
5234
|
seed: c,
|
|
5213
5235
|
currentThreadId: i ? t : null,
|
|
5214
5236
|
initialThreadId: i ? t : null,
|
|
5215
5237
|
isStreaming: !1,
|
|
5216
5238
|
getMessages: () => f,
|
|
5217
5239
|
autoLoadInitial: !0
|
|
5218
|
-
}),
|
|
5219
|
-
var
|
|
5220
|
-
return ((
|
|
5221
|
-
}, [h]), m = t || n, y = i ? f : (a == null ? void 0 : a.messages) || [], I = i ? d : (o == null ? void 0 : o.isLoading) || !1,
|
|
5240
|
+
}), k = de(() => {
|
|
5241
|
+
var w;
|
|
5242
|
+
return ((w = h[0]) == null ? void 0 : w.values) || {};
|
|
5243
|
+
}, [h]), m = t || n, y = i ? f : (a == null ? void 0 : a.messages) || [], I = i ? d : (o == null ? void 0 : o.isLoading) || !1, S = i ? k : (o == null ? void 0 : o.values) || {}, C = i ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, L = i ? g : (a == null ? void 0 : a.error) || (o == null ? void 0 : o.error) || null;
|
|
5222
5244
|
return {
|
|
5223
5245
|
// UNIFIED: Single thread ID concept
|
|
5224
5246
|
threadId: m,
|
|
5225
5247
|
messages: y,
|
|
5226
5248
|
isLoading: I,
|
|
5227
5249
|
isHistoryLoading: I,
|
|
5228
|
-
error:
|
|
5250
|
+
error: L,
|
|
5229
5251
|
// Values & Metadata
|
|
5230
|
-
values:
|
|
5231
|
-
taskMessagesByScope:
|
|
5252
|
+
values: S,
|
|
5253
|
+
taskMessagesByScope: C,
|
|
5232
5254
|
metadata: o == null ? void 0 : o.metadata,
|
|
5233
5255
|
// Actions & State relating to Global/Active Thread only
|
|
5234
5256
|
navigateToCheckpoint: (o == null ? void 0 : o.navigateToCheckpoint) || (async () => {
|
|
@@ -5246,7 +5268,7 @@ function js(e) {
|
|
|
5246
5268
|
isStreaming: (a == null ? void 0 : a.isStreaming) || !1,
|
|
5247
5269
|
activeMessageId: (a == null ? void 0 : a.activeMessageId) || null,
|
|
5248
5270
|
connectionState: (a == null ? void 0 : a.connectionState) || "disconnected",
|
|
5249
|
-
streamingAssistantId: a != null && a.isStreaming && ((
|
|
5271
|
+
streamingAssistantId: a != null && a.isStreaming && ((z = o == null ? void 0 : o.metadata) != null && z.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
|
|
5250
5272
|
// Actions
|
|
5251
5273
|
submit: (a == null ? void 0 : a.submit) || (async () => {
|
|
5252
5274
|
}),
|
|
@@ -5260,8 +5282,8 @@ function js(e) {
|
|
|
5260
5282
|
deleteThread: s.deleteThread,
|
|
5261
5283
|
renameThread: s.renameThread,
|
|
5262
5284
|
shareThread: s.shareThread,
|
|
5263
|
-
threads:
|
|
5264
|
-
isThreadsLoading:
|
|
5285
|
+
threads: rt().threads,
|
|
5286
|
+
isThreadsLoading: rt().isLoading
|
|
5265
5287
|
};
|
|
5266
5288
|
}
|
|
5267
5289
|
function no({
|
|
@@ -5280,78 +5302,78 @@ function no({
|
|
|
5280
5302
|
threadId: g,
|
|
5281
5303
|
clearComposerOnSend: h = !0
|
|
5282
5304
|
}) {
|
|
5283
|
-
const { messages:
|
|
5284
|
-
|
|
5305
|
+
const { messages: k } = js(), [m, y] = W(null), [I, S] = W(""), [C, L] = W(null), [z, w] = W(null), [v, F] = W(!1), [$, B] = W(""), D = H($), P = H(null);
|
|
5306
|
+
se(() => {
|
|
5285
5307
|
if (!m)
|
|
5286
5308
|
if (g) {
|
|
5287
5309
|
const u = localStorage.getItem(Mt(g));
|
|
5288
|
-
|
|
5310
|
+
B(u || "");
|
|
5289
5311
|
} else
|
|
5290
|
-
|
|
5312
|
+
B("");
|
|
5291
5313
|
}, [g, m]);
|
|
5292
5314
|
const J = E((u) => {
|
|
5293
|
-
|
|
5315
|
+
B(u), !m && g && localStorage.setItem(Mt(g), u);
|
|
5294
5316
|
}, [g, m]);
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
}, [
|
|
5317
|
+
se(() => {
|
|
5318
|
+
D.current = $;
|
|
5319
|
+
}, [$]), se(() => {
|
|
5298
5320
|
if (!m) {
|
|
5299
|
-
|
|
5321
|
+
P.current = null;
|
|
5300
5322
|
return;
|
|
5301
5323
|
}
|
|
5302
|
-
|
|
5324
|
+
P.current === null && (P.current = D.current), J(I ?? "");
|
|
5303
5325
|
}, [I, m, J]);
|
|
5304
|
-
const
|
|
5326
|
+
const G = E(
|
|
5305
5327
|
(u) => {
|
|
5306
5328
|
J(u);
|
|
5307
5329
|
},
|
|
5308
5330
|
[J]
|
|
5309
|
-
), Q = async (u,
|
|
5310
|
-
const
|
|
5311
|
-
if (!(!
|
|
5331
|
+
), Q = async (u, N) => {
|
|
5332
|
+
const _ = Array.isArray(N) ? { files: N } : N ?? {}, T = _.files ?? [], p = _.contentParts ?? [], M = u.trim();
|
|
5333
|
+
if (!(!M && T.length === 0 && p.length === 0))
|
|
5312
5334
|
try {
|
|
5313
|
-
const
|
|
5335
|
+
const x = T.map(async (j) => {
|
|
5314
5336
|
try {
|
|
5315
|
-
const
|
|
5316
|
-
return { file:
|
|
5317
|
-
} catch (
|
|
5318
|
-
throw console.error("Failed to upload file",
|
|
5337
|
+
const re = await hn.uploadFile(j);
|
|
5338
|
+
return { file: j, record: re };
|
|
5339
|
+
} catch (re) {
|
|
5340
|
+
throw console.error("Failed to upload file", j.name, re), new Error(`Failed to upload ${j.name}`);
|
|
5319
5341
|
}
|
|
5320
|
-
}),
|
|
5321
|
-
const
|
|
5322
|
-
return
|
|
5342
|
+
}), U = (await Promise.all(x)).map(({ record: j }) => {
|
|
5343
|
+
const re = j.mime_type;
|
|
5344
|
+
return re.startsWith("image/") ? {
|
|
5323
5345
|
type: "image_url",
|
|
5324
|
-
image_url: { url:
|
|
5346
|
+
image_url: { url: j.content_url }
|
|
5325
5347
|
} : {
|
|
5326
5348
|
type: "file",
|
|
5327
|
-
url:
|
|
5328
|
-
mimeType:
|
|
5329
|
-
name:
|
|
5330
|
-
size:
|
|
5349
|
+
url: j.content_url,
|
|
5350
|
+
mimeType: re,
|
|
5351
|
+
name: j.filename,
|
|
5352
|
+
size: j.size
|
|
5331
5353
|
};
|
|
5332
|
-
}),
|
|
5354
|
+
}), ne = [...p, ...U], ee = m ? (C == null ? void 0 : C.checkpointId) ?? n ?? void 0 : n ?? void 0, Y = m ? (C == null ? void 0 : C.checkpointNs) ?? r ?? void 0 : r ?? void 0;
|
|
5333
5355
|
await e(
|
|
5334
5356
|
{
|
|
5335
|
-
text:
|
|
5336
|
-
contentParts:
|
|
5337
|
-
attachments:
|
|
5357
|
+
text: M || "",
|
|
5358
|
+
contentParts: ne,
|
|
5359
|
+
attachments: T,
|
|
5338
5360
|
payload: t.payload,
|
|
5339
5361
|
edit: !!m,
|
|
5340
|
-
checkpointId:
|
|
5341
|
-
checkpointNs:
|
|
5362
|
+
checkpointId: ee,
|
|
5363
|
+
checkpointNs: Y,
|
|
5342
5364
|
project: c ?? void 0,
|
|
5343
5365
|
originalMessageId: m ?? void 0,
|
|
5344
5366
|
config: t.config
|
|
5345
5367
|
},
|
|
5346
5368
|
d ? { onEvent: d } : void 0
|
|
5347
|
-
), s == null || s(
|
|
5348
|
-
} catch (
|
|
5349
|
-
const q = (
|
|
5350
|
-
|
|
5369
|
+
), s == null || s(M), l(!0), h && (g && localStorage.removeItem(Mt(g)), J("")), w(null), y(null), S(""), L(null);
|
|
5370
|
+
} catch (x) {
|
|
5371
|
+
const q = (x == null ? void 0 : x.message) || "Failed to send message";
|
|
5372
|
+
w(q), a == null || a(q), l(!1);
|
|
5351
5373
|
}
|
|
5352
|
-
},
|
|
5353
|
-
|
|
5354
|
-
},
|
|
5374
|
+
}, X = (u, N) => {
|
|
5375
|
+
N || Q(u, { files: [] });
|
|
5376
|
+
}, oe = E(
|
|
5355
5377
|
async (u) => {
|
|
5356
5378
|
await e(
|
|
5357
5379
|
{
|
|
@@ -5366,41 +5388,41 @@ function no({
|
|
|
5366
5388
|
), o == null || o({ file: u });
|
|
5367
5389
|
},
|
|
5368
5390
|
[n, r, t, o, e]
|
|
5369
|
-
),
|
|
5370
|
-
(u,
|
|
5371
|
-
i && (
|
|
5372
|
-
checkpointId: (
|
|
5373
|
-
checkpointNs: (
|
|
5374
|
-
}),
|
|
5391
|
+
), A = E(
|
|
5392
|
+
(u, N, _) => {
|
|
5393
|
+
i && (P.current = $, y(u), S(N), L({
|
|
5394
|
+
checkpointId: (_ == null ? void 0 : _.checkpointId) ?? null,
|
|
5395
|
+
checkpointNs: (_ == null ? void 0 : _.checkpointNs) ?? null
|
|
5396
|
+
}), w(null));
|
|
5375
5397
|
},
|
|
5376
|
-
[
|
|
5377
|
-
),
|
|
5378
|
-
y(null),
|
|
5379
|
-
const u =
|
|
5380
|
-
u !== null &&
|
|
5381
|
-
}, []),
|
|
5382
|
-
let
|
|
5383
|
-
for (let
|
|
5384
|
-
if (f[
|
|
5385
|
-
|
|
5398
|
+
[$, i]
|
|
5399
|
+
), R = E(() => {
|
|
5400
|
+
y(null), S(""), L(null), w(null);
|
|
5401
|
+
const u = P.current;
|
|
5402
|
+
u !== null && B(u), P.current = null;
|
|
5403
|
+
}, []), V = E((u) => {
|
|
5404
|
+
let N = null;
|
|
5405
|
+
for (let M = u - 1; M >= 0; M--)
|
|
5406
|
+
if (f[M].role === "user") {
|
|
5407
|
+
N = f[M];
|
|
5386
5408
|
break;
|
|
5387
5409
|
}
|
|
5388
|
-
if (!
|
|
5389
|
-
const
|
|
5410
|
+
if (!N) return;
|
|
5411
|
+
const _ = Array.isArray(N.content) ? N.content : [], p = _.filter((M) => (M == null ? void 0 : M.type) === "text").map((M) => M.text).join("") || (() => {
|
|
5390
5412
|
try {
|
|
5391
|
-
return JSON.stringify(
|
|
5413
|
+
return JSON.stringify(_, null, 2);
|
|
5392
5414
|
} catch {
|
|
5393
|
-
return String(
|
|
5415
|
+
return String(_);
|
|
5394
5416
|
}
|
|
5395
5417
|
})();
|
|
5396
|
-
|
|
5418
|
+
p && e(
|
|
5397
5419
|
{
|
|
5398
|
-
text:
|
|
5420
|
+
text: p,
|
|
5399
5421
|
payload: t.payload,
|
|
5400
5422
|
checkpointId: n ?? void 0,
|
|
5401
5423
|
checkpointNs: r ?? void 0,
|
|
5402
5424
|
edit: !0,
|
|
5403
|
-
originalMessageId:
|
|
5425
|
+
originalMessageId: N.id,
|
|
5404
5426
|
config: t.config
|
|
5405
5427
|
},
|
|
5406
5428
|
d ? { onEvent: d } : void 0
|
|
@@ -5409,27 +5431,27 @@ function no({
|
|
|
5409
5431
|
return {
|
|
5410
5432
|
editingMessageId: m,
|
|
5411
5433
|
editingInitialValue: I,
|
|
5412
|
-
inputError:
|
|
5413
|
-
setInputError:
|
|
5414
|
-
dismissError:
|
|
5415
|
-
setDismissError:
|
|
5416
|
-
composerValue:
|
|
5417
|
-
handleComposerChange:
|
|
5434
|
+
inputError: z,
|
|
5435
|
+
setInputError: w,
|
|
5436
|
+
dismissError: v,
|
|
5437
|
+
setDismissError: F,
|
|
5438
|
+
composerValue: $,
|
|
5439
|
+
handleComposerChange: G,
|
|
5418
5440
|
handleSendMessage: Q,
|
|
5419
|
-
handleQuickPrompt:
|
|
5420
|
-
handleExcelUpload:
|
|
5421
|
-
startEditing:
|
|
5422
|
-
cancelEditing:
|
|
5423
|
-
handleRegenerateCb:
|
|
5424
|
-
displayMessages:
|
|
5441
|
+
handleQuickPrompt: X,
|
|
5442
|
+
handleExcelUpload: oe,
|
|
5443
|
+
startEditing: A,
|
|
5444
|
+
cancelEditing: R,
|
|
5445
|
+
handleRegenerateCb: V,
|
|
5446
|
+
displayMessages: k
|
|
5425
5447
|
};
|
|
5426
5448
|
}
|
|
5427
5449
|
function ro(e) {
|
|
5428
|
-
return
|
|
5450
|
+
return de(() => e ? {
|
|
5429
5451
|
textContent: Ir(e),
|
|
5430
|
-
imageParts:
|
|
5431
|
-
fileParts:
|
|
5432
|
-
toolCalls:
|
|
5452
|
+
imageParts: vr(e),
|
|
5453
|
+
fileParts: Tr(e),
|
|
5454
|
+
toolCalls: ln(e),
|
|
5433
5455
|
contentParts: e.content
|
|
5434
5456
|
} : {
|
|
5435
5457
|
textContent: "",
|
|
@@ -5440,8 +5462,8 @@ function ro(e) {
|
|
|
5440
5462
|
}, [e]);
|
|
5441
5463
|
}
|
|
5442
5464
|
function so(e, t, n) {
|
|
5443
|
-
const [r, s] =
|
|
5444
|
-
return
|
|
5465
|
+
const [r, s] = W(e), o = H(e), a = H(null);
|
|
5466
|
+
return se(() => {
|
|
5445
5467
|
o.current = e;
|
|
5446
5468
|
const i = () => {
|
|
5447
5469
|
s(o.current), a.current && (clearTimeout(a.current), a.current = null);
|
|
@@ -5459,33 +5481,33 @@ function so(e, t, n) {
|
|
|
5459
5481
|
}
|
|
5460
5482
|
export {
|
|
5461
5483
|
Ys as ChatProviders,
|
|
5462
|
-
|
|
5484
|
+
vs as ThreadStateProvider,
|
|
5463
5485
|
rs as ThreadsProvider,
|
|
5464
5486
|
Vs as cn,
|
|
5465
|
-
|
|
5487
|
+
Kr as collectText,
|
|
5466
5488
|
Qs as createTaskSyncToolEndHandler,
|
|
5467
5489
|
Es as extractTaskIdFromToolEnd,
|
|
5468
|
-
|
|
5490
|
+
Hr as extractToolMeta,
|
|
5469
5491
|
Ks as formatToolOutput,
|
|
5470
5492
|
Gs as getAgentNameFromMessage,
|
|
5471
|
-
|
|
5493
|
+
fn as getChatToken,
|
|
5472
5494
|
Xs as getMessageAttemptInfo,
|
|
5473
5495
|
qs as getToolCallArtifacts,
|
|
5474
|
-
|
|
5496
|
+
Rr as getToolCalls,
|
|
5475
5497
|
Hs as hasContent,
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5498
|
+
ft as hydrateHistorySnapshots,
|
|
5499
|
+
un as isFileLike,
|
|
5500
|
+
br as looksLikeMarkdown,
|
|
5479
5501
|
Js as messageSignature,
|
|
5480
5502
|
Ws as normalizeInterruptId,
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
|
|
5484
|
-
|
|
5503
|
+
pn as onChatTokenChanged,
|
|
5504
|
+
zt as parseJsonSafe,
|
|
5505
|
+
dn as pretty,
|
|
5506
|
+
Gr as refreshHistoryFileUrls,
|
|
5485
5507
|
yt as sanitizeForDisplay,
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5508
|
+
De as setChatToken,
|
|
5509
|
+
Sr as stringifyTool,
|
|
5510
|
+
qe as useApi,
|
|
5489
5511
|
no as useChatController,
|
|
5490
5512
|
js as useChatSession,
|
|
5491
5513
|
Zs as useFilePreview,
|
|
@@ -5493,10 +5515,10 @@ export {
|
|
|
5493
5515
|
eo as useParsedMessageContent,
|
|
5494
5516
|
Zr as useStream,
|
|
5495
5517
|
so as useStreamingMarkdownBuffer,
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5518
|
+
vn as useThreadHistoryState,
|
|
5519
|
+
Sn as useThreadState,
|
|
5520
|
+
Is as useThreadStateUpdater,
|
|
5521
|
+
rt as useThreads,
|
|
5500
5522
|
ns as useThreadsState,
|
|
5501
5523
|
to as useToolPayload
|
|
5502
5524
|
};
|