@fencyai/react 0.1.108 → 0.1.110

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.js CHANGED
@@ -1,26 +1,26 @@
1
- import { createAgentTask as K, createFileDownloadLink as q, AgentTaskProgressItemType as F, createStream as G } from "@fencyai/js";
2
- import { createContext as V, useContext as X, useState as k, useEffect as P, useMemo as B, useCallback as D, useRef as R } from "react";
3
- import { jsxs as S, jsx as g } from "react/jsx-runtime";
4
- import { motion as v, useInView as Y, AnimatePresence as _ } from "motion/react";
1
+ import { createAgentTask as q, createFileDownloadLink as G, AgentTaskProgressItemType as O, createStream as V } from "@fencyai/js";
2
+ import { createContext as X, useContext as Y, useState as T, useEffect as x, useMemo as B, useCallback as D, useRef as F } from "react";
3
+ import { jsxs as I, jsx as g } from "react/jsx-runtime";
4
+ import { motion as C, useInView as J, AnimatePresence as _ } from "motion/react";
5
5
  import W from "react-markdown";
6
6
  import { Prism as j } from "react-syntax-highlighter";
7
- import p from "remark-gfm";
8
- import './assets/index.css';const L = V(
7
+ import L from "remark-gfm";
8
+ import './assets/index.css';const $ = X(
9
9
  void 0
10
10
  );
11
- function U() {
12
- const e = X(L);
11
+ function R() {
12
+ const e = Y($);
13
13
  if (e === void 0)
14
14
  throw new Error("useFencyContext must be used within a FencyProvider");
15
15
  return e;
16
16
  }
17
- async function J(e, t) {
17
+ async function Q(e, t) {
18
18
  const o = e.getReader();
19
19
  let i;
20
20
  for (; !(i = await o.read()).done; )
21
21
  t(i.value);
22
22
  }
23
- function Q(e) {
23
+ function Z(e) {
24
24
  let t, o, i, s = !1;
25
25
  return function(u) {
26
26
  t === void 0 ? (t = u, o = 0, i = -1) : t = ee(t, u);
@@ -47,7 +47,7 @@ function Q(e) {
47
47
  n === a ? t = void 0 : n !== 0 && (t = t.subarray(n), o -= n);
48
48
  };
49
49
  }
50
- function Z(e, t, o) {
50
+ function p(e, t, o) {
51
51
  let i = z();
52
52
  const s = new TextDecoder();
53
53
  return function(u, a) {
@@ -94,42 +94,42 @@ var te = function(e, t) {
94
94
  t.indexOf(i[s]) < 0 && Object.prototype.propertyIsEnumerable.call(e, i[s]) && (o[i[s]] = e[i[s]]);
95
95
  return o;
96
96
  };
97
- const O = "text/event-stream", ne = 1e3, H = "last-event-id";
97
+ const U = "text/event-stream", ne = 1e3, H = "last-event-id";
98
98
  function re(e, t) {
99
99
  var { signal: o, headers: i, onopen: s, onmessage: m, onclose: u, onerror: a, openWhenHidden: n, fetch: d } = t, l = te(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
100
100
  return new Promise((c, r) => {
101
101
  const f = Object.assign({}, i);
102
- f.accept || (f.accept = O);
102
+ f.accept || (f.accept = U);
103
103
  let h;
104
- function C() {
104
+ function b() {
105
105
  h.abort(), document.hidden || A();
106
106
  }
107
- n || document.addEventListener("visibilitychange", C);
108
- let b = ne, y = 0;
109
- function w() {
110
- document.removeEventListener("visibilitychange", C), window.clearTimeout(y), h.abort();
107
+ n || document.addEventListener("visibilitychange", b);
108
+ let w = ne, y = 0;
109
+ function k() {
110
+ document.removeEventListener("visibilitychange", b), window.clearTimeout(y), h.abort();
111
111
  }
112
112
  o == null || o.addEventListener("abort", () => {
113
- w(), c();
113
+ k(), c();
114
114
  });
115
- const T = d ?? window.fetch, E = s ?? oe;
115
+ const v = d ?? window.fetch, E = s ?? oe;
116
116
  async function A() {
117
- var x;
117
+ var P;
118
118
  h = new AbortController();
119
119
  try {
120
- const N = await T(e, Object.assign(Object.assign({}, l), { headers: f, signal: h.signal }));
121
- await E(N), await J(N.body, Q(Z((I) => {
122
- I ? f[H] = I : delete f[H];
123
- }, (I) => {
124
- b = I;
125
- }, m))), u == null || u(), w(), c();
120
+ const N = await v(e, Object.assign(Object.assign({}, l), { headers: f, signal: h.signal }));
121
+ await E(N), await Q(N.body, Z(p((S) => {
122
+ S ? f[H] = S : delete f[H];
123
+ }, (S) => {
124
+ w = S;
125
+ }, m))), u == null || u(), k(), c();
126
126
  } catch (N) {
127
127
  if (!h.signal.aborted)
128
128
  try {
129
- const I = (x = a == null ? void 0 : a(N)) !== null && x !== void 0 ? x : b;
130
- window.clearTimeout(y), y = window.setTimeout(A, I);
131
- } catch (I) {
132
- w(), r(I);
129
+ const S = (P = a == null ? void 0 : a(N)) !== null && P !== void 0 ? P : w;
130
+ window.clearTimeout(y), y = window.setTimeout(A, S);
131
+ } catch (S) {
132
+ k(), r(S);
133
133
  }
134
134
  }
135
135
  }
@@ -138,12 +138,12 @@ function re(e, t) {
138
138
  }
139
139
  function oe(e) {
140
140
  const t = e.headers.get("content-type");
141
- if (!(t != null && t.startsWith(O)))
142
- throw new Error(`Expected content-type to be ${O}, Actual: ${t}`);
141
+ if (!(t != null && t.startsWith(U)))
142
+ throw new Error(`Expected content-type to be ${U}, Actual: ${t}`);
143
143
  }
144
144
  function ae(e) {
145
- const [t, o] = k(null);
146
- return P(() => {
145
+ const [t, o] = T(null);
146
+ return x(() => {
147
147
  if (!t)
148
148
  return;
149
149
  const i = new AbortController();
@@ -190,65 +190,34 @@ const se = (e) => {
190
190
  if (!(typeof e == "object" && e !== null && "type" in e && "streamId" in e && "timestamp" in e))
191
191
  return null;
192
192
  switch (e.type) {
193
- case "NewChatCompletionStreamChunk":
194
- return le(e);
195
- case "ChatCompletionStreamCompleted":
196
- return de(e);
197
193
  case "StreamTimeout":
198
- return ue(e);
194
+ return le(e);
199
195
  case "StreamNotFound":
200
- return me(e);
201
- case "FileUploadCompleted":
202
- return ge(e);
203
- case "FileTextContentReady":
204
- return fe(e);
196
+ return de(e);
205
197
  case "AgentTaskProgressItemUpdated":
206
- return ye(e);
198
+ return ue(e);
207
199
  }
208
200
  return null;
209
201
  }, le = (e) => ({
210
- type: "NewChatCompletionStreamChunk",
211
- streamId: e.streamId,
212
- chatCompletionId: e.chatCompletionId,
213
- timestamp: e.timestamp,
214
- content: e.content
215
- }), de = (e) => ({
216
- type: "ChatCompletionStreamCompleted",
217
- streamId: e.streamId,
218
- chatCompletionId: e.chatCompletionId,
219
- timestamp: e.timestamp
220
- }), ue = (e) => ({
221
202
  type: "StreamTimeout",
222
203
  streamId: e.streamId,
223
204
  timestamp: e.timestamp
224
- }), me = (e) => ({
205
+ }), de = (e) => ({
225
206
  type: "StreamNotFound",
226
207
  streamId: e.streamId,
227
208
  timestamp: e.timestamp
228
- }), ge = (e) => ({
229
- type: "FileUploadCompleted",
230
- streamId: e.streamId,
231
- uploadId: e.fileId,
232
- fileId: e.fileId,
233
- timestamp: e.timestamp
234
- }), fe = (e) => ({
235
- type: "FileTextContentReady",
236
- streamId: e.streamId,
237
- fileId: e.fileId,
238
- textContent: e.textContent,
239
- timestamp: e.timestamp
240
- }), ye = (e) => ({
209
+ }), ue = (e) => ({
241
210
  type: "AgentTaskProgressItemUpdated",
242
211
  streamId: e.streamId,
243
212
  agentTaskId: e.agentTaskId,
244
213
  progressItemId: e.progressItemId,
245
214
  title: e.title,
246
- startedAt: e.startedAt,
247
- completedAt: e.completedAt || void 0,
215
+ timestamp: e.timestamp,
216
+ createdAt: e.createdAt,
248
217
  response: e.response,
249
218
  progressItemType: e.progressItemType
250
- }), he = (e) => {
251
- const t = U(), [o, i] = k(null), [s, m] = k(null), [u, a] = k(null), n = B(() => {
219
+ }), me = (e) => {
220
+ const t = R(), [o, i] = T(null), [s, m] = T(null), [u, a] = T(null), n = B(() => {
252
221
  if (s)
253
222
  return {
254
223
  "X-Fency-Publishable-Key": t.fency.publishableKey,
@@ -267,7 +236,7 @@ const se = (e) => {
267
236
  });
268
237
  },
269
238
  onMessage: (c) => {
270
- var f, h, C, b, y, w, T, E, A, x;
239
+ var f, h, b, w, y, k, v, E, A, P;
271
240
  const r = se(c.data);
272
241
  if (!r)
273
242
  return !1;
@@ -277,25 +246,25 @@ const se = (e) => {
277
246
  case "ChatCompletionStreamCompleted":
278
247
  return (h = e == null ? void 0 : e.onChatCompletionStreamCompleted) == null || h.call(e, r), !0;
279
248
  case "StreamTimeout":
280
- return (C = e == null ? void 0 : e.onStreamTimeout) == null || C.call(e, r), !0;
249
+ return (b = e == null ? void 0 : e.onStreamTimeout) == null || b.call(e, r), !0;
281
250
  case "StreamNotFound":
282
- return (b = e == null ? void 0 : e.onStreamNotFound) == null || b.call(e, r), !0;
251
+ return (w = e == null ? void 0 : e.onStreamNotFound) == null || w.call(e, r), !0;
283
252
  case "FileUploadCompleted":
284
253
  return (y = e == null ? void 0 : e.onFileUploadCompleted) == null || y.call(e, r), !0;
285
254
  case "FileTextContentReady":
286
- return (w = e == null ? void 0 : e.onFileTextContentReady) == null || w.call(e, r), !0;
255
+ return (k = e == null ? void 0 : e.onFileTextContentReady) == null || k.call(e, r), !0;
287
256
  case "WebsiteHtmlContentReady":
288
- return (T = e == null ? void 0 : e.onWebsiteHtmlContentReady) == null || T.call(e, r), !0;
257
+ return (v = e == null ? void 0 : e.onWebsiteHtmlContentReady) == null || v.call(e, r), !0;
289
258
  case "WebsiteTextContentReady":
290
259
  return (E = e == null ? void 0 : e.onWebsiteTextContentReady) == null || E.call(e, r), !0;
291
260
  case "FileSearchIndexReady":
292
261
  return (A = e == null ? void 0 : e.onFileSearchIndexReady) == null || A.call(e, r), !0;
293
262
  case "AgentTaskProgressItemUpdated":
294
- return (x = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || x.call(e, r), !0;
263
+ return (P = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || P.call(e, r), !0;
295
264
  }
296
265
  }
297
266
  });
298
- return P(() => {
267
+ return x(() => {
299
268
  u && s && o && (d.setSourceUrl(u), a(null));
300
269
  }, [u, s, o]), {
301
270
  createStream: async () => {
@@ -319,8 +288,8 @@ const se = (e) => {
319
288
  },
320
289
  stream: o
321
290
  };
322
- }, Ee = (e) => {
323
- const t = U(), [o, i] = k([]), { createStream: s } = he({
291
+ }, Ce = (e) => {
292
+ const t = R(), [o, i] = T([]), { createStream: s } = me({
324
293
  fetchTokens: e.fetchCreateStreamTokens,
325
294
  onAgentTaskProgressItemUpdated: (a) => {
326
295
  var n;
@@ -391,7 +360,7 @@ const se = (e) => {
391
360
  doneStreaming: !1
392
361
  }
393
362
  ]);
394
- const { clientToken: d } = await e.fetchClientToken(), l = await K({
363
+ const { clientToken: d } = await e.fetchClientToken(), l = await q({
395
364
  pk: t.fency.publishableKey,
396
365
  baseUrl: t.fency.baseUrl,
397
366
  clientToken: d,
@@ -481,22 +450,22 @@ const se = (e) => {
481
450
  latest: u
482
451
  };
483
452
  };
484
- function Ne(e, t) {
485
- const [o, i] = k(
453
+ function Ae(e, t) {
454
+ const [o, i] = T(
486
455
  null
487
- ), [s, m] = k(
456
+ ), [s, m] = T(
488
457
  null
489
- ), u = U(), a = async (c) => {
490
- const r = await c.fetchTokens(), { fetchTokens: f, nextPageToken: h, previousPageToken: C, ...b } = c, y = await e({
458
+ ), u = R(), a = async (c) => {
459
+ const r = await c.fetchTokens(), { fetchTokens: f, nextPageToken: h, previousPageToken: b, ...w } = c, y = await e({
491
460
  pk: u.fency.publishableKey,
492
461
  clientToken: r.clientToken,
493
462
  streamToken: r.streamToken,
494
463
  request: {
495
- ...b,
464
+ ...w,
496
465
  limit: (t == null ? void 0 : t.pageSize) ?? 50,
497
466
  pagination: {
498
467
  nextPageToken: h,
499
- previousPageToken: C
468
+ previousPageToken: b
500
469
  }
501
470
  },
502
471
  baseUrl: u.fency.baseUrl
@@ -584,7 +553,7 @@ function Ne(e, t) {
584
553
  currentPage: s
585
554
  };
586
555
  }
587
- const $ = {
556
+ const K = {
588
557
  'code[class*="language-"]': {
589
558
  color: "#f8f8f2",
590
559
  background: "none",
@@ -735,16 +704,16 @@ const $ = {
735
704
  italic: {
736
705
  fontStyle: "italic"
737
706
  }
738
- }, Ce = ({
707
+ }, ge = ({
739
708
  markdown: e,
740
709
  streamToken: t,
741
710
  fetchClientToken: o,
742
711
  durationSeconds: i
743
712
  }) => {
744
- const { fency: s } = U(), m = D(
713
+ const { fency: s } = R(), m = D(
745
714
  async (u) => {
746
715
  try {
747
- const { clientToken: a } = await o(), n = await q({
716
+ const { clientToken: a } = await o(), n = await G({
748
717
  pk: s.publishableKey,
749
718
  baseUrl: s.baseUrl,
750
719
  clientToken: a,
@@ -760,7 +729,7 @@ const $ = {
760
729
  },
761
730
  [s, t, o]
762
731
  );
763
- return /* @__PURE__ */ S(
732
+ return /* @__PURE__ */ I(
764
733
  "div",
765
734
  {
766
735
  style: {
@@ -768,7 +737,7 @@ const $ = {
768
737
  },
769
738
  children: [
770
739
  /* @__PURE__ */ g(
771
- v.div,
740
+ C.div,
772
741
  {
773
742
  className: "fency-markdown-body-raw",
774
743
  initial: { opacity: 0, y: -10 },
@@ -777,7 +746,7 @@ const $ = {
777
746
  children: /* @__PURE__ */ g(
778
747
  W,
779
748
  {
780
- remarkPlugins: [p],
749
+ remarkPlugins: [L],
781
750
  components: {
782
751
  code(u) {
783
752
  const { children: a, className: n, node: d, ref: l, ...c } = u, r = /language-(\w+)/.exec(n || "");
@@ -791,7 +760,7 @@ const $ = {
791
760
  ""
792
761
  ),
793
762
  language: r[1],
794
- style: $
763
+ style: K
795
764
  }
796
765
  ) : /* @__PURE__ */ g("code", { ...c, className: n, children: String(a) });
797
766
  },
@@ -821,7 +790,7 @@ const $ = {
821
790
  )
822
791
  }
823
792
  ),
824
- i !== void 0 && /* @__PURE__ */ S(
793
+ i !== void 0 && /* @__PURE__ */ I(
825
794
  "div",
826
795
  {
827
796
  style: {
@@ -856,9 +825,9 @@ function M({
856
825
  shimmerColor: c = "#000",
857
826
  direction: r = "fromBottom"
858
827
  }) {
859
- const f = R(null), h = Y(f, { once: a, margin: n }), C = B(() => e.length * d, [e, d]), b = !u || h, y = r === "fromBottom" ? "100% center" : "-100% center", w = r === "fromBottom" ? "0% center" : "200% center";
828
+ const f = F(null), h = J(f, { once: a, margin: n }), b = B(() => e.length * d, [e, d]), w = !u || h, y = r === "fromBottom" ? "100% center" : "-100% center", k = r === "fromBottom" ? "0% center" : "200% center";
860
829
  return /* @__PURE__ */ g(
861
- v.span,
830
+ C.span,
862
831
  {
863
832
  ref: f,
864
833
  className: m,
@@ -871,7 +840,7 @@ function M({
871
840
  color: "transparent",
872
841
  WebkitTextFillColor: "transparent",
873
842
  backgroundRepeat: "no-repeat, padding-box",
874
- "--spread": `${C}px`,
843
+ "--spread": `${b}px`,
875
844
  "--base-color": l,
876
845
  "--shimmer-color": c,
877
846
  "--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
@@ -881,8 +850,8 @@ function M({
881
850
  backgroundPosition: y,
882
851
  opacity: 0
883
852
  },
884
- animate: b ? {
885
- backgroundPosition: w,
853
+ animate: w ? {
854
+ backgroundPosition: k,
886
855
  opacity: 1
887
856
  } : {},
888
857
  transition: {
@@ -902,12 +871,12 @@ function M({
902
871
  }
903
872
  );
904
873
  }
905
- const be = ({
874
+ const fe = ({
906
875
  title: e,
907
876
  completed: t,
908
877
  isLatest: o = !1,
909
878
  durationSeconds: i
910
- }) => /* @__PURE__ */ S(
879
+ }) => /* @__PURE__ */ I(
911
880
  "div",
912
881
  {
913
882
  style: {
@@ -915,7 +884,7 @@ const be = ({
915
884
  },
916
885
  children: [
917
886
  /* @__PURE__ */ g(
918
- v.div,
887
+ C.div,
919
888
  {
920
889
  style: {
921
890
  display: "flex",
@@ -938,7 +907,7 @@ const be = ({
938
907
  ) : /* @__PURE__ */ g("span", { style: { color: "#666" }, children: e })
939
908
  }
940
909
  ),
941
- i !== void 0 && /* @__PURE__ */ S(
910
+ i !== void 0 && /* @__PURE__ */ I(
942
911
  "div",
943
912
  {
944
913
  style: {
@@ -961,17 +930,17 @@ const be = ({
961
930
  ` })
962
931
  ]
963
932
  }
964
- ), we = ({
933
+ ), ye = ({
965
934
  title: e,
966
935
  markdown: t,
967
936
  completed: o,
968
937
  isLatest: i = !1,
969
938
  durationSeconds: s
970
939
  }) => {
971
- const m = R(null);
972
- return P(() => {
940
+ const m = F(null);
941
+ return x(() => {
973
942
  m.current && !o && (m.current.scrollTop = m.current.scrollHeight);
974
- }, [t, o]), /* @__PURE__ */ S(
943
+ }, [t, o]), /* @__PURE__ */ I(
975
944
  "div",
976
945
  {
977
946
  style: {
@@ -979,7 +948,7 @@ const be = ({
979
948
  },
980
949
  children: [
981
950
  /* @__PURE__ */ g(
982
- v.h3,
951
+ C.h3,
983
952
  {
984
953
  style: { marginBottom: "10px", color: "#666" },
985
954
  initial: { opacity: 0, y: -10 },
@@ -998,7 +967,7 @@ const be = ({
998
967
  }
999
968
  ),
1000
969
  /* @__PURE__ */ g(
1001
- v.div,
970
+ C.div,
1002
971
  {
1003
972
  ref: m,
1004
973
  style: {
@@ -1016,7 +985,7 @@ const be = ({
1016
985
  children: /* @__PURE__ */ g("div", { className: "fency-markdown-body-raw", children: /* @__PURE__ */ g(
1017
986
  W,
1018
987
  {
1019
- remarkPlugins: [p],
988
+ remarkPlugins: [L],
1020
989
  components: {
1021
990
  code(u) {
1022
991
  const {
@@ -1038,7 +1007,7 @@ const be = ({
1038
1007
  ""
1039
1008
  ),
1040
1009
  language: r[1],
1041
- style: $
1010
+ style: K
1042
1011
  }
1043
1012
  ) : /* @__PURE__ */ g("code", { ...c, className: n, children: String(a) });
1044
1013
  }
@@ -1048,7 +1017,7 @@ const be = ({
1048
1017
  ) })
1049
1018
  }
1050
1019
  ),
1051
- s !== void 0 && /* @__PURE__ */ S(
1020
+ s !== void 0 && /* @__PURE__ */ I(
1052
1021
  "div",
1053
1022
  {
1054
1023
  style: {
@@ -1067,11 +1036,11 @@ const be = ({
1067
1036
  ]
1068
1037
  }
1069
1038
  );
1070
- }, ke = ({ message: e, isLatest: t = !1, streamToken: o, fetchClientToken: i }) => {
1039
+ }, he = ({ message: e, isLatest: t = !1, streamToken: o, fetchClientToken: i }) => {
1071
1040
  const s = e.state || "complete";
1072
- if (s === F.EXECUTION)
1041
+ if (s === O.EXECUTION)
1073
1042
  return /* @__PURE__ */ g(
1074
- be,
1043
+ fe,
1075
1044
  {
1076
1045
  title: e.title,
1077
1046
  completed: e.completed,
@@ -1079,9 +1048,9 @@ const be = ({
1079
1048
  durationSeconds: e.durationSeconds
1080
1049
  }
1081
1050
  );
1082
- if (s === F.REASONING)
1051
+ if (s === O.REASONING)
1083
1052
  return /* @__PURE__ */ g(
1084
- we,
1053
+ ye,
1085
1054
  {
1086
1055
  title: e.title,
1087
1056
  markdown: e.markdown,
@@ -1090,9 +1059,9 @@ const be = ({
1090
1059
  durationSeconds: e.durationSeconds
1091
1060
  }
1092
1061
  );
1093
- if (s === F.FINAL_RESPONSE)
1062
+ if (s === O.FINAL_RESPONSE)
1094
1063
  return /* @__PURE__ */ g(
1095
- Ce,
1064
+ ge,
1096
1065
  {
1097
1066
  markdown: e.markdown,
1098
1067
  streamToken: o,
@@ -1101,50 +1070,49 @@ const be = ({
1101
1070
  }
1102
1071
  );
1103
1072
  throw new Error(`Unknown state: ${s}`);
1104
- }, Fe = ({
1073
+ }, Pe = ({
1105
1074
  agentTask: e,
1106
1075
  mode: t = "verbose",
1107
1076
  placeholderMessage: o = "Processing your request",
1108
1077
  streamToken: i,
1109
1078
  fetchClientToken: s
1110
1079
  }) => {
1111
- const [m, u] = k([]), a = R(null);
1112
- if (P(() => {
1080
+ const [m, u] = T([]), a = F(null);
1081
+ if (x(() => {
1113
1082
  const n = e.progressItems.map((r, f) => {
1114
1083
  let h;
1115
- const C = e.progressItems[f + 1];
1116
- if (C != null && C.startedAt) {
1117
- const y = new Date(r.startedAt).getTime(), w = new Date(C.startedAt).getTime();
1118
- h = Math.round((w - y) / 1e3);
1084
+ const b = e.progressItems[f + 1];
1085
+ if (b != null && b.createdAt) {
1086
+ const y = new Date(r.createdAt).getTime(), k = new Date(b.createdAt).getTime();
1087
+ h = Math.round((k - y) / 1e3);
1119
1088
  }
1120
- const b = C != null;
1089
+ const w = b != null;
1121
1090
  return {
1122
1091
  id: r.progressItemId,
1123
1092
  title: r.title,
1124
1093
  markdown: r.response || "",
1125
1094
  state: r.progressItemType,
1126
- completed: b,
1127
- startedAt: r.startedAt,
1128
- completedAt: r.completedAt,
1095
+ completed: w,
1096
+ startedAt: r.createdAt,
1129
1097
  durationSeconds: h
1130
1098
  };
1131
1099
  });
1132
1100
  let d;
1133
1101
  const l = e.progressItems[0];
1134
- if (l != null && l.startedAt) {
1135
- const r = new Date(e.triggeredAt).getTime(), f = new Date(l.startedAt).getTime();
1102
+ if (l != null && l.createdAt) {
1103
+ const r = new Date(e.triggeredAt).getTime(), f = new Date(l.createdAt).getTime();
1136
1104
  d = Math.round((f - r) / 1e3);
1137
1105
  }
1138
1106
  const c = {
1139
1107
  id: "placeholder",
1140
1108
  title: o,
1141
1109
  markdown: "",
1142
- state: F.EXECUTION,
1110
+ state: O.EXECUTION,
1143
1111
  completed: l != null,
1144
1112
  durationSeconds: d
1145
1113
  };
1146
1114
  u([c, ...n]);
1147
- }, [e, o]), P(() => {
1115
+ }, [e, o]), x(() => {
1148
1116
  t === "verbose" && a.current && (a.current.scrollTop = a.current.scrollHeight);
1149
1117
  }, [m, t]), t === "simple") {
1150
1118
  const n = m[m.length - 1];
@@ -1152,7 +1120,7 @@ const be = ({
1152
1120
  return null;
1153
1121
  const d = n.completed;
1154
1122
  return /* @__PURE__ */ g("div", { className: "simple-mode-container", children: /* @__PURE__ */ g(_, { mode: "wait", children: /* @__PURE__ */ g(
1155
- v.div,
1123
+ C.div,
1156
1124
  {
1157
1125
  initial: { opacity: 0, y: 10 },
1158
1126
  animate: { opacity: 1, y: 0 },
@@ -1193,7 +1161,7 @@ const be = ({
1193
1161
  // Important for flex scroll
1194
1162
  },
1195
1163
  children: /* @__PURE__ */ g(_, { children: m.length > 0 && m.map((n, d) => /* @__PURE__ */ g(
1196
- v.div,
1164
+ C.div,
1197
1165
  {
1198
1166
  initial: { opacity: 0, y: -20 },
1199
1167
  animate: { opacity: 1, y: 0 },
@@ -1204,7 +1172,7 @@ const be = ({
1204
1172
  ease: "easeOut"
1205
1173
  },
1206
1174
  children: /* @__PURE__ */ g(
1207
- ke,
1175
+ he,
1208
1176
  {
1209
1177
  message: n,
1210
1178
  isLatest: d === m.length - 1,
@@ -1218,11 +1186,11 @@ const be = ({
1218
1186
  }
1219
1187
  );
1220
1188
  };
1221
- function Re({ fency: e, children: t }) {
1222
- const [o, i] = k(
1189
+ function xe({ fency: e, children: t }) {
1190
+ const [o, i] = T(
1223
1191
  null
1224
- ), [s, m] = k(!0), [u, a] = k(null), [n, d] = k(null), l = R(null);
1225
- P(() => {
1192
+ ), [s, m] = T(!0), [u, a] = T(null), [n, d] = T(null), l = F(null);
1193
+ x(() => {
1226
1194
  e.then((f) => {
1227
1195
  i(f), m(!1);
1228
1196
  }).catch((f) => {
@@ -1233,32 +1201,32 @@ function Re({ fency: e, children: t }) {
1233
1201
  async (f, h = 3e4) => {
1234
1202
  if (l.current)
1235
1203
  return l.current;
1236
- const C = Date.now();
1237
- if (n && C - n.createdAt < h)
1204
+ const b = Date.now();
1205
+ if (n && b - n.createdAt < h)
1238
1206
  return n.stream;
1239
- const b = (async () => {
1207
+ const w = (async () => {
1240
1208
  if (!o)
1241
1209
  throw new Error("Fency instance not initialized");
1242
- const y = await f(), w = await G({
1210
+ const y = await f(), k = await V({
1243
1211
  pk: o.publishableKey,
1244
1212
  baseUrl: o.baseUrl,
1245
1213
  clientToken: (y == null ? void 0 : y.clientToken) ?? ""
1246
1214
  });
1247
- if (w.type === "success") {
1248
- const T = {
1249
- stream: w.stream,
1215
+ if (k.type === "success") {
1216
+ const v = {
1217
+ stream: k.stream,
1250
1218
  createdAt: Date.now()
1251
1219
  };
1252
- return d(T), l.current = null, w.stream;
1220
+ return d(v), l.current = null, k.stream;
1253
1221
  } else
1254
1222
  throw l.current = null, new Error("Failed to create stream");
1255
1223
  })();
1256
- return l.current = b, b;
1224
+ return l.current = w, w;
1257
1225
  },
1258
1226
  [o, n]
1259
1227
  );
1260
1228
  if (u)
1261
- return /* @__PURE__ */ S("div", { children: [
1229
+ return /* @__PURE__ */ I("div", { children: [
1262
1230
  "Fency error: ",
1263
1231
  u.message
1264
1232
  ] });
@@ -1271,19 +1239,19 @@ function Re({ fency: e, children: t }) {
1271
1239
  activeStream: n,
1272
1240
  getOrCreateStream: c
1273
1241
  };
1274
- return /* @__PURE__ */ g(L.Provider, { value: r, children: t });
1242
+ return /* @__PURE__ */ g($.Provider, { value: r, children: t });
1275
1243
  }
1276
1244
  export {
1277
- Fe as AgentTaskProgress,
1278
- ke as ChatResponse,
1279
- Ce as ChatResponseComplete,
1280
- be as ChatResponseLoading,
1281
- we as ChatResponseThinking,
1282
- Re as FencyProvider,
1245
+ Pe as AgentTaskProgress,
1246
+ he as ChatResponse,
1247
+ ge as ChatResponseComplete,
1248
+ fe as ChatResponseLoading,
1249
+ ye as ChatResponseThinking,
1250
+ xe as FencyProvider,
1283
1251
  M as ShimmeringText,
1284
- Ee as useAgentTasks,
1285
- U as useFencyContext,
1252
+ Ce as useAgentTasks,
1253
+ R as useFencyContext,
1286
1254
  ae as useFencyEventSource,
1287
- Ne as usePaginatedQuery,
1288
- he as useStream
1255
+ Ae as usePaginatedQuery,
1256
+ me as useStream
1289
1257
  };
@@ -62,8 +62,8 @@ export type AgentTaskProgressItemUpdated = {
62
62
  agentTaskId: string;
63
63
  progressItemId: string;
64
64
  title: string;
65
- startedAt: string;
66
- completedAt?: string;
65
+ timestamp: string;
66
+ createdAt: string;
67
67
  response: string;
68
68
  progressItemType: AgentTaskProgressItemType;
69
69
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fencyai/react",
3
- "version": "0.1.108",
3
+ "version": "0.1.110",
4
4
  "description": "> TODO: description",
5
5
  "author": "staklau <steinaageklaussen@gmail.com>",
6
6
  "homepage": "",
@@ -35,7 +35,7 @@
35
35
  "@microsoft/fetch-event-source": "^2.0.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@fencyai/js": "^0.1.108",
38
+ "@fencyai/js": "^0.1.110",
39
39
  "@types/jest": "^29.5.11",
40
40
  "@types/node": "^20.10.5",
41
41
  "@types/react": "^18.2.45",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@emotion/is-prop-valid": "^1.3.0",
53
- "@fencyai/js": "^0.1.108",
53
+ "@fencyai/js": "^0.1.110",
54
54
  "@radix-ui/react-popover": "^1.1.15",
55
55
  "motion": "^11.15.0",
56
56
  "react": ">=16.8.0",
@@ -65,5 +65,5 @@
65
65
  "optional": false
66
66
  }
67
67
  },
68
- "gitHead": "b6e2b8dfa4bb130b0f57dc2d4decbb08c5f91850"
68
+ "gitHead": "9836dad9a8577fb445a3a378490071c0522fbca7"
69
69
  }