@fencyai/react 0.1.124 → 0.1.126

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 (36) 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/useAgentTasks/index.d.ts.map +1 -1
  10. package/dist/hooks/useStream/index.d.ts.map +1 -1
  11. package/dist/index.js +456 -481
  12. package/dist/types/AgentTask.d.ts +0 -1
  13. package/dist/types/AgentTask.d.ts.map +1 -1
  14. package/dist/types/CreateAgentTaskParams.d.ts +3 -3
  15. package/dist/types/CreateAgentTaskParams.d.ts.map +1 -1
  16. package/dist/types/CreateAgentTaskResponse.d.ts +1 -1
  17. package/dist/types/CreateAgentTaskResponse.d.ts.map +1 -1
  18. package/dist/types/StreamData.d.ts +1 -48
  19. package/dist/types/StreamData.d.ts.map +1 -1
  20. package/dist/types/UseAgentTasksProps.d.ts +1 -1
  21. package/dist/types/UseAgentTasksProps.d.ts.map +1 -1
  22. package/dist/types/UseStreamProps.d.ts +2 -9
  23. package/dist/types/UseStreamProps.d.ts.map +1 -1
  24. package/dist/types/index.d.ts +0 -1
  25. package/dist/types/index.d.ts.map +1 -1
  26. package/package.json +4 -4
  27. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionExploreMemory.d.ts +0 -14
  28. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionExploreMemory.d.ts.map +0 -1
  29. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionFindSources.d.ts +0 -12
  30. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionFindSources.d.ts.map +0 -1
  31. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionSearch.d.ts +0 -12
  32. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionSearch.d.ts.map +0 -1
  33. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionSourcesResult.d.ts +0 -11
  34. package/dist/agent-task/data-types/StreamingMemoryTypeChatCompletionSourcesResult.d.ts.map +0 -1
  35. package/dist/types/AgentTaskData.d.ts +0 -6
  36. 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,246 @@ 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
- doneStreaming: !1,
457
- loadingText: o == null ? void 0 : o.loadingText
435
+ loadingText: a == null ? void 0 : a.loadingText
458
436
  }
459
437
  ]);
460
- const { clientToken: h } = await e.fetchCreateAgentTaskClientToken(a.type), m = await q({
438
+ const { clientToken: f } = await e.fetchCreateAgentTaskClientToken(o.type), y = await q({
461
439
  pk: t.fency.publishableKey,
462
440
  baseUrl: t.fency.baseUrl,
463
- clientToken: h,
464
- streamToken: g.stream.token,
441
+ clientToken: f,
442
+ streamToken: m.stream.token,
465
443
  request: {
466
- streamingChatCompletionTask: a.type === "streamingChatCompletion" ? {
467
- messages: a.messages,
468
- model: a.model
444
+ streamingChatCompletionTask: o.type === "StreamingChatCompletion" ? {
445
+ messages: o.messages,
446
+ model: o.model
469
447
  } : void 0,
470
- structuredChatCompletionTask: a.type === "structuredChatCompletion" ? {
471
- messages: a.messages,
472
- jsonSchema: a.jsonSchema,
473
- model: a.model
448
+ structuredChatCompletionTask: o.type === "StructuredChatCompletion" ? {
449
+ messages: o.messages,
450
+ jsonSchema: o.jsonSchema,
451
+ model: o.model
474
452
  } : void 0,
475
- streamingMemoryTypeChatCompletionTask: a.type === "streamingMemoryTypeChatCompletion" ? {
476
- messages: a.messages,
477
- model: a.model
453
+ memoryChatCompletionTask: o.type === "MemoryChatCompletion" ? {
454
+ messages: o.messages,
455
+ model: o.model
478
456
  } : void 0
479
457
  }
480
458
  });
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),
459
+ if (y.type === "success" && y.agentTask) {
460
+ c.current.add(
461
+ y.agentTask.id
462
+ ), r((h) => [
463
+ ...h.filter((S) => S.taskKey !== g),
486
464
  {
487
- taskKey: y,
488
- streamId: g.stream.id,
465
+ taskKey: g,
466
+ streamId: m.stream.id,
489
467
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
490
- taskId: m.agentTask.id,
491
- createdAt: m.agentTask.createdAt,
468
+ taskId: y.agentTask.id,
469
+ createdAt: y.agentTask.createdAt,
492
470
  error: null,
493
- params: a,
471
+ params: o,
494
472
  progressItems: [],
495
- doneStreaming: !1,
496
473
  loading: !0,
497
- loadingText: o == null ? void 0 : o.loadingText,
474
+ loadingText: a == null ? void 0 : a.loadingText,
498
475
  confirmedData: {
499
- taskId: m.agentTask.id,
500
- createdAt: m.agentTask.createdAt
476
+ taskId: y.agentTask.id,
477
+ createdAt: y.agentTask.createdAt
501
478
  }
502
479
  }
503
480
  ]);
504
- const S = await new Promise((f) => {
481
+ const p = await new Promise((h) => {
505
482
  u.current.set(
506
- m.agentTask.id,
507
- f
483
+ y.agentTask.id,
484
+ h
508
485
  );
509
486
  });
510
487
  return {
511
488
  type: "success",
512
- streamId: g.stream.id,
513
- agentTaskId: m.agentTask.id,
514
- response: S
489
+ streamId: m.stream.id,
490
+ agentTaskId: y.agentTask.id,
491
+ response: p
515
492
  };
516
493
  } else {
517
- if (m.type === "error")
518
- return n((S) => [
519
- ...S.filter((f) => f.taskKey !== y),
494
+ if (y.type === "error")
495
+ return r((p) => [
496
+ ...p.filter((h) => h.taskKey !== g),
520
497
  {
521
- taskKey: y,
498
+ taskKey: g,
522
499
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
523
- streamId: g.stream.id,
524
- params: a,
525
- error: m.error,
500
+ streamId: m.stream.id,
501
+ params: o,
502
+ error: y.error,
526
503
  progressItems: [],
527
504
  loading: !1,
528
- doneStreaming: !1,
529
- loadingText: o == null ? void 0 : o.loadingText,
505
+ loadingText: a == null ? void 0 : a.loadingText,
530
506
  confirmedData: null
531
507
  }
532
508
  ]), {
533
509
  type: "error",
534
- error: m.error
510
+ error: y.error
535
511
  };
536
512
  {
537
- const S = {
513
+ const p = {
538
514
  message: "No response received",
539
515
  code: "UnknownError"
540
516
  };
541
- return n((f) => [
542
- ...f.filter((b) => b.taskKey !== y),
517
+ return r((h) => [
518
+ ...h.filter((S) => S.taskKey !== g),
543
519
  {
544
- taskKey: y,
520
+ taskKey: g,
545
521
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
546
- streamId: g.stream.id,
547
- error: S,
548
- params: a,
522
+ streamId: m.stream.id,
523
+ error: p,
524
+ params: o,
549
525
  progressItems: [],
550
526
  loading: !1,
551
- doneStreaming: !1,
552
- loadingText: o == null ? void 0 : o.loadingText,
527
+ loadingText: a == null ? void 0 : a.loadingText,
553
528
  confirmedData: null
554
529
  }
555
530
  ]), {
556
531
  type: "error",
557
- error: S
532
+ error: p
558
533
  };
559
534
  }
560
535
  }
561
536
  } else
562
- return console.error(g.error), g;
537
+ return console.error(m.error), m;
563
538
  },
564
- [t, r, s]
539
+ [t, n, i]
565
540
  ), 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();
541
+ if (n.length !== 0)
542
+ return [...n].sort((o, a) => new Date(a.triggeredAt).getTime() - new Date(o.triggeredAt).getTime())[0];
543
+ }, [n]);
544
+ return w(() => () => {
545
+ c.current.clear(), u.current.clear();
571
546
  }, []), {
572
- agentTasks: r,
573
- createAgentTask: c,
547
+ agentTasks: n,
548
+ createAgentTask: l,
574
549
  latest: d
575
550
  };
576
551
  };
577
- function be(e) {
578
- return e.progressItems.map((t, r) => {
579
- const n = e.progressItems[r + 1], l = n != null;
552
+ function Se(e) {
553
+ return e.progressItems.map((t, n) => {
554
+ const r = e.progressItems[n + 1], c = r != null;
580
555
  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);
556
+ if (r != null && r.createdAt) {
557
+ const i = new Date(t.createdAt).getTime(), l = new Date(r.createdAt).getTime();
558
+ u = Math.round((l - i) / 1e3);
584
559
  }
585
560
  return {
586
561
  item: t,
587
- completed: l,
588
- isLatest: r === e.progressItems.length - 1,
562
+ completed: c,
563
+ isLatest: n === e.progressItems.length - 1,
589
564
  durationSeconds: u
590
565
  };
591
566
  });
592
567
  }
593
- function F({
568
+ function D({
594
569
  text: e,
595
570
  duration: t = 2,
596
- delay: r = 0,
597
- repeat: n = !0,
598
- repeatDelay: l = 0.5,
571
+ delay: n = 0,
572
+ repeat: r = !0,
573
+ repeatDelay: c = 0.5,
599
574
  className: u,
600
- startOnView: s = !1,
601
- once: c = !1,
575
+ startOnView: i = !1,
576
+ once: l = !1,
602
577
  inViewMargin: d,
603
- spread: a = 2,
604
- color: o = "#999",
605
- shimmerColor: y = "#000",
606
- direction: g = "fromBottom"
578
+ spread: o = 2,
579
+ color: a = "#999",
580
+ shimmerColor: g = "#000",
581
+ direction: m = "fromBottom"
607
582
  }) {
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,
583
+ 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";
584
+ return /* @__PURE__ */ s(
585
+ T.span,
611
586
  {
612
- ref: h,
587
+ ref: f,
613
588
  className: u,
614
589
  style: {
615
590
  position: "relative",
@@ -620,38 +595,38 @@ function F({
620
595
  color: "transparent",
621
596
  WebkitTextFillColor: "transparent",
622
597
  backgroundRepeat: "no-repeat, padding-box",
623
- "--spread": `${S}px`,
624
- "--base-color": o,
625
- "--shimmer-color": y,
598
+ "--spread": `${p}px`,
599
+ "--base-color": a,
600
+ "--shimmer-color": g,
626
601
  "--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
627
602
  backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
628
603
  },
629
604
  initial: {
630
- backgroundPosition: b,
605
+ backgroundPosition: S,
631
606
  opacity: 0
632
607
  },
633
- animate: f ? {
634
- backgroundPosition: C,
608
+ animate: h ? {
609
+ backgroundPosition: b,
635
610
  opacity: 1
636
611
  } : {},
637
612
  transition: {
638
613
  backgroundPosition: {
639
- repeat: n ? 1 / 0 : 0,
614
+ repeat: r ? 1 / 0 : 0,
640
615
  duration: t,
641
- delay: r,
642
- repeatDelay: l,
616
+ delay: n,
617
+ repeatDelay: c,
643
618
  ease: "linear"
644
619
  },
645
620
  opacity: {
646
621
  duration: 0.3,
647
- delay: r
622
+ delay: n
648
623
  }
649
624
  },
650
625
  children: e
651
626
  }
652
627
  );
653
628
  }
654
- function Ce(e) {
629
+ function be(e) {
655
630
  const t = e.item.data;
656
631
  if (t.taskType === "StreamingChatCompletion") {
657
632
  if (t.eventType === "Text") return "Streaming...";
@@ -661,7 +636,7 @@ function Ce(e) {
661
636
  if (t.eventType === "Json") return "Generating...";
662
637
  if (t.eventType === "Completed") return "Completed";
663
638
  }
664
- if (t.taskType === "StreamingMemoryTypeChatCompletion")
639
+ if (t.taskType === "MemoryChatCompletion")
665
640
  switch (t.eventType) {
666
641
  case "Text":
667
642
  return "Streaming...";
@@ -682,28 +657,28 @@ function Ce(e) {
682
657
  }
683
658
  return "Processing...";
684
659
  }
685
- const Te = ({ progressViewItems: e }) => {
660
+ const ve = ({ progressViewItems: e }) => {
686
661
  const t = e[e.length - 1];
687
662
  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,
663
+ const n = be(t);
664
+ return /* @__PURE__ */ s("div", { className: "simple-mode-container", children: /* @__PURE__ */ s(W, { mode: "wait", children: /* @__PURE__ */ s(
665
+ T.div,
691
666
  {
692
667
  initial: { opacity: 0, y: 10 },
693
668
  animate: { opacity: 1, y: 0 },
694
669
  exit: { opacity: 0, y: -10 },
695
670
  transition: { duration: 0.3 },
696
- children: t.completed ? /* @__PURE__ */ i(
671
+ children: t.completed ? /* @__PURE__ */ s(
697
672
  "div",
698
673
  {
699
674
  className: "simple-mode-title",
700
675
  style: { color: "#666" },
701
- children: r
676
+ children: n
702
677
  }
703
- ) : /* @__PURE__ */ i(
704
- F,
678
+ ) : /* @__PURE__ */ s(
679
+ D,
705
680
  {
706
- text: r,
681
+ text: n,
707
682
  className: "simple-mode-title",
708
683
  duration: 2.5,
709
684
  repeat: !0,
@@ -714,7 +689,7 @@ const Te = ({ progressViewItems: e }) => {
714
689
  },
715
690
  t.item.progressItemId
716
691
  ) }) });
717
- }, j = {
692
+ }, H = {
718
693
  'code[class*="language-"]': {
719
694
  color: "#f8f8f2",
720
695
  background: "none",
@@ -867,52 +842,52 @@ const Te = ({ progressViewItems: e }) => {
867
842
  }
868
843
  }, z = ({
869
844
  text: e
870
- }) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
871
- v.div,
845
+ }) => /* @__PURE__ */ s("div", { style: { padding: "16px" }, children: /* @__PURE__ */ s(
846
+ T.div,
872
847
  {
873
848
  className: "fency-markdown-body-raw",
874
849
  initial: { opacity: 0, y: -10 },
875
850
  animate: { opacity: 1, y: 0 },
876
851
  transition: { duration: 0.3, delay: 0 },
877
- children: /* @__PURE__ */ i(
852
+ children: /* @__PURE__ */ s(
878
853
  Y,
879
854
  {
880
855
  remarkPlugins: [Z],
881
856
  components: {
882
857
  code(t) {
883
- const { children: r, className: n, node: l, ref: u, ...s } = t, c = /language-(\w+)/.exec(n || "");
884
- return c ? /* @__PURE__ */ i(
858
+ const { children: n, className: r, node: c, ref: u, ...i } = t, l = /language-(\w+)/.exec(r || "");
859
+ return l ? /* @__PURE__ */ s(
885
860
  $,
886
861
  {
887
- ...s,
862
+ ...i,
888
863
  PreTag: "div",
889
- children: String(r).replace(/\n$/, ""),
890
- language: c[1],
891
- style: j
864
+ children: String(n).replace(/\n$/, ""),
865
+ language: l[1],
866
+ style: H
892
867
  }
893
- ) : /* @__PURE__ */ i("code", { ...s, className: n, children: String(r) });
868
+ ) : /* @__PURE__ */ s("code", { ...i, className: r, children: String(n) });
894
869
  }
895
870
  },
896
871
  children: e
897
872
  }
898
873
  )
899
874
  }
900
- ) }), ve = ({ data: e }) => {
875
+ ) }), Te = ({ data: e }) => {
901
876
  const t = JSON.stringify(e.json, null, 2);
902
- return /* @__PURE__ */ i("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ i(
903
- v.div,
877
+ return /* @__PURE__ */ s("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ s(
878
+ T.div,
904
879
  {
905
880
  initial: { opacity: 0, y: -10 },
906
881
  animate: { opacity: 1, y: 0 },
907
882
  transition: { duration: 0.3, delay: 0 },
908
- children: /* @__PURE__ */ i($, { language: "json", style: j, PreTag: "div", children: t })
883
+ children: /* @__PURE__ */ s($, { language: "json", style: H, PreTag: "div", children: t })
909
884
  }
910
885
  ) });
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,
886
+ }, Ce = ({ data: e, isLatest: t = !1, durationSeconds: n }) => {
887
+ const r = `Searching: ${e.queryDescription}`;
888
+ return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
889
+ /* @__PURE__ */ s(
890
+ T.div,
916
891
  {
917
892
  style: {
918
893
  display: "flex",
@@ -923,19 +898,19 @@ const Te = ({ progressViewItems: e }) => {
923
898
  initial: { opacity: 0, y: -10 },
924
899
  animate: { opacity: 1, y: 0 },
925
900
  transition: { duration: 0.3, delay: 0 },
926
- children: t && !r ? /* @__PURE__ */ i(
927
- F,
901
+ children: t && !n ? /* @__PURE__ */ s(
902
+ D,
928
903
  {
929
- text: n,
904
+ text: r,
930
905
  duration: 2.5,
931
906
  repeat: !0,
932
907
  color: "#999",
933
908
  shimmerColor: "#000"
934
909
  }
935
- ) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: n })
910
+ ) : /* @__PURE__ */ s("span", { style: { color: "#666" }, children: r })
936
911
  }
937
912
  ),
938
- r !== void 0 && /* @__PURE__ */ k(
913
+ n !== void 0 && /* @__PURE__ */ C(
939
914
  "div",
940
915
  {
941
916
  style: {
@@ -946,17 +921,17 @@ const Te = ({ progressViewItems: e }) => {
946
921
  },
947
922
  children: [
948
923
  "Took ",
949
- r,
924
+ n,
950
925
  " seconds"
951
926
  ]
952
927
  }
953
928
  )
954
929
  ] });
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,
930
+ }, ke = ({ isLatest: e = !1, durationSeconds: t }) => {
931
+ const n = "Adding sources...";
932
+ return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
933
+ /* @__PURE__ */ s(
934
+ T.div,
960
935
  {
961
936
  style: {
962
937
  display: "flex",
@@ -967,19 +942,19 @@ const Te = ({ progressViewItems: e }) => {
967
942
  initial: { opacity: 0, y: -10 },
968
943
  animate: { opacity: 1, y: 0 },
969
944
  transition: { duration: 0.3, delay: 0 },
970
- children: e && !t ? /* @__PURE__ */ i(
971
- F,
945
+ children: e && !t ? /* @__PURE__ */ s(
946
+ D,
972
947
  {
973
- text: r,
948
+ text: n,
974
949
  duration: 2.5,
975
950
  repeat: !0,
976
951
  color: "#999",
977
952
  shimmerColor: "#000"
978
953
  }
979
- ) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: r })
954
+ ) : /* @__PURE__ */ s("span", { style: { color: "#666" }, children: n })
980
955
  }
981
956
  ),
982
- t !== void 0 && /* @__PURE__ */ k(
957
+ t !== void 0 && /* @__PURE__ */ C(
983
958
  "div",
984
959
  {
985
960
  style: {
@@ -996,9 +971,9 @@ const Te = ({ progressViewItems: e }) => {
996
971
  }
997
972
  )
998
973
  ] });
999
- }, we = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ k("div", { style: { padding: "16px" }, children: [
1000
- /* @__PURE__ */ i(
1001
- v.div,
974
+ }, xe = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
975
+ /* @__PURE__ */ s(
976
+ T.div,
1002
977
  {
1003
978
  style: {
1004
979
  marginBottom: "10px",
@@ -1014,17 +989,17 @@ const Te = ({ progressViewItems: e }) => {
1014
989
  children: "Sources"
1015
990
  }
1016
991
  ),
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,
992
+ /* @__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
+ Ee,
1019
994
  {
1020
- source: r,
1021
- index: n,
995
+ source: n,
996
+ index: r,
1022
997
  onSourceClick: t
1023
998
  },
1024
- r.memoryId
999
+ n.memoryId
1025
1000
  )) })
1026
1001
  ] });
1027
- function pe(e) {
1002
+ function we(e) {
1028
1003
  if (e.length === 0) return "";
1029
1004
  if (e.length === 1) return `page ${e[0]}`;
1030
1005
  if (e.length === 2)
@@ -1032,17 +1007,17 @@ function pe(e) {
1032
1007
  const t = e[e.length - 1];
1033
1008
  return `pages ${e.slice(0, -1).join(", ")} and ${t}`;
1034
1009
  }
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,
1010
+ const Ee = ({ source: e, index: t, onSourceClick: n }) => {
1011
+ const [r, c] = k(!1), u = !!n, i = e.pageNumbers ?? [], l = we(i);
1012
+ return /* @__PURE__ */ C(
1013
+ T.div,
1039
1014
  {
1040
1015
  initial: { opacity: 0, scale: 0.9 },
1041
1016
  animate: { opacity: 1, scale: 1 },
1042
1017
  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,
1018
+ onClick: u ? () => n(e.memoryId) : void 0,
1019
+ onMouseEnter: u ? () => c(!0) : void 0,
1020
+ onMouseLeave: u ? () => c(!1) : void 0,
1046
1021
  style: {
1047
1022
  display: "inline-flex",
1048
1023
  flexDirection: "column",
@@ -1050,29 +1025,29 @@ const Ie = ({ source: e, index: t, onSourceClick: r }) => {
1050
1025
  padding: "8px 12px",
1051
1026
  borderRadius: "6px",
1052
1027
  border: "1px solid #e0e0e0",
1053
- backgroundColor: n ? "#f5f5f5" : "transparent",
1028
+ backgroundColor: r ? "#f5f5f5" : "transparent",
1054
1029
  cursor: u ? "pointer" : "default",
1055
1030
  transition: "background-color 0.15s ease",
1056
1031
  userSelect: "none"
1057
1032
  },
1058
1033
  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 })
1034
+ /* @__PURE__ */ s("span", { style: { fontSize: "13px", fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1035
+ l && /* @__PURE__ */ s("span", { style: { fontSize: "12px", color: "#666" }, children: l })
1061
1036
  ]
1062
1037
  }
1063
1038
  );
1064
1039
  };
1065
- function Ee({
1040
+ function Ie({
1066
1041
  eventType: e,
1067
1042
  completed: t
1068
1043
  }) {
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;
1044
+ 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
1045
  }
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;
1046
+ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
1047
+ 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
1048
  if (e.eventType === "ExploreMemoryStart" && !t) {
1074
- const o = `Exploring ${e.memoryTitle}...`;
1075
- return /* @__PURE__ */ i(
1049
+ const a = `Exploring ${e.memoryTitle}...`;
1050
+ return /* @__PURE__ */ s(
1076
1051
  "div",
1077
1052
  {
1078
1053
  style: {
@@ -1080,26 +1055,26 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1080
1055
  display: "flex",
1081
1056
  alignItems: "center"
1082
1057
  },
1083
- children: r ? /* @__PURE__ */ i(
1084
- F,
1058
+ children: n ? /* @__PURE__ */ s(
1059
+ D,
1085
1060
  {
1086
- text: o,
1061
+ text: a,
1087
1062
  duration: 2.5,
1088
1063
  repeat: !0,
1089
1064
  color: "#999",
1090
1065
  shimmerColor: "#000"
1091
1066
  }
1092
- ) : /* @__PURE__ */ i("span", { style: { fontSize: 13, color: "#999" }, children: o })
1067
+ ) : /* @__PURE__ */ s("span", { style: { fontSize: 13, color: "#999" }, children: a })
1093
1068
  }
1094
1069
  );
1095
1070
  }
1096
- return /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ k(
1097
- v.div,
1071
+ return /* @__PURE__ */ s("div", { style: { padding: "16px" }, children: /* @__PURE__ */ C(
1072
+ T.div,
1098
1073
  {
1099
1074
  initial: { opacity: 0 },
1100
1075
  animate: { opacity: 1 },
1101
1076
  transition: { duration: 0.25 },
1102
- onClick: d ? () => l((o) => !o) : void 0,
1077
+ onClick: d ? () => c((a) => !a) : void 0,
1103
1078
  style: {
1104
1079
  paddingBottom: "12px",
1105
1080
  borderBottom: "1px solid #eee",
@@ -1111,7 +1086,7 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1111
1086
  cursor: d ? "pointer" : "default"
1112
1087
  },
1113
1088
  children: [
1114
- /* @__PURE__ */ i(
1089
+ /* @__PURE__ */ s(
1115
1090
  "div",
1116
1091
  {
1117
1092
  style: {
@@ -1121,10 +1096,10 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1121
1096
  flexShrink: 0,
1122
1097
  width: 20
1123
1098
  },
1124
- children: /* @__PURE__ */ i(Ee, { eventType: e.eventType, completed: t })
1099
+ children: /* @__PURE__ */ s(Ie, { eventType: e.eventType, completed: t })
1125
1100
  }
1126
1101
  ),
1127
- /* @__PURE__ */ k(
1102
+ /* @__PURE__ */ C(
1128
1103
  "div",
1129
1104
  {
1130
1105
  style: {
@@ -1134,20 +1109,20 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1134
1109
  minWidth: 0
1135
1110
  },
1136
1111
  children: [
1137
- /* @__PURE__ */ i("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1138
- c != null && /* @__PURE__ */ i(
1112
+ /* @__PURE__ */ s("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1113
+ l != null && /* @__PURE__ */ s(
1139
1114
  "span",
1140
1115
  {
1141
1116
  style: {
1142
1117
  fontSize: 12,
1143
1118
  color: "#666",
1144
1119
  lineHeight: 1.4,
1145
- whiteSpace: n ? "pre-wrap" : void 0
1120
+ whiteSpace: r ? "pre-wrap" : void 0
1146
1121
  },
1147
- children: c
1122
+ children: l
1148
1123
  }
1149
1124
  ),
1150
- d && /* @__PURE__ */ i(
1125
+ d && /* @__PURE__ */ s(
1151
1126
  "span",
1152
1127
  {
1153
1128
  style: {
@@ -1155,7 +1130,7 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1155
1130
  color: "#999",
1156
1131
  marginTop: 2
1157
1132
  },
1158
- children: n ? "Click to collapse" : "Click to expand"
1133
+ children: r ? "Click to collapse" : "Click to expand"
1159
1134
  }
1160
1135
  )
1161
1136
  ]
@@ -1167,59 +1142,59 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1167
1142
  }, Me = ({
1168
1143
  progressViewItems: e,
1169
1144
  streamToken: t,
1170
- fetchClientToken: r,
1171
- loadingText: n,
1172
- onSourceClick: l
1145
+ fetchClientToken: n,
1146
+ loadingText: r,
1147
+ onSourceClick: c
1173
1148
  }) => {
1174
- const u = A(null);
1175
- E(() => {
1149
+ const u = E(null);
1150
+ w(() => {
1176
1151
  u.current && (u.current.scrollTop = u.current.scrollHeight);
1177
1152
  }, [e.length]);
1178
- const s = (c) => {
1179
- const d = c.item.data;
1153
+ const i = (l) => {
1154
+ const d = l.item.data;
1180
1155
  if (d.taskType === "StreamingChatCompletion" && d.eventType === "Text")
1181
- return /* @__PURE__ */ i(z, { text: d.text });
1156
+ return /* @__PURE__ */ s(z, { text: d.text });
1182
1157
  if (d.taskType === "StructuredChatCompletion" && d.eventType === "Json")
1183
- return /* @__PURE__ */ i(ve, { data: d });
1184
- if (d.taskType === "StreamingMemoryTypeChatCompletion")
1158
+ return /* @__PURE__ */ s(Te, { data: d });
1159
+ if (d.taskType === "MemoryChatCompletion")
1185
1160
  switch (d.eventType) {
1186
1161
  case "Text":
1187
- return /* @__PURE__ */ i(z, { text: d.text });
1162
+ return /* @__PURE__ */ s(z, { text: d.text });
1188
1163
  case "Search":
1189
- return /* @__PURE__ */ i(
1190
- ke,
1164
+ return /* @__PURE__ */ s(
1165
+ Ce,
1191
1166
  {
1192
1167
  data: d,
1193
- isLatest: c.isLatest,
1194
- durationSeconds: c.durationSeconds
1168
+ isLatest: l.isLatest,
1169
+ durationSeconds: l.durationSeconds
1195
1170
  }
1196
1171
  );
1197
1172
  case "FindSources":
1198
- return /* @__PURE__ */ i(
1199
- xe,
1173
+ return /* @__PURE__ */ s(
1174
+ ke,
1200
1175
  {
1201
1176
  data: d,
1202
- isLatest: c.isLatest,
1203
- durationSeconds: c.durationSeconds
1177
+ isLatest: l.isLatest,
1178
+ durationSeconds: l.durationSeconds
1204
1179
  }
1205
1180
  );
1206
1181
  case "SourcesResult":
1207
- return /* @__PURE__ */ i(
1208
- we,
1182
+ return /* @__PURE__ */ s(
1183
+ xe,
1209
1184
  {
1210
1185
  data: d,
1211
- onSourceClick: l
1186
+ onSourceClick: c
1212
1187
  }
1213
1188
  );
1214
1189
  case "ExploreMemoryStart":
1215
1190
  case "ExploreMemoryResult":
1216
1191
  case "ExploreMemoryError":
1217
- return /* @__PURE__ */ i(
1192
+ return /* @__PURE__ */ s(
1218
1193
  Ae,
1219
1194
  {
1220
1195
  data: d,
1221
- completed: c.completed,
1222
- isLatest: c.isLatest
1196
+ completed: l.completed,
1197
+ isLatest: l.isLatest
1223
1198
  }
1224
1199
  );
1225
1200
  case "Completed":
@@ -1227,20 +1202,20 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1227
1202
  }
1228
1203
  return d.taskType === "StreamingChatCompletion" && d.eventType === "Completed" || d.taskType === "StructuredChatCompletion" && d.eventType === "Completed", null;
1229
1204
  };
1230
- return e.length === 0 ? /* @__PURE__ */ i("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ i(
1231
- F,
1205
+ return e.length === 0 ? /* @__PURE__ */ s("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ s(
1206
+ D,
1232
1207
  {
1233
- text: n ?? "Processing your task...",
1208
+ text: r ?? "Processing your task...",
1234
1209
  duration: 1.5,
1235
1210
  repeat: !0,
1236
1211
  repeatDelay: 0,
1237
1212
  color: "#999",
1238
1213
  shimmerColor: "#000"
1239
1214
  }
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,
1215
+ ) }) : /* @__PURE__ */ s("div", { id: "agent-task-progress-verbose", ref: u, children: /* @__PURE__ */ s(W, { children: e.map((l, d) => /* @__PURE__ */ s(
1216
+ T.div,
1242
1217
  {
1243
- id: `agent-task-progress-item-${c.item.progressItemId}`,
1218
+ id: `agent-task-progress-item-${l.item.progressItemId}`,
1244
1219
  initial: { opacity: 0, y: -20 },
1245
1220
  animate: { opacity: 1, y: 0 },
1246
1221
  transition: {
@@ -1248,31 +1223,31 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: r = !1 }) => {
1248
1223
  delay: d * 0.1,
1249
1224
  ease: "easeOut"
1250
1225
  },
1251
- children: s(c)
1226
+ children: i(l)
1252
1227
  },
1253
- c.item.progressItemId
1228
+ l.item.progressItemId
1254
1229
  )) }) });
1255
- }, Le = ({
1230
+ }, We = ({
1256
1231
  agentTask: e,
1257
1232
  mode: t = "verbose",
1258
- streamToken: r,
1259
- fetchClientToken: n,
1260
- onSourceClick: l
1233
+ streamToken: n,
1234
+ fetchClientToken: r,
1235
+ onSourceClick: c
1261
1236
  }) => {
1262
- const u = be(e);
1263
- return t === "simple" ? /* @__PURE__ */ i(Te, { progressViewItems: u }) : /* @__PURE__ */ i(
1237
+ const u = Se(e);
1238
+ return t === "simple" ? /* @__PURE__ */ s(ve, { progressViewItems: u }) : /* @__PURE__ */ s(
1264
1239
  Me,
1265
1240
  {
1266
1241
  progressViewItems: u,
1267
- streamToken: r,
1268
- fetchClientToken: n,
1242
+ streamToken: n,
1243
+ fetchClientToken: r,
1269
1244
  loadingText: e.loadingText,
1270
- onSourceClick: l
1245
+ onSourceClick: c
1271
1246
  }
1272
1247
  );
1273
1248
  };
1274
1249
  export {
1275
- Le as AgentTaskProgress,
1276
- We as FencyProvider,
1250
+ We as AgentTaskProgress,
1251
+ Le as FencyProvider,
1277
1252
  Ue as useAgentTasks
1278
1253
  };