@teodorruskvi/chat-core 0.1.54 → 0.1.56
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 +681 -675
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +7 -7
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var Ht = Object.defineProperty;
|
|
2
2
|
var Gt = (e, t, n) => t in e ? Ht(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var at = (e, t, n) => Gt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import { jsx as
|
|
4
|
+
import { jsx as ce } from "react/jsx-runtime";
|
|
5
5
|
import * as it from "react";
|
|
6
|
-
import { createContext as Ce, useContext as je, useState as
|
|
6
|
+
import { createContext as Ce, useContext as je, useState as D, useRef as H, useEffect as Q, useCallback as N, useMemo as Z, useReducer as Wt } from "react";
|
|
7
7
|
import Jt, { isCancel as Xt } from "axios";
|
|
8
8
|
function It(e) {
|
|
9
9
|
var t, n, r = "";
|
|
@@ -191,10 +191,10 @@ const et = "-", Yt = (e) => {
|
|
|
191
191
|
}
|
|
192
192
|
I = !1;
|
|
193
193
|
}
|
|
194
|
-
const v = sn(l).join(":"), x = f ? v + xt : v,
|
|
195
|
-
if (s.includes(
|
|
194
|
+
const v = sn(l).join(":"), x = f ? v + xt : v, S = x + u;
|
|
195
|
+
if (s.includes(S))
|
|
196
196
|
continue;
|
|
197
|
-
s.push(
|
|
197
|
+
s.push(S);
|
|
198
198
|
const A = o(u, I);
|
|
199
199
|
for (let w = 0; w < A.length; ++w) {
|
|
200
200
|
const b = A[w];
|
|
@@ -235,10 +235,10 @@ function un(e, ...t) {
|
|
|
235
235
|
return s(dn.apply(null, arguments));
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
|
-
const
|
|
238
|
+
const q = (e) => {
|
|
239
239
|
const t = (n) => n[e] || [];
|
|
240
240
|
return t.isThemeGetter = !0, t;
|
|
241
|
-
}, Tt = /^\[(?:([a-z-]+):)?(.+)\]$/i, fn = /^\d+\/\d+$/, pn = /* @__PURE__ */ new Set(["px", "full", "screen"]), gn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, mn = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/, yn = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, hn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, bn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, ue = (e) => Te(e) || pn.has(e) || fn.test(e),
|
|
241
|
+
}, Tt = /^\[(?:([a-z-]+):)?(.+)\]$/i, fn = /^\d+\/\d+$/, pn = /* @__PURE__ */ new Set(["px", "full", "screen"]), gn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, mn = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/, yn = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, hn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, bn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, ue = (e) => Te(e) || pn.has(e) || fn.test(e), ke = (e) => Ee(e, "length", Sn), Te = (e) => !!e && !Number.isNaN(Number(e)), qe = (e) => Ee(e, "number", Te), _e = (e) => !!e && Number.isInteger(Number(e)), wn = (e) => e.endsWith("%") && Te(e.slice(0, -1)), z = (e) => Tt.test(e), Ie = (e) => gn.test(e), kn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), In = (e) => Ee(e, kn, St), vn = (e) => Ee(e, "position", St), xn = /* @__PURE__ */ new Set(["image", "url"]), An = (e) => Ee(e, xn, Cn), Tn = (e) => Ee(e, "", Mn), Ne = () => !0, Ee = (e, t, n) => {
|
|
242
242
|
const r = Tt.exec(e);
|
|
243
243
|
return r ? r[1] ? typeof t == "string" ? r[1] === t : t.has(r[1]) : n(r[2]) : !1;
|
|
244
244
|
}, Sn = (e) => (
|
|
@@ -247,36 +247,36 @@ const D = (e) => {
|
|
|
247
247
|
// I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough.
|
|
248
248
|
mn.test(e) && !yn.test(e)
|
|
249
249
|
), St = () => !1, Mn = (e) => hn.test(e), Cn = (e) => bn.test(e), En = () => {
|
|
250
|
-
const e =
|
|
250
|
+
const e = q("colors"), t = q("spacing"), n = q("blur"), r = q("brightness"), o = q("borderColor"), s = q("borderRadius"), a = q("borderSpacing"), i = q("borderWidth"), d = q("contrast"), c = q("grayscale"), l = q("hueRotate"), f = q("invert"), p = q("gap"), g = q("gradientColorStops"), I = q("gradientColorStopPositions"), u = q("inset"), v = q("margin"), x = q("opacity"), S = q("padding"), A = q("saturate"), w = q("scale"), b = q("sepia"), y = q("skew"), T = q("space"), m = q("translate"), k = () => ["auto", "contain", "none"], E = () => ["auto", "hidden", "clip", "visible", "scroll"], U = () => ["auto", z, t], M = () => [z, t], $ = () => ["", ue, ke], F = () => ["auto", Te, z], _ = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], O = () => ["solid", "dashed", "dotted", "double", "none"], R = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], W = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], B = () => ["", "0", z], L = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], h = () => [Te, z];
|
|
251
251
|
return {
|
|
252
252
|
cacheSize: 500,
|
|
253
253
|
separator: ":",
|
|
254
254
|
theme: {
|
|
255
255
|
colors: [Ne],
|
|
256
|
-
spacing: [ue,
|
|
257
|
-
blur: ["none", "",
|
|
258
|
-
brightness:
|
|
256
|
+
spacing: [ue, ke],
|
|
257
|
+
blur: ["none", "", Ie, z],
|
|
258
|
+
brightness: h(),
|
|
259
259
|
borderColor: [e],
|
|
260
|
-
borderRadius: ["none", "", "full",
|
|
261
|
-
borderSpacing:
|
|
262
|
-
borderWidth:
|
|
263
|
-
contrast:
|
|
264
|
-
grayscale:
|
|
265
|
-
hueRotate:
|
|
266
|
-
invert:
|
|
267
|
-
gap:
|
|
260
|
+
borderRadius: ["none", "", "full", Ie, z],
|
|
261
|
+
borderSpacing: M(),
|
|
262
|
+
borderWidth: $(),
|
|
263
|
+
contrast: h(),
|
|
264
|
+
grayscale: B(),
|
|
265
|
+
hueRotate: h(),
|
|
266
|
+
invert: B(),
|
|
267
|
+
gap: M(),
|
|
268
268
|
gradientColorStops: [e],
|
|
269
|
-
gradientColorStopPositions: [wn,
|
|
270
|
-
inset:
|
|
271
|
-
margin:
|
|
272
|
-
opacity:
|
|
273
|
-
padding:
|
|
274
|
-
saturate:
|
|
275
|
-
scale:
|
|
276
|
-
sepia:
|
|
277
|
-
skew:
|
|
278
|
-
space:
|
|
279
|
-
translate:
|
|
269
|
+
gradientColorStopPositions: [wn, ke],
|
|
270
|
+
inset: U(),
|
|
271
|
+
margin: U(),
|
|
272
|
+
opacity: h(),
|
|
273
|
+
padding: M(),
|
|
274
|
+
saturate: h(),
|
|
275
|
+
scale: h(),
|
|
276
|
+
sepia: B(),
|
|
277
|
+
skew: h(),
|
|
278
|
+
space: M(),
|
|
279
|
+
translate: M()
|
|
280
280
|
},
|
|
281
281
|
classGroups: {
|
|
282
282
|
// Layout
|
|
@@ -285,7 +285,7 @@ const D = (e) => {
|
|
|
285
285
|
* @see https://tailwindcss.com/docs/aspect-ratio
|
|
286
286
|
*/
|
|
287
287
|
aspect: [{
|
|
288
|
-
aspect: ["auto", "square", "video",
|
|
288
|
+
aspect: ["auto", "square", "video", z]
|
|
289
289
|
}],
|
|
290
290
|
/**
|
|
291
291
|
* Container
|
|
@@ -297,21 +297,21 @@ const D = (e) => {
|
|
|
297
297
|
* @see https://tailwindcss.com/docs/columns
|
|
298
298
|
*/
|
|
299
299
|
columns: [{
|
|
300
|
-
columns: [
|
|
300
|
+
columns: [Ie]
|
|
301
301
|
}],
|
|
302
302
|
/**
|
|
303
303
|
* Break After
|
|
304
304
|
* @see https://tailwindcss.com/docs/break-after
|
|
305
305
|
*/
|
|
306
306
|
"break-after": [{
|
|
307
|
-
"break-after":
|
|
307
|
+
"break-after": L()
|
|
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": L()
|
|
315
315
|
}],
|
|
316
316
|
/**
|
|
317
317
|
* Break Inside
|
|
@@ -370,7 +370,7 @@ const D = (e) => {
|
|
|
370
370
|
* @see https://tailwindcss.com/docs/object-position
|
|
371
371
|
*/
|
|
372
372
|
"object-position": [{
|
|
373
|
-
object: [...
|
|
373
|
+
object: [..._(), z]
|
|
374
374
|
}],
|
|
375
375
|
/**
|
|
376
376
|
* Overflow
|
|
@@ -492,7 +492,7 @@ const D = (e) => {
|
|
|
492
492
|
* @see https://tailwindcss.com/docs/z-index
|
|
493
493
|
*/
|
|
494
494
|
z: [{
|
|
495
|
-
z: ["auto", _e,
|
|
495
|
+
z: ["auto", _e, z]
|
|
496
496
|
}],
|
|
497
497
|
// Flexbox and Grid
|
|
498
498
|
/**
|
|
@@ -500,7 +500,7 @@ const D = (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
|
|
@@ -521,28 +521,28 @@ const D = (e) => {
|
|
|
521
521
|
* @see https://tailwindcss.com/docs/flex
|
|
522
522
|
*/
|
|
523
523
|
flex: [{
|
|
524
|
-
flex: ["1", "auto", "initial", "none",
|
|
524
|
+
flex: ["1", "auto", "initial", "none", z]
|
|
525
525
|
}],
|
|
526
526
|
/**
|
|
527
527
|
* Flex Grow
|
|
528
528
|
* @see https://tailwindcss.com/docs/flex-grow
|
|
529
529
|
*/
|
|
530
530
|
grow: [{
|
|
531
|
-
grow:
|
|
531
|
+
grow: B()
|
|
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: B()
|
|
539
539
|
}],
|
|
540
540
|
/**
|
|
541
541
|
* Order
|
|
542
542
|
* @see https://tailwindcss.com/docs/order
|
|
543
543
|
*/
|
|
544
544
|
order: [{
|
|
545
|
-
order: ["first", "last", "none", _e,
|
|
545
|
+
order: ["first", "last", "none", _e, z]
|
|
546
546
|
}],
|
|
547
547
|
/**
|
|
548
548
|
* Grid Template Columns
|
|
@@ -557,8 +557,8 @@ const D = (e) => {
|
|
|
557
557
|
*/
|
|
558
558
|
"col-start-end": [{
|
|
559
559
|
col: ["auto", {
|
|
560
|
-
span: ["full", _e,
|
|
561
|
-
},
|
|
560
|
+
span: ["full", _e, z]
|
|
561
|
+
}, z]
|
|
562
562
|
}],
|
|
563
563
|
/**
|
|
564
564
|
* Grid Column Start
|
|
@@ -587,8 +587,8 @@ const D = (e) => {
|
|
|
587
587
|
*/
|
|
588
588
|
"row-start-end": [{
|
|
589
589
|
row: ["auto", {
|
|
590
|
-
span: [_e,
|
|
591
|
-
},
|
|
590
|
+
span: [_e, z]
|
|
591
|
+
}, z]
|
|
592
592
|
}],
|
|
593
593
|
/**
|
|
594
594
|
* Grid Row Start
|
|
@@ -616,14 +616,14 @@ const D = (e) => {
|
|
|
616
616
|
* @see https://tailwindcss.com/docs/grid-auto-columns
|
|
617
617
|
*/
|
|
618
618
|
"auto-cols": [{
|
|
619
|
-
"auto-cols": ["auto", "min", "max", "fr",
|
|
619
|
+
"auto-cols": ["auto", "min", "max", "fr", z]
|
|
620
620
|
}],
|
|
621
621
|
/**
|
|
622
622
|
* Grid Auto Rows
|
|
623
623
|
* @see https://tailwindcss.com/docs/grid-auto-rows
|
|
624
624
|
*/
|
|
625
625
|
"auto-rows": [{
|
|
626
|
-
"auto-rows": ["auto", "min", "max", "fr",
|
|
626
|
+
"auto-rows": ["auto", "min", "max", "fr", z]
|
|
627
627
|
}],
|
|
628
628
|
/**
|
|
629
629
|
* Gap
|
|
@@ -651,7 +651,7 @@ const D = (e) => {
|
|
|
651
651
|
* @see https://tailwindcss.com/docs/justify-content
|
|
652
652
|
*/
|
|
653
653
|
"justify-content": [{
|
|
654
|
-
justify: ["normal", ...
|
|
654
|
+
justify: ["normal", ...W()]
|
|
655
655
|
}],
|
|
656
656
|
/**
|
|
657
657
|
* Justify Items
|
|
@@ -672,7 +672,7 @@ const D = (e) => {
|
|
|
672
672
|
* @see https://tailwindcss.com/docs/align-content
|
|
673
673
|
*/
|
|
674
674
|
"align-content": [{
|
|
675
|
-
content: ["normal", ...
|
|
675
|
+
content: ["normal", ...W(), "baseline"]
|
|
676
676
|
}],
|
|
677
677
|
/**
|
|
678
678
|
* Align Items
|
|
@@ -693,7 +693,7 @@ const D = (e) => {
|
|
|
693
693
|
* @see https://tailwindcss.com/docs/place-content
|
|
694
694
|
*/
|
|
695
695
|
"place-content": [{
|
|
696
|
-
"place-content": [...
|
|
696
|
+
"place-content": [...W(), "baseline"]
|
|
697
697
|
}],
|
|
698
698
|
/**
|
|
699
699
|
* Place Items
|
|
@@ -715,63 +715,63 @@ const D = (e) => {
|
|
|
715
715
|
* @see https://tailwindcss.com/docs/padding
|
|
716
716
|
*/
|
|
717
717
|
p: [{
|
|
718
|
-
p: [
|
|
718
|
+
p: [S]
|
|
719
719
|
}],
|
|
720
720
|
/**
|
|
721
721
|
* Padding X
|
|
722
722
|
* @see https://tailwindcss.com/docs/padding
|
|
723
723
|
*/
|
|
724
724
|
px: [{
|
|
725
|
-
px: [
|
|
725
|
+
px: [S]
|
|
726
726
|
}],
|
|
727
727
|
/**
|
|
728
728
|
* Padding Y
|
|
729
729
|
* @see https://tailwindcss.com/docs/padding
|
|
730
730
|
*/
|
|
731
731
|
py: [{
|
|
732
|
-
py: [
|
|
732
|
+
py: [S]
|
|
733
733
|
}],
|
|
734
734
|
/**
|
|
735
735
|
* Padding Start
|
|
736
736
|
* @see https://tailwindcss.com/docs/padding
|
|
737
737
|
*/
|
|
738
738
|
ps: [{
|
|
739
|
-
ps: [
|
|
739
|
+
ps: [S]
|
|
740
740
|
}],
|
|
741
741
|
/**
|
|
742
742
|
* Padding End
|
|
743
743
|
* @see https://tailwindcss.com/docs/padding
|
|
744
744
|
*/
|
|
745
745
|
pe: [{
|
|
746
|
-
pe: [
|
|
746
|
+
pe: [S]
|
|
747
747
|
}],
|
|
748
748
|
/**
|
|
749
749
|
* Padding Top
|
|
750
750
|
* @see https://tailwindcss.com/docs/padding
|
|
751
751
|
*/
|
|
752
752
|
pt: [{
|
|
753
|
-
pt: [
|
|
753
|
+
pt: [S]
|
|
754
754
|
}],
|
|
755
755
|
/**
|
|
756
756
|
* Padding Right
|
|
757
757
|
* @see https://tailwindcss.com/docs/padding
|
|
758
758
|
*/
|
|
759
759
|
pr: [{
|
|
760
|
-
pr: [
|
|
760
|
+
pr: [S]
|
|
761
761
|
}],
|
|
762
762
|
/**
|
|
763
763
|
* Padding Bottom
|
|
764
764
|
* @see https://tailwindcss.com/docs/padding
|
|
765
765
|
*/
|
|
766
766
|
pb: [{
|
|
767
|
-
pb: [
|
|
767
|
+
pb: [S]
|
|
768
768
|
}],
|
|
769
769
|
/**
|
|
770
770
|
* Padding Left
|
|
771
771
|
* @see https://tailwindcss.com/docs/padding
|
|
772
772
|
*/
|
|
773
773
|
pl: [{
|
|
774
|
-
pl: [
|
|
774
|
+
pl: [S]
|
|
775
775
|
}],
|
|
776
776
|
/**
|
|
777
777
|
* Margin
|
|
@@ -866,51 +866,51 @@ const D = (e) => {
|
|
|
866
866
|
* @see https://tailwindcss.com/docs/width
|
|
867
867
|
*/
|
|
868
868
|
w: [{
|
|
869
|
-
w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw",
|
|
869
|
+
w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", z, t]
|
|
870
870
|
}],
|
|
871
871
|
/**
|
|
872
872
|
* Min-Width
|
|
873
873
|
* @see https://tailwindcss.com/docs/min-width
|
|
874
874
|
*/
|
|
875
875
|
"min-w": [{
|
|
876
|
-
"min-w": [
|
|
876
|
+
"min-w": [z, t, "min", "max", "fit"]
|
|
877
877
|
}],
|
|
878
878
|
/**
|
|
879
879
|
* Max-Width
|
|
880
880
|
* @see https://tailwindcss.com/docs/max-width
|
|
881
881
|
*/
|
|
882
882
|
"max-w": [{
|
|
883
|
-
"max-w": [
|
|
884
|
-
screen: [
|
|
885
|
-
},
|
|
883
|
+
"max-w": [z, t, "none", "full", "min", "max", "fit", "prose", {
|
|
884
|
+
screen: [Ie]
|
|
885
|
+
}, Ie]
|
|
886
886
|
}],
|
|
887
887
|
/**
|
|
888
888
|
* Height
|
|
889
889
|
* @see https://tailwindcss.com/docs/height
|
|
890
890
|
*/
|
|
891
891
|
h: [{
|
|
892
|
-
h: [
|
|
892
|
+
h: [z, t, "auto", "min", "max", "fit", "svh", "lvh", "dvh"]
|
|
893
893
|
}],
|
|
894
894
|
/**
|
|
895
895
|
* Min-Height
|
|
896
896
|
* @see https://tailwindcss.com/docs/min-height
|
|
897
897
|
*/
|
|
898
898
|
"min-h": [{
|
|
899
|
-
"min-h": [
|
|
899
|
+
"min-h": [z, t, "min", "max", "fit", "svh", "lvh", "dvh"]
|
|
900
900
|
}],
|
|
901
901
|
/**
|
|
902
902
|
* Max-Height
|
|
903
903
|
* @see https://tailwindcss.com/docs/max-height
|
|
904
904
|
*/
|
|
905
905
|
"max-h": [{
|
|
906
|
-
"max-h": [
|
|
906
|
+
"max-h": [z, t, "min", "max", "fit", "svh", "lvh", "dvh"]
|
|
907
907
|
}],
|
|
908
908
|
/**
|
|
909
909
|
* Size
|
|
910
910
|
* @see https://tailwindcss.com/docs/size
|
|
911
911
|
*/
|
|
912
912
|
size: [{
|
|
913
|
-
size: [
|
|
913
|
+
size: [z, t, "auto", "min", "max", "fit"]
|
|
914
914
|
}],
|
|
915
915
|
// Typography
|
|
916
916
|
/**
|
|
@@ -918,7 +918,7 @@ const D = (e) => {
|
|
|
918
918
|
* @see https://tailwindcss.com/docs/font-size
|
|
919
919
|
*/
|
|
920
920
|
"font-size": [{
|
|
921
|
-
text: ["base",
|
|
921
|
+
text: ["base", Ie, ke]
|
|
922
922
|
}],
|
|
923
923
|
/**
|
|
924
924
|
* Font Smoothing
|
|
@@ -979,7 +979,7 @@ const D = (e) => {
|
|
|
979
979
|
* @see https://tailwindcss.com/docs/letter-spacing
|
|
980
980
|
*/
|
|
981
981
|
tracking: [{
|
|
982
|
-
tracking: ["tighter", "tight", "normal", "wide", "wider", "widest",
|
|
982
|
+
tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", z]
|
|
983
983
|
}],
|
|
984
984
|
/**
|
|
985
985
|
* Line Clamp
|
|
@@ -993,21 +993,21 @@ const D = (e) => {
|
|
|
993
993
|
* @see https://tailwindcss.com/docs/line-height
|
|
994
994
|
*/
|
|
995
995
|
leading: [{
|
|
996
|
-
leading: ["none", "tight", "snug", "normal", "relaxed", "loose", ue,
|
|
996
|
+
leading: ["none", "tight", "snug", "normal", "relaxed", "loose", ue, z]
|
|
997
997
|
}],
|
|
998
998
|
/**
|
|
999
999
|
* List Style Image
|
|
1000
1000
|
* @see https://tailwindcss.com/docs/list-style-image
|
|
1001
1001
|
*/
|
|
1002
1002
|
"list-image": [{
|
|
1003
|
-
"list-image": ["none",
|
|
1003
|
+
"list-image": ["none", z]
|
|
1004
1004
|
}],
|
|
1005
1005
|
/**
|
|
1006
1006
|
* List Style Type
|
|
1007
1007
|
* @see https://tailwindcss.com/docs/list-style-type
|
|
1008
1008
|
*/
|
|
1009
1009
|
"list-style-type": [{
|
|
1010
|
-
list: ["none", "disc", "decimal",
|
|
1010
|
+
list: ["none", "disc", "decimal", z]
|
|
1011
1011
|
}],
|
|
1012
1012
|
/**
|
|
1013
1013
|
* List Style Position
|
|
@@ -1062,21 +1062,21 @@ const D = (e) => {
|
|
|
1062
1062
|
* @see https://tailwindcss.com/docs/text-decoration-style
|
|
1063
1063
|
*/
|
|
1064
1064
|
"text-decoration-style": [{
|
|
1065
|
-
decoration: [...
|
|
1065
|
+
decoration: [...O(), "wavy"]
|
|
1066
1066
|
}],
|
|
1067
1067
|
/**
|
|
1068
1068
|
* Text Decoration Thickness
|
|
1069
1069
|
* @see https://tailwindcss.com/docs/text-decoration-thickness
|
|
1070
1070
|
*/
|
|
1071
1071
|
"text-decoration-thickness": [{
|
|
1072
|
-
decoration: ["auto", "from-font", ue,
|
|
1072
|
+
decoration: ["auto", "from-font", ue, ke]
|
|
1073
1073
|
}],
|
|
1074
1074
|
/**
|
|
1075
1075
|
* Text Underline Offset
|
|
1076
1076
|
* @see https://tailwindcss.com/docs/text-underline-offset
|
|
1077
1077
|
*/
|
|
1078
1078
|
"underline-offset": [{
|
|
1079
|
-
"underline-offset": ["auto", ue,
|
|
1079
|
+
"underline-offset": ["auto", ue, z]
|
|
1080
1080
|
}],
|
|
1081
1081
|
/**
|
|
1082
1082
|
* Text Decoration Color
|
|
@@ -1107,14 +1107,14 @@ const D = (e) => {
|
|
|
1107
1107
|
* @see https://tailwindcss.com/docs/text-indent
|
|
1108
1108
|
*/
|
|
1109
1109
|
indent: [{
|
|
1110
|
-
indent:
|
|
1110
|
+
indent: M()
|
|
1111
1111
|
}],
|
|
1112
1112
|
/**
|
|
1113
1113
|
* Vertical Alignment
|
|
1114
1114
|
* @see https://tailwindcss.com/docs/vertical-align
|
|
1115
1115
|
*/
|
|
1116
1116
|
"vertical-align": [{
|
|
1117
|
-
align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super",
|
|
1117
|
+
align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super", z]
|
|
1118
1118
|
}],
|
|
1119
1119
|
/**
|
|
1120
1120
|
* Whitespace
|
|
@@ -1142,7 +1142,7 @@ const D = (e) => {
|
|
|
1142
1142
|
* @see https://tailwindcss.com/docs/content
|
|
1143
1143
|
*/
|
|
1144
1144
|
content: [{
|
|
1145
|
-
content: ["none",
|
|
1145
|
+
content: ["none", z]
|
|
1146
1146
|
}],
|
|
1147
1147
|
// Backgrounds
|
|
1148
1148
|
/**
|
|
@@ -1179,7 +1179,7 @@ const D = (e) => {
|
|
|
1179
1179
|
* @see https://tailwindcss.com/docs/background-position
|
|
1180
1180
|
*/
|
|
1181
1181
|
"bg-position": [{
|
|
1182
|
-
bg: [...
|
|
1182
|
+
bg: [..._(), vn]
|
|
1183
1183
|
}],
|
|
1184
1184
|
/**
|
|
1185
1185
|
* Background Repeat
|
|
@@ -1436,7 +1436,7 @@ const D = (e) => {
|
|
|
1436
1436
|
* @see https://tailwindcss.com/docs/border-style
|
|
1437
1437
|
*/
|
|
1438
1438
|
"border-style": [{
|
|
1439
|
-
border: [...
|
|
1439
|
+
border: [...O(), "hidden"]
|
|
1440
1440
|
}],
|
|
1441
1441
|
/**
|
|
1442
1442
|
* Divide Width X
|
|
@@ -1474,7 +1474,7 @@ const D = (e) => {
|
|
|
1474
1474
|
* @see https://tailwindcss.com/docs/divide-style
|
|
1475
1475
|
*/
|
|
1476
1476
|
"divide-style": [{
|
|
1477
|
-
divide:
|
|
1477
|
+
divide: O()
|
|
1478
1478
|
}],
|
|
1479
1479
|
/**
|
|
1480
1480
|
* Border Color
|
|
@@ -1551,21 +1551,21 @@ const D = (e) => {
|
|
|
1551
1551
|
* @see https://tailwindcss.com/docs/outline-style
|
|
1552
1552
|
*/
|
|
1553
1553
|
"outline-style": [{
|
|
1554
|
-
outline: ["", ...
|
|
1554
|
+
outline: ["", ...O()]
|
|
1555
1555
|
}],
|
|
1556
1556
|
/**
|
|
1557
1557
|
* Outline Offset
|
|
1558
1558
|
* @see https://tailwindcss.com/docs/outline-offset
|
|
1559
1559
|
*/
|
|
1560
1560
|
"outline-offset": [{
|
|
1561
|
-
"outline-offset": [ue,
|
|
1561
|
+
"outline-offset": [ue, z]
|
|
1562
1562
|
}],
|
|
1563
1563
|
/**
|
|
1564
1564
|
* Outline Width
|
|
1565
1565
|
* @see https://tailwindcss.com/docs/outline-width
|
|
1566
1566
|
*/
|
|
1567
1567
|
"outline-w": [{
|
|
1568
|
-
outline: [ue,
|
|
1568
|
+
outline: [ue, ke]
|
|
1569
1569
|
}],
|
|
1570
1570
|
/**
|
|
1571
1571
|
* Outline Color
|
|
@@ -1579,7 +1579,7 @@ const D = (e) => {
|
|
|
1579
1579
|
* @see https://tailwindcss.com/docs/ring-width
|
|
1580
1580
|
*/
|
|
1581
1581
|
"ring-w": [{
|
|
1582
|
-
ring:
|
|
1582
|
+
ring: $()
|
|
1583
1583
|
}],
|
|
1584
1584
|
/**
|
|
1585
1585
|
* Ring Width Inset
|
|
@@ -1605,7 +1605,7 @@ const D = (e) => {
|
|
|
1605
1605
|
* @see https://tailwindcss.com/docs/ring-offset-width
|
|
1606
1606
|
*/
|
|
1607
1607
|
"ring-offset-w": [{
|
|
1608
|
-
"ring-offset": [ue,
|
|
1608
|
+
"ring-offset": [ue, ke]
|
|
1609
1609
|
}],
|
|
1610
1610
|
/**
|
|
1611
1611
|
* Ring Offset Color
|
|
@@ -1620,7 +1620,7 @@ const D = (e) => {
|
|
|
1620
1620
|
* @see https://tailwindcss.com/docs/box-shadow
|
|
1621
1621
|
*/
|
|
1622
1622
|
shadow: [{
|
|
1623
|
-
shadow: ["", "inner", "none",
|
|
1623
|
+
shadow: ["", "inner", "none", Ie, Tn]
|
|
1624
1624
|
}],
|
|
1625
1625
|
/**
|
|
1626
1626
|
* Box Shadow Color
|
|
@@ -1641,14 +1641,14 @@ const D = (e) => {
|
|
|
1641
1641
|
* @see https://tailwindcss.com/docs/mix-blend-mode
|
|
1642
1642
|
*/
|
|
1643
1643
|
"mix-blend": [{
|
|
1644
|
-
"mix-blend": [...
|
|
1644
|
+
"mix-blend": [...R(), "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": R()
|
|
1652
1652
|
}],
|
|
1653
1653
|
// Filters
|
|
1654
1654
|
/**
|
|
@@ -1685,7 +1685,7 @@ const D = (e) => {
|
|
|
1685
1685
|
* @see https://tailwindcss.com/docs/drop-shadow
|
|
1686
1686
|
*/
|
|
1687
1687
|
"drop-shadow": [{
|
|
1688
|
-
"drop-shadow": ["", "none",
|
|
1688
|
+
"drop-shadow": ["", "none", Ie, z]
|
|
1689
1689
|
}],
|
|
1690
1690
|
/**
|
|
1691
1691
|
* Grayscale
|
|
@@ -1842,35 +1842,35 @@ const D = (e) => {
|
|
|
1842
1842
|
* @see https://tailwindcss.com/docs/transition-property
|
|
1843
1843
|
*/
|
|
1844
1844
|
transition: [{
|
|
1845
|
-
transition: ["none", "all", "", "colors", "opacity", "shadow", "transform",
|
|
1845
|
+
transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", z]
|
|
1846
1846
|
}],
|
|
1847
1847
|
/**
|
|
1848
1848
|
* Transition Duration
|
|
1849
1849
|
* @see https://tailwindcss.com/docs/transition-duration
|
|
1850
1850
|
*/
|
|
1851
1851
|
duration: [{
|
|
1852
|
-
duration:
|
|
1852
|
+
duration: h()
|
|
1853
1853
|
}],
|
|
1854
1854
|
/**
|
|
1855
1855
|
* Transition Timing Function
|
|
1856
1856
|
* @see https://tailwindcss.com/docs/transition-timing-function
|
|
1857
1857
|
*/
|
|
1858
1858
|
ease: [{
|
|
1859
|
-
ease: ["linear", "in", "out", "in-out",
|
|
1859
|
+
ease: ["linear", "in", "out", "in-out", z]
|
|
1860
1860
|
}],
|
|
1861
1861
|
/**
|
|
1862
1862
|
* Transition Delay
|
|
1863
1863
|
* @see https://tailwindcss.com/docs/transition-delay
|
|
1864
1864
|
*/
|
|
1865
1865
|
delay: [{
|
|
1866
|
-
delay:
|
|
1866
|
+
delay: h()
|
|
1867
1867
|
}],
|
|
1868
1868
|
/**
|
|
1869
1869
|
* Animation
|
|
1870
1870
|
* @see https://tailwindcss.com/docs/animation
|
|
1871
1871
|
*/
|
|
1872
1872
|
animate: [{
|
|
1873
|
-
animate: ["none", "spin", "ping", "pulse", "bounce",
|
|
1873
|
+
animate: ["none", "spin", "ping", "pulse", "bounce", z]
|
|
1874
1874
|
}],
|
|
1875
1875
|
// Transforms
|
|
1876
1876
|
/**
|
|
@@ -1906,7 +1906,7 @@ const D = (e) => {
|
|
|
1906
1906
|
* @see https://tailwindcss.com/docs/rotate
|
|
1907
1907
|
*/
|
|
1908
1908
|
rotate: [{
|
|
1909
|
-
rotate: [_e,
|
|
1909
|
+
rotate: [_e, z]
|
|
1910
1910
|
}],
|
|
1911
1911
|
/**
|
|
1912
1912
|
* Translate X
|
|
@@ -1927,21 +1927,21 @@ const D = (e) => {
|
|
|
1927
1927
|
* @see https://tailwindcss.com/docs/skew
|
|
1928
1928
|
*/
|
|
1929
1929
|
"skew-x": [{
|
|
1930
|
-
"skew-x": [
|
|
1930
|
+
"skew-x": [y]
|
|
1931
1931
|
}],
|
|
1932
1932
|
/**
|
|
1933
1933
|
* Skew Y
|
|
1934
1934
|
* @see https://tailwindcss.com/docs/skew
|
|
1935
1935
|
*/
|
|
1936
1936
|
"skew-y": [{
|
|
1937
|
-
"skew-y": [
|
|
1937
|
+
"skew-y": [y]
|
|
1938
1938
|
}],
|
|
1939
1939
|
/**
|
|
1940
1940
|
* Transform Origin
|
|
1941
1941
|
* @see https://tailwindcss.com/docs/transform-origin
|
|
1942
1942
|
*/
|
|
1943
1943
|
"transform-origin": [{
|
|
1944
|
-
origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left",
|
|
1944
|
+
origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", z]
|
|
1945
1945
|
}],
|
|
1946
1946
|
// Interactivity
|
|
1947
1947
|
/**
|
|
@@ -1963,7 +1963,7 @@ const D = (e) => {
|
|
|
1963
1963
|
* @see https://tailwindcss.com/docs/cursor
|
|
1964
1964
|
*/
|
|
1965
1965
|
cursor: [{
|
|
1966
|
-
cursor: ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", "none", "context-menu", "progress", "cell", "crosshair", "vertical-text", "alias", "copy", "no-drop", "grab", "grabbing", "all-scroll", "col-resize", "row-resize", "n-resize", "e-resize", "s-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize", "ew-resize", "ns-resize", "nesw-resize", "nwse-resize", "zoom-in", "zoom-out",
|
|
1966
|
+
cursor: ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", "none", "context-menu", "progress", "cell", "crosshair", "vertical-text", "alias", "copy", "no-drop", "grab", "grabbing", "all-scroll", "col-resize", "row-resize", "n-resize", "e-resize", "s-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize", "ew-resize", "ns-resize", "nesw-resize", "nwse-resize", "zoom-in", "zoom-out", z]
|
|
1967
1967
|
}],
|
|
1968
1968
|
/**
|
|
1969
1969
|
* Caret Color
|
|
@@ -1998,126 +1998,126 @@ const D = (e) => {
|
|
|
1998
1998
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
1999
1999
|
*/
|
|
2000
2000
|
"scroll-m": [{
|
|
2001
|
-
"scroll-m":
|
|
2001
|
+
"scroll-m": M()
|
|
2002
2002
|
}],
|
|
2003
2003
|
/**
|
|
2004
2004
|
* Scroll Margin X
|
|
2005
2005
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2006
2006
|
*/
|
|
2007
2007
|
"scroll-mx": [{
|
|
2008
|
-
"scroll-mx":
|
|
2008
|
+
"scroll-mx": M()
|
|
2009
2009
|
}],
|
|
2010
2010
|
/**
|
|
2011
2011
|
* Scroll Margin Y
|
|
2012
2012
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2013
2013
|
*/
|
|
2014
2014
|
"scroll-my": [{
|
|
2015
|
-
"scroll-my":
|
|
2015
|
+
"scroll-my": M()
|
|
2016
2016
|
}],
|
|
2017
2017
|
/**
|
|
2018
2018
|
* Scroll Margin Start
|
|
2019
2019
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2020
2020
|
*/
|
|
2021
2021
|
"scroll-ms": [{
|
|
2022
|
-
"scroll-ms":
|
|
2022
|
+
"scroll-ms": M()
|
|
2023
2023
|
}],
|
|
2024
2024
|
/**
|
|
2025
2025
|
* Scroll Margin End
|
|
2026
2026
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2027
2027
|
*/
|
|
2028
2028
|
"scroll-me": [{
|
|
2029
|
-
"scroll-me":
|
|
2029
|
+
"scroll-me": M()
|
|
2030
2030
|
}],
|
|
2031
2031
|
/**
|
|
2032
2032
|
* Scroll Margin Top
|
|
2033
2033
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2034
2034
|
*/
|
|
2035
2035
|
"scroll-mt": [{
|
|
2036
|
-
"scroll-mt":
|
|
2036
|
+
"scroll-mt": M()
|
|
2037
2037
|
}],
|
|
2038
2038
|
/**
|
|
2039
2039
|
* Scroll Margin Right
|
|
2040
2040
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2041
2041
|
*/
|
|
2042
2042
|
"scroll-mr": [{
|
|
2043
|
-
"scroll-mr":
|
|
2043
|
+
"scroll-mr": M()
|
|
2044
2044
|
}],
|
|
2045
2045
|
/**
|
|
2046
2046
|
* Scroll Margin Bottom
|
|
2047
2047
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2048
2048
|
*/
|
|
2049
2049
|
"scroll-mb": [{
|
|
2050
|
-
"scroll-mb":
|
|
2050
|
+
"scroll-mb": M()
|
|
2051
2051
|
}],
|
|
2052
2052
|
/**
|
|
2053
2053
|
* Scroll Margin Left
|
|
2054
2054
|
* @see https://tailwindcss.com/docs/scroll-margin
|
|
2055
2055
|
*/
|
|
2056
2056
|
"scroll-ml": [{
|
|
2057
|
-
"scroll-ml":
|
|
2057
|
+
"scroll-ml": M()
|
|
2058
2058
|
}],
|
|
2059
2059
|
/**
|
|
2060
2060
|
* Scroll Padding
|
|
2061
2061
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2062
2062
|
*/
|
|
2063
2063
|
"scroll-p": [{
|
|
2064
|
-
"scroll-p":
|
|
2064
|
+
"scroll-p": M()
|
|
2065
2065
|
}],
|
|
2066
2066
|
/**
|
|
2067
2067
|
* Scroll Padding X
|
|
2068
2068
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2069
2069
|
*/
|
|
2070
2070
|
"scroll-px": [{
|
|
2071
|
-
"scroll-px":
|
|
2071
|
+
"scroll-px": M()
|
|
2072
2072
|
}],
|
|
2073
2073
|
/**
|
|
2074
2074
|
* Scroll Padding Y
|
|
2075
2075
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2076
2076
|
*/
|
|
2077
2077
|
"scroll-py": [{
|
|
2078
|
-
"scroll-py":
|
|
2078
|
+
"scroll-py": M()
|
|
2079
2079
|
}],
|
|
2080
2080
|
/**
|
|
2081
2081
|
* Scroll Padding Start
|
|
2082
2082
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2083
2083
|
*/
|
|
2084
2084
|
"scroll-ps": [{
|
|
2085
|
-
"scroll-ps":
|
|
2085
|
+
"scroll-ps": M()
|
|
2086
2086
|
}],
|
|
2087
2087
|
/**
|
|
2088
2088
|
* Scroll Padding End
|
|
2089
2089
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2090
2090
|
*/
|
|
2091
2091
|
"scroll-pe": [{
|
|
2092
|
-
"scroll-pe":
|
|
2092
|
+
"scroll-pe": M()
|
|
2093
2093
|
}],
|
|
2094
2094
|
/**
|
|
2095
2095
|
* Scroll Padding Top
|
|
2096
2096
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2097
2097
|
*/
|
|
2098
2098
|
"scroll-pt": [{
|
|
2099
|
-
"scroll-pt":
|
|
2099
|
+
"scroll-pt": M()
|
|
2100
2100
|
}],
|
|
2101
2101
|
/**
|
|
2102
2102
|
* Scroll Padding Right
|
|
2103
2103
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2104
2104
|
*/
|
|
2105
2105
|
"scroll-pr": [{
|
|
2106
|
-
"scroll-pr":
|
|
2106
|
+
"scroll-pr": M()
|
|
2107
2107
|
}],
|
|
2108
2108
|
/**
|
|
2109
2109
|
* Scroll Padding Bottom
|
|
2110
2110
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2111
2111
|
*/
|
|
2112
2112
|
"scroll-pb": [{
|
|
2113
|
-
"scroll-pb":
|
|
2113
|
+
"scroll-pb": M()
|
|
2114
2114
|
}],
|
|
2115
2115
|
/**
|
|
2116
2116
|
* Scroll Padding Left
|
|
2117
2117
|
* @see https://tailwindcss.com/docs/scroll-padding
|
|
2118
2118
|
*/
|
|
2119
2119
|
"scroll-pl": [{
|
|
2120
|
-
"scroll-pl":
|
|
2120
|
+
"scroll-pl": M()
|
|
2121
2121
|
}],
|
|
2122
2122
|
/**
|
|
2123
2123
|
* Scroll Snap Align
|
|
@@ -2185,7 +2185,7 @@ const D = (e) => {
|
|
|
2185
2185
|
* @see https://tailwindcss.com/docs/will-change
|
|
2186
2186
|
*/
|
|
2187
2187
|
"will-change": [{
|
|
2188
|
-
"will-change": ["auto", "scroll", "contents", "transform",
|
|
2188
|
+
"will-change": ["auto", "scroll", "contents", "transform", z]
|
|
2189
2189
|
}],
|
|
2190
2190
|
// SVG
|
|
2191
2191
|
/**
|
|
@@ -2200,7 +2200,7 @@ const D = (e) => {
|
|
|
2200
2200
|
* @see https://tailwindcss.com/docs/stroke-width
|
|
2201
2201
|
*/
|
|
2202
2202
|
"stroke-w": [{
|
|
2203
|
-
stroke: [ue,
|
|
2203
|
+
stroke: [ue, ke, qe]
|
|
2204
2204
|
}],
|
|
2205
2205
|
/**
|
|
2206
2206
|
* Stroke
|
|
@@ -2343,12 +2343,12 @@ function Bn(e) {
|
|
|
2343
2343
|
function Ct(e) {
|
|
2344
2344
|
return !!(e && typeof e == "object" && (e.type === "file" || e.mimeType || e.filename || e.sourceType === "base64"));
|
|
2345
2345
|
}
|
|
2346
|
-
function
|
|
2346
|
+
function De(e) {
|
|
2347
2347
|
if (typeof e == "string")
|
|
2348
2348
|
return e;
|
|
2349
2349
|
if (e && typeof e == "object") {
|
|
2350
2350
|
if (Array.isArray(e)) {
|
|
2351
|
-
const n = e.map(
|
|
2351
|
+
const n = e.map(De).filter((r) => r !== void 0);
|
|
2352
2352
|
if (!n.length) {
|
|
2353
2353
|
console.debug("[message-utils] sanitizeForDisplay - array emptied -> returning undefined", { originalLength: e.length });
|
|
2354
2354
|
return;
|
|
@@ -2372,7 +2372,7 @@ function Ke(e) {
|
|
|
2372
2372
|
if (n === "data" && typeof r == "string" && r.length > 100)
|
|
2373
2373
|
t[n] = `[base64 ${r.length} chars omitted]`;
|
|
2374
2374
|
else {
|
|
2375
|
-
const o =
|
|
2375
|
+
const o = De(r);
|
|
2376
2376
|
o !== void 0 && (t[n] = o);
|
|
2377
2377
|
}
|
|
2378
2378
|
}
|
|
@@ -2391,7 +2391,7 @@ function Et(e) {
|
|
|
2391
2391
|
if (typeof e == "string") return e;
|
|
2392
2392
|
if (Ct(e)) return "";
|
|
2393
2393
|
try {
|
|
2394
|
-
const t =
|
|
2394
|
+
const t = De(e);
|
|
2395
2395
|
return t === void 0 ? "" : typeof t == "string" ? t : JSON.stringify(t, null, 2);
|
|
2396
2396
|
} catch {
|
|
2397
2397
|
return "";
|
|
@@ -2404,7 +2404,7 @@ function oo(e) {
|
|
|
2404
2404
|
function Fn(e) {
|
|
2405
2405
|
const t = (r) => {
|
|
2406
2406
|
try {
|
|
2407
|
-
const o =
|
|
2407
|
+
const o = De(r);
|
|
2408
2408
|
return typeof o == "string" ? o : JSON.stringify(o ?? "");
|
|
2409
2409
|
} catch {
|
|
2410
2410
|
return "";
|
|
@@ -2416,44 +2416,44 @@ function Fn(e) {
|
|
|
2416
2416
|
function so(e) {
|
|
2417
2417
|
return e.content.some((t) => t.type === "text" ? t.text.trim().length > 0 : t.type === "image_url" || t.type === "file");
|
|
2418
2418
|
}
|
|
2419
|
-
function
|
|
2419
|
+
function le(e) {
|
|
2420
2420
|
if (e == null) return e;
|
|
2421
2421
|
if (typeof e == "string") {
|
|
2422
2422
|
const t = e.trim();
|
|
2423
2423
|
if (t.startsWith("{") || t.startsWith("[")) {
|
|
2424
2424
|
const n = tt(t);
|
|
2425
2425
|
if (n !== null)
|
|
2426
|
-
return
|
|
2426
|
+
return le(n);
|
|
2427
2427
|
}
|
|
2428
2428
|
return e;
|
|
2429
2429
|
}
|
|
2430
2430
|
if (typeof e == "object" && !Array.isArray(e)) {
|
|
2431
2431
|
if (e.content !== void 0)
|
|
2432
|
-
return Array.isArray(e.content) ? e.content.map((t) =>
|
|
2433
|
-
`) :
|
|
2432
|
+
return Array.isArray(e.content) ? e.content.map((t) => le(t)).filter(Boolean).join(`
|
|
2433
|
+
`) : le(e.content);
|
|
2434
2434
|
if (e.value !== void 0)
|
|
2435
|
-
return
|
|
2435
|
+
return le(e.value);
|
|
2436
2436
|
}
|
|
2437
|
-
return typeof e == "object" && !Array.isArray(e) && (e.type === "text" && typeof e.text == "string" || typeof e.text == "string") ? e.text : Array.isArray(e) && e.length > 0 ?
|
|
2437
|
+
return typeof e == "object" && !Array.isArray(e) && (e.type === "text" && typeof e.text == "string" || typeof e.text == "string") ? e.text : Array.isArray(e) && e.length > 0 ? le(e[0]) : e;
|
|
2438
2438
|
}
|
|
2439
2439
|
function On(e) {
|
|
2440
2440
|
return e.replace(/[_-](\w)/g, (t, n) => n ? n.toUpperCase() : "").replace(/^\w/, (t) => t.toLowerCase());
|
|
2441
2441
|
}
|
|
2442
|
-
function
|
|
2443
|
-
return !e || typeof e != "object" ? e : Array.isArray(e) ? e.map(
|
|
2442
|
+
function de(e) {
|
|
2443
|
+
return !e || typeof e != "object" ? e : Array.isArray(e) ? e.map(de) : Object.fromEntries(
|
|
2444
2444
|
Object.entries(e).map(([t, n]) => [
|
|
2445
2445
|
On(t),
|
|
2446
|
-
|
|
2446
|
+
de(n)
|
|
2447
2447
|
])
|
|
2448
2448
|
);
|
|
2449
2449
|
}
|
|
2450
2450
|
function nt(e) {
|
|
2451
|
-
var x,
|
|
2451
|
+
var x, S, A, w, b, y, T;
|
|
2452
2452
|
if (!e || typeof e != "object") return null;
|
|
2453
|
-
const t =
|
|
2453
|
+
const t = de(e), n = Kn(t);
|
|
2454
2454
|
if (!n)
|
|
2455
2455
|
return null;
|
|
2456
|
-
const r = t.toolCalls ?? ((x = t.additionalKwargs) == null ? void 0 : x.toolCalls), o = Array.isArray(r) ? r.map(rt) : void 0, s = Dn(t.content ?? t.parts, !!(o != null && o.length)), a = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, i = t.createdAt ?? ((
|
|
2456
|
+
const r = t.toolCalls ?? ((x = t.additionalKwargs) == null ? void 0 : x.toolCalls), o = Array.isArray(r) ? r.map(rt) : void 0, s = Dn(t.content ?? t.parts, !!(o != null && o.length)), a = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, i = t.createdAt ?? ((S = t.additionalKwargs) == null ? void 0 : S.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), d = t.name ?? ((A = t.additionalKwargs) == null ? void 0 : A.agentName) ?? void 0, c = t.model ?? ((w = t.additionalKwargs) == null ? void 0 : w.model) ?? void 0, l = t.toolCallId ?? void 0, f = t.additionalKwargs ?? void 0, p = t.responseMetadata ?? void 0, g = t.checkpointId ?? ((b = t.additionalKwargs) == null ? void 0 : b.checkpointId) ?? void 0, I = t.checkpointNs ?? ((y = t.additionalKwargs) == null ? void 0 : y.checkpointNs) ?? void 0, u = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((T = t.additionalKwargs) != null && T.toolStreaming);
|
|
2457
2457
|
return {
|
|
2458
2458
|
...t,
|
|
2459
2459
|
id: a,
|
|
@@ -2474,7 +2474,7 @@ function nt(e) {
|
|
|
2474
2474
|
}
|
|
2475
2475
|
function $n(e) {
|
|
2476
2476
|
if (!e || typeof e != "object") return e;
|
|
2477
|
-
const t =
|
|
2477
|
+
const t = de(e);
|
|
2478
2478
|
if (t.tool && !t.name && (t.name = t.tool), t.type === "artifact.update" && t.artifact && typeof t.artifact == "object") {
|
|
2479
2479
|
const n = t.artifact;
|
|
2480
2480
|
!n.type && t.name && (n.type = t.name);
|
|
@@ -2482,7 +2482,7 @@ function $n(e) {
|
|
|
2482
2482
|
return t;
|
|
2483
2483
|
}
|
|
2484
2484
|
function rt(e) {
|
|
2485
|
-
const t =
|
|
2485
|
+
const t = de(e), n = t.content ?? t.output ?? void 0;
|
|
2486
2486
|
return {
|
|
2487
2487
|
...t,
|
|
2488
2488
|
type: "tool_call",
|
|
@@ -2493,12 +2493,12 @@ function rt(e) {
|
|
|
2493
2493
|
};
|
|
2494
2494
|
}
|
|
2495
2495
|
function Dn(e, t) {
|
|
2496
|
-
return typeof e == "string" ? [{ type: "text", text: e }] : Array.isArray(e) ? e.map((n) => typeof n == "string" ? { type: "text", text: n } : n.type === "tool_call" || n.type === "tool" ? t ? null : rt(
|
|
2496
|
+
return typeof e == "string" ? [{ type: "text", text: e }] : Array.isArray(e) ? e.map((n) => typeof n == "string" ? { type: "text", text: n } : n.type === "tool_call" || n.type === "tool" ? t ? null : rt(de(n)) : n).filter(
|
|
2497
2497
|
(n) => !!(n && typeof n == "object" && typeof n.type == "string")
|
|
2498
2498
|
) : [];
|
|
2499
2499
|
}
|
|
2500
2500
|
function Kn(e) {
|
|
2501
|
-
const t =
|
|
2501
|
+
const t = de(e), n = t.role;
|
|
2502
2502
|
if (n && (n === "assistant" || n === "user" || n === "system" || n === "tool"))
|
|
2503
2503
|
return n;
|
|
2504
2504
|
const r = t.type;
|
|
@@ -2540,7 +2540,7 @@ function qn(e, t = []) {
|
|
|
2540
2540
|
var f, p, g;
|
|
2541
2541
|
const i = He(a.id, e) || He(a.id, t), d = Array.isArray((f = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : f.toolProgress) ? (p = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : p.toolProgress : void 0, c = (i == null ? void 0 : i.artifact) ?? a.artifact, l = dt(a.status) ?? ((g = i == null ? void 0 : i.additionalKwargs) != null && g.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
|
|
2542
2542
|
if (i && !a.content && l === "completed") {
|
|
2543
|
-
const I =
|
|
2543
|
+
const I = le(i);
|
|
2544
2544
|
typeof I == "string" && (a.content = I);
|
|
2545
2545
|
}
|
|
2546
2546
|
return {
|
|
@@ -2558,7 +2558,7 @@ function qn(e, t = []) {
|
|
|
2558
2558
|
var d, c, l;
|
|
2559
2559
|
const o = He(r.id, t) ?? Vn(e, r), s = Array.isArray((d = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : d.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 = dt(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 f =
|
|
2561
|
+
const f = le(o);
|
|
2562
2562
|
typeof f == "string" && (r.content = f);
|
|
2563
2563
|
}
|
|
2564
2564
|
return {
|
|
@@ -2585,20 +2585,20 @@ const ze = {
|
|
|
2585
2585
|
function Ge(e) {
|
|
2586
2586
|
return `draft:${e}`;
|
|
2587
2587
|
}
|
|
2588
|
-
let
|
|
2588
|
+
let Ke = null;
|
|
2589
2589
|
const Qe = /* @__PURE__ */ new Set();
|
|
2590
2590
|
function Pt() {
|
|
2591
|
-
return
|
|
2591
|
+
return Ke;
|
|
2592
2592
|
}
|
|
2593
|
-
function
|
|
2594
|
-
|
|
2593
|
+
function ve(e) {
|
|
2594
|
+
Ke = e, Qe.forEach((t) => t(e));
|
|
2595
2595
|
}
|
|
2596
2596
|
function _t(e) {
|
|
2597
2597
|
return Qe.add(e), () => Qe.delete(e);
|
|
2598
2598
|
}
|
|
2599
2599
|
const Hn = 12e4, Gn = 12e4;
|
|
2600
2600
|
let Ye = Hn, Nt = Gn;
|
|
2601
|
-
const
|
|
2601
|
+
const te = Jt.create({
|
|
2602
2602
|
// BaseURL is set dynamically via ApiProvider -> api.updateConfig
|
|
2603
2603
|
timeout: Ye,
|
|
2604
2604
|
withCredentials: !0
|
|
@@ -2608,18 +2608,18 @@ function ft(e) {
|
|
|
2608
2608
|
}
|
|
2609
2609
|
function Wn(e) {
|
|
2610
2610
|
const t = ft(e.requestTimeoutMs), n = ft(e.historyTimeoutMs);
|
|
2611
|
-
t !== null && (Ye = t,
|
|
2611
|
+
t !== null && (Ye = t, te.defaults.timeout = Ye), n !== null && (Nt = n);
|
|
2612
2612
|
}
|
|
2613
2613
|
function Jn() {
|
|
2614
2614
|
return Nt;
|
|
2615
2615
|
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2616
|
+
te.interceptors.request.use((e) => (Ke && (e.headers.Authorization = `Bearer ${Ke}`), e));
|
|
2617
|
+
te.interceptors.response.use(
|
|
2618
2618
|
(e) => {
|
|
2619
2619
|
if (typeof window < "u" && (e != null && e.data))
|
|
2620
2620
|
try {
|
|
2621
2621
|
const t = e.data, n = t.data || {}, r = typeof t.token == "string" && t.token || typeof n.token == "string" && n.token || null, o = typeof t.expires_at == "number" && t.expires_at || typeof n.expires_at == "number" && n.expires_at || typeof t.expiresAt == "number" && t.expiresAt || typeof n.expiresAt == "number" && n.expiresAt || null;
|
|
2622
|
-
r && (localStorage.setItem(ze.authToken, r),
|
|
2622
|
+
r && (localStorage.setItem(ze.authToken, r), ve(r)), o && localStorage.setItem(ze.authTokenExpiresAt, o.toString()), (r || o) && window.dispatchEvent(
|
|
2623
2623
|
new CustomEvent("smartorg:chat-token-updated", {
|
|
2624
2624
|
detail: { token: r, expiresAt: o }
|
|
2625
2625
|
})
|
|
@@ -2632,18 +2632,18 @@ ne.interceptors.response.use(
|
|
|
2632
2632
|
(e) => Promise.reject(e)
|
|
2633
2633
|
);
|
|
2634
2634
|
async function se(e, t) {
|
|
2635
|
-
return
|
|
2635
|
+
return te.defaults.baseURL ? (await te.get(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2636
2636
|
}
|
|
2637
2637
|
async function Ze(e, t, n) {
|
|
2638
|
-
return
|
|
2638
|
+
return te.defaults.baseURL ? (await te.post(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2639
2639
|
}
|
|
2640
2640
|
async function Xn(e, t, n) {
|
|
2641
|
-
return
|
|
2641
|
+
return te.defaults.baseURL ? (await te.put(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2642
2642
|
}
|
|
2643
2643
|
async function Qn(e, t) {
|
|
2644
|
-
return
|
|
2644
|
+
return te.defaults.baseURL ? (await te.delete(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2645
2645
|
}
|
|
2646
|
-
function
|
|
2646
|
+
function ie(e) {
|
|
2647
2647
|
return e && typeof e == "object" && "data" in e ? e.data : e;
|
|
2648
2648
|
}
|
|
2649
2649
|
class Yn {
|
|
@@ -2651,16 +2651,16 @@ class Yn {
|
|
|
2651
2651
|
// Chat client uses the default httpClient baseURL, no need for internal tracking
|
|
2652
2652
|
// unless we want to support multiple instances with different URLs in the future.
|
|
2653
2653
|
get baseUrl() {
|
|
2654
|
-
return
|
|
2654
|
+
return te.defaults.baseURL || "";
|
|
2655
2655
|
}
|
|
2656
2656
|
updateConfig(t) {
|
|
2657
2657
|
if (t.chatBaseUrl)
|
|
2658
|
-
|
|
2658
|
+
te.defaults.baseURL = t.chatBaseUrl;
|
|
2659
2659
|
else if (t.baseUrl) {
|
|
2660
2660
|
const n = t.baseUrl.replace(/\/+$/, "");
|
|
2661
|
-
|
|
2661
|
+
te.defaults.baseURL = n;
|
|
2662
2662
|
}
|
|
2663
|
-
t.apiKey !== void 0 ?
|
|
2663
|
+
t.apiKey !== void 0 ? ve(t.apiKey) : t.getToken && ve(t.getToken()), (t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0) && Wn({
|
|
2664
2664
|
requestTimeoutMs: t.requestTimeoutMs,
|
|
2665
2665
|
historyTimeoutMs: t.historyTimeoutMs
|
|
2666
2666
|
});
|
|
@@ -2670,14 +2670,14 @@ class Yn {
|
|
|
2670
2670
|
return Pt();
|
|
2671
2671
|
}
|
|
2672
2672
|
setAuthToken(t) {
|
|
2673
|
-
|
|
2673
|
+
ve(t);
|
|
2674
2674
|
}
|
|
2675
2675
|
onTokenChange(t) {
|
|
2676
2676
|
return _t(t);
|
|
2677
2677
|
}
|
|
2678
2678
|
// ---- Thread Management ----
|
|
2679
2679
|
async listThreads() {
|
|
2680
|
-
const t = await se("/threads"), n =
|
|
2680
|
+
const t = await se("/threads"), n = ie(t);
|
|
2681
2681
|
return (n == null ? void 0 : n.items) ?? (t == null ? void 0 : t.items) ?? [];
|
|
2682
2682
|
}
|
|
2683
2683
|
// listUsers moved to AuthApi
|
|
@@ -2685,32 +2685,32 @@ class Yn {
|
|
|
2685
2685
|
const r = {};
|
|
2686
2686
|
t && (r.title = t), n && (r.project = n);
|
|
2687
2687
|
const o = await Ze("/threads", Object.keys(r).length ? r : void 0);
|
|
2688
|
-
return
|
|
2688
|
+
return ie(o);
|
|
2689
2689
|
}
|
|
2690
2690
|
async updateThread(t, n) {
|
|
2691
2691
|
const r = await Xn(`/threads/${t}`, { title: n });
|
|
2692
|
-
return
|
|
2692
|
+
return ie(r);
|
|
2693
2693
|
}
|
|
2694
2694
|
async deleteThread(t) {
|
|
2695
2695
|
const n = await Qn(`/threads/${t}`);
|
|
2696
|
-
return
|
|
2696
|
+
return ie(n);
|
|
2697
2697
|
}
|
|
2698
2698
|
async threadInfo(t) {
|
|
2699
2699
|
const n = await se(`/threads/${t}/info`);
|
|
2700
|
-
return
|
|
2700
|
+
return ie(n);
|
|
2701
2701
|
}
|
|
2702
2702
|
// ---- Agents ----
|
|
2703
2703
|
async listAgents() {
|
|
2704
|
-
const t = await se("/agents"), n =
|
|
2704
|
+
const t = await se("/agents"), n = ie(t);
|
|
2705
2705
|
return (n == null ? void 0 : n.items) ?? [];
|
|
2706
2706
|
}
|
|
2707
2707
|
async getAgent(t) {
|
|
2708
2708
|
const n = await se(`/agents/${t}`);
|
|
2709
|
-
return
|
|
2709
|
+
return ie(n);
|
|
2710
2710
|
}
|
|
2711
2711
|
async getAgentSchema(t) {
|
|
2712
2712
|
const n = await se(`/agents/${t}/schema`);
|
|
2713
|
-
return
|
|
2713
|
+
return ie(n);
|
|
2714
2714
|
}
|
|
2715
2715
|
async getState(t) {
|
|
2716
2716
|
const n = await se(`/threads/${t.threadId}/state`, {
|
|
@@ -2719,7 +2719,7 @@ class Yn {
|
|
|
2719
2719
|
checkpoint_ns: t.checkpointNs
|
|
2720
2720
|
}
|
|
2721
2721
|
});
|
|
2722
|
-
return
|
|
2722
|
+
return ie(n);
|
|
2723
2723
|
}
|
|
2724
2724
|
async getStateHistory(t) {
|
|
2725
2725
|
const n = await se(`/threads/${t.threadId}/state/history`, {
|
|
@@ -2733,12 +2733,12 @@ class Yn {
|
|
|
2733
2733
|
timeout: Jn(),
|
|
2734
2734
|
signal: t.signal
|
|
2735
2735
|
});
|
|
2736
|
-
return
|
|
2736
|
+
return ie(n);
|
|
2737
2737
|
}
|
|
2738
2738
|
// ---- Run Management ----
|
|
2739
2739
|
async cancelRun(t) {
|
|
2740
2740
|
const n = await Ze(`/runs/${t}/cancel`);
|
|
2741
|
-
return
|
|
2741
|
+
return ie(n);
|
|
2742
2742
|
}
|
|
2743
2743
|
}
|
|
2744
2744
|
const zt = new Yn();
|
|
@@ -2820,14 +2820,14 @@ class er {
|
|
|
2820
2820
|
const n = t.baseUrl.replace(/\/+$/, "");
|
|
2821
2821
|
this._authBaseUrl = `${n}/auth`;
|
|
2822
2822
|
}
|
|
2823
|
-
t.apiKey !== void 0 ?
|
|
2823
|
+
t.apiKey !== void 0 ? ve(t.apiKey) : t.getToken && ve(t.getToken());
|
|
2824
2824
|
}
|
|
2825
2825
|
// ---- Token Management ----
|
|
2826
2826
|
getAuthToken() {
|
|
2827
2827
|
return Pt();
|
|
2828
2828
|
}
|
|
2829
2829
|
setAuthToken(t) {
|
|
2830
|
-
|
|
2830
|
+
ve(t);
|
|
2831
2831
|
}
|
|
2832
2832
|
onTokenChange(t) {
|
|
2833
2833
|
return _t(t);
|
|
@@ -2855,7 +2855,7 @@ function nr({ children: e, apiConfig: t }) {
|
|
|
2855
2855
|
fileApi: Rt,
|
|
2856
2856
|
baseUrl: n.baseUrl
|
|
2857
2857
|
};
|
|
2858
|
-
return /* @__PURE__ */
|
|
2858
|
+
return /* @__PURE__ */ ce(Lt.Provider, { value: o, children: e });
|
|
2859
2859
|
}
|
|
2860
2860
|
async function rr(e) {
|
|
2861
2861
|
return await new Promise((t, n) => {
|
|
@@ -3009,30 +3009,30 @@ function fr(e, t) {
|
|
|
3009
3009
|
return "type" in n || (n.type = e), n;
|
|
3010
3010
|
}
|
|
3011
3011
|
function pr(e = {}) {
|
|
3012
|
-
const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, o] =
|
|
3013
|
-
|
|
3012
|
+
const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, o] = D(e.token ?? null), s = H(e.headers ?? {}), a = e.credentials ?? "include", i = H(e);
|
|
3013
|
+
Q(() => {
|
|
3014
3014
|
i.current = e;
|
|
3015
3015
|
}, [e]);
|
|
3016
|
-
const d =
|
|
3017
|
-
var
|
|
3016
|
+
const d = N((m) => {
|
|
3017
|
+
var U, M, $, F, _, O, R, W, B, L;
|
|
3018
3018
|
const k = i.current;
|
|
3019
3019
|
if (!k) return;
|
|
3020
|
-
(
|
|
3021
|
-
}, []), [c, l] =
|
|
3020
|
+
(U = k.onEvent) == null || U.call(k, m), m.type === "thread_info" && ((M = k.onThreadInfo) == null || M.call(k, m)), m.type === "values" && (($ = k.handleValuesEvent) == null || $.call(k, m)), m.type === "metadata" && ((F = k.onMetadataEvent) == null || F.call(k, m)), typeof m.type == "string" && (m.type === "custom" || m.type.startsWith("custom.")) && ((_ = k.onCustomEvent) == null || _.call(k, m)), m.type === "updates" && ((O = k.onUpdateEvent) == null || O.call(k, m)), m.type === "tool.end" ? (R = k.onToolEnd) == null || R.call(k, m) : m.type === "tool.start" && ((W = k.onToolStart) == null || W.call(k, m)), m.type === "heartbeat" && ((B = k.onHeartbeat) == null || B.call(k, m)), m.type === "token" && ((L = k.onToken) == null || L.call(k, m.token));
|
|
3021
|
+
}, []), [c, l] = D(!1), [f, p] = D(null), [g, I] = D(!1), [u, v] = D(null), x = H(null), S = H(!0), A = H(null), w = N((m) => {
|
|
3022
3022
|
o(m);
|
|
3023
|
-
}, []), b =
|
|
3023
|
+
}, []), b = N(() => {
|
|
3024
3024
|
p(null), v(null);
|
|
3025
|
-
}, []),
|
|
3026
|
-
var
|
|
3025
|
+
}, []), y = N(() => {
|
|
3026
|
+
var M, $;
|
|
3027
3027
|
console.debug("[use-chat] stop() invoked - aborting stream");
|
|
3028
|
-
const m = (
|
|
3028
|
+
const m = (M = A.current) == null ? void 0 : M.threadId, k = ($ = A.current) == null ? void 0 : $.runId, E = () => {
|
|
3029
3029
|
var F;
|
|
3030
3030
|
(F = x.current) == null || F.abort(), x.current = null, A.current = null, l(!1), I(!1);
|
|
3031
3031
|
};
|
|
3032
3032
|
(k || m ? zt.cancelRun(k || m).catch((F) => {
|
|
3033
3033
|
console.warn("[use-chat] cancel run failed:", F);
|
|
3034
3034
|
}) : Promise.resolve()).finally(E);
|
|
3035
|
-
}, []), T =
|
|
3035
|
+
}, []), T = N(
|
|
3036
3036
|
(m) => {
|
|
3037
3037
|
x.current && (x.current.abort(), x.current = null);
|
|
3038
3038
|
const k = {
|
|
@@ -3052,7 +3052,7 @@ function pr(e = {}) {
|
|
|
3052
3052
|
l(!0), p(null), v(null);
|
|
3053
3053
|
const E = new AbortController();
|
|
3054
3054
|
x.current = E;
|
|
3055
|
-
let
|
|
3055
|
+
let U = null, M = !1;
|
|
3056
3056
|
return A.current = {
|
|
3057
3057
|
threadId: k.threadId ?? void 0,
|
|
3058
3058
|
runId: void 0,
|
|
@@ -3060,161 +3060,161 @@ function pr(e = {}) {
|
|
|
3060
3060
|
headers: {},
|
|
3061
3061
|
isStreaming: !0
|
|
3062
3062
|
}, (async () => {
|
|
3063
|
-
var
|
|
3063
|
+
var $, F, _, O, R, W;
|
|
3064
3064
|
try {
|
|
3065
|
-
let
|
|
3065
|
+
let B = {};
|
|
3066
3066
|
try {
|
|
3067
3067
|
if (r)
|
|
3068
|
-
|
|
3068
|
+
B = { Authorization: `Bearer ${r}` };
|
|
3069
3069
|
else if (typeof window < "u") {
|
|
3070
|
-
const
|
|
3071
|
-
let
|
|
3070
|
+
const ne = window.__AUTH_TOKEN__, me = (($ = window.localStorage) == null ? void 0 : $.getItem(ze.authToken)) || null;
|
|
3071
|
+
let X = null;
|
|
3072
3072
|
try {
|
|
3073
|
-
const
|
|
3074
|
-
|
|
3073
|
+
const ye = (F = window.localStorage) == null ? void 0 : F.getItem(ze.chatSettings);
|
|
3074
|
+
ye && (X = ((_ = JSON.parse(ye)) == null ? void 0 : _.apiKey) || null);
|
|
3075
3075
|
} catch {
|
|
3076
3076
|
}
|
|
3077
|
-
const
|
|
3078
|
-
|
|
3077
|
+
const Y = ne || me || X || null;
|
|
3078
|
+
Y && (B = { Authorization: `Bearer ${Y}` });
|
|
3079
3079
|
}
|
|
3080
3080
|
} catch {
|
|
3081
3081
|
}
|
|
3082
3082
|
console.debug("[use-chat] POST", t + n);
|
|
3083
|
-
let
|
|
3083
|
+
let L = {};
|
|
3084
3084
|
if (typeof window < "u")
|
|
3085
3085
|
try {
|
|
3086
|
-
const
|
|
3087
|
-
|
|
3086
|
+
const G = (O = window.localStorage) == null ? void 0 : O.getItem(ze.authSessionId);
|
|
3087
|
+
G && (L = { "X-Session-Id": G });
|
|
3088
3088
|
} catch {
|
|
3089
3089
|
}
|
|
3090
|
-
const
|
|
3091
|
-
...
|
|
3092
|
-
...
|
|
3090
|
+
const h = {
|
|
3091
|
+
...B,
|
|
3092
|
+
...L,
|
|
3093
3093
|
...s.current
|
|
3094
|
-
},
|
|
3094
|
+
}, j = {
|
|
3095
3095
|
"Content-Type": "application/json",
|
|
3096
3096
|
Accept: "text/event-stream",
|
|
3097
|
-
...
|
|
3098
|
-
},
|
|
3097
|
+
...h
|
|
3098
|
+
}, C = await fetch(t + n, {
|
|
3099
3099
|
method: "POST",
|
|
3100
|
-
headers:
|
|
3100
|
+
headers: j,
|
|
3101
3101
|
body: JSON.stringify(k),
|
|
3102
3102
|
signal: E.signal,
|
|
3103
3103
|
credentials: a
|
|
3104
3104
|
});
|
|
3105
|
-
if (A.current && (A.current.headers =
|
|
3106
|
-
const
|
|
3105
|
+
if (A.current && (A.current.headers = h), !C.ok || !C.body) {
|
|
3106
|
+
const G = await C.text().catch(() => "");
|
|
3107
3107
|
console.debug(
|
|
3108
3108
|
"[use-chat] non-OK response",
|
|
3109
|
-
|
|
3110
|
-
|
|
3109
|
+
C.status,
|
|
3110
|
+
G == null ? void 0 : G.slice(0, 500)
|
|
3111
3111
|
);
|
|
3112
|
-
const
|
|
3113
|
-
throw
|
|
3112
|
+
const ne = `stream ${C.status}${G ? ": " + G : ""}`;
|
|
3113
|
+
throw ne && (p(ne), U = "error"), new Error(ne);
|
|
3114
3114
|
}
|
|
3115
3115
|
I(!0);
|
|
3116
|
-
const
|
|
3116
|
+
const P = C.body.getReader(), J = new TextDecoder();
|
|
3117
3117
|
let K = "", V = 0, ee = Date.now();
|
|
3118
|
-
const
|
|
3119
|
-
Date.now() - ee > 18e5 && (p("Stream idle timeout"),
|
|
3120
|
-
}, 5e3),
|
|
3118
|
+
const ae = setInterval(() => {
|
|
3119
|
+
Date.now() - ee > 18e5 && (p("Stream idle timeout"), U = "error", E.abort());
|
|
3120
|
+
}, 5e3), ge = 1024 * 1024;
|
|
3121
3121
|
try {
|
|
3122
|
-
const
|
|
3122
|
+
const G = C.headers.get("X-Thread-Id") || C.headers.get("x-thread-id"), ne = C.headers.get("X-Run-Id") || C.headers.get("x-run-id");
|
|
3123
3123
|
for (A.current && (A.current = {
|
|
3124
3124
|
...A.current,
|
|
3125
|
-
threadId:
|
|
3126
|
-
runId:
|
|
3125
|
+
threadId: G ?? A.current.threadId,
|
|
3126
|
+
runId: ne ?? A.current.runId
|
|
3127
3127
|
}); ; ) {
|
|
3128
|
-
const { value:
|
|
3129
|
-
if (
|
|
3130
|
-
K +=
|
|
3131
|
-
let
|
|
3132
|
-
for (; (
|
|
3128
|
+
const { value: me, done: X } = await P.read();
|
|
3129
|
+
if (X) break;
|
|
3130
|
+
K += J.decode(me, { stream: !0 }), K.length > ge && (K = "", console.warn("Stream buffer reset: exceeded 1MB"));
|
|
3131
|
+
let Y;
|
|
3132
|
+
for (; (Y = K.indexOf(`
|
|
3133
3133
|
|
|
3134
3134
|
`)) >= 0; ) {
|
|
3135
|
-
const
|
|
3136
|
-
K = K.slice(
|
|
3137
|
-
const
|
|
3138
|
-
let
|
|
3139
|
-
for (const
|
|
3140
|
-
if (!
|
|
3141
|
-
if (
|
|
3142
|
-
const Ae =
|
|
3143
|
-
Ae && (
|
|
3135
|
+
const ye = K.slice(0, Y);
|
|
3136
|
+
K = K.slice(Y + 2);
|
|
3137
|
+
const Ve = ye.split(/\r?\n/), he = [];
|
|
3138
|
+
let Pe = null;
|
|
3139
|
+
for (const xe of Ve)
|
|
3140
|
+
if (!xe.startsWith(":") && xe) {
|
|
3141
|
+
if (xe.startsWith("event:")) {
|
|
3142
|
+
const Ae = xe.slice(6).trim();
|
|
3143
|
+
Ae && (Pe = Ae);
|
|
3144
3144
|
continue;
|
|
3145
3145
|
}
|
|
3146
|
-
if (
|
|
3147
|
-
const Ae =
|
|
3148
|
-
|
|
3146
|
+
if (xe.startsWith("data:")) {
|
|
3147
|
+
const Ae = xe.slice(5);
|
|
3148
|
+
he.push(Ae.startsWith(" ") ? Ae.slice(1) : Ae);
|
|
3149
3149
|
}
|
|
3150
3150
|
}
|
|
3151
|
-
const
|
|
3151
|
+
const be = he.join(`
|
|
3152
3152
|
`);
|
|
3153
|
-
if (!
|
|
3153
|
+
if (!be) continue;
|
|
3154
3154
|
let oe;
|
|
3155
3155
|
try {
|
|
3156
|
-
oe = JSON.parse(
|
|
3156
|
+
oe = JSON.parse(be);
|
|
3157
3157
|
} catch {
|
|
3158
|
-
console.debug("[use-chat] malformed SSE:",
|
|
3158
|
+
console.debug("[use-chat] malformed SSE:", be.slice(0, 200));
|
|
3159
3159
|
continue;
|
|
3160
3160
|
}
|
|
3161
|
-
oe = fr(
|
|
3162
|
-
const
|
|
3163
|
-
if (!
|
|
3161
|
+
oe = fr(Pe, oe);
|
|
3162
|
+
const Ue = cr(oe) ? oe.data : oe;
|
|
3163
|
+
if (!Ue) {
|
|
3164
3164
|
console.warn("[use-chat] dropped envelope event without payload", oe);
|
|
3165
3165
|
continue;
|
|
3166
3166
|
}
|
|
3167
|
-
const
|
|
3167
|
+
const re = $n(Ue);
|
|
3168
3168
|
ee = Date.now();
|
|
3169
|
-
const
|
|
3170
|
-
if (
|
|
3171
|
-
if (
|
|
3172
|
-
console.debug("[use-chat] drop duplicate/out-of-order event", { seq:
|
|
3169
|
+
const we = typeof re.seq == "number" ? re.seq : void 0;
|
|
3170
|
+
if (we !== void 0) {
|
|
3171
|
+
if (we <= V) {
|
|
3172
|
+
console.debug("[use-chat] drop duplicate/out-of-order event", { seq: we, lastProcessedSeq: V, type: re.type });
|
|
3173
3173
|
continue;
|
|
3174
3174
|
}
|
|
3175
|
-
V =
|
|
3175
|
+
V = we;
|
|
3176
3176
|
}
|
|
3177
|
-
d(
|
|
3177
|
+
d(re);
|
|
3178
3178
|
}
|
|
3179
3179
|
}
|
|
3180
|
-
|
|
3181
|
-
} catch (
|
|
3182
|
-
if (
|
|
3183
|
-
|
|
3180
|
+
U === null && !E.signal.aborted && (U = "complete");
|
|
3181
|
+
} catch (G) {
|
|
3182
|
+
if (G.name === "AbortError")
|
|
3183
|
+
U = U ?? "aborted";
|
|
3184
3184
|
else {
|
|
3185
|
-
const
|
|
3186
|
-
|
|
3185
|
+
const ne = G.message || String(G);
|
|
3186
|
+
U = "error", p(ne);
|
|
3187
3187
|
}
|
|
3188
3188
|
} finally {
|
|
3189
3189
|
try {
|
|
3190
|
-
await
|
|
3190
|
+
await P.cancel();
|
|
3191
3191
|
} catch {
|
|
3192
3192
|
} finally {
|
|
3193
|
-
(
|
|
3193
|
+
(R = P.releaseLock) == null || R.call(P);
|
|
3194
3194
|
}
|
|
3195
|
-
clearInterval(
|
|
3195
|
+
clearInterval(ae);
|
|
3196
3196
|
}
|
|
3197
|
-
} catch (
|
|
3198
|
-
if (
|
|
3199
|
-
|
|
3197
|
+
} catch (B) {
|
|
3198
|
+
if (B.name === "AbortError")
|
|
3199
|
+
U = U ?? "aborted";
|
|
3200
3200
|
else {
|
|
3201
|
-
const
|
|
3202
|
-
|
|
3201
|
+
const L = B.message || String(B);
|
|
3202
|
+
U = "error", p(L), M || (M = !0, (W = e.onConnectionError) == null || W.call(e, L));
|
|
3203
3203
|
}
|
|
3204
3204
|
} finally {
|
|
3205
3205
|
try {
|
|
3206
3206
|
if (e.onFinish) {
|
|
3207
|
-
const
|
|
3207
|
+
const B = {
|
|
3208
3208
|
lastSeq: 0,
|
|
3209
3209
|
lastCheckpointId: null,
|
|
3210
3210
|
lastCheckpointNs: null,
|
|
3211
3211
|
lastValues: null
|
|
3212
3212
|
// Let the reducer/history hook provide the final values
|
|
3213
3213
|
};
|
|
3214
|
-
e.onFinish(
|
|
3214
|
+
e.onFinish(B);
|
|
3215
3215
|
}
|
|
3216
|
-
} catch (
|
|
3217
|
-
console.warn("[use-chat] onClosed callback failed",
|
|
3216
|
+
} catch (B) {
|
|
3217
|
+
console.warn("[use-chat] onClosed callback failed", B);
|
|
3218
3218
|
}
|
|
3219
3219
|
l(!1), I(!1), x.current = null, A.current = null;
|
|
3220
3220
|
}
|
|
@@ -3222,9 +3222,9 @@ function pr(e = {}) {
|
|
|
3222
3222
|
},
|
|
3223
3223
|
[t, n, r, e, d]
|
|
3224
3224
|
);
|
|
3225
|
-
return
|
|
3225
|
+
return Q(() => () => {
|
|
3226
3226
|
var m;
|
|
3227
|
-
|
|
3227
|
+
S.current = !1, (m = x.current) == null || m.abort();
|
|
3228
3228
|
}, []), {
|
|
3229
3229
|
isStreaming: c,
|
|
3230
3230
|
error: f,
|
|
@@ -3238,7 +3238,7 @@ function pr(e = {}) {
|
|
|
3238
3238
|
lastSeq: 0,
|
|
3239
3239
|
connected: g,
|
|
3240
3240
|
stream: T,
|
|
3241
|
-
stop:
|
|
3241
|
+
stop: y,
|
|
3242
3242
|
clear: b,
|
|
3243
3243
|
setToken: w,
|
|
3244
3244
|
values: {},
|
|
@@ -3259,33 +3259,33 @@ function gr({
|
|
|
3259
3259
|
onThreadChange: r,
|
|
3260
3260
|
onCurrentThreadDeleted: o
|
|
3261
3261
|
}) {
|
|
3262
|
-
const [s, a] =
|
|
3263
|
-
|
|
3262
|
+
const [s, a] = D([]), [i, d] = D(t), [c, l] = D(!1), [f, p] = D(null), g = H(i), I = H(/* @__PURE__ */ new Map());
|
|
3263
|
+
Q(() => {
|
|
3264
3264
|
g.current = i;
|
|
3265
|
-
}, [i]),
|
|
3265
|
+
}, [i]), Q(() => {
|
|
3266
3266
|
t !== void 0 && t !== g.current && d(t);
|
|
3267
3267
|
}, [t]);
|
|
3268
|
-
const u =
|
|
3268
|
+
const u = N(async () => {
|
|
3269
3269
|
l(!0), p(null);
|
|
3270
3270
|
try {
|
|
3271
3271
|
const b = await e.listThreads();
|
|
3272
3272
|
a(b ?? []);
|
|
3273
3273
|
} catch (b) {
|
|
3274
|
-
const
|
|
3275
|
-
p(
|
|
3274
|
+
const y = String(b);
|
|
3275
|
+
p(y), n == null || n(y);
|
|
3276
3276
|
} finally {
|
|
3277
3277
|
l(!1);
|
|
3278
3278
|
}
|
|
3279
3279
|
}, [e, n]);
|
|
3280
|
-
|
|
3280
|
+
Q(() => {
|
|
3281
3281
|
u();
|
|
3282
|
-
}, [u]),
|
|
3282
|
+
}, [u]), Q(() => {
|
|
3283
3283
|
r == null || r(i);
|
|
3284
3284
|
}, [i, r]);
|
|
3285
|
-
const v =
|
|
3286
|
-
async (b,
|
|
3285
|
+
const v = N(
|
|
3286
|
+
async (b, y) => {
|
|
3287
3287
|
try {
|
|
3288
|
-
const T =
|
|
3288
|
+
const T = y && typeof y == "object" ? { id: y.id, name: y.name ?? "" } : void 0, m = await e.createThread(b, T);
|
|
3289
3289
|
return d(m.threadId), await u(), m.threadId;
|
|
3290
3290
|
} catch (T) {
|
|
3291
3291
|
const m = String(T);
|
|
@@ -3293,16 +3293,16 @@ function gr({
|
|
|
3293
3293
|
}
|
|
3294
3294
|
},
|
|
3295
3295
|
[e, n, u]
|
|
3296
|
-
), x =
|
|
3296
|
+
), x = N(
|
|
3297
3297
|
async (b) => {
|
|
3298
|
-
const
|
|
3298
|
+
const y = s;
|
|
3299
3299
|
a((m) => m.filter((k) => k.threadId !== b));
|
|
3300
3300
|
const T = new AbortController();
|
|
3301
3301
|
I.current.set(b, T);
|
|
3302
3302
|
try {
|
|
3303
3303
|
await e.deleteThread(b), g.current === b && (d(null), o == null || o());
|
|
3304
3304
|
} catch (m) {
|
|
3305
|
-
a(
|
|
3305
|
+
a(y);
|
|
3306
3306
|
const k = String(m);
|
|
3307
3307
|
n == null || n(k);
|
|
3308
3308
|
} finally {
|
|
@@ -3310,26 +3310,26 @@ function gr({
|
|
|
3310
3310
|
}
|
|
3311
3311
|
},
|
|
3312
3312
|
[e, o, n, s]
|
|
3313
|
-
),
|
|
3314
|
-
async (b,
|
|
3313
|
+
), S = N(
|
|
3314
|
+
async (b, y) => {
|
|
3315
3315
|
try {
|
|
3316
|
-
await e.updateThread(b,
|
|
3316
|
+
await e.updateThread(b, y), await u();
|
|
3317
3317
|
} catch (T) {
|
|
3318
3318
|
n == null || n(String(T));
|
|
3319
3319
|
}
|
|
3320
3320
|
},
|
|
3321
3321
|
[e, n, u]
|
|
3322
|
-
), A =
|
|
3322
|
+
), A = Z(
|
|
3323
3323
|
() => ({
|
|
3324
3324
|
createThread: v,
|
|
3325
3325
|
deleteThread: x,
|
|
3326
|
-
renameThread:
|
|
3326
|
+
renameThread: S,
|
|
3327
3327
|
refreshThreads: u
|
|
3328
3328
|
}),
|
|
3329
|
-
[v, x,
|
|
3330
|
-
), w =
|
|
3329
|
+
[v, x, S, u]
|
|
3330
|
+
), w = N((b) => {
|
|
3331
3331
|
if (!(b != null && b.threadId)) return;
|
|
3332
|
-
const
|
|
3332
|
+
const y = {
|
|
3333
3333
|
threadId: b.threadId,
|
|
3334
3334
|
title: b.title || `Thread ${b.threadId.slice(0, 8)}`,
|
|
3335
3335
|
project: b.project,
|
|
@@ -3339,14 +3339,14 @@ function gr({
|
|
|
3339
3339
|
};
|
|
3340
3340
|
a((T) => {
|
|
3341
3341
|
let m = !1;
|
|
3342
|
-
const k = T.map((E) => E.threadId ===
|
|
3342
|
+
const k = T.map((E) => E.threadId === y.threadId ? (m = !0, console.debug("[useThreadsState] thread_info: updating existing thread", y.threadId), {
|
|
3343
3343
|
...E,
|
|
3344
|
-
title:
|
|
3345
|
-
project:
|
|
3346
|
-
updatedAt:
|
|
3347
|
-
messageCount:
|
|
3344
|
+
title: y.title ?? E.title,
|
|
3345
|
+
project: y.project ?? E.project,
|
|
3346
|
+
updatedAt: y.updatedAt ?? E.updatedAt,
|
|
3347
|
+
messageCount: y.messageCount ?? E.messageCount
|
|
3348
3348
|
}) : E);
|
|
3349
|
-
return m ? k : (console.debug("[useThreadsState] thread_info: adding thread to list",
|
|
3349
|
+
return m ? k : (console.debug("[useThreadsState] thread_info: adding thread to list", y.threadId), [y, ...T]);
|
|
3350
3350
|
});
|
|
3351
3351
|
}, []);
|
|
3352
3352
|
return {
|
|
@@ -3381,7 +3381,7 @@ function mr({
|
|
|
3381
3381
|
initialThreadId: t,
|
|
3382
3382
|
onError: n,
|
|
3383
3383
|
onThreadChange: r
|
|
3384
|
-
}), g =
|
|
3384
|
+
}), g = Z(
|
|
3385
3385
|
() => ({
|
|
3386
3386
|
threads: s,
|
|
3387
3387
|
currentThreadId: a,
|
|
@@ -3403,7 +3403,7 @@ function mr({
|
|
|
3403
3403
|
p
|
|
3404
3404
|
]
|
|
3405
3405
|
);
|
|
3406
|
-
return /* @__PURE__ */
|
|
3406
|
+
return /* @__PURE__ */ ce(Ut.Provider, { value: g, children: e });
|
|
3407
3407
|
}
|
|
3408
3408
|
function ot(e) {
|
|
3409
3409
|
const t = je(Ut);
|
|
@@ -3442,7 +3442,7 @@ function hr(e, t, n) {
|
|
|
3442
3442
|
return !!((o == null ? void 0 : o.id) === t || n && r.toolCallId === n);
|
|
3443
3443
|
}) ?? null;
|
|
3444
3444
|
}
|
|
3445
|
-
function
|
|
3445
|
+
function Fe(e) {
|
|
3446
3446
|
const t = /* @__PURE__ */ new Set();
|
|
3447
3447
|
return e.map((n) => nt(n)).filter((n) => !n || t.has(n.id) ? !1 : (t.add(n.id), !0));
|
|
3448
3448
|
}
|
|
@@ -3481,21 +3481,23 @@ function wr(e, t) {
|
|
|
3481
3481
|
case "reset":
|
|
3482
3482
|
return {
|
|
3483
3483
|
...Ot,
|
|
3484
|
-
messages:
|
|
3484
|
+
messages: Fe(((n = t.payload) == null ? void 0 : n.messages) ?? [])
|
|
3485
3485
|
};
|
|
3486
3486
|
case "user_message": {
|
|
3487
3487
|
const { message: r, editingMessageId: o } = t.payload;
|
|
3488
3488
|
if (o) {
|
|
3489
|
-
const s = e.messages.findIndex((a) => a.id === o);
|
|
3490
|
-
if (s !== -1)
|
|
3489
|
+
const s = e.messages.findIndex((a) => (a.id || a.messageId || a.id) === o);
|
|
3490
|
+
if (s !== -1) {
|
|
3491
|
+
const a = e.messages[s], i = { ...r, id: o };
|
|
3491
3492
|
return {
|
|
3492
3493
|
...e,
|
|
3493
3494
|
status: "streaming",
|
|
3494
|
-
messages: [...e.messages.slice(0, s),
|
|
3495
|
+
messages: [...e.messages.slice(0, s), i],
|
|
3495
3496
|
assemblingId: null,
|
|
3496
|
-
lastCheckpointId: null,
|
|
3497
|
+
lastCheckpointId: a.checkpointId || e.lastCheckpointId || null,
|
|
3497
3498
|
error: null
|
|
3498
3499
|
};
|
|
3500
|
+
}
|
|
3499
3501
|
}
|
|
3500
3502
|
return {
|
|
3501
3503
|
...e,
|
|
@@ -3507,7 +3509,7 @@ function wr(e, t) {
|
|
|
3507
3509
|
};
|
|
3508
3510
|
}
|
|
3509
3511
|
case "seed": {
|
|
3510
|
-
const r =
|
|
3512
|
+
const r = Fe(t.payload.messages), o = {
|
|
3511
3513
|
...e,
|
|
3512
3514
|
status: "idle",
|
|
3513
3515
|
messages: r,
|
|
@@ -3519,7 +3521,7 @@ function wr(e, t) {
|
|
|
3519
3521
|
return Object.prototype.hasOwnProperty.call(t.payload, "checkpointId") && (o.lastCheckpointId = t.payload.checkpointId ?? null), Object.prototype.hasOwnProperty.call(t.payload, "checkpointNs") && (o.lastCheckpointNs = t.payload.checkpointNs ?? null), Object.prototype.hasOwnProperty.call(t.payload, "values") && (o.values = t.payload.values ?? {}), o;
|
|
3520
3522
|
}
|
|
3521
3523
|
case "prepend": {
|
|
3522
|
-
const r =
|
|
3524
|
+
const r = Fe(t.payload.messages);
|
|
3523
3525
|
if (!r.length) return e;
|
|
3524
3526
|
const o = new Set(e.messages.map((a) => a.id)), s = r.filter((a) => !o.has(a.id));
|
|
3525
3527
|
return s.length ? { ...e, messages: [...s, ...e.messages] } : e;
|
|
@@ -3535,15 +3537,15 @@ function wr(e, t) {
|
|
|
3535
3537
|
}
|
|
3536
3538
|
}
|
|
3537
3539
|
function kr(e = []) {
|
|
3538
|
-
const [t, n] = Wt(wr, { ...Ot, messages: e }), r =
|
|
3540
|
+
const [t, n] = Wt(wr, { ...Ot, messages: e }), r = H([]), o = H(null), s = N(() => {
|
|
3539
3541
|
o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), o.current = null;
|
|
3540
3542
|
const c = r.current;
|
|
3541
3543
|
c.length && (r.current = [], n({ type: "batch", payload: { events: c } }));
|
|
3542
|
-
}, []), a =
|
|
3544
|
+
}, []), a = N(() => {
|
|
3543
3545
|
typeof window < "u" && typeof window.requestAnimationFrame == "function" ? o.current === null && (o.current = window.requestAnimationFrame(() => s())) : setTimeout(s, 8);
|
|
3544
|
-
}, [s]), i =
|
|
3546
|
+
}, [s]), i = N((c) => {
|
|
3545
3547
|
r.current.push(c), a();
|
|
3546
|
-
}, [a]), d =
|
|
3548
|
+
}, [a]), d = Z(() => ({
|
|
3547
3549
|
setStatus: (c, l) => n({ type: "status", payload: { status: c, error: l } }),
|
|
3548
3550
|
reset: (c) => n({ type: "reset", payload: { messages: c } }),
|
|
3549
3551
|
seed: (c, l) => n({ type: "seed", payload: { messages: c, ...l ?? {} } }),
|
|
@@ -3586,7 +3588,7 @@ function pt(e, t) {
|
|
|
3586
3588
|
const s = t, a = s.values && typeof s.values == "object" ? { ...s.values } : {}, i = Array.isArray(s.messages) ? s.messages : Array.isArray(a.messages) ? a.messages : [];
|
|
3587
3589
|
if (!i.length && Object.keys(a).length === 0)
|
|
3588
3590
|
return e;
|
|
3589
|
-
const d =
|
|
3591
|
+
const d = Fe(i);
|
|
3590
3592
|
delete a.messages;
|
|
3591
3593
|
let c = e.lastCheckpointId, l = e.lastCheckpointNs;
|
|
3592
3594
|
const f = s.config || s.checkpoint, p = (f == null ? void 0 : f.configurable) || f;
|
|
@@ -3651,7 +3653,7 @@ function pt(e, t) {
|
|
|
3651
3653
|
return t.type === "message.start" ? { ...e, assemblingId: t.id, status: "streaming" } : t.type === "message.end" ? { ...e, assemblingId: null } : t.type === "tool.start" ? { ...vr(e, t, o), status: "streaming" } : t.type === "tool.progress" ? xr(e, t, o) : t.type === "tool.end" ? Ar(e, t, o) : t.type === "artifact.update" ? Tr(e, t) : e;
|
|
3652
3654
|
}
|
|
3653
3655
|
function Ir(e, t, n) {
|
|
3654
|
-
var g, I, u, v, x,
|
|
3656
|
+
var g, I, u, v, x, S, A;
|
|
3655
3657
|
const r = t.messages;
|
|
3656
3658
|
if (!r.length)
|
|
3657
3659
|
return console.warn("[messagesReducer] Dropping messages/partial event without messages[]", t), e;
|
|
@@ -3694,7 +3696,7 @@ function Ir(e, t, n) {
|
|
|
3694
3696
|
[s]: {
|
|
3695
3697
|
...((u = e.messagesStreamMeta) == null ? void 0 : u[s]) ?? {},
|
|
3696
3698
|
lastSeq: t.seq ?? ((x = (v = e.messagesStreamMeta) == null ? void 0 : v[s]) == null ? void 0 : x.lastSeq) ?? null,
|
|
3697
|
-
lastText: d || (((A = (
|
|
3699
|
+
lastText: d || (((A = (S = e.messagesStreamMeta) == null ? void 0 : S[s]) == null ? void 0 : A.lastText) ?? "")
|
|
3698
3700
|
}
|
|
3699
3701
|
}
|
|
3700
3702
|
};
|
|
@@ -3761,7 +3763,7 @@ function xr(e, t, n) {
|
|
|
3761
3763
|
let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
|
|
3762
3764
|
const a = st(s, r);
|
|
3763
3765
|
if (a !== -1) {
|
|
3764
|
-
const i = s[a], d =
|
|
3766
|
+
const i = s[a], d = le(t.content), c = (i.toolCalls || []).map(
|
|
3765
3767
|
(l) => l.id === r ? { ...l, content: typeof d == "string" ? d : l.content } : l
|
|
3766
3768
|
);
|
|
3767
3769
|
s[a] = {
|
|
@@ -3782,7 +3784,7 @@ function Ar(e, t, n) {
|
|
|
3782
3784
|
if (!r) return e;
|
|
3783
3785
|
const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
|
|
3784
3786
|
let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
|
|
3785
|
-
const a = st(s, r), i =
|
|
3787
|
+
const a = st(s, r), i = le(t.content ?? t.error);
|
|
3786
3788
|
if (a !== -1) {
|
|
3787
3789
|
const c = s[a], l = (c.toolCalls || []).map(
|
|
3788
3790
|
(f) => f.id === r ? {
|
|
@@ -3830,7 +3832,7 @@ function Re(e) {
|
|
|
3830
3832
|
if (!(!e || typeof e != "object" || Array.isArray(e)))
|
|
3831
3833
|
return { ...e };
|
|
3832
3834
|
}
|
|
3833
|
-
function
|
|
3835
|
+
function Be(e, t) {
|
|
3834
3836
|
if (e)
|
|
3835
3837
|
for (const n of t) {
|
|
3836
3838
|
const r = e[n];
|
|
@@ -3855,7 +3857,7 @@ function gt(e) {
|
|
|
3855
3857
|
async function Mr(e, t) {
|
|
3856
3858
|
var i, d;
|
|
3857
3859
|
if (!e) return e ?? null;
|
|
3858
|
-
const n =
|
|
3860
|
+
const n = de(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], o = /* @__PURE__ */ new Set();
|
|
3859
3861
|
for (const c of r) {
|
|
3860
3862
|
const l = (i = c == null ? void 0 : c.values) == null ? void 0 : i.messages;
|
|
3861
3863
|
if (Array.isArray(l))
|
|
@@ -3874,7 +3876,7 @@ async function Mr(e, t) {
|
|
|
3874
3876
|
const s = await Promise.all(
|
|
3875
3877
|
Array.from(o).map(async (c) => {
|
|
3876
3878
|
try {
|
|
3877
|
-
const l = await t.getFileInfo(c), f =
|
|
3879
|
+
const l = await t.getFileInfo(c), f = de(l);
|
|
3878
3880
|
return [c, f];
|
|
3879
3881
|
} catch {
|
|
3880
3882
|
return [c, null];
|
|
@@ -3899,7 +3901,7 @@ async function Mr(e, t) {
|
|
|
3899
3901
|
return n;
|
|
3900
3902
|
}
|
|
3901
3903
|
function mt(e) {
|
|
3902
|
-
const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((s, a) => Cr(
|
|
3904
|
+
const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((s, a) => Cr(de(s), a)).filter((s) => !!s)].sort((s, a) => yt(a.createdAt) - yt(s.createdAt)), o = r[0] ?? null;
|
|
3903
3905
|
return {
|
|
3904
3906
|
threadId: (e == null ? void 0 : e.threadId) ?? "",
|
|
3905
3907
|
latest: o,
|
|
@@ -3908,13 +3910,13 @@ function mt(e) {
|
|
|
3908
3910
|
};
|
|
3909
3911
|
}
|
|
3910
3912
|
function Cr(e, t) {
|
|
3911
|
-
var b,
|
|
3913
|
+
var b, y;
|
|
3912
3914
|
if (!e) return null;
|
|
3913
|
-
const n = ((b = e.values) == null ? void 0 : b.activeAgent) ?? null, r = (
|
|
3915
|
+
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((T) => Er(T, n)).filter((T) => !!T), a = Re(e.metadata) ?? {}, i = gt(e.config), d = Re(e.parentConfig), c = gt(d), l = Be(i, ["checkpointId"]), f = Be(i, ["checkpointNs"]), p = Be(c, ["checkpointId"]), g = Re(e.config), I = Array.isArray(e.tasks) ? e.tasks.map((T) => ({ ...T })) : e.tasks ?? null, u = 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(), x = {
|
|
3914
3916
|
...a,
|
|
3915
3917
|
step: Sr(a, ["step"]) ?? 0,
|
|
3916
|
-
source:
|
|
3917
|
-
},
|
|
3918
|
+
source: Be(a, ["source"]) ?? null
|
|
3919
|
+
}, S = s.map((T) => ({
|
|
3918
3920
|
...T,
|
|
3919
3921
|
checkpointId: T.checkpointId ?? l ?? null,
|
|
3920
3922
|
checkpointNs: T.checkpointNs ?? f ?? null
|
|
@@ -3924,7 +3926,7 @@ function Cr(e, t) {
|
|
|
3924
3926
|
checkpointNs: f ?? null,
|
|
3925
3927
|
createdAt: v,
|
|
3926
3928
|
parentId: p ?? null,
|
|
3927
|
-
messages:
|
|
3929
|
+
messages: S,
|
|
3928
3930
|
interrupt: Pr(
|
|
3929
3931
|
w,
|
|
3930
3932
|
t,
|
|
@@ -3981,9 +3983,9 @@ function zr(e) {
|
|
|
3981
3983
|
for (let c = 0; c < e.length; c++) {
|
|
3982
3984
|
const l = e[c], f = l.checkpointId, p = f ?? `cp-${c}`, g = l.metadata ?? {}, I = typeof g.step == "number" ? g.step : null, u = typeof g.source == "string" ? g.source : null;
|
|
3983
3985
|
let v = null, x = null;
|
|
3984
|
-
const
|
|
3985
|
-
for (const
|
|
3986
|
-
|
|
3986
|
+
const S = Array.isArray(l.messages) ? l.messages : [];
|
|
3987
|
+
for (const y of S)
|
|
3988
|
+
y.role === "user" && (x || (x = y), y.id && (v = y.id));
|
|
3987
3989
|
const A = l.next && l.next.length > 0 ? String(l.next[0]) : null, w = l.parentConfig ?? null, b = {
|
|
3988
3990
|
id: p,
|
|
3989
3991
|
step: I,
|
|
@@ -3996,8 +3998,8 @@ function zr(e) {
|
|
|
3996
3998
|
userMessageId: v
|
|
3997
3999
|
};
|
|
3998
4000
|
if (o.push(b), f && t.set(f, b), f && x) {
|
|
3999
|
-
const
|
|
4000
|
-
|
|
4001
|
+
const y = Nr(x);
|
|
4002
|
+
y && r.set(f, y);
|
|
4001
4003
|
}
|
|
4002
4004
|
n.push({
|
|
4003
4005
|
id: p,
|
|
@@ -4067,7 +4069,7 @@ function uo(e, t, n) {
|
|
|
4067
4069
|
};
|
|
4068
4070
|
}
|
|
4069
4071
|
function Rr(e) {
|
|
4070
|
-
return
|
|
4072
|
+
return Z(() => zr(e), [e]);
|
|
4071
4073
|
}
|
|
4072
4074
|
function $t({
|
|
4073
4075
|
api: e,
|
|
@@ -4079,108 +4081,108 @@ function $t({
|
|
|
4079
4081
|
isStreaming: a,
|
|
4080
4082
|
getMessages: i
|
|
4081
4083
|
}) {
|
|
4082
|
-
const [d, c] =
|
|
4084
|
+
const [d, c] = D(null), f = Z(
|
|
4083
4085
|
() => mt(d),
|
|
4084
4086
|
[d]
|
|
4085
|
-
).checkpoints, p = Rr(f), g = p.timeline, [I, u] =
|
|
4086
|
-
|
|
4087
|
-
|
|
4087
|
+
).checkpoints, p = Rr(f), g = p.timeline, [I, u] = D(!1), [v, x] = D(!1), [S, A] = D(!1), [w, b] = D(null), y = H(o), T = H(null), m = H(null);
|
|
4088
|
+
Q(() => {
|
|
4089
|
+
y.current = o;
|
|
4088
4090
|
}, [o]);
|
|
4089
|
-
const k =
|
|
4090
|
-
async (
|
|
4091
|
-
const
|
|
4092
|
-
threadId:
|
|
4093
|
-
checkpointId:
|
|
4094
|
-
checkpointNs:
|
|
4095
|
-
}),
|
|
4091
|
+
const k = N(
|
|
4092
|
+
async (_) => {
|
|
4093
|
+
const O = await e.getState({
|
|
4094
|
+
threadId: _.threadId,
|
|
4095
|
+
checkpointId: _.checkpointId,
|
|
4096
|
+
checkpointNs: _.checkpointNs
|
|
4097
|
+
}), R = {
|
|
4096
4098
|
version: "values@1",
|
|
4097
|
-
threadId:
|
|
4098
|
-
checkpoints: [
|
|
4099
|
-
},
|
|
4100
|
-
return
|
|
4099
|
+
threadId: _.threadId,
|
|
4100
|
+
checkpoints: [O]
|
|
4101
|
+
}, W = t ? await Mr(R, t) : R, { latest: B } = mt(W);
|
|
4102
|
+
return B;
|
|
4101
4103
|
},
|
|
4102
4104
|
[e, t]
|
|
4103
|
-
), E =
|
|
4104
|
-
async (
|
|
4105
|
-
var
|
|
4106
|
-
if (!
|
|
4107
|
-
const
|
|
4108
|
-
if (T.current ===
|
|
4109
|
-
(
|
|
4110
|
-
const
|
|
4111
|
-
m.current =
|
|
4105
|
+
), E = N(
|
|
4106
|
+
async (_, O) => {
|
|
4107
|
+
var B;
|
|
4108
|
+
if (!_) return;
|
|
4109
|
+
const R = `${_}:${O ?? "latest"}`;
|
|
4110
|
+
if (T.current === R || I) return;
|
|
4111
|
+
(B = m.current) == null || B.abort();
|
|
4112
|
+
const W = new AbortController();
|
|
4113
|
+
m.current = W, u(!0), b(null);
|
|
4112
4114
|
try {
|
|
4113
|
-
const
|
|
4114
|
-
threadId:
|
|
4115
|
-
checkpointId:
|
|
4115
|
+
const L = await k({
|
|
4116
|
+
threadId: _,
|
|
4117
|
+
checkpointId: O ?? void 0
|
|
4116
4118
|
});
|
|
4117
|
-
if (
|
|
4119
|
+
if (y.current !== _) {
|
|
4118
4120
|
u(!1);
|
|
4119
4121
|
return;
|
|
4120
4122
|
}
|
|
4121
|
-
n((
|
|
4122
|
-
checkpointId: (
|
|
4123
|
-
checkpointNs: (
|
|
4124
|
-
pendingInterrupt: (
|
|
4125
|
-
values:
|
|
4126
|
-
}), T.current =
|
|
4123
|
+
n((L == null ? void 0 : L.messages) ?? [], {
|
|
4124
|
+
checkpointId: (L == null ? void 0 : L.checkpointId) ?? null,
|
|
4125
|
+
checkpointNs: (L == null ? void 0 : L.checkpointNs) ?? null,
|
|
4126
|
+
pendingInterrupt: (L == null ? void 0 : L.interrupt) ?? null,
|
|
4127
|
+
values: L == null ? void 0 : L.values
|
|
4128
|
+
}), T.current = R, u(!1), A(!0);
|
|
4127
4129
|
try {
|
|
4128
|
-
const
|
|
4129
|
-
threadId:
|
|
4130
|
+
const h = await e.getStateHistory({
|
|
4131
|
+
threadId: _,
|
|
4130
4132
|
limit: 100,
|
|
4131
4133
|
includeMessages: !1
|
|
4132
4134
|
});
|
|
4133
|
-
|
|
4135
|
+
y.current === _ && c(h);
|
|
4134
4136
|
} finally {
|
|
4135
4137
|
A(!1);
|
|
4136
4138
|
}
|
|
4137
|
-
} catch (
|
|
4138
|
-
if (u(!1), !Xt(
|
|
4139
|
-
const
|
|
4140
|
-
b(
|
|
4139
|
+
} catch (L) {
|
|
4140
|
+
if (u(!1), !Xt(L)) {
|
|
4141
|
+
const h = String(L);
|
|
4142
|
+
b(h), r == null || r(h);
|
|
4141
4143
|
}
|
|
4142
4144
|
}
|
|
4143
4145
|
},
|
|
4144
4146
|
[e, n, k, r, i]
|
|
4145
|
-
),
|
|
4146
|
-
async (
|
|
4147
|
+
), U = N(
|
|
4148
|
+
async (_, O) => {
|
|
4147
4149
|
if (o) {
|
|
4148
4150
|
x(!0);
|
|
4149
4151
|
try {
|
|
4150
|
-
const
|
|
4152
|
+
const R = await k({
|
|
4151
4153
|
threadId: o,
|
|
4152
|
-
checkpointId:
|
|
4153
|
-
checkpointNs:
|
|
4154
|
+
checkpointId: _,
|
|
4155
|
+
checkpointNs: O ?? void 0
|
|
4154
4156
|
});
|
|
4155
|
-
n((
|
|
4156
|
-
checkpointId: (
|
|
4157
|
-
checkpointNs: (
|
|
4158
|
-
pendingInterrupt: (
|
|
4159
|
-
values:
|
|
4157
|
+
n((R == null ? void 0 : R.messages) ?? [], {
|
|
4158
|
+
checkpointId: (R == null ? void 0 : R.checkpointId) ?? _,
|
|
4159
|
+
checkpointNs: (R == null ? void 0 : R.checkpointNs) ?? O,
|
|
4160
|
+
pendingInterrupt: (R == null ? void 0 : R.interrupt) ?? null,
|
|
4161
|
+
values: R == null ? void 0 : R.values
|
|
4160
4162
|
});
|
|
4161
|
-
} catch (
|
|
4162
|
-
console.error("[useThreadHistoryState] Navigation failed",
|
|
4163
|
+
} catch (R) {
|
|
4164
|
+
console.error("[useThreadHistoryState] Navigation failed", R);
|
|
4163
4165
|
} finally {
|
|
4164
4166
|
x(!1);
|
|
4165
4167
|
}
|
|
4166
4168
|
}
|
|
4167
4169
|
},
|
|
4168
4170
|
[o, k, n]
|
|
4169
|
-
),
|
|
4171
|
+
), M = N(async () => {
|
|
4170
4172
|
o && await E(o);
|
|
4171
|
-
}, [o, E]),
|
|
4172
|
-
async (
|
|
4173
|
-
const
|
|
4174
|
-
!
|
|
4173
|
+
}, [o, E]), $ = N(
|
|
4174
|
+
async (_) => {
|
|
4175
|
+
const O = (_ == null ? void 0 : _.threadId) || o;
|
|
4176
|
+
!O || o !== O || (c(_), T.current = `${O}:latest`);
|
|
4175
4177
|
},
|
|
4176
4178
|
[o]
|
|
4177
4179
|
);
|
|
4178
|
-
|
|
4180
|
+
Q(() => {
|
|
4179
4181
|
if (!s || !o || I || a) return;
|
|
4180
|
-
const
|
|
4181
|
-
T.current !==
|
|
4182
|
+
const _ = `${o}:latest`;
|
|
4183
|
+
T.current !== _ && E(o);
|
|
4182
4184
|
}, [s, o, I, a, E]);
|
|
4183
|
-
const F =
|
|
4185
|
+
const F = N(() => {
|
|
4184
4186
|
c(null), u(!1), x(!1), A(!1), b(null), T.current = null;
|
|
4185
4187
|
}, []);
|
|
4186
4188
|
return {
|
|
@@ -4189,15 +4191,15 @@ function $t({
|
|
|
4189
4191
|
checkpointIndex: p,
|
|
4190
4192
|
isLoadingThread: I,
|
|
4191
4193
|
isLoadingCheckpoint: v,
|
|
4192
|
-
isLoadingHistory:
|
|
4194
|
+
isLoadingHistory: S,
|
|
4193
4195
|
threadStateError: w,
|
|
4194
4196
|
loadThread: E,
|
|
4195
|
-
navigateToCheckpoint:
|
|
4196
|
-
setCurrentCheckpointId: (
|
|
4197
|
-
n(i(), { checkpointId:
|
|
4197
|
+
navigateToCheckpoint: U,
|
|
4198
|
+
setCurrentCheckpointId: (_, O) => {
|
|
4199
|
+
n(i(), { checkpointId: _, checkpointNs: O });
|
|
4198
4200
|
},
|
|
4199
|
-
returnToLatest:
|
|
4200
|
-
handleValuesEvent:
|
|
4201
|
+
returnToLatest: M,
|
|
4202
|
+
handleValuesEvent: $,
|
|
4201
4203
|
markSkipNextLoad: () => {
|
|
4202
4204
|
},
|
|
4203
4205
|
markStreamPendingThread: () => {
|
|
@@ -4232,17 +4234,17 @@ function jr({
|
|
|
4232
4234
|
threadTimeline: u,
|
|
4233
4235
|
checkpointIndex: v,
|
|
4234
4236
|
isLoadingThread: x,
|
|
4235
|
-
isLoadingCheckpoint:
|
|
4237
|
+
isLoadingCheckpoint: S,
|
|
4236
4238
|
isLoadingHistory: A,
|
|
4237
4239
|
threadStateError: w,
|
|
4238
4240
|
loadThread: b,
|
|
4239
|
-
navigateToCheckpoint:
|
|
4241
|
+
navigateToCheckpoint: y,
|
|
4240
4242
|
setCurrentCheckpointId: T,
|
|
4241
4243
|
returnToLatest: m,
|
|
4242
4244
|
handleValuesEvent: k,
|
|
4243
4245
|
markSkipNextLoad: E,
|
|
4244
|
-
markStreamPendingThread:
|
|
4245
|
-
resetHistoryState:
|
|
4246
|
+
markStreamPendingThread: U,
|
|
4247
|
+
resetHistoryState: M
|
|
4246
4248
|
} = $t({
|
|
4247
4249
|
api: i,
|
|
4248
4250
|
fileApi: d,
|
|
@@ -4254,34 +4256,34 @@ function jr({
|
|
|
4254
4256
|
initialCheckpointNs: r,
|
|
4255
4257
|
autoLoadInitial: o,
|
|
4256
4258
|
isStreaming: s,
|
|
4257
|
-
getMessages:
|
|
4258
|
-
}),
|
|
4259
|
-
(
|
|
4260
|
-
|
|
4259
|
+
getMessages: N(() => l.messages, [l.messages])
|
|
4260
|
+
}), $ = H(null), F = N(
|
|
4261
|
+
(P) => {
|
|
4262
|
+
$.current = P;
|
|
4261
4263
|
},
|
|
4262
4264
|
[]
|
|
4263
|
-
),
|
|
4264
|
-
(
|
|
4265
|
-
|
|
4265
|
+
), _ = H(null), O = N(
|
|
4266
|
+
(P) => {
|
|
4267
|
+
_.current = P;
|
|
4266
4268
|
},
|
|
4267
4269
|
[]
|
|
4268
|
-
),
|
|
4269
|
-
(
|
|
4270
|
-
const K = jt(
|
|
4270
|
+
), R = Z(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), W = N(
|
|
4271
|
+
(P, J) => {
|
|
4272
|
+
const K = jt(P, "user");
|
|
4271
4273
|
return g({
|
|
4272
4274
|
type: "user_message",
|
|
4273
4275
|
payload: {
|
|
4274
4276
|
message: K,
|
|
4275
|
-
editingMessageId:
|
|
4277
|
+
editingMessageId: J == null ? void 0 : J.editingMessageId
|
|
4276
4278
|
}
|
|
4277
4279
|
}), K;
|
|
4278
4280
|
},
|
|
4279
4281
|
[g]
|
|
4280
|
-
),
|
|
4281
|
-
|
|
4282
|
-
}, [f,
|
|
4283
|
-
await b(
|
|
4284
|
-
}, [b]),
|
|
4282
|
+
), B = N(async () => {
|
|
4283
|
+
$.current ? await $.current() : (f([], {}), M());
|
|
4284
|
+
}, [f, M]), L = N(async (P, J, K) => {
|
|
4285
|
+
await b(P, J, { clearProgress: !1 });
|
|
4286
|
+
}, [b]), h = Z(() => Bn(l.messages), [l.messages]), j = Z(
|
|
4285
4287
|
() => ({
|
|
4286
4288
|
status: l.status,
|
|
4287
4289
|
threadId: c,
|
|
@@ -4295,40 +4297,40 @@ function jr({
|
|
|
4295
4297
|
checkpoints: I,
|
|
4296
4298
|
checkpointIndex: v,
|
|
4297
4299
|
timelineCheckpoints: u,
|
|
4298
|
-
metadata:
|
|
4300
|
+
metadata: R,
|
|
4299
4301
|
values: l.values ?? {},
|
|
4300
4302
|
isLoading: x,
|
|
4301
|
-
isLoadingCheckpoint:
|
|
4303
|
+
isLoadingCheckpoint: S,
|
|
4302
4304
|
isLoadingHistory: A,
|
|
4303
4305
|
error: w,
|
|
4304
4306
|
loadOlder: async () => {
|
|
4305
4307
|
},
|
|
4306
4308
|
// Placeholder
|
|
4307
|
-
seedFromSnapshot: (
|
|
4308
|
-
f(
|
|
4309
|
-
checkpointId:
|
|
4310
|
-
checkpointNs:
|
|
4311
|
-
pendingInterrupt:
|
|
4312
|
-
values:
|
|
4309
|
+
seedFromSnapshot: (P) => {
|
|
4310
|
+
f(P.messages, {
|
|
4311
|
+
checkpointId: P.checkpointId,
|
|
4312
|
+
checkpointNs: P.checkpointNs,
|
|
4313
|
+
pendingInterrupt: P.interrupt,
|
|
4314
|
+
values: P.values
|
|
4313
4315
|
});
|
|
4314
4316
|
},
|
|
4315
|
-
clearState:
|
|
4316
|
-
navigateToCheckpoint:
|
|
4317
|
+
clearState: B,
|
|
4318
|
+
navigateToCheckpoint: y,
|
|
4317
4319
|
setCurrentCheckpointId: T,
|
|
4318
4320
|
returnToLatest: m,
|
|
4319
|
-
loadThread:
|
|
4320
|
-
clearThread:
|
|
4321
|
-
respondToInterrupt: async (
|
|
4322
|
-
|
|
4321
|
+
loadThread: L,
|
|
4322
|
+
clearThread: B,
|
|
4323
|
+
respondToInterrupt: async (P, J, K) => {
|
|
4324
|
+
_.current && await _.current(P, J, K);
|
|
4323
4325
|
},
|
|
4324
4326
|
messagePreviews: v.messagePreviews,
|
|
4325
4327
|
handleValuesEvent: k,
|
|
4326
4328
|
markSkipNextLoad: E,
|
|
4327
|
-
markStreamPendingThread:
|
|
4328
|
-
resetHistoryState:
|
|
4329
|
-
pushUser:
|
|
4329
|
+
markStreamPendingThread: U,
|
|
4330
|
+
resetHistoryState: M,
|
|
4331
|
+
pushUser: W,
|
|
4330
4332
|
onEvent: p,
|
|
4331
|
-
artifacts:
|
|
4333
|
+
artifacts: h
|
|
4332
4334
|
}),
|
|
4333
4335
|
[
|
|
4334
4336
|
c,
|
|
@@ -4341,32 +4343,32 @@ function jr({
|
|
|
4341
4343
|
I,
|
|
4342
4344
|
u,
|
|
4343
4345
|
v,
|
|
4344
|
-
|
|
4346
|
+
R,
|
|
4345
4347
|
x,
|
|
4346
|
-
|
|
4348
|
+
S,
|
|
4347
4349
|
A,
|
|
4348
4350
|
w,
|
|
4349
4351
|
f,
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
+
B,
|
|
4353
|
+
y,
|
|
4352
4354
|
T,
|
|
4353
4355
|
m,
|
|
4354
|
-
|
|
4356
|
+
L,
|
|
4355
4357
|
k,
|
|
4356
4358
|
E,
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
+
U,
|
|
4360
|
+
W,
|
|
4359
4361
|
p,
|
|
4360
|
-
|
|
4362
|
+
h
|
|
4361
4363
|
]
|
|
4362
|
-
),
|
|
4364
|
+
), C = Z(
|
|
4363
4365
|
() => ({
|
|
4364
4366
|
registerClearThread: F,
|
|
4365
|
-
registerRespondToInterrupt:
|
|
4367
|
+
registerRespondToInterrupt: O
|
|
4366
4368
|
}),
|
|
4367
|
-
[F,
|
|
4369
|
+
[F, O]
|
|
4368
4370
|
);
|
|
4369
|
-
return /* @__PURE__ */
|
|
4371
|
+
return /* @__PURE__ */ ce(Kt.Provider, { value: C, children: /* @__PURE__ */ ce(Dt.Provider, { value: j, children: e }) });
|
|
4370
4372
|
}
|
|
4371
4373
|
const qt = Ce(null), Ur = Ce(!1);
|
|
4372
4374
|
function Br({
|
|
@@ -4381,13 +4383,13 @@ function Br({
|
|
|
4381
4383
|
onFinish: d,
|
|
4382
4384
|
onStreamingChange: c
|
|
4383
4385
|
}) {
|
|
4384
|
-
const { chatApi: l, baseUrl: f } = Me(), p = f, g = fe(t), I = fe(n), u = fe(r), v = fe(o), x = fe(s),
|
|
4386
|
+
const { chatApi: l, baseUrl: f } = Me(), p = f, g = fe(t), I = fe(n), u = fe(r), v = fe(o), x = fe(s), S = fe(a), A = fe(i), w = fe(d), b = fe(c), y = Z(
|
|
4385
4387
|
() => ({
|
|
4386
4388
|
onError: g,
|
|
4387
4389
|
onAuthError: I,
|
|
4388
4390
|
onConnectionError: u,
|
|
4389
4391
|
onMetadataEvent: A,
|
|
4390
|
-
onCustomEvent:
|
|
4392
|
+
onCustomEvent: S,
|
|
4391
4393
|
onUpdateEvent: x,
|
|
4392
4394
|
onToolEnd: v,
|
|
4393
4395
|
onFinish: w
|
|
@@ -4397,18 +4399,18 @@ function Br({
|
|
|
4397
4399
|
I,
|
|
4398
4400
|
u,
|
|
4399
4401
|
A,
|
|
4400
|
-
|
|
4402
|
+
S,
|
|
4401
4403
|
x,
|
|
4402
4404
|
v,
|
|
4403
4405
|
w
|
|
4404
4406
|
]
|
|
4405
4407
|
);
|
|
4406
|
-
return /* @__PURE__ */
|
|
4408
|
+
return /* @__PURE__ */ ce(Ur.Provider, { value: !0, children: /* @__PURE__ */ ce(
|
|
4407
4409
|
Fr,
|
|
4408
4410
|
{
|
|
4409
4411
|
api: l,
|
|
4410
4412
|
streamBaseUrl: p,
|
|
4411
|
-
handlers:
|
|
4413
|
+
handlers: y,
|
|
4412
4414
|
onStreamingChange: b,
|
|
4413
4415
|
children: e
|
|
4414
4416
|
}
|
|
@@ -4431,18 +4433,18 @@ function Fr({
|
|
|
4431
4433
|
resetHistoryState: u,
|
|
4432
4434
|
pushUser: v,
|
|
4433
4435
|
onEvent: x,
|
|
4434
|
-
messages:
|
|
4435
|
-
} = Vt(), { registerClearThread: A, registerRespondToInterrupt: w } = Lr(), b =
|
|
4436
|
-
(
|
|
4437
|
-
i(
|
|
4436
|
+
messages: S
|
|
4437
|
+
} = Vt(), { registerClearThread: A, registerRespondToInterrupt: w } = Lr(), b = N(
|
|
4438
|
+
(h) => {
|
|
4439
|
+
i(h), I(h.threadId), a.current !== h.threadId && ((h.created ?? !a.current) && g(h.threadId), s(h.threadId));
|
|
4438
4440
|
},
|
|
4439
4441
|
[i, g, I, s, a]
|
|
4440
|
-
),
|
|
4442
|
+
), y = pr({
|
|
4441
4443
|
baseUrl: n,
|
|
4442
4444
|
onEvent: x,
|
|
4443
|
-
onError: (
|
|
4444
|
-
var
|
|
4445
|
-
(
|
|
4445
|
+
onError: (h) => {
|
|
4446
|
+
var j;
|
|
4447
|
+
(j = r.onError) == null || j.call(r, (h == null ? void 0 : h.message) ?? String(h));
|
|
4446
4448
|
},
|
|
4447
4449
|
onAuthError: r.onAuthError,
|
|
4448
4450
|
onConnectionError: r.onConnectionError,
|
|
@@ -4454,126 +4456,130 @@ function Fr({
|
|
|
4454
4456
|
onToolEnd: r.onToolEnd,
|
|
4455
4457
|
handleValuesEvent: p
|
|
4456
4458
|
});
|
|
4457
|
-
|
|
4458
|
-
o == null || o(
|
|
4459
|
-
}, [
|
|
4460
|
-
const { stream: T, stop: m, clear: k, isStreaming: E, error:
|
|
4461
|
-
|
|
4459
|
+
Q(() => {
|
|
4460
|
+
o == null || o(y.isStreaming);
|
|
4461
|
+
}, [y.isStreaming, o]);
|
|
4462
|
+
const { stream: T, stop: m, clear: k, isStreaming: E, error: U, connected: M, activeMessageId: $ } = y;
|
|
4463
|
+
Q(() => {
|
|
4462
4464
|
d !== void 0 && k();
|
|
4463
4465
|
}, [d, k]);
|
|
4464
|
-
const
|
|
4465
|
-
async (
|
|
4466
|
-
await T(
|
|
4466
|
+
const F = N(
|
|
4467
|
+
async (h, j) => {
|
|
4468
|
+
await T(h, j);
|
|
4467
4469
|
},
|
|
4468
4470
|
[T]
|
|
4469
|
-
),
|
|
4470
|
-
|
|
4471
|
-
|
|
4471
|
+
), _ = H(l);
|
|
4472
|
+
Q(() => {
|
|
4473
|
+
_.current = l;
|
|
4472
4474
|
}, [l]);
|
|
4473
|
-
const
|
|
4474
|
-
async (
|
|
4475
|
-
var
|
|
4476
|
-
const
|
|
4477
|
-
if (!
|
|
4475
|
+
const O = N(
|
|
4476
|
+
async (h, j, C) => {
|
|
4477
|
+
var ge;
|
|
4478
|
+
const P = a.current;
|
|
4479
|
+
if (!P)
|
|
4478
4480
|
throw new Error("No active thread to handle interrupt");
|
|
4479
|
-
const
|
|
4480
|
-
threadId:
|
|
4481
|
-
checkpointId:
|
|
4482
|
-
checkpointNs:
|
|
4483
|
-
command: { kind: "resume", value:
|
|
4481
|
+
const J = h ? j ?? !0 : !1, K = _.current, V = (C == null ? void 0 : C.checkpointId) ?? K.id ?? void 0, ee = (C == null ? void 0 : C.checkpointNs) ?? K.namespace ?? void 0, ae = {
|
|
4482
|
+
threadId: P,
|
|
4483
|
+
checkpointId: V,
|
|
4484
|
+
checkpointNs: ee,
|
|
4485
|
+
command: { kind: "resume", value: J },
|
|
4484
4486
|
payload: {
|
|
4485
|
-
...(
|
|
4486
|
-
creativityLevel: ((
|
|
4487
|
+
...(C == null ? void 0 : C.payload) ?? {},
|
|
4488
|
+
creativityLevel: ((ge = C == null ? void 0 : C.payload) == null ? void 0 : ge.creativityLevel) ?? "medium"
|
|
4487
4489
|
},
|
|
4488
4490
|
edit: !1
|
|
4489
4491
|
};
|
|
4490
|
-
|
|
4492
|
+
F(ae);
|
|
4491
4493
|
},
|
|
4492
|
-
[a,
|
|
4494
|
+
[a, F]
|
|
4493
4495
|
);
|
|
4494
|
-
|
|
4495
|
-
w(
|
|
4496
|
-
}, [
|
|
4497
|
-
const
|
|
4496
|
+
Q(() => {
|
|
4497
|
+
w(O);
|
|
4498
|
+
}, [O, w]);
|
|
4499
|
+
const R = N(async () => {
|
|
4498
4500
|
m(), k(), u(), s(null);
|
|
4499
4501
|
}, [k, u, s, m]);
|
|
4500
|
-
|
|
4501
|
-
A(
|
|
4502
|
-
}, [
|
|
4503
|
-
const
|
|
4504
|
-
async (
|
|
4502
|
+
Q(() => {
|
|
4503
|
+
A(R);
|
|
4504
|
+
}, [R, A]);
|
|
4505
|
+
const W = N(
|
|
4506
|
+
async (h, j) => {
|
|
4505
4507
|
E && m();
|
|
4506
|
-
let
|
|
4507
|
-
const
|
|
4508
|
-
|
|
4509
|
-
const
|
|
4510
|
-
if (!
|
|
4511
|
-
if (!
|
|
4512
|
-
const
|
|
4513
|
-
|
|
4508
|
+
let C = a.current;
|
|
4509
|
+
const P = (h == null ? void 0 : h.text) ?? "", J = (h == null ? void 0 : h.attachments) ?? [], K = (P == null ? void 0 : P.trim()) ?? "", V = { ...(h == null ? void 0 : h.payload) ?? {} }, ee = Array.isArray(V.messages) ? V.messages : void 0;
|
|
4510
|
+
ee && delete V.messages;
|
|
4511
|
+
const ae = !!(ee && ee.length), ge = !!(h.contentParts && h.contentParts.length > 0);
|
|
4512
|
+
if (!C && !K && J.length === 0 && !ae && !ge) return;
|
|
4513
|
+
if (!C) {
|
|
4514
|
+
const re = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), we = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
|
|
4515
|
+
C = `${re}${we}`, g(C), s(C);
|
|
4514
4516
|
}
|
|
4515
|
-
let
|
|
4516
|
-
|
|
4517
|
-
const { contentParts:
|
|
4518
|
-
|
|
4519
|
-
const
|
|
4520
|
-
let
|
|
4521
|
-
if (
|
|
4522
|
-
const
|
|
4523
|
-
|
|
4524
|
-
id:
|
|
4517
|
+
let G = null;
|
|
4518
|
+
h.contentParts && h.contentParts.length > 0 && (G = h.contentParts);
|
|
4519
|
+
const { contentParts: ne, filesInfo: me } = G ? { contentParts: G, filesInfo: [] } : await or(J), X = [...ne];
|
|
4520
|
+
K && X.push({ type: "text", text: P });
|
|
4521
|
+
const Y = h == null ? void 0 : h.originalMessageId, ye = !!(h != null && h.edit && Y), Ve = !ae && X.length > 0;
|
|
4522
|
+
let he = null;
|
|
4523
|
+
if (Ve) {
|
|
4524
|
+
const re = ye ? Y : `msg-${Date.now()}`;
|
|
4525
|
+
he = jt({
|
|
4526
|
+
id: re,
|
|
4525
4527
|
role: "user",
|
|
4526
|
-
content:
|
|
4528
|
+
content: X,
|
|
4527
4529
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4528
|
-
}, "user"),
|
|
4530
|
+
}, "user"), ye ? v(he, { editingMessageId: Y }) : v(he);
|
|
4529
4531
|
}
|
|
4530
|
-
const
|
|
4531
|
-
...
|
|
4532
|
-
...
|
|
4532
|
+
const Pe = ae ? ee : he ? [he] : [], be = {
|
|
4533
|
+
...V,
|
|
4534
|
+
...me.length ? { files_info: me } : {}
|
|
4533
4535
|
};
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
if (
|
|
4536
|
+
Pe.length ? be.messages = Pe : "messages" in be || (be.messages = []);
|
|
4537
|
+
let oe = (h == null ? void 0 : h.checkpointId) ?? l.id ?? void 0;
|
|
4538
|
+
if (ye && !oe) {
|
|
4539
|
+
const re = S.find((we) => we.id === Y);
|
|
4540
|
+
re != null && re.checkpointId && (oe = re.checkpointId);
|
|
4541
|
+
}
|
|
4542
|
+
if (h != null && h.edit && !oe)
|
|
4537
4543
|
throw new Error(
|
|
4538
|
-
`[streaming] Missing checkpointId for edit submit. threadId=${
|
|
4544
|
+
`[streaming] Missing checkpointId for edit submit. threadId=${C ?? "null"}. Ensure you are editing a message that has been saved.`
|
|
4539
4545
|
);
|
|
4540
|
-
const
|
|
4541
|
-
threadId:
|
|
4542
|
-
content:
|
|
4543
|
-
payload:
|
|
4544
|
-
config:
|
|
4545
|
-
checkpointId:
|
|
4546
|
-
command:
|
|
4547
|
-
edit:
|
|
4546
|
+
const Ue = {
|
|
4547
|
+
threadId: C,
|
|
4548
|
+
content: h == null ? void 0 : h.text,
|
|
4549
|
+
payload: be,
|
|
4550
|
+
config: h == null ? void 0 : h.config,
|
|
4551
|
+
checkpointId: oe,
|
|
4552
|
+
command: h == null ? void 0 : h.command,
|
|
4553
|
+
edit: h == null ? void 0 : h.edit
|
|
4548
4554
|
};
|
|
4549
|
-
return
|
|
4555
|
+
return F(Ue, j);
|
|
4550
4556
|
},
|
|
4551
|
-
[l, a, E, g, v,
|
|
4552
|
-
),
|
|
4557
|
+
[l, a, E, g, v, F, m, f]
|
|
4558
|
+
), B = Z(() => S, [S]), L = Z(
|
|
4553
4559
|
() => ({
|
|
4554
4560
|
isStreaming: E,
|
|
4555
|
-
error:
|
|
4556
|
-
connectionState:
|
|
4557
|
-
messages:
|
|
4558
|
-
activeMessageId:
|
|
4559
|
-
submit:
|
|
4561
|
+
error: U,
|
|
4562
|
+
connectionState: U ? "error" : E ? M ? "connected" : "connecting" : "idle",
|
|
4563
|
+
messages: B,
|
|
4564
|
+
activeMessageId: $,
|
|
4565
|
+
submit: W,
|
|
4560
4566
|
stop: m,
|
|
4561
4567
|
interrupt: c,
|
|
4562
4568
|
resume: () => Promise.resolve(),
|
|
4563
|
-
goto: (
|
|
4569
|
+
goto: (h, j) => Promise.resolve(),
|
|
4564
4570
|
clearError: () => {
|
|
4565
4571
|
}
|
|
4566
4572
|
// TODO: Implement error clearing
|
|
4567
4573
|
}),
|
|
4568
|
-
[E,
|
|
4574
|
+
[E, U, W, m, c, M, B]
|
|
4569
4575
|
);
|
|
4570
|
-
return /* @__PURE__ */
|
|
4576
|
+
return /* @__PURE__ */ ce(qt.Provider, { value: L, children: e });
|
|
4571
4577
|
}
|
|
4572
4578
|
function fe(e) {
|
|
4573
|
-
const t =
|
|
4574
|
-
return
|
|
4579
|
+
const t = H(e);
|
|
4580
|
+
return Q(() => {
|
|
4575
4581
|
t.current = e;
|
|
4576
|
-
}, [e]),
|
|
4582
|
+
}, [e]), N((...n) => {
|
|
4577
4583
|
const r = t.current;
|
|
4578
4584
|
if (r)
|
|
4579
4585
|
return r(...n);
|
|
@@ -4597,7 +4603,7 @@ function $r(e, t) {
|
|
|
4597
4603
|
return !0;
|
|
4598
4604
|
}
|
|
4599
4605
|
function Dr(e) {
|
|
4600
|
-
const t =
|
|
4606
|
+
const t = H(e), n = H(e);
|
|
4601
4607
|
return $r(t.current, e) || (t.current = e, n.current = e), n.current;
|
|
4602
4608
|
}
|
|
4603
4609
|
function Kr(e) {
|
|
@@ -4628,47 +4634,47 @@ function po({
|
|
|
4628
4634
|
onMetadataEvent: g,
|
|
4629
4635
|
onFinish: I
|
|
4630
4636
|
}) {
|
|
4631
|
-
const u = Dr(t), [v, x] =
|
|
4637
|
+
const u = Dr(t), [v, x] = D(!1), S = pe(i), A = pe(d), w = pe(a), b = pe(c), y = pe(l), T = pe(f), m = pe(p), k = pe(g), E = pe(I), U = Z(
|
|
4632
4638
|
() => ({
|
|
4633
|
-
onError:
|
|
4639
|
+
onError: S,
|
|
4634
4640
|
onAuthError: A,
|
|
4635
4641
|
onConnectionError: w,
|
|
4636
|
-
onToolEnd:
|
|
4642
|
+
onToolEnd: y,
|
|
4637
4643
|
onUpdateEvent: T,
|
|
4638
4644
|
onCustomEvent: m,
|
|
4639
4645
|
onMetadataEvent: k,
|
|
4640
4646
|
onFinish: E
|
|
4641
4647
|
}),
|
|
4642
4648
|
[
|
|
4643
|
-
|
|
4649
|
+
S,
|
|
4644
4650
|
A,
|
|
4645
4651
|
w,
|
|
4646
|
-
|
|
4652
|
+
y,
|
|
4647
4653
|
T,
|
|
4648
4654
|
m,
|
|
4649
4655
|
k,
|
|
4650
4656
|
E
|
|
4651
4657
|
]
|
|
4652
4658
|
);
|
|
4653
|
-
return /* @__PURE__ */
|
|
4659
|
+
return /* @__PURE__ */ ce(nr, { apiConfig: u, children: /* @__PURE__ */ ce(
|
|
4654
4660
|
mr,
|
|
4655
4661
|
{
|
|
4656
4662
|
initialThreadId: n,
|
|
4657
|
-
onError:
|
|
4663
|
+
onError: S,
|
|
4658
4664
|
onThreadChange: b,
|
|
4659
|
-
children: /* @__PURE__ */
|
|
4665
|
+
children: /* @__PURE__ */ ce(
|
|
4660
4666
|
jr,
|
|
4661
4667
|
{
|
|
4662
4668
|
initialThreadId: n,
|
|
4663
4669
|
initialCheckpointId: r,
|
|
4664
4670
|
initialCheckpointNs: o,
|
|
4665
4671
|
autoLoadInitial: s,
|
|
4666
|
-
onError:
|
|
4672
|
+
onError: S,
|
|
4667
4673
|
isStreaming: v,
|
|
4668
|
-
children: /* @__PURE__ */
|
|
4674
|
+
children: /* @__PURE__ */ ce(
|
|
4669
4675
|
Br,
|
|
4670
4676
|
{
|
|
4671
|
-
...
|
|
4677
|
+
...U,
|
|
4672
4678
|
onStreamingChange: x,
|
|
4673
4679
|
children: e
|
|
4674
4680
|
}
|
|
@@ -4679,8 +4685,8 @@ function po({
|
|
|
4679
4685
|
) });
|
|
4680
4686
|
}
|
|
4681
4687
|
function pe(e) {
|
|
4682
|
-
const t =
|
|
4683
|
-
return t.current = e,
|
|
4688
|
+
const t = H(e);
|
|
4689
|
+
return t.current = e, N((...n) => {
|
|
4684
4690
|
const r = t.current;
|
|
4685
4691
|
if (r)
|
|
4686
4692
|
return r(...n);
|
|
@@ -4738,11 +4744,11 @@ const Je = /* @__PURE__ */ new Map(), wt = (e) => {
|
|
|
4738
4744
|
toasts: e.toasts.filter((n) => n.id !== t.toastId)
|
|
4739
4745
|
};
|
|
4740
4746
|
}
|
|
4741
|
-
},
|
|
4742
|
-
let
|
|
4747
|
+
}, Oe = [];
|
|
4748
|
+
let $e = { toasts: [] };
|
|
4743
4749
|
function Le(e) {
|
|
4744
|
-
|
|
4745
|
-
t(
|
|
4750
|
+
$e = Gr($e, e), Oe.forEach((t) => {
|
|
4751
|
+
t($e);
|
|
4746
4752
|
});
|
|
4747
4753
|
}
|
|
4748
4754
|
function Wr({ ...e }) {
|
|
@@ -4767,10 +4773,10 @@ function Wr({ ...e }) {
|
|
|
4767
4773
|
};
|
|
4768
4774
|
}
|
|
4769
4775
|
function Jr() {
|
|
4770
|
-
const [e, t] = it.useState(
|
|
4771
|
-
return it.useEffect(() => (
|
|
4772
|
-
const n =
|
|
4773
|
-
n > -1 &&
|
|
4776
|
+
const [e, t] = it.useState($e);
|
|
4777
|
+
return it.useEffect(() => (Oe.push(t), () => {
|
|
4778
|
+
const n = Oe.indexOf(t);
|
|
4779
|
+
n > -1 && Oe.splice(n, 1);
|
|
4774
4780
|
}), [e]), {
|
|
4775
4781
|
...e,
|
|
4776
4782
|
toast: Wr,
|
|
@@ -4778,13 +4784,13 @@ function Jr() {
|
|
|
4778
4784
|
};
|
|
4779
4785
|
}
|
|
4780
4786
|
function go(e) {
|
|
4781
|
-
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast: o } = Jr(), [s, a] =
|
|
4787
|
+
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast: o } = Jr(), [s, a] = D({}), [i, d] = D(null), [c, l] = D(!1), f = N(() => {
|
|
4782
4788
|
l(!1), d(null);
|
|
4783
|
-
}, []), p =
|
|
4789
|
+
}, []), p = N((I) => {
|
|
4784
4790
|
d(I), l(!0);
|
|
4785
|
-
}, []), g =
|
|
4791
|
+
}, []), g = N(
|
|
4786
4792
|
async (I, u, v) => {
|
|
4787
|
-
var x,
|
|
4793
|
+
var x, S;
|
|
4788
4794
|
if (!t) {
|
|
4789
4795
|
I.preventDefault();
|
|
4790
4796
|
return;
|
|
@@ -4797,18 +4803,18 @@ function go(e) {
|
|
|
4797
4803
|
const A = String(u.url ?? ""), w = A.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
|
|
4798
4804
|
if (w) {
|
|
4799
4805
|
I.preventDefault();
|
|
4800
|
-
const b = w[1],
|
|
4801
|
-
p({ id: b, name:
|
|
4806
|
+
const b = w[1], y = u.name || `file_${b}`, T = u.mimeType || "application/octet-stream";
|
|
4807
|
+
p({ id: b, name: y, mimeType: T });
|
|
4802
4808
|
return;
|
|
4803
4809
|
}
|
|
4804
4810
|
if (A.startsWith("data:")) {
|
|
4805
|
-
I.preventDefault(), a((
|
|
4811
|
+
I.preventDefault(), a((y) => ({ ...y, [v]: !0 }));
|
|
4806
4812
|
const b = o({ title: "Fetching file...", description: "", open: !0 });
|
|
4807
4813
|
try {
|
|
4808
|
-
const
|
|
4809
|
-
if (!
|
|
4814
|
+
const y = await r.listFiles(n ?? void 0);
|
|
4815
|
+
if (!y || !Array.isArray(y))
|
|
4810
4816
|
throw new Error("Invalid file list response");
|
|
4811
|
-
const T =
|
|
4817
|
+
const T = y.find((m) => !m || typeof m != "object" || !((m.filename ?? "") === (u.name ?? "")) ? !1 : typeof u.size == "number" && typeof m.size == "number" ? m.size === u.size : !0);
|
|
4812
4818
|
if (!(T != null && T.id))
|
|
4813
4819
|
throw new Error(`File "${u.name}" is not yet available on the server`);
|
|
4814
4820
|
if (!T.id || !T.filename)
|
|
@@ -4823,16 +4829,16 @@ function go(e) {
|
|
|
4823
4829
|
description: `Opened ${u.name}`,
|
|
4824
4830
|
open: !0
|
|
4825
4831
|
});
|
|
4826
|
-
} catch (
|
|
4827
|
-
console.error("Failed to fetch server file:",
|
|
4828
|
-
const T =
|
|
4829
|
-
(
|
|
4832
|
+
} catch (y) {
|
|
4833
|
+
console.error("Failed to fetch server file:", y);
|
|
4834
|
+
const T = y instanceof Error ? y.message : "Unknown error occurred";
|
|
4835
|
+
(S = b.update) == null || S.call(b, { id: b.id, title: "Failed", description: T }), o({
|
|
4830
4836
|
title: "Failed to fetch file",
|
|
4831
4837
|
description: T,
|
|
4832
4838
|
open: !0
|
|
4833
4839
|
});
|
|
4834
4840
|
} finally {
|
|
4835
|
-
a((
|
|
4841
|
+
a((y) => ({ ...y, [v]: !1 }));
|
|
4836
4842
|
}
|
|
4837
4843
|
}
|
|
4838
4844
|
} catch (A) {
|
|
@@ -4850,7 +4856,7 @@ function go(e) {
|
|
|
4850
4856
|
};
|
|
4851
4857
|
}
|
|
4852
4858
|
function mo(e) {
|
|
4853
|
-
return
|
|
4859
|
+
return Z(() => {
|
|
4854
4860
|
const t = e;
|
|
4855
4861
|
let n = Array.isArray(t.content) ? t.content : [];
|
|
4856
4862
|
return typeof t.content == "string" && (n = [{ type: "text", text: t.content }]), {
|
|
@@ -4889,7 +4895,7 @@ function Qr(e) {
|
|
|
4889
4895
|
return null;
|
|
4890
4896
|
}
|
|
4891
4897
|
function yo(e) {
|
|
4892
|
-
return
|
|
4898
|
+
return Z(() => {
|
|
4893
4899
|
const t = e.content.filter(
|
|
4894
4900
|
(d) => d.type === "text"
|
|
4895
4901
|
);
|
|
@@ -4908,7 +4914,7 @@ function yo(e) {
|
|
|
4908
4914
|
const s = Qr(r) ?? r[r.length - 1];
|
|
4909
4915
|
if (!s)
|
|
4910
4916
|
return null;
|
|
4911
|
-
const a = s.output ?? s.payload ?? s, i =
|
|
4917
|
+
const a = s.output ?? s.payload ?? s, i = le(a);
|
|
4912
4918
|
return i && typeof i == "object" && !Array.isArray(i) ? {
|
|
4913
4919
|
kind: "dict",
|
|
4914
4920
|
value: i,
|
|
@@ -4922,13 +4928,13 @@ function yo(e) {
|
|
|
4922
4928
|
}, [e]);
|
|
4923
4929
|
}
|
|
4924
4930
|
function Yr(e) {
|
|
4925
|
-
var
|
|
4931
|
+
var M, $;
|
|
4926
4932
|
const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = ot({ optional: !0 }), o = Vt({ optional: !0 }), s = Or(), { currentThreadId: a, setCurrentThreadId: i, actions: d } = r || {
|
|
4927
4933
|
currentThreadId: null,
|
|
4928
4934
|
setCurrentThreadId: () => {
|
|
4929
4935
|
},
|
|
4930
4936
|
actions: {}
|
|
4931
|
-
}, c = !!t && t !== a, [l, f] =
|
|
4937
|
+
}, c = !!t && t !== a, [l, f] = D([]), p = N((F) => {
|
|
4932
4938
|
f(F);
|
|
4933
4939
|
}, []), {
|
|
4934
4940
|
isLoadingThread: g,
|
|
@@ -4946,21 +4952,21 @@ function Yr(e) {
|
|
|
4946
4952
|
getMessages: () => l,
|
|
4947
4953
|
autoLoadInitial: c && !n
|
|
4948
4954
|
});
|
|
4949
|
-
|
|
4955
|
+
Q(() => {
|
|
4950
4956
|
!c && !n && a && (o != null && o.loadThread) && o.loadThread(a);
|
|
4951
4957
|
}, [c, n, a, o == null ? void 0 : o.loadThread]);
|
|
4952
|
-
const
|
|
4958
|
+
const S = Z(() => {
|
|
4953
4959
|
var F;
|
|
4954
4960
|
return ((F = u[0]) == null ? void 0 : F.values) || {};
|
|
4955
|
-
}, [u]), A =
|
|
4961
|
+
}, [u]), A = Z(() => ({ timeline: [], messagePreviews: {} }), []), w = t || a, b = c ? g ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", y = c ? l : (s == null ? void 0 : s.messages) || [], T = c ? g : (o == null ? void 0 : o.isLoading) || !1, m = c ? v : (o == null ? void 0 : o.isLoadingHistory) || !1, k = c ? S : (o == null ? void 0 : o.values) || {}, E = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, U = c ? I : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
|
|
4956
4962
|
return {
|
|
4957
4963
|
// UNIFIED: Single thread ID concept
|
|
4958
4964
|
threadId: w,
|
|
4959
4965
|
status: b,
|
|
4960
|
-
messages:
|
|
4966
|
+
messages: y,
|
|
4961
4967
|
isLoading: T,
|
|
4962
4968
|
isHistoryLoading: m,
|
|
4963
|
-
error:
|
|
4969
|
+
error: U,
|
|
4964
4970
|
// Values & Metadata
|
|
4965
4971
|
values: k,
|
|
4966
4972
|
taskMessagesByScope: E,
|
|
@@ -4982,9 +4988,9 @@ function Yr(e) {
|
|
|
4982
4988
|
// Streaming Status
|
|
4983
4989
|
// Even in standalone mode, allow streaming state/stop if a stream context exists.
|
|
4984
4990
|
isStreaming: (s == null ? void 0 : s.isStreaming) || !1,
|
|
4985
|
-
activeMessageId: c ? null : ((
|
|
4991
|
+
activeMessageId: c ? null : ((M = o == null ? void 0 : o.metadata) == null ? void 0 : M.assemblingMessageId) || (s == null ? void 0 : s.activeMessageId) || null,
|
|
4986
4992
|
connectionState: (s == null ? void 0 : s.connectionState) || "disconnected",
|
|
4987
|
-
streamingAssistantId: !c && (s != null && s.isStreaming) && ((
|
|
4993
|
+
streamingAssistantId: !c && (s != null && s.isStreaming) && (($ = o == null ? void 0 : o.metadata) != null && $.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
|
|
4988
4994
|
// Actions
|
|
4989
4995
|
submit: (s == null ? void 0 : s.submit) || (async () => {
|
|
4990
4996
|
}),
|
|
@@ -5025,82 +5031,82 @@ function ho({
|
|
|
5025
5031
|
threadId: p,
|
|
5026
5032
|
clearComposerOnSend: g = !0
|
|
5027
5033
|
}) {
|
|
5028
|
-
const { messages: I } = Yr(), [u, v] =
|
|
5029
|
-
|
|
5034
|
+
const { messages: I } = Yr(), [u, v] = D(null), [x, S] = D(""), [A, w] = D(null), [b, y] = D(null), [T, m] = D(!1), [k, E] = D(""), U = H(k), M = H(null);
|
|
5035
|
+
Q(() => {
|
|
5030
5036
|
if (!u)
|
|
5031
5037
|
if (p) {
|
|
5032
|
-
const
|
|
5033
|
-
E(
|
|
5038
|
+
const j = localStorage.getItem(Ge(p));
|
|
5039
|
+
E(j || "");
|
|
5034
5040
|
} else
|
|
5035
5041
|
E("");
|
|
5036
5042
|
}, [p, u]);
|
|
5037
|
-
const
|
|
5038
|
-
E(
|
|
5043
|
+
const $ = N((j) => {
|
|
5044
|
+
E(j), !u && p && localStorage.setItem(Ge(p), j);
|
|
5039
5045
|
}, [p, u]);
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
}, [k]),
|
|
5046
|
+
Q(() => {
|
|
5047
|
+
U.current = k;
|
|
5048
|
+
}, [k]), Q(() => {
|
|
5043
5049
|
if (!u) {
|
|
5044
|
-
|
|
5050
|
+
M.current = null;
|
|
5045
5051
|
return;
|
|
5046
5052
|
}
|
|
5047
|
-
|
|
5048
|
-
}, [x, u,
|
|
5049
|
-
const F =
|
|
5050
|
-
(
|
|
5051
|
-
|
|
5053
|
+
M.current === null && (M.current = U.current), $(x ?? "");
|
|
5054
|
+
}, [x, u, $]);
|
|
5055
|
+
const F = N(
|
|
5056
|
+
(j) => {
|
|
5057
|
+
$(j);
|
|
5052
5058
|
},
|
|
5053
|
-
[
|
|
5054
|
-
),
|
|
5055
|
-
const
|
|
5056
|
-
if (!(!V &&
|
|
5059
|
+
[$]
|
|
5060
|
+
), _ = async (j, C) => {
|
|
5061
|
+
const P = Array.isArray(C) ? { files: C } : C ?? {}, J = P.files ?? [], K = P.contentParts ?? [], V = j.trim();
|
|
5062
|
+
if (!(!V && J.length === 0 && K.length === 0))
|
|
5057
5063
|
try {
|
|
5058
|
-
const ee =
|
|
5064
|
+
const ee = J.map(async (X) => {
|
|
5059
5065
|
try {
|
|
5060
|
-
const
|
|
5061
|
-
return { file:
|
|
5062
|
-
} catch (
|
|
5063
|
-
throw console.error("Failed to upload file",
|
|
5066
|
+
const Y = await Rt.uploadFile(X);
|
|
5067
|
+
return { file: X, record: Y };
|
|
5068
|
+
} catch (Y) {
|
|
5069
|
+
throw console.error("Failed to upload file", X.name, Y), new Error(`Failed to upload ${X.name}`);
|
|
5064
5070
|
}
|
|
5065
|
-
}),
|
|
5066
|
-
const
|
|
5067
|
-
return
|
|
5071
|
+
}), ge = (await Promise.all(ee)).map(({ record: X }) => {
|
|
5072
|
+
const Y = X.mime_type;
|
|
5073
|
+
return Y.startsWith("image/") ? {
|
|
5068
5074
|
type: "image_url",
|
|
5069
|
-
image_url: { url:
|
|
5075
|
+
image_url: { url: X.content_url }
|
|
5070
5076
|
} : {
|
|
5071
5077
|
type: "file",
|
|
5072
|
-
url:
|
|
5073
|
-
mimeType:
|
|
5074
|
-
name:
|
|
5075
|
-
size:
|
|
5078
|
+
url: X.content_url,
|
|
5079
|
+
mimeType: Y,
|
|
5080
|
+
name: X.filename,
|
|
5081
|
+
size: X.size
|
|
5076
5082
|
};
|
|
5077
|
-
}),
|
|
5083
|
+
}), G = [...K, ...ge], ne = u ? (A == null ? void 0 : A.checkpointId) ?? n ?? void 0 : n ?? void 0, me = u ? (A == null ? void 0 : A.checkpointNs) ?? r ?? void 0 : r ?? void 0;
|
|
5078
5084
|
await e(
|
|
5079
5085
|
{
|
|
5080
5086
|
text: V || "",
|
|
5081
|
-
contentParts:
|
|
5082
|
-
attachments:
|
|
5087
|
+
contentParts: G,
|
|
5088
|
+
attachments: J,
|
|
5083
5089
|
payload: t.payload,
|
|
5084
5090
|
edit: !!u,
|
|
5085
|
-
checkpointId:
|
|
5086
|
-
checkpointNs:
|
|
5091
|
+
checkpointId: ne,
|
|
5092
|
+
checkpointNs: me,
|
|
5087
5093
|
project: l ?? void 0,
|
|
5088
5094
|
originalMessageId: u ?? void 0,
|
|
5089
5095
|
config: t.config
|
|
5090
5096
|
},
|
|
5091
5097
|
f ? { onEvent: f } : void 0
|
|
5092
|
-
), o == null || o(V), c(!0), g && (p && localStorage.removeItem(Ge(p)),
|
|
5098
|
+
), o == null || o(V), c(!0), g && (p && localStorage.removeItem(Ge(p)), $("")), y(null), v(null), S(""), w(null);
|
|
5093
5099
|
} catch (ee) {
|
|
5094
|
-
const
|
|
5095
|
-
|
|
5100
|
+
const ae = (ee == null ? void 0 : ee.message) || "Failed to send message";
|
|
5101
|
+
y(ae), a == null || a(ae), c(!1);
|
|
5096
5102
|
}
|
|
5097
|
-
},
|
|
5098
|
-
|
|
5099
|
-
},
|
|
5100
|
-
async (
|
|
5103
|
+
}, O = (j, C) => {
|
|
5104
|
+
C || _(j, { files: [] });
|
|
5105
|
+
}, R = N(
|
|
5106
|
+
async (j) => {
|
|
5101
5107
|
await e(
|
|
5102
5108
|
{
|
|
5103
|
-
attachments: [
|
|
5109
|
+
attachments: [j],
|
|
5104
5110
|
payload: t.payload,
|
|
5105
5111
|
checkpointId: n ?? void 0,
|
|
5106
5112
|
checkpointNs: r ?? void 0,
|
|
@@ -5108,34 +5114,34 @@ function ho({
|
|
|
5108
5114
|
config: t.config
|
|
5109
5115
|
},
|
|
5110
5116
|
f ? { onEvent: f } : void 0
|
|
5111
|
-
), s == null || s({ file:
|
|
5117
|
+
), s == null || s({ file: j });
|
|
5112
5118
|
},
|
|
5113
5119
|
[n, r, t, s, e]
|
|
5114
|
-
),
|
|
5115
|
-
(
|
|
5116
|
-
i && (
|
|
5117
|
-
checkpointId: (
|
|
5118
|
-
checkpointNs: (
|
|
5119
|
-
}),
|
|
5120
|
+
), W = N(
|
|
5121
|
+
(j, C, P) => {
|
|
5122
|
+
i && (M.current = k, v(j), S(C), w({
|
|
5123
|
+
checkpointId: (P == null ? void 0 : P.checkpointId) ?? null,
|
|
5124
|
+
checkpointNs: (P == null ? void 0 : P.checkpointNs) ?? null
|
|
5125
|
+
}), y(null));
|
|
5120
5126
|
},
|
|
5121
5127
|
[k, i]
|
|
5122
|
-
),
|
|
5123
|
-
v(null),
|
|
5124
|
-
const
|
|
5125
|
-
|
|
5126
|
-
}, []),
|
|
5127
|
-
let
|
|
5128
|
-
for (let V =
|
|
5128
|
+
), B = N(() => {
|
|
5129
|
+
v(null), S(""), w(null), y(null);
|
|
5130
|
+
const j = M.current;
|
|
5131
|
+
j !== null && E(j), M.current = null;
|
|
5132
|
+
}, []), L = N((j) => {
|
|
5133
|
+
let C = null;
|
|
5134
|
+
for (let V = j - 1; V >= 0; V--)
|
|
5129
5135
|
if (d[V].role === "user") {
|
|
5130
|
-
|
|
5136
|
+
C = d[V];
|
|
5131
5137
|
break;
|
|
5132
5138
|
}
|
|
5133
|
-
if (!
|
|
5134
|
-
const
|
|
5139
|
+
if (!C) return;
|
|
5140
|
+
const P = Array.isArray(C.content) ? C.content : [], K = P.filter((V) => (V == null ? void 0 : V.type) === "text").map((V) => V.text).join("") || (() => {
|
|
5135
5141
|
try {
|
|
5136
|
-
return JSON.stringify(
|
|
5142
|
+
return JSON.stringify(P, null, 2);
|
|
5137
5143
|
} catch {
|
|
5138
|
-
return String(
|
|
5144
|
+
return String(P);
|
|
5139
5145
|
}
|
|
5140
5146
|
})();
|
|
5141
5147
|
K && e(
|
|
@@ -5145,7 +5151,7 @@ function ho({
|
|
|
5145
5151
|
checkpointId: n ?? void 0,
|
|
5146
5152
|
checkpointNs: r ?? void 0,
|
|
5147
5153
|
edit: !0,
|
|
5148
|
-
originalMessageId:
|
|
5154
|
+
originalMessageId: C.id,
|
|
5149
5155
|
config: t.config
|
|
5150
5156
|
},
|
|
5151
5157
|
f ? { onEvent: f } : void 0
|
|
@@ -5155,22 +5161,22 @@ function ho({
|
|
|
5155
5161
|
editingMessageId: u,
|
|
5156
5162
|
editingInitialValue: x,
|
|
5157
5163
|
inputError: b,
|
|
5158
|
-
setInputError:
|
|
5164
|
+
setInputError: y,
|
|
5159
5165
|
dismissError: T,
|
|
5160
5166
|
setDismissError: m,
|
|
5161
5167
|
composerValue: k,
|
|
5162
5168
|
handleComposerChange: F,
|
|
5163
|
-
handleSendMessage:
|
|
5164
|
-
handleQuickPrompt:
|
|
5165
|
-
handleExcelUpload:
|
|
5166
|
-
startEditing:
|
|
5167
|
-
cancelEditing:
|
|
5168
|
-
handleRegenerateCb:
|
|
5169
|
+
handleSendMessage: _,
|
|
5170
|
+
handleQuickPrompt: O,
|
|
5171
|
+
handleExcelUpload: R,
|
|
5172
|
+
startEditing: W,
|
|
5173
|
+
cancelEditing: B,
|
|
5174
|
+
handleRegenerateCb: L,
|
|
5169
5175
|
displayMessages: I
|
|
5170
5176
|
};
|
|
5171
5177
|
}
|
|
5172
5178
|
function bo(e) {
|
|
5173
|
-
return
|
|
5179
|
+
return Z(() => e ? {
|
|
5174
5180
|
textContent: Ln(e),
|
|
5175
5181
|
imageParts: jn(e),
|
|
5176
5182
|
fileParts: Un(e),
|
|
@@ -5185,8 +5191,8 @@ function bo(e) {
|
|
|
5185
5191
|
}, [e]);
|
|
5186
5192
|
}
|
|
5187
5193
|
function wo(e, t, n) {
|
|
5188
|
-
const [r, o] =
|
|
5189
|
-
return
|
|
5194
|
+
const [r, o] = D(e), s = H(e), a = H(null);
|
|
5195
|
+
return Q(() => {
|
|
5190
5196
|
s.current = e;
|
|
5191
5197
|
const i = () => {
|
|
5192
5198
|
o(s.current), a.current && (clearTimeout(a.current), a.current = null);
|
|
@@ -5227,8 +5233,8 @@ export {
|
|
|
5227
5233
|
tt as parseJsonSafe,
|
|
5228
5234
|
Et as pretty,
|
|
5229
5235
|
Mr as refreshHistoryFileUrls,
|
|
5230
|
-
|
|
5231
|
-
|
|
5236
|
+
De as sanitizeForDisplay,
|
|
5237
|
+
ve as setChatToken,
|
|
5232
5238
|
Fn as stringifyTool,
|
|
5233
5239
|
Me as useApi,
|
|
5234
5240
|
ho as useChatController,
|