@teodorruskvi/chat-core 0.1.57 → 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 CHANGED
@@ -1,9 +1,9 @@
1
- var Ht = Object.defineProperty;
2
- var Gt = (e, t, n) => t in e ? Ht(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
1
+ var qt = Object.defineProperty;
2
+ var Gt = (e, t, n) => t in e ? qt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var at = (e, t, n) => Gt(e, typeof t != "symbol" ? t + "" : t, n);
4
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 D, useRef as H, useEffect as Y, useCallback as N, useMemo as Z, useReducer as Wt } from "react";
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 = "";
@@ -29,8 +29,8 @@ const et = "-", Yt = (e) => {
29
29
  return i[0] === "" && i.length !== 1 && i.shift(), vt(i, t) || Zt(a);
30
30
  },
31
31
  getConflictingClassGroupIds: (a, i) => {
32
- const d = n[a] || [];
33
- return i && r[a] ? [...d, ...r[a]] : d;
32
+ const u = n[a] || [];
33
+ return i && r[a] ? [...u, ...r[a]] : u;
34
34
  }
35
35
  };
36
36
  }, vt = (e, t) => {
@@ -120,40 +120,40 @@ const et = "-", Yt = (e) => {
120
120
  n.has(s) ? n.set(s, a) : o(s, a);
121
121
  }
122
122
  };
123
- }, xt = "!", on = (e) => {
123
+ }, xt = "!", sn = (e) => {
124
124
  const {
125
125
  separator: t,
126
126
  experimentalParseClassName: n
127
127
  } = e, r = t.length === 1, o = t[0], s = t.length, a = (i) => {
128
- const d = [];
129
- let c = 0, l = 0, f;
130
- for (let v = 0; v < i.length; v++) {
131
- let x = i[v];
132
- if (c === 0) {
133
- if (x === o && (r || i.slice(v, v + s) === t)) {
134
- d.push(i.slice(l, v)), l = v + s;
128
+ const u = [];
129
+ let l = 0, c = 0, d;
130
+ for (let h = 0; h < i.length; h++) {
131
+ let x = i[h];
132
+ if (l === 0) {
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
- f = v;
138
+ d = h;
139
139
  continue;
140
140
  }
141
141
  }
142
- x === "[" ? c++ : x === "]" && c--;
142
+ x === "[" ? l++ : x === "]" && l--;
143
143
  }
144
- const p = d.length === 0 ? i : i.substring(l), g = p.startsWith(xt), I = g ? p.substring(1) : p, u = f && f > l ? f - l : void 0;
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
- modifiers: d,
147
- hasImportantModifier: g,
146
+ modifiers: u,
147
+ hasImportantModifier: p,
148
148
  baseClassName: I,
149
- maybePostfixModifierPosition: u
149
+ maybePostfixModifierPosition: f
150
150
  };
151
151
  };
152
152
  return n ? (i) => n({
153
153
  className: i,
154
154
  parseClassName: a
155
155
  }) : a;
156
- }, sn = (e) => {
156
+ }, on = (e) => {
157
157
  if (e.length <= 1)
158
158
  return e;
159
159
  const t = [];
@@ -163,7 +163,7 @@ const et = "-", Yt = (e) => {
163
163
  }), t.push(...n.sort()), t;
164
164
  }, an = (e) => ({
165
165
  cache: rn(e.cacheSize),
166
- parseClassName: on(e),
166
+ parseClassName: sn(e),
167
167
  ...Yt(e)
168
168
  }), cn = /\s+/, ln = (e, t) => {
169
169
  const {
@@ -172,35 +172,35 @@ const et = "-", Yt = (e) => {
172
172
  getConflictingClassGroupIds: o
173
173
  } = t, s = [], a = e.trim().split(cn);
174
174
  let i = "";
175
- for (let d = a.length - 1; d >= 0; d -= 1) {
176
- const c = a[d], {
177
- modifiers: l,
178
- hasImportantModifier: f,
179
- baseClassName: p,
180
- maybePostfixModifierPosition: g
181
- } = n(c);
182
- let I = !!g, u = r(I ? p.substring(0, g) : p);
183
- if (!u) {
175
+ for (let u = a.length - 1; u >= 0; u -= 1) {
176
+ const l = a[u], {
177
+ modifiers: c,
178
+ hasImportantModifier: d,
179
+ baseClassName: m,
180
+ maybePostfixModifierPosition: p
181
+ } = n(l);
182
+ let I = !!p, f = r(I ? m.substring(0, p) : m);
183
+ if (!f) {
184
184
  if (!I) {
185
- i = c + (i.length > 0 ? " " + i : i);
185
+ i = l + (i.length > 0 ? " " + i : i);
186
186
  continue;
187
187
  }
188
- if (u = r(p), !u) {
189
- i = c + (i.length > 0 ? " " + i : i);
188
+ if (f = r(m), !f) {
189
+ i = l + (i.length > 0 ? " " + i : i);
190
190
  continue;
191
191
  }
192
192
  I = !1;
193
193
  }
194
- const v = sn(l).join(":"), x = f ? v + xt : v, S = x + u;
194
+ const h = on(c).join(":"), x = d ? h + xt : h, S = x + f;
195
195
  if (s.includes(S))
196
196
  continue;
197
197
  s.push(S);
198
- const A = o(u, I);
198
+ const A = o(f, I);
199
199
  for (let w = 0; w < A.length; ++w) {
200
- const b = A[w];
201
- s.push(x + b);
200
+ const k = A[w];
201
+ s.push(x + k);
202
202
  }
203
- i = c + (i.length > 0 ? " " + i : i);
203
+ i = l + (i.length > 0 ? " " + i : i);
204
204
  }
205
205
  return i;
206
206
  };
@@ -220,16 +220,16 @@ const At = (e) => {
220
220
  };
221
221
  function un(e, ...t) {
222
222
  let n, r, o, s = a;
223
- function a(d) {
224
- const c = t.reduce((l, f) => f(l), e());
225
- return n = an(c), r = n.cache.get, o = n.cache.set, s = i, i(d);
223
+ function a(u) {
224
+ const l = t.reduce((c, d) => d(c), e());
225
+ return n = an(l), r = n.cache.get, o = n.cache.set, s = i, i(u);
226
226
  }
227
- function i(d) {
228
- const c = r(d);
229
- if (c)
230
- return c;
231
- const l = ln(d, n);
232
- return o(d, l), l;
227
+ function i(u) {
228
+ const l = r(u);
229
+ if (l)
230
+ return l;
231
+ const c = ln(u, n);
232
+ return o(u, c), c;
233
233
  }
234
234
  return function() {
235
235
  return s(dn.apply(null, arguments));
@@ -238,7 +238,7 @@ function un(e, ...t) {
238
238
  const q = (e) => {
239
239
  const t = (n) => n[e] || [];
240
240
  return t.isThemeGetter = !0, t;
241
- }, Tt = /^\[(?:([a-z-]+):)?(.+)\]$/i, fn = /^\d+\/\d+$/, pn = /* @__PURE__ */ new Set(["px", "full", "screen"]), gn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, mn = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/, yn = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, hn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, bn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, pe = (e) => Te(e) || pn.has(e) || fn.test(e), Ie = (e) => Ee(e, "length", Sn), Te = (e) => !!e && !Number.isNaN(Number(e)), qe = (e) => Ee(e, "number", Te), _e = (e) => !!e && Number.isInteger(Number(e)), wn = (e) => e.endsWith("%") && Te(e.slice(0, -1)), z = (e) => Tt.test(e), ve = (e) => gn.test(e), kn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), In = (e) => Ee(e, kn, St), vn = (e) => Ee(e, "position", St), xn = /* @__PURE__ */ new Set(["image", "url"]), An = (e) => Ee(e, xn, Cn), Tn = (e) => Ee(e, "", Mn), Ne = () => !0, Ee = (e, t, n) => {
241
+ }, Tt = /^\[(?:([a-z-]+):)?(.+)\]$/i, fn = /^\d+\/\d+$/, pn = /* @__PURE__ */ new Set(["px", "full", "screen"]), gn = /^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/, mn = /\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/, yn = /^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/, hn = /^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/, bn = /^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/, pe = (e) => Te(e) || pn.has(e) || fn.test(e), Ie = (e) => Ee(e, "length", Sn), Te = (e) => !!e && !Number.isNaN(Number(e)), Ve = (e) => Ee(e, "number", Te), _e = (e) => !!e && Number.isInteger(Number(e)), wn = (e) => e.endsWith("%") && Te(e.slice(0, -1)), R = (e) => Tt.test(e), ve = (e) => gn.test(e), kn = /* @__PURE__ */ new Set(["length", "size", "percentage"]), In = (e) => Ee(e, kn, St), vn = (e) => Ee(e, "position", St), xn = /* @__PURE__ */ new Set(["image", "url"]), An = (e) => Ee(e, xn, Cn), Tn = (e) => Ee(e, "", Mn), Ne = () => !0, Ee = (e, t, n) => {
242
242
  const r = Tt.exec(e);
243
243
  return r ? r[1] ? typeof t == "string" ? r[1] === t : t.has(r[1]) : n(r[2]) : !1;
244
244
  }, Sn = (e) => (
@@ -247,34 +247,34 @@ 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"), o = q("borderColor"), s = q("borderRadius"), a = q("borderSpacing"), i = q("borderWidth"), d = q("contrast"), c = q("grayscale"), l = q("hueRotate"), f = q("invert"), p = q("gap"), g = q("gradientColorStops"), I = q("gradientColorStopPositions"), u = q("inset"), v = q("margin"), x = q("opacity"), S = q("padding"), A = q("saturate"), w = q("scale"), b = q("sepia"), y = q("skew"), T = q("space"), m = q("translate"), k = () => ["auto", "contain", "none"], E = () => ["auto", "hidden", "clip", "visible", "scroll"], U = () => ["auto", z, t], M = () => [z, t], $ = () => ["", pe, Ie], F = () => ["auto", Te, z], _ = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], O = () => ["solid", "dashed", "dotted", "double", "none"], R = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], W = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], B = () => ["", "0", z], L = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], h = () => [Te, z];
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: ":",
254
254
  theme: {
255
255
  colors: [Ne],
256
256
  spacing: [pe, Ie],
257
- blur: ["none", "", ve, z],
258
- brightness: h(),
257
+ blur: ["none", "", ve, R],
258
+ brightness: g(),
259
259
  borderColor: [e],
260
- borderRadius: ["none", "", "full", ve, z],
260
+ borderRadius: ["none", "", "full", ve, R],
261
261
  borderSpacing: M(),
262
262
  borderWidth: $(),
263
- contrast: h(),
264
- grayscale: B(),
265
- hueRotate: h(),
266
- invert: B(),
263
+ contrast: g(),
264
+ grayscale: j(),
265
+ hueRotate: g(),
266
+ invert: j(),
267
267
  gap: M(),
268
268
  gradientColorStops: [e],
269
269
  gradientColorStopPositions: [wn, Ie],
270
- inset: U(),
271
- margin: U(),
272
- opacity: h(),
270
+ inset: L(),
271
+ margin: L(),
272
+ opacity: g(),
273
273
  padding: M(),
274
- saturate: h(),
275
- scale: h(),
276
- sepia: B(),
277
- skew: h(),
274
+ saturate: g(),
275
+ scale: g(),
276
+ sepia: j(),
277
+ skew: g(),
278
278
  space: M(),
279
279
  translate: M()
280
280
  },
@@ -285,7 +285,7 @@ const q = (e) => {
285
285
  * @see https://tailwindcss.com/docs/aspect-ratio
286
286
  */
287
287
  aspect: [{
288
- aspect: ["auto", "square", "video", z]
288
+ aspect: ["auto", "square", "video", R]
289
289
  }],
290
290
  /**
291
291
  * Container
@@ -304,14 +304,14 @@ const q = (e) => {
304
304
  * @see https://tailwindcss.com/docs/break-after
305
305
  */
306
306
  "break-after": [{
307
- "break-after": L()
307
+ "break-after": G()
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": L()
314
+ "break-before": G()
315
315
  }],
316
316
  /**
317
317
  * Break Inside
@@ -370,49 +370,49 @@ const q = (e) => {
370
370
  * @see https://tailwindcss.com/docs/object-position
371
371
  */
372
372
  "object-position": [{
373
- object: [..._(), z]
373
+ object: [...V(), R]
374
374
  }],
375
375
  /**
376
376
  * Overflow
377
377
  * @see https://tailwindcss.com/docs/overflow
378
378
  */
379
379
  overflow: [{
380
- overflow: E()
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": E()
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": E()
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: k()
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": k()
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": k()
415
+ "overscroll-y": v()
416
416
  }],
417
417
  /**
418
418
  * Position
@@ -424,63 +424,63 @@ const q = (e) => {
424
424
  * @see https://tailwindcss.com/docs/top-right-bottom-left
425
425
  */
426
426
  inset: [{
427
- inset: [u]
427
+ inset: [f]
428
428
  }],
429
429
  /**
430
430
  * Right / Left
431
431
  * @see https://tailwindcss.com/docs/top-right-bottom-left
432
432
  */
433
433
  "inset-x": [{
434
- "inset-x": [u]
434
+ "inset-x": [f]
435
435
  }],
436
436
  /**
437
437
  * Top / Bottom
438
438
  * @see https://tailwindcss.com/docs/top-right-bottom-left
439
439
  */
440
440
  "inset-y": [{
441
- "inset-y": [u]
441
+ "inset-y": [f]
442
442
  }],
443
443
  /**
444
444
  * Start
445
445
  * @see https://tailwindcss.com/docs/top-right-bottom-left
446
446
  */
447
447
  start: [{
448
- start: [u]
448
+ start: [f]
449
449
  }],
450
450
  /**
451
451
  * End
452
452
  * @see https://tailwindcss.com/docs/top-right-bottom-left
453
453
  */
454
454
  end: [{
455
- end: [u]
455
+ end: [f]
456
456
  }],
457
457
  /**
458
458
  * Top
459
459
  * @see https://tailwindcss.com/docs/top-right-bottom-left
460
460
  */
461
461
  top: [{
462
- top: [u]
462
+ top: [f]
463
463
  }],
464
464
  /**
465
465
  * Right
466
466
  * @see https://tailwindcss.com/docs/top-right-bottom-left
467
467
  */
468
468
  right: [{
469
- right: [u]
469
+ right: [f]
470
470
  }],
471
471
  /**
472
472
  * Bottom
473
473
  * @see https://tailwindcss.com/docs/top-right-bottom-left
474
474
  */
475
475
  bottom: [{
476
- bottom: [u]
476
+ bottom: [f]
477
477
  }],
478
478
  /**
479
479
  * Left
480
480
  * @see https://tailwindcss.com/docs/top-right-bottom-left
481
481
  */
482
482
  left: [{
483
- left: [u]
483
+ left: [f]
484
484
  }],
485
485
  /**
486
486
  * Visibility
@@ -492,7 +492,7 @@ const q = (e) => {
492
492
  * @see https://tailwindcss.com/docs/z-index
493
493
  */
494
494
  z: [{
495
- z: ["auto", _e, z]
495
+ z: ["auto", _e, R]
496
496
  }],
497
497
  // Flexbox and Grid
498
498
  /**
@@ -500,7 +500,7 @@ const q = (e) => {
500
500
  * @see https://tailwindcss.com/docs/flex-basis
501
501
  */
502
502
  basis: [{
503
- basis: U()
503
+ basis: L()
504
504
  }],
505
505
  /**
506
506
  * Flex Direction
@@ -521,28 +521,28 @@ const q = (e) => {
521
521
  * @see https://tailwindcss.com/docs/flex
522
522
  */
523
523
  flex: [{
524
- flex: ["1", "auto", "initial", "none", z]
524
+ flex: ["1", "auto", "initial", "none", R]
525
525
  }],
526
526
  /**
527
527
  * Flex Grow
528
528
  * @see https://tailwindcss.com/docs/flex-grow
529
529
  */
530
530
  grow: [{
531
- grow: B()
531
+ grow: j()
532
532
  }],
533
533
  /**
534
534
  * Flex Shrink
535
535
  * @see https://tailwindcss.com/docs/flex-shrink
536
536
  */
537
537
  shrink: [{
538
- shrink: B()
538
+ shrink: j()
539
539
  }],
540
540
  /**
541
541
  * Order
542
542
  * @see https://tailwindcss.com/docs/order
543
543
  */
544
544
  order: [{
545
- order: ["first", "last", "none", _e, z]
545
+ order: ["first", "last", "none", _e, R]
546
546
  }],
547
547
  /**
548
548
  * Grid Template Columns
@@ -557,22 +557,22 @@ const q = (e) => {
557
557
  */
558
558
  "col-start-end": [{
559
559
  col: ["auto", {
560
- span: ["full", _e, z]
561
- }, z]
560
+ span: ["full", _e, R]
561
+ }, R]
562
562
  }],
563
563
  /**
564
564
  * Grid Column Start
565
565
  * @see https://tailwindcss.com/docs/grid-column
566
566
  */
567
567
  "col-start": [{
568
- "col-start": F()
568
+ "col-start": U()
569
569
  }],
570
570
  /**
571
571
  * Grid Column End
572
572
  * @see https://tailwindcss.com/docs/grid-column
573
573
  */
574
574
  "col-end": [{
575
- "col-end": F()
575
+ "col-end": U()
576
576
  }],
577
577
  /**
578
578
  * Grid Template Rows
@@ -587,22 +587,22 @@ const q = (e) => {
587
587
  */
588
588
  "row-start-end": [{
589
589
  row: ["auto", {
590
- span: [_e, z]
591
- }, z]
590
+ span: [_e, R]
591
+ }, R]
592
592
  }],
593
593
  /**
594
594
  * Grid Row Start
595
595
  * @see https://tailwindcss.com/docs/grid-row
596
596
  */
597
597
  "row-start": [{
598
- "row-start": F()
598
+ "row-start": U()
599
599
  }],
600
600
  /**
601
601
  * Grid Row End
602
602
  * @see https://tailwindcss.com/docs/grid-row
603
603
  */
604
604
  "row-end": [{
605
- "row-end": F()
605
+ "row-end": U()
606
606
  }],
607
607
  /**
608
608
  * Grid Auto Flow
@@ -616,42 +616,42 @@ const q = (e) => {
616
616
  * @see https://tailwindcss.com/docs/grid-auto-columns
617
617
  */
618
618
  "auto-cols": [{
619
- "auto-cols": ["auto", "min", "max", "fr", z]
619
+ "auto-cols": ["auto", "min", "max", "fr", R]
620
620
  }],
621
621
  /**
622
622
  * Grid Auto Rows
623
623
  * @see https://tailwindcss.com/docs/grid-auto-rows
624
624
  */
625
625
  "auto-rows": [{
626
- "auto-rows": ["auto", "min", "max", "fr", z]
626
+ "auto-rows": ["auto", "min", "max", "fr", R]
627
627
  }],
628
628
  /**
629
629
  * Gap
630
630
  * @see https://tailwindcss.com/docs/gap
631
631
  */
632
632
  gap: [{
633
- gap: [p]
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": [p]
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": [p]
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", ...W()]
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", ...W(), "baseline"]
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": [...W(), "baseline"]
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: [v]
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: [v]
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: [v]
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: [v]
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: [v]
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: [v]
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: [v]
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: [v]
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: [v]
837
+ ml: [h]
838
838
  }],
839
839
  /**
840
840
  * Space Between X
@@ -866,21 +866,21 @@ const q = (e) => {
866
866
  * @see https://tailwindcss.com/docs/width
867
867
  */
868
868
  w: [{
869
- w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", z, t]
869
+ w: ["auto", "min", "max", "fit", "svw", "lvw", "dvw", R, t]
870
870
  }],
871
871
  /**
872
872
  * Min-Width
873
873
  * @see https://tailwindcss.com/docs/min-width
874
874
  */
875
875
  "min-w": [{
876
- "min-w": [z, t, "min", "max", "fit"]
876
+ "min-w": [R, t, "min", "max", "fit"]
877
877
  }],
878
878
  /**
879
879
  * Max-Width
880
880
  * @see https://tailwindcss.com/docs/max-width
881
881
  */
882
882
  "max-w": [{
883
- "max-w": [z, t, "none", "full", "min", "max", "fit", "prose", {
883
+ "max-w": [R, t, "none", "full", "min", "max", "fit", "prose", {
884
884
  screen: [ve]
885
885
  }, ve]
886
886
  }],
@@ -889,28 +889,28 @@ const q = (e) => {
889
889
  * @see https://tailwindcss.com/docs/height
890
890
  */
891
891
  h: [{
892
- h: [z, t, "auto", "min", "max", "fit", "svh", "lvh", "dvh"]
892
+ h: [R, t, "auto", "min", "max", "fit", "svh", "lvh", "dvh"]
893
893
  }],
894
894
  /**
895
895
  * Min-Height
896
896
  * @see https://tailwindcss.com/docs/min-height
897
897
  */
898
898
  "min-h": [{
899
- "min-h": [z, t, "min", "max", "fit", "svh", "lvh", "dvh"]
899
+ "min-h": [R, t, "min", "max", "fit", "svh", "lvh", "dvh"]
900
900
  }],
901
901
  /**
902
902
  * Max-Height
903
903
  * @see https://tailwindcss.com/docs/max-height
904
904
  */
905
905
  "max-h": [{
906
- "max-h": [z, t, "min", "max", "fit", "svh", "lvh", "dvh"]
906
+ "max-h": [R, t, "min", "max", "fit", "svh", "lvh", "dvh"]
907
907
  }],
908
908
  /**
909
909
  * Size
910
910
  * @see https://tailwindcss.com/docs/size
911
911
  */
912
912
  size: [{
913
- size: [z, t, "auto", "min", "max", "fit"]
913
+ size: [R, t, "auto", "min", "max", "fit"]
914
914
  }],
915
915
  // Typography
916
916
  /**
@@ -935,7 +935,7 @@ const q = (e) => {
935
935
  * @see https://tailwindcss.com/docs/font-weight
936
936
  */
937
937
  "font-weight": [{
938
- font: ["thin", "extralight", "light", "normal", "medium", "semibold", "bold", "extrabold", "black", qe]
938
+ font: ["thin", "extralight", "light", "normal", "medium", "semibold", "bold", "extrabold", "black", Ve]
939
939
  }],
940
940
  /**
941
941
  * Font Family
@@ -979,35 +979,35 @@ const q = (e) => {
979
979
  * @see https://tailwindcss.com/docs/letter-spacing
980
980
  */
981
981
  tracking: [{
982
- tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", z]
982
+ tracking: ["tighter", "tight", "normal", "wide", "wider", "widest", R]
983
983
  }],
984
984
  /**
985
985
  * Line Clamp
986
986
  * @see https://tailwindcss.com/docs/line-clamp
987
987
  */
988
988
  "line-clamp": [{
989
- "line-clamp": ["none", Te, qe]
989
+ "line-clamp": ["none", Te, Ve]
990
990
  }],
991
991
  /**
992
992
  * Line Height
993
993
  * @see https://tailwindcss.com/docs/line-height
994
994
  */
995
995
  leading: [{
996
- leading: ["none", "tight", "snug", "normal", "relaxed", "loose", pe, z]
996
+ leading: ["none", "tight", "snug", "normal", "relaxed", "loose", pe, R]
997
997
  }],
998
998
  /**
999
999
  * List Style Image
1000
1000
  * @see https://tailwindcss.com/docs/list-style-image
1001
1001
  */
1002
1002
  "list-image": [{
1003
- "list-image": ["none", z]
1003
+ "list-image": ["none", R]
1004
1004
  }],
1005
1005
  /**
1006
1006
  * List Style Type
1007
1007
  * @see https://tailwindcss.com/docs/list-style-type
1008
1008
  */
1009
1009
  "list-style-type": [{
1010
- list: ["none", "disc", "decimal", z]
1010
+ list: ["none", "disc", "decimal", R]
1011
1011
  }],
1012
1012
  /**
1013
1013
  * List Style Position
@@ -1062,7 +1062,7 @@ const q = (e) => {
1062
1062
  * @see https://tailwindcss.com/docs/text-decoration-style
1063
1063
  */
1064
1064
  "text-decoration-style": [{
1065
- decoration: [...O(), "wavy"]
1065
+ decoration: [...P(), "wavy"]
1066
1066
  }],
1067
1067
  /**
1068
1068
  * Text Decoration Thickness
@@ -1076,7 +1076,7 @@ const q = (e) => {
1076
1076
  * @see https://tailwindcss.com/docs/text-underline-offset
1077
1077
  */
1078
1078
  "underline-offset": [{
1079
- "underline-offset": ["auto", pe, z]
1079
+ "underline-offset": ["auto", pe, R]
1080
1080
  }],
1081
1081
  /**
1082
1082
  * Text Decoration Color
@@ -1114,7 +1114,7 @@ const q = (e) => {
1114
1114
  * @see https://tailwindcss.com/docs/vertical-align
1115
1115
  */
1116
1116
  "vertical-align": [{
1117
- align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super", z]
1117
+ align: ["baseline", "top", "middle", "bottom", "text-top", "text-bottom", "sub", "super", R]
1118
1118
  }],
1119
1119
  /**
1120
1120
  * Whitespace
@@ -1142,7 +1142,7 @@ const q = (e) => {
1142
1142
  * @see https://tailwindcss.com/docs/content
1143
1143
  */
1144
1144
  content: [{
1145
- content: ["none", z]
1145
+ content: ["none", R]
1146
1146
  }],
1147
1147
  // Backgrounds
1148
1148
  /**
@@ -1179,7 +1179,7 @@ const q = (e) => {
1179
1179
  * @see https://tailwindcss.com/docs/background-position
1180
1180
  */
1181
1181
  "bg-position": [{
1182
- bg: [..._(), vn]
1182
+ bg: [...V(), vn]
1183
1183
  }],
1184
1184
  /**
1185
1185
  * Background Repeat
@@ -1239,21 +1239,21 @@ const q = (e) => {
1239
1239
  * @see https://tailwindcss.com/docs/gradient-color-stops
1240
1240
  */
1241
1241
  "gradient-from": [{
1242
- from: [g]
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: [g]
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: [g]
1256
+ to: [p]
1257
1257
  }],
1258
1258
  // Borders
1259
1259
  /**
@@ -1436,7 +1436,7 @@ const q = (e) => {
1436
1436
  * @see https://tailwindcss.com/docs/border-style
1437
1437
  */
1438
1438
  "border-style": [{
1439
- border: [...O(), "hidden"]
1439
+ border: [...P(), "hidden"]
1440
1440
  }],
1441
1441
  /**
1442
1442
  * Divide Width X
@@ -1474,7 +1474,7 @@ const q = (e) => {
1474
1474
  * @see https://tailwindcss.com/docs/divide-style
1475
1475
  */
1476
1476
  "divide-style": [{
1477
- divide: O()
1477
+ divide: P()
1478
1478
  }],
1479
1479
  /**
1480
1480
  * Border Color
@@ -1551,14 +1551,14 @@ const q = (e) => {
1551
1551
  * @see https://tailwindcss.com/docs/outline-style
1552
1552
  */
1553
1553
  "outline-style": [{
1554
- outline: ["", ...O()]
1554
+ outline: ["", ...P()]
1555
1555
  }],
1556
1556
  /**
1557
1557
  * Outline Offset
1558
1558
  * @see https://tailwindcss.com/docs/outline-offset
1559
1559
  */
1560
1560
  "outline-offset": [{
1561
- "outline-offset": [pe, z]
1561
+ "outline-offset": [pe, R]
1562
1562
  }],
1563
1563
  /**
1564
1564
  * Outline Width
@@ -1641,14 +1641,14 @@ const q = (e) => {
1641
1641
  * @see https://tailwindcss.com/docs/mix-blend-mode
1642
1642
  */
1643
1643
  "mix-blend": [{
1644
- "mix-blend": [...R(), "plus-lighter", "plus-darker"]
1644
+ "mix-blend": [...F(), "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": R()
1651
+ "bg-blend": F()
1652
1652
  }],
1653
1653
  // Filters
1654
1654
  /**
@@ -1678,35 +1678,35 @@ const q = (e) => {
1678
1678
  * @see https://tailwindcss.com/docs/contrast
1679
1679
  */
1680
1680
  contrast: [{
1681
- contrast: [d]
1681
+ contrast: [u]
1682
1682
  }],
1683
1683
  /**
1684
1684
  * Drop Shadow
1685
1685
  * @see https://tailwindcss.com/docs/drop-shadow
1686
1686
  */
1687
1687
  "drop-shadow": [{
1688
- "drop-shadow": ["", "none", ve, z]
1688
+ "drop-shadow": ["", "none", ve, R]
1689
1689
  }],
1690
1690
  /**
1691
1691
  * Grayscale
1692
1692
  * @see https://tailwindcss.com/docs/grayscale
1693
1693
  */
1694
1694
  grayscale: [{
1695
- grayscale: [c]
1695
+ grayscale: [l]
1696
1696
  }],
1697
1697
  /**
1698
1698
  * Hue Rotate
1699
1699
  * @see https://tailwindcss.com/docs/hue-rotate
1700
1700
  */
1701
1701
  "hue-rotate": [{
1702
- "hue-rotate": [l]
1702
+ "hue-rotate": [c]
1703
1703
  }],
1704
1704
  /**
1705
1705
  * Invert
1706
1706
  * @see https://tailwindcss.com/docs/invert
1707
1707
  */
1708
1708
  invert: [{
1709
- invert: [f]
1709
+ invert: [d]
1710
1710
  }],
1711
1711
  /**
1712
1712
  * Saturate
@@ -1720,7 +1720,7 @@ const q = (e) => {
1720
1720
  * @see https://tailwindcss.com/docs/sepia
1721
1721
  */
1722
1722
  sepia: [{
1723
- sepia: [b]
1723
+ sepia: [k]
1724
1724
  }],
1725
1725
  /**
1726
1726
  * Backdrop Filter
@@ -1749,28 +1749,28 @@ const q = (e) => {
1749
1749
  * @see https://tailwindcss.com/docs/backdrop-contrast
1750
1750
  */
1751
1751
  "backdrop-contrast": [{
1752
- "backdrop-contrast": [d]
1752
+ "backdrop-contrast": [u]
1753
1753
  }],
1754
1754
  /**
1755
1755
  * Backdrop Grayscale
1756
1756
  * @see https://tailwindcss.com/docs/backdrop-grayscale
1757
1757
  */
1758
1758
  "backdrop-grayscale": [{
1759
- "backdrop-grayscale": [c]
1759
+ "backdrop-grayscale": [l]
1760
1760
  }],
1761
1761
  /**
1762
1762
  * Backdrop Hue Rotate
1763
1763
  * @see https://tailwindcss.com/docs/backdrop-hue-rotate
1764
1764
  */
1765
1765
  "backdrop-hue-rotate": [{
1766
- "backdrop-hue-rotate": [l]
1766
+ "backdrop-hue-rotate": [c]
1767
1767
  }],
1768
1768
  /**
1769
1769
  * Backdrop Invert
1770
1770
  * @see https://tailwindcss.com/docs/backdrop-invert
1771
1771
  */
1772
1772
  "backdrop-invert": [{
1773
- "backdrop-invert": [f]
1773
+ "backdrop-invert": [d]
1774
1774
  }],
1775
1775
  /**
1776
1776
  * Backdrop Opacity
@@ -1791,7 +1791,7 @@ const q = (e) => {
1791
1791
  * @see https://tailwindcss.com/docs/backdrop-sepia
1792
1792
  */
1793
1793
  "backdrop-sepia": [{
1794
- "backdrop-sepia": [b]
1794
+ "backdrop-sepia": [k]
1795
1795
  }],
1796
1796
  // Tables
1797
1797
  /**
@@ -1842,35 +1842,35 @@ const q = (e) => {
1842
1842
  * @see https://tailwindcss.com/docs/transition-property
1843
1843
  */
1844
1844
  transition: [{
1845
- transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", z]
1845
+ transition: ["none", "all", "", "colors", "opacity", "shadow", "transform", R]
1846
1846
  }],
1847
1847
  /**
1848
1848
  * Transition Duration
1849
1849
  * @see https://tailwindcss.com/docs/transition-duration
1850
1850
  */
1851
1851
  duration: [{
1852
- duration: h()
1852
+ duration: g()
1853
1853
  }],
1854
1854
  /**
1855
1855
  * Transition Timing Function
1856
1856
  * @see https://tailwindcss.com/docs/transition-timing-function
1857
1857
  */
1858
1858
  ease: [{
1859
- ease: ["linear", "in", "out", "in-out", z]
1859
+ ease: ["linear", "in", "out", "in-out", R]
1860
1860
  }],
1861
1861
  /**
1862
1862
  * Transition Delay
1863
1863
  * @see https://tailwindcss.com/docs/transition-delay
1864
1864
  */
1865
1865
  delay: [{
1866
- delay: h()
1866
+ delay: g()
1867
1867
  }],
1868
1868
  /**
1869
1869
  * Animation
1870
1870
  * @see https://tailwindcss.com/docs/animation
1871
1871
  */
1872
1872
  animate: [{
1873
- animate: ["none", "spin", "ping", "pulse", "bounce", z]
1873
+ animate: ["none", "spin", "ping", "pulse", "bounce", R]
1874
1874
  }],
1875
1875
  // Transforms
1876
1876
  /**
@@ -1906,42 +1906,42 @@ const q = (e) => {
1906
1906
  * @see https://tailwindcss.com/docs/rotate
1907
1907
  */
1908
1908
  rotate: [{
1909
- rotate: [_e, z]
1909
+ rotate: [_e, R]
1910
1910
  }],
1911
1911
  /**
1912
1912
  * Translate X
1913
1913
  * @see https://tailwindcss.com/docs/translate
1914
1914
  */
1915
1915
  "translate-x": [{
1916
- "translate-x": [m]
1916
+ "translate-x": [y]
1917
1917
  }],
1918
1918
  /**
1919
1919
  * Translate Y
1920
1920
  * @see https://tailwindcss.com/docs/translate
1921
1921
  */
1922
1922
  "translate-y": [{
1923
- "translate-y": [m]
1923
+ "translate-y": [y]
1924
1924
  }],
1925
1925
  /**
1926
1926
  * Skew X
1927
1927
  * @see https://tailwindcss.com/docs/skew
1928
1928
  */
1929
1929
  "skew-x": [{
1930
- "skew-x": [y]
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": [y]
1937
+ "skew-y": [b]
1938
1938
  }],
1939
1939
  /**
1940
1940
  * Transform Origin
1941
1941
  * @see https://tailwindcss.com/docs/transform-origin
1942
1942
  */
1943
1943
  "transform-origin": [{
1944
- origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", z]
1944
+ origin: ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", R]
1945
1945
  }],
1946
1946
  // Interactivity
1947
1947
  /**
@@ -1963,7 +1963,7 @@ const q = (e) => {
1963
1963
  * @see https://tailwindcss.com/docs/cursor
1964
1964
  */
1965
1965
  cursor: [{
1966
- cursor: ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", "none", "context-menu", "progress", "cell", "crosshair", "vertical-text", "alias", "copy", "no-drop", "grab", "grabbing", "all-scroll", "col-resize", "row-resize", "n-resize", "e-resize", "s-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize", "ew-resize", "ns-resize", "nesw-resize", "nwse-resize", "zoom-in", "zoom-out", z]
1966
+ cursor: ["auto", "default", "pointer", "wait", "text", "move", "help", "not-allowed", "none", "context-menu", "progress", "cell", "crosshair", "vertical-text", "alias", "copy", "no-drop", "grab", "grabbing", "all-scroll", "col-resize", "row-resize", "n-resize", "e-resize", "s-resize", "w-resize", "ne-resize", "nw-resize", "se-resize", "sw-resize", "ew-resize", "ns-resize", "nesw-resize", "nwse-resize", "zoom-in", "zoom-out", R]
1967
1967
  }],
1968
1968
  /**
1969
1969
  * Caret Color
@@ -2185,7 +2185,7 @@ const q = (e) => {
2185
2185
  * @see https://tailwindcss.com/docs/will-change
2186
2186
  */
2187
2187
  "will-change": [{
2188
- "will-change": ["auto", "scroll", "contents", "transform", z]
2188
+ "will-change": ["auto", "scroll", "contents", "transform", R]
2189
2189
  }],
2190
2190
  // SVG
2191
2191
  /**
@@ -2200,7 +2200,7 @@ const q = (e) => {
2200
2200
  * @see https://tailwindcss.com/docs/stroke-width
2201
2201
  */
2202
2202
  "stroke-w": [{
2203
- stroke: [pe, Ie, qe]
2203
+ stroke: [pe, Ie, Ve]
2204
2204
  }],
2205
2205
  /**
2206
2206
  * Stroke
@@ -2276,7 +2276,7 @@ const q = (e) => {
2276
2276
  }
2277
2277
  };
2278
2278
  }, Pn = /* @__PURE__ */ un(En);
2279
- function ro(...e) {
2279
+ function rs(...e) {
2280
2280
  return Pn(Qt(e));
2281
2281
  }
2282
2282
  function _n(e) {
@@ -2397,7 +2397,7 @@ function Et(e) {
2397
2397
  return "";
2398
2398
  }
2399
2399
  }
2400
- function oo(e) {
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
  }
@@ -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 so(e) {
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, b, y, T;
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), o = Array.isArray(r) ? r.map(rt) : void 0, s = Dn(t.content ?? t.parts, !!(o != null && o.length)), a = t.id ?? `msg-${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`, i = t.createdAt ?? ((S = t.additionalKwargs) == null ? void 0 : S.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(), d = t.name ?? ((A = t.additionalKwargs) == null ? void 0 : A.agentName) ?? void 0, c = t.model ?? ((w = t.additionalKwargs) == null ? void 0 : w.model) ?? void 0, l = t.toolCallId ?? void 0, f = t.additionalKwargs ?? void 0, p = t.responseMetadata ?? void 0, g = t.checkpointId ?? ((b = t.additionalKwargs) == null ? void 0 : b.checkpointId) ?? void 0, I = t.checkpointNs ?? ((y = t.additionalKwargs) == null ? void 0 : y.checkpointNs) ?? void 0, u = typeof t.toolStreaming == "boolean" ? t.toolStreaming : !!((T = t.additionalKwargs) != null && T.toolStreaming);
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
2461
  content: s,
2462
2462
  createdAt: i,
2463
- name: d,
2464
- model: c,
2465
- toolCallId: l,
2463
+ name: u,
2464
+ model: l,
2465
+ toolCallId: c,
2466
2466
  toolCalls: o,
2467
- checkpointId: g,
2467
+ checkpointId: p,
2468
2468
  checkpointNs: I,
2469
- toolStreaming: u,
2470
- additionalKwargs: f,
2471
- responseMetadata: p,
2469
+ toolStreaming: f,
2470
+ additionalKwargs: d,
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
  }
@@ -2512,12 +2512,12 @@ function dt(e) {
2512
2512
  function ut(e) {
2513
2513
  return (Array.isArray(e.toolCalls) ? e.toolCalls : Mt(e)).map(rt);
2514
2514
  }
2515
- function He(e, t) {
2515
+ function qe(e, t) {
2516
2516
  return t.find(
2517
2517
  (n) => n.role === "tool" && (n.toolCallId === e || n.id === e)
2518
2518
  );
2519
2519
  }
2520
- function Vn(e, t) {
2520
+ function Hn(e, t) {
2521
2521
  const n = t.response ?? t.content;
2522
2522
  if (!n) return;
2523
2523
  const r = typeof n == "string" ? n : Et(n);
@@ -2533,33 +2533,33 @@ function Vn(e, t) {
2533
2533
  createdAt: e.createdAt
2534
2534
  };
2535
2535
  }
2536
- function qn(e, t = []) {
2536
+ function Vn(e, t = []) {
2537
2537
  if (Array.isArray(e)) {
2538
2538
  const o = e.filter((a) => a.role === "assistant").flatMap((a) => ut(a)), s = /* @__PURE__ */ new Map();
2539
2539
  return o.forEach((a) => s.set(a.id, a)), Array.from(s.values()).map((a) => {
2540
- var f, p, g;
2541
- const i = He(a.id, e) || He(a.id, t), d = Array.isArray((f = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : f.toolProgress) ? (p = i == null ? void 0 : i.additionalKwargs) == null ? void 0 : p.toolProgress : void 0, c = (i == null ? void 0 : i.artifact) ?? a.artifact, l = dt(a.status) ?? ((g = i == null ? void 0 : i.additionalKwargs) != null && g.toolStreaming ? "pending" : null) ?? (i ? "completed" : "pending");
2542
- if (i && !a.content && l === "completed") {
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
+ if (i && !a.content && c === "completed") {
2543
2543
  const I = ue(i);
2544
2544
  typeof I == "string" && (a.content = I);
2545
2545
  }
2546
2546
  return {
2547
2547
  call: a,
2548
2548
  result: i,
2549
- state: l,
2550
- progress: d,
2551
- artifact: c
2549
+ state: c,
2550
+ progress: u,
2551
+ artifact: l
2552
2552
  };
2553
2553
  });
2554
2554
  }
2555
2555
  if (e.role !== "assistant") return [];
2556
2556
  const n = ut(e);
2557
2557
  return n.length === 0 ? [] : n.map((r) => {
2558
- var d, c, l;
2559
- const o = He(r.id, t) ?? Vn(e, r), s = Array.isArray((d = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : d.toolProgress) ? (c = o == null ? void 0 : o.additionalKwargs) == null ? void 0 : c.toolProgress : void 0, a = (o == null ? void 0 : o.artifact) ?? r.artifact, i = dt(r.status) ?? ((l = o == null ? void 0 : o.additionalKwargs) != null && l.toolStreaming ? "pending" : null) ?? (o ? "completed" : "pending");
2558
+ var u, l, c;
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
2560
  if (o && !r.content && i === "completed") {
2561
- const f = ue(o);
2562
- typeof f == "string" && (r.content = f);
2561
+ const d = ue(o);
2562
+ typeof d == "string" && (r.content = d);
2563
2563
  }
2564
2564
  return {
2565
2565
  call: r,
@@ -2570,8 +2570,8 @@ function qn(e, t = []) {
2570
2570
  };
2571
2571
  });
2572
2572
  }
2573
- function ao(e, t = []) {
2574
- return qn(e, t).map((n) => n.artifact).filter((n) => !!n);
2573
+ function as(e, t = []) {
2574
+ return Vn(e, t).map((n) => n.artifact).filter((n) => !!n);
2575
2575
  }
2576
2576
  const ze = {
2577
2577
  authToken: "authToken",
@@ -2596,9 +2596,9 @@ function xe(e) {
2596
2596
  function _t(e) {
2597
2597
  return Qe.add(e), () => Qe.delete(e);
2598
2598
  }
2599
- const Hn = 12e4, Gn = 12e4;
2600
- let Ye = Hn, Nt = Gn;
2601
- const oe = Jt.create({
2599
+ const qn = 12e4, Gn = 12e4;
2600
+ let Ye = qn, Nt = Gn;
2601
+ const se = Jt.create({
2602
2602
  // BaseURL is set dynamically via ApiProvider -> api.updateConfig
2603
2603
  timeout: Ye,
2604
2604
  withCredentials: !0
@@ -2608,13 +2608,13 @@ 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, oe.defaults.timeout = Ye), n !== null && (Nt = n);
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
- oe.interceptors.request.use((e) => (Ke && (e.headers.Authorization = `Bearer ${Ke}`), e));
2617
- oe.interceptors.response.use(
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 {
@@ -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 oe.defaults.baseURL ? (await oe.get(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
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 oe.defaults.baseURL ? (await oe.post(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
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 oe.defaults.baseURL ? (await oe.put(e, t, n)).data : Promise.reject(new Error("API base URL is not configured"));
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 oe.defaults.baseURL ? (await oe.delete(e, t)).data : Promise.reject(new Error("API base URL is not configured"));
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 oe.defaults.baseURL || "";
2654
+ return se.defaults.baseURL || "";
2655
2655
  }
2656
2656
  updateConfig(t) {
2657
2657
  if (t.chatBaseUrl)
2658
- oe.defaults.baseURL = t.chatBaseUrl;
2658
+ se.defaults.baseURL = t.chatBaseUrl;
2659
2659
  else if (t.baseUrl) {
2660
2660
  const n = t.baseUrl.replace(/\/+$/, "");
2661
- oe.defaults.baseURL = n;
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,
@@ -2842,8 +2842,8 @@ 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 s = n.baseUrl, a = r.baseUrl, i = n.getAuthToken(), d = t.requestTimeoutMs !== void 0 || t.historyTimeoutMs !== void 0;
2846
- (t.baseUrl || t.chatBaseUrl || d) && (d || 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 }));
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
2848
  const o = {
2849
2849
  token: n.getAuthToken(),
@@ -2865,7 +2865,7 @@ async function rr(e) {
2865
2865
  const o = r.result, s = new Uint8Array(o);
2866
2866
  let a = "";
2867
2867
  const i = s.byteLength;
2868
- for (let d = 0; d < i; d++) a += String.fromCharCode(s[d]);
2868
+ for (let u = 0; u < i; u++) a += String.fromCharCode(s[u]);
2869
2869
  t(btoa(a));
2870
2870
  } catch (o) {
2871
2871
  n(o);
@@ -2873,7 +2873,7 @@ async function rr(e) {
2873
2873
  }, r.onerror = (o) => n(o), r.readAsArrayBuffer(e);
2874
2874
  });
2875
2875
  }
2876
- async function or(e = []) {
2876
+ async function sr(e = []) {
2877
2877
  const t = [], n = [];
2878
2878
  for (const r of e)
2879
2879
  try {
@@ -2896,10 +2896,10 @@ async function or(e = []) {
2896
2896
  }
2897
2897
  return { contentParts: t, filesInfo: n };
2898
2898
  }
2899
- function sr(e) {
2899
+ function or(e) {
2900
2900
  return e.filter((t) => t.type === "text").map((t) => t.text).join("");
2901
2901
  }
2902
- function io(e) {
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 co(e) {
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 lo(e) {
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":
@@ -3009,134 +3009,134 @@ function fr(e, t) {
3009
3009
  return "type" in n || (n.type = e), n;
3010
3010
  }
3011
3011
  function pr(e = {}) {
3012
- const t = e.baseUrl || "", n = e.streamPath ?? "/stream", [r, o] = D(e.token ?? null), s = H(e.headers ?? {}), a = e.credentials ?? "include", i = H(e);
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 d = N((m) => {
3017
- var U, M, $, F, _, O, R, W, B, L;
3018
- const k = i.current;
3019
- if (!k) return;
3020
- (U = k.onEvent) == null || U.call(k, m), m.type === "thread_info" && ((M = k.onThreadInfo) == null || M.call(k, m)), m.type === "values" && (($ = k.handleValuesEvent) == null || $.call(k, m)), m.type === "metadata" && ((F = k.onMetadataEvent) == null || F.call(k, m)), typeof m.type == "string" && (m.type === "custom" || m.type.startsWith("custom.")) && ((_ = k.onCustomEvent) == null || _.call(k, m)), m.type === "updates" && ((O = k.onUpdateEvent) == null || O.call(k, m)), m.type === "tool.end" ? (R = k.onToolEnd) == null || R.call(k, m) : m.type === "tool.start" && ((W = k.onToolStart) == null || W.call(k, m)), m.type === "heartbeat" && ((B = k.onHeartbeat) == null || B.call(k, m)), m.type === "token" && ((L = k.onToken) == null || L.call(k, m.token));
3021
- }, []), [c, l] = D(!1), [f, p] = D(null), [g, I] = D(!1), [u, v] = D(null), x = H(null), S = H(!0), A = H(null), w = N((m) => {
3022
- o(m);
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);
3023
3025
  }, []), b = N(() => {
3024
- p(null), v(null);
3025
- }, []), y = N(() => {
3026
3026
  var M, $;
3027
3027
  console.debug("[use-chat] stop() invoked - aborting stream");
3028
- const m = (M = A.current) == null ? void 0 : M.threadId, k = ($ = A.current) == null ? void 0 : $.runId, E = () => {
3029
- var F;
3030
- (F = x.current) == null || F.abort(), x.current = null, A.current = null, l(!1), I(!1);
3028
+ const y = (M = A.current) == null ? void 0 : M.threadId, v = ($ = A.current) == null ? void 0 : $.runId, _ = () => {
3029
+ var U;
3030
+ (U = x.current) == null || U.abort(), x.current = null, A.current = null, c(!1), I(!1);
3031
3031
  };
3032
- (k || m ? zt.cancelRun(k || m).catch((F) => {
3033
- console.warn("[use-chat] cancel run failed:", F);
3034
- }) : Promise.resolve()).finally(E);
3032
+ (v || y ? zt.cancelRun(v || y).catch((U) => {
3033
+ console.warn("[use-chat] cancel run failed:", U);
3034
+ }) : Promise.resolve()).finally(_);
3035
3035
  }, []), T = N(
3036
- (m) => {
3036
+ (y) => {
3037
3037
  x.current && (x.current.abort(), x.current = null);
3038
- const k = {
3039
- text: typeof m.content == "string" ? m.content : m.text,
3040
- threadId: m.threadId,
3041
- attachments: m.attachments,
3042
- payload: m.payload ? {
3043
- ...m.payload,
3044
- creativityLevel: m.payload.creativityLevel ?? "medium"
3038
+ const v = {
3039
+ text: typeof y.content == "string" ? y.content : y.text,
3040
+ threadId: y.threadId,
3041
+ attachments: y.attachments,
3042
+ payload: y.payload ? {
3043
+ ...y.payload,
3044
+ creativityLevel: y.payload.creativityLevel ?? "medium"
3045
3045
  } : { creativityLevel: "medium" },
3046
- config: m.config,
3047
- checkpointId: m.checkpointId,
3048
- checkpointNs: m.checkpointNs || void 0,
3049
- edit: m.edit ?? !1,
3050
- command: m.command
3046
+ config: y.config,
3047
+ checkpointId: y.checkpointId,
3048
+ checkpointNs: y.checkpointNs || void 0,
3049
+ edit: y.edit ?? !1,
3050
+ command: y.command
3051
3051
  };
3052
- l(!0), p(null), v(null);
3053
- const E = new AbortController();
3054
- x.current = E;
3055
- let U = null, M = !1;
3052
+ c(!0), m(null), h(null);
3053
+ const _ = new AbortController();
3054
+ x.current = _;
3055
+ let L = null, M = !1;
3056
3056
  return A.current = {
3057
- threadId: k.threadId ?? void 0,
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 $, F, _, O, R, W;
3063
+ var $, U, V, P, F, E;
3064
3064
  try {
3065
- let B = {};
3065
+ let j = {};
3066
3066
  try {
3067
3067
  if (r)
3068
- B = { Authorization: `Bearer ${r}` };
3068
+ j = { Authorization: `Bearer ${r}` };
3069
3069
  else if (typeof window < "u") {
3070
- const se = window.__AUTH_TOKEN__, he = (($ = window.localStorage) == null ? void 0 : $.getItem(ze.authToken)) || null;
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
- const be = (F = window.localStorage) == null ? void 0 : F.getItem(ze.chatSettings);
3074
- be && (X = ((_ = JSON.parse(be)) == null ? void 0 : _.apiKey) || null);
3073
+ const be = (U = window.localStorage) == null ? void 0 : U.getItem(ze.chatSettings);
3074
+ be && (X = ((V = JSON.parse(be)) == null ? void 0 : V.apiKey) || null);
3075
3075
  } catch {
3076
3076
  }
3077
- const Q = se || he || X || null;
3078
- Q && (B = { Authorization: `Bearer ${Q}` });
3077
+ const Q = oe || he || X || null;
3078
+ Q && (j = { Authorization: `Bearer ${Q}` });
3079
3079
  }
3080
3080
  } catch {
3081
3081
  }
3082
3082
  console.debug("[use-chat] POST", t + n);
3083
- let L = {};
3083
+ let G = {};
3084
3084
  if (typeof window < "u")
3085
3085
  try {
3086
- const G = (O = window.localStorage) == null ? void 0 : O.getItem(ze.authSessionId);
3087
- G && (L = { "X-Session-Id": G });
3086
+ const J = (P = window.localStorage) == null ? void 0 : P.getItem(ze.authSessionId);
3087
+ J && (G = { "X-Session-Id": J });
3088
3088
  } catch {
3089
3089
  }
3090
- const h = {
3091
- ...B,
3092
- ...L,
3090
+ const g = {
3091
+ ...j,
3092
+ ...G,
3093
3093
  ...s.current
3094
- }, j = {
3094
+ }, z = {
3095
3095
  "Content-Type": "application/json",
3096
3096
  Accept: "text/event-stream",
3097
- ...h
3097
+ ...g
3098
3098
  }, C = await fetch(t + n, {
3099
3099
  method: "POST",
3100
- headers: j,
3101
- body: JSON.stringify(k),
3102
- signal: E.signal,
3100
+ headers: z,
3101
+ body: JSON.stringify(v),
3102
+ signal: _.signal,
3103
3103
  credentials: a
3104
3104
  });
3105
- if (A.current && (A.current.headers = h), !C.ok || !C.body) {
3106
- const G = await C.text().catch(() => "");
3105
+ if (A.current && (A.current.headers = g), !C.ok || !C.body) {
3106
+ const J = await C.text().catch(() => "");
3107
3107
  console.debug(
3108
3108
  "[use-chat] non-OK response",
3109
3109
  C.status,
3110
- G == null ? void 0 : G.slice(0, 500)
3110
+ J == null ? void 0 : J.slice(0, 500)
3111
3111
  );
3112
- const se = `stream ${C.status}${G ? ": " + G : ""}`;
3113
- throw se && (p(se), U = "error"), new Error(se);
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
- const P = C.body.getReader(), J = new TextDecoder();
3117
- let K = "", V = 0, ee = Date.now();
3116
+ const O = C.body.getReader(), D = new TextDecoder();
3117
+ let K = "", B = 0, ee = Date.now();
3118
3118
  const ie = setInterval(() => {
3119
- Date.now() - ee > 18e5 && (p("Stream idle timeout"), U = "error", E.abort());
3119
+ Date.now() - ee > 18e5 && (m("Stream idle timeout"), L = "error", _.abort());
3120
3120
  }, 5e3), ye = 1024 * 1024;
3121
3121
  try {
3122
- const G = C.headers.get("X-Thread-Id") || C.headers.get("x-thread-id"), se = C.headers.get("X-Run-Id") || C.headers.get("x-run-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
- threadId: G ?? A.current.threadId,
3126
- runId: se ?? A.current.runId
3125
+ threadId: J ?? A.current.threadId,
3126
+ runId: oe ?? A.current.runId
3127
3127
  }); ; ) {
3128
- const { value: he, done: X } = await P.read();
3128
+ const { value: he, done: X } = await O.read();
3129
3129
  if (X) break;
3130
- K += J.decode(he, { stream: !0 }), K.length > ye && (K = "", console.warn("Stream buffer reset: exceeded 1MB"));
3130
+ K += D.decode(he, { stream: !0 }), K.length > ye && (K = "", console.warn("Stream buffer reset: exceeded 1MB"));
3131
3131
  let Q;
3132
3132
  for (; (Q = K.indexOf(`
3133
3133
 
3134
3134
  `)) >= 0; ) {
3135
3135
  const be = K.slice(0, Q);
3136
3136
  K = K.slice(Q + 2);
3137
- const Ve = be.split(/\r?\n/), we = [];
3137
+ const He = be.split(/\r?\n/), we = [];
3138
3138
  let Pe = null;
3139
- for (const ce of Ve)
3139
+ for (const ce of He)
3140
3140
  if (!ce.startsWith(":") && ce) {
3141
3141
  if (ce.startsWith("event:")) {
3142
3142
  const Ae = ce.slice(6).trim();
@@ -3168,85 +3168,85 @@ function pr(e = {}) {
3168
3168
  ee = Date.now();
3169
3169
  const te = typeof re.seq == "number" ? re.seq : void 0;
3170
3170
  if (te !== void 0) {
3171
- if (te <= V) {
3172
- console.debug("[use-chat] drop duplicate/out-of-order event", { seq: te, lastProcessedSeq: V, type: re.type });
3171
+ if (te <= B) {
3172
+ console.debug("[use-chat] drop duplicate/out-of-order event", { seq: te, lastProcessedSeq: B, type: re.type });
3173
3173
  continue;
3174
3174
  }
3175
- V = te;
3175
+ B = te;
3176
3176
  }
3177
- d(re);
3177
+ u(re);
3178
3178
  }
3179
3179
  }
3180
- U === null && !E.signal.aborted && (U = "complete");
3181
- } catch (G) {
3182
- if (G.name === "AbortError")
3183
- U = U ?? "aborted";
3180
+ L === null && !_.signal.aborted && (L = "complete");
3181
+ } catch (J) {
3182
+ if (J.name === "AbortError")
3183
+ L = L ?? "aborted";
3184
3184
  else {
3185
- const se = G.message || String(G);
3186
- U = "error", p(se);
3185
+ const oe = J.message || String(J);
3186
+ L = "error", m(oe);
3187
3187
  }
3188
3188
  } finally {
3189
3189
  try {
3190
- await P.cancel();
3190
+ await O.cancel();
3191
3191
  } catch {
3192
3192
  } finally {
3193
- (R = P.releaseLock) == null || R.call(P);
3193
+ (F = O.releaseLock) == null || F.call(O);
3194
3194
  }
3195
3195
  clearInterval(ie);
3196
3196
  }
3197
- } catch (B) {
3198
- if (B.name === "AbortError")
3199
- U = U ?? "aborted";
3197
+ } catch (j) {
3198
+ if (j.name === "AbortError")
3199
+ L = L ?? "aborted";
3200
3200
  else {
3201
- const L = B.message || String(B);
3202
- U = "error", p(L), M || (M = !0, (W = e.onConnectionError) == null || W.call(e, L));
3201
+ const G = j.message || String(j);
3202
+ L = "error", m(G), M || (M = !0, (E = e.onConnectionError) == null || E.call(e, G));
3203
3203
  }
3204
3204
  } finally {
3205
3205
  try {
3206
3206
  if (e.onFinish) {
3207
- const B = {
3207
+ const j = {
3208
3208
  lastSeq: 0,
3209
3209
  lastCheckpointId: null,
3210
3210
  lastCheckpointNs: null,
3211
3211
  lastValues: null
3212
3212
  // Let the reducer/history hook provide the final values
3213
3213
  };
3214
- e.onFinish(B);
3214
+ e.onFinish(j);
3215
3215
  }
3216
- } catch (B) {
3217
- console.warn("[use-chat] onClosed callback failed", B);
3216
+ } catch (j) {
3217
+ console.warn("[use-chat] onClosed callback failed", j);
3218
3218
  }
3219
- l(!1), I(!1), x.current = null, A.current = null;
3219
+ c(!1), I(!1), x.current = null, A.current = null;
3220
3220
  }
3221
3221
  })(), Promise.resolve();
3222
3222
  },
3223
- [t, n, r, e, d]
3223
+ [t, n, r, e, u]
3224
3224
  );
3225
3225
  return Y(() => () => {
3226
- var m;
3227
- S.current = !1, (m = x.current) == null || m.abort();
3226
+ var y;
3227
+ S.current = !1, (y = x.current) == null || y.abort();
3228
3228
  }, []), {
3229
- isStreaming: c,
3230
- error: f,
3229
+ isStreaming: l,
3230
+ error: d,
3231
3231
  assistantText: "",
3232
3232
  // Deprecated: use messages from reducer
3233
- activeMessageId: u,
3233
+ activeMessageId: f,
3234
3234
  streamedMessages: {},
3235
3235
  // Deprecated: use messages from reducer
3236
3236
  lastCheckpointId: null,
3237
3237
  // Deprecated: use checkpoint from reducer
3238
3238
  lastSeq: 0,
3239
- connected: g,
3239
+ connected: p,
3240
3240
  stream: T,
3241
- stop: y,
3242
- clear: b,
3241
+ stop: b,
3242
+ clear: k,
3243
3243
  setToken: w,
3244
3244
  values: {},
3245
3245
  // Provide empty object for backward compatibility
3246
3246
  interrupt: () => Promise.resolve(),
3247
3247
  resume: () => Promise.resolve(),
3248
3248
  goto: () => Promise.resolve(),
3249
- connectionState: f ? "error" : c ? g ? "connected" : "connecting" : "idle",
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
@@ -3259,103 +3259,103 @@ function gr({
3259
3259
  onThreadChange: r,
3260
3260
  onCurrentThreadDeleted: o
3261
3261
  }) {
3262
- const [s, a] = D([]), [i, d] = D(t), [c, l] = D(!1), [f, p] = D(null), g = H(i), I = H(/* @__PURE__ */ new Map());
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
- g.current = i;
3264
+ p.current = i;
3265
3265
  }, [i]), Y(() => {
3266
- t !== void 0 && t !== g.current && d(t);
3266
+ t !== void 0 && t !== p.current && u(t);
3267
3267
  }, [t]);
3268
- const u = N(async () => {
3269
- l(!0), p(null);
3268
+ const f = N(async () => {
3269
+ c(!0), m(null);
3270
3270
  try {
3271
- const b = await e.listThreads();
3272
- a(b ?? []);
3273
- } catch (b) {
3274
- const y = String(b);
3275
- p(y), n == null || n(y);
3271
+ const k = await e.listThreads();
3272
+ a(k ?? []);
3273
+ } catch (k) {
3274
+ const b = String(k);
3275
+ m(b), n == null || n(b);
3276
3276
  } finally {
3277
- l(!1);
3277
+ c(!1);
3278
3278
  }
3279
3279
  }, [e, n]);
3280
3280
  Y(() => {
3281
- u();
3282
- }, [u]), Y(() => {
3281
+ f();
3282
+ }, [f]), Y(() => {
3283
3283
  r == null || r(i);
3284
3284
  }, [i, r]);
3285
- const v = N(
3286
- async (b, y) => {
3285
+ const h = N(
3286
+ async (k, b) => {
3287
3287
  try {
3288
- const T = y && typeof y == "object" ? { id: y.id, name: y.name ?? "" } : void 0, m = await e.createThread(b, T);
3289
- return d(m.threadId), await u(), m.threadId;
3288
+ const T = b && typeof b == "object" ? { id: b.id, name: b.name ?? "" } : void 0, y = await e.createThread(k, T);
3289
+ return u(y.threadId), await f(), y.threadId;
3290
3290
  } catch (T) {
3291
- const m = String(T);
3292
- return n == null || n(m), null;
3291
+ const y = String(T);
3292
+ return n == null || n(y), null;
3293
3293
  }
3294
3294
  },
3295
- [e, n, u]
3295
+ [e, n, f]
3296
3296
  ), x = N(
3297
- async (b) => {
3298
- const y = s;
3299
- a((m) => m.filter((k) => k.threadId !== b));
3297
+ async (k) => {
3298
+ const b = s;
3299
+ a((y) => y.filter((v) => v.threadId !== k));
3300
3300
  const T = new AbortController();
3301
- I.current.set(b, T);
3301
+ I.current.set(k, T);
3302
3302
  try {
3303
- await e.deleteThread(b), g.current === b && (d(null), o == null || o());
3304
- } catch (m) {
3305
- a(y);
3306
- const k = String(m);
3307
- n == null || n(k);
3303
+ await e.deleteThread(k), p.current === k && (u(null), o == null || o());
3304
+ } catch (y) {
3305
+ a(b);
3306
+ const v = String(y);
3307
+ n == null || n(v);
3308
3308
  } finally {
3309
- I.current.delete(b);
3309
+ I.current.delete(k);
3310
3310
  }
3311
3311
  },
3312
3312
  [e, o, n, s]
3313
3313
  ), S = N(
3314
- async (b, y) => {
3314
+ async (k, b) => {
3315
3315
  try {
3316
- await e.updateThread(b, y), await u();
3316
+ await e.updateThread(k, b), await f();
3317
3317
  } catch (T) {
3318
3318
  n == null || n(String(T));
3319
3319
  }
3320
3320
  },
3321
- [e, n, u]
3321
+ [e, n, f]
3322
3322
  ), A = Z(
3323
3323
  () => ({
3324
- createThread: v,
3324
+ createThread: h,
3325
3325
  deleteThread: x,
3326
3326
  renameThread: S,
3327
- refreshThreads: u
3327
+ refreshThreads: f
3328
3328
  }),
3329
- [v, x, S, u]
3330
- ), w = N((b) => {
3331
- if (!(b != null && b.threadId)) return;
3332
- const y = {
3333
- threadId: b.threadId,
3334
- title: b.title || `Thread ${b.threadId.slice(0, 8)}`,
3335
- project: b.project,
3336
- createdAt: b.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
3337
- updatedAt: b.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
3338
- messageCount: b.messageCount ?? 1
3329
+ [h, x, S, f]
3330
+ ), w = N((k) => {
3331
+ if (!(k != null && k.threadId)) return;
3332
+ const b = {
3333
+ threadId: k.threadId,
3334
+ title: k.title || `Thread ${k.threadId.slice(0, 8)}`,
3335
+ project: k.project,
3336
+ createdAt: k.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
3337
+ updatedAt: k.updatedAt || (/* @__PURE__ */ new Date()).toISOString(),
3338
+ messageCount: k.messageCount ?? 1
3339
3339
  };
3340
3340
  a((T) => {
3341
- let m = !1;
3342
- const k = T.map((E) => E.threadId === y.threadId ? (m = !0, console.debug("[useThreadsState] thread_info: updating existing thread", y.threadId), {
3343
- ...E,
3344
- title: y.title ?? E.title,
3345
- project: y.project ?? E.project,
3346
- updatedAt: y.updatedAt ?? E.updatedAt,
3347
- messageCount: y.messageCount ?? E.messageCount
3348
- }) : E);
3349
- return m ? k : (console.debug("[useThreadsState] thread_info: adding thread to list", y.threadId), [y, ...T]);
3341
+ let y = !1;
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
3353
  threads: s,
3354
3354
  currentThreadId: i,
3355
- currentThreadIdRef: g,
3356
- setCurrentThreadId: d,
3357
- isLoadingThreads: c,
3358
- threadsError: f,
3355
+ currentThreadIdRef: p,
3356
+ setCurrentThreadId: u,
3357
+ isLoadingThreads: l,
3358
+ threadsError: d,
3359
3359
  actions: A,
3360
3360
  addThreadFromEvent: w
3361
3361
  };
@@ -3371,41 +3371,41 @@ function mr({
3371
3371
  threads: s,
3372
3372
  currentThreadId: a,
3373
3373
  setCurrentThreadId: i,
3374
- currentThreadIdRef: d,
3375
- isLoadingThreads: c,
3376
- threadsError: l,
3377
- actions: f,
3378
- addThreadFromEvent: p
3374
+ currentThreadIdRef: u,
3375
+ isLoadingThreads: l,
3376
+ threadsError: c,
3377
+ actions: d,
3378
+ addThreadFromEvent: m
3379
3379
  } = gr({
3380
3380
  api: o,
3381
3381
  initialThreadId: t,
3382
3382
  onError: n,
3383
3383
  onThreadChange: r
3384
- }), g = Z(
3384
+ }), p = Z(
3385
3385
  () => ({
3386
3386
  threads: s,
3387
3387
  currentThreadId: a,
3388
3388
  setCurrentThreadId: i,
3389
- currentThreadIdRef: d,
3390
- isLoading: c,
3391
- error: l,
3392
- actions: f,
3393
- addThreadFromEvent: p
3389
+ currentThreadIdRef: u,
3390
+ isLoading: l,
3391
+ error: c,
3392
+ actions: d,
3393
+ addThreadFromEvent: m
3394
3394
  }),
3395
3395
  [
3396
3396
  s,
3397
3397
  a,
3398
3398
  i,
3399
- d,
3400
- c,
3399
+ u,
3401
3400
  l,
3402
- f,
3403
- p
3401
+ c,
3402
+ d,
3403
+ m
3404
3404
  ]
3405
3405
  );
3406
- return /* @__PURE__ */ de(Ut.Provider, { value: g, children: e });
3406
+ return /* @__PURE__ */ de(Ut.Provider, { value: p, children: e });
3407
3407
  }
3408
- function ot(e) {
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;
@@ -3537,22 +3537,22 @@ function wr(e, t) {
3537
3537
  }
3538
3538
  }
3539
3539
  function kr(e = []) {
3540
- const [t, n] = Wt(wr, { ...Ot, messages: e }), r = H([]), o = H(null), s = N(() => {
3540
+ const [t, n] = Wt(wr, { ...Ot, messages: e }), r = W([]), o = W(null), s = N(() => {
3541
3541
  o.current !== null && typeof window < "u" && window.cancelAnimationFrame(o.current), o.current = null;
3542
- const c = r.current;
3543
- c.length && (r.current = [], n({ type: "batch", payload: { events: c } }));
3542
+ const l = r.current;
3543
+ l.length && (r.current = [], n({ type: "batch", payload: { events: l } }));
3544
3544
  }, []), a = N(() => {
3545
3545
  typeof window < "u" && typeof window.requestAnimationFrame == "function" ? o.current === null && (o.current = window.requestAnimationFrame(() => s())) : setTimeout(s, 8);
3546
- }, [s]), i = N((c) => {
3547
- r.current.push(c), a();
3548
- }, [a]), d = Z(() => ({
3549
- setStatus: (c, l) => n({ type: "status", payload: { status: c, error: l } }),
3550
- reset: (c) => n({ type: "reset", payload: { messages: c } }),
3551
- seed: (c, l) => n({ type: "seed", payload: { messages: c, ...l ?? {} } }),
3552
- pushUser: (c, l) => n({ type: "user_message", payload: { message: c, editingMessageId: l } }),
3546
+ }, [s]), i = N((l) => {
3547
+ r.current.push(l), a();
3548
+ }, [a]), u = Z(() => ({
3549
+ setStatus: (l, c) => n({ type: "status", payload: { status: l, error: c } }),
3550
+ reset: (l) => n({ type: "reset", payload: { messages: l } }),
3551
+ seed: (l, c) => n({ type: "seed", payload: { messages: l, ...c ?? {} } }),
3552
+ pushUser: (l, c) => n({ type: "user_message", payload: { message: l, editingMessageId: c } }),
3553
3553
  onEvent: i
3554
3554
  }), [i]);
3555
- return { state: t, dispatch: n, ...d };
3555
+ return { state: t, dispatch: n, ...u };
3556
3556
  }
3557
3557
  function pt(e, t) {
3558
3558
  const n = t.origin, r = t.scope, o = n === "task" || typeof r == "string" && r.startsWith("tools:");
@@ -3585,54 +3585,54 @@ function pt(e, t) {
3585
3585
  return { ...e, status: "error", error: t.message, messages: [...e.messages, s] };
3586
3586
  }
3587
3587
  if (t.type === "values") {
3588
- const s = t, a = s.values && typeof s.values == "object" ? { ...s.values } : {}, i = Array.isArray(s.messages) ? s.messages : Array.isArray(a.messages) ? a.messages : [];
3589
- if (!i.length && Object.keys(a).length === 0)
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 d = Fe(i);
3592
- delete a.messages;
3593
- let c = e.lastCheckpointId, l = e.lastCheckpointNs;
3594
- const f = s.config || s.checkpoint, p = (f == null ? void 0 : f.configurable) || f;
3595
- if ((p != null && p.checkpoint_id || p != null && p.checkpointId) && (c = p.checkpoint_id || p.checkpointId, l = p.checkpoint_ns || p.checkpointNs || null), !c) {
3596
- for (let u = d.length - 1; u >= 0; u--)
3597
- if (d[u].checkpointId) {
3598
- c = d[u].checkpointId, l = d[u].checkpointNs ?? null;
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 g = s.interrupts || a.__interrupt__ || a.interrupts, I = Array.isArray(g) && g.length > 0 ? {
3603
- id: g[0].id || "native-interrupt",
3604
- value: g[0].value || g[0],
3605
- alternatives: g[0].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
3607
  if (o) {
3608
- const u = typeof r == "string" && r.length > 0 ? r : "task";
3608
+ const h = typeof r == "string" && r.length > 0 ? r : "task";
3609
3609
  return {
3610
3610
  ...e,
3611
- taskMessagesByScope: { ...e.taskMessagesByScope, [u]: d },
3611
+ taskMessagesByScope: { ...e.taskMessagesByScope, [h]: l },
3612
3612
  assemblingId: null
3613
3613
  };
3614
3614
  }
3615
3615
  return {
3616
3616
  ...e,
3617
- status: I ? "awaiting_input" : e.status === "streaming" ? "idle" : e.status,
3618
- messages: d,
3617
+ status: f ? "awaiting_input" : e.status === "streaming" ? "idle" : e.status,
3618
+ messages: l,
3619
3619
  assemblingId: null,
3620
3620
  lastCheckpointId: c,
3621
- lastCheckpointNs: l,
3622
- pendingInterrupt: I,
3621
+ lastCheckpointNs: d,
3622
+ pendingInterrupt: f,
3623
3623
  values: { ...e.values, ...a }
3624
3624
  };
3625
3625
  }
3626
3626
  if (t.type === "messages/metadata") {
3627
3627
  const s = { ...e.messagesStreamMeta ?? {} }, a = t.metadata;
3628
- return a && typeof a == "object" && Object.entries(a).forEach(([i, d]) => {
3629
- const c = d == null ? void 0 : d.metadata;
3630
- if (!c || typeof c != "object") return;
3631
- const l = s[i] ?? {};
3628
+ return a && typeof a == "object" && Object.entries(a).forEach(([i, u]) => {
3629
+ const l = u == null ? void 0 : u.metadata;
3630
+ if (!l || typeof l != "object") return;
3631
+ const c = s[i] ?? {};
3632
3632
  s[i] = {
3633
- ...l,
3634
- lastSeq: t.seq ?? l.lastSeq ?? null,
3635
- metadata: { ...l.metadata ?? {}, ...c }
3633
+ ...c,
3634
+ lastSeq: t.seq ?? c.lastSeq ?? null,
3635
+ metadata: { ...c.metadata ?? {}, ...l }
3636
3636
  };
3637
3637
  }), { ...e, messagesStreamMeta: s };
3638
3638
  }
@@ -3653,55 +3653,55 @@ function pt(e, t) {
3653
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 g, I, u, v, x, S, A;
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
3660
  const o = r.find((w) => w.type === "ai" || w.type === "assistant" || w.role === "assistant");
3661
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)) : [], d = i.filter((w) => w.type === "text").map((w) => w.text).join(""), c = e.assemblingId !== s, l = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3663
- let f = n ? [...e.taskMessagesByScope[l] || []] : [...e.messages];
3664
- const p = (I = (g = e.messagesStreamMeta) == null ? void 0 : g[s]) == null ? void 0 : I.metadata;
3665
- if (c) {
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
+ let d = n ? [...e.taskMessagesByScope[c] || []] : [...e.messages];
3664
+ const m = (I = (p = e.messagesStreamMeta) == null ? void 0 : p[s]) == null ? void 0 : I.metadata;
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: { ...p, ...o.responseMetadata ?? {} }
3672
+ responseMetadata: { ...m, ...o.responseMetadata ?? {} }
3673
3673
  });
3674
- w && f.push(w);
3674
+ w && d.push(w);
3675
3675
  } else {
3676
- const w = f.findIndex((b) => b.id === s);
3676
+ const w = d.findIndex((k) => k.id === s);
3677
3677
  if (w !== -1) {
3678
- const b = f[w];
3679
- f[w] = {
3680
- ...b,
3678
+ const k = d[w];
3679
+ d[w] = {
3680
+ ...k,
3681
3681
  content: i,
3682
- scope: t.scope ?? b.scope,
3683
- origin: t.origin ?? b.origin,
3684
- responseMetadata: { ...p, ...b.responseMetadata, ...o.responseMetadata ?? {} }
3682
+ scope: t.scope ?? k.scope,
3683
+ origin: t.origin ?? k.origin,
3684
+ responseMetadata: { ...m, ...k.responseMetadata, ...o.responseMetadata ?? {} }
3685
3685
  };
3686
3686
  }
3687
3687
  }
3688
3688
  return {
3689
3689
  ...e,
3690
3690
  status: "streaming",
3691
- messages: n ? e.messages : f,
3692
- taskMessagesByScope: n ? { ...e.taskMessagesByScope, [l]: f } : e.taskMessagesByScope,
3691
+ messages: n ? e.messages : d,
3692
+ taskMessagesByScope: n ? { ...e.taskMessagesByScope, [c]: d } : e.taskMessagesByScope,
3693
3693
  assemblingId: s,
3694
3694
  messagesStreamMeta: {
3695
3695
  ...e.messagesStreamMeta ?? {},
3696
3696
  [s]: {
3697
- ...((u = e.messagesStreamMeta) == null ? void 0 : u[s]) ?? {},
3698
- lastSeq: t.seq ?? ((x = (v = e.messagesStreamMeta) == null ? void 0 : v[s]) == null ? void 0 : x.lastSeq) ?? null,
3699
- lastText: d || (((A = (S = e.messagesStreamMeta) == null ? void 0 : S[s]) == null ? void 0 : A.lastText) ?? "")
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 st(e, t) {
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--) {
@@ -3715,16 +3715,16 @@ function vr(e, t, n) {
3715
3715
  const r = t.id || t.callId;
3716
3716
  if (!r) return e;
3717
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], d = st(i, r);
3719
- if (d === -1) {
3720
- for (let c = i.length - 1; c >= 0; c--)
3721
- if (i[c].role === "assistant") {
3722
- d = c;
3718
+ let i = n ? [...e.taskMessagesByScope[a] || []] : [...e.messages], u = ot(i, r);
3719
+ if (u === -1) {
3720
+ for (let l = i.length - 1; l >= 0; l--)
3721
+ if (i[l].role === "assistant") {
3722
+ u = l;
3723
3723
  break;
3724
3724
  }
3725
3725
  }
3726
- if (d === -1) {
3727
- const c = {
3726
+ if (u === -1) {
3727
+ const l = {
3728
3728
  id: `assistant-${r}`,
3729
3729
  role: "assistant",
3730
3730
  content: [{ type: "text", text: "" }],
@@ -3733,21 +3733,21 @@ function vr(e, t, n) {
3733
3733
  scope: t.scope,
3734
3734
  origin: t.origin
3735
3735
  };
3736
- i.push(c), d = i.length - 1;
3736
+ i.push(l), u = i.length - 1;
3737
3737
  }
3738
- if (d !== -1) {
3739
- const c = i[d], l = [...c.toolCalls || []], f = l.findIndex((p) => p.id === r);
3740
- f >= 0 ? l[f] = { ...l[f], status: "running", content: s } : l.push({
3738
+ if (u !== -1) {
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
3742
  name: o,
3743
3743
  args: t.args || {},
3744
3744
  status: "running",
3745
3745
  content: s
3746
- }), i[d] = {
3747
- ...c,
3748
- toolCalls: l,
3749
- scope: t.scope ?? c.scope,
3750
- origin: t.origin ?? c.origin
3746
+ }), i[u] = {
3747
+ ...l,
3748
+ toolCalls: c,
3749
+ scope: t.scope ?? l.scope,
3750
+ origin: t.origin ?? l.origin
3751
3751
  };
3752
3752
  }
3753
3753
  return {
@@ -3761,14 +3761,14 @@ function xr(e, t, n) {
3761
3761
  if (!r) return e;
3762
3762
  const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3763
3763
  let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
3764
- const a = st(s, r);
3764
+ const a = ot(s, r);
3765
3765
  if (a !== -1) {
3766
- const i = s[a], d = ue(t.content), c = (i.toolCalls || []).map(
3767
- (l) => l.id === r ? { ...l, content: typeof d == "string" ? d : l.content } : l
3766
+ const i = s[a], u = ue(t.content), l = (i.toolCalls || []).map(
3767
+ (c) => c.id === r ? { ...c, content: typeof u == "string" ? u : c.content } : c
3768
3768
  );
3769
3769
  s[a] = {
3770
3770
  ...i,
3771
- toolCalls: c,
3771
+ toolCalls: l,
3772
3772
  scope: t.scope ?? i.scope,
3773
3773
  origin: t.origin ?? i.origin
3774
3774
  };
@@ -3784,24 +3784,24 @@ function Ar(e, t, n) {
3784
3784
  if (!r) return e;
3785
3785
  const o = typeof t.scope == "string" && t.scope.length > 0 ? t.scope : "task";
3786
3786
  let s = n ? [...e.taskMessagesByScope[o] || []] : [...e.messages];
3787
- const a = st(s, r), i = ue(t.content ?? t.error);
3787
+ const a = ot(s, r), i = ue(t.content ?? t.error);
3788
3788
  if (a !== -1) {
3789
- const c = s[a], l = (c.toolCalls || []).map(
3790
- (f) => f.id === r ? {
3791
- ...f,
3789
+ const l = s[a], c = (l.toolCalls || []).map(
3790
+ (d) => d.id === r ? {
3791
+ ...d,
3792
3792
  status: t.error ? "failed" : "completed",
3793
- content: typeof i == "string" ? i : f.content,
3793
+ content: typeof i == "string" ? i : d.content,
3794
3794
  artifact: t.artifact
3795
- } : f
3795
+ } : d
3796
3796
  );
3797
3797
  s[a] = {
3798
- ...c,
3799
- toolCalls: l,
3800
- scope: t.scope ?? c.scope,
3801
- origin: t.origin ?? c.origin
3798
+ ...l,
3799
+ toolCalls: c,
3800
+ scope: t.scope ?? l.scope,
3801
+ origin: t.origin ?? l.origin
3802
3802
  };
3803
3803
  }
3804
- const d = {
3804
+ const u = {
3805
3805
  id: `tool-${r}`,
3806
3806
  role: "tool",
3807
3807
  name: t.name,
@@ -3812,7 +3812,7 @@ function Ar(e, t, n) {
3812
3812
  scope: t.scope,
3813
3813
  origin: t.origin
3814
3814
  };
3815
- return s.push(d), {
3815
+ return s.push(u), {
3816
3816
  ...e,
3817
3817
  messages: n ? e.messages : s,
3818
3818
  taskMessagesByScope: n ? { ...e.taskMessagesByScope, [o]: s } : e.taskMessagesByScope
@@ -3855,18 +3855,18 @@ function gt(e) {
3855
3855
  return Re(t.configurable) ?? t;
3856
3856
  }
3857
3857
  async function Mr(e, t) {
3858
- var i, d;
3858
+ var i, u;
3859
3859
  if (!e) return e ?? null;
3860
3860
  const n = fe(e), r = Array.isArray(n.checkpoints) ? n.checkpoints : n.checkpoints ? Object.values(n.checkpoints) : [], o = /* @__PURE__ */ new Set();
3861
- for (const c of r) {
3862
- const l = (i = c == null ? void 0 : c.values) == null ? void 0 : i.messages;
3863
- if (Array.isArray(l))
3864
- for (const f of l) {
3865
- const p = f == null ? void 0 : f.content;
3866
- if (Array.isArray(p))
3867
- for (const g of p) {
3868
- if (!g || typeof g != "object" || g.type !== "image_url" && g.type !== "file") continue;
3869
- const I = g.fileId || g.file_id;
3861
+ for (const l of r) {
3862
+ const c = (i = l == null ? void 0 : l.values) == null ? void 0 : i.messages;
3863
+ if (Array.isArray(c))
3864
+ for (const d of c) {
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
3870
  typeof I == "string" && I.trim() && o.add(I);
3871
3871
  }
3872
3872
  }
@@ -3874,27 +3874,27 @@ async function Mr(e, t) {
3874
3874
  if (o.size === 0)
3875
3875
  return n;
3876
3876
  const s = await Promise.all(
3877
- Array.from(o).map(async (c) => {
3877
+ Array.from(o).map(async (l) => {
3878
3878
  try {
3879
- const l = await t.getFileInfo(c), f = fe(l);
3880
- return [c, f];
3879
+ const c = await t.getFileInfo(l), d = fe(c);
3880
+ return [l, d];
3881
3881
  } catch {
3882
- return [c, null];
3882
+ return [l, null];
3883
3883
  }
3884
3884
  })
3885
3885
  ), a = new Map(s);
3886
- for (const c of r) {
3887
- const l = (d = c == null ? void 0 : c.values) == null ? void 0 : d.messages;
3888
- if (Array.isArray(l))
3889
- for (const f of l) {
3890
- const p = f == null ? void 0 : f.content;
3891
- if (Array.isArray(p))
3892
- for (const g of p) {
3893
- if (!g || typeof g != "object" || g.type !== "image_url" && g.type !== "file") continue;
3894
- const I = g.fileId || g.file_id;
3886
+ for (const l of r) {
3887
+ const c = (u = l == null ? void 0 : l.values) == null ? void 0 : u.messages;
3888
+ if (Array.isArray(c))
3889
+ for (const d of c) {
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
3895
  if (!I) continue;
3896
- const u = a.get(I), v = (u == null ? void 0 : u.contentUrl) || (u == null ? void 0 : u.content_url);
3897
- v && (g.type === "image_url" ? (g.imageUrl = g.imageUrl || {}, g.imageUrl.url = v) : g.type === "file" && (g.url = v, !g.name && (u != null && u.filename || u != null && u.name) && (g.name = (u == null ? void 0 : u.filename) || (u == null ? void 0 : u.name))));
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
  }
@@ -3910,32 +3910,32 @@ function mt(e) {
3910
3910
  };
3911
3911
  }
3912
3912
  function Cr(e, t) {
3913
- var b, y;
3913
+ var k, b;
3914
3914
  if (!e) return null;
3915
- const n = ((b = e.values) == null ? void 0 : b.activeAgent) ?? null, r = (y = e.values) == null ? void 0 : y.messages, s = (Array.isArray(r) ? r : []).map((T) => Er(T, n)).filter((T) => !!T), a = Re(e.metadata) ?? {}, i = gt(e.config), d = Re(e.parentConfig), c = gt(d), l = Be(i, ["checkpointId"]), f = Be(i, ["checkpointNs"]), p = Be(c, ["checkpointId"]), g = Re(e.config), I = Array.isArray(e.tasks) ? e.tasks.map((T) => ({ ...T })) : e.tasks ?? null, u = Array.isArray(e.next) ? [...e.next] : e.next ?? null, v = typeof e.createdAt == "string" && e.createdAt.trim() ? e.createdAt : new Date(Date.now() - t).toISOString(), x = {
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
3919
  }, S = s.map((T) => ({
3920
3920
  ...T,
3921
- checkpointId: T.checkpointId ?? l ?? null,
3922
- checkpointNs: T.checkpointNs ?? f ?? null
3921
+ checkpointId: T.checkpointId ?? c ?? null,
3922
+ checkpointNs: T.checkpointNs ?? d ?? null
3923
3923
  })), A = e.values, w = Array.isArray(e.interrupts) ? e.interrupts : Array.isArray(A == null ? void 0 : A.interrupts) ? A.interrupts : [];
3924
3924
  return {
3925
- checkpointId: l ?? null,
3926
- checkpointNs: f ?? null,
3927
- createdAt: v,
3928
- parentId: p ?? null,
3925
+ checkpointId: c ?? null,
3926
+ checkpointNs: d ?? null,
3927
+ createdAt: h,
3928
+ parentId: m ?? null,
3929
3929
  messages: S,
3930
3930
  interrupt: Pr(
3931
3931
  w,
3932
3932
  t,
3933
- l ?? null
3933
+ c ?? null
3934
3934
  ),
3935
3935
  metadata: x,
3936
- config: g ?? null,
3937
- parentConfig: d ?? null,
3938
- next: u,
3936
+ config: p ?? null,
3937
+ parentConfig: u ?? null,
3938
+ next: f,
3939
3939
  tasks: I,
3940
3940
  values: e.values ?? {}
3941
3941
  };
@@ -3980,53 +3980,53 @@ function Nr(e) {
3980
3980
  }
3981
3981
  function zr(e) {
3982
3982
  const t = /* @__PURE__ */ new Map(), n = [], r = /* @__PURE__ */ new Map(), o = [];
3983
- for (let c = 0; c < e.length; c++) {
3984
- const l = e[c], f = l.checkpointId, p = f ?? `cp-${c}`, g = l.metadata ?? {}, I = typeof g.step == "number" ? g.step : null, u = typeof g.source == "string" ? g.source : null;
3985
- let v = null, x = null;
3986
- const S = Array.isArray(l.messages) ? l.messages : [];
3987
- for (const y of S)
3988
- y.role === "user" && (x || (x = y), y.id && (v = y.id));
3989
- const A = l.next && l.next.length > 0 ? String(l.next[0]) : null, w = l.parentConfig ?? null, b = {
3990
- id: p,
3983
+ for (let l = 0; l < e.length; l++) {
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
+ const S = Array.isArray(c.messages) ? c.messages : [];
3987
+ for (const b of S)
3988
+ b.role === "user" && (x || (x = b), b.id && (h = b.id));
3989
+ const A = c.next && c.next.length > 0 ? String(c.next[0]) : null, w = c.parentConfig ?? null, k = {
3990
+ id: m,
3991
3991
  step: I,
3992
- source: u,
3993
- createdAt: l.createdAt ?? null,
3994
- namespace: l.checkpointNs ?? null,
3995
- parentId: l.parentId ?? null,
3992
+ source: f,
3993
+ createdAt: c.createdAt ?? null,
3994
+ namespace: c.checkpointNs ?? null,
3995
+ parentId: c.parentId ?? null,
3996
3996
  next: A,
3997
3997
  parentConfig: w,
3998
- userMessageId: v
3998
+ userMessageId: h
3999
3999
  };
4000
- if (o.push(b), f && t.set(f, b), f && x) {
4001
- const y = Nr(x);
4002
- y && r.set(f, y);
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: p,
4006
- messageId: v,
4005
+ id: m,
4006
+ messageId: h,
4007
4007
  step: I,
4008
- source: u,
4009
- createdAt: l.createdAt ?? null,
4008
+ source: f,
4009
+ createdAt: c.createdAt ?? null,
4010
4010
  next: A,
4011
4011
  parentConfig: w
4012
4012
  });
4013
4013
  }
4014
4014
  const s = /* @__PURE__ */ new Map();
4015
- for (const c of o) {
4016
- if (!c.userMessageId) continue;
4017
- const l = s.get(c.userMessageId) ?? [];
4018
- l.push(c), s.set(c.userMessageId, l);
4015
+ for (const l of o) {
4016
+ if (!l.userMessageId) continue;
4017
+ const c = s.get(l.userMessageId) ?? [];
4018
+ c.push(l), s.set(l.userMessageId, c);
4019
4019
  }
4020
- for (const c of s.values()) {
4021
- if (!c.length) continue;
4022
- c.sort((f, p) => {
4023
- const g = f.createdAt ? Date.parse(f.createdAt) : 0;
4024
- return (p.createdAt ? Date.parse(p.createdAt) : 0) - g;
4020
+ for (const l of s.values()) {
4021
+ if (!l.length) continue;
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
- const l = c.length;
4027
- for (let f = 0; f < c.length; f++) {
4028
- const p = c[f];
4029
- p.attemptCount = l, p.attemptIndex = f, p.isLatestAttempt = f === 0;
4026
+ const c = l.length;
4027
+ for (let d = 0; d < l.length; d++) {
4028
+ const m = l[d];
4029
+ m.attemptCount = c, m.attemptIndex = d, m.isLatestAttempt = d === 0;
4030
4030
  }
4031
4031
  }
4032
4032
  return {
@@ -4035,23 +4035,23 @@ function zr(e) {
4035
4035
  timeline: n,
4036
4036
  messagePreviews: r,
4037
4037
  getLatest: () => {
4038
- const c = n[0];
4039
- if (c)
4040
- return t.get(c.id);
4038
+ const l = n[0];
4039
+ if (l)
4040
+ return t.get(l.id);
4041
4041
  },
4042
- getCheckpoint: (c) => t.get(c),
4043
- getMessageAttempts: (c) => {
4044
- const l = [];
4045
- for (const f of t.values())
4046
- f.userMessageId === c && l.push(f);
4047
- return l.length ? (l.sort((f, p) => {
4048
- const g = typeof f.attemptIndex == "number" ? f.attemptIndex : Number.MAX_SAFE_INTEGER, I = typeof p.attemptIndex == "number" ? p.attemptIndex : Number.MAX_SAFE_INTEGER;
4049
- return g - I;
4050
- }), l) : [];
4042
+ getCheckpoint: (l) => t.get(l),
4043
+ getMessageAttempts: (l) => {
4044
+ const c = [];
4045
+ for (const d of t.values())
4046
+ d.userMessageId === l && c.push(d);
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
+ }), c) : [];
4051
4051
  }
4052
4052
  };
4053
4053
  }
4054
- function uo(e, t, n) {
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);
@@ -4079,137 +4079,143 @@ function $t({
4079
4079
  currentThreadId: o,
4080
4080
  autoLoadInitial: s = !0,
4081
4081
  isStreaming: a,
4082
- getMessages: i
4082
+ getMessages: i,
4083
+ includeHistory: u = !0
4083
4084
  }) {
4084
- const [d, c] = D(null), f = Z(
4085
- () => mt(d),
4086
- [d]
4087
- ).checkpoints, p = Rr(f), g = p.timeline, [I, u] = D(!1), [v, x] = D(!1), [S, A] = D(!1), [w, b] = D(null), y = H(o), T = H(null), m = H(null);
4085
+ const [l, c] = H(null), m = Z(
4086
+ () => mt(l),
4087
+ [l]
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);
4088
4089
  Y(() => {
4089
- y.current = o;
4090
+ T.current = o;
4090
4091
  }, [o]);
4091
- const k = N(
4092
- async (_) => {
4093
- const O = await e.getState({
4094
- threadId: _.threadId,
4095
- checkpointId: _.checkpointId,
4096
- checkpointNs: _.checkpointNs
4097
- }), R = {
4092
+ const _ = N(
4093
+ async (P) => {
4094
+ const F = await e.getState({
4095
+ threadId: P.threadId,
4096
+ checkpointId: P.checkpointId,
4097
+ checkpointNs: P.checkpointNs
4098
+ }), E = {
4098
4099
  version: "values@1",
4099
- threadId: _.threadId,
4100
- checkpoints: [O]
4101
- }, W = t ? await Mr(R, t) : R, { latest: B } = mt(W);
4102
- return B;
4100
+ threadId: P.threadId,
4101
+ checkpoints: [F]
4102
+ }, j = t ? await Mr(E, t) : E, { latest: G } = mt(j);
4103
+ return G;
4103
4104
  },
4104
4105
  [e, t]
4105
- ), E = N(
4106
- async (_, O) => {
4107
- var B;
4108
- if (!_) return;
4109
- const R = `${_}:${O ?? "latest"}`;
4110
- if (T.current === R || I) return;
4111
- (B = m.current) == null || B.abort();
4112
- const W = new AbortController();
4113
- m.current = W, u(!0), b(null);
4106
+ ), L = N(
4107
+ async (P, F) => {
4108
+ var G;
4109
+ if (!P) return;
4110
+ const E = `${P}:${F ?? "latest"}`;
4111
+ if (y.current === E || f) return;
4112
+ (G = v.current) == null || G.abort();
4113
+ const j = new AbortController();
4114
+ v.current = j, h(!0), b(null);
4114
4115
  try {
4115
- const L = await k({
4116
- threadId: _,
4117
- checkpointId: O ?? void 0
4116
+ const g = await _({
4117
+ threadId: P,
4118
+ checkpointId: F ?? void 0
4118
4119
  });
4119
- if (y.current !== _) {
4120
- u(!1);
4120
+ if (T.current !== P) {
4121
+ h(!1);
4121
4122
  return;
4122
4123
  }
4123
- n((L == null ? void 0 : L.messages) ?? [], {
4124
- checkpointId: (L == null ? void 0 : L.checkpointId) ?? null,
4125
- checkpointNs: (L == null ? void 0 : L.checkpointNs) ?? null,
4126
- pendingInterrupt: (L == null ? void 0 : L.interrupt) ?? null,
4127
- values: L == null ? void 0 : L.values
4128
- }), T.current = R, u(!1), A(!0);
4129
- try {
4130
- const h = await e.getStateHistory({
4131
- threadId: _,
4132
- limit: 100,
4133
- includeMessages: !1
4134
- });
4135
- y.current === _ && c(h);
4136
- } finally {
4137
- A(!1);
4124
+ if (n((g == null ? void 0 : g.messages) ?? [], {
4125
+ checkpointId: (g == null ? void 0 : g.checkpointId) ?? null,
4126
+ checkpointNs: (g == null ? void 0 : g.checkpointNs) ?? null,
4127
+ pendingInterrupt: (g == null ? void 0 : g.interrupt) ?? null,
4128
+ values: g == null ? void 0 : g.values
4129
+ }), y.current = E, h(!1), u) {
4130
+ w(!0);
4131
+ try {
4132
+ const z = await e.getStateHistory({
4133
+ threadId: P,
4134
+ limit: 100,
4135
+ includeMessages: !1
4136
+ });
4137
+ T.current === P && c(z);
4138
+ } finally {
4139
+ w(!1);
4140
+ }
4138
4141
  }
4139
- } catch (L) {
4140
- if (u(!1), !Xt(L)) {
4141
- const h = String(L);
4142
- b(h), r == null || r(h);
4142
+ } catch (g) {
4143
+ if (h(!1), !Xt(g)) {
4144
+ const z = String(g);
4145
+ b(z), r == null || r(z);
4143
4146
  }
4144
4147
  }
4145
4148
  },
4146
- [e, n, k, r, i]
4147
- ), U = N(
4148
- async (_, O) => {
4149
+ [e, n, _, r, i]
4150
+ ), M = N(
4151
+ async (P, F) => {
4149
4152
  if (o) {
4150
- x(!0);
4153
+ S(!0);
4151
4154
  try {
4152
- const R = await k({
4155
+ const E = await _({
4153
4156
  threadId: o,
4154
- checkpointId: _,
4155
- checkpointNs: O ?? void 0
4157
+ checkpointId: P,
4158
+ checkpointNs: F ?? void 0
4156
4159
  });
4157
- n((R == null ? void 0 : R.messages) ?? [], {
4158
- checkpointId: (R == null ? void 0 : R.checkpointId) ?? _,
4159
- checkpointNs: (R == null ? void 0 : R.checkpointNs) ?? O,
4160
- pendingInterrupt: (R == null ? void 0 : R.interrupt) ?? null,
4161
- values: R == null ? void 0 : R.values
4160
+ 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
4162
4165
  });
4163
- } catch (R) {
4164
- console.error("[useThreadHistoryState] Navigation failed", R);
4166
+ } catch (E) {
4167
+ console.error("[useThreadHistoryState] Navigation failed", E);
4165
4168
  } finally {
4166
- x(!1);
4169
+ S(!1);
4167
4170
  }
4168
4171
  }
4169
4172
  },
4170
- [o, k, n]
4171
- ), M = N(async () => {
4172
- o && await E(o);
4173
- }, [o, E]), $ = N(
4174
- async (_) => {
4175
- const O = (_ == null ? void 0 : _.threadId) || o;
4176
- !O || o !== O || (c(_), T.current = `${O}:latest`);
4173
+ [o, _, n]
4174
+ ), $ = N(async () => {
4175
+ o && await L(o);
4176
+ }, [o, L]), U = N(
4177
+ async (P) => {
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`);
4177
4183
  },
4178
4184
  [o]
4179
4185
  );
4180
4186
  Y(() => {
4181
- if (!s || !o || I || a) return;
4182
- const _ = `${o}:latest`;
4183
- T.current !== _ && E(o);
4184
- }, [s, o, I, a, E]);
4185
- const F = N(() => {
4186
- c(null), u(!1), x(!1), A(!1), b(null), T.current = 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;
4187
4193
  }, []);
4188
4194
  return {
4189
- threadCheckpoints: f,
4190
- threadTimeline: g,
4195
+ threadCheckpoints: m,
4196
+ threadTimeline: I,
4191
4197
  checkpointIndex: p,
4192
- isLoadingThread: I,
4193
- isLoadingCheckpoint: v,
4194
- isLoadingHistory: S,
4195
- threadStateError: w,
4196
- loadThread: E,
4197
- navigateToCheckpoint: U,
4198
- setCurrentCheckpointId: (_, O) => {
4199
- n(i(), { checkpointId: _, checkpointNs: O });
4198
+ isLoadingThread: f,
4199
+ isLoadingCheckpoint: x,
4200
+ isLoadingHistory: A,
4201
+ threadStateError: k,
4202
+ loadThread: L,
4203
+ navigateToCheckpoint: M,
4204
+ setCurrentCheckpointId: (P, F) => {
4205
+ n(i(), { checkpointId: P, checkpointNs: F });
4200
4206
  },
4201
- returnToLatest: M,
4202
- handleValuesEvent: $,
4207
+ returnToLatest: $,
4208
+ handleValuesEvent: U,
4203
4209
  markSkipNextLoad: () => {
4204
4210
  },
4205
4211
  markStreamPendingThread: () => {
4206
4212
  },
4207
- resetHistoryState: F,
4208
- clearState: F
4213
+ resetHistoryState: V,
4214
+ clearState: V
4209
4215
  };
4210
4216
  }
4211
4217
  const Dt = Ce(null), Kt = Ce(null);
4212
- function Vt(e) {
4218
+ function Ht(e) {
4213
4219
  const t = je(Dt);
4214
4220
  if (!t && !(e != null && e.optional)) throw new Error("useThreadState must be used within a ThreadStateProvider");
4215
4221
  return t;
@@ -4227,28 +4233,29 @@ function jr({
4227
4233
  initialCheckpointNs: r = null,
4228
4234
  autoLoadInitial: o = !0,
4229
4235
  isStreaming: s,
4230
- onError: a
4236
+ onError: a,
4237
+ includeHistory: i = !0
4231
4238
  }) {
4232
- const { chatApi: i, fileApi: d } = Me(), { currentThreadId: c } = ot(), { state: l, seed: f, onEvent: p, dispatch: g } = kr(), {
4233
- threadCheckpoints: I,
4234
- threadTimeline: u,
4235
- checkpointIndex: v,
4236
- isLoadingThread: x,
4237
- isLoadingCheckpoint: S,
4238
- isLoadingHistory: A,
4239
- threadStateError: w,
4239
+ const { chatApi: u, fileApi: l } = Me(), { currentThreadId: c } = st(), { state: d, seed: m, onEvent: p, dispatch: I } = kr(), {
4240
+ threadCheckpoints: f,
4241
+ threadTimeline: h,
4242
+ checkpointIndex: x,
4243
+ isLoadingThread: S,
4244
+ isLoadingCheckpoint: A,
4245
+ isLoadingHistory: w,
4246
+ threadStateError: k,
4240
4247
  loadThread: b,
4241
- navigateToCheckpoint: y,
4242
- setCurrentCheckpointId: T,
4243
- returnToLatest: m,
4244
- handleValuesEvent: k,
4245
- markSkipNextLoad: E,
4246
- markStreamPendingThread: U,
4247
- resetHistoryState: M
4248
+ navigateToCheckpoint: T,
4249
+ setCurrentCheckpointId: y,
4250
+ returnToLatest: v,
4251
+ handleValuesEvent: _,
4252
+ markSkipNextLoad: L,
4253
+ markStreamPendingThread: M,
4254
+ resetHistoryState: $
4248
4255
  } = $t({
4249
- api: i,
4250
- fileApi: d,
4251
- seed: f,
4256
+ api: u,
4257
+ fileApi: l,
4258
+ seed: m,
4252
4259
  onError: a,
4253
4260
  currentThreadId: c,
4254
4261
  initialThreadId: t,
@@ -4256,121 +4263,122 @@ function jr({
4256
4263
  initialCheckpointNs: r,
4257
4264
  autoLoadInitial: o,
4258
4265
  isStreaming: s,
4259
- getMessages: N(() => l.messages, [l.messages])
4260
- }), $ = H(null), F = N(
4261
- (P) => {
4262
- $.current = P;
4266
+ getMessages: N(() => d.messages, [d.messages]),
4267
+ includeHistory: i
4268
+ }), U = W(null), V = N(
4269
+ (D) => {
4270
+ U.current = D;
4263
4271
  },
4264
4272
  []
4265
- ), _ = H(null), O = N(
4266
- (P) => {
4267
- _.current = P;
4273
+ ), P = W(null), F = N(
4274
+ (D) => {
4275
+ P.current = D;
4268
4276
  },
4269
4277
  []
4270
- ), R = Z(() => ({ assemblingMessageId: l.assemblingId ?? null }), [l.assemblingId]), W = N(
4271
- (P, J) => {
4272
- const K = jt(P, "user");
4273
- return g({
4278
+ ), E = Z(() => ({ assemblingMessageId: d.assemblingId ?? null }), [d.assemblingId]), j = N(
4279
+ (D, K) => {
4280
+ const B = jt(D, "user");
4281
+ return I({
4274
4282
  type: "user_message",
4275
4283
  payload: {
4276
- message: K,
4277
- editingMessageId: J == null ? void 0 : J.editingMessageId
4284
+ message: B,
4285
+ editingMessageId: K == null ? void 0 : K.editingMessageId
4278
4286
  }
4279
- }), K;
4287
+ }), B;
4280
4288
  },
4281
- [g]
4282
- ), B = N(async () => {
4283
- $.current ? await $.current() : (f([], {}), M());
4284
- }, [f, M]), L = N(async (P, J, K) => {
4285
- await b(P, J, { clearProgress: !1 });
4286
- }, [b]), h = Z(() => Bn(l.messages), [l.messages]), j = Z(
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(
4287
4295
  () => ({
4288
- status: l.status,
4296
+ status: d.status,
4289
4297
  threadId: c,
4290
- messages: l.messages,
4291
- taskMessagesByScope: l.taskMessagesByScope,
4292
- interrupt: l.pendingInterrupt,
4298
+ messages: d.messages,
4299
+ taskMessagesByScope: d.taskMessagesByScope,
4300
+ interrupt: d.pendingInterrupt,
4293
4301
  checkpoint: {
4294
- id: l.lastCheckpointId ?? null,
4295
- namespace: l.lastCheckpointNs ?? null
4302
+ id: d.lastCheckpointId ?? null,
4303
+ namespace: d.lastCheckpointNs ?? null
4296
4304
  },
4297
- checkpoints: I,
4298
- checkpointIndex: v,
4299
- timelineCheckpoints: u,
4300
- metadata: R,
4301
- values: l.values ?? {},
4302
- isLoading: x,
4303
- isLoadingCheckpoint: S,
4304
- isLoadingHistory: A,
4305
- error: w,
4305
+ checkpoints: f,
4306
+ checkpointIndex: x,
4307
+ timelineCheckpoints: h,
4308
+ metadata: E,
4309
+ values: d.values ?? {},
4310
+ isLoading: S,
4311
+ isLoadingCheckpoint: A,
4312
+ isLoadingHistory: w,
4313
+ error: k,
4306
4314
  loadOlder: async () => {
4307
4315
  },
4308
4316
  // Placeholder
4309
- seedFromSnapshot: (P) => {
4310
- f(P.messages, {
4311
- checkpointId: P.checkpointId,
4312
- checkpointNs: P.checkpointNs,
4313
- pendingInterrupt: P.interrupt,
4314
- values: P.values
4317
+ seedFromSnapshot: (D) => {
4318
+ m(D.messages, {
4319
+ checkpointId: D.checkpointId,
4320
+ checkpointNs: D.checkpointNs,
4321
+ pendingInterrupt: D.interrupt,
4322
+ values: D.values
4315
4323
  });
4316
4324
  },
4317
- clearState: B,
4318
- navigateToCheckpoint: y,
4319
- setCurrentCheckpointId: T,
4320
- returnToLatest: m,
4321
- loadThread: L,
4322
- clearThread: B,
4323
- respondToInterrupt: async (P, J, K) => {
4324
- _.current && await _.current(P, J, K);
4325
+ clearState: G,
4326
+ navigateToCheckpoint: T,
4327
+ setCurrentCheckpointId: y,
4328
+ returnToLatest: v,
4329
+ loadThread: g,
4330
+ clearThread: G,
4331
+ respondToInterrupt: async (D, K, B) => {
4332
+ P.current && await P.current(D, K, B);
4325
4333
  },
4326
- messagePreviews: v.messagePreviews,
4327
- handleValuesEvent: k,
4328
- markSkipNextLoad: E,
4329
- markStreamPendingThread: U,
4330
- resetHistoryState: M,
4331
- pushUser: W,
4334
+ messagePreviews: x.messagePreviews,
4335
+ handleValuesEvent: _,
4336
+ markSkipNextLoad: L,
4337
+ markStreamPendingThread: M,
4338
+ resetHistoryState: $,
4339
+ pushUser: j,
4332
4340
  onEvent: p,
4333
- artifacts: h
4341
+ artifacts: z
4334
4342
  }),
4335
4343
  [
4336
4344
  c,
4337
- l.messages,
4338
- l.taskMessagesByScope,
4339
- l.pendingInterrupt,
4340
- l.lastCheckpointId,
4341
- l.lastCheckpointNs,
4342
- l.values,
4343
- I,
4344
- u,
4345
- v,
4346
- R,
4345
+ d.messages,
4346
+ d.taskMessagesByScope,
4347
+ d.pendingInterrupt,
4348
+ d.lastCheckpointId,
4349
+ d.lastCheckpointNs,
4350
+ d.values,
4351
+ f,
4352
+ h,
4347
4353
  x,
4354
+ E,
4348
4355
  S,
4349
4356
  A,
4350
4357
  w,
4351
- f,
4352
- B,
4353
- y,
4354
- T,
4358
+ k,
4355
4359
  m,
4360
+ G,
4361
+ T,
4362
+ y,
4363
+ v,
4364
+ g,
4365
+ _,
4356
4366
  L,
4357
- k,
4358
- E,
4359
- U,
4360
- W,
4367
+ M,
4368
+ j,
4361
4369
  p,
4362
- h
4370
+ z
4363
4371
  ]
4364
- ), C = Z(
4372
+ ), O = Z(
4365
4373
  () => ({
4366
- registerClearThread: F,
4367
- registerRespondToInterrupt: O
4374
+ registerClearThread: V,
4375
+ registerRespondToInterrupt: F
4368
4376
  }),
4369
- [F, O]
4377
+ [V, F]
4370
4378
  );
4371
- return /* @__PURE__ */ de(Kt.Provider, { value: C, children: /* @__PURE__ */ de(Dt.Provider, { value: j, children: e }) });
4379
+ return /* @__PURE__ */ de(Kt.Provider, { value: O, children: /* @__PURE__ */ de(Dt.Provider, { value: C, children: e }) });
4372
4380
  }
4373
- const qt = Ce(null), Ur = Ce(!1);
4381
+ const Vt = Ce(null), Ur = Ce(!1);
4374
4382
  function Br({
4375
4383
  children: e,
4376
4384
  onError: t,
@@ -4380,38 +4388,38 @@ function Br({
4380
4388
  onUpdateEvent: s,
4381
4389
  onCustomEvent: a,
4382
4390
  onMetadataEvent: i,
4383
- onFinish: d,
4384
- onStreamingChange: c
4391
+ onFinish: u,
4392
+ onStreamingChange: l
4385
4393
  }) {
4386
- const { chatApi: l, baseUrl: f } = Me(), p = f, g = ge(t), I = ge(n), u = ge(r), v = ge(o), x = ge(s), S = ge(a), A = ge(i), w = ge(d), b = ge(c), y = Z(
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(
4387
4395
  () => ({
4388
- onError: g,
4396
+ onError: p,
4389
4397
  onAuthError: I,
4390
- onConnectionError: u,
4398
+ onConnectionError: f,
4391
4399
  onMetadataEvent: A,
4392
4400
  onCustomEvent: S,
4393
4401
  onUpdateEvent: x,
4394
- onToolEnd: v,
4402
+ onToolEnd: h,
4395
4403
  onFinish: w
4396
4404
  }),
4397
4405
  [
4398
- g,
4406
+ p,
4399
4407
  I,
4400
- u,
4408
+ f,
4401
4409
  A,
4402
4410
  S,
4403
4411
  x,
4404
- v,
4412
+ h,
4405
4413
  w
4406
4414
  ]
4407
4415
  );
4408
4416
  return /* @__PURE__ */ de(Ur.Provider, { value: !0, children: /* @__PURE__ */ de(
4409
4417
  Fr,
4410
4418
  {
4411
- api: l,
4412
- streamBaseUrl: p,
4413
- handlers: y,
4414
- onStreamingChange: b,
4419
+ api: c,
4420
+ streamBaseUrl: m,
4421
+ handlers: b,
4422
+ onStreamingChange: k,
4415
4423
  children: e
4416
4424
  }
4417
4425
  ) });
@@ -4423,118 +4431,118 @@ function Fr({
4423
4431
  handlers: r,
4424
4432
  onStreamingChange: o
4425
4433
  }) {
4426
- const { setCurrentThreadId: s, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: d } = ot(), {
4427
- interrupt: c,
4428
- checkpoint: l,
4429
- timelineCheckpoints: f,
4430
- handleValuesEvent: p,
4431
- markSkipNextLoad: g,
4434
+ const { setCurrentThreadId: s, currentThreadIdRef: a, addThreadFromEvent: i, currentThreadId: u } = st(), {
4435
+ interrupt: l,
4436
+ checkpoint: c,
4437
+ timelineCheckpoints: d,
4438
+ handleValuesEvent: m,
4439
+ markSkipNextLoad: p,
4432
4440
  markStreamPendingThread: I,
4433
- resetHistoryState: u,
4434
- pushUser: v,
4441
+ resetHistoryState: f,
4442
+ pushUser: h,
4435
4443
  onEvent: x,
4436
4444
  messages: S
4437
- } = Vt(), { registerClearThread: A, registerRespondToInterrupt: w } = Lr(), b = N(
4438
- (h) => {
4439
- i(h), I(h.threadId), a.current !== h.threadId && ((h.created ?? !a.current) && g(h.threadId), s(h.threadId));
4445
+ } = Ht(), { registerClearThread: A, registerRespondToInterrupt: w } = Lr(), k = N(
4446
+ (g) => {
4447
+ i(g), I(g.threadId), a.current !== g.threadId && ((g.created ?? !a.current) && p(g.threadId), s(g.threadId));
4440
4448
  },
4441
- [i, g, I, s, a]
4442
- ), y = pr({
4449
+ [i, p, I, s, a]
4450
+ ), b = pr({
4443
4451
  baseUrl: n,
4444
4452
  onEvent: x,
4445
- onError: (h) => {
4446
- var j;
4447
- (j = r.onError) == null || j.call(r, (h == null ? void 0 : h.message) ?? String(h));
4453
+ onError: (g) => {
4454
+ var z;
4455
+ (z = r.onError) == null || z.call(r, (g == null ? void 0 : g.message) ?? String(g));
4448
4456
  },
4449
4457
  onAuthError: r.onAuthError,
4450
4458
  onConnectionError: r.onConnectionError,
4451
4459
  onFinish: r.onFinish,
4452
- onThreadInfo: b,
4460
+ onThreadInfo: k,
4453
4461
  onMetadataEvent: r.onMetadataEvent,
4454
4462
  onCustomEvent: r.onCustomEvent,
4455
4463
  onUpdateEvent: r.onUpdateEvent,
4456
4464
  onToolEnd: r.onToolEnd,
4457
- handleValuesEvent: p
4465
+ handleValuesEvent: m
4458
4466
  });
4459
4467
  Y(() => {
4460
- o == null || o(y.isStreaming);
4461
- }, [y.isStreaming, o]);
4462
- const { stream: T, stop: m, clear: k, isStreaming: E, error: U, connected: M, activeMessageId: $ } = y;
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;
4463
4471
  Y(() => {
4464
- d !== void 0 && k();
4465
- }, [d, k]);
4466
- const F = N(
4467
- async (h, j) => {
4468
- await T(h, j);
4472
+ u !== void 0 && v();
4473
+ }, [u, v]);
4474
+ const U = N(
4475
+ async (g, z) => {
4476
+ await T(g, z);
4469
4477
  },
4470
4478
  [T]
4471
- ), _ = H(l);
4479
+ ), V = W(c);
4472
4480
  Y(() => {
4473
- _.current = l;
4474
- }, [l]);
4475
- const O = N(
4476
- async (h, j, C) => {
4481
+ V.current = c;
4482
+ }, [c]);
4483
+ const P = N(
4484
+ async (g, z, C) => {
4477
4485
  var ye;
4478
- const P = a.current;
4479
- if (!P)
4486
+ const O = a.current;
4487
+ if (!O)
4480
4488
  throw new Error("No active thread to handle interrupt");
4481
- const J = h ? j ?? !0 : !1, K = _.current, V = (C == null ? void 0 : C.checkpointId) ?? K.id ?? void 0, ee = (C == null ? void 0 : C.checkpointNs) ?? K.namespace ?? void 0, ie = {
4482
- threadId: P,
4483
- checkpointId: V,
4489
+ const D = g ? z ?? !0 : !1, K = V.current, B = (C == null ? void 0 : C.checkpointId) ?? K.id ?? void 0, ee = (C == null ? void 0 : C.checkpointNs) ?? K.namespace ?? void 0, ie = {
4490
+ threadId: O,
4491
+ checkpointId: B,
4484
4492
  checkpointNs: ee,
4485
- command: { kind: "resume", value: J },
4493
+ command: { kind: "resume", value: D },
4486
4494
  payload: {
4487
4495
  ...(C == null ? void 0 : C.payload) ?? {},
4488
4496
  creativityLevel: ((ye = C == null ? void 0 : C.payload) == null ? void 0 : ye.creativityLevel) ?? "medium"
4489
4497
  },
4490
4498
  edit: !1
4491
4499
  };
4492
- F(ie);
4500
+ U(ie);
4493
4501
  },
4494
- [a, F]
4502
+ [a, U]
4495
4503
  );
4496
4504
  Y(() => {
4497
- w(O);
4498
- }, [O, w]);
4499
- const R = N(async () => {
4500
- m(), k(), u(), s(null);
4501
- }, [k, u, s, m]);
4505
+ w(P);
4506
+ }, [P, w]);
4507
+ const F = N(async () => {
4508
+ y(), v(), f(), s(null);
4509
+ }, [v, f, s, y]);
4502
4510
  Y(() => {
4503
- A(R);
4504
- }, [R, A]);
4505
- const W = N(
4506
- async (h, j) => {
4507
- E && m();
4511
+ A(F);
4512
+ }, [F, A]);
4513
+ const E = N(
4514
+ async (g, z) => {
4515
+ _ && y();
4508
4516
  let C = a.current;
4509
- const P = (h == null ? void 0 : h.text) ?? "", J = (h == null ? void 0 : h.attachments) ?? [], K = (P == null ? void 0 : P.trim()) ?? "", V = { ...(h == null ? void 0 : h.payload) ?? {} }, ee = Array.isArray(V.messages) ? V.messages : void 0;
4510
- ee && delete V.messages;
4511
- const ie = !!(ee && ee.length), ye = !!(h.contentParts && h.contentParts.length > 0);
4512
- if (!C && !K && J.length === 0 && !ie && !ye) return;
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;
4518
+ ee && delete B.messages;
4519
+ const ie = !!(ee && ee.length), ye = !!(g.contentParts && g.contentParts.length > 0);
4520
+ if (!C && !K && D.length === 0 && !ie && !ye) return;
4513
4521
  if (!C) {
4514
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);
4515
- C = `${re}${te}`, g(C), s(C);
4523
+ C = `${re}${te}`, p(C), s(C);
4516
4524
  }
4517
- let G = null;
4518
- h.contentParts && h.contentParts.length > 0 && (G = h.contentParts);
4519
- const { contentParts: se, filesInfo: he } = G ? { contentParts: G, filesInfo: [] } : await or(J), X = [...se];
4520
- K && X.push({ type: "text", text: P });
4521
- const Q = h == null ? void 0 : h.originalMessageId, be = !!(h != null && h.edit && Q), Ve = !ie && X.length > 0;
4525
+ let J = null;
4526
+ g.contentParts && g.contentParts.length > 0 && (J = g.contentParts);
4527
+ const { contentParts: oe, filesInfo: he } = J ? { contentParts: J, filesInfo: [] } : await sr(D), X = [...oe];
4528
+ K && X.push({ type: "text", text: O });
4529
+ const Q = g == null ? void 0 : g.originalMessageId, be = !!(g != null && g.edit && Q), He = !ie && X.length > 0;
4522
4530
  let we = null;
4523
- if (Ve) {
4531
+ if (He) {
4524
4532
  const re = be ? Q : `msg-${Date.now()}`;
4525
4533
  we = jt({
4526
4534
  id: re,
4527
4535
  role: "user",
4528
4536
  content: X,
4529
4537
  createdAt: (/* @__PURE__ */ new Date()).toISOString()
4530
- }, "user"), be ? v(we, { editingMessageId: Q }) : v(we);
4538
+ }, "user"), be ? h(we, { editingMessageId: Q }) : h(we);
4531
4539
  }
4532
4540
  const Pe = ie ? ee : we ? [we] : [], ke = {
4533
- ...V,
4541
+ ...B,
4534
4542
  ...he.length ? { files_info: he } : {}
4535
4543
  };
4536
4544
  Pe.length ? ke.messages = Pe : "messages" in ke || (ke.messages = []);
4537
- let ne = (h == null ? void 0 : h.checkpointId) ?? l.id ?? void 0;
4545
+ let ne = (g == null ? void 0 : g.checkpointId) ?? c.id ?? void 0;
4538
4546
  if (be) {
4539
4547
  const re = S.find((te) => te.id === Q);
4540
4548
  if (re)
@@ -4549,44 +4557,44 @@ function Fr({
4549
4557
  te > 0 && S[te - 1].checkpointId && (ne = S[te - 1].checkpointId ?? void 0);
4550
4558
  }
4551
4559
  }
4552
- if (h != null && h.edit && !ne)
4560
+ if (g != null && g.edit && !ne)
4553
4561
  throw new Error(
4554
4562
  `[streaming] Missing checkpointId for edit submit. threadId=${C ?? "null"}. Ensure you are editing a message that has been saved.`
4555
4563
  );
4556
4564
  const Ue = {
4557
4565
  threadId: C,
4558
- content: h == null ? void 0 : h.text,
4566
+ content: g == null ? void 0 : g.text,
4559
4567
  payload: ke,
4560
- config: h == null ? void 0 : h.config,
4568
+ config: g == null ? void 0 : g.config,
4561
4569
  checkpointId: ne,
4562
- command: h == null ? void 0 : h.command,
4563
- edit: h == null ? void 0 : h.edit
4570
+ command: g == null ? void 0 : g.command,
4571
+ edit: g == null ? void 0 : g.edit
4564
4572
  };
4565
- return F(Ue, j);
4573
+ return U(Ue, z);
4566
4574
  },
4567
- [l, a, E, g, v, F, m, f]
4568
- ), B = Z(() => S, [S]), L = Z(
4575
+ [c, a, _, p, h, U, y, d]
4576
+ ), j = Z(() => S, [S]), G = Z(
4569
4577
  () => ({
4570
- isStreaming: E,
4571
- error: U,
4572
- connectionState: U ? "error" : E ? M ? "connected" : "connecting" : "idle",
4573
- messages: B,
4578
+ isStreaming: _,
4579
+ error: L,
4580
+ connectionState: L ? "error" : _ ? M ? "connected" : "connecting" : "idle",
4581
+ messages: j,
4574
4582
  activeMessageId: $,
4575
- submit: W,
4576
- stop: m,
4577
- interrupt: c,
4583
+ submit: E,
4584
+ stop: y,
4585
+ interrupt: l,
4578
4586
  resume: () => Promise.resolve(),
4579
- goto: (h, j) => Promise.resolve(),
4587
+ goto: (g, z) => Promise.resolve(),
4580
4588
  clearError: () => {
4581
4589
  }
4582
4590
  // TODO: Implement error clearing
4583
4591
  }),
4584
- [E, U, W, m, c, M, B]
4592
+ [_, L, E, y, l, M, j]
4585
4593
  );
4586
- return /* @__PURE__ */ de(qt.Provider, { value: L, children: e });
4594
+ return /* @__PURE__ */ de(Vt.Provider, { value: G, children: e });
4587
4595
  }
4588
4596
  function ge(e) {
4589
- const t = H(e);
4597
+ const t = W(e);
4590
4598
  return Y(() => {
4591
4599
  t.current = e;
4592
4600
  }, [e]), N((...n) => {
@@ -4596,7 +4604,7 @@ function ge(e) {
4596
4604
  }, []);
4597
4605
  }
4598
4606
  function Or(e) {
4599
- return je(qt);
4607
+ return je(Vt);
4600
4608
  }
4601
4609
  function bt(e) {
4602
4610
  return typeof e == "object" && e !== null;
@@ -4613,21 +4621,21 @@ function $r(e, t) {
4613
4621
  return !0;
4614
4622
  }
4615
4623
  function Dr(e) {
4616
- const t = H(e), n = H(e);
4624
+ const t = W(e), n = W(e);
4617
4625
  return $r(t.current, e) || (t.current = e, n.current = e), n.current;
4618
4626
  }
4619
4627
  function Kr(e) {
4620
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;
4621
4629
  return typeof o == "string" ? o : null;
4622
4630
  }
4623
- function fo(e) {
4631
+ function us(e) {
4624
4632
  const { setCurrentTaskId: t, getCurrentTaskId: n, onToolEnd: r } = e;
4625
4633
  return (o) => {
4626
4634
  const s = Kr(o), a = (n == null ? void 0 : n()) ?? null;
4627
4635
  s && s !== a && t(s), r == null || r(o);
4628
4636
  };
4629
4637
  }
4630
- function po({
4638
+ function fs({
4631
4639
  children: e,
4632
4640
  apiConfig: t,
4633
4641
  initialThreadId: n = null,
@@ -4636,42 +4644,42 @@ function po({
4636
4644
  autoLoadInitial: s = !0,
4637
4645
  onConnectionError: a,
4638
4646
  onError: i,
4639
- onAuthError: d,
4640
- onThreadChange: c,
4641
- onToolEnd: l,
4642
- onUpdateEvent: f,
4643
- onCustomEvent: p,
4644
- onMetadataEvent: g,
4647
+ onAuthError: u,
4648
+ onThreadChange: l,
4649
+ onToolEnd: c,
4650
+ onUpdateEvent: d,
4651
+ onCustomEvent: m,
4652
+ onMetadataEvent: p,
4645
4653
  onFinish: I
4646
4654
  }) {
4647
- const u = Dr(t), [v, x] = D(!1), S = me(i), A = me(d), w = me(a), b = me(c), y = me(l), T = me(f), m = me(p), k = me(g), E = me(I), U = Z(
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(
4648
4656
  () => ({
4649
4657
  onError: S,
4650
4658
  onAuthError: A,
4651
4659
  onConnectionError: w,
4652
- onToolEnd: y,
4660
+ onToolEnd: b,
4653
4661
  onUpdateEvent: T,
4654
- onCustomEvent: m,
4655
- onMetadataEvent: k,
4656
- onFinish: E
4662
+ onCustomEvent: y,
4663
+ onMetadataEvent: v,
4664
+ onFinish: _
4657
4665
  }),
4658
4666
  [
4659
4667
  S,
4660
4668
  A,
4661
4669
  w,
4662
- y,
4670
+ b,
4663
4671
  T,
4664
- m,
4665
- k,
4666
- E
4672
+ y,
4673
+ v,
4674
+ _
4667
4675
  ]
4668
4676
  );
4669
- return /* @__PURE__ */ de(nr, { apiConfig: u, children: /* @__PURE__ */ de(
4677
+ return /* @__PURE__ */ de(nr, { apiConfig: f, children: /* @__PURE__ */ de(
4670
4678
  mr,
4671
4679
  {
4672
4680
  initialThreadId: n,
4673
4681
  onError: S,
4674
- onThreadChange: b,
4682
+ onThreadChange: k,
4675
4683
  children: /* @__PURE__ */ de(
4676
4684
  jr,
4677
4685
  {
@@ -4680,11 +4688,11 @@ function po({
4680
4688
  initialCheckpointNs: o,
4681
4689
  autoLoadInitial: s,
4682
4690
  onError: S,
4683
- isStreaming: v,
4691
+ isStreaming: h,
4684
4692
  children: /* @__PURE__ */ de(
4685
4693
  Br,
4686
4694
  {
4687
- ...U,
4695
+ ...L,
4688
4696
  onStreamingChange: x,
4689
4697
  children: e
4690
4698
  }
@@ -4695,16 +4703,16 @@ function po({
4695
4703
  ) });
4696
4704
  }
4697
4705
  function me(e) {
4698
- const t = H(e);
4706
+ const t = W(e);
4699
4707
  return t.current = e, N((...n) => {
4700
4708
  const r = t.current;
4701
4709
  if (r)
4702
4710
  return r(...n);
4703
4711
  }, []);
4704
4712
  }
4705
- const Vr = 1, qr = 1e6;
4713
+ const Hr = 1, Vr = 1e6;
4706
4714
  let We = 0;
4707
- function Hr() {
4715
+ function qr() {
4708
4716
  return We = (We + 1) % Number.MAX_SAFE_INTEGER, We.toString();
4709
4717
  }
4710
4718
  const Je = /* @__PURE__ */ new Map(), wt = (e) => {
@@ -4715,14 +4723,14 @@ const Je = /* @__PURE__ */ new Map(), wt = (e) => {
4715
4723
  type: "REMOVE_TOAST",
4716
4724
  toastId: e
4717
4725
  });
4718
- }, qr);
4726
+ }, Vr);
4719
4727
  Je.set(e, t);
4720
4728
  }, Gr = (e, t) => {
4721
4729
  switch (t.type) {
4722
4730
  case "ADD_TOAST":
4723
4731
  return {
4724
4732
  ...e,
4725
- toasts: [t.toast, ...e.toasts].slice(0, Vr)
4733
+ toasts: [t.toast, ...e.toasts].slice(0, Hr)
4726
4734
  };
4727
4735
  case "UPDATE_TOAST":
4728
4736
  return {
@@ -4762,7 +4770,7 @@ function Le(e) {
4762
4770
  });
4763
4771
  }
4764
4772
  function Wr({ ...e }) {
4765
- const t = Hr(), n = (o) => Le({
4773
+ const t = qr(), n = (o) => Le({
4766
4774
  type: "UPDATE_TOAST",
4767
4775
  toast: { ...o, id: t }
4768
4776
  }), r = () => Le({ type: "DISMISS_TOAST", toastId: t });
@@ -4793,85 +4801,85 @@ function Jr() {
4793
4801
  dismiss: (n) => Le({ type: "DISMISS_TOAST", toastId: n })
4794
4802
  };
4795
4803
  }
4796
- function go(e) {
4797
- const { allowFileOpen: t, currentThreadId: n } = e, { fileApi: r } = Me(), { toast: o } = Jr(), [s, a] = D({}), [i, d] = D(null), [c, l] = D(!1), f = N(() => {
4798
- l(!1), d(null);
4799
- }, []), p = N((I) => {
4800
- d(I), l(!0);
4801
- }, []), g = N(
4802
- async (I, u, v) => {
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(() => {
4806
+ c(!1), u(null);
4807
+ }, []), m = N((I) => {
4808
+ u(I), c(!0);
4809
+ }, []), p = N(
4810
+ async (I, f, h) => {
4803
4811
  var x, S;
4804
4812
  if (!t) {
4805
4813
  I.preventDefault();
4806
4814
  return;
4807
4815
  }
4808
- if (s[v]) {
4816
+ if (s[h]) {
4809
4817
  I.preventDefault();
4810
4818
  return;
4811
4819
  }
4812
4820
  try {
4813
- const A = String(u.url ?? ""), w = A.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
4821
+ const A = String(f.url ?? ""), w = A.match(/\/chat\/files\/([^/]+)(?:\/(view|download))?/);
4814
4822
  if (w) {
4815
4823
  I.preventDefault();
4816
- const b = w[1], y = u.name || `file_${b}`, T = u.mimeType || "application/octet-stream";
4817
- p({ id: b, name: y, mimeType: T });
4824
+ const k = w[1], b = f.name || `file_${k}`, T = f.mimeType || "application/octet-stream";
4825
+ m({ id: k, name: b, mimeType: T });
4818
4826
  return;
4819
4827
  }
4820
4828
  if (A.startsWith("data:")) {
4821
- I.preventDefault(), a((y) => ({ ...y, [v]: !0 }));
4822
- const b = o({ title: "Fetching file...", description: "", open: !0 });
4829
+ I.preventDefault(), a((b) => ({ ...b, [h]: !0 }));
4830
+ const k = o({ title: "Fetching file...", description: "", open: !0 });
4823
4831
  try {
4824
- const y = await r.listFiles(n ?? void 0);
4825
- if (!y || !Array.isArray(y))
4832
+ const b = await r.listFiles(n ?? void 0);
4833
+ if (!b || !Array.isArray(b))
4826
4834
  throw new Error("Invalid file list response");
4827
- const T = y.find((m) => !m || typeof m != "object" || !((m.filename ?? "") === (u.name ?? "")) ? !1 : typeof u.size == "number" && typeof m.size == "number" ? m.size === u.size : !0);
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);
4828
4836
  if (!(T != null && T.id))
4829
- throw new Error(`File "${u.name}" is not yet available on the server`);
4837
+ throw new Error(`File "${f.name}" is not yet available on the server`);
4830
4838
  if (!T.id || !T.filename)
4831
4839
  throw new Error("Invalid file data received from server");
4832
- p({
4840
+ m({
4833
4841
  id: T.id,
4834
- name: u.name || T.filename || `file_${T.id}`,
4835
- mimeType: u.mimeType || T.mime_type || "application/octet-stream"
4836
- }), (x = b.update) == null || x.call(b, {
4837
- id: b.id,
4842
+ name: f.name || T.filename || `file_${T.id}`,
4843
+ mimeType: f.mimeType || T.mime_type || "application/octet-stream"
4844
+ }), (x = k.update) == null || x.call(k, {
4845
+ id: k.id,
4838
4846
  title: "Success",
4839
- description: `Opened ${u.name}`,
4847
+ description: `Opened ${f.name}`,
4840
4848
  open: !0
4841
4849
  });
4842
- } catch (y) {
4843
- console.error("Failed to fetch server file:", y);
4844
- const T = y instanceof Error ? y.message : "Unknown error occurred";
4845
- (S = b.update) == null || S.call(b, { id: b.id, title: "Failed", description: T }), o({
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({
4846
4854
  title: "Failed to fetch file",
4847
4855
  description: T,
4848
4856
  open: !0
4849
4857
  });
4850
4858
  } finally {
4851
- a((y) => ({ ...y, [v]: !1 }));
4859
+ a((b) => ({ ...b, [h]: !1 }));
4852
4860
  }
4853
4861
  }
4854
4862
  } catch (A) {
4855
- console.error("File click error:", A), a((w) => ({ ...w, [v]: !1 }));
4863
+ console.error("File click error:", A), a((w) => ({ ...w, [h]: !1 }));
4856
4864
  }
4857
4865
  },
4858
- [t, s, o, n, p]
4866
+ [t, s, o, n, m]
4859
4867
  );
4860
4868
  return {
4861
4869
  uploadingFiles: s,
4862
- handleFileClick: g,
4863
- fileViewerOpen: c,
4870
+ handleFileClick: p,
4871
+ fileViewerOpen: l,
4864
4872
  currentFileInfo: i,
4865
- closeFileViewer: f
4873
+ closeFileViewer: d
4866
4874
  };
4867
4875
  }
4868
- function mo(e) {
4876
+ function gs(e) {
4869
4877
  return Z(() => {
4870
4878
  const t = e;
4871
4879
  let n = Array.isArray(t.content) ? t.content : [];
4872
4880
  return typeof t.content == "string" && (n = [{ type: "text", text: t.content }]), {
4873
4881
  contentParts: n,
4874
- textContent: sr(n),
4882
+ textContent: or(n),
4875
4883
  toolMeta: ar(t),
4876
4884
  imageParts: n.filter((r) => r.type === "image_url"),
4877
4885
  fileParts: n.filter((r) => r.type === "file"),
@@ -4904,20 +4912,20 @@ function Qr(e) {
4904
4912
  }
4905
4913
  return null;
4906
4914
  }
4907
- function yo(e) {
4915
+ function ms(e) {
4908
4916
  return Z(() => {
4909
4917
  const t = e.content.filter(
4910
- (d) => d.type === "text"
4918
+ (u) => u.type === "text"
4911
4919
  );
4912
4920
  if (!t.length)
4913
4921
  return null;
4914
4922
  let r = t.flatMap(
4915
- (d) => Xr(d.text ?? "")
4923
+ (u) => Xr(u.text ?? "")
4916
4924
  );
4917
4925
  if (!r.length) {
4918
- const d = t.map((l) => l.text ?? "").join(`
4919
- `), c = tt(d);
4920
- c && typeof c == "object" && (r = [c]);
4926
+ const u = t.map((c) => c.text ?? "").join(`
4927
+ `), l = tt(u);
4928
+ l && typeof l == "object" && (r = [l]);
4921
4929
  }
4922
4930
  if (!r.length)
4923
4931
  return null;
@@ -4938,20 +4946,20 @@ function yo(e) {
4938
4946
  }, [e]);
4939
4947
  }
4940
4948
  function Yr(e) {
4941
- var M, $;
4942
- const t = typeof e == "string" ? e : e == null ? void 0 : e.threadId, n = typeof e == "object" ? e.lazy : !1, r = ot({ optional: !0 }), o = Vt({ optional: !0 }), s = Or(), { currentThreadId: a, setCurrentThreadId: i, actions: d } = r || {
4949
+ var $, U;
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 || {
4943
4951
  currentThreadId: null,
4944
4952
  setCurrentThreadId: () => {
4945
4953
  },
4946
4954
  actions: {}
4947
- }, c = !!t && t !== a, [l, f] = D([]), p = N((F) => {
4948
- f(F);
4955
+ }, c = !!t && t !== i, [d, m] = H([]), p = N((V) => {
4956
+ m(V);
4949
4957
  }, []), {
4950
- isLoadingThread: g,
4951
- threadStateError: I,
4952
- threadCheckpoints: u,
4953
- isLoadingHistory: v,
4954
- loadThread: x
4958
+ isLoadingThread: I,
4959
+ threadStateError: f,
4960
+ threadCheckpoints: h,
4961
+ isLoadingHistory: x,
4962
+ loadThread: S
4955
4963
  } = $t({
4956
4964
  api: Me().chatApi,
4957
4965
  fileApi: Me().fileApi,
@@ -4959,73 +4967,74 @@ function Yr(e) {
4959
4967
  currentThreadId: c ? t : null,
4960
4968
  initialThreadId: c ? t : null,
4961
4969
  isStreaming: !1,
4962
- getMessages: () => l,
4963
- autoLoadInitial: c && !n
4970
+ getMessages: () => d,
4971
+ autoLoadInitial: c && !n,
4972
+ includeHistory: r
4964
4973
  });
4965
4974
  Y(() => {
4966
- !c && !n && a && (o != null && o.loadThread) && o.loadThread(a);
4967
- }, [c, n, a, o == null ? void 0 : o.loadThread]);
4968
- const S = Z(() => {
4969
- var F;
4970
- return ((F = u[0]) == null ? void 0 : F.values) || {};
4971
- }, [u]), A = Z(() => ({ timeline: [], messagePreviews: {} }), []), w = t || a, b = c ? g ? "loading" : "idle" : (o == null ? void 0 : o.status) || "idle", y = c ? l : (s == null ? void 0 : s.messages) || [], T = c ? g : (o == null ? void 0 : o.isLoading) || !1, m = c ? v : (o == null ? void 0 : o.isLoadingHistory) || !1, k = c ? S : (o == null ? void 0 : o.values) || {}, E = c ? {} : (o == null ? void 0 : o.taskMessagesByScope) || {}, U = c ? I : (s == null ? void 0 : s.error) || (o == null ? void 0 : o.error) || null;
4975
+ !c && !n && i && (s != null && s.loadThread) && s.loadThread(i);
4976
+ }, [c, n, i, s == null ? void 0 : s.loadThread]);
4977
+ const A = Z(() => {
4978
+ var V;
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;
4972
4981
  return {
4973
4982
  // UNIFIED: Single thread ID concept
4974
- threadId: w,
4983
+ threadId: k,
4975
4984
  status: b,
4976
- messages: y,
4977
- isLoading: T,
4978
- isHistoryLoading: m,
4979
- error: U,
4985
+ messages: T,
4986
+ isLoading: y,
4987
+ isHistoryLoading: v,
4988
+ error: M,
4980
4989
  // Values & Metadata
4981
- values: k,
4982
- taskMessagesByScope: E,
4983
- metadata: c ? {} : o == null ? void 0 : o.metadata,
4990
+ values: _,
4991
+ taskMessagesByScope: L,
4992
+ metadata: c ? {} : s == null ? void 0 : s.metadata,
4984
4993
  // Actions & State relating to Global/Active Thread only
4985
4994
  navigateToCheckpoint: c ? async () => {
4986
- } : (o == null ? void 0 : o.navigateToCheckpoint) || (async () => {
4995
+ } : (s == null ? void 0 : s.navigateToCheckpoint) || (async () => {
4987
4996
  }),
4988
4997
  returnToLatest: c ? async () => {
4989
- } : (o == null ? void 0 : o.returnToLatest) || (async () => {
4998
+ } : (s == null ? void 0 : s.returnToLatest) || (async () => {
4990
4999
  }),
4991
- checkpoint: c ? u[0] ? { id: u[0].checkpointId, namespace: u[0].checkpointNs } : null : (o == null ? void 0 : o.checkpoint) || null,
4992
- checkpoints: c ? u : (o == null ? void 0 : o.checkpoints) || [],
4993
- checkpointIndex: c ? A : (o == null ? void 0 : o.checkpointIndex) || { timeline: [], messagePreviews: {} },
4994
- interrupt: c ? null : (o == null ? void 0 : o.interrupt) || 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,
4995
5004
  respondToInterrupt: c ? async () => {
4996
- } : (o == null ? void 0 : o.respondToInterrupt) || (async () => {
5005
+ } : (s == null ? void 0 : s.respondToInterrupt) || (async () => {
4997
5006
  }),
4998
5007
  // Streaming Status
4999
5008
  // Even in standalone mode, allow streaming state/stop if a stream context exists.
5000
- isStreaming: (s == null ? void 0 : s.isStreaming) || !1,
5001
- activeMessageId: c ? null : ((M = o == null ? void 0 : o.metadata) == null ? void 0 : M.assemblingMessageId) || (s == null ? void 0 : s.activeMessageId) || null,
5002
- connectionState: (s == null ? void 0 : s.connectionState) || "disconnected",
5003
- streamingAssistantId: !c && (s != null && s.isStreaming) && (($ = o == null ? void 0 : o.metadata) != null && $.assemblingMessageId) ? o.metadata.assemblingMessageId : null,
5009
+ isStreaming: (a == null ? void 0 : a.isStreaming) || !1,
5010
+ activeMessageId: c ? null : (($ = s == null ? void 0 : s.metadata) == null ? void 0 : $.assemblingMessageId) || (a == null ? void 0 : a.activeMessageId) || null,
5011
+ connectionState: (a == null ? void 0 : a.connectionState) || "disconnected",
5012
+ streamingAssistantId: !c && (a != null && a.isStreaming) && ((U = s == null ? void 0 : s.metadata) != null && U.assemblingMessageId) ? s.metadata.assemblingMessageId : null,
5004
5013
  // Actions
5005
- submit: (s == null ? void 0 : s.submit) || (async () => {
5014
+ submit: (a == null ? void 0 : a.submit) || (async () => {
5006
5015
  }),
5007
- stop: (s == null ? void 0 : s.stop) || (() => {
5016
+ stop: (a == null ? void 0 : a.stop) || (() => {
5008
5017
  }),
5009
5018
  clearThread: c ? async () => {
5010
- } : (o == null ? void 0 : o.clearThread) || (async () => {
5019
+ } : (s == null ? void 0 : s.clearThread) || (async () => {
5011
5020
  }),
5012
- setCurrentThreadId: i,
5021
+ setCurrentThreadId: u,
5013
5022
  loadHistory: c ? async () => {
5014
- t && await x(t);
5023
+ t && await S(t);
5015
5024
  } : async () => {
5016
5025
  },
5017
5026
  onEvent: c ? () => {
5018
- } : (o == null ? void 0 : o.onEvent) || (() => {
5027
+ } : (s == null ? void 0 : s.onEvent) || (() => {
5019
5028
  }),
5020
5029
  // Thread Management
5021
- createThread: d == null ? void 0 : d.createThread,
5022
- deleteThread: d == null ? void 0 : d.deleteThread,
5023
- renameThread: d == null ? void 0 : d.renameThread,
5024
- threads: (r == null ? void 0 : r.threads) || [],
5025
- isThreadsLoading: (r == null ? void 0 : r.isLoading) || !1
5030
+ createThread: l == null ? void 0 : l.createThread,
5031
+ deleteThread: l == null ? void 0 : l.deleteThread,
5032
+ renameThread: l == null ? void 0 : l.renameThread,
5033
+ threads: (o == null ? void 0 : o.threads) || [],
5034
+ isThreadsLoading: (o == null ? void 0 : o.isLoading) || !1
5026
5035
  };
5027
5036
  }
5028
- function ho({
5037
+ function ys({
5029
5038
  submit: e,
5030
5039
  chatRequest: t,
5031
5040
  lastCheckpointId: n,
@@ -5034,44 +5043,44 @@ function ho({
5034
5043
  onExcelUploadSuccess: s,
5035
5044
  onError: a,
5036
5045
  enableMessageEditing: i,
5037
- messages: d,
5038
- setPendingAssistantResponse: c,
5039
- project: l,
5040
- onEvent: f,
5041
- threadId: p,
5042
- clearComposerOnSend: g = !0
5046
+ messages: u,
5047
+ setPendingAssistantResponse: l,
5048
+ project: c,
5049
+ onEvent: d,
5050
+ threadId: m,
5051
+ clearComposerOnSend: p = !0
5043
5052
  }) {
5044
- const { messages: I } = Yr(), [u, v] = D(null), [x, S] = D(""), [A, w] = D(null), [b, y] = D(null), [T, m] = D(!1), [k, E] = D(""), U = H(k), M = H(null);
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);
5045
5054
  Y(() => {
5046
- if (!u)
5047
- if (p) {
5048
- const j = localStorage.getItem(Ge(p));
5049
- E(j || "");
5055
+ if (!f)
5056
+ if (m) {
5057
+ const z = localStorage.getItem(Ge(m));
5058
+ _(z || "");
5050
5059
  } else
5051
- E("");
5052
- }, [p, u]);
5053
- const $ = N((j) => {
5054
- E(j), !u && p && localStorage.setItem(Ge(p), j);
5055
- }, [p, u]);
5060
+ _("");
5061
+ }, [m, f]);
5062
+ const $ = N((z) => {
5063
+ _(z), !f && m && localStorage.setItem(Ge(m), z);
5064
+ }, [m, f]);
5056
5065
  Y(() => {
5057
- U.current = k;
5058
- }, [k]), Y(() => {
5059
- if (!u) {
5066
+ L.current = v;
5067
+ }, [v]), Y(() => {
5068
+ if (!f) {
5060
5069
  M.current = null;
5061
5070
  return;
5062
5071
  }
5063
- M.current === null && (M.current = U.current), $(x ?? "");
5064
- }, [x, u, $]);
5065
- const F = N(
5066
- (j) => {
5067
- $(j);
5072
+ M.current === null && (M.current = L.current), $(x ?? "");
5073
+ }, [x, f, $]);
5074
+ const U = N(
5075
+ (z) => {
5076
+ $(z);
5068
5077
  },
5069
5078
  [$]
5070
- ), _ = async (j, C) => {
5071
- const P = Array.isArray(C) ? { files: C } : C ?? {}, J = P.files ?? [], K = P.contentParts ?? [], V = j.trim();
5072
- if (!(!V && J.length === 0 && K.length === 0))
5079
+ ), V = async (z, C) => {
5080
+ const O = Array.isArray(C) ? { files: C } : C ?? {}, D = O.files ?? [], K = O.contentParts ?? [], B = z.trim();
5081
+ if (!(!B && D.length === 0 && K.length === 0))
5073
5082
  try {
5074
- const ee = J.map(async (X) => {
5083
+ const ee = D.map(async (X) => {
5075
5084
  try {
5076
5085
  const Q = await Rt.uploadFile(X);
5077
5086
  return { file: X, record: Q };
@@ -5090,68 +5099,68 @@ function ho({
5090
5099
  name: X.filename,
5091
5100
  size: X.size
5092
5101
  };
5093
- }), G = [...K, ...ye], se = u ? (A == null ? void 0 : A.checkpointId) ?? n ?? void 0 : n ?? void 0, he = u ? (A == null ? void 0 : A.checkpointNs) ?? r ?? void 0 : r ?? void 0;
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;
5094
5103
  await e(
5095
5104
  {
5096
- text: V || "",
5097
- contentParts: G,
5098
- attachments: J,
5105
+ text: B || "",
5106
+ contentParts: J,
5107
+ attachments: D,
5099
5108
  payload: t.payload,
5100
- edit: !!u,
5101
- checkpointId: se,
5109
+ edit: !!f,
5110
+ checkpointId: oe,
5102
5111
  checkpointNs: he,
5103
- project: l ?? void 0,
5104
- originalMessageId: u ?? void 0,
5112
+ project: c ?? void 0,
5113
+ originalMessageId: f ?? void 0,
5105
5114
  config: t.config
5106
5115
  },
5107
- f ? { onEvent: f } : void 0
5108
- ), o == null || o(V), c(!0), g && (p && localStorage.removeItem(Ge(p)), $("")), y(null), v(null), S(""), w(null);
5116
+ d ? { onEvent: d } : void 0
5117
+ ), o == null || o(B), l(!0), p && (m && localStorage.removeItem(Ge(m)), $("")), b(null), h(null), S(""), w(null);
5109
5118
  } catch (ee) {
5110
5119
  const ie = (ee == null ? void 0 : ee.message) || "Failed to send message";
5111
- y(ie), a == null || a(ie), c(!1);
5120
+ b(ie), a == null || a(ie), l(!1);
5112
5121
  }
5113
- }, O = (j, C) => {
5114
- C || _(j, { files: [] });
5115
- }, R = N(
5116
- async (j) => {
5122
+ }, P = (z, C) => {
5123
+ C || V(z, { files: [] });
5124
+ }, F = N(
5125
+ async (z) => {
5117
5126
  await e(
5118
5127
  {
5119
- attachments: [j],
5128
+ attachments: [z],
5120
5129
  payload: t.payload,
5121
5130
  checkpointId: n ?? void 0,
5122
5131
  checkpointNs: r ?? void 0,
5123
- project: l ?? void 0,
5132
+ project: c ?? void 0,
5124
5133
  config: t.config
5125
5134
  },
5126
- f ? { onEvent: f } : void 0
5127
- ), s == null || s({ file: j });
5135
+ d ? { onEvent: d } : void 0
5136
+ ), s == null || s({ file: z });
5128
5137
  },
5129
5138
  [n, r, t, s, e]
5130
- ), W = N(
5131
- (j, C, P) => {
5132
- i && (M.current = k, v(j), S(C), w({
5133
- checkpointId: (P == null ? void 0 : P.checkpointId) ?? null,
5134
- checkpointNs: (P == null ? void 0 : P.checkpointNs) ?? null
5135
- }), y(null));
5139
+ ), E = N(
5140
+ (z, C, O) => {
5141
+ i && (M.current = v, h(z), S(C), w({
5142
+ checkpointId: (O == null ? void 0 : O.checkpointId) ?? null,
5143
+ checkpointNs: (O == null ? void 0 : O.checkpointNs) ?? null
5144
+ }), b(null));
5136
5145
  },
5137
- [k, i]
5138
- ), B = N(() => {
5139
- v(null), S(""), w(null), y(null);
5140
- const j = M.current;
5141
- j !== null && E(j), M.current = null;
5142
- }, []), L = N((j) => {
5146
+ [v, i]
5147
+ ), j = N(() => {
5148
+ h(null), S(""), w(null), b(null);
5149
+ const z = M.current;
5150
+ z !== null && _(z), M.current = null;
5151
+ }, []), G = N((z) => {
5143
5152
  let C = null;
5144
- for (let V = j - 1; V >= 0; V--)
5145
- if (d[V].role === "user") {
5146
- C = d[V];
5153
+ for (let B = z - 1; B >= 0; B--)
5154
+ if (u[B].role === "user") {
5155
+ C = u[B];
5147
5156
  break;
5148
5157
  }
5149
5158
  if (!C) return;
5150
- const P = Array.isArray(C.content) ? C.content : [], K = P.filter((V) => (V == null ? void 0 : V.type) === "text").map((V) => V.text).join("") || (() => {
5159
+ const O = Array.isArray(C.content) ? C.content : [], K = O.filter((B) => (B == null ? void 0 : B.type) === "text").map((B) => B.text).join("") || (() => {
5151
5160
  try {
5152
- return JSON.stringify(P, null, 2);
5161
+ return JSON.stringify(O, null, 2);
5153
5162
  } catch {
5154
- return String(P);
5163
+ return String(O);
5155
5164
  }
5156
5165
  })();
5157
5166
  K && e(
@@ -5164,28 +5173,28 @@ function ho({
5164
5173
  originalMessageId: C.id,
5165
5174
  config: t.config
5166
5175
  },
5167
- f ? { onEvent: f } : void 0
5176
+ d ? { onEvent: d } : void 0
5168
5177
  );
5169
- }, [d, e, n, r, t]);
5178
+ }, [u, e, n, r, t]);
5170
5179
  return {
5171
- editingMessageId: u,
5180
+ editingMessageId: f,
5172
5181
  editingInitialValue: x,
5173
- inputError: b,
5174
- setInputError: y,
5182
+ inputError: k,
5183
+ setInputError: b,
5175
5184
  dismissError: T,
5176
- setDismissError: m,
5177
- composerValue: k,
5178
- handleComposerChange: F,
5179
- handleSendMessage: _,
5180
- handleQuickPrompt: O,
5181
- handleExcelUpload: R,
5182
- startEditing: W,
5183
- cancelEditing: B,
5184
- handleRegenerateCb: L,
5185
+ setDismissError: y,
5186
+ composerValue: v,
5187
+ handleComposerChange: U,
5188
+ handleSendMessage: V,
5189
+ handleQuickPrompt: P,
5190
+ handleExcelUpload: F,
5191
+ startEditing: E,
5192
+ cancelEditing: j,
5193
+ handleRegenerateCb: G,
5185
5194
  displayMessages: I
5186
5195
  };
5187
5196
  }
5188
- function bo(e) {
5197
+ function hs(e) {
5189
5198
  return Z(() => e ? {
5190
5199
  textContent: Ln(e),
5191
5200
  imageParts: jn(e),
@@ -5200,8 +5209,8 @@ function bo(e) {
5200
5209
  contentParts: []
5201
5210
  }, [e]);
5202
5211
  }
5203
- function wo(e, t, n) {
5204
- const [r, o] = D(e), s = H(e), a = H(null);
5212
+ function bs(e, t, n) {
5213
+ const [r, o] = H(e), s = W(e), a = W(null);
5205
5214
  return Y(() => {
5206
5215
  s.current = e;
5207
5216
  const i = () => {
@@ -5219,26 +5228,26 @@ function wo(e, t, n) {
5219
5228
  }, [e, t, n]), r;
5220
5229
  }
5221
5230
  export {
5222
- po as ChatProviders,
5231
+ fs as ChatProviders,
5223
5232
  jr as ThreadStateProvider,
5224
5233
  mr as ThreadsProvider,
5225
- ro as cn,
5226
- sr as collectText,
5227
- fo as createTaskSyncToolEndHandler,
5234
+ rs as cn,
5235
+ or as collectText,
5236
+ us as createTaskSyncToolEndHandler,
5228
5237
  Kr as extractTaskIdFromToolEnd,
5229
5238
  ar as extractToolMeta,
5230
- oo as formatToolOutput,
5231
- co as getAgentNameFromMessage,
5239
+ ss as formatToolOutput,
5240
+ cs as getAgentNameFromMessage,
5232
5241
  Pt as getChatToken,
5233
- uo as getMessageAttemptInfo,
5234
- ao as getToolCallArtifacts,
5235
- qn as getToolCalls,
5236
- so as hasContent,
5242
+ ds as getMessageAttemptInfo,
5243
+ as as getToolCallArtifacts,
5244
+ Vn as getToolCalls,
5245
+ os as hasContent,
5237
5246
  mt as hydrateHistorySnapshots,
5238
5247
  Ct as isFileLike,
5239
5248
  Nn as looksLikeMarkdown,
5240
- lo as messageSignature,
5241
- io as normalizeInterruptId,
5249
+ ls as messageSignature,
5250
+ is as normalizeInterruptId,
5242
5251
  _t as onChatTokenChanged,
5243
5252
  tt as parseJsonSafe,
5244
5253
  Et as pretty,
@@ -5247,18 +5256,18 @@ export {
5247
5256
  xe as setChatToken,
5248
5257
  Fn as stringifyTool,
5249
5258
  Me as useApi,
5250
- ho as useChatController,
5259
+ ys as useChatController,
5251
5260
  Yr as useChatSession,
5252
- go as useFilePreview,
5253
- bo as useMessageContent,
5254
- mo as useParsedMessageContent,
5261
+ ps as useFilePreview,
5262
+ hs as useMessageContent,
5263
+ gs as useParsedMessageContent,
5255
5264
  pr as useStream,
5256
- wo as useStreamingMarkdownBuffer,
5265
+ bs as useStreamingMarkdownBuffer,
5257
5266
  $t as useThreadHistoryState,
5258
- Vt as useThreadState,
5267
+ Ht as useThreadState,
5259
5268
  Lr as useThreadStateUpdater,
5260
- ot as useThreads,
5269
+ st as useThreads,
5261
5270
  gr as useThreadsState,
5262
- yo as useToolPayload
5271
+ ms as useToolPayload
5263
5272
  };
5264
5273
  //# sourceMappingURL=index.esm.js.map