@teodorruskvi/chat-core 0.1.36 → 0.1.37
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 +322 -322
- 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,7 +3,7 @@ var qt = (e, t, n) => t in e ? Wt(e, t, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var at = (e, t, n) => qt(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
4
|
import { jsx as ie } from "react/jsx-runtime";
|
|
5
5
|
import * as it from "react";
|
|
6
|
-
import { createContext as Se, useContext as Ue, useState as
|
|
6
|
+
import { createContext as Se, useContext as Ue, useState as B, useRef as H, useEffect as q, useCallback as z, useMemo as Q, useReducer as Jt } from "react";
|
|
7
7
|
import Xt, { isCancel as Qt } from "axios";
|
|
8
8
|
function It(e) {
|
|
9
9
|
var t, n, r = "";
|
|
@@ -247,7 +247,7 @@ const K = (e) => {
|
|
|
247
247
|
// I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough.
|
|
248
248
|
hn.test(e) && !yn.test(e)
|
|
249
249
|
), Ct = () => !1, Mn = (e) => bn.test(e), En = (e) => wn.test(e), Pn = () => {
|
|
250
|
-
const e = K("colors"), t = K("spacing"), n = K("blur"), r = K("brightness"), o = K("borderColor"), s = K("borderRadius"), a = K("borderSpacing"), i = K("borderWidth"), u = K("contrast"), c = K("grayscale"), l = K("hueRotate"), p = K("invert"), m = K("gap"), h = K("gradientColorStops"), v = K("gradientColorStopPositions"), f = K("inset"), w = K("margin"), k = K("opacity"), E = K("padding"), I = K("saturate"), N = K("scale"), P = K("sepia"),
|
|
250
|
+
const e = K("colors"), t = K("spacing"), n = K("blur"), r = K("brightness"), o = K("borderColor"), s = K("borderRadius"), a = K("borderSpacing"), i = K("borderWidth"), u = K("contrast"), c = K("grayscale"), l = K("hueRotate"), p = K("invert"), m = K("gap"), h = K("gradientColorStops"), v = K("gradientColorStopPositions"), f = K("inset"), w = K("margin"), k = K("opacity"), E = K("padding"), I = K("saturate"), N = K("scale"), P = K("sepia"), T = K("skew"), S = K("space"), g = K("translate"), b = () => ["auto", "contain", "none"], O = () => ["auto", "hidden", "clip", "visible", "scroll"], U = () => ["auto", j, t], C = () => [j, t], M = () => ["", fe, be], L = () => ["auto", xe, j], R = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], V = () => ["solid", "dashed", "dotted", "double", "none"], D = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], A = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], y = () => ["", "0", j], F = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], $ = () => [xe, j];
|
|
251
251
|
return {
|
|
252
252
|
cacheSize: 500,
|
|
253
253
|
separator: ":",
|
|
@@ -255,26 +255,26 @@ const K = (e) => {
|
|
|
255
255
|
colors: [_e],
|
|
256
256
|
spacing: [fe, be],
|
|
257
257
|
blur: ["none", "", we, j],
|
|
258
|
-
brightness:
|
|
258
|
+
brightness: $(),
|
|
259
259
|
borderColor: [e],
|
|
260
260
|
borderRadius: ["none", "", "full", we, j],
|
|
261
261
|
borderSpacing: C(),
|
|
262
262
|
borderWidth: M(),
|
|
263
|
-
contrast:
|
|
264
|
-
grayscale:
|
|
265
|
-
hueRotate:
|
|
266
|
-
invert:
|
|
263
|
+
contrast: $(),
|
|
264
|
+
grayscale: y(),
|
|
265
|
+
hueRotate: $(),
|
|
266
|
+
invert: y(),
|
|
267
267
|
gap: C(),
|
|
268
268
|
gradientColorStops: [e],
|
|
269
269
|
gradientColorStopPositions: [vn, be],
|
|
270
270
|
inset: U(),
|
|
271
271
|
margin: U(),
|
|
272
|
-
opacity:
|
|
272
|
+
opacity: $(),
|
|
273
273
|
padding: C(),
|
|
274
|
-
saturate:
|
|
275
|
-
scale:
|
|
276
|
-
sepia:
|
|
277
|
-
skew:
|
|
274
|
+
saturate: $(),
|
|
275
|
+
scale: $(),
|
|
276
|
+
sepia: y(),
|
|
277
|
+
skew: $(),
|
|
278
278
|
space: C(),
|
|
279
279
|
translate: C()
|
|
280
280
|
},
|
|
@@ -304,14 +304,14 @@ const K = (e) => {
|
|
|
304
304
|
* @see https://tailwindcss.com/docs/break-after
|
|
305
305
|
*/
|
|
306
306
|
"break-after": [{
|
|
307
|
-
"break-after":
|
|
307
|
+
"break-after": F()
|
|
308
308
|
}],
|
|
309
309
|
/**
|
|
310
310
|
* Break Before
|
|
311
311
|
* @see https://tailwindcss.com/docs/break-before
|
|
312
312
|
*/
|
|
313
313
|
"break-before": [{
|
|
314
|
-
"break-before":
|
|
314
|
+
"break-before": F()
|
|
315
315
|
}],
|
|
316
316
|
/**
|
|
317
317
|
* Break Inside
|
|
@@ -377,42 +377,42 @@ const K = (e) => {
|
|
|
377
377
|
* @see https://tailwindcss.com/docs/overflow
|
|
378
378
|
*/
|
|
379
379
|
overflow: [{
|
|
380
|
-
overflow:
|
|
380
|
+
overflow: O()
|
|
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": O()
|
|
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": O()
|
|
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: b()
|
|
402
402
|
}],
|
|
403
403
|
/**
|
|
404
404
|
* Overscroll Behavior X
|
|
405
405
|
* @see https://tailwindcss.com/docs/overscroll-behavior
|
|
406
406
|
*/
|
|
407
407
|
"overscroll-x": [{
|
|
408
|
-
"overscroll-x":
|
|
408
|
+
"overscroll-x": b()
|
|
409
409
|
}],
|
|
410
410
|
/**
|
|
411
411
|
* Overscroll Behavior Y
|
|
412
412
|
* @see https://tailwindcss.com/docs/overscroll-behavior
|
|
413
413
|
*/
|
|
414
414
|
"overscroll-y": [{
|
|
415
|
-
"overscroll-y":
|
|
415
|
+
"overscroll-y": b()
|
|
416
416
|
}],
|
|
417
417
|
/**
|
|
418
418
|
* Position
|
|
@@ -528,14 +528,14 @@ const K = (e) => {
|
|
|
528
528
|
* @see https://tailwindcss.com/docs/flex-grow
|
|
529
529
|
*/
|
|
530
530
|
grow: [{
|
|
531
|
-
grow:
|
|
531
|
+
grow: y()
|
|
532
532
|
}],
|
|
533
533
|
/**
|
|
534
534
|
* Flex Shrink
|
|
535
535
|
* @see https://tailwindcss.com/docs/flex-shrink
|
|
536
536
|
*/
|
|
537
537
|
shrink: [{
|
|
538
|
-
shrink:
|
|
538
|
+
shrink: y()
|
|
539
539
|
}],
|
|
540
540
|
/**
|
|
541
541
|
* Order
|
|
@@ -651,7 +651,7 @@ const K = (e) => {
|
|
|
651
651
|
* @see https://tailwindcss.com/docs/justify-content
|
|
652
652
|
*/
|
|
653
653
|
"justify-content": [{
|
|
654
|
-
justify: ["normal", ...
|
|
654
|
+
justify: ["normal", ...A()]
|
|
655
655
|
}],
|
|
656
656
|
/**
|
|
657
657
|
* Justify Items
|
|
@@ -672,7 +672,7 @@ const K = (e) => {
|
|
|
672
672
|
* @see https://tailwindcss.com/docs/align-content
|
|
673
673
|
*/
|
|
674
674
|
"align-content": [{
|
|
675
|
-
content: ["normal", ...
|
|
675
|
+
content: ["normal", ...A(), "baseline"]
|
|
676
676
|
}],
|
|
677
677
|
/**
|
|
678
678
|
* Align Items
|
|
@@ -693,7 +693,7 @@ const K = (e) => {
|
|
|
693
693
|
* @see https://tailwindcss.com/docs/place-content
|
|
694
694
|
*/
|
|
695
695
|
"place-content": [{
|
|
696
|
-
"place-content": [...
|
|
696
|
+
"place-content": [...A(), "baseline"]
|
|
697
697
|
}],
|
|
698
698
|
/**
|
|
699
699
|
* Place Items
|
|
@@ -1641,14 +1641,14 @@ const K = (e) => {
|
|
|
1641
1641
|
* @see https://tailwindcss.com/docs/mix-blend-mode
|
|
1642
1642
|
*/
|
|
1643
1643
|
"mix-blend": [{
|
|
1644
|
-
"mix-blend": [...
|
|
1644
|
+
"mix-blend": [...D(), "plus-lighter", "plus-darker"]
|
|
1645
1645
|
}],
|
|
1646
1646
|
/**
|
|
1647
1647
|
* Background Blend Mode
|
|
1648
1648
|
* @see https://tailwindcss.com/docs/background-blend-mode
|
|
1649
1649
|
*/
|
|
1650
1650
|
"bg-blend": [{
|
|
1651
|
-
"bg-blend":
|
|
1651
|
+
"bg-blend": D()
|
|
1652
1652
|
}],
|
|
1653
1653
|
// Filters
|
|
1654
1654
|
/**
|
|
@@ -1849,7 +1849,7 @@ const K = (e) => {
|
|
|
1849
1849
|
* @see https://tailwindcss.com/docs/transition-duration
|
|
1850
1850
|
*/
|
|
1851
1851
|
duration: [{
|
|
1852
|
-
duration:
|
|
1852
|
+
duration: $()
|
|
1853
1853
|
}],
|
|
1854
1854
|
/**
|
|
1855
1855
|
* Transition Timing Function
|
|
@@ -1863,7 +1863,7 @@ const K = (e) => {
|
|
|
1863
1863
|
* @see https://tailwindcss.com/docs/transition-delay
|
|
1864
1864
|
*/
|
|
1865
1865
|
delay: [{
|
|
1866
|
-
delay:
|
|
1866
|
+
delay: $()
|
|
1867
1867
|
}],
|
|
1868
1868
|
/**
|
|
1869
1869
|
* Animation
|
|
@@ -1927,14 +1927,14 @@ const K = (e) => {
|
|
|
1927
1927
|
* @see https://tailwindcss.com/docs/skew
|
|
1928
1928
|
*/
|
|
1929
1929
|
"skew-x": [{
|
|
1930
|
-
"skew-x": [
|
|
1930
|
+
"skew-x": [T]
|
|
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": [T]
|
|
1938
1938
|
}],
|
|
1939
1939
|
/**
|
|
1940
1940
|
* Transform Origin
|
|
@@ -2966,33 +2966,33 @@ function cr(e) {
|
|
|
2966
2966
|
return !!e && typeof e == "object" && "data" in e;
|
|
2967
2967
|
}
|
|
2968
2968
|
function lr(e = {}) {
|
|
2969
|
-
const t = e.baseUrl || "", n = e.streamPath ?? "/runs/stream", [r, o] =
|
|
2969
|
+
const t = e.baseUrl || "", n = e.streamPath ?? "/runs/stream", [r, o] = B(e.token ?? null), s = H(e.headers ?? {}), a = e.credentials ?? "include", i = H(e);
|
|
2970
2970
|
q(() => {
|
|
2971
2971
|
i.current = e;
|
|
2972
2972
|
}, [e]);
|
|
2973
2973
|
const u = z((g) => {
|
|
2974
|
-
var U, C, M, L, R, V,
|
|
2975
|
-
const
|
|
2976
|
-
if (!
|
|
2977
|
-
(U =
|
|
2978
|
-
}, []), [c, l] =
|
|
2974
|
+
var U, C, M, L, R, V, D, A, y, F;
|
|
2975
|
+
const b = i.current;
|
|
2976
|
+
if (!b) return;
|
|
2977
|
+
(U = b.onEvent) == null || U.call(b, g), g.type === "thread_info" && ((C = b.onThreadInfo) == null || C.call(b, g)), g.type === "values" && Array.isArray(g.checkpoints) && ((M = b.handleValuesEvent) == null || M.call(b, g)), g.type === "metadata" && ((L = b.onMetadataEvent) == null || L.call(b, g)), typeof g.type == "string" && (g.type === "custom" || g.type.startsWith("custom.")) && ((R = b.onCustomEvent) == null || R.call(b, g)), g.type === "updates" && ((V = b.onUpdateEvent) == null || V.call(b, g)), g.type === "tool.end" ? (D = b.onToolEnd) == null || D.call(b, g) : g.type === "tool.start" && ((A = b.onToolStart) == null || A.call(b, g)), g.type === "heartbeat" && ((y = b.onHeartbeat) == null || y.call(b, g)), g.type === "token" && ((F = b.onToken) == null || F.call(b, g.token));
|
|
2978
|
+
}, []), [c, l] = B(!1), [p, m] = B(null), [h, v] = B(!1), [f, w] = B(null), k = H(null), E = H(!0), I = H(null), N = z((g) => {
|
|
2979
2979
|
o(g);
|
|
2980
2980
|
}, []), P = z(() => {
|
|
2981
2981
|
m(null), w(null);
|
|
2982
|
-
}, []),
|
|
2982
|
+
}, []), T = z(() => {
|
|
2983
2983
|
var C, M;
|
|
2984
2984
|
console.debug("[use-chat] stop() invoked - aborting stream");
|
|
2985
|
-
const g = (C = I.current) == null ? void 0 : C.threadId,
|
|
2985
|
+
const g = (C = I.current) == null ? void 0 : C.threadId, b = (M = I.current) == null ? void 0 : M.runId, O = () => {
|
|
2986
2986
|
var L;
|
|
2987
2987
|
(L = k.current) == null || L.abort(), k.current = null, I.current = null, l(!1), v(!1);
|
|
2988
2988
|
};
|
|
2989
|
-
(
|
|
2989
|
+
(b || g ? zt.cancelRun(b || g).catch((L) => {
|
|
2990
2990
|
console.warn("[use-chat] cancel run failed:", L);
|
|
2991
|
-
}) : Promise.resolve()).finally(
|
|
2991
|
+
}) : Promise.resolve()).finally(O);
|
|
2992
2992
|
}, []), S = z(
|
|
2993
2993
|
(g) => {
|
|
2994
2994
|
k.current && (k.current.abort(), k.current = null);
|
|
2995
|
-
const
|
|
2995
|
+
const b = {
|
|
2996
2996
|
text: typeof g.content == "string" ? g.content : g.text,
|
|
2997
2997
|
threadId: g.threadId,
|
|
2998
2998
|
attachments: g.attachments,
|
|
@@ -3004,22 +3004,22 @@ function lr(e = {}) {
|
|
|
3004
3004
|
command: g.command
|
|
3005
3005
|
};
|
|
3006
3006
|
l(!0), m(null), w(null);
|
|
3007
|
-
const
|
|
3008
|
-
k.current =
|
|
3007
|
+
const O = new AbortController();
|
|
3008
|
+
k.current = O;
|
|
3009
3009
|
let U = null, C = !1;
|
|
3010
3010
|
return I.current = {
|
|
3011
|
-
threadId:
|
|
3011
|
+
threadId: b.threadId ?? void 0,
|
|
3012
3012
|
runId: void 0,
|
|
3013
3013
|
// Will be updated from headers
|
|
3014
3014
|
headers: {},
|
|
3015
3015
|
isStreaming: !0
|
|
3016
3016
|
}, (async () => {
|
|
3017
|
-
var M, L, R, V,
|
|
3017
|
+
var M, L, R, V, D, A;
|
|
3018
3018
|
try {
|
|
3019
|
-
let
|
|
3019
|
+
let y = {};
|
|
3020
3020
|
try {
|
|
3021
3021
|
if (r)
|
|
3022
|
-
|
|
3022
|
+
y = { Authorization: `Bearer ${r}` };
|
|
3023
3023
|
else if (typeof window < "u") {
|
|
3024
3024
|
const ee = window.__AUTH_TOKEN__, ve = ((M = window.localStorage) == null ? void 0 : M.getItem(Ne.authToken)) || null;
|
|
3025
3025
|
let X = null;
|
|
@@ -3029,51 +3029,51 @@ function lr(e = {}) {
|
|
|
3029
3029
|
} catch {
|
|
3030
3030
|
}
|
|
3031
3031
|
const Y = ee || ve || X || null;
|
|
3032
|
-
Y && (
|
|
3032
|
+
Y && (y = { Authorization: `Bearer ${Y}` });
|
|
3033
3033
|
}
|
|
3034
3034
|
} catch {
|
|
3035
3035
|
}
|
|
3036
3036
|
console.debug("[use-chat] POST", t + n);
|
|
3037
|
-
let
|
|
3037
|
+
let F = {};
|
|
3038
3038
|
if (typeof window < "u")
|
|
3039
3039
|
try {
|
|
3040
3040
|
const W = (V = window.localStorage) == null ? void 0 : V.getItem(Ne.authSessionId);
|
|
3041
|
-
W && (
|
|
3041
|
+
W && (F = { "X-Session-Id": W });
|
|
3042
3042
|
} catch {
|
|
3043
3043
|
}
|
|
3044
|
-
const
|
|
3045
|
-
...
|
|
3046
|
-
|
|
3044
|
+
const $ = {
|
|
3045
|
+
...y,
|
|
3046
|
+
...F,
|
|
3047
3047
|
...s.current
|
|
3048
3048
|
}, d = {
|
|
3049
3049
|
"Content-Type": "application/json",
|
|
3050
3050
|
Accept: "text/event-stream",
|
|
3051
|
-
|
|
3052
|
-
},
|
|
3051
|
+
...$
|
|
3052
|
+
}, x = await fetch(t + n, {
|
|
3053
3053
|
method: "POST",
|
|
3054
3054
|
headers: d,
|
|
3055
|
-
body: JSON.stringify(
|
|
3056
|
-
signal:
|
|
3055
|
+
body: JSON.stringify(b),
|
|
3056
|
+
signal: O.signal,
|
|
3057
3057
|
credentials: a
|
|
3058
3058
|
});
|
|
3059
|
-
if (I.current && (I.current.headers =
|
|
3060
|
-
const W = await
|
|
3059
|
+
if (I.current && (I.current.headers = $), !x.ok || !x.body) {
|
|
3060
|
+
const W = await x.text().catch(() => "");
|
|
3061
3061
|
console.debug(
|
|
3062
3062
|
"[use-chat] non-OK response",
|
|
3063
|
-
|
|
3063
|
+
x.status,
|
|
3064
3064
|
W == null ? void 0 : W.slice(0, 500)
|
|
3065
3065
|
);
|
|
3066
|
-
const ee = `stream ${
|
|
3066
|
+
const ee = `stream ${x.status}${W ? ": " + W : ""}`;
|
|
3067
3067
|
throw ee && (m(ee), U = "error"), new Error(ee);
|
|
3068
3068
|
}
|
|
3069
3069
|
v(!0);
|
|
3070
|
-
const _ =
|
|
3070
|
+
const _ = x.body.getReader(), te = new TextDecoder();
|
|
3071
3071
|
let J = "", G = 0, Z = Date.now();
|
|
3072
3072
|
const ae = setInterval(() => {
|
|
3073
|
-
Date.now() - Z > 18e5 && (m("Stream idle timeout"), U = "error",
|
|
3073
|
+
Date.now() - Z > 18e5 && (m("Stream idle timeout"), U = "error", O.abort());
|
|
3074
3074
|
}, 5e3), ue = 1024 * 1024;
|
|
3075
3075
|
try {
|
|
3076
|
-
const W =
|
|
3076
|
+
const W = x.headers.get("X-Thread-Id") || x.headers.get("x-thread-id"), ee = x.headers.get("X-Run-Id") || x.headers.get("x-run-id");
|
|
3077
3077
|
for (I.current && (I.current = {
|
|
3078
3078
|
...I.current,
|
|
3079
3079
|
threadId: W ?? I.current.threadId,
|
|
@@ -3131,7 +3131,7 @@ function lr(e = {}) {
|
|
|
3131
3131
|
u(Ee);
|
|
3132
3132
|
}
|
|
3133
3133
|
}
|
|
3134
|
-
U === null && !
|
|
3134
|
+
U === null && !O.signal.aborted && (U = "complete");
|
|
3135
3135
|
} catch (W) {
|
|
3136
3136
|
if (W.name === "AbortError")
|
|
3137
3137
|
U = U ?? "aborted";
|
|
@@ -3144,31 +3144,31 @@ function lr(e = {}) {
|
|
|
3144
3144
|
await _.cancel();
|
|
3145
3145
|
} catch {
|
|
3146
3146
|
} finally {
|
|
3147
|
-
(
|
|
3147
|
+
(D = _.releaseLock) == null || D.call(_);
|
|
3148
3148
|
}
|
|
3149
3149
|
clearInterval(ae);
|
|
3150
3150
|
}
|
|
3151
|
-
} catch (
|
|
3152
|
-
if (
|
|
3151
|
+
} catch (y) {
|
|
3152
|
+
if (y.name === "AbortError")
|
|
3153
3153
|
U = U ?? "aborted";
|
|
3154
3154
|
else {
|
|
3155
|
-
const
|
|
3156
|
-
U = "error", m(
|
|
3155
|
+
const F = y.message || String(y);
|
|
3156
|
+
U = "error", m(F), C || (C = !0, (A = e.onConnectionError) == null || A.call(e, F));
|
|
3157
3157
|
}
|
|
3158
3158
|
} finally {
|
|
3159
3159
|
try {
|
|
3160
3160
|
if (e.onFinish) {
|
|
3161
|
-
const
|
|
3161
|
+
const y = {
|
|
3162
3162
|
lastSeq: 0,
|
|
3163
3163
|
lastCheckpointId: null,
|
|
3164
3164
|
lastCheckpointNs: null,
|
|
3165
3165
|
lastValues: null
|
|
3166
3166
|
// Let the reducer/history hook provide the final values
|
|
3167
3167
|
};
|
|
3168
|
-
e.onFinish(
|
|
3168
|
+
e.onFinish(y);
|
|
3169
3169
|
}
|
|
3170
|
-
} catch (
|
|
3171
|
-
console.warn("[use-chat] onClosed callback failed",
|
|
3170
|
+
} catch (y) {
|
|
3171
|
+
console.warn("[use-chat] onClosed callback failed", y);
|
|
3172
3172
|
}
|
|
3173
3173
|
l(!1), v(!1), k.current = null, I.current = null;
|
|
3174
3174
|
}
|
|
@@ -3192,7 +3192,7 @@ function lr(e = {}) {
|
|
|
3192
3192
|
lastSeq: 0,
|
|
3193
3193
|
connected: h,
|
|
3194
3194
|
stream: S,
|
|
3195
|
-
stop:
|
|
3195
|
+
stop: T,
|
|
3196
3196
|
clear: P,
|
|
3197
3197
|
setToken: N,
|
|
3198
3198
|
values: {},
|
|
@@ -3256,31 +3256,31 @@ function fr({
|
|
|
3256
3256
|
onThreadChange: r,
|
|
3257
3257
|
onCurrentThreadDeleted: o
|
|
3258
3258
|
}) {
|
|
3259
|
-
const [s, a] =
|
|
3259
|
+
const [s, a] = B([]), [i, u] = B(t), [c, l] = B(!1), [p, m] = B(null), [h, v] = B([]), [f, w] = B(!1), [, k] = B(null), [E, I] = B(null), [N, P] = B(!1), T = H(i), S = H(/* @__PURE__ */ new Map());
|
|
3260
3260
|
q(() => {
|
|
3261
|
-
|
|
3261
|
+
T.current = i;
|
|
3262
3262
|
}, [i]), q(() => {
|
|
3263
|
-
t !== void 0 && t !==
|
|
3263
|
+
t !== void 0 && t !== T.current && u(t);
|
|
3264
3264
|
}, [t]);
|
|
3265
3265
|
const g = z(async () => {
|
|
3266
3266
|
l(!0), m(null);
|
|
3267
3267
|
try {
|
|
3268
|
-
const
|
|
3269
|
-
a(
|
|
3270
|
-
} catch (
|
|
3271
|
-
const
|
|
3272
|
-
m(
|
|
3268
|
+
const A = await e.listThreads();
|
|
3269
|
+
a(A ?? []);
|
|
3270
|
+
} catch (A) {
|
|
3271
|
+
const y = String(A);
|
|
3272
|
+
m(y), n == null || n(y);
|
|
3273
3273
|
} finally {
|
|
3274
3274
|
l(!1);
|
|
3275
3275
|
}
|
|
3276
|
-
}, [e, n]),
|
|
3276
|
+
}, [e, n]), b = z(async () => {
|
|
3277
3277
|
w(!0), k(null);
|
|
3278
3278
|
try {
|
|
3279
|
-
const
|
|
3280
|
-
v(
|
|
3281
|
-
} catch (
|
|
3282
|
-
const
|
|
3283
|
-
k(
|
|
3279
|
+
const A = await e.listSharedThreads();
|
|
3280
|
+
v(A ?? []);
|
|
3281
|
+
} catch (A) {
|
|
3282
|
+
const y = String(A);
|
|
3283
|
+
k(y), n == null || n(y);
|
|
3284
3284
|
} finally {
|
|
3285
3285
|
w(!1);
|
|
3286
3286
|
}
|
|
@@ -3288,107 +3288,107 @@ function fr({
|
|
|
3288
3288
|
q(() => {
|
|
3289
3289
|
g();
|
|
3290
3290
|
}, [g]), q(() => {
|
|
3291
|
-
|
|
3292
|
-
}, [
|
|
3291
|
+
b();
|
|
3292
|
+
}, [b]), q(() => {
|
|
3293
3293
|
r == null || r(i);
|
|
3294
3294
|
}, [i, r]);
|
|
3295
|
-
const
|
|
3296
|
-
async (
|
|
3295
|
+
const O = z(
|
|
3296
|
+
async (A, y) => {
|
|
3297
3297
|
try {
|
|
3298
|
-
const
|
|
3299
|
-
return u(
|
|
3300
|
-
} catch (
|
|
3301
|
-
const
|
|
3302
|
-
return n == null || n(
|
|
3298
|
+
const F = y && typeof y == "object" ? { id: y.id, name: y.name ?? "" } : void 0, $ = await e.createThread(A, F);
|
|
3299
|
+
return u($.threadId), await g(), $.threadId;
|
|
3300
|
+
} catch (F) {
|
|
3301
|
+
const $ = String(F);
|
|
3302
|
+
return n == null || n($), null;
|
|
3303
3303
|
}
|
|
3304
3304
|
},
|
|
3305
3305
|
[e, n, g]
|
|
3306
3306
|
), U = z(
|
|
3307
|
-
async (
|
|
3308
|
-
const
|
|
3309
|
-
a((
|
|
3310
|
-
const
|
|
3311
|
-
S.current.set(
|
|
3307
|
+
async (A) => {
|
|
3308
|
+
const y = s;
|
|
3309
|
+
a(($) => $.filter((d) => d.threadId !== A));
|
|
3310
|
+
const F = new AbortController();
|
|
3311
|
+
S.current.set(A, F);
|
|
3312
3312
|
try {
|
|
3313
|
-
await e.deleteThread(
|
|
3314
|
-
} catch (
|
|
3315
|
-
a(
|
|
3316
|
-
const d = String(
|
|
3313
|
+
await e.deleteThread(A), T.current === A && (u(null), o == null || o());
|
|
3314
|
+
} catch ($) {
|
|
3315
|
+
a(y);
|
|
3316
|
+
const d = String($);
|
|
3317
3317
|
n == null || n(d);
|
|
3318
3318
|
} finally {
|
|
3319
|
-
S.current.delete(
|
|
3319
|
+
S.current.delete(A);
|
|
3320
3320
|
}
|
|
3321
3321
|
},
|
|
3322
3322
|
[e, o, n, s]
|
|
3323
3323
|
), C = z(
|
|
3324
|
-
async (
|
|
3324
|
+
async (A, y) => {
|
|
3325
3325
|
try {
|
|
3326
|
-
await e.updateThread(
|
|
3327
|
-
} catch (
|
|
3328
|
-
n == null || n(String(
|
|
3326
|
+
await e.updateThread(A, y), await g();
|
|
3327
|
+
} catch (F) {
|
|
3328
|
+
n == null || n(String(F));
|
|
3329
3329
|
}
|
|
3330
3330
|
},
|
|
3331
3331
|
[e, n, g]
|
|
3332
3332
|
), M = z(
|
|
3333
|
-
async (
|
|
3333
|
+
async (A, y) => {
|
|
3334
3334
|
P(!0), I("Sharing thread…");
|
|
3335
3335
|
try {
|
|
3336
|
-
await e.shareThread(
|
|
3337
|
-
} catch (
|
|
3338
|
-
const
|
|
3339
|
-
throw n == null || n(
|
|
3336
|
+
await e.shareThread(A, y), await b(), I("Shared successfully");
|
|
3337
|
+
} catch (F) {
|
|
3338
|
+
const $ = dr(F);
|
|
3339
|
+
throw n == null || n($), I(`Failed to share: ${$}`), new Error($);
|
|
3340
3340
|
} finally {
|
|
3341
3341
|
P(!1);
|
|
3342
3342
|
}
|
|
3343
3343
|
},
|
|
3344
|
-
[e, n,
|
|
3344
|
+
[e, n, b]
|
|
3345
3345
|
), L = z(
|
|
3346
|
-
async (
|
|
3346
|
+
async (A, y) => {
|
|
3347
3347
|
try {
|
|
3348
|
-
await e.unshareThread(
|
|
3349
|
-
} catch (
|
|
3350
|
-
const
|
|
3351
|
-
throw n == null || n(
|
|
3348
|
+
await e.unshareThread(A, y), await b();
|
|
3349
|
+
} catch (F) {
|
|
3350
|
+
const $ = String(F);
|
|
3351
|
+
throw n == null || n($), F;
|
|
3352
3352
|
}
|
|
3353
3353
|
},
|
|
3354
|
-
[e, n,
|
|
3354
|
+
[e, n, b]
|
|
3355
3355
|
), R = Q(
|
|
3356
3356
|
() => ({
|
|
3357
|
-
createThread:
|
|
3357
|
+
createThread: O,
|
|
3358
3358
|
deleteThread: U,
|
|
3359
3359
|
renameThread: C,
|
|
3360
3360
|
refreshThreads: g,
|
|
3361
|
-
refreshSharedThreads:
|
|
3361
|
+
refreshSharedThreads: b,
|
|
3362
3362
|
shareThread: M,
|
|
3363
3363
|
unshareThread: L
|
|
3364
3364
|
}),
|
|
3365
|
-
[
|
|
3366
|
-
), V = z((
|
|
3367
|
-
if (!(
|
|
3368
|
-
const
|
|
3369
|
-
threadId:
|
|
3370
|
-
title:
|
|
3371
|
-
project:
|
|
3372
|
-
createdAt:
|
|
3373
|
-
updatedAt:
|
|
3374
|
-
messageCount:
|
|
3365
|
+
[O, U, C, g, b, M, L]
|
|
3366
|
+
), V = z((A) => {
|
|
3367
|
+
if (!(A != null && A.threadId)) return;
|
|
3368
|
+
const y = {
|
|
3369
|
+
threadId: A.threadId,
|
|
3370
|
+
title: A.title || `Thread ${A.threadId.slice(0, 8)}`,
|
|
3371
|
+
project: A.project,
|
|
3372
|
+
createdAt: A.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
3373
|
+
updatedAt: A.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
3374
|
+
messageCount: A.messageCount ?? 1
|
|
3375
3375
|
};
|
|
3376
|
-
a((
|
|
3377
|
-
let
|
|
3378
|
-
const d =
|
|
3379
|
-
...
|
|
3380
|
-
title:
|
|
3381
|
-
project:
|
|
3382
|
-
updatedAt:
|
|
3383
|
-
messageCount:
|
|
3384
|
-
}) :
|
|
3385
|
-
return
|
|
3376
|
+
a((F) => {
|
|
3377
|
+
let $ = !1;
|
|
3378
|
+
const d = F.map((x) => x.threadId === y.threadId ? ($ = !0, console.debug("[useThreadsState] thread_info: updating existing thread", y.threadId), {
|
|
3379
|
+
...x,
|
|
3380
|
+
title: y.title ?? x.title,
|
|
3381
|
+
project: y.project ?? x.project,
|
|
3382
|
+
updatedAt: y.updatedAt ?? x.updatedAt,
|
|
3383
|
+
messageCount: y.messageCount ?? x.messageCount
|
|
3384
|
+
}) : x);
|
|
3385
|
+
return $ ? d : (console.debug("[useThreadsState] thread_info: adding thread to list", y.threadId), [y, ...F]);
|
|
3386
3386
|
});
|
|
3387
|
-
}, []),
|
|
3387
|
+
}, []), D = z(() => I(null), []);
|
|
3388
3388
|
return {
|
|
3389
3389
|
threads: s,
|
|
3390
3390
|
currentThreadId: i,
|
|
3391
|
-
currentThreadIdRef:
|
|
3391
|
+
currentThreadIdRef: T,
|
|
3392
3392
|
setCurrentThreadId: u,
|
|
3393
3393
|
isLoadingThreads: c,
|
|
3394
3394
|
threadsError: p,
|
|
@@ -3398,7 +3398,7 @@ function fr({
|
|
|
3398
3398
|
addThreadFromEvent: V,
|
|
3399
3399
|
shareInFlight: N,
|
|
3400
3400
|
shareStatus: E,
|
|
3401
|
-
clearShareStatus:
|
|
3401
|
+
clearShareStatus: D
|
|
3402
3402
|
};
|
|
3403
3403
|
}
|
|
3404
3404
|
const Ft = Se(null);
|
|
@@ -3830,9 +3830,9 @@ function ht(e) {
|
|
|
3830
3830
|
};
|
|
3831
3831
|
}
|
|
3832
3832
|
function Sr(e, t) {
|
|
3833
|
-
var P,
|
|
3833
|
+
var P, T;
|
|
3834
3834
|
if (!e) return null;
|
|
3835
|
-
const n = ((P = e.values) == null ? void 0 : P.activeAgent) ?? null, r = (
|
|
3835
|
+
const n = ((P = e.values) == null ? void 0 : P.activeAgent) ?? null, r = (T = e.values) == null ? void 0 : T.messages, s = (Array.isArray(r) ? r : []).map((S) => Cr(S, n)).filter((S) => !!S), a = Re(e.metadata) ?? {}, i = mt(e.config), u = Re(e.parentConfig), c = mt(u), l = Fe(i, ["checkpointId"]), p = Fe(i, ["checkpointNs"]), m = Fe(c, ["checkpointId"]), h = Re(e.config), v = Array.isArray(e.tasks) ? e.tasks.map((S) => ({ ...S })) : e.tasks ?? null, f = Array.isArray(e.next) ? [...e.next] : e.next ?? null, w = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), k = {
|
|
3836
3836
|
...a,
|
|
3837
3837
|
step: xr(a, ["step"]) ?? 0,
|
|
3838
3838
|
source: Fe(a, ["source"]) ?? null
|
|
@@ -3904,8 +3904,8 @@ function _r(e) {
|
|
|
3904
3904
|
const l = e[c], p = l.checkpointId, m = p ?? `cp-${c}`, h = l.metadata ?? {}, v = typeof h.step == "number" ? h.step : null, f = typeof h.source == "string" ? h.source : null;
|
|
3905
3905
|
let w = null, k = null;
|
|
3906
3906
|
const E = Array.isArray(l.messages) ? l.messages : [];
|
|
3907
|
-
for (const
|
|
3908
|
-
|
|
3907
|
+
for (const T of E)
|
|
3908
|
+
T.role === "user" && (k || (k = T), T.id && (w = T.id));
|
|
3909
3909
|
const I = l.next && l.next.length > 0 ? String(l.next[0]) : null, N = l.parentConfig ?? null, P = {
|
|
3910
3910
|
id: m,
|
|
3911
3911
|
step: v,
|
|
@@ -3918,8 +3918,8 @@ function _r(e) {
|
|
|
3918
3918
|
userMessageId: w
|
|
3919
3919
|
};
|
|
3920
3920
|
if (o.push(P), p && t.set(p, P), p && k) {
|
|
3921
|
-
const
|
|
3922
|
-
|
|
3921
|
+
const T = Pr(k);
|
|
3922
|
+
T && r.set(p, T);
|
|
3923
3923
|
}
|
|
3924
3924
|
n.push({
|
|
3925
3925
|
id: m,
|
|
@@ -4001,10 +4001,10 @@ function Dt({
|
|
|
4001
4001
|
isStreaming: a,
|
|
4002
4002
|
getMessages: i
|
|
4003
4003
|
}) {
|
|
4004
|
-
const [u, c] =
|
|
4004
|
+
const [u, c] = B(null), p = Q(
|
|
4005
4005
|
() => ht(u),
|
|
4006
4006
|
[u]
|
|
4007
|
-
).checkpoints, m = Nr(p), h = m.timeline, [v, f] =
|
|
4007
|
+
).checkpoints, m = Nr(p), h = m.timeline, [v, f] = B(!1), [w, k] = B(!1), [E, I] = B(null), N = H(o), P = H(null), T = H(null);
|
|
4008
4008
|
q(() => {
|
|
4009
4009
|
N.current = o;
|
|
4010
4010
|
}, [o]);
|
|
@@ -4018,48 +4018,48 @@ function Dt({
|
|
|
4018
4018
|
version: "values@1",
|
|
4019
4019
|
threadId: M.threadId,
|
|
4020
4020
|
checkpoints: [L]
|
|
4021
|
-
}, V = t ? await Ar(R, t) : R, { latest:
|
|
4022
|
-
return
|
|
4021
|
+
}, V = t ? await Ar(R, t) : R, { latest: D } = ht(V);
|
|
4022
|
+
return D;
|
|
4023
4023
|
},
|
|
4024
4024
|
[e, t]
|
|
4025
4025
|
), g = z(
|
|
4026
4026
|
async (M, L) => {
|
|
4027
|
-
var
|
|
4027
|
+
var A;
|
|
4028
4028
|
if (!M) return;
|
|
4029
|
-
const R = `${M}:${L ?? "latest"}
|
|
4030
|
-
if (P.current === R && !v) return;
|
|
4031
|
-
(
|
|
4032
|
-
const
|
|
4033
|
-
|
|
4029
|
+
const R = `${M}:${L ?? "latest"}`, V = i();
|
|
4030
|
+
if (P.current === R && !v && V.length > 0) return;
|
|
4031
|
+
(A = T.current) == null || A.abort();
|
|
4032
|
+
const D = new AbortController();
|
|
4033
|
+
T.current = D, f(!0), I(null);
|
|
4034
4034
|
try {
|
|
4035
|
-
const
|
|
4035
|
+
const y = await S({
|
|
4036
4036
|
threadId: M,
|
|
4037
4037
|
checkpointId: L ?? void 0
|
|
4038
4038
|
});
|
|
4039
4039
|
if (N.current !== M) return;
|
|
4040
|
-
n((
|
|
4041
|
-
checkpointId: (
|
|
4042
|
-
checkpointNs: (
|
|
4043
|
-
pendingInterrupt: (
|
|
4044
|
-
values:
|
|
4040
|
+
n((y == null ? void 0 : y.messages) ?? [], {
|
|
4041
|
+
checkpointId: (y == null ? void 0 : y.checkpointId) ?? null,
|
|
4042
|
+
checkpointNs: (y == null ? void 0 : y.checkpointNs) ?? null,
|
|
4043
|
+
pendingInterrupt: (y == null ? void 0 : y.interrupt) ?? null,
|
|
4044
|
+
values: y == null ? void 0 : y.values
|
|
4045
4045
|
}), P.current = R;
|
|
4046
|
-
const
|
|
4046
|
+
const F = await e.getStateHistory({
|
|
4047
4047
|
threadId: M,
|
|
4048
4048
|
limit: 100,
|
|
4049
4049
|
includeMessages: !1
|
|
4050
4050
|
});
|
|
4051
|
-
N.current === M && c(
|
|
4052
|
-
} catch (
|
|
4053
|
-
if (!Qt(
|
|
4054
|
-
const
|
|
4055
|
-
I(
|
|
4051
|
+
N.current === M && c(F);
|
|
4052
|
+
} catch (y) {
|
|
4053
|
+
if (!Qt(y)) {
|
|
4054
|
+
const F = String(y);
|
|
4055
|
+
I(F), r == null || r(F);
|
|
4056
4056
|
}
|
|
4057
4057
|
} finally {
|
|
4058
4058
|
f(!1);
|
|
4059
4059
|
}
|
|
4060
4060
|
},
|
|
4061
|
-
[e, n, S, r, v]
|
|
4062
|
-
),
|
|
4061
|
+
[e, n, S, r, v, i]
|
|
4062
|
+
), b = z(
|
|
4063
4063
|
async (M, L) => {
|
|
4064
4064
|
if (o) {
|
|
4065
4065
|
k(!0);
|
|
@@ -4083,7 +4083,7 @@ function Dt({
|
|
|
4083
4083
|
}
|
|
4084
4084
|
},
|
|
4085
4085
|
[o, S, n]
|
|
4086
|
-
),
|
|
4086
|
+
), O = z(async () => {
|
|
4087
4087
|
o && await g(o);
|
|
4088
4088
|
}, [o, g]), U = z(
|
|
4089
4089
|
async (M) => {
|
|
@@ -4091,14 +4091,14 @@ function Dt({
|
|
|
4091
4091
|
const L = (M == null ? void 0 : M.threadId) || o;
|
|
4092
4092
|
if (!L || o !== L) return;
|
|
4093
4093
|
if (c(M), P.current = `${L}:latest`, (V = M.values) != null && V.messages) {
|
|
4094
|
-
const
|
|
4094
|
+
const D = await S({
|
|
4095
4095
|
threadId: L
|
|
4096
4096
|
});
|
|
4097
|
-
|
|
4098
|
-
checkpointId:
|
|
4099
|
-
checkpointNs:
|
|
4100
|
-
pendingInterrupt:
|
|
4101
|
-
values:
|
|
4097
|
+
D && n(D.messages ?? [], {
|
|
4098
|
+
checkpointId: D.checkpointId ?? null,
|
|
4099
|
+
checkpointNs: D.checkpointNs ?? null,
|
|
4100
|
+
pendingInterrupt: D.interrupt ?? null,
|
|
4101
|
+
values: D.values
|
|
4102
4102
|
});
|
|
4103
4103
|
}
|
|
4104
4104
|
},
|
|
@@ -4120,11 +4120,11 @@ function Dt({
|
|
|
4120
4120
|
isLoadingCheckpoint: w,
|
|
4121
4121
|
threadStateError: E,
|
|
4122
4122
|
loadThread: g,
|
|
4123
|
-
navigateToCheckpoint:
|
|
4123
|
+
navigateToCheckpoint: b,
|
|
4124
4124
|
setCurrentCheckpointId: (M, L) => {
|
|
4125
4125
|
n(i(), { checkpointId: M, checkpointNs: L });
|
|
4126
4126
|
},
|
|
4127
|
-
returnToLatest:
|
|
4127
|
+
returnToLatest: O,
|
|
4128
4128
|
handleValuesEvent: U,
|
|
4129
4129
|
markSkipNextLoad: () => {
|
|
4130
4130
|
},
|
|
@@ -4164,11 +4164,11 @@ function zr({
|
|
|
4164
4164
|
threadStateError: I,
|
|
4165
4165
|
loadThread: N,
|
|
4166
4166
|
navigateToCheckpoint: P,
|
|
4167
|
-
setCurrentCheckpointId:
|
|
4167
|
+
setCurrentCheckpointId: T,
|
|
4168
4168
|
returnToLatest: S,
|
|
4169
4169
|
handleValuesEvent: g,
|
|
4170
|
-
markSkipNextLoad:
|
|
4171
|
-
markStreamPendingThread:
|
|
4170
|
+
markSkipNextLoad: b,
|
|
4171
|
+
markStreamPendingThread: O,
|
|
4172
4172
|
resetHistoryState: U
|
|
4173
4173
|
} = Dt({
|
|
4174
4174
|
api: i,
|
|
@@ -4182,11 +4182,7 @@ function zr({
|
|
|
4182
4182
|
autoLoadInitial: o,
|
|
4183
4183
|
isStreaming: s,
|
|
4184
4184
|
getMessages: z(() => l.messages, [l.messages])
|
|
4185
|
-
})
|
|
4186
|
-
q(() => {
|
|
4187
|
-
c || (p([], {}), U());
|
|
4188
|
-
}, [c, p, U]);
|
|
4189
|
-
const C = H(null), M = z(
|
|
4185
|
+
}), C = H(null), M = z(
|
|
4190
4186
|
(d) => {
|
|
4191
4187
|
C.current = d;
|
|
4192
4188
|
},
|
|
@@ -4196,21 +4192,21 @@ function zr({
|
|
|
4196
4192
|
L.current = d;
|
|
4197
4193
|
},
|
|
4198
4194
|
[]
|
|
4199
|
-
), V = Q(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]),
|
|
4200
|
-
(d,
|
|
4195
|
+
), V = Q(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), D = z(
|
|
4196
|
+
(d, x) => {
|
|
4201
4197
|
const _ = jt(d, "user");
|
|
4202
4198
|
return h({
|
|
4203
4199
|
type: "user_message",
|
|
4204
4200
|
payload: {
|
|
4205
4201
|
message: _,
|
|
4206
|
-
editingMessageId:
|
|
4202
|
+
editingMessageId: x == null ? void 0 : x.editingMessageId
|
|
4207
4203
|
}
|
|
4208
4204
|
}), _;
|
|
4209
4205
|
},
|
|
4210
4206
|
[h]
|
|
4211
|
-
),
|
|
4207
|
+
), A = z(async () => {
|
|
4212
4208
|
C.current ? await C.current() : (p([], {}), U());
|
|
4213
|
-
}, [p, U]),
|
|
4209
|
+
}, [p, U]), y = Q(() => On(l.messages), [l.messages]), F = Q(
|
|
4214
4210
|
() => ({
|
|
4215
4211
|
status: l.status,
|
|
4216
4212
|
threadId: c,
|
|
@@ -4240,25 +4236,25 @@ function zr({
|
|
|
4240
4236
|
values: d.values
|
|
4241
4237
|
});
|
|
4242
4238
|
},
|
|
4243
|
-
clearState:
|
|
4239
|
+
clearState: A,
|
|
4244
4240
|
navigateToCheckpoint: P,
|
|
4245
|
-
setCurrentCheckpointId:
|
|
4241
|
+
setCurrentCheckpointId: T,
|
|
4246
4242
|
returnToLatest: S,
|
|
4247
|
-
loadThread: async (d,
|
|
4248
|
-
await N(d,
|
|
4243
|
+
loadThread: async (d, x, _) => {
|
|
4244
|
+
await N(d, x, { clearProgress: !1 });
|
|
4249
4245
|
},
|
|
4250
|
-
clearThread:
|
|
4251
|
-
respondToInterrupt: async (d,
|
|
4252
|
-
L.current && await L.current(d,
|
|
4246
|
+
clearThread: A,
|
|
4247
|
+
respondToInterrupt: async (d, x, _) => {
|
|
4248
|
+
L.current && await L.current(d, x, _);
|
|
4253
4249
|
},
|
|
4254
4250
|
messagePreviews: w.messagePreviews,
|
|
4255
4251
|
handleValuesEvent: g,
|
|
4256
|
-
markSkipNextLoad:
|
|
4257
|
-
markStreamPendingThread:
|
|
4252
|
+
markSkipNextLoad: b,
|
|
4253
|
+
markStreamPendingThread: O,
|
|
4258
4254
|
resetHistoryState: U,
|
|
4259
|
-
pushUser:
|
|
4255
|
+
pushUser: D,
|
|
4260
4256
|
onEvent: m,
|
|
4261
|
-
artifacts:
|
|
4257
|
+
artifacts: y
|
|
4262
4258
|
}),
|
|
4263
4259
|
[
|
|
4264
4260
|
c,
|
|
@@ -4276,26 +4272,26 @@ function zr({
|
|
|
4276
4272
|
E,
|
|
4277
4273
|
I,
|
|
4278
4274
|
p,
|
|
4279
|
-
|
|
4275
|
+
A,
|
|
4280
4276
|
P,
|
|
4281
|
-
|
|
4277
|
+
T,
|
|
4282
4278
|
S,
|
|
4283
4279
|
N,
|
|
4284
4280
|
g,
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4281
|
+
b,
|
|
4282
|
+
O,
|
|
4283
|
+
D,
|
|
4288
4284
|
m,
|
|
4289
|
-
|
|
4285
|
+
y
|
|
4290
4286
|
]
|
|
4291
|
-
),
|
|
4287
|
+
), $ = Q(
|
|
4292
4288
|
() => ({
|
|
4293
4289
|
registerClearThread: M,
|
|
4294
4290
|
registerRespondToInterrupt: R
|
|
4295
4291
|
}),
|
|
4296
4292
|
[M, R]
|
|
4297
4293
|
);
|
|
4298
|
-
return /* @__PURE__ */ ie(Kt.Provider, { value:
|
|
4294
|
+
return /* @__PURE__ */ ie(Kt.Provider, { value: $, children: /* @__PURE__ */ ie(Vt.Provider, { value: F, children: e }) });
|
|
4299
4295
|
}
|
|
4300
4296
|
const Ht = Se(null), Ur = Se(!1);
|
|
4301
4297
|
function Lr({
|
|
@@ -4310,7 +4306,7 @@ function Lr({
|
|
|
4310
4306
|
onFinish: u,
|
|
4311
4307
|
onStreamingChange: c
|
|
4312
4308
|
}) {
|
|
4313
|
-
const { chatApi: l, baseUrl: p } = Ae(), m = p, h = pe(t), v = pe(n), f = pe(r), w = pe(o), k = pe(s), E = pe(a), I = pe(i), N = pe(u), P = pe(c),
|
|
4309
|
+
const { chatApi: l, baseUrl: p } = Ae(), m = p, h = pe(t), v = pe(n), f = pe(r), w = pe(o), k = pe(s), E = pe(a), I = pe(i), N = pe(u), P = pe(c), T = Q(
|
|
4314
4310
|
() => ({
|
|
4315
4311
|
onError: h,
|
|
4316
4312
|
onAuthError: v,
|
|
@@ -4337,7 +4333,7 @@ function Lr({
|
|
|
4337
4333
|
{
|
|
4338
4334
|
api: l,
|
|
4339
4335
|
streamBaseUrl: m,
|
|
4340
|
-
handlers:
|
|
4336
|
+
handlers: T,
|
|
4341
4337
|
onStreamingChange: P,
|
|
4342
4338
|
children: e
|
|
4343
4339
|
}
|
|
@@ -4366,12 +4362,12 @@ function jr({
|
|
|
4366
4362
|
i(d), v(d.threadId), a.current !== d.threadId && ((d.created ?? !a.current) && h(d.threadId), s(d.threadId));
|
|
4367
4363
|
},
|
|
4368
4364
|
[i, h, v, s, a]
|
|
4369
|
-
),
|
|
4365
|
+
), T = lr({
|
|
4370
4366
|
baseUrl: n,
|
|
4371
4367
|
onEvent: k,
|
|
4372
4368
|
onError: (d) => {
|
|
4373
|
-
var
|
|
4374
|
-
(
|
|
4369
|
+
var x;
|
|
4370
|
+
(x = r.onError) == null || x.call(r, (d == null ? void 0 : d.message) ?? String(d));
|
|
4375
4371
|
},
|
|
4376
4372
|
onAuthError: r.onAuthError,
|
|
4377
4373
|
onConnectionError: r.onConnectionError,
|
|
@@ -4384,27 +4380,27 @@ function jr({
|
|
|
4384
4380
|
handleValuesEvent: m
|
|
4385
4381
|
});
|
|
4386
4382
|
q(() => {
|
|
4387
|
-
o == null || o(
|
|
4388
|
-
}, [
|
|
4389
|
-
const { stream: S, stop: g, clear:
|
|
4383
|
+
o == null || o(T.isStreaming);
|
|
4384
|
+
}, [T.isStreaming, o]);
|
|
4385
|
+
const { stream: S, stop: g, clear: b, isStreaming: O, error: U, connected: C, streamedMessages: M, activeMessageId: L } = T;
|
|
4390
4386
|
q(() => {
|
|
4391
|
-
u !== void 0 &&
|
|
4392
|
-
}, [u,
|
|
4387
|
+
u !== void 0 && b();
|
|
4388
|
+
}, [u, b]);
|
|
4393
4389
|
const R = z(
|
|
4394
|
-
async (d,
|
|
4395
|
-
await S(d,
|
|
4390
|
+
async (d, x) => {
|
|
4391
|
+
await S(d, x);
|
|
4396
4392
|
},
|
|
4397
4393
|
[S]
|
|
4398
4394
|
), V = H(l);
|
|
4399
4395
|
q(() => {
|
|
4400
4396
|
V.current = l;
|
|
4401
4397
|
}, [l]);
|
|
4402
|
-
const
|
|
4403
|
-
async (d,
|
|
4398
|
+
const D = z(
|
|
4399
|
+
async (d, x, _) => {
|
|
4404
4400
|
const te = a.current;
|
|
4405
4401
|
if (!te)
|
|
4406
4402
|
throw new Error("No active thread to handle interrupt");
|
|
4407
|
-
const J = d ?
|
|
4403
|
+
const J = d ? x ?? !0 : !1, G = V.current, Z = (_ == null ? void 0 : _.checkpointId) ?? G.id ?? void 0, ae = (_ == null ? void 0 : _.checkpointNs) ?? G.namespace ?? void 0, ue = {
|
|
4408
4404
|
threadId: te,
|
|
4409
4405
|
checkpointId: Z,
|
|
4410
4406
|
checkpointNs: ae,
|
|
@@ -4416,17 +4412,17 @@ function jr({
|
|
|
4416
4412
|
[a, R]
|
|
4417
4413
|
);
|
|
4418
4414
|
q(() => {
|
|
4419
|
-
N(
|
|
4420
|
-
}, [
|
|
4421
|
-
const
|
|
4422
|
-
g(),
|
|
4423
|
-
}, [
|
|
4415
|
+
N(D);
|
|
4416
|
+
}, [D, N]);
|
|
4417
|
+
const A = z(async () => {
|
|
4418
|
+
g(), b(), f(), s(null);
|
|
4419
|
+
}, [b, f, s, g]);
|
|
4424
4420
|
q(() => {
|
|
4425
|
-
I(
|
|
4426
|
-
}, [
|
|
4427
|
-
const
|
|
4428
|
-
async (d,
|
|
4429
|
-
|
|
4421
|
+
I(A);
|
|
4422
|
+
}, [A, I]);
|
|
4423
|
+
const y = z(
|
|
4424
|
+
async (d, x) => {
|
|
4425
|
+
O && g();
|
|
4430
4426
|
let _ = a.current;
|
|
4431
4427
|
const te = (d == null ? void 0 : d.text) ?? "", J = (d == null ? void 0 : d.attachments) ?? [], G = (te == null ? void 0 : te.trim()) ?? "", Z = { ...(d == null ? void 0 : d.payload) ?? {} }, ae = Array.isArray(Z.messages) ? Z.messages : void 0;
|
|
4432
4428
|
ae && delete Z.messages;
|
|
@@ -4470,36 +4466,36 @@ function jr({
|
|
|
4470
4466
|
command: d == null ? void 0 : d.command,
|
|
4471
4467
|
edit: d == null ? void 0 : d.edit
|
|
4472
4468
|
};
|
|
4473
|
-
return R(Ee,
|
|
4469
|
+
return R(Ee, x);
|
|
4474
4470
|
},
|
|
4475
|
-
[l, a,
|
|
4476
|
-
),
|
|
4471
|
+
[l, a, O, h, w, R, g, p]
|
|
4472
|
+
), F = Q(() => {
|
|
4477
4473
|
const d = Object.keys(M).length > 0;
|
|
4478
|
-
if (!
|
|
4474
|
+
if (!O && !d)
|
|
4479
4475
|
return E;
|
|
4480
|
-
const
|
|
4481
|
-
return E.forEach((_) =>
|
|
4482
|
-
|
|
4483
|
-
}), Array.from(
|
|
4484
|
-
}, [
|
|
4476
|
+
const x = /* @__PURE__ */ new Map();
|
|
4477
|
+
return E.forEach((_) => x.set(_.id, _)), Object.values(M).forEach((_) => {
|
|
4478
|
+
x.set(_.id, _);
|
|
4479
|
+
}), Array.from(x.values());
|
|
4480
|
+
}, [O, M, E]), $ = Q(
|
|
4485
4481
|
() => ({
|
|
4486
|
-
isStreaming:
|
|
4482
|
+
isStreaming: O,
|
|
4487
4483
|
error: U,
|
|
4488
|
-
connectionState: U ? "error" :
|
|
4489
|
-
messages:
|
|
4484
|
+
connectionState: U ? "error" : O ? C ? "connected" : "connecting" : "idle",
|
|
4485
|
+
messages: F,
|
|
4490
4486
|
activeMessageId: L,
|
|
4491
|
-
submit:
|
|
4487
|
+
submit: y,
|
|
4492
4488
|
stop: g,
|
|
4493
4489
|
interrupt: c,
|
|
4494
4490
|
resume: () => Promise.resolve(),
|
|
4495
|
-
goto: (d,
|
|
4491
|
+
goto: (d, x) => Promise.resolve(),
|
|
4496
4492
|
clearError: () => {
|
|
4497
4493
|
}
|
|
4498
4494
|
// TODO: Implement error clearing
|
|
4499
4495
|
}),
|
|
4500
|
-
[
|
|
4496
|
+
[O, U, y, g, c, C, F]
|
|
4501
4497
|
);
|
|
4502
|
-
return /* @__PURE__ */ ie(Ht.Provider, { value:
|
|
4498
|
+
return /* @__PURE__ */ ie(Ht.Provider, { value: $, children: e });
|
|
4503
4499
|
}
|
|
4504
4500
|
function pe(e) {
|
|
4505
4501
|
const t = H(e);
|
|
@@ -4560,26 +4556,26 @@ function uo({
|
|
|
4560
4556
|
onMetadataEvent: h,
|
|
4561
4557
|
onFinish: v
|
|
4562
4558
|
}) {
|
|
4563
|
-
const f = $r(t), [w, k] =
|
|
4559
|
+
const f = $r(t), [w, k] = B(!1), E = ge(i), I = ge(u), N = ge(a), P = ge(c), T = ge(l), S = ge(p), g = ge(m), b = ge(h), O = ge(v), U = Q(
|
|
4564
4560
|
() => ({
|
|
4565
4561
|
onError: E,
|
|
4566
4562
|
onAuthError: I,
|
|
4567
4563
|
onConnectionError: N,
|
|
4568
|
-
onToolEnd:
|
|
4564
|
+
onToolEnd: T,
|
|
4569
4565
|
onUpdateEvent: S,
|
|
4570
4566
|
onCustomEvent: g,
|
|
4571
|
-
onMetadataEvent:
|
|
4572
|
-
onFinish:
|
|
4567
|
+
onMetadataEvent: b,
|
|
4568
|
+
onFinish: O
|
|
4573
4569
|
}),
|
|
4574
4570
|
[
|
|
4575
4571
|
E,
|
|
4576
4572
|
I,
|
|
4577
4573
|
N,
|
|
4578
|
-
|
|
4574
|
+
T,
|
|
4579
4575
|
S,
|
|
4580
4576
|
g,
|
|
4581
|
-
|
|
4582
|
-
|
|
4577
|
+
b,
|
|
4578
|
+
O
|
|
4583
4579
|
]
|
|
4584
4580
|
);
|
|
4585
4581
|
return /* @__PURE__ */ ie(nr, { apiConfig: f, children: /* @__PURE__ */ ie(
|
|
@@ -4710,7 +4706,7 @@ function Wr() {
|
|
|
4710
4706
|
};
|
|
4711
4707
|
}
|
|
4712
4708
|
function fo(e) {
|
|
4713
|
-
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Ae(), { toast: o } = Wr(), [s, a] =
|
|
4709
|
+
const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Ae(), { toast: o } = Wr(), [s, a] = B({}), [i, u] = B(null), [c, l] = B(!1), p = z(() => {
|
|
4714
4710
|
l(!1), u(null);
|
|
4715
4711
|
}, []), m = z((v) => {
|
|
4716
4712
|
u(v), l(!0);
|
|
@@ -4729,18 +4725,18 @@ function fo(e) {
|
|
|
4729
4725
|
const I = String(f.url ?? ""), N = I.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
|
|
4730
4726
|
if (N) {
|
|
4731
4727
|
v.preventDefault();
|
|
4732
|
-
const P = N[1],
|
|
4733
|
-
m({ id: P, name:
|
|
4728
|
+
const P = N[1], T = f.name || `file_${P}`, S = f.mimeType || "application/octet-stream";
|
|
4729
|
+
m({ id: P, name: T, mimeType: S });
|
|
4734
4730
|
return;
|
|
4735
4731
|
}
|
|
4736
4732
|
if (I.startsWith("data:")) {
|
|
4737
|
-
v.preventDefault(), a((
|
|
4733
|
+
v.preventDefault(), a((T) => ({ ...T, [w]: !0 }));
|
|
4738
4734
|
const P = o({ title: "Fetching file...", description: "", open: !0 });
|
|
4739
4735
|
try {
|
|
4740
|
-
const
|
|
4741
|
-
if (!
|
|
4736
|
+
const T = await r.listFiles(n ?? void 0);
|
|
4737
|
+
if (!T || !Array.isArray(T))
|
|
4742
4738
|
throw new Error("Invalid file list response");
|
|
4743
|
-
const S =
|
|
4739
|
+
const S = T.find((g) => !g || typeof g != "object" || !((g.filename ?? "") === (f.name ?? "")) ? !1 : typeof f.size == "number" && typeof g.size == "number" ? g.size === f.size : !0);
|
|
4744
4740
|
if (!(S != null && S.id))
|
|
4745
4741
|
throw new Error(`File "${f.name}" is not yet available on the server`);
|
|
4746
4742
|
if (!S.id || !S.filename)
|
|
@@ -4755,16 +4751,16 @@ function fo(e) {
|
|
|
4755
4751
|
description: `Opened ${f.name}`,
|
|
4756
4752
|
open: !0
|
|
4757
4753
|
});
|
|
4758
|
-
} catch (
|
|
4759
|
-
console.error("Failed to fetch server file:",
|
|
4760
|
-
const S =
|
|
4754
|
+
} catch (T) {
|
|
4755
|
+
console.error("Failed to fetch server file:", T);
|
|
4756
|
+
const S = T instanceof Error ? T.message : "Unknown error occurred";
|
|
4761
4757
|
(E = P.update) == null || E.call(P, { id: P.id, title: "Failed", description: S }), o({
|
|
4762
4758
|
title: "Failed to fetch file",
|
|
4763
4759
|
description: S,
|
|
4764
4760
|
open: !0
|
|
4765
4761
|
});
|
|
4766
4762
|
} finally {
|
|
4767
|
-
a((
|
|
4763
|
+
a((T) => ({ ...T, [w]: !1 }));
|
|
4768
4764
|
}
|
|
4769
4765
|
}
|
|
4770
4766
|
} catch (I) {
|
|
@@ -4854,13 +4850,13 @@ function go(e) {
|
|
|
4854
4850
|
}, [e]);
|
|
4855
4851
|
}
|
|
4856
4852
|
function Xr(e) {
|
|
4857
|
-
var
|
|
4853
|
+
var O;
|
|
4858
4854
|
const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = ot({ optional: !0 }), o = Gt({ optional: !0 }), s = Fr(), { currentThreadId: a, setCurrentThreadId: i, actions: u } = r || {
|
|
4859
4855
|
currentThreadId: null,
|
|
4860
4856
|
setCurrentThreadId: () => {
|
|
4861
4857
|
},
|
|
4862
4858
|
actions: {}
|
|
4863
|
-
}, c = !!t && t !== a, [l, p] =
|
|
4859
|
+
}, c = !!t && t !== a, [l, p] = B([]), m = z((U) => {
|
|
4864
4860
|
p(U);
|
|
4865
4861
|
}, []), {
|
|
4866
4862
|
isLoadingThread: h,
|
|
@@ -4876,18 +4872,22 @@ function Xr(e) {
|
|
|
4876
4872
|
isStreaming: !1,
|
|
4877
4873
|
getMessages: () => l,
|
|
4878
4874
|
autoLoadInitial: c && !n
|
|
4879
|
-
})
|
|
4875
|
+
});
|
|
4876
|
+
q(() => {
|
|
4877
|
+
!c && !n && a && (o != null && o.loadThread) && o.loadThread(a);
|
|
4878
|
+
}, [c, n, a, o == null ? void 0 : o.loadThread]);
|
|
4879
|
+
const k = Q(() => {
|
|
4880
4880
|
var U;
|
|
4881
4881
|
return ((U = f[0]) == null ? void 0 : U.values) || {};
|
|
4882
|
-
}, [f]), E = Q(() => ({ timeline: [], messagePreviews: {} }), []), I = t || a, N = c ? h ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", P = c ? l : (s == null ? void 0 : s.messages) || [],
|
|
4882
|
+
}, [f]), E = Q(() => ({ timeline: [], messagePreviews: {} }), []), I = t || a, N = c ? h ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", P = c ? l : (s == null ? void 0 : s.messages) || [], T = c ? h : (o == null ? void 0 : o.isLoading) || !1, S = c ? k : (o == null ? void 0 : o.values) || {}, g = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, b = c ? v : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
|
|
4883
4883
|
return {
|
|
4884
4884
|
// UNIFIED: Single thread ID concept
|
|
4885
4885
|
threadId: I,
|
|
4886
4886
|
status: N,
|
|
4887
4887
|
messages: P,
|
|
4888
|
-
isLoading:
|
|
4889
|
-
isHistoryLoading:
|
|
4890
|
-
error:
|
|
4888
|
+
isLoading: T,
|
|
4889
|
+
isHistoryLoading: T,
|
|
4890
|
+
error: b,
|
|
4891
4891
|
// Values & Metadata
|
|
4892
4892
|
values: S,
|
|
4893
4893
|
taskMessagesByScope: g,
|
|
@@ -4911,7 +4911,7 @@ function Xr(e) {
|
|
|
4911
4911
|
isStreaming: (s == null ? void 0 : s.isStreaming) || !1,
|
|
4912
4912
|
activeMessageId: (s == null ? void 0 : s.activeMessageId) || null,
|
|
4913
4913
|
connectionState: (s == null ? void 0 : s.connectionState) || "disconnected",
|
|
4914
|
-
streamingAssistantId: !c && (s != null && s.isStreaming) && ((
|
|
4914
|
+
streamingAssistantId: !c && (s != null && s.isStreaming) && ((O = o == null ? void 0 : o.metadata) != null && O.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
|
|
4915
4915
|
// Actions
|
|
4916
4916
|
submit: (s == null ? void 0 : s.submit) || (async () => {
|
|
4917
4917
|
}),
|
|
@@ -4950,21 +4950,21 @@ function mo({
|
|
|
4950
4950
|
threadId: m,
|
|
4951
4951
|
clearComposerOnSend: h = !0
|
|
4952
4952
|
}) {
|
|
4953
|
-
const { messages: v } = Xr(), [f, w] =
|
|
4953
|
+
const { messages: v } = Xr(), [f, w] = B(null), [k, E] = B(""), [I, N] = B(null), [P, T] = B(null), [S, g] = B(!1), [b, O] = B(""), U = H(b), C = H(null);
|
|
4954
4954
|
q(() => {
|
|
4955
4955
|
if (!f)
|
|
4956
4956
|
if (m) {
|
|
4957
4957
|
const d = localStorage.getItem(qe(m));
|
|
4958
|
-
|
|
4958
|
+
O(d || "");
|
|
4959
4959
|
} else
|
|
4960
|
-
|
|
4960
|
+
O("");
|
|
4961
4961
|
}, [m, f]);
|
|
4962
4962
|
const M = z((d) => {
|
|
4963
|
-
|
|
4963
|
+
O(d), !f && m && localStorage.setItem(qe(m), d);
|
|
4964
4964
|
}, [m, f]);
|
|
4965
4965
|
q(() => {
|
|
4966
|
-
U.current =
|
|
4967
|
-
}, [
|
|
4966
|
+
U.current = b;
|
|
4967
|
+
}, [b]), q(() => {
|
|
4968
4968
|
if (!f) {
|
|
4969
4969
|
C.current = null;
|
|
4970
4970
|
return;
|
|
@@ -4976,8 +4976,8 @@ function mo({
|
|
|
4976
4976
|
M(d);
|
|
4977
4977
|
},
|
|
4978
4978
|
[M]
|
|
4979
|
-
), R = async (d,
|
|
4980
|
-
const _ = Array.isArray(
|
|
4979
|
+
), R = async (d, x) => {
|
|
4980
|
+
const _ = Array.isArray(x) ? { files: x } : x ?? {}, te = _.files ?? [], J = _.contentParts ?? [], G = d.trim();
|
|
4981
4981
|
if (!(!G && te.length === 0 && J.length === 0))
|
|
4982
4982
|
try {
|
|
4983
4983
|
const Z = te.map(async (X) => {
|
|
@@ -5014,14 +5014,14 @@ function mo({
|
|
|
5014
5014
|
config: t.config
|
|
5015
5015
|
},
|
|
5016
5016
|
p ? { onEvent: p } : void 0
|
|
5017
|
-
), o == null || o(G), c(!0), h && (m && localStorage.removeItem(qe(m)), M("")),
|
|
5017
|
+
), o == null || o(G), c(!0), h && (m && localStorage.removeItem(qe(m)), M("")), T(null), w(null), E(""), N(null);
|
|
5018
5018
|
} catch (Z) {
|
|
5019
5019
|
const ae = (Z == null ? void 0 : Z.message) || "Failed to send message";
|
|
5020
|
-
|
|
5020
|
+
T(ae), a == null || a(ae), c(!1);
|
|
5021
5021
|
}
|
|
5022
|
-
}, V = (d,
|
|
5023
|
-
|
|
5024
|
-
},
|
|
5022
|
+
}, V = (d, x) => {
|
|
5023
|
+
x || R(d, { files: [] });
|
|
5024
|
+
}, D = z(
|
|
5025
5025
|
async (d) => {
|
|
5026
5026
|
await e(
|
|
5027
5027
|
{
|
|
@@ -5036,27 +5036,27 @@ function mo({
|
|
|
5036
5036
|
), s == null || s({ file: d });
|
|
5037
5037
|
},
|
|
5038
5038
|
[n, r, t, s, e]
|
|
5039
|
-
),
|
|
5040
|
-
(d,
|
|
5041
|
-
i && (C.current =
|
|
5039
|
+
), A = z(
|
|
5040
|
+
(d, x, _) => {
|
|
5041
|
+
i && (C.current = b, w(d), E(x), N({
|
|
5042
5042
|
checkpointId: (_ == null ? void 0 : _.checkpointId) ?? null,
|
|
5043
5043
|
checkpointNs: (_ == null ? void 0 : _.checkpointNs) ?? null
|
|
5044
|
-
}),
|
|
5044
|
+
}), T(null));
|
|
5045
5045
|
},
|
|
5046
|
-
[
|
|
5047
|
-
),
|
|
5048
|
-
w(null), E(""), N(null),
|
|
5046
|
+
[b, i]
|
|
5047
|
+
), y = z(() => {
|
|
5048
|
+
w(null), E(""), N(null), T(null);
|
|
5049
5049
|
const d = C.current;
|
|
5050
|
-
d !== null &&
|
|
5051
|
-
}, []),
|
|
5052
|
-
let
|
|
5050
|
+
d !== null && O(d), C.current = null;
|
|
5051
|
+
}, []), F = z((d) => {
|
|
5052
|
+
let x = null;
|
|
5053
5053
|
for (let G = d - 1; G >= 0; G--)
|
|
5054
5054
|
if (u[G].role === "user") {
|
|
5055
|
-
|
|
5055
|
+
x = u[G];
|
|
5056
5056
|
break;
|
|
5057
5057
|
}
|
|
5058
|
-
if (!
|
|
5059
|
-
const _ = Array.isArray(
|
|
5058
|
+
if (!x) return;
|
|
5059
|
+
const _ = Array.isArray(x.content) ? x.content : [], J = _.filter((G) => (G == null ? void 0 : G.type) === "text").map((G) => G.text).join("") || (() => {
|
|
5060
5060
|
try {
|
|
5061
5061
|
return JSON.stringify(_, null, 2);
|
|
5062
5062
|
} catch {
|
|
@@ -5070,7 +5070,7 @@ function mo({
|
|
|
5070
5070
|
checkpointId: n ?? void 0,
|
|
5071
5071
|
checkpointNs: r ?? void 0,
|
|
5072
5072
|
edit: !0,
|
|
5073
|
-
originalMessageId:
|
|
5073
|
+
originalMessageId: x.id,
|
|
5074
5074
|
config: t.config
|
|
5075
5075
|
},
|
|
5076
5076
|
p ? { onEvent: p } : void 0
|
|
@@ -5080,17 +5080,17 @@ function mo({
|
|
|
5080
5080
|
editingMessageId: f,
|
|
5081
5081
|
editingInitialValue: k,
|
|
5082
5082
|
inputError: P,
|
|
5083
|
-
setInputError:
|
|
5083
|
+
setInputError: T,
|
|
5084
5084
|
dismissError: S,
|
|
5085
5085
|
setDismissError: g,
|
|
5086
|
-
composerValue:
|
|
5086
|
+
composerValue: b,
|
|
5087
5087
|
handleComposerChange: L,
|
|
5088
5088
|
handleSendMessage: R,
|
|
5089
5089
|
handleQuickPrompt: V,
|
|
5090
|
-
handleExcelUpload:
|
|
5091
|
-
startEditing:
|
|
5092
|
-
cancelEditing:
|
|
5093
|
-
handleRegenerateCb:
|
|
5090
|
+
handleExcelUpload: D,
|
|
5091
|
+
startEditing: A,
|
|
5092
|
+
cancelEditing: y,
|
|
5093
|
+
handleRegenerateCb: F,
|
|
5094
5094
|
displayMessages: v
|
|
5095
5095
|
};
|
|
5096
5096
|
}
|
|
@@ -5110,7 +5110,7 @@ function ho(e) {
|
|
|
5110
5110
|
}, [e]);
|
|
5111
5111
|
}
|
|
5112
5112
|
function yo(e, t, n) {
|
|
5113
|
-
const [r, o] =
|
|
5113
|
+
const [r, o] = B(e), s = H(e), a = H(null);
|
|
5114
5114
|
return q(() => {
|
|
5115
5115
|
s.current = e;
|
|
5116
5116
|
const i = () => {
|