@teodorruskvi/chat-core 0.1.22 → 0.1.25
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 +99 -98
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +6 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -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
|
Qn.test(e) && !Yn.test(e)
|
|
249
249
|
), on = () => !1, lr = (e) => Zn.test(e), ur = (e) => er.test(e), dr = () => {
|
|
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"), f = Q("contrast"), l = Q("grayscale"), c = Q("hueRotate"), d = Q("invert"), m = Q("gap"), y = Q("gradientColorStops"), w = Q("gradientColorStopPositions"), g = Q("inset"), b = Q("margin"), I = Q("opacity"), x = Q("padding"), M = Q("saturate"), R = Q("scale"), N = Q("sepia"), v = Q("skew"), k = Q("space"), L = Q("translate"), F = () => ["auto", "contain", "none"], j = () => ["auto", "hidden", "clip", "visible", "scroll"], O = () => ["auto", z, t], E = () => [z, t], W = () => ["", Pe, Ue], K = () => ["auto", Ge, z],
|
|
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"), f = Q("contrast"), l = Q("grayscale"), c = Q("hueRotate"), d = Q("invert"), m = Q("gap"), y = Q("gradientColorStops"), w = Q("gradientColorStopPositions"), g = Q("inset"), b = Q("margin"), I = Q("opacity"), x = Q("padding"), M = Q("saturate"), R = Q("scale"), N = Q("sepia"), v = Q("skew"), k = Q("space"), L = Q("translate"), F = () => ["auto", "contain", "none"], j = () => ["auto", "hidden", "clip", "visible", "scroll"], O = () => ["auto", z, t], E = () => [z, t], W = () => ["", Pe, Ue], K = () => ["auto", Ge, z], J = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], Y = () => ["solid", "dashed", "dotted", "double", "none"], Z = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], T = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], U = () => ["", "0", z], H = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], B = () => [Ge, z];
|
|
251
251
|
return {
|
|
252
252
|
cacheSize: 500,
|
|
253
253
|
separator: ":",
|
|
@@ -255,26 +255,26 @@ const Q = (e) => {
|
|
|
255
255
|
colors: [Ye],
|
|
256
256
|
spacing: [Pe, Ue],
|
|
257
257
|
blur: ["none", "", ze, z],
|
|
258
|
-
brightness:
|
|
258
|
+
brightness: B(),
|
|
259
259
|
borderColor: [e],
|
|
260
260
|
borderRadius: ["none", "", "full", ze, z],
|
|
261
261
|
borderSpacing: E(),
|
|
262
262
|
borderWidth: W(),
|
|
263
|
-
contrast:
|
|
263
|
+
contrast: B(),
|
|
264
264
|
grayscale: U(),
|
|
265
|
-
hueRotate:
|
|
265
|
+
hueRotate: B(),
|
|
266
266
|
invert: U(),
|
|
267
267
|
gap: E(),
|
|
268
268
|
gradientColorStops: [e],
|
|
269
269
|
gradientColorStopPositions: [tr, Ue],
|
|
270
270
|
inset: O(),
|
|
271
271
|
margin: O(),
|
|
272
|
-
opacity:
|
|
272
|
+
opacity: B(),
|
|
273
273
|
padding: E(),
|
|
274
|
-
saturate:
|
|
275
|
-
scale:
|
|
274
|
+
saturate: B(),
|
|
275
|
+
scale: B(),
|
|
276
276
|
sepia: U(),
|
|
277
|
-
skew:
|
|
277
|
+
skew: B(),
|
|
278
278
|
space: E(),
|
|
279
279
|
translate: E()
|
|
280
280
|
},
|
|
@@ -370,7 +370,7 @@ const Q = (e) => {
|
|
|
370
370
|
* @see https://tailwindcss.com/docs/object-position
|
|
371
371
|
*/
|
|
372
372
|
"object-position": [{
|
|
373
|
-
object: [...
|
|
373
|
+
object: [...J(), z]
|
|
374
374
|
}],
|
|
375
375
|
/**
|
|
376
376
|
* Overflow
|
|
@@ -1179,7 +1179,7 @@ const Q = (e) => {
|
|
|
1179
1179
|
* @see https://tailwindcss.com/docs/background-position
|
|
1180
1180
|
*/
|
|
1181
1181
|
"bg-position": [{
|
|
1182
|
-
bg: [...
|
|
1182
|
+
bg: [...J(), or]
|
|
1183
1183
|
}],
|
|
1184
1184
|
/**
|
|
1185
1185
|
* Background Repeat
|
|
@@ -1849,7 +1849,7 @@ const Q = (e) => {
|
|
|
1849
1849
|
* @see https://tailwindcss.com/docs/transition-duration
|
|
1850
1850
|
*/
|
|
1851
1851
|
duration: [{
|
|
1852
|
-
duration:
|
|
1852
|
+
duration: B()
|
|
1853
1853
|
}],
|
|
1854
1854
|
/**
|
|
1855
1855
|
* Transition Timing Function
|
|
@@ -1863,7 +1863,7 @@ const Q = (e) => {
|
|
|
1863
1863
|
* @see https://tailwindcss.com/docs/transition-delay
|
|
1864
1864
|
*/
|
|
1865
1865
|
delay: [{
|
|
1866
|
-
delay:
|
|
1866
|
+
delay: B()
|
|
1867
1867
|
}],
|
|
1868
1868
|
/**
|
|
1869
1869
|
* Animation
|
|
@@ -3094,7 +3094,7 @@ function Hr(e = {}) {
|
|
|
3094
3094
|
i.current = e;
|
|
3095
3095
|
}, [e]);
|
|
3096
3096
|
const f = P((p) => {
|
|
3097
|
-
var S, _, G,
|
|
3097
|
+
var S, _, G, q, $, ae, re, de, X, se;
|
|
3098
3098
|
const h = i.current;
|
|
3099
3099
|
if (!h) return;
|
|
3100
3100
|
if (p.type === "thread_info") {
|
|
@@ -3110,23 +3110,23 @@ function Hr(e = {}) {
|
|
|
3110
3110
|
return;
|
|
3111
3111
|
}
|
|
3112
3112
|
if (typeof p.type == "string" && (p.type === "custom" || p.type.startsWith("custom."))) {
|
|
3113
|
-
(
|
|
3113
|
+
(q = h.onCustomEvent) == null || q.call(h, p);
|
|
3114
3114
|
return;
|
|
3115
3115
|
}
|
|
3116
|
-
(
|
|
3117
|
-
}, []), [l, c] = D(!1), [d, m] = D(null), [y, w] = D(""), [g, b] = D(null), [I, x] = D(0), [M, R] = D(!1), [N, v] = D({}), [k, L] = D(null), [F, j] = D({}), O = V(null), E = V(!0), W = V(0), K = V(null),
|
|
3116
|
+
($ = h.onEvent) == null || $.call(h, p), p.type === "updates" && ((ae = h.onUpdateEvent) == null || ae.call(h, p)), p.type === "tool.end" ? (re = h.onToolEnd) == null || re.call(h, p) : p.type === "tool.start" && ((de = h.onToolStart) == null || de.call(h, p)), p.type === "heartbeat" && ((X = h.onHeartbeat) == null || X.call(h, p)), p.type === "token" && ((se = h.onToken) == null || se.call(h, p.token));
|
|
3117
|
+
}, []), [l, c] = D(!1), [d, m] = D(null), [y, w] = D(""), [g, b] = D(null), [I, x] = D(0), [M, R] = D(!1), [N, v] = D({}), [k, L] = D(null), [F, j] = D({}), O = V(null), E = V(!0), W = V(0), K = V(null), J = V(null), Y = V(null), Z = V(null), T = V({
|
|
3118
3118
|
messageId: null,
|
|
3119
3119
|
lastSeq: null,
|
|
3120
3120
|
lastText: ""
|
|
3121
3121
|
}), U = P((p) => {
|
|
3122
3122
|
o(p);
|
|
3123
3123
|
}, []), H = P(() => {
|
|
3124
|
-
w(""), b(null), m(null),
|
|
3124
|
+
w(""), b(null), m(null), J.current = null, Y.current = null, Z.current = null, v({}), L(null), j({}), T.current = {
|
|
3125
3125
|
messageId: null,
|
|
3126
3126
|
lastSeq: null,
|
|
3127
3127
|
lastText: ""
|
|
3128
3128
|
};
|
|
3129
|
-
}, []),
|
|
3129
|
+
}, []), B = P(() => {
|
|
3130
3130
|
var S;
|
|
3131
3131
|
console.debug("[use-chat] stop() invoked - aborting stream");
|
|
3132
3132
|
const p = (S = K.current) == null ? void 0 : S.threadId, h = () => {
|
|
@@ -3150,7 +3150,7 @@ function Hr(e = {}) {
|
|
|
3150
3150
|
edit: p.edit,
|
|
3151
3151
|
command: p.command
|
|
3152
3152
|
};
|
|
3153
|
-
c(!0), m(null), w(""), b(null),
|
|
3153
|
+
c(!0), m(null), w(""), b(null), J.current = null, Y.current = null, Z.current = null, v({}), L(null), j({}), T.current = {
|
|
3154
3154
|
messageId: null,
|
|
3155
3155
|
lastSeq: null,
|
|
3156
3156
|
lastText: ""
|
|
@@ -3163,7 +3163,7 @@ function Hr(e = {}) {
|
|
|
3163
3163
|
headers: {},
|
|
3164
3164
|
isStreaming: !0
|
|
3165
3165
|
}, (async () => {
|
|
3166
|
-
var G,
|
|
3166
|
+
var G, q, $, ae, re, de, X, se, _e, Le, ce, Ae;
|
|
3167
3167
|
try {
|
|
3168
3168
|
let ye = {};
|
|
3169
3169
|
try {
|
|
@@ -3173,8 +3173,8 @@ function Hr(e = {}) {
|
|
|
3173
3173
|
const we = window.__AUTH_TOKEN__, vt = ((G = window.localStorage) == null ? void 0 : G.getItem(et.authToken)) || null;
|
|
3174
3174
|
let it = null;
|
|
3175
3175
|
try {
|
|
3176
|
-
const ct = (
|
|
3177
|
-
ct && (it = ((
|
|
3176
|
+
const ct = (q = window.localStorage) == null ? void 0 : q.getItem(et.chatSettings);
|
|
3177
|
+
ct && (it = (($ = JSON.parse(ct)) == null ? void 0 : $.apiKey) || null);
|
|
3178
3178
|
} catch {
|
|
3179
3179
|
}
|
|
3180
3180
|
const Ke = we || vt || it || null;
|
|
@@ -3297,14 +3297,14 @@ function Hr(e = {}) {
|
|
|
3297
3297
|
let ve = ie.type || "unknown";
|
|
3298
3298
|
if (Mn.includes(ve) || (ie.messages || ie.content !== void 0 && ie.id) && (ve = "messages/partial"), ve === "checkpoint") {
|
|
3299
3299
|
const C = ie;
|
|
3300
|
-
|
|
3300
|
+
J.current = C.checkpointId ?? null, Y.current = C.checkpointNs ?? null, b(C.checkpointId ?? null);
|
|
3301
3301
|
} else if (ve === "values") {
|
|
3302
3302
|
const C = ie;
|
|
3303
3303
|
if (Array.isArray(C.checkpoints)) {
|
|
3304
3304
|
Z.current = C;
|
|
3305
3305
|
try {
|
|
3306
3306
|
const oe = Ze(C).latest;
|
|
3307
|
-
oe && (
|
|
3307
|
+
oe && (J.current = oe.checkpointId ?? null, Y.current = oe.checkpointNs ?? null, b(oe.checkpointId ?? null), j(oe.values ?? {})), v({}), L(null);
|
|
3308
3308
|
} catch (ee) {
|
|
3309
3309
|
console.warn("[use-chat] Failed to hydrate values payload", ee);
|
|
3310
3310
|
}
|
|
@@ -3443,7 +3443,7 @@ function Hr(e = {}) {
|
|
|
3443
3443
|
S = "error", m(be), _ || (_ = !0, (Ae = e.onConnectionError) == null || Ae.call(e, be));
|
|
3444
3444
|
}
|
|
3445
3445
|
} finally {
|
|
3446
|
-
const ye = W.current, be =
|
|
3446
|
+
const ye = W.current, be = J.current, Fe = Y.current, Je = Z.current;
|
|
3447
3447
|
try {
|
|
3448
3448
|
if (e.onFinish) {
|
|
3449
3449
|
const fe = {
|
|
@@ -3476,7 +3476,7 @@ function Hr(e = {}) {
|
|
|
3476
3476
|
lastSeq: I,
|
|
3477
3477
|
connected: M,
|
|
3478
3478
|
stream: u,
|
|
3479
|
-
stop:
|
|
3479
|
+
stop: B,
|
|
3480
3480
|
clear: H,
|
|
3481
3481
|
setToken: U,
|
|
3482
3482
|
values: F,
|
|
@@ -3578,25 +3578,25 @@ function Jr({
|
|
|
3578
3578
|
const j = P(
|
|
3579
3579
|
async (T, U) => {
|
|
3580
3580
|
try {
|
|
3581
|
-
const H = U && typeof U == "object" ? { id: U.id, name: U.name ?? "" } : void 0,
|
|
3582
|
-
return f(
|
|
3581
|
+
const H = U && typeof U == "object" ? { id: U.id, name: U.name ?? "" } : void 0, B = await e.createThread(T, H);
|
|
3582
|
+
return f(B.threadId), await L(), B.threadId;
|
|
3583
3583
|
} catch (H) {
|
|
3584
|
-
const
|
|
3585
|
-
return n == null || n(
|
|
3584
|
+
const B = String(H);
|
|
3585
|
+
return n == null || n(B), null;
|
|
3586
3586
|
}
|
|
3587
3587
|
},
|
|
3588
3588
|
[e, n, L]
|
|
3589
3589
|
), O = P(
|
|
3590
3590
|
async (T) => {
|
|
3591
3591
|
const U = s;
|
|
3592
|
-
a((
|
|
3592
|
+
a((B) => B.filter((u) => u.threadId !== T));
|
|
3593
3593
|
const H = new AbortController();
|
|
3594
3594
|
k.current.set(T, H);
|
|
3595
3595
|
try {
|
|
3596
3596
|
await e.deleteThread(T), v.current === T && (f(null), o == null || o());
|
|
3597
|
-
} catch (
|
|
3597
|
+
} catch (B) {
|
|
3598
3598
|
a(U);
|
|
3599
|
-
const u = String(
|
|
3599
|
+
const u = String(B);
|
|
3600
3600
|
n == null || n(u);
|
|
3601
3601
|
} finally {
|
|
3602
3602
|
k.current.delete(T);
|
|
@@ -3618,8 +3618,8 @@ function Jr({
|
|
|
3618
3618
|
try {
|
|
3619
3619
|
await e.shareThread(T, U), await F(), M("Shared successfully");
|
|
3620
3620
|
} catch (H) {
|
|
3621
|
-
const
|
|
3622
|
-
throw n == null || n(
|
|
3621
|
+
const B = qr(H);
|
|
3622
|
+
throw n == null || n(B), M(`Failed to share: ${B}`), new Error(B);
|
|
3623
3623
|
} finally {
|
|
3624
3624
|
N(!1);
|
|
3625
3625
|
}
|
|
@@ -3630,12 +3630,12 @@ function Jr({
|
|
|
3630
3630
|
try {
|
|
3631
3631
|
await e.unshareThread(T, U), await F();
|
|
3632
3632
|
} catch (H) {
|
|
3633
|
-
const
|
|
3634
|
-
throw n == null || n(
|
|
3633
|
+
const B = String(H);
|
|
3634
|
+
throw n == null || n(B), H;
|
|
3635
3635
|
}
|
|
3636
3636
|
},
|
|
3637
3637
|
[e, n, F]
|
|
3638
|
-
),
|
|
3638
|
+
), J = ue(
|
|
3639
3639
|
() => ({
|
|
3640
3640
|
createThread: j,
|
|
3641
3641
|
deleteThread: O,
|
|
@@ -3657,15 +3657,15 @@ function Jr({
|
|
|
3657
3657
|
messageCount: T.messageCount ?? 1
|
|
3658
3658
|
};
|
|
3659
3659
|
a((H) => {
|
|
3660
|
-
let
|
|
3661
|
-
const u = H.map((p) => p.threadId === U.threadId ? (
|
|
3660
|
+
let B = !1;
|
|
3661
|
+
const u = H.map((p) => p.threadId === U.threadId ? (B = !0, console.debug("[useThreadsState] thread_info: updating existing thread", U.threadId), {
|
|
3662
3662
|
...p,
|
|
3663
3663
|
title: U.title ?? p.title,
|
|
3664
3664
|
project: U.project ?? p.project,
|
|
3665
3665
|
updatedAt: U.updatedAt ?? p.updatedAt,
|
|
3666
3666
|
messageCount: U.messageCount ?? p.messageCount
|
|
3667
3667
|
}) : p);
|
|
3668
|
-
return
|
|
3668
|
+
return B ? u : (console.debug("[useThreadsState] thread_info: adding thread to list", U.threadId), [U, ...H]);
|
|
3669
3669
|
});
|
|
3670
3670
|
}, []), Z = P(() => M(null), []);
|
|
3671
3671
|
return {
|
|
@@ -3677,7 +3677,7 @@ function Jr({
|
|
|
3677
3677
|
threadsError: d,
|
|
3678
3678
|
sharedThreads: y,
|
|
3679
3679
|
isLoadingSharedThreads: g,
|
|
3680
|
-
actions:
|
|
3680
|
+
actions: J,
|
|
3681
3681
|
addThreadFromEvent: Y,
|
|
3682
3682
|
shareInFlight: R,
|
|
3683
3683
|
shareStatus: x,
|
|
@@ -4227,7 +4227,7 @@ function bn({
|
|
|
4227
4227
|
ne(() => {
|
|
4228
4228
|
k.current = o;
|
|
4229
4229
|
}, [o]);
|
|
4230
|
-
const
|
|
4230
|
+
const J = P(
|
|
4231
4231
|
async (A) => {
|
|
4232
4232
|
var _, G;
|
|
4233
4233
|
if (!A.threadId) return;
|
|
@@ -4235,12 +4235,12 @@ function bn({
|
|
|
4235
4235
|
(_ = A.onStart) == null || _.call(A), A.setLoading(!0);
|
|
4236
4236
|
try {
|
|
4237
4237
|
await A.action(S);
|
|
4238
|
-
} catch (
|
|
4239
|
-
if (!Ot(
|
|
4240
|
-
const ae = String(
|
|
4238
|
+
} catch (q) {
|
|
4239
|
+
if (!Ot(q) && k.current === S) {
|
|
4240
|
+
const ae = String(q);
|
|
4241
4241
|
(G = A.handleError) == null || G.call(A, ae), r == null || r(ae);
|
|
4242
4242
|
}
|
|
4243
|
-
throw
|
|
4243
|
+
throw q;
|
|
4244
4244
|
} finally {
|
|
4245
4245
|
A.setLoading(!1);
|
|
4246
4246
|
}
|
|
@@ -4254,9 +4254,9 @@ function bn({
|
|
|
4254
4254
|
if (G)
|
|
4255
4255
|
return G;
|
|
4256
4256
|
(ae = K.current) == null || ae.abort();
|
|
4257
|
-
const
|
|
4258
|
-
K.current =
|
|
4259
|
-
const
|
|
4257
|
+
const q = new AbortController();
|
|
4258
|
+
K.current = q;
|
|
4259
|
+
const $ = J({
|
|
4260
4260
|
threadId: A,
|
|
4261
4261
|
setLoading: x,
|
|
4262
4262
|
onStart: () => v(null),
|
|
@@ -4280,15 +4280,15 @@ function bn({
|
|
|
4280
4280
|
}), m(se);
|
|
4281
4281
|
}
|
|
4282
4282
|
});
|
|
4283
|
-
W.current.set(_,
|
|
4283
|
+
W.current.set(_, $);
|
|
4284
4284
|
try {
|
|
4285
|
-
await
|
|
4285
|
+
await $;
|
|
4286
4286
|
} finally {
|
|
4287
|
-
W.current.delete(_), K.current ===
|
|
4287
|
+
W.current.delete(_), K.current === q && (K.current = null);
|
|
4288
4288
|
}
|
|
4289
|
-
return k.current === A && (E.current = _),
|
|
4289
|
+
return k.current === A && (E.current = _), $;
|
|
4290
4290
|
},
|
|
4291
|
-
[e, n,
|
|
4291
|
+
[e, n, J, t]
|
|
4292
4292
|
), Z = P(
|
|
4293
4293
|
async (A, S) => {
|
|
4294
4294
|
O.current = A;
|
|
@@ -4311,30 +4311,30 @@ function bn({
|
|
|
4311
4311
|
const S = A.threadId ?? k.current;
|
|
4312
4312
|
if (!S || k.current && k.current !== S && j.current !== S)
|
|
4313
4313
|
return;
|
|
4314
|
-
const _ = t ? await St(A, t) : A, { checkpoints: G, latest:
|
|
4314
|
+
const _ = t ? await St(A, t) : A, { checkpoints: G, latest: q } = Ze(_);
|
|
4315
4315
|
if (!G.length)
|
|
4316
4316
|
return;
|
|
4317
|
-
const
|
|
4318
|
-
n((
|
|
4319
|
-
checkpointId: (
|
|
4320
|
-
checkpointNs: (
|
|
4321
|
-
pendingInterrupt: (
|
|
4322
|
-
values:
|
|
4317
|
+
const $ = q;
|
|
4318
|
+
n(($ == null ? void 0 : $.messages) ?? [], {
|
|
4319
|
+
checkpointId: ($ == null ? void 0 : $.checkpointId) ?? null,
|
|
4320
|
+
checkpointNs: ($ == null ? void 0 : $.checkpointNs) ?? null,
|
|
4321
|
+
pendingInterrupt: ($ == null ? void 0 : $.interrupt) ?? null,
|
|
4322
|
+
values: $ == null ? void 0 : $.values
|
|
4323
4323
|
}), m(_), E.current = `${S}:latest`, F.current = null, j.current === S && (j.current = null);
|
|
4324
4324
|
},
|
|
4325
4325
|
[n, l, t]
|
|
4326
|
-
),
|
|
4326
|
+
), B = P(
|
|
4327
4327
|
async (A, S) => {
|
|
4328
4328
|
const _ = k.current;
|
|
4329
|
-
await
|
|
4329
|
+
await J({
|
|
4330
4330
|
threadId: _,
|
|
4331
4331
|
setLoading: R,
|
|
4332
4332
|
action: async (G) => {
|
|
4333
|
-
const
|
|
4333
|
+
const q = await e.getState({
|
|
4334
4334
|
threadId: G,
|
|
4335
4335
|
checkpointId: A,
|
|
4336
4336
|
checkpointNs: S ?? void 0
|
|
4337
|
-
}),
|
|
4337
|
+
}), $ = Jt(G, q), ae = t ? await St($, t) : $;
|
|
4338
4338
|
if (k.current !== G)
|
|
4339
4339
|
return;
|
|
4340
4340
|
const { checkpoints: re } = Ze(ae), de = re.find(
|
|
@@ -4352,7 +4352,7 @@ function bn({
|
|
|
4352
4352
|
}).catch(() => {
|
|
4353
4353
|
});
|
|
4354
4354
|
},
|
|
4355
|
-
[e, n,
|
|
4355
|
+
[e, n, J, t]
|
|
4356
4356
|
), u = P(
|
|
4357
4357
|
(A, S) => {
|
|
4358
4358
|
n(c(), {
|
|
@@ -4406,7 +4406,7 @@ function bn({
|
|
|
4406
4406
|
isLoadingCheckpoint: M,
|
|
4407
4407
|
threadStateError: N,
|
|
4408
4408
|
loadThread: Z,
|
|
4409
|
-
navigateToCheckpoint:
|
|
4409
|
+
navigateToCheckpoint: B,
|
|
4410
4410
|
setCurrentCheckpointId: u,
|
|
4411
4411
|
returnToLatest: p,
|
|
4412
4412
|
handleValuesEvent: H,
|
|
@@ -4473,7 +4473,7 @@ function ho({
|
|
|
4473
4473
|
E.current = u;
|
|
4474
4474
|
},
|
|
4475
4475
|
[]
|
|
4476
|
-
), K = V(null),
|
|
4476
|
+
), K = V(null), J = P(
|
|
4477
4477
|
(u) => {
|
|
4478
4478
|
K.current = u;
|
|
4479
4479
|
},
|
|
@@ -4567,14 +4567,14 @@ function ho({
|
|
|
4567
4567
|
m,
|
|
4568
4568
|
U
|
|
4569
4569
|
]
|
|
4570
|
-
),
|
|
4570
|
+
), B = ue(
|
|
4571
4571
|
() => ({
|
|
4572
4572
|
registerClearThread: W,
|
|
4573
|
-
registerRespondToInterrupt:
|
|
4573
|
+
registerRespondToInterrupt: J
|
|
4574
4574
|
}),
|
|
4575
|
-
[W,
|
|
4575
|
+
[W, J]
|
|
4576
4576
|
);
|
|
4577
|
-
return /* @__PURE__ */ ke(vn.Provider, { value:
|
|
4577
|
+
return /* @__PURE__ */ ke(vn.Provider, { value: B, children: /* @__PURE__ */ ke(wn.Provider, { value: H, children: e }) });
|
|
4578
4578
|
}
|
|
4579
4579
|
const kn = We(null), yo = We(!1);
|
|
4580
4580
|
function bo({
|
|
@@ -4669,7 +4669,7 @@ function wo({
|
|
|
4669
4669
|
ne(() => {
|
|
4670
4670
|
f !== void 0 && F();
|
|
4671
4671
|
}, [f, F]);
|
|
4672
|
-
const
|
|
4672
|
+
const J = P(
|
|
4673
4673
|
async (u, p) => {
|
|
4674
4674
|
await k(u, p);
|
|
4675
4675
|
},
|
|
@@ -4683,16 +4683,16 @@ function wo({
|
|
|
4683
4683
|
const A = a.current;
|
|
4684
4684
|
if (!A)
|
|
4685
4685
|
throw new Error("No active thread to handle interrupt");
|
|
4686
|
-
const S = u ? p ?? !0 : !1, _ = Y.current, G = {
|
|
4686
|
+
const S = u ? p ?? !0 : !1, _ = Y.current, G = (h == null ? void 0 : h.checkpointId) ?? _.id ?? void 0, q = (h == null ? void 0 : h.checkpointNs) ?? _.namespace ?? void 0, $ = {
|
|
4687
4687
|
threadId: A,
|
|
4688
|
-
checkpointId:
|
|
4689
|
-
checkpointNs:
|
|
4688
|
+
checkpointId: G,
|
|
4689
|
+
checkpointNs: q,
|
|
4690
4690
|
command: { kind: "resume", value: S },
|
|
4691
4691
|
payload: h == null ? void 0 : h.payload
|
|
4692
4692
|
};
|
|
4693
|
-
|
|
4693
|
+
J($);
|
|
4694
4694
|
},
|
|
4695
|
-
[a,
|
|
4695
|
+
[a, J]
|
|
4696
4696
|
);
|
|
4697
4697
|
ne(() => {
|
|
4698
4698
|
R(Z);
|
|
@@ -4707,10 +4707,10 @@ function wo({
|
|
|
4707
4707
|
async (u, p) => {
|
|
4708
4708
|
j && L();
|
|
4709
4709
|
let h = a.current;
|
|
4710
|
-
const A = (u == null ? void 0 : u.text) ?? "", S = (u == null ? void 0 : u.attachments) ?? [], _ = (A == null ? void 0 : A.trim()) ?? "", G = { ...(u == null ? void 0 : u.payload) ?? {} },
|
|
4711
|
-
|
|
4712
|
-
const
|
|
4713
|
-
if (!h && !_ && S.length === 0 &&
|
|
4710
|
+
const A = (u == null ? void 0 : u.text) ?? "", S = (u == null ? void 0 : u.attachments) ?? [], _ = (A == null ? void 0 : A.trim()) ?? "", G = { ...(u == null ? void 0 : u.payload) ?? {} }, q = Array.isArray(G.messages) ? G.messages : void 0;
|
|
4711
|
+
q && delete G.messages;
|
|
4712
|
+
const $ = !!(q && q.length), ae = !!(u.contentParts && u.contentParts.length > 0);
|
|
4713
|
+
if (!h && !_ && S.length === 0 && !$ && !ae) return;
|
|
4714
4714
|
if (!h) {
|
|
4715
4715
|
const fe = Math.floor(Date.now() / 1e3).toString(16).padStart(8, "0"), je = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967295).toString(16).padStart(8, "0")).join("").slice(0, 16);
|
|
4716
4716
|
h = `${fe}${je}`, y(h), s(h);
|
|
@@ -4719,7 +4719,7 @@ function wo({
|
|
|
4719
4719
|
u.contentParts && u.contentParts.length > 0 && (re = u.contentParts);
|
|
4720
4720
|
const { contentParts: de, filesInfo: X } = re ? { contentParts: re, filesInfo: [] } : await Fr(S), se = [...de];
|
|
4721
4721
|
_ && se.push({ type: "text", text: A });
|
|
4722
|
-
const _e = u == null ? void 0 : u.originalMessageId, Le = !!(u != null && u.edit && _e), ce =
|
|
4722
|
+
const _e = u == null ? void 0 : u.originalMessageId, Le = !!(u != null && u.edit && _e), ce = !$ && se.length > 0;
|
|
4723
4723
|
let Ae = null;
|
|
4724
4724
|
if (ce) {
|
|
4725
4725
|
const fe = Le ? _e : `msg-${Date.now()}`;
|
|
@@ -4730,7 +4730,7 @@ function wo({
|
|
|
4730
4730
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4731
4731
|
}, "user"), Le ? b(Ae, { editingMessageId: _e }) : b(Ae);
|
|
4732
4732
|
}
|
|
4733
|
-
const ye =
|
|
4733
|
+
const ye = $ ? q : Ae ? [Ae] : [], be = {
|
|
4734
4734
|
...G,
|
|
4735
4735
|
...X.length ? { files_info: X } : {}
|
|
4736
4736
|
};
|
|
@@ -4749,9 +4749,9 @@ function wo({
|
|
|
4749
4749
|
command: u == null ? void 0 : u.command,
|
|
4750
4750
|
edit: u == null ? void 0 : u.edit
|
|
4751
4751
|
};
|
|
4752
|
-
return
|
|
4752
|
+
return J(Je, p);
|
|
4753
4753
|
},
|
|
4754
|
-
[c, a, j, y, b,
|
|
4754
|
+
[c, a, j, y, b, J, L, d]
|
|
4755
4755
|
), H = ue(() => {
|
|
4756
4756
|
const u = Object.keys(W).length > 0;
|
|
4757
4757
|
if (!j && !u)
|
|
@@ -4760,7 +4760,7 @@ function wo({
|
|
|
4760
4760
|
return x.forEach((h) => p.set(h.id, h)), Object.values(W).forEach((h) => {
|
|
4761
4761
|
p.set(h.id, h);
|
|
4762
4762
|
}), Array.from(p.values());
|
|
4763
|
-
}, [j, W, x]),
|
|
4763
|
+
}, [j, W, x]), B = ue(
|
|
4764
4764
|
() => ({
|
|
4765
4765
|
isStreaming: j,
|
|
4766
4766
|
error: O,
|
|
@@ -4778,7 +4778,7 @@ function wo({
|
|
|
4778
4778
|
}),
|
|
4779
4779
|
[j, O, U, L, l, E, H]
|
|
4780
4780
|
);
|
|
4781
|
-
return /* @__PURE__ */ ke(kn.Provider, { value:
|
|
4781
|
+
return /* @__PURE__ */ ke(kn.Provider, { value: B, children: e });
|
|
4782
4782
|
}
|
|
4783
4783
|
function Re(e) {
|
|
4784
4784
|
const t = V(e);
|
|
@@ -5176,8 +5176,9 @@ function No(e) {
|
|
|
5176
5176
|
interrupt: (s == null ? void 0 : s.interrupt) || null,
|
|
5177
5177
|
respondToInterrupt: (s == null ? void 0 : s.respondToInterrupt) || (async () => {
|
|
5178
5178
|
}),
|
|
5179
|
-
// Streaming Status
|
|
5180
|
-
|
|
5179
|
+
// Streaming Status
|
|
5180
|
+
// Even in standalone mode, allow streaming state/stop if a stream context exists.
|
|
5181
|
+
isStreaming: (a == null ? void 0 : a.isStreaming) || !1,
|
|
5181
5182
|
activeMessageId: (a == null ? void 0 : a.activeMessageId) || null,
|
|
5182
5183
|
connectionState: (a == null ? void 0 : a.connectionState) || "disconnected",
|
|
5183
5184
|
streamingAssistantId: a != null && a.isStreaming && ((R = s == null ? void 0 : s.metadata) != null && R.assemblingMessageId) ? s.metadata.assemblingMessageId : null,
|
|
@@ -5240,7 +5241,7 @@ function Xo({
|
|
|
5240
5241
|
W(u);
|
|
5241
5242
|
},
|
|
5242
5243
|
[W]
|
|
5243
|
-
),
|
|
5244
|
+
), J = async (u, p) => {
|
|
5244
5245
|
const h = Array.isArray(p) ? { files: p } : p ?? {}, A = h.files ?? [], S = h.contentParts ?? [], _ = u.trim();
|
|
5245
5246
|
if (!(!_ && A.length === 0 && S.length === 0))
|
|
5246
5247
|
try {
|
|
@@ -5251,7 +5252,7 @@ function Xo({
|
|
|
5251
5252
|
} catch (se) {
|
|
5252
5253
|
throw console.error("Failed to upload file", X.name, se), new Error(`Failed to upload ${X.name}`);
|
|
5253
5254
|
}
|
|
5254
|
-
}),
|
|
5255
|
+
}), $ = (await Promise.all(G)).map(({ record: X }) => {
|
|
5255
5256
|
const se = X.mime_type;
|
|
5256
5257
|
return se.startsWith("image/") ? {
|
|
5257
5258
|
type: "image_url",
|
|
@@ -5263,7 +5264,7 @@ function Xo({
|
|
|
5263
5264
|
name: X.filename,
|
|
5264
5265
|
size: X.size
|
|
5265
5266
|
};
|
|
5266
|
-
}), ae = [...S,
|
|
5267
|
+
}), ae = [...S, ...$], re = g ? (M == null ? void 0 : M.checkpointId) ?? n ?? void 0 : n ?? void 0, de = g ? (M == null ? void 0 : M.checkpointNs) ?? r ?? void 0 : r ?? void 0;
|
|
5267
5268
|
await e(
|
|
5268
5269
|
{
|
|
5269
5270
|
text: _ || "",
|
|
@@ -5280,11 +5281,11 @@ function Xo({
|
|
|
5280
5281
|
d ? { onEvent: d } : void 0
|
|
5281
5282
|
), o == null || o(_), l(!0), y && (m && localStorage.removeItem(xt(m)), W("")), v(null), b(null), x(""), R(null);
|
|
5282
5283
|
} catch (G) {
|
|
5283
|
-
const
|
|
5284
|
-
v(
|
|
5284
|
+
const q = (G == null ? void 0 : G.message) || "Failed to send message";
|
|
5285
|
+
v(q), a == null || a(q), l(!1);
|
|
5285
5286
|
}
|
|
5286
5287
|
}, Y = (u, p) => {
|
|
5287
|
-
p ||
|
|
5288
|
+
p || J(u, { files: [] });
|
|
5288
5289
|
}, Z = P(
|
|
5289
5290
|
async (u) => {
|
|
5290
5291
|
await e(
|
|
@@ -5349,7 +5350,7 @@ function Xo({
|
|
|
5349
5350
|
setDismissError: L,
|
|
5350
5351
|
composerValue: F,
|
|
5351
5352
|
handleComposerChange: K,
|
|
5352
|
-
handleSendMessage:
|
|
5353
|
+
handleSendMessage: J,
|
|
5353
5354
|
handleQuickPrompt: Y,
|
|
5354
5355
|
handleExcelUpload: Z,
|
|
5355
5356
|
startEditing: T,
|