@teodorruskvi/chat-core 0.1.39 → 0.1.40
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 +615 -615
- 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
|
@@ -3,7 +3,7 @@ var Ht = (e, t, n) => t in e ? Gt(e, t, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var st = (e, t, n) => Ht(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { jsx as ie } from "react/jsx-runtime";
|
|
5
5
|
import * as at from "react";
|
|
6
|
-
import { createContext as Se, useContext as Ue, useState as
|
|
6
|
+
import { createContext as Se, useContext as Ue, useState as V, useRef as K, useEffect as q, useCallback as z, useMemo as Q, useReducer as Wt } from "react";
|
|
7
7
|
import qt, { isCancel as Jt } from "axios";
|
|
8
8
|
function vt(e) {
|
|
9
9
|
var t, n, r = "";
|
|
@@ -126,7 +126,7 @@ const Ze = "-", Qt = (e) => {
|
|
|
126
126
|
experimentalParseClassName: n
|
|
127
127
|
} = e, r = t.length === 1, o = t[0], s = t.length, a = (i) => {
|
|
128
128
|
const u = [];
|
|
129
|
-
let c = 0, l = 0,
|
|
129
|
+
let c = 0, l = 0, f;
|
|
130
130
|
for (let v = 0; v < i.length; v++) {
|
|
131
131
|
let I = i[v];
|
|
132
132
|
if (c === 0) {
|
|
@@ -135,13 +135,13 @@ const Ze = "-", Qt = (e) => {
|
|
|
135
135
|
continue;
|
|
136
136
|
}
|
|
137
137
|
if (I === "/") {
|
|
138
|
-
|
|
138
|
+
f = v;
|
|
139
139
|
continue;
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
I === "[" ? c++ : I === "]" && c--;
|
|
143
143
|
}
|
|
144
|
-
const m = u.length === 0 ? i : i.substring(l), h = m.startsWith(It), k = h ? m.substring(1) : m, d =
|
|
144
|
+
const m = u.length === 0 ? i : i.substring(l), h = m.startsWith(It), k = h ? m.substring(1) : m, d = f && f > l ? f - l : void 0;
|
|
145
145
|
return {
|
|
146
146
|
modifiers: u,
|
|
147
147
|
hasImportantModifier: h,
|
|
@@ -175,7 +175,7 @@ const Ze = "-", Qt = (e) => {
|
|
|
175
175
|
for (let u = a.length - 1; u >= 0; u -= 1) {
|
|
176
176
|
const c = a[u], {
|
|
177
177
|
modifiers: l,
|
|
178
|
-
hasImportantModifier:
|
|
178
|
+
hasImportantModifier: f,
|
|
179
179
|
baseClassName: m,
|
|
180
180
|
maybePostfixModifierPosition: h
|
|
181
181
|
} = n(c);
|
|
@@ -191,13 +191,13 @@ const Ze = "-", Qt = (e) => {
|
|
|
191
191
|
}
|
|
192
192
|
k = !1;
|
|
193
193
|
}
|
|
194
|
-
const v = on(l).join(":"), I =
|
|
195
|
-
if (s.includes(
|
|
194
|
+
const v = on(l).join(":"), I = f ? v + It : v, C = I + d;
|
|
195
|
+
if (s.includes(C))
|
|
196
196
|
continue;
|
|
197
|
-
s.push(
|
|
197
|
+
s.push(C);
|
|
198
198
|
const T = o(d, k);
|
|
199
|
-
for (let
|
|
200
|
-
const b = T[
|
|
199
|
+
for (let P = 0; P < T.length; ++P) {
|
|
200
|
+
const b = T[P];
|
|
201
201
|
s.push(I + b);
|
|
202
202
|
}
|
|
203
203
|
i = c + (i.length > 0 ? " " + i : i);
|
|
@@ -221,7 +221,7 @@ const Tt = (e) => {
|
|
|
221
221
|
function un(e, ...t) {
|
|
222
222
|
let n, r, o, s = a;
|
|
223
223
|
function a(u) {
|
|
224
|
-
const c = t.reduce((l,
|
|
224
|
+
const c = t.reduce((l, f) => f(l), e());
|
|
225
225
|
return n = sn(c), r = n.cache.get, o = n.cache.set, s = i, i(u);
|
|
226
226
|
}
|
|
227
227
|
function i(u) {
|
|
@@ -235,7 +235,7 @@ function un(e, ...t) {
|
|
|
235
235
|
return s(ln.apply(null, arguments));
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
|
-
const
|
|
238
|
+
const $ = (e) => {
|
|
239
239
|
const t = (n) => n[e] || [];
|
|
240
240
|
return t.isThemeGetter = !0, t;
|
|
241
241
|
}, xt = /^\[(?:([a-z-]+):)?(.+)\]$/i, dn = /^\d+\/\d+$/, fn = /* @__PURE__ */ new Set(["px", "full", "screen"]), pn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, gn = /\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$/, mn = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, hn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, yn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, fe = (e) => xe(e) || fn.has(e) || dn.test(e), be = (e) => Ce(e, "length", An), xe = (e) => !!e && !Number.isNaN(Number(e)), Ke = (e) => Ce(e, "number", xe), Pe = (e) => !!e && Number.isInteger(Number(e)), bn = (e) => e.endsWith("%") && xe(e.slice(0, -1)), R = (e) => xt.test(e), we = (e) => pn.test(e), wn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), vn = (e) => Ce(e, wn, At), kn = (e) => Ce(e, "position", At), In = /* @__PURE__ */ new Set(["image", "url"]), Tn = (e) => Ce(e, In, Cn), xn = (e) => Ce(e, "", Sn), Ne = () => !0, Ce = (e, t, n) => {
|
|
@@ -247,7 +247,7 @@ const B = (e) => {
|
|
|
247
247
|
// I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough.
|
|
248
248
|
gn.test(e) && !mn.test(e)
|
|
249
249
|
), At = () => !1, Sn = (e) => hn.test(e), Cn = (e) => yn.test(e), Mn = () => {
|
|
250
|
-
const e =
|
|
250
|
+
const e = $("colors"), t = $("spacing"), n = $("blur"), r = $("brightness"), o = $("borderColor"), s = $("borderRadius"), a = $("borderSpacing"), i = $("borderWidth"), u = $("contrast"), c = $("grayscale"), l = $("hueRotate"), f = $("invert"), m = $("gap"), h = $("gradientColorStops"), k = $("gradientColorStopPositions"), d = $("inset"), v = $("margin"), I = $("opacity"), C = $("padding"), T = $("saturate"), P = $("scale"), b = $("sepia"), y = $("skew"), x = $("space"), p = $("translate"), w = () => ["auto", "contain", "none"], _ = () => ["auto", "hidden", "clip", "visible", "scroll"], U = () => ["auto", R, t], M = () => [R, t], E = () => ["", fe, be], j = () => ["auto", xe, R], N = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], B = () => ["solid", "dashed", "dotted", "double", "none"], O = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], L = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], F = () => ["", "0", R], W = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], Y = () => [xe, R];
|
|
251
251
|
return {
|
|
252
252
|
cacheSize: 500,
|
|
253
253
|
separator: ":",
|
|
@@ -255,28 +255,28 @@ const B = (e) => {
|
|
|
255
255
|
colors: [Ne],
|
|
256
256
|
spacing: [fe, be],
|
|
257
257
|
blur: ["none", "", we, R],
|
|
258
|
-
brightness:
|
|
258
|
+
brightness: Y(),
|
|
259
259
|
borderColor: [e],
|
|
260
260
|
borderRadius: ["none", "", "full", we, R],
|
|
261
|
-
borderSpacing:
|
|
262
|
-
borderWidth:
|
|
263
|
-
contrast:
|
|
264
|
-
grayscale:
|
|
265
|
-
hueRotate:
|
|
266
|
-
invert:
|
|
267
|
-
gap:
|
|
261
|
+
borderSpacing: M(),
|
|
262
|
+
borderWidth: E(),
|
|
263
|
+
contrast: Y(),
|
|
264
|
+
grayscale: F(),
|
|
265
|
+
hueRotate: Y(),
|
|
266
|
+
invert: F(),
|
|
267
|
+
gap: M(),
|
|
268
268
|
gradientColorStops: [e],
|
|
269
269
|
gradientColorStopPositions: [bn, be],
|
|
270
|
-
inset:
|
|
271
|
-
margin:
|
|
272
|
-
opacity:
|
|
273
|
-
padding:
|
|
274
|
-
saturate:
|
|
275
|
-
scale:
|
|
276
|
-
sepia:
|
|
277
|
-
skew:
|
|
278
|
-
space:
|
|
279
|
-
translate:
|
|
270
|
+
inset: U(),
|
|
271
|
+
margin: U(),
|
|
272
|
+
opacity: Y(),
|
|
273
|
+
padding: M(),
|
|
274
|
+
saturate: Y(),
|
|
275
|
+
scale: Y(),
|
|
276
|
+
sepia: F(),
|
|
277
|
+
skew: Y(),
|
|
278
|
+
space: M(),
|
|
279
|
+
translate: M()
|
|
280
280
|
},
|
|
281
281
|
classGroups: {
|
|
282
282
|
// Layout
|
|
@@ -304,14 +304,14 @@ const B = (e) => {
|
|
|
304
304
|
* @see https://tailwindcss.com/docs/break-after
|
|
305
305
|
*/
|
|
306
306
|
"break-after": [{
|
|
307
|
-
"break-after":
|
|
307
|
+
"break-after": W()
|
|
308
308
|
}],
|
|
309
309
|
/**
|
|
310
310
|
* Break Before
|
|
311
311
|
* @see https://tailwindcss.com/docs/break-before
|
|
312
312
|
*/
|
|
313
313
|
"break-before": [{
|
|
314
|
-
"break-before":
|
|
314
|
+
"break-before": W()
|
|
315
315
|
}],
|
|
316
316
|
/**
|
|
317
317
|
* Break Inside
|
|
@@ -370,28 +370,28 @@ const B = (e) => {
|
|
|
370
370
|
* @see https://tailwindcss.com/docs/object-position
|
|
371
371
|
*/
|
|
372
372
|
"object-position": [{
|
|
373
|
-
object: [...
|
|
373
|
+
object: [...N(), R]
|
|
374
374
|
}],
|
|
375
375
|
/**
|
|
376
376
|
* Overflow
|
|
377
377
|
* @see https://tailwindcss.com/docs/overflow
|
|
378
378
|
*/
|
|
379
379
|
overflow: [{
|
|
380
|
-
overflow:
|
|
380
|
+
overflow: _()
|
|
381
381
|
}],
|
|
382
382
|
/**
|
|
383
383
|
* Overflow X
|
|
384
384
|
* @see https://tailwindcss.com/docs/overflow
|
|
385
385
|
*/
|
|
386
386
|
"overflow-x": [{
|
|
387
|
-
"overflow-x":
|
|
387
|
+
"overflow-x": _()
|
|
388
388
|
}],
|
|
389
389
|
/**
|
|
390
390
|
* Overflow Y
|
|
391
391
|
* @see https://tailwindcss.com/docs/overflow
|
|
392
392
|
*/
|
|
393
393
|
"overflow-y": [{
|
|
394
|
-
"overflow-y":
|
|
394
|
+
"overflow-y": _()
|
|
395
395
|
}],
|
|
396
396
|
/**
|
|
397
397
|
* Overscroll Behavior
|
|
@@ -500,7 +500,7 @@ const B = (e) => {
|
|
|
500
500
|
* @see https://tailwindcss.com/docs/flex-basis
|
|
501
501
|
*/
|
|
502
502
|
basis: [{
|
|
503
|
-
basis:
|
|
503
|
+
basis: U()
|
|
504
504
|
}],
|
|
505
505
|
/**
|
|
506
506
|
* Flex Direction
|
|
@@ -528,14 +528,14 @@ const B = (e) => {
|
|
|
528
528
|
* @see https://tailwindcss.com/docs/flex-grow
|
|
529
529
|
*/
|
|
530
530
|
grow: [{
|
|
531
|
-
grow:
|
|
531
|
+
grow: F()
|
|
532
532
|
}],
|
|
533
533
|
/**
|
|
534
534
|
* Flex Shrink
|
|
535
535
|
* @see https://tailwindcss.com/docs/flex-shrink
|
|
536
536
|
*/
|
|
537
537
|
shrink: [{
|
|
538
|
-
shrink:
|
|
538
|
+
shrink: F()
|
|
539
539
|
}],
|
|
540
540
|
/**
|
|
541
541
|
* Order
|
|
@@ -565,14 +565,14 @@ const B = (e) => {
|
|
|
565
565
|
* @see https://tailwindcss.com/docs/grid-column
|
|
566
566
|
*/
|
|
567
567
|
"col-start": [{
|
|
568
|
-
"col-start":
|
|
568
|
+
"col-start": j()
|
|
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": j()
|
|
576
576
|
}],
|
|
577
577
|
/**
|
|
578
578
|
* Grid Template Rows
|
|
@@ -595,14 +595,14 @@ const B = (e) => {
|
|
|
595
595
|
* @see https://tailwindcss.com/docs/grid-row
|
|
596
596
|
*/
|
|
597
597
|
"row-start": [{
|
|
598
|
-
"row-start":
|
|
598
|
+
"row-start": j()
|
|
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": j()
|
|
606
606
|
}],
|
|
607
607
|
/**
|
|
608
608
|
* Grid Auto Flow
|
|
@@ -651,7 +651,7 @@ const B = (e) => {
|
|
|
651
651
|
* @see https://tailwindcss.com/docs/justify-content
|
|
652
652
|
*/
|
|
653
653
|
"justify-content": [{
|
|
654
|
-
justify: ["normal", ...
|
|
654
|
+
justify: ["normal", ...L()]
|
|
655
655
|
}],
|
|
656
656
|
/**
|
|
657
657
|
* Justify Items
|
|
@@ -672,7 +672,7 @@ const B = (e) => {
|
|
|
672
672
|
* @see https://tailwindcss.com/docs/align-content
|
|
673
673
|
*/
|
|
674
674
|
"align-content": [{
|
|
675
|
-
content: ["normal", ...
|
|
675
|
+
content: ["normal", ...L(), "baseline"]
|
|
676
676
|
}],
|
|
677
677
|
/**
|
|
678
678
|
* Align Items
|
|
@@ -693,7 +693,7 @@ const B = (e) => {
|
|
|
693
693
|
* @see https://tailwindcss.com/docs/place-content
|
|
694
694
|
*/
|
|
695
695
|
"place-content": [{
|
|
696
|
-
"place-content": [...
|
|
696
|
+
"place-content": [...L(), "baseline"]
|
|
697
697
|
}],
|
|
698
698
|
/**
|
|
699
699
|
* Place Items
|
|
@@ -715,63 +715,63 @@ const B = (e) => {
|
|
|
715
715
|
* @see https://tailwindcss.com/docs/padding
|
|
716
716
|
*/
|
|
717
717
|
p: [{
|
|
718
|
-
p: [
|
|
718
|
+
p: [C]
|
|
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: [C]
|
|
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: [C]
|
|
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: [C]
|
|
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: [C]
|
|
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: [C]
|
|
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: [C]
|
|
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: [C]
|
|
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: [C]
|
|
775
775
|
}],
|
|
776
776
|
/**
|
|
777
777
|
* Margin
|
|
@@ -1062,7 +1062,7 @@ const B = (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 B = (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
|
|
@@ -1179,7 +1179,7 @@ const B = (e) => {
|
|
|
1179
1179
|
* @see https://tailwindcss.com/docs/background-position
|
|
1180
1180
|
*/
|
|
1181
1181
|
"bg-position": [{
|
|
1182
|
-
bg: [...
|
|
1182
|
+
bg: [...N(), kn]
|
|
1183
1183
|
}],
|
|
1184
1184
|
/**
|
|
1185
1185
|
* Background Repeat
|
|
@@ -1436,7 +1436,7 @@ const B = (e) => {
|
|
|
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
|
|
@@ -1474,7 +1474,7 @@ const B = (e) => {
|
|
|
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 B = (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
|
|
@@ -1579,7 +1579,7 @@ const B = (e) => {
|
|
|
1579
1579
|
* @see https://tailwindcss.com/docs/ring-width
|
|
1580
1580
|
*/
|
|
1581
1581
|
"ring-w": [{
|
|
1582
|
-
ring:
|
|
1582
|
+
ring: E()
|
|
1583
1583
|
}],
|
|
1584
1584
|
/**
|
|
1585
1585
|
* Ring Width Inset
|
|
@@ -1641,14 +1641,14 @@ const B = (e) => {
|
|
|
1641
1641
|
* @see https://tailwindcss.com/docs/mix-blend-mode
|
|
1642
1642
|
*/
|
|
1643
1643
|
"mix-blend": [{
|
|
1644
|
-
"mix-blend": [...
|
|
1644
|
+
"mix-blend": [...O(), "plus-lighter", "plus-darker"]
|
|
1645
1645
|
}],
|
|
1646
1646
|
/**
|
|
1647
1647
|
* Background Blend Mode
|
|
1648
1648
|
* @see https://tailwindcss.com/docs/background-blend-mode
|
|
1649
1649
|
*/
|
|
1650
1650
|
"bg-blend": [{
|
|
1651
|
-
"bg-blend":
|
|
1651
|
+
"bg-blend": O()
|
|
1652
1652
|
}],
|
|
1653
1653
|
// Filters
|
|
1654
1654
|
/**
|
|
@@ -1706,7 +1706,7 @@ const B = (e) => {
|
|
|
1706
1706
|
* @see https://tailwindcss.com/docs/invert
|
|
1707
1707
|
*/
|
|
1708
1708
|
invert: [{
|
|
1709
|
-
invert: [
|
|
1709
|
+
invert: [f]
|
|
1710
1710
|
}],
|
|
1711
1711
|
/**
|
|
1712
1712
|
* Saturate
|
|
@@ -1770,7 +1770,7 @@ const B = (e) => {
|
|
|
1770
1770
|
* @see https://tailwindcss.com/docs/backdrop-invert
|
|
1771
1771
|
*/
|
|
1772
1772
|
"backdrop-invert": [{
|
|
1773
|
-
"backdrop-invert": [
|
|
1773
|
+
"backdrop-invert": [f]
|
|
1774
1774
|
}],
|
|
1775
1775
|
/**
|
|
1776
1776
|
* Backdrop Opacity
|
|
@@ -1849,7 +1849,7 @@ const B = (e) => {
|
|
|
1849
1849
|
* @see https://tailwindcss.com/docs/transition-duration
|
|
1850
1850
|
*/
|
|
1851
1851
|
duration: [{
|
|
1852
|
-
duration:
|
|
1852
|
+
duration: Y()
|
|
1853
1853
|
}],
|
|
1854
1854
|
/**
|
|
1855
1855
|
* Transition Timing Function
|
|
@@ -1863,7 +1863,7 @@ const B = (e) => {
|
|
|
1863
1863
|
* @see https://tailwindcss.com/docs/transition-delay
|
|
1864
1864
|
*/
|
|
1865
1865
|
delay: [{
|
|
1866
|
-
delay:
|
|
1866
|
+
delay: Y()
|
|
1867
1867
|
}],
|
|
1868
1868
|
/**
|
|
1869
1869
|
* Animation
|
|
@@ -1885,21 +1885,21 @@ const B = (e) => {
|
|
|
1885
1885
|
* @see https://tailwindcss.com/docs/scale
|
|
1886
1886
|
*/
|
|
1887
1887
|
scale: [{
|
|
1888
|
-
scale: [
|
|
1888
|
+
scale: [P]
|
|
1889
1889
|
}],
|
|
1890
1890
|
/**
|
|
1891
1891
|
* Scale X
|
|
1892
1892
|
* @see https://tailwindcss.com/docs/scale
|
|
1893
1893
|
*/
|
|
1894
1894
|
"scale-x": [{
|
|
1895
|
-
"scale-x": [
|
|
1895
|
+
"scale-x": [P]
|
|
1896
1896
|
}],
|
|
1897
1897
|
/**
|
|
1898
1898
|
* Scale Y
|
|
1899
1899
|
* @see https://tailwindcss.com/docs/scale
|
|
1900
1900
|
*/
|
|
1901
1901
|
"scale-y": [{
|
|
1902
|
-
"scale-y": [
|
|
1902
|
+
"scale-y": [P]
|
|
1903
1903
|
}],
|
|
1904
1904
|
/**
|
|
1905
1905
|
* Rotate
|
|
@@ -1913,14 +1913,14 @@ const B = (e) => {
|
|
|
1913
1913
|
* @see https://tailwindcss.com/docs/translate
|
|
1914
1914
|
*/
|
|
1915
1915
|
"translate-x": [{
|
|
1916
|
-
"translate-x": [
|
|
1916
|
+
"translate-x": [p]
|
|
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": [p]
|
|
1924
1924
|
}],
|
|
1925
1925
|
/**
|
|
1926
1926
|
* Skew X
|
|
@@ -1998,126 +1998,126 @@ const B = (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
|
|
@@ -2448,12 +2448,12 @@ function le(e) {
|
|
|
2448
2448
|
);
|
|
2449
2449
|
}
|
|
2450
2450
|
function tt(e) {
|
|
2451
|
-
var v, I,
|
|
2451
|
+
var v, I, C, T, P, b;
|
|
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(nt) : void 0, o = $n(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 ?? ((v = t.additionalKwargs) == null ? void 0 : v.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), i = t.name ?? ((I = t.additionalKwargs) == null ? void 0 : I.agentName) ?? void 0, u = t.model ?? ((
|
|
2456
|
+
const r = Array.isArray(t.toolCalls) ? t.toolCalls.map(nt) : void 0, o = $n(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 ?? ((v = t.additionalKwargs) == null ? void 0 : v.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), i = t.name ?? ((I = t.additionalKwargs) == null ? void 0 : I.agentName) ?? void 0, u = t.model ?? ((C = t.additionalKwargs) == null ? void 0 : C.model) ?? void 0, c = t.toolCallId ?? void 0, l = t.additionalKwargs ?? void 0, f = t.responseMetadata ?? void 0, m = t.checkpointId ?? ((T = t.additionalKwargs) == null ? void 0 : T.checkpointId) ?? void 0, h = t.checkpointNs ?? ((P = t.additionalKwargs) == null ? void 0 : P.checkpointNs) ?? void 0, k = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((b = t.additionalKwargs) != null && b.toolStreaming);
|
|
2457
2457
|
return {
|
|
2458
2458
|
...t,
|
|
2459
2459
|
id: s,
|
|
@@ -2468,7 +2468,7 @@ function tt(e) {
|
|
|
2468
2468
|
checkpointNs: h,
|
|
2469
2469
|
toolStreaming: k,
|
|
2470
2470
|
additionalKwargs: l,
|
|
2471
|
-
responseMetadata:
|
|
2471
|
+
responseMetadata: f,
|
|
2472
2472
|
artifact: t.artifact ?? void 0
|
|
2473
2473
|
};
|
|
2474
2474
|
}
|
|
@@ -2537,8 +2537,8 @@ function Kn(e, t = []) {
|
|
|
2537
2537
|
if (Array.isArray(e)) {
|
|
2538
2538
|
const o = e.filter((a) => a.role === "assistant").flatMap((a) => ut(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 = Ge(a.id, e) || Ge(a.id, t), u = Array.isArray((
|
|
2540
|
+
var f, m, h;
|
|
2541
|
+
const i = Ge(a.id, e) || Ge(a.id, t), u = Array.isArray((f = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : f.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 = lt(a.status) ?? ((h = i == null ? void 0 : i.additionalKwargs) != null && h.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
|
|
2542
2542
|
if (i && !a.content && l === "completed") {
|
|
2543
2543
|
const k = ce(i);
|
|
2544
2544
|
typeof k == "string" && (a.content = k);
|
|
@@ -2558,8 +2558,8 @@ function Kn(e, t = []) {
|
|
|
2558
2558
|
var u, c, l;
|
|
2559
2559
|
const o = Ge(r.id, t) ?? Dn(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 = lt(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 f = ce(o);
|
|
2562
|
+
typeof f == "string" && (r.content = f);
|
|
2563
2563
|
}
|
|
2564
2564
|
return {
|
|
2565
2565
|
call: r,
|
|
@@ -2952,47 +2952,47 @@ function ir(e) {
|
|
|
2952
2952
|
return !!e && typeof e == "object" && "data" in e;
|
|
2953
2953
|
}
|
|
2954
2954
|
function cr(e = {}) {
|
|
2955
|
-
const t = e.baseUrl || "", n = e.streamPath ?? "/runs/stream", [r, o] =
|
|
2956
|
-
|
|
2955
|
+
const t = e.baseUrl || "", n = e.streamPath ?? "/runs/stream", [r, o] = V(e.token ?? null), s = K(e.headers ?? {}), a = e.credentials ?? "include", i = K(e);
|
|
2956
|
+
q(() => {
|
|
2957
2957
|
i.current = e;
|
|
2958
2958
|
}, [e]);
|
|
2959
|
-
const u =
|
|
2960
|
-
var
|
|
2959
|
+
const u = z((p) => {
|
|
2960
|
+
var U, M, E, j, N, B, O, L, F, W;
|
|
2961
2961
|
const w = i.current;
|
|
2962
2962
|
if (!w) return;
|
|
2963
|
-
(
|
|
2964
|
-
}, []), [c, l] =
|
|
2965
|
-
o(
|
|
2966
|
-
}, []), b =
|
|
2963
|
+
(U = w.onEvent) == null || U.call(w, p), p.type === "thread_info" && ((M = w.onThreadInfo) == null || M.call(w, p)), p.type === "values" && Array.isArray(p.checkpoints) && ((E = w.handleValuesEvent) == null || E.call(w, p)), p.type === "metadata" && ((j = w.onMetadataEvent) == null || j.call(w, p)), typeof p.type == "string" && (p.type === "custom" || p.type.startsWith("custom.")) && ((N = w.onCustomEvent) == null || N.call(w, p)), p.type === "updates" && ((B = w.onUpdateEvent) == null || B.call(w, p)), p.type === "tool.end" ? (O = w.onToolEnd) == null || O.call(w, p) : p.type === "tool.start" && ((L = w.onToolStart) == null || L.call(w, p)), p.type === "heartbeat" && ((F = w.onHeartbeat) == null || F.call(w, p)), p.type === "token" && ((W = w.onToken) == null || W.call(w, p.token));
|
|
2964
|
+
}, []), [c, l] = V(!1), [f, m] = V(null), [h, k] = V(!1), [d, v] = V(null), I = K(null), C = K(!0), T = K(null), P = z((p) => {
|
|
2965
|
+
o(p);
|
|
2966
|
+
}, []), b = z(() => {
|
|
2967
2967
|
m(null), v(null);
|
|
2968
|
-
}, []), y =
|
|
2969
|
-
var
|
|
2968
|
+
}, []), y = z(() => {
|
|
2969
|
+
var M, E;
|
|
2970
2970
|
console.debug("[use-chat] stop() invoked - aborting stream");
|
|
2971
|
-
const
|
|
2972
|
-
var
|
|
2973
|
-
(
|
|
2971
|
+
const p = (M = T.current) == null ? void 0 : M.threadId, w = (E = T.current) == null ? void 0 : E.runId, _ = () => {
|
|
2972
|
+
var j;
|
|
2973
|
+
(j = I.current) == null || j.abort(), I.current = null, T.current = null, l(!1), k(!1);
|
|
2974
2974
|
};
|
|
2975
|
-
(w ||
|
|
2976
|
-
console.warn("[use-chat] cancel run failed:",
|
|
2977
|
-
}) : Promise.resolve()).finally(
|
|
2978
|
-
}, []), x =
|
|
2979
|
-
(
|
|
2975
|
+
(w || p ? _t.cancelRun(w || p).catch((j) => {
|
|
2976
|
+
console.warn("[use-chat] cancel run failed:", j);
|
|
2977
|
+
}) : Promise.resolve()).finally(_);
|
|
2978
|
+
}, []), x = z(
|
|
2979
|
+
(p) => {
|
|
2980
2980
|
I.current && (I.current.abort(), I.current = null);
|
|
2981
2981
|
const w = {
|
|
2982
|
-
text: typeof
|
|
2983
|
-
threadId:
|
|
2984
|
-
attachments:
|
|
2985
|
-
payload:
|
|
2986
|
-
config:
|
|
2987
|
-
checkpointId:
|
|
2988
|
-
checkpointNs:
|
|
2989
|
-
edit:
|
|
2990
|
-
command:
|
|
2982
|
+
text: typeof p.content == "string" ? p.content : p.text,
|
|
2983
|
+
threadId: p.threadId,
|
|
2984
|
+
attachments: p.attachments,
|
|
2985
|
+
payload: p.payload,
|
|
2986
|
+
config: p.config,
|
|
2987
|
+
checkpointId: p.checkpointId,
|
|
2988
|
+
checkpointNs: p.checkpointNs || void 0,
|
|
2989
|
+
edit: p.edit,
|
|
2990
|
+
command: p.command
|
|
2991
2991
|
};
|
|
2992
2992
|
l(!0), m(null), v(null);
|
|
2993
|
-
const
|
|
2994
|
-
I.current =
|
|
2995
|
-
let
|
|
2993
|
+
const _ = new AbortController();
|
|
2994
|
+
I.current = _;
|
|
2995
|
+
let U = null, M = !1;
|
|
2996
2996
|
return T.current = {
|
|
2997
2997
|
threadId: w.threadId ?? void 0,
|
|
2998
2998
|
runId: void 0,
|
|
@@ -3000,80 +3000,80 @@ function cr(e = {}) {
|
|
|
3000
3000
|
headers: {},
|
|
3001
3001
|
isStreaming: !0
|
|
3002
3002
|
}, (async () => {
|
|
3003
|
-
var
|
|
3003
|
+
var E, j, N, B, O, L;
|
|
3004
3004
|
try {
|
|
3005
|
-
let
|
|
3005
|
+
let F = {};
|
|
3006
3006
|
try {
|
|
3007
3007
|
if (r)
|
|
3008
|
-
|
|
3008
|
+
F = { Authorization: `Bearer ${r}` };
|
|
3009
3009
|
else if (typeof window < "u") {
|
|
3010
|
-
const
|
|
3011
|
-
let
|
|
3010
|
+
const te = window.__AUTH_TOKEN__, ve = ((E = window.localStorage) == null ? void 0 : E.getItem(_e.authToken)) || null;
|
|
3011
|
+
let X = null;
|
|
3012
3012
|
try {
|
|
3013
|
-
const me = (
|
|
3014
|
-
me && (
|
|
3013
|
+
const me = (j = window.localStorage) == null ? void 0 : j.getItem(_e.chatSettings);
|
|
3014
|
+
me && (X = ((N = JSON.parse(me)) == null ? void 0 : N.apiKey) || null);
|
|
3015
3015
|
} catch {
|
|
3016
3016
|
}
|
|
3017
|
-
const
|
|
3018
|
-
|
|
3017
|
+
const Z = te || ve || X || null;
|
|
3018
|
+
Z && (F = { Authorization: `Bearer ${Z}` });
|
|
3019
3019
|
}
|
|
3020
3020
|
} catch {
|
|
3021
3021
|
}
|
|
3022
3022
|
console.debug("[use-chat] POST", t + n);
|
|
3023
|
-
let
|
|
3023
|
+
let W = {};
|
|
3024
3024
|
if (typeof window < "u")
|
|
3025
3025
|
try {
|
|
3026
|
-
const H = (
|
|
3027
|
-
H && (
|
|
3026
|
+
const H = (B = window.localStorage) == null ? void 0 : B.getItem(_e.authSessionId);
|
|
3027
|
+
H && (W = { "X-Session-Id": H });
|
|
3028
3028
|
} catch {
|
|
3029
3029
|
}
|
|
3030
|
-
const
|
|
3031
|
-
...
|
|
3032
|
-
...
|
|
3030
|
+
const Y = {
|
|
3031
|
+
...F,
|
|
3032
|
+
...W,
|
|
3033
3033
|
...s.current
|
|
3034
|
-
},
|
|
3034
|
+
}, g = {
|
|
3035
3035
|
"Content-Type": "application/json",
|
|
3036
3036
|
Accept: "text/event-stream",
|
|
3037
|
-
...
|
|
3038
|
-
},
|
|
3037
|
+
...Y
|
|
3038
|
+
}, A = await fetch(t + n, {
|
|
3039
3039
|
method: "POST",
|
|
3040
|
-
headers:
|
|
3040
|
+
headers: g,
|
|
3041
3041
|
body: JSON.stringify(w),
|
|
3042
|
-
signal:
|
|
3042
|
+
signal: _.signal,
|
|
3043
3043
|
credentials: a
|
|
3044
3044
|
});
|
|
3045
|
-
if (T.current && (T.current.headers =
|
|
3046
|
-
const H = await
|
|
3045
|
+
if (T.current && (T.current.headers = Y), !A.ok || !A.body) {
|
|
3046
|
+
const H = await A.text().catch(() => "");
|
|
3047
3047
|
console.debug(
|
|
3048
3048
|
"[use-chat] non-OK response",
|
|
3049
|
-
|
|
3049
|
+
A.status,
|
|
3050
3050
|
H == null ? void 0 : H.slice(0, 500)
|
|
3051
3051
|
);
|
|
3052
|
-
const
|
|
3053
|
-
throw
|
|
3052
|
+
const te = `stream ${A.status}${H ? ": " + H : ""}`;
|
|
3053
|
+
throw te && (m(te), U = "error"), new Error(te);
|
|
3054
3054
|
}
|
|
3055
3055
|
k(!0);
|
|
3056
|
-
const
|
|
3057
|
-
let
|
|
3056
|
+
const S = A.body.getReader(), G = new TextDecoder();
|
|
3057
|
+
let J = "", D = 0, ee = Date.now();
|
|
3058
3058
|
const oe = setInterval(() => {
|
|
3059
|
-
Date.now() -
|
|
3059
|
+
Date.now() - ee > 18e5 && (m("Stream idle timeout"), U = "error", _.abort());
|
|
3060
3060
|
}, 5e3), ue = 1024 * 1024;
|
|
3061
3061
|
try {
|
|
3062
|
-
const H =
|
|
3062
|
+
const H = A.headers.get("X-Thread-Id") || A.headers.get("x-thread-id"), te = A.headers.get("X-Run-Id") || A.headers.get("x-run-id");
|
|
3063
3063
|
for (T.current && (T.current = {
|
|
3064
3064
|
...T.current,
|
|
3065
3065
|
threadId: H ?? T.current.threadId,
|
|
3066
|
-
runId:
|
|
3066
|
+
runId: te ?? T.current.runId
|
|
3067
3067
|
}); ; ) {
|
|
3068
|
-
const { value: ve, done:
|
|
3069
|
-
if (
|
|
3070
|
-
|
|
3071
|
-
let
|
|
3072
|
-
for (; (
|
|
3068
|
+
const { value: ve, done: X } = await S.read();
|
|
3069
|
+
if (X) break;
|
|
3070
|
+
J += G.decode(ve, { stream: !0 }), J.length > ue && (J = "", console.warn("Stream buffer reset: exceeded 1MB"));
|
|
3071
|
+
let Z;
|
|
3072
|
+
for (; (Z = J.indexOf(`
|
|
3073
3073
|
|
|
3074
3074
|
`)) >= 0; ) {
|
|
3075
|
-
const me =
|
|
3076
|
-
|
|
3075
|
+
const me = J.slice(0, Z);
|
|
3076
|
+
J = J.slice(Z + 2);
|
|
3077
3077
|
const je = me.split(/\r?\n/), Le = [];
|
|
3078
3078
|
let de = null;
|
|
3079
3079
|
for (const ye of je)
|
|
@@ -3105,56 +3105,56 @@ function cr(e = {}) {
|
|
|
3105
3105
|
continue;
|
|
3106
3106
|
}
|
|
3107
3107
|
const Ee = Bn(Me);
|
|
3108
|
-
|
|
3108
|
+
ee = Date.now();
|
|
3109
3109
|
const he = Ee.seq;
|
|
3110
3110
|
if (he !== void 0) {
|
|
3111
|
-
if (he <=
|
|
3112
|
-
console.debug("[use-chat] drop duplicate/out-of-order event", { seq: he, lastProcessedSeq:
|
|
3111
|
+
if (he <= D) {
|
|
3112
|
+
console.debug("[use-chat] drop duplicate/out-of-order event", { seq: he, lastProcessedSeq: D, type: Ee.type });
|
|
3113
3113
|
continue;
|
|
3114
3114
|
}
|
|
3115
|
-
|
|
3115
|
+
D = he;
|
|
3116
3116
|
}
|
|
3117
3117
|
u(Ee);
|
|
3118
3118
|
}
|
|
3119
3119
|
}
|
|
3120
|
-
|
|
3120
|
+
U === null && !_.signal.aborted && (U = "complete");
|
|
3121
3121
|
} catch (H) {
|
|
3122
3122
|
if (H.name === "AbortError")
|
|
3123
|
-
|
|
3123
|
+
U = U ?? "aborted";
|
|
3124
3124
|
else {
|
|
3125
|
-
const
|
|
3126
|
-
|
|
3125
|
+
const te = H.message || String(H);
|
|
3126
|
+
U = "error", m(te);
|
|
3127
3127
|
}
|
|
3128
3128
|
} finally {
|
|
3129
3129
|
try {
|
|
3130
|
-
await
|
|
3130
|
+
await S.cancel();
|
|
3131
3131
|
} catch {
|
|
3132
3132
|
} finally {
|
|
3133
|
-
(
|
|
3133
|
+
(O = S.releaseLock) == null || O.call(S);
|
|
3134
3134
|
}
|
|
3135
3135
|
clearInterval(oe);
|
|
3136
3136
|
}
|
|
3137
|
-
} catch (
|
|
3138
|
-
if (
|
|
3139
|
-
|
|
3137
|
+
} catch (F) {
|
|
3138
|
+
if (F.name === "AbortError")
|
|
3139
|
+
U = U ?? "aborted";
|
|
3140
3140
|
else {
|
|
3141
|
-
const
|
|
3142
|
-
|
|
3141
|
+
const W = F.message || String(F);
|
|
3142
|
+
U = "error", m(W), M || (M = !0, (L = e.onConnectionError) == null || L.call(e, W));
|
|
3143
3143
|
}
|
|
3144
3144
|
} finally {
|
|
3145
3145
|
try {
|
|
3146
3146
|
if (e.onFinish) {
|
|
3147
|
-
const
|
|
3147
|
+
const F = {
|
|
3148
3148
|
lastSeq: 0,
|
|
3149
3149
|
lastCheckpointId: null,
|
|
3150
3150
|
lastCheckpointNs: null,
|
|
3151
3151
|
lastValues: null
|
|
3152
3152
|
// Let the reducer/history hook provide the final values
|
|
3153
3153
|
};
|
|
3154
|
-
e.onFinish(
|
|
3154
|
+
e.onFinish(F);
|
|
3155
3155
|
}
|
|
3156
|
-
} catch (
|
|
3157
|
-
console.warn("[use-chat] onClosed callback failed",
|
|
3156
|
+
} catch (F) {
|
|
3157
|
+
console.warn("[use-chat] onClosed callback failed", F);
|
|
3158
3158
|
}
|
|
3159
3159
|
l(!1), k(!1), I.current = null, T.current = null;
|
|
3160
3160
|
}
|
|
@@ -3162,12 +3162,12 @@ function cr(e = {}) {
|
|
|
3162
3162
|
},
|
|
3163
3163
|
[t, n, r, e, u]
|
|
3164
3164
|
);
|
|
3165
|
-
return
|
|
3166
|
-
var
|
|
3167
|
-
|
|
3165
|
+
return q(() => () => {
|
|
3166
|
+
var p;
|
|
3167
|
+
C.current = !1, (p = I.current) == null || p.abort();
|
|
3168
3168
|
}, []), {
|
|
3169
3169
|
isStreaming: c,
|
|
3170
|
-
error:
|
|
3170
|
+
error: f,
|
|
3171
3171
|
assistantText: "",
|
|
3172
3172
|
// Deprecated: use messages from reducer
|
|
3173
3173
|
activeMessageId: d,
|
|
@@ -3180,13 +3180,13 @@ function cr(e = {}) {
|
|
|
3180
3180
|
stream: x,
|
|
3181
3181
|
stop: y,
|
|
3182
3182
|
clear: b,
|
|
3183
|
-
setToken:
|
|
3183
|
+
setToken: P,
|
|
3184
3184
|
values: {},
|
|
3185
3185
|
// Provide empty object for backward compatibility
|
|
3186
3186
|
interrupt: () => Promise.resolve(),
|
|
3187
3187
|
resume: () => Promise.resolve(),
|
|
3188
3188
|
goto: () => Promise.resolve(),
|
|
3189
|
-
connectionState:
|
|
3189
|
+
connectionState: f ? "error" : c ? h ? "connected" : "connecting" : "idle",
|
|
3190
3190
|
messages: [],
|
|
3191
3191
|
// useStream doesn't maintain messages, use useChatSession instead
|
|
3192
3192
|
submit: x
|
|
@@ -3199,13 +3199,13 @@ function lr({
|
|
|
3199
3199
|
onThreadChange: r,
|
|
3200
3200
|
onCurrentThreadDeleted: o
|
|
3201
3201
|
}) {
|
|
3202
|
-
const [s, a] =
|
|
3203
|
-
|
|
3202
|
+
const [s, a] = V([]), [i, u] = V(t), [c, l] = V(!1), [f, m] = V(null), h = K(i), k = K(/* @__PURE__ */ new Map());
|
|
3203
|
+
q(() => {
|
|
3204
3204
|
h.current = i;
|
|
3205
|
-
}, [i]),
|
|
3205
|
+
}, [i]), q(() => {
|
|
3206
3206
|
t !== void 0 && t !== h.current && u(t);
|
|
3207
3207
|
}, [t]);
|
|
3208
|
-
const d =
|
|
3208
|
+
const d = z(async () => {
|
|
3209
3209
|
l(!0), m(null);
|
|
3210
3210
|
try {
|
|
3211
3211
|
const b = await e.listThreads();
|
|
@@ -3217,40 +3217,40 @@ function lr({
|
|
|
3217
3217
|
l(!1);
|
|
3218
3218
|
}
|
|
3219
3219
|
}, [e, n]);
|
|
3220
|
-
|
|
3220
|
+
q(() => {
|
|
3221
3221
|
d();
|
|
3222
|
-
}, [d]),
|
|
3222
|
+
}, [d]), q(() => {
|
|
3223
3223
|
r == null || r(i);
|
|
3224
3224
|
}, [i, r]);
|
|
3225
|
-
const v =
|
|
3225
|
+
const v = z(
|
|
3226
3226
|
async (b, y) => {
|
|
3227
3227
|
try {
|
|
3228
|
-
const x = y && typeof y == "object" ? { id: y.id, name: y.name ?? "" } : void 0,
|
|
3229
|
-
return u(
|
|
3228
|
+
const x = y && typeof y == "object" ? { id: y.id, name: y.name ?? "" } : void 0, p = await e.createThread(b, x);
|
|
3229
|
+
return u(p.threadId), await d(), p.threadId;
|
|
3230
3230
|
} catch (x) {
|
|
3231
|
-
const
|
|
3232
|
-
return n == null || n(
|
|
3231
|
+
const p = String(x);
|
|
3232
|
+
return n == null || n(p), null;
|
|
3233
3233
|
}
|
|
3234
3234
|
},
|
|
3235
3235
|
[e, n, d]
|
|
3236
|
-
), I =
|
|
3236
|
+
), I = z(
|
|
3237
3237
|
async (b) => {
|
|
3238
3238
|
const y = s;
|
|
3239
|
-
a((
|
|
3239
|
+
a((p) => p.filter((w) => w.threadId !== b));
|
|
3240
3240
|
const x = new AbortController();
|
|
3241
3241
|
k.current.set(b, x);
|
|
3242
3242
|
try {
|
|
3243
3243
|
await e.deleteThread(b), h.current === b && (u(null), o == null || o());
|
|
3244
|
-
} catch (
|
|
3244
|
+
} catch (p) {
|
|
3245
3245
|
a(y);
|
|
3246
|
-
const w = String(
|
|
3246
|
+
const w = String(p);
|
|
3247
3247
|
n == null || n(w);
|
|
3248
3248
|
} finally {
|
|
3249
3249
|
k.current.delete(b);
|
|
3250
3250
|
}
|
|
3251
3251
|
},
|
|
3252
3252
|
[e, o, n, s]
|
|
3253
|
-
),
|
|
3253
|
+
), C = z(
|
|
3254
3254
|
async (b, y) => {
|
|
3255
3255
|
try {
|
|
3256
3256
|
await e.updateThread(b, y), await d();
|
|
@@ -3259,15 +3259,15 @@ function lr({
|
|
|
3259
3259
|
}
|
|
3260
3260
|
},
|
|
3261
3261
|
[e, n, d]
|
|
3262
|
-
), T =
|
|
3262
|
+
), T = Q(
|
|
3263
3263
|
() => ({
|
|
3264
3264
|
createThread: v,
|
|
3265
3265
|
deleteThread: I,
|
|
3266
|
-
renameThread:
|
|
3266
|
+
renameThread: C,
|
|
3267
3267
|
refreshThreads: d
|
|
3268
3268
|
}),
|
|
3269
|
-
[v, I,
|
|
3270
|
-
),
|
|
3269
|
+
[v, I, C, d]
|
|
3270
|
+
), P = z((b) => {
|
|
3271
3271
|
if (!(b != null && b.threadId)) return;
|
|
3272
3272
|
const y = {
|
|
3273
3273
|
threadId: b.threadId,
|
|
@@ -3278,15 +3278,15 @@ function lr({
|
|
|
3278
3278
|
messageCount: b.messageCount ?? 1
|
|
3279
3279
|
};
|
|
3280
3280
|
a((x) => {
|
|
3281
|
-
let
|
|
3282
|
-
const w = x.map((
|
|
3283
|
-
...
|
|
3284
|
-
title: y.title ??
|
|
3285
|
-
project: y.project ??
|
|
3286
|
-
updatedAt: y.updatedAt ??
|
|
3287
|
-
messageCount: y.messageCount ??
|
|
3288
|
-
}) :
|
|
3289
|
-
return
|
|
3281
|
+
let p = !1;
|
|
3282
|
+
const w = x.map((_) => _.threadId === y.threadId ? (p = !0, console.debug("[useThreadsState] thread_info: updating existing thread", y.threadId), {
|
|
3283
|
+
..._,
|
|
3284
|
+
title: y.title ?? _.title,
|
|
3285
|
+
project: y.project ?? _.project,
|
|
3286
|
+
updatedAt: y.updatedAt ?? _.updatedAt,
|
|
3287
|
+
messageCount: y.messageCount ?? _.messageCount
|
|
3288
|
+
}) : _);
|
|
3289
|
+
return p ? w : (console.debug("[useThreadsState] thread_info: adding thread to list", y.threadId), [y, ...x]);
|
|
3290
3290
|
});
|
|
3291
3291
|
}, []);
|
|
3292
3292
|
return {
|
|
@@ -3295,9 +3295,9 @@ function lr({
|
|
|
3295
3295
|
currentThreadIdRef: h,
|
|
3296
3296
|
setCurrentThreadId: u,
|
|
3297
3297
|
isLoadingThreads: c,
|
|
3298
|
-
threadsError:
|
|
3298
|
+
threadsError: f,
|
|
3299
3299
|
actions: T,
|
|
3300
|
-
addThreadFromEvent:
|
|
3300
|
+
addThreadFromEvent: P
|
|
3301
3301
|
};
|
|
3302
3302
|
}
|
|
3303
3303
|
const jt = Se(null);
|
|
@@ -3314,14 +3314,14 @@ function ur({
|
|
|
3314
3314
|
currentThreadIdRef: u,
|
|
3315
3315
|
isLoadingThreads: c,
|
|
3316
3316
|
threadsError: l,
|
|
3317
|
-
actions:
|
|
3317
|
+
actions: f,
|
|
3318
3318
|
addThreadFromEvent: m
|
|
3319
3319
|
} = lr({
|
|
3320
3320
|
api: o,
|
|
3321
3321
|
initialThreadId: t,
|
|
3322
3322
|
onError: n,
|
|
3323
3323
|
onThreadChange: r
|
|
3324
|
-
}), h =
|
|
3324
|
+
}), h = Q(
|
|
3325
3325
|
() => ({
|
|
3326
3326
|
threads: s,
|
|
3327
3327
|
currentThreadId: a,
|
|
@@ -3329,7 +3329,7 @@ function ur({
|
|
|
3329
3329
|
currentThreadIdRef: u,
|
|
3330
3330
|
isLoading: c,
|
|
3331
3331
|
error: l,
|
|
3332
|
-
actions:
|
|
3332
|
+
actions: f,
|
|
3333
3333
|
addThreadFromEvent: m
|
|
3334
3334
|
}),
|
|
3335
3335
|
[
|
|
@@ -3339,7 +3339,7 @@ function ur({
|
|
|
3339
3339
|
u,
|
|
3340
3340
|
c,
|
|
3341
3341
|
l,
|
|
3342
|
-
|
|
3342
|
+
f,
|
|
3343
3343
|
m
|
|
3344
3344
|
]
|
|
3345
3345
|
);
|
|
@@ -3462,15 +3462,15 @@ function gr(e, t) {
|
|
|
3462
3462
|
}
|
|
3463
3463
|
}
|
|
3464
3464
|
function mr(e = []) {
|
|
3465
|
-
const [t, n] = Wt(gr, { ...Ot, messages: e }), r = K([]), o = K(null), s =
|
|
3465
|
+
const [t, n] = Wt(gr, { ...Ot, messages: e }), r = K([]), o = K(null), s = z(() => {
|
|
3466
3466
|
o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), o.current = null;
|
|
3467
3467
|
const c = r.current;
|
|
3468
3468
|
c.length && (r.current = [], n({ type: "batch", payload: { events: c } }));
|
|
3469
|
-
}, []), a =
|
|
3469
|
+
}, []), a = z(() => {
|
|
3470
3470
|
typeof window < "u" && typeof window.requestAnimationFrame == "function" ? o.current === null && (o.current = window.requestAnimationFrame(() => s())) : setTimeout(s, 8);
|
|
3471
|
-
}, [s]), i =
|
|
3471
|
+
}, [s]), i = z((c) => {
|
|
3472
3472
|
r.current.push(c), a();
|
|
3473
|
-
}, [a]), u =
|
|
3473
|
+
}, [a]), u = Q(() => ({
|
|
3474
3474
|
setStatus: (c, l) => n({ type: "status", payload: { status: c, error: l } }),
|
|
3475
3475
|
reset: (c) => n({ type: "reset", payload: { messages: c } }),
|
|
3476
3476
|
seed: (c, l) => n({ type: "seed", payload: { messages: c, ...l ?? {} } }),
|
|
@@ -3500,7 +3500,7 @@ function ft(e, t) {
|
|
|
3500
3500
|
return { ...e, status: "error", error: t.message, messages: [...e.messages, i] };
|
|
3501
3501
|
}
|
|
3502
3502
|
if (t.type === "values" && ((a = n.values) != null && a.messages)) {
|
|
3503
|
-
const i = n.values, u = Array.isArray(i.messages) ? i.messages : [], c = Oe(u), { messages: l, ...
|
|
3503
|
+
const i = n.values, u = Array.isArray(i.messages) ? i.messages : [], c = Oe(u), { messages: l, ...f } = i;
|
|
3504
3504
|
if (s) {
|
|
3505
3505
|
const m = typeof o == "string" && o.length > 0 ? o : "task";
|
|
3506
3506
|
return {
|
|
@@ -3514,7 +3514,7 @@ function ft(e, t) {
|
|
|
3514
3514
|
messages: c,
|
|
3515
3515
|
assemblingId: null,
|
|
3516
3516
|
pendingInterrupt: null,
|
|
3517
|
-
values:
|
|
3517
|
+
values: f
|
|
3518
3518
|
};
|
|
3519
3519
|
}
|
|
3520
3520
|
return t.type === "messages/partial" ? hr(e, n) : t.type === "tool.start" ? s ? e : yr(e, t) : t.type === "tool.progress" ? s ? e : br(e, t) : t.type === "tool.end" ? s ? e : wr(e, t) : t.type === "artifact.update" ? vr(e, t) : e;
|
|
@@ -3571,7 +3571,7 @@ function yr(e, t) {
|
|
|
3571
3571
|
}
|
|
3572
3572
|
}
|
|
3573
3573
|
if (i !== -1) {
|
|
3574
|
-
const u = a[i], c = [...u.toolCalls || []], l = c.findIndex((
|
|
3574
|
+
const u = a[i], c = [...u.toolCalls || []], l = c.findIndex((f) => f.id === r);
|
|
3575
3575
|
l >= 0 ? c[l] = { ...c[l], status: "running", content: s } : c.push({
|
|
3576
3576
|
id: r,
|
|
3577
3577
|
name: o,
|
|
@@ -3665,8 +3665,8 @@ async function Ir(e, t) {
|
|
|
3665
3665
|
for (const c of r) {
|
|
3666
3666
|
const l = (i = c == null ? void 0 : c.values) == null ? void 0 : i.messages;
|
|
3667
3667
|
if (Array.isArray(l))
|
|
3668
|
-
for (const
|
|
3669
|
-
const m =
|
|
3668
|
+
for (const f of l) {
|
|
3669
|
+
const m = f == null ? void 0 : f.content;
|
|
3670
3670
|
if (Array.isArray(m))
|
|
3671
3671
|
for (const h of m) {
|
|
3672
3672
|
if (!h || typeof h != "object" || h.type !== "image_url" && h.type !== "file") continue;
|
|
@@ -3680,8 +3680,8 @@ async function Ir(e, t) {
|
|
|
3680
3680
|
const s = await Promise.all(
|
|
3681
3681
|
Array.from(o).map(async (c) => {
|
|
3682
3682
|
try {
|
|
3683
|
-
const l = await t.getFileInfo(c),
|
|
3684
|
-
return [c,
|
|
3683
|
+
const l = await t.getFileInfo(c), f = le(l);
|
|
3684
|
+
return [c, f];
|
|
3685
3685
|
} catch {
|
|
3686
3686
|
return [c, null];
|
|
3687
3687
|
}
|
|
@@ -3690,8 +3690,8 @@ async function Ir(e, t) {
|
|
|
3690
3690
|
for (const c of r) {
|
|
3691
3691
|
const l = (u = c == null ? void 0 : c.values) == null ? void 0 : u.messages;
|
|
3692
3692
|
if (Array.isArray(l))
|
|
3693
|
-
for (const
|
|
3694
|
-
const m =
|
|
3693
|
+
for (const f of l) {
|
|
3694
|
+
const m = f == null ? void 0 : f.content;
|
|
3695
3695
|
if (Array.isArray(m))
|
|
3696
3696
|
for (const h of m) {
|
|
3697
3697
|
if (!h || typeof h != "object" || h.type !== "image_url" && h.type !== "file") continue;
|
|
@@ -3716,23 +3716,23 @@ function gt(e) {
|
|
|
3716
3716
|
function Tr(e, t) {
|
|
3717
3717
|
var b, y;
|
|
3718
3718
|
if (!e) return null;
|
|
3719
|
-
const n = ((b = e.values) == null ? void 0 : b.activeAgent) ?? null, r = (y = e.values) == null ? void 0 : y.messages, s = (Array.isArray(r) ? r : []).map((x) => xr(x, n)).filter((x) => !!x), a = ze(e.metadata) ?? {}, i = pt(e.config), u = ze(e.parentConfig), c = pt(u), l = Fe(i, ["checkpointId"]),
|
|
3719
|
+
const n = ((b = e.values) == null ? void 0 : b.activeAgent) ?? null, r = (y = e.values) == null ? void 0 : y.messages, s = (Array.isArray(r) ? r : []).map((x) => xr(x, n)).filter((x) => !!x), a = ze(e.metadata) ?? {}, i = pt(e.config), u = ze(e.parentConfig), c = pt(u), l = Fe(i, ["checkpointId"]), f = Fe(i, ["checkpointNs"]), m = Fe(c, ["checkpointId"]), h = ze(e.config), k = Array.isArray(e.tasks) ? e.tasks.map((x) => ({ ...x })) : e.tasks ?? null, d = Array.isArray(e.next) ? [...e.next] : e.next ?? null, v = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), I = {
|
|
3720
3720
|
...a,
|
|
3721
3721
|
step: kr(a, ["step"]) ?? 0,
|
|
3722
3722
|
source: Fe(a, ["source"]) ?? null
|
|
3723
|
-
},
|
|
3723
|
+
}, C = s.map((x) => ({
|
|
3724
3724
|
...x,
|
|
3725
3725
|
checkpointId: x.checkpointId ?? l ?? null,
|
|
3726
|
-
checkpointNs: x.checkpointNs ??
|
|
3727
|
-
})), T = e.values,
|
|
3726
|
+
checkpointNs: x.checkpointNs ?? f ?? null
|
|
3727
|
+
})), T = e.values, P = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(T == null ? void 0 : T.interrupts) ? T.interrupts : [];
|
|
3728
3728
|
return {
|
|
3729
3729
|
checkpointId: l ?? null,
|
|
3730
|
-
checkpointNs:
|
|
3730
|
+
checkpointNs: f ?? null,
|
|
3731
3731
|
createdAt: v,
|
|
3732
3732
|
parentId: m ?? null,
|
|
3733
|
-
messages:
|
|
3733
|
+
messages: C,
|
|
3734
3734
|
interrupt: Ar(
|
|
3735
|
-
|
|
3735
|
+
P,
|
|
3736
3736
|
t,
|
|
3737
3737
|
l ?? null
|
|
3738
3738
|
),
|
|
@@ -3785,12 +3785,12 @@ function Cr(e) {
|
|
|
3785
3785
|
function Mr(e) {
|
|
3786
3786
|
const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), o = [];
|
|
3787
3787
|
for (let c = 0; c < e.length; c++) {
|
|
3788
|
-
const l = e[c],
|
|
3788
|
+
const l = e[c], f = l.checkpointId, m = f ?? `cp-${c}`, h = l.metadata ?? {}, k = typeof h.step == "number" ? h.step : null, d = typeof h.source == "string" ? h.source : null;
|
|
3789
3789
|
let v = null, I = null;
|
|
3790
|
-
const
|
|
3791
|
-
for (const y of
|
|
3790
|
+
const C = Array.isArray(l.messages) ? l.messages : [];
|
|
3791
|
+
for (const y of C)
|
|
3792
3792
|
y.role === "user" && (I || (I = y), y.id && (v = y.id));
|
|
3793
|
-
const T = l.next && l.next.length > 0 ? String(l.next[0]) : null,
|
|
3793
|
+
const T = l.next && l.next.length > 0 ? String(l.next[0]) : null, P = l.parentConfig ?? null, b = {
|
|
3794
3794
|
id: m,
|
|
3795
3795
|
step: k,
|
|
3796
3796
|
source: d,
|
|
@@ -3798,12 +3798,12 @@ function Mr(e) {
|
|
|
3798
3798
|
namespace: l.checkpointNs ?? null,
|
|
3799
3799
|
parentId: l.parentId ?? null,
|
|
3800
3800
|
next: T,
|
|
3801
|
-
parentConfig:
|
|
3801
|
+
parentConfig: P,
|
|
3802
3802
|
userMessageId: v
|
|
3803
3803
|
};
|
|
3804
|
-
if (o.push(b),
|
|
3804
|
+
if (o.push(b), f && t.set(f, b), f && I) {
|
|
3805
3805
|
const y = Cr(I);
|
|
3806
|
-
y && r.set(
|
|
3806
|
+
y && r.set(f, y);
|
|
3807
3807
|
}
|
|
3808
3808
|
n.push({
|
|
3809
3809
|
id: m,
|
|
@@ -3812,7 +3812,7 @@ function Mr(e) {
|
|
|
3812
3812
|
source: d,
|
|
3813
3813
|
createdAt: l.createdAt ?? null,
|
|
3814
3814
|
next: T,
|
|
3815
|
-
parentConfig:
|
|
3815
|
+
parentConfig: P
|
|
3816
3816
|
});
|
|
3817
3817
|
}
|
|
3818
3818
|
const s = /* @__PURE__ */ new Map();
|
|
@@ -3823,14 +3823,14 @@ function Mr(e) {
|
|
|
3823
3823
|
}
|
|
3824
3824
|
for (const c of s.values()) {
|
|
3825
3825
|
if (!c.length) continue;
|
|
3826
|
-
c.sort((
|
|
3827
|
-
const h =
|
|
3826
|
+
c.sort((f, m) => {
|
|
3827
|
+
const h = f.createdAt ? Date.parse(f.createdAt) : 0;
|
|
3828
3828
|
return (m.createdAt ? Date.parse(m.createdAt) : 0) - h;
|
|
3829
3829
|
});
|
|
3830
3830
|
const l = c.length;
|
|
3831
|
-
for (let
|
|
3832
|
-
const m = c[
|
|
3833
|
-
m.attemptCount = l, m.attemptIndex =
|
|
3831
|
+
for (let f = 0; f < c.length; f++) {
|
|
3832
|
+
const m = c[f];
|
|
3833
|
+
m.attemptCount = l, m.attemptIndex = f, m.isLatestAttempt = f === 0;
|
|
3834
3834
|
}
|
|
3835
3835
|
}
|
|
3836
3836
|
return {
|
|
@@ -3846,10 +3846,10 @@ function Mr(e) {
|
|
|
3846
3846
|
getCheckpoint: (c) => t.get(c),
|
|
3847
3847
|
getMessageAttempts: (c) => {
|
|
3848
3848
|
const l = [];
|
|
3849
|
-
for (const
|
|
3850
|
-
|
|
3851
|
-
return l.length ? (l.sort((
|
|
3852
|
-
const h = typeof
|
|
3849
|
+
for (const f of t.values())
|
|
3850
|
+
f.userMessageId === c && l.push(f);
|
|
3851
|
+
return l.length ? (l.sort((f, m) => {
|
|
3852
|
+
const h = typeof f.attemptIndex == "number" ? f.attemptIndex : Number.MAX_SAFE_INTEGER, k = typeof m.attemptIndex == "number" ? m.attemptIndex : Number.MAX_SAFE_INTEGER;
|
|
3853
3853
|
return h - k;
|
|
3854
3854
|
}), l) : [];
|
|
3855
3855
|
}
|
|
@@ -3873,7 +3873,7 @@ function so(e, t, n) {
|
|
|
3873
3873
|
};
|
|
3874
3874
|
}
|
|
3875
3875
|
function Er(e) {
|
|
3876
|
-
return
|
|
3876
|
+
return Q(() => Mr(e), [e]);
|
|
3877
3877
|
}
|
|
3878
3878
|
function Bt({
|
|
3879
3879
|
api: e,
|
|
@@ -3885,137 +3885,137 @@ function Bt({
|
|
|
3885
3885
|
isStreaming: a,
|
|
3886
3886
|
getMessages: i
|
|
3887
3887
|
}) {
|
|
3888
|
-
const [u, c] =
|
|
3888
|
+
const [u, c] = V(null), f = Q(
|
|
3889
3889
|
() => gt(u),
|
|
3890
3890
|
[u]
|
|
3891
|
-
).checkpoints, m = Er(
|
|
3892
|
-
|
|
3893
|
-
|
|
3891
|
+
).checkpoints, m = Er(f), h = m.timeline, [k, d] = V(!1), [v, I] = V(!1), [C, T] = V(null), P = K(o), b = K(null), y = K(null);
|
|
3892
|
+
q(() => {
|
|
3893
|
+
P.current = o;
|
|
3894
3894
|
}, [o]);
|
|
3895
|
-
const x =
|
|
3896
|
-
async (
|
|
3897
|
-
const
|
|
3898
|
-
threadId:
|
|
3899
|
-
checkpointId:
|
|
3900
|
-
checkpointNs:
|
|
3901
|
-
}),
|
|
3895
|
+
const x = z(
|
|
3896
|
+
async (E) => {
|
|
3897
|
+
const j = await e.getState({
|
|
3898
|
+
threadId: E.threadId,
|
|
3899
|
+
checkpointId: E.checkpointId,
|
|
3900
|
+
checkpointNs: E.checkpointNs
|
|
3901
|
+
}), N = {
|
|
3902
3902
|
version: "values@1",
|
|
3903
|
-
threadId:
|
|
3904
|
-
checkpoints: [
|
|
3905
|
-
},
|
|
3906
|
-
return
|
|
3903
|
+
threadId: E.threadId,
|
|
3904
|
+
checkpoints: [j]
|
|
3905
|
+
}, B = t ? await Ir(N, t) : N, { latest: O } = gt(B);
|
|
3906
|
+
return O;
|
|
3907
3907
|
},
|
|
3908
3908
|
[e, t]
|
|
3909
|
-
),
|
|
3910
|
-
async (
|
|
3911
|
-
var
|
|
3912
|
-
if (!
|
|
3913
|
-
const
|
|
3914
|
-
if (b.current ===
|
|
3915
|
-
(
|
|
3916
|
-
const
|
|
3917
|
-
y.current =
|
|
3909
|
+
), p = z(
|
|
3910
|
+
async (E, j) => {
|
|
3911
|
+
var O;
|
|
3912
|
+
if (!E) return;
|
|
3913
|
+
const N = `${E}:${j ?? "latest"}`;
|
|
3914
|
+
if (b.current === N && !k) return;
|
|
3915
|
+
(O = y.current) == null || O.abort();
|
|
3916
|
+
const B = new AbortController();
|
|
3917
|
+
y.current = B, d(!0), T(null);
|
|
3918
3918
|
try {
|
|
3919
|
-
const
|
|
3920
|
-
threadId:
|
|
3921
|
-
checkpointId:
|
|
3919
|
+
const L = await x({
|
|
3920
|
+
threadId: E,
|
|
3921
|
+
checkpointId: j ?? void 0
|
|
3922
3922
|
});
|
|
3923
|
-
if (
|
|
3924
|
-
n((
|
|
3925
|
-
checkpointId: (
|
|
3926
|
-
checkpointNs: (
|
|
3927
|
-
pendingInterrupt: (
|
|
3928
|
-
values:
|
|
3929
|
-
}), b.current =
|
|
3930
|
-
const
|
|
3931
|
-
threadId:
|
|
3923
|
+
if (P.current !== E) return;
|
|
3924
|
+
n((L == null ? void 0 : L.messages) ?? [], {
|
|
3925
|
+
checkpointId: (L == null ? void 0 : L.checkpointId) ?? null,
|
|
3926
|
+
checkpointNs: (L == null ? void 0 : L.checkpointNs) ?? null,
|
|
3927
|
+
pendingInterrupt: (L == null ? void 0 : L.interrupt) ?? null,
|
|
3928
|
+
values: L == null ? void 0 : L.values
|
|
3929
|
+
}), b.current = N;
|
|
3930
|
+
const F = await e.getStateHistory({
|
|
3931
|
+
threadId: E,
|
|
3932
3932
|
limit: 100,
|
|
3933
3933
|
includeMessages: !1
|
|
3934
3934
|
});
|
|
3935
|
-
|
|
3936
|
-
} catch (
|
|
3937
|
-
if (!Jt(
|
|
3938
|
-
const
|
|
3939
|
-
T(
|
|
3935
|
+
P.current === E && c(F);
|
|
3936
|
+
} catch (L) {
|
|
3937
|
+
if (!Jt(L)) {
|
|
3938
|
+
const F = String(L);
|
|
3939
|
+
T(F), r == null || r(F);
|
|
3940
3940
|
}
|
|
3941
3941
|
} finally {
|
|
3942
3942
|
d(!1);
|
|
3943
3943
|
}
|
|
3944
3944
|
},
|
|
3945
3945
|
[e, n, x, r, k, i]
|
|
3946
|
-
), w =
|
|
3947
|
-
async (
|
|
3946
|
+
), w = z(
|
|
3947
|
+
async (E, j) => {
|
|
3948
3948
|
if (o) {
|
|
3949
3949
|
I(!0);
|
|
3950
3950
|
try {
|
|
3951
|
-
const
|
|
3951
|
+
const N = await x({
|
|
3952
3952
|
threadId: o,
|
|
3953
|
-
checkpointId:
|
|
3954
|
-
checkpointNs:
|
|
3953
|
+
checkpointId: E,
|
|
3954
|
+
checkpointNs: j ?? void 0
|
|
3955
3955
|
});
|
|
3956
|
-
n((
|
|
3957
|
-
checkpointId: (
|
|
3958
|
-
checkpointNs: (
|
|
3959
|
-
pendingInterrupt: (
|
|
3960
|
-
values:
|
|
3956
|
+
n((N == null ? void 0 : N.messages) ?? [], {
|
|
3957
|
+
checkpointId: (N == null ? void 0 : N.checkpointId) ?? E,
|
|
3958
|
+
checkpointNs: (N == null ? void 0 : N.checkpointNs) ?? j,
|
|
3959
|
+
pendingInterrupt: (N == null ? void 0 : N.interrupt) ?? null,
|
|
3960
|
+
values: N == null ? void 0 : N.values
|
|
3961
3961
|
});
|
|
3962
|
-
} catch (
|
|
3963
|
-
console.error("[useThreadHistoryState] Navigation failed",
|
|
3962
|
+
} catch (N) {
|
|
3963
|
+
console.error("[useThreadHistoryState] Navigation failed", N);
|
|
3964
3964
|
} finally {
|
|
3965
3965
|
I(!1);
|
|
3966
3966
|
}
|
|
3967
3967
|
}
|
|
3968
3968
|
},
|
|
3969
3969
|
[o, x, n]
|
|
3970
|
-
),
|
|
3971
|
-
o && await
|
|
3972
|
-
}, [o,
|
|
3973
|
-
async (
|
|
3974
|
-
var
|
|
3975
|
-
const
|
|
3976
|
-
if (!
|
|
3977
|
-
if (c(
|
|
3978
|
-
const
|
|
3979
|
-
threadId:
|
|
3970
|
+
), _ = z(async () => {
|
|
3971
|
+
o && await p(o);
|
|
3972
|
+
}, [o, p]), U = z(
|
|
3973
|
+
async (E) => {
|
|
3974
|
+
var B;
|
|
3975
|
+
const j = (E == null ? void 0 : E.threadId) || o;
|
|
3976
|
+
if (!j || o !== j) return;
|
|
3977
|
+
if (c(E), b.current = `${j}:latest`, (B = E.values) != null && B.messages) {
|
|
3978
|
+
const O = await x({
|
|
3979
|
+
threadId: j
|
|
3980
3980
|
});
|
|
3981
|
-
|
|
3982
|
-
checkpointId:
|
|
3983
|
-
checkpointNs:
|
|
3984
|
-
pendingInterrupt:
|
|
3985
|
-
values:
|
|
3981
|
+
O && n(O.messages ?? [], {
|
|
3982
|
+
checkpointId: O.checkpointId ?? null,
|
|
3983
|
+
checkpointNs: O.checkpointNs ?? null,
|
|
3984
|
+
pendingInterrupt: O.interrupt ?? null,
|
|
3985
|
+
values: O.values
|
|
3986
3986
|
});
|
|
3987
3987
|
}
|
|
3988
3988
|
},
|
|
3989
3989
|
[o, x, n]
|
|
3990
3990
|
);
|
|
3991
|
-
|
|
3991
|
+
q(() => {
|
|
3992
3992
|
if (!s || !o || k || a) return;
|
|
3993
|
-
const
|
|
3994
|
-
b.current !==
|
|
3995
|
-
}, [s, o, k, a,
|
|
3996
|
-
const
|
|
3993
|
+
const E = `${o}:latest`;
|
|
3994
|
+
b.current !== E && p(o);
|
|
3995
|
+
}, [s, o, k, a, p]);
|
|
3996
|
+
const M = z(() => {
|
|
3997
3997
|
c(null), d(!1), I(!1), T(null), b.current = null;
|
|
3998
3998
|
}, []);
|
|
3999
3999
|
return {
|
|
4000
|
-
threadCheckpoints:
|
|
4000
|
+
threadCheckpoints: f,
|
|
4001
4001
|
threadTimeline: h,
|
|
4002
4002
|
checkpointIndex: m,
|
|
4003
4003
|
isLoadingThread: k,
|
|
4004
4004
|
isLoadingCheckpoint: v,
|
|
4005
|
-
threadStateError:
|
|
4006
|
-
loadThread:
|
|
4005
|
+
threadStateError: C,
|
|
4006
|
+
loadThread: p,
|
|
4007
4007
|
navigateToCheckpoint: w,
|
|
4008
|
-
setCurrentCheckpointId: (
|
|
4009
|
-
n(i(), { checkpointId:
|
|
4008
|
+
setCurrentCheckpointId: (E, j) => {
|
|
4009
|
+
n(i(), { checkpointId: E, checkpointNs: j });
|
|
4010
4010
|
},
|
|
4011
|
-
returnToLatest:
|
|
4012
|
-
handleValuesEvent:
|
|
4011
|
+
returnToLatest: _,
|
|
4012
|
+
handleValuesEvent: U,
|
|
4013
4013
|
markSkipNextLoad: () => {
|
|
4014
4014
|
},
|
|
4015
4015
|
markStreamPendingThread: () => {
|
|
4016
4016
|
},
|
|
4017
|
-
resetHistoryState:
|
|
4018
|
-
clearState:
|
|
4017
|
+
resetHistoryState: M,
|
|
4018
|
+
clearState: M
|
|
4019
4019
|
};
|
|
4020
4020
|
}
|
|
4021
4021
|
const $t = Se(null), Vt = Se(null);
|
|
@@ -4039,25 +4039,25 @@ function Nr({
|
|
|
4039
4039
|
isStreaming: s,
|
|
4040
4040
|
onError: a
|
|
4041
4041
|
}) {
|
|
4042
|
-
const { chatApi: i, fileApi: u } = Ae(), { currentThreadId: c } = rt(), { state: l, seed:
|
|
4042
|
+
const { chatApi: i, fileApi: u } = Ae(), { currentThreadId: c } = rt(), { state: l, seed: f, onEvent: m, dispatch: h } = mr(), {
|
|
4043
4043
|
threadCheckpoints: k,
|
|
4044
4044
|
threadTimeline: d,
|
|
4045
4045
|
checkpointIndex: v,
|
|
4046
4046
|
isLoadingThread: I,
|
|
4047
|
-
isLoadingCheckpoint:
|
|
4047
|
+
isLoadingCheckpoint: C,
|
|
4048
4048
|
threadStateError: T,
|
|
4049
|
-
loadThread:
|
|
4049
|
+
loadThread: P,
|
|
4050
4050
|
navigateToCheckpoint: b,
|
|
4051
4051
|
setCurrentCheckpointId: y,
|
|
4052
4052
|
returnToLatest: x,
|
|
4053
|
-
handleValuesEvent:
|
|
4053
|
+
handleValuesEvent: p,
|
|
4054
4054
|
markSkipNextLoad: w,
|
|
4055
|
-
markStreamPendingThread:
|
|
4056
|
-
resetHistoryState:
|
|
4055
|
+
markStreamPendingThread: _,
|
|
4056
|
+
resetHistoryState: U
|
|
4057
4057
|
} = Bt({
|
|
4058
4058
|
api: i,
|
|
4059
4059
|
fileApi: u,
|
|
4060
|
-
seed:
|
|
4060
|
+
seed: f,
|
|
4061
4061
|
onError: a,
|
|
4062
4062
|
currentThreadId: c,
|
|
4063
4063
|
initialThreadId: t,
|
|
@@ -4065,32 +4065,34 @@ function Nr({
|
|
|
4065
4065
|
initialCheckpointNs: r,
|
|
4066
4066
|
autoLoadInitial: o,
|
|
4067
4067
|
isStreaming: s,
|
|
4068
|
-
getMessages:
|
|
4069
|
-
}),
|
|
4070
|
-
(
|
|
4071
|
-
|
|
4068
|
+
getMessages: z(() => l.messages, [l.messages])
|
|
4069
|
+
}), M = K(null), E = z(
|
|
4070
|
+
(A) => {
|
|
4071
|
+
M.current = A;
|
|
4072
4072
|
},
|
|
4073
4073
|
[]
|
|
4074
|
-
),
|
|
4075
|
-
(
|
|
4076
|
-
|
|
4074
|
+
), j = K(null), N = z(
|
|
4075
|
+
(A) => {
|
|
4076
|
+
j.current = A;
|
|
4077
4077
|
},
|
|
4078
4078
|
[]
|
|
4079
|
-
),
|
|
4080
|
-
(
|
|
4081
|
-
const
|
|
4079
|
+
), B = Q(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), O = z(
|
|
4080
|
+
(A, S) => {
|
|
4081
|
+
const G = Ut(A, "user");
|
|
4082
4082
|
return h({
|
|
4083
4083
|
type: "user_message",
|
|
4084
4084
|
payload: {
|
|
4085
|
-
message:
|
|
4086
|
-
editingMessageId:
|
|
4085
|
+
message: G,
|
|
4086
|
+
editingMessageId: S == null ? void 0 : S.editingMessageId
|
|
4087
4087
|
}
|
|
4088
|
-
}),
|
|
4088
|
+
}), G;
|
|
4089
4089
|
},
|
|
4090
4090
|
[h]
|
|
4091
|
-
),
|
|
4092
|
-
|
|
4093
|
-
}, [
|
|
4091
|
+
), L = z(async () => {
|
|
4092
|
+
M.current ? await M.current() : (f([], {}), U());
|
|
4093
|
+
}, [f, U]), F = z(async (A, S, G) => {
|
|
4094
|
+
await P(A, S, { clearProgress: !1 });
|
|
4095
|
+
}, [P]), W = Q(() => Ln(l.messages), [l.messages]), Y = Q(
|
|
4094
4096
|
() => ({
|
|
4095
4097
|
status: l.status,
|
|
4096
4098
|
threadId: c,
|
|
@@ -4104,41 +4106,39 @@ function Nr({
|
|
|
4104
4106
|
checkpoints: k,
|
|
4105
4107
|
checkpointIndex: v,
|
|
4106
4108
|
timelineCheckpoints: d,
|
|
4107
|
-
metadata:
|
|
4109
|
+
metadata: B,
|
|
4108
4110
|
values: l.values ?? {},
|
|
4109
4111
|
isLoading: I,
|
|
4110
|
-
isLoadingCheckpoint:
|
|
4112
|
+
isLoadingCheckpoint: C,
|
|
4111
4113
|
error: T,
|
|
4112
4114
|
loadOlder: async () => {
|
|
4113
4115
|
},
|
|
4114
4116
|
// Placeholder
|
|
4115
|
-
seedFromSnapshot: (
|
|
4116
|
-
|
|
4117
|
-
checkpointId:
|
|
4118
|
-
checkpointNs:
|
|
4119
|
-
pendingInterrupt:
|
|
4120
|
-
values:
|
|
4117
|
+
seedFromSnapshot: (A) => {
|
|
4118
|
+
f(A.messages, {
|
|
4119
|
+
checkpointId: A.checkpointId,
|
|
4120
|
+
checkpointNs: A.checkpointNs,
|
|
4121
|
+
pendingInterrupt: A.interrupt,
|
|
4122
|
+
values: A.values
|
|
4121
4123
|
});
|
|
4122
4124
|
},
|
|
4123
|
-
clearState:
|
|
4125
|
+
clearState: L,
|
|
4124
4126
|
navigateToCheckpoint: b,
|
|
4125
4127
|
setCurrentCheckpointId: y,
|
|
4126
4128
|
returnToLatest: x,
|
|
4127
|
-
loadThread:
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
respondToInterrupt: async (f, P, M) => {
|
|
4132
|
-
L.current && await L.current(f, P, M);
|
|
4129
|
+
loadThread: F,
|
|
4130
|
+
clearThread: L,
|
|
4131
|
+
respondToInterrupt: async (A, S, G) => {
|
|
4132
|
+
j.current && await j.current(A, S, G);
|
|
4133
4133
|
},
|
|
4134
4134
|
messagePreviews: v.messagePreviews,
|
|
4135
|
-
handleValuesEvent:
|
|
4135
|
+
handleValuesEvent: p,
|
|
4136
4136
|
markSkipNextLoad: w,
|
|
4137
|
-
markStreamPendingThread:
|
|
4138
|
-
resetHistoryState:
|
|
4139
|
-
pushUser:
|
|
4137
|
+
markStreamPendingThread: _,
|
|
4138
|
+
resetHistoryState: U,
|
|
4139
|
+
pushUser: O,
|
|
4140
4140
|
onEvent: m,
|
|
4141
|
-
artifacts:
|
|
4141
|
+
artifacts: W
|
|
4142
4142
|
}),
|
|
4143
4143
|
[
|
|
4144
4144
|
c,
|
|
@@ -4151,31 +4151,31 @@ function Nr({
|
|
|
4151
4151
|
k,
|
|
4152
4152
|
d,
|
|
4153
4153
|
v,
|
|
4154
|
-
|
|
4154
|
+
B,
|
|
4155
4155
|
I,
|
|
4156
|
-
|
|
4156
|
+
C,
|
|
4157
4157
|
T,
|
|
4158
|
-
|
|
4159
|
-
|
|
4158
|
+
f,
|
|
4159
|
+
L,
|
|
4160
4160
|
b,
|
|
4161
4161
|
y,
|
|
4162
4162
|
x,
|
|
4163
|
-
N,
|
|
4164
|
-
g,
|
|
4165
|
-
w,
|
|
4166
|
-
z,
|
|
4167
4163
|
F,
|
|
4164
|
+
p,
|
|
4165
|
+
w,
|
|
4166
|
+
_,
|
|
4167
|
+
O,
|
|
4168
4168
|
m,
|
|
4169
|
-
|
|
4169
|
+
W
|
|
4170
4170
|
]
|
|
4171
|
-
),
|
|
4171
|
+
), g = Q(
|
|
4172
4172
|
() => ({
|
|
4173
|
-
registerClearThread:
|
|
4174
|
-
registerRespondToInterrupt:
|
|
4173
|
+
registerClearThread: E,
|
|
4174
|
+
registerRespondToInterrupt: N
|
|
4175
4175
|
}),
|
|
4176
|
-
[
|
|
4176
|
+
[E, N]
|
|
4177
4177
|
);
|
|
4178
|
-
return /* @__PURE__ */ ie(Vt.Provider, { value:
|
|
4178
|
+
return /* @__PURE__ */ ie(Vt.Provider, { value: g, children: /* @__PURE__ */ ie($t.Provider, { value: Y, children: e }) });
|
|
4179
4179
|
}
|
|
4180
4180
|
const Kt = Se(null), _r = Se(!1);
|
|
4181
4181
|
function zr({
|
|
@@ -4190,26 +4190,26 @@ function zr({
|
|
|
4190
4190
|
onFinish: u,
|
|
4191
4191
|
onStreamingChange: c
|
|
4192
4192
|
}) {
|
|
4193
|
-
const { chatApi: l, baseUrl:
|
|
4193
|
+
const { chatApi: l, baseUrl: f } = Ae(), m = f, h = pe(t), k = pe(n), d = pe(r), v = pe(o), I = pe(s), C = pe(a), T = pe(i), P = pe(u), b = pe(c), y = Q(
|
|
4194
4194
|
() => ({
|
|
4195
4195
|
onError: h,
|
|
4196
4196
|
onAuthError: k,
|
|
4197
4197
|
onConnectionError: d,
|
|
4198
4198
|
onMetadataEvent: T,
|
|
4199
|
-
onCustomEvent:
|
|
4199
|
+
onCustomEvent: C,
|
|
4200
4200
|
onUpdateEvent: I,
|
|
4201
4201
|
onToolEnd: v,
|
|
4202
|
-
onFinish:
|
|
4202
|
+
onFinish: P
|
|
4203
4203
|
}),
|
|
4204
4204
|
[
|
|
4205
4205
|
h,
|
|
4206
4206
|
k,
|
|
4207
4207
|
d,
|
|
4208
4208
|
T,
|
|
4209
|
-
|
|
4209
|
+
C,
|
|
4210
4210
|
I,
|
|
4211
4211
|
v,
|
|
4212
|
-
|
|
4212
|
+
P
|
|
4213
4213
|
]
|
|
4214
4214
|
);
|
|
4215
4215
|
return /* @__PURE__ */ ie(_r.Provider, { value: !0, children: /* @__PURE__ */ ie(
|
|
@@ -4233,25 +4233,25 @@ function Rr({
|
|
|
4233
4233
|
const { setCurrentThreadId: s, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: u } = rt(), {
|
|
4234
4234
|
interrupt: c,
|
|
4235
4235
|
checkpoint: l,
|
|
4236
|
-
timelineCheckpoints:
|
|
4236
|
+
timelineCheckpoints: f,
|
|
4237
4237
|
handleValuesEvent: m,
|
|
4238
4238
|
markSkipNextLoad: h,
|
|
4239
4239
|
markStreamPendingThread: k,
|
|
4240
4240
|
resetHistoryState: d,
|
|
4241
4241
|
pushUser: v,
|
|
4242
4242
|
onEvent: I,
|
|
4243
|
-
messages:
|
|
4244
|
-
} = Dt(), { registerClearThread: T, registerRespondToInterrupt:
|
|
4245
|
-
(
|
|
4246
|
-
i(
|
|
4243
|
+
messages: C
|
|
4244
|
+
} = Dt(), { registerClearThread: T, registerRespondToInterrupt: P } = Pr(), b = z(
|
|
4245
|
+
(g) => {
|
|
4246
|
+
i(g), k(g.threadId), a.current !== g.threadId && ((g.created ?? !a.current) && h(g.threadId), s(g.threadId));
|
|
4247
4247
|
},
|
|
4248
4248
|
[i, h, k, s, a]
|
|
4249
4249
|
), y = cr({
|
|
4250
4250
|
baseUrl: n,
|
|
4251
4251
|
onEvent: I,
|
|
4252
|
-
onError: (
|
|
4253
|
-
var
|
|
4254
|
-
(
|
|
4252
|
+
onError: (g) => {
|
|
4253
|
+
var A;
|
|
4254
|
+
(A = r.onError) == null || A.call(r, (g == null ? void 0 : g.message) ?? String(g));
|
|
4255
4255
|
},
|
|
4256
4256
|
onAuthError: r.onAuthError,
|
|
4257
4257
|
onConnectionError: r.onConnectionError,
|
|
@@ -4263,129 +4263,129 @@ function Rr({
|
|
|
4263
4263
|
onToolEnd: r.onToolEnd,
|
|
4264
4264
|
handleValuesEvent: m
|
|
4265
4265
|
});
|
|
4266
|
-
|
|
4266
|
+
q(() => {
|
|
4267
4267
|
o == null || o(y.isStreaming);
|
|
4268
4268
|
}, [y.isStreaming, o]);
|
|
4269
|
-
const { stream: x, stop:
|
|
4270
|
-
|
|
4269
|
+
const { stream: x, stop: p, clear: w, isStreaming: _, error: U, connected: M, streamedMessages: E, activeMessageId: j } = y;
|
|
4270
|
+
q(() => {
|
|
4271
4271
|
u !== void 0 && w();
|
|
4272
4272
|
}, [u, w]);
|
|
4273
|
-
const
|
|
4274
|
-
async (
|
|
4275
|
-
await x(
|
|
4273
|
+
const N = z(
|
|
4274
|
+
async (g, A) => {
|
|
4275
|
+
await x(g, A);
|
|
4276
4276
|
},
|
|
4277
4277
|
[x]
|
|
4278
|
-
),
|
|
4279
|
-
|
|
4280
|
-
|
|
4278
|
+
), B = K(l);
|
|
4279
|
+
q(() => {
|
|
4280
|
+
B.current = l;
|
|
4281
4281
|
}, [l]);
|
|
4282
|
-
const
|
|
4283
|
-
async (
|
|
4284
|
-
const
|
|
4285
|
-
if (!
|
|
4282
|
+
const O = z(
|
|
4283
|
+
async (g, A, S) => {
|
|
4284
|
+
const G = a.current;
|
|
4285
|
+
if (!G)
|
|
4286
4286
|
throw new Error("No active thread to handle interrupt");
|
|
4287
|
-
const
|
|
4288
|
-
threadId:
|
|
4289
|
-
checkpointId:
|
|
4287
|
+
const J = g ? A ?? !0 : !1, D = B.current, ee = (S == null ? void 0 : S.checkpointId) ?? D.id ?? void 0, oe = (S == null ? void 0 : S.checkpointNs) ?? D.namespace ?? void 0, ue = {
|
|
4288
|
+
threadId: G,
|
|
4289
|
+
checkpointId: ee,
|
|
4290
4290
|
checkpointNs: oe,
|
|
4291
|
-
command: { kind: "resume", value:
|
|
4292
|
-
payload:
|
|
4291
|
+
command: { kind: "resume", value: J },
|
|
4292
|
+
payload: S == null ? void 0 : S.payload
|
|
4293
4293
|
};
|
|
4294
|
-
|
|
4294
|
+
N(ue);
|
|
4295
4295
|
},
|
|
4296
|
-
[a,
|
|
4296
|
+
[a, N]
|
|
4297
4297
|
);
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
}, [
|
|
4301
|
-
const
|
|
4302
|
-
|
|
4303
|
-
}, [w, d, s,
|
|
4304
|
-
|
|
4305
|
-
T(
|
|
4306
|
-
}, [
|
|
4307
|
-
const
|
|
4308
|
-
async (
|
|
4309
|
-
|
|
4310
|
-
let
|
|
4311
|
-
const
|
|
4312
|
-
oe && delete
|
|
4313
|
-
const ue = !!(oe && oe.length), H = !!(
|
|
4314
|
-
if (!
|
|
4315
|
-
if (!
|
|
4298
|
+
q(() => {
|
|
4299
|
+
P(O);
|
|
4300
|
+
}, [O, P]);
|
|
4301
|
+
const L = z(async () => {
|
|
4302
|
+
p(), w(), d(), s(null);
|
|
4303
|
+
}, [w, d, s, p]);
|
|
4304
|
+
q(() => {
|
|
4305
|
+
T(L);
|
|
4306
|
+
}, [L, T]);
|
|
4307
|
+
const F = z(
|
|
4308
|
+
async (g, A) => {
|
|
4309
|
+
_ && p();
|
|
4310
|
+
let S = a.current;
|
|
4311
|
+
const G = (g == null ? void 0 : g.text) ?? "", J = (g == null ? void 0 : g.attachments) ?? [], D = (G == null ? void 0 : G.trim()) ?? "", ee = { ...(g == null ? void 0 : g.payload) ?? {} }, oe = Array.isArray(ee.messages) ? ee.messages : void 0;
|
|
4312
|
+
oe && delete ee.messages;
|
|
4313
|
+
const ue = !!(oe && oe.length), H = !!(g.contentParts && g.contentParts.length > 0);
|
|
4314
|
+
if (!S && !D && J.length === 0 && !ue && !H) return;
|
|
4315
|
+
if (!S) {
|
|
4316
4316
|
const he = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), ye = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
|
|
4317
|
-
|
|
4317
|
+
S = `${he}${ye}`, h(S), s(S);
|
|
4318
4318
|
}
|
|
4319
|
-
let
|
|
4320
|
-
|
|
4321
|
-
const { contentParts: ve, filesInfo:
|
|
4322
|
-
|
|
4323
|
-
const me =
|
|
4319
|
+
let te = null;
|
|
4320
|
+
g.contentParts && g.contentParts.length > 0 && (te = g.contentParts);
|
|
4321
|
+
const { contentParts: ve, filesInfo: X } = te ? { contentParts: te, filesInfo: [] } : await rr(J), Z = [...ve];
|
|
4322
|
+
D && Z.push({ type: "text", text: G });
|
|
4323
|
+
const me = g == null ? void 0 : g.originalMessageId, je = !!(g != null && g.edit && me), Le = !ue && Z.length > 0;
|
|
4324
4324
|
let de = null;
|
|
4325
4325
|
if (Le) {
|
|
4326
4326
|
const he = je ? me : `msg-${Date.now()}`;
|
|
4327
4327
|
de = Ut({
|
|
4328
4328
|
id: he,
|
|
4329
4329
|
role: "user",
|
|
4330
|
-
content:
|
|
4330
|
+
content: Z,
|
|
4331
4331
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4332
4332
|
}, "user"), je ? v(de, { editingMessageId: me }) : v(de);
|
|
4333
4333
|
}
|
|
4334
4334
|
const Ie = ue ? oe : de ? [de] : [], ne = {
|
|
4335
|
-
...
|
|
4336
|
-
...
|
|
4335
|
+
...ee,
|
|
4336
|
+
...X.length ? { files_info: X } : {}
|
|
4337
4337
|
};
|
|
4338
4338
|
Ie.length ? ne.messages = Ie : "messages" in ne || (ne.messages = []);
|
|
4339
|
-
const Me = (
|
|
4340
|
-
if (
|
|
4339
|
+
const Me = (g == null ? void 0 : g.checkpointId) ?? l.id ?? void 0;
|
|
4340
|
+
if (g != null && g.edit && !Me)
|
|
4341
4341
|
throw new Error(
|
|
4342
|
-
`[streaming] Missing checkpointId for edit submit. threadId=${
|
|
4342
|
+
`[streaming] Missing checkpointId for edit submit. threadId=${S ?? "null"}`
|
|
4343
4343
|
);
|
|
4344
4344
|
const Ee = {
|
|
4345
|
-
threadId:
|
|
4346
|
-
content:
|
|
4345
|
+
threadId: S,
|
|
4346
|
+
content: g == null ? void 0 : g.text,
|
|
4347
4347
|
payload: ne,
|
|
4348
|
-
config:
|
|
4348
|
+
config: g == null ? void 0 : g.config,
|
|
4349
4349
|
checkpointId: Me,
|
|
4350
|
-
command:
|
|
4351
|
-
edit:
|
|
4350
|
+
command: g == null ? void 0 : g.command,
|
|
4351
|
+
edit: g == null ? void 0 : g.edit
|
|
4352
4352
|
};
|
|
4353
|
-
return
|
|
4353
|
+
return N(Ee, A);
|
|
4354
4354
|
},
|
|
4355
|
-
[l, a,
|
|
4356
|
-
),
|
|
4357
|
-
const
|
|
4358
|
-
if (!
|
|
4359
|
-
return
|
|
4360
|
-
const
|
|
4361
|
-
return
|
|
4362
|
-
|
|
4363
|
-
}), Array.from(
|
|
4364
|
-
}, [
|
|
4355
|
+
[l, a, _, h, v, N, p, f]
|
|
4356
|
+
), W = Q(() => {
|
|
4357
|
+
const g = Object.keys(E).length > 0;
|
|
4358
|
+
if (!_ && !g)
|
|
4359
|
+
return C;
|
|
4360
|
+
const A = /* @__PURE__ */ new Map();
|
|
4361
|
+
return C.forEach((S) => A.set(S.id, S)), Object.values(E).forEach((S) => {
|
|
4362
|
+
A.set(S.id, S);
|
|
4363
|
+
}), Array.from(A.values());
|
|
4364
|
+
}, [_, E, C]), Y = Q(
|
|
4365
4365
|
() => ({
|
|
4366
|
-
isStreaming:
|
|
4367
|
-
error:
|
|
4368
|
-
connectionState:
|
|
4369
|
-
messages:
|
|
4370
|
-
activeMessageId:
|
|
4371
|
-
submit:
|
|
4372
|
-
stop:
|
|
4366
|
+
isStreaming: _,
|
|
4367
|
+
error: U,
|
|
4368
|
+
connectionState: U ? "error" : _ ? M ? "connected" : "connecting" : "idle",
|
|
4369
|
+
messages: W,
|
|
4370
|
+
activeMessageId: j,
|
|
4371
|
+
submit: F,
|
|
4372
|
+
stop: p,
|
|
4373
4373
|
interrupt: c,
|
|
4374
4374
|
resume: () => Promise.resolve(),
|
|
4375
|
-
goto: (
|
|
4375
|
+
goto: (g, A) => Promise.resolve(),
|
|
4376
4376
|
clearError: () => {
|
|
4377
4377
|
}
|
|
4378
4378
|
// TODO: Implement error clearing
|
|
4379
4379
|
}),
|
|
4380
|
-
[
|
|
4380
|
+
[_, U, F, p, c, M, W]
|
|
4381
4381
|
);
|
|
4382
|
-
return /* @__PURE__ */ ie(Kt.Provider, { value:
|
|
4382
|
+
return /* @__PURE__ */ ie(Kt.Provider, { value: Y, children: e });
|
|
4383
4383
|
}
|
|
4384
4384
|
function pe(e) {
|
|
4385
4385
|
const t = K(e);
|
|
4386
|
-
return
|
|
4386
|
+
return q(() => {
|
|
4387
4387
|
t.current = e;
|
|
4388
|
-
}, [e]),
|
|
4388
|
+
}, [e]), z((...n) => {
|
|
4389
4389
|
const r = t.current;
|
|
4390
4390
|
if (r)
|
|
4391
4391
|
return r(...n);
|
|
@@ -4435,38 +4435,38 @@ function io({
|
|
|
4435
4435
|
onAuthError: u,
|
|
4436
4436
|
onThreadChange: c,
|
|
4437
4437
|
onToolEnd: l,
|
|
4438
|
-
onUpdateEvent:
|
|
4438
|
+
onUpdateEvent: f,
|
|
4439
4439
|
onCustomEvent: m,
|
|
4440
4440
|
onMetadataEvent: h,
|
|
4441
4441
|
onFinish: k
|
|
4442
4442
|
}) {
|
|
4443
|
-
const d = Lr(t), [v, I] =
|
|
4443
|
+
const d = Lr(t), [v, I] = V(!1), C = ge(i), T = ge(u), P = ge(a), b = ge(c), y = ge(l), x = ge(f), p = ge(m), w = ge(h), _ = ge(k), U = Q(
|
|
4444
4444
|
() => ({
|
|
4445
|
-
onError:
|
|
4445
|
+
onError: C,
|
|
4446
4446
|
onAuthError: T,
|
|
4447
|
-
onConnectionError:
|
|
4447
|
+
onConnectionError: P,
|
|
4448
4448
|
onToolEnd: y,
|
|
4449
4449
|
onUpdateEvent: x,
|
|
4450
|
-
onCustomEvent:
|
|
4450
|
+
onCustomEvent: p,
|
|
4451
4451
|
onMetadataEvent: w,
|
|
4452
|
-
onFinish:
|
|
4452
|
+
onFinish: _
|
|
4453
4453
|
}),
|
|
4454
4454
|
[
|
|
4455
|
-
|
|
4455
|
+
C,
|
|
4456
4456
|
T,
|
|
4457
|
-
|
|
4457
|
+
P,
|
|
4458
4458
|
y,
|
|
4459
4459
|
x,
|
|
4460
|
-
|
|
4460
|
+
p,
|
|
4461
4461
|
w,
|
|
4462
|
-
|
|
4462
|
+
_
|
|
4463
4463
|
]
|
|
4464
4464
|
);
|
|
4465
4465
|
return /* @__PURE__ */ ie(tr, { apiConfig: d, children: /* @__PURE__ */ ie(
|
|
4466
4466
|
ur,
|
|
4467
4467
|
{
|
|
4468
4468
|
initialThreadId: n,
|
|
4469
|
-
onError:
|
|
4469
|
+
onError: C,
|
|
4470
4470
|
onThreadChange: b,
|
|
4471
4471
|
children: /* @__PURE__ */ ie(
|
|
4472
4472
|
Nr,
|
|
@@ -4475,12 +4475,12 @@ function io({
|
|
|
4475
4475
|
initialCheckpointId: r,
|
|
4476
4476
|
initialCheckpointNs: o,
|
|
4477
4477
|
autoLoadInitial: s,
|
|
4478
|
-
onError:
|
|
4478
|
+
onError: C,
|
|
4479
4479
|
isStreaming: v,
|
|
4480
4480
|
children: /* @__PURE__ */ ie(
|
|
4481
4481
|
zr,
|
|
4482
4482
|
{
|
|
4483
|
-
...
|
|
4483
|
+
...U,
|
|
4484
4484
|
onStreamingChange: I,
|
|
4485
4485
|
children: e
|
|
4486
4486
|
}
|
|
@@ -4492,7 +4492,7 @@ function io({
|
|
|
4492
4492
|
}
|
|
4493
4493
|
function ge(e) {
|
|
4494
4494
|
const t = K(e);
|
|
4495
|
-
return t.current = e,
|
|
4495
|
+
return t.current = e, z((...n) => {
|
|
4496
4496
|
const r = t.current;
|
|
4497
4497
|
if (r)
|
|
4498
4498
|
return r(...n);
|
|
@@ -4590,13 +4590,13 @@ function Kr() {
|
|
|
4590
4590
|
};
|
|
4591
4591
|
}
|
|
4592
4592
|
function co(e) {
|
|
4593
|
-
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Ae(), { toast: o } = Kr(), [s, a] =
|
|
4593
|
+
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Ae(), { toast: o } = Kr(), [s, a] = V({}), [i, u] = V(null), [c, l] = V(!1), f = z(() => {
|
|
4594
4594
|
l(!1), u(null);
|
|
4595
|
-
}, []), m =
|
|
4595
|
+
}, []), m = z((k) => {
|
|
4596
4596
|
u(k), l(!0);
|
|
4597
|
-
}, []), h =
|
|
4597
|
+
}, []), h = z(
|
|
4598
4598
|
async (k, d, v) => {
|
|
4599
|
-
var I,
|
|
4599
|
+
var I, C;
|
|
4600
4600
|
if (!t) {
|
|
4601
4601
|
k.preventDefault();
|
|
4602
4602
|
return;
|
|
@@ -4606,10 +4606,10 @@ function co(e) {
|
|
|
4606
4606
|
return;
|
|
4607
4607
|
}
|
|
4608
4608
|
try {
|
|
4609
|
-
const T = String(d.url ?? ""),
|
|
4610
|
-
if (
|
|
4609
|
+
const T = String(d.url ?? ""), P = T.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
|
|
4610
|
+
if (P) {
|
|
4611
4611
|
k.preventDefault();
|
|
4612
|
-
const b =
|
|
4612
|
+
const b = P[1], y = d.name || `file_${b}`, x = d.mimeType || "application/octet-stream";
|
|
4613
4613
|
m({ id: b, name: y, mimeType: x });
|
|
4614
4614
|
return;
|
|
4615
4615
|
}
|
|
@@ -4620,7 +4620,7 @@ function co(e) {
|
|
|
4620
4620
|
const y = await r.listFiles(n ?? void 0);
|
|
4621
4621
|
if (!y || !Array.isArray(y))
|
|
4622
4622
|
throw new Error("Invalid file list response");
|
|
4623
|
-
const x = y.find((
|
|
4623
|
+
const x = y.find((p) => !p || typeof p != "object" || !((p.filename ?? "") === (d.name ?? "")) ? !1 : typeof d.size == "number" && typeof p.size == "number" ? p.size === d.size : !0);
|
|
4624
4624
|
if (!(x != null && x.id))
|
|
4625
4625
|
throw new Error(`File "${d.name}" is not yet available on the server`);
|
|
4626
4626
|
if (!x.id || !x.filename)
|
|
@@ -4638,7 +4638,7 @@ function co(e) {
|
|
|
4638
4638
|
} catch (y) {
|
|
4639
4639
|
console.error("Failed to fetch server file:", y);
|
|
4640
4640
|
const x = y instanceof Error ? y.message : "Unknown error occurred";
|
|
4641
|
-
(
|
|
4641
|
+
(C = b.update) == null || C.call(b, { id: b.id, title: "Failed", description: x }), o({
|
|
4642
4642
|
title: "Failed to fetch file",
|
|
4643
4643
|
description: x,
|
|
4644
4644
|
open: !0
|
|
@@ -4648,7 +4648,7 @@ function co(e) {
|
|
|
4648
4648
|
}
|
|
4649
4649
|
}
|
|
4650
4650
|
} catch (T) {
|
|
4651
|
-
console.error("File click error:", T), a((
|
|
4651
|
+
console.error("File click error:", T), a((P) => ({ ...P, [v]: !1 }));
|
|
4652
4652
|
}
|
|
4653
4653
|
},
|
|
4654
4654
|
[t, s, o, n, m]
|
|
@@ -4658,11 +4658,11 @@ function co(e) {
|
|
|
4658
4658
|
handleFileClick: h,
|
|
4659
4659
|
fileViewerOpen: c,
|
|
4660
4660
|
currentFileInfo: i,
|
|
4661
|
-
closeFileViewer:
|
|
4661
|
+
closeFileViewer: f
|
|
4662
4662
|
};
|
|
4663
4663
|
}
|
|
4664
4664
|
function lo(e) {
|
|
4665
|
-
return
|
|
4665
|
+
return Q(() => {
|
|
4666
4666
|
const t = e;
|
|
4667
4667
|
let n = Array.isArray(t.content) ? t.content : [];
|
|
4668
4668
|
return typeof t.content == "string" && (n = [{ type: "text", text: t.content }]), {
|
|
@@ -4701,7 +4701,7 @@ function Hr(e) {
|
|
|
4701
4701
|
return null;
|
|
4702
4702
|
}
|
|
4703
4703
|
function uo(e) {
|
|
4704
|
-
return
|
|
4704
|
+
return Q(() => {
|
|
4705
4705
|
const t = e.content.filter(
|
|
4706
4706
|
(u) => u.type === "text"
|
|
4707
4707
|
);
|
|
@@ -4734,14 +4734,14 @@ function uo(e) {
|
|
|
4734
4734
|
}, [e]);
|
|
4735
4735
|
}
|
|
4736
4736
|
function Wr(e) {
|
|
4737
|
-
var
|
|
4737
|
+
var _;
|
|
4738
4738
|
const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = rt({ optional: !0 }), o = Dt({ optional: !0 }), s = Ur(), { currentThreadId: a, setCurrentThreadId: i, actions: u } = r || {
|
|
4739
4739
|
currentThreadId: null,
|
|
4740
4740
|
setCurrentThreadId: () => {
|
|
4741
4741
|
},
|
|
4742
4742
|
actions: {}
|
|
4743
|
-
}, c = !!t && t !== a, [l,
|
|
4744
|
-
|
|
4743
|
+
}, c = !!t && t !== a, [l, f] = V([]), m = z((U) => {
|
|
4744
|
+
f(U);
|
|
4745
4745
|
}, []), {
|
|
4746
4746
|
isLoadingThread: h,
|
|
4747
4747
|
threadStateError: k,
|
|
@@ -4757,24 +4757,24 @@ function Wr(e) {
|
|
|
4757
4757
|
getMessages: () => l,
|
|
4758
4758
|
autoLoadInitial: c && !n
|
|
4759
4759
|
});
|
|
4760
|
-
|
|
4760
|
+
q(() => {
|
|
4761
4761
|
!c && !n && a && (o != null && o.loadThread) && o.loadThread(a);
|
|
4762
4762
|
}, [c, n, a, o == null ? void 0 : o.loadThread]);
|
|
4763
|
-
const I =
|
|
4764
|
-
var
|
|
4765
|
-
return ((
|
|
4766
|
-
}, [d]),
|
|
4763
|
+
const I = Q(() => {
|
|
4764
|
+
var U;
|
|
4765
|
+
return ((U = d[0]) == null ? void 0 : U.values) || {};
|
|
4766
|
+
}, [d]), C = Q(() => ({ timeline: [], messagePreviews: {} }), []), T = t || a, P = c ? h ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", b = c ? l : (s == null ? void 0 : s.messages) || [], y = c ? h : (o == null ? void 0 : o.isLoading) || !1, x = c ? I : (o == null ? void 0 : o.values) || {}, p = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, w = c ? k : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
|
|
4767
4767
|
return {
|
|
4768
4768
|
// UNIFIED: Single thread ID concept
|
|
4769
4769
|
threadId: T,
|
|
4770
|
-
status:
|
|
4770
|
+
status: P,
|
|
4771
4771
|
messages: b,
|
|
4772
4772
|
isLoading: y,
|
|
4773
4773
|
isHistoryLoading: y,
|
|
4774
4774
|
error: w,
|
|
4775
4775
|
// Values & Metadata
|
|
4776
4776
|
values: x,
|
|
4777
|
-
taskMessagesByScope:
|
|
4777
|
+
taskMessagesByScope: p,
|
|
4778
4778
|
metadata: c ? {} : o == null ? void 0 : o.metadata,
|
|
4779
4779
|
// Actions & State relating to Global/Active Thread only
|
|
4780
4780
|
navigateToCheckpoint: c ? async () => {
|
|
@@ -4785,7 +4785,7 @@ function Wr(e) {
|
|
|
4785
4785
|
}),
|
|
4786
4786
|
checkpoint: c ? d[0] ? { id: d[0].checkpointId, namespace: d[0].checkpointNs } : null : (o == null ? void 0 : o.checkpoint) || null,
|
|
4787
4787
|
checkpoints: c ? d : (o == null ? void 0 : o.checkpoints) || [],
|
|
4788
|
-
checkpointIndex: c ?
|
|
4788
|
+
checkpointIndex: c ? C : (o == null ? void 0 : o.checkpointIndex) || { timeline: [], messagePreviews: {} },
|
|
4789
4789
|
interrupt: c ? null : (o == null ? void 0 : o.interrupt) || null,
|
|
4790
4790
|
respondToInterrupt: c ? async () => {
|
|
4791
4791
|
} : (o == null ? void 0 : o.respondToInterrupt) || (async () => {
|
|
@@ -4795,7 +4795,7 @@ function Wr(e) {
|
|
|
4795
4795
|
isStreaming: (s == null ? void 0 : s.isStreaming) || !1,
|
|
4796
4796
|
activeMessageId: (s == null ? void 0 : s.activeMessageId) || null,
|
|
4797
4797
|
connectionState: (s == null ? void 0 : s.connectionState) || "disconnected",
|
|
4798
|
-
streamingAssistantId: !c && (s != null && s.isStreaming) && ((
|
|
4798
|
+
streamingAssistantId: !c && (s != null && s.isStreaming) && ((_ = o == null ? void 0 : o.metadata) != null && _.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
|
|
4799
4799
|
// Actions
|
|
4800
4800
|
submit: (s == null ? void 0 : s.submit) || (async () => {
|
|
4801
4801
|
}),
|
|
@@ -4829,134 +4829,134 @@ function fo({
|
|
|
4829
4829
|
messages: u,
|
|
4830
4830
|
setPendingAssistantResponse: c,
|
|
4831
4831
|
project: l,
|
|
4832
|
-
onEvent:
|
|
4832
|
+
onEvent: f,
|
|
4833
4833
|
threadId: m,
|
|
4834
4834
|
clearComposerOnSend: h = !0
|
|
4835
4835
|
}) {
|
|
4836
|
-
const { messages: k } = Wr(), [d, v] =
|
|
4837
|
-
|
|
4836
|
+
const { messages: k } = Wr(), [d, v] = V(null), [I, C] = V(""), [T, P] = V(null), [b, y] = V(null), [x, p] = V(!1), [w, _] = V(""), U = K(w), M = K(null);
|
|
4837
|
+
q(() => {
|
|
4838
4838
|
if (!d)
|
|
4839
4839
|
if (m) {
|
|
4840
|
-
const
|
|
4841
|
-
|
|
4840
|
+
const g = localStorage.getItem(He(m));
|
|
4841
|
+
_(g || "");
|
|
4842
4842
|
} else
|
|
4843
|
-
|
|
4843
|
+
_("");
|
|
4844
4844
|
}, [m, d]);
|
|
4845
|
-
const
|
|
4846
|
-
|
|
4845
|
+
const E = z((g) => {
|
|
4846
|
+
_(g), !d && m && localStorage.setItem(He(m), g);
|
|
4847
4847
|
}, [m, d]);
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
}, [w]),
|
|
4848
|
+
q(() => {
|
|
4849
|
+
U.current = w;
|
|
4850
|
+
}, [w]), q(() => {
|
|
4851
4851
|
if (!d) {
|
|
4852
|
-
|
|
4852
|
+
M.current = null;
|
|
4853
4853
|
return;
|
|
4854
4854
|
}
|
|
4855
|
-
|
|
4856
|
-
}, [I, d,
|
|
4857
|
-
const
|
|
4858
|
-
(
|
|
4859
|
-
|
|
4855
|
+
M.current === null && (M.current = U.current), E(I ?? "");
|
|
4856
|
+
}, [I, d, E]);
|
|
4857
|
+
const j = z(
|
|
4858
|
+
(g) => {
|
|
4859
|
+
E(g);
|
|
4860
4860
|
},
|
|
4861
|
-
[
|
|
4862
|
-
),
|
|
4863
|
-
const
|
|
4864
|
-
if (!(!
|
|
4861
|
+
[E]
|
|
4862
|
+
), N = async (g, A) => {
|
|
4863
|
+
const S = Array.isArray(A) ? { files: A } : A ?? {}, G = S.files ?? [], J = S.contentParts ?? [], D = g.trim();
|
|
4864
|
+
if (!(!D && G.length === 0 && J.length === 0))
|
|
4865
4865
|
try {
|
|
4866
|
-
const
|
|
4866
|
+
const ee = G.map(async (X) => {
|
|
4867
4867
|
try {
|
|
4868
|
-
const
|
|
4869
|
-
return { file:
|
|
4870
|
-
} catch (
|
|
4871
|
-
throw console.error("Failed to upload file",
|
|
4868
|
+
const Z = await zt.uploadFile(X);
|
|
4869
|
+
return { file: X, record: Z };
|
|
4870
|
+
} catch (Z) {
|
|
4871
|
+
throw console.error("Failed to upload file", X.name, Z), new Error(`Failed to upload ${X.name}`);
|
|
4872
4872
|
}
|
|
4873
|
-
}), ue = (await Promise.all(
|
|
4874
|
-
const
|
|
4875
|
-
return
|
|
4873
|
+
}), ue = (await Promise.all(ee)).map(({ record: X }) => {
|
|
4874
|
+
const Z = X.mime_type;
|
|
4875
|
+
return Z.startsWith("image/") ? {
|
|
4876
4876
|
type: "image_url",
|
|
4877
|
-
image_url: { url:
|
|
4877
|
+
image_url: { url: X.content_url }
|
|
4878
4878
|
} : {
|
|
4879
4879
|
type: "file",
|
|
4880
|
-
url:
|
|
4881
|
-
mimeType:
|
|
4882
|
-
name:
|
|
4883
|
-
size:
|
|
4880
|
+
url: X.content_url,
|
|
4881
|
+
mimeType: Z,
|
|
4882
|
+
name: X.filename,
|
|
4883
|
+
size: X.size
|
|
4884
4884
|
};
|
|
4885
|
-
}), H = [...
|
|
4885
|
+
}), H = [...J, ...ue], te = d ? (T == null ? void 0 : T.checkpointId) ?? n ?? void 0 : n ?? void 0, ve = d ? (T == null ? void 0 : T.checkpointNs) ?? r ?? void 0 : r ?? void 0;
|
|
4886
4886
|
await e(
|
|
4887
4887
|
{
|
|
4888
|
-
text:
|
|
4888
|
+
text: D || "",
|
|
4889
4889
|
contentParts: H,
|
|
4890
|
-
attachments:
|
|
4890
|
+
attachments: G,
|
|
4891
4891
|
payload: t.payload,
|
|
4892
4892
|
edit: !!d,
|
|
4893
|
-
checkpointId:
|
|
4893
|
+
checkpointId: te,
|
|
4894
4894
|
checkpointNs: ve,
|
|
4895
4895
|
project: l ?? void 0,
|
|
4896
4896
|
originalMessageId: d ?? void 0,
|
|
4897
4897
|
config: t.config
|
|
4898
4898
|
},
|
|
4899
|
-
|
|
4900
|
-
), o == null || o(
|
|
4901
|
-
} catch (
|
|
4902
|
-
const oe = (
|
|
4899
|
+
f ? { onEvent: f } : void 0
|
|
4900
|
+
), o == null || o(D), c(!0), h && (m && localStorage.removeItem(He(m)), E("")), y(null), v(null), C(""), P(null);
|
|
4901
|
+
} catch (ee) {
|
|
4902
|
+
const oe = (ee == null ? void 0 : ee.message) || "Failed to send message";
|
|
4903
4903
|
y(oe), a == null || a(oe), c(!1);
|
|
4904
4904
|
}
|
|
4905
|
-
},
|
|
4906
|
-
|
|
4907
|
-
},
|
|
4908
|
-
async (
|
|
4905
|
+
}, B = (g, A) => {
|
|
4906
|
+
A || N(g, { files: [] });
|
|
4907
|
+
}, O = z(
|
|
4908
|
+
async (g) => {
|
|
4909
4909
|
await e(
|
|
4910
4910
|
{
|
|
4911
|
-
attachments: [
|
|
4911
|
+
attachments: [g],
|
|
4912
4912
|
payload: t.payload,
|
|
4913
4913
|
checkpointId: n ?? void 0,
|
|
4914
4914
|
checkpointNs: r ?? void 0,
|
|
4915
4915
|
project: l ?? void 0,
|
|
4916
4916
|
config: t.config
|
|
4917
4917
|
},
|
|
4918
|
-
|
|
4919
|
-
), s == null || s({ file:
|
|
4918
|
+
f ? { onEvent: f } : void 0
|
|
4919
|
+
), s == null || s({ file: g });
|
|
4920
4920
|
},
|
|
4921
4921
|
[n, r, t, s, e]
|
|
4922
|
-
),
|
|
4923
|
-
(
|
|
4924
|
-
i && (
|
|
4925
|
-
checkpointId: (
|
|
4926
|
-
checkpointNs: (
|
|
4922
|
+
), L = z(
|
|
4923
|
+
(g, A, S) => {
|
|
4924
|
+
i && (M.current = w, v(g), C(A), P({
|
|
4925
|
+
checkpointId: (S == null ? void 0 : S.checkpointId) ?? null,
|
|
4926
|
+
checkpointNs: (S == null ? void 0 : S.checkpointNs) ?? null
|
|
4927
4927
|
}), y(null));
|
|
4928
4928
|
},
|
|
4929
4929
|
[w, i]
|
|
4930
|
-
),
|
|
4931
|
-
v(null),
|
|
4932
|
-
const
|
|
4933
|
-
|
|
4934
|
-
}, []),
|
|
4935
|
-
let
|
|
4936
|
-
for (let
|
|
4937
|
-
if (u[
|
|
4938
|
-
|
|
4930
|
+
), F = z(() => {
|
|
4931
|
+
v(null), C(""), P(null), y(null);
|
|
4932
|
+
const g = M.current;
|
|
4933
|
+
g !== null && _(g), M.current = null;
|
|
4934
|
+
}, []), W = z((g) => {
|
|
4935
|
+
let A = null;
|
|
4936
|
+
for (let D = g - 1; D >= 0; D--)
|
|
4937
|
+
if (u[D].role === "user") {
|
|
4938
|
+
A = u[D];
|
|
4939
4939
|
break;
|
|
4940
4940
|
}
|
|
4941
|
-
if (!
|
|
4942
|
-
const
|
|
4941
|
+
if (!A) return;
|
|
4942
|
+
const S = Array.isArray(A.content) ? A.content : [], J = S.filter((D) => (D == null ? void 0 : D.type) === "text").map((D) => D.text).join("") || (() => {
|
|
4943
4943
|
try {
|
|
4944
|
-
return JSON.stringify(
|
|
4944
|
+
return JSON.stringify(S, null, 2);
|
|
4945
4945
|
} catch {
|
|
4946
|
-
return String(
|
|
4946
|
+
return String(S);
|
|
4947
4947
|
}
|
|
4948
4948
|
})();
|
|
4949
|
-
|
|
4949
|
+
J && e(
|
|
4950
4950
|
{
|
|
4951
|
-
text:
|
|
4951
|
+
text: J,
|
|
4952
4952
|
payload: t.payload,
|
|
4953
4953
|
checkpointId: n ?? void 0,
|
|
4954
4954
|
checkpointNs: r ?? void 0,
|
|
4955
4955
|
edit: !0,
|
|
4956
|
-
originalMessageId:
|
|
4956
|
+
originalMessageId: A.id,
|
|
4957
4957
|
config: t.config
|
|
4958
4958
|
},
|
|
4959
|
-
|
|
4959
|
+
f ? { onEvent: f } : void 0
|
|
4960
4960
|
);
|
|
4961
4961
|
}, [u, e, n, r, t]);
|
|
4962
4962
|
return {
|
|
@@ -4965,20 +4965,20 @@ function fo({
|
|
|
4965
4965
|
inputError: b,
|
|
4966
4966
|
setInputError: y,
|
|
4967
4967
|
dismissError: x,
|
|
4968
|
-
setDismissError:
|
|
4968
|
+
setDismissError: p,
|
|
4969
4969
|
composerValue: w,
|
|
4970
|
-
handleComposerChange:
|
|
4971
|
-
handleSendMessage:
|
|
4972
|
-
handleQuickPrompt:
|
|
4973
|
-
handleExcelUpload:
|
|
4974
|
-
startEditing:
|
|
4975
|
-
cancelEditing:
|
|
4976
|
-
handleRegenerateCb:
|
|
4970
|
+
handleComposerChange: j,
|
|
4971
|
+
handleSendMessage: N,
|
|
4972
|
+
handleQuickPrompt: B,
|
|
4973
|
+
handleExcelUpload: O,
|
|
4974
|
+
startEditing: L,
|
|
4975
|
+
cancelEditing: F,
|
|
4976
|
+
handleRegenerateCb: W,
|
|
4977
4977
|
displayMessages: k
|
|
4978
4978
|
};
|
|
4979
4979
|
}
|
|
4980
4980
|
function po(e) {
|
|
4981
|
-
return
|
|
4981
|
+
return Q(() => e ? {
|
|
4982
4982
|
textContent: Rn(e),
|
|
4983
4983
|
imageParts: Un(e),
|
|
4984
4984
|
fileParts: jn(e),
|
|
@@ -4993,8 +4993,8 @@ function po(e) {
|
|
|
4993
4993
|
}, [e]);
|
|
4994
4994
|
}
|
|
4995
4995
|
function go(e, t, n) {
|
|
4996
|
-
const [r, o] =
|
|
4997
|
-
return
|
|
4996
|
+
const [r, o] = V(e), s = K(e), a = K(null);
|
|
4997
|
+
return q(() => {
|
|
4998
4998
|
s.current = e;
|
|
4999
4999
|
const i = () => {
|
|
5000
5000
|
o(s.current), a.current && (clearTimeout(a.current), a.current = null);
|