@fencyai/react 0.1.124 → 0.1.125

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.
Files changed (33) hide show
  1. package/dist/agent-task/data-types/MemoryChatCompletionExploreMemory.d.ts +14 -0
  2. package/dist/agent-task/data-types/MemoryChatCompletionExploreMemory.d.ts.map +1 -0
  3. package/dist/agent-task/data-types/MemoryChatCompletionFindSources.d.ts +12 -0
  4. package/dist/agent-task/data-types/MemoryChatCompletionFindSources.d.ts.map +1 -0
  5. package/dist/agent-task/data-types/MemoryChatCompletionSearch.d.ts +12 -0
  6. package/dist/agent-task/data-types/MemoryChatCompletionSearch.d.ts.map +1 -0
  7. package/dist/agent-task/data-types/MemoryChatCompletionSourcesResult.d.ts +11 -0
  8. package/dist/agent-task/data-types/MemoryChatCompletionSourcesResult.d.ts.map +1 -0
  9. package/dist/hooks/useStream/index.d.ts.map +1 -1
  10. package/dist/index.js +456 -477
  11. package/dist/types/CreateAgentTaskParams.d.ts +3 -3
  12. package/dist/types/CreateAgentTaskParams.d.ts.map +1 -1
  13. package/dist/types/CreateAgentTaskResponse.d.ts +1 -1
  14. package/dist/types/CreateAgentTaskResponse.d.ts.map +1 -1
  15. package/dist/types/StreamData.d.ts +1 -48
  16. package/dist/types/StreamData.d.ts.map +1 -1
  17. package/dist/types/UseAgentTasksProps.d.ts +1 -1
  18. package/dist/types/UseAgentTasksProps.d.ts.map +1 -1
  19. package/dist/types/UseStreamProps.d.ts +2 -9
  20. package/dist/types/UseStreamProps.d.ts.map +1 -1
  21. package/dist/types/index.d.ts +0 -1
  22. package/dist/types/index.d.ts.map +1 -1
  23. package/package.json +4 -4
  24. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionExploreMemory.d.ts +0 -14
  25. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionExploreMemory.d.ts.map +0 -1
  26. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionFindSources.d.ts +0 -12
  27. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionFindSources.d.ts.map +0 -1
  28. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionSearch.d.ts +0 -12
  29. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionSearch.d.ts.map +0 -1
  30. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionSourcesResult.d.ts +0 -11
  31. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionSourcesResult.d.ts.map +0 -1
  32. package/dist/types/AgentTaskData.d.ts +0 -6
  33. package/dist/types/AgentTaskData.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsxs as k, 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
- import { createContext as G, useState as w, useRef as A, useEffect as E, useCallback as W, useContext as X, useMemo as U } from "react";
4
- import { useInView as Q, motion as v, AnimatePresence as L } from "motion/react";
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";
5
5
  import Y from "react-markdown";
6
6
  import { Prism as $ } from "react-syntax-highlighter";
7
7
  import Z from "remark-gfm";
@@ -9,70 +9,70 @@ import './assets/index.css';const N = G(
9
9
  void 0
10
10
  );
11
11
  async function ee(e, t) {
12
- const r = e.getReader();
13
- let n;
14
- for (; !(n = await r.read()).done; )
15
- t(n.value);
12
+ const n = e.getReader();
13
+ let r;
14
+ for (; !(r = await n.read()).done; )
15
+ t(r.value);
16
16
  }
17
17
  function te(e) {
18
- let t, r, n, l = !1;
19
- return function(s) {
20
- t === void 0 ? (t = s, r = 0, n = -1) : t = re(t, s);
21
- const c = t.length;
18
+ let t, n, r, c = !1;
19
+ return function(i) {
20
+ t === void 0 ? (t = i, n = 0, r = -1) : t = ne(t, i);
21
+ const l = t.length;
22
22
  let d = 0;
23
- for (; r < c; ) {
24
- l && (t[r] === 10 && (d = ++r), l = !1);
25
- let a = -1;
26
- for (; r < c && a === -1; ++r)
27
- switch (t[r]) {
23
+ for (; n < l; ) {
24
+ c && (t[n] === 10 && (d = ++n), c = !1);
25
+ let o = -1;
26
+ for (; n < l && o === -1; ++n)
27
+ switch (t[n]) {
28
28
  case 58:
29
- n === -1 && (n = r - d);
29
+ r === -1 && (r = n - d);
30
30
  break;
31
31
  case 13:
32
- l = !0;
32
+ c = !0;
33
33
  case 10:
34
- a = r;
34
+ o = n;
35
35
  break;
36
36
  }
37
- if (a === -1)
37
+ if (o === -1)
38
38
  break;
39
- e(t.subarray(d, a), n), d = r, n = -1;
39
+ e(t.subarray(d, o), r), d = n, r = -1;
40
40
  }
41
- d === c ? t = void 0 : d !== 0 && (t = t.subarray(d), r -= d);
41
+ d === l ? t = void 0 : d !== 0 && (t = t.subarray(d), n -= d);
42
42
  };
43
43
  }
44
- function ne(e, t, r) {
45
- let n = P();
46
- const l = new TextDecoder();
47
- return function(s, c) {
48
- if (s.length === 0)
49
- r == null || r(n), n = P();
50
- else if (c > 0) {
51
- const d = l.decode(s.subarray(0, c)), a = c + (s[c + 1] === 32 ? 2 : 1), o = l.decode(s.subarray(a));
44
+ function re(e, t, n) {
45
+ let r = F();
46
+ const c = new TextDecoder();
47
+ return function(i, l) {
48
+ if (i.length === 0)
49
+ n == null || n(r), r = F();
50
+ else if (l > 0) {
51
+ const d = c.decode(i.subarray(0, l)), o = l + (i[l + 1] === 32 ? 2 : 1), a = c.decode(i.subarray(o));
52
52
  switch (d) {
53
53
  case "data":
54
- n.data = n.data ? n.data + `
55
- ` + o : o;
54
+ r.data = r.data ? r.data + `
55
+ ` + a : a;
56
56
  break;
57
57
  case "event":
58
- n.event = o;
58
+ r.event = a;
59
59
  break;
60
60
  case "id":
61
- e(n.id = o);
61
+ e(r.id = a);
62
62
  break;
63
63
  case "retry":
64
- const y = parseInt(o, 10);
65
- isNaN(y) || t(n.retry = y);
64
+ const g = parseInt(a, 10);
65
+ isNaN(g) || t(r.retry = g);
66
66
  break;
67
67
  }
68
68
  }
69
69
  };
70
70
  }
71
- function re(e, t) {
72
- const r = new Uint8Array(e.length + t.length);
73
- return r.set(e), r.set(t, e.length), r;
71
+ function ne(e, t) {
72
+ const n = new Uint8Array(e.length + t.length);
73
+ return n.set(e), n.set(t, e.length), n;
74
74
  }
75
- function P() {
75
+ function F() {
76
76
  return {
77
77
  data: "",
78
78
  event: "",
@@ -80,68 +80,68 @@ function P() {
80
80
  retry: void 0
81
81
  };
82
82
  }
83
- var ae = function(e, t) {
84
- var r = {};
85
- for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
83
+ var oe = function(e, t) {
84
+ var n = {};
85
+ for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
86
86
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
87
- for (var l = 0, n = Object.getOwnPropertySymbols(e); l < n.length; l++)
88
- t.indexOf(n[l]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[l]) && (r[n[l]] = e[n[l]]);
89
- return r;
87
+ for (var c = 0, r = Object.getOwnPropertySymbols(e); c < r.length; c++)
88
+ t.indexOf(r[c]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[c]) && (n[r[c]] = e[r[c]]);
89
+ return n;
90
90
  };
91
- const R = "text/event-stream", oe = 1e3, O = "last-event-id";
92
- function ie(e, t) {
93
- var { signal: r, headers: n, onopen: l, onmessage: u, onclose: s, onerror: c, openWhenHidden: d, fetch: a } = t, o = ae(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
94
- return new Promise((y, g) => {
95
- const h = Object.assign({}, n);
96
- h.accept || (h.accept = R);
97
- let m;
98
- function S() {
99
- m.abort(), document.hidden || I();
91
+ const O = "text/event-stream", ae = 1e3, R = "last-event-id";
92
+ function se(e, t) {
93
+ var { signal: n, headers: r, onopen: c, onmessage: u, onclose: i, onerror: l, openWhenHidden: d, fetch: o } = t, a = oe(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
94
+ return new Promise((g, m) => {
95
+ const f = Object.assign({}, r);
96
+ f.accept || (f.accept = O);
97
+ let y;
98
+ function p() {
99
+ y.abort(), document.hidden || x();
100
100
  }
101
- d || document.addEventListener("visibilitychange", S);
102
- let f = oe, b = 0;
103
- function C() {
104
- document.removeEventListener("visibilitychange", S), window.clearTimeout(b), m.abort();
101
+ d || document.addEventListener("visibilitychange", p);
102
+ let h = ae, S = 0;
103
+ function b() {
104
+ document.removeEventListener("visibilitychange", p), window.clearTimeout(S), y.abort();
105
105
  }
106
- r == null || r.addEventListener("abort", () => {
107
- C(), y();
106
+ n == null || n.addEventListener("abort", () => {
107
+ b(), g();
108
108
  });
109
- const p = a ?? window.fetch, x = l ?? se;
110
- async function I() {
111
- var D;
112
- m = new AbortController();
109
+ const P = o ?? window.fetch, A = c ?? ie;
110
+ async function x() {
111
+ var M;
112
+ y = new AbortController();
113
113
  try {
114
- const M = await p(e, Object.assign(Object.assign({}, o), { headers: h, signal: m.signal }));
115
- await x(M), await ee(M.body, te(ne((T) => {
116
- T ? h[O] = T : delete h[O];
117
- }, (T) => {
118
- f = T;
119
- }, u))), s == null || s(), C(), y();
120
- } catch (M) {
121
- if (!m.signal.aborted)
114
+ const I = await P(e, Object.assign(Object.assign({}, a), { headers: f, signal: y.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
+ }, u))), i == null || i(), b(), g();
120
+ } catch (I) {
121
+ if (!y.signal.aborted)
122
122
  try {
123
- const T = (D = c == null ? void 0 : c(M)) !== null && D !== void 0 ? D : f;
124
- window.clearTimeout(b), b = window.setTimeout(I, T);
125
- } catch (T) {
126
- C(), g(T);
123
+ const v = (M = l == null ? void 0 : l(I)) !== null && M !== void 0 ? M : h;
124
+ window.clearTimeout(S), S = window.setTimeout(x, v);
125
+ } catch (v) {
126
+ b(), m(v);
127
127
  }
128
128
  }
129
129
  }
130
- I();
130
+ x();
131
131
  });
132
132
  }
133
- function se(e) {
133
+ function ie(e) {
134
134
  const t = e.headers.get("content-type");
135
- if (!(t != null && t.startsWith(R)))
136
- throw new Error(`Expected content-type to be ${R}, Actual: ${t}`);
135
+ if (!(t != null && t.startsWith(O)))
136
+ throw new Error(`Expected content-type to be ${O}, Actual: ${t}`);
137
137
  }
138
- function le(e) {
139
- const t = atob(e), r = new Uint8Array(t.length);
140
- for (let n = 0; n < t.length; n++)
141
- r[n] = t.charCodeAt(n);
142
- return new TextDecoder("utf-8").decode(r);
138
+ function ce(e) {
139
+ const t = atob(e), n = new Uint8Array(t.length);
140
+ for (let r = 0; r < t.length; r++)
141
+ n[r] = t.charCodeAt(r);
142
+ return new TextDecoder("utf-8").decode(n);
143
143
  }
144
- class ce {
144
+ class le {
145
145
  constructor(t) {
146
146
  this.eventSources = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Map(), this.fency = t;
147
147
  }
@@ -150,37 +150,37 @@ class ce {
150
150
  * Creates new connections and removes old ones.
151
151
  */
152
152
  updateStreams(t) {
153
- t.forEach((n) => {
154
- const l = n.stream.id;
155
- this.eventSources.has(l) || this.connectStream(n);
153
+ t.forEach((r) => {
154
+ const c = r.stream.id;
155
+ this.eventSources.has(c) || this.connectStream(r);
156
156
  });
157
- const r = new Set(t.map((n) => n.stream.id));
158
- this.eventSources.forEach((n, l) => {
159
- r.has(l) || (n.abort(), this.eventSources.delete(l));
157
+ const n = new Set(t.map((r) => r.stream.id));
158
+ this.eventSources.forEach((r, c) => {
159
+ n.has(c) || (r.abort(), this.eventSources.delete(c));
160
160
  });
161
161
  }
162
162
  connectStream(t) {
163
- const r = t.stream.id, n = new AbortController();
164
- this.eventSources.set(r, n);
165
- const l = `${this.fency.baseUrl}/sse/streams/${r}`, u = {
163
+ const n = t.stream.id, r = new AbortController();
164
+ this.eventSources.set(n, r);
165
+ const c = `${this.fency.baseUrl}/sse/streams/${n}`, u = {
166
166
  "X-Fency-Publishable-Key": this.fency.publishableKey,
167
167
  "X-Fency-Stream-Token": t.stream.token
168
168
  };
169
- ie(l, {
169
+ se(c, {
170
170
  headers: u,
171
- signal: n.signal,
172
- async onopen(s) {
173
- if (!s.ok && s.status >= 400 && s.status < 500 && s.status !== 429)
174
- throw new Error(`Client error ${s.status}`);
171
+ signal: r.signal,
172
+ async onopen(i) {
173
+ if (!i.ok && i.status >= 400 && i.status < 500 && i.status !== 429)
174
+ throw new Error(`Client error ${i.status}`);
175
175
  },
176
- onmessage: (s) => {
177
- if (s.data) {
178
- const c = le(s.data);
179
- this.broadcast(c, r);
176
+ onmessage: (i) => {
177
+ if (i.data) {
178
+ const l = ce(i.data);
179
+ this.broadcast(l, n);
180
180
  }
181
181
  },
182
- onerror: (s) => {
183
- throw console.error("EventSource error for stream", r, ":", s), this.broadcastError(r), s;
182
+ onerror: (i) => {
183
+ throw console.error("EventSource error for stream", n, ":", i), this.broadcastError(n), i;
184
184
  },
185
185
  onclose() {
186
186
  }
@@ -190,19 +190,19 @@ class ce {
190
190
  * Subscribe to events from all active streams.
191
191
  * Returns an unsubscribe function.
192
192
  */
193
- subscribe(t, r) {
194
- return this.subscribers.set(t, r), () => {
193
+ subscribe(t, n) {
194
+ return this.subscribers.set(t, n), () => {
195
195
  this.subscribers.delete(t);
196
196
  };
197
197
  }
198
- broadcast(t, r) {
199
- this.subscribers.forEach((n) => {
200
- n.onMessage(t, r);
198
+ broadcast(t, n) {
199
+ this.subscribers.forEach((r) => {
200
+ r.onMessage(t, n);
201
201
  });
202
202
  }
203
203
  broadcastError(t) {
204
- this.subscribers.forEach((r) => {
205
- r.onError(t);
204
+ this.subscribers.forEach((n) => {
205
+ n.onError(t);
206
206
  });
207
207
  }
208
208
  /**
@@ -214,76 +214,76 @@ class ce {
214
214
  }
215
215
  const de = 12e4, ue = (e) => {
216
216
  const t = Date.now();
217
- return e.filter((r) => t - r.createdAt < de);
217
+ return e.filter((n) => t - n.createdAt < de);
218
218
  };
219
- function We({ fency: e, fetchCreateStreamClientToken: t, children: r }) {
220
- const [n, l] = w(
219
+ function Le({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
220
+ const [r, c] = k(
221
221
  null
222
- ), [u, s] = w(!0), [c, d] = w(null), [a, o] = w([]), y = A(null), g = A(null);
223
- E(() => {
224
- e.then((f) => {
225
- l(f), s(!1);
226
- }).catch((f) => {
227
- d(f), s(!1);
222
+ ), [u, i] = k(!0), [l, d] = k(null), [o, a] = k([]), g = E(null), m = E(null);
223
+ w(() => {
224
+ e.then((h) => {
225
+ c(h), i(!1);
226
+ }).catch((h) => {
227
+ d(h), i(!1);
228
228
  });
229
- }, [e]), E(() => {
230
- n && !g.current && (g.current = new ce(n));
231
- }, [n]), E(() => {
232
- g.current && g.current.updateStreams(a);
233
- }, [a]), E(() => () => {
234
- var f;
235
- (f = g.current) == null || f.cleanup();
229
+ }, [e]), w(() => {
230
+ r && !m.current && (m.current = new le(r));
231
+ }, [r]), w(() => {
232
+ m.current && m.current.updateStreams(o);
233
+ }, [o]), w(() => () => {
234
+ var h;
235
+ (h = m.current) == null || h.cleanup();
236
236
  }, []);
237
- const h = W(
238
- async (f = 3e4) => {
239
- if (y.current)
240
- return y.current;
241
- const b = Date.now(), C = a.length > 0 ? a[a.length - 1] : null;
242
- if (C && b - C.createdAt < f)
243
- return C.stream;
244
- const p = (async () => {
245
- if (!n)
237
+ const f = L(
238
+ async (h = 3e4) => {
239
+ if (g.current)
240
+ return g.current;
241
+ const S = Date.now(), b = o.length > 0 ? o[o.length - 1] : null;
242
+ if (b && S - b.createdAt < h)
243
+ return b.stream;
244
+ const P = (async () => {
245
+ if (!r)
246
246
  throw new Error("Fency instance not initialized");
247
- const x = await t(), I = await K({
248
- pk: n.publishableKey,
249
- baseUrl: n.baseUrl,
250
- clientToken: (x == null ? void 0 : x.clientToken) ?? ""
247
+ const A = await t(), x = await K({
248
+ pk: r.publishableKey,
249
+ baseUrl: r.baseUrl,
250
+ clientToken: (A == null ? void 0 : A.clientToken) ?? ""
251
251
  });
252
- if (I.type === "success") {
253
- const D = {
254
- stream: I.stream,
252
+ if (x.type === "success") {
253
+ const M = {
254
+ stream: x.stream,
255
255
  createdAt: Date.now()
256
256
  };
257
- return o((M) => {
258
- const T = [...M, D];
259
- return ue(T);
260
- }), y.current = null, I.stream;
257
+ return a((I) => {
258
+ const v = [...I, M];
259
+ return ue(v);
260
+ }), g.current = null, x.stream;
261
261
  } else
262
- throw y.current = null, new Error("Failed to create stream");
262
+ throw g.current = null, new Error("Failed to create stream");
263
263
  })();
264
- return y.current = p, p;
264
+ return g.current = P, P;
265
265
  },
266
- [n, a]
266
+ [r, o]
267
267
  );
268
- if (c)
269
- return /* @__PURE__ */ k("div", { children: [
268
+ if (l)
269
+ return /* @__PURE__ */ C("div", { children: [
270
270
  "Fency error: ",
271
- c.message
271
+ l.message
272
272
  ] });
273
- if (!n)
273
+ if (!r)
274
274
  return null;
275
- const m = a.length > 0 ? a[a.length - 1] : null, S = {
276
- fency: n,
275
+ const y = o.length > 0 ? o[o.length - 1] : null, p = {
276
+ fency: r,
277
277
  loading: u,
278
- error: c,
279
- activeStreams: a,
280
- latestStream: m,
281
- eventManager: g.current,
282
- getOrCreateStream: h
278
+ error: l,
279
+ activeStreams: o,
280
+ latestStream: y,
281
+ eventManager: m.current,
282
+ getOrCreateStream: f
283
283
  };
284
- return /* @__PURE__ */ i(N.Provider, { value: S, children: r });
284
+ return /* @__PURE__ */ s(N.Provider, { value: p, children: n });
285
285
  }
286
- function H() {
286
+ function j() {
287
287
  const e = X(N);
288
288
  if (e === void 0)
289
289
  throw new Error("useFencyContext must be used within a FencyProvider");
@@ -312,51 +312,30 @@ const me = (e) => {
312
312
  timestamp: e.timestamp,
313
313
  createdAt: e.createdAt,
314
314
  data: JSON.parse(e.data)
315
- }), Se = (e) => {
316
- const t = H(), [r, n] = w(null), l = A(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
317
- return E(() => {
315
+ }), pe = (e) => {
316
+ const t = j(), [n, r] = k(null), c = E(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
317
+ return w(() => {
318
318
  if (!t.eventManager) return;
319
- const s = {
320
- onMessage: (d, a) => {
321
- var y, g, h, m, S, f, b, C, p, x;
322
- const o = me(d);
323
- if (o)
324
- switch (o.type) {
325
- case "NewChatCompletionStreamChunk":
326
- (y = e == null ? void 0 : e.onNewChatCompletionStreamChunk) == null || y.call(e, o);
327
- break;
328
- case "ChatCompletionStreamCompleted":
329
- (g = e == null ? void 0 : e.onChatCompletionStreamCompleted) == null || g.call(e, o);
330
- break;
319
+ const i = {
320
+ onMessage: (d, o) => {
321
+ var g, m, f;
322
+ const a = me(d);
323
+ if (a)
324
+ switch (a.type) {
331
325
  case "StreamTimeout":
332
- (h = e == null ? void 0 : e.onStreamTimeout) == null || h.call(e, o);
326
+ (g = e == null ? void 0 : e.onStreamTimeout) == null || g.call(e, a);
333
327
  break;
334
328
  case "StreamNotFound":
335
- (m = e == null ? void 0 : e.onStreamNotFound) == null || m.call(e, o);
336
- break;
337
- case "FileUploadCompleted":
338
- (S = e == null ? void 0 : e.onFileUploadCompleted) == null || S.call(e, o);
339
- break;
340
- case "FileTextContentReady":
341
- (f = e == null ? void 0 : e.onFileTextContentReady) == null || f.call(e, o);
342
- break;
343
- case "WebsiteHtmlContentReady":
344
- (b = e == null ? void 0 : e.onWebsiteHtmlContentReady) == null || b.call(e, o);
345
- break;
346
- case "WebsiteTextContentReady":
347
- (C = e == null ? void 0 : e.onWebsiteTextContentReady) == null || C.call(e, o);
348
- break;
349
- case "FileSearchIndexReady":
350
- (p = e == null ? void 0 : e.onFileSearchIndexReady) == null || p.call(e, o);
329
+ (m = e == null ? void 0 : e.onStreamNotFound) == null || m.call(e, a);
351
330
  break;
352
331
  case "AgentTaskProgressItemUpdated":
353
- (x = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || x.call(e, o);
332
+ (f = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || f.call(e, a);
354
333
  break;
355
334
  }
356
335
  },
357
336
  onError: (d) => {
358
- var a;
359
- (a = e == null ? void 0 : e.onStreamError) == null || a.call(e, {
337
+ var o;
338
+ (o = e == null ? void 0 : e.onStreamError) == null || o.call(e, {
360
339
  streamId: d,
361
340
  error: {
362
341
  code: "UnknownError",
@@ -366,250 +345,250 @@ const me = (e) => {
366
345
  }
367
346
  };
368
347
  return t.eventManager.subscribe(
369
- l.current,
370
- s
348
+ c.current,
349
+ i
371
350
  );
372
351
  }, [t.eventManager, e]), {
373
352
  createStream: async () => {
374
353
  try {
375
- const s = await t.getOrCreateStream(3e4);
376
- return n(s), {
354
+ const i = await t.getOrCreateStream(3e4);
355
+ return r(i), {
377
356
  type: "success",
378
- stream: s
357
+ stream: i
379
358
  };
380
- } catch (s) {
359
+ } catch (i) {
381
360
  return {
382
361
  type: "error",
383
362
  error: {
384
363
  code: "UnknownError",
385
- message: s instanceof Error ? s.message : "Failed to create stream"
364
+ message: i instanceof Error ? i.message : "Failed to create stream"
386
365
  }
387
366
  };
388
367
  }
389
368
  },
390
- stream: r
369
+ stream: n
391
370
  };
392
371
  }, Ue = (e) => {
393
- const t = H(), [r, n] = w([]), l = A(/* @__PURE__ */ new Set()), u = A(/* @__PURE__ */ new Map()), { createStream: s } = Se({
394
- onAgentTaskProgressItemUpdated: (a) => {
395
- var g;
396
- if (!l.current.has(a.agentTaskId)) return;
397
- const o = a.data;
398
- if (o.taskType === "StreamingChatCompletion" && o.eventType === "Completed" || o.taskType === "StructuredChatCompletion" && o.eventType === "Completed" || o.taskType === "StreamingMemoryTypeChatCompletion" && o.eventType === "Completed") {
399
- const h = u.current.get(
400
- a.agentTaskId
372
+ const t = j(), [n, r] = k([]), c = E(/* @__PURE__ */ new Set()), u = E(/* @__PURE__ */ new Map()), { createStream: i } = pe({
373
+ onAgentTaskProgressItemUpdated: (o) => {
374
+ var m;
375
+ if (!c.current.has(o.agentTaskId)) return;
376
+ const a = o.data;
377
+ if (a.taskType === "StreamingChatCompletion" && a.eventType === "Completed" || a.taskType === "StructuredChatCompletion" && a.eventType === "Completed" || a.taskType === "MemoryChatCompletion" && a.eventType === "Completed") {
378
+ const f = u.current.get(
379
+ o.agentTaskId
401
380
  );
402
- h && (u.current.delete(a.agentTaskId), h(o));
381
+ f && (u.current.delete(o.agentTaskId), f(a));
403
382
  return;
404
383
  }
405
- (g = e.onAgentTaskProgressItemUpdated) == null || g.call(e, a), n(
406
- (h) => h.map((m) => {
407
- var b;
408
- if (((b = m.confirmedData) == null ? void 0 : b.taskId) !== a.agentTaskId)
409
- return m;
410
- const f = m.progressItems.some(
411
- (C) => C.progressItemId === a.progressItemId
412
- ) ? m.progressItems.map(
413
- (C) => C.progressItemId === a.progressItemId ? a : C
414
- ) : [...m.progressItems, a];
415
- return { ...m, progressItems: f };
384
+ (m = e.onAgentTaskProgressItemUpdated) == null || m.call(e, o), r(
385
+ (f) => f.map((y) => {
386
+ var S;
387
+ if (((S = y.confirmedData) == null ? void 0 : S.taskId) !== o.agentTaskId)
388
+ return y;
389
+ const h = y.progressItems.some(
390
+ (b) => b.progressItemId === o.progressItemId
391
+ ) ? y.progressItems.map(
392
+ (b) => b.progressItemId === o.progressItemId ? o : b
393
+ ) : [...y.progressItems, o];
394
+ return { ...y, progressItems: h };
416
395
  })
417
396
  );
418
397
  },
419
- onStreamError: (a) => {
420
- var o;
421
- (o = e == null ? void 0 : e.onStreamError) == null || o.call(e, a), n((y) => {
422
- const g = y.find((h) => h.streamId === a.streamId);
423
- return g ? [
424
- ...y.filter((h) => h.streamId !== a.streamId),
398
+ onStreamError: (o) => {
399
+ var a;
400
+ (a = e == null ? void 0 : e.onStreamError) == null || a.call(e, o), r((g) => {
401
+ const m = g.find((f) => f.streamId === o.streamId);
402
+ return m ? [
403
+ ...g.filter((f) => f.streamId !== o.streamId),
425
404
  {
426
- ...g,
405
+ ...m,
427
406
  loading: !1,
428
- error: a.error
407
+ error: o.error
429
408
  }
430
- ] : y;
409
+ ] : g;
431
410
  });
432
411
  },
433
- onStreamNotFound: (a) => {
434
- var o;
435
- (o = e == null ? void 0 : e.onStreamNotFound) == null || o.call(e, a);
412
+ onStreamNotFound: (o) => {
413
+ var a;
414
+ (a = e == null ? void 0 : e.onStreamNotFound) == null || a.call(e, o);
436
415
  },
437
- onStreamTimeout: (a) => {
438
- var o;
439
- (o = e == null ? void 0 : e.onStreamTimeout) == null || o.call(e, a);
416
+ onStreamTimeout: (o) => {
417
+ var a;
418
+ (a = e == null ? void 0 : e.onStreamTimeout) == null || a.call(e, o);
440
419
  }
441
- }), c = W(
442
- async (a, o) => {
443
- const y = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, g = await s();
444
- if (g.type === "success") {
445
- n([
446
- ...r,
420
+ }), l = L(
421
+ async (o, a) => {
422
+ const g = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, m = await i();
423
+ if (m.type === "success") {
424
+ r([
425
+ ...n,
447
426
  {
448
- taskKey: y,
449
- streamId: g.stream.id,
427
+ taskKey: g,
428
+ streamId: m.stream.id,
450
429
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
451
430
  confirmedData: null,
452
431
  error: null,
453
- params: a,
432
+ params: o,
454
433
  progressItems: [],
455
434
  loading: !0,
456
435
  doneStreaming: !1,
457
- loadingText: o == null ? void 0 : o.loadingText
436
+ loadingText: a == null ? void 0 : a.loadingText
458
437
  }
459
438
  ]);
460
- const { clientToken: h } = await e.fetchCreateAgentTaskClientToken(a.type), m = await q({
439
+ const { clientToken: f } = await e.fetchCreateAgentTaskClientToken(o.type), y = await q({
461
440
  pk: t.fency.publishableKey,
462
441
  baseUrl: t.fency.baseUrl,
463
- clientToken: h,
464
- streamToken: g.stream.token,
442
+ clientToken: f,
443
+ streamToken: m.stream.token,
465
444
  request: {
466
- streamingChatCompletionTask: a.type === "streamingChatCompletion" ? {
467
- messages: a.messages,
468
- model: a.model
445
+ streamingChatCompletionTask: o.type === "StreamingChatCompletion" ? {
446
+ messages: o.messages,
447
+ model: o.model
469
448
  } : void 0,
470
- structuredChatCompletionTask: a.type === "structuredChatCompletion" ? {
471
- messages: a.messages,
472
- jsonSchema: a.jsonSchema,
473
- model: a.model
449
+ structuredChatCompletionTask: o.type === "StructuredChatCompletion" ? {
450
+ messages: o.messages,
451
+ jsonSchema: o.jsonSchema,
452
+ model: o.model
474
453
  } : void 0,
475
- streamingMemoryTypeChatCompletionTask: a.type === "streamingMemoryTypeChatCompletion" ? {
476
- messages: a.messages,
477
- model: a.model
454
+ memoryChatCompletionTask: o.type === "MemoryChatCompletion" ? {
455
+ messages: o.messages,
456
+ model: o.model
478
457
  } : void 0
479
458
  }
480
459
  });
481
- if (m.type === "success" && m.agentTask) {
482
- l.current.add(
483
- m.agentTask.id
484
- ), n((f) => [
485
- ...f.filter((b) => b.taskKey !== y),
460
+ if (y.type === "success" && y.agentTask) {
461
+ c.current.add(
462
+ y.agentTask.id
463
+ ), r((h) => [
464
+ ...h.filter((S) => S.taskKey !== g),
486
465
  {
487
- taskKey: y,
488
- streamId: g.stream.id,
466
+ taskKey: g,
467
+ streamId: m.stream.id,
489
468
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
490
- taskId: m.agentTask.id,
491
- createdAt: m.agentTask.createdAt,
469
+ taskId: y.agentTask.id,
470
+ createdAt: y.agentTask.createdAt,
492
471
  error: null,
493
- params: a,
472
+ params: o,
494
473
  progressItems: [],
495
474
  doneStreaming: !1,
496
475
  loading: !0,
497
- loadingText: o == null ? void 0 : o.loadingText,
476
+ loadingText: a == null ? void 0 : a.loadingText,
498
477
  confirmedData: {
499
- taskId: m.agentTask.id,
500
- createdAt: m.agentTask.createdAt
478
+ taskId: y.agentTask.id,
479
+ createdAt: y.agentTask.createdAt
501
480
  }
502
481
  }
503
482
  ]);
504
- const S = await new Promise((f) => {
483
+ const p = await new Promise((h) => {
505
484
  u.current.set(
506
- m.agentTask.id,
507
- f
485
+ y.agentTask.id,
486
+ h
508
487
  );
509
488
  });
510
489
  return {
511
490
  type: "success",
512
- streamId: g.stream.id,
513
- agentTaskId: m.agentTask.id,
514
- response: S
491
+ streamId: m.stream.id,
492
+ agentTaskId: y.agentTask.id,
493
+ response: p
515
494
  };
516
495
  } else {
517
- if (m.type === "error")
518
- return n((S) => [
519
- ...S.filter((f) => f.taskKey !== y),
496
+ if (y.type === "error")
497
+ return r((p) => [
498
+ ...p.filter((h) => h.taskKey !== g),
520
499
  {
521
- taskKey: y,
500
+ taskKey: g,
522
501
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
523
- streamId: g.stream.id,
524
- params: a,
525
- error: m.error,
502
+ streamId: m.stream.id,
503
+ params: o,
504
+ error: y.error,
526
505
  progressItems: [],
527
506
  loading: !1,
528
507
  doneStreaming: !1,
529
- loadingText: o == null ? void 0 : o.loadingText,
508
+ loadingText: a == null ? void 0 : a.loadingText,
530
509
  confirmedData: null
531
510
  }
532
511
  ]), {
533
512
  type: "error",
534
- error: m.error
513
+ error: y.error
535
514
  };
536
515
  {
537
- const S = {
516
+ const p = {
538
517
  message: "No response received",
539
518
  code: "UnknownError"
540
519
  };
541
- return n((f) => [
542
- ...f.filter((b) => b.taskKey !== y),
520
+ return r((h) => [
521
+ ...h.filter((S) => S.taskKey !== g),
543
522
  {
544
- taskKey: y,
523
+ taskKey: g,
545
524
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
546
- streamId: g.stream.id,
547
- error: S,
548
- params: a,
525
+ streamId: m.stream.id,
526
+ error: p,
527
+ params: o,
549
528
  progressItems: [],
550
529
  loading: !1,
551
530
  doneStreaming: !1,
552
- loadingText: o == null ? void 0 : o.loadingText,
531
+ loadingText: a == null ? void 0 : a.loadingText,
553
532
  confirmedData: null
554
533
  }
555
534
  ]), {
556
535
  type: "error",
557
- error: S
536
+ error: p
558
537
  };
559
538
  }
560
539
  }
561
540
  } else
562
- return console.error(g.error), g;
541
+ return console.error(m.error), m;
563
542
  },
564
- [t, r, s]
543
+ [t, n, i]
565
544
  ), d = U(() => {
566
- if (r.length !== 0)
567
- return [...r].sort((a, o) => new Date(o.triggeredAt).getTime() - new Date(a.triggeredAt).getTime())[0];
568
- }, [r]);
569
- return E(() => () => {
570
- l.current.clear(), u.current.clear();
545
+ if (n.length !== 0)
546
+ return [...n].sort((o, a) => new Date(a.triggeredAt).getTime() - new Date(o.triggeredAt).getTime())[0];
547
+ }, [n]);
548
+ return w(() => () => {
549
+ c.current.clear(), u.current.clear();
571
550
  }, []), {
572
- agentTasks: r,
573
- createAgentTask: c,
551
+ agentTasks: n,
552
+ createAgentTask: l,
574
553
  latest: d
575
554
  };
576
555
  };
577
- function be(e) {
578
- return e.progressItems.map((t, r) => {
579
- const n = e.progressItems[r + 1], l = n != null;
556
+ function Se(e) {
557
+ return e.progressItems.map((t, n) => {
558
+ const r = e.progressItems[n + 1], c = r != null;
580
559
  let u;
581
- if (n != null && n.createdAt) {
582
- const s = new Date(t.createdAt).getTime(), c = new Date(n.createdAt).getTime();
583
- u = Math.round((c - s) / 1e3);
560
+ if (r != null && r.createdAt) {
561
+ const i = new Date(t.createdAt).getTime(), l = new Date(r.createdAt).getTime();
562
+ u = Math.round((l - i) / 1e3);
584
563
  }
585
564
  return {
586
565
  item: t,
587
- completed: l,
588
- isLatest: r === e.progressItems.length - 1,
566
+ completed: c,
567
+ isLatest: n === e.progressItems.length - 1,
589
568
  durationSeconds: u
590
569
  };
591
570
  });
592
571
  }
593
- function F({
572
+ function D({
594
573
  text: e,
595
574
  duration: t = 2,
596
- delay: r = 0,
597
- repeat: n = !0,
598
- repeatDelay: l = 0.5,
575
+ delay: n = 0,
576
+ repeat: r = !0,
577
+ repeatDelay: c = 0.5,
599
578
  className: u,
600
- startOnView: s = !1,
601
- once: c = !1,
579
+ startOnView: i = !1,
580
+ once: l = !1,
602
581
  inViewMargin: d,
603
- spread: a = 2,
604
- color: o = "#999",
605
- shimmerColor: y = "#000",
606
- direction: g = "fromBottom"
582
+ spread: o = 2,
583
+ color: a = "#999",
584
+ shimmerColor: g = "#000",
585
+ direction: m = "fromBottom"
607
586
  }) {
608
- const h = A(null), m = Q(h, { once: c, margin: d }), S = U(() => e.length * a, [e, a]), f = !s || m, b = g === "fromBottom" ? "100% center" : "-100% center", C = g === "fromBottom" ? "0% center" : "200% center";
609
- return /* @__PURE__ */ i(
610
- v.span,
587
+ const f = E(null), y = Q(f, { once: l, margin: d }), p = U(() => e.length * o, [e, o]), h = !i || y, S = m === "fromBottom" ? "100% center" : "-100% center", b = m === "fromBottom" ? "0% center" : "200% center";
588
+ return /* @__PURE__ */ s(
589
+ T.span,
611
590
  {
612
- ref: h,
591
+ ref: f,
613
592
  className: u,
614
593
  style: {
615
594
  position: "relative",
@@ -620,38 +599,38 @@ function F({
620
599
  color: "transparent",
621
600
  WebkitTextFillColor: "transparent",
622
601
  backgroundRepeat: "no-repeat, padding-box",
623
- "--spread": `${S}px`,
624
- "--base-color": o,
625
- "--shimmer-color": y,
602
+ "--spread": `${p}px`,
603
+ "--base-color": a,
604
+ "--shimmer-color": g,
626
605
  "--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
627
606
  backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
628
607
  },
629
608
  initial: {
630
- backgroundPosition: b,
609
+ backgroundPosition: S,
631
610
  opacity: 0
632
611
  },
633
- animate: f ? {
634
- backgroundPosition: C,
612
+ animate: h ? {
613
+ backgroundPosition: b,
635
614
  opacity: 1
636
615
  } : {},
637
616
  transition: {
638
617
  backgroundPosition: {
639
- repeat: n ? 1 / 0 : 0,
618
+ repeat: r ? 1 / 0 : 0,
640
619
  duration: t,
641
- delay: r,
642
- repeatDelay: l,
620
+ delay: n,
621
+ repeatDelay: c,
643
622
  ease: "linear"
644
623
  },
645
624
  opacity: {
646
625
  duration: 0.3,
647
- delay: r
626
+ delay: n
648
627
  }
649
628
  },
650
629
  children: e
651
630
  }
652
631
  );
653
632
  }
654
- function Ce(e) {
633
+ function be(e) {
655
634
  const t = e.item.data;
656
635
  if (t.taskType === "StreamingChatCompletion") {
657
636
  if (t.eventType === "Text") return "Streaming...";
@@ -661,7 +640,7 @@ function Ce(e) {
661
640
  if (t.eventType === "Json") return "Generating...";
662
641
  if (t.eventType === "Completed") return "Completed";
663
642
  }
664
- if (t.taskType === "StreamingMemoryTypeChatCompletion")
643
+ if (t.taskType === "MemoryChatCompletion")
665
644
  switch (t.eventType) {
666
645
  case "Text":
667
646
  return "Streaming...";
@@ -682,28 +661,28 @@ function Ce(e) {
682
661
  }
683
662
  return "Processing...";
684
663
  }
685
- const Te = ({ progressViewItems: e }) => {
664
+ const ve = ({ progressViewItems: e }) => {
686
665
  const t = e[e.length - 1];
687
666
  if (!t) return null;
688
- const r = Ce(t);
689
- return /* @__PURE__ */ i("div", { className: "simple-mode-container", children: /* @__PURE__ */ i(L, { mode: "wait", children: /* @__PURE__ */ i(
690
- v.div,
667
+ const n = be(t);
668
+ return /* @__PURE__ */ s("div", { className: "simple-mode-container", children: /* @__PURE__ */ s(W, { mode: "wait", children: /* @__PURE__ */ s(
669
+ T.div,
691
670
  {
692
671
  initial: { opacity: 0, y: 10 },
693
672
  animate: { opacity: 1, y: 0 },
694
673
  exit: { opacity: 0, y: -10 },
695
674
  transition: { duration: 0.3 },
696
- children: t.completed ? /* @__PURE__ */ i(
675
+ children: t.completed ? /* @__PURE__ */ s(
697
676
  "div",
698
677
  {
699
678
  className: "simple-mode-title",
700
679
  style: { color: "#666" },
701
- children: r
680
+ children: n
702
681
  }
703
- ) : /* @__PURE__ */ i(
704
- F,
682
+ ) : /* @__PURE__ */ s(
683
+ D,
705
684
  {
706
- text: r,
685
+ text: n,
707
686
  className: "simple-mode-title",
708
687
  duration: 2.5,
709
688
  repeat: !0,
@@ -714,7 +693,7 @@ const Te = ({ progressViewItems: e }) => {
714
693
  },
715
694
  t.item.progressItemId
716
695
  ) }) });
717
- }, j = {
696
+ }, H = {
718
697
  'code[class*="language-"]': {
719
698
  color: "#f8f8f2",
720
699
  background: "none",
@@ -867,52 +846,52 @@ const Te = ({ progressViewItems: e }) => {
867
846
  }
868
847
  }, z = ({
869
848
  text: e
870
- }) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
871
- v.div,
849
+ }) => /* @__PURE__ */ s("div", { style: { padding: "16px" }, children: /* @__PURE__ */ s(
850
+ T.div,
872
851
  {
873
852
  className: "fency-markdown-body-raw",
874
853
  initial: { opacity: 0, y: -10 },
875
854
  animate: { opacity: 1, y: 0 },
876
855
  transition: { duration: 0.3, delay: 0 },
877
- children: /* @__PURE__ */ i(
856
+ children: /* @__PURE__ */ s(
878
857
  Y,
879
858
  {
880
859
  remarkPlugins: [Z],
881
860
  components: {
882
861
  code(t) {
883
- const { children: r, className: n, node: l, ref: u, ...s } = t, c = /language-(\w+)/.exec(n || "");
884
- return c ? /* @__PURE__ */ i(
862
+ const { children: n, className: r, node: c, ref: u, ...i } = t, l = /language-(\w+)/.exec(r || "");
863
+ return l ? /* @__PURE__ */ s(
885
864
  $,
886
865
  {
887
- ...s,
866
+ ...i,
888
867
  PreTag: "div",
889
- children: String(r).replace(/\n$/, ""),
890
- language: c[1],
891
- style: j
868
+ children: String(n).replace(/\n$/, ""),
869
+ language: l[1],
870
+ style: H
892
871
  }
893
- ) : /* @__PURE__ */ i("code", { ...s, className: n, children: String(r) });
872
+ ) : /* @__PURE__ */ s("code", { ...i, className: r, children: String(n) });
894
873
  }
895
874
  },
896
875
  children: e
897
876
  }
898
877
  )
899
878
  }
900
- ) }), ve = ({ data: e }) => {
879
+ ) }), Te = ({ data: e }) => {
901
880
  const t = JSON.stringify(e.json, null, 2);
902
- return /* @__PURE__ */ i("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ i(
903
- v.div,
881
+ return /* @__PURE__ */ s("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ s(
882
+ T.div,
904
883
  {
905
884
  initial: { opacity: 0, y: -10 },
906
885
  animate: { opacity: 1, y: 0 },
907
886
  transition: { duration: 0.3, delay: 0 },
908
- children: /* @__PURE__ */ i($, { language: "json", style: j, PreTag: "div", children: t })
887
+ children: /* @__PURE__ */ s($, { language: "json", style: H, PreTag: "div", children: t })
909
888
  }
910
889
  ) });
911
- }, ke = ({ data: e, isLatest: t = !1, durationSeconds: r }) => {
912
- const n = `Searching: ${e.queryDescription}`;
913
- return /* @__PURE__ */ k("div", { style: { padding: "16px" }, children: [
914
- /* @__PURE__ */ i(
915
- v.div,
890
+ }, Ce = ({ data: e, isLatest: t = !1, durationSeconds: n }) => {
891
+ const r = `Searching: ${e.queryDescription}`;
892
+ return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
893
+ /* @__PURE__ */ s(
894
+ T.div,
916
895
  {
917
896
  style: {
918
897
  display: "flex",
@@ -923,19 +902,19 @@ const Te = ({ progressViewItems: e }) => {
923
902
  initial: { opacity: 0, y: -10 },
924
903
  animate: { opacity: 1, y: 0 },
925
904
  transition: { duration: 0.3, delay: 0 },
926
- children: t && !r ? /* @__PURE__ */ i(
927
- F,
905
+ children: t && !n ? /* @__PURE__ */ s(
906
+ D,
928
907
  {
929
- text: n,
908
+ text: r,
930
909
  duration: 2.5,
931
910
  repeat: !0,
932
911
  color: "#999",
933
912
  shimmerColor: "#000"
934
913
  }
935
- ) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: n })
914
+ ) : /* @__PURE__ */ s("span", { style: { color: "#666" }, children: r })
936
915
  }
937
916
  ),
938
- r !== void 0 && /* @__PURE__ */ k(
917
+ n !== void 0 && /* @__PURE__ */ C(
939
918
  "div",
940
919
  {
941
920
  style: {
@@ -946,17 +925,17 @@ const Te = ({ progressViewItems: e }) => {
946
925
  },
947
926
  children: [
948
927
  "Took ",
949
- r,
928
+ n,
950
929
  " seconds"
951
930
  ]
952
931
  }
953
932
  )
954
933
  ] });
955
- }, xe = ({ isLatest: e = !1, durationSeconds: t }) => {
956
- const r = "Adding sources...";
957
- return /* @__PURE__ */ k("div", { style: { padding: "16px" }, children: [
958
- /* @__PURE__ */ i(
959
- v.div,
934
+ }, ke = ({ isLatest: e = !1, durationSeconds: t }) => {
935
+ const n = "Adding sources...";
936
+ return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
937
+ /* @__PURE__ */ s(
938
+ T.div,
960
939
  {
961
940
  style: {
962
941
  display: "flex",
@@ -967,19 +946,19 @@ const Te = ({ progressViewItems: e }) => {
967
946
  initial: { opacity: 0, y: -10 },
968
947
  animate: { opacity: 1, y: 0 },
969
948
  transition: { duration: 0.3, delay: 0 },
970
- children: e && !t ? /* @__PURE__ */ i(
971
- F,
949
+ children: e && !t ? /* @__PURE__ */ s(
950
+ D,
972
951
  {
973
- text: r,
952
+ text: n,
974
953
  duration: 2.5,
975
954
  repeat: !0,
976
955
  color: "#999",
977
956
  shimmerColor: "#000"
978
957
  }
979
- ) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: r })
958
+ ) : /* @__PURE__ */ s("span", { style: { color: "#666" }, children: n })
980
959
  }
981
960
  ),
982
- t !== void 0 && /* @__PURE__ */ k(
961
+ t !== void 0 && /* @__PURE__ */ C(
983
962
  "div",
984
963
  {
985
964
  style: {
@@ -996,9 +975,9 @@ const Te = ({ progressViewItems: e }) => {
996
975
  }
997
976
  )
998
977
  ] });
999
- }, we = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ k("div", { style: { padding: "16px" }, children: [
1000
- /* @__PURE__ */ i(
1001
- v.div,
978
+ }, xe = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
979
+ /* @__PURE__ */ s(
980
+ T.div,
1002
981
  {
1003
982
  style: {
1004
983
  marginBottom: "10px",
@@ -1014,17 +993,17 @@ const Te = ({ progressViewItems: e }) => {
1014
993
  children: "Sources"
1015
994
  }
1016
995
  ),
1017
- /* @__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((r, n) => /* @__PURE__ */ i(
1018
- Ie,
996
+ /* @__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(
997
+ Ee,
1019
998
  {
1020
- source: r,
1021
- index: n,
999
+ source: n,
1000
+ index: r,
1022
1001
  onSourceClick: t
1023
1002
  },
1024
- r.memoryId
1003
+ n.memoryId
1025
1004
  )) })
1026
1005
  ] });
1027
- function pe(e) {
1006
+ function we(e) {
1028
1007
  if (e.length === 0) return "";
1029
1008
  if (e.length === 1) return `page ${e[0]}`;
1030
1009
  if (e.length === 2)
@@ -1032,17 +1011,17 @@ function pe(e) {
1032
1011
  const t = e[e.length - 1];
1033
1012
  return `pages ${e.slice(0, -1).join(", ")} and ${t}`;
1034
1013
  }
1035
- const Ie = ({ source: e, index: t, onSourceClick: r }) => {
1036
- const [n, l] = w(!1), u = !!r, s = e.pageNumbers ?? [], c = pe(s);
1037
- return /* @__PURE__ */ k(
1038
- v.div,
1014
+ const Ee = ({ source: e, index: t, onSourceClick: n }) => {
1015
+ const [r, c] = k(!1), u = !!n, i = e.pageNumbers ?? [], l = we(i);
1016
+ return /* @__PURE__ */ C(
1017
+ T.div,
1039
1018
  {
1040
1019
  initial: { opacity: 0, scale: 0.9 },
1041
1020
  animate: { opacity: 1, scale: 1 },
1042
1021
  transition: { duration: 0.25, delay: t * 0.05 },
1043
- onClick: u ? () => r(e.memoryId) : void 0,
1044
- onMouseEnter: u ? () => l(!0) : void 0,
1045
- onMouseLeave: u ? () => l(!1) : void 0,
1022
+ onClick: u ? () => n(e.memoryId) : void 0,
1023
+ onMouseEnter: u ? () => c(!0) : void 0,
1024
+ onMouseLeave: u ? () => c(!1) : void 0,
1046
1025
  style: {
1047
1026
  display: "inline-flex",
1048
1027
  flexDirection: "column",
@@ -1050,29 +1029,29 @@ const Ie = ({ source: e, index: t, onSourceClick: r }) => {
1050
1029
  padding: "8px 12px",
1051
1030
  borderRadius: "6px",
1052
1031
  border: "1px solid #e0e0e0",
1053
- backgroundColor: n ? "#f5f5f5" : "transparent",
1032
+ backgroundColor: r ? "#f5f5f5" : "transparent",
1054
1033
  cursor: u ? "pointer" : "default",
1055
1034
  transition: "background-color 0.15s ease",
1056
1035
  userSelect: "none"
1057
1036
  },
1058
1037
  children: [
1059
- /* @__PURE__ */ i("span", { style: { fontSize: "13px", fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1060
- c && /* @__PURE__ */ i("span", { style: { fontSize: "12px", color: "#666" }, children: c })
1038
+ /* @__PURE__ */ s("span", { style: { fontSize: "13px", fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1039
+ l && /* @__PURE__ */ s("span", { style: { fontSize: "12px", color: "#666" }, children: l })
1061
1040
  ]
1062
1041
  }
1063
1042
  );
1064
1043
  };
1065
- function Ee({
1044
+ function Ie({
1066
1045
  eventType: e,
1067
1046
  completed: t
1068
1047
  }) {
1069
- 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;
1048
+ 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;
1070
1049
  }
1071
- const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1072
- const [n, l] = w(!1), u = e.eventType === "ExploreMemoryResult" ? e.result : void 0, s = u != null && u.length > B, c = u != null ? n || !s ? u : `${u.slice(0, B)}...` : void 0, d = s;
1050
+ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1051
+ const [r, c] = k(!1), u = e.eventType === "ExploreMemoryResult" ? e.result : void 0, i = u != null && u.length > B, l = u != null ? r || !i ? u : `${u.slice(0, B)}...` : void 0, d = i;
1073
1052
  if (e.eventType === "ExploreMemoryStart" && !t) {
1074
- const o = `Exploring ${e.memoryTitle}...`;
1075
- return /* @__PURE__ */ i(
1053
+ const a = `Exploring ${e.memoryTitle}...`;
1054
+ return /* @__PURE__ */ s(
1076
1055
  "div",
1077
1056
  {
1078
1057
  style: {
@@ -1080,26 +1059,26 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1080
1059
  display: "flex",
1081
1060
  alignItems: "center"
1082
1061
  },
1083
- children: r ? /* @__PURE__ */ i(
1084
- F,
1062
+ children: n ? /* @__PURE__ */ s(
1063
+ D,
1085
1064
  {
1086
- text: o,
1065
+ text: a,
1087
1066
  duration: 2.5,
1088
1067
  repeat: !0,
1089
1068
  color: "#999",
1090
1069
  shimmerColor: "#000"
1091
1070
  }
1092
- ) : /* @__PURE__ */ i("span", { style: { fontSize: 13, color: "#999" }, children: o })
1071
+ ) : /* @__PURE__ */ s("span", { style: { fontSize: 13, color: "#999" }, children: a })
1093
1072
  }
1094
1073
  );
1095
1074
  }
1096
- return /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ k(
1097
- v.div,
1075
+ return /* @__PURE__ */ s("div", { style: { padding: "16px" }, children: /* @__PURE__ */ C(
1076
+ T.div,
1098
1077
  {
1099
1078
  initial: { opacity: 0 },
1100
1079
  animate: { opacity: 1 },
1101
1080
  transition: { duration: 0.25 },
1102
- onClick: d ? () => l((o) => !o) : void 0,
1081
+ onClick: d ? () => c((a) => !a) : void 0,
1103
1082
  style: {
1104
1083
  paddingBottom: "12px",
1105
1084
  borderBottom: "1px solid #eee",
@@ -1111,7 +1090,7 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1111
1090
  cursor: d ? "pointer" : "default"
1112
1091
  },
1113
1092
  children: [
1114
- /* @__PURE__ */ i(
1093
+ /* @__PURE__ */ s(
1115
1094
  "div",
1116
1095
  {
1117
1096
  style: {
@@ -1121,10 +1100,10 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1121
1100
  flexShrink: 0,
1122
1101
  width: 20
1123
1102
  },
1124
- children: /* @__PURE__ */ i(Ee, { eventType: e.eventType, completed: t })
1103
+ children: /* @__PURE__ */ s(Ie, { eventType: e.eventType, completed: t })
1125
1104
  }
1126
1105
  ),
1127
- /* @__PURE__ */ k(
1106
+ /* @__PURE__ */ C(
1128
1107
  "div",
1129
1108
  {
1130
1109
  style: {
@@ -1134,20 +1113,20 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1134
1113
  minWidth: 0
1135
1114
  },
1136
1115
  children: [
1137
- /* @__PURE__ */ i("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1138
- c != null && /* @__PURE__ */ i(
1116
+ /* @__PURE__ */ s("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1117
+ l != null && /* @__PURE__ */ s(
1139
1118
  "span",
1140
1119
  {
1141
1120
  style: {
1142
1121
  fontSize: 12,
1143
1122
  color: "#666",
1144
1123
  lineHeight: 1.4,
1145
- whiteSpace: n ? "pre-wrap" : void 0
1124
+ whiteSpace: r ? "pre-wrap" : void 0
1146
1125
  },
1147
- children: c
1126
+ children: l
1148
1127
  }
1149
1128
  ),
1150
- d && /* @__PURE__ */ i(
1129
+ d && /* @__PURE__ */ s(
1151
1130
  "span",
1152
1131
  {
1153
1132
  style: {
@@ -1155,7 +1134,7 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1155
1134
  color: "#999",
1156
1135
  marginTop: 2
1157
1136
  },
1158
- children: n ? "Click to collapse" : "Click to expand"
1137
+ children: r ? "Click to collapse" : "Click to expand"
1159
1138
  }
1160
1139
  )
1161
1140
  ]
@@ -1167,59 +1146,59 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1167
1146
  }, Me = ({
1168
1147
  progressViewItems: e,
1169
1148
  streamToken: t,
1170
- fetchClientToken: r,
1171
- loadingText: n,
1172
- onSourceClick: l
1149
+ fetchClientToken: n,
1150
+ loadingText: r,
1151
+ onSourceClick: c
1173
1152
  }) => {
1174
- const u = A(null);
1175
- E(() => {
1153
+ const u = E(null);
1154
+ w(() => {
1176
1155
  u.current && (u.current.scrollTop = u.current.scrollHeight);
1177
1156
  }, [e.length]);
1178
- const s = (c) => {
1179
- const d = c.item.data;
1157
+ const i = (l) => {
1158
+ const d = l.item.data;
1180
1159
  if (d.taskType === "StreamingChatCompletion" && d.eventType === "Text")
1181
- return /* @__PURE__ */ i(z, { text: d.text });
1160
+ return /* @__PURE__ */ s(z, { text: d.text });
1182
1161
  if (d.taskType === "StructuredChatCompletion" && d.eventType === "Json")
1183
- return /* @__PURE__ */ i(ve, { data: d });
1184
- if (d.taskType === "StreamingMemoryTypeChatCompletion")
1162
+ return /* @__PURE__ */ s(Te, { data: d });
1163
+ if (d.taskType === "MemoryChatCompletion")
1185
1164
  switch (d.eventType) {
1186
1165
  case "Text":
1187
- return /* @__PURE__ */ i(z, { text: d.text });
1166
+ return /* @__PURE__ */ s(z, { text: d.text });
1188
1167
  case "Search":
1189
- return /* @__PURE__ */ i(
1190
- ke,
1168
+ return /* @__PURE__ */ s(
1169
+ Ce,
1191
1170
  {
1192
1171
  data: d,
1193
- isLatest: c.isLatest,
1194
- durationSeconds: c.durationSeconds
1172
+ isLatest: l.isLatest,
1173
+ durationSeconds: l.durationSeconds
1195
1174
  }
1196
1175
  );
1197
1176
  case "FindSources":
1198
- return /* @__PURE__ */ i(
1199
- xe,
1177
+ return /* @__PURE__ */ s(
1178
+ ke,
1200
1179
  {
1201
1180
  data: d,
1202
- isLatest: c.isLatest,
1203
- durationSeconds: c.durationSeconds
1181
+ isLatest: l.isLatest,
1182
+ durationSeconds: l.durationSeconds
1204
1183
  }
1205
1184
  );
1206
1185
  case "SourcesResult":
1207
- return /* @__PURE__ */ i(
1208
- we,
1186
+ return /* @__PURE__ */ s(
1187
+ xe,
1209
1188
  {
1210
1189
  data: d,
1211
- onSourceClick: l
1190
+ onSourceClick: c
1212
1191
  }
1213
1192
  );
1214
1193
  case "ExploreMemoryStart":
1215
1194
  case "ExploreMemoryResult":
1216
1195
  case "ExploreMemoryError":
1217
- return /* @__PURE__ */ i(
1196
+ return /* @__PURE__ */ s(
1218
1197
  Ae,
1219
1198
  {
1220
1199
  data: d,
1221
- completed: c.completed,
1222
- isLatest: c.isLatest
1200
+ completed: l.completed,
1201
+ isLatest: l.isLatest
1223
1202
  }
1224
1203
  );
1225
1204
  case "Completed":
@@ -1227,20 +1206,20 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1227
1206
  }
1228
1207
  return d.taskType === "StreamingChatCompletion" && d.eventType === "Completed" || d.taskType === "StructuredChatCompletion" && d.eventType === "Completed", null;
1229
1208
  };
1230
- return e.length === 0 ? /* @__PURE__ */ i("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ i(
1231
- F,
1209
+ return e.length === 0 ? /* @__PURE__ */ s("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ s(
1210
+ D,
1232
1211
  {
1233
- text: n ?? "Processing your task...",
1212
+ text: r ?? "Processing your task...",
1234
1213
  duration: 1.5,
1235
1214
  repeat: !0,
1236
1215
  repeatDelay: 0,
1237
1216
  color: "#999",
1238
1217
  shimmerColor: "#000"
1239
1218
  }
1240
- ) }) : /* @__PURE__ */ i("div", { id: "agent-task-progress-verbose", ref: u, children: /* @__PURE__ */ i(L, { children: e.map((c, d) => /* @__PURE__ */ i(
1241
- v.div,
1219
+ ) }) : /* @__PURE__ */ s("div", { id: "agent-task-progress-verbose", ref: u, children: /* @__PURE__ */ s(W, { children: e.map((l, d) => /* @__PURE__ */ s(
1220
+ T.div,
1242
1221
  {
1243
- id: `agent-task-progress-item-${c.item.progressItemId}`,
1222
+ id: `agent-task-progress-item-${l.item.progressItemId}`,
1244
1223
  initial: { opacity: 0, y: -20 },
1245
1224
  animate: { opacity: 1, y: 0 },
1246
1225
  transition: {
@@ -1248,31 +1227,31 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1248
1227
  delay: d * 0.1,
1249
1228
  ease: "easeOut"
1250
1229
  },
1251
- children: s(c)
1230
+ children: i(l)
1252
1231
  },
1253
- c.item.progressItemId
1232
+ l.item.progressItemId
1254
1233
  )) }) });
1255
- }, Le = ({
1234
+ }, We = ({
1256
1235
  agentTask: e,
1257
1236
  mode: t = "verbose",
1258
- streamToken: r,
1259
- fetchClientToken: n,
1260
- onSourceClick: l
1237
+ streamToken: n,
1238
+ fetchClientToken: r,
1239
+ onSourceClick: c
1261
1240
  }) => {
1262
- const u = be(e);
1263
- return t === "simple" ? /* @__PURE__ */ i(Te, { progressViewItems: u }) : /* @__PURE__ */ i(
1241
+ const u = Se(e);
1242
+ return t === "simple" ? /* @__PURE__ */ s(ve, { progressViewItems: u }) : /* @__PURE__ */ s(
1264
1243
  Me,
1265
1244
  {
1266
1245
  progressViewItems: u,
1267
- streamToken: r,
1268
- fetchClientToken: n,
1246
+ streamToken: n,
1247
+ fetchClientToken: r,
1269
1248
  loadingText: e.loadingText,
1270
- onSourceClick: l
1249
+ onSourceClick: c
1271
1250
  }
1272
1251
  );
1273
1252
  };
1274
1253
  export {
1275
- Le as AgentTaskProgress,
1276
- We as FencyProvider,
1254
+ We as AgentTaskProgress,
1255
+ Le as FencyProvider,
1277
1256
  Ue as useAgentTasks
1278
1257
  };