@teodorruskvi/chat-core 0.1.42 → 0.1.45
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 +687 -671
- 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 Gt = Object.defineProperty;
|
|
2
2
|
var Ht = (e, t, n) => t in e ? Gt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var st = (e, t, n) => Ht(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
import { jsx as
|
|
4
|
+
import { jsx as le } from "react/jsx-runtime";
|
|
5
5
|
import * as at from "react";
|
|
6
|
-
import { createContext as Se, useContext as Ue, useState as
|
|
6
|
+
import { createContext as Se, useContext as Ue, useState as V, useRef as K, useEffect as q, useCallback as z, useMemo as Y, useReducer as Wt } from "react";
|
|
7
7
|
import qt, { isCancel as Jt } from "axios";
|
|
8
8
|
function vt(e) {
|
|
9
9
|
var t, n, r = "";
|
|
@@ -196,9 +196,9 @@ const Ze = "-", Qt = (e) => {
|
|
|
196
196
|
continue;
|
|
197
197
|
s.push(C);
|
|
198
198
|
const T = o(d, k);
|
|
199
|
-
for (let
|
|
200
|
-
const
|
|
201
|
-
s.push(I +
|
|
199
|
+
for (let P = 0; P < T.length; ++P) {
|
|
200
|
+
const b = T[P];
|
|
201
|
+
s.push(I + b);
|
|
202
202
|
}
|
|
203
203
|
i = c + (i.length > 0 ? " " + i : i);
|
|
204
204
|
}
|
|
@@ -235,46 +235,46 @@ function un(e, ...t) {
|
|
|
235
235
|
return s(ln.apply(null, arguments));
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
|
-
const
|
|
238
|
+
const $ = (e) => {
|
|
239
239
|
const t = (n) => n[e] || [];
|
|
240
240
|
return t.isThemeGetter = !0, t;
|
|
241
|
-
},
|
|
242
|
-
const r =
|
|
241
|
+
}, At = /^\[(?:([a-z-]+):)?(.+)\]$/i, dn = /^\d+\/\d+$/, fn = /* @__PURE__ */ new Set(["px", "full", "screen"]), pn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, gn = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/, mn = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, hn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, yn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, pe = (e) => Ae(e) || fn.has(e) || dn.test(e), be = (e) => Ce(e, "length", xn), Ae = (e) => !!e && !Number.isNaN(Number(e)), Ke = (e) => Ce(e, "number", Ae), Pe = (e) => !!e && Number.isInteger(Number(e)), bn = (e) => e.endsWith("%") && Ae(e.slice(0, -1)), R = (e) => At.test(e), we = (e) => pn.test(e), wn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), vn = (e) => Ce(e, wn, xt), kn = (e) => Ce(e, "position", xt), In = /* @__PURE__ */ new Set(["image", "url"]), Tn = (e) => Ce(e, In, Cn), An = (e) => Ce(e, "", Sn), Ne = () => !0, Ce = (e, t, n) => {
|
|
242
|
+
const r = At.exec(e);
|
|
243
243
|
return r ? r[1] ? typeof t == "string" ? r[1] === t : t.has(r[1]) : n(r[2]) : !1;
|
|
244
|
-
},
|
|
244
|
+
}, xn = (e) => (
|
|
245
245
|
// `colorFunctionRegex` check is necessary because color functions can have percentages in them which which would be incorrectly classified as lengths.
|
|
246
246
|
// For example, `hsl(0 0% 0%)` would be classified as a length without this check.
|
|
247
247
|
// I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough.
|
|
248
248
|
gn.test(e) && !mn.test(e)
|
|
249
|
-
),
|
|
250
|
-
const e =
|
|
249
|
+
), xt = () => !1, Sn = (e) => hn.test(e), Cn = (e) => yn.test(e), Mn = () => {
|
|
250
|
+
const e = $("colors"), t = $("spacing"), n = $("blur"), r = $("brightness"), o = $("borderColor"), s = $("borderRadius"), a = $("borderSpacing"), i = $("borderWidth"), u = $("contrast"), c = $("grayscale"), l = $("hueRotate"), f = $("invert"), m = $("gap"), h = $("gradientColorStops"), k = $("gradientColorStopPositions"), d = $("inset"), v = $("margin"), I = $("opacity"), C = $("padding"), T = $("saturate"), P = $("scale"), b = $("sepia"), y = $("skew"), A = $("space"), p = $("translate"), w = () => ["auto", "contain", "none"], _ = () => ["auto", "hidden", "clip", "visible", "scroll"], U = () => ["auto", R, t], M = () => [R, t], E = () => ["", pe, be], j = () => ["auto", Ae, R], N = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], B = () => ["solid", "dashed", "dotted", "double", "none"], O = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], F = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], L = () => ["", "0", R], W = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], Z = () => [Ae, R];
|
|
251
251
|
return {
|
|
252
252
|
cacheSize: 500,
|
|
253
253
|
separator: ":",
|
|
254
254
|
theme: {
|
|
255
255
|
colors: [Ne],
|
|
256
|
-
spacing: [
|
|
257
|
-
blur: ["none", "", we,
|
|
258
|
-
brightness:
|
|
256
|
+
spacing: [pe, be],
|
|
257
|
+
blur: ["none", "", we, R],
|
|
258
|
+
brightness: Z(),
|
|
259
259
|
borderColor: [e],
|
|
260
|
-
borderRadius: ["none", "", "full", we,
|
|
260
|
+
borderRadius: ["none", "", "full", we, R],
|
|
261
261
|
borderSpacing: M(),
|
|
262
|
-
borderWidth:
|
|
263
|
-
contrast:
|
|
264
|
-
grayscale:
|
|
265
|
-
hueRotate:
|
|
266
|
-
invert:
|
|
262
|
+
borderWidth: E(),
|
|
263
|
+
contrast: Z(),
|
|
264
|
+
grayscale: L(),
|
|
265
|
+
hueRotate: Z(),
|
|
266
|
+
invert: L(),
|
|
267
267
|
gap: M(),
|
|
268
268
|
gradientColorStops: [e],
|
|
269
269
|
gradientColorStopPositions: [bn, be],
|
|
270
|
-
inset:
|
|
271
|
-
margin:
|
|
272
|
-
opacity:
|
|
270
|
+
inset: U(),
|
|
271
|
+
margin: U(),
|
|
272
|
+
opacity: Z(),
|
|
273
273
|
padding: M(),
|
|
274
|
-
saturate:
|
|
275
|
-
scale:
|
|
276
|
-
sepia:
|
|
277
|
-
skew:
|
|
274
|
+
saturate: Z(),
|
|
275
|
+
scale: Z(),
|
|
276
|
+
sepia: L(),
|
|
277
|
+
skew: Z(),
|
|
278
278
|
space: M(),
|
|
279
279
|
translate: M()
|
|
280
280
|
},
|
|
@@ -285,7 +285,7 @@ const B = (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", R]
|
|
289
289
|
}],
|
|
290
290
|
/**
|
|
291
291
|
* Container
|
|
@@ -304,14 +304,14 @@ const B = (e) => {
|
|
|
304
304
|
* @see https://tailwindcss.com/docs/break-after
|
|
305
305
|
*/
|
|
306
306
|
"break-after": [{
|
|
307
|
-
"break-after":
|
|
307
|
+
"break-after": W()
|
|
308
308
|
}],
|
|
309
309
|
/**
|
|
310
310
|
* Break Before
|
|
311
311
|
* @see https://tailwindcss.com/docs/break-before
|
|
312
312
|
*/
|
|
313
313
|
"break-before": [{
|
|
314
|
-
"break-before":
|
|
314
|
+
"break-before": W()
|
|
315
315
|
}],
|
|
316
316
|
/**
|
|
317
317
|
* Break Inside
|
|
@@ -370,49 +370,49 @@ const B = (e) => {
|
|
|
370
370
|
* @see https://tailwindcss.com/docs/object-position
|
|
371
371
|
*/
|
|
372
372
|
"object-position": [{
|
|
373
|
-
object: [...
|
|
373
|
+
object: [...N(), R]
|
|
374
374
|
}],
|
|
375
375
|
/**
|
|
376
376
|
* Overflow
|
|
377
377
|
* @see https://tailwindcss.com/docs/overflow
|
|
378
378
|
*/
|
|
379
379
|
overflow: [{
|
|
380
|
-
overflow:
|
|
380
|
+
overflow: _()
|
|
381
381
|
}],
|
|
382
382
|
/**
|
|
383
383
|
* Overflow X
|
|
384
384
|
* @see https://tailwindcss.com/docs/overflow
|
|
385
385
|
*/
|
|
386
386
|
"overflow-x": [{
|
|
387
|
-
"overflow-x":
|
|
387
|
+
"overflow-x": _()
|
|
388
388
|
}],
|
|
389
389
|
/**
|
|
390
390
|
* Overflow Y
|
|
391
391
|
* @see https://tailwindcss.com/docs/overflow
|
|
392
392
|
*/
|
|
393
393
|
"overflow-y": [{
|
|
394
|
-
"overflow-y":
|
|
394
|
+
"overflow-y": _()
|
|
395
395
|
}],
|
|
396
396
|
/**
|
|
397
397
|
* Overscroll Behavior
|
|
398
398
|
* @see https://tailwindcss.com/docs/overscroll-behavior
|
|
399
399
|
*/
|
|
400
400
|
overscroll: [{
|
|
401
|
-
overscroll:
|
|
401
|
+
overscroll: w()
|
|
402
402
|
}],
|
|
403
403
|
/**
|
|
404
404
|
* Overscroll Behavior X
|
|
405
405
|
* @see https://tailwindcss.com/docs/overscroll-behavior
|
|
406
406
|
*/
|
|
407
407
|
"overscroll-x": [{
|
|
408
|
-
"overscroll-x":
|
|
408
|
+
"overscroll-x": w()
|
|
409
409
|
}],
|
|
410
410
|
/**
|
|
411
411
|
* Overscroll Behavior Y
|
|
412
412
|
* @see https://tailwindcss.com/docs/overscroll-behavior
|
|
413
413
|
*/
|
|
414
414
|
"overscroll-y": [{
|
|
415
|
-
"overscroll-y":
|
|
415
|
+
"overscroll-y": w()
|
|
416
416
|
}],
|
|
417
417
|
/**
|
|
418
418
|
* Position
|
|
@@ -492,7 +492,7 @@ const B = (e) => {
|
|
|
492
492
|
* @see https://tailwindcss.com/docs/z-index
|
|
493
493
|
*/
|
|
494
494
|
z: [{
|
|
495
|
-
z: ["auto", Pe,
|
|
495
|
+
z: ["auto", Pe, R]
|
|
496
496
|
}],
|
|
497
497
|
// Flexbox and Grid
|
|
498
498
|
/**
|
|
@@ -500,7 +500,7 @@ const B = (e) => {
|
|
|
500
500
|
* @see https://tailwindcss.com/docs/flex-basis
|
|
501
501
|
*/
|
|
502
502
|
basis: [{
|
|
503
|
-
basis:
|
|
503
|
+
basis: U()
|
|
504
504
|
}],
|
|
505
505
|
/**
|
|
506
506
|
* Flex Direction
|
|
@@ -521,28 +521,28 @@ const B = (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", R]
|
|
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: L()
|
|
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: L()
|
|
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", Pe,
|
|
545
|
+
order: ["first", "last", "none", Pe, R]
|
|
546
546
|
}],
|
|
547
547
|
/**
|
|
548
548
|
* Grid Template Columns
|
|
@@ -557,22 +557,22 @@ const B = (e) => {
|
|
|
557
557
|
*/
|
|
558
558
|
"col-start-end": [{
|
|
559
559
|
col: ["auto", {
|
|
560
|
-
span: ["full", Pe,
|
|
561
|
-
},
|
|
560
|
+
span: ["full", Pe, R]
|
|
561
|
+
}, R]
|
|
562
562
|
}],
|
|
563
563
|
/**
|
|
564
564
|
* Grid Column Start
|
|
565
565
|
* @see https://tailwindcss.com/docs/grid-column
|
|
566
566
|
*/
|
|
567
567
|
"col-start": [{
|
|
568
|
-
"col-start":
|
|
568
|
+
"col-start": j()
|
|
569
569
|
}],
|
|
570
570
|
/**
|
|
571
571
|
* Grid Column End
|
|
572
572
|
* @see https://tailwindcss.com/docs/grid-column
|
|
573
573
|
*/
|
|
574
574
|
"col-end": [{
|
|
575
|
-
"col-end":
|
|
575
|
+
"col-end": j()
|
|
576
576
|
}],
|
|
577
577
|
/**
|
|
578
578
|
* Grid Template Rows
|
|
@@ -587,22 +587,22 @@ const B = (e) => {
|
|
|
587
587
|
*/
|
|
588
588
|
"row-start-end": [{
|
|
589
589
|
row: ["auto", {
|
|
590
|
-
span: [Pe,
|
|
591
|
-
},
|
|
590
|
+
span: [Pe, R]
|
|
591
|
+
}, R]
|
|
592
592
|
}],
|
|
593
593
|
/**
|
|
594
594
|
* Grid Row Start
|
|
595
595
|
* @see https://tailwindcss.com/docs/grid-row
|
|
596
596
|
*/
|
|
597
597
|
"row-start": [{
|
|
598
|
-
"row-start":
|
|
598
|
+
"row-start": j()
|
|
599
599
|
}],
|
|
600
600
|
/**
|
|
601
601
|
* Grid Row End
|
|
602
602
|
* @see https://tailwindcss.com/docs/grid-row
|
|
603
603
|
*/
|
|
604
604
|
"row-end": [{
|
|
605
|
-
"row-end":
|
|
605
|
+
"row-end": j()
|
|
606
606
|
}],
|
|
607
607
|
/**
|
|
608
608
|
* Grid Auto Flow
|
|
@@ -616,14 +616,14 @@ const B = (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", R]
|
|
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", R]
|
|
627
627
|
}],
|
|
628
628
|
/**
|
|
629
629
|
* Gap
|
|
@@ -841,7 +841,7 @@ const B = (e) => {
|
|
|
841
841
|
* @see https://tailwindcss.com/docs/space
|
|
842
842
|
*/
|
|
843
843
|
"space-x": [{
|
|
844
|
-
"space-x": [
|
|
844
|
+
"space-x": [A]
|
|
845
845
|
}],
|
|
846
846
|
/**
|
|
847
847
|
* Space Between X Reverse
|
|
@@ -853,7 +853,7 @@ const B = (e) => {
|
|
|
853
853
|
* @see https://tailwindcss.com/docs/space
|
|
854
854
|
*/
|
|
855
855
|
"space-y": [{
|
|
856
|
-
"space-y": [
|
|
856
|
+
"space-y": [A]
|
|
857
857
|
}],
|
|
858
858
|
/**
|
|
859
859
|
* Space Between Y Reverse
|
|
@@ -866,21 +866,21 @@ const B = (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", R, 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": [R, t, "min", "max", "fit"]
|
|
877
877
|
}],
|
|
878
878
|
/**
|
|
879
879
|
* Max-Width
|
|
880
880
|
* @see https://tailwindcss.com/docs/max-width
|
|
881
881
|
*/
|
|
882
882
|
"max-w": [{
|
|
883
|
-
"max-w": [
|
|
883
|
+
"max-w": [R, t, "none", "full", "min", "max", "fit", "prose", {
|
|
884
884
|
screen: [we]
|
|
885
885
|
}, we]
|
|
886
886
|
}],
|
|
@@ -889,28 +889,28 @@ const B = (e) => {
|
|
|
889
889
|
* @see https://tailwindcss.com/docs/height
|
|
890
890
|
*/
|
|
891
891
|
h: [{
|
|
892
|
-
h: [
|
|
892
|
+
h: [R, 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": [R, 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": [R, 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: [R, t, "auto", "min", "max", "fit"]
|
|
914
914
|
}],
|
|
915
915
|
// Typography
|
|
916
916
|
/**
|
|
@@ -979,35 +979,35 @@ const B = (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", R]
|
|
983
983
|
}],
|
|
984
984
|
/**
|
|
985
985
|
* Line Clamp
|
|
986
986
|
* @see https://tailwindcss.com/docs/line-clamp
|
|
987
987
|
*/
|
|
988
988
|
"line-clamp": [{
|
|
989
|
-
"line-clamp": ["none",
|
|
989
|
+
"line-clamp": ["none", Ae, Ke]
|
|
990
990
|
}],
|
|
991
991
|
/**
|
|
992
992
|
* Line Height
|
|
993
993
|
* @see https://tailwindcss.com/docs/line-height
|
|
994
994
|
*/
|
|
995
995
|
leading: [{
|
|
996
|
-
leading: ["none", "tight", "snug", "normal", "relaxed", "loose",
|
|
996
|
+
leading: ["none", "tight", "snug", "normal", "relaxed", "loose", pe, R]
|
|
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", R]
|
|
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", R]
|
|
1011
1011
|
}],
|
|
1012
1012
|
/**
|
|
1013
1013
|
* List Style Position
|
|
@@ -1062,21 +1062,21 @@ const B = (e) => {
|
|
|
1062
1062
|
* @see https://tailwindcss.com/docs/text-decoration-style
|
|
1063
1063
|
*/
|
|
1064
1064
|
"text-decoration-style": [{
|
|
1065
|
-
decoration: [...
|
|
1065
|
+
decoration: [...B(), "wavy"]
|
|
1066
1066
|
}],
|
|
1067
1067
|
/**
|
|
1068
1068
|
* Text Decoration Thickness
|
|
1069
1069
|
* @see https://tailwindcss.com/docs/text-decoration-thickness
|
|
1070
1070
|
*/
|
|
1071
1071
|
"text-decoration-thickness": [{
|
|
1072
|
-
decoration: ["auto", "from-font",
|
|
1072
|
+
decoration: ["auto", "from-font", pe, be]
|
|
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",
|
|
1079
|
+
"underline-offset": ["auto", pe, R]
|
|
1080
1080
|
}],
|
|
1081
1081
|
/**
|
|
1082
1082
|
* Text Decoration Color
|
|
@@ -1114,7 +1114,7 @@ const B = (e) => {
|
|
|
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", R]
|
|
1118
1118
|
}],
|
|
1119
1119
|
/**
|
|
1120
1120
|
* Whitespace
|
|
@@ -1142,7 +1142,7 @@ const B = (e) => {
|
|
|
1142
1142
|
* @see https://tailwindcss.com/docs/content
|
|
1143
1143
|
*/
|
|
1144
1144
|
content: [{
|
|
1145
|
-
content: ["none",
|
|
1145
|
+
content: ["none", R]
|
|
1146
1146
|
}],
|
|
1147
1147
|
// Backgrounds
|
|
1148
1148
|
/**
|
|
@@ -1179,7 +1179,7 @@ const B = (e) => {
|
|
|
1179
1179
|
* @see https://tailwindcss.com/docs/background-position
|
|
1180
1180
|
*/
|
|
1181
1181
|
"bg-position": [{
|
|
1182
|
-
bg: [...
|
|
1182
|
+
bg: [...N(), kn]
|
|
1183
1183
|
}],
|
|
1184
1184
|
/**
|
|
1185
1185
|
* Background Repeat
|
|
@@ -1436,7 +1436,7 @@ const B = (e) => {
|
|
|
1436
1436
|
* @see https://tailwindcss.com/docs/border-style
|
|
1437
1437
|
*/
|
|
1438
1438
|
"border-style": [{
|
|
1439
|
-
border: [...
|
|
1439
|
+
border: [...B(), "hidden"]
|
|
1440
1440
|
}],
|
|
1441
1441
|
/**
|
|
1442
1442
|
* Divide Width X
|
|
@@ -1474,7 +1474,7 @@ const B = (e) => {
|
|
|
1474
1474
|
* @see https://tailwindcss.com/docs/divide-style
|
|
1475
1475
|
*/
|
|
1476
1476
|
"divide-style": [{
|
|
1477
|
-
divide:
|
|
1477
|
+
divide: B()
|
|
1478
1478
|
}],
|
|
1479
1479
|
/**
|
|
1480
1480
|
* Border Color
|
|
@@ -1551,21 +1551,21 @@ const B = (e) => {
|
|
|
1551
1551
|
* @see https://tailwindcss.com/docs/outline-style
|
|
1552
1552
|
*/
|
|
1553
1553
|
"outline-style": [{
|
|
1554
|
-
outline: ["", ...
|
|
1554
|
+
outline: ["", ...B()]
|
|
1555
1555
|
}],
|
|
1556
1556
|
/**
|
|
1557
1557
|
* Outline Offset
|
|
1558
1558
|
* @see https://tailwindcss.com/docs/outline-offset
|
|
1559
1559
|
*/
|
|
1560
1560
|
"outline-offset": [{
|
|
1561
|
-
"outline-offset": [
|
|
1561
|
+
"outline-offset": [pe, R]
|
|
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: [
|
|
1568
|
+
outline: [pe, be]
|
|
1569
1569
|
}],
|
|
1570
1570
|
/**
|
|
1571
1571
|
* Outline Color
|
|
@@ -1579,7 +1579,7 @@ const B = (e) => {
|
|
|
1579
1579
|
* @see https://tailwindcss.com/docs/ring-width
|
|
1580
1580
|
*/
|
|
1581
1581
|
"ring-w": [{
|
|
1582
|
-
ring:
|
|
1582
|
+
ring: E()
|
|
1583
1583
|
}],
|
|
1584
1584
|
/**
|
|
1585
1585
|
* Ring Width Inset
|
|
@@ -1605,7 +1605,7 @@ const B = (e) => {
|
|
|
1605
1605
|
* @see https://tailwindcss.com/docs/ring-offset-width
|
|
1606
1606
|
*/
|
|
1607
1607
|
"ring-offset-w": [{
|
|
1608
|
-
"ring-offset": [
|
|
1608
|
+
"ring-offset": [pe, be]
|
|
1609
1609
|
}],
|
|
1610
1610
|
/**
|
|
1611
1611
|
* Ring Offset Color
|
|
@@ -1620,7 +1620,7 @@ const B = (e) => {
|
|
|
1620
1620
|
* @see https://tailwindcss.com/docs/box-shadow
|
|
1621
1621
|
*/
|
|
1622
1622
|
shadow: [{
|
|
1623
|
-
shadow: ["", "inner", "none", we,
|
|
1623
|
+
shadow: ["", "inner", "none", we, An]
|
|
1624
1624
|
}],
|
|
1625
1625
|
/**
|
|
1626
1626
|
* Box Shadow Color
|
|
@@ -1641,14 +1641,14 @@ const B = (e) => {
|
|
|
1641
1641
|
* @see https://tailwindcss.com/docs/mix-blend-mode
|
|
1642
1642
|
*/
|
|
1643
1643
|
"mix-blend": [{
|
|
1644
|
-
"mix-blend": [...
|
|
1644
|
+
"mix-blend": [...O(), "plus-lighter", "plus-darker"]
|
|
1645
1645
|
}],
|
|
1646
1646
|
/**
|
|
1647
1647
|
* Background Blend Mode
|
|
1648
1648
|
* @see https://tailwindcss.com/docs/background-blend-mode
|
|
1649
1649
|
*/
|
|
1650
1650
|
"bg-blend": [{
|
|
1651
|
-
"bg-blend":
|
|
1651
|
+
"bg-blend": O()
|
|
1652
1652
|
}],
|
|
1653
1653
|
// Filters
|
|
1654
1654
|
/**
|
|
@@ -1685,7 +1685,7 @@ const B = (e) => {
|
|
|
1685
1685
|
* @see https://tailwindcss.com/docs/drop-shadow
|
|
1686
1686
|
*/
|
|
1687
1687
|
"drop-shadow": [{
|
|
1688
|
-
"drop-shadow": ["", "none", we,
|
|
1688
|
+
"drop-shadow": ["", "none", we, R]
|
|
1689
1689
|
}],
|
|
1690
1690
|
/**
|
|
1691
1691
|
* Grayscale
|
|
@@ -1720,7 +1720,7 @@ const B = (e) => {
|
|
|
1720
1720
|
* @see https://tailwindcss.com/docs/sepia
|
|
1721
1721
|
*/
|
|
1722
1722
|
sepia: [{
|
|
1723
|
-
sepia: [
|
|
1723
|
+
sepia: [b]
|
|
1724
1724
|
}],
|
|
1725
1725
|
/**
|
|
1726
1726
|
* Backdrop Filter
|
|
@@ -1791,7 +1791,7 @@ const B = (e) => {
|
|
|
1791
1791
|
* @see https://tailwindcss.com/docs/backdrop-sepia
|
|
1792
1792
|
*/
|
|
1793
1793
|
"backdrop-sepia": [{
|
|
1794
|
-
"backdrop-sepia": [
|
|
1794
|
+
"backdrop-sepia": [b]
|
|
1795
1795
|
}],
|
|
1796
1796
|
// Tables
|
|
1797
1797
|
/**
|
|
@@ -1842,35 +1842,35 @@ const B = (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", R]
|
|
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: Z()
|
|
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", R]
|
|
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: Z()
|
|
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", R]
|
|
1874
1874
|
}],
|
|
1875
1875
|
// Transforms
|
|
1876
1876
|
/**
|
|
@@ -1885,28 +1885,28 @@ const B = (e) => {
|
|
|
1885
1885
|
* @see https://tailwindcss.com/docs/scale
|
|
1886
1886
|
*/
|
|
1887
1887
|
scale: [{
|
|
1888
|
-
scale: [
|
|
1888
|
+
scale: [P]
|
|
1889
1889
|
}],
|
|
1890
1890
|
/**
|
|
1891
1891
|
* Scale X
|
|
1892
1892
|
* @see https://tailwindcss.com/docs/scale
|
|
1893
1893
|
*/
|
|
1894
1894
|
"scale-x": [{
|
|
1895
|
-
"scale-x": [
|
|
1895
|
+
"scale-x": [P]
|
|
1896
1896
|
}],
|
|
1897
1897
|
/**
|
|
1898
1898
|
* Scale Y
|
|
1899
1899
|
* @see https://tailwindcss.com/docs/scale
|
|
1900
1900
|
*/
|
|
1901
1901
|
"scale-y": [{
|
|
1902
|
-
"scale-y": [
|
|
1902
|
+
"scale-y": [P]
|
|
1903
1903
|
}],
|
|
1904
1904
|
/**
|
|
1905
1905
|
* Rotate
|
|
1906
1906
|
* @see https://tailwindcss.com/docs/rotate
|
|
1907
1907
|
*/
|
|
1908
1908
|
rotate: [{
|
|
1909
|
-
rotate: [Pe,
|
|
1909
|
+
rotate: [Pe, R]
|
|
1910
1910
|
}],
|
|
1911
1911
|
/**
|
|
1912
1912
|
* Translate X
|
|
@@ -1941,7 +1941,7 @@ const B = (e) => {
|
|
|
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", R]
|
|
1945
1945
|
}],
|
|
1946
1946
|
// Interactivity
|
|
1947
1947
|
/**
|
|
@@ -1963,7 +1963,7 @@ const B = (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", R]
|
|
1967
1967
|
}],
|
|
1968
1968
|
/**
|
|
1969
1969
|
* Caret Color
|
|
@@ -2185,7 +2185,7 @@ const B = (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", R]
|
|
2189
2189
|
}],
|
|
2190
2190
|
// SVG
|
|
2191
2191
|
/**
|
|
@@ -2200,7 +2200,7 @@ const B = (e) => {
|
|
|
2200
2200
|
* @see https://tailwindcss.com/docs/stroke-width
|
|
2201
2201
|
*/
|
|
2202
2202
|
"stroke-w": [{
|
|
2203
|
-
stroke: [
|
|
2203
|
+
stroke: [pe, be, Ke]
|
|
2204
2204
|
}],
|
|
2205
2205
|
/**
|
|
2206
2206
|
* Stroke
|
|
@@ -2332,7 +2332,7 @@ function jn(e) {
|
|
|
2332
2332
|
function St(e) {
|
|
2333
2333
|
return Array.isArray(e.toolCalls) ? e.toolCalls : [];
|
|
2334
2334
|
}
|
|
2335
|
-
function
|
|
2335
|
+
function Fn(e) {
|
|
2336
2336
|
const t = [];
|
|
2337
2337
|
return e.forEach((n) => {
|
|
2338
2338
|
n.artifact && t.push(n.artifact), Array.isArray(n.toolCalls) && n.toolCalls.forEach((r) => {
|
|
@@ -2401,7 +2401,7 @@ function Zr(e) {
|
|
|
2401
2401
|
const t = Mt(e);
|
|
2402
2402
|
return typeof e == "string" && Nn(e) ? { content: e, isMarkdown: !0 } : { content: t, isMarkdown: !1 };
|
|
2403
2403
|
}
|
|
2404
|
-
function
|
|
2404
|
+
function Ln(e) {
|
|
2405
2405
|
const t = (r) => {
|
|
2406
2406
|
try {
|
|
2407
2407
|
const o = Ve(r);
|
|
@@ -2416,44 +2416,44 @@ function Fn(e) {
|
|
|
2416
2416
|
function eo(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 ue(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 = et(t);
|
|
2425
2425
|
if (n !== null)
|
|
2426
|
-
return
|
|
2426
|
+
return ue(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) => ue(t)).filter(Boolean).join(`
|
|
2433
|
+
`) : ue(e.content);
|
|
2434
2434
|
if (e.value !== void 0)
|
|
2435
|
-
return
|
|
2435
|
+
return ue(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 ? ue(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 tt(e) {
|
|
2451
|
-
var v, I, C, T,
|
|
2451
|
+
var v, I, C, T, P, b;
|
|
2452
2452
|
if (!e || typeof e != "object") return null;
|
|
2453
|
-
const t =
|
|
2453
|
+
const t = de(e), n = Vn(t);
|
|
2454
2454
|
if (!n)
|
|
2455
2455
|
return null;
|
|
2456
|
-
const r = Array.isArray(t.toolCalls) ? t.toolCalls.map(nt) : void 0, o = $n(t.content ?? t.parts, !!(r != null && r.length)), s = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, a = t.createdAt ?? ((v = t.additionalKwargs) == null ? void 0 : v.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), i = t.name ?? ((I = t.additionalKwargs) == null ? void 0 : I.agentName) ?? void 0, u = t.model ?? ((C = t.additionalKwargs) == null ? void 0 : C.model) ?? void 0, c = t.toolCallId ?? void 0, l = t.additionalKwargs ?? void 0, f = t.responseMetadata ?? void 0, m = t.checkpointId ?? ((T = t.additionalKwargs) == null ? void 0 : T.checkpointId) ?? void 0, h = t.checkpointNs ?? ((
|
|
2456
|
+
const r = Array.isArray(t.toolCalls) ? t.toolCalls.map(nt) : void 0, o = $n(t.content ?? t.parts, !!(r != null && r.length)), s = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, a = t.createdAt ?? ((v = t.additionalKwargs) == null ? void 0 : v.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), i = t.name ?? ((I = t.additionalKwargs) == null ? void 0 : I.agentName) ?? void 0, u = t.model ?? ((C = t.additionalKwargs) == null ? void 0 : C.model) ?? void 0, c = t.toolCallId ?? void 0, l = t.additionalKwargs ?? void 0, f = t.responseMetadata ?? void 0, m = t.checkpointId ?? ((T = t.additionalKwargs) == null ? void 0 : T.checkpointId) ?? void 0, h = t.checkpointNs ?? ((P = t.additionalKwargs) == null ? void 0 : P.checkpointNs) ?? void 0, k = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((b = t.additionalKwargs) != null && b.toolStreaming);
|
|
2457
2457
|
return {
|
|
2458
2458
|
...t,
|
|
2459
2459
|
id: s,
|
|
@@ -2474,7 +2474,7 @@ function tt(e) {
|
|
|
2474
2474
|
}
|
|
2475
2475
|
function Bn(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.id && n.artifactId && (n.id = n.artifactId), !n.type && n.artifactType && (n.type = n.artifactType);
|
|
@@ -2482,7 +2482,7 @@ function Bn(e) {
|
|
|
2482
2482
|
return t;
|
|
2483
2483
|
}
|
|
2484
2484
|
function nt(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 nt(e) {
|
|
|
2493
2493
|
};
|
|
2494
2494
|
}
|
|
2495
2495
|
function $n(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 : nt(
|
|
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 : nt(de(n)) : n).filter(
|
|
2497
2497
|
(n) => !!(n && typeof n == "object" && typeof n.type == "string")
|
|
2498
2498
|
) : [];
|
|
2499
2499
|
}
|
|
2500
2500
|
function Vn(e) {
|
|
2501
|
-
const t =
|
|
2501
|
+
const t = de(e), n = t.role;
|
|
2502
2502
|
if (n && (n === "assistant" || n === "user" || n === "system" || n === "tool" || n === "interrupt"))
|
|
2503
2503
|
return n;
|
|
2504
2504
|
const r = t.type;
|
|
@@ -2540,7 +2540,7 @@ function Kn(e, t = []) {
|
|
|
2540
2540
|
var f, m, h;
|
|
2541
2541
|
const i = Ge(a.id, e) || Ge(a.id, t), u = Array.isArray((f = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : f.toolProgress) ? (m = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : m.toolProgress : void 0, c = (i == null ? void 0 : i.artifact) ?? a.artifact, l = lt(a.status) ?? ((h = i == null ? void 0 : i.additionalKwargs) != null && h.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
|
|
2542
2542
|
if (i && !a.content && l === "completed") {
|
|
2543
|
-
const k =
|
|
2543
|
+
const k = ue(i);
|
|
2544
2544
|
typeof k == "string" && (a.content = k);
|
|
2545
2545
|
}
|
|
2546
2546
|
return {
|
|
@@ -2558,7 +2558,7 @@ function Kn(e, t = []) {
|
|
|
2558
2558
|
var u, c, l;
|
|
2559
2559
|
const o = Ge(r.id, t) ?? Dn(e, r), s = Array.isArray((u = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : u.toolProgress) ? (c = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : c.toolProgress : void 0, a = (o == null ? void 0 : o.artifact) ?? r.artifact, i = lt(r.status) ?? ((l = o == null ? void 0 : o.additionalKwargs) != null && l.toolStreaming ? "pending" : null) ?? (o ? "completed" : "pending");
|
|
2560
2560
|
if (o && !r.content && i === "completed") {
|
|
2561
|
-
const f =
|
|
2561
|
+
const f = ue(o);
|
|
2562
2562
|
typeof f == "string" && (r.content = f);
|
|
2563
2563
|
}
|
|
2564
2564
|
return {
|
|
@@ -2590,7 +2590,7 @@ const Xe = /* @__PURE__ */ new Set();
|
|
|
2590
2590
|
function Et() {
|
|
2591
2591
|
return De;
|
|
2592
2592
|
}
|
|
2593
|
-
function
|
|
2593
|
+
function Ie(e) {
|
|
2594
2594
|
De = e, Xe.forEach((t) => t(e));
|
|
2595
2595
|
}
|
|
2596
2596
|
function Pt(e) {
|
|
@@ -2598,7 +2598,7 @@ function Pt(e) {
|
|
|
2598
2598
|
}
|
|
2599
2599
|
const Gn = 12e4, Hn = 12e4;
|
|
2600
2600
|
let Qe = Gn, Nt = Hn;
|
|
2601
|
-
const
|
|
2601
|
+
const oe = qt.create({
|
|
2602
2602
|
// BaseURL is set dynamically via ApiProvider -> api.updateConfig
|
|
2603
2603
|
timeout: Qe,
|
|
2604
2604
|
withCredentials: !0
|
|
@@ -2608,18 +2608,18 @@ function dt(e) {
|
|
|
2608
2608
|
}
|
|
2609
2609
|
function Wn(e) {
|
|
2610
2610
|
const t = dt(e.requestTimeoutMs), n = dt(e.historyTimeoutMs);
|
|
2611
|
-
t !== null && (Qe = t,
|
|
2611
|
+
t !== null && (Qe = t, oe.defaults.timeout = Qe), n !== null && (Nt = n);
|
|
2612
2612
|
}
|
|
2613
2613
|
function qn() {
|
|
2614
2614
|
return Nt;
|
|
2615
2615
|
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2616
|
+
oe.interceptors.request.use((e) => (De && (e.headers.Authorization = `Bearer ${De}`), e));
|
|
2617
|
+
oe.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(_e.authToken, r),
|
|
2622
|
+
r && (localStorage.setItem(_e.authToken, r), Ie(r)), o && localStorage.setItem(_e.authTokenExpiresAt, o.toString()), (r || o) && window.dispatchEvent(
|
|
2623
2623
|
new CustomEvent("smartorg:chat-token-updated", {
|
|
2624
2624
|
detail: { token: r, expiresAt: o }
|
|
2625
2625
|
})
|
|
@@ -2631,19 +2631,19 @@ re.interceptors.response.use(
|
|
|
2631
2631
|
},
|
|
2632
2632
|
(e) => Promise.reject(e)
|
|
2633
2633
|
);
|
|
2634
|
-
async function
|
|
2635
|
-
return
|
|
2634
|
+
async function ae(e, t) {
|
|
2635
|
+
return oe.defaults.baseURL ? (await oe.get(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2636
2636
|
}
|
|
2637
2637
|
async function Ye(e, t, n) {
|
|
2638
|
-
return
|
|
2638
|
+
return oe.defaults.baseURL ? (await oe.post(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2639
2639
|
}
|
|
2640
2640
|
async function Jn(e, t, n) {
|
|
2641
|
-
return
|
|
2641
|
+
return oe.defaults.baseURL ? (await oe.put(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2642
2642
|
}
|
|
2643
2643
|
async function Xn(e, t) {
|
|
2644
|
-
return
|
|
2644
|
+
return oe.defaults.baseURL ? (await oe.delete(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2645
2645
|
}
|
|
2646
|
-
function
|
|
2646
|
+
function ce(e) {
|
|
2647
2647
|
return e && typeof e == "object" && "data" in e ? e.data : e;
|
|
2648
2648
|
}
|
|
2649
2649
|
class Qn {
|
|
@@ -2651,16 +2651,16 @@ class Qn {
|
|
|
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 oe.defaults.baseURL || "";
|
|
2655
2655
|
}
|
|
2656
2656
|
updateConfig(t) {
|
|
2657
2657
|
if (t.chatBaseUrl)
|
|
2658
|
-
|
|
2658
|
+
oe.defaults.baseURL = t.chatBaseUrl;
|
|
2659
2659
|
else if (t.baseUrl) {
|
|
2660
2660
|
const n = t.baseUrl.replace(/\/+$/, "");
|
|
2661
|
-
|
|
2661
|
+
oe.defaults.baseURL = n;
|
|
2662
2662
|
}
|
|
2663
|
-
t.apiKey !== void 0 ?
|
|
2663
|
+
t.apiKey !== void 0 ? Ie(t.apiKey) : t.getToken && Ie(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 Qn {
|
|
|
2670
2670
|
return Et();
|
|
2671
2671
|
}
|
|
2672
2672
|
setAuthToken(t) {
|
|
2673
|
-
|
|
2673
|
+
Ie(t);
|
|
2674
2674
|
}
|
|
2675
2675
|
onTokenChange(t) {
|
|
2676
2676
|
return Pt(t);
|
|
2677
2677
|
}
|
|
2678
2678
|
// ---- Thread Management ----
|
|
2679
2679
|
async listThreads() {
|
|
2680
|
-
const t = await
|
|
2680
|
+
const t = await ae("/threads"), n = ce(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,44 +2685,44 @@ class Qn {
|
|
|
2685
2685
|
const r = {};
|
|
2686
2686
|
t && (r.title = t), n && (r.project = n);
|
|
2687
2687
|
const o = await Ye("/threads", Object.keys(r).length ? r : void 0);
|
|
2688
|
-
return
|
|
2688
|
+
return ce(o);
|
|
2689
2689
|
}
|
|
2690
2690
|
async updateThread(t, n) {
|
|
2691
2691
|
const r = await Jn(`/threads/${t}`, { title: n });
|
|
2692
|
-
return
|
|
2692
|
+
return ce(r);
|
|
2693
2693
|
}
|
|
2694
2694
|
async deleteThread(t) {
|
|
2695
2695
|
const n = await Xn(`/threads/${t}`);
|
|
2696
|
-
return
|
|
2696
|
+
return ce(n);
|
|
2697
2697
|
}
|
|
2698
2698
|
async threadInfo(t) {
|
|
2699
|
-
const n = await
|
|
2700
|
-
return
|
|
2699
|
+
const n = await ae(`/threads/${t}/info`);
|
|
2700
|
+
return ce(n);
|
|
2701
2701
|
}
|
|
2702
2702
|
// ---- Agents ----
|
|
2703
2703
|
async listAgents() {
|
|
2704
|
-
const t = await
|
|
2704
|
+
const t = await ae("/agents"), n = ce(t);
|
|
2705
2705
|
return (n == null ? void 0 : n.items) ?? [];
|
|
2706
2706
|
}
|
|
2707
2707
|
async getAgent(t) {
|
|
2708
|
-
const n = await
|
|
2709
|
-
return
|
|
2708
|
+
const n = await ae(`/agents/${t}`);
|
|
2709
|
+
return ce(n);
|
|
2710
2710
|
}
|
|
2711
2711
|
async getAgentSchema(t) {
|
|
2712
|
-
const n = await
|
|
2713
|
-
return
|
|
2712
|
+
const n = await ae(`/agents/${t}/schema`);
|
|
2713
|
+
return ce(n);
|
|
2714
2714
|
}
|
|
2715
2715
|
async getState(t) {
|
|
2716
|
-
const n = await
|
|
2716
|
+
const n = await ae(`/threads/${t.threadId}/state`, {
|
|
2717
2717
|
params: {
|
|
2718
2718
|
checkpoint_id: t.checkpointId,
|
|
2719
2719
|
checkpoint_ns: t.checkpointNs
|
|
2720
2720
|
}
|
|
2721
2721
|
});
|
|
2722
|
-
return
|
|
2722
|
+
return ce(n);
|
|
2723
2723
|
}
|
|
2724
2724
|
async getStateHistory(t) {
|
|
2725
|
-
const n = await
|
|
2725
|
+
const n = await ae(`/threads/${t.threadId}/state/history`, {
|
|
2726
2726
|
params: {
|
|
2727
2727
|
checkpoint_id: t.checkpointId,
|
|
2728
2728
|
checkpoint_ns: t.checkpointNs,
|
|
@@ -2733,12 +2733,12 @@ class Qn {
|
|
|
2733
2733
|
timeout: qn(),
|
|
2734
2734
|
signal: t.signal
|
|
2735
2735
|
});
|
|
2736
|
-
return
|
|
2736
|
+
return ce(n);
|
|
2737
2737
|
}
|
|
2738
2738
|
// ---- Run Management ----
|
|
2739
2739
|
async cancelRun(t) {
|
|
2740
2740
|
const n = await Ye(`/runs/${t}/cancel`);
|
|
2741
|
-
return
|
|
2741
|
+
return ce(n);
|
|
2742
2742
|
}
|
|
2743
2743
|
}
|
|
2744
2744
|
const _t = new Qn();
|
|
@@ -2746,7 +2746,7 @@ class Yn {
|
|
|
2746
2746
|
// Config logic could go here if files ever need a distinct base URL from chat
|
|
2747
2747
|
// For now, it shares the chatBaseUrl via the shared httpClient
|
|
2748
2748
|
async fetchFileBlob(t, n) {
|
|
2749
|
-
return await
|
|
2749
|
+
return await ae(t, {
|
|
2750
2750
|
responseType: "blob",
|
|
2751
2751
|
onDownloadProgress: (o) => {
|
|
2752
2752
|
try {
|
|
@@ -2775,7 +2775,7 @@ class Yn {
|
|
|
2775
2775
|
const r = await this.fetchFileBlob(`/files/${t}/download`, n), o = URL.createObjectURL(r);
|
|
2776
2776
|
let s = `file_${t}`;
|
|
2777
2777
|
try {
|
|
2778
|
-
const i = await
|
|
2778
|
+
const i = await ae(`/files/${t}`);
|
|
2779
2779
|
s = (i == null ? void 0 : i.filename) ?? s;
|
|
2780
2780
|
} catch {
|
|
2781
2781
|
}
|
|
@@ -2783,11 +2783,11 @@ class Yn {
|
|
|
2783
2783
|
a.href = o, a.download = s, document.body.appendChild(a), a.click(), a.remove(), setTimeout(() => URL.revokeObjectURL(o), 6e4);
|
|
2784
2784
|
}
|
|
2785
2785
|
async getFileInfo(t) {
|
|
2786
|
-
return await
|
|
2786
|
+
return await ae(`/files/${t}`);
|
|
2787
2787
|
}
|
|
2788
2788
|
async listFiles(t, n = 50, r = 0) {
|
|
2789
2789
|
const o = { limit: n, offset: r };
|
|
2790
|
-
return t && (o.thread_id = t), await
|
|
2790
|
+
return t && (o.thread_id = t), await ae("/files", { params: o });
|
|
2791
2791
|
}
|
|
2792
2792
|
async uploadFile(t, n, r) {
|
|
2793
2793
|
const o = new FormData();
|
|
@@ -2820,21 +2820,21 @@ class Zn {
|
|
|
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 ? Ie(t.apiKey) : t.getToken && Ie(t.getToken());
|
|
2824
2824
|
}
|
|
2825
2825
|
// ---- Token Management ----
|
|
2826
2826
|
getAuthToken() {
|
|
2827
2827
|
return Et();
|
|
2828
2828
|
}
|
|
2829
2829
|
setAuthToken(t) {
|
|
2830
|
-
|
|
2830
|
+
Ie(t);
|
|
2831
2831
|
}
|
|
2832
2832
|
onTokenChange(t) {
|
|
2833
2833
|
return Pt(t);
|
|
2834
2834
|
}
|
|
2835
2835
|
// ---- User Management ----
|
|
2836
2836
|
async listUsers() {
|
|
2837
|
-
const t = await
|
|
2837
|
+
const t = await ae("/users", { baseURL: this.baseUrl });
|
|
2838
2838
|
return (t == null ? void 0 : t.users) ?? [];
|
|
2839
2839
|
}
|
|
2840
2840
|
}
|
|
@@ -2855,7 +2855,7 @@ function tr({ children: e, apiConfig: t }) {
|
|
|
2855
2855
|
fileApi: zt,
|
|
2856
2856
|
baseUrl: n.baseUrl
|
|
2857
2857
|
};
|
|
2858
|
-
return /* @__PURE__ */
|
|
2858
|
+
return /* @__PURE__ */ le(Rt.Provider, { value: o, children: e });
|
|
2859
2859
|
}
|
|
2860
2860
|
async function nr(e) {
|
|
2861
2861
|
return await new Promise((t, n) => {
|
|
@@ -2930,7 +2930,7 @@ function oo(e) {
|
|
|
2930
2930
|
}).join("|") : "", r = "checkpointId" in e && e.checkpointId ? `cp:${e.checkpointId}` : "", o = "checkpointNs" in e && e.checkpointNs ? `ns:${e.checkpointNs}` : "", s = [r, o].filter(Boolean).join("|");
|
|
2931
2931
|
return `${e.id}:${t}:${n}${s ? `:${s}` : ""}`;
|
|
2932
2932
|
}
|
|
2933
|
-
function
|
|
2933
|
+
function xe() {
|
|
2934
2934
|
const e = Ue(Rt);
|
|
2935
2935
|
if (!e) throw new Error("useApi must be used within ApiProvider");
|
|
2936
2936
|
return e;
|
|
@@ -2952,33 +2952,33 @@ function ir(e) {
|
|
|
2952
2952
|
return !!e && typeof e == "object" && "data" in e;
|
|
2953
2953
|
}
|
|
2954
2954
|
function cr(e = {}) {
|
|
2955
|
-
const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, o] =
|
|
2955
|
+
const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, o] = V(e.token ?? null), s = K(e.headers ?? {}), a = e.credentials ?? "include", i = K(e);
|
|
2956
2956
|
q(() => {
|
|
2957
2957
|
i.current = e;
|
|
2958
2958
|
}, [e]);
|
|
2959
|
-
const u =
|
|
2960
|
-
var
|
|
2961
|
-
const
|
|
2962
|
-
if (!
|
|
2963
|
-
(
|
|
2964
|
-
}, []), [c, l] =
|
|
2959
|
+
const u = z((p) => {
|
|
2960
|
+
var U, M, E, j, N, B, O, F, L, W;
|
|
2961
|
+
const w = i.current;
|
|
2962
|
+
if (!w) return;
|
|
2963
|
+
(U = w.onEvent) == null || U.call(w, p), p.type === "thread_info" && ((M = w.onThreadInfo) == null || M.call(w, p)), p.type === "values" && Array.isArray(p.checkpoints) && ((E = w.handleValuesEvent) == null || E.call(w, p)), p.type === "metadata" && ((j = w.onMetadataEvent) == null || j.call(w, p)), typeof p.type == "string" && (p.type === "custom" || p.type.startsWith("custom.")) && ((N = w.onCustomEvent) == null || N.call(w, p)), p.type === "updates" && ((B = w.onUpdateEvent) == null || B.call(w, p)), p.type === "tool.end" ? (O = w.onToolEnd) == null || O.call(w, p) : p.type === "tool.start" && ((F = w.onToolStart) == null || F.call(w, p)), p.type === "heartbeat" && ((L = w.onHeartbeat) == null || L.call(w, p)), p.type === "token" && ((W = w.onToken) == null || W.call(w, p.token));
|
|
2964
|
+
}, []), [c, l] = V(!1), [f, m] = V(null), [h, k] = V(!1), [d, v] = V(null), I = K(null), C = K(!0), T = K(null), P = z((p) => {
|
|
2965
2965
|
o(p);
|
|
2966
|
-
}, []),
|
|
2966
|
+
}, []), b = z(() => {
|
|
2967
2967
|
m(null), v(null);
|
|
2968
|
-
}, []), y =
|
|
2969
|
-
var M,
|
|
2968
|
+
}, []), y = z(() => {
|
|
2969
|
+
var M, E;
|
|
2970
2970
|
console.debug("[use-chat] stop() invoked - aborting stream");
|
|
2971
|
-
const p = (M = T.current) == null ? void 0 : M.threadId,
|
|
2972
|
-
var
|
|
2973
|
-
(
|
|
2971
|
+
const p = (M = T.current) == null ? void 0 : M.threadId, w = (E = T.current) == null ? void 0 : E.runId, _ = () => {
|
|
2972
|
+
var j;
|
|
2973
|
+
(j = I.current) == null || j.abort(), I.current = null, T.current = null, l(!1), k(!1);
|
|
2974
2974
|
};
|
|
2975
|
-
(
|
|
2976
|
-
console.warn("[use-chat] cancel run failed:",
|
|
2977
|
-
}) : Promise.resolve()).finally(
|
|
2978
|
-
}, []),
|
|
2975
|
+
(w || p ? _t.cancelRun(w || p).catch((j) => {
|
|
2976
|
+
console.warn("[use-chat] cancel run failed:", j);
|
|
2977
|
+
}) : Promise.resolve()).finally(_);
|
|
2978
|
+
}, []), A = z(
|
|
2979
2979
|
(p) => {
|
|
2980
2980
|
I.current && (I.current.abort(), I.current = null);
|
|
2981
|
-
const
|
|
2981
|
+
const w = {
|
|
2982
2982
|
text: typeof p.content == "string" ? p.content : p.text,
|
|
2983
2983
|
threadId: p.threadId,
|
|
2984
2984
|
attachments: p.attachments,
|
|
@@ -2990,171 +2990,187 @@ function cr(e = {}) {
|
|
|
2990
2990
|
command: p.command
|
|
2991
2991
|
};
|
|
2992
2992
|
l(!0), m(null), v(null);
|
|
2993
|
-
const
|
|
2994
|
-
I.current =
|
|
2995
|
-
let
|
|
2993
|
+
const _ = new AbortController();
|
|
2994
|
+
I.current = _;
|
|
2995
|
+
let U = null, M = !1;
|
|
2996
2996
|
return T.current = {
|
|
2997
|
-
threadId:
|
|
2997
|
+
threadId: w.threadId ?? void 0,
|
|
2998
2998
|
runId: void 0,
|
|
2999
2999
|
// Will be updated from headers
|
|
3000
3000
|
headers: {},
|
|
3001
3001
|
isStreaming: !0
|
|
3002
3002
|
}, (async () => {
|
|
3003
|
-
var
|
|
3003
|
+
var E, j, N, B, O, F;
|
|
3004
3004
|
try {
|
|
3005
|
-
let
|
|
3005
|
+
let L = {};
|
|
3006
3006
|
try {
|
|
3007
3007
|
if (r)
|
|
3008
|
-
|
|
3008
|
+
L = { Authorization: `Bearer ${r}` };
|
|
3009
3009
|
else if (typeof window < "u") {
|
|
3010
|
-
const
|
|
3010
|
+
const re = window.__AUTH_TOKEN__, ve = ((E = window.localStorage) == null ? void 0 : E.getItem(_e.authToken)) || null;
|
|
3011
3011
|
let X = null;
|
|
3012
3012
|
try {
|
|
3013
|
-
const
|
|
3014
|
-
|
|
3013
|
+
const he = (j = window.localStorage) == null ? void 0 : j.getItem(_e.chatSettings);
|
|
3014
|
+
he && (X = ((N = JSON.parse(he)) == null ? void 0 : N.apiKey) || null);
|
|
3015
3015
|
} catch {
|
|
3016
3016
|
}
|
|
3017
|
-
const
|
|
3018
|
-
|
|
3017
|
+
const ee = re || ve || X || null;
|
|
3018
|
+
ee && (L = { Authorization: `Bearer ${ee}` });
|
|
3019
3019
|
}
|
|
3020
3020
|
} catch {
|
|
3021
3021
|
}
|
|
3022
3022
|
console.debug("[use-chat] POST", t + n);
|
|
3023
|
-
let
|
|
3023
|
+
let W = {};
|
|
3024
3024
|
if (typeof window < "u")
|
|
3025
3025
|
try {
|
|
3026
|
-
const
|
|
3027
|
-
|
|
3026
|
+
const H = (B = window.localStorage) == null ? void 0 : B.getItem(_e.authSessionId);
|
|
3027
|
+
H && (W = { "X-Session-Id": H });
|
|
3028
3028
|
} catch {
|
|
3029
3029
|
}
|
|
3030
|
-
const
|
|
3031
|
-
...
|
|
3032
|
-
...
|
|
3030
|
+
const Z = {
|
|
3031
|
+
...L,
|
|
3032
|
+
...W,
|
|
3033
3033
|
...s.current
|
|
3034
3034
|
}, g = {
|
|
3035
3035
|
"Content-Type": "application/json",
|
|
3036
3036
|
Accept: "text/event-stream",
|
|
3037
|
-
...
|
|
3038
|
-
},
|
|
3037
|
+
...Z
|
|
3038
|
+
}, x = await fetch(t + n, {
|
|
3039
3039
|
method: "POST",
|
|
3040
3040
|
headers: g,
|
|
3041
|
-
body: JSON.stringify(
|
|
3042
|
-
signal:
|
|
3041
|
+
body: JSON.stringify(w),
|
|
3042
|
+
signal: _.signal,
|
|
3043
3043
|
credentials: a
|
|
3044
3044
|
});
|
|
3045
|
-
if (T.current && (T.current.headers =
|
|
3046
|
-
const
|
|
3045
|
+
if (T.current && (T.current.headers = Z), !x.ok || !x.body) {
|
|
3046
|
+
const H = await x.text().catch(() => "");
|
|
3047
3047
|
console.debug(
|
|
3048
3048
|
"[use-chat] non-OK response",
|
|
3049
|
-
|
|
3050
|
-
|
|
3049
|
+
x.status,
|
|
3050
|
+
H == null ? void 0 : H.slice(0, 500)
|
|
3051
3051
|
);
|
|
3052
|
-
const
|
|
3053
|
-
throw
|
|
3052
|
+
const re = `stream ${x.status}${H ? ": " + H : ""}`;
|
|
3053
|
+
throw re && (m(re), U = "error"), new Error(re);
|
|
3054
3054
|
}
|
|
3055
3055
|
k(!0);
|
|
3056
|
-
const S =
|
|
3057
|
-
let J = "", D = 0,
|
|
3058
|
-
const
|
|
3059
|
-
Date.now() -
|
|
3060
|
-
}, 5e3),
|
|
3056
|
+
const S = x.body.getReader(), G = new TextDecoder();
|
|
3057
|
+
let J = "", D = 0, ne = Date.now();
|
|
3058
|
+
const se = setInterval(() => {
|
|
3059
|
+
Date.now() - ne > 18e5 && (m("Stream idle timeout"), U = "error", _.abort());
|
|
3060
|
+
}, 5e3), fe = 1024 * 1024;
|
|
3061
3061
|
try {
|
|
3062
|
-
const
|
|
3062
|
+
const H = x.headers.get("X-Thread-Id") || x.headers.get("x-thread-id"), re = x.headers.get("X-Run-Id") || x.headers.get("x-run-id");
|
|
3063
3063
|
for (T.current && (T.current = {
|
|
3064
3064
|
...T.current,
|
|
3065
|
-
threadId:
|
|
3066
|
-
runId:
|
|
3065
|
+
threadId: H ?? T.current.threadId,
|
|
3066
|
+
runId: re ?? T.current.runId
|
|
3067
3067
|
}); ; ) {
|
|
3068
3068
|
const { value: ve, done: X } = await S.read();
|
|
3069
3069
|
if (X) break;
|
|
3070
|
-
J +=
|
|
3071
|
-
let
|
|
3072
|
-
for (; (
|
|
3070
|
+
J += G.decode(ve, { stream: !0 }), J.length > fe && (J = "", console.warn("Stream buffer reset: exceeded 1MB"));
|
|
3071
|
+
let ee;
|
|
3072
|
+
for (; (ee = J.indexOf(`
|
|
3073
3073
|
|
|
3074
3074
|
`)) >= 0; ) {
|
|
3075
|
-
const
|
|
3076
|
-
J = J.slice(
|
|
3077
|
-
const je =
|
|
3078
|
-
let
|
|
3079
|
-
for (const
|
|
3080
|
-
if (!
|
|
3081
|
-
if (
|
|
3082
|
-
const
|
|
3083
|
-
|
|
3075
|
+
const he = J.slice(0, ee);
|
|
3076
|
+
J = J.slice(ee + 2);
|
|
3077
|
+
const je = he.split(/\r?\n/), Fe = [];
|
|
3078
|
+
let ie = null;
|
|
3079
|
+
for (const Q of je)
|
|
3080
|
+
if (!Q.startsWith(":") && Q) {
|
|
3081
|
+
if (Q.startsWith("event:")) {
|
|
3082
|
+
const ke = Q.slice(6).trim();
|
|
3083
|
+
ke && (ie = ke);
|
|
3084
3084
|
continue;
|
|
3085
3085
|
}
|
|
3086
|
-
if (
|
|
3087
|
-
const
|
|
3088
|
-
|
|
3086
|
+
if (Q.startsWith("data:")) {
|
|
3087
|
+
const ke = Q.slice(5);
|
|
3088
|
+
Fe.push(ke.startsWith(" ") ? ke.slice(1) : ke);
|
|
3089
3089
|
}
|
|
3090
3090
|
}
|
|
3091
|
-
const
|
|
3091
|
+
const Te = Fe.join(`
|
|
3092
3092
|
`);
|
|
3093
|
-
if (!
|
|
3094
|
-
let
|
|
3093
|
+
if (!Te) continue;
|
|
3094
|
+
let te;
|
|
3095
3095
|
try {
|
|
3096
|
-
|
|
3096
|
+
te = JSON.parse(Te);
|
|
3097
3097
|
} catch {
|
|
3098
|
-
console.debug("[use-chat] malformed SSE:",
|
|
3098
|
+
console.debug("[use-chat] malformed SSE:", Te.slice(0, 200));
|
|
3099
3099
|
continue;
|
|
3100
3100
|
}
|
|
3101
|
-
|
|
3102
|
-
|
|
3101
|
+
if (ie && typeof te == "object" && te !== null)
|
|
3102
|
+
if (ie === "messages/partial" && Array.isArray(te))
|
|
3103
|
+
te = {
|
|
3104
|
+
type: "messages/partial",
|
|
3105
|
+
messages: te
|
|
3106
|
+
};
|
|
3107
|
+
else {
|
|
3108
|
+
const Q = te;
|
|
3109
|
+
"type" in Q ? ie === "messages/partial" && (Q.type === "ai" || Q.type === "assistant" || Q.role === "assistant") && (te = {
|
|
3110
|
+
type: "messages/partial",
|
|
3111
|
+
messages: [Q],
|
|
3112
|
+
// Preserve common meta fields if present.
|
|
3113
|
+
seq: Q.seq,
|
|
3114
|
+
scope: Q.scope,
|
|
3115
|
+
origin: Q.origin
|
|
3116
|
+
}) : Q.type = ie;
|
|
3117
|
+
}
|
|
3118
|
+
const Me = ir(te) ? te.data : te;
|
|
3103
3119
|
if (!Me) {
|
|
3104
|
-
console.warn("[use-chat] dropped envelope event without payload",
|
|
3120
|
+
console.warn("[use-chat] dropped envelope event without payload", te);
|
|
3105
3121
|
continue;
|
|
3106
3122
|
}
|
|
3107
3123
|
const Ee = Bn(Me);
|
|
3108
|
-
|
|
3109
|
-
const
|
|
3110
|
-
if (
|
|
3111
|
-
if (
|
|
3112
|
-
console.debug("[use-chat] drop duplicate/out-of-order event", { seq:
|
|
3124
|
+
ne = Date.now();
|
|
3125
|
+
const ye = Ee.seq;
|
|
3126
|
+
if (ye !== void 0) {
|
|
3127
|
+
if (ye <= D) {
|
|
3128
|
+
console.debug("[use-chat] drop duplicate/out-of-order event", { seq: ye, lastProcessedSeq: D, type: Ee.type });
|
|
3113
3129
|
continue;
|
|
3114
3130
|
}
|
|
3115
|
-
D =
|
|
3131
|
+
D = ye;
|
|
3116
3132
|
}
|
|
3117
3133
|
u(Ee);
|
|
3118
3134
|
}
|
|
3119
3135
|
}
|
|
3120
|
-
|
|
3121
|
-
} catch (
|
|
3122
|
-
if (
|
|
3123
|
-
|
|
3136
|
+
U === null && !_.signal.aborted && (U = "complete");
|
|
3137
|
+
} catch (H) {
|
|
3138
|
+
if (H.name === "AbortError")
|
|
3139
|
+
U = U ?? "aborted";
|
|
3124
3140
|
else {
|
|
3125
|
-
const
|
|
3126
|
-
|
|
3141
|
+
const re = H.message || String(H);
|
|
3142
|
+
U = "error", m(re);
|
|
3127
3143
|
}
|
|
3128
3144
|
} finally {
|
|
3129
3145
|
try {
|
|
3130
3146
|
await S.cancel();
|
|
3131
3147
|
} catch {
|
|
3132
3148
|
} finally {
|
|
3133
|
-
(
|
|
3149
|
+
(O = S.releaseLock) == null || O.call(S);
|
|
3134
3150
|
}
|
|
3135
|
-
clearInterval(
|
|
3151
|
+
clearInterval(se);
|
|
3136
3152
|
}
|
|
3137
|
-
} catch (
|
|
3138
|
-
if (
|
|
3139
|
-
|
|
3153
|
+
} catch (L) {
|
|
3154
|
+
if (L.name === "AbortError")
|
|
3155
|
+
U = U ?? "aborted";
|
|
3140
3156
|
else {
|
|
3141
|
-
const
|
|
3142
|
-
|
|
3157
|
+
const W = L.message || String(L);
|
|
3158
|
+
U = "error", m(W), M || (M = !0, (F = e.onConnectionError) == null || F.call(e, W));
|
|
3143
3159
|
}
|
|
3144
3160
|
} finally {
|
|
3145
3161
|
try {
|
|
3146
3162
|
if (e.onFinish) {
|
|
3147
|
-
const
|
|
3163
|
+
const L = {
|
|
3148
3164
|
lastSeq: 0,
|
|
3149
3165
|
lastCheckpointId: null,
|
|
3150
3166
|
lastCheckpointNs: null,
|
|
3151
3167
|
lastValues: null
|
|
3152
3168
|
// Let the reducer/history hook provide the final values
|
|
3153
3169
|
};
|
|
3154
|
-
e.onFinish(
|
|
3170
|
+
e.onFinish(L);
|
|
3155
3171
|
}
|
|
3156
|
-
} catch (
|
|
3157
|
-
console.warn("[use-chat] onClosed callback failed",
|
|
3172
|
+
} catch (L) {
|
|
3173
|
+
console.warn("[use-chat] onClosed callback failed", L);
|
|
3158
3174
|
}
|
|
3159
3175
|
l(!1), k(!1), I.current = null, T.current = null;
|
|
3160
3176
|
}
|
|
@@ -3177,10 +3193,10 @@ function cr(e = {}) {
|
|
|
3177
3193
|
// Deprecated: use checkpoint from reducer
|
|
3178
3194
|
lastSeq: 0,
|
|
3179
3195
|
connected: h,
|
|
3180
|
-
stream:
|
|
3196
|
+
stream: A,
|
|
3181
3197
|
stop: y,
|
|
3182
|
-
clear:
|
|
3183
|
-
setToken:
|
|
3198
|
+
clear: b,
|
|
3199
|
+
setToken: P,
|
|
3184
3200
|
values: {},
|
|
3185
3201
|
// Provide empty object for backward compatibility
|
|
3186
3202
|
interrupt: () => Promise.resolve(),
|
|
@@ -3189,7 +3205,7 @@ function cr(e = {}) {
|
|
|
3189
3205
|
connectionState: f ? "error" : c ? h ? "connected" : "connecting" : "idle",
|
|
3190
3206
|
messages: [],
|
|
3191
3207
|
// useStream doesn't maintain messages, use useChatSession instead
|
|
3192
|
-
submit:
|
|
3208
|
+
submit: A
|
|
3193
3209
|
};
|
|
3194
3210
|
}
|
|
3195
3211
|
function lr({
|
|
@@ -3199,19 +3215,19 @@ function lr({
|
|
|
3199
3215
|
onThreadChange: r,
|
|
3200
3216
|
onCurrentThreadDeleted: o
|
|
3201
3217
|
}) {
|
|
3202
|
-
const [s, a] =
|
|
3218
|
+
const [s, a] = V([]), [i, u] = V(t), [c, l] = V(!1), [f, m] = V(null), h = K(i), k = K(/* @__PURE__ */ new Map());
|
|
3203
3219
|
q(() => {
|
|
3204
3220
|
h.current = i;
|
|
3205
3221
|
}, [i]), q(() => {
|
|
3206
3222
|
t !== void 0 && t !== h.current && u(t);
|
|
3207
3223
|
}, [t]);
|
|
3208
|
-
const d =
|
|
3224
|
+
const d = z(async () => {
|
|
3209
3225
|
l(!0), m(null);
|
|
3210
3226
|
try {
|
|
3211
|
-
const
|
|
3212
|
-
a(
|
|
3213
|
-
} catch (
|
|
3214
|
-
const y = String(
|
|
3227
|
+
const b = await e.listThreads();
|
|
3228
|
+
a(b ?? []);
|
|
3229
|
+
} catch (b) {
|
|
3230
|
+
const y = String(b);
|
|
3215
3231
|
m(y), n == null || n(y);
|
|
3216
3232
|
} finally {
|
|
3217
3233
|
l(!1);
|
|
@@ -3222,44 +3238,44 @@ function lr({
|
|
|
3222
3238
|
}, [d]), q(() => {
|
|
3223
3239
|
r == null || r(i);
|
|
3224
3240
|
}, [i, r]);
|
|
3225
|
-
const v =
|
|
3226
|
-
async (
|
|
3241
|
+
const v = z(
|
|
3242
|
+
async (b, y) => {
|
|
3227
3243
|
try {
|
|
3228
|
-
const
|
|
3244
|
+
const A = y && typeof y == "object" ? { id: y.id, name: y.name ?? "" } : void 0, p = await e.createThread(b, A);
|
|
3229
3245
|
return u(p.threadId), await d(), p.threadId;
|
|
3230
|
-
} catch (
|
|
3231
|
-
const p = String(
|
|
3246
|
+
} catch (A) {
|
|
3247
|
+
const p = String(A);
|
|
3232
3248
|
return n == null || n(p), null;
|
|
3233
3249
|
}
|
|
3234
3250
|
},
|
|
3235
3251
|
[e, n, d]
|
|
3236
|
-
), I =
|
|
3237
|
-
async (
|
|
3252
|
+
), I = z(
|
|
3253
|
+
async (b) => {
|
|
3238
3254
|
const y = s;
|
|
3239
|
-
a((p) => p.filter((
|
|
3240
|
-
const
|
|
3241
|
-
k.current.set(
|
|
3255
|
+
a((p) => p.filter((w) => w.threadId !== b));
|
|
3256
|
+
const A = new AbortController();
|
|
3257
|
+
k.current.set(b, A);
|
|
3242
3258
|
try {
|
|
3243
|
-
await e.deleteThread(
|
|
3259
|
+
await e.deleteThread(b), h.current === b && (u(null), o == null || o());
|
|
3244
3260
|
} catch (p) {
|
|
3245
3261
|
a(y);
|
|
3246
|
-
const
|
|
3247
|
-
n == null || n(
|
|
3262
|
+
const w = String(p);
|
|
3263
|
+
n == null || n(w);
|
|
3248
3264
|
} finally {
|
|
3249
|
-
k.current.delete(
|
|
3265
|
+
k.current.delete(b);
|
|
3250
3266
|
}
|
|
3251
3267
|
},
|
|
3252
3268
|
[e, o, n, s]
|
|
3253
|
-
), C =
|
|
3254
|
-
async (
|
|
3269
|
+
), C = z(
|
|
3270
|
+
async (b, y) => {
|
|
3255
3271
|
try {
|
|
3256
|
-
await e.updateThread(
|
|
3257
|
-
} catch (
|
|
3258
|
-
n == null || n(String(
|
|
3272
|
+
await e.updateThread(b, y), await d();
|
|
3273
|
+
} catch (A) {
|
|
3274
|
+
n == null || n(String(A));
|
|
3259
3275
|
}
|
|
3260
3276
|
},
|
|
3261
3277
|
[e, n, d]
|
|
3262
|
-
), T =
|
|
3278
|
+
), T = Y(
|
|
3263
3279
|
() => ({
|
|
3264
3280
|
createThread: v,
|
|
3265
3281
|
deleteThread: I,
|
|
@@ -3267,26 +3283,26 @@ function lr({
|
|
|
3267
3283
|
refreshThreads: d
|
|
3268
3284
|
}),
|
|
3269
3285
|
[v, I, C, d]
|
|
3270
|
-
),
|
|
3271
|
-
if (!(
|
|
3286
|
+
), P = z((b) => {
|
|
3287
|
+
if (!(b != null && b.threadId)) return;
|
|
3272
3288
|
const y = {
|
|
3273
|
-
threadId:
|
|
3274
|
-
title:
|
|
3275
|
-
project:
|
|
3276
|
-
createdAt:
|
|
3277
|
-
updatedAt:
|
|
3278
|
-
messageCount:
|
|
3289
|
+
threadId: b.threadId,
|
|
3290
|
+
title: b.title || `Thread ${b.threadId.slice(0, 8)}`,
|
|
3291
|
+
project: b.project,
|
|
3292
|
+
createdAt: b.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
3293
|
+
updatedAt: b.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
3294
|
+
messageCount: b.messageCount ?? 1
|
|
3279
3295
|
};
|
|
3280
|
-
a((
|
|
3296
|
+
a((A) => {
|
|
3281
3297
|
let p = !1;
|
|
3282
|
-
const
|
|
3283
|
-
...
|
|
3284
|
-
title: y.title ??
|
|
3285
|
-
project: y.project ??
|
|
3286
|
-
updatedAt: y.updatedAt ??
|
|
3287
|
-
messageCount: y.messageCount ??
|
|
3288
|
-
}) :
|
|
3289
|
-
return p ?
|
|
3298
|
+
const w = A.map((_) => _.threadId === y.threadId ? (p = !0, console.debug("[useThreadsState] thread_info: updating existing thread", y.threadId), {
|
|
3299
|
+
..._,
|
|
3300
|
+
title: y.title ?? _.title,
|
|
3301
|
+
project: y.project ?? _.project,
|
|
3302
|
+
updatedAt: y.updatedAt ?? _.updatedAt,
|
|
3303
|
+
messageCount: y.messageCount ?? _.messageCount
|
|
3304
|
+
}) : _);
|
|
3305
|
+
return p ? w : (console.debug("[useThreadsState] thread_info: adding thread to list", y.threadId), [y, ...A]);
|
|
3290
3306
|
});
|
|
3291
3307
|
}, []);
|
|
3292
3308
|
return {
|
|
@@ -3297,7 +3313,7 @@ function lr({
|
|
|
3297
3313
|
isLoadingThreads: c,
|
|
3298
3314
|
threadsError: f,
|
|
3299
3315
|
actions: T,
|
|
3300
|
-
addThreadFromEvent:
|
|
3316
|
+
addThreadFromEvent: P
|
|
3301
3317
|
};
|
|
3302
3318
|
}
|
|
3303
3319
|
const jt = Se(null);
|
|
@@ -3307,7 +3323,7 @@ function ur({
|
|
|
3307
3323
|
onError: n,
|
|
3308
3324
|
onThreadChange: r
|
|
3309
3325
|
}) {
|
|
3310
|
-
const { chatApi: o } =
|
|
3326
|
+
const { chatApi: o } = xe(), {
|
|
3311
3327
|
threads: s,
|
|
3312
3328
|
currentThreadId: a,
|
|
3313
3329
|
setCurrentThreadId: i,
|
|
@@ -3321,7 +3337,7 @@ function ur({
|
|
|
3321
3337
|
initialThreadId: t,
|
|
3322
3338
|
onError: n,
|
|
3323
3339
|
onThreadChange: r
|
|
3324
|
-
}), h =
|
|
3340
|
+
}), h = Y(
|
|
3325
3341
|
() => ({
|
|
3326
3342
|
threads: s,
|
|
3327
3343
|
currentThreadId: a,
|
|
@@ -3343,14 +3359,14 @@ function ur({
|
|
|
3343
3359
|
m
|
|
3344
3360
|
]
|
|
3345
3361
|
);
|
|
3346
|
-
return /* @__PURE__ */
|
|
3362
|
+
return /* @__PURE__ */ le(jt.Provider, { value: h, children: e });
|
|
3347
3363
|
}
|
|
3348
3364
|
function rt(e) {
|
|
3349
3365
|
const t = Ue(jt);
|
|
3350
3366
|
if (!t && !(e != null && e.optional)) throw new Error("useThreads must be used within a ThreadsProvider");
|
|
3351
3367
|
return t;
|
|
3352
3368
|
}
|
|
3353
|
-
function
|
|
3369
|
+
function Ft(e) {
|
|
3354
3370
|
const t = e.artifact;
|
|
3355
3371
|
return !t || typeof t != "object" ? null : "metadata" in t && t.metadata ? t.metadata : {
|
|
3356
3372
|
id: t.id ?? e.id ?? `artifact-${Date.now()}`,
|
|
@@ -3361,7 +3377,7 @@ function Lt(e) {
|
|
|
3361
3377
|
};
|
|
3362
3378
|
}
|
|
3363
3379
|
function dr(e, t) {
|
|
3364
|
-
const n =
|
|
3380
|
+
const n = Ft(e);
|
|
3365
3381
|
if (!n) return e;
|
|
3366
3382
|
const r = {
|
|
3367
3383
|
...n,
|
|
@@ -3378,21 +3394,21 @@ function dr(e, t) {
|
|
|
3378
3394
|
}
|
|
3379
3395
|
function fr(e, t, n) {
|
|
3380
3396
|
return e.find((r) => {
|
|
3381
|
-
const o =
|
|
3397
|
+
const o = Ft(r);
|
|
3382
3398
|
return !!((o == null ? void 0 : o.id) === t || n && r.toolCallId === n);
|
|
3383
3399
|
}) ?? null;
|
|
3384
3400
|
}
|
|
3385
3401
|
function Oe(e) {
|
|
3386
3402
|
return e.map((t) => tt(t)).filter((t) => !!t);
|
|
3387
3403
|
}
|
|
3388
|
-
function
|
|
3404
|
+
function Lt(e, t, n) {
|
|
3389
3405
|
return t < 0 || t >= e.length ? e : [...e.slice(0, t), n, ...e.slice(t + 1)];
|
|
3390
3406
|
}
|
|
3391
3407
|
function pr(e, t, n) {
|
|
3392
3408
|
for (let r = e.length - 1; r >= 0; r--)
|
|
3393
3409
|
if (e[r].role === "assistant") {
|
|
3394
3410
|
const s = { ...e[r], checkpointId: t, checkpointNs: n ?? void 0 };
|
|
3395
|
-
return
|
|
3411
|
+
return Lt(e, r, s);
|
|
3396
3412
|
}
|
|
3397
3413
|
return e;
|
|
3398
3414
|
}
|
|
@@ -3462,15 +3478,15 @@ function gr(e, t) {
|
|
|
3462
3478
|
}
|
|
3463
3479
|
}
|
|
3464
3480
|
function mr(e = []) {
|
|
3465
|
-
const [t, n] = Wt(gr, { ...Ot, messages: e }), r = K([]), o = K(null), s =
|
|
3481
|
+
const [t, n] = Wt(gr, { ...Ot, messages: e }), r = K([]), o = K(null), s = z(() => {
|
|
3466
3482
|
o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), o.current = null;
|
|
3467
3483
|
const c = r.current;
|
|
3468
3484
|
c.length && (r.current = [], n({ type: "batch", payload: { events: c } }));
|
|
3469
|
-
}, []), a =
|
|
3485
|
+
}, []), a = z(() => {
|
|
3470
3486
|
typeof window < "u" && typeof window.requestAnimationFrame == "function" ? o.current === null && (o.current = window.requestAnimationFrame(() => s())) : setTimeout(s, 8);
|
|
3471
|
-
}, [s]), i =
|
|
3487
|
+
}, [s]), i = z((c) => {
|
|
3472
3488
|
r.current.push(c), a();
|
|
3473
|
-
}, [a]), u =
|
|
3489
|
+
}, [a]), u = Y(() => ({
|
|
3474
3490
|
setStatus: (c, l) => n({ type: "status", payload: { status: c, error: l } }),
|
|
3475
3491
|
reset: (c) => n({ type: "reset", payload: { messages: c } }),
|
|
3476
3492
|
seed: (c, l) => n({ type: "seed", payload: { messages: c, ...l ?? {} } }),
|
|
@@ -3588,7 +3604,7 @@ function br(e, t) {
|
|
|
3588
3604
|
let r = [...e.messages];
|
|
3589
3605
|
const o = ot(r, n);
|
|
3590
3606
|
if (o !== -1) {
|
|
3591
|
-
const s = r[o], a =
|
|
3607
|
+
const s = r[o], a = ue(t.content), i = (s.toolCalls || []).map(
|
|
3592
3608
|
(u) => u.id === n ? { ...u, content: typeof a == "string" ? a : u.content } : u
|
|
3593
3609
|
);
|
|
3594
3610
|
r[o] = { ...s, toolCalls: i };
|
|
@@ -3599,7 +3615,7 @@ function wr(e, t) {
|
|
|
3599
3615
|
const n = t.id;
|
|
3600
3616
|
if (!n) return e;
|
|
3601
3617
|
let r = [...e.messages];
|
|
3602
|
-
const o = ot(r, n), s =
|
|
3618
|
+
const o = ot(r, n), s = ue(t.content ?? t.error);
|
|
3603
3619
|
if (o !== -1) {
|
|
3604
3620
|
const i = r[o], u = (i.toolCalls || []).map(
|
|
3605
3621
|
(c) => c.id === n ? {
|
|
@@ -3630,13 +3646,13 @@ function vr(e, t) {
|
|
|
3630
3646
|
progress: t.progress,
|
|
3631
3647
|
error: t.error
|
|
3632
3648
|
});
|
|
3633
|
-
return t.partial_data && s.artifact && (s.artifact = { ...s.artifact, ...t.partial_data }), { ...e, messages:
|
|
3649
|
+
return t.partial_data && s.artifact && (s.artifact = { ...s.artifact, ...t.partial_data }), { ...e, messages: Lt(e.messages, o, s) };
|
|
3634
3650
|
}
|
|
3635
3651
|
function ze(e) {
|
|
3636
3652
|
if (!(!e || typeof e != "object" || Array.isArray(e)))
|
|
3637
3653
|
return { ...e };
|
|
3638
3654
|
}
|
|
3639
|
-
function
|
|
3655
|
+
function Le(e, t) {
|
|
3640
3656
|
if (e)
|
|
3641
3657
|
for (const n of t) {
|
|
3642
3658
|
const r = e[n];
|
|
@@ -3661,7 +3677,7 @@ function pt(e) {
|
|
|
3661
3677
|
async function Ir(e, t) {
|
|
3662
3678
|
var i, u;
|
|
3663
3679
|
if (!e) return e ?? null;
|
|
3664
|
-
const n =
|
|
3680
|
+
const n = de(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], o = /* @__PURE__ */ new Set();
|
|
3665
3681
|
for (const c of r) {
|
|
3666
3682
|
const l = (i = c == null ? void 0 : c.values) == null ? void 0 : i.messages;
|
|
3667
3683
|
if (Array.isArray(l))
|
|
@@ -3680,7 +3696,7 @@ async function Ir(e, t) {
|
|
|
3680
3696
|
const s = await Promise.all(
|
|
3681
3697
|
Array.from(o).map(async (c) => {
|
|
3682
3698
|
try {
|
|
3683
|
-
const l = await t.getFileInfo(c), f =
|
|
3699
|
+
const l = await t.getFileInfo(c), f = de(l);
|
|
3684
3700
|
return [c, f];
|
|
3685
3701
|
} catch {
|
|
3686
3702
|
return [c, null];
|
|
@@ -3705,7 +3721,7 @@ async function Ir(e, t) {
|
|
|
3705
3721
|
return n;
|
|
3706
3722
|
}
|
|
3707
3723
|
function gt(e) {
|
|
3708
|
-
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) => Tr(
|
|
3724
|
+
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) => Tr(de(s), a)).filter((s) => !!s)].sort((s, a) => mt(a.createdAt) - mt(s.createdAt)), o = r[0] ?? null;
|
|
3709
3725
|
return {
|
|
3710
3726
|
threadId: (e == null ? void 0 : e.threadId) ?? "",
|
|
3711
3727
|
latest: o,
|
|
@@ -3714,25 +3730,25 @@ function gt(e) {
|
|
|
3714
3730
|
};
|
|
3715
3731
|
}
|
|
3716
3732
|
function Tr(e, t) {
|
|
3717
|
-
var
|
|
3733
|
+
var b, y;
|
|
3718
3734
|
if (!e) return null;
|
|
3719
|
-
const n = ((
|
|
3735
|
+
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((A) => Ar(A, n)).filter((A) => !!A), a = ze(e.metadata) ?? {}, i = pt(e.config), u = ze(e.parentConfig), c = pt(u), l = Le(i, ["checkpointId"]), f = Le(i, ["checkpointNs"]), m = Le(c, ["checkpointId"]), h = ze(e.config), k = Array.isArray(e.tasks) ? e.tasks.map((A) => ({ ...A })) : e.tasks ?? null, d = Array.isArray(e.next) ? [...e.next] : e.next ?? null, v = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), I = {
|
|
3720
3736
|
...a,
|
|
3721
3737
|
step: kr(a, ["step"]) ?? 0,
|
|
3722
|
-
source:
|
|
3723
|
-
}, C = s.map((
|
|
3724
|
-
...
|
|
3725
|
-
checkpointId:
|
|
3726
|
-
checkpointNs:
|
|
3727
|
-
})), T = e.values,
|
|
3738
|
+
source: Le(a, ["source"]) ?? null
|
|
3739
|
+
}, C = s.map((A) => ({
|
|
3740
|
+
...A,
|
|
3741
|
+
checkpointId: A.checkpointId ?? l ?? null,
|
|
3742
|
+
checkpointNs: A.checkpointNs ?? f ?? null
|
|
3743
|
+
})), T = e.values, P = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(T == null ? void 0 : T.interrupts) ? T.interrupts : [];
|
|
3728
3744
|
return {
|
|
3729
3745
|
checkpointId: l ?? null,
|
|
3730
3746
|
checkpointNs: f ?? null,
|
|
3731
3747
|
createdAt: v,
|
|
3732
3748
|
parentId: m ?? null,
|
|
3733
3749
|
messages: C,
|
|
3734
|
-
interrupt:
|
|
3735
|
-
|
|
3750
|
+
interrupt: xr(
|
|
3751
|
+
P,
|
|
3736
3752
|
t,
|
|
3737
3753
|
l ?? null
|
|
3738
3754
|
),
|
|
@@ -3744,11 +3760,11 @@ function Tr(e, t) {
|
|
|
3744
3760
|
values: e.values ?? {}
|
|
3745
3761
|
};
|
|
3746
3762
|
}
|
|
3747
|
-
function
|
|
3763
|
+
function Ar(e, t) {
|
|
3748
3764
|
const n = tt(e);
|
|
3749
3765
|
return n ? (n.role === "assistant" && !n.name && t && (n.name = t), n) : null;
|
|
3750
3766
|
}
|
|
3751
|
-
function
|
|
3767
|
+
function xr(e, t, n) {
|
|
3752
3768
|
const r = e.length;
|
|
3753
3769
|
for (let o = r - 1; o >= 0; o -= 1) {
|
|
3754
3770
|
const s = e[o];
|
|
@@ -3790,7 +3806,7 @@ function Mr(e) {
|
|
|
3790
3806
|
const C = Array.isArray(l.messages) ? l.messages : [];
|
|
3791
3807
|
for (const y of C)
|
|
3792
3808
|
y.role === "user" && (I || (I = y), y.id && (v = y.id));
|
|
3793
|
-
const T = l.next && l.next.length > 0 ? String(l.next[0]) : null,
|
|
3809
|
+
const T = l.next && l.next.length > 0 ? String(l.next[0]) : null, P = l.parentConfig ?? null, b = {
|
|
3794
3810
|
id: m,
|
|
3795
3811
|
step: k,
|
|
3796
3812
|
source: d,
|
|
@@ -3798,10 +3814,10 @@ function Mr(e) {
|
|
|
3798
3814
|
namespace: l.checkpointNs ?? null,
|
|
3799
3815
|
parentId: l.parentId ?? null,
|
|
3800
3816
|
next: T,
|
|
3801
|
-
parentConfig:
|
|
3817
|
+
parentConfig: P,
|
|
3802
3818
|
userMessageId: v
|
|
3803
3819
|
};
|
|
3804
|
-
if (o.push(
|
|
3820
|
+
if (o.push(b), f && t.set(f, b), f && I) {
|
|
3805
3821
|
const y = Cr(I);
|
|
3806
3822
|
y && r.set(f, y);
|
|
3807
3823
|
}
|
|
@@ -3812,7 +3828,7 @@ function Mr(e) {
|
|
|
3812
3828
|
source: d,
|
|
3813
3829
|
createdAt: l.createdAt ?? null,
|
|
3814
3830
|
next: T,
|
|
3815
|
-
parentConfig:
|
|
3831
|
+
parentConfig: P
|
|
3816
3832
|
});
|
|
3817
3833
|
}
|
|
3818
3834
|
const s = /* @__PURE__ */ new Map();
|
|
@@ -3873,7 +3889,7 @@ function so(e, t, n) {
|
|
|
3873
3889
|
};
|
|
3874
3890
|
}
|
|
3875
3891
|
function Er(e) {
|
|
3876
|
-
return
|
|
3892
|
+
return Y(() => Mr(e), [e]);
|
|
3877
3893
|
}
|
|
3878
3894
|
function Bt({
|
|
3879
3895
|
api: e,
|
|
@@ -3885,116 +3901,116 @@ function Bt({
|
|
|
3885
3901
|
isStreaming: a,
|
|
3886
3902
|
getMessages: i
|
|
3887
3903
|
}) {
|
|
3888
|
-
const [u, c] =
|
|
3904
|
+
const [u, c] = V(null), f = Y(
|
|
3889
3905
|
() => gt(u),
|
|
3890
3906
|
[u]
|
|
3891
|
-
).checkpoints, m = Er(f), h = m.timeline, [k, d] =
|
|
3907
|
+
).checkpoints, m = Er(f), h = m.timeline, [k, d] = V(!1), [v, I] = V(!1), [C, T] = V(null), P = K(o), b = K(null), y = K(null);
|
|
3892
3908
|
q(() => {
|
|
3893
|
-
|
|
3909
|
+
P.current = o;
|
|
3894
3910
|
}, [o]);
|
|
3895
|
-
const
|
|
3911
|
+
const A = z(
|
|
3896
3912
|
async (E) => {
|
|
3897
|
-
const
|
|
3913
|
+
const j = await e.getState({
|
|
3898
3914
|
threadId: E.threadId,
|
|
3899
3915
|
checkpointId: E.checkpointId,
|
|
3900
3916
|
checkpointNs: E.checkpointNs
|
|
3901
|
-
}),
|
|
3917
|
+
}), N = {
|
|
3902
3918
|
version: "values@1",
|
|
3903
3919
|
threadId: E.threadId,
|
|
3904
|
-
checkpoints: [
|
|
3905
|
-
},
|
|
3906
|
-
return
|
|
3920
|
+
checkpoints: [j]
|
|
3921
|
+
}, B = t ? await Ir(N, t) : N, { latest: O } = gt(B);
|
|
3922
|
+
return O;
|
|
3907
3923
|
},
|
|
3908
3924
|
[e, t]
|
|
3909
|
-
),
|
|
3910
|
-
async (E,
|
|
3911
|
-
var
|
|
3925
|
+
), p = z(
|
|
3926
|
+
async (E, j) => {
|
|
3927
|
+
var O;
|
|
3912
3928
|
if (!E) return;
|
|
3913
|
-
const
|
|
3914
|
-
if (
|
|
3915
|
-
|
|
3916
|
-
const
|
|
3917
|
-
|
|
3929
|
+
const N = `${E}:${j ?? "latest"}`;
|
|
3930
|
+
if (b.current === N || k) return;
|
|
3931
|
+
(O = y.current) == null || O.abort();
|
|
3932
|
+
const B = new AbortController();
|
|
3933
|
+
y.current = B, d(!0), T(null);
|
|
3918
3934
|
try {
|
|
3919
|
-
const
|
|
3935
|
+
const F = await A({
|
|
3920
3936
|
threadId: E,
|
|
3921
|
-
checkpointId:
|
|
3937
|
+
checkpointId: j ?? void 0
|
|
3922
3938
|
});
|
|
3923
|
-
if (
|
|
3924
|
-
n((
|
|
3925
|
-
checkpointId: (
|
|
3926
|
-
checkpointNs: (
|
|
3927
|
-
pendingInterrupt: (
|
|
3928
|
-
values:
|
|
3929
|
-
}),
|
|
3930
|
-
const
|
|
3939
|
+
if (P.current !== E) return;
|
|
3940
|
+
n((F == null ? void 0 : F.messages) ?? [], {
|
|
3941
|
+
checkpointId: (F == null ? void 0 : F.checkpointId) ?? null,
|
|
3942
|
+
checkpointNs: (F == null ? void 0 : F.checkpointNs) ?? null,
|
|
3943
|
+
pendingInterrupt: (F == null ? void 0 : F.interrupt) ?? null,
|
|
3944
|
+
values: F == null ? void 0 : F.values
|
|
3945
|
+
}), b.current = N;
|
|
3946
|
+
const L = await e.getStateHistory({
|
|
3931
3947
|
threadId: E,
|
|
3932
3948
|
limit: 100,
|
|
3933
3949
|
includeMessages: !1
|
|
3934
3950
|
});
|
|
3935
|
-
|
|
3936
|
-
} catch (
|
|
3937
|
-
if (!Jt(
|
|
3938
|
-
const
|
|
3939
|
-
T(
|
|
3951
|
+
P.current === E && c(L);
|
|
3952
|
+
} catch (F) {
|
|
3953
|
+
if (!Jt(F)) {
|
|
3954
|
+
const L = String(F);
|
|
3955
|
+
T(L), r == null || r(L);
|
|
3940
3956
|
}
|
|
3941
3957
|
} finally {
|
|
3942
|
-
|
|
3958
|
+
d(!1);
|
|
3943
3959
|
}
|
|
3944
3960
|
},
|
|
3945
|
-
[e, n,
|
|
3946
|
-
),
|
|
3947
|
-
async (E,
|
|
3961
|
+
[e, n, A, r, k, i]
|
|
3962
|
+
), w = z(
|
|
3963
|
+
async (E, j) => {
|
|
3948
3964
|
if (o) {
|
|
3949
3965
|
I(!0);
|
|
3950
3966
|
try {
|
|
3951
|
-
const
|
|
3967
|
+
const N = await A({
|
|
3952
3968
|
threadId: o,
|
|
3953
3969
|
checkpointId: E,
|
|
3954
|
-
checkpointNs:
|
|
3970
|
+
checkpointNs: j ?? void 0
|
|
3955
3971
|
});
|
|
3956
|
-
n((
|
|
3957
|
-
checkpointId: (
|
|
3958
|
-
checkpointNs: (
|
|
3959
|
-
pendingInterrupt: (
|
|
3960
|
-
values:
|
|
3972
|
+
n((N == null ? void 0 : N.messages) ?? [], {
|
|
3973
|
+
checkpointId: (N == null ? void 0 : N.checkpointId) ?? E,
|
|
3974
|
+
checkpointNs: (N == null ? void 0 : N.checkpointNs) ?? j,
|
|
3975
|
+
pendingInterrupt: (N == null ? void 0 : N.interrupt) ?? null,
|
|
3976
|
+
values: N == null ? void 0 : N.values
|
|
3961
3977
|
});
|
|
3962
|
-
} catch (
|
|
3963
|
-
console.error("[useThreadHistoryState] Navigation failed",
|
|
3978
|
+
} catch (N) {
|
|
3979
|
+
console.error("[useThreadHistoryState] Navigation failed", N);
|
|
3964
3980
|
} finally {
|
|
3965
3981
|
I(!1);
|
|
3966
3982
|
}
|
|
3967
3983
|
}
|
|
3968
3984
|
},
|
|
3969
|
-
[o,
|
|
3970
|
-
),
|
|
3971
|
-
o && await
|
|
3972
|
-
}, [o,
|
|
3985
|
+
[o, A, n]
|
|
3986
|
+
), _ = z(async () => {
|
|
3987
|
+
o && await p(o);
|
|
3988
|
+
}, [o, p]), U = z(
|
|
3973
3989
|
async (E) => {
|
|
3974
|
-
var
|
|
3975
|
-
const
|
|
3976
|
-
if (!
|
|
3977
|
-
if (c(E),
|
|
3978
|
-
const
|
|
3979
|
-
threadId:
|
|
3990
|
+
var B;
|
|
3991
|
+
const j = (E == null ? void 0 : E.threadId) || o;
|
|
3992
|
+
if (!j || o !== j) return;
|
|
3993
|
+
if (c(E), b.current = `${j}:latest`, (B = E.values) != null && B.messages) {
|
|
3994
|
+
const O = await A({
|
|
3995
|
+
threadId: j
|
|
3980
3996
|
});
|
|
3981
|
-
|
|
3982
|
-
checkpointId:
|
|
3983
|
-
checkpointNs:
|
|
3984
|
-
pendingInterrupt:
|
|
3985
|
-
values:
|
|
3997
|
+
O && n(O.messages ?? [], {
|
|
3998
|
+
checkpointId: O.checkpointId ?? null,
|
|
3999
|
+
checkpointNs: O.checkpointNs ?? null,
|
|
4000
|
+
pendingInterrupt: O.interrupt ?? null,
|
|
4001
|
+
values: O.values
|
|
3986
4002
|
});
|
|
3987
4003
|
}
|
|
3988
4004
|
},
|
|
3989
|
-
[o,
|
|
4005
|
+
[o, A, n]
|
|
3990
4006
|
);
|
|
3991
4007
|
q(() => {
|
|
3992
4008
|
if (!s || !o || k || a) return;
|
|
3993
4009
|
const E = `${o}:latest`;
|
|
3994
|
-
|
|
3995
|
-
}, [s, o, k, a,
|
|
3996
|
-
const
|
|
3997
|
-
c(null), d(!1), I(!1), T(null),
|
|
4010
|
+
b.current !== E && p(o);
|
|
4011
|
+
}, [s, o, k, a, p]);
|
|
4012
|
+
const M = z(() => {
|
|
4013
|
+
c(null), d(!1), I(!1), T(null), b.current = null;
|
|
3998
4014
|
}, []);
|
|
3999
4015
|
return {
|
|
4000
4016
|
threadCheckpoints: f,
|
|
@@ -4003,19 +4019,19 @@ function Bt({
|
|
|
4003
4019
|
isLoadingThread: k,
|
|
4004
4020
|
isLoadingCheckpoint: v,
|
|
4005
4021
|
threadStateError: C,
|
|
4006
|
-
loadThread:
|
|
4007
|
-
navigateToCheckpoint:
|
|
4008
|
-
setCurrentCheckpointId: (E,
|
|
4009
|
-
n(i(), { checkpointId: E, checkpointNs:
|
|
4022
|
+
loadThread: p,
|
|
4023
|
+
navigateToCheckpoint: w,
|
|
4024
|
+
setCurrentCheckpointId: (E, j) => {
|
|
4025
|
+
n(i(), { checkpointId: E, checkpointNs: j });
|
|
4010
4026
|
},
|
|
4011
|
-
returnToLatest:
|
|
4012
|
-
handleValuesEvent:
|
|
4027
|
+
returnToLatest: _,
|
|
4028
|
+
handleValuesEvent: U,
|
|
4013
4029
|
markSkipNextLoad: () => {
|
|
4014
4030
|
},
|
|
4015
4031
|
markStreamPendingThread: () => {
|
|
4016
4032
|
},
|
|
4017
|
-
resetHistoryState:
|
|
4018
|
-
clearState:
|
|
4033
|
+
resetHistoryState: M,
|
|
4034
|
+
clearState: M
|
|
4019
4035
|
};
|
|
4020
4036
|
}
|
|
4021
4037
|
const $t = Se(null), Vt = Se(null);
|
|
@@ -4039,21 +4055,21 @@ function Nr({
|
|
|
4039
4055
|
isStreaming: s,
|
|
4040
4056
|
onError: a
|
|
4041
4057
|
}) {
|
|
4042
|
-
const { chatApi: i, fileApi: u } =
|
|
4058
|
+
const { chatApi: i, fileApi: u } = xe(), { currentThreadId: c } = rt(), { state: l, seed: f, onEvent: m, dispatch: h } = mr(), {
|
|
4043
4059
|
threadCheckpoints: k,
|
|
4044
4060
|
threadTimeline: d,
|
|
4045
4061
|
checkpointIndex: v,
|
|
4046
4062
|
isLoadingThread: I,
|
|
4047
4063
|
isLoadingCheckpoint: C,
|
|
4048
4064
|
threadStateError: T,
|
|
4049
|
-
loadThread:
|
|
4050
|
-
navigateToCheckpoint:
|
|
4065
|
+
loadThread: P,
|
|
4066
|
+
navigateToCheckpoint: b,
|
|
4051
4067
|
setCurrentCheckpointId: y,
|
|
4052
|
-
returnToLatest:
|
|
4068
|
+
returnToLatest: A,
|
|
4053
4069
|
handleValuesEvent: p,
|
|
4054
|
-
markSkipNextLoad:
|
|
4055
|
-
markStreamPendingThread:
|
|
4056
|
-
resetHistoryState:
|
|
4070
|
+
markSkipNextLoad: w,
|
|
4071
|
+
markStreamPendingThread: _,
|
|
4072
|
+
resetHistoryState: U
|
|
4057
4073
|
} = Bt({
|
|
4058
4074
|
api: i,
|
|
4059
4075
|
fileApi: u,
|
|
@@ -4065,34 +4081,34 @@ function Nr({
|
|
|
4065
4081
|
initialCheckpointNs: r,
|
|
4066
4082
|
autoLoadInitial: o,
|
|
4067
4083
|
isStreaming: s,
|
|
4068
|
-
getMessages:
|
|
4069
|
-
}), M = K(null),
|
|
4070
|
-
(
|
|
4071
|
-
M.current =
|
|
4084
|
+
getMessages: z(() => l.messages, [l.messages])
|
|
4085
|
+
}), M = K(null), E = z(
|
|
4086
|
+
(x) => {
|
|
4087
|
+
M.current = x;
|
|
4072
4088
|
},
|
|
4073
4089
|
[]
|
|
4074
|
-
),
|
|
4075
|
-
(
|
|
4076
|
-
|
|
4090
|
+
), j = K(null), N = z(
|
|
4091
|
+
(x) => {
|
|
4092
|
+
j.current = x;
|
|
4077
4093
|
},
|
|
4078
4094
|
[]
|
|
4079
|
-
),
|
|
4080
|
-
(
|
|
4081
|
-
const
|
|
4095
|
+
), B = Y(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), O = z(
|
|
4096
|
+
(x, S) => {
|
|
4097
|
+
const G = Ut(x, "user");
|
|
4082
4098
|
return h({
|
|
4083
4099
|
type: "user_message",
|
|
4084
4100
|
payload: {
|
|
4085
|
-
message:
|
|
4101
|
+
message: G,
|
|
4086
4102
|
editingMessageId: S == null ? void 0 : S.editingMessageId
|
|
4087
4103
|
}
|
|
4088
|
-
}),
|
|
4104
|
+
}), G;
|
|
4089
4105
|
},
|
|
4090
4106
|
[h]
|
|
4091
|
-
), F =
|
|
4092
|
-
M.current ? await M.current() : (f([], {}),
|
|
4093
|
-
}, [f,
|
|
4094
|
-
await
|
|
4095
|
-
}, [
|
|
4107
|
+
), F = z(async () => {
|
|
4108
|
+
M.current ? await M.current() : (f([], {}), U());
|
|
4109
|
+
}, [f, U]), L = z(async (x, S, G) => {
|
|
4110
|
+
await P(x, S, { clearProgress: !1 });
|
|
4111
|
+
}, [P]), W = Y(() => Fn(l.messages), [l.messages]), Z = Y(
|
|
4096
4112
|
() => ({
|
|
4097
4113
|
status: l.status,
|
|
4098
4114
|
threadId: c,
|
|
@@ -4106,7 +4122,7 @@ function Nr({
|
|
|
4106
4122
|
checkpoints: k,
|
|
4107
4123
|
checkpointIndex: v,
|
|
4108
4124
|
timelineCheckpoints: d,
|
|
4109
|
-
metadata:
|
|
4125
|
+
metadata: B,
|
|
4110
4126
|
values: l.values ?? {},
|
|
4111
4127
|
isLoading: I,
|
|
4112
4128
|
isLoadingCheckpoint: C,
|
|
@@ -4114,31 +4130,31 @@ function Nr({
|
|
|
4114
4130
|
loadOlder: async () => {
|
|
4115
4131
|
},
|
|
4116
4132
|
// Placeholder
|
|
4117
|
-
seedFromSnapshot: (
|
|
4118
|
-
f(
|
|
4119
|
-
checkpointId:
|
|
4120
|
-
checkpointNs:
|
|
4121
|
-
pendingInterrupt:
|
|
4122
|
-
values:
|
|
4133
|
+
seedFromSnapshot: (x) => {
|
|
4134
|
+
f(x.messages, {
|
|
4135
|
+
checkpointId: x.checkpointId,
|
|
4136
|
+
checkpointNs: x.checkpointNs,
|
|
4137
|
+
pendingInterrupt: x.interrupt,
|
|
4138
|
+
values: x.values
|
|
4123
4139
|
});
|
|
4124
4140
|
},
|
|
4125
4141
|
clearState: F,
|
|
4126
|
-
navigateToCheckpoint:
|
|
4142
|
+
navigateToCheckpoint: b,
|
|
4127
4143
|
setCurrentCheckpointId: y,
|
|
4128
|
-
returnToLatest:
|
|
4129
|
-
loadThread:
|
|
4144
|
+
returnToLatest: A,
|
|
4145
|
+
loadThread: L,
|
|
4130
4146
|
clearThread: F,
|
|
4131
|
-
respondToInterrupt: async (
|
|
4132
|
-
|
|
4147
|
+
respondToInterrupt: async (x, S, G) => {
|
|
4148
|
+
j.current && await j.current(x, S, G);
|
|
4133
4149
|
},
|
|
4134
4150
|
messagePreviews: v.messagePreviews,
|
|
4135
4151
|
handleValuesEvent: p,
|
|
4136
|
-
markSkipNextLoad:
|
|
4137
|
-
markStreamPendingThread:
|
|
4138
|
-
resetHistoryState:
|
|
4139
|
-
pushUser:
|
|
4152
|
+
markSkipNextLoad: w,
|
|
4153
|
+
markStreamPendingThread: _,
|
|
4154
|
+
resetHistoryState: U,
|
|
4155
|
+
pushUser: O,
|
|
4140
4156
|
onEvent: m,
|
|
4141
|
-
artifacts:
|
|
4157
|
+
artifacts: W
|
|
4142
4158
|
}),
|
|
4143
4159
|
[
|
|
4144
4160
|
c,
|
|
@@ -4151,31 +4167,31 @@ function Nr({
|
|
|
4151
4167
|
k,
|
|
4152
4168
|
d,
|
|
4153
4169
|
v,
|
|
4154
|
-
|
|
4170
|
+
B,
|
|
4155
4171
|
I,
|
|
4156
4172
|
C,
|
|
4157
4173
|
T,
|
|
4158
4174
|
f,
|
|
4159
4175
|
F,
|
|
4160
|
-
|
|
4176
|
+
b,
|
|
4161
4177
|
y,
|
|
4162
|
-
|
|
4163
|
-
|
|
4178
|
+
A,
|
|
4179
|
+
L,
|
|
4164
4180
|
p,
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4181
|
+
w,
|
|
4182
|
+
_,
|
|
4183
|
+
O,
|
|
4168
4184
|
m,
|
|
4169
|
-
|
|
4185
|
+
W
|
|
4170
4186
|
]
|
|
4171
|
-
), g =
|
|
4187
|
+
), g = Y(
|
|
4172
4188
|
() => ({
|
|
4173
|
-
registerClearThread:
|
|
4174
|
-
registerRespondToInterrupt:
|
|
4189
|
+
registerClearThread: E,
|
|
4190
|
+
registerRespondToInterrupt: N
|
|
4175
4191
|
}),
|
|
4176
|
-
[
|
|
4192
|
+
[E, N]
|
|
4177
4193
|
);
|
|
4178
|
-
return /* @__PURE__ */
|
|
4194
|
+
return /* @__PURE__ */ le(Vt.Provider, { value: g, children: /* @__PURE__ */ le($t.Provider, { value: Z, children: e }) });
|
|
4179
4195
|
}
|
|
4180
4196
|
const Kt = Se(null), _r = Se(!1);
|
|
4181
4197
|
function zr({
|
|
@@ -4190,7 +4206,7 @@ function zr({
|
|
|
4190
4206
|
onFinish: u,
|
|
4191
4207
|
onStreamingChange: c
|
|
4192
4208
|
}) {
|
|
4193
|
-
const { chatApi: l, baseUrl: f } =
|
|
4209
|
+
const { chatApi: l, baseUrl: f } = xe(), m = f, h = ge(t), k = ge(n), d = ge(r), v = ge(o), I = ge(s), C = ge(a), T = ge(i), P = ge(u), b = ge(c), y = Y(
|
|
4194
4210
|
() => ({
|
|
4195
4211
|
onError: h,
|
|
4196
4212
|
onAuthError: k,
|
|
@@ -4199,7 +4215,7 @@ function zr({
|
|
|
4199
4215
|
onCustomEvent: C,
|
|
4200
4216
|
onUpdateEvent: I,
|
|
4201
4217
|
onToolEnd: v,
|
|
4202
|
-
onFinish:
|
|
4218
|
+
onFinish: P
|
|
4203
4219
|
}),
|
|
4204
4220
|
[
|
|
4205
4221
|
h,
|
|
@@ -4209,16 +4225,16 @@ function zr({
|
|
|
4209
4225
|
C,
|
|
4210
4226
|
I,
|
|
4211
4227
|
v,
|
|
4212
|
-
|
|
4228
|
+
P
|
|
4213
4229
|
]
|
|
4214
4230
|
);
|
|
4215
|
-
return /* @__PURE__ */
|
|
4231
|
+
return /* @__PURE__ */ le(_r.Provider, { value: !0, children: /* @__PURE__ */ le(
|
|
4216
4232
|
Rr,
|
|
4217
4233
|
{
|
|
4218
4234
|
api: l,
|
|
4219
4235
|
streamBaseUrl: m,
|
|
4220
4236
|
handlers: y,
|
|
4221
|
-
onStreamingChange:
|
|
4237
|
+
onStreamingChange: b,
|
|
4222
4238
|
children: e
|
|
4223
4239
|
}
|
|
4224
4240
|
) });
|
|
@@ -4241,7 +4257,7 @@ function Rr({
|
|
|
4241
4257
|
pushUser: v,
|
|
4242
4258
|
onEvent: I,
|
|
4243
4259
|
messages: C
|
|
4244
|
-
} = Dt(), { registerClearThread: T, registerRespondToInterrupt:
|
|
4260
|
+
} = Dt(), { registerClearThread: T, registerRespondToInterrupt: P } = Pr(), b = z(
|
|
4245
4261
|
(g) => {
|
|
4246
4262
|
i(g), k(g.threadId), a.current !== g.threadId && ((g.created ?? !a.current) && h(g.threadId), s(g.threadId));
|
|
4247
4263
|
},
|
|
@@ -4250,13 +4266,13 @@ function Rr({
|
|
|
4250
4266
|
baseUrl: n,
|
|
4251
4267
|
onEvent: I,
|
|
4252
4268
|
onError: (g) => {
|
|
4253
|
-
var
|
|
4254
|
-
(
|
|
4269
|
+
var x;
|
|
4270
|
+
(x = r.onError) == null || x.call(r, (g == null ? void 0 : g.message) ?? String(g));
|
|
4255
4271
|
},
|
|
4256
4272
|
onAuthError: r.onAuthError,
|
|
4257
4273
|
onConnectionError: r.onConnectionError,
|
|
4258
4274
|
onFinish: r.onFinish,
|
|
4259
|
-
onThreadInfo:
|
|
4275
|
+
onThreadInfo: b,
|
|
4260
4276
|
onMetadataEvent: r.onMetadataEvent,
|
|
4261
4277
|
onCustomEvent: r.onCustomEvent,
|
|
4262
4278
|
onUpdateEvent: r.onUpdateEvent,
|
|
@@ -4266,76 +4282,76 @@ function Rr({
|
|
|
4266
4282
|
q(() => {
|
|
4267
4283
|
o == null || o(y.isStreaming);
|
|
4268
4284
|
}, [y.isStreaming, o]);
|
|
4269
|
-
const { stream:
|
|
4285
|
+
const { stream: A, stop: p, clear: w, isStreaming: _, error: U, connected: M, streamedMessages: E, activeMessageId: j } = y;
|
|
4270
4286
|
q(() => {
|
|
4271
|
-
u !== void 0 &&
|
|
4272
|
-
}, [u,
|
|
4273
|
-
const
|
|
4274
|
-
async (g,
|
|
4275
|
-
await
|
|
4287
|
+
u !== void 0 && w();
|
|
4288
|
+
}, [u, w]);
|
|
4289
|
+
const N = z(
|
|
4290
|
+
async (g, x) => {
|
|
4291
|
+
await A(g, x);
|
|
4276
4292
|
},
|
|
4277
|
-
[
|
|
4278
|
-
),
|
|
4293
|
+
[A]
|
|
4294
|
+
), B = K(l);
|
|
4279
4295
|
q(() => {
|
|
4280
|
-
|
|
4296
|
+
B.current = l;
|
|
4281
4297
|
}, [l]);
|
|
4282
|
-
const
|
|
4283
|
-
async (g,
|
|
4284
|
-
const
|
|
4285
|
-
if (!
|
|
4298
|
+
const O = z(
|
|
4299
|
+
async (g, x, S) => {
|
|
4300
|
+
const G = a.current;
|
|
4301
|
+
if (!G)
|
|
4286
4302
|
throw new Error("No active thread to handle interrupt");
|
|
4287
|
-
const J = g ?
|
|
4288
|
-
threadId:
|
|
4289
|
-
checkpointId:
|
|
4290
|
-
checkpointNs:
|
|
4303
|
+
const J = g ? x ?? !0 : !1, D = B.current, ne = (S == null ? void 0 : S.checkpointId) ?? D.id ?? void 0, se = (S == null ? void 0 : S.checkpointNs) ?? D.namespace ?? void 0, fe = {
|
|
4304
|
+
threadId: G,
|
|
4305
|
+
checkpointId: ne,
|
|
4306
|
+
checkpointNs: se,
|
|
4291
4307
|
command: { kind: "resume", value: J },
|
|
4292
4308
|
payload: S == null ? void 0 : S.payload
|
|
4293
4309
|
};
|
|
4294
|
-
|
|
4310
|
+
N(fe);
|
|
4295
4311
|
},
|
|
4296
|
-
[a,
|
|
4312
|
+
[a, N]
|
|
4297
4313
|
);
|
|
4298
4314
|
q(() => {
|
|
4299
|
-
|
|
4300
|
-
}, [
|
|
4301
|
-
const F =
|
|
4302
|
-
p(),
|
|
4303
|
-
}, [
|
|
4315
|
+
P(O);
|
|
4316
|
+
}, [O, P]);
|
|
4317
|
+
const F = z(async () => {
|
|
4318
|
+
p(), w(), d(), s(null);
|
|
4319
|
+
}, [w, d, s, p]);
|
|
4304
4320
|
q(() => {
|
|
4305
4321
|
T(F);
|
|
4306
4322
|
}, [F, T]);
|
|
4307
|
-
const
|
|
4308
|
-
async (g,
|
|
4309
|
-
|
|
4323
|
+
const L = z(
|
|
4324
|
+
async (g, x) => {
|
|
4325
|
+
_ && p();
|
|
4310
4326
|
let S = a.current;
|
|
4311
|
-
const
|
|
4312
|
-
|
|
4313
|
-
const
|
|
4314
|
-
if (!S && !D && J.length === 0 && !
|
|
4327
|
+
const G = (g == null ? void 0 : g.text) ?? "", J = (g == null ? void 0 : g.attachments) ?? [], D = (G == null ? void 0 : G.trim()) ?? "", ne = { ...(g == null ? void 0 : g.payload) ?? {} }, se = Array.isArray(ne.messages) ? ne.messages : void 0;
|
|
4328
|
+
se && delete ne.messages;
|
|
4329
|
+
const fe = !!(se && se.length), H = !!(g.contentParts && g.contentParts.length > 0);
|
|
4330
|
+
if (!S && !D && J.length === 0 && !fe && !H) return;
|
|
4315
4331
|
if (!S) {
|
|
4316
|
-
const
|
|
4317
|
-
S = `${
|
|
4332
|
+
const ye = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), Q = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
|
|
4333
|
+
S = `${ye}${Q}`, h(S), s(S);
|
|
4318
4334
|
}
|
|
4319
|
-
let
|
|
4320
|
-
g.contentParts && g.contentParts.length > 0 && (
|
|
4321
|
-
const { contentParts: ve, filesInfo: X } =
|
|
4322
|
-
D &&
|
|
4323
|
-
const
|
|
4324
|
-
let
|
|
4325
|
-
if (
|
|
4326
|
-
const
|
|
4327
|
-
|
|
4328
|
-
id:
|
|
4335
|
+
let re = null;
|
|
4336
|
+
g.contentParts && g.contentParts.length > 0 && (re = g.contentParts);
|
|
4337
|
+
const { contentParts: ve, filesInfo: X } = re ? { contentParts: re, filesInfo: [] } : await rr(J), ee = [...ve];
|
|
4338
|
+
D && ee.push({ type: "text", text: G });
|
|
4339
|
+
const he = g == null ? void 0 : g.originalMessageId, je = !!(g != null && g.edit && he), Fe = !fe && ee.length > 0;
|
|
4340
|
+
let ie = null;
|
|
4341
|
+
if (Fe) {
|
|
4342
|
+
const ye = je ? he : `msg-${Date.now()}`;
|
|
4343
|
+
ie = Ut({
|
|
4344
|
+
id: ye,
|
|
4329
4345
|
role: "user",
|
|
4330
|
-
content:
|
|
4346
|
+
content: ee,
|
|
4331
4347
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4332
|
-
}, "user"), je ? v(
|
|
4348
|
+
}, "user"), je ? v(ie, { editingMessageId: he }) : v(ie);
|
|
4333
4349
|
}
|
|
4334
|
-
const
|
|
4335
|
-
...
|
|
4350
|
+
const Te = fe ? se : ie ? [ie] : [], te = {
|
|
4351
|
+
...ne,
|
|
4336
4352
|
...X.length ? { files_info: X } : {}
|
|
4337
4353
|
};
|
|
4338
|
-
|
|
4354
|
+
Te.length ? te.messages = Te : "messages" in te || (te.messages = []);
|
|
4339
4355
|
const Me = (g == null ? void 0 : g.checkpointId) ?? l.id ?? void 0;
|
|
4340
4356
|
if (g != null && g.edit && !Me)
|
|
4341
4357
|
throw new Error(
|
|
@@ -4344,48 +4360,48 @@ function Rr({
|
|
|
4344
4360
|
const Ee = {
|
|
4345
4361
|
threadId: S,
|
|
4346
4362
|
content: g == null ? void 0 : g.text,
|
|
4347
|
-
payload:
|
|
4363
|
+
payload: te,
|
|
4348
4364
|
config: g == null ? void 0 : g.config,
|
|
4349
4365
|
checkpointId: Me,
|
|
4350
4366
|
command: g == null ? void 0 : g.command,
|
|
4351
4367
|
edit: g == null ? void 0 : g.edit
|
|
4352
4368
|
};
|
|
4353
|
-
return
|
|
4369
|
+
return N(Ee, x);
|
|
4354
4370
|
},
|
|
4355
|
-
[l, a,
|
|
4356
|
-
),
|
|
4357
|
-
const g = Object.keys(
|
|
4358
|
-
if (!
|
|
4371
|
+
[l, a, _, h, v, N, p, f]
|
|
4372
|
+
), W = Y(() => {
|
|
4373
|
+
const g = Object.keys(E).length > 0;
|
|
4374
|
+
if (!_ && !g)
|
|
4359
4375
|
return C;
|
|
4360
|
-
const
|
|
4361
|
-
return C.forEach((S) =>
|
|
4362
|
-
|
|
4363
|
-
}), Array.from(
|
|
4364
|
-
}, [
|
|
4376
|
+
const x = /* @__PURE__ */ new Map();
|
|
4377
|
+
return C.forEach((S) => x.set(S.id, S)), Object.values(E).forEach((S) => {
|
|
4378
|
+
x.set(S.id, S);
|
|
4379
|
+
}), Array.from(x.values());
|
|
4380
|
+
}, [_, E, C]), Z = Y(
|
|
4365
4381
|
() => ({
|
|
4366
|
-
isStreaming:
|
|
4367
|
-
error:
|
|
4368
|
-
connectionState:
|
|
4369
|
-
messages:
|
|
4370
|
-
activeMessageId:
|
|
4371
|
-
submit:
|
|
4382
|
+
isStreaming: _,
|
|
4383
|
+
error: U,
|
|
4384
|
+
connectionState: U ? "error" : _ ? M ? "connected" : "connecting" : "idle",
|
|
4385
|
+
messages: W,
|
|
4386
|
+
activeMessageId: j,
|
|
4387
|
+
submit: L,
|
|
4372
4388
|
stop: p,
|
|
4373
4389
|
interrupt: c,
|
|
4374
4390
|
resume: () => Promise.resolve(),
|
|
4375
|
-
goto: (g,
|
|
4391
|
+
goto: (g, x) => Promise.resolve(),
|
|
4376
4392
|
clearError: () => {
|
|
4377
4393
|
}
|
|
4378
4394
|
// TODO: Implement error clearing
|
|
4379
4395
|
}),
|
|
4380
|
-
[
|
|
4396
|
+
[_, U, L, p, c, M, W]
|
|
4381
4397
|
);
|
|
4382
|
-
return /* @__PURE__ */
|
|
4398
|
+
return /* @__PURE__ */ le(Kt.Provider, { value: Z, children: e });
|
|
4383
4399
|
}
|
|
4384
|
-
function
|
|
4400
|
+
function ge(e) {
|
|
4385
4401
|
const t = K(e);
|
|
4386
4402
|
return q(() => {
|
|
4387
4403
|
t.current = e;
|
|
4388
|
-
}, [e]),
|
|
4404
|
+
}, [e]), z((...n) => {
|
|
4389
4405
|
const r = t.current;
|
|
4390
4406
|
if (r)
|
|
4391
4407
|
return r(...n);
|
|
@@ -4408,18 +4424,18 @@ function jr(e, t) {
|
|
|
4408
4424
|
return !1;
|
|
4409
4425
|
return !0;
|
|
4410
4426
|
}
|
|
4411
|
-
function
|
|
4427
|
+
function Fr(e) {
|
|
4412
4428
|
const t = K(e), n = K(e);
|
|
4413
4429
|
return jr(t.current, e) || (t.current = e, n.current = e), n.current;
|
|
4414
4430
|
}
|
|
4415
|
-
function
|
|
4431
|
+
function Lr(e) {
|
|
4416
4432
|
const t = e.artifact && typeof e.artifact == "object" ? e.artifact : null, n = !t && e.content && typeof e.content == "object" ? e.content : null, r = t ?? n, o = (r == null ? void 0 : r.task_id) ?? (r == null ? void 0 : r.taskId) ?? null;
|
|
4417
4433
|
return typeof o == "string" ? o : null;
|
|
4418
4434
|
}
|
|
4419
4435
|
function ao(e) {
|
|
4420
4436
|
const { setCurrentTaskId: t, getCurrentTaskId: n, onToolEnd: r } = e;
|
|
4421
4437
|
return (o) => {
|
|
4422
|
-
const s =
|
|
4438
|
+
const s = Lr(o), a = (n == null ? void 0 : n()) ?? null;
|
|
4423
4439
|
s && s !== a && t(s), r == null || r(o);
|
|
4424
4440
|
};
|
|
4425
4441
|
}
|
|
@@ -4440,35 +4456,35 @@ function io({
|
|
|
4440
4456
|
onMetadataEvent: h,
|
|
4441
4457
|
onFinish: k
|
|
4442
4458
|
}) {
|
|
4443
|
-
const d =
|
|
4459
|
+
const d = Fr(t), [v, I] = V(!1), C = me(i), T = me(u), P = me(a), b = me(c), y = me(l), A = me(f), p = me(m), w = me(h), _ = me(k), U = Y(
|
|
4444
4460
|
() => ({
|
|
4445
4461
|
onError: C,
|
|
4446
4462
|
onAuthError: T,
|
|
4447
|
-
onConnectionError:
|
|
4463
|
+
onConnectionError: P,
|
|
4448
4464
|
onToolEnd: y,
|
|
4449
|
-
onUpdateEvent:
|
|
4465
|
+
onUpdateEvent: A,
|
|
4450
4466
|
onCustomEvent: p,
|
|
4451
|
-
onMetadataEvent:
|
|
4452
|
-
onFinish:
|
|
4467
|
+
onMetadataEvent: w,
|
|
4468
|
+
onFinish: _
|
|
4453
4469
|
}),
|
|
4454
4470
|
[
|
|
4455
4471
|
C,
|
|
4456
4472
|
T,
|
|
4457
|
-
|
|
4473
|
+
P,
|
|
4458
4474
|
y,
|
|
4459
|
-
|
|
4475
|
+
A,
|
|
4460
4476
|
p,
|
|
4461
|
-
|
|
4462
|
-
|
|
4477
|
+
w,
|
|
4478
|
+
_
|
|
4463
4479
|
]
|
|
4464
4480
|
);
|
|
4465
|
-
return /* @__PURE__ */
|
|
4481
|
+
return /* @__PURE__ */ le(tr, { apiConfig: d, children: /* @__PURE__ */ le(
|
|
4466
4482
|
ur,
|
|
4467
4483
|
{
|
|
4468
4484
|
initialThreadId: n,
|
|
4469
4485
|
onError: C,
|
|
4470
|
-
onThreadChange:
|
|
4471
|
-
children: /* @__PURE__ */
|
|
4486
|
+
onThreadChange: b,
|
|
4487
|
+
children: /* @__PURE__ */ le(
|
|
4472
4488
|
Nr,
|
|
4473
4489
|
{
|
|
4474
4490
|
initialThreadId: n,
|
|
@@ -4477,10 +4493,10 @@ function io({
|
|
|
4477
4493
|
autoLoadInitial: s,
|
|
4478
4494
|
onError: C,
|
|
4479
4495
|
isStreaming: v,
|
|
4480
|
-
children: /* @__PURE__ */
|
|
4496
|
+
children: /* @__PURE__ */ le(
|
|
4481
4497
|
zr,
|
|
4482
4498
|
{
|
|
4483
|
-
...
|
|
4499
|
+
...U,
|
|
4484
4500
|
onStreamingChange: I,
|
|
4485
4501
|
children: e
|
|
4486
4502
|
}
|
|
@@ -4490,9 +4506,9 @@ function io({
|
|
|
4490
4506
|
}
|
|
4491
4507
|
) });
|
|
4492
4508
|
}
|
|
4493
|
-
function
|
|
4509
|
+
function me(e) {
|
|
4494
4510
|
const t = K(e);
|
|
4495
|
-
return t.current = e,
|
|
4511
|
+
return t.current = e, z((...n) => {
|
|
4496
4512
|
const r = t.current;
|
|
4497
4513
|
if (r)
|
|
4498
4514
|
return r(...n);
|
|
@@ -4590,11 +4606,11 @@ function Kr() {
|
|
|
4590
4606
|
};
|
|
4591
4607
|
}
|
|
4592
4608
|
function co(e) {
|
|
4593
|
-
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } =
|
|
4609
|
+
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = xe(), { toast: o } = Kr(), [s, a] = V({}), [i, u] = V(null), [c, l] = V(!1), f = z(() => {
|
|
4594
4610
|
l(!1), u(null);
|
|
4595
|
-
}, []), m =
|
|
4611
|
+
}, []), m = z((k) => {
|
|
4596
4612
|
u(k), l(!0);
|
|
4597
|
-
}, []), h =
|
|
4613
|
+
}, []), h = z(
|
|
4598
4614
|
async (k, d, v) => {
|
|
4599
4615
|
var I, C;
|
|
4600
4616
|
if (!t) {
|
|
@@ -4606,41 +4622,41 @@ function co(e) {
|
|
|
4606
4622
|
return;
|
|
4607
4623
|
}
|
|
4608
4624
|
try {
|
|
4609
|
-
const T = String(d.url ?? ""),
|
|
4610
|
-
if (
|
|
4625
|
+
const T = String(d.url ?? ""), P = T.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
|
|
4626
|
+
if (P) {
|
|
4611
4627
|
k.preventDefault();
|
|
4612
|
-
const
|
|
4613
|
-
m({ id:
|
|
4628
|
+
const b = P[1], y = d.name || `file_${b}`, A = d.mimeType || "application/octet-stream";
|
|
4629
|
+
m({ id: b, name: y, mimeType: A });
|
|
4614
4630
|
return;
|
|
4615
4631
|
}
|
|
4616
4632
|
if (T.startsWith("data:")) {
|
|
4617
4633
|
k.preventDefault(), a((y) => ({ ...y, [v]: !0 }));
|
|
4618
|
-
const
|
|
4634
|
+
const b = o({ title: "Fetching file...", description: "", open: !0 });
|
|
4619
4635
|
try {
|
|
4620
4636
|
const y = await r.listFiles(n ?? void 0);
|
|
4621
4637
|
if (!y || !Array.isArray(y))
|
|
4622
4638
|
throw new Error("Invalid file list response");
|
|
4623
|
-
const
|
|
4624
|
-
if (!(
|
|
4639
|
+
const A = y.find((p) => !p || typeof p != "object" || !((p.filename ?? "") === (d.name ?? "")) ? !1 : typeof d.size == "number" && typeof p.size == "number" ? p.size === d.size : !0);
|
|
4640
|
+
if (!(A != null && A.id))
|
|
4625
4641
|
throw new Error(`File "${d.name}" is not yet available on the server`);
|
|
4626
|
-
if (!
|
|
4642
|
+
if (!A.id || !A.filename)
|
|
4627
4643
|
throw new Error("Invalid file data received from server");
|
|
4628
4644
|
m({
|
|
4629
|
-
id:
|
|
4630
|
-
name: d.name ||
|
|
4631
|
-
mimeType: d.mimeType ||
|
|
4632
|
-
}), (I =
|
|
4633
|
-
id:
|
|
4645
|
+
id: A.id,
|
|
4646
|
+
name: d.name || A.filename || `file_${A.id}`,
|
|
4647
|
+
mimeType: d.mimeType || A.mime_type || "application/octet-stream"
|
|
4648
|
+
}), (I = b.update) == null || I.call(b, {
|
|
4649
|
+
id: b.id,
|
|
4634
4650
|
title: "Success",
|
|
4635
4651
|
description: `Opened ${d.name}`,
|
|
4636
4652
|
open: !0
|
|
4637
4653
|
});
|
|
4638
4654
|
} catch (y) {
|
|
4639
4655
|
console.error("Failed to fetch server file:", y);
|
|
4640
|
-
const
|
|
4641
|
-
(C =
|
|
4656
|
+
const A = y instanceof Error ? y.message : "Unknown error occurred";
|
|
4657
|
+
(C = b.update) == null || C.call(b, { id: b.id, title: "Failed", description: A }), o({
|
|
4642
4658
|
title: "Failed to fetch file",
|
|
4643
|
-
description:
|
|
4659
|
+
description: A,
|
|
4644
4660
|
open: !0
|
|
4645
4661
|
});
|
|
4646
4662
|
} finally {
|
|
@@ -4648,7 +4664,7 @@ function co(e) {
|
|
|
4648
4664
|
}
|
|
4649
4665
|
}
|
|
4650
4666
|
} catch (T) {
|
|
4651
|
-
console.error("File click error:", T), a((
|
|
4667
|
+
console.error("File click error:", T), a((P) => ({ ...P, [v]: !1 }));
|
|
4652
4668
|
}
|
|
4653
4669
|
},
|
|
4654
4670
|
[t, s, o, n, m]
|
|
@@ -4662,7 +4678,7 @@ function co(e) {
|
|
|
4662
4678
|
};
|
|
4663
4679
|
}
|
|
4664
4680
|
function lo(e) {
|
|
4665
|
-
return
|
|
4681
|
+
return Y(() => {
|
|
4666
4682
|
const t = e;
|
|
4667
4683
|
let n = Array.isArray(t.content) ? t.content : [];
|
|
4668
4684
|
return typeof t.content == "string" && (n = [{ type: "text", text: t.content }]), {
|
|
@@ -4671,7 +4687,7 @@ function lo(e) {
|
|
|
4671
4687
|
toolMeta: sr(t),
|
|
4672
4688
|
imageParts: n.filter((r) => r.type === "image_url"),
|
|
4673
4689
|
fileParts: n.filter((r) => r.type === "file"),
|
|
4674
|
-
toolRaw:
|
|
4690
|
+
toolRaw: Ln(n),
|
|
4675
4691
|
isToolStreaming: !!t.toolStreaming
|
|
4676
4692
|
};
|
|
4677
4693
|
}, [e]);
|
|
@@ -4701,7 +4717,7 @@ function Hr(e) {
|
|
|
4701
4717
|
return null;
|
|
4702
4718
|
}
|
|
4703
4719
|
function uo(e) {
|
|
4704
|
-
return
|
|
4720
|
+
return Y(() => {
|
|
4705
4721
|
const t = e.content.filter(
|
|
4706
4722
|
(u) => u.type === "text"
|
|
4707
4723
|
);
|
|
@@ -4720,7 +4736,7 @@ function uo(e) {
|
|
|
4720
4736
|
const s = Hr(r) ?? r[r.length - 1];
|
|
4721
4737
|
if (!s)
|
|
4722
4738
|
return null;
|
|
4723
|
-
const a = s.output ?? s.payload ?? s, i =
|
|
4739
|
+
const a = s.output ?? s.payload ?? s, i = ue(a);
|
|
4724
4740
|
return i && typeof i == "object" && !Array.isArray(i) ? {
|
|
4725
4741
|
kind: "dict",
|
|
4726
4742
|
value: i,
|
|
@@ -4734,22 +4750,22 @@ function uo(e) {
|
|
|
4734
4750
|
}, [e]);
|
|
4735
4751
|
}
|
|
4736
4752
|
function Wr(e) {
|
|
4737
|
-
var
|
|
4753
|
+
var _;
|
|
4738
4754
|
const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = rt({ optional: !0 }), o = Dt({ optional: !0 }), s = Ur(), { currentThreadId: a, setCurrentThreadId: i, actions: u } = r || {
|
|
4739
4755
|
currentThreadId: null,
|
|
4740
4756
|
setCurrentThreadId: () => {
|
|
4741
4757
|
},
|
|
4742
4758
|
actions: {}
|
|
4743
|
-
}, c = !!t && t !== a, [l, f] =
|
|
4744
|
-
f(
|
|
4759
|
+
}, c = !!t && t !== a, [l, f] = V([]), m = z((U) => {
|
|
4760
|
+
f(U);
|
|
4745
4761
|
}, []), {
|
|
4746
4762
|
isLoadingThread: h,
|
|
4747
4763
|
threadStateError: k,
|
|
4748
4764
|
threadCheckpoints: d,
|
|
4749
4765
|
loadThread: v
|
|
4750
4766
|
} = Bt({
|
|
4751
|
-
api:
|
|
4752
|
-
fileApi:
|
|
4767
|
+
api: xe().chatApi,
|
|
4768
|
+
fileApi: xe().fileApi,
|
|
4753
4769
|
seed: m,
|
|
4754
4770
|
currentThreadId: c ? t : null,
|
|
4755
4771
|
initialThreadId: c ? t : null,
|
|
@@ -4760,20 +4776,20 @@ function Wr(e) {
|
|
|
4760
4776
|
q(() => {
|
|
4761
4777
|
!c && !n && a && (o != null && o.loadThread) && o.loadThread(a);
|
|
4762
4778
|
}, [c, n, a, o == null ? void 0 : o.loadThread]);
|
|
4763
|
-
const I =
|
|
4764
|
-
var
|
|
4765
|
-
return ((
|
|
4766
|
-
}, [d]), C =
|
|
4779
|
+
const I = Y(() => {
|
|
4780
|
+
var U;
|
|
4781
|
+
return ((U = d[0]) == null ? void 0 : U.values) || {};
|
|
4782
|
+
}, [d]), C = Y(() => ({ timeline: [], messagePreviews: {} }), []), T = t || a, P = c ? h ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", b = c ? l : (s == null ? void 0 : s.messages) || [], y = c ? h : (o == null ? void 0 : o.isLoading) || !1, A = c ? I : (o == null ? void 0 : o.values) || {}, p = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, w = c ? k : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
|
|
4767
4783
|
return {
|
|
4768
4784
|
// UNIFIED: Single thread ID concept
|
|
4769
4785
|
threadId: T,
|
|
4770
|
-
status:
|
|
4771
|
-
messages:
|
|
4786
|
+
status: P,
|
|
4787
|
+
messages: b,
|
|
4772
4788
|
isLoading: y,
|
|
4773
4789
|
isHistoryLoading: y,
|
|
4774
|
-
error:
|
|
4790
|
+
error: w,
|
|
4775
4791
|
// Values & Metadata
|
|
4776
|
-
values:
|
|
4792
|
+
values: A,
|
|
4777
4793
|
taskMessagesByScope: p,
|
|
4778
4794
|
metadata: c ? {} : o == null ? void 0 : o.metadata,
|
|
4779
4795
|
// Actions & State relating to Global/Active Thread only
|
|
@@ -4795,7 +4811,7 @@ function Wr(e) {
|
|
|
4795
4811
|
isStreaming: (s == null ? void 0 : s.isStreaming) || !1,
|
|
4796
4812
|
activeMessageId: (s == null ? void 0 : s.activeMessageId) || null,
|
|
4797
4813
|
connectionState: (s == null ? void 0 : s.connectionState) || "disconnected",
|
|
4798
|
-
streamingAssistantId: !c && (s != null && s.isStreaming) && ((
|
|
4814
|
+
streamingAssistantId: !c && (s != null && s.isStreaming) && ((_ = o == null ? void 0 : o.metadata) != null && _.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
|
|
4799
4815
|
// Actions
|
|
4800
4816
|
submit: (s == null ? void 0 : s.submit) || (async () => {
|
|
4801
4817
|
}),
|
|
@@ -4833,78 +4849,78 @@ function fo({
|
|
|
4833
4849
|
threadId: m,
|
|
4834
4850
|
clearComposerOnSend: h = !0
|
|
4835
4851
|
}) {
|
|
4836
|
-
const { messages: k } = Wr(), [d, v] =
|
|
4852
|
+
const { messages: k } = Wr(), [d, v] = V(null), [I, C] = V(""), [T, P] = V(null), [b, y] = V(null), [A, p] = V(!1), [w, _] = V(""), U = K(w), M = K(null);
|
|
4837
4853
|
q(() => {
|
|
4838
4854
|
if (!d)
|
|
4839
4855
|
if (m) {
|
|
4840
4856
|
const g = localStorage.getItem(He(m));
|
|
4841
|
-
|
|
4857
|
+
_(g || "");
|
|
4842
4858
|
} else
|
|
4843
|
-
|
|
4859
|
+
_("");
|
|
4844
4860
|
}, [m, d]);
|
|
4845
|
-
const
|
|
4846
|
-
|
|
4861
|
+
const E = z((g) => {
|
|
4862
|
+
_(g), !d && m && localStorage.setItem(He(m), g);
|
|
4847
4863
|
}, [m, d]);
|
|
4848
4864
|
q(() => {
|
|
4849
|
-
|
|
4850
|
-
}, [
|
|
4865
|
+
U.current = w;
|
|
4866
|
+
}, [w]), q(() => {
|
|
4851
4867
|
if (!d) {
|
|
4852
4868
|
M.current = null;
|
|
4853
4869
|
return;
|
|
4854
4870
|
}
|
|
4855
|
-
M.current === null && (M.current =
|
|
4856
|
-
}, [I, d,
|
|
4857
|
-
const
|
|
4871
|
+
M.current === null && (M.current = U.current), E(I ?? "");
|
|
4872
|
+
}, [I, d, E]);
|
|
4873
|
+
const j = z(
|
|
4858
4874
|
(g) => {
|
|
4859
|
-
|
|
4875
|
+
E(g);
|
|
4860
4876
|
},
|
|
4861
|
-
[
|
|
4862
|
-
),
|
|
4863
|
-
const S = Array.isArray(
|
|
4864
|
-
if (!(!D &&
|
|
4877
|
+
[E]
|
|
4878
|
+
), N = async (g, x) => {
|
|
4879
|
+
const S = Array.isArray(x) ? { files: x } : x ?? {}, G = S.files ?? [], J = S.contentParts ?? [], D = g.trim();
|
|
4880
|
+
if (!(!D && G.length === 0 && J.length === 0))
|
|
4865
4881
|
try {
|
|
4866
|
-
const
|
|
4882
|
+
const ne = G.map(async (X) => {
|
|
4867
4883
|
try {
|
|
4868
|
-
const
|
|
4869
|
-
return { file: X, record:
|
|
4870
|
-
} catch (
|
|
4871
|
-
throw console.error("Failed to upload file", X.name,
|
|
4884
|
+
const ee = await zt.uploadFile(X);
|
|
4885
|
+
return { file: X, record: ee };
|
|
4886
|
+
} catch (ee) {
|
|
4887
|
+
throw console.error("Failed to upload file", X.name, ee), new Error(`Failed to upload ${X.name}`);
|
|
4872
4888
|
}
|
|
4873
|
-
}),
|
|
4874
|
-
const
|
|
4875
|
-
return
|
|
4889
|
+
}), fe = (await Promise.all(ne)).map(({ record: X }) => {
|
|
4890
|
+
const ee = X.mime_type;
|
|
4891
|
+
return ee.startsWith("image/") ? {
|
|
4876
4892
|
type: "image_url",
|
|
4877
4893
|
image_url: { url: X.content_url }
|
|
4878
4894
|
} : {
|
|
4879
4895
|
type: "file",
|
|
4880
4896
|
url: X.content_url,
|
|
4881
|
-
mimeType:
|
|
4897
|
+
mimeType: ee,
|
|
4882
4898
|
name: X.filename,
|
|
4883
4899
|
size: X.size
|
|
4884
4900
|
};
|
|
4885
|
-
}),
|
|
4901
|
+
}), H = [...J, ...fe], re = d ? (T == null ? void 0 : T.checkpointId) ?? n ?? void 0 : n ?? void 0, ve = d ? (T == null ? void 0 : T.checkpointNs) ?? r ?? void 0 : r ?? void 0;
|
|
4886
4902
|
await e(
|
|
4887
4903
|
{
|
|
4888
4904
|
text: D || "",
|
|
4889
|
-
contentParts:
|
|
4890
|
-
attachments:
|
|
4905
|
+
contentParts: H,
|
|
4906
|
+
attachments: G,
|
|
4891
4907
|
payload: t.payload,
|
|
4892
4908
|
edit: !!d,
|
|
4893
|
-
checkpointId:
|
|
4909
|
+
checkpointId: re,
|
|
4894
4910
|
checkpointNs: ve,
|
|
4895
4911
|
project: l ?? void 0,
|
|
4896
4912
|
originalMessageId: d ?? void 0,
|
|
4897
4913
|
config: t.config
|
|
4898
4914
|
},
|
|
4899
4915
|
f ? { onEvent: f } : void 0
|
|
4900
|
-
), o == null || o(D), c(!0), h && (m && localStorage.removeItem(He(m)),
|
|
4901
|
-
} catch (
|
|
4902
|
-
const
|
|
4903
|
-
y(
|
|
4916
|
+
), o == null || o(D), c(!0), h && (m && localStorage.removeItem(He(m)), E("")), y(null), v(null), C(""), P(null);
|
|
4917
|
+
} catch (ne) {
|
|
4918
|
+
const se = (ne == null ? void 0 : ne.message) || "Failed to send message";
|
|
4919
|
+
y(se), a == null || a(se), c(!1);
|
|
4904
4920
|
}
|
|
4905
|
-
},
|
|
4906
|
-
|
|
4907
|
-
},
|
|
4921
|
+
}, B = (g, x) => {
|
|
4922
|
+
x || N(g, { files: [] });
|
|
4923
|
+
}, O = z(
|
|
4908
4924
|
async (g) => {
|
|
4909
4925
|
await e(
|
|
4910
4926
|
{
|
|
@@ -4919,27 +4935,27 @@ function fo({
|
|
|
4919
4935
|
), s == null || s({ file: g });
|
|
4920
4936
|
},
|
|
4921
4937
|
[n, r, t, s, e]
|
|
4922
|
-
), F =
|
|
4923
|
-
(g,
|
|
4924
|
-
i && (M.current =
|
|
4938
|
+
), F = z(
|
|
4939
|
+
(g, x, S) => {
|
|
4940
|
+
i && (M.current = w, v(g), C(x), P({
|
|
4925
4941
|
checkpointId: (S == null ? void 0 : S.checkpointId) ?? null,
|
|
4926
4942
|
checkpointNs: (S == null ? void 0 : S.checkpointNs) ?? null
|
|
4927
4943
|
}), y(null));
|
|
4928
4944
|
},
|
|
4929
|
-
[
|
|
4930
|
-
),
|
|
4931
|
-
v(null), C(""),
|
|
4945
|
+
[w, i]
|
|
4946
|
+
), L = z(() => {
|
|
4947
|
+
v(null), C(""), P(null), y(null);
|
|
4932
4948
|
const g = M.current;
|
|
4933
|
-
g !== null &&
|
|
4934
|
-
}, []),
|
|
4935
|
-
let
|
|
4949
|
+
g !== null && _(g), M.current = null;
|
|
4950
|
+
}, []), W = z((g) => {
|
|
4951
|
+
let x = null;
|
|
4936
4952
|
for (let D = g - 1; D >= 0; D--)
|
|
4937
4953
|
if (u[D].role === "user") {
|
|
4938
|
-
|
|
4954
|
+
x = u[D];
|
|
4939
4955
|
break;
|
|
4940
4956
|
}
|
|
4941
|
-
if (!
|
|
4942
|
-
const S = Array.isArray(
|
|
4957
|
+
if (!x) return;
|
|
4958
|
+
const S = Array.isArray(x.content) ? x.content : [], J = S.filter((D) => (D == null ? void 0 : D.type) === "text").map((D) => D.text).join("") || (() => {
|
|
4943
4959
|
try {
|
|
4944
4960
|
return JSON.stringify(S, null, 2);
|
|
4945
4961
|
} catch {
|
|
@@ -4953,7 +4969,7 @@ function fo({
|
|
|
4953
4969
|
checkpointId: n ?? void 0,
|
|
4954
4970
|
checkpointNs: r ?? void 0,
|
|
4955
4971
|
edit: !0,
|
|
4956
|
-
originalMessageId:
|
|
4972
|
+
originalMessageId: x.id,
|
|
4957
4973
|
config: t.config
|
|
4958
4974
|
},
|
|
4959
4975
|
f ? { onEvent: f } : void 0
|
|
@@ -4962,23 +4978,23 @@ function fo({
|
|
|
4962
4978
|
return {
|
|
4963
4979
|
editingMessageId: d,
|
|
4964
4980
|
editingInitialValue: I,
|
|
4965
|
-
inputError:
|
|
4981
|
+
inputError: b,
|
|
4966
4982
|
setInputError: y,
|
|
4967
|
-
dismissError:
|
|
4983
|
+
dismissError: A,
|
|
4968
4984
|
setDismissError: p,
|
|
4969
|
-
composerValue:
|
|
4970
|
-
handleComposerChange:
|
|
4971
|
-
handleSendMessage:
|
|
4972
|
-
handleQuickPrompt:
|
|
4973
|
-
handleExcelUpload:
|
|
4985
|
+
composerValue: w,
|
|
4986
|
+
handleComposerChange: j,
|
|
4987
|
+
handleSendMessage: N,
|
|
4988
|
+
handleQuickPrompt: B,
|
|
4989
|
+
handleExcelUpload: O,
|
|
4974
4990
|
startEditing: F,
|
|
4975
|
-
cancelEditing:
|
|
4976
|
-
handleRegenerateCb:
|
|
4991
|
+
cancelEditing: L,
|
|
4992
|
+
handleRegenerateCb: W,
|
|
4977
4993
|
displayMessages: k
|
|
4978
4994
|
};
|
|
4979
4995
|
}
|
|
4980
4996
|
function po(e) {
|
|
4981
|
-
return
|
|
4997
|
+
return Y(() => e ? {
|
|
4982
4998
|
textContent: Rn(e),
|
|
4983
4999
|
imageParts: Un(e),
|
|
4984
5000
|
fileParts: jn(e),
|
|
@@ -4993,7 +5009,7 @@ function po(e) {
|
|
|
4993
5009
|
}, [e]);
|
|
4994
5010
|
}
|
|
4995
5011
|
function go(e, t, n) {
|
|
4996
|
-
const [r, o] =
|
|
5012
|
+
const [r, o] = V(e), s = K(e), a = K(null);
|
|
4997
5013
|
return q(() => {
|
|
4998
5014
|
s.current = e;
|
|
4999
5015
|
const i = () => {
|
|
@@ -5017,7 +5033,7 @@ export {
|
|
|
5017
5033
|
Yr as cn,
|
|
5018
5034
|
or as collectText,
|
|
5019
5035
|
ao as createTaskSyncToolEndHandler,
|
|
5020
|
-
|
|
5036
|
+
Lr as extractTaskIdFromToolEnd,
|
|
5021
5037
|
sr as extractToolMeta,
|
|
5022
5038
|
Zr as formatToolOutput,
|
|
5023
5039
|
ro as getAgentNameFromMessage,
|
|
@@ -5036,9 +5052,9 @@ export {
|
|
|
5036
5052
|
Mt as pretty,
|
|
5037
5053
|
Ir as refreshHistoryFileUrls,
|
|
5038
5054
|
Ve as sanitizeForDisplay,
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5055
|
+
Ie as setChatToken,
|
|
5056
|
+
Ln as stringifyTool,
|
|
5057
|
+
xe as useApi,
|
|
5042
5058
|
fo as useChatController,
|
|
5043
5059
|
Wr as useChatSession,
|
|
5044
5060
|
co as useFilePreview,
|