@teodorruskvi/chat-core 0.1.59 → 0.1.60
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 +740 -737
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +4 -4
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -3,19 +3,19 @@ var Gt = (e, t, n) => t in e ? qt(e, t, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var at = (e, t, n) => Gt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { jsx as de } from "react/jsx-runtime";
|
|
5
5
|
import * as it from "react";
|
|
6
|
-
import { createContext as Ce, useContext as je, useState as H, useRef as W, useEffect as Y, useCallback as
|
|
6
|
+
import { createContext as Ce, useContext as je, useState as H, useRef as W, useEffect as Y, useCallback as N, useMemo as Z, useReducer as Wt } from "react";
|
|
7
7
|
import Jt, { isCancel as Xt } from "axios";
|
|
8
8
|
function It(e) {
|
|
9
9
|
var t, n, r = "";
|
|
10
10
|
if (typeof e == "string" || typeof e == "number") r += e;
|
|
11
11
|
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
12
|
-
var
|
|
13
|
-
for (t = 0; t <
|
|
12
|
+
var o = e.length;
|
|
13
|
+
for (t = 0; t < o; t++) e[t] && (n = It(e[t])) && (r && (r += " "), r += n);
|
|
14
14
|
} else for (n in e) e[n] && (r && (r += " "), r += n);
|
|
15
15
|
return r;
|
|
16
16
|
}
|
|
17
17
|
function Qt() {
|
|
18
|
-
for (var e, t, n = 0, r = "",
|
|
18
|
+
for (var e, t, n = 0, r = "", o = arguments.length; n < o; n++) (e = arguments[n]) && (t = It(e)) && (r && (r += " "), r += t);
|
|
19
19
|
return r;
|
|
20
20
|
}
|
|
21
21
|
const et = "-", Yt = (e) => {
|
|
@@ -37,15 +37,15 @@ const et = "-", Yt = (e) => {
|
|
|
37
37
|
var a;
|
|
38
38
|
if (e.length === 0)
|
|
39
39
|
return t.classGroupId;
|
|
40
|
-
const n = e[0], r = t.nextPart.get(n),
|
|
41
|
-
if (
|
|
42
|
-
return
|
|
40
|
+
const n = e[0], r = t.nextPart.get(n), o = r ? vt(e.slice(1), r) : void 0;
|
|
41
|
+
if (o)
|
|
42
|
+
return o;
|
|
43
43
|
if (t.validators.length === 0)
|
|
44
44
|
return;
|
|
45
|
-
const
|
|
45
|
+
const s = e.join(et);
|
|
46
46
|
return (a = t.validators.find(({
|
|
47
47
|
validator: i
|
|
48
|
-
}) => i(
|
|
48
|
+
}) => i(s))) == null ? void 0 : a.classGroupId;
|
|
49
49
|
}, ct = /^\[(.+)\]$/, Zt = (e) => {
|
|
50
50
|
if (ct.test(e)) {
|
|
51
51
|
const t = ct.exec(e)[1], n = t == null ? void 0 : t.substring(0, t.indexOf(":"));
|
|
@@ -60,29 +60,29 @@ const et = "-", Yt = (e) => {
|
|
|
60
60
|
nextPart: /* @__PURE__ */ new Map(),
|
|
61
61
|
validators: []
|
|
62
62
|
};
|
|
63
|
-
return nn(Object.entries(e.classGroups), n).forEach(([
|
|
64
|
-
Xe(a, r,
|
|
63
|
+
return nn(Object.entries(e.classGroups), n).forEach(([s, a]) => {
|
|
64
|
+
Xe(a, r, s, t);
|
|
65
65
|
}), r;
|
|
66
66
|
}, Xe = (e, t, n, r) => {
|
|
67
|
-
e.forEach((
|
|
68
|
-
if (typeof
|
|
69
|
-
const
|
|
70
|
-
|
|
67
|
+
e.forEach((o) => {
|
|
68
|
+
if (typeof o == "string") {
|
|
69
|
+
const s = o === "" ? t : lt(t, o);
|
|
70
|
+
s.classGroupId = n;
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
if (typeof
|
|
74
|
-
if (tn(
|
|
75
|
-
Xe(
|
|
73
|
+
if (typeof o == "function") {
|
|
74
|
+
if (tn(o)) {
|
|
75
|
+
Xe(o(r), t, n, r);
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
t.validators.push({
|
|
79
|
-
validator:
|
|
79
|
+
validator: o,
|
|
80
80
|
classGroupId: n
|
|
81
81
|
});
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
Object.entries(
|
|
85
|
-
Xe(a, lt(t,
|
|
84
|
+
Object.entries(o).forEach(([s, a]) => {
|
|
85
|
+
Xe(a, lt(t, s), n, r);
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
88
|
}, lt = (e, t) => {
|
|
@@ -94,8 +94,8 @@ const et = "-", Yt = (e) => {
|
|
|
94
94
|
}), n = n.nextPart.get(r);
|
|
95
95
|
}), n;
|
|
96
96
|
}, tn = (e) => e.isThemeGetter, nn = (e, t) => t ? e.map(([n, r]) => {
|
|
97
|
-
const
|
|
98
|
-
return [n,
|
|
97
|
+
const o = r.map((s) => typeof s == "string" ? t + s : typeof s == "object" ? Object.fromEntries(Object.entries(s).map(([a, i]) => [t + a, i])) : s);
|
|
98
|
+
return [n, o];
|
|
99
99
|
}) : e, rn = (e) => {
|
|
100
100
|
if (e < 1)
|
|
101
101
|
return {
|
|
@@ -105,47 +105,47 @@ const et = "-", Yt = (e) => {
|
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
let t = 0, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
108
|
-
const
|
|
109
|
-
n.set(
|
|
108
|
+
const o = (s, a) => {
|
|
109
|
+
n.set(s, a), t++, t > e && (t = 0, r = n, n = /* @__PURE__ */ new Map());
|
|
110
110
|
};
|
|
111
111
|
return {
|
|
112
|
-
get(
|
|
113
|
-
let a = n.get(
|
|
112
|
+
get(s) {
|
|
113
|
+
let a = n.get(s);
|
|
114
114
|
if (a !== void 0)
|
|
115
115
|
return a;
|
|
116
|
-
if ((a = r.get(
|
|
117
|
-
return s
|
|
116
|
+
if ((a = r.get(s)) !== void 0)
|
|
117
|
+
return o(s, a), a;
|
|
118
118
|
},
|
|
119
|
-
set(
|
|
120
|
-
n.has(
|
|
119
|
+
set(s, a) {
|
|
120
|
+
n.has(s) ? n.set(s, a) : o(s, a);
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
|
-
}, xt = "!",
|
|
123
|
+
}, xt = "!", sn = (e) => {
|
|
124
124
|
const {
|
|
125
125
|
separator: t,
|
|
126
126
|
experimentalParseClassName: n
|
|
127
|
-
} = e, r = t.length === 1,
|
|
127
|
+
} = e, r = t.length === 1, o = t[0], s = t.length, a = (i) => {
|
|
128
128
|
const u = [];
|
|
129
129
|
let l = 0, c = 0, d;
|
|
130
|
-
for (let
|
|
131
|
-
let x = i[
|
|
130
|
+
for (let h = 0; h < i.length; h++) {
|
|
131
|
+
let x = i[h];
|
|
132
132
|
if (l === 0) {
|
|
133
|
-
if (x ===
|
|
134
|
-
u.push(i.slice(c,
|
|
133
|
+
if (x === o && (r || i.slice(h, h + s) === t)) {
|
|
134
|
+
u.push(i.slice(c, h)), c = h + s;
|
|
135
135
|
continue;
|
|
136
136
|
}
|
|
137
137
|
if (x === "/") {
|
|
138
|
-
d =
|
|
138
|
+
d = h;
|
|
139
139
|
continue;
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
x === "[" ? l++ : x === "]" && l--;
|
|
143
143
|
}
|
|
144
|
-
const
|
|
144
|
+
const m = u.length === 0 ? i : i.substring(c), p = m.startsWith(xt), I = p ? m.substring(1) : m, f = d && d > c ? d - c : void 0;
|
|
145
145
|
return {
|
|
146
146
|
modifiers: u,
|
|
147
|
-
hasImportantModifier:
|
|
148
|
-
baseClassName:
|
|
147
|
+
hasImportantModifier: p,
|
|
148
|
+
baseClassName: I,
|
|
149
149
|
maybePostfixModifierPosition: f
|
|
150
150
|
};
|
|
151
151
|
};
|
|
@@ -153,7 +153,7 @@ const et = "-", Yt = (e) => {
|
|
|
153
153
|
className: i,
|
|
154
154
|
parseClassName: a
|
|
155
155
|
}) : a;
|
|
156
|
-
},
|
|
156
|
+
}, on = (e) => {
|
|
157
157
|
if (e.length <= 1)
|
|
158
158
|
return e;
|
|
159
159
|
const t = [];
|
|
@@ -163,42 +163,42 @@ const et = "-", Yt = (e) => {
|
|
|
163
163
|
}), t.push(...n.sort()), t;
|
|
164
164
|
}, an = (e) => ({
|
|
165
165
|
cache: rn(e.cacheSize),
|
|
166
|
-
parseClassName:
|
|
166
|
+
parseClassName: sn(e),
|
|
167
167
|
...Yt(e)
|
|
168
168
|
}), cn = /\s+/, ln = (e, t) => {
|
|
169
169
|
const {
|
|
170
170
|
parseClassName: n,
|
|
171
171
|
getClassGroupId: r,
|
|
172
|
-
getConflictingClassGroupIds:
|
|
173
|
-
} = t,
|
|
172
|
+
getConflictingClassGroupIds: o
|
|
173
|
+
} = t, s = [], a = e.trim().split(cn);
|
|
174
174
|
let i = "";
|
|
175
175
|
for (let u = a.length - 1; u >= 0; u -= 1) {
|
|
176
176
|
const l = a[u], {
|
|
177
177
|
modifiers: c,
|
|
178
178
|
hasImportantModifier: d,
|
|
179
|
-
baseClassName:
|
|
180
|
-
maybePostfixModifierPosition:
|
|
179
|
+
baseClassName: m,
|
|
180
|
+
maybePostfixModifierPosition: p
|
|
181
181
|
} = n(l);
|
|
182
|
-
let
|
|
182
|
+
let I = !!p, f = r(I ? m.substring(0, p) : m);
|
|
183
183
|
if (!f) {
|
|
184
|
-
if (!
|
|
184
|
+
if (!I) {
|
|
185
185
|
i = l + (i.length > 0 ? " " + i : i);
|
|
186
186
|
continue;
|
|
187
187
|
}
|
|
188
|
-
if (f = r(
|
|
188
|
+
if (f = r(m), !f) {
|
|
189
189
|
i = l + (i.length > 0 ? " " + i : i);
|
|
190
190
|
continue;
|
|
191
191
|
}
|
|
192
|
-
|
|
192
|
+
I = !1;
|
|
193
193
|
}
|
|
194
|
-
const
|
|
195
|
-
if (
|
|
194
|
+
const h = on(c).join(":"), x = d ? h + xt : h, S = x + f;
|
|
195
|
+
if (s.includes(S))
|
|
196
196
|
continue;
|
|
197
|
-
|
|
198
|
-
const A =
|
|
197
|
+
s.push(S);
|
|
198
|
+
const A = o(f, I);
|
|
199
199
|
for (let w = 0; w < A.length; ++w) {
|
|
200
200
|
const k = A[w];
|
|
201
|
-
|
|
201
|
+
s.push(x + k);
|
|
202
202
|
}
|
|
203
203
|
i = l + (i.length > 0 ? " " + i : i);
|
|
204
204
|
}
|
|
@@ -219,20 +219,20 @@ const At = (e) => {
|
|
|
219
219
|
return n;
|
|
220
220
|
};
|
|
221
221
|
function un(e, ...t) {
|
|
222
|
-
let n, r,
|
|
222
|
+
let n, r, o, s = a;
|
|
223
223
|
function a(u) {
|
|
224
224
|
const l = t.reduce((c, d) => d(c), e());
|
|
225
|
-
return n = an(l), r = n.cache.get,
|
|
225
|
+
return n = an(l), r = n.cache.get, o = n.cache.set, s = i, i(u);
|
|
226
226
|
}
|
|
227
227
|
function i(u) {
|
|
228
228
|
const l = r(u);
|
|
229
229
|
if (l)
|
|
230
230
|
return l;
|
|
231
231
|
const c = ln(u, n);
|
|
232
|
-
return
|
|
232
|
+
return o(u, c), c;
|
|
233
233
|
}
|
|
234
234
|
return function() {
|
|
235
|
-
return
|
|
235
|
+
return s(dn.apply(null, arguments));
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
238
|
const q = (e) => {
|
|
@@ -247,7 +247,7 @@ const q = (e) => {
|
|
|
247
247
|
// I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough.
|
|
248
248
|
mn.test(e) && !yn.test(e)
|
|
249
249
|
), St = () => !1, Mn = (e) => hn.test(e), Cn = (e) => bn.test(e), En = () => {
|
|
250
|
-
const e = q("colors"), t = q("spacing"), n = q("blur"), r = q("brightness"),
|
|
250
|
+
const e = q("colors"), t = q("spacing"), n = q("blur"), r = q("brightness"), o = q("borderColor"), s = q("borderRadius"), a = q("borderSpacing"), i = q("borderWidth"), u = q("contrast"), l = q("grayscale"), c = q("hueRotate"), d = q("invert"), m = q("gap"), p = q("gradientColorStops"), I = q("gradientColorStopPositions"), f = q("inset"), h = q("margin"), x = q("opacity"), S = q("padding"), A = q("saturate"), w = q("scale"), k = q("sepia"), b = q("skew"), T = q("space"), y = q("translate"), v = () => ["auto", "contain", "none"], _ = () => ["auto", "hidden", "clip", "visible", "scroll"], L = () => ["auto", R, t], M = () => [R, t], $ = () => ["", pe, Ie], U = () => ["auto", Te, R], V = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], P = () => ["solid", "dashed", "dotted", "double", "none"], F = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], E = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], j = () => ["", "0", R], G = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], g = () => [Te, R];
|
|
251
251
|
return {
|
|
252
252
|
cacheSize: 500,
|
|
253
253
|
separator: ":",
|
|
@@ -377,42 +377,42 @@ const q = (e) => {
|
|
|
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: v()
|
|
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": v()
|
|
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": v()
|
|
416
416
|
}],
|
|
417
417
|
/**
|
|
418
418
|
* Position
|
|
@@ -630,28 +630,28 @@ const q = (e) => {
|
|
|
630
630
|
* @see https://tailwindcss.com/docs/gap
|
|
631
631
|
*/
|
|
632
632
|
gap: [{
|
|
633
|
-
gap: [
|
|
633
|
+
gap: [m]
|
|
634
634
|
}],
|
|
635
635
|
/**
|
|
636
636
|
* Gap X
|
|
637
637
|
* @see https://tailwindcss.com/docs/gap
|
|
638
638
|
*/
|
|
639
639
|
"gap-x": [{
|
|
640
|
-
"gap-x": [
|
|
640
|
+
"gap-x": [m]
|
|
641
641
|
}],
|
|
642
642
|
/**
|
|
643
643
|
* Gap Y
|
|
644
644
|
* @see https://tailwindcss.com/docs/gap
|
|
645
645
|
*/
|
|
646
646
|
"gap-y": [{
|
|
647
|
-
"gap-y": [
|
|
647
|
+
"gap-y": [m]
|
|
648
648
|
}],
|
|
649
649
|
/**
|
|
650
650
|
* Justify Content
|
|
651
651
|
* @see https://tailwindcss.com/docs/justify-content
|
|
652
652
|
*/
|
|
653
653
|
"justify-content": [{
|
|
654
|
-
justify: ["normal", ...
|
|
654
|
+
justify: ["normal", ...E()]
|
|
655
655
|
}],
|
|
656
656
|
/**
|
|
657
657
|
* Justify Items
|
|
@@ -672,7 +672,7 @@ const q = (e) => {
|
|
|
672
672
|
* @see https://tailwindcss.com/docs/align-content
|
|
673
673
|
*/
|
|
674
674
|
"align-content": [{
|
|
675
|
-
content: ["normal", ...
|
|
675
|
+
content: ["normal", ...E(), "baseline"]
|
|
676
676
|
}],
|
|
677
677
|
/**
|
|
678
678
|
* Align Items
|
|
@@ -693,7 +693,7 @@ const q = (e) => {
|
|
|
693
693
|
* @see https://tailwindcss.com/docs/place-content
|
|
694
694
|
*/
|
|
695
695
|
"place-content": [{
|
|
696
|
-
"place-content": [...
|
|
696
|
+
"place-content": [...E(), "baseline"]
|
|
697
697
|
}],
|
|
698
698
|
/**
|
|
699
699
|
* Place Items
|
|
@@ -778,63 +778,63 @@ const q = (e) => {
|
|
|
778
778
|
* @see https://tailwindcss.com/docs/margin
|
|
779
779
|
*/
|
|
780
780
|
m: [{
|
|
781
|
-
m: [
|
|
781
|
+
m: [h]
|
|
782
782
|
}],
|
|
783
783
|
/**
|
|
784
784
|
* Margin X
|
|
785
785
|
* @see https://tailwindcss.com/docs/margin
|
|
786
786
|
*/
|
|
787
787
|
mx: [{
|
|
788
|
-
mx: [
|
|
788
|
+
mx: [h]
|
|
789
789
|
}],
|
|
790
790
|
/**
|
|
791
791
|
* Margin Y
|
|
792
792
|
* @see https://tailwindcss.com/docs/margin
|
|
793
793
|
*/
|
|
794
794
|
my: [{
|
|
795
|
-
my: [
|
|
795
|
+
my: [h]
|
|
796
796
|
}],
|
|
797
797
|
/**
|
|
798
798
|
* Margin Start
|
|
799
799
|
* @see https://tailwindcss.com/docs/margin
|
|
800
800
|
*/
|
|
801
801
|
ms: [{
|
|
802
|
-
ms: [
|
|
802
|
+
ms: [h]
|
|
803
803
|
}],
|
|
804
804
|
/**
|
|
805
805
|
* Margin End
|
|
806
806
|
* @see https://tailwindcss.com/docs/margin
|
|
807
807
|
*/
|
|
808
808
|
me: [{
|
|
809
|
-
me: [
|
|
809
|
+
me: [h]
|
|
810
810
|
}],
|
|
811
811
|
/**
|
|
812
812
|
* Margin Top
|
|
813
813
|
* @see https://tailwindcss.com/docs/margin
|
|
814
814
|
*/
|
|
815
815
|
mt: [{
|
|
816
|
-
mt: [
|
|
816
|
+
mt: [h]
|
|
817
817
|
}],
|
|
818
818
|
/**
|
|
819
819
|
* Margin Right
|
|
820
820
|
* @see https://tailwindcss.com/docs/margin
|
|
821
821
|
*/
|
|
822
822
|
mr: [{
|
|
823
|
-
mr: [
|
|
823
|
+
mr: [h]
|
|
824
824
|
}],
|
|
825
825
|
/**
|
|
826
826
|
* Margin Bottom
|
|
827
827
|
* @see https://tailwindcss.com/docs/margin
|
|
828
828
|
*/
|
|
829
829
|
mb: [{
|
|
830
|
-
mb: [
|
|
830
|
+
mb: [h]
|
|
831
831
|
}],
|
|
832
832
|
/**
|
|
833
833
|
* Margin Left
|
|
834
834
|
* @see https://tailwindcss.com/docs/margin
|
|
835
835
|
*/
|
|
836
836
|
ml: [{
|
|
837
|
-
ml: [
|
|
837
|
+
ml: [h]
|
|
838
838
|
}],
|
|
839
839
|
/**
|
|
840
840
|
* Space Between X
|
|
@@ -1218,42 +1218,42 @@ const q = (e) => {
|
|
|
1218
1218
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
1219
1219
|
*/
|
|
1220
1220
|
"gradient-from-pos": [{
|
|
1221
|
-
from: [
|
|
1221
|
+
from: [I]
|
|
1222
1222
|
}],
|
|
1223
1223
|
/**
|
|
1224
1224
|
* Gradient Color Stops Via Position
|
|
1225
1225
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
1226
1226
|
*/
|
|
1227
1227
|
"gradient-via-pos": [{
|
|
1228
|
-
via: [
|
|
1228
|
+
via: [I]
|
|
1229
1229
|
}],
|
|
1230
1230
|
/**
|
|
1231
1231
|
* Gradient Color Stops To Position
|
|
1232
1232
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
1233
1233
|
*/
|
|
1234
1234
|
"gradient-to-pos": [{
|
|
1235
|
-
to: [
|
|
1235
|
+
to: [I]
|
|
1236
1236
|
}],
|
|
1237
1237
|
/**
|
|
1238
1238
|
* Gradient Color Stops From
|
|
1239
1239
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
1240
1240
|
*/
|
|
1241
1241
|
"gradient-from": [{
|
|
1242
|
-
from: [
|
|
1242
|
+
from: [p]
|
|
1243
1243
|
}],
|
|
1244
1244
|
/**
|
|
1245
1245
|
* Gradient Color Stops Via
|
|
1246
1246
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
1247
1247
|
*/
|
|
1248
1248
|
"gradient-via": [{
|
|
1249
|
-
via: [
|
|
1249
|
+
via: [p]
|
|
1250
1250
|
}],
|
|
1251
1251
|
/**
|
|
1252
1252
|
* Gradient Color Stops To
|
|
1253
1253
|
* @see https://tailwindcss.com/docs/gradient-color-stops
|
|
1254
1254
|
*/
|
|
1255
1255
|
"gradient-to": [{
|
|
1256
|
-
to: [
|
|
1256
|
+
to: [p]
|
|
1257
1257
|
}],
|
|
1258
1258
|
// Borders
|
|
1259
1259
|
/**
|
|
@@ -1261,105 +1261,105 @@ const q = (e) => {
|
|
|
1261
1261
|
* @see https://tailwindcss.com/docs/border-radius
|
|
1262
1262
|
*/
|
|
1263
1263
|
rounded: [{
|
|
1264
|
-
rounded: [
|
|
1264
|
+
rounded: [s]
|
|
1265
1265
|
}],
|
|
1266
1266
|
/**
|
|
1267
1267
|
* Border Radius Start
|
|
1268
1268
|
* @see https://tailwindcss.com/docs/border-radius
|
|
1269
1269
|
*/
|
|
1270
1270
|
"rounded-s": [{
|
|
1271
|
-
"rounded-s": [
|
|
1271
|
+
"rounded-s": [s]
|
|
1272
1272
|
}],
|
|
1273
1273
|
/**
|
|
1274
1274
|
* Border Radius End
|
|
1275
1275
|
* @see https://tailwindcss.com/docs/border-radius
|
|
1276
1276
|
*/
|
|
1277
1277
|
"rounded-e": [{
|
|
1278
|
-
"rounded-e": [
|
|
1278
|
+
"rounded-e": [s]
|
|
1279
1279
|
}],
|
|
1280
1280
|
/**
|
|
1281
1281
|
* Border Radius Top
|
|
1282
1282
|
* @see https://tailwindcss.com/docs/border-radius
|
|
1283
1283
|
*/
|
|
1284
1284
|
"rounded-t": [{
|
|
1285
|
-
"rounded-t": [
|
|
1285
|
+
"rounded-t": [s]
|
|
1286
1286
|
}],
|
|
1287
1287
|
/**
|
|
1288
1288
|
* Border Radius Right
|
|
1289
1289
|
* @see https://tailwindcss.com/docs/border-radius
|
|
1290
1290
|
*/
|
|
1291
1291
|
"rounded-r": [{
|
|
1292
|
-
"rounded-r": [
|
|
1292
|
+
"rounded-r": [s]
|
|
1293
1293
|
}],
|
|
1294
1294
|
/**
|
|
1295
1295
|
* Border Radius Bottom
|
|
1296
1296
|
* @see https://tailwindcss.com/docs/border-radius
|
|
1297
1297
|
*/
|
|
1298
1298
|
"rounded-b": [{
|
|
1299
|
-
"rounded-b": [
|
|
1299
|
+
"rounded-b": [s]
|
|
1300
1300
|
}],
|
|
1301
1301
|
/**
|
|
1302
1302
|
* Border Radius Left
|
|
1303
1303
|
* @see https://tailwindcss.com/docs/border-radius
|
|
1304
1304
|
*/
|
|
1305
1305
|
"rounded-l": [{
|
|
1306
|
-
"rounded-l": [
|
|
1306
|
+
"rounded-l": [s]
|
|
1307
1307
|
}],
|
|
1308
1308
|
/**
|
|
1309
1309
|
* Border Radius Start Start
|
|
1310
1310
|
* @see https://tailwindcss.com/docs/border-radius
|
|
1311
1311
|
*/
|
|
1312
1312
|
"rounded-ss": [{
|
|
1313
|
-
"rounded-ss": [
|
|
1313
|
+
"rounded-ss": [s]
|
|
1314
1314
|
}],
|
|
1315
1315
|
/**
|
|
1316
1316
|
* Border Radius Start End
|
|
1317
1317
|
* @see https://tailwindcss.com/docs/border-radius
|
|
1318
1318
|
*/
|
|
1319
1319
|
"rounded-se": [{
|
|
1320
|
-
"rounded-se": [
|
|
1320
|
+
"rounded-se": [s]
|
|
1321
1321
|
}],
|
|
1322
1322
|
/**
|
|
1323
1323
|
* Border Radius End End
|
|
1324
1324
|
* @see https://tailwindcss.com/docs/border-radius
|
|
1325
1325
|
*/
|
|
1326
1326
|
"rounded-ee": [{
|
|
1327
|
-
"rounded-ee": [
|
|
1327
|
+
"rounded-ee": [s]
|
|
1328
1328
|
}],
|
|
1329
1329
|
/**
|
|
1330
1330
|
* Border Radius End Start
|
|
1331
1331
|
* @see https://tailwindcss.com/docs/border-radius
|
|
1332
1332
|
*/
|
|
1333
1333
|
"rounded-es": [{
|
|
1334
|
-
"rounded-es": [
|
|
1334
|
+
"rounded-es": [s]
|
|
1335
1335
|
}],
|
|
1336
1336
|
/**
|
|
1337
1337
|
* Border Radius Top Left
|
|
1338
1338
|
* @see https://tailwindcss.com/docs/border-radius
|
|
1339
1339
|
*/
|
|
1340
1340
|
"rounded-tl": [{
|
|
1341
|
-
"rounded-tl": [
|
|
1341
|
+
"rounded-tl": [s]
|
|
1342
1342
|
}],
|
|
1343
1343
|
/**
|
|
1344
1344
|
* Border Radius Top Right
|
|
1345
1345
|
* @see https://tailwindcss.com/docs/border-radius
|
|
1346
1346
|
*/
|
|
1347
1347
|
"rounded-tr": [{
|
|
1348
|
-
"rounded-tr": [
|
|
1348
|
+
"rounded-tr": [s]
|
|
1349
1349
|
}],
|
|
1350
1350
|
/**
|
|
1351
1351
|
* Border Radius Bottom Right
|
|
1352
1352
|
* @see https://tailwindcss.com/docs/border-radius
|
|
1353
1353
|
*/
|
|
1354
1354
|
"rounded-br": [{
|
|
1355
|
-
"rounded-br": [
|
|
1355
|
+
"rounded-br": [s]
|
|
1356
1356
|
}],
|
|
1357
1357
|
/**
|
|
1358
1358
|
* Border Radius Bottom Left
|
|
1359
1359
|
* @see https://tailwindcss.com/docs/border-radius
|
|
1360
1360
|
*/
|
|
1361
1361
|
"rounded-bl": [{
|
|
1362
|
-
"rounded-bl": [
|
|
1362
|
+
"rounded-bl": [s]
|
|
1363
1363
|
}],
|
|
1364
1364
|
/**
|
|
1365
1365
|
* Border Width
|
|
@@ -1481,70 +1481,70 @@ const q = (e) => {
|
|
|
1481
1481
|
* @see https://tailwindcss.com/docs/border-color
|
|
1482
1482
|
*/
|
|
1483
1483
|
"border-color": [{
|
|
1484
|
-
border: [
|
|
1484
|
+
border: [o]
|
|
1485
1485
|
}],
|
|
1486
1486
|
/**
|
|
1487
1487
|
* Border Color X
|
|
1488
1488
|
* @see https://tailwindcss.com/docs/border-color
|
|
1489
1489
|
*/
|
|
1490
1490
|
"border-color-x": [{
|
|
1491
|
-
"border-x": [
|
|
1491
|
+
"border-x": [o]
|
|
1492
1492
|
}],
|
|
1493
1493
|
/**
|
|
1494
1494
|
* Border Color Y
|
|
1495
1495
|
* @see https://tailwindcss.com/docs/border-color
|
|
1496
1496
|
*/
|
|
1497
1497
|
"border-color-y": [{
|
|
1498
|
-
"border-y": [
|
|
1498
|
+
"border-y": [o]
|
|
1499
1499
|
}],
|
|
1500
1500
|
/**
|
|
1501
1501
|
* Border Color S
|
|
1502
1502
|
* @see https://tailwindcss.com/docs/border-color
|
|
1503
1503
|
*/
|
|
1504
1504
|
"border-color-s": [{
|
|
1505
|
-
"border-s": [
|
|
1505
|
+
"border-s": [o]
|
|
1506
1506
|
}],
|
|
1507
1507
|
/**
|
|
1508
1508
|
* Border Color E
|
|
1509
1509
|
* @see https://tailwindcss.com/docs/border-color
|
|
1510
1510
|
*/
|
|
1511
1511
|
"border-color-e": [{
|
|
1512
|
-
"border-e": [
|
|
1512
|
+
"border-e": [o]
|
|
1513
1513
|
}],
|
|
1514
1514
|
/**
|
|
1515
1515
|
* Border Color Top
|
|
1516
1516
|
* @see https://tailwindcss.com/docs/border-color
|
|
1517
1517
|
*/
|
|
1518
1518
|
"border-color-t": [{
|
|
1519
|
-
"border-t": [
|
|
1519
|
+
"border-t": [o]
|
|
1520
1520
|
}],
|
|
1521
1521
|
/**
|
|
1522
1522
|
* Border Color Right
|
|
1523
1523
|
* @see https://tailwindcss.com/docs/border-color
|
|
1524
1524
|
*/
|
|
1525
1525
|
"border-color-r": [{
|
|
1526
|
-
"border-r": [
|
|
1526
|
+
"border-r": [o]
|
|
1527
1527
|
}],
|
|
1528
1528
|
/**
|
|
1529
1529
|
* Border Color Bottom
|
|
1530
1530
|
* @see https://tailwindcss.com/docs/border-color
|
|
1531
1531
|
*/
|
|
1532
1532
|
"border-color-b": [{
|
|
1533
|
-
"border-b": [
|
|
1533
|
+
"border-b": [o]
|
|
1534
1534
|
}],
|
|
1535
1535
|
/**
|
|
1536
1536
|
* Border Color Left
|
|
1537
1537
|
* @see https://tailwindcss.com/docs/border-color
|
|
1538
1538
|
*/
|
|
1539
1539
|
"border-color-l": [{
|
|
1540
|
-
"border-l": [
|
|
1540
|
+
"border-l": [o]
|
|
1541
1541
|
}],
|
|
1542
1542
|
/**
|
|
1543
1543
|
* Divide Color
|
|
1544
1544
|
* @see https://tailwindcss.com/docs/divide-color
|
|
1545
1545
|
*/
|
|
1546
1546
|
"divide-color": [{
|
|
1547
|
-
divide: [
|
|
1547
|
+
divide: [o]
|
|
1548
1548
|
}],
|
|
1549
1549
|
/**
|
|
1550
1550
|
* Outline Style
|
|
@@ -1927,14 +1927,14 @@ const q = (e) => {
|
|
|
1927
1927
|
* @see https://tailwindcss.com/docs/skew
|
|
1928
1928
|
*/
|
|
1929
1929
|
"skew-x": [{
|
|
1930
|
-
"skew-x": [
|
|
1930
|
+
"skew-x": [b]
|
|
1931
1931
|
}],
|
|
1932
1932
|
/**
|
|
1933
1933
|
* Skew Y
|
|
1934
1934
|
* @see https://tailwindcss.com/docs/skew
|
|
1935
1935
|
*/
|
|
1936
1936
|
"skew-y": [{
|
|
1937
|
-
"skew-y": [
|
|
1937
|
+
"skew-y": [b]
|
|
1938
1938
|
}],
|
|
1939
1939
|
/**
|
|
1940
1940
|
* Transform Origin
|
|
@@ -2276,21 +2276,21 @@ const q = (e) => {
|
|
|
2276
2276
|
}
|
|
2277
2277
|
};
|
|
2278
2278
|
}, Pn = /* @__PURE__ */ un(En);
|
|
2279
|
-
function
|
|
2279
|
+
function rs(...e) {
|
|
2280
2280
|
return Pn(Qt(e));
|
|
2281
2281
|
}
|
|
2282
2282
|
function _n(e) {
|
|
2283
2283
|
let t = !1, n = "";
|
|
2284
|
-
for (const
|
|
2285
|
-
if (
|
|
2286
|
-
n +=
|
|
2284
|
+
for (const o of e) {
|
|
2285
|
+
if (o === "\\") {
|
|
2286
|
+
n += o, t = !t;
|
|
2287
2287
|
continue;
|
|
2288
2288
|
}
|
|
2289
|
-
if (
|
|
2289
|
+
if (o === "'" && !t) {
|
|
2290
2290
|
n += '"';
|
|
2291
2291
|
continue;
|
|
2292
2292
|
}
|
|
2293
|
-
n +=
|
|
2293
|
+
n += o, t = !1;
|
|
2294
2294
|
}
|
|
2295
2295
|
return n.replace(/\bTrue\b/g, "true").replace(/\bFalse\b/g, "false").replace(/\bNone\b/g, "null");
|
|
2296
2296
|
}
|
|
@@ -2372,8 +2372,8 @@ function De(e) {
|
|
|
2372
2372
|
if (n === "data" && typeof r == "string" && r.length > 100)
|
|
2373
2373
|
t[n] = `[base64 ${r.length} chars omitted]`;
|
|
2374
2374
|
else {
|
|
2375
|
-
const
|
|
2376
|
-
|
|
2375
|
+
const o = De(r);
|
|
2376
|
+
o !== void 0 && (t[n] = o);
|
|
2377
2377
|
}
|
|
2378
2378
|
}
|
|
2379
2379
|
if (Object.keys(t).length)
|
|
@@ -2397,15 +2397,15 @@ function Et(e) {
|
|
|
2397
2397
|
return "";
|
|
2398
2398
|
}
|
|
2399
2399
|
}
|
|
2400
|
-
function
|
|
2400
|
+
function ss(e) {
|
|
2401
2401
|
const t = Et(e);
|
|
2402
2402
|
return typeof e == "string" && Nn(e) ? { content: e, isMarkdown: !0 } : { content: t, isMarkdown: !1 };
|
|
2403
2403
|
}
|
|
2404
2404
|
function Fn(e) {
|
|
2405
2405
|
const t = (r) => {
|
|
2406
2406
|
try {
|
|
2407
|
-
const
|
|
2408
|
-
return typeof
|
|
2407
|
+
const o = De(r);
|
|
2408
|
+
return typeof o == "string" ? o : JSON.stringify(o ?? "");
|
|
2409
2409
|
} catch {
|
|
2410
2410
|
return "";
|
|
2411
2411
|
}
|
|
@@ -2413,7 +2413,7 @@ function Fn(e) {
|
|
|
2413
2413
|
return n.length ? t(n.map((r) => r.text).join(`
|
|
2414
2414
|
`)) : t(e);
|
|
2415
2415
|
}
|
|
2416
|
-
function
|
|
2416
|
+
function os(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
2419
|
function ue(e) {
|
|
@@ -2448,27 +2448,27 @@ function fe(e) {
|
|
|
2448
2448
|
);
|
|
2449
2449
|
}
|
|
2450
2450
|
function nt(e) {
|
|
2451
|
-
var x, S, A, w, k,
|
|
2451
|
+
var x, S, A, w, k, b, T;
|
|
2452
2452
|
if (!e || typeof e != "object") return null;
|
|
2453
2453
|
const t = fe(e), n = Kn(t);
|
|
2454
2454
|
if (!n)
|
|
2455
2455
|
return null;
|
|
2456
|
-
const r = t.toolCalls ?? ((x = t.additionalKwargs) == null ? void 0 : x.toolCalls),
|
|
2456
|
+
const r = t.toolCalls ?? ((x = t.additionalKwargs) == null ? void 0 : x.toolCalls), o = Array.isArray(r) ? r.map(rt) : void 0, s = Dn(t.content ?? t.parts, !!(o != null && o.length)), a = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, i = t.createdAt ?? ((S = t.additionalKwargs) == null ? void 0 : S.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), u = t.name ?? ((A = t.additionalKwargs) == null ? void 0 : A.agentName) ?? void 0, l = t.model ?? ((w = t.additionalKwargs) == null ? void 0 : w.model) ?? void 0, c = t.toolCallId ?? void 0, d = t.additionalKwargs ?? void 0, m = t.responseMetadata ?? void 0, p = t.checkpointId ?? ((k = t.additionalKwargs) == null ? void 0 : k.checkpointId) ?? void 0, I = t.checkpointNs ?? ((b = t.additionalKwargs) == null ? void 0 : b.checkpointNs) ?? void 0, f = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((T = t.additionalKwargs) != null && T.toolStreaming);
|
|
2457
2457
|
return {
|
|
2458
2458
|
...t,
|
|
2459
2459
|
id: a,
|
|
2460
2460
|
role: n,
|
|
2461
|
-
content:
|
|
2461
|
+
content: s,
|
|
2462
2462
|
createdAt: i,
|
|
2463
2463
|
name: u,
|
|
2464
2464
|
model: l,
|
|
2465
2465
|
toolCallId: c,
|
|
2466
|
-
toolCalls:
|
|
2467
|
-
checkpointId:
|
|
2468
|
-
checkpointNs:
|
|
2466
|
+
toolCalls: o,
|
|
2467
|
+
checkpointId: p,
|
|
2468
|
+
checkpointNs: I,
|
|
2469
2469
|
toolStreaming: f,
|
|
2470
2470
|
additionalKwargs: d,
|
|
2471
|
-
responseMetadata:
|
|
2471
|
+
responseMetadata: m,
|
|
2472
2472
|
artifact: t.artifact && typeof t.artifact == "object" && !t.artifact.type ? { ...t.artifact, type: t.name } : t.artifact ?? void 0
|
|
2473
2473
|
};
|
|
2474
2474
|
}
|
|
@@ -2522,11 +2522,11 @@ function Hn(e, t) {
|
|
|
2522
2522
|
if (!n) return;
|
|
2523
2523
|
const r = typeof n == "string" ? n : Et(n);
|
|
2524
2524
|
if (!r.trim()) return;
|
|
2525
|
-
const
|
|
2525
|
+
const o = [{ type: "text", text: r }];
|
|
2526
2526
|
return {
|
|
2527
2527
|
id: `tool-${t.id}`,
|
|
2528
2528
|
role: "tool",
|
|
2529
|
-
content:
|
|
2529
|
+
content: o,
|
|
2530
2530
|
name: t.name,
|
|
2531
2531
|
toolCallId: t.id,
|
|
2532
2532
|
artifact: t.artifact,
|
|
@@ -2535,13 +2535,13 @@ function Hn(e, t) {
|
|
|
2535
2535
|
}
|
|
2536
2536
|
function Vn(e, t = []) {
|
|
2537
2537
|
if (Array.isArray(e)) {
|
|
2538
|
-
const
|
|
2539
|
-
return
|
|
2540
|
-
var d,
|
|
2541
|
-
const i = qe(a.id, e) || qe(a.id, t), u = Array.isArray((d = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : d.toolProgress) ? (
|
|
2538
|
+
const o = e.filter((a) => a.role === "assistant").flatMap((a) => ut(a)), s = /* @__PURE__ */ new Map();
|
|
2539
|
+
return o.forEach((a) => s.set(a.id, a)), Array.from(s.values()).map((a) => {
|
|
2540
|
+
var d, m, p;
|
|
2541
|
+
const i = qe(a.id, e) || qe(a.id, t), u = Array.isArray((d = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : d.toolProgress) ? (m = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : m.toolProgress : void 0, l = (i == null ? void 0 : i.artifact) ?? a.artifact, c = dt(a.status) ?? ((p = i == null ? void 0 : i.additionalKwargs) != null && p.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
|
|
2542
2542
|
if (i && !a.content && c === "completed") {
|
|
2543
|
-
const
|
|
2544
|
-
typeof
|
|
2543
|
+
const I = ue(i);
|
|
2544
|
+
typeof I == "string" && (a.content = I);
|
|
2545
2545
|
}
|
|
2546
2546
|
return {
|
|
2547
2547
|
call: a,
|
|
@@ -2556,21 +2556,21 @@ function Vn(e, t = []) {
|
|
|
2556
2556
|
const n = ut(e);
|
|
2557
2557
|
return n.length === 0 ? [] : n.map((r) => {
|
|
2558
2558
|
var u, l, c;
|
|
2559
|
-
const
|
|
2560
|
-
if (
|
|
2561
|
-
const d = ue(
|
|
2559
|
+
const o = qe(r.id, t) ?? Hn(e, r), s = Array.isArray((u = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : u.toolProgress) ? (l = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : l.toolProgress : void 0, a = (o == null ? void 0 : o.artifact) ?? r.artifact, i = dt(r.status) ?? ((c = o == null ? void 0 : o.additionalKwargs) != null && c.toolStreaming ? "pending" : null) ?? (o ? "completed" : "pending");
|
|
2560
|
+
if (o && !r.content && i === "completed") {
|
|
2561
|
+
const d = ue(o);
|
|
2562
2562
|
typeof d == "string" && (r.content = d);
|
|
2563
2563
|
}
|
|
2564
2564
|
return {
|
|
2565
2565
|
call: r,
|
|
2566
|
-
result:
|
|
2566
|
+
result: o,
|
|
2567
2567
|
state: i,
|
|
2568
|
-
progress:
|
|
2568
|
+
progress: s,
|
|
2569
2569
|
artifact: a
|
|
2570
2570
|
};
|
|
2571
2571
|
});
|
|
2572
2572
|
}
|
|
2573
|
-
function
|
|
2573
|
+
function as(e, t = []) {
|
|
2574
2574
|
return Vn(e, t).map((n) => n.artifact).filter((n) => !!n);
|
|
2575
2575
|
}
|
|
2576
2576
|
const ze = {
|
|
@@ -2598,7 +2598,7 @@ function _t(e) {
|
|
|
2598
2598
|
}
|
|
2599
2599
|
const qn = 12e4, Gn = 12e4;
|
|
2600
2600
|
let Ye = qn, Nt = Gn;
|
|
2601
|
-
const
|
|
2601
|
+
const se = Jt.create({
|
|
2602
2602
|
// BaseURL is set dynamically via ApiProvider -> api.updateConfig
|
|
2603
2603
|
timeout: Ye,
|
|
2604
2604
|
withCredentials: !0
|
|
@@ -2608,20 +2608,20 @@ function ft(e) {
|
|
|
2608
2608
|
}
|
|
2609
2609
|
function Wn(e) {
|
|
2610
2610
|
const t = ft(e.requestTimeoutMs), n = ft(e.historyTimeoutMs);
|
|
2611
|
-
t !== null && (Ye = t,
|
|
2611
|
+
t !== null && (Ye = t, se.defaults.timeout = Ye), n !== null && (Nt = n);
|
|
2612
2612
|
}
|
|
2613
2613
|
function Jn() {
|
|
2614
2614
|
return Nt;
|
|
2615
2615
|
}
|
|
2616
|
-
|
|
2617
|
-
|
|
2616
|
+
se.interceptors.request.use((e) => (Ke && (e.headers.Authorization = `Bearer ${Ke}`), e));
|
|
2617
|
+
se.interceptors.response.use(
|
|
2618
2618
|
(e) => {
|
|
2619
2619
|
if (typeof window < "u" && (e != null && e.data))
|
|
2620
2620
|
try {
|
|
2621
|
-
const t = e.data, n = t.data || {}, r = typeof t.token == "string" && t.token || typeof n.token == "string" && n.token || null,
|
|
2622
|
-
r && (localStorage.setItem(ze.authToken, r), xe(r)),
|
|
2621
|
+
const t = e.data, n = t.data || {}, r = typeof t.token == "string" && t.token || typeof n.token == "string" && n.token || null, o = typeof t.expires_at == "number" && t.expires_at || typeof n.expires_at == "number" && n.expires_at || typeof t.expiresAt == "number" && t.expiresAt || typeof n.expiresAt == "number" && n.expiresAt || null;
|
|
2622
|
+
r && (localStorage.setItem(ze.authToken, r), xe(r)), o && localStorage.setItem(ze.authTokenExpiresAt, o.toString()), (r || o) && window.dispatchEvent(
|
|
2623
2623
|
new CustomEvent("smartorg:chat-token-updated", {
|
|
2624
|
-
detail: { token: r, expiresAt:
|
|
2624
|
+
detail: { token: r, expiresAt: o }
|
|
2625
2625
|
})
|
|
2626
2626
|
);
|
|
2627
2627
|
} catch (t) {
|
|
@@ -2632,16 +2632,16 @@ oe.interceptors.response.use(
|
|
|
2632
2632
|
(e) => Promise.reject(e)
|
|
2633
2633
|
);
|
|
2634
2634
|
async function ae(e, t) {
|
|
2635
|
-
return
|
|
2635
|
+
return se.defaults.baseURL ? (await se.get(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2636
2636
|
}
|
|
2637
2637
|
async function Ze(e, t, n) {
|
|
2638
|
-
return
|
|
2638
|
+
return se.defaults.baseURL ? (await se.post(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2639
2639
|
}
|
|
2640
2640
|
async function Xn(e, t, n) {
|
|
2641
|
-
return
|
|
2641
|
+
return se.defaults.baseURL ? (await se.put(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2642
2642
|
}
|
|
2643
2643
|
async function Qn(e, t) {
|
|
2644
|
-
return
|
|
2644
|
+
return se.defaults.baseURL ? (await se.delete(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
|
|
2645
2645
|
}
|
|
2646
2646
|
function le(e) {
|
|
2647
2647
|
return e && typeof e == "object" && "data" in e ? e.data : e;
|
|
@@ -2651,14 +2651,14 @@ class Yn {
|
|
|
2651
2651
|
// Chat client uses the default httpClient baseURL, no need for internal tracking
|
|
2652
2652
|
// unless we want to support multiple instances with different URLs in the future.
|
|
2653
2653
|
get baseUrl() {
|
|
2654
|
-
return
|
|
2654
|
+
return se.defaults.baseURL || "";
|
|
2655
2655
|
}
|
|
2656
2656
|
updateConfig(t) {
|
|
2657
2657
|
if (t.chatBaseUrl)
|
|
2658
|
-
|
|
2658
|
+
se.defaults.baseURL = t.chatBaseUrl;
|
|
2659
2659
|
else if (t.baseUrl) {
|
|
2660
2660
|
const n = t.baseUrl.replace(/\/+$/, "");
|
|
2661
|
-
|
|
2661
|
+
se.defaults.baseURL = n;
|
|
2662
2662
|
}
|
|
2663
2663
|
t.apiKey !== void 0 ? xe(t.apiKey) : t.getToken && xe(t.getToken()), (t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0) && Wn({
|
|
2664
2664
|
requestTimeoutMs: t.requestTimeoutMs,
|
|
@@ -2684,8 +2684,8 @@ class Yn {
|
|
|
2684
2684
|
async createThread(t, n) {
|
|
2685
2685
|
const r = {};
|
|
2686
2686
|
t && (r.title = t), n && (r.project = n);
|
|
2687
|
-
const
|
|
2688
|
-
return le(
|
|
2687
|
+
const o = await Ze("/threads", Object.keys(r).length ? r : void 0);
|
|
2688
|
+
return le(o);
|
|
2689
2689
|
}
|
|
2690
2690
|
async updateThread(t, n) {
|
|
2691
2691
|
const r = await Xn(`/threads/${t}`, { title: n });
|
|
@@ -2748,11 +2748,11 @@ class Zn {
|
|
|
2748
2748
|
async fetchFileBlob(t, n) {
|
|
2749
2749
|
return await ae(t, {
|
|
2750
2750
|
responseType: "blob",
|
|
2751
|
-
onDownloadProgress: (
|
|
2751
|
+
onDownloadProgress: (o) => {
|
|
2752
2752
|
try {
|
|
2753
|
-
if (n &&
|
|
2754
|
-
const
|
|
2755
|
-
n(
|
|
2753
|
+
if (n && o.lengthComputable) {
|
|
2754
|
+
const s = o.loaded / o.total;
|
|
2755
|
+
n(s);
|
|
2756
2756
|
}
|
|
2757
2757
|
} catch {
|
|
2758
2758
|
}
|
|
@@ -2762,8 +2762,8 @@ class Zn {
|
|
|
2762
2762
|
});
|
|
2763
2763
|
}
|
|
2764
2764
|
async viewFileById(t, n) {
|
|
2765
|
-
const r = await this.fetchFileBlob(`/files/${t}/view`, n),
|
|
2766
|
-
window.open(
|
|
2765
|
+
const r = await this.fetchFileBlob(`/files/${t}/view`, n), o = URL.createObjectURL(r);
|
|
2766
|
+
window.open(o, "_blank"), setTimeout(() => URL.revokeObjectURL(o), 6e4);
|
|
2767
2767
|
}
|
|
2768
2768
|
async getFileBlob(t, n) {
|
|
2769
2769
|
return await this.fetchFileBlob(`/files/${t}/view`, n);
|
|
@@ -2772,30 +2772,30 @@ class Zn {
|
|
|
2772
2772
|
return await (await this.fetchFileBlob(`/files/${t}/view`, n)).text();
|
|
2773
2773
|
}
|
|
2774
2774
|
async downloadFileById(t, n) {
|
|
2775
|
-
const r = await this.fetchFileBlob(`/files/${t}/download`, n),
|
|
2776
|
-
let
|
|
2775
|
+
const r = await this.fetchFileBlob(`/files/${t}/download`, n), o = URL.createObjectURL(r);
|
|
2776
|
+
let s = `file_${t}`;
|
|
2777
2777
|
try {
|
|
2778
2778
|
const i = await ae(`/files/${t}`);
|
|
2779
|
-
|
|
2779
|
+
s = (i == null ? void 0 : i.filename) ?? s;
|
|
2780
2780
|
} catch {
|
|
2781
2781
|
}
|
|
2782
2782
|
const a = document.createElement("a");
|
|
2783
|
-
a.href =
|
|
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
2786
|
return await ae(`/files/${t}`);
|
|
2787
2787
|
}
|
|
2788
2788
|
async listFiles(t, n = 50, r = 0) {
|
|
2789
|
-
const
|
|
2790
|
-
return t && (
|
|
2789
|
+
const o = { limit: n, offset: r };
|
|
2790
|
+
return t && (o.thread_id = t), await ae("/files", { params: o });
|
|
2791
2791
|
}
|
|
2792
2792
|
async uploadFile(t, n, r) {
|
|
2793
|
-
const
|
|
2794
|
-
return
|
|
2795
|
-
onUploadProgress: (
|
|
2793
|
+
const o = new FormData();
|
|
2794
|
+
return o.append("file", t), n && o.append("thread_id", n), await Ze("/files/upload-form", o, {
|
|
2795
|
+
onUploadProgress: (s) => {
|
|
2796
2796
|
try {
|
|
2797
|
-
if (r &&
|
|
2798
|
-
const a =
|
|
2797
|
+
if (r && s.lengthComputable) {
|
|
2798
|
+
const a = s.loaded / s.total;
|
|
2799
2799
|
r(a);
|
|
2800
2800
|
}
|
|
2801
2801
|
} catch {
|
|
@@ -2842,53 +2842,53 @@ const tr = new er(), Lt = Ce(null);
|
|
|
2842
2842
|
function nr({ children: e, apiConfig: t }) {
|
|
2843
2843
|
const n = zt, r = tr;
|
|
2844
2844
|
if (t) {
|
|
2845
|
-
const
|
|
2846
|
-
(t.baseUrl || t.chatBaseUrl || u) && (u || t.chatBaseUrl && t.chatBaseUrl !==
|
|
2845
|
+
const s = n.baseUrl, a = r.baseUrl, i = n.getAuthToken(), u = t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0;
|
|
2846
|
+
(t.baseUrl || t.chatBaseUrl || u) && (u || t.chatBaseUrl && t.chatBaseUrl !== s || t.baseUrl && !s.startsWith(t.baseUrl)) && n.updateConfig(t), (t.baseUrl || t.authBaseUrl) && (t.authBaseUrl && t.authBaseUrl !== a || t.baseUrl && !a.startsWith(t.baseUrl)) && r.updateConfig(t), t.apiKey !== void 0 && t.apiKey !== i && (n.updateConfig({ apiKey: t.apiKey }), r.updateConfig({ apiKey: t.apiKey }));
|
|
2847
2847
|
}
|
|
2848
|
-
const
|
|
2848
|
+
const o = {
|
|
2849
2849
|
token: n.getAuthToken(),
|
|
2850
|
-
setToken: (
|
|
2851
|
-
n.setAuthToken(
|
|
2850
|
+
setToken: (s) => {
|
|
2851
|
+
n.setAuthToken(s), r.setAuthToken(s);
|
|
2852
2852
|
},
|
|
2853
2853
|
chatApi: n,
|
|
2854
2854
|
authApi: r,
|
|
2855
2855
|
fileApi: Rt,
|
|
2856
2856
|
baseUrl: n.baseUrl
|
|
2857
2857
|
};
|
|
2858
|
-
return /* @__PURE__ */ de(Lt.Provider, { value:
|
|
2858
|
+
return /* @__PURE__ */ de(Lt.Provider, { value: o, children: e });
|
|
2859
2859
|
}
|
|
2860
2860
|
async function rr(e) {
|
|
2861
2861
|
return await new Promise((t, n) => {
|
|
2862
2862
|
const r = new FileReader();
|
|
2863
2863
|
r.onload = () => {
|
|
2864
2864
|
try {
|
|
2865
|
-
const
|
|
2865
|
+
const o = r.result, s = new Uint8Array(o);
|
|
2866
2866
|
let a = "";
|
|
2867
|
-
const i =
|
|
2868
|
-
for (let u = 0; u < i; u++) a += String.fromCharCode(
|
|
2867
|
+
const i = s.byteLength;
|
|
2868
|
+
for (let u = 0; u < i; u++) a += String.fromCharCode(s[u]);
|
|
2869
2869
|
t(btoa(a));
|
|
2870
|
-
} catch (
|
|
2871
|
-
n(
|
|
2870
|
+
} catch (o) {
|
|
2871
|
+
n(o);
|
|
2872
2872
|
}
|
|
2873
|
-
}, r.onerror = (
|
|
2873
|
+
}, r.onerror = (o) => n(o), r.readAsArrayBuffer(e);
|
|
2874
2874
|
});
|
|
2875
2875
|
}
|
|
2876
|
-
async function
|
|
2876
|
+
async function sr(e = []) {
|
|
2877
2877
|
const t = [], n = [];
|
|
2878
2878
|
for (const r of e)
|
|
2879
2879
|
try {
|
|
2880
|
-
const
|
|
2880
|
+
const o = await rr(r), s = r.type || "application/octet-stream";
|
|
2881
2881
|
n.push({
|
|
2882
2882
|
filename: r.name,
|
|
2883
|
-
data:
|
|
2884
|
-
mime_type:
|
|
2885
|
-
}),
|
|
2883
|
+
data: o,
|
|
2884
|
+
mime_type: s
|
|
2885
|
+
}), s.startsWith("image/") ? t.push({
|
|
2886
2886
|
type: "image_url",
|
|
2887
|
-
image_url: { url: `data:${
|
|
2887
|
+
image_url: { url: `data:${s};base64,${o}` }
|
|
2888
2888
|
}) : t.push({
|
|
2889
2889
|
type: "file",
|
|
2890
|
-
url: `data:${
|
|
2891
|
-
mimeType:
|
|
2890
|
+
url: `data:${s};base64,${o}`,
|
|
2891
|
+
mimeType: s,
|
|
2892
2892
|
name: r.name,
|
|
2893
2893
|
size: r.size
|
|
2894
2894
|
});
|
|
@@ -2896,10 +2896,10 @@ async function or(e = []) {
|
|
|
2896
2896
|
}
|
|
2897
2897
|
return { contentParts: t, filesInfo: n };
|
|
2898
2898
|
}
|
|
2899
|
-
function
|
|
2899
|
+
function or(e) {
|
|
2900
2900
|
return e.filter((t) => t.type === "text").map((t) => t.text).join("");
|
|
2901
2901
|
}
|
|
2902
|
-
function
|
|
2902
|
+
function is(e) {
|
|
2903
2903
|
if (e == null) return null;
|
|
2904
2904
|
const t = String(e).trim();
|
|
2905
2905
|
return t.length > 0 ? t : null;
|
|
@@ -2911,13 +2911,13 @@ function ar(e) {
|
|
|
2911
2911
|
name: e.name ?? void 0
|
|
2912
2912
|
};
|
|
2913
2913
|
}
|
|
2914
|
-
function
|
|
2914
|
+
function cs(e) {
|
|
2915
2915
|
var n;
|
|
2916
2916
|
if (e.name && e.name.trim()) return e.name;
|
|
2917
2917
|
const t = (n = e.additionalKwargs) == null ? void 0 : n.agentName;
|
|
2918
2918
|
return typeof t == "string" && t.trim() ? t : e.model && e.model.includes("/") ? e.model.split("/").pop() || null : e.model || null;
|
|
2919
2919
|
}
|
|
2920
|
-
function
|
|
2920
|
+
function ls(e) {
|
|
2921
2921
|
const t = e.updatedAt ?? e.createdAt ?? "", n = Array.isArray(e.content) ? e.content.map((a) => {
|
|
2922
2922
|
switch (a.type) {
|
|
2923
2923
|
case "text":
|
|
@@ -2927,8 +2927,8 @@ function lo(e) {
|
|
|
2927
2927
|
default:
|
|
2928
2928
|
return a.type === "interrupt" ? "interrupt" : "unknown";
|
|
2929
2929
|
}
|
|
2930
|
-
}).join("|") : "", r = "checkpointId" in e && e.checkpointId ? `cp:${e.checkpointId}` : "",
|
|
2931
|
-
return `${e.id}:${t}:${n}${
|
|
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
|
+
return `${e.id}:${t}:${n}${s ? `:${s}` : ""}`;
|
|
2932
2932
|
}
|
|
2933
2933
|
function Me() {
|
|
2934
2934
|
const e = je(Lt);
|
|
@@ -3009,33 +3009,33 @@ function fr(e, t) {
|
|
|
3009
3009
|
return "type" in n || (n.type = e), n;
|
|
3010
3010
|
}
|
|
3011
3011
|
function pr(e = {}) {
|
|
3012
|
-
const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r,
|
|
3012
|
+
const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, o] = H(e.token ?? null), s = W(e.headers ?? {}), a = e.credentials ?? "include", i = W(e);
|
|
3013
3013
|
Y(() => {
|
|
3014
3014
|
i.current = e;
|
|
3015
3015
|
}, [e]);
|
|
3016
|
-
const u =
|
|
3017
|
-
var L, M, $, U, V, P, F,
|
|
3018
|
-
const
|
|
3019
|
-
if (!
|
|
3020
|
-
(L =
|
|
3021
|
-
}, []), [l, c] = H(!1), [d,
|
|
3022
|
-
|
|
3023
|
-
}, []), k =
|
|
3024
|
-
|
|
3025
|
-
}, []),
|
|
3016
|
+
const u = N((y) => {
|
|
3017
|
+
var L, M, $, U, V, P, F, E, j, G;
|
|
3018
|
+
const v = i.current;
|
|
3019
|
+
if (!v) return;
|
|
3020
|
+
(L = v.onEvent) == null || L.call(v, y), y.type === "thread_info" && ((M = v.onThreadInfo) == null || M.call(v, y)), y.type === "values" && (($ = v.handleValuesEvent) == null || $.call(v, y)), y.type === "metadata" && ((U = v.onMetadataEvent) == null || U.call(v, y)), typeof y.type == "string" && (y.type === "custom" || y.type.startsWith("custom.")) && ((V = v.onCustomEvent) == null || V.call(v, y)), y.type === "updates" && ((P = v.onUpdateEvent) == null || P.call(v, y)), y.type === "tool.end" ? (F = v.onToolEnd) == null || F.call(v, y) : y.type === "tool.start" && ((E = v.onToolStart) == null || E.call(v, y)), y.type === "heartbeat" && ((j = v.onHeartbeat) == null || j.call(v, y)), y.type === "token" && ((G = v.onToken) == null || G.call(v, y.token));
|
|
3021
|
+
}, []), [l, c] = H(!1), [d, m] = H(null), [p, I] = H(!1), [f, h] = H(null), x = W(null), S = W(!0), A = W(null), w = N((y) => {
|
|
3022
|
+
o(y);
|
|
3023
|
+
}, []), k = N(() => {
|
|
3024
|
+
m(null), h(null);
|
|
3025
|
+
}, []), b = N(() => {
|
|
3026
3026
|
var M, $;
|
|
3027
3027
|
console.debug("[use-chat] stop() invoked - aborting stream");
|
|
3028
|
-
const y = (M = A.current) == null ? void 0 : M.threadId,
|
|
3028
|
+
const y = (M = A.current) == null ? void 0 : M.threadId, v = ($ = A.current) == null ? void 0 : $.runId, _ = () => {
|
|
3029
3029
|
var U;
|
|
3030
|
-
(U = x.current) == null || U.abort(), x.current = null, A.current = null, c(!1),
|
|
3030
|
+
(U = x.current) == null || U.abort(), x.current = null, A.current = null, c(!1), I(!1);
|
|
3031
3031
|
};
|
|
3032
|
-
(
|
|
3032
|
+
(v || y ? zt.cancelRun(v || y).catch((U) => {
|
|
3033
3033
|
console.warn("[use-chat] cancel run failed:", U);
|
|
3034
|
-
}) : Promise.resolve()).finally(
|
|
3035
|
-
}, []), T =
|
|
3034
|
+
}) : Promise.resolve()).finally(_);
|
|
3035
|
+
}, []), T = N(
|
|
3036
3036
|
(y) => {
|
|
3037
3037
|
x.current && (x.current.abort(), x.current = null);
|
|
3038
|
-
const
|
|
3038
|
+
const v = {
|
|
3039
3039
|
text: typeof y.content == "string" ? y.content : y.text,
|
|
3040
3040
|
threadId: y.threadId,
|
|
3041
3041
|
attachments: y.attachments,
|
|
@@ -3049,32 +3049,32 @@ function pr(e = {}) {
|
|
|
3049
3049
|
edit: y.edit ?? !1,
|
|
3050
3050
|
command: y.command
|
|
3051
3051
|
};
|
|
3052
|
-
c(!0),
|
|
3053
|
-
const
|
|
3054
|
-
x.current =
|
|
3052
|
+
c(!0), m(null), h(null);
|
|
3053
|
+
const _ = new AbortController();
|
|
3054
|
+
x.current = _;
|
|
3055
3055
|
let L = null, M = !1;
|
|
3056
3056
|
return A.current = {
|
|
3057
|
-
threadId:
|
|
3057
|
+
threadId: v.threadId ?? void 0,
|
|
3058
3058
|
runId: void 0,
|
|
3059
3059
|
// Will be updated from headers
|
|
3060
3060
|
headers: {},
|
|
3061
3061
|
isStreaming: !0
|
|
3062
3062
|
}, (async () => {
|
|
3063
|
-
var $, U, V, P, F,
|
|
3063
|
+
var $, U, V, P, F, E;
|
|
3064
3064
|
try {
|
|
3065
3065
|
let j = {};
|
|
3066
3066
|
try {
|
|
3067
3067
|
if (r)
|
|
3068
3068
|
j = { Authorization: `Bearer ${r}` };
|
|
3069
3069
|
else if (typeof window < "u") {
|
|
3070
|
-
const
|
|
3070
|
+
const oe = window.__AUTH_TOKEN__, he = (($ = window.localStorage) == null ? void 0 : $.getItem(ze.authToken)) || null;
|
|
3071
3071
|
let X = null;
|
|
3072
3072
|
try {
|
|
3073
3073
|
const be = (U = window.localStorage) == null ? void 0 : U.getItem(ze.chatSettings);
|
|
3074
3074
|
be && (X = ((V = JSON.parse(be)) == null ? void 0 : V.apiKey) || null);
|
|
3075
3075
|
} catch {
|
|
3076
3076
|
}
|
|
3077
|
-
const Q =
|
|
3077
|
+
const Q = oe || he || X || null;
|
|
3078
3078
|
Q && (j = { Authorization: `Bearer ${Q}` });
|
|
3079
3079
|
}
|
|
3080
3080
|
} catch {
|
|
@@ -3090,7 +3090,7 @@ function pr(e = {}) {
|
|
|
3090
3090
|
const g = {
|
|
3091
3091
|
...j,
|
|
3092
3092
|
...G,
|
|
3093
|
-
...
|
|
3093
|
+
...s.current
|
|
3094
3094
|
}, z = {
|
|
3095
3095
|
"Content-Type": "application/json",
|
|
3096
3096
|
Accept: "text/event-stream",
|
|
@@ -3098,8 +3098,8 @@ function pr(e = {}) {
|
|
|
3098
3098
|
}, C = await fetch(t + n, {
|
|
3099
3099
|
method: "POST",
|
|
3100
3100
|
headers: z,
|
|
3101
|
-
body: JSON.stringify(
|
|
3102
|
-
signal:
|
|
3101
|
+
body: JSON.stringify(v),
|
|
3102
|
+
signal: _.signal,
|
|
3103
3103
|
credentials: a
|
|
3104
3104
|
});
|
|
3105
3105
|
if (A.current && (A.current.headers = g), !C.ok || !C.body) {
|
|
@@ -3109,21 +3109,21 @@ function pr(e = {}) {
|
|
|
3109
3109
|
C.status,
|
|
3110
3110
|
J == null ? void 0 : J.slice(0, 500)
|
|
3111
3111
|
);
|
|
3112
|
-
const
|
|
3113
|
-
throw
|
|
3112
|
+
const oe = `stream ${C.status}${J ? ": " + J : ""}`;
|
|
3113
|
+
throw oe && (m(oe), L = "error"), new Error(oe);
|
|
3114
3114
|
}
|
|
3115
|
-
|
|
3115
|
+
I(!0);
|
|
3116
3116
|
const O = C.body.getReader(), D = new TextDecoder();
|
|
3117
3117
|
let K = "", B = 0, ee = Date.now();
|
|
3118
3118
|
const ie = setInterval(() => {
|
|
3119
|
-
Date.now() - ee > 18e5 && (
|
|
3119
|
+
Date.now() - ee > 18e5 && (m("Stream idle timeout"), L = "error", _.abort());
|
|
3120
3120
|
}, 5e3), ye = 1024 * 1024;
|
|
3121
3121
|
try {
|
|
3122
|
-
const J = C.headers.get("X-Thread-Id") || C.headers.get("x-thread-id"),
|
|
3122
|
+
const J = C.headers.get("X-Thread-Id") || C.headers.get("x-thread-id"), oe = C.headers.get("X-Run-Id") || C.headers.get("x-run-id");
|
|
3123
3123
|
for (A.current && (A.current = {
|
|
3124
3124
|
...A.current,
|
|
3125
3125
|
threadId: J ?? A.current.threadId,
|
|
3126
|
-
runId:
|
|
3126
|
+
runId: oe ?? A.current.runId
|
|
3127
3127
|
}); ; ) {
|
|
3128
3128
|
const { value: he, done: X } = await O.read();
|
|
3129
3129
|
if (X) break;
|
|
@@ -3177,13 +3177,13 @@ function pr(e = {}) {
|
|
|
3177
3177
|
u(re);
|
|
3178
3178
|
}
|
|
3179
3179
|
}
|
|
3180
|
-
L === null && !
|
|
3180
|
+
L === null && !_.signal.aborted && (L = "complete");
|
|
3181
3181
|
} catch (J) {
|
|
3182
3182
|
if (J.name === "AbortError")
|
|
3183
3183
|
L = L ?? "aborted";
|
|
3184
3184
|
else {
|
|
3185
|
-
const
|
|
3186
|
-
L = "error",
|
|
3185
|
+
const oe = J.message || String(J);
|
|
3186
|
+
L = "error", m(oe);
|
|
3187
3187
|
}
|
|
3188
3188
|
} finally {
|
|
3189
3189
|
try {
|
|
@@ -3199,7 +3199,7 @@ function pr(e = {}) {
|
|
|
3199
3199
|
L = L ?? "aborted";
|
|
3200
3200
|
else {
|
|
3201
3201
|
const G = j.message || String(j);
|
|
3202
|
-
L = "error",
|
|
3202
|
+
L = "error", m(G), M || (M = !0, (E = e.onConnectionError) == null || E.call(e, G));
|
|
3203
3203
|
}
|
|
3204
3204
|
} finally {
|
|
3205
3205
|
try {
|
|
@@ -3216,7 +3216,7 @@ function pr(e = {}) {
|
|
|
3216
3216
|
} catch (j) {
|
|
3217
3217
|
console.warn("[use-chat] onClosed callback failed", j);
|
|
3218
3218
|
}
|
|
3219
|
-
c(!1),
|
|
3219
|
+
c(!1), I(!1), x.current = null, A.current = null;
|
|
3220
3220
|
}
|
|
3221
3221
|
})(), Promise.resolve();
|
|
3222
3222
|
},
|
|
@@ -3236,9 +3236,9 @@ function pr(e = {}) {
|
|
|
3236
3236
|
lastCheckpointId: null,
|
|
3237
3237
|
// Deprecated: use checkpoint from reducer
|
|
3238
3238
|
lastSeq: 0,
|
|
3239
|
-
connected:
|
|
3239
|
+
connected: p,
|
|
3240
3240
|
stream: T,
|
|
3241
|
-
stop:
|
|
3241
|
+
stop: b,
|
|
3242
3242
|
clear: k,
|
|
3243
3243
|
setToken: w,
|
|
3244
3244
|
values: {},
|
|
@@ -3246,7 +3246,7 @@ function pr(e = {}) {
|
|
|
3246
3246
|
interrupt: () => Promise.resolve(),
|
|
3247
3247
|
resume: () => Promise.resolve(),
|
|
3248
3248
|
goto: () => Promise.resolve(),
|
|
3249
|
-
connectionState: d ? "error" : l ?
|
|
3249
|
+
connectionState: d ? "error" : l ? p ? "connected" : "connecting" : "idle",
|
|
3250
3250
|
messages: [],
|
|
3251
3251
|
// useStream doesn't maintain messages, use useChatSession instead
|
|
3252
3252
|
submit: T
|
|
@@ -3257,22 +3257,22 @@ function gr({
|
|
|
3257
3257
|
initialThreadId: t = null,
|
|
3258
3258
|
onError: n,
|
|
3259
3259
|
onThreadChange: r,
|
|
3260
|
-
onCurrentThreadDeleted:
|
|
3260
|
+
onCurrentThreadDeleted: o
|
|
3261
3261
|
}) {
|
|
3262
|
-
const [
|
|
3262
|
+
const [s, a] = H([]), [i, u] = H(t), [l, c] = H(!1), [d, m] = H(null), p = W(i), I = W(/* @__PURE__ */ new Map());
|
|
3263
3263
|
Y(() => {
|
|
3264
|
-
|
|
3264
|
+
p.current = i;
|
|
3265
3265
|
}, [i]), Y(() => {
|
|
3266
|
-
t !== void 0 && t !==
|
|
3266
|
+
t !== void 0 && t !== p.current && u(t);
|
|
3267
3267
|
}, [t]);
|
|
3268
|
-
const f =
|
|
3269
|
-
c(!0),
|
|
3268
|
+
const f = N(async () => {
|
|
3269
|
+
c(!0), m(null);
|
|
3270
3270
|
try {
|
|
3271
3271
|
const k = await e.listThreads();
|
|
3272
3272
|
a(k ?? []);
|
|
3273
3273
|
} catch (k) {
|
|
3274
|
-
const
|
|
3275
|
-
|
|
3274
|
+
const b = String(k);
|
|
3275
|
+
m(b), n == null || n(b);
|
|
3276
3276
|
} finally {
|
|
3277
3277
|
c(!1);
|
|
3278
3278
|
}
|
|
@@ -3282,10 +3282,10 @@ function gr({
|
|
|
3282
3282
|
}, [f]), Y(() => {
|
|
3283
3283
|
r == null || r(i);
|
|
3284
3284
|
}, [i, r]);
|
|
3285
|
-
const
|
|
3286
|
-
async (k,
|
|
3285
|
+
const h = N(
|
|
3286
|
+
async (k, b) => {
|
|
3287
3287
|
try {
|
|
3288
|
-
const T =
|
|
3288
|
+
const T = b && typeof b == "object" ? { id: b.id, name: b.name ?? "" } : void 0, y = await e.createThread(k, T);
|
|
3289
3289
|
return u(y.threadId), await f(), y.threadId;
|
|
3290
3290
|
} catch (T) {
|
|
3291
3291
|
const y = String(T);
|
|
@@ -3293,27 +3293,27 @@ function gr({
|
|
|
3293
3293
|
}
|
|
3294
3294
|
},
|
|
3295
3295
|
[e, n, f]
|
|
3296
|
-
), x =
|
|
3296
|
+
), x = N(
|
|
3297
3297
|
async (k) => {
|
|
3298
|
-
const
|
|
3299
|
-
a((y) => y.filter((
|
|
3298
|
+
const b = s;
|
|
3299
|
+
a((y) => y.filter((v) => v.threadId !== k));
|
|
3300
3300
|
const T = new AbortController();
|
|
3301
|
-
|
|
3301
|
+
I.current.set(k, T);
|
|
3302
3302
|
try {
|
|
3303
|
-
await e.deleteThread(k),
|
|
3303
|
+
await e.deleteThread(k), p.current === k && (u(null), o == null || o());
|
|
3304
3304
|
} catch (y) {
|
|
3305
|
-
a(
|
|
3306
|
-
const
|
|
3307
|
-
n == null || n(
|
|
3305
|
+
a(b);
|
|
3306
|
+
const v = String(y);
|
|
3307
|
+
n == null || n(v);
|
|
3308
3308
|
} finally {
|
|
3309
|
-
|
|
3309
|
+
I.current.delete(k);
|
|
3310
3310
|
}
|
|
3311
3311
|
},
|
|
3312
|
-
[e,
|
|
3313
|
-
), S =
|
|
3314
|
-
async (k,
|
|
3312
|
+
[e, o, n, s]
|
|
3313
|
+
), S = N(
|
|
3314
|
+
async (k, b) => {
|
|
3315
3315
|
try {
|
|
3316
|
-
await e.updateThread(k,
|
|
3316
|
+
await e.updateThread(k, b), await f();
|
|
3317
3317
|
} catch (T) {
|
|
3318
3318
|
n == null || n(String(T));
|
|
3319
3319
|
}
|
|
@@ -3321,15 +3321,15 @@ function gr({
|
|
|
3321
3321
|
[e, n, f]
|
|
3322
3322
|
), A = Z(
|
|
3323
3323
|
() => ({
|
|
3324
|
-
createThread:
|
|
3324
|
+
createThread: h,
|
|
3325
3325
|
deleteThread: x,
|
|
3326
3326
|
renameThread: S,
|
|
3327
3327
|
refreshThreads: f
|
|
3328
3328
|
}),
|
|
3329
|
-
[
|
|
3330
|
-
), w =
|
|
3329
|
+
[h, x, S, f]
|
|
3330
|
+
), w = N((k) => {
|
|
3331
3331
|
if (!(k != null && k.threadId)) return;
|
|
3332
|
-
const
|
|
3332
|
+
const b = {
|
|
3333
3333
|
threadId: k.threadId,
|
|
3334
3334
|
title: k.title || `Thread ${k.threadId.slice(0, 8)}`,
|
|
3335
3335
|
project: k.project,
|
|
@@ -3339,20 +3339,20 @@ function gr({
|
|
|
3339
3339
|
};
|
|
3340
3340
|
a((T) => {
|
|
3341
3341
|
let y = !1;
|
|
3342
|
-
const
|
|
3343
|
-
...
|
|
3344
|
-
title:
|
|
3345
|
-
project:
|
|
3346
|
-
updatedAt:
|
|
3347
|
-
messageCount:
|
|
3348
|
-
}) :
|
|
3349
|
-
return y ?
|
|
3342
|
+
const v = T.map((_) => _.threadId === b.threadId ? (y = !0, console.debug("[useThreadsState] thread_info: updating existing thread", b.threadId), {
|
|
3343
|
+
..._,
|
|
3344
|
+
title: b.title ?? _.title,
|
|
3345
|
+
project: b.project ?? _.project,
|
|
3346
|
+
updatedAt: b.updatedAt ?? _.updatedAt,
|
|
3347
|
+
messageCount: b.messageCount ?? _.messageCount
|
|
3348
|
+
}) : _);
|
|
3349
|
+
return y ? v : (console.debug("[useThreadsState] thread_info: adding thread to list", b.threadId), [b, ...T]);
|
|
3350
3350
|
});
|
|
3351
3351
|
}, []);
|
|
3352
3352
|
return {
|
|
3353
|
-
threads:
|
|
3353
|
+
threads: s,
|
|
3354
3354
|
currentThreadId: i,
|
|
3355
|
-
currentThreadIdRef:
|
|
3355
|
+
currentThreadIdRef: p,
|
|
3356
3356
|
setCurrentThreadId: u,
|
|
3357
3357
|
isLoadingThreads: l,
|
|
3358
3358
|
threadsError: d,
|
|
@@ -3367,45 +3367,45 @@ function mr({
|
|
|
3367
3367
|
onError: n,
|
|
3368
3368
|
onThreadChange: r
|
|
3369
3369
|
}) {
|
|
3370
|
-
const { chatApi:
|
|
3371
|
-
threads:
|
|
3370
|
+
const { chatApi: o } = Me(), {
|
|
3371
|
+
threads: s,
|
|
3372
3372
|
currentThreadId: a,
|
|
3373
3373
|
setCurrentThreadId: i,
|
|
3374
3374
|
currentThreadIdRef: u,
|
|
3375
3375
|
isLoadingThreads: l,
|
|
3376
3376
|
threadsError: c,
|
|
3377
3377
|
actions: d,
|
|
3378
|
-
addThreadFromEvent:
|
|
3378
|
+
addThreadFromEvent: m
|
|
3379
3379
|
} = gr({
|
|
3380
|
-
api:
|
|
3380
|
+
api: o,
|
|
3381
3381
|
initialThreadId: t,
|
|
3382
3382
|
onError: n,
|
|
3383
3383
|
onThreadChange: r
|
|
3384
|
-
}),
|
|
3384
|
+
}), p = Z(
|
|
3385
3385
|
() => ({
|
|
3386
|
-
threads:
|
|
3386
|
+
threads: s,
|
|
3387
3387
|
currentThreadId: a,
|
|
3388
3388
|
setCurrentThreadId: i,
|
|
3389
3389
|
currentThreadIdRef: u,
|
|
3390
3390
|
isLoading: l,
|
|
3391
3391
|
error: c,
|
|
3392
3392
|
actions: d,
|
|
3393
|
-
addThreadFromEvent:
|
|
3393
|
+
addThreadFromEvent: m
|
|
3394
3394
|
}),
|
|
3395
3395
|
[
|
|
3396
|
-
|
|
3396
|
+
s,
|
|
3397
3397
|
a,
|
|
3398
3398
|
i,
|
|
3399
3399
|
u,
|
|
3400
3400
|
l,
|
|
3401
3401
|
c,
|
|
3402
3402
|
d,
|
|
3403
|
-
|
|
3403
|
+
m
|
|
3404
3404
|
]
|
|
3405
3405
|
);
|
|
3406
|
-
return /* @__PURE__ */ de(Ut.Provider, { value:
|
|
3406
|
+
return /* @__PURE__ */ de(Ut.Provider, { value: p, children: e });
|
|
3407
3407
|
}
|
|
3408
|
-
function
|
|
3408
|
+
function st(e) {
|
|
3409
3409
|
const t = je(Ut);
|
|
3410
3410
|
if (!t && !(e != null && e.optional)) throw new Error("useThreads must be used within a ThreadsProvider");
|
|
3411
3411
|
return t;
|
|
@@ -3438,8 +3438,8 @@ function yr(e, t) {
|
|
|
3438
3438
|
}
|
|
3439
3439
|
function hr(e, t, n) {
|
|
3440
3440
|
return e.find((r) => {
|
|
3441
|
-
const
|
|
3442
|
-
return !!((
|
|
3441
|
+
const o = Bt(r);
|
|
3442
|
+
return !!((o == null ? void 0 : o.id) === t || n && r.toolCallId === n);
|
|
3443
3443
|
}) ?? null;
|
|
3444
3444
|
}
|
|
3445
3445
|
function Fe(e) {
|
|
@@ -3452,8 +3452,8 @@ function Ft(e, t, n) {
|
|
|
3452
3452
|
function br(e, t, n) {
|
|
3453
3453
|
for (let r = e.length - 1; r >= 0; r--)
|
|
3454
3454
|
if (e[r].role === "assistant") {
|
|
3455
|
-
const
|
|
3456
|
-
return Ft(e, r,
|
|
3455
|
+
const s = { ...e[r], checkpointId: t, checkpointNs: n ?? void 0 };
|
|
3456
|
+
return Ft(e, r, s);
|
|
3457
3457
|
}
|
|
3458
3458
|
return e;
|
|
3459
3459
|
}
|
|
@@ -3484,15 +3484,15 @@ function wr(e, t) {
|
|
|
3484
3484
|
messages: Fe(((n = t.payload) == null ? void 0 : n.messages) ?? [])
|
|
3485
3485
|
};
|
|
3486
3486
|
case "user_message": {
|
|
3487
|
-
const { message: r, editingMessageId:
|
|
3488
|
-
if (
|
|
3489
|
-
const
|
|
3490
|
-
if (
|
|
3491
|
-
const a = e.messages[
|
|
3487
|
+
const { message: r, editingMessageId: o } = t.payload;
|
|
3488
|
+
if (o) {
|
|
3489
|
+
const s = e.messages.findIndex((a) => (a.id || a.messageId || a.id) === o);
|
|
3490
|
+
if (s !== -1) {
|
|
3491
|
+
const a = e.messages[s], i = { ...r, id: o };
|
|
3492
3492
|
return {
|
|
3493
3493
|
...e,
|
|
3494
3494
|
status: "streaming",
|
|
3495
|
-
messages: [...e.messages.slice(0,
|
|
3495
|
+
messages: [...e.messages.slice(0, s), i],
|
|
3496
3496
|
assemblingId: null,
|
|
3497
3497
|
lastCheckpointId: a.checkpointId || e.lastCheckpointId || null,
|
|
3498
3498
|
error: null
|
|
@@ -3509,7 +3509,7 @@ function wr(e, t) {
|
|
|
3509
3509
|
};
|
|
3510
3510
|
}
|
|
3511
3511
|
case "seed": {
|
|
3512
|
-
const r = Fe(t.payload.messages),
|
|
3512
|
+
const r = Fe(t.payload.messages), o = {
|
|
3513
3513
|
...e,
|
|
3514
3514
|
status: "idle",
|
|
3515
3515
|
messages: r,
|
|
@@ -3518,32 +3518,32 @@ function wr(e, t) {
|
|
|
3518
3518
|
taskMessagesByScope: {},
|
|
3519
3519
|
error: null
|
|
3520
3520
|
};
|
|
3521
|
-
return Object.prototype.hasOwnProperty.call(t.payload, "checkpointId") && (
|
|
3521
|
+
return Object.prototype.hasOwnProperty.call(t.payload, "checkpointId") && (o.lastCheckpointId = t.payload.checkpointId ?? null), Object.prototype.hasOwnProperty.call(t.payload, "checkpointNs") && (o.lastCheckpointNs = t.payload.checkpointNs ?? null), Object.prototype.hasOwnProperty.call(t.payload, "values") && (o.values = t.payload.values ?? {}), o;
|
|
3522
3522
|
}
|
|
3523
3523
|
case "prepend": {
|
|
3524
3524
|
const r = Fe(t.payload.messages);
|
|
3525
3525
|
if (!r.length) return e;
|
|
3526
|
-
const
|
|
3527
|
-
return
|
|
3526
|
+
const o = new Set(e.messages.map((a) => a.id)), s = r.filter((a) => !o.has(a.id));
|
|
3527
|
+
return s.length ? { ...e, messages: [...s, ...e.messages] } : e;
|
|
3528
3528
|
}
|
|
3529
3529
|
case "event":
|
|
3530
3530
|
return pt(e, t.payload.ev);
|
|
3531
3531
|
case "batch": {
|
|
3532
3532
|
const { events: r } = t.payload;
|
|
3533
|
-
return r.length ? r.reduce((
|
|
3533
|
+
return r.length ? r.reduce((o, s) => pt(o, s), e) : e;
|
|
3534
3534
|
}
|
|
3535
3535
|
default:
|
|
3536
3536
|
return e;
|
|
3537
3537
|
}
|
|
3538
3538
|
}
|
|
3539
3539
|
function kr(e = []) {
|
|
3540
|
-
const [t, n] = Wt(wr, { ...Ot, messages: e }), r = W([]),
|
|
3541
|
-
|
|
3540
|
+
const [t, n] = Wt(wr, { ...Ot, messages: e }), r = W([]), o = W(null), s = N(() => {
|
|
3541
|
+
o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), o.current = null;
|
|
3542
3542
|
const l = r.current;
|
|
3543
3543
|
l.length && (r.current = [], n({ type: "batch", payload: { events: l } }));
|
|
3544
|
-
}, []), a =
|
|
3545
|
-
typeof window < "u" && typeof window.requestAnimationFrame == "function" ?
|
|
3546
|
-
}, [
|
|
3544
|
+
}, []), a = N(() => {
|
|
3545
|
+
typeof window < "u" && typeof window.requestAnimationFrame == "function" ? o.current === null && (o.current = window.requestAnimationFrame(() => s())) : setTimeout(s, 8);
|
|
3546
|
+
}, [s]), i = N((l) => {
|
|
3547
3547
|
r.current.push(l), a();
|
|
3548
3548
|
}, [a]), u = Z(() => ({
|
|
3549
3549
|
setStatus: (l, c) => n({ type: "status", payload: { status: l, error: c } }),
|
|
@@ -3555,14 +3555,14 @@ function kr(e = []) {
|
|
|
3555
3555
|
return { state: t, dispatch: n, ...u };
|
|
3556
3556
|
}
|
|
3557
3557
|
function pt(e, t) {
|
|
3558
|
-
const n = t.origin, r = t.scope,
|
|
3558
|
+
const n = t.origin, r = t.scope, o = n === "task" || typeof r == "string" && r.startsWith("tools:");
|
|
3559
3559
|
if (t.type === "checkpoint") {
|
|
3560
|
-
const
|
|
3561
|
-
return { ...e, lastCheckpointId: t.checkpointId, lastCheckpointNs:
|
|
3560
|
+
const s = t.checkpointNs ?? e.lastCheckpointNs ?? null, a = br(e.messages, t.checkpointId, s);
|
|
3561
|
+
return { ...e, lastCheckpointId: t.checkpointId, lastCheckpointNs: s, messages: a };
|
|
3562
3562
|
}
|
|
3563
3563
|
if (t.type === "status") {
|
|
3564
|
-
const
|
|
3565
|
-
return { ...e, status:
|
|
3564
|
+
const s = t.status === "completed" || t.status === "error" ? "idle" : t.status === "interrupted" ? "awaiting_input" : e.status;
|
|
3565
|
+
return { ...e, status: s };
|
|
3566
3566
|
}
|
|
3567
3567
|
if (t.type === "interrupt")
|
|
3568
3568
|
return {
|
|
@@ -3576,68 +3576,68 @@ function pt(e, t) {
|
|
|
3576
3576
|
}
|
|
3577
3577
|
};
|
|
3578
3578
|
if (t.type === "error") {
|
|
3579
|
-
const
|
|
3579
|
+
const s = {
|
|
3580
3580
|
id: `err-${Date.now()}`,
|
|
3581
3581
|
role: "system",
|
|
3582
3582
|
content: [{ type: "text", text: `Error: ${t.message}` }],
|
|
3583
3583
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3584
3584
|
};
|
|
3585
|
-
return { ...e, status: "error", error: t.message, messages: [...e.messages,
|
|
3585
|
+
return { ...e, status: "error", error: t.message, messages: [...e.messages, s] };
|
|
3586
3586
|
}
|
|
3587
3587
|
if (t.type === "values") {
|
|
3588
|
-
const
|
|
3589
|
-
if (!i
|
|
3588
|
+
const s = t, a = s.values && typeof s.values == "object" ? { ...s.values } : {}, i = Array.isArray(s.messages) || Array.isArray(a.messages), u = Array.isArray(s.messages) ? s.messages : Array.isArray(a.messages) ? a.messages : null;
|
|
3589
|
+
if (!i && Object.keys(a).length === 0)
|
|
3590
3590
|
return e;
|
|
3591
|
-
const
|
|
3592
|
-
delete a.messages;
|
|
3593
|
-
let
|
|
3594
|
-
const
|
|
3595
|
-
if ((p != null && p.checkpoint_id || p != null && p.checkpointId) && (
|
|
3596
|
-
for (let
|
|
3597
|
-
if (
|
|
3598
|
-
|
|
3591
|
+
const l = u !== null ? Fe(u) : e.messages;
|
|
3592
|
+
a && delete a.messages;
|
|
3593
|
+
let c = e.lastCheckpointId, d = e.lastCheckpointNs;
|
|
3594
|
+
const m = s.config || s.checkpoint, p = (m == null ? void 0 : m.configurable) || m;
|
|
3595
|
+
if ((p != null && p.checkpoint_id || p != null && p.checkpointId) && (c = p.checkpoint_id || p.checkpointId, d = p.checkpoint_ns || p.checkpointNs || null), !c) {
|
|
3596
|
+
for (let h = l.length - 1; h >= 0; h--)
|
|
3597
|
+
if (l[h].checkpointId) {
|
|
3598
|
+
c = l[h].checkpointId, d = l[h].checkpointNs ?? null;
|
|
3599
3599
|
break;
|
|
3600
3600
|
}
|
|
3601
3601
|
}
|
|
3602
|
-
const
|
|
3603
|
-
id:
|
|
3604
|
-
value:
|
|
3605
|
-
alternatives:
|
|
3602
|
+
const I = s.interrupts || a.__interrupt__ || a.interrupts, f = Array.isArray(I) && I.length > 0 ? {
|
|
3603
|
+
id: I[0].id || "native-interrupt",
|
|
3604
|
+
value: I[0].value || I[0],
|
|
3605
|
+
alternatives: I[0].alternatives
|
|
3606
3606
|
} : null;
|
|
3607
|
-
if (
|
|
3608
|
-
const
|
|
3607
|
+
if (o) {
|
|
3608
|
+
const h = typeof r == "string" && r.length > 0 ? r : "task";
|
|
3609
3609
|
return {
|
|
3610
3610
|
...e,
|
|
3611
|
-
taskMessagesByScope: { ...e.taskMessagesByScope, [
|
|
3611
|
+
taskMessagesByScope: { ...e.taskMessagesByScope, [h]: l },
|
|
3612
3612
|
assemblingId: null
|
|
3613
3613
|
};
|
|
3614
3614
|
}
|
|
3615
3615
|
return {
|
|
3616
3616
|
...e,
|
|
3617
|
-
status:
|
|
3618
|
-
messages:
|
|
3617
|
+
status: f ? "awaiting_input" : e.status === "streaming" ? "idle" : e.status,
|
|
3618
|
+
messages: l,
|
|
3619
3619
|
assemblingId: null,
|
|
3620
|
-
lastCheckpointId:
|
|
3621
|
-
lastCheckpointNs:
|
|
3622
|
-
pendingInterrupt:
|
|
3620
|
+
lastCheckpointId: c,
|
|
3621
|
+
lastCheckpointNs: d,
|
|
3622
|
+
pendingInterrupt: f,
|
|
3623
3623
|
values: { ...e.values, ...a }
|
|
3624
3624
|
};
|
|
3625
3625
|
}
|
|
3626
3626
|
if (t.type === "messages/metadata") {
|
|
3627
|
-
const
|
|
3627
|
+
const s = { ...e.messagesStreamMeta ?? {} }, a = t.metadata;
|
|
3628
3628
|
return a && typeof a == "object" && Object.entries(a).forEach(([i, u]) => {
|
|
3629
3629
|
const l = u == null ? void 0 : u.metadata;
|
|
3630
3630
|
if (!l || typeof l != "object") return;
|
|
3631
|
-
const c =
|
|
3632
|
-
|
|
3631
|
+
const c = s[i] ?? {};
|
|
3632
|
+
s[i] = {
|
|
3633
3633
|
...c,
|
|
3634
3634
|
lastSeq: t.seq ?? c.lastSeq ?? null,
|
|
3635
3635
|
metadata: { ...c.metadata ?? {}, ...l }
|
|
3636
3636
|
};
|
|
3637
|
-
}), { ...e, messagesStreamMeta:
|
|
3637
|
+
}), { ...e, messagesStreamMeta: s };
|
|
3638
3638
|
}
|
|
3639
3639
|
if (t.type === "messages/partial" || t.type === "message.delta") {
|
|
3640
|
-
const
|
|
3640
|
+
const s = t.type === "messages/partial" ? t : {
|
|
3641
3641
|
...t,
|
|
3642
3642
|
type: "messages/partial",
|
|
3643
3643
|
messages: t.delta ? [{
|
|
@@ -3648,32 +3648,32 @@ function pt(e, t) {
|
|
|
3648
3648
|
origin: t.origin
|
|
3649
3649
|
}] : []
|
|
3650
3650
|
};
|
|
3651
|
-
return Ir(e,
|
|
3651
|
+
return Ir(e, s, o);
|
|
3652
3652
|
}
|
|
3653
|
-
return t.type === "message.start" ? { ...e, assemblingId: t.id, status: "streaming" } : t.type === "message.end" ? { ...e, assemblingId: null } : t.type === "tool.start" ? { ...vr(e, t,
|
|
3653
|
+
return t.type === "message.start" ? { ...e, assemblingId: t.id, status: "streaming" } : t.type === "message.end" ? { ...e, assemblingId: null } : t.type === "tool.start" ? { ...vr(e, t, o), status: "streaming" } : t.type === "tool.progress" ? xr(e, t, o) : t.type === "tool.end" ? Ar(e, t, o) : t.type === "artifact.update" ? Tr(e, t) : e;
|
|
3654
3654
|
}
|
|
3655
3655
|
function Ir(e, t, n) {
|
|
3656
|
-
var
|
|
3656
|
+
var p, I, f, h, x, S, A;
|
|
3657
3657
|
const r = t.messages;
|
|
3658
3658
|
if (!r.length)
|
|
3659
3659
|
return console.warn("[messagesReducer] Dropping messages/partial event without messages[]", t), e;
|
|
3660
|
-
const
|
|
3661
|
-
if (!
|
|
3662
|
-
const
|
|
3660
|
+
const o = r.find((w) => w.type === "ai" || w.type === "assistant" || w.role === "assistant");
|
|
3661
|
+
if (!o) return e;
|
|
3662
|
+
const s = o.id, a = o.content ?? "", i = typeof a == "string" ? [{ type: "text", text: a }] : Array.isArray(a) ? a.map((w) => typeof w == "string" ? { type: "text", text: w } : (w == null ? void 0 : w.type) === "text" ? { type: "text", text: typeof w.text == "string" ? w.text : w.content ?? "" } : ((w == null ? void 0 : w.type) === "reasoning", w)) : [], u = i.filter((w) => w.type === "text").map((w) => w.text).join(""), l = e.assemblingId !== s, c = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
|
|
3663
3663
|
let d = n ? [...e.taskMessagesByScope[c] || []] : [...e.messages];
|
|
3664
|
-
const
|
|
3664
|
+
const m = (I = (p = e.messagesStreamMeta) == null ? void 0 : p[s]) == null ? void 0 : I.metadata;
|
|
3665
3665
|
if (l) {
|
|
3666
3666
|
const w = nt({
|
|
3667
|
-
...
|
|
3667
|
+
...o,
|
|
3668
3668
|
role: "assistant",
|
|
3669
3669
|
content: i,
|
|
3670
3670
|
scope: t.scope,
|
|
3671
3671
|
origin: t.origin,
|
|
3672
|
-
responseMetadata: { ...
|
|
3672
|
+
responseMetadata: { ...m, ...o.responseMetadata ?? {} }
|
|
3673
3673
|
});
|
|
3674
3674
|
w && d.push(w);
|
|
3675
3675
|
} else {
|
|
3676
|
-
const w = d.findIndex((k) => k.id ===
|
|
3676
|
+
const w = d.findIndex((k) => k.id === s);
|
|
3677
3677
|
if (w !== -1) {
|
|
3678
3678
|
const k = d[w];
|
|
3679
3679
|
d[w] = {
|
|
@@ -3681,7 +3681,7 @@ function Ir(e, t, n) {
|
|
|
3681
3681
|
content: i,
|
|
3682
3682
|
scope: t.scope ?? k.scope,
|
|
3683
3683
|
origin: t.origin ?? k.origin,
|
|
3684
|
-
responseMetadata: { ...
|
|
3684
|
+
responseMetadata: { ...m, ...k.responseMetadata, ...o.responseMetadata ?? {} }
|
|
3685
3685
|
};
|
|
3686
3686
|
}
|
|
3687
3687
|
}
|
|
@@ -3690,23 +3690,23 @@ function Ir(e, t, n) {
|
|
|
3690
3690
|
status: "streaming",
|
|
3691
3691
|
messages: n ? e.messages : d,
|
|
3692
3692
|
taskMessagesByScope: n ? { ...e.taskMessagesByScope, [c]: d } : e.taskMessagesByScope,
|
|
3693
|
-
assemblingId:
|
|
3693
|
+
assemblingId: s,
|
|
3694
3694
|
messagesStreamMeta: {
|
|
3695
3695
|
...e.messagesStreamMeta ?? {},
|
|
3696
|
-
[
|
|
3697
|
-
...((f = e.messagesStreamMeta) == null ? void 0 : f[
|
|
3698
|
-
lastSeq: t.seq ?? ((x = (
|
|
3699
|
-
lastText: u || (((A = (S = e.messagesStreamMeta) == null ? void 0 : S[
|
|
3696
|
+
[s]: {
|
|
3697
|
+
...((f = e.messagesStreamMeta) == null ? void 0 : f[s]) ?? {},
|
|
3698
|
+
lastSeq: t.seq ?? ((x = (h = e.messagesStreamMeta) == null ? void 0 : h[s]) == null ? void 0 : x.lastSeq) ?? null,
|
|
3699
|
+
lastText: u || (((A = (S = e.messagesStreamMeta) == null ? void 0 : S[s]) == null ? void 0 : A.lastText) ?? "")
|
|
3700
3700
|
}
|
|
3701
3701
|
}
|
|
3702
3702
|
};
|
|
3703
3703
|
}
|
|
3704
|
-
function
|
|
3704
|
+
function ot(e, t) {
|
|
3705
3705
|
var n;
|
|
3706
3706
|
if (!t) return -1;
|
|
3707
3707
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
3708
|
-
const
|
|
3709
|
-
if (
|
|
3708
|
+
const o = e[r];
|
|
3709
|
+
if (o.role === "assistant" && ((n = o.toolCalls) != null && n.some((s) => s.id === t)))
|
|
3710
3710
|
return r;
|
|
3711
3711
|
}
|
|
3712
3712
|
return -1;
|
|
@@ -3714,8 +3714,8 @@ function st(e, t) {
|
|
|
3714
3714
|
function vr(e, t, n) {
|
|
3715
3715
|
const r = t.id || t.callId;
|
|
3716
3716
|
if (!r) return e;
|
|
3717
|
-
const
|
|
3718
|
-
let i = n ? [...e.taskMessagesByScope[a] || []] : [...e.messages], u =
|
|
3717
|
+
const o = t.name || "tool", s = `Starting ${o}...`, a = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
|
|
3718
|
+
let i = n ? [...e.taskMessagesByScope[a] || []] : [...e.messages], u = ot(i, r);
|
|
3719
3719
|
if (u === -1) {
|
|
3720
3720
|
for (let l = i.length - 1; l >= 0; l--)
|
|
3721
3721
|
if (i[l].role === "assistant") {
|
|
@@ -3736,13 +3736,13 @@ function vr(e, t, n) {
|
|
|
3736
3736
|
i.push(l), u = i.length - 1;
|
|
3737
3737
|
}
|
|
3738
3738
|
if (u !== -1) {
|
|
3739
|
-
const l = i[u], c = [...l.toolCalls || []], d = c.findIndex((
|
|
3740
|
-
d >= 0 ? c[d] = { ...c[d], status: "running", content:
|
|
3739
|
+
const l = i[u], c = [...l.toolCalls || []], d = c.findIndex((m) => m.id === r);
|
|
3740
|
+
d >= 0 ? c[d] = { ...c[d], status: "running", content: s } : c.push({
|
|
3741
3741
|
id: r,
|
|
3742
|
-
name:
|
|
3742
|
+
name: o,
|
|
3743
3743
|
args: t.args || {},
|
|
3744
3744
|
status: "running",
|
|
3745
|
-
content:
|
|
3745
|
+
content: s
|
|
3746
3746
|
}), i[u] = {
|
|
3747
3747
|
...l,
|
|
3748
3748
|
toolCalls: c,
|
|
@@ -3759,14 +3759,14 @@ function vr(e, t, n) {
|
|
|
3759
3759
|
function xr(e, t, n) {
|
|
3760
3760
|
const r = t.id;
|
|
3761
3761
|
if (!r) return e;
|
|
3762
|
-
const
|
|
3763
|
-
let
|
|
3764
|
-
const a =
|
|
3762
|
+
const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
|
|
3763
|
+
let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
|
|
3764
|
+
const a = ot(s, r);
|
|
3765
3765
|
if (a !== -1) {
|
|
3766
|
-
const i =
|
|
3766
|
+
const i = s[a], u = ue(t.content), l = (i.toolCalls || []).map(
|
|
3767
3767
|
(c) => c.id === r ? { ...c, content: typeof u == "string" ? u : c.content } : c
|
|
3768
3768
|
);
|
|
3769
|
-
|
|
3769
|
+
s[a] = {
|
|
3770
3770
|
...i,
|
|
3771
3771
|
toolCalls: l,
|
|
3772
3772
|
scope: t.scope ?? i.scope,
|
|
@@ -3775,18 +3775,18 @@ function xr(e, t, n) {
|
|
|
3775
3775
|
}
|
|
3776
3776
|
return {
|
|
3777
3777
|
...e,
|
|
3778
|
-
messages: n ? e.messages :
|
|
3779
|
-
taskMessagesByScope: n ? { ...e.taskMessagesByScope, [
|
|
3778
|
+
messages: n ? e.messages : s,
|
|
3779
|
+
taskMessagesByScope: n ? { ...e.taskMessagesByScope, [o]: s } : e.taskMessagesByScope
|
|
3780
3780
|
};
|
|
3781
3781
|
}
|
|
3782
3782
|
function Ar(e, t, n) {
|
|
3783
3783
|
const r = t.id;
|
|
3784
3784
|
if (!r) return e;
|
|
3785
|
-
const
|
|
3786
|
-
let
|
|
3787
|
-
const a =
|
|
3785
|
+
const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
|
|
3786
|
+
let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
|
|
3787
|
+
const a = ot(s, r), i = ue(t.content ?? t.error);
|
|
3788
3788
|
if (a !== -1) {
|
|
3789
|
-
const l =
|
|
3789
|
+
const l = s[a], c = (l.toolCalls || []).map(
|
|
3790
3790
|
(d) => d.id === r ? {
|
|
3791
3791
|
...d,
|
|
3792
3792
|
status: t.error ? "failed" : "completed",
|
|
@@ -3794,7 +3794,7 @@ function Ar(e, t, n) {
|
|
|
3794
3794
|
artifact: t.artifact
|
|
3795
3795
|
} : d
|
|
3796
3796
|
);
|
|
3797
|
-
|
|
3797
|
+
s[a] = {
|
|
3798
3798
|
...l,
|
|
3799
3799
|
toolCalls: c,
|
|
3800
3800
|
scope: t.scope ?? l.scope,
|
|
@@ -3812,21 +3812,21 @@ function Ar(e, t, n) {
|
|
|
3812
3812
|
scope: t.scope,
|
|
3813
3813
|
origin: t.origin
|
|
3814
3814
|
};
|
|
3815
|
-
return
|
|
3815
|
+
return s.push(u), {
|
|
3816
3816
|
...e,
|
|
3817
|
-
messages: n ? e.messages :
|
|
3818
|
-
taskMessagesByScope: n ? { ...e.taskMessagesByScope, [
|
|
3817
|
+
messages: n ? e.messages : s,
|
|
3818
|
+
taskMessagesByScope: n ? { ...e.taskMessagesByScope, [o]: s } : e.taskMessagesByScope
|
|
3819
3819
|
};
|
|
3820
3820
|
}
|
|
3821
3821
|
function Tr(e, t) {
|
|
3822
3822
|
const n = t.artifactId, r = hr(e.messages, n, t.callId);
|
|
3823
3823
|
if (!r) return e;
|
|
3824
|
-
const
|
|
3824
|
+
const o = e.messages.indexOf(r), s = yr(r, {
|
|
3825
3825
|
status: t.status,
|
|
3826
3826
|
progress: t.progress,
|
|
3827
3827
|
error: t.error
|
|
3828
3828
|
});
|
|
3829
|
-
return t.partial_data &&
|
|
3829
|
+
return t.partial_data && s.artifact && (s.artifact = { ...s.artifact, ...t.partial_data }), { ...e, messages: Ft(e.messages, o, s) };
|
|
3830
3830
|
}
|
|
3831
3831
|
function Re(e) {
|
|
3832
3832
|
if (!(!e || typeof e != "object" || Array.isArray(e)))
|
|
@@ -3857,24 +3857,24 @@ function gt(e) {
|
|
|
3857
3857
|
async function Mr(e, t) {
|
|
3858
3858
|
var i, u;
|
|
3859
3859
|
if (!e) return e ?? null;
|
|
3860
|
-
const n = fe(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [],
|
|
3860
|
+
const n = fe(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], o = /* @__PURE__ */ new Set();
|
|
3861
3861
|
for (const l of r) {
|
|
3862
3862
|
const c = (i = l == null ? void 0 : l.values) == null ? void 0 : i.messages;
|
|
3863
3863
|
if (Array.isArray(c))
|
|
3864
3864
|
for (const d of c) {
|
|
3865
|
-
const
|
|
3866
|
-
if (Array.isArray(
|
|
3867
|
-
for (const
|
|
3868
|
-
if (!
|
|
3869
|
-
const
|
|
3870
|
-
typeof
|
|
3865
|
+
const m = d == null ? void 0 : d.content;
|
|
3866
|
+
if (Array.isArray(m))
|
|
3867
|
+
for (const p of m) {
|
|
3868
|
+
if (!p || typeof p != "object" || p.type !== "image_url" && p.type !== "file") continue;
|
|
3869
|
+
const I = p.fileId || p.file_id;
|
|
3870
|
+
typeof I == "string" && I.trim() && o.add(I);
|
|
3871
3871
|
}
|
|
3872
3872
|
}
|
|
3873
3873
|
}
|
|
3874
|
-
if (
|
|
3874
|
+
if (o.size === 0)
|
|
3875
3875
|
return n;
|
|
3876
|
-
const
|
|
3877
|
-
Array.from(
|
|
3876
|
+
const s = await Promise.all(
|
|
3877
|
+
Array.from(o).map(async (l) => {
|
|
3878
3878
|
try {
|
|
3879
3879
|
const c = await t.getFileInfo(l), d = fe(c);
|
|
3880
3880
|
return [l, d];
|
|
@@ -3882,41 +3882,41 @@ async function Mr(e, t) {
|
|
|
3882
3882
|
return [l, null];
|
|
3883
3883
|
}
|
|
3884
3884
|
})
|
|
3885
|
-
), a = new Map(
|
|
3885
|
+
), a = new Map(s);
|
|
3886
3886
|
for (const l of r) {
|
|
3887
3887
|
const c = (u = l == null ? void 0 : l.values) == null ? void 0 : u.messages;
|
|
3888
3888
|
if (Array.isArray(c))
|
|
3889
3889
|
for (const d of c) {
|
|
3890
|
-
const
|
|
3891
|
-
if (Array.isArray(
|
|
3892
|
-
for (const
|
|
3893
|
-
if (!
|
|
3894
|
-
const
|
|
3895
|
-
if (!
|
|
3896
|
-
const f = a.get(
|
|
3897
|
-
|
|
3890
|
+
const m = d == null ? void 0 : d.content;
|
|
3891
|
+
if (Array.isArray(m))
|
|
3892
|
+
for (const p of m) {
|
|
3893
|
+
if (!p || typeof p != "object" || p.type !== "image_url" && p.type !== "file") continue;
|
|
3894
|
+
const I = p.fileId || p.file_id;
|
|
3895
|
+
if (!I) continue;
|
|
3896
|
+
const f = a.get(I), h = (f == null ? void 0 : f.contentUrl) || (f == null ? void 0 : f.content_url);
|
|
3897
|
+
h && (p.type === "image_url" ? (p.imageUrl = p.imageUrl || {}, p.imageUrl.url = h) : p.type === "file" && (p.url = h, !p.name && (f != null && f.filename || f != null && f.name) && (p.name = (f == null ? void 0 : f.filename) || (f == null ? void 0 : f.name))));
|
|
3898
3898
|
}
|
|
3899
3899
|
}
|
|
3900
3900
|
}
|
|
3901
3901
|
return n;
|
|
3902
3902
|
}
|
|
3903
3903
|
function mt(e) {
|
|
3904
|
-
const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((
|
|
3904
|
+
const r = [...(Array.isArray(e == null ? void 0 : e.checkpoints) ? (e == null ? void 0 : e.checkpoints) ?? [] : e != null && e.checkpoints ? Object.values(e.checkpoints) : []).map((s, a) => Cr(fe(s), a)).filter((s) => !!s)].sort((s, a) => yt(a.createdAt) - yt(s.createdAt)), o = r[0] ?? null;
|
|
3905
3905
|
return {
|
|
3906
3906
|
threadId: (e == null ? void 0 : e.threadId) ?? "",
|
|
3907
|
-
latest:
|
|
3907
|
+
latest: o,
|
|
3908
3908
|
checkpoints: r,
|
|
3909
|
-
interrupt: (
|
|
3909
|
+
interrupt: (o == null ? void 0 : o.interrupt) ?? null
|
|
3910
3910
|
};
|
|
3911
3911
|
}
|
|
3912
3912
|
function Cr(e, t) {
|
|
3913
|
-
var k,
|
|
3913
|
+
var k, b;
|
|
3914
3914
|
if (!e) return null;
|
|
3915
|
-
const n = ((k = e.values) == null ? void 0 : k.activeAgent) ?? null, r = (
|
|
3915
|
+
const n = ((k = e.values) == null ? void 0 : k.activeAgent) ?? null, r = (b = e.values) == null ? void 0 : b.messages, s = (Array.isArray(r) ? r : []).map((T) => Er(T, n)).filter((T) => !!T), a = Re(e.metadata) ?? {}, i = gt(e.config), u = Re(e.parentConfig), l = gt(u), c = Be(i, ["checkpointId"]), d = Be(i, ["checkpointNs"]), m = Be(l, ["checkpointId"]), p = Re(e.config), I = Array.isArray(e.tasks) ? e.tasks.map((T) => ({ ...T })) : e.tasks ?? null, f = Array.isArray(e.next) ? [...e.next] : e.next ?? null, h = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), x = {
|
|
3916
3916
|
...a,
|
|
3917
3917
|
step: Sr(a, ["step"]) ?? 0,
|
|
3918
3918
|
source: Be(a, ["source"]) ?? null
|
|
3919
|
-
}, S =
|
|
3919
|
+
}, S = s.map((T) => ({
|
|
3920
3920
|
...T,
|
|
3921
3921
|
checkpointId: T.checkpointId ?? c ?? null,
|
|
3922
3922
|
checkpointNs: T.checkpointNs ?? d ?? null
|
|
@@ -3924,8 +3924,8 @@ function Cr(e, t) {
|
|
|
3924
3924
|
return {
|
|
3925
3925
|
checkpointId: c ?? null,
|
|
3926
3926
|
checkpointNs: d ?? null,
|
|
3927
|
-
createdAt:
|
|
3928
|
-
parentId:
|
|
3927
|
+
createdAt: h,
|
|
3928
|
+
parentId: m ?? null,
|
|
3929
3929
|
messages: S,
|
|
3930
3930
|
interrupt: Pr(
|
|
3931
3931
|
w,
|
|
@@ -3933,10 +3933,10 @@ function Cr(e, t) {
|
|
|
3933
3933
|
c ?? null
|
|
3934
3934
|
),
|
|
3935
3935
|
metadata: x,
|
|
3936
|
-
config:
|
|
3936
|
+
config: p ?? null,
|
|
3937
3937
|
parentConfig: u ?? null,
|
|
3938
3938
|
next: f,
|
|
3939
|
-
tasks:
|
|
3939
|
+
tasks: I,
|
|
3940
3940
|
values: e.values ?? {}
|
|
3941
3941
|
};
|
|
3942
3942
|
}
|
|
@@ -3946,15 +3946,15 @@ function Er(e, t) {
|
|
|
3946
3946
|
}
|
|
3947
3947
|
function Pr(e, t, n) {
|
|
3948
3948
|
const r = e.length;
|
|
3949
|
-
for (let
|
|
3950
|
-
const
|
|
3951
|
-
if (!
|
|
3949
|
+
for (let o = r - 1; o >= 0; o -= 1) {
|
|
3950
|
+
const s = e[o];
|
|
3951
|
+
if (!s || typeof s != "object")
|
|
3952
3952
|
continue;
|
|
3953
|
-
const a =
|
|
3953
|
+
const a = s, i = a.value ?? s;
|
|
3954
3954
|
if (i == null)
|
|
3955
3955
|
continue;
|
|
3956
3956
|
return {
|
|
3957
|
-
id: typeof a.id == "string" && a.id.trim() ? a.id : `interrupt-${n ?? t}-${
|
|
3957
|
+
id: typeof a.id == "string" && a.id.trim() ? a.id : `interrupt-${n ?? t}-${o}`,
|
|
3958
3958
|
value: i
|
|
3959
3959
|
};
|
|
3960
3960
|
}
|
|
@@ -3979,54 +3979,54 @@ function Nr(e) {
|
|
|
3979
3979
|
return _r(e.content) || "";
|
|
3980
3980
|
}
|
|
3981
3981
|
function zr(e) {
|
|
3982
|
-
const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(),
|
|
3982
|
+
const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), o = [];
|
|
3983
3983
|
for (let l = 0; l < e.length; l++) {
|
|
3984
|
-
const c = e[l], d = c.checkpointId,
|
|
3985
|
-
let
|
|
3984
|
+
const c = e[l], d = c.checkpointId, m = d ?? `cp-${l}`, p = c.metadata ?? {}, I = typeof p.step == "number" ? p.step : null, f = typeof p.source == "string" ? p.source : null;
|
|
3985
|
+
let h = null, x = null;
|
|
3986
3986
|
const S = Array.isArray(c.messages) ? c.messages : [];
|
|
3987
|
-
for (const
|
|
3988
|
-
|
|
3987
|
+
for (const b of S)
|
|
3988
|
+
b.role === "user" && (x || (x = b), b.id && (h = b.id));
|
|
3989
3989
|
const A = c.next && c.next.length > 0 ? String(c.next[0]) : null, w = c.parentConfig ?? null, k = {
|
|
3990
|
-
id:
|
|
3991
|
-
step:
|
|
3990
|
+
id: m,
|
|
3991
|
+
step: I,
|
|
3992
3992
|
source: f,
|
|
3993
3993
|
createdAt: c.createdAt ?? null,
|
|
3994
3994
|
namespace: c.checkpointNs ?? null,
|
|
3995
3995
|
parentId: c.parentId ?? null,
|
|
3996
3996
|
next: A,
|
|
3997
3997
|
parentConfig: w,
|
|
3998
|
-
userMessageId:
|
|
3998
|
+
userMessageId: h
|
|
3999
3999
|
};
|
|
4000
|
-
if (
|
|
4001
|
-
const
|
|
4002
|
-
|
|
4000
|
+
if (o.push(k), d && t.set(d, k), d && x) {
|
|
4001
|
+
const b = Nr(x);
|
|
4002
|
+
b && r.set(d, b);
|
|
4003
4003
|
}
|
|
4004
4004
|
n.push({
|
|
4005
|
-
id:
|
|
4006
|
-
messageId:
|
|
4007
|
-
step:
|
|
4005
|
+
id: m,
|
|
4006
|
+
messageId: h,
|
|
4007
|
+
step: I,
|
|
4008
4008
|
source: f,
|
|
4009
4009
|
createdAt: c.createdAt ?? null,
|
|
4010
4010
|
next: A,
|
|
4011
4011
|
parentConfig: w
|
|
4012
4012
|
});
|
|
4013
4013
|
}
|
|
4014
|
-
const
|
|
4015
|
-
for (const l of
|
|
4014
|
+
const s = /* @__PURE__ */ new Map();
|
|
4015
|
+
for (const l of o) {
|
|
4016
4016
|
if (!l.userMessageId) continue;
|
|
4017
|
-
const c =
|
|
4018
|
-
c.push(l),
|
|
4017
|
+
const c = s.get(l.userMessageId) ?? [];
|
|
4018
|
+
c.push(l), s.set(l.userMessageId, c);
|
|
4019
4019
|
}
|
|
4020
|
-
for (const l of
|
|
4020
|
+
for (const l of s.values()) {
|
|
4021
4021
|
if (!l.length) continue;
|
|
4022
|
-
l.sort((d,
|
|
4023
|
-
const
|
|
4024
|
-
return (
|
|
4022
|
+
l.sort((d, m) => {
|
|
4023
|
+
const p = d.createdAt ? Date.parse(d.createdAt) : 0;
|
|
4024
|
+
return (m.createdAt ? Date.parse(m.createdAt) : 0) - p;
|
|
4025
4025
|
});
|
|
4026
4026
|
const c = l.length;
|
|
4027
4027
|
for (let d = 0; d < l.length; d++) {
|
|
4028
|
-
const
|
|
4029
|
-
|
|
4028
|
+
const m = l[d];
|
|
4029
|
+
m.attemptCount = c, m.attemptIndex = d, m.isLatestAttempt = d === 0;
|
|
4030
4030
|
}
|
|
4031
4031
|
}
|
|
4032
4032
|
return {
|
|
@@ -4044,27 +4044,27 @@ function zr(e) {
|
|
|
4044
4044
|
const c = [];
|
|
4045
4045
|
for (const d of t.values())
|
|
4046
4046
|
d.userMessageId === l && c.push(d);
|
|
4047
|
-
return c.length ? (c.sort((d,
|
|
4048
|
-
const
|
|
4049
|
-
return
|
|
4047
|
+
return c.length ? (c.sort((d, m) => {
|
|
4048
|
+
const p = typeof d.attemptIndex == "number" ? d.attemptIndex : Number.MAX_SAFE_INTEGER, I = typeof m.attemptIndex == "number" ? m.attemptIndex : Number.MAX_SAFE_INTEGER;
|
|
4049
|
+
return p - I;
|
|
4050
4050
|
}), c) : [];
|
|
4051
4051
|
}
|
|
4052
4052
|
};
|
|
4053
4053
|
}
|
|
4054
|
-
function
|
|
4054
|
+
function ds(e, t, n) {
|
|
4055
4055
|
if (!e)
|
|
4056
4056
|
return { attemptCount: 1, attemptIndex: 0, attempts: [] };
|
|
4057
4057
|
const r = n.getMessageAttempts(e);
|
|
4058
4058
|
if (!r.length)
|
|
4059
4059
|
return { attemptCount: 1, attemptIndex: 0, attempts: [] };
|
|
4060
|
-
let
|
|
4060
|
+
let o = 0;
|
|
4061
4061
|
if (t) {
|
|
4062
|
-
const
|
|
4063
|
-
|
|
4062
|
+
const s = r.findIndex((a) => a.id === t);
|
|
4063
|
+
s >= 0 && (o = s);
|
|
4064
4064
|
}
|
|
4065
4065
|
return {
|
|
4066
4066
|
attemptCount: r.length,
|
|
4067
|
-
attemptIndex:
|
|
4067
|
+
attemptIndex: o,
|
|
4068
4068
|
attempts: r
|
|
4069
4069
|
};
|
|
4070
4070
|
}
|
|
@@ -4076,49 +4076,49 @@ function $t({
|
|
|
4076
4076
|
fileApi: t,
|
|
4077
4077
|
seed: n,
|
|
4078
4078
|
onError: r,
|
|
4079
|
-
currentThreadId:
|
|
4080
|
-
autoLoadInitial:
|
|
4079
|
+
currentThreadId: o,
|
|
4080
|
+
autoLoadInitial: s = !0,
|
|
4081
4081
|
isStreaming: a,
|
|
4082
4082
|
getMessages: i,
|
|
4083
4083
|
includeHistory: u = !0
|
|
4084
4084
|
}) {
|
|
4085
|
-
const [l, c] = H(null),
|
|
4085
|
+
const [l, c] = H(null), m = Z(
|
|
4086
4086
|
() => mt(l),
|
|
4087
4087
|
[l]
|
|
4088
|
-
).checkpoints,
|
|
4088
|
+
).checkpoints, p = Rr(m), I = p.timeline, [f, h] = H(!1), [x, S] = H(!1), [A, w] = H(!1), [k, b] = H(null), T = W(o), y = W(null), v = W(null);
|
|
4089
4089
|
Y(() => {
|
|
4090
|
-
T.current =
|
|
4091
|
-
}, [
|
|
4092
|
-
const
|
|
4090
|
+
T.current = o;
|
|
4091
|
+
}, [o]);
|
|
4092
|
+
const _ = N(
|
|
4093
4093
|
async (P) => {
|
|
4094
4094
|
const F = await e.getState({
|
|
4095
4095
|
threadId: P.threadId,
|
|
4096
4096
|
checkpointId: P.checkpointId,
|
|
4097
4097
|
checkpointNs: P.checkpointNs
|
|
4098
|
-
}),
|
|
4098
|
+
}), E = {
|
|
4099
4099
|
version: "values@1",
|
|
4100
4100
|
threadId: P.threadId,
|
|
4101
4101
|
checkpoints: [F]
|
|
4102
|
-
}, j = t ? await Mr(
|
|
4102
|
+
}, j = t ? await Mr(E, t) : E, { latest: G } = mt(j);
|
|
4103
4103
|
return G;
|
|
4104
4104
|
},
|
|
4105
4105
|
[e, t]
|
|
4106
|
-
), L =
|
|
4106
|
+
), L = N(
|
|
4107
4107
|
async (P, F) => {
|
|
4108
4108
|
var G;
|
|
4109
4109
|
if (!P) return;
|
|
4110
|
-
const
|
|
4111
|
-
if (y.current ===
|
|
4112
|
-
(G =
|
|
4110
|
+
const E = `${P}:${F ?? "latest"}`;
|
|
4111
|
+
if (y.current === E || f) return;
|
|
4112
|
+
(G = v.current) == null || G.abort();
|
|
4113
4113
|
const j = new AbortController();
|
|
4114
|
-
|
|
4114
|
+
v.current = j, h(!0), b(null);
|
|
4115
4115
|
try {
|
|
4116
|
-
const g = await
|
|
4116
|
+
const g = await _({
|
|
4117
4117
|
threadId: P,
|
|
4118
4118
|
checkpointId: F ?? void 0
|
|
4119
4119
|
});
|
|
4120
4120
|
if (T.current !== P) {
|
|
4121
|
-
|
|
4121
|
+
h(!1);
|
|
4122
4122
|
return;
|
|
4123
4123
|
}
|
|
4124
4124
|
if (n((g == null ? void 0 : g.messages) ?? [], {
|
|
@@ -4126,7 +4126,7 @@ function $t({
|
|
|
4126
4126
|
checkpointNs: (g == null ? void 0 : g.checkpointNs) ?? null,
|
|
4127
4127
|
pendingInterrupt: (g == null ? void 0 : g.interrupt) ?? null,
|
|
4128
4128
|
values: g == null ? void 0 : g.values
|
|
4129
|
-
}), y.current =
|
|
4129
|
+
}), y.current = E, h(!1), u) {
|
|
4130
4130
|
w(!0);
|
|
4131
4131
|
try {
|
|
4132
4132
|
const z = await e.getStateHistory({
|
|
@@ -4140,58 +4140,61 @@ function $t({
|
|
|
4140
4140
|
}
|
|
4141
4141
|
}
|
|
4142
4142
|
} catch (g) {
|
|
4143
|
-
if (
|
|
4143
|
+
if (h(!1), !Xt(g)) {
|
|
4144
4144
|
const z = String(g);
|
|
4145
|
-
|
|
4145
|
+
b(z), r == null || r(z);
|
|
4146
4146
|
}
|
|
4147
4147
|
}
|
|
4148
4148
|
},
|
|
4149
|
-
[e, n,
|
|
4150
|
-
), M =
|
|
4149
|
+
[e, n, _, r, i]
|
|
4150
|
+
), M = N(
|
|
4151
4151
|
async (P, F) => {
|
|
4152
|
-
if (
|
|
4152
|
+
if (o) {
|
|
4153
4153
|
S(!0);
|
|
4154
4154
|
try {
|
|
4155
|
-
const
|
|
4156
|
-
threadId:
|
|
4155
|
+
const E = await _({
|
|
4156
|
+
threadId: o,
|
|
4157
4157
|
checkpointId: P,
|
|
4158
4158
|
checkpointNs: F ?? void 0
|
|
4159
4159
|
});
|
|
4160
|
-
n((
|
|
4161
|
-
checkpointId: (
|
|
4162
|
-
checkpointNs: (
|
|
4163
|
-
pendingInterrupt: (
|
|
4164
|
-
values:
|
|
4160
|
+
n((E == null ? void 0 : E.messages) ?? [], {
|
|
4161
|
+
checkpointId: (E == null ? void 0 : E.checkpointId) ?? P,
|
|
4162
|
+
checkpointNs: (E == null ? void 0 : E.checkpointNs) ?? F,
|
|
4163
|
+
pendingInterrupt: (E == null ? void 0 : E.interrupt) ?? null,
|
|
4164
|
+
values: E == null ? void 0 : E.values
|
|
4165
4165
|
});
|
|
4166
|
-
} catch (
|
|
4167
|
-
console.error("[useThreadHistoryState] Navigation failed",
|
|
4166
|
+
} catch (E) {
|
|
4167
|
+
console.error("[useThreadHistoryState] Navigation failed", E);
|
|
4168
4168
|
} finally {
|
|
4169
4169
|
S(!1);
|
|
4170
4170
|
}
|
|
4171
4171
|
}
|
|
4172
4172
|
},
|
|
4173
|
-
[
|
|
4174
|
-
), $ =
|
|
4175
|
-
|
|
4176
|
-
}, [
|
|
4173
|
+
[o, _, n]
|
|
4174
|
+
), $ = N(async () => {
|
|
4175
|
+
o && await L(o);
|
|
4176
|
+
}, [o, L]), U = N(
|
|
4177
4177
|
async (P) => {
|
|
4178
|
-
const F = (P == null ? void 0 : P.threadId) ||
|
|
4179
|
-
!F ||
|
|
4178
|
+
const F = (P == null ? void 0 : P.threadId) || o;
|
|
4179
|
+
if (!F || o !== F) return;
|
|
4180
|
+
c(P);
|
|
4181
|
+
const E = P.scope;
|
|
4182
|
+
(!E || E === "main" || E === "agent") && (y.current = `${F}:latest`);
|
|
4180
4183
|
},
|
|
4181
|
-
[
|
|
4184
|
+
[o]
|
|
4182
4185
|
);
|
|
4183
4186
|
Y(() => {
|
|
4184
|
-
if (!
|
|
4185
|
-
const P = `${
|
|
4186
|
-
y.current !== P && L(
|
|
4187
|
-
}, [
|
|
4188
|
-
const V =
|
|
4189
|
-
c(null),
|
|
4187
|
+
if (!s || !o || f || a) return;
|
|
4188
|
+
const P = `${o}:latest`;
|
|
4189
|
+
y.current !== P && L(o);
|
|
4190
|
+
}, [s, o, f, a, L]);
|
|
4191
|
+
const V = N(() => {
|
|
4192
|
+
c(null), h(!1), S(!1), w(!1), b(null), y.current = null;
|
|
4190
4193
|
}, []);
|
|
4191
4194
|
return {
|
|
4192
|
-
threadCheckpoints:
|
|
4193
|
-
threadTimeline:
|
|
4194
|
-
checkpointIndex:
|
|
4195
|
+
threadCheckpoints: m,
|
|
4196
|
+
threadTimeline: I,
|
|
4197
|
+
checkpointIndex: p,
|
|
4195
4198
|
isLoadingThread: f,
|
|
4196
4199
|
isLoadingCheckpoint: x,
|
|
4197
4200
|
isLoadingHistory: A,
|
|
@@ -4228,54 +4231,54 @@ function jr({
|
|
|
4228
4231
|
initialThreadId: t = null,
|
|
4229
4232
|
initialCheckpointId: n = null,
|
|
4230
4233
|
initialCheckpointNs: r = null,
|
|
4231
|
-
autoLoadInitial:
|
|
4232
|
-
isStreaming:
|
|
4234
|
+
autoLoadInitial: o = !0,
|
|
4235
|
+
isStreaming: s,
|
|
4233
4236
|
onError: a,
|
|
4234
4237
|
includeHistory: i = !0
|
|
4235
4238
|
}) {
|
|
4236
|
-
const { chatApi: u, fileApi: l } = Me(), { currentThreadId: c } =
|
|
4239
|
+
const { chatApi: u, fileApi: l } = Me(), { currentThreadId: c } = st(), { state: d, seed: m, onEvent: p, dispatch: I } = kr(), {
|
|
4237
4240
|
threadCheckpoints: f,
|
|
4238
|
-
threadTimeline:
|
|
4241
|
+
threadTimeline: h,
|
|
4239
4242
|
checkpointIndex: x,
|
|
4240
4243
|
isLoadingThread: S,
|
|
4241
4244
|
isLoadingCheckpoint: A,
|
|
4242
4245
|
isLoadingHistory: w,
|
|
4243
4246
|
threadStateError: k,
|
|
4244
|
-
loadThread:
|
|
4247
|
+
loadThread: b,
|
|
4245
4248
|
navigateToCheckpoint: T,
|
|
4246
4249
|
setCurrentCheckpointId: y,
|
|
4247
|
-
returnToLatest:
|
|
4248
|
-
handleValuesEvent:
|
|
4250
|
+
returnToLatest: v,
|
|
4251
|
+
handleValuesEvent: _,
|
|
4249
4252
|
markSkipNextLoad: L,
|
|
4250
4253
|
markStreamPendingThread: M,
|
|
4251
4254
|
resetHistoryState: $
|
|
4252
4255
|
} = $t({
|
|
4253
4256
|
api: u,
|
|
4254
4257
|
fileApi: l,
|
|
4255
|
-
seed:
|
|
4258
|
+
seed: m,
|
|
4256
4259
|
onError: a,
|
|
4257
4260
|
currentThreadId: c,
|
|
4258
4261
|
initialThreadId: t,
|
|
4259
4262
|
initialCheckpointId: n,
|
|
4260
4263
|
initialCheckpointNs: r,
|
|
4261
|
-
autoLoadInitial:
|
|
4262
|
-
isStreaming:
|
|
4263
|
-
getMessages:
|
|
4264
|
+
autoLoadInitial: o,
|
|
4265
|
+
isStreaming: s,
|
|
4266
|
+
getMessages: N(() => d.messages, [d.messages]),
|
|
4264
4267
|
includeHistory: i
|
|
4265
|
-
}), U = W(null), V =
|
|
4268
|
+
}), U = W(null), V = N(
|
|
4266
4269
|
(D) => {
|
|
4267
4270
|
U.current = D;
|
|
4268
4271
|
},
|
|
4269
4272
|
[]
|
|
4270
|
-
), P = W(null), F =
|
|
4273
|
+
), P = W(null), F = N(
|
|
4271
4274
|
(D) => {
|
|
4272
4275
|
P.current = D;
|
|
4273
4276
|
},
|
|
4274
4277
|
[]
|
|
4275
|
-
),
|
|
4278
|
+
), E = Z(() => ({ assemblingMessageId: d.assemblingId ?? null }), [d.assemblingId]), j = N(
|
|
4276
4279
|
(D, K) => {
|
|
4277
4280
|
const B = jt(D, "user");
|
|
4278
|
-
return
|
|
4281
|
+
return I({
|
|
4279
4282
|
type: "user_message",
|
|
4280
4283
|
payload: {
|
|
4281
4284
|
message: B,
|
|
@@ -4283,12 +4286,12 @@ function jr({
|
|
|
4283
4286
|
}
|
|
4284
4287
|
}), B;
|
|
4285
4288
|
},
|
|
4286
|
-
[
|
|
4287
|
-
), G =
|
|
4288
|
-
U.current ? await U.current() : (
|
|
4289
|
-
}, [
|
|
4290
|
-
await
|
|
4291
|
-
}, [
|
|
4289
|
+
[I]
|
|
4290
|
+
), G = N(async () => {
|
|
4291
|
+
U.current ? await U.current() : (m([], {}), $());
|
|
4292
|
+
}, [m, $]), g = N(async (D, K, B) => {
|
|
4293
|
+
await b(D, K, { clearProgress: !1 });
|
|
4294
|
+
}, [b]), z = Z(() => Bn(d.messages), [d.messages]), C = Z(
|
|
4292
4295
|
() => ({
|
|
4293
4296
|
status: d.status,
|
|
4294
4297
|
threadId: c,
|
|
@@ -4301,8 +4304,8 @@ function jr({
|
|
|
4301
4304
|
},
|
|
4302
4305
|
checkpoints: f,
|
|
4303
4306
|
checkpointIndex: x,
|
|
4304
|
-
timelineCheckpoints:
|
|
4305
|
-
metadata:
|
|
4307
|
+
timelineCheckpoints: h,
|
|
4308
|
+
metadata: E,
|
|
4306
4309
|
values: d.values ?? {},
|
|
4307
4310
|
isLoading: S,
|
|
4308
4311
|
isLoadingCheckpoint: A,
|
|
@@ -4312,7 +4315,7 @@ function jr({
|
|
|
4312
4315
|
},
|
|
4313
4316
|
// Placeholder
|
|
4314
4317
|
seedFromSnapshot: (D) => {
|
|
4315
|
-
|
|
4318
|
+
m(D.messages, {
|
|
4316
4319
|
checkpointId: D.checkpointId,
|
|
4317
4320
|
checkpointNs: D.checkpointNs,
|
|
4318
4321
|
pendingInterrupt: D.interrupt,
|
|
@@ -4322,19 +4325,19 @@ function jr({
|
|
|
4322
4325
|
clearState: G,
|
|
4323
4326
|
navigateToCheckpoint: T,
|
|
4324
4327
|
setCurrentCheckpointId: y,
|
|
4325
|
-
returnToLatest:
|
|
4328
|
+
returnToLatest: v,
|
|
4326
4329
|
loadThread: g,
|
|
4327
4330
|
clearThread: G,
|
|
4328
4331
|
respondToInterrupt: async (D, K, B) => {
|
|
4329
4332
|
P.current && await P.current(D, K, B);
|
|
4330
4333
|
},
|
|
4331
4334
|
messagePreviews: x.messagePreviews,
|
|
4332
|
-
handleValuesEvent:
|
|
4335
|
+
handleValuesEvent: _,
|
|
4333
4336
|
markSkipNextLoad: L,
|
|
4334
4337
|
markStreamPendingThread: M,
|
|
4335
4338
|
resetHistoryState: $,
|
|
4336
4339
|
pushUser: j,
|
|
4337
|
-
onEvent:
|
|
4340
|
+
onEvent: p,
|
|
4338
4341
|
artifacts: z
|
|
4339
4342
|
}),
|
|
4340
4343
|
[
|
|
@@ -4346,24 +4349,24 @@ function jr({
|
|
|
4346
4349
|
d.lastCheckpointNs,
|
|
4347
4350
|
d.values,
|
|
4348
4351
|
f,
|
|
4349
|
-
|
|
4352
|
+
h,
|
|
4350
4353
|
x,
|
|
4351
|
-
|
|
4354
|
+
E,
|
|
4352
4355
|
S,
|
|
4353
4356
|
A,
|
|
4354
4357
|
w,
|
|
4355
4358
|
k,
|
|
4356
|
-
|
|
4359
|
+
m,
|
|
4357
4360
|
G,
|
|
4358
4361
|
T,
|
|
4359
4362
|
y,
|
|
4360
|
-
|
|
4363
|
+
v,
|
|
4361
4364
|
g,
|
|
4362
|
-
|
|
4365
|
+
_,
|
|
4363
4366
|
L,
|
|
4364
4367
|
M,
|
|
4365
4368
|
j,
|
|
4366
|
-
|
|
4369
|
+
p,
|
|
4367
4370
|
z
|
|
4368
4371
|
]
|
|
4369
4372
|
), O = Z(
|
|
@@ -4381,32 +4384,32 @@ function Br({
|
|
|
4381
4384
|
onError: t,
|
|
4382
4385
|
onAuthError: n,
|
|
4383
4386
|
onConnectionError: r,
|
|
4384
|
-
onToolEnd:
|
|
4385
|
-
onUpdateEvent:
|
|
4387
|
+
onToolEnd: o,
|
|
4388
|
+
onUpdateEvent: s,
|
|
4386
4389
|
onCustomEvent: a,
|
|
4387
4390
|
onMetadataEvent: i,
|
|
4388
4391
|
onFinish: u,
|
|
4389
4392
|
onStreamingChange: l
|
|
4390
4393
|
}) {
|
|
4391
|
-
const { chatApi: c, baseUrl: d } = Me(),
|
|
4394
|
+
const { chatApi: c, baseUrl: d } = Me(), m = d, p = ge(t), I = ge(n), f = ge(r), h = ge(o), x = ge(s), S = ge(a), A = ge(i), w = ge(u), k = ge(l), b = Z(
|
|
4392
4395
|
() => ({
|
|
4393
|
-
onError:
|
|
4394
|
-
onAuthError:
|
|
4396
|
+
onError: p,
|
|
4397
|
+
onAuthError: I,
|
|
4395
4398
|
onConnectionError: f,
|
|
4396
4399
|
onMetadataEvent: A,
|
|
4397
4400
|
onCustomEvent: S,
|
|
4398
4401
|
onUpdateEvent: x,
|
|
4399
|
-
onToolEnd:
|
|
4402
|
+
onToolEnd: h,
|
|
4400
4403
|
onFinish: w
|
|
4401
4404
|
}),
|
|
4402
4405
|
[
|
|
4403
|
-
|
|
4404
|
-
|
|
4406
|
+
p,
|
|
4407
|
+
I,
|
|
4405
4408
|
f,
|
|
4406
4409
|
A,
|
|
4407
4410
|
S,
|
|
4408
4411
|
x,
|
|
4409
|
-
|
|
4412
|
+
h,
|
|
4410
4413
|
w
|
|
4411
4414
|
]
|
|
4412
4415
|
);
|
|
@@ -4414,8 +4417,8 @@ function Br({
|
|
|
4414
4417
|
Fr,
|
|
4415
4418
|
{
|
|
4416
4419
|
api: c,
|
|
4417
|
-
streamBaseUrl:
|
|
4418
|
-
handlers:
|
|
4420
|
+
streamBaseUrl: m,
|
|
4421
|
+
handlers: b,
|
|
4419
4422
|
onStreamingChange: k,
|
|
4420
4423
|
children: e
|
|
4421
4424
|
}
|
|
@@ -4426,25 +4429,25 @@ function Fr({
|
|
|
4426
4429
|
api: t,
|
|
4427
4430
|
streamBaseUrl: n,
|
|
4428
4431
|
handlers: r,
|
|
4429
|
-
onStreamingChange:
|
|
4432
|
+
onStreamingChange: o
|
|
4430
4433
|
}) {
|
|
4431
|
-
const { setCurrentThreadId:
|
|
4434
|
+
const { setCurrentThreadId: s, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: u } = st(), {
|
|
4432
4435
|
interrupt: l,
|
|
4433
4436
|
checkpoint: c,
|
|
4434
4437
|
timelineCheckpoints: d,
|
|
4435
|
-
handleValuesEvent:
|
|
4436
|
-
markSkipNextLoad:
|
|
4437
|
-
markStreamPendingThread:
|
|
4438
|
+
handleValuesEvent: m,
|
|
4439
|
+
markSkipNextLoad: p,
|
|
4440
|
+
markStreamPendingThread: I,
|
|
4438
4441
|
resetHistoryState: f,
|
|
4439
|
-
pushUser:
|
|
4442
|
+
pushUser: h,
|
|
4440
4443
|
onEvent: x,
|
|
4441
4444
|
messages: S
|
|
4442
|
-
} = Ht(), { registerClearThread: A, registerRespondToInterrupt: w } = Lr(), k =
|
|
4445
|
+
} = Ht(), { registerClearThread: A, registerRespondToInterrupt: w } = Lr(), k = N(
|
|
4443
4446
|
(g) => {
|
|
4444
|
-
i(g),
|
|
4447
|
+
i(g), I(g.threadId), a.current !== g.threadId && ((g.created ?? !a.current) && p(g.threadId), s(g.threadId));
|
|
4445
4448
|
},
|
|
4446
|
-
[i,
|
|
4447
|
-
),
|
|
4449
|
+
[i, p, I, s, a]
|
|
4450
|
+
), b = pr({
|
|
4448
4451
|
baseUrl: n,
|
|
4449
4452
|
onEvent: x,
|
|
4450
4453
|
onError: (g) => {
|
|
@@ -4459,16 +4462,16 @@ function Fr({
|
|
|
4459
4462
|
onCustomEvent: r.onCustomEvent,
|
|
4460
4463
|
onUpdateEvent: r.onUpdateEvent,
|
|
4461
4464
|
onToolEnd: r.onToolEnd,
|
|
4462
|
-
handleValuesEvent:
|
|
4465
|
+
handleValuesEvent: m
|
|
4463
4466
|
});
|
|
4464
4467
|
Y(() => {
|
|
4465
|
-
|
|
4466
|
-
}, [
|
|
4467
|
-
const { stream: T, stop: y, clear:
|
|
4468
|
+
o == null || o(b.isStreaming);
|
|
4469
|
+
}, [b.isStreaming, o]);
|
|
4470
|
+
const { stream: T, stop: y, clear: v, isStreaming: _, error: L, connected: M, activeMessageId: $ } = b;
|
|
4468
4471
|
Y(() => {
|
|
4469
|
-
u !== void 0 &&
|
|
4470
|
-
}, [u,
|
|
4471
|
-
const U =
|
|
4472
|
+
u !== void 0 && v();
|
|
4473
|
+
}, [u, v]);
|
|
4474
|
+
const U = N(
|
|
4472
4475
|
async (g, z) => {
|
|
4473
4476
|
await T(g, z);
|
|
4474
4477
|
},
|
|
@@ -4477,7 +4480,7 @@ function Fr({
|
|
|
4477
4480
|
Y(() => {
|
|
4478
4481
|
V.current = c;
|
|
4479
4482
|
}, [c]);
|
|
4480
|
-
const P =
|
|
4483
|
+
const P = N(
|
|
4481
4484
|
async (g, z, C) => {
|
|
4482
4485
|
var ye;
|
|
4483
4486
|
const O = a.current;
|
|
@@ -4501,15 +4504,15 @@ function Fr({
|
|
|
4501
4504
|
Y(() => {
|
|
4502
4505
|
w(P);
|
|
4503
4506
|
}, [P, w]);
|
|
4504
|
-
const F =
|
|
4505
|
-
y(),
|
|
4506
|
-
}, [
|
|
4507
|
+
const F = N(async () => {
|
|
4508
|
+
y(), v(), f(), s(null);
|
|
4509
|
+
}, [v, f, s, y]);
|
|
4507
4510
|
Y(() => {
|
|
4508
4511
|
A(F);
|
|
4509
4512
|
}, [F, A]);
|
|
4510
|
-
const
|
|
4513
|
+
const E = N(
|
|
4511
4514
|
async (g, z) => {
|
|
4512
|
-
|
|
4515
|
+
_ && y();
|
|
4513
4516
|
let C = a.current;
|
|
4514
4517
|
const O = (g == null ? void 0 : g.text) ?? "", D = (g == null ? void 0 : g.attachments) ?? [], K = (O == null ? void 0 : O.trim()) ?? "", B = { ...(g == null ? void 0 : g.payload) ?? {} }, ee = Array.isArray(B.messages) ? B.messages : void 0;
|
|
4515
4518
|
ee && delete B.messages;
|
|
@@ -4517,11 +4520,11 @@ function Fr({
|
|
|
4517
4520
|
if (!C && !K && D.length === 0 && !ie && !ye) return;
|
|
4518
4521
|
if (!C) {
|
|
4519
4522
|
const re = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), te = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
|
|
4520
|
-
C = `${re}${te}`,
|
|
4523
|
+
C = `${re}${te}`, p(C), s(C);
|
|
4521
4524
|
}
|
|
4522
4525
|
let J = null;
|
|
4523
4526
|
g.contentParts && g.contentParts.length > 0 && (J = g.contentParts);
|
|
4524
|
-
const { contentParts:
|
|
4527
|
+
const { contentParts: oe, filesInfo: he } = J ? { contentParts: J, filesInfo: [] } : await sr(D), X = [...oe];
|
|
4525
4528
|
K && X.push({ type: "text", text: O });
|
|
4526
4529
|
const Q = g == null ? void 0 : g.originalMessageId, be = !!(g != null && g.edit && Q), He = !ie && X.length > 0;
|
|
4527
4530
|
let we = null;
|
|
@@ -4532,7 +4535,7 @@ function Fr({
|
|
|
4532
4535
|
role: "user",
|
|
4533
4536
|
content: X,
|
|
4534
4537
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4535
|
-
}, "user"), be ?
|
|
4538
|
+
}, "user"), be ? h(we, { editingMessageId: Q }) : h(we);
|
|
4536
4539
|
}
|
|
4537
4540
|
const Pe = ie ? ee : we ? [we] : [], ke = {
|
|
4538
4541
|
...B,
|
|
@@ -4569,15 +4572,15 @@ function Fr({
|
|
|
4569
4572
|
};
|
|
4570
4573
|
return U(Ue, z);
|
|
4571
4574
|
},
|
|
4572
|
-
[c, a,
|
|
4575
|
+
[c, a, _, p, h, U, y, d]
|
|
4573
4576
|
), j = Z(() => S, [S]), G = Z(
|
|
4574
4577
|
() => ({
|
|
4575
|
-
isStreaming:
|
|
4578
|
+
isStreaming: _,
|
|
4576
4579
|
error: L,
|
|
4577
|
-
connectionState: L ? "error" :
|
|
4580
|
+
connectionState: L ? "error" : _ ? M ? "connected" : "connecting" : "idle",
|
|
4578
4581
|
messages: j,
|
|
4579
4582
|
activeMessageId: $,
|
|
4580
|
-
submit:
|
|
4583
|
+
submit: E,
|
|
4581
4584
|
stop: y,
|
|
4582
4585
|
interrupt: l,
|
|
4583
4586
|
resume: () => Promise.resolve(),
|
|
@@ -4586,7 +4589,7 @@ function Fr({
|
|
|
4586
4589
|
}
|
|
4587
4590
|
// TODO: Implement error clearing
|
|
4588
4591
|
}),
|
|
4589
|
-
[
|
|
4592
|
+
[_, L, E, y, l, M, j]
|
|
4590
4593
|
);
|
|
4591
4594
|
return /* @__PURE__ */ de(Vt.Provider, { value: G, children: e });
|
|
4592
4595
|
}
|
|
@@ -4594,7 +4597,7 @@ function ge(e) {
|
|
|
4594
4597
|
const t = W(e);
|
|
4595
4598
|
return Y(() => {
|
|
4596
4599
|
t.current = e;
|
|
4597
|
-
}, [e]),
|
|
4600
|
+
}, [e]), N((...n) => {
|
|
4598
4601
|
const r = t.current;
|
|
4599
4602
|
if (r)
|
|
4600
4603
|
return r(...n);
|
|
@@ -4612,8 +4615,8 @@ function $r(e, t) {
|
|
|
4612
4615
|
const n = Object.keys(e), r = Object.keys(t);
|
|
4613
4616
|
if (n.length !== r.length)
|
|
4614
4617
|
return !1;
|
|
4615
|
-
for (const
|
|
4616
|
-
if (!Object.prototype.hasOwnProperty.call(t,
|
|
4618
|
+
for (const o of n)
|
|
4619
|
+
if (!Object.prototype.hasOwnProperty.call(t, o) || !Object.is(e[o], t[o]))
|
|
4617
4620
|
return !1;
|
|
4618
4621
|
return !0;
|
|
4619
4622
|
}
|
|
@@ -4622,53 +4625,53 @@ function Dr(e) {
|
|
|
4622
4625
|
return $r(t.current, e) || (t.current = e, n.current = e), n.current;
|
|
4623
4626
|
}
|
|
4624
4627
|
function Kr(e) {
|
|
4625
|
-
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,
|
|
4626
|
-
return typeof
|
|
4628
|
+
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;
|
|
4629
|
+
return typeof o == "string" ? o : null;
|
|
4627
4630
|
}
|
|
4628
|
-
function
|
|
4631
|
+
function us(e) {
|
|
4629
4632
|
const { setCurrentTaskId: t, getCurrentTaskId: n, onToolEnd: r } = e;
|
|
4630
|
-
return (
|
|
4631
|
-
const
|
|
4632
|
-
|
|
4633
|
+
return (o) => {
|
|
4634
|
+
const s = Kr(o), a = (n == null ? void 0 : n()) ?? null;
|
|
4635
|
+
s && s !== a && t(s), r == null || r(o);
|
|
4633
4636
|
};
|
|
4634
4637
|
}
|
|
4635
|
-
function
|
|
4638
|
+
function fs({
|
|
4636
4639
|
children: e,
|
|
4637
4640
|
apiConfig: t,
|
|
4638
4641
|
initialThreadId: n = null,
|
|
4639
4642
|
initialCheckpointId: r = null,
|
|
4640
|
-
initialCheckpointNs:
|
|
4641
|
-
autoLoadInitial:
|
|
4643
|
+
initialCheckpointNs: o = null,
|
|
4644
|
+
autoLoadInitial: s = !0,
|
|
4642
4645
|
onConnectionError: a,
|
|
4643
4646
|
onError: i,
|
|
4644
4647
|
onAuthError: u,
|
|
4645
4648
|
onThreadChange: l,
|
|
4646
4649
|
onToolEnd: c,
|
|
4647
4650
|
onUpdateEvent: d,
|
|
4648
|
-
onCustomEvent:
|
|
4649
|
-
onMetadataEvent:
|
|
4650
|
-
onFinish:
|
|
4651
|
+
onCustomEvent: m,
|
|
4652
|
+
onMetadataEvent: p,
|
|
4653
|
+
onFinish: I
|
|
4651
4654
|
}) {
|
|
4652
|
-
const f = Dr(t), [
|
|
4655
|
+
const f = Dr(t), [h, x] = H(!1), S = me(i), A = me(u), w = me(a), k = me(l), b = me(c), T = me(d), y = me(m), v = me(p), _ = me(I), L = Z(
|
|
4653
4656
|
() => ({
|
|
4654
4657
|
onError: S,
|
|
4655
4658
|
onAuthError: A,
|
|
4656
4659
|
onConnectionError: w,
|
|
4657
|
-
onToolEnd:
|
|
4660
|
+
onToolEnd: b,
|
|
4658
4661
|
onUpdateEvent: T,
|
|
4659
4662
|
onCustomEvent: y,
|
|
4660
|
-
onMetadataEvent:
|
|
4661
|
-
onFinish:
|
|
4663
|
+
onMetadataEvent: v,
|
|
4664
|
+
onFinish: _
|
|
4662
4665
|
}),
|
|
4663
4666
|
[
|
|
4664
4667
|
S,
|
|
4665
4668
|
A,
|
|
4666
4669
|
w,
|
|
4667
|
-
|
|
4670
|
+
b,
|
|
4668
4671
|
T,
|
|
4669
4672
|
y,
|
|
4670
|
-
|
|
4671
|
-
|
|
4673
|
+
v,
|
|
4674
|
+
_
|
|
4672
4675
|
]
|
|
4673
4676
|
);
|
|
4674
4677
|
return /* @__PURE__ */ de(nr, { apiConfig: f, children: /* @__PURE__ */ de(
|
|
@@ -4682,10 +4685,10 @@ function po({
|
|
|
4682
4685
|
{
|
|
4683
4686
|
initialThreadId: n,
|
|
4684
4687
|
initialCheckpointId: r,
|
|
4685
|
-
initialCheckpointNs:
|
|
4686
|
-
autoLoadInitial:
|
|
4688
|
+
initialCheckpointNs: o,
|
|
4689
|
+
autoLoadInitial: s,
|
|
4687
4690
|
onError: S,
|
|
4688
|
-
isStreaming:
|
|
4691
|
+
isStreaming: h,
|
|
4689
4692
|
children: /* @__PURE__ */ de(
|
|
4690
4693
|
Br,
|
|
4691
4694
|
{
|
|
@@ -4701,7 +4704,7 @@ function po({
|
|
|
4701
4704
|
}
|
|
4702
4705
|
function me(e) {
|
|
4703
4706
|
const t = W(e);
|
|
4704
|
-
return t.current = e,
|
|
4707
|
+
return t.current = e, N((...n) => {
|
|
4705
4708
|
const r = t.current;
|
|
4706
4709
|
if (r)
|
|
4707
4710
|
return r(...n);
|
|
@@ -4767,9 +4770,9 @@ function Le(e) {
|
|
|
4767
4770
|
});
|
|
4768
4771
|
}
|
|
4769
4772
|
function Wr({ ...e }) {
|
|
4770
|
-
const t = qr(), n = (
|
|
4773
|
+
const t = qr(), n = (o) => Le({
|
|
4771
4774
|
type: "UPDATE_TOAST",
|
|
4772
|
-
toast: { ...
|
|
4775
|
+
toast: { ...o, id: t }
|
|
4773
4776
|
}), r = () => Le({ type: "DISMISS_TOAST", toastId: t });
|
|
4774
4777
|
return Le({
|
|
4775
4778
|
type: "ADD_TOAST",
|
|
@@ -4777,8 +4780,8 @@ function Wr({ ...e }) {
|
|
|
4777
4780
|
...e,
|
|
4778
4781
|
id: t,
|
|
4779
4782
|
open: !0,
|
|
4780
|
-
onOpenChange: (
|
|
4781
|
-
|
|
4783
|
+
onOpenChange: (o) => {
|
|
4784
|
+
o || r();
|
|
4782
4785
|
}
|
|
4783
4786
|
}
|
|
4784
4787
|
}), {
|
|
@@ -4798,43 +4801,43 @@ function Jr() {
|
|
|
4798
4801
|
dismiss: (n) => Le({ type: "DISMISS_TOAST", toastId: n })
|
|
4799
4802
|
};
|
|
4800
4803
|
}
|
|
4801
|
-
function
|
|
4802
|
-
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast:
|
|
4804
|
+
function ps(e) {
|
|
4805
|
+
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast: o } = Jr(), [s, a] = H({}), [i, u] = H(null), [l, c] = H(!1), d = N(() => {
|
|
4803
4806
|
c(!1), u(null);
|
|
4804
|
-
}, []),
|
|
4805
|
-
u(
|
|
4806
|
-
}, []),
|
|
4807
|
-
async (
|
|
4807
|
+
}, []), m = N((I) => {
|
|
4808
|
+
u(I), c(!0);
|
|
4809
|
+
}, []), p = N(
|
|
4810
|
+
async (I, f, h) => {
|
|
4808
4811
|
var x, S;
|
|
4809
4812
|
if (!t) {
|
|
4810
|
-
|
|
4813
|
+
I.preventDefault();
|
|
4811
4814
|
return;
|
|
4812
4815
|
}
|
|
4813
|
-
if (
|
|
4814
|
-
|
|
4816
|
+
if (s[h]) {
|
|
4817
|
+
I.preventDefault();
|
|
4815
4818
|
return;
|
|
4816
4819
|
}
|
|
4817
4820
|
try {
|
|
4818
4821
|
const A = String(f.url ?? ""), w = A.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
|
|
4819
4822
|
if (w) {
|
|
4820
|
-
|
|
4821
|
-
const k = w[1],
|
|
4822
|
-
|
|
4823
|
+
I.preventDefault();
|
|
4824
|
+
const k = w[1], b = f.name || `file_${k}`, T = f.mimeType || "application/octet-stream";
|
|
4825
|
+
m({ id: k, name: b, mimeType: T });
|
|
4823
4826
|
return;
|
|
4824
4827
|
}
|
|
4825
4828
|
if (A.startsWith("data:")) {
|
|
4826
|
-
|
|
4827
|
-
const k =
|
|
4829
|
+
I.preventDefault(), a((b) => ({ ...b, [h]: !0 }));
|
|
4830
|
+
const k = o({ title: "Fetching file...", description: "", open: !0 });
|
|
4828
4831
|
try {
|
|
4829
|
-
const
|
|
4830
|
-
if (!
|
|
4832
|
+
const b = await r.listFiles(n ?? void 0);
|
|
4833
|
+
if (!b || !Array.isArray(b))
|
|
4831
4834
|
throw new Error("Invalid file list response");
|
|
4832
|
-
const T =
|
|
4835
|
+
const T = b.find((y) => !y || typeof y != "object" || !((y.filename ?? "") === (f.name ?? "")) ? !1 : typeof f.size == "number" && typeof y.size == "number" ? y.size === f.size : !0);
|
|
4833
4836
|
if (!(T != null && T.id))
|
|
4834
4837
|
throw new Error(`File "${f.name}" is not yet available on the server`);
|
|
4835
4838
|
if (!T.id || !T.filename)
|
|
4836
4839
|
throw new Error("Invalid file data received from server");
|
|
4837
|
-
|
|
4840
|
+
m({
|
|
4838
4841
|
id: T.id,
|
|
4839
4842
|
name: f.name || T.filename || `file_${T.id}`,
|
|
4840
4843
|
mimeType: f.mimeType || T.mime_type || "application/octet-stream"
|
|
@@ -4844,39 +4847,39 @@ function go(e) {
|
|
|
4844
4847
|
description: `Opened ${f.name}`,
|
|
4845
4848
|
open: !0
|
|
4846
4849
|
});
|
|
4847
|
-
} catch (
|
|
4848
|
-
console.error("Failed to fetch server file:",
|
|
4849
|
-
const T =
|
|
4850
|
-
(S = k.update) == null || S.call(k, { id: k.id, title: "Failed", description: T }),
|
|
4850
|
+
} catch (b) {
|
|
4851
|
+
console.error("Failed to fetch server file:", b);
|
|
4852
|
+
const T = b instanceof Error ? b.message : "Unknown error occurred";
|
|
4853
|
+
(S = k.update) == null || S.call(k, { id: k.id, title: "Failed", description: T }), o({
|
|
4851
4854
|
title: "Failed to fetch file",
|
|
4852
4855
|
description: T,
|
|
4853
4856
|
open: !0
|
|
4854
4857
|
});
|
|
4855
4858
|
} finally {
|
|
4856
|
-
a((
|
|
4859
|
+
a((b) => ({ ...b, [h]: !1 }));
|
|
4857
4860
|
}
|
|
4858
4861
|
}
|
|
4859
4862
|
} catch (A) {
|
|
4860
|
-
console.error("File click error:", A), a((w) => ({ ...w, [
|
|
4863
|
+
console.error("File click error:", A), a((w) => ({ ...w, [h]: !1 }));
|
|
4861
4864
|
}
|
|
4862
4865
|
},
|
|
4863
|
-
[t,
|
|
4866
|
+
[t, s, o, n, m]
|
|
4864
4867
|
);
|
|
4865
4868
|
return {
|
|
4866
|
-
uploadingFiles:
|
|
4867
|
-
handleFileClick:
|
|
4869
|
+
uploadingFiles: s,
|
|
4870
|
+
handleFileClick: p,
|
|
4868
4871
|
fileViewerOpen: l,
|
|
4869
4872
|
currentFileInfo: i,
|
|
4870
4873
|
closeFileViewer: d
|
|
4871
4874
|
};
|
|
4872
4875
|
}
|
|
4873
|
-
function
|
|
4876
|
+
function gs(e) {
|
|
4874
4877
|
return Z(() => {
|
|
4875
4878
|
const t = e;
|
|
4876
4879
|
let n = Array.isArray(t.content) ? t.content : [];
|
|
4877
4880
|
return typeof t.content == "string" && (n = [{ type: "text", text: t.content }]), {
|
|
4878
4881
|
contentParts: n,
|
|
4879
|
-
textContent:
|
|
4882
|
+
textContent: or(n),
|
|
4880
4883
|
toolMeta: ar(t),
|
|
4881
4884
|
imageParts: n.filter((r) => r.type === "image_url"),
|
|
4882
4885
|
fileParts: n.filter((r) => r.type === "file"),
|
|
@@ -4890,13 +4893,13 @@ function Xr(e) {
|
|
|
4890
4893
|
if (!e) return [];
|
|
4891
4894
|
const t = [], n = e.split(/\r?\n/);
|
|
4892
4895
|
for (const r of n) {
|
|
4893
|
-
const
|
|
4894
|
-
if (!
|
|
4896
|
+
const o = r.trim();
|
|
4897
|
+
if (!o || !o.startsWith(kt))
|
|
4895
4898
|
continue;
|
|
4896
|
-
const
|
|
4897
|
-
if (!
|
|
4899
|
+
const s = o.slice(kt.length).trim();
|
|
4900
|
+
if (!s || s.toLowerCase() === "[done]")
|
|
4898
4901
|
continue;
|
|
4899
|
-
const a = tt(
|
|
4902
|
+
const a = tt(s);
|
|
4900
4903
|
a && typeof a == "object" && t.push(a);
|
|
4901
4904
|
}
|
|
4902
4905
|
return t;
|
|
@@ -4909,7 +4912,7 @@ function Qr(e) {
|
|
|
4909
4912
|
}
|
|
4910
4913
|
return null;
|
|
4911
4914
|
}
|
|
4912
|
-
function
|
|
4915
|
+
function ms(e) {
|
|
4913
4916
|
return Z(() => {
|
|
4914
4917
|
const t = e.content.filter(
|
|
4915
4918
|
(u) => u.type === "text"
|
|
@@ -4926,41 +4929,41 @@ function yo(e) {
|
|
|
4926
4929
|
}
|
|
4927
4930
|
if (!r.length)
|
|
4928
4931
|
return null;
|
|
4929
|
-
const
|
|
4930
|
-
if (!
|
|
4932
|
+
const s = Qr(r) ?? r[r.length - 1];
|
|
4933
|
+
if (!s)
|
|
4931
4934
|
return null;
|
|
4932
|
-
const a =
|
|
4935
|
+
const a = s.output ?? s.payload ?? s, i = ue(a);
|
|
4933
4936
|
return i && typeof i == "object" && !Array.isArray(i) ? {
|
|
4934
4937
|
kind: "dict",
|
|
4935
4938
|
value: i,
|
|
4936
4939
|
data: i,
|
|
4937
|
-
event:
|
|
4940
|
+
event: s
|
|
4938
4941
|
} : {
|
|
4939
4942
|
kind: "generic",
|
|
4940
4943
|
value: i,
|
|
4941
|
-
event:
|
|
4944
|
+
event: s
|
|
4942
4945
|
};
|
|
4943
4946
|
}, [e]);
|
|
4944
4947
|
}
|
|
4945
4948
|
function Yr(e) {
|
|
4946
4949
|
var $, U;
|
|
4947
|
-
const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = typeof e == "object" ? e.includeHistory : !0,
|
|
4950
|
+
const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = typeof e == "object" ? e.includeHistory : !0, o = st({ optional: !0 }), s = Ht({ optional: !0 }), a = Or(), { currentThreadId: i, setCurrentThreadId: u, actions: l } = o || {
|
|
4948
4951
|
currentThreadId: null,
|
|
4949
4952
|
setCurrentThreadId: () => {
|
|
4950
4953
|
},
|
|
4951
4954
|
actions: {}
|
|
4952
|
-
}, c = !!t && t !== i, [d,
|
|
4953
|
-
|
|
4955
|
+
}, c = !!t && t !== i, [d, m] = H([]), p = N((V) => {
|
|
4956
|
+
m(V);
|
|
4954
4957
|
}, []), {
|
|
4955
|
-
isLoadingThread:
|
|
4958
|
+
isLoadingThread: I,
|
|
4956
4959
|
threadStateError: f,
|
|
4957
|
-
threadCheckpoints:
|
|
4960
|
+
threadCheckpoints: h,
|
|
4958
4961
|
isLoadingHistory: x,
|
|
4959
4962
|
loadThread: S
|
|
4960
4963
|
} = $t({
|
|
4961
4964
|
api: Me().chatApi,
|
|
4962
4965
|
fileApi: Me().fileApi,
|
|
4963
|
-
seed:
|
|
4966
|
+
seed: p,
|
|
4964
4967
|
currentThreadId: c ? t : null,
|
|
4965
4968
|
initialThreadId: c ? t : null,
|
|
4966
4969
|
isStreaming: !1,
|
|
@@ -4969,51 +4972,51 @@ function Yr(e) {
|
|
|
4969
4972
|
includeHistory: r
|
|
4970
4973
|
});
|
|
4971
4974
|
Y(() => {
|
|
4972
|
-
!c && !n && i && (
|
|
4973
|
-
}, [c, n, i,
|
|
4975
|
+
!c && !n && i && (s != null && s.loadThread) && s.loadThread(i);
|
|
4976
|
+
}, [c, n, i, s == null ? void 0 : s.loadThread]);
|
|
4974
4977
|
const A = Z(() => {
|
|
4975
4978
|
var V;
|
|
4976
|
-
return ((V =
|
|
4977
|
-
}, [
|
|
4979
|
+
return ((V = h[0]) == null ? void 0 : V.values) || {};
|
|
4980
|
+
}, [h]), w = Z(() => ({ timeline: [], messagePreviews: {} }), []), k = t || i, b = c ? I ? "loading" : "idle" : (s == null ? void 0 : s.status) || "idle", T = c ? d : (a == null ? void 0 : a.messages) || [], y = c ? I : (s == null ? void 0 : s.isLoading) || !1, v = c ? x : (s == null ? void 0 : s.isLoadingHistory) || !1, _ = c ? A : (s == null ? void 0 : s.values) || {}, L = c ? {} : (s == null ? void 0 : s.taskMessagesByScope) || {}, M = c ? f : (a == null ? void 0 : a.error) || (s == null ? void 0 : s.error) || null;
|
|
4978
4981
|
return {
|
|
4979
4982
|
// UNIFIED: Single thread ID concept
|
|
4980
4983
|
threadId: k,
|
|
4981
|
-
status:
|
|
4984
|
+
status: b,
|
|
4982
4985
|
messages: T,
|
|
4983
4986
|
isLoading: y,
|
|
4984
|
-
isHistoryLoading:
|
|
4987
|
+
isHistoryLoading: v,
|
|
4985
4988
|
error: M,
|
|
4986
4989
|
// Values & Metadata
|
|
4987
|
-
values:
|
|
4990
|
+
values: _,
|
|
4988
4991
|
taskMessagesByScope: L,
|
|
4989
|
-
metadata: c ? {} :
|
|
4992
|
+
metadata: c ? {} : s == null ? void 0 : s.metadata,
|
|
4990
4993
|
// Actions & State relating to Global/Active Thread only
|
|
4991
4994
|
navigateToCheckpoint: c ? async () => {
|
|
4992
|
-
} : (
|
|
4995
|
+
} : (s == null ? void 0 : s.navigateToCheckpoint) || (async () => {
|
|
4993
4996
|
}),
|
|
4994
4997
|
returnToLatest: c ? async () => {
|
|
4995
|
-
} : (
|
|
4998
|
+
} : (s == null ? void 0 : s.returnToLatest) || (async () => {
|
|
4996
4999
|
}),
|
|
4997
|
-
checkpoint: c ?
|
|
4998
|
-
checkpoints: c ?
|
|
4999
|
-
checkpointIndex: c ? w : (
|
|
5000
|
-
interrupt: c ? null : (
|
|
5000
|
+
checkpoint: c ? h[0] ? { id: h[0].checkpointId, namespace: h[0].checkpointNs } : null : (s == null ? void 0 : s.checkpoint) || null,
|
|
5001
|
+
checkpoints: c ? h : (s == null ? void 0 : s.checkpoints) || [],
|
|
5002
|
+
checkpointIndex: c ? w : (s == null ? void 0 : s.checkpointIndex) || { timeline: [], messagePreviews: {} },
|
|
5003
|
+
interrupt: c ? null : (s == null ? void 0 : s.interrupt) || null,
|
|
5001
5004
|
respondToInterrupt: c ? async () => {
|
|
5002
|
-
} : (
|
|
5005
|
+
} : (s == null ? void 0 : s.respondToInterrupt) || (async () => {
|
|
5003
5006
|
}),
|
|
5004
5007
|
// Streaming Status
|
|
5005
5008
|
// Even in standalone mode, allow streaming state/stop if a stream context exists.
|
|
5006
5009
|
isStreaming: (a == null ? void 0 : a.isStreaming) || !1,
|
|
5007
|
-
activeMessageId: c ? null : (($ =
|
|
5010
|
+
activeMessageId: c ? null : (($ = s == null ? void 0 : s.metadata) == null ? void 0 : $.assemblingMessageId) || (a == null ? void 0 : a.activeMessageId) || null,
|
|
5008
5011
|
connectionState: (a == null ? void 0 : a.connectionState) || "disconnected",
|
|
5009
|
-
streamingAssistantId: !c && (a != null && a.isStreaming) && ((U =
|
|
5012
|
+
streamingAssistantId: !c && (a != null && a.isStreaming) && ((U = s == null ? void 0 : s.metadata) != null && U.assemblingMessageId) ? s.metadata.assemblingMessageId : null,
|
|
5010
5013
|
// Actions
|
|
5011
5014
|
submit: (a == null ? void 0 : a.submit) || (async () => {
|
|
5012
5015
|
}),
|
|
5013
5016
|
stop: (a == null ? void 0 : a.stop) || (() => {
|
|
5014
5017
|
}),
|
|
5015
5018
|
clearThread: c ? async () => {
|
|
5016
|
-
} : (
|
|
5019
|
+
} : (s == null ? void 0 : s.clearThread) || (async () => {
|
|
5017
5020
|
}),
|
|
5018
5021
|
setCurrentThreadId: u,
|
|
5019
5022
|
loadHistory: c ? async () => {
|
|
@@ -5021,54 +5024,54 @@ function Yr(e) {
|
|
|
5021
5024
|
} : async () => {
|
|
5022
5025
|
},
|
|
5023
5026
|
onEvent: c ? () => {
|
|
5024
|
-
} : (
|
|
5027
|
+
} : (s == null ? void 0 : s.onEvent) || (() => {
|
|
5025
5028
|
}),
|
|
5026
5029
|
// Thread Management
|
|
5027
5030
|
createThread: l == null ? void 0 : l.createThread,
|
|
5028
5031
|
deleteThread: l == null ? void 0 : l.deleteThread,
|
|
5029
5032
|
renameThread: l == null ? void 0 : l.renameThread,
|
|
5030
|
-
threads: (
|
|
5031
|
-
isThreadsLoading: (
|
|
5033
|
+
threads: (o == null ? void 0 : o.threads) || [],
|
|
5034
|
+
isThreadsLoading: (o == null ? void 0 : o.isLoading) || !1
|
|
5032
5035
|
};
|
|
5033
5036
|
}
|
|
5034
|
-
function
|
|
5037
|
+
function ys({
|
|
5035
5038
|
submit: e,
|
|
5036
5039
|
chatRequest: t,
|
|
5037
5040
|
lastCheckpointId: n,
|
|
5038
5041
|
lastCheckpointNs: r,
|
|
5039
|
-
onMessageSent:
|
|
5040
|
-
onExcelUploadSuccess:
|
|
5042
|
+
onMessageSent: o,
|
|
5043
|
+
onExcelUploadSuccess: s,
|
|
5041
5044
|
onError: a,
|
|
5042
5045
|
enableMessageEditing: i,
|
|
5043
5046
|
messages: u,
|
|
5044
5047
|
setPendingAssistantResponse: l,
|
|
5045
5048
|
project: c,
|
|
5046
5049
|
onEvent: d,
|
|
5047
|
-
threadId:
|
|
5048
|
-
clearComposerOnSend:
|
|
5050
|
+
threadId: m,
|
|
5051
|
+
clearComposerOnSend: p = !0
|
|
5049
5052
|
}) {
|
|
5050
|
-
const { messages:
|
|
5053
|
+
const { messages: I } = Yr(), [f, h] = H(null), [x, S] = H(""), [A, w] = H(null), [k, b] = H(null), [T, y] = H(!1), [v, _] = H(""), L = W(v), M = W(null);
|
|
5051
5054
|
Y(() => {
|
|
5052
5055
|
if (!f)
|
|
5053
|
-
if (
|
|
5054
|
-
const z = localStorage.getItem(Ge(
|
|
5055
|
-
|
|
5056
|
+
if (m) {
|
|
5057
|
+
const z = localStorage.getItem(Ge(m));
|
|
5058
|
+
_(z || "");
|
|
5056
5059
|
} else
|
|
5057
|
-
|
|
5058
|
-
}, [
|
|
5059
|
-
const $ =
|
|
5060
|
-
|
|
5061
|
-
}, [
|
|
5060
|
+
_("");
|
|
5061
|
+
}, [m, f]);
|
|
5062
|
+
const $ = N((z) => {
|
|
5063
|
+
_(z), !f && m && localStorage.setItem(Ge(m), z);
|
|
5064
|
+
}, [m, f]);
|
|
5062
5065
|
Y(() => {
|
|
5063
|
-
L.current =
|
|
5064
|
-
}, [
|
|
5066
|
+
L.current = v;
|
|
5067
|
+
}, [v]), Y(() => {
|
|
5065
5068
|
if (!f) {
|
|
5066
5069
|
M.current = null;
|
|
5067
5070
|
return;
|
|
5068
5071
|
}
|
|
5069
5072
|
M.current === null && (M.current = L.current), $(x ?? "");
|
|
5070
5073
|
}, [x, f, $]);
|
|
5071
|
-
const U =
|
|
5074
|
+
const U = N(
|
|
5072
5075
|
(z) => {
|
|
5073
5076
|
$(z);
|
|
5074
5077
|
},
|
|
@@ -5096,7 +5099,7 @@ function ho({
|
|
|
5096
5099
|
name: X.filename,
|
|
5097
5100
|
size: X.size
|
|
5098
5101
|
};
|
|
5099
|
-
}), J = [...K, ...ye],
|
|
5102
|
+
}), J = [...K, ...ye], oe = f ? (A == null ? void 0 : A.checkpointId) ?? n ?? void 0 : n ?? void 0, he = f ? (A == null ? void 0 : A.checkpointNs) ?? r ?? void 0 : r ?? void 0;
|
|
5100
5103
|
await e(
|
|
5101
5104
|
{
|
|
5102
5105
|
text: B || "",
|
|
@@ -5104,21 +5107,21 @@ function ho({
|
|
|
5104
5107
|
attachments: D,
|
|
5105
5108
|
payload: t.payload,
|
|
5106
5109
|
edit: !!f,
|
|
5107
|
-
checkpointId:
|
|
5110
|
+
checkpointId: oe,
|
|
5108
5111
|
checkpointNs: he,
|
|
5109
5112
|
project: c ?? void 0,
|
|
5110
5113
|
originalMessageId: f ?? void 0,
|
|
5111
5114
|
config: t.config
|
|
5112
5115
|
},
|
|
5113
5116
|
d ? { onEvent: d } : void 0
|
|
5114
|
-
),
|
|
5117
|
+
), o == null || o(B), l(!0), p && (m && localStorage.removeItem(Ge(m)), $("")), b(null), h(null), S(""), w(null);
|
|
5115
5118
|
} catch (ee) {
|
|
5116
5119
|
const ie = (ee == null ? void 0 : ee.message) || "Failed to send message";
|
|
5117
|
-
|
|
5120
|
+
b(ie), a == null || a(ie), l(!1);
|
|
5118
5121
|
}
|
|
5119
5122
|
}, P = (z, C) => {
|
|
5120
5123
|
C || V(z, { files: [] });
|
|
5121
|
-
}, F =
|
|
5124
|
+
}, F = N(
|
|
5122
5125
|
async (z) => {
|
|
5123
5126
|
await e(
|
|
5124
5127
|
{
|
|
@@ -5130,22 +5133,22 @@ function ho({
|
|
|
5130
5133
|
config: t.config
|
|
5131
5134
|
},
|
|
5132
5135
|
d ? { onEvent: d } : void 0
|
|
5133
|
-
),
|
|
5136
|
+
), s == null || s({ file: z });
|
|
5134
5137
|
},
|
|
5135
|
-
[n, r, t,
|
|
5136
|
-
),
|
|
5138
|
+
[n, r, t, s, e]
|
|
5139
|
+
), E = N(
|
|
5137
5140
|
(z, C, O) => {
|
|
5138
|
-
i && (M.current =
|
|
5141
|
+
i && (M.current = v, h(z), S(C), w({
|
|
5139
5142
|
checkpointId: (O == null ? void 0 : O.checkpointId) ?? null,
|
|
5140
5143
|
checkpointNs: (O == null ? void 0 : O.checkpointNs) ?? null
|
|
5141
|
-
}),
|
|
5144
|
+
}), b(null));
|
|
5142
5145
|
},
|
|
5143
|
-
[
|
|
5144
|
-
), j =
|
|
5145
|
-
|
|
5146
|
+
[v, i]
|
|
5147
|
+
), j = N(() => {
|
|
5148
|
+
h(null), S(""), w(null), b(null);
|
|
5146
5149
|
const z = M.current;
|
|
5147
|
-
z !== null &&
|
|
5148
|
-
}, []), G =
|
|
5150
|
+
z !== null && _(z), M.current = null;
|
|
5151
|
+
}, []), G = N((z) => {
|
|
5149
5152
|
let C = null;
|
|
5150
5153
|
for (let B = z - 1; B >= 0; B--)
|
|
5151
5154
|
if (u[B].role === "user") {
|
|
@@ -5177,21 +5180,21 @@ function ho({
|
|
|
5177
5180
|
editingMessageId: f,
|
|
5178
5181
|
editingInitialValue: x,
|
|
5179
5182
|
inputError: k,
|
|
5180
|
-
setInputError:
|
|
5183
|
+
setInputError: b,
|
|
5181
5184
|
dismissError: T,
|
|
5182
5185
|
setDismissError: y,
|
|
5183
|
-
composerValue:
|
|
5186
|
+
composerValue: v,
|
|
5184
5187
|
handleComposerChange: U,
|
|
5185
5188
|
handleSendMessage: V,
|
|
5186
5189
|
handleQuickPrompt: P,
|
|
5187
5190
|
handleExcelUpload: F,
|
|
5188
|
-
startEditing:
|
|
5191
|
+
startEditing: E,
|
|
5189
5192
|
cancelEditing: j,
|
|
5190
5193
|
handleRegenerateCb: G,
|
|
5191
|
-
displayMessages:
|
|
5194
|
+
displayMessages: I
|
|
5192
5195
|
};
|
|
5193
5196
|
}
|
|
5194
|
-
function
|
|
5197
|
+
function hs(e) {
|
|
5195
5198
|
return Z(() => e ? {
|
|
5196
5199
|
textContent: Ln(e),
|
|
5197
5200
|
imageParts: jn(e),
|
|
@@ -5206,12 +5209,12 @@ function bo(e) {
|
|
|
5206
5209
|
contentParts: []
|
|
5207
5210
|
}, [e]);
|
|
5208
5211
|
}
|
|
5209
|
-
function
|
|
5210
|
-
const [r,
|
|
5212
|
+
function bs(e, t, n) {
|
|
5213
|
+
const [r, o] = H(e), s = W(e), a = W(null);
|
|
5211
5214
|
return Y(() => {
|
|
5212
|
-
|
|
5215
|
+
s.current = e;
|
|
5213
5216
|
const i = () => {
|
|
5214
|
-
s
|
|
5217
|
+
o(s.current), a.current && (clearTimeout(a.current), a.current = null);
|
|
5215
5218
|
};
|
|
5216
5219
|
if (!t || n <= 0) {
|
|
5217
5220
|
i();
|
|
@@ -5225,26 +5228,26 @@ function wo(e, t, n) {
|
|
|
5225
5228
|
}, [e, t, n]), r;
|
|
5226
5229
|
}
|
|
5227
5230
|
export {
|
|
5228
|
-
|
|
5231
|
+
fs as ChatProviders,
|
|
5229
5232
|
jr as ThreadStateProvider,
|
|
5230
5233
|
mr as ThreadsProvider,
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
+
rs as cn,
|
|
5235
|
+
or as collectText,
|
|
5236
|
+
us as createTaskSyncToolEndHandler,
|
|
5234
5237
|
Kr as extractTaskIdFromToolEnd,
|
|
5235
5238
|
ar as extractToolMeta,
|
|
5236
|
-
|
|
5237
|
-
|
|
5239
|
+
ss as formatToolOutput,
|
|
5240
|
+
cs as getAgentNameFromMessage,
|
|
5238
5241
|
Pt as getChatToken,
|
|
5239
|
-
|
|
5240
|
-
|
|
5242
|
+
ds as getMessageAttemptInfo,
|
|
5243
|
+
as as getToolCallArtifacts,
|
|
5241
5244
|
Vn as getToolCalls,
|
|
5242
|
-
|
|
5245
|
+
os as hasContent,
|
|
5243
5246
|
mt as hydrateHistorySnapshots,
|
|
5244
5247
|
Ct as isFileLike,
|
|
5245
5248
|
Nn as looksLikeMarkdown,
|
|
5246
|
-
|
|
5247
|
-
|
|
5249
|
+
ls as messageSignature,
|
|
5250
|
+
is as normalizeInterruptId,
|
|
5248
5251
|
_t as onChatTokenChanged,
|
|
5249
5252
|
tt as parseJsonSafe,
|
|
5250
5253
|
Et as pretty,
|
|
@@ -5253,18 +5256,18 @@ export {
|
|
|
5253
5256
|
xe as setChatToken,
|
|
5254
5257
|
Fn as stringifyTool,
|
|
5255
5258
|
Me as useApi,
|
|
5256
|
-
|
|
5259
|
+
ys as useChatController,
|
|
5257
5260
|
Yr as useChatSession,
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
+
ps as useFilePreview,
|
|
5262
|
+
hs as useMessageContent,
|
|
5263
|
+
gs as useParsedMessageContent,
|
|
5261
5264
|
pr as useStream,
|
|
5262
|
-
|
|
5265
|
+
bs as useStreamingMarkdownBuffer,
|
|
5263
5266
|
$t as useThreadHistoryState,
|
|
5264
5267
|
Ht as useThreadState,
|
|
5265
5268
|
Lr as useThreadStateUpdater,
|
|
5266
|
-
|
|
5269
|
+
st as useThreads,
|
|
5267
5270
|
gr as useThreadsState,
|
|
5268
|
-
|
|
5271
|
+
ms as useToolPayload
|
|
5269
5272
|
};
|
|
5270
5273
|
//# sourceMappingURL=index.esm.js.map
|