@fencyai/react 0.1.131 → 0.1.132

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.
@@ -1 +1 @@
1
- {"version":3,"file":"AgentTaskProgressSimple.d.ts","sourceRoot":"","sources":["../../src/agent-task/AgentTaskProgressSimple.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,yBAAyB,CAAA;AAEhC,MAAM,WAAW,4BAA4B;IACzC,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;CACxC;AAmCD,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAC1C,4BAA4B,CAsC/B,CAAA"}
1
+ {"version":3,"file":"AgentTaskProgressSimple.d.ts","sourceRoot":"","sources":["../../src/agent-task/AgentTaskProgressSimple.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,OAAO,yBAAyB,CAAA;AAEhC,MAAM,WAAW,4BAA4B;IACzC,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;CACxC;AAsCD,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAC1C,4BAA4B,CAsC/B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"AgentTaskProgressVerbose.d.ts","sourceRoot":"","sources":["../../src/agent-task/AgentTaskProgressVerbose.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AASrD,MAAM,WAAW,6BAA6B;IAC1C,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;IACrC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CAC7C;AAED,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAC3C,6BAA6B,CAsHhC,CAAA"}
1
+ {"version":3,"file":"AgentTaskProgressVerbose.d.ts","sourceRoot":"","sources":["../../src/agent-task/AgentTaskProgressVerbose.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAUrD,MAAM,WAAW,6BAA6B;IAC1C,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;IACrC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CAC7C;AAED,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAC3C,6BAA6B,CAyHhC,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ export interface AgentTaskErrorProps {
3
+ message: string;
4
+ }
5
+ export declare const AgentTaskError: React.FC<AgentTaskErrorProps>;
6
+ //# sourceMappingURL=AgentTaskError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentTaskError.d.ts","sourceRoot":"","sources":["../../../src/agent-task/data-types/AgentTaskError.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,WAAW,mBAAmB;IAChC,OAAO,EAAE,MAAM,CAAA;CAClB;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAyBxD,CAAA"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsxs as C, jsx as i } from "react/jsx-runtime";
1
+ import { jsxs as C, jsx as s } from "react/jsx-runtime";
2
2
  import { createStream as K, isStreamTimeoutEvent as _, isStreamNotFoundEvent as J, isAgentTaskProgressItemUpdatedEvent as V, createAgentTask as q } from "@fencyai/js";
3
3
  import { createContext as G, useState as k, useRef as E, useEffect as w, useCallback as L, useContext as X, useMemo as U } from "react";
4
- import { useInView as Q, motion as T, AnimatePresence as W } from "motion/react";
4
+ import { useInView as Q, motion as b, AnimatePresence as W } from "motion/react";
5
5
  import Y from "react-markdown";
6
6
  import { Prism as $ } from "react-syntax-highlighter";
7
7
  import Z from "remark-gfm";
@@ -48,20 +48,20 @@ function re(e, t, n) {
48
48
  if (o.length === 0)
49
49
  n == null || n(r), r = F();
50
50
  else if (d > 0) {
51
- const y = c.decode(o.subarray(0, d)), a = d + (o[d + 1] === 32 ? 2 : 1), s = c.decode(o.subarray(a));
51
+ const y = c.decode(o.subarray(0, d)), a = d + (o[d + 1] === 32 ? 2 : 1), i = c.decode(o.subarray(a));
52
52
  switch (y) {
53
53
  case "data":
54
54
  r.data = r.data ? r.data + `
55
- ` + s : s;
55
+ ` + i : i;
56
56
  break;
57
57
  case "event":
58
- r.event = s;
58
+ r.event = i;
59
59
  break;
60
60
  case "id":
61
- e(r.id = s);
61
+ e(r.id = i);
62
62
  break;
63
63
  case "retry":
64
- const m = parseInt(s, 10);
64
+ const m = parseInt(i, 10);
65
65
  isNaN(m) || t(r.retry = m);
66
66
  break;
67
67
  }
@@ -90,7 +90,7 @@ var oe = function(e, t) {
90
90
  };
91
91
  const O = "text/event-stream", ae = 1e3, R = "last-event-id";
92
92
  function se(e, t) {
93
- var { signal: n, headers: r, onopen: c, onmessage: l, onclose: o, onerror: d, openWhenHidden: y, fetch: a } = t, s = oe(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
93
+ var { signal: n, headers: r, onopen: c, onmessage: l, onclose: o, onerror: d, openWhenHidden: y, fetch: a } = t, i = oe(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
94
94
  return new Promise((m, u) => {
95
95
  const f = Object.assign({}, r);
96
96
  f.accept || (f.accept = O);
@@ -100,30 +100,30 @@ function se(e, t) {
100
100
  }
101
101
  y || document.addEventListener("visibilitychange", p);
102
102
  let h = ae, S = 0;
103
- function b() {
103
+ function v() {
104
104
  document.removeEventListener("visibilitychange", p), window.clearTimeout(S), g.abort();
105
105
  }
106
106
  n == null || n.addEventListener("abort", () => {
107
- b(), m();
107
+ v(), m();
108
108
  });
109
109
  const P = a ?? window.fetch, A = c ?? ie;
110
110
  async function x() {
111
111
  var M;
112
112
  g = new AbortController();
113
113
  try {
114
- const I = await P(e, Object.assign(Object.assign({}, s), { headers: f, signal: g.signal }));
115
- await A(I), await ee(I.body, te(re((v) => {
116
- v ? f[R] = v : delete f[R];
117
- }, (v) => {
118
- h = v;
119
- }, l))), o == null || o(), b(), m();
114
+ const I = await P(e, Object.assign(Object.assign({}, i), { headers: f, signal: g.signal }));
115
+ await A(I), await ee(I.body, te(re((T) => {
116
+ T ? f[R] = T : delete f[R];
117
+ }, (T) => {
118
+ h = T;
119
+ }, l))), o == null || o(), v(), m();
120
120
  } catch (I) {
121
121
  if (!g.signal.aborted)
122
122
  try {
123
- const v = (M = d == null ? void 0 : d(I)) !== null && M !== void 0 ? M : h;
124
- window.clearTimeout(S), S = window.setTimeout(x, v);
125
- } catch (v) {
126
- b(), u(v);
123
+ const T = (M = d == null ? void 0 : d(I)) !== null && M !== void 0 ? M : h;
124
+ window.clearTimeout(S), S = window.setTimeout(x, T);
125
+ } catch (T) {
126
+ v(), u(T);
127
127
  }
128
128
  }
129
129
  }
@@ -216,10 +216,10 @@ const de = 12e4, ue = (e) => {
216
216
  const t = Date.now();
217
217
  return e.filter((n) => t - n.createdAt < de);
218
218
  };
219
- function Le({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
219
+ function Ue({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
220
220
  const [r, c] = k(
221
221
  null
222
- ), [l, o] = k(!0), [d, y] = k(null), [a, s] = k([]), m = E(null), u = E(null);
222
+ ), [l, o] = k(!0), [d, y] = k(null), [a, i] = k([]), m = E(null), u = E(null);
223
223
  w(() => {
224
224
  e.then((h) => {
225
225
  c(h), o(!1);
@@ -238,9 +238,9 @@ function Le({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
238
238
  async (h = 3e4) => {
239
239
  if (m.current)
240
240
  return m.current;
241
- const S = Date.now(), b = a.length > 0 ? a[a.length - 1] : null;
242
- if (b && S - b.createdAt < h)
243
- return b.stream;
241
+ const S = Date.now(), v = a.length > 0 ? a[a.length - 1] : null;
242
+ if (v && S - v.createdAt < h)
243
+ return v.stream;
244
244
  const P = (async () => {
245
245
  if (!r)
246
246
  throw new Error("Fency instance not initialized");
@@ -254,9 +254,9 @@ function Le({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
254
254
  stream: x.stream,
255
255
  createdAt: Date.now()
256
256
  };
257
- return s((I) => {
258
- const v = [...I, M];
259
- return ue(v);
257
+ return i((I) => {
258
+ const T = [...I, M];
259
+ return ue(T);
260
260
  }), m.current = null, x.stream;
261
261
  } else
262
262
  throw m.current = null, new Error("Failed to create stream");
@@ -281,7 +281,7 @@ function Le({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
281
281
  eventManager: u.current,
282
282
  getOrCreateStream: f
283
283
  };
284
- return /* @__PURE__ */ i(N.Provider, { value: p, children: n });
284
+ return /* @__PURE__ */ s(N.Provider, { value: p, children: n });
285
285
  }
286
286
  function j() {
287
287
  const e = X(N);
@@ -319,17 +319,17 @@ const me = (e) => {
319
319
  const o = {
320
320
  onMessage: (y, a) => {
321
321
  var m, u, f;
322
- const s = me(y);
323
- if (s)
324
- switch (s.type) {
322
+ const i = me(y);
323
+ if (i)
324
+ switch (i.type) {
325
325
  case "StreamTimeout":
326
- (m = e == null ? void 0 : e.onStreamTimeout) == null || m.call(e, s);
326
+ (m = e == null ? void 0 : e.onStreamTimeout) == null || m.call(e, i);
327
327
  break;
328
328
  case "StreamNotFound":
329
- (u = e == null ? void 0 : e.onStreamNotFound) == null || u.call(e, s);
329
+ (u = e == null ? void 0 : e.onStreamNotFound) == null || u.call(e, i);
330
330
  break;
331
331
  case "AgentTaskProgressItemUpdated":
332
- (f = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || f.call(e, s);
332
+ (f = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || f.call(e, i);
333
333
  break;
334
334
  }
335
335
  },
@@ -368,17 +368,17 @@ const me = (e) => {
368
368
  },
369
369
  stream: n
370
370
  };
371
- }, Ue = (e) => {
371
+ }, We = (e) => {
372
372
  const t = j(), [n, r] = k([]), c = E(/* @__PURE__ */ new Set()), l = E(/* @__PURE__ */ new Map()), { createStream: o } = pe({
373
373
  onAgentTaskProgressItemUpdated: (a) => {
374
374
  var u;
375
375
  if (!c.current.has(a.agentTaskId)) return;
376
- const s = a.data;
377
- if (s.taskType === "StreamingChatCompletion" && s.eventType === "Completed" || s.taskType === "StructuredChatCompletion" && s.eventType === "Completed" || s.taskType === "MemoryChatCompletion" && s.eventType === "Completed") {
376
+ const i = a.data;
377
+ if (i.taskType === "StreamingChatCompletion" && i.eventType === "Completed" || i.taskType === "StructuredChatCompletion" && i.eventType === "Completed" || i.taskType === "MemoryChatCompletion" && i.eventType === "Completed") {
378
378
  const f = l.current.get(
379
379
  a.agentTaskId
380
380
  );
381
- f && (l.current.delete(a.agentTaskId), f(s));
381
+ f && (l.current.delete(a.agentTaskId), f(i));
382
382
  return;
383
383
  }
384
384
  (u = e.onAgentTaskProgressItemUpdated) == null || u.call(e, a), r(
@@ -387,17 +387,17 @@ const me = (e) => {
387
387
  if (((S = g.confirmedData) == null ? void 0 : S.taskId) !== a.agentTaskId)
388
388
  return g;
389
389
  const h = g.progressItems.some(
390
- (b) => b.progressItemId === a.progressItemId
390
+ (v) => v.progressItemId === a.progressItemId
391
391
  ) ? g.progressItems.map(
392
- (b) => b.progressItemId === a.progressItemId ? a : b
392
+ (v) => v.progressItemId === a.progressItemId ? a : v
393
393
  ) : [...g.progressItems, a];
394
394
  return { ...g, progressItems: h };
395
395
  })
396
396
  );
397
397
  },
398
398
  onStreamError: (a) => {
399
- var s;
400
- (s = e == null ? void 0 : e.onStreamError) == null || s.call(e, a), r((m) => {
399
+ var i;
400
+ (i = e == null ? void 0 : e.onStreamError) == null || i.call(e, a), r((m) => {
401
401
  const u = m.find((f) => f.streamId === a.streamId);
402
402
  return u ? [
403
403
  ...m.filter((f) => f.streamId !== a.streamId),
@@ -410,15 +410,15 @@ const me = (e) => {
410
410
  });
411
411
  },
412
412
  onStreamNotFound: (a) => {
413
- var s;
414
- (s = e == null ? void 0 : e.onStreamNotFound) == null || s.call(e, a);
413
+ var i;
414
+ (i = e == null ? void 0 : e.onStreamNotFound) == null || i.call(e, a);
415
415
  },
416
416
  onStreamTimeout: (a) => {
417
- var s;
418
- (s = e == null ? void 0 : e.onStreamTimeout) == null || s.call(e, a);
417
+ var i;
418
+ (i = e == null ? void 0 : e.onStreamTimeout) == null || i.call(e, a);
419
419
  }
420
420
  }), d = L(
421
- async (a, s) => {
421
+ async (a, i) => {
422
422
  const m = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, u = await o();
423
423
  if (u.type === "success") {
424
424
  r([
@@ -432,7 +432,7 @@ const me = (e) => {
432
432
  params: a,
433
433
  progressItems: [],
434
434
  loading: !0,
435
- loadingText: s == null ? void 0 : s.loadingText
435
+ loadingText: i == null ? void 0 : i.loadingText
436
436
  }
437
437
  ]);
438
438
  const { clientToken: f } = await e.fetchCreateAgentTaskClientToken(a.type), g = await q({
@@ -471,7 +471,7 @@ const me = (e) => {
471
471
  params: a,
472
472
  progressItems: [],
473
473
  loading: !0,
474
- loadingText: s == null ? void 0 : s.loadingText,
474
+ loadingText: i == null ? void 0 : i.loadingText,
475
475
  confirmedData: {
476
476
  taskId: g.agentTask.id,
477
477
  createdAt: g.agentTask.createdAt
@@ -502,7 +502,7 @@ const me = (e) => {
502
502
  error: g.error,
503
503
  progressItems: [],
504
504
  loading: !1,
505
- loadingText: s == null ? void 0 : s.loadingText,
505
+ loadingText: i == null ? void 0 : i.loadingText,
506
506
  confirmedData: null
507
507
  }
508
508
  ]), {
@@ -524,7 +524,7 @@ const me = (e) => {
524
524
  params: a,
525
525
  progressItems: [],
526
526
  loading: !1,
527
- loadingText: s == null ? void 0 : s.loadingText,
527
+ loadingText: i == null ? void 0 : i.loadingText,
528
528
  confirmedData: null
529
529
  }
530
530
  ]), {
@@ -539,7 +539,7 @@ const me = (e) => {
539
539
  [t, n, o]
540
540
  ), y = U(() => {
541
541
  if (n.length !== 0)
542
- return [...n].sort((a, s) => new Date(s.triggeredAt).getTime() - new Date(a.triggeredAt).getTime())[0];
542
+ return [...n].sort((a, i) => new Date(i.triggeredAt).getTime() - new Date(a.triggeredAt).getTime())[0];
543
543
  }, [n]);
544
544
  return w(() => () => {
545
545
  c.current.clear(), l.current.clear();
@@ -576,13 +576,13 @@ function D({
576
576
  once: d = !1,
577
577
  inViewMargin: y,
578
578
  spread: a = 2,
579
- color: s = "#999",
579
+ color: i = "#999",
580
580
  shimmerColor: m = "#000",
581
581
  direction: u = "fromBottom"
582
582
  }) {
583
- const f = E(null), g = Q(f, { once: d, margin: y }), p = U(() => e.length * a, [e, a]), h = !o || g, S = u === "fromBottom" ? "100% center" : "-100% center", b = u === "fromBottom" ? "0% center" : "200% center";
584
- return /* @__PURE__ */ i(
585
- T.span,
583
+ const f = E(null), g = Q(f, { once: d, margin: y }), p = U(() => e.length * a, [e, a]), h = !o || g, S = u === "fromBottom" ? "100% center" : "-100% center", v = u === "fromBottom" ? "0% center" : "200% center";
584
+ return /* @__PURE__ */ s(
585
+ b.span,
586
586
  {
587
587
  ref: f,
588
588
  className: l,
@@ -596,7 +596,7 @@ function D({
596
596
  WebkitTextFillColor: "transparent",
597
597
  backgroundRepeat: "no-repeat, padding-box",
598
598
  "--spread": `${p}px`,
599
- "--base-color": s,
599
+ "--base-color": i,
600
600
  "--shimmer-color": m,
601
601
  "--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
602
602
  backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
@@ -606,7 +606,7 @@ function D({
606
606
  opacity: 0
607
607
  },
608
608
  animate: h ? {
609
- backgroundPosition: b,
609
+ backgroundPosition: v,
610
610
  opacity: 1
611
611
  } : {},
612
612
  transition: {
@@ -626,8 +626,10 @@ function D({
626
626
  }
627
627
  );
628
628
  }
629
- function be(e) {
629
+ function ve(e) {
630
630
  const t = e.item.data;
631
+ if (t.eventType === "Error" && "message" in t)
632
+ return "Error";
631
633
  if (t.taskType === "StreamingChatCompletion") {
632
634
  if (t.eventType === "Text") return "Streaming...";
633
635
  if (t.eventType === "Completed") return "Completed";
@@ -657,25 +659,25 @@ function be(e) {
657
659
  }
658
660
  return "Processing...";
659
661
  }
660
- const ve = ({ progressViewItems: e }) => {
662
+ const be = ({ progressViewItems: e }) => {
661
663
  const t = e[e.length - 1];
662
664
  if (!t) return null;
663
- const n = be(t);
664
- return /* @__PURE__ */ i("div", { className: "simple-mode-container", children: /* @__PURE__ */ i(W, { mode: "wait", children: /* @__PURE__ */ i(
665
- T.div,
665
+ const n = ve(t);
666
+ return /* @__PURE__ */ s("div", { className: "simple-mode-container", children: /* @__PURE__ */ s(W, { mode: "wait", children: /* @__PURE__ */ s(
667
+ b.div,
666
668
  {
667
669
  initial: { opacity: 0, y: 10 },
668
670
  animate: { opacity: 1, y: 0 },
669
671
  exit: { opacity: 0, y: -10 },
670
672
  transition: { duration: 0.3 },
671
- children: t.completed ? /* @__PURE__ */ i(
673
+ children: t.completed ? /* @__PURE__ */ s(
672
674
  "div",
673
675
  {
674
676
  className: "simple-mode-title",
675
677
  style: { color: "#666" },
676
678
  children: n
677
679
  }
678
- ) : /* @__PURE__ */ i(
680
+ ) : /* @__PURE__ */ s(
679
681
  D,
680
682
  {
681
683
  text: n,
@@ -842,21 +844,21 @@ const ve = ({ progressViewItems: e }) => {
842
844
  }
843
845
  }, z = ({
844
846
  text: e
845
- }) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
846
- T.div,
847
+ }) => /* @__PURE__ */ s("div", { style: { padding: "16px" }, children: /* @__PURE__ */ s(
848
+ b.div,
847
849
  {
848
850
  className: "fency-markdown-body-raw",
849
851
  initial: { opacity: 0, y: -10 },
850
852
  animate: { opacity: 1, y: 0 },
851
853
  transition: { duration: 0.3, delay: 0 },
852
- children: /* @__PURE__ */ i(
854
+ children: /* @__PURE__ */ s(
853
855
  Y,
854
856
  {
855
857
  remarkPlugins: [Z],
856
858
  components: {
857
859
  code(t) {
858
860
  const { children: n, className: r, node: c, ref: l, ...o } = t, d = /language-(\w+)/.exec(r || "");
859
- return d ? /* @__PURE__ */ i(
861
+ return d ? /* @__PURE__ */ s(
860
862
  $,
861
863
  {
862
864
  ...o,
@@ -865,7 +867,7 @@ const ve = ({ progressViewItems: e }) => {
865
867
  language: d[1],
866
868
  style: H
867
869
  }
868
- ) : /* @__PURE__ */ i("code", { ...o, className: r, children: String(n) });
870
+ ) : /* @__PURE__ */ s("code", { ...o, className: r, children: String(n) });
869
871
  }
870
872
  },
871
873
  children: e
@@ -874,20 +876,20 @@ const ve = ({ progressViewItems: e }) => {
874
876
  }
875
877
  ) }), Te = ({ data: e }) => {
876
878
  const t = JSON.stringify(e.json, null, 2);
877
- return /* @__PURE__ */ i("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ i(
878
- T.div,
879
+ return /* @__PURE__ */ s("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ s(
880
+ b.div,
879
881
  {
880
882
  initial: { opacity: 0, y: -10 },
881
883
  animate: { opacity: 1, y: 0 },
882
884
  transition: { duration: 0.3, delay: 0 },
883
- children: /* @__PURE__ */ i($, { language: "json", style: H, PreTag: "div", children: t })
885
+ children: /* @__PURE__ */ s($, { language: "json", style: H, PreTag: "div", children: t })
884
886
  }
885
887
  ) });
886
888
  }, Ce = ({ data: e, isLatest: t = !1, durationSeconds: n }) => {
887
889
  const r = `Searching: ${e.queryDescription}`;
888
890
  return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
889
- /* @__PURE__ */ i(
890
- T.div,
891
+ /* @__PURE__ */ s(
892
+ b.div,
891
893
  {
892
894
  style: {
893
895
  display: "flex",
@@ -898,7 +900,7 @@ const ve = ({ progressViewItems: e }) => {
898
900
  initial: { opacity: 0, y: -10 },
899
901
  animate: { opacity: 1, y: 0 },
900
902
  transition: { duration: 0.3, delay: 0 },
901
- children: t && !n ? /* @__PURE__ */ i(
903
+ children: t && !n ? /* @__PURE__ */ s(
902
904
  D,
903
905
  {
904
906
  text: r,
@@ -907,7 +909,7 @@ const ve = ({ progressViewItems: e }) => {
907
909
  color: "#999",
908
910
  shimmerColor: "#000"
909
911
  }
910
- ) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: r })
912
+ ) : /* @__PURE__ */ s("span", { style: { color: "#666" }, children: r })
911
913
  }
912
914
  ),
913
915
  n !== void 0 && /* @__PURE__ */ C(
@@ -930,8 +932,8 @@ const ve = ({ progressViewItems: e }) => {
930
932
  }, ke = ({ isLatest: e = !1, durationSeconds: t }) => {
931
933
  const n = "Adding sources...";
932
934
  return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
933
- /* @__PURE__ */ i(
934
- T.div,
935
+ /* @__PURE__ */ s(
936
+ b.div,
935
937
  {
936
938
  style: {
937
939
  display: "flex",
@@ -942,7 +944,7 @@ const ve = ({ progressViewItems: e }) => {
942
944
  initial: { opacity: 0, y: -10 },
943
945
  animate: { opacity: 1, y: 0 },
944
946
  transition: { duration: 0.3, delay: 0 },
945
- children: e && !t ? /* @__PURE__ */ i(
947
+ children: e && !t ? /* @__PURE__ */ s(
946
948
  D,
947
949
  {
948
950
  text: n,
@@ -951,7 +953,7 @@ const ve = ({ progressViewItems: e }) => {
951
953
  color: "#999",
952
954
  shimmerColor: "#000"
953
955
  }
954
- ) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: n })
956
+ ) : /* @__PURE__ */ s("span", { style: { color: "#666" }, children: n })
955
957
  }
956
958
  ),
957
959
  t !== void 0 && /* @__PURE__ */ C(
@@ -972,8 +974,8 @@ const ve = ({ progressViewItems: e }) => {
972
974
  )
973
975
  ] });
974
976
  }, xe = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
975
- /* @__PURE__ */ i(
976
- T.div,
977
+ /* @__PURE__ */ s(
978
+ b.div,
977
979
  {
978
980
  style: {
979
981
  marginBottom: "10px",
@@ -989,7 +991,7 @@ const ve = ({ progressViewItems: e }) => {
989
991
  children: "Sources"
990
992
  }
991
993
  ),
992
- /* @__PURE__ */ i("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.length === 0 ? /* @__PURE__ */ i("span", { style: { fontSize: "13px", color: "#888" }, children: "No sources" }) : e.sources.map((n, r) => /* @__PURE__ */ i(
994
+ /* @__PURE__ */ s("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.length === 0 ? /* @__PURE__ */ s("span", { style: { fontSize: "13px", color: "#888" }, children: "No sources" }) : e.sources.map((n, r) => /* @__PURE__ */ s(
993
995
  Ee,
994
996
  {
995
997
  source: n,
@@ -1010,7 +1012,7 @@ function we(e) {
1010
1012
  const Ee = ({ source: e, index: t, onSourceClick: n }) => {
1011
1013
  const [r, c] = k(!1), l = !!n, o = e.pageNumbers ?? [], d = we(o);
1012
1014
  return /* @__PURE__ */ C(
1013
- T.div,
1015
+ b.div,
1014
1016
  {
1015
1017
  initial: { opacity: 0, scale: 0.9 },
1016
1018
  animate: { opacity: 1, scale: 1 },
@@ -1031,8 +1033,8 @@ const Ee = ({ source: e, index: t, onSourceClick: n }) => {
1031
1033
  userSelect: "none"
1032
1034
  },
1033
1035
  children: [
1034
- /* @__PURE__ */ i("span", { style: { fontSize: "13px", fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1035
- d && /* @__PURE__ */ i("span", { style: { fontSize: "12px", color: "#666" }, children: d })
1036
+ /* @__PURE__ */ s("span", { style: { fontSize: "13px", fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1037
+ d && /* @__PURE__ */ s("span", { style: { fontSize: "12px", color: "#666" }, children: d })
1036
1038
  ]
1037
1039
  }
1038
1040
  );
@@ -1041,13 +1043,13 @@ function Ie({
1041
1043
  eventType: e,
1042
1044
  completed: t
1043
1045
  }) {
1044
- return e === "ExploreMemoryError" ? /* @__PURE__ */ i("span", { style: { color: "#c62828", fontSize: 14, fontWeight: 600 }, children: "✗" }) : e === "ExploreMemoryResult" ? /* @__PURE__ */ i("span", { style: { color: "#999", fontSize: 14, fontWeight: 600 }, children: "✓" }) : e === "ExploreMemoryStart" && t ? /* @__PURE__ */ i("span", { style: { color: "#999", fontSize: 14, fontWeight: 600 }, children: "✓" }) : null;
1046
+ return e === "ExploreMemoryError" ? /* @__PURE__ */ s("span", { style: { color: "#c62828", fontSize: 14, fontWeight: 600 }, children: "✗" }) : e === "ExploreMemoryResult" ? /* @__PURE__ */ s("span", { style: { color: "#999", fontSize: 14, fontWeight: 600 }, children: "✓" }) : e === "ExploreMemoryStart" && t ? /* @__PURE__ */ s("span", { style: { color: "#999", fontSize: 14, fontWeight: 600 }, children: "✓" }) : null;
1045
1047
  }
1046
1048
  const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1047
1049
  const [r, c] = k(!1), l = e.eventType === "ExploreMemoryResult" ? e.result : void 0, o = l != null && l.length > B, d = l != null ? r || !o ? l : `${l.slice(0, B)}...` : void 0, y = o;
1048
1050
  if (e.eventType === "ExploreMemoryStart" && !t) {
1049
- const s = `Exploring ${e.memoryTitle}...`;
1050
- return /* @__PURE__ */ i(
1051
+ const i = `Exploring ${e.memoryTitle}...`;
1052
+ return /* @__PURE__ */ s(
1051
1053
  "div",
1052
1054
  {
1053
1055
  style: {
@@ -1055,26 +1057,26 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1055
1057
  display: "flex",
1056
1058
  alignItems: "center"
1057
1059
  },
1058
- children: n ? /* @__PURE__ */ i(
1060
+ children: n ? /* @__PURE__ */ s(
1059
1061
  D,
1060
1062
  {
1061
- text: s,
1063
+ text: i,
1062
1064
  duration: 2.5,
1063
1065
  repeat: !0,
1064
1066
  color: "#999",
1065
1067
  shimmerColor: "#000"
1066
1068
  }
1067
- ) : /* @__PURE__ */ i("span", { style: { fontSize: 13, color: "#999" }, children: s })
1069
+ ) : /* @__PURE__ */ s("span", { style: { fontSize: 13, color: "#999" }, children: i })
1068
1070
  }
1069
1071
  );
1070
1072
  }
1071
- return /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ C(
1072
- T.div,
1073
+ return /* @__PURE__ */ s("div", { style: { padding: "16px" }, children: /* @__PURE__ */ C(
1074
+ b.div,
1073
1075
  {
1074
1076
  initial: { opacity: 0 },
1075
1077
  animate: { opacity: 1 },
1076
1078
  transition: { duration: 0.25 },
1077
- onClick: y ? () => c((s) => !s) : void 0,
1079
+ onClick: y ? () => c((i) => !i) : void 0,
1078
1080
  style: {
1079
1081
  paddingBottom: "12px",
1080
1082
  borderBottom: "1px solid #eee",
@@ -1086,7 +1088,7 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1086
1088
  cursor: y ? "pointer" : "default"
1087
1089
  },
1088
1090
  children: [
1089
- /* @__PURE__ */ i(
1091
+ /* @__PURE__ */ s(
1090
1092
  "div",
1091
1093
  {
1092
1094
  style: {
@@ -1096,7 +1098,7 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1096
1098
  flexShrink: 0,
1097
1099
  width: 20
1098
1100
  },
1099
- children: /* @__PURE__ */ i(Ie, { eventType: e.eventType, completed: t })
1101
+ children: /* @__PURE__ */ s(Ie, { eventType: e.eventType, completed: t })
1100
1102
  }
1101
1103
  ),
1102
1104
  /* @__PURE__ */ C(
@@ -1109,8 +1111,8 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1109
1111
  minWidth: 0
1110
1112
  },
1111
1113
  children: [
1112
- /* @__PURE__ */ i("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1113
- d != null && /* @__PURE__ */ i(
1114
+ /* @__PURE__ */ s("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1115
+ d != null && /* @__PURE__ */ s(
1114
1116
  "span",
1115
1117
  {
1116
1118
  style: {
@@ -1122,7 +1124,7 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1122
1124
  children: d
1123
1125
  }
1124
1126
  ),
1125
- y && /* @__PURE__ */ i(
1127
+ y && /* @__PURE__ */ s(
1126
1128
  "span",
1127
1129
  {
1128
1130
  style: {
@@ -1139,7 +1141,30 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1139
1141
  ]
1140
1142
  }
1141
1143
  ) });
1142
- }, Me = ({
1144
+ }, Me = ({ message: e }) => /* @__PURE__ */ s("div", { style: { padding: "16px" }, children: /* @__PURE__ */ s(
1145
+ b.div,
1146
+ {
1147
+ initial: { opacity: 0, y: -10 },
1148
+ animate: { opacity: 1, y: 0 },
1149
+ transition: { duration: 0.3, delay: 0 },
1150
+ style: {
1151
+ display: "flex",
1152
+ alignItems: "flex-start",
1153
+ gap: "10px"
1154
+ },
1155
+ children: /* @__PURE__ */ s(
1156
+ "span",
1157
+ {
1158
+ style: {
1159
+ fontSize: 16,
1160
+ color: "#c62828",
1161
+ lineHeight: 1.4
1162
+ },
1163
+ children: e
1164
+ }
1165
+ )
1166
+ }
1167
+ ) }), De = ({
1143
1168
  progressViewItems: e,
1144
1169
  loadingText: t,
1145
1170
  onSourceClick: n
@@ -1151,15 +1176,15 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1151
1176
  const c = (l) => {
1152
1177
  const o = l.item.data;
1153
1178
  if (o.taskType === "StreamingChatCompletion" && o.eventType === "Text")
1154
- return /* @__PURE__ */ i(z, { text: o.text });
1179
+ return /* @__PURE__ */ s(z, { text: o.text });
1155
1180
  if (o.taskType === "StructuredChatCompletion" && o.eventType === "Json")
1156
- return /* @__PURE__ */ i(Te, { data: o });
1181
+ return /* @__PURE__ */ s(Te, { data: o });
1157
1182
  if (o.taskType === "MemoryChatCompletion")
1158
1183
  switch (o.eventType) {
1159
1184
  case "Text":
1160
- return /* @__PURE__ */ i(z, { text: o.text });
1185
+ return /* @__PURE__ */ s(z, { text: o.text });
1161
1186
  case "Search":
1162
- return /* @__PURE__ */ i(
1187
+ return /* @__PURE__ */ s(
1163
1188
  Ce,
1164
1189
  {
1165
1190
  data: o,
@@ -1168,7 +1193,7 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1168
1193
  }
1169
1194
  );
1170
1195
  case "FindSources":
1171
- return /* @__PURE__ */ i(
1196
+ return /* @__PURE__ */ s(
1172
1197
  ke,
1173
1198
  {
1174
1199
  data: o,
@@ -1177,7 +1202,7 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1177
1202
  }
1178
1203
  );
1179
1204
  case "SourcesResult":
1180
- return /* @__PURE__ */ i(
1205
+ return /* @__PURE__ */ s(
1181
1206
  xe,
1182
1207
  {
1183
1208
  data: o,
@@ -1187,7 +1212,7 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1187
1212
  case "ExploreMemoryStart":
1188
1213
  case "ExploreMemoryResult":
1189
1214
  case "ExploreMemoryError":
1190
- return /* @__PURE__ */ i(
1215
+ return /* @__PURE__ */ s(
1191
1216
  Ae,
1192
1217
  {
1193
1218
  data: o,
@@ -1198,9 +1223,9 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1198
1223
  case "Completed":
1199
1224
  return null;
1200
1225
  }
1201
- return o.taskType === "StreamingChatCompletion" && o.eventType === "Completed" || o.taskType === "StructuredChatCompletion" && o.eventType === "Completed", null;
1226
+ return o.taskType === "StreamingChatCompletion" && o.eventType === "Completed" || o.taskType === "StructuredChatCompletion" && o.eventType === "Completed" ? null : o.eventType === "Error" && "message" in o ? /* @__PURE__ */ s(Me, { message: o.message }) : null;
1202
1227
  };
1203
- return e.length === 0 ? /* @__PURE__ */ i("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ i(
1228
+ return e.length === 0 ? /* @__PURE__ */ s("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ s(
1204
1229
  D,
1205
1230
  {
1206
1231
  text: t ?? "Processing your task...",
@@ -1210,8 +1235,8 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1210
1235
  color: "#999",
1211
1236
  shimmerColor: "#000"
1212
1237
  }
1213
- ) }) : /* @__PURE__ */ i("div", { id: "agent-task-progress-verbose", ref: r, children: /* @__PURE__ */ i(W, { children: e.map((l, o) => /* @__PURE__ */ i(
1214
- T.div,
1238
+ ) }) : /* @__PURE__ */ s("div", { id: "agent-task-progress-verbose", ref: r, children: /* @__PURE__ */ s(W, { children: e.map((l, o) => /* @__PURE__ */ s(
1239
+ b.div,
1215
1240
  {
1216
1241
  id: `agent-task-progress-item-${l.item.progressItemId}`,
1217
1242
  initial: { opacity: 0, y: -20 },
@@ -1225,14 +1250,14 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1225
1250
  },
1226
1251
  l.item.progressItemId
1227
1252
  )) }) });
1228
- }, We = ({
1253
+ }, $e = ({
1229
1254
  agentTask: e,
1230
1255
  mode: t = "verbose",
1231
1256
  onSourceClick: n
1232
1257
  }) => {
1233
1258
  const r = Se(e);
1234
- return t === "simple" ? /* @__PURE__ */ i(ve, { progressViewItems: r }) : /* @__PURE__ */ i(
1235
- Me,
1259
+ return t === "simple" ? /* @__PURE__ */ s(be, { progressViewItems: r }) : /* @__PURE__ */ s(
1260
+ De,
1236
1261
  {
1237
1262
  progressViewItems: r,
1238
1263
  loadingText: e.loadingText,
@@ -1241,7 +1266,7 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1241
1266
  );
1242
1267
  };
1243
1268
  export {
1244
- We as AgentTaskProgress,
1245
- Le as FencyProvider,
1246
- Ue as useAgentTasks
1269
+ $e as AgentTaskProgress,
1270
+ Ue as FencyProvider,
1271
+ We as useAgentTasks
1247
1272
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fencyai/react",
3
- "version": "0.1.131",
3
+ "version": "0.1.132",
4
4
  "description": "> TODO: description",
5
5
  "author": "staklau <steinaageklaussen@gmail.com>",
6
6
  "homepage": "",
@@ -37,7 +37,7 @@
37
37
  "@microsoft/fetch-event-source": "^2.0.1"
38
38
  },
39
39
  "devDependencies": {
40
- "@fencyai/js": "^0.1.131",
40
+ "@fencyai/js": "^0.1.132",
41
41
  "@testing-library/react": "^16.3.2",
42
42
  "@types/jest": "^29.5.11",
43
43
  "@types/node": "^20.10.5",
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@emotion/is-prop-valid": "^1.3.0",
57
- "@fencyai/js": "^0.1.131",
57
+ "@fencyai/js": "^0.1.132",
58
58
  "@radix-ui/react-popover": "^1.1.15",
59
59
  "motion": "^11.15.0",
60
60
  "react": ">=16.8.0",
@@ -69,5 +69,5 @@
69
69
  "optional": false
70
70
  }
71
71
  },
72
- "gitHead": "de43772a6bc8a40273f9c3ba29c87e918db90bc6"
72
+ "gitHead": "9228298eda0593b83b99f337e17a3c4cca390b49"
73
73
  }