@teodorruskvi/chat-core 0.1.46 → 0.1.48
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 +954 -936
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +6 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Gt = (e, t, n) => t in e ?
|
|
1
|
+
var Ht = Object.defineProperty;
|
|
2
|
+
var Gt = (e, t, n) => t in e ? Ht(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var at = (e, t, n) => Gt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { jsx as ie } from "react/jsx-runtime";
|
|
5
5
|
import * as it from "react";
|
|
6
|
-
import { createContext as
|
|
6
|
+
import { createContext as Ce, useContext as Ue, useState as $, useRef as W, useEffect as X, useCallback as _, useMemo as Y, useReducer as Wt } from "react";
|
|
7
7
|
import Jt, { isCancel as Xt } from "axios";
|
|
8
|
-
function
|
|
8
|
+
function vt(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 o = e.length;
|
|
13
|
-
for (t = 0; t < o; t++) e[t] && (n =
|
|
13
|
+
for (t = 0; t < o; t++) e[t] && (n = vt(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
17
|
function Qt() {
|
|
18
|
-
for (var e, t, n = 0, r = "", o = arguments.length; n < o; n++) (e = arguments[n]) && (t =
|
|
18
|
+
for (var e, t, n = 0, r = "", o = arguments.length; n < o; n++) (e = arguments[n]) && (t = vt(e)) && (r && (r += " "), r += t);
|
|
19
19
|
return r;
|
|
20
20
|
}
|
|
21
21
|
const et = "-", Yt = (e) => {
|
|
@@ -29,8 +29,8 @@ const et = "-", Yt = (e) => {
|
|
|
29
29
|
return i[0] === "" && i.length !== 1 && i.shift(), It(i, t) || Zt(a);
|
|
30
30
|
},
|
|
31
31
|
getConflictingClassGroupIds: (a, i) => {
|
|
32
|
-
const
|
|
33
|
-
return i && r[a] ? [...
|
|
32
|
+
const u = n[a] || [];
|
|
33
|
+
return i && r[a] ? [...u, ...r[a]] : u;
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
}, It = (e, t) => {
|
|
@@ -120,33 +120,33 @@ const et = "-", Yt = (e) => {
|
|
|
120
120
|
n.has(s) ? n.set(s, a) : o(s, a);
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
|
-
},
|
|
123
|
+
}, At = "!", on = (e) => {
|
|
124
124
|
const {
|
|
125
125
|
separator: t,
|
|
126
126
|
experimentalParseClassName: n
|
|
127
127
|
} = e, r = t.length === 1, o = t[0], s = t.length, a = (i) => {
|
|
128
|
-
const
|
|
129
|
-
let c = 0, l = 0,
|
|
130
|
-
for (let
|
|
131
|
-
let
|
|
128
|
+
const u = [];
|
|
129
|
+
let c = 0, l = 0, d;
|
|
130
|
+
for (let k = 0; k < i.length; k++) {
|
|
131
|
+
let p = i[k];
|
|
132
132
|
if (c === 0) {
|
|
133
|
-
if (
|
|
134
|
-
|
|
133
|
+
if (p === o && (r || i.slice(k, k + s) === t)) {
|
|
134
|
+
u.push(i.slice(l, k)), l = k + s;
|
|
135
135
|
continue;
|
|
136
136
|
}
|
|
137
|
-
if (
|
|
138
|
-
|
|
137
|
+
if (p === "/") {
|
|
138
|
+
d = k;
|
|
139
139
|
continue;
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
|
-
|
|
142
|
+
p === "[" ? c++ : p === "]" && c--;
|
|
143
143
|
}
|
|
144
|
-
const
|
|
144
|
+
const m = u.length === 0 ? i : i.substring(l), y = m.startsWith(At), I = y ? m.substring(1) : m, f = d && d > l ? d - l : void 0;
|
|
145
145
|
return {
|
|
146
|
-
modifiers:
|
|
147
|
-
hasImportantModifier:
|
|
148
|
-
baseClassName:
|
|
149
|
-
maybePostfixModifierPosition:
|
|
146
|
+
modifiers: u,
|
|
147
|
+
hasImportantModifier: y,
|
|
148
|
+
baseClassName: I,
|
|
149
|
+
maybePostfixModifierPosition: f
|
|
150
150
|
};
|
|
151
151
|
};
|
|
152
152
|
return n ? (i) => n({
|
|
@@ -172,33 +172,33 @@ const et = "-", Yt = (e) => {
|
|
|
172
172
|
getConflictingClassGroupIds: o
|
|
173
173
|
} = t, s = [], a = e.trim().split(cn);
|
|
174
174
|
let i = "";
|
|
175
|
-
for (let
|
|
176
|
-
const c = a[
|
|
175
|
+
for (let u = a.length - 1; u >= 0; u -= 1) {
|
|
176
|
+
const c = a[u], {
|
|
177
177
|
modifiers: l,
|
|
178
|
-
hasImportantModifier:
|
|
179
|
-
baseClassName:
|
|
180
|
-
maybePostfixModifierPosition:
|
|
178
|
+
hasImportantModifier: d,
|
|
179
|
+
baseClassName: m,
|
|
180
|
+
maybePostfixModifierPosition: y
|
|
181
181
|
} = n(c);
|
|
182
|
-
let
|
|
183
|
-
if (!
|
|
184
|
-
if (!
|
|
182
|
+
let I = !!y, f = r(I ? m.substring(0, y) : m);
|
|
183
|
+
if (!f) {
|
|
184
|
+
if (!I) {
|
|
185
185
|
i = c + (i.length > 0 ? " " + i : i);
|
|
186
186
|
continue;
|
|
187
187
|
}
|
|
188
|
-
if (
|
|
188
|
+
if (f = r(m), !f) {
|
|
189
189
|
i = c + (i.length > 0 ? " " + i : i);
|
|
190
190
|
continue;
|
|
191
191
|
}
|
|
192
|
-
|
|
192
|
+
I = !1;
|
|
193
193
|
}
|
|
194
|
-
const
|
|
195
|
-
if (s.includes(
|
|
194
|
+
const k = sn(l).join(":"), p = d ? k + At : k, S = p + f;
|
|
195
|
+
if (s.includes(S))
|
|
196
196
|
continue;
|
|
197
|
-
s.push(
|
|
198
|
-
const
|
|
199
|
-
for (let E = 0; E <
|
|
200
|
-
const v =
|
|
201
|
-
s.push(
|
|
197
|
+
s.push(S);
|
|
198
|
+
const A = o(f, I);
|
|
199
|
+
for (let E = 0; E < A.length; ++E) {
|
|
200
|
+
const v = A[E];
|
|
201
|
+
s.push(p + v);
|
|
202
202
|
}
|
|
203
203
|
i = c + (i.length > 0 ? " " + i : i);
|
|
204
204
|
}
|
|
@@ -207,29 +207,29 @@ const et = "-", Yt = (e) => {
|
|
|
207
207
|
function un() {
|
|
208
208
|
let e = 0, t, n, r = "";
|
|
209
209
|
for (; e < arguments.length; )
|
|
210
|
-
(t = arguments[e++]) && (n =
|
|
210
|
+
(t = arguments[e++]) && (n = xt(t)) && (r && (r += " "), r += n);
|
|
211
211
|
return r;
|
|
212
212
|
}
|
|
213
|
-
const
|
|
213
|
+
const xt = (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 = xt(e[r])) && (n && (n += " "), n += t);
|
|
219
219
|
return n;
|
|
220
220
|
};
|
|
221
221
|
function dn(e, ...t) {
|
|
222
222
|
let n, r, o, s = a;
|
|
223
|
-
function a(
|
|
224
|
-
const c = t.reduce((l,
|
|
225
|
-
return n = an(c), r = n.cache.get, o = n.cache.set, s = i, i(
|
|
223
|
+
function a(u) {
|
|
224
|
+
const c = t.reduce((l, d) => d(l), e());
|
|
225
|
+
return n = an(c), r = n.cache.get, o = n.cache.set, s = i, i(u);
|
|
226
226
|
}
|
|
227
|
-
function i(
|
|
228
|
-
const c = r(
|
|
227
|
+
function i(u) {
|
|
228
|
+
const c = r(u);
|
|
229
229
|
if (c)
|
|
230
230
|
return c;
|
|
231
|
-
const l = ln(
|
|
232
|
-
return o(
|
|
231
|
+
const l = ln(u, n);
|
|
232
|
+
return o(u, l), l;
|
|
233
233
|
}
|
|
234
234
|
return function() {
|
|
235
235
|
return s(un.apply(null, arguments));
|
|
@@ -238,7 +238,7 @@ function dn(e, ...t) {
|
|
|
238
238
|
const D = (e) => {
|
|
239
239
|
const t = (n) => n[e] || [];
|
|
240
240
|
return t.isThemeGetter = !0, t;
|
|
241
|
-
}, Tt = /^\[(?:([a-z-]+):)?(.+)\]$/i, fn = /^\d+\/\d+$/, pn = /* @__PURE__ */ new Set(["px", "full", "screen"]), gn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, mn = /\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$/, yn = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, hn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, bn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, de = (e) => Te(e) || pn.has(e) || fn.test(e), be = (e) => Ee(e, "length", Sn), Te = (e) => !!e && !Number.isNaN(Number(e)),
|
|
241
|
+
}, Tt = /^\[(?:([a-z-]+):)?(.+)\]$/i, fn = /^\d+\/\d+$/, pn = /* @__PURE__ */ new Set(["px", "full", "screen"]), gn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, mn = /\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$/, yn = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, hn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, bn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, de = (e) => Te(e) || pn.has(e) || fn.test(e), be = (e) => Ee(e, "length", Sn), Te = (e) => !!e && !Number.isNaN(Number(e)), qe = (e) => Ee(e, "number", Te), _e = (e) => !!e && Number.isInteger(Number(e)), wn = (e) => e.endsWith("%") && Te(e.slice(0, -1)), R = (e) => Tt.test(e), we = (e) => gn.test(e), kn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), vn = (e) => Ee(e, kn, St), In = (e) => Ee(e, "position", St), An = /* @__PURE__ */ new Set(["image", "url"]), xn = (e) => Ee(e, An, Cn), Tn = (e) => Ee(e, "", Mn), Ne = () => !0, Ee = (e, t, n) => {
|
|
242
242
|
const r = Tt.exec(e);
|
|
243
243
|
return r ? r[1] ? typeof t == "string" ? r[1] === t : t.has(r[1]) : n(r[2]) : !1;
|
|
244
244
|
}, Sn = (e) => (
|
|
@@ -246,8 +246,8 @@ const D = (e) => {
|
|
|
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
248
|
mn.test(e) && !yn.test(e)
|
|
249
|
-
), St = () => !1,
|
|
250
|
-
const e = D("colors"), t = D("spacing"), n = D("blur"), r = D("brightness"), o = D("borderColor"), s = D("borderRadius"), a = D("borderSpacing"), i = D("borderWidth"),
|
|
249
|
+
), St = () => !1, Mn = (e) => hn.test(e), Cn = (e) => bn.test(e), En = () => {
|
|
250
|
+
const e = D("colors"), t = D("spacing"), n = D("blur"), r = D("brightness"), o = D("borderColor"), s = D("borderRadius"), a = D("borderSpacing"), i = D("borderWidth"), u = D("contrast"), c = D("grayscale"), l = D("hueRotate"), d = D("invert"), m = D("gap"), y = D("gradientColorStops"), I = D("gradientColorStopPositions"), f = D("inset"), k = D("margin"), p = D("opacity"), S = D("padding"), A = D("saturate"), E = D("scale"), v = D("sepia"), w = D("skew"), x = D("space"), g = D("translate"), b = () => ["auto", "contain", "none"], P = () => ["auto", "hidden", "clip", "visible", "scroll"], j = () => ["auto", R, t], M = () => [R, t], O = () => ["", de, be], F = () => ["auto", Te, R], C = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], B = () => ["solid", "dashed", "dotted", "double", "none"], N = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], V = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], z = () => ["", "0", R], L = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], H = () => [Te, R];
|
|
251
251
|
return {
|
|
252
252
|
cacheSize: 500,
|
|
253
253
|
separator: ":",
|
|
@@ -255,28 +255,28 @@ const D = (e) => {
|
|
|
255
255
|
colors: [Ne],
|
|
256
256
|
spacing: [de, be],
|
|
257
257
|
blur: ["none", "", we, R],
|
|
258
|
-
brightness:
|
|
258
|
+
brightness: H(),
|
|
259
259
|
borderColor: [e],
|
|
260
260
|
borderRadius: ["none", "", "full", we, R],
|
|
261
|
-
borderSpacing:
|
|
261
|
+
borderSpacing: M(),
|
|
262
262
|
borderWidth: O(),
|
|
263
|
-
contrast:
|
|
263
|
+
contrast: H(),
|
|
264
264
|
grayscale: z(),
|
|
265
|
-
hueRotate:
|
|
265
|
+
hueRotate: H(),
|
|
266
266
|
invert: z(),
|
|
267
|
-
gap:
|
|
267
|
+
gap: M(),
|
|
268
268
|
gradientColorStops: [e],
|
|
269
269
|
gradientColorStopPositions: [wn, be],
|
|
270
270
|
inset: j(),
|
|
271
271
|
margin: j(),
|
|
272
|
-
opacity:
|
|
273
|
-
padding:
|
|
274
|
-
saturate:
|
|
275
|
-
scale:
|
|
272
|
+
opacity: H(),
|
|
273
|
+
padding: M(),
|
|
274
|
+
saturate: H(),
|
|
275
|
+
scale: H(),
|
|
276
276
|
sepia: z(),
|
|
277
|
-
skew:
|
|
278
|
-
space:
|
|
279
|
-
translate:
|
|
277
|
+
skew: H(),
|
|
278
|
+
space: M(),
|
|
279
|
+
translate: M()
|
|
280
280
|
},
|
|
281
281
|
classGroups: {
|
|
282
282
|
// Layout
|
|
@@ -370,7 +370,7 @@ const D = (e) => {
|
|
|
370
370
|
* @see https://tailwindcss.com/docs/object-position
|
|
371
371
|
*/
|
|
372
372
|
"object-position": [{
|
|
373
|
-
object: [...
|
|
373
|
+
object: [...C(), R]
|
|
374
374
|
}],
|
|
375
375
|
/**
|
|
376
376
|
* Overflow
|
|
@@ -398,21 +398,21 @@ const D = (e) => {
|
|
|
398
398
|
* @see https://tailwindcss.com/docs/overscroll-behavior
|
|
399
399
|
*/
|
|
400
400
|
overscroll: [{
|
|
401
|
-
overscroll:
|
|
401
|
+
overscroll: b()
|
|
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": b()
|
|
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": b()
|
|
416
416
|
}],
|
|
417
417
|
/**
|
|
418
418
|
* Position
|
|
@@ -424,63 +424,63 @@ const D = (e) => {
|
|
|
424
424
|
* @see https://tailwindcss.com/docs/top-right-bottom-left
|
|
425
425
|
*/
|
|
426
426
|
inset: [{
|
|
427
|
-
inset: [
|
|
427
|
+
inset: [f]
|
|
428
428
|
}],
|
|
429
429
|
/**
|
|
430
430
|
* Right / Left
|
|
431
431
|
* @see https://tailwindcss.com/docs/top-right-bottom-left
|
|
432
432
|
*/
|
|
433
433
|
"inset-x": [{
|
|
434
|
-
"inset-x": [
|
|
434
|
+
"inset-x": [f]
|
|
435
435
|
}],
|
|
436
436
|
/**
|
|
437
437
|
* Top / Bottom
|
|
438
438
|
* @see https://tailwindcss.com/docs/top-right-bottom-left
|
|
439
439
|
*/
|
|
440
440
|
"inset-y": [{
|
|
441
|
-
"inset-y": [
|
|
441
|
+
"inset-y": [f]
|
|
442
442
|
}],
|
|
443
443
|
/**
|
|
444
444
|
* Start
|
|
445
445
|
* @see https://tailwindcss.com/docs/top-right-bottom-left
|
|
446
446
|
*/
|
|
447
447
|
start: [{
|
|
448
|
-
start: [
|
|
448
|
+
start: [f]
|
|
449
449
|
}],
|
|
450
450
|
/**
|
|
451
451
|
* End
|
|
452
452
|
* @see https://tailwindcss.com/docs/top-right-bottom-left
|
|
453
453
|
*/
|
|
454
454
|
end: [{
|
|
455
|
-
end: [
|
|
455
|
+
end: [f]
|
|
456
456
|
}],
|
|
457
457
|
/**
|
|
458
458
|
* Top
|
|
459
459
|
* @see https://tailwindcss.com/docs/top-right-bottom-left
|
|
460
460
|
*/
|
|
461
461
|
top: [{
|
|
462
|
-
top: [
|
|
462
|
+
top: [f]
|
|
463
463
|
}],
|
|
464
464
|
/**
|
|
465
465
|
* Right
|
|
466
466
|
* @see https://tailwindcss.com/docs/top-right-bottom-left
|
|
467
467
|
*/
|
|
468
468
|
right: [{
|
|
469
|
-
right: [
|
|
469
|
+
right: [f]
|
|
470
470
|
}],
|
|
471
471
|
/**
|
|
472
472
|
* Bottom
|
|
473
473
|
* @see https://tailwindcss.com/docs/top-right-bottom-left
|
|
474
474
|
*/
|
|
475
475
|
bottom: [{
|
|
476
|
-
bottom: [
|
|
476
|
+
bottom: [f]
|
|
477
477
|
}],
|
|
478
478
|
/**
|
|
479
479
|
* Left
|
|
480
480
|
* @see https://tailwindcss.com/docs/top-right-bottom-left
|
|
481
481
|
*/
|
|
482
482
|
left: [{
|
|
483
|
-
left: [
|
|
483
|
+
left: [f]
|
|
484
484
|
}],
|
|
485
485
|
/**
|
|
486
486
|
* Visibility
|
|
@@ -565,14 +565,14 @@ const D = (e) => {
|
|
|
565
565
|
* @see https://tailwindcss.com/docs/grid-column
|
|
566
566
|
*/
|
|
567
567
|
"col-start": [{
|
|
568
|
-
"col-start":
|
|
568
|
+
"col-start": F()
|
|
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": F()
|
|
576
576
|
}],
|
|
577
577
|
/**
|
|
578
578
|
* Grid Template Rows
|
|
@@ -595,14 +595,14 @@ const D = (e) => {
|
|
|
595
595
|
* @see https://tailwindcss.com/docs/grid-row
|
|
596
596
|
*/
|
|
597
597
|
"row-start": [{
|
|
598
|
-
"row-start":
|
|
598
|
+
"row-start": F()
|
|
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": F()
|
|
606
606
|
}],
|
|
607
607
|
/**
|
|
608
608
|
* Grid Auto Flow
|
|
@@ -630,21 +630,21 @@ const D = (e) => {
|
|
|
630
630
|
* @see https://tailwindcss.com/docs/gap
|
|
631
631
|
*/
|
|
632
632
|
gap: [{
|
|
633
|
-
gap: [
|
|
633
|
+
gap: [m]
|
|
634
634
|
}],
|
|
635
635
|
/**
|
|
636
636
|
* Gap X
|
|
637
637
|
* @see https://tailwindcss.com/docs/gap
|
|
638
638
|
*/
|
|
639
639
|
"gap-x": [{
|
|
640
|
-
"gap-x": [
|
|
640
|
+
"gap-x": [m]
|
|
641
641
|
}],
|
|
642
642
|
/**
|
|
643
643
|
* Gap Y
|
|
644
644
|
* @see https://tailwindcss.com/docs/gap
|
|
645
645
|
*/
|
|
646
646
|
"gap-y": [{
|
|
647
|
-
"gap-y": [
|
|
647
|
+
"gap-y": [m]
|
|
648
648
|
}],
|
|
649
649
|
/**
|
|
650
650
|
* Justify Content
|
|
@@ -715,133 +715,133 @@ const D = (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
|
|
778
778
|
* @see https://tailwindcss.com/docs/margin
|
|
779
779
|
*/
|
|
780
780
|
m: [{
|
|
781
|
-
m: [
|
|
781
|
+
m: [k]
|
|
782
782
|
}],
|
|
783
783
|
/**
|
|
784
784
|
* Margin X
|
|
785
785
|
* @see https://tailwindcss.com/docs/margin
|
|
786
786
|
*/
|
|
787
787
|
mx: [{
|
|
788
|
-
mx: [
|
|
788
|
+
mx: [k]
|
|
789
789
|
}],
|
|
790
790
|
/**
|
|
791
791
|
* Margin Y
|
|
792
792
|
* @see https://tailwindcss.com/docs/margin
|
|
793
793
|
*/
|
|
794
794
|
my: [{
|
|
795
|
-
my: [
|
|
795
|
+
my: [k]
|
|
796
796
|
}],
|
|
797
797
|
/**
|
|
798
798
|
* Margin Start
|
|
799
799
|
* @see https://tailwindcss.com/docs/margin
|
|
800
800
|
*/
|
|
801
801
|
ms: [{
|
|
802
|
-
ms: [
|
|
802
|
+
ms: [k]
|
|
803
803
|
}],
|
|
804
804
|
/**
|
|
805
805
|
* Margin End
|
|
806
806
|
* @see https://tailwindcss.com/docs/margin
|
|
807
807
|
*/
|
|
808
808
|
me: [{
|
|
809
|
-
me: [
|
|
809
|
+
me: [k]
|
|
810
810
|
}],
|
|
811
811
|
/**
|
|
812
812
|
* Margin Top
|
|
813
813
|
* @see https://tailwindcss.com/docs/margin
|
|
814
814
|
*/
|
|
815
815
|
mt: [{
|
|
816
|
-
mt: [
|
|
816
|
+
mt: [k]
|
|
817
817
|
}],
|
|
818
818
|
/**
|
|
819
819
|
* Margin Right
|
|
820
820
|
* @see https://tailwindcss.com/docs/margin
|
|
821
821
|
*/
|
|
822
822
|
mr: [{
|
|
823
|
-
mr: [
|
|
823
|
+
mr: [k]
|
|
824
824
|
}],
|
|
825
825
|
/**
|
|
826
826
|
* Margin Bottom
|
|
827
827
|
* @see https://tailwindcss.com/docs/margin
|
|
828
828
|
*/
|
|
829
829
|
mb: [{
|
|
830
|
-
mb: [
|
|
830
|
+
mb: [k]
|
|
831
831
|
}],
|
|
832
832
|
/**
|
|
833
833
|
* Margin Left
|
|
834
834
|
* @see https://tailwindcss.com/docs/margin
|
|
835
835
|
*/
|
|
836
836
|
ml: [{
|
|
837
|
-
ml: [
|
|
837
|
+
ml: [k]
|
|
838
838
|
}],
|
|
839
839
|
/**
|
|
840
840
|
* Space Between X
|
|
841
841
|
* @see https://tailwindcss.com/docs/space
|
|
842
842
|
*/
|
|
843
843
|
"space-x": [{
|
|
844
|
-
"space-x": [
|
|
844
|
+
"space-x": [x]
|
|
845
845
|
}],
|
|
846
846
|
/**
|
|
847
847
|
* Space Between X Reverse
|
|
@@ -853,7 +853,7 @@ const D = (e) => {
|
|
|
853
853
|
* @see https://tailwindcss.com/docs/space
|
|
854
854
|
*/
|
|
855
855
|
"space-y": [{
|
|
856
|
-
"space-y": [
|
|
856
|
+
"space-y": [x]
|
|
857
857
|
}],
|
|
858
858
|
/**
|
|
859
859
|
* Space Between Y Reverse
|
|
@@ -935,7 +935,7 @@ const D = (e) => {
|
|
|
935
935
|
* @see https://tailwindcss.com/docs/font-weight
|
|
936
936
|
*/
|
|
937
937
|
"font-weight": [{
|
|
938
|
-
font: ["thin", "extralight", "light", "normal", "medium", "semibold", "bold", "extrabold", "black",
|
|
938
|
+
font: ["thin", "extralight", "light", "normal", "medium", "semibold", "bold", "extrabold", "black", qe]
|
|
939
939
|
}],
|
|
940
940
|
/**
|
|
941
941
|
* Font Family
|
|
@@ -986,7 +986,7 @@ const D = (e) => {
|
|
|
986
986
|
* @see https://tailwindcss.com/docs/line-clamp
|
|
987
987
|
*/
|
|
988
988
|
"line-clamp": [{
|
|
989
|
-
"line-clamp": ["none", Te,
|
|
989
|
+
"line-clamp": ["none", Te, qe]
|
|
990
990
|
}],
|
|
991
991
|
/**
|
|
992
992
|
* Line Height
|
|
@@ -1029,7 +1029,7 @@ const D = (e) => {
|
|
|
1029
1029
|
* @see https://tailwindcss.com/docs/placeholder-opacity
|
|
1030
1030
|
*/
|
|
1031
1031
|
"placeholder-opacity": [{
|
|
1032
|
-
"placeholder-opacity": [
|
|
1032
|
+
"placeholder-opacity": [p]
|
|
1033
1033
|
}],
|
|
1034
1034
|
/**
|
|
1035
1035
|
* Text Alignment
|
|
@@ -1050,7 +1050,7 @@ const D = (e) => {
|
|
|
1050
1050
|
* @see https://tailwindcss.com/docs/text-opacity
|
|
1051
1051
|
*/
|
|
1052
1052
|
"text-opacity": [{
|
|
1053
|
-
"text-opacity": [
|
|
1053
|
+
"text-opacity": [p]
|
|
1054
1054
|
}],
|
|
1055
1055
|
/**
|
|
1056
1056
|
* Text Decoration
|
|
@@ -1062,7 +1062,7 @@ const D = (e) => {
|
|
|
1062
1062
|
* @see https://tailwindcss.com/docs/text-decoration-style
|
|
1063
1063
|
*/
|
|
1064
1064
|
"text-decoration-style": [{
|
|
1065
|
-
decoration: [...
|
|
1065
|
+
decoration: [...B(), "wavy"]
|
|
1066
1066
|
}],
|
|
1067
1067
|
/**
|
|
1068
1068
|
* Text Decoration Thickness
|
|
@@ -1107,7 +1107,7 @@ const D = (e) => {
|
|
|
1107
1107
|
* @see https://tailwindcss.com/docs/text-indent
|
|
1108
1108
|
*/
|
|
1109
1109
|
indent: [{
|
|
1110
|
-
indent:
|
|
1110
|
+
indent: M()
|
|
1111
1111
|
}],
|
|
1112
1112
|
/**
|
|
1113
1113
|
* Vertical Alignment
|
|
@@ -1165,7 +1165,7 @@ const D = (e) => {
|
|
|
1165
1165
|
* @see https://tailwindcss.com/docs/background-opacity
|
|
1166
1166
|
*/
|
|
1167
1167
|
"bg-opacity": [{
|
|
1168
|
-
"bg-opacity": [
|
|
1168
|
+
"bg-opacity": [p]
|
|
1169
1169
|
}],
|
|
1170
1170
|
/**
|
|
1171
1171
|
* Background Origin
|
|
@@ -1179,7 +1179,7 @@ const D = (e) => {
|
|
|
1179
1179
|
* @see https://tailwindcss.com/docs/background-position
|
|
1180
1180
|
*/
|
|
1181
1181
|
"bg-position": [{
|
|
1182
|
-
bg: [...
|
|
1182
|
+
bg: [...C(), In]
|
|
1183
1183
|
}],
|
|
1184
1184
|
/**
|
|
1185
1185
|
* Background Repeat
|
|
@@ -1195,7 +1195,7 @@ const D = (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", vn]
|
|
1199
1199
|
}],
|
|
1200
1200
|
/**
|
|
1201
1201
|
* Background Image
|
|
@@ -1204,7 +1204,7 @@ const D = (e) => {
|
|
|
1204
1204
|
"bg-image": [{
|
|
1205
1205
|
bg: ["none", {
|
|
1206
1206
|
"gradient-to": ["t", "tr", "r", "br", "b", "bl", "l", "tl"]
|
|
1207
|
-
},
|
|
1207
|
+
}, xn]
|
|
1208
1208
|
}],
|
|
1209
1209
|
/**
|
|
1210
1210
|
* Background Color
|
|
@@ -1218,42 +1218,42 @@ const D = (e) => {
|
|
|
1218
1218
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
1219
1219
|
*/
|
|
1220
1220
|
"gradient-from-pos": [{
|
|
1221
|
-
from: [
|
|
1221
|
+
from: [I]
|
|
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: [I]
|
|
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: [I]
|
|
1236
1236
|
}],
|
|
1237
1237
|
/**
|
|
1238
1238
|
* Gradient Color Stops From
|
|
1239
1239
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
1240
1240
|
*/
|
|
1241
1241
|
"gradient-from": [{
|
|
1242
|
-
from: [
|
|
1242
|
+
from: [y]
|
|
1243
1243
|
}],
|
|
1244
1244
|
/**
|
|
1245
1245
|
* Gradient Color Stops Via
|
|
1246
1246
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
1247
1247
|
*/
|
|
1248
1248
|
"gradient-via": [{
|
|
1249
|
-
via: [
|
|
1249
|
+
via: [y]
|
|
1250
1250
|
}],
|
|
1251
1251
|
/**
|
|
1252
1252
|
* Gradient Color Stops To
|
|
1253
1253
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
1254
1254
|
*/
|
|
1255
1255
|
"gradient-to": [{
|
|
1256
|
-
to: [
|
|
1256
|
+
to: [y]
|
|
1257
1257
|
}],
|
|
1258
1258
|
// Borders
|
|
1259
1259
|
/**
|
|
@@ -1429,14 +1429,14 @@ const D = (e) => {
|
|
|
1429
1429
|
* @see https://tailwindcss.com/docs/border-opacity
|
|
1430
1430
|
*/
|
|
1431
1431
|
"border-opacity": [{
|
|
1432
|
-
"border-opacity": [
|
|
1432
|
+
"border-opacity": [p]
|
|
1433
1433
|
}],
|
|
1434
1434
|
/**
|
|
1435
1435
|
* Border Style
|
|
1436
1436
|
* @see https://tailwindcss.com/docs/border-style
|
|
1437
1437
|
*/
|
|
1438
1438
|
"border-style": [{
|
|
1439
|
-
border: [...
|
|
1439
|
+
border: [...B(), "hidden"]
|
|
1440
1440
|
}],
|
|
1441
1441
|
/**
|
|
1442
1442
|
* Divide Width X
|
|
@@ -1467,14 +1467,14 @@ const D = (e) => {
|
|
|
1467
1467
|
* @see https://tailwindcss.com/docs/divide-opacity
|
|
1468
1468
|
*/
|
|
1469
1469
|
"divide-opacity": [{
|
|
1470
|
-
"divide-opacity": [
|
|
1470
|
+
"divide-opacity": [p]
|
|
1471
1471
|
}],
|
|
1472
1472
|
/**
|
|
1473
1473
|
* Divide Style
|
|
1474
1474
|
* @see https://tailwindcss.com/docs/divide-style
|
|
1475
1475
|
*/
|
|
1476
1476
|
"divide-style": [{
|
|
1477
|
-
divide:
|
|
1477
|
+
divide: B()
|
|
1478
1478
|
}],
|
|
1479
1479
|
/**
|
|
1480
1480
|
* Border Color
|
|
@@ -1551,7 +1551,7 @@ const D = (e) => {
|
|
|
1551
1551
|
* @see https://tailwindcss.com/docs/outline-style
|
|
1552
1552
|
*/
|
|
1553
1553
|
"outline-style": [{
|
|
1554
|
-
outline: ["", ...
|
|
1554
|
+
outline: ["", ...B()]
|
|
1555
1555
|
}],
|
|
1556
1556
|
/**
|
|
1557
1557
|
* Outline Offset
|
|
@@ -1598,7 +1598,7 @@ const D = (e) => {
|
|
|
1598
1598
|
* @see https://tailwindcss.com/docs/ring-opacity
|
|
1599
1599
|
*/
|
|
1600
1600
|
"ring-opacity": [{
|
|
1601
|
-
"ring-opacity": [
|
|
1601
|
+
"ring-opacity": [p]
|
|
1602
1602
|
}],
|
|
1603
1603
|
/**
|
|
1604
1604
|
* Ring Offset Width
|
|
@@ -1634,7 +1634,7 @@ const D = (e) => {
|
|
|
1634
1634
|
* @see https://tailwindcss.com/docs/opacity
|
|
1635
1635
|
*/
|
|
1636
1636
|
opacity: [{
|
|
1637
|
-
opacity: [
|
|
1637
|
+
opacity: [p]
|
|
1638
1638
|
}],
|
|
1639
1639
|
/**
|
|
1640
1640
|
* Mix Blend Mode
|
|
@@ -1678,7 +1678,7 @@ const D = (e) => {
|
|
|
1678
1678
|
* @see https://tailwindcss.com/docs/contrast
|
|
1679
1679
|
*/
|
|
1680
1680
|
contrast: [{
|
|
1681
|
-
contrast: [
|
|
1681
|
+
contrast: [u]
|
|
1682
1682
|
}],
|
|
1683
1683
|
/**
|
|
1684
1684
|
* Drop Shadow
|
|
@@ -1706,14 +1706,14 @@ const D = (e) => {
|
|
|
1706
1706
|
* @see https://tailwindcss.com/docs/invert
|
|
1707
1707
|
*/
|
|
1708
1708
|
invert: [{
|
|
1709
|
-
invert: [
|
|
1709
|
+
invert: [d]
|
|
1710
1710
|
}],
|
|
1711
1711
|
/**
|
|
1712
1712
|
* Saturate
|
|
1713
1713
|
* @see https://tailwindcss.com/docs/saturate
|
|
1714
1714
|
*/
|
|
1715
1715
|
saturate: [{
|
|
1716
|
-
saturate: [
|
|
1716
|
+
saturate: [A]
|
|
1717
1717
|
}],
|
|
1718
1718
|
/**
|
|
1719
1719
|
* Sepia
|
|
@@ -1749,7 +1749,7 @@ const D = (e) => {
|
|
|
1749
1749
|
* @see https://tailwindcss.com/docs/backdrop-contrast
|
|
1750
1750
|
*/
|
|
1751
1751
|
"backdrop-contrast": [{
|
|
1752
|
-
"backdrop-contrast": [
|
|
1752
|
+
"backdrop-contrast": [u]
|
|
1753
1753
|
}],
|
|
1754
1754
|
/**
|
|
1755
1755
|
* Backdrop Grayscale
|
|
@@ -1770,21 +1770,21 @@ const D = (e) => {
|
|
|
1770
1770
|
* @see https://tailwindcss.com/docs/backdrop-invert
|
|
1771
1771
|
*/
|
|
1772
1772
|
"backdrop-invert": [{
|
|
1773
|
-
"backdrop-invert": [
|
|
1773
|
+
"backdrop-invert": [d]
|
|
1774
1774
|
}],
|
|
1775
1775
|
/**
|
|
1776
1776
|
* Backdrop Opacity
|
|
1777
1777
|
* @see https://tailwindcss.com/docs/backdrop-opacity
|
|
1778
1778
|
*/
|
|
1779
1779
|
"backdrop-opacity": [{
|
|
1780
|
-
"backdrop-opacity": [
|
|
1780
|
+
"backdrop-opacity": [p]
|
|
1781
1781
|
}],
|
|
1782
1782
|
/**
|
|
1783
1783
|
* Backdrop Saturate
|
|
1784
1784
|
* @see https://tailwindcss.com/docs/backdrop-saturate
|
|
1785
1785
|
*/
|
|
1786
1786
|
"backdrop-saturate": [{
|
|
1787
|
-
"backdrop-saturate": [
|
|
1787
|
+
"backdrop-saturate": [A]
|
|
1788
1788
|
}],
|
|
1789
1789
|
/**
|
|
1790
1790
|
* Backdrop Sepia
|
|
@@ -1849,7 +1849,7 @@ const D = (e) => {
|
|
|
1849
1849
|
* @see https://tailwindcss.com/docs/transition-duration
|
|
1850
1850
|
*/
|
|
1851
1851
|
duration: [{
|
|
1852
|
-
duration:
|
|
1852
|
+
duration: H()
|
|
1853
1853
|
}],
|
|
1854
1854
|
/**
|
|
1855
1855
|
* Transition Timing Function
|
|
@@ -1863,7 +1863,7 @@ const D = (e) => {
|
|
|
1863
1863
|
* @see https://tailwindcss.com/docs/transition-delay
|
|
1864
1864
|
*/
|
|
1865
1865
|
delay: [{
|
|
1866
|
-
delay:
|
|
1866
|
+
delay: H()
|
|
1867
1867
|
}],
|
|
1868
1868
|
/**
|
|
1869
1869
|
* Animation
|
|
@@ -1913,28 +1913,28 @@ const D = (e) => {
|
|
|
1913
1913
|
* @see https://tailwindcss.com/docs/translate
|
|
1914
1914
|
*/
|
|
1915
1915
|
"translate-x": [{
|
|
1916
|
-
"translate-x": [
|
|
1916
|
+
"translate-x": [g]
|
|
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": [g]
|
|
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
|
|
@@ -1998,126 +1998,126 @@ const D = (e) => {
|
|
|
1998
1998
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
1999
1999
|
*/
|
|
2000
2000
|
"scroll-m": [{
|
|
2001
|
-
"scroll-m":
|
|
2001
|
+
"scroll-m": M()
|
|
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": M()
|
|
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": M()
|
|
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": M()
|
|
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": M()
|
|
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": M()
|
|
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": M()
|
|
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": M()
|
|
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": M()
|
|
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": M()
|
|
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": M()
|
|
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": M()
|
|
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": M()
|
|
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": M()
|
|
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": M()
|
|
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": M()
|
|
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": M()
|
|
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": M()
|
|
2121
2121
|
}],
|
|
2122
2122
|
/**
|
|
2123
2123
|
* Scroll Snap Align
|
|
@@ -2200,7 +2200,7 @@ const D = (e) => {
|
|
|
2200
2200
|
* @see https://tailwindcss.com/docs/stroke-width
|
|
2201
2201
|
*/
|
|
2202
2202
|
"stroke-w": [{
|
|
2203
|
-
stroke: [de, be,
|
|
2203
|
+
stroke: [de, be, qe]
|
|
2204
2204
|
}],
|
|
2205
2205
|
/**
|
|
2206
2206
|
* Stroke
|
|
@@ -2329,10 +2329,10 @@ function Un(e) {
|
|
|
2329
2329
|
function jn(e) {
|
|
2330
2330
|
return e.content.filter(Rn);
|
|
2331
2331
|
}
|
|
2332
|
-
function
|
|
2332
|
+
function Mt(e) {
|
|
2333
2333
|
return Array.isArray(e.toolCalls) ? e.toolCalls : [];
|
|
2334
2334
|
}
|
|
2335
|
-
function
|
|
2335
|
+
function Bn(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 Fn(e) {
|
|
|
2340
2340
|
});
|
|
2341
2341
|
}), t;
|
|
2342
2342
|
}
|
|
2343
|
-
function
|
|
2343
|
+
function Ct(e) {
|
|
2344
2344
|
return !!(e && typeof e == "object" && (e.type === "file" || e.mimeType || e.filename || e.sourceType === "base64"));
|
|
2345
2345
|
}
|
|
2346
2346
|
function Ve(e) {
|
|
@@ -2355,7 +2355,7 @@ function Ve(e) {
|
|
|
2355
2355
|
}
|
|
2356
2356
|
return n;
|
|
2357
2357
|
}
|
|
2358
|
-
if (
|
|
2358
|
+
if (Ct(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,
|
|
@@ -2389,7 +2389,7 @@ function Ve(e) {
|
|
|
2389
2389
|
}
|
|
2390
2390
|
function Et(e) {
|
|
2391
2391
|
if (typeof e == "string") return e;
|
|
2392
|
-
if (
|
|
2392
|
+
if (Ct(e)) return "";
|
|
2393
2393
|
try {
|
|
2394
2394
|
const t = Ve(e);
|
|
2395
2395
|
return t === void 0 ? "" : typeof t == "string" ? t : JSON.stringify(t, null, 2);
|
|
@@ -2401,7 +2401,7 @@ function oo(e) {
|
|
|
2401
2401
|
const t = Et(e);
|
|
2402
2402
|
return typeof e == "string" && Nn(e) ? { content: e, isMarkdown: !0 } : { content: t, isMarkdown: !1 };
|
|
2403
2403
|
}
|
|
2404
|
-
function
|
|
2404
|
+
function Fn(e) {
|
|
2405
2405
|
const t = (r) => {
|
|
2406
2406
|
try {
|
|
2407
2407
|
const o = Ve(r);
|
|
@@ -2436,24 +2436,24 @@ function ce(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 ? ce(e[0]) : e;
|
|
2438
2438
|
}
|
|
2439
|
-
function
|
|
2439
|
+
function On(e) {
|
|
2440
2440
|
return e.replace(/[_-](\w)/g, (t, n) => n ? n.toUpperCase() : "").replace(/^\w/, (t) => t.toLowerCase());
|
|
2441
2441
|
}
|
|
2442
2442
|
function le(e) {
|
|
2443
2443
|
return !e || typeof e != "object" ? e : Array.isArray(e) ? e.map(le) : Object.fromEntries(
|
|
2444
2444
|
Object.entries(e).map(([t, n]) => [
|
|
2445
|
-
|
|
2445
|
+
On(t),
|
|
2446
2446
|
le(n)
|
|
2447
2447
|
])
|
|
2448
2448
|
);
|
|
2449
2449
|
}
|
|
2450
2450
|
function nt(e) {
|
|
2451
|
-
var
|
|
2451
|
+
var k, p, S, A, E, v;
|
|
2452
2452
|
if (!e || typeof e != "object") return null;
|
|
2453
2453
|
const t = le(e), n = Vn(t);
|
|
2454
2454
|
if (!n)
|
|
2455
2455
|
return null;
|
|
2456
|
-
const r = Array.isArray(t.toolCalls) ? t.toolCalls.map(rt) : void 0, o = Dn(t.content ?? t.parts, !!(r != null && r.length)), s = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, a = t.createdAt ?? ((
|
|
2456
|
+
const r = Array.isArray(t.toolCalls) ? t.toolCalls.map(rt) : void 0, o = Dn(t.content ?? t.parts, !!(r != null && r.length)), s = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, a = t.createdAt ?? ((k = t.additionalKwargs) == null ? void 0 : k.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), i = t.name ?? ((p = t.additionalKwargs) == null ? void 0 : p.agentName) ?? void 0, u = t.model ?? ((S = t.additionalKwargs) == null ? void 0 : S.model) ?? void 0, c = t.toolCallId ?? void 0, l = t.additionalKwargs ?? void 0, d = t.responseMetadata ?? void 0, m = t.checkpointId ?? ((A = t.additionalKwargs) == null ? void 0 : A.checkpointId) ?? void 0, y = t.checkpointNs ?? ((E = t.additionalKwargs) == null ? void 0 : E.checkpointNs) ?? void 0, I = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((v = t.additionalKwargs) != null && v.toolStreaming);
|
|
2457
2457
|
return {
|
|
2458
2458
|
...t,
|
|
2459
2459
|
id: s,
|
|
@@ -2461,14 +2461,14 @@ function nt(e) {
|
|
|
2461
2461
|
content: o,
|
|
2462
2462
|
createdAt: a,
|
|
2463
2463
|
name: i,
|
|
2464
|
-
model:
|
|
2464
|
+
model: u,
|
|
2465
2465
|
toolCallId: c,
|
|
2466
2466
|
toolCalls: r,
|
|
2467
|
-
checkpointId:
|
|
2468
|
-
checkpointNs:
|
|
2469
|
-
toolStreaming:
|
|
2467
|
+
checkpointId: m,
|
|
2468
|
+
checkpointNs: y,
|
|
2469
|
+
toolStreaming: I,
|
|
2470
2470
|
additionalKwargs: l,
|
|
2471
|
-
responseMetadata:
|
|
2471
|
+
responseMetadata: d,
|
|
2472
2472
|
artifact: t.artifact && typeof t.artifact == "object" && !t.artifact.type ? { ...t.artifact, type: t.name } : t.artifact ?? void 0
|
|
2473
2473
|
};
|
|
2474
2474
|
}
|
|
@@ -2510,14 +2510,14 @@ function ut(e) {
|
|
|
2510
2510
|
return t === "running" || t === "pending" ? "pending" : t === "completed" || t === "success" ? "completed" : t === "error" || t === "failed" || t === "failure" ? "error" : null;
|
|
2511
2511
|
}
|
|
2512
2512
|
function dt(e) {
|
|
2513
|
-
return (Array.isArray(e.toolCalls) ? e.toolCalls :
|
|
2513
|
+
return (Array.isArray(e.toolCalls) ? e.toolCalls : Mt(e)).map(rt);
|
|
2514
2514
|
}
|
|
2515
|
-
function
|
|
2515
|
+
function He(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 Kn(e, t) {
|
|
2521
2521
|
const n = t.response ?? t.content;
|
|
2522
2522
|
if (!n) return;
|
|
2523
2523
|
const r = typeof n == "string" ? n : Et(n);
|
|
@@ -2533,21 +2533,21 @@ function qn(e, t) {
|
|
|
2533
2533
|
createdAt: e.createdAt
|
|
2534
2534
|
};
|
|
2535
2535
|
}
|
|
2536
|
-
function
|
|
2536
|
+
function qn(e, t = []) {
|
|
2537
2537
|
if (Array.isArray(e)) {
|
|
2538
2538
|
const o = e.filter((a) => a.role === "assistant").flatMap((a) => dt(a)), s = /* @__PURE__ */ new Map();
|
|
2539
2539
|
return o.forEach((a) => s.set(a.id, a)), Array.from(s.values()).map((a) => {
|
|
2540
|
-
var
|
|
2541
|
-
const i =
|
|
2540
|
+
var d, m, y;
|
|
2541
|
+
const i = He(a.id, e) || He(a.id, t), u = Array.isArray((d = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : d.toolProgress) ? (m = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : m.toolProgress : void 0, c = (i == null ? void 0 : i.artifact) ?? a.artifact, l = ut(a.status) ?? ((y = i == null ? void 0 : i.additionalKwargs) != null && y.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
|
|
2542
2542
|
if (i && !a.content && l === "completed") {
|
|
2543
|
-
const
|
|
2544
|
-
typeof
|
|
2543
|
+
const I = ce(i);
|
|
2544
|
+
typeof I == "string" && (a.content = I);
|
|
2545
2545
|
}
|
|
2546
2546
|
return {
|
|
2547
2547
|
call: a,
|
|
2548
2548
|
result: i,
|
|
2549
2549
|
state: l,
|
|
2550
|
-
progress:
|
|
2550
|
+
progress: u,
|
|
2551
2551
|
artifact: c
|
|
2552
2552
|
};
|
|
2553
2553
|
});
|
|
@@ -2555,11 +2555,11 @@ function Hn(e, t = []) {
|
|
|
2555
2555
|
if (e.role !== "assistant") return [];
|
|
2556
2556
|
const n = dt(e);
|
|
2557
2557
|
return n.length === 0 ? [] : n.map((r) => {
|
|
2558
|
-
var
|
|
2559
|
-
const o =
|
|
2558
|
+
var u, c, l;
|
|
2559
|
+
const o = He(r.id, t) ?? Kn(e, r), s = Array.isArray((u = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : u.toolProgress) ? (c = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : c.toolProgress : void 0, a = (o == null ? void 0 : o.artifact) ?? r.artifact, i = ut(r.status) ?? ((l = o == null ? void 0 : o.additionalKwargs) != null && l.toolStreaming ? "pending" : null) ?? (o ? "completed" : "pending");
|
|
2560
2560
|
if (o && !r.content && i === "completed") {
|
|
2561
|
-
const
|
|
2562
|
-
typeof
|
|
2561
|
+
const d = ce(o);
|
|
2562
|
+
typeof d == "string" && (r.content = d);
|
|
2563
2563
|
}
|
|
2564
2564
|
return {
|
|
2565
2565
|
call: r,
|
|
@@ -2571,7 +2571,7 @@ function Hn(e, t = []) {
|
|
|
2571
2571
|
});
|
|
2572
2572
|
}
|
|
2573
2573
|
function ao(e, t = []) {
|
|
2574
|
-
return
|
|
2574
|
+
return qn(e, t).map((n) => n.artifact).filter((n) => !!n);
|
|
2575
2575
|
}
|
|
2576
2576
|
const ze = {
|
|
2577
2577
|
authToken: "authToken",
|
|
@@ -2585,19 +2585,19 @@ const ze = {
|
|
|
2585
2585
|
function Ge(e) {
|
|
2586
2586
|
return `draft:${e}`;
|
|
2587
2587
|
}
|
|
2588
|
-
let
|
|
2588
|
+
let Ke = null;
|
|
2589
2589
|
const Qe = /* @__PURE__ */ new Set();
|
|
2590
2590
|
function Pt() {
|
|
2591
|
-
return
|
|
2591
|
+
return Ke;
|
|
2592
2592
|
}
|
|
2593
|
-
function
|
|
2594
|
-
|
|
2593
|
+
function ve(e) {
|
|
2594
|
+
Ke = e, Qe.forEach((t) => t(e));
|
|
2595
2595
|
}
|
|
2596
2596
|
function _t(e) {
|
|
2597
2597
|
return Qe.add(e), () => Qe.delete(e);
|
|
2598
2598
|
}
|
|
2599
|
-
const
|
|
2600
|
-
let Ye =
|
|
2599
|
+
const Hn = 12e4, Gn = 12e4;
|
|
2600
|
+
let Ye = Hn, Nt = Gn;
|
|
2601
2601
|
const ne = Jt.create({
|
|
2602
2602
|
// BaseURL is set dynamically via ApiProvider -> api.updateConfig
|
|
2603
2603
|
timeout: Ye,
|
|
@@ -2613,13 +2613,13 @@ function Wn(e) {
|
|
|
2613
2613
|
function Jn() {
|
|
2614
2614
|
return Nt;
|
|
2615
2615
|
}
|
|
2616
|
-
ne.interceptors.request.use((e) => (
|
|
2616
|
+
ne.interceptors.request.use((e) => (Ke && (e.headers.Authorization = `Bearer ${Ke}`), e));
|
|
2617
2617
|
ne.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, o = 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(ze.authToken, r),
|
|
2622
|
+
r && (localStorage.setItem(ze.authToken, r), ve(r)), o && localStorage.setItem(ze.authTokenExpiresAt, o.toString()), (r || o) && window.dispatchEvent(
|
|
2623
2623
|
new CustomEvent("smartorg:chat-token-updated", {
|
|
2624
2624
|
detail: { token: r, expiresAt: o }
|
|
2625
2625
|
})
|
|
@@ -2660,7 +2660,7 @@ class Yn {
|
|
|
2660
2660
|
const n = t.baseUrl.replace(/\/+$/, "");
|
|
2661
2661
|
ne.defaults.baseURL = n;
|
|
2662
2662
|
}
|
|
2663
|
-
t.apiKey !== void 0 ?
|
|
2663
|
+
t.apiKey !== void 0 ? ve(t.apiKey) : t.getToken && ve(t.getToken()), (t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0) && Wn({
|
|
2664
2664
|
requestTimeoutMs: t.requestTimeoutMs,
|
|
2665
2665
|
historyTimeoutMs: t.historyTimeoutMs
|
|
2666
2666
|
});
|
|
@@ -2670,7 +2670,7 @@ class Yn {
|
|
|
2670
2670
|
return Pt();
|
|
2671
2671
|
}
|
|
2672
2672
|
setAuthToken(t) {
|
|
2673
|
-
|
|
2673
|
+
ve(t);
|
|
2674
2674
|
}
|
|
2675
2675
|
onTokenChange(t) {
|
|
2676
2676
|
return _t(t);
|
|
@@ -2820,14 +2820,14 @@ class er {
|
|
|
2820
2820
|
const n = t.baseUrl.replace(/\/+$/, "");
|
|
2821
2821
|
this._authBaseUrl = `${n}/auth`;
|
|
2822
2822
|
}
|
|
2823
|
-
t.apiKey !== void 0 ?
|
|
2823
|
+
t.apiKey !== void 0 ? ve(t.apiKey) : t.getToken && ve(t.getToken());
|
|
2824
2824
|
}
|
|
2825
2825
|
// ---- Token Management ----
|
|
2826
2826
|
getAuthToken() {
|
|
2827
2827
|
return Pt();
|
|
2828
2828
|
}
|
|
2829
2829
|
setAuthToken(t) {
|
|
2830
|
-
|
|
2830
|
+
ve(t);
|
|
2831
2831
|
}
|
|
2832
2832
|
onTokenChange(t) {
|
|
2833
2833
|
return _t(t);
|
|
@@ -2838,12 +2838,12 @@ class er {
|
|
|
2838
2838
|
return (t == null ? void 0 : t.users) ?? [];
|
|
2839
2839
|
}
|
|
2840
2840
|
}
|
|
2841
|
-
const tr = new er(), Lt =
|
|
2841
|
+
const tr = new er(), Lt = Ce(null);
|
|
2842
2842
|
function nr({ children: e, apiConfig: t }) {
|
|
2843
2843
|
const n = zt, r = tr;
|
|
2844
2844
|
if (t) {
|
|
2845
|
-
const s = n.baseUrl, a = r.baseUrl, i = n.getAuthToken(),
|
|
2846
|
-
(t.baseUrl || t.chatBaseUrl ||
|
|
2845
|
+
const s = n.baseUrl, a = r.baseUrl, i = n.getAuthToken(), u = t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0;
|
|
2846
|
+
(t.baseUrl || t.chatBaseUrl || u) && (u || t.chatBaseUrl && t.chatBaseUrl !== s || t.baseUrl && !s.startsWith(t.baseUrl)) && n.updateConfig(t), (t.baseUrl || t.authBaseUrl) && (t.authBaseUrl && t.authBaseUrl !== a || t.baseUrl && !a.startsWith(t.baseUrl)) && r.updateConfig(t), t.apiKey !== void 0 && t.apiKey !== i && (n.updateConfig({ apiKey: t.apiKey }), r.updateConfig({ apiKey: t.apiKey }));
|
|
2847
2847
|
}
|
|
2848
2848
|
const o = {
|
|
2849
2849
|
token: n.getAuthToken(),
|
|
@@ -2865,7 +2865,7 @@ async function rr(e) {
|
|
|
2865
2865
|
const o = r.result, s = new Uint8Array(o);
|
|
2866
2866
|
let a = "";
|
|
2867
2867
|
const i = s.byteLength;
|
|
2868
|
-
for (let
|
|
2868
|
+
for (let u = 0; u < i; u++) a += String.fromCharCode(s[u]);
|
|
2869
2869
|
t(btoa(a));
|
|
2870
2870
|
} catch (o) {
|
|
2871
2871
|
n(o);
|
|
@@ -2930,7 +2930,7 @@ function lo(e) {
|
|
|
2930
2930
|
}).join("|") : "", r = "checkpointId" in e && e.checkpointId ? `cp:${e.checkpointId}` : "", o = "checkpointNs" in e && e.checkpointNs ? `ns:${e.checkpointNs}` : "", s = [r, o].filter(Boolean).join("|");
|
|
2931
2931
|
return `${e.id}:${t}:${n}${s ? `:${s}` : ""}`;
|
|
2932
2932
|
}
|
|
2933
|
-
function
|
|
2933
|
+
function Me() {
|
|
2934
2934
|
const e = Ue(Lt);
|
|
2935
2935
|
if (!e) throw new Error("useApi must be used within ApiProvider");
|
|
2936
2936
|
return e;
|
|
@@ -3009,72 +3009,72 @@ function fr(e, t) {
|
|
|
3009
3009
|
return "type" in n || (n.type = e), n;
|
|
3010
3010
|
}
|
|
3011
3011
|
function pr(e = {}) {
|
|
3012
|
-
const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, o] =
|
|
3012
|
+
const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, o] = $(e.token ?? null), s = W(e.headers ?? {}), a = e.credentials ?? "include", i = W(e);
|
|
3013
3013
|
X(() => {
|
|
3014
3014
|
i.current = e;
|
|
3015
3015
|
}, [e]);
|
|
3016
|
-
const
|
|
3017
|
-
var j,
|
|
3018
|
-
const
|
|
3019
|
-
if (!
|
|
3020
|
-
(j =
|
|
3021
|
-
}, []), [c, l] =
|
|
3022
|
-
o(
|
|
3016
|
+
const u = _((g) => {
|
|
3017
|
+
var j, M, O, F, C, B, N, V, z, L;
|
|
3018
|
+
const b = i.current;
|
|
3019
|
+
if (!b) return;
|
|
3020
|
+
(j = b.onEvent) == null || j.call(b, g), g.type === "thread_info" && ((M = b.onThreadInfo) == null || M.call(b, g)), g.type === "values" && Array.isArray(g.checkpoints) && ((O = b.handleValuesEvent) == null || O.call(b, g)), g.type === "metadata" && ((F = b.onMetadataEvent) == null || F.call(b, g)), typeof g.type == "string" && (g.type === "custom" || g.type.startsWith("custom.")) && ((C = b.onCustomEvent) == null || C.call(b, g)), g.type === "updates" && ((B = b.onUpdateEvent) == null || B.call(b, g)), g.type === "tool.end" ? (N = b.onToolEnd) == null || N.call(b, g) : g.type === "tool.start" && ((V = b.onToolStart) == null || V.call(b, g)), g.type === "heartbeat" && ((z = b.onHeartbeat) == null || z.call(b, g)), g.type === "token" && ((L = b.onToken) == null || L.call(b, g.token));
|
|
3021
|
+
}, []), [c, l] = $(!1), [d, m] = $(null), [y, I] = $(!1), [f, k] = $(null), p = W(null), S = W(!0), A = W(null), E = _((g) => {
|
|
3022
|
+
o(g);
|
|
3023
3023
|
}, []), v = _(() => {
|
|
3024
|
-
|
|
3025
|
-
}, []),
|
|
3026
|
-
var
|
|
3024
|
+
m(null), k(null);
|
|
3025
|
+
}, []), w = _(() => {
|
|
3026
|
+
var M, O;
|
|
3027
3027
|
console.debug("[use-chat] stop() invoked - aborting stream");
|
|
3028
|
-
const
|
|
3029
|
-
var
|
|
3030
|
-
(
|
|
3028
|
+
const g = (M = A.current) == null ? void 0 : M.threadId, b = (O = A.current) == null ? void 0 : O.runId, P = () => {
|
|
3029
|
+
var F;
|
|
3030
|
+
(F = p.current) == null || F.abort(), p.current = null, A.current = null, l(!1), I(!1);
|
|
3031
3031
|
};
|
|
3032
|
-
(
|
|
3033
|
-
console.warn("[use-chat] cancel run failed:",
|
|
3032
|
+
(b || g ? zt.cancelRun(b || g).catch((F) => {
|
|
3033
|
+
console.warn("[use-chat] cancel run failed:", F);
|
|
3034
3034
|
}) : Promise.resolve()).finally(P);
|
|
3035
|
-
}, []),
|
|
3036
|
-
(
|
|
3037
|
-
|
|
3038
|
-
const
|
|
3039
|
-
text: typeof
|
|
3040
|
-
threadId:
|
|
3041
|
-
attachments:
|
|
3042
|
-
payload:
|
|
3043
|
-
...
|
|
3044
|
-
creativityLevel:
|
|
3035
|
+
}, []), x = _(
|
|
3036
|
+
(g) => {
|
|
3037
|
+
p.current && (p.current.abort(), p.current = null);
|
|
3038
|
+
const b = {
|
|
3039
|
+
text: typeof g.content == "string" ? g.content : g.text,
|
|
3040
|
+
threadId: g.threadId,
|
|
3041
|
+
attachments: g.attachments,
|
|
3042
|
+
payload: g.payload ? {
|
|
3043
|
+
...g.payload,
|
|
3044
|
+
creativityLevel: g.payload.creativityLevel ?? "medium"
|
|
3045
3045
|
} : { creativityLevel: "medium" },
|
|
3046
|
-
config:
|
|
3047
|
-
checkpointId:
|
|
3048
|
-
checkpointNs:
|
|
3049
|
-
edit:
|
|
3050
|
-
command:
|
|
3046
|
+
config: g.config,
|
|
3047
|
+
checkpointId: g.checkpointId,
|
|
3048
|
+
checkpointNs: g.checkpointNs || void 0,
|
|
3049
|
+
edit: g.edit ?? !1,
|
|
3050
|
+
command: g.command
|
|
3051
3051
|
};
|
|
3052
|
-
l(!0),
|
|
3052
|
+
l(!0), m(null), k(null);
|
|
3053
3053
|
const P = new AbortController();
|
|
3054
|
-
|
|
3055
|
-
let j = null,
|
|
3056
|
-
return
|
|
3057
|
-
threadId:
|
|
3054
|
+
p.current = P;
|
|
3055
|
+
let j = null, M = !1;
|
|
3056
|
+
return A.current = {
|
|
3057
|
+
threadId: b.threadId ?? void 0,
|
|
3058
3058
|
runId: void 0,
|
|
3059
3059
|
// Will be updated from headers
|
|
3060
3060
|
headers: {},
|
|
3061
3061
|
isStreaming: !0
|
|
3062
3062
|
}, (async () => {
|
|
3063
|
-
var O,
|
|
3063
|
+
var O, F, C, B, N, V;
|
|
3064
3064
|
try {
|
|
3065
3065
|
let z = {};
|
|
3066
3066
|
try {
|
|
3067
3067
|
if (r)
|
|
3068
3068
|
z = { Authorization: `Bearer ${r}` };
|
|
3069
3069
|
else if (typeof window < "u") {
|
|
3070
|
-
const te = window.__AUTH_TOKEN__,
|
|
3070
|
+
const te = window.__AUTH_TOKEN__, ke = ((O = window.localStorage) == null ? void 0 : O.getItem(ze.authToken)) || null;
|
|
3071
3071
|
let Q = null;
|
|
3072
3072
|
try {
|
|
3073
|
-
const ge = (
|
|
3074
|
-
ge && (Q = ((
|
|
3073
|
+
const ge = (F = window.localStorage) == null ? void 0 : F.getItem(ze.chatSettings);
|
|
3074
|
+
ge && (Q = ((C = JSON.parse(ge)) == null ? void 0 : C.apiKey) || null);
|
|
3075
3075
|
} catch {
|
|
3076
3076
|
}
|
|
3077
|
-
const Z = te ||
|
|
3077
|
+
const Z = te || ke || Q || null;
|
|
3078
3078
|
Z && (z = { Authorization: `Bearer ${Z}` });
|
|
3079
3079
|
}
|
|
3080
3080
|
} catch {
|
|
@@ -3083,26 +3083,26 @@ function pr(e = {}) {
|
|
|
3083
3083
|
let L = {};
|
|
3084
3084
|
if (typeof window < "u")
|
|
3085
3085
|
try {
|
|
3086
|
-
const G = (
|
|
3086
|
+
const G = (B = window.localStorage) == null ? void 0 : B.getItem(ze.authSessionId);
|
|
3087
3087
|
G && (L = { "X-Session-Id": G });
|
|
3088
3088
|
} catch {
|
|
3089
3089
|
}
|
|
3090
|
-
const
|
|
3090
|
+
const H = {
|
|
3091
3091
|
...z,
|
|
3092
3092
|
...L,
|
|
3093
3093
|
...s.current
|
|
3094
|
-
},
|
|
3094
|
+
}, h = {
|
|
3095
3095
|
"Content-Type": "application/json",
|
|
3096
3096
|
Accept: "text/event-stream",
|
|
3097
|
-
...
|
|
3097
|
+
...H
|
|
3098
3098
|
}, U = await fetch(t + n, {
|
|
3099
3099
|
method: "POST",
|
|
3100
|
-
headers:
|
|
3101
|
-
body: JSON.stringify(
|
|
3100
|
+
headers: h,
|
|
3101
|
+
body: JSON.stringify(b),
|
|
3102
3102
|
signal: P.signal,
|
|
3103
3103
|
credentials: a
|
|
3104
3104
|
});
|
|
3105
|
-
if (
|
|
3105
|
+
if (A.current && (A.current.headers = H), !U.ok || !U.body) {
|
|
3106
3106
|
const G = await U.text().catch(() => "");
|
|
3107
3107
|
console.debug(
|
|
3108
3108
|
"[use-chat] non-OK response",
|
|
@@ -3110,45 +3110,45 @@ function pr(e = {}) {
|
|
|
3110
3110
|
G == null ? void 0 : G.slice(0, 500)
|
|
3111
3111
|
);
|
|
3112
3112
|
const te = `stream ${U.status}${G ? ": " + G : ""}`;
|
|
3113
|
-
throw te && (
|
|
3113
|
+
throw te && (m(te), j = "error"), new Error(te);
|
|
3114
3114
|
}
|
|
3115
|
-
|
|
3115
|
+
I(!0);
|
|
3116
3116
|
const T = U.body.getReader(), J = new TextDecoder();
|
|
3117
|
-
let
|
|
3117
|
+
let K = "", q = 0, ee = Date.now();
|
|
3118
3118
|
const re = setInterval(() => {
|
|
3119
|
-
Date.now() - ee > 18e5 && (
|
|
3119
|
+
Date.now() - ee > 18e5 && (m("Stream idle timeout"), j = "error", P.abort());
|
|
3120
3120
|
}, 5e3), ue = 1024 * 1024;
|
|
3121
3121
|
try {
|
|
3122
3122
|
const G = U.headers.get("X-Thread-Id") || U.headers.get("x-thread-id"), te = U.headers.get("X-Run-Id") || U.headers.get("x-run-id");
|
|
3123
|
-
for (
|
|
3124
|
-
...
|
|
3125
|
-
threadId: G ??
|
|
3126
|
-
runId: te ??
|
|
3123
|
+
for (A.current && (A.current = {
|
|
3124
|
+
...A.current,
|
|
3125
|
+
threadId: G ?? A.current.threadId,
|
|
3126
|
+
runId: te ?? A.current.runId
|
|
3127
3127
|
}); ; ) {
|
|
3128
|
-
const { value:
|
|
3128
|
+
const { value: ke, done: Q } = await T.read();
|
|
3129
3129
|
if (Q) break;
|
|
3130
|
-
|
|
3130
|
+
K += J.decode(ke, { stream: !0 }), K.length > ue && (K = "", console.warn("Stream buffer reset: exceeded 1MB"));
|
|
3131
3131
|
let Z;
|
|
3132
|
-
for (; (Z =
|
|
3132
|
+
for (; (Z = K.indexOf(`
|
|
3133
3133
|
|
|
3134
3134
|
`)) >= 0; ) {
|
|
3135
|
-
const ge =
|
|
3136
|
-
|
|
3137
|
-
const je = ge.split(/\r?\n/),
|
|
3135
|
+
const ge = K.slice(0, Z);
|
|
3136
|
+
K = K.slice(Z + 2);
|
|
3137
|
+
const je = ge.split(/\r?\n/), Be = [];
|
|
3138
3138
|
let me = null;
|
|
3139
3139
|
for (const he of je)
|
|
3140
3140
|
if (!he.startsWith(":") && he) {
|
|
3141
3141
|
if (he.startsWith("event:")) {
|
|
3142
|
-
const
|
|
3143
|
-
|
|
3142
|
+
const xe = he.slice(6).trim();
|
|
3143
|
+
xe && (me = xe);
|
|
3144
3144
|
continue;
|
|
3145
3145
|
}
|
|
3146
3146
|
if (he.startsWith("data:")) {
|
|
3147
|
-
const
|
|
3148
|
-
|
|
3147
|
+
const xe = he.slice(5);
|
|
3148
|
+
Be.push(xe.startsWith(" ") ? xe.slice(1) : xe);
|
|
3149
3149
|
}
|
|
3150
3150
|
}
|
|
3151
|
-
const Ie =
|
|
3151
|
+
const Ie = Be.join(`
|
|
3152
3152
|
`);
|
|
3153
3153
|
if (!Ie) continue;
|
|
3154
3154
|
let oe;
|
|
@@ -3164,17 +3164,17 @@ function pr(e = {}) {
|
|
|
3164
3164
|
console.warn("[use-chat] dropped envelope event without payload", oe);
|
|
3165
3165
|
continue;
|
|
3166
3166
|
}
|
|
3167
|
-
const
|
|
3167
|
+
const Ae = $n(Pe);
|
|
3168
3168
|
ee = Date.now();
|
|
3169
|
-
const ye = typeof
|
|
3169
|
+
const ye = typeof Ae.seq == "number" ? Ae.seq : void 0;
|
|
3170
3170
|
if (ye !== void 0) {
|
|
3171
|
-
if (ye <=
|
|
3172
|
-
console.debug("[use-chat] drop duplicate/out-of-order event", { seq: ye, lastProcessedSeq:
|
|
3171
|
+
if (ye <= q) {
|
|
3172
|
+
console.debug("[use-chat] drop duplicate/out-of-order event", { seq: ye, lastProcessedSeq: q, type: Ae.type });
|
|
3173
3173
|
continue;
|
|
3174
3174
|
}
|
|
3175
|
-
|
|
3175
|
+
q = ye;
|
|
3176
3176
|
}
|
|
3177
|
-
|
|
3177
|
+
u(Ae);
|
|
3178
3178
|
}
|
|
3179
3179
|
}
|
|
3180
3180
|
j === null && !P.signal.aborted && (j = "complete");
|
|
@@ -3183,7 +3183,7 @@ function pr(e = {}) {
|
|
|
3183
3183
|
j = j ?? "aborted";
|
|
3184
3184
|
else {
|
|
3185
3185
|
const te = G.message || String(G);
|
|
3186
|
-
j = "error",
|
|
3186
|
+
j = "error", m(te);
|
|
3187
3187
|
}
|
|
3188
3188
|
} finally {
|
|
3189
3189
|
try {
|
|
@@ -3199,7 +3199,7 @@ function pr(e = {}) {
|
|
|
3199
3199
|
j = j ?? "aborted";
|
|
3200
3200
|
else {
|
|
3201
3201
|
const L = z.message || String(z);
|
|
3202
|
-
j = "error",
|
|
3202
|
+
j = "error", m(L), M || (M = !0, (V = e.onConnectionError) == null || V.call(e, L));
|
|
3203
3203
|
}
|
|
3204
3204
|
} finally {
|
|
3205
3205
|
try {
|
|
@@ -3216,29 +3216,29 @@ function pr(e = {}) {
|
|
|
3216
3216
|
} catch (z) {
|
|
3217
3217
|
console.warn("[use-chat] onClosed callback failed", z);
|
|
3218
3218
|
}
|
|
3219
|
-
l(!1),
|
|
3219
|
+
l(!1), I(!1), p.current = null, A.current = null;
|
|
3220
3220
|
}
|
|
3221
3221
|
})(), Promise.resolve();
|
|
3222
3222
|
},
|
|
3223
|
-
[t, n, r, e,
|
|
3223
|
+
[t, n, r, e, u]
|
|
3224
3224
|
);
|
|
3225
3225
|
return X(() => () => {
|
|
3226
|
-
var
|
|
3227
|
-
|
|
3226
|
+
var g;
|
|
3227
|
+
S.current = !1, (g = p.current) == null || g.abort();
|
|
3228
3228
|
}, []), {
|
|
3229
3229
|
isStreaming: c,
|
|
3230
|
-
error:
|
|
3230
|
+
error: d,
|
|
3231
3231
|
assistantText: "",
|
|
3232
3232
|
// Deprecated: use messages from reducer
|
|
3233
|
-
activeMessageId:
|
|
3233
|
+
activeMessageId: f,
|
|
3234
3234
|
streamedMessages: {},
|
|
3235
3235
|
// Deprecated: use messages from reducer
|
|
3236
3236
|
lastCheckpointId: null,
|
|
3237
3237
|
// Deprecated: use checkpoint from reducer
|
|
3238
3238
|
lastSeq: 0,
|
|
3239
|
-
connected:
|
|
3240
|
-
stream:
|
|
3241
|
-
stop:
|
|
3239
|
+
connected: y,
|
|
3240
|
+
stream: x,
|
|
3241
|
+
stop: w,
|
|
3242
3242
|
clear: v,
|
|
3243
3243
|
setToken: E,
|
|
3244
3244
|
values: {},
|
|
@@ -3246,10 +3246,10 @@ function pr(e = {}) {
|
|
|
3246
3246
|
interrupt: () => Promise.resolve(),
|
|
3247
3247
|
resume: () => Promise.resolve(),
|
|
3248
3248
|
goto: () => Promise.resolve(),
|
|
3249
|
-
connectionState:
|
|
3249
|
+
connectionState: d ? "error" : c ? y ? "connected" : "connecting" : "idle",
|
|
3250
3250
|
messages: [],
|
|
3251
3251
|
// useStream doesn't maintain messages, use useChatSession instead
|
|
3252
|
-
submit:
|
|
3252
|
+
submit: x
|
|
3253
3253
|
};
|
|
3254
3254
|
}
|
|
3255
3255
|
function gr({
|
|
@@ -3259,77 +3259,77 @@ function gr({
|
|
|
3259
3259
|
onThreadChange: r,
|
|
3260
3260
|
onCurrentThreadDeleted: o
|
|
3261
3261
|
}) {
|
|
3262
|
-
const [s, a] =
|
|
3262
|
+
const [s, a] = $([]), [i, u] = $(t), [c, l] = $(!1), [d, m] = $(null), y = W(i), I = W(/* @__PURE__ */ new Map());
|
|
3263
3263
|
X(() => {
|
|
3264
|
-
|
|
3264
|
+
y.current = i;
|
|
3265
3265
|
}, [i]), X(() => {
|
|
3266
|
-
t !== void 0 && t !==
|
|
3266
|
+
t !== void 0 && t !== y.current && u(t);
|
|
3267
3267
|
}, [t]);
|
|
3268
|
-
const
|
|
3269
|
-
l(!0),
|
|
3268
|
+
const f = _(async () => {
|
|
3269
|
+
l(!0), m(null);
|
|
3270
3270
|
try {
|
|
3271
3271
|
const v = await e.listThreads();
|
|
3272
3272
|
a(v ?? []);
|
|
3273
3273
|
} catch (v) {
|
|
3274
|
-
const
|
|
3275
|
-
|
|
3274
|
+
const w = String(v);
|
|
3275
|
+
m(w), n == null || n(w);
|
|
3276
3276
|
} finally {
|
|
3277
3277
|
l(!1);
|
|
3278
3278
|
}
|
|
3279
3279
|
}, [e, n]);
|
|
3280
3280
|
X(() => {
|
|
3281
|
-
|
|
3282
|
-
}, [
|
|
3281
|
+
f();
|
|
3282
|
+
}, [f]), X(() => {
|
|
3283
3283
|
r == null || r(i);
|
|
3284
3284
|
}, [i, r]);
|
|
3285
|
-
const
|
|
3286
|
-
async (v,
|
|
3285
|
+
const k = _(
|
|
3286
|
+
async (v, w) => {
|
|
3287
3287
|
try {
|
|
3288
|
-
const
|
|
3289
|
-
return
|
|
3290
|
-
} catch (
|
|
3291
|
-
const
|
|
3292
|
-
return n == null || n(
|
|
3288
|
+
const x = w && typeof w == "object" ? { id: w.id, name: w.name ?? "" } : void 0, g = await e.createThread(v, x);
|
|
3289
|
+
return u(g.threadId), await f(), g.threadId;
|
|
3290
|
+
} catch (x) {
|
|
3291
|
+
const g = String(x);
|
|
3292
|
+
return n == null || n(g), null;
|
|
3293
3293
|
}
|
|
3294
3294
|
},
|
|
3295
|
-
[e, n,
|
|
3296
|
-
),
|
|
3295
|
+
[e, n, f]
|
|
3296
|
+
), p = _(
|
|
3297
3297
|
async (v) => {
|
|
3298
|
-
const
|
|
3299
|
-
a((
|
|
3300
|
-
const
|
|
3301
|
-
|
|
3298
|
+
const w = s;
|
|
3299
|
+
a((g) => g.filter((b) => b.threadId !== v));
|
|
3300
|
+
const x = new AbortController();
|
|
3301
|
+
I.current.set(v, x);
|
|
3302
3302
|
try {
|
|
3303
|
-
await e.deleteThread(v),
|
|
3304
|
-
} catch (
|
|
3305
|
-
a(
|
|
3306
|
-
const
|
|
3307
|
-
n == null || n(
|
|
3303
|
+
await e.deleteThread(v), y.current === v && (u(null), o == null || o());
|
|
3304
|
+
} catch (g) {
|
|
3305
|
+
a(w);
|
|
3306
|
+
const b = String(g);
|
|
3307
|
+
n == null || n(b);
|
|
3308
3308
|
} finally {
|
|
3309
|
-
|
|
3309
|
+
I.current.delete(v);
|
|
3310
3310
|
}
|
|
3311
3311
|
},
|
|
3312
3312
|
[e, o, n, s]
|
|
3313
|
-
),
|
|
3314
|
-
async (v,
|
|
3313
|
+
), S = _(
|
|
3314
|
+
async (v, w) => {
|
|
3315
3315
|
try {
|
|
3316
|
-
await e.updateThread(v,
|
|
3317
|
-
} catch (
|
|
3318
|
-
n == null || n(String(
|
|
3316
|
+
await e.updateThread(v, w), await f();
|
|
3317
|
+
} catch (x) {
|
|
3318
|
+
n == null || n(String(x));
|
|
3319
3319
|
}
|
|
3320
3320
|
},
|
|
3321
|
-
[e, n,
|
|
3322
|
-
),
|
|
3321
|
+
[e, n, f]
|
|
3322
|
+
), A = Y(
|
|
3323
3323
|
() => ({
|
|
3324
|
-
createThread:
|
|
3325
|
-
deleteThread:
|
|
3326
|
-
renameThread:
|
|
3327
|
-
refreshThreads:
|
|
3324
|
+
createThread: k,
|
|
3325
|
+
deleteThread: p,
|
|
3326
|
+
renameThread: S,
|
|
3327
|
+
refreshThreads: f
|
|
3328
3328
|
}),
|
|
3329
|
-
[
|
|
3329
|
+
[k, p, S, f]
|
|
3330
3330
|
), E = _((v) => {
|
|
3331
3331
|
if (!(v != null && v.threadId)) return;
|
|
3332
|
-
const
|
|
3332
|
+
const w = {
|
|
3333
3333
|
threadId: v.threadId,
|
|
3334
3334
|
title: v.title || `Thread ${v.threadId.slice(0, 8)}`,
|
|
3335
3335
|
project: v.project,
|
|
@@ -3337,80 +3337,80 @@ function gr({
|
|
|
3337
3337
|
updatedAt: v.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
3338
3338
|
messageCount: v.messageCount ?? 1
|
|
3339
3339
|
};
|
|
3340
|
-
a((
|
|
3341
|
-
let
|
|
3342
|
-
const
|
|
3340
|
+
a((x) => {
|
|
3341
|
+
let g = !1;
|
|
3342
|
+
const b = x.map((P) => P.threadId === w.threadId ? (g = !0, console.debug("[useThreadsState] thread_info: updating existing thread", w.threadId), {
|
|
3343
3343
|
...P,
|
|
3344
|
-
title:
|
|
3345
|
-
project:
|
|
3346
|
-
updatedAt:
|
|
3347
|
-
messageCount:
|
|
3344
|
+
title: w.title ?? P.title,
|
|
3345
|
+
project: w.project ?? P.project,
|
|
3346
|
+
updatedAt: w.updatedAt ?? P.updatedAt,
|
|
3347
|
+
messageCount: w.messageCount ?? P.messageCount
|
|
3348
3348
|
}) : P);
|
|
3349
|
-
return
|
|
3349
|
+
return g ? b : (console.debug("[useThreadsState] thread_info: adding thread to list", w.threadId), [w, ...x]);
|
|
3350
3350
|
});
|
|
3351
3351
|
}, []);
|
|
3352
3352
|
return {
|
|
3353
3353
|
threads: s,
|
|
3354
3354
|
currentThreadId: i,
|
|
3355
|
-
currentThreadIdRef:
|
|
3356
|
-
setCurrentThreadId:
|
|
3355
|
+
currentThreadIdRef: y,
|
|
3356
|
+
setCurrentThreadId: u,
|
|
3357
3357
|
isLoadingThreads: c,
|
|
3358
|
-
threadsError:
|
|
3359
|
-
actions:
|
|
3358
|
+
threadsError: d,
|
|
3359
|
+
actions: A,
|
|
3360
3360
|
addThreadFromEvent: E
|
|
3361
3361
|
};
|
|
3362
3362
|
}
|
|
3363
|
-
const jt =
|
|
3363
|
+
const jt = Ce(null);
|
|
3364
3364
|
function mr({
|
|
3365
3365
|
children: e,
|
|
3366
3366
|
initialThreadId: t = null,
|
|
3367
3367
|
onError: n,
|
|
3368
3368
|
onThreadChange: r
|
|
3369
3369
|
}) {
|
|
3370
|
-
const { chatApi: o } =
|
|
3370
|
+
const { chatApi: o } = Me(), {
|
|
3371
3371
|
threads: s,
|
|
3372
3372
|
currentThreadId: a,
|
|
3373
3373
|
setCurrentThreadId: i,
|
|
3374
|
-
currentThreadIdRef:
|
|
3374
|
+
currentThreadIdRef: u,
|
|
3375
3375
|
isLoadingThreads: c,
|
|
3376
3376
|
threadsError: l,
|
|
3377
|
-
actions:
|
|
3378
|
-
addThreadFromEvent:
|
|
3377
|
+
actions: d,
|
|
3378
|
+
addThreadFromEvent: m
|
|
3379
3379
|
} = gr({
|
|
3380
3380
|
api: o,
|
|
3381
3381
|
initialThreadId: t,
|
|
3382
3382
|
onError: n,
|
|
3383
3383
|
onThreadChange: r
|
|
3384
|
-
}),
|
|
3384
|
+
}), y = Y(
|
|
3385
3385
|
() => ({
|
|
3386
3386
|
threads: s,
|
|
3387
3387
|
currentThreadId: a,
|
|
3388
3388
|
setCurrentThreadId: i,
|
|
3389
|
-
currentThreadIdRef:
|
|
3389
|
+
currentThreadIdRef: u,
|
|
3390
3390
|
isLoading: c,
|
|
3391
3391
|
error: l,
|
|
3392
|
-
actions:
|
|
3393
|
-
addThreadFromEvent:
|
|
3392
|
+
actions: d,
|
|
3393
|
+
addThreadFromEvent: m
|
|
3394
3394
|
}),
|
|
3395
3395
|
[
|
|
3396
3396
|
s,
|
|
3397
3397
|
a,
|
|
3398
3398
|
i,
|
|
3399
|
-
|
|
3399
|
+
u,
|
|
3400
3400
|
c,
|
|
3401
3401
|
l,
|
|
3402
|
-
|
|
3403
|
-
|
|
3402
|
+
d,
|
|
3403
|
+
m
|
|
3404
3404
|
]
|
|
3405
3405
|
);
|
|
3406
|
-
return /* @__PURE__ */ ie(jt.Provider, { value:
|
|
3406
|
+
return /* @__PURE__ */ ie(jt.Provider, { value: y, children: e });
|
|
3407
3407
|
}
|
|
3408
3408
|
function ot(e) {
|
|
3409
3409
|
const t = Ue(jt);
|
|
3410
3410
|
if (!t && !(e != null && e.optional)) throw new Error("useThreads must be used within a ThreadsProvider");
|
|
3411
3411
|
return t;
|
|
3412
3412
|
}
|
|
3413
|
-
function
|
|
3413
|
+
function Bt(e) {
|
|
3414
3414
|
const t = e.artifact;
|
|
3415
3415
|
return !t || typeof t != "object" ? null : "metadata" in t && t.metadata ? t.metadata : {
|
|
3416
3416
|
id: t.id ?? e.id ?? `artifact-${Date.now()}`,
|
|
@@ -3421,7 +3421,7 @@ function Ft(e) {
|
|
|
3421
3421
|
};
|
|
3422
3422
|
}
|
|
3423
3423
|
function yr(e, t) {
|
|
3424
|
-
const n =
|
|
3424
|
+
const n = Bt(e);
|
|
3425
3425
|
if (!n) return e;
|
|
3426
3426
|
const r = {
|
|
3427
3427
|
...n,
|
|
@@ -3438,25 +3438,26 @@ function yr(e, t) {
|
|
|
3438
3438
|
}
|
|
3439
3439
|
function hr(e, t, n) {
|
|
3440
3440
|
return e.find((r) => {
|
|
3441
|
-
const o =
|
|
3441
|
+
const o = Bt(r);
|
|
3442
3442
|
return !!((o == null ? void 0 : o.id) === t || n && r.toolCallId === n);
|
|
3443
3443
|
}) ?? null;
|
|
3444
3444
|
}
|
|
3445
|
-
function
|
|
3446
|
-
|
|
3445
|
+
function Oe(e) {
|
|
3446
|
+
const t = /* @__PURE__ */ new Set();
|
|
3447
|
+
return e.map((n) => nt(n)).filter((n) => !n || t.has(n.id) ? !1 : (t.add(n.id), !0));
|
|
3447
3448
|
}
|
|
3448
|
-
function
|
|
3449
|
+
function Ft(e, t, n) {
|
|
3449
3450
|
return t < 0 || t >= e.length ? e : [...e.slice(0, t), n, ...e.slice(t + 1)];
|
|
3450
3451
|
}
|
|
3451
3452
|
function br(e, t, n) {
|
|
3452
3453
|
for (let r = e.length - 1; r >= 0; r--)
|
|
3453
3454
|
if (e[r].role === "assistant") {
|
|
3454
3455
|
const s = { ...e[r], checkpointId: t, checkpointNs: n ?? void 0 };
|
|
3455
|
-
return
|
|
3456
|
+
return Ft(e, r, s);
|
|
3456
3457
|
}
|
|
3457
3458
|
return e;
|
|
3458
3459
|
}
|
|
3459
|
-
const
|
|
3460
|
+
const Ot = {
|
|
3460
3461
|
status: "idle",
|
|
3461
3462
|
messages: [],
|
|
3462
3463
|
taskMessagesByScope: {},
|
|
@@ -3479,8 +3480,8 @@ function wr(e, t) {
|
|
|
3479
3480
|
};
|
|
3480
3481
|
case "reset":
|
|
3481
3482
|
return {
|
|
3482
|
-
...
|
|
3483
|
-
messages:
|
|
3483
|
+
...Ot,
|
|
3484
|
+
messages: Oe(((n = t.payload) == null ? void 0 : n.messages) ?? [])
|
|
3484
3485
|
};
|
|
3485
3486
|
case "user_message": {
|
|
3486
3487
|
const { message: r } = t.payload;
|
|
@@ -3494,7 +3495,7 @@ function wr(e, t) {
|
|
|
3494
3495
|
};
|
|
3495
3496
|
}
|
|
3496
3497
|
case "seed": {
|
|
3497
|
-
const r =
|
|
3498
|
+
const r = Oe(t.payload.messages), o = {
|
|
3498
3499
|
...e,
|
|
3499
3500
|
status: "idle",
|
|
3500
3501
|
messages: r,
|
|
@@ -3506,7 +3507,7 @@ function wr(e, t) {
|
|
|
3506
3507
|
return Object.prototype.hasOwnProperty.call(t.payload, "checkpointId") && (o.lastCheckpointId = t.payload.checkpointId ?? null), Object.prototype.hasOwnProperty.call(t.payload, "checkpointNs") && (o.lastCheckpointNs = t.payload.checkpointNs ?? null), Object.prototype.hasOwnProperty.call(t.payload, "values") && (o.values = t.payload.values ?? {}), o;
|
|
3507
3508
|
}
|
|
3508
3509
|
case "prepend": {
|
|
3509
|
-
const r =
|
|
3510
|
+
const r = Oe(t.payload.messages);
|
|
3510
3511
|
if (!r.length) return e;
|
|
3511
3512
|
const o = new Set(e.messages.map((a) => a.id)), s = r.filter((a) => !o.has(a.id));
|
|
3512
3513
|
return s.length ? { ...e, messages: [...s, ...e.messages] } : e;
|
|
@@ -3521,8 +3522,8 @@ function wr(e, t) {
|
|
|
3521
3522
|
return e;
|
|
3522
3523
|
}
|
|
3523
3524
|
}
|
|
3524
|
-
function
|
|
3525
|
-
const [t, n] = Wt(wr, { ...
|
|
3525
|
+
function kr(e = []) {
|
|
3526
|
+
const [t, n] = Wt(wr, { ...Ot, messages: e }), r = W([]), o = W(null), s = _(() => {
|
|
3526
3527
|
o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), o.current = null;
|
|
3527
3528
|
const c = r.current;
|
|
3528
3529
|
c.length && (r.current = [], n({ type: "batch", payload: { events: c } }));
|
|
@@ -3530,14 +3531,14 @@ function vr(e = []) {
|
|
|
3530
3531
|
typeof window < "u" && typeof window.requestAnimationFrame == "function" ? o.current === null && (o.current = window.requestAnimationFrame(() => s())) : setTimeout(s, 8);
|
|
3531
3532
|
}, [s]), i = _((c) => {
|
|
3532
3533
|
r.current.push(c), a();
|
|
3533
|
-
}, [a]),
|
|
3534
|
+
}, [a]), u = Y(() => ({
|
|
3534
3535
|
setStatus: (c, l) => n({ type: "status", payload: { status: c, error: l } }),
|
|
3535
3536
|
reset: (c) => n({ type: "reset", payload: { messages: c } }),
|
|
3536
3537
|
seed: (c, l) => n({ type: "seed", payload: { messages: c, ...l ?? {} } }),
|
|
3537
3538
|
pushUser: (c, l) => n({ type: "user_message", payload: { message: c, editingMessageId: l } }),
|
|
3538
3539
|
onEvent: i
|
|
3539
3540
|
}), [i]);
|
|
3540
|
-
return { state: t, dispatch: n, ...
|
|
3541
|
+
return { state: t, dispatch: n, ...u };
|
|
3541
3542
|
}
|
|
3542
3543
|
function pt(e, t) {
|
|
3543
3544
|
const n = t.origin, r = t.scope, o = n === "task" || typeof r == "string" && r.startsWith("tools:");
|
|
@@ -3570,31 +3571,33 @@ function pt(e, t) {
|
|
|
3570
3571
|
return { ...e, status: "error", error: t.message, messages: [...e.messages, s] };
|
|
3571
3572
|
}
|
|
3572
3573
|
if (t.type === "values" && "messages" in t && Array.isArray(t.messages)) {
|
|
3573
|
-
const s = t, a = Array.isArray(s.messages) ? s.messages : [], i =
|
|
3574
|
+
const s = t, a = Array.isArray(s.messages) ? s.messages : [], i = Oe(a), { messages: u, ...c } = s, l = c.__interrupt__ ?? c.interrupts, d = Array.isArray(l) && l.length > 0 ? {
|
|
3574
3575
|
id: l[0].id || "native-interrupt",
|
|
3575
3576
|
value: l[0].value || l[0],
|
|
3576
3577
|
alternatives: l[0].alternatives
|
|
3577
3578
|
} : null;
|
|
3578
3579
|
if (o) {
|
|
3579
|
-
const
|
|
3580
|
+
const m = typeof r == "string" && r.length > 0 ? r : "task";
|
|
3580
3581
|
return {
|
|
3581
3582
|
...e,
|
|
3582
|
-
taskMessagesByScope: { ...e.taskMessagesByScope, [
|
|
3583
|
+
taskMessagesByScope: { ...e.taskMessagesByScope, [m]: i },
|
|
3584
|
+
assemblingId: null
|
|
3585
|
+
// Clear streaming state when finalized
|
|
3583
3586
|
};
|
|
3584
3587
|
}
|
|
3585
3588
|
return {
|
|
3586
3589
|
...e,
|
|
3587
|
-
status:
|
|
3590
|
+
status: d ? "awaiting_input" : e.status === "streaming" ? "idle" : e.status,
|
|
3588
3591
|
messages: i,
|
|
3589
3592
|
assemblingId: null,
|
|
3590
|
-
pendingInterrupt:
|
|
3593
|
+
pendingInterrupt: d,
|
|
3591
3594
|
values: c
|
|
3592
3595
|
};
|
|
3593
3596
|
}
|
|
3594
3597
|
if (t.type === "messages/metadata") {
|
|
3595
3598
|
const s = { ...e.messagesStreamMeta ?? {} }, a = t.metadata;
|
|
3596
|
-
return a && typeof a == "object" && Object.entries(a).forEach(([i,
|
|
3597
|
-
const c =
|
|
3599
|
+
return a && typeof a == "object" && Object.entries(a).forEach(([i, u]) => {
|
|
3600
|
+
const c = u == null ? void 0 : u.metadata;
|
|
3598
3601
|
if (!c || typeof c != "object") return;
|
|
3599
3602
|
const l = s[i] ?? {};
|
|
3600
3603
|
s[i] = {
|
|
@@ -3603,49 +3606,50 @@ function pt(e, t) {
|
|
|
3603
3606
|
};
|
|
3604
3607
|
}), { ...e, messagesStreamMeta: s };
|
|
3605
3608
|
}
|
|
3606
|
-
return t.type === "messages/partial" ?
|
|
3609
|
+
return t.type === "messages/partial" ? vr(e, t, o) : t.type === "tool.start" ? { ...Ir(e, t, o), status: "streaming" } : t.type === "tool.progress" ? Ar(e, t, o) : t.type === "tool.end" ? xr(e, t, o) : t.type === "artifact.update" ? Tr(e, t) : e;
|
|
3607
3610
|
}
|
|
3608
|
-
function
|
|
3609
|
-
var
|
|
3610
|
-
const
|
|
3611
|
-
if (!
|
|
3611
|
+
function vr(e, t, n) {
|
|
3612
|
+
var m, y, I, f, k;
|
|
3613
|
+
const r = t.messages;
|
|
3614
|
+
if (!r.length)
|
|
3612
3615
|
return console.warn("[messagesReducer] Dropping messages/partial event without messages[]", t), e;
|
|
3613
|
-
const
|
|
3614
|
-
if (!
|
|
3615
|
-
const
|
|
3616
|
-
let
|
|
3617
|
-
if (
|
|
3618
|
-
const
|
|
3619
|
-
...
|
|
3616
|
+
const o = r.find((p) => p.type === "ai" || p.type === "assistant" || p.role === "assistant");
|
|
3617
|
+
if (!o) return e;
|
|
3618
|
+
const s = o.id, a = o.content ?? "", i = typeof a == "string" ? [{ type: "text", text: a }] : Array.isArray(a) ? a.map((p) => typeof p == "string" ? { type: "text", text: p } : (p == null ? void 0 : p.type) === "text" ? { type: "text", text: typeof p.text == "string" ? p.text : p.content ?? "" } : ((p == null ? void 0 : p.type) === "reasoning", p)) : [], u = i.filter((p) => p.type === "text").map((p) => p.text).join(""), c = e.assemblingId !== s, l = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
|
|
3619
|
+
let d = n ? [...e.taskMessagesByScope[l] || []] : [...e.messages];
|
|
3620
|
+
if (c) {
|
|
3621
|
+
const p = nt({
|
|
3622
|
+
...o,
|
|
3620
3623
|
role: "assistant",
|
|
3621
|
-
content:
|
|
3624
|
+
content: i,
|
|
3622
3625
|
scope: t.scope,
|
|
3623
3626
|
origin: t.origin
|
|
3624
3627
|
});
|
|
3625
|
-
|
|
3628
|
+
p && d.push(p);
|
|
3626
3629
|
} else {
|
|
3627
|
-
const
|
|
3628
|
-
if (
|
|
3629
|
-
const
|
|
3630
|
-
|
|
3631
|
-
...
|
|
3632
|
-
content:
|
|
3633
|
-
scope: t.scope ??
|
|
3634
|
-
origin: t.origin ??
|
|
3630
|
+
const p = d.findIndex((S) => S.id === s);
|
|
3631
|
+
if (p !== -1) {
|
|
3632
|
+
const S = d[p];
|
|
3633
|
+
d[p] = {
|
|
3634
|
+
...S,
|
|
3635
|
+
content: i,
|
|
3636
|
+
scope: t.scope ?? S.scope,
|
|
3637
|
+
origin: t.origin ?? S.origin
|
|
3635
3638
|
};
|
|
3636
3639
|
}
|
|
3637
3640
|
}
|
|
3638
3641
|
return {
|
|
3639
3642
|
...e,
|
|
3640
3643
|
status: "streaming",
|
|
3641
|
-
messages:
|
|
3642
|
-
|
|
3644
|
+
messages: n ? e.messages : d,
|
|
3645
|
+
taskMessagesByScope: n ? { ...e.taskMessagesByScope, [l]: d } : e.taskMessagesByScope,
|
|
3646
|
+
assemblingId: s,
|
|
3643
3647
|
messagesStreamMeta: {
|
|
3644
3648
|
...e.messagesStreamMeta ?? {},
|
|
3645
|
-
[
|
|
3646
|
-
...((
|
|
3647
|
-
lastSeq: t.seq ?? ((
|
|
3648
|
-
lastText:
|
|
3649
|
+
[s]: {
|
|
3650
|
+
...((m = e.messagesStreamMeta) == null ? void 0 : m[s]) ?? {},
|
|
3651
|
+
lastSeq: t.seq ?? ((I = (y = e.messagesStreamMeta) == null ? void 0 : y[s]) == null ? void 0 : I.lastSeq) ?? null,
|
|
3652
|
+
lastText: u || (((k = (f = e.messagesStreamMeta) == null ? void 0 : f[s]) == null ? void 0 : k.lastText) ?? "")
|
|
3649
3653
|
}
|
|
3650
3654
|
}
|
|
3651
3655
|
};
|
|
@@ -3660,21 +3664,21 @@ function st(e, t) {
|
|
|
3660
3664
|
}
|
|
3661
3665
|
return -1;
|
|
3662
3666
|
}
|
|
3663
|
-
function Ir(e, t) {
|
|
3664
|
-
const
|
|
3665
|
-
if (!
|
|
3666
|
-
const
|
|
3667
|
-
let
|
|
3668
|
-
if (
|
|
3669
|
-
for (let
|
|
3670
|
-
if (
|
|
3671
|
-
|
|
3667
|
+
function Ir(e, t, n) {
|
|
3668
|
+
const r = t.id || t.callId;
|
|
3669
|
+
if (!r) return e;
|
|
3670
|
+
const o = t.name || "tool", s = `Starting ${o}...`, a = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
|
|
3671
|
+
let i = n ? [...e.taskMessagesByScope[a] || []] : [...e.messages], u = st(i, r);
|
|
3672
|
+
if (u === -1) {
|
|
3673
|
+
for (let c = i.length - 1; c >= 0; c--)
|
|
3674
|
+
if (i[c].role === "assistant") {
|
|
3675
|
+
u = c;
|
|
3672
3676
|
break;
|
|
3673
3677
|
}
|
|
3674
3678
|
}
|
|
3675
|
-
if (
|
|
3676
|
-
const
|
|
3677
|
-
id: `assistant-${
|
|
3679
|
+
if (u === -1) {
|
|
3680
|
+
const c = {
|
|
3681
|
+
id: `assistant-${r}`,
|
|
3678
3682
|
role: "assistant",
|
|
3679
3683
|
content: [{ type: "text", text: "" }],
|
|
3680
3684
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -3682,76 +3686,90 @@ function Ir(e, t) {
|
|
|
3682
3686
|
scope: t.scope,
|
|
3683
3687
|
origin: t.origin
|
|
3684
3688
|
};
|
|
3685
|
-
|
|
3689
|
+
i.push(c), u = i.length - 1;
|
|
3686
3690
|
}
|
|
3687
|
-
if (
|
|
3688
|
-
const
|
|
3689
|
-
|
|
3690
|
-
id:
|
|
3691
|
-
name:
|
|
3691
|
+
if (u !== -1) {
|
|
3692
|
+
const c = i[u], l = [...c.toolCalls || []], d = l.findIndex((m) => m.id === r);
|
|
3693
|
+
d >= 0 ? l[d] = { ...l[d], status: "running", content: s } : l.push({
|
|
3694
|
+
id: r,
|
|
3695
|
+
name: o,
|
|
3692
3696
|
args: t.args || {},
|
|
3693
3697
|
status: "running",
|
|
3694
|
-
content:
|
|
3695
|
-
}),
|
|
3696
|
-
...
|
|
3697
|
-
toolCalls:
|
|
3698
|
-
scope: t.scope ??
|
|
3699
|
-
origin: t.origin ??
|
|
3698
|
+
content: s
|
|
3699
|
+
}), i[u] = {
|
|
3700
|
+
...c,
|
|
3701
|
+
toolCalls: l,
|
|
3702
|
+
scope: t.scope ?? c.scope,
|
|
3703
|
+
origin: t.origin ?? c.origin
|
|
3700
3704
|
};
|
|
3701
3705
|
}
|
|
3702
|
-
return {
|
|
3706
|
+
return {
|
|
3707
|
+
...e,
|
|
3708
|
+
messages: n ? e.messages : i,
|
|
3709
|
+
taskMessagesByScope: n ? { ...e.taskMessagesByScope, [a]: i } : e.taskMessagesByScope
|
|
3710
|
+
};
|
|
3703
3711
|
}
|
|
3704
|
-
function
|
|
3705
|
-
const
|
|
3706
|
-
if (!
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
+
function Ar(e, t, n) {
|
|
3713
|
+
const r = t.id;
|
|
3714
|
+
if (!r) return e;
|
|
3715
|
+
const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
|
|
3716
|
+
let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
|
|
3717
|
+
const a = st(s, r);
|
|
3718
|
+
if (a !== -1) {
|
|
3719
|
+
const i = s[a], u = ce(t.content), c = (i.toolCalls || []).map(
|
|
3720
|
+
(l) => l.id === r ? { ...l, content: typeof u == "string" ? u : l.content } : l
|
|
3712
3721
|
);
|
|
3713
|
-
|
|
3714
|
-
...
|
|
3715
|
-
toolCalls:
|
|
3716
|
-
scope: t.scope ??
|
|
3717
|
-
origin: t.origin ??
|
|
3722
|
+
s[a] = {
|
|
3723
|
+
...i,
|
|
3724
|
+
toolCalls: c,
|
|
3725
|
+
scope: t.scope ?? i.scope,
|
|
3726
|
+
origin: t.origin ?? i.origin
|
|
3718
3727
|
};
|
|
3719
3728
|
}
|
|
3720
|
-
return {
|
|
3729
|
+
return {
|
|
3730
|
+
...e,
|
|
3731
|
+
messages: n ? e.messages : s,
|
|
3732
|
+
taskMessagesByScope: n ? { ...e.taskMessagesByScope, [o]: s } : e.taskMessagesByScope
|
|
3733
|
+
};
|
|
3721
3734
|
}
|
|
3722
|
-
function
|
|
3723
|
-
const
|
|
3724
|
-
if (!
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3735
|
+
function xr(e, t, n) {
|
|
3736
|
+
const r = t.id;
|
|
3737
|
+
if (!r) return e;
|
|
3738
|
+
const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
|
|
3739
|
+
let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
|
|
3740
|
+
const a = st(s, r), i = ce(t.content ?? t.error);
|
|
3741
|
+
if (a !== -1) {
|
|
3742
|
+
const c = s[a], l = (c.toolCalls || []).map(
|
|
3743
|
+
(d) => d.id === r ? {
|
|
3744
|
+
...d,
|
|
3731
3745
|
status: t.error ? "failed" : "completed",
|
|
3732
|
-
content: typeof
|
|
3746
|
+
content: typeof i == "string" ? i : d.content,
|
|
3733
3747
|
artifact: t.artifact
|
|
3734
|
-
} :
|
|
3748
|
+
} : d
|
|
3735
3749
|
);
|
|
3736
|
-
|
|
3737
|
-
...
|
|
3738
|
-
toolCalls:
|
|
3739
|
-
scope: t.scope ??
|
|
3740
|
-
origin: t.origin ??
|
|
3750
|
+
s[a] = {
|
|
3751
|
+
...c,
|
|
3752
|
+
toolCalls: l,
|
|
3753
|
+
scope: t.scope ?? c.scope,
|
|
3754
|
+
origin: t.origin ?? c.origin
|
|
3741
3755
|
};
|
|
3742
3756
|
}
|
|
3743
|
-
const
|
|
3744
|
-
id: `tool-${
|
|
3757
|
+
const u = {
|
|
3758
|
+
id: `tool-${r}`,
|
|
3745
3759
|
role: "tool",
|
|
3746
3760
|
name: t.name,
|
|
3747
|
-
content: [{ type: "text", text: typeof
|
|
3761
|
+
content: [{ type: "text", text: typeof i == "string" ? i : "" }],
|
|
3748
3762
|
artifact: t.artifact,
|
|
3749
|
-
toolCallId:
|
|
3763
|
+
toolCallId: r,
|
|
3750
3764
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3751
3765
|
scope: t.scope,
|
|
3752
3766
|
origin: t.origin
|
|
3753
3767
|
};
|
|
3754
|
-
return
|
|
3768
|
+
return s.push(u), {
|
|
3769
|
+
...e,
|
|
3770
|
+
messages: n ? e.messages : s,
|
|
3771
|
+
taskMessagesByScope: n ? { ...e.taskMessagesByScope, [o]: s } : e.taskMessagesByScope
|
|
3772
|
+
};
|
|
3755
3773
|
}
|
|
3756
3774
|
function Tr(e, t) {
|
|
3757
3775
|
const n = t.artifactId, r = hr(e.messages, n, t.callId);
|
|
@@ -3761,13 +3779,13 @@ function Tr(e, t) {
|
|
|
3761
3779
|
progress: t.progress,
|
|
3762
3780
|
error: t.error
|
|
3763
3781
|
});
|
|
3764
|
-
return t.partial_data && s.artifact && (s.artifact = { ...s.artifact, ...t.partial_data }), { ...e, messages:
|
|
3782
|
+
return t.partial_data && s.artifact && (s.artifact = { ...s.artifact, ...t.partial_data }), { ...e, messages: Ft(e.messages, o, s) };
|
|
3765
3783
|
}
|
|
3766
3784
|
function Re(e) {
|
|
3767
3785
|
if (!(!e || typeof e != "object" || Array.isArray(e)))
|
|
3768
3786
|
return { ...e };
|
|
3769
3787
|
}
|
|
3770
|
-
function
|
|
3788
|
+
function Fe(e, t) {
|
|
3771
3789
|
if (e)
|
|
3772
3790
|
for (const n of t) {
|
|
3773
3791
|
const r = e[n];
|
|
@@ -3789,20 +3807,20 @@ function gt(e) {
|
|
|
3789
3807
|
if (t)
|
|
3790
3808
|
return Re(t.configurable) ?? t;
|
|
3791
3809
|
}
|
|
3792
|
-
async function
|
|
3793
|
-
var i,
|
|
3810
|
+
async function Mr(e, t) {
|
|
3811
|
+
var i, u;
|
|
3794
3812
|
if (!e) return e ?? null;
|
|
3795
3813
|
const n = le(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], o = /* @__PURE__ */ new Set();
|
|
3796
3814
|
for (const c of r) {
|
|
3797
3815
|
const l = (i = c == null ? void 0 : c.values) == null ? void 0 : i.messages;
|
|
3798
3816
|
if (Array.isArray(l))
|
|
3799
|
-
for (const
|
|
3800
|
-
const
|
|
3801
|
-
if (Array.isArray(
|
|
3802
|
-
for (const
|
|
3803
|
-
if (!
|
|
3804
|
-
const
|
|
3805
|
-
typeof
|
|
3817
|
+
for (const d of l) {
|
|
3818
|
+
const m = d == null ? void 0 : d.content;
|
|
3819
|
+
if (Array.isArray(m))
|
|
3820
|
+
for (const y of m) {
|
|
3821
|
+
if (!y || typeof y != "object" || y.type !== "image_url" && y.type !== "file") continue;
|
|
3822
|
+
const I = y.fileId || y.file_id;
|
|
3823
|
+
typeof I == "string" && I.trim() && o.add(I);
|
|
3806
3824
|
}
|
|
3807
3825
|
}
|
|
3808
3826
|
}
|
|
@@ -3811,32 +3829,32 @@ async function Cr(e, t) {
|
|
|
3811
3829
|
const s = await Promise.all(
|
|
3812
3830
|
Array.from(o).map(async (c) => {
|
|
3813
3831
|
try {
|
|
3814
|
-
const l = await t.getFileInfo(c),
|
|
3815
|
-
return [c,
|
|
3832
|
+
const l = await t.getFileInfo(c), d = le(l);
|
|
3833
|
+
return [c, d];
|
|
3816
3834
|
} catch {
|
|
3817
3835
|
return [c, null];
|
|
3818
3836
|
}
|
|
3819
3837
|
})
|
|
3820
3838
|
), a = new Map(s);
|
|
3821
3839
|
for (const c of r) {
|
|
3822
|
-
const l = (
|
|
3840
|
+
const l = (u = c == null ? void 0 : c.values) == null ? void 0 : u.messages;
|
|
3823
3841
|
if (Array.isArray(l))
|
|
3824
|
-
for (const
|
|
3825
|
-
const
|
|
3826
|
-
if (Array.isArray(
|
|
3827
|
-
for (const
|
|
3828
|
-
if (!
|
|
3829
|
-
const
|
|
3830
|
-
if (!
|
|
3831
|
-
const
|
|
3832
|
-
|
|
3842
|
+
for (const d of l) {
|
|
3843
|
+
const m = d == null ? void 0 : d.content;
|
|
3844
|
+
if (Array.isArray(m))
|
|
3845
|
+
for (const y of m) {
|
|
3846
|
+
if (!y || typeof y != "object" || y.type !== "image_url" && y.type !== "file") continue;
|
|
3847
|
+
const I = y.fileId || y.file_id;
|
|
3848
|
+
if (!I) continue;
|
|
3849
|
+
const f = a.get(I), k = (f == null ? void 0 : f.contentUrl) || (f == null ? void 0 : f.content_url);
|
|
3850
|
+
k && (y.type === "image_url" ? (y.imageUrl = y.imageUrl || {}, y.imageUrl.url = k) : y.type === "file" && (y.url = k, !y.name && (f != null && f.filename || f != null && f.name) && (y.name = (f == null ? void 0 : f.filename) || (f == null ? void 0 : f.name))));
|
|
3833
3851
|
}
|
|
3834
3852
|
}
|
|
3835
3853
|
}
|
|
3836
3854
|
return n;
|
|
3837
3855
|
}
|
|
3838
3856
|
function mt(e) {
|
|
3839
|
-
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((s, a) =>
|
|
3857
|
+
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((s, a) => Cr(le(s), a)).filter((s) => !!s)].sort((s, a) => yt(a.createdAt) - yt(s.createdAt)), o = r[0] ?? null;
|
|
3840
3858
|
return {
|
|
3841
3859
|
threadId: (e == null ? void 0 : e.threadId) ?? "",
|
|
3842
3860
|
latest: o,
|
|
@@ -3844,34 +3862,34 @@ function mt(e) {
|
|
|
3844
3862
|
interrupt: (o == null ? void 0 : o.interrupt) ?? null
|
|
3845
3863
|
};
|
|
3846
3864
|
}
|
|
3847
|
-
function
|
|
3848
|
-
var v,
|
|
3865
|
+
function Cr(e, t) {
|
|
3866
|
+
var v, w;
|
|
3849
3867
|
if (!e) return null;
|
|
3850
|
-
const n = ((v = e.values) == null ? void 0 : v.activeAgent) ?? null, r = (
|
|
3868
|
+
const n = ((v = e.values) == null ? void 0 : v.activeAgent) ?? null, r = (w = e.values) == null ? void 0 : w.messages, s = (Array.isArray(r) ? r : []).map((x) => Er(x, n)).filter((x) => !!x), a = Re(e.metadata) ?? {}, i = gt(e.config), u = Re(e.parentConfig), c = gt(u), l = Fe(i, ["checkpointId"]), d = Fe(i, ["checkpointNs"]), m = Fe(c, ["checkpointId"]), y = Re(e.config), I = Array.isArray(e.tasks) ? e.tasks.map((x) => ({ ...x })) : e.tasks ?? null, f = Array.isArray(e.next) ? [...e.next] : e.next ?? null, k = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), p = {
|
|
3851
3869
|
...a,
|
|
3852
3870
|
step: Sr(a, ["step"]) ?? 0,
|
|
3853
|
-
source:
|
|
3854
|
-
},
|
|
3855
|
-
...
|
|
3856
|
-
checkpointId:
|
|
3857
|
-
checkpointNs:
|
|
3858
|
-
})),
|
|
3871
|
+
source: Fe(a, ["source"]) ?? null
|
|
3872
|
+
}, S = s.map((x) => ({
|
|
3873
|
+
...x,
|
|
3874
|
+
checkpointId: x.checkpointId ?? l ?? null,
|
|
3875
|
+
checkpointNs: x.checkpointNs ?? d ?? null
|
|
3876
|
+
})), A = e.values, E = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(A == null ? void 0 : A.interrupts) ? A.interrupts : [];
|
|
3859
3877
|
return {
|
|
3860
3878
|
checkpointId: l ?? null,
|
|
3861
|
-
checkpointNs:
|
|
3862
|
-
createdAt:
|
|
3863
|
-
parentId:
|
|
3864
|
-
messages:
|
|
3879
|
+
checkpointNs: d ?? null,
|
|
3880
|
+
createdAt: k,
|
|
3881
|
+
parentId: m ?? null,
|
|
3882
|
+
messages: S,
|
|
3865
3883
|
interrupt: Pr(
|
|
3866
3884
|
E,
|
|
3867
3885
|
t,
|
|
3868
3886
|
l ?? null
|
|
3869
3887
|
),
|
|
3870
|
-
metadata:
|
|
3871
|
-
config:
|
|
3872
|
-
parentConfig:
|
|
3873
|
-
next:
|
|
3874
|
-
tasks:
|
|
3888
|
+
metadata: p,
|
|
3889
|
+
config: y ?? null,
|
|
3890
|
+
parentConfig: u ?? null,
|
|
3891
|
+
next: f,
|
|
3892
|
+
tasks: I,
|
|
3875
3893
|
values: e.values ?? {}
|
|
3876
3894
|
};
|
|
3877
3895
|
}
|
|
@@ -3916,33 +3934,33 @@ function Nr(e) {
|
|
|
3916
3934
|
function zr(e) {
|
|
3917
3935
|
const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), o = [];
|
|
3918
3936
|
for (let c = 0; c < e.length; c++) {
|
|
3919
|
-
const l = e[c],
|
|
3920
|
-
let
|
|
3921
|
-
const
|
|
3922
|
-
for (const
|
|
3923
|
-
|
|
3924
|
-
const
|
|
3925
|
-
id:
|
|
3926
|
-
step:
|
|
3927
|
-
source:
|
|
3937
|
+
const l = e[c], d = l.checkpointId, m = d ?? `cp-${c}`, y = l.metadata ?? {}, I = typeof y.step == "number" ? y.step : null, f = typeof y.source == "string" ? y.source : null;
|
|
3938
|
+
let k = null, p = null;
|
|
3939
|
+
const S = Array.isArray(l.messages) ? l.messages : [];
|
|
3940
|
+
for (const w of S)
|
|
3941
|
+
w.role === "user" && (p || (p = w), w.id && (k = w.id));
|
|
3942
|
+
const A = l.next && l.next.length > 0 ? String(l.next[0]) : null, E = l.parentConfig ?? null, v = {
|
|
3943
|
+
id: m,
|
|
3944
|
+
step: I,
|
|
3945
|
+
source: f,
|
|
3928
3946
|
createdAt: l.createdAt ?? null,
|
|
3929
3947
|
namespace: l.checkpointNs ?? null,
|
|
3930
3948
|
parentId: l.parentId ?? null,
|
|
3931
|
-
next:
|
|
3949
|
+
next: A,
|
|
3932
3950
|
parentConfig: E,
|
|
3933
|
-
userMessageId:
|
|
3951
|
+
userMessageId: k
|
|
3934
3952
|
};
|
|
3935
|
-
if (o.push(v),
|
|
3936
|
-
const
|
|
3937
|
-
|
|
3953
|
+
if (o.push(v), d && t.set(d, v), d && p) {
|
|
3954
|
+
const w = Nr(p);
|
|
3955
|
+
w && r.set(d, w);
|
|
3938
3956
|
}
|
|
3939
3957
|
n.push({
|
|
3940
|
-
id:
|
|
3941
|
-
messageId:
|
|
3942
|
-
step:
|
|
3943
|
-
source:
|
|
3958
|
+
id: m,
|
|
3959
|
+
messageId: k,
|
|
3960
|
+
step: I,
|
|
3961
|
+
source: f,
|
|
3944
3962
|
createdAt: l.createdAt ?? null,
|
|
3945
|
-
next:
|
|
3963
|
+
next: A,
|
|
3946
3964
|
parentConfig: E
|
|
3947
3965
|
});
|
|
3948
3966
|
}
|
|
@@ -3954,14 +3972,14 @@ function zr(e) {
|
|
|
3954
3972
|
}
|
|
3955
3973
|
for (const c of s.values()) {
|
|
3956
3974
|
if (!c.length) continue;
|
|
3957
|
-
c.sort((
|
|
3958
|
-
const
|
|
3959
|
-
return (
|
|
3975
|
+
c.sort((d, m) => {
|
|
3976
|
+
const y = d.createdAt ? Date.parse(d.createdAt) : 0;
|
|
3977
|
+
return (m.createdAt ? Date.parse(m.createdAt) : 0) - y;
|
|
3960
3978
|
});
|
|
3961
3979
|
const l = c.length;
|
|
3962
|
-
for (let
|
|
3963
|
-
const
|
|
3964
|
-
|
|
3980
|
+
for (let d = 0; d < c.length; d++) {
|
|
3981
|
+
const m = c[d];
|
|
3982
|
+
m.attemptCount = l, m.attemptIndex = d, m.isLatestAttempt = d === 0;
|
|
3965
3983
|
}
|
|
3966
3984
|
}
|
|
3967
3985
|
return {
|
|
@@ -3977,11 +3995,11 @@ function zr(e) {
|
|
|
3977
3995
|
getCheckpoint: (c) => t.get(c),
|
|
3978
3996
|
getMessageAttempts: (c) => {
|
|
3979
3997
|
const l = [];
|
|
3980
|
-
for (const
|
|
3981
|
-
|
|
3982
|
-
return l.length ? (l.sort((
|
|
3983
|
-
const
|
|
3984
|
-
return
|
|
3998
|
+
for (const d of t.values())
|
|
3999
|
+
d.userMessageId === c && l.push(d);
|
|
4000
|
+
return l.length ? (l.sort((d, m) => {
|
|
4001
|
+
const y = typeof d.attemptIndex == "number" ? d.attemptIndex : Number.MAX_SAFE_INTEGER, I = typeof m.attemptIndex == "number" ? m.attemptIndex : Number.MAX_SAFE_INTEGER;
|
|
4002
|
+
return y - I;
|
|
3985
4003
|
}), l) : [];
|
|
3986
4004
|
}
|
|
3987
4005
|
};
|
|
@@ -4016,43 +4034,43 @@ function $t({
|
|
|
4016
4034
|
isStreaming: a,
|
|
4017
4035
|
getMessages: i
|
|
4018
4036
|
}) {
|
|
4019
|
-
const [
|
|
4020
|
-
() => mt(
|
|
4021
|
-
[
|
|
4022
|
-
).checkpoints,
|
|
4037
|
+
const [u, c] = $(null), d = Y(
|
|
4038
|
+
() => mt(u),
|
|
4039
|
+
[u]
|
|
4040
|
+
).checkpoints, m = Rr(d), y = m.timeline, [I, f] = $(!1), [k, p] = $(!1), [S, A] = $(!1), [E, v] = $(null), w = W(o), x = W(null), g = W(null);
|
|
4023
4041
|
X(() => {
|
|
4024
|
-
|
|
4042
|
+
w.current = o;
|
|
4025
4043
|
}, [o]);
|
|
4026
|
-
const
|
|
4027
|
-
async (
|
|
4028
|
-
const
|
|
4029
|
-
threadId:
|
|
4030
|
-
checkpointId:
|
|
4031
|
-
checkpointNs:
|
|
4044
|
+
const b = _(
|
|
4045
|
+
async (C) => {
|
|
4046
|
+
const B = await e.getState({
|
|
4047
|
+
threadId: C.threadId,
|
|
4048
|
+
checkpointId: C.checkpointId,
|
|
4049
|
+
checkpointNs: C.checkpointNs
|
|
4032
4050
|
}), N = {
|
|
4033
4051
|
version: "values@1",
|
|
4034
|
-
threadId:
|
|
4035
|
-
checkpoints: [
|
|
4036
|
-
}, V = t ? await
|
|
4052
|
+
threadId: C.threadId,
|
|
4053
|
+
checkpoints: [B]
|
|
4054
|
+
}, V = t ? await Mr(N, t) : N, { latest: z } = mt(V);
|
|
4037
4055
|
return z;
|
|
4038
4056
|
},
|
|
4039
4057
|
[e, t]
|
|
4040
4058
|
), P = _(
|
|
4041
|
-
async (
|
|
4059
|
+
async (C, B) => {
|
|
4042
4060
|
var z;
|
|
4043
|
-
if (!
|
|
4044
|
-
const N = `${
|
|
4045
|
-
if (
|
|
4046
|
-
(z =
|
|
4061
|
+
if (!C) return;
|
|
4062
|
+
const N = `${C}:${B ?? "latest"}`;
|
|
4063
|
+
if (x.current === N || I) return;
|
|
4064
|
+
(z = g.current) == null || z.abort();
|
|
4047
4065
|
const V = new AbortController();
|
|
4048
|
-
|
|
4066
|
+
g.current = V, f(!0), v(null);
|
|
4049
4067
|
try {
|
|
4050
|
-
const L = await
|
|
4051
|
-
threadId:
|
|
4052
|
-
checkpointId:
|
|
4068
|
+
const L = await b({
|
|
4069
|
+
threadId: C,
|
|
4070
|
+
checkpointId: B ?? void 0
|
|
4053
4071
|
});
|
|
4054
|
-
if (
|
|
4055
|
-
|
|
4072
|
+
if (w.current !== C) {
|
|
4073
|
+
f(!1);
|
|
4056
4074
|
return;
|
|
4057
4075
|
}
|
|
4058
4076
|
n((L == null ? void 0 : L.messages) ?? [], {
|
|
@@ -4060,59 +4078,59 @@ function $t({
|
|
|
4060
4078
|
checkpointNs: (L == null ? void 0 : L.checkpointNs) ?? null,
|
|
4061
4079
|
pendingInterrupt: (L == null ? void 0 : L.interrupt) ?? null,
|
|
4062
4080
|
values: L == null ? void 0 : L.values
|
|
4063
|
-
}),
|
|
4081
|
+
}), x.current = N, f(!1), A(!0);
|
|
4064
4082
|
try {
|
|
4065
|
-
const
|
|
4066
|
-
threadId:
|
|
4083
|
+
const H = await e.getStateHistory({
|
|
4084
|
+
threadId: C,
|
|
4067
4085
|
limit: 100,
|
|
4068
4086
|
includeMessages: !1
|
|
4069
4087
|
});
|
|
4070
|
-
|
|
4088
|
+
w.current === C && c(H);
|
|
4071
4089
|
} finally {
|
|
4072
|
-
|
|
4090
|
+
A(!1);
|
|
4073
4091
|
}
|
|
4074
4092
|
} catch (L) {
|
|
4075
|
-
if (
|
|
4076
|
-
const
|
|
4077
|
-
v(
|
|
4093
|
+
if (f(!1), !Xt(L)) {
|
|
4094
|
+
const H = String(L);
|
|
4095
|
+
v(H), r == null || r(H);
|
|
4078
4096
|
}
|
|
4079
4097
|
}
|
|
4080
4098
|
},
|
|
4081
|
-
[e, n,
|
|
4099
|
+
[e, n, b, r, i]
|
|
4082
4100
|
), j = _(
|
|
4083
|
-
async (
|
|
4101
|
+
async (C, B) => {
|
|
4084
4102
|
if (o) {
|
|
4085
|
-
|
|
4103
|
+
p(!0);
|
|
4086
4104
|
try {
|
|
4087
|
-
const N = await
|
|
4105
|
+
const N = await b({
|
|
4088
4106
|
threadId: o,
|
|
4089
|
-
checkpointId:
|
|
4090
|
-
checkpointNs:
|
|
4107
|
+
checkpointId: C,
|
|
4108
|
+
checkpointNs: B ?? void 0
|
|
4091
4109
|
});
|
|
4092
4110
|
n((N == null ? void 0 : N.messages) ?? [], {
|
|
4093
|
-
checkpointId: (N == null ? void 0 : N.checkpointId) ??
|
|
4094
|
-
checkpointNs: (N == null ? void 0 : N.checkpointNs) ??
|
|
4111
|
+
checkpointId: (N == null ? void 0 : N.checkpointId) ?? C,
|
|
4112
|
+
checkpointNs: (N == null ? void 0 : N.checkpointNs) ?? B,
|
|
4095
4113
|
pendingInterrupt: (N == null ? void 0 : N.interrupt) ?? null,
|
|
4096
4114
|
values: N == null ? void 0 : N.values
|
|
4097
4115
|
});
|
|
4098
4116
|
} catch (N) {
|
|
4099
4117
|
console.error("[useThreadHistoryState] Navigation failed", N);
|
|
4100
4118
|
} finally {
|
|
4101
|
-
|
|
4119
|
+
p(!1);
|
|
4102
4120
|
}
|
|
4103
4121
|
}
|
|
4104
4122
|
},
|
|
4105
|
-
[o,
|
|
4106
|
-
),
|
|
4123
|
+
[o, b, n]
|
|
4124
|
+
), M = _(async () => {
|
|
4107
4125
|
o && await P(o);
|
|
4108
4126
|
}, [o, P]), O = _(
|
|
4109
|
-
async (
|
|
4127
|
+
async (C) => {
|
|
4110
4128
|
var V;
|
|
4111
|
-
const
|
|
4112
|
-
if (!
|
|
4113
|
-
if (c(
|
|
4114
|
-
const z = await
|
|
4115
|
-
threadId:
|
|
4129
|
+
const B = (C == null ? void 0 : C.threadId) || o;
|
|
4130
|
+
if (!B || o !== B) return;
|
|
4131
|
+
if (c(C), x.current = `${B}:latest`, (V = C.values) != null && V.messages) {
|
|
4132
|
+
const z = await b({
|
|
4133
|
+
threadId: B
|
|
4116
4134
|
});
|
|
4117
4135
|
z && n(z.messages ?? [], {
|
|
4118
4136
|
checkpointId: z.checkpointId ?? null,
|
|
@@ -4122,41 +4140,41 @@ function $t({
|
|
|
4122
4140
|
});
|
|
4123
4141
|
}
|
|
4124
4142
|
},
|
|
4125
|
-
[o,
|
|
4143
|
+
[o, b, n]
|
|
4126
4144
|
);
|
|
4127
4145
|
X(() => {
|
|
4128
|
-
if (!s || !o ||
|
|
4129
|
-
const
|
|
4130
|
-
|
|
4131
|
-
}, [s, o,
|
|
4132
|
-
const
|
|
4133
|
-
c(null),
|
|
4146
|
+
if (!s || !o || I || a) return;
|
|
4147
|
+
const C = `${o}:latest`;
|
|
4148
|
+
x.current !== C && P(o);
|
|
4149
|
+
}, [s, o, I, a, P]);
|
|
4150
|
+
const F = _(() => {
|
|
4151
|
+
c(null), f(!1), p(!1), A(!1), v(null), x.current = null;
|
|
4134
4152
|
}, []);
|
|
4135
4153
|
return {
|
|
4136
|
-
threadCheckpoints:
|
|
4137
|
-
threadTimeline:
|
|
4138
|
-
checkpointIndex:
|
|
4139
|
-
isLoadingThread:
|
|
4140
|
-
isLoadingCheckpoint:
|
|
4141
|
-
isLoadingHistory:
|
|
4154
|
+
threadCheckpoints: d,
|
|
4155
|
+
threadTimeline: y,
|
|
4156
|
+
checkpointIndex: m,
|
|
4157
|
+
isLoadingThread: I,
|
|
4158
|
+
isLoadingCheckpoint: k,
|
|
4159
|
+
isLoadingHistory: S,
|
|
4142
4160
|
threadStateError: E,
|
|
4143
4161
|
loadThread: P,
|
|
4144
4162
|
navigateToCheckpoint: j,
|
|
4145
|
-
setCurrentCheckpointId: (
|
|
4146
|
-
n(i(), { checkpointId:
|
|
4163
|
+
setCurrentCheckpointId: (C, B) => {
|
|
4164
|
+
n(i(), { checkpointId: C, checkpointNs: B });
|
|
4147
4165
|
},
|
|
4148
|
-
returnToLatest:
|
|
4166
|
+
returnToLatest: M,
|
|
4149
4167
|
handleValuesEvent: O,
|
|
4150
4168
|
markSkipNextLoad: () => {
|
|
4151
4169
|
},
|
|
4152
4170
|
markStreamPendingThread: () => {
|
|
4153
4171
|
},
|
|
4154
|
-
resetHistoryState:
|
|
4155
|
-
clearState:
|
|
4172
|
+
resetHistoryState: F,
|
|
4173
|
+
clearState: F
|
|
4156
4174
|
};
|
|
4157
4175
|
}
|
|
4158
|
-
const Dt =
|
|
4159
|
-
function
|
|
4176
|
+
const Dt = Ce(null), Vt = Ce(null);
|
|
4177
|
+
function Kt(e) {
|
|
4160
4178
|
const t = Ue(Dt);
|
|
4161
4179
|
if (!t && !(e != null && e.optional)) throw new Error("useThreadState must be used within a ThreadStateProvider");
|
|
4162
4180
|
return t;
|
|
@@ -4176,26 +4194,26 @@ function Ur({
|
|
|
4176
4194
|
isStreaming: s,
|
|
4177
4195
|
onError: a
|
|
4178
4196
|
}) {
|
|
4179
|
-
const { chatApi: i, fileApi:
|
|
4180
|
-
threadCheckpoints:
|
|
4181
|
-
threadTimeline:
|
|
4182
|
-
checkpointIndex:
|
|
4183
|
-
isLoadingThread:
|
|
4184
|
-
isLoadingCheckpoint:
|
|
4185
|
-
isLoadingHistory:
|
|
4197
|
+
const { chatApi: i, fileApi: u } = Me(), { currentThreadId: c } = ot(), { state: l, seed: d, onEvent: m, dispatch: y } = kr(), {
|
|
4198
|
+
threadCheckpoints: I,
|
|
4199
|
+
threadTimeline: f,
|
|
4200
|
+
checkpointIndex: k,
|
|
4201
|
+
isLoadingThread: p,
|
|
4202
|
+
isLoadingCheckpoint: S,
|
|
4203
|
+
isLoadingHistory: A,
|
|
4186
4204
|
threadStateError: E,
|
|
4187
4205
|
loadThread: v,
|
|
4188
|
-
navigateToCheckpoint:
|
|
4189
|
-
setCurrentCheckpointId:
|
|
4190
|
-
returnToLatest:
|
|
4191
|
-
handleValuesEvent:
|
|
4206
|
+
navigateToCheckpoint: w,
|
|
4207
|
+
setCurrentCheckpointId: x,
|
|
4208
|
+
returnToLatest: g,
|
|
4209
|
+
handleValuesEvent: b,
|
|
4192
4210
|
markSkipNextLoad: P,
|
|
4193
4211
|
markStreamPendingThread: j,
|
|
4194
|
-
resetHistoryState:
|
|
4212
|
+
resetHistoryState: M
|
|
4195
4213
|
} = $t({
|
|
4196
4214
|
api: i,
|
|
4197
|
-
fileApi:
|
|
4198
|
-
seed:
|
|
4215
|
+
fileApi: u,
|
|
4216
|
+
seed: d,
|
|
4199
4217
|
onError: a,
|
|
4200
4218
|
currentThreadId: c,
|
|
4201
4219
|
initialThreadId: t,
|
|
@@ -4204,33 +4222,33 @@ function Ur({
|
|
|
4204
4222
|
autoLoadInitial: o,
|
|
4205
4223
|
isStreaming: s,
|
|
4206
4224
|
getMessages: _(() => l.messages, [l.messages])
|
|
4207
|
-
}), O = W(null),
|
|
4225
|
+
}), O = W(null), F = _(
|
|
4208
4226
|
(T) => {
|
|
4209
4227
|
O.current = T;
|
|
4210
4228
|
},
|
|
4211
4229
|
[]
|
|
4212
|
-
),
|
|
4230
|
+
), C = W(null), B = _(
|
|
4213
4231
|
(T) => {
|
|
4214
|
-
|
|
4232
|
+
C.current = T;
|
|
4215
4233
|
},
|
|
4216
4234
|
[]
|
|
4217
4235
|
), N = Y(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), V = _(
|
|
4218
4236
|
(T, J) => {
|
|
4219
|
-
const
|
|
4220
|
-
return
|
|
4237
|
+
const K = Ut(T, "user");
|
|
4238
|
+
return y({
|
|
4221
4239
|
type: "user_message",
|
|
4222
4240
|
payload: {
|
|
4223
|
-
message:
|
|
4241
|
+
message: K,
|
|
4224
4242
|
editingMessageId: J == null ? void 0 : J.editingMessageId
|
|
4225
4243
|
}
|
|
4226
|
-
}),
|
|
4244
|
+
}), K;
|
|
4227
4245
|
},
|
|
4228
|
-
[
|
|
4246
|
+
[y]
|
|
4229
4247
|
), z = _(async () => {
|
|
4230
|
-
O.current ? await O.current() : (
|
|
4231
|
-
}, [
|
|
4248
|
+
O.current ? await O.current() : (d([], {}), M());
|
|
4249
|
+
}, [d, M]), L = _(async (T, J, K) => {
|
|
4232
4250
|
await v(T, J, { clearProgress: !1 });
|
|
4233
|
-
}, [v]),
|
|
4251
|
+
}, [v]), H = Y(() => Bn(l.messages), [l.messages]), h = Y(
|
|
4234
4252
|
() => ({
|
|
4235
4253
|
status: l.status,
|
|
4236
4254
|
threadId: c,
|
|
@@ -4241,20 +4259,20 @@ function Ur({
|
|
|
4241
4259
|
id: l.lastCheckpointId ?? null,
|
|
4242
4260
|
namespace: l.lastCheckpointNs ?? null
|
|
4243
4261
|
},
|
|
4244
|
-
checkpoints:
|
|
4245
|
-
checkpointIndex:
|
|
4246
|
-
timelineCheckpoints:
|
|
4262
|
+
checkpoints: I,
|
|
4263
|
+
checkpointIndex: k,
|
|
4264
|
+
timelineCheckpoints: f,
|
|
4247
4265
|
metadata: N,
|
|
4248
4266
|
values: l.values ?? {},
|
|
4249
|
-
isLoading:
|
|
4250
|
-
isLoadingCheckpoint:
|
|
4251
|
-
isLoadingHistory:
|
|
4267
|
+
isLoading: p,
|
|
4268
|
+
isLoadingCheckpoint: S,
|
|
4269
|
+
isLoadingHistory: A,
|
|
4252
4270
|
error: E,
|
|
4253
4271
|
loadOlder: async () => {
|
|
4254
4272
|
},
|
|
4255
4273
|
// Placeholder
|
|
4256
4274
|
seedFromSnapshot: (T) => {
|
|
4257
|
-
|
|
4275
|
+
d(T.messages, {
|
|
4258
4276
|
checkpointId: T.checkpointId,
|
|
4259
4277
|
checkpointNs: T.checkpointNs,
|
|
4260
4278
|
pendingInterrupt: T.interrupt,
|
|
@@ -4262,22 +4280,22 @@ function Ur({
|
|
|
4262
4280
|
});
|
|
4263
4281
|
},
|
|
4264
4282
|
clearState: z,
|
|
4265
|
-
navigateToCheckpoint:
|
|
4266
|
-
setCurrentCheckpointId:
|
|
4267
|
-
returnToLatest:
|
|
4283
|
+
navigateToCheckpoint: w,
|
|
4284
|
+
setCurrentCheckpointId: x,
|
|
4285
|
+
returnToLatest: g,
|
|
4268
4286
|
loadThread: L,
|
|
4269
4287
|
clearThread: z,
|
|
4270
|
-
respondToInterrupt: async (T, J,
|
|
4271
|
-
|
|
4288
|
+
respondToInterrupt: async (T, J, K) => {
|
|
4289
|
+
C.current && await C.current(T, J, K);
|
|
4272
4290
|
},
|
|
4273
|
-
messagePreviews:
|
|
4274
|
-
handleValuesEvent:
|
|
4291
|
+
messagePreviews: k.messagePreviews,
|
|
4292
|
+
handleValuesEvent: b,
|
|
4275
4293
|
markSkipNextLoad: P,
|
|
4276
4294
|
markStreamPendingThread: j,
|
|
4277
|
-
resetHistoryState:
|
|
4295
|
+
resetHistoryState: M,
|
|
4278
4296
|
pushUser: V,
|
|
4279
|
-
onEvent:
|
|
4280
|
-
artifacts:
|
|
4297
|
+
onEvent: m,
|
|
4298
|
+
artifacts: H
|
|
4281
4299
|
}),
|
|
4282
4300
|
[
|
|
4283
4301
|
c,
|
|
@@ -4287,38 +4305,38 @@ function Ur({
|
|
|
4287
4305
|
l.lastCheckpointId,
|
|
4288
4306
|
l.lastCheckpointNs,
|
|
4289
4307
|
l.values,
|
|
4308
|
+
I,
|
|
4309
|
+
f,
|
|
4290
4310
|
k,
|
|
4291
|
-
u,
|
|
4292
|
-
w,
|
|
4293
4311
|
N,
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4312
|
+
p,
|
|
4313
|
+
S,
|
|
4314
|
+
A,
|
|
4297
4315
|
E,
|
|
4298
|
-
|
|
4316
|
+
d,
|
|
4299
4317
|
z,
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4318
|
+
w,
|
|
4319
|
+
x,
|
|
4320
|
+
g,
|
|
4303
4321
|
L,
|
|
4304
|
-
|
|
4322
|
+
b,
|
|
4305
4323
|
P,
|
|
4306
4324
|
j,
|
|
4307
4325
|
V,
|
|
4308
|
-
|
|
4309
|
-
|
|
4326
|
+
m,
|
|
4327
|
+
H
|
|
4310
4328
|
]
|
|
4311
4329
|
), U = Y(
|
|
4312
4330
|
() => ({
|
|
4313
|
-
registerClearThread:
|
|
4314
|
-
registerRespondToInterrupt:
|
|
4331
|
+
registerClearThread: F,
|
|
4332
|
+
registerRespondToInterrupt: B
|
|
4315
4333
|
}),
|
|
4316
|
-
[
|
|
4334
|
+
[F, B]
|
|
4317
4335
|
);
|
|
4318
|
-
return /* @__PURE__ */ ie(Vt.Provider, { value: U, children: /* @__PURE__ */ ie(Dt.Provider, { value:
|
|
4336
|
+
return /* @__PURE__ */ ie(Vt.Provider, { value: U, children: /* @__PURE__ */ ie(Dt.Provider, { value: h, children: e }) });
|
|
4319
4337
|
}
|
|
4320
|
-
const
|
|
4321
|
-
function
|
|
4338
|
+
const qt = Ce(null), jr = Ce(!1);
|
|
4339
|
+
function Br({
|
|
4322
4340
|
children: e,
|
|
4323
4341
|
onError: t,
|
|
4324
4342
|
onAuthError: n,
|
|
@@ -4327,71 +4345,71 @@ function Fr({
|
|
|
4327
4345
|
onUpdateEvent: s,
|
|
4328
4346
|
onCustomEvent: a,
|
|
4329
4347
|
onMetadataEvent: i,
|
|
4330
|
-
onFinish:
|
|
4348
|
+
onFinish: u,
|
|
4331
4349
|
onStreamingChange: c
|
|
4332
4350
|
}) {
|
|
4333
|
-
const { chatApi: l, baseUrl:
|
|
4351
|
+
const { chatApi: l, baseUrl: d } = Me(), m = d, y = fe(t), I = fe(n), f = fe(r), k = fe(o), p = fe(s), S = fe(a), A = fe(i), E = fe(u), v = fe(c), w = Y(
|
|
4334
4352
|
() => ({
|
|
4335
|
-
onError:
|
|
4336
|
-
onAuthError:
|
|
4337
|
-
onConnectionError:
|
|
4338
|
-
onMetadataEvent:
|
|
4339
|
-
onCustomEvent:
|
|
4340
|
-
onUpdateEvent:
|
|
4341
|
-
onToolEnd:
|
|
4353
|
+
onError: y,
|
|
4354
|
+
onAuthError: I,
|
|
4355
|
+
onConnectionError: f,
|
|
4356
|
+
onMetadataEvent: A,
|
|
4357
|
+
onCustomEvent: S,
|
|
4358
|
+
onUpdateEvent: p,
|
|
4359
|
+
onToolEnd: k,
|
|
4342
4360
|
onFinish: E
|
|
4343
4361
|
}),
|
|
4344
4362
|
[
|
|
4345
|
-
|
|
4346
|
-
k,
|
|
4347
|
-
u,
|
|
4348
|
-
x,
|
|
4349
|
-
C,
|
|
4363
|
+
y,
|
|
4350
4364
|
I,
|
|
4351
|
-
|
|
4365
|
+
f,
|
|
4366
|
+
A,
|
|
4367
|
+
S,
|
|
4368
|
+
p,
|
|
4369
|
+
k,
|
|
4352
4370
|
E
|
|
4353
4371
|
]
|
|
4354
4372
|
);
|
|
4355
4373
|
return /* @__PURE__ */ ie(jr.Provider, { value: !0, children: /* @__PURE__ */ ie(
|
|
4356
|
-
|
|
4374
|
+
Fr,
|
|
4357
4375
|
{
|
|
4358
4376
|
api: l,
|
|
4359
|
-
streamBaseUrl:
|
|
4360
|
-
handlers:
|
|
4377
|
+
streamBaseUrl: m,
|
|
4378
|
+
handlers: w,
|
|
4361
4379
|
onStreamingChange: v,
|
|
4362
4380
|
children: e
|
|
4363
4381
|
}
|
|
4364
4382
|
) });
|
|
4365
4383
|
}
|
|
4366
|
-
function
|
|
4384
|
+
function Fr({
|
|
4367
4385
|
children: e,
|
|
4368
4386
|
api: t,
|
|
4369
4387
|
streamBaseUrl: n,
|
|
4370
4388
|
handlers: r,
|
|
4371
4389
|
onStreamingChange: o
|
|
4372
4390
|
}) {
|
|
4373
|
-
const { setCurrentThreadId: s, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId:
|
|
4391
|
+
const { setCurrentThreadId: s, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: u } = ot(), {
|
|
4374
4392
|
interrupt: c,
|
|
4375
4393
|
checkpoint: l,
|
|
4376
|
-
timelineCheckpoints:
|
|
4377
|
-
handleValuesEvent:
|
|
4378
|
-
markSkipNextLoad:
|
|
4379
|
-
markStreamPendingThread:
|
|
4380
|
-
resetHistoryState:
|
|
4381
|
-
pushUser:
|
|
4382
|
-
onEvent:
|
|
4383
|
-
messages:
|
|
4384
|
-
} =
|
|
4385
|
-
(
|
|
4386
|
-
i(
|
|
4394
|
+
timelineCheckpoints: d,
|
|
4395
|
+
handleValuesEvent: m,
|
|
4396
|
+
markSkipNextLoad: y,
|
|
4397
|
+
markStreamPendingThread: I,
|
|
4398
|
+
resetHistoryState: f,
|
|
4399
|
+
pushUser: k,
|
|
4400
|
+
onEvent: p,
|
|
4401
|
+
messages: S
|
|
4402
|
+
} = Kt(), { registerClearThread: A, registerRespondToInterrupt: E } = Lr(), v = _(
|
|
4403
|
+
(h) => {
|
|
4404
|
+
i(h), I(h.threadId), a.current !== h.threadId && ((h.created ?? !a.current) && y(h.threadId), s(h.threadId));
|
|
4387
4405
|
},
|
|
4388
|
-
[i,
|
|
4389
|
-
),
|
|
4406
|
+
[i, y, I, s, a]
|
|
4407
|
+
), w = pr({
|
|
4390
4408
|
baseUrl: n,
|
|
4391
|
-
onEvent:
|
|
4392
|
-
onError: (
|
|
4409
|
+
onEvent: p,
|
|
4410
|
+
onError: (h) => {
|
|
4393
4411
|
var U;
|
|
4394
|
-
(U = r.onError) == null || U.call(r, (
|
|
4412
|
+
(U = r.onError) == null || U.call(r, (h == null ? void 0 : h.message) ?? String(h));
|
|
4395
4413
|
},
|
|
4396
4414
|
onAuthError: r.onAuthError,
|
|
4397
4415
|
onConnectionError: r.onConnectionError,
|
|
@@ -4401,122 +4419,122 @@ function Or({
|
|
|
4401
4419
|
onCustomEvent: r.onCustomEvent,
|
|
4402
4420
|
onUpdateEvent: r.onUpdateEvent,
|
|
4403
4421
|
onToolEnd: r.onToolEnd,
|
|
4404
|
-
handleValuesEvent:
|
|
4422
|
+
handleValuesEvent: m
|
|
4405
4423
|
});
|
|
4406
4424
|
X(() => {
|
|
4407
|
-
o == null || o(
|
|
4408
|
-
}, [
|
|
4409
|
-
const { stream:
|
|
4425
|
+
o == null || o(w.isStreaming);
|
|
4426
|
+
}, [w.isStreaming, o]);
|
|
4427
|
+
const { stream: x, stop: g, clear: b, isStreaming: P, error: j, connected: M, streamedMessages: O, activeMessageId: F } = w;
|
|
4410
4428
|
X(() => {
|
|
4411
|
-
|
|
4412
|
-
}, [
|
|
4413
|
-
const
|
|
4414
|
-
async (
|
|
4415
|
-
await
|
|
4429
|
+
u !== void 0 && b();
|
|
4430
|
+
}, [u, b]);
|
|
4431
|
+
const C = _(
|
|
4432
|
+
async (h, U) => {
|
|
4433
|
+
await x(h, U);
|
|
4416
4434
|
},
|
|
4417
|
-
[
|
|
4418
|
-
),
|
|
4435
|
+
[x]
|
|
4436
|
+
), B = W(l);
|
|
4419
4437
|
X(() => {
|
|
4420
|
-
|
|
4438
|
+
B.current = l;
|
|
4421
4439
|
}, [l]);
|
|
4422
4440
|
const N = _(
|
|
4423
|
-
async (
|
|
4441
|
+
async (h, U, T) => {
|
|
4424
4442
|
var G;
|
|
4425
4443
|
const J = a.current;
|
|
4426
4444
|
if (!J)
|
|
4427
4445
|
throw new Error("No active thread to handle interrupt");
|
|
4428
|
-
const
|
|
4446
|
+
const K = h ? U ?? !0 : !1, q = B.current, ee = (T == null ? void 0 : T.checkpointId) ?? q.id ?? void 0, re = (T == null ? void 0 : T.checkpointNs) ?? q.namespace ?? void 0, ue = {
|
|
4429
4447
|
threadId: J,
|
|
4430
4448
|
checkpointId: ee,
|
|
4431
4449
|
checkpointNs: re,
|
|
4432
|
-
command: { kind: "resume", value:
|
|
4450
|
+
command: { kind: "resume", value: K },
|
|
4433
4451
|
payload: {
|
|
4434
4452
|
...(T == null ? void 0 : T.payload) ?? {},
|
|
4435
4453
|
creativityLevel: ((G = T == null ? void 0 : T.payload) == null ? void 0 : G.creativityLevel) ?? "medium"
|
|
4436
4454
|
},
|
|
4437
4455
|
edit: !1
|
|
4438
4456
|
};
|
|
4439
|
-
|
|
4457
|
+
C(ue);
|
|
4440
4458
|
},
|
|
4441
|
-
[a,
|
|
4459
|
+
[a, C]
|
|
4442
4460
|
);
|
|
4443
4461
|
X(() => {
|
|
4444
4462
|
E(N);
|
|
4445
4463
|
}, [N, E]);
|
|
4446
4464
|
const V = _(async () => {
|
|
4447
|
-
|
|
4448
|
-
}, [
|
|
4465
|
+
g(), b(), f(), s(null);
|
|
4466
|
+
}, [b, f, s, g]);
|
|
4449
4467
|
X(() => {
|
|
4450
|
-
|
|
4451
|
-
}, [V,
|
|
4468
|
+
A(V);
|
|
4469
|
+
}, [V, A]);
|
|
4452
4470
|
const z = _(
|
|
4453
|
-
async (
|
|
4454
|
-
P &&
|
|
4471
|
+
async (h, U) => {
|
|
4472
|
+
P && g();
|
|
4455
4473
|
let T = a.current;
|
|
4456
|
-
const J = (
|
|
4474
|
+
const J = (h == null ? void 0 : h.text) ?? "", K = (h == null ? void 0 : h.attachments) ?? [], q = (J == null ? void 0 : J.trim()) ?? "", ee = { ...(h == null ? void 0 : h.payload) ?? {} }, re = Array.isArray(ee.messages) ? ee.messages : void 0;
|
|
4457
4475
|
re && delete ee.messages;
|
|
4458
|
-
const ue = !!(re && re.length), G = !!(
|
|
4459
|
-
if (!T && !
|
|
4476
|
+
const ue = !!(re && re.length), G = !!(h.contentParts && h.contentParts.length > 0);
|
|
4477
|
+
if (!T && !q && K.length === 0 && !ue && !G) return;
|
|
4460
4478
|
if (!T) {
|
|
4461
4479
|
const ye = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), he = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
|
|
4462
|
-
T = `${ye}${he}`,
|
|
4480
|
+
T = `${ye}${he}`, y(T), s(T);
|
|
4463
4481
|
}
|
|
4464
4482
|
let te = null;
|
|
4465
|
-
|
|
4466
|
-
const { contentParts:
|
|
4467
|
-
|
|
4468
|
-
const ge =
|
|
4483
|
+
h.contentParts && h.contentParts.length > 0 && (te = h.contentParts);
|
|
4484
|
+
const { contentParts: ke, filesInfo: Q } = te ? { contentParts: te, filesInfo: [] } : await or(K), Z = [...ke];
|
|
4485
|
+
q && Z.push({ type: "text", text: J });
|
|
4486
|
+
const ge = h == null ? void 0 : h.originalMessageId, je = !!(h != null && h.edit && ge), Be = !ue && Z.length > 0;
|
|
4469
4487
|
let me = null;
|
|
4470
|
-
if (
|
|
4488
|
+
if (Be) {
|
|
4471
4489
|
const ye = je ? ge : `msg-${Date.now()}`;
|
|
4472
4490
|
me = Ut({
|
|
4473
4491
|
id: ye,
|
|
4474
4492
|
role: "user",
|
|
4475
4493
|
content: Z,
|
|
4476
4494
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4477
|
-
}, "user"), je ?
|
|
4495
|
+
}, "user"), je ? k(me, { editingMessageId: ge }) : k(me);
|
|
4478
4496
|
}
|
|
4479
4497
|
const Ie = ue ? re : me ? [me] : [], oe = {
|
|
4480
4498
|
...ee,
|
|
4481
4499
|
...Q.length ? { files_info: Q } : {}
|
|
4482
4500
|
};
|
|
4483
4501
|
Ie.length ? oe.messages = Ie : "messages" in oe || (oe.messages = []);
|
|
4484
|
-
const Pe = (
|
|
4485
|
-
if (
|
|
4502
|
+
const Pe = (h == null ? void 0 : h.checkpointId) ?? l.id ?? void 0;
|
|
4503
|
+
if (h != null && h.edit && !Pe)
|
|
4486
4504
|
throw new Error(
|
|
4487
4505
|
`[streaming] Missing checkpointId for edit submit. threadId=${T ?? "null"}`
|
|
4488
4506
|
);
|
|
4489
|
-
const
|
|
4507
|
+
const Ae = {
|
|
4490
4508
|
threadId: T,
|
|
4491
|
-
content:
|
|
4509
|
+
content: h == null ? void 0 : h.text,
|
|
4492
4510
|
payload: oe,
|
|
4493
|
-
config:
|
|
4511
|
+
config: h == null ? void 0 : h.config,
|
|
4494
4512
|
checkpointId: Pe,
|
|
4495
|
-
command:
|
|
4496
|
-
edit:
|
|
4513
|
+
command: h == null ? void 0 : h.command,
|
|
4514
|
+
edit: h == null ? void 0 : h.edit
|
|
4497
4515
|
};
|
|
4498
|
-
return
|
|
4516
|
+
return C(Ae, U);
|
|
4499
4517
|
},
|
|
4500
|
-
[l, a, P,
|
|
4501
|
-
), L = Y(() =>
|
|
4518
|
+
[l, a, P, y, k, C, g, d]
|
|
4519
|
+
), L = Y(() => S, [S]), H = Y(
|
|
4502
4520
|
() => ({
|
|
4503
4521
|
isStreaming: P,
|
|
4504
4522
|
error: j,
|
|
4505
|
-
connectionState: j ? "error" : P ?
|
|
4523
|
+
connectionState: j ? "error" : P ? M ? "connected" : "connecting" : "idle",
|
|
4506
4524
|
messages: L,
|
|
4507
|
-
activeMessageId:
|
|
4525
|
+
activeMessageId: F,
|
|
4508
4526
|
submit: z,
|
|
4509
|
-
stop:
|
|
4527
|
+
stop: g,
|
|
4510
4528
|
interrupt: c,
|
|
4511
4529
|
resume: () => Promise.resolve(),
|
|
4512
|
-
goto: (
|
|
4530
|
+
goto: (h, U) => Promise.resolve(),
|
|
4513
4531
|
clearError: () => {
|
|
4514
4532
|
}
|
|
4515
4533
|
// TODO: Implement error clearing
|
|
4516
4534
|
}),
|
|
4517
|
-
[P, j, z,
|
|
4535
|
+
[P, j, z, g, c, M, L]
|
|
4518
4536
|
);
|
|
4519
|
-
return /* @__PURE__ */ ie(
|
|
4537
|
+
return /* @__PURE__ */ ie(qt.Provider, { value: H, children: e });
|
|
4520
4538
|
}
|
|
4521
4539
|
function fe(e) {
|
|
4522
4540
|
const t = W(e);
|
|
@@ -4528,8 +4546,8 @@ function fe(e) {
|
|
|
4528
4546
|
return r(...n);
|
|
4529
4547
|
}, []);
|
|
4530
4548
|
}
|
|
4531
|
-
function
|
|
4532
|
-
return Ue(
|
|
4549
|
+
function Or(e) {
|
|
4550
|
+
return Ue(qt);
|
|
4533
4551
|
}
|
|
4534
4552
|
function bt(e) {
|
|
4535
4553
|
return typeof e == "object" && e !== null;
|
|
@@ -4569,41 +4587,41 @@ function po({
|
|
|
4569
4587
|
autoLoadInitial: s = !0,
|
|
4570
4588
|
onConnectionError: a,
|
|
4571
4589
|
onError: i,
|
|
4572
|
-
onAuthError:
|
|
4590
|
+
onAuthError: u,
|
|
4573
4591
|
onThreadChange: c,
|
|
4574
4592
|
onToolEnd: l,
|
|
4575
|
-
onUpdateEvent:
|
|
4576
|
-
onCustomEvent:
|
|
4577
|
-
onMetadataEvent:
|
|
4578
|
-
onFinish:
|
|
4593
|
+
onUpdateEvent: d,
|
|
4594
|
+
onCustomEvent: m,
|
|
4595
|
+
onMetadataEvent: y,
|
|
4596
|
+
onFinish: I
|
|
4579
4597
|
}) {
|
|
4580
|
-
const
|
|
4598
|
+
const f = Dr(t), [k, p] = $(!1), S = pe(i), A = pe(u), E = pe(a), v = pe(c), w = pe(l), x = pe(d), g = pe(m), b = pe(y), P = pe(I), j = Y(
|
|
4581
4599
|
() => ({
|
|
4582
|
-
onError:
|
|
4583
|
-
onAuthError:
|
|
4600
|
+
onError: S,
|
|
4601
|
+
onAuthError: A,
|
|
4584
4602
|
onConnectionError: E,
|
|
4585
|
-
onToolEnd:
|
|
4586
|
-
onUpdateEvent:
|
|
4587
|
-
onCustomEvent:
|
|
4588
|
-
onMetadataEvent:
|
|
4603
|
+
onToolEnd: w,
|
|
4604
|
+
onUpdateEvent: x,
|
|
4605
|
+
onCustomEvent: g,
|
|
4606
|
+
onMetadataEvent: b,
|
|
4589
4607
|
onFinish: P
|
|
4590
4608
|
}),
|
|
4591
4609
|
[
|
|
4592
|
-
|
|
4593
|
-
|
|
4610
|
+
S,
|
|
4611
|
+
A,
|
|
4594
4612
|
E,
|
|
4613
|
+
w,
|
|
4614
|
+
x,
|
|
4615
|
+
g,
|
|
4595
4616
|
b,
|
|
4596
|
-
A,
|
|
4597
|
-
p,
|
|
4598
|
-
h,
|
|
4599
4617
|
P
|
|
4600
4618
|
]
|
|
4601
4619
|
);
|
|
4602
|
-
return /* @__PURE__ */ ie(nr, { apiConfig:
|
|
4620
|
+
return /* @__PURE__ */ ie(nr, { apiConfig: f, children: /* @__PURE__ */ ie(
|
|
4603
4621
|
mr,
|
|
4604
4622
|
{
|
|
4605
4623
|
initialThreadId: n,
|
|
4606
|
-
onError:
|
|
4624
|
+
onError: S,
|
|
4607
4625
|
onThreadChange: v,
|
|
4608
4626
|
children: /* @__PURE__ */ ie(
|
|
4609
4627
|
Ur,
|
|
@@ -4612,13 +4630,13 @@ function po({
|
|
|
4612
4630
|
initialCheckpointId: r,
|
|
4613
4631
|
initialCheckpointNs: o,
|
|
4614
4632
|
autoLoadInitial: s,
|
|
4615
|
-
onError:
|
|
4616
|
-
isStreaming:
|
|
4633
|
+
onError: S,
|
|
4634
|
+
isStreaming: k,
|
|
4617
4635
|
children: /* @__PURE__ */ ie(
|
|
4618
|
-
|
|
4636
|
+
Br,
|
|
4619
4637
|
{
|
|
4620
4638
|
...j,
|
|
4621
|
-
onStreamingChange:
|
|
4639
|
+
onStreamingChange: p,
|
|
4622
4640
|
children: e
|
|
4623
4641
|
}
|
|
4624
4642
|
)
|
|
@@ -4635,9 +4653,9 @@ function pe(e) {
|
|
|
4635
4653
|
return r(...n);
|
|
4636
4654
|
}, []);
|
|
4637
4655
|
}
|
|
4638
|
-
const
|
|
4656
|
+
const Kr = 1, qr = 1e6;
|
|
4639
4657
|
let We = 0;
|
|
4640
|
-
function
|
|
4658
|
+
function Hr() {
|
|
4641
4659
|
return We = (We + 1) % Number.MAX_SAFE_INTEGER, We.toString();
|
|
4642
4660
|
}
|
|
4643
4661
|
const Je = /* @__PURE__ */ new Map(), wt = (e) => {
|
|
@@ -4648,14 +4666,14 @@ const Je = /* @__PURE__ */ new Map(), wt = (e) => {
|
|
|
4648
4666
|
type: "REMOVE_TOAST",
|
|
4649
4667
|
toastId: e
|
|
4650
4668
|
});
|
|
4651
|
-
},
|
|
4669
|
+
}, qr);
|
|
4652
4670
|
Je.set(e, t);
|
|
4653
4671
|
}, Gr = (e, t) => {
|
|
4654
4672
|
switch (t.type) {
|
|
4655
4673
|
case "ADD_TOAST":
|
|
4656
4674
|
return {
|
|
4657
4675
|
...e,
|
|
4658
|
-
toasts: [t.toast, ...e.toasts].slice(0,
|
|
4676
|
+
toasts: [t.toast, ...e.toasts].slice(0, Kr)
|
|
4659
4677
|
};
|
|
4660
4678
|
case "UPDATE_TOAST":
|
|
4661
4679
|
return {
|
|
@@ -4695,7 +4713,7 @@ function Le(e) {
|
|
|
4695
4713
|
});
|
|
4696
4714
|
}
|
|
4697
4715
|
function Wr({ ...e }) {
|
|
4698
|
-
const t =
|
|
4716
|
+
const t = Hr(), n = (o) => Le({
|
|
4699
4717
|
type: "UPDATE_TOAST",
|
|
4700
4718
|
toast: { ...o, id: t }
|
|
4701
4719
|
}), r = () => Le({ type: "DISMISS_TOAST", toastId: t });
|
|
@@ -4727,75 +4745,75 @@ function Jr() {
|
|
|
4727
4745
|
};
|
|
4728
4746
|
}
|
|
4729
4747
|
function go(e) {
|
|
4730
|
-
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } =
|
|
4731
|
-
l(!1),
|
|
4732
|
-
}, []),
|
|
4733
|
-
|
|
4734
|
-
}, []),
|
|
4735
|
-
async (
|
|
4736
|
-
var
|
|
4748
|
+
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast: o } = Jr(), [s, a] = $({}), [i, u] = $(null), [c, l] = $(!1), d = _(() => {
|
|
4749
|
+
l(!1), u(null);
|
|
4750
|
+
}, []), m = _((I) => {
|
|
4751
|
+
u(I), l(!0);
|
|
4752
|
+
}, []), y = _(
|
|
4753
|
+
async (I, f, k) => {
|
|
4754
|
+
var p, S;
|
|
4737
4755
|
if (!t) {
|
|
4738
|
-
|
|
4756
|
+
I.preventDefault();
|
|
4739
4757
|
return;
|
|
4740
4758
|
}
|
|
4741
|
-
if (s[
|
|
4742
|
-
|
|
4759
|
+
if (s[k]) {
|
|
4760
|
+
I.preventDefault();
|
|
4743
4761
|
return;
|
|
4744
4762
|
}
|
|
4745
4763
|
try {
|
|
4746
|
-
const
|
|
4764
|
+
const A = String(f.url ?? ""), E = A.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
|
|
4747
4765
|
if (E) {
|
|
4748
|
-
|
|
4749
|
-
const v = E[1],
|
|
4750
|
-
|
|
4766
|
+
I.preventDefault();
|
|
4767
|
+
const v = E[1], w = f.name || `file_${v}`, x = f.mimeType || "application/octet-stream";
|
|
4768
|
+
m({ id: v, name: w, mimeType: x });
|
|
4751
4769
|
return;
|
|
4752
4770
|
}
|
|
4753
|
-
if (
|
|
4754
|
-
|
|
4771
|
+
if (A.startsWith("data:")) {
|
|
4772
|
+
I.preventDefault(), a((w) => ({ ...w, [k]: !0 }));
|
|
4755
4773
|
const v = o({ title: "Fetching file...", description: "", open: !0 });
|
|
4756
4774
|
try {
|
|
4757
|
-
const
|
|
4758
|
-
if (!
|
|
4775
|
+
const w = await r.listFiles(n ?? void 0);
|
|
4776
|
+
if (!w || !Array.isArray(w))
|
|
4759
4777
|
throw new Error("Invalid file list response");
|
|
4760
|
-
const
|
|
4761
|
-
if (!(
|
|
4762
|
-
throw new Error(`File "${
|
|
4763
|
-
if (!
|
|
4778
|
+
const x = w.find((g) => !g || typeof g != "object" || !((g.filename ?? "") === (f.name ?? "")) ? !1 : typeof f.size == "number" && typeof g.size == "number" ? g.size === f.size : !0);
|
|
4779
|
+
if (!(x != null && x.id))
|
|
4780
|
+
throw new Error(`File "${f.name}" is not yet available on the server`);
|
|
4781
|
+
if (!x.id || !x.filename)
|
|
4764
4782
|
throw new Error("Invalid file data received from server");
|
|
4765
|
-
|
|
4766
|
-
id:
|
|
4767
|
-
name:
|
|
4768
|
-
mimeType:
|
|
4769
|
-
}), (
|
|
4783
|
+
m({
|
|
4784
|
+
id: x.id,
|
|
4785
|
+
name: f.name || x.filename || `file_${x.id}`,
|
|
4786
|
+
mimeType: f.mimeType || x.mime_type || "application/octet-stream"
|
|
4787
|
+
}), (p = v.update) == null || p.call(v, {
|
|
4770
4788
|
id: v.id,
|
|
4771
4789
|
title: "Success",
|
|
4772
|
-
description: `Opened ${
|
|
4790
|
+
description: `Opened ${f.name}`,
|
|
4773
4791
|
open: !0
|
|
4774
4792
|
});
|
|
4775
|
-
} catch (
|
|
4776
|
-
console.error("Failed to fetch server file:",
|
|
4777
|
-
const
|
|
4778
|
-
(
|
|
4793
|
+
} catch (w) {
|
|
4794
|
+
console.error("Failed to fetch server file:", w);
|
|
4795
|
+
const x = w instanceof Error ? w.message : "Unknown error occurred";
|
|
4796
|
+
(S = v.update) == null || S.call(v, { id: v.id, title: "Failed", description: x }), o({
|
|
4779
4797
|
title: "Failed to fetch file",
|
|
4780
|
-
description:
|
|
4798
|
+
description: x,
|
|
4781
4799
|
open: !0
|
|
4782
4800
|
});
|
|
4783
4801
|
} finally {
|
|
4784
|
-
a((
|
|
4802
|
+
a((w) => ({ ...w, [k]: !1 }));
|
|
4785
4803
|
}
|
|
4786
4804
|
}
|
|
4787
|
-
} catch (
|
|
4788
|
-
console.error("File click error:",
|
|
4805
|
+
} catch (A) {
|
|
4806
|
+
console.error("File click error:", A), a((E) => ({ ...E, [k]: !1 }));
|
|
4789
4807
|
}
|
|
4790
4808
|
},
|
|
4791
|
-
[t, s, o, n,
|
|
4809
|
+
[t, s, o, n, m]
|
|
4792
4810
|
);
|
|
4793
4811
|
return {
|
|
4794
4812
|
uploadingFiles: s,
|
|
4795
|
-
handleFileClick:
|
|
4813
|
+
handleFileClick: y,
|
|
4796
4814
|
fileViewerOpen: c,
|
|
4797
4815
|
currentFileInfo: i,
|
|
4798
|
-
closeFileViewer:
|
|
4816
|
+
closeFileViewer: d
|
|
4799
4817
|
};
|
|
4800
4818
|
}
|
|
4801
4819
|
function mo(e) {
|
|
@@ -4808,20 +4826,20 @@ function mo(e) {
|
|
|
4808
4826
|
toolMeta: ar(t),
|
|
4809
4827
|
imageParts: n.filter((r) => r.type === "image_url"),
|
|
4810
4828
|
fileParts: n.filter((r) => r.type === "file"),
|
|
4811
|
-
toolRaw:
|
|
4829
|
+
toolRaw: Fn(n),
|
|
4812
4830
|
isToolStreaming: !!t.toolStreaming
|
|
4813
4831
|
};
|
|
4814
4832
|
}, [e]);
|
|
4815
4833
|
}
|
|
4816
|
-
const
|
|
4834
|
+
const kt = "data:";
|
|
4817
4835
|
function Xr(e) {
|
|
4818
4836
|
if (!e) return [];
|
|
4819
4837
|
const t = [], n = e.split(/\r?\n/);
|
|
4820
4838
|
for (const r of n) {
|
|
4821
4839
|
const o = r.trim();
|
|
4822
|
-
if (!o || !o.startsWith(
|
|
4840
|
+
if (!o || !o.startsWith(kt))
|
|
4823
4841
|
continue;
|
|
4824
|
-
const s = o.slice(
|
|
4842
|
+
const s = o.slice(kt.length).trim();
|
|
4825
4843
|
if (!s || s.toLowerCase() === "[done]")
|
|
4826
4844
|
continue;
|
|
4827
4845
|
const a = tt(s);
|
|
@@ -4840,16 +4858,16 @@ function Qr(e) {
|
|
|
4840
4858
|
function yo(e) {
|
|
4841
4859
|
return Y(() => {
|
|
4842
4860
|
const t = e.content.filter(
|
|
4843
|
-
(
|
|
4861
|
+
(u) => u.type === "text"
|
|
4844
4862
|
);
|
|
4845
4863
|
if (!t.length)
|
|
4846
4864
|
return null;
|
|
4847
4865
|
let r = t.flatMap(
|
|
4848
|
-
(
|
|
4866
|
+
(u) => Xr(u.text ?? "")
|
|
4849
4867
|
);
|
|
4850
4868
|
if (!r.length) {
|
|
4851
|
-
const
|
|
4852
|
-
`), c = tt(
|
|
4869
|
+
const u = t.map((l) => l.text ?? "").join(`
|
|
4870
|
+
`), c = tt(u);
|
|
4853
4871
|
c && typeof c == "object" && (r = [c]);
|
|
4854
4872
|
}
|
|
4855
4873
|
if (!r.length)
|
|
@@ -4871,24 +4889,24 @@ function yo(e) {
|
|
|
4871
4889
|
}, [e]);
|
|
4872
4890
|
}
|
|
4873
4891
|
function Yr(e) {
|
|
4874
|
-
var
|
|
4875
|
-
const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = ot({ optional: !0 }), o =
|
|
4892
|
+
var M, O;
|
|
4893
|
+
const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = ot({ optional: !0 }), o = Kt({ optional: !0 }), s = Or(), { currentThreadId: a, setCurrentThreadId: i, actions: u } = r || {
|
|
4876
4894
|
currentThreadId: null,
|
|
4877
4895
|
setCurrentThreadId: () => {
|
|
4878
4896
|
},
|
|
4879
4897
|
actions: {}
|
|
4880
|
-
}, c = !!t && t !== a, [l,
|
|
4881
|
-
|
|
4898
|
+
}, c = !!t && t !== a, [l, d] = $([]), m = _((F) => {
|
|
4899
|
+
d(F);
|
|
4882
4900
|
}, []), {
|
|
4883
|
-
isLoadingThread:
|
|
4884
|
-
threadStateError:
|
|
4885
|
-
threadCheckpoints:
|
|
4886
|
-
isLoadingHistory:
|
|
4887
|
-
loadThread:
|
|
4901
|
+
isLoadingThread: y,
|
|
4902
|
+
threadStateError: I,
|
|
4903
|
+
threadCheckpoints: f,
|
|
4904
|
+
isLoadingHistory: k,
|
|
4905
|
+
loadThread: p
|
|
4888
4906
|
} = $t({
|
|
4889
|
-
api:
|
|
4890
|
-
fileApi:
|
|
4891
|
-
seed:
|
|
4907
|
+
api: Me().chatApi,
|
|
4908
|
+
fileApi: Me().fileApi,
|
|
4909
|
+
seed: m,
|
|
4892
4910
|
currentThreadId: c ? t : null,
|
|
4893
4911
|
initialThreadId: c ? t : null,
|
|
4894
4912
|
isStreaming: !1,
|
|
@@ -4898,20 +4916,20 @@ function Yr(e) {
|
|
|
4898
4916
|
X(() => {
|
|
4899
4917
|
!c && !n && a && (o != null && o.loadThread) && o.loadThread(a);
|
|
4900
4918
|
}, [c, n, a, o == null ? void 0 : o.loadThread]);
|
|
4901
|
-
const
|
|
4902
|
-
var
|
|
4903
|
-
return ((
|
|
4904
|
-
}, [
|
|
4919
|
+
const S = Y(() => {
|
|
4920
|
+
var F;
|
|
4921
|
+
return ((F = f[0]) == null ? void 0 : F.values) || {};
|
|
4922
|
+
}, [f]), A = Y(() => ({ timeline: [], messagePreviews: {} }), []), E = t || a, v = c ? y ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", w = c ? l : (s == null ? void 0 : s.messages) || [], x = c ? y : (o == null ? void 0 : o.isLoading) || !1, g = c ? k : (o == null ? void 0 : o.isLoadingHistory) || !1, b = c ? S : (o == null ? void 0 : o.values) || {}, P = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, j = c ? I : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
|
|
4905
4923
|
return {
|
|
4906
4924
|
// UNIFIED: Single thread ID concept
|
|
4907
4925
|
threadId: E,
|
|
4908
4926
|
status: v,
|
|
4909
|
-
messages:
|
|
4910
|
-
isLoading:
|
|
4911
|
-
isHistoryLoading:
|
|
4927
|
+
messages: w,
|
|
4928
|
+
isLoading: x,
|
|
4929
|
+
isHistoryLoading: g,
|
|
4912
4930
|
error: j,
|
|
4913
4931
|
// Values & Metadata
|
|
4914
|
-
values:
|
|
4932
|
+
values: b,
|
|
4915
4933
|
taskMessagesByScope: P,
|
|
4916
4934
|
metadata: c ? {} : o == null ? void 0 : o.metadata,
|
|
4917
4935
|
// Actions & State relating to Global/Active Thread only
|
|
@@ -4921,9 +4939,9 @@ function Yr(e) {
|
|
|
4921
4939
|
returnToLatest: c ? async () => {
|
|
4922
4940
|
} : (o == null ? void 0 : o.returnToLatest) || (async () => {
|
|
4923
4941
|
}),
|
|
4924
|
-
checkpoint: c ?
|
|
4925
|
-
checkpoints: c ?
|
|
4926
|
-
checkpointIndex: c ?
|
|
4942
|
+
checkpoint: c ? f[0] ? { id: f[0].checkpointId, namespace: f[0].checkpointNs } : null : (o == null ? void 0 : o.checkpoint) || null,
|
|
4943
|
+
checkpoints: c ? f : (o == null ? void 0 : o.checkpoints) || [],
|
|
4944
|
+
checkpointIndex: c ? A : (o == null ? void 0 : o.checkpointIndex) || { timeline: [], messagePreviews: {} },
|
|
4927
4945
|
interrupt: c ? null : (o == null ? void 0 : o.interrupt) || null,
|
|
4928
4946
|
respondToInterrupt: c ? async () => {
|
|
4929
4947
|
} : (o == null ? void 0 : o.respondToInterrupt) || (async () => {
|
|
@@ -4931,9 +4949,9 @@ function Yr(e) {
|
|
|
4931
4949
|
// Streaming Status
|
|
4932
4950
|
// Even in standalone mode, allow streaming state/stop if a stream context exists.
|
|
4933
4951
|
isStreaming: (s == null ? void 0 : s.isStreaming) || !1,
|
|
4934
|
-
activeMessageId: (s == null ? void 0 : s.activeMessageId) || null,
|
|
4952
|
+
activeMessageId: c ? null : ((M = o == null ? void 0 : o.metadata) == null ? void 0 : M.assemblingMessageId) || (s == null ? void 0 : s.activeMessageId) || null,
|
|
4935
4953
|
connectionState: (s == null ? void 0 : s.connectionState) || "disconnected",
|
|
4936
|
-
streamingAssistantId: !c && (s != null && s.isStreaming) && ((
|
|
4954
|
+
streamingAssistantId: !c && (s != null && s.isStreaming) && ((O = o == null ? void 0 : o.metadata) != null && O.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
|
|
4937
4955
|
// Actions
|
|
4938
4956
|
submit: (s == null ? void 0 : s.submit) || (async () => {
|
|
4939
4957
|
}),
|
|
@@ -4944,16 +4962,16 @@ function Yr(e) {
|
|
|
4944
4962
|
}),
|
|
4945
4963
|
setCurrentThreadId: i,
|
|
4946
4964
|
loadHistory: c ? async () => {
|
|
4947
|
-
t && await
|
|
4965
|
+
t && await p(t);
|
|
4948
4966
|
} : async () => {
|
|
4949
4967
|
},
|
|
4950
4968
|
onEvent: c ? () => {
|
|
4951
4969
|
} : (o == null ? void 0 : o.onEvent) || (() => {
|
|
4952
4970
|
}),
|
|
4953
4971
|
// Thread Management
|
|
4954
|
-
createThread:
|
|
4955
|
-
deleteThread:
|
|
4956
|
-
renameThread:
|
|
4972
|
+
createThread: u == null ? void 0 : u.createThread,
|
|
4973
|
+
deleteThread: u == null ? void 0 : u.deleteThread,
|
|
4974
|
+
renameThread: u == null ? void 0 : u.renameThread,
|
|
4957
4975
|
threads: (r == null ? void 0 : r.threads) || [],
|
|
4958
4976
|
isThreadsLoading: (r == null ? void 0 : r.isLoading) || !1
|
|
4959
4977
|
};
|
|
@@ -4967,42 +4985,42 @@ function ho({
|
|
|
4967
4985
|
onExcelUploadSuccess: s,
|
|
4968
4986
|
onError: a,
|
|
4969
4987
|
enableMessageEditing: i,
|
|
4970
|
-
messages:
|
|
4988
|
+
messages: u,
|
|
4971
4989
|
setPendingAssistantResponse: c,
|
|
4972
4990
|
project: l,
|
|
4973
|
-
onEvent:
|
|
4974
|
-
threadId:
|
|
4975
|
-
clearComposerOnSend:
|
|
4991
|
+
onEvent: d,
|
|
4992
|
+
threadId: m,
|
|
4993
|
+
clearComposerOnSend: y = !0
|
|
4976
4994
|
}) {
|
|
4977
|
-
const { messages:
|
|
4995
|
+
const { messages: I } = Yr(), [f, k] = $(null), [p, S] = $(""), [A, E] = $(null), [v, w] = $(null), [x, g] = $(!1), [b, P] = $(""), j = W(b), M = W(null);
|
|
4978
4996
|
X(() => {
|
|
4979
|
-
if (!
|
|
4980
|
-
if (
|
|
4981
|
-
const
|
|
4982
|
-
P(
|
|
4997
|
+
if (!f)
|
|
4998
|
+
if (m) {
|
|
4999
|
+
const h = localStorage.getItem(Ge(m));
|
|
5000
|
+
P(h || "");
|
|
4983
5001
|
} else
|
|
4984
5002
|
P("");
|
|
4985
|
-
}, [
|
|
4986
|
-
const O = _((
|
|
4987
|
-
P(
|
|
4988
|
-
}, [
|
|
5003
|
+
}, [m, f]);
|
|
5004
|
+
const O = _((h) => {
|
|
5005
|
+
P(h), !f && m && localStorage.setItem(Ge(m), h);
|
|
5006
|
+
}, [m, f]);
|
|
4989
5007
|
X(() => {
|
|
4990
|
-
j.current =
|
|
4991
|
-
}, [
|
|
4992
|
-
if (!
|
|
4993
|
-
|
|
5008
|
+
j.current = b;
|
|
5009
|
+
}, [b]), X(() => {
|
|
5010
|
+
if (!f) {
|
|
5011
|
+
M.current = null;
|
|
4994
5012
|
return;
|
|
4995
5013
|
}
|
|
4996
|
-
|
|
4997
|
-
}, [
|
|
4998
|
-
const
|
|
4999
|
-
(
|
|
5000
|
-
O(
|
|
5014
|
+
M.current === null && (M.current = j.current), O(p ?? "");
|
|
5015
|
+
}, [p, f, O]);
|
|
5016
|
+
const F = _(
|
|
5017
|
+
(h) => {
|
|
5018
|
+
O(h);
|
|
5001
5019
|
},
|
|
5002
5020
|
[O]
|
|
5003
|
-
),
|
|
5004
|
-
const T = Array.isArray(U) ? { files: U } : U ?? {}, J = T.files ?? [],
|
|
5005
|
-
if (!(!
|
|
5021
|
+
), C = async (h, U) => {
|
|
5022
|
+
const T = Array.isArray(U) ? { files: U } : U ?? {}, J = T.files ?? [], K = T.contentParts ?? [], q = h.trim();
|
|
5023
|
+
if (!(!q && J.length === 0 && K.length === 0))
|
|
5006
5024
|
try {
|
|
5007
5025
|
const ee = J.map(async (Q) => {
|
|
5008
5026
|
try {
|
|
@@ -5023,73 +5041,73 @@ function ho({
|
|
|
5023
5041
|
name: Q.filename,
|
|
5024
5042
|
size: Q.size
|
|
5025
5043
|
};
|
|
5026
|
-
}), G = [...
|
|
5044
|
+
}), G = [...K, ...ue], te = f ? (A == null ? void 0 : A.checkpointId) ?? n ?? void 0 : n ?? void 0, ke = f ? (A == null ? void 0 : A.checkpointNs) ?? r ?? void 0 : r ?? void 0;
|
|
5027
5045
|
await e(
|
|
5028
5046
|
{
|
|
5029
|
-
text:
|
|
5047
|
+
text: q || "",
|
|
5030
5048
|
contentParts: G,
|
|
5031
5049
|
attachments: J,
|
|
5032
5050
|
payload: t.payload,
|
|
5033
|
-
edit: !!
|
|
5051
|
+
edit: !!f,
|
|
5034
5052
|
checkpointId: te,
|
|
5035
|
-
checkpointNs:
|
|
5053
|
+
checkpointNs: ke,
|
|
5036
5054
|
project: l ?? void 0,
|
|
5037
|
-
originalMessageId:
|
|
5055
|
+
originalMessageId: f ?? void 0,
|
|
5038
5056
|
config: t.config
|
|
5039
5057
|
},
|
|
5040
|
-
|
|
5041
|
-
), o == null || o(
|
|
5058
|
+
d ? { onEvent: d } : void 0
|
|
5059
|
+
), o == null || o(q), c(!0), y && (m && localStorage.removeItem(Ge(m)), O("")), w(null), k(null), S(""), E(null);
|
|
5042
5060
|
} catch (ee) {
|
|
5043
5061
|
const re = (ee == null ? void 0 : ee.message) || "Failed to send message";
|
|
5044
|
-
|
|
5062
|
+
w(re), a == null || a(re), c(!1);
|
|
5045
5063
|
}
|
|
5046
|
-
},
|
|
5047
|
-
U ||
|
|
5064
|
+
}, B = (h, U) => {
|
|
5065
|
+
U || C(h, { files: [] });
|
|
5048
5066
|
}, N = _(
|
|
5049
|
-
async (
|
|
5067
|
+
async (h) => {
|
|
5050
5068
|
await e(
|
|
5051
5069
|
{
|
|
5052
|
-
attachments: [
|
|
5070
|
+
attachments: [h],
|
|
5053
5071
|
payload: t.payload,
|
|
5054
5072
|
checkpointId: n ?? void 0,
|
|
5055
5073
|
checkpointNs: r ?? void 0,
|
|
5056
5074
|
project: l ?? void 0,
|
|
5057
5075
|
config: t.config
|
|
5058
5076
|
},
|
|
5059
|
-
|
|
5060
|
-
), s == null || s({ file:
|
|
5077
|
+
d ? { onEvent: d } : void 0
|
|
5078
|
+
), s == null || s({ file: h });
|
|
5061
5079
|
},
|
|
5062
5080
|
[n, r, t, s, e]
|
|
5063
5081
|
), V = _(
|
|
5064
|
-
(
|
|
5065
|
-
i && (
|
|
5082
|
+
(h, U, T) => {
|
|
5083
|
+
i && (M.current = b, k(h), S(U), E({
|
|
5066
5084
|
checkpointId: (T == null ? void 0 : T.checkpointId) ?? null,
|
|
5067
5085
|
checkpointNs: (T == null ? void 0 : T.checkpointNs) ?? null
|
|
5068
|
-
}),
|
|
5086
|
+
}), w(null));
|
|
5069
5087
|
},
|
|
5070
|
-
[
|
|
5088
|
+
[b, i]
|
|
5071
5089
|
), z = _(() => {
|
|
5072
|
-
|
|
5073
|
-
const
|
|
5074
|
-
|
|
5075
|
-
}, []), L = _((
|
|
5090
|
+
k(null), S(""), E(null), w(null);
|
|
5091
|
+
const h = M.current;
|
|
5092
|
+
h !== null && P(h), M.current = null;
|
|
5093
|
+
}, []), L = _((h) => {
|
|
5076
5094
|
let U = null;
|
|
5077
|
-
for (let
|
|
5078
|
-
if (
|
|
5079
|
-
U =
|
|
5095
|
+
for (let q = h - 1; q >= 0; q--)
|
|
5096
|
+
if (u[q].role === "user") {
|
|
5097
|
+
U = u[q];
|
|
5080
5098
|
break;
|
|
5081
5099
|
}
|
|
5082
5100
|
if (!U) return;
|
|
5083
|
-
const T = Array.isArray(U.content) ? U.content : [],
|
|
5101
|
+
const T = Array.isArray(U.content) ? U.content : [], K = T.filter((q) => (q == null ? void 0 : q.type) === "text").map((q) => q.text).join("") || (() => {
|
|
5084
5102
|
try {
|
|
5085
5103
|
return JSON.stringify(T, null, 2);
|
|
5086
5104
|
} catch {
|
|
5087
5105
|
return String(T);
|
|
5088
5106
|
}
|
|
5089
5107
|
})();
|
|
5090
|
-
|
|
5108
|
+
K && e(
|
|
5091
5109
|
{
|
|
5092
|
-
text:
|
|
5110
|
+
text: K,
|
|
5093
5111
|
payload: t.payload,
|
|
5094
5112
|
checkpointId: n ?? void 0,
|
|
5095
5113
|
checkpointNs: r ?? void 0,
|
|
@@ -5097,25 +5115,25 @@ function ho({
|
|
|
5097
5115
|
originalMessageId: U.id,
|
|
5098
5116
|
config: t.config
|
|
5099
5117
|
},
|
|
5100
|
-
|
|
5118
|
+
d ? { onEvent: d } : void 0
|
|
5101
5119
|
);
|
|
5102
|
-
}, [
|
|
5120
|
+
}, [u, e, n, r, t]);
|
|
5103
5121
|
return {
|
|
5104
|
-
editingMessageId:
|
|
5105
|
-
editingInitialValue:
|
|
5122
|
+
editingMessageId: f,
|
|
5123
|
+
editingInitialValue: p,
|
|
5106
5124
|
inputError: v,
|
|
5107
|
-
setInputError:
|
|
5108
|
-
dismissError:
|
|
5109
|
-
setDismissError:
|
|
5110
|
-
composerValue:
|
|
5111
|
-
handleComposerChange:
|
|
5112
|
-
handleSendMessage:
|
|
5113
|
-
handleQuickPrompt:
|
|
5125
|
+
setInputError: w,
|
|
5126
|
+
dismissError: x,
|
|
5127
|
+
setDismissError: g,
|
|
5128
|
+
composerValue: b,
|
|
5129
|
+
handleComposerChange: F,
|
|
5130
|
+
handleSendMessage: C,
|
|
5131
|
+
handleQuickPrompt: B,
|
|
5114
5132
|
handleExcelUpload: N,
|
|
5115
5133
|
startEditing: V,
|
|
5116
5134
|
cancelEditing: z,
|
|
5117
5135
|
handleRegenerateCb: L,
|
|
5118
|
-
displayMessages:
|
|
5136
|
+
displayMessages: I
|
|
5119
5137
|
};
|
|
5120
5138
|
}
|
|
5121
5139
|
function bo(e) {
|
|
@@ -5123,7 +5141,7 @@ function bo(e) {
|
|
|
5123
5141
|
textContent: Ln(e),
|
|
5124
5142
|
imageParts: Un(e),
|
|
5125
5143
|
fileParts: jn(e),
|
|
5126
|
-
toolCalls:
|
|
5144
|
+
toolCalls: Mt(e),
|
|
5127
5145
|
contentParts: e.content
|
|
5128
5146
|
} : {
|
|
5129
5147
|
textContent: "",
|
|
@@ -5134,7 +5152,7 @@ function bo(e) {
|
|
|
5134
5152
|
}, [e]);
|
|
5135
5153
|
}
|
|
5136
5154
|
function wo(e, t, n) {
|
|
5137
|
-
const [r, o] =
|
|
5155
|
+
const [r, o] = $(e), s = W(e), a = W(null);
|
|
5138
5156
|
return X(() => {
|
|
5139
5157
|
s.current = e;
|
|
5140
5158
|
const i = () => {
|
|
@@ -5165,21 +5183,21 @@ export {
|
|
|
5165
5183
|
Pt as getChatToken,
|
|
5166
5184
|
uo as getMessageAttemptInfo,
|
|
5167
5185
|
ao as getToolCallArtifacts,
|
|
5168
|
-
|
|
5186
|
+
qn as getToolCalls,
|
|
5169
5187
|
so as hasContent,
|
|
5170
5188
|
mt as hydrateHistorySnapshots,
|
|
5171
|
-
|
|
5189
|
+
Ct as isFileLike,
|
|
5172
5190
|
Nn as looksLikeMarkdown,
|
|
5173
5191
|
lo as messageSignature,
|
|
5174
5192
|
io as normalizeInterruptId,
|
|
5175
5193
|
_t as onChatTokenChanged,
|
|
5176
5194
|
tt as parseJsonSafe,
|
|
5177
5195
|
Et as pretty,
|
|
5178
|
-
|
|
5196
|
+
Mr as refreshHistoryFileUrls,
|
|
5179
5197
|
Ve as sanitizeForDisplay,
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5198
|
+
ve as setChatToken,
|
|
5199
|
+
Fn as stringifyTool,
|
|
5200
|
+
Me as useApi,
|
|
5183
5201
|
ho as useChatController,
|
|
5184
5202
|
Yr as useChatSession,
|
|
5185
5203
|
go as useFilePreview,
|
|
@@ -5188,7 +5206,7 @@ export {
|
|
|
5188
5206
|
pr as useStream,
|
|
5189
5207
|
wo as useStreamingMarkdownBuffer,
|
|
5190
5208
|
$t as useThreadHistoryState,
|
|
5191
|
-
|
|
5209
|
+
Kt as useThreadState,
|
|
5192
5210
|
Lr as useThreadStateUpdater,
|
|
5193
5211
|
ot as useThreads,
|
|
5194
5212
|
gr as useThreadsState,
|