@fencyai/react 0.1.118 → 0.1.120

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,47 +1,47 @@
1
- import { createAgentTask as q, createFileDownloadLink as J, createStream as V } from "@fencyai/js";
2
- import { createContext as X, useContext as Q, useState as x, useRef as I, useEffect as w, useCallback as U, useMemo as j } from "react";
3
- import { jsx as l, jsxs as C } from "react/jsx-runtime";
4
- import { useInView as Y, motion as T, AnimatePresence as W } from "motion/react";
5
- import B from "react-markdown";
6
- import { Prism as R } from "react-syntax-highlighter";
7
- import z from "remark-gfm";
8
- import './assets/index.css';const $ = X(
1
+ import { createAgentTask as J, createFileDownloadLink as V, createStream as X } from "@fencyai/js";
2
+ import { createContext as Y, useContext as Q, useState as C, useRef as E, useEffect as p, useCallback as U, useMemo as j } from "react";
3
+ import { jsx as i, jsxs as b, Fragment as Z } from "react/jsx-runtime";
4
+ import { useInView as ee, motion as v, AnimatePresence as H } from "motion/react";
5
+ import z from "react-markdown";
6
+ import { Prism as F } from "react-syntax-highlighter";
7
+ import L from "remark-gfm";
8
+ import './assets/index.css';const G = Y(
9
9
  void 0
10
10
  );
11
- function M() {
12
- const e = Q($);
11
+ function N() {
12
+ const e = Q(G);
13
13
  if (e === void 0)
14
14
  throw new Error("useFencyContext must be used within a FencyProvider");
15
15
  return e;
16
16
  }
17
- const Z = (e) => {
17
+ const te = (e) => {
18
18
  try {
19
19
  const t = JSON.parse(e);
20
- return ee(t);
20
+ return ne(t);
21
21
  } catch (t) {
22
22
  return console.error("Error parsing message:", t), null;
23
23
  }
24
- }, ee = (e) => {
24
+ }, ne = (e) => {
25
25
  if (!(typeof e == "object" && e !== null && "type" in e && "streamId" in e && "timestamp" in e))
26
26
  return null;
27
27
  switch (e.type) {
28
28
  case "StreamTimeout":
29
- return te(e);
29
+ return re(e);
30
30
  case "StreamNotFound":
31
- return ne(e);
31
+ return oe(e);
32
32
  case "AgentTaskProgressItemUpdated":
33
- return re(e);
33
+ return ae(e);
34
34
  }
35
35
  return null;
36
- }, te = (e) => ({
36
+ }, re = (e) => ({
37
37
  type: "StreamTimeout",
38
38
  streamId: e.streamId,
39
39
  timestamp: e.timestamp
40
- }), ne = (e) => ({
40
+ }), oe = (e) => ({
41
41
  type: "StreamNotFound",
42
42
  streamId: e.streamId,
43
43
  timestamp: e.timestamp
44
- }), re = (e) => ({
44
+ }), ae = (e) => ({
45
45
  type: "AgentTaskProgressItemUpdated",
46
46
  streamId: e.streamId,
47
47
  agentTaskId: e.agentTaskId,
@@ -49,52 +49,52 @@ const Z = (e) => {
49
49
  timestamp: e.timestamp,
50
50
  createdAt: e.createdAt,
51
51
  data: JSON.parse(e.data)
52
- }), ae = (e) => {
53
- const t = M(), [n, r] = x(null), a = I(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
54
- return w(() => {
52
+ }), ie = (e) => {
53
+ const t = N(), [n, r] = C(null), o = E(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
54
+ return p(() => {
55
55
  if (!t.eventManager) return;
56
- const c = {
57
- onMessage: (g, i) => {
58
- var d, u, b, y, S, f, h, k, P, A;
59
- const s = Z(g);
60
- if (s)
61
- switch (s.type) {
56
+ const d = {
57
+ onMessage: (c, a) => {
58
+ var u, m, T, y, S, f, h, k, A, w;
59
+ const l = te(c);
60
+ if (l)
61
+ switch (l.type) {
62
62
  case "NewChatCompletionStreamChunk":
63
- (d = e == null ? void 0 : e.onNewChatCompletionStreamChunk) == null || d.call(e, s);
63
+ (u = e == null ? void 0 : e.onNewChatCompletionStreamChunk) == null || u.call(e, l);
64
64
  break;
65
65
  case "ChatCompletionStreamCompleted":
66
- (u = e == null ? void 0 : e.onChatCompletionStreamCompleted) == null || u.call(e, s);
66
+ (m = e == null ? void 0 : e.onChatCompletionStreamCompleted) == null || m.call(e, l);
67
67
  break;
68
68
  case "StreamTimeout":
69
- (b = e == null ? void 0 : e.onStreamTimeout) == null || b.call(e, s);
69
+ (T = e == null ? void 0 : e.onStreamTimeout) == null || T.call(e, l);
70
70
  break;
71
71
  case "StreamNotFound":
72
- (y = e == null ? void 0 : e.onStreamNotFound) == null || y.call(e, s);
72
+ (y = e == null ? void 0 : e.onStreamNotFound) == null || y.call(e, l);
73
73
  break;
74
74
  case "FileUploadCompleted":
75
- (S = e == null ? void 0 : e.onFileUploadCompleted) == null || S.call(e, s);
75
+ (S = e == null ? void 0 : e.onFileUploadCompleted) == null || S.call(e, l);
76
76
  break;
77
77
  case "FileTextContentReady":
78
- (f = e == null ? void 0 : e.onFileTextContentReady) == null || f.call(e, s);
78
+ (f = e == null ? void 0 : e.onFileTextContentReady) == null || f.call(e, l);
79
79
  break;
80
80
  case "WebsiteHtmlContentReady":
81
- (h = e == null ? void 0 : e.onWebsiteHtmlContentReady) == null || h.call(e, s);
81
+ (h = e == null ? void 0 : e.onWebsiteHtmlContentReady) == null || h.call(e, l);
82
82
  break;
83
83
  case "WebsiteTextContentReady":
84
- (k = e == null ? void 0 : e.onWebsiteTextContentReady) == null || k.call(e, s);
84
+ (k = e == null ? void 0 : e.onWebsiteTextContentReady) == null || k.call(e, l);
85
85
  break;
86
86
  case "FileSearchIndexReady":
87
- (P = e == null ? void 0 : e.onFileSearchIndexReady) == null || P.call(e, s);
87
+ (A = e == null ? void 0 : e.onFileSearchIndexReady) == null || A.call(e, l);
88
88
  break;
89
89
  case "AgentTaskProgressItemUpdated":
90
- (A = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || A.call(e, s);
90
+ (w = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || w.call(e, l);
91
91
  break;
92
92
  }
93
93
  },
94
- onError: (g) => {
95
- var i;
96
- (i = e == null ? void 0 : e.onStreamError) == null || i.call(e, {
97
- streamId: g,
94
+ onError: (c) => {
95
+ var a;
96
+ (a = e == null ? void 0 : e.onStreamError) == null || a.call(e, {
97
+ streamId: c,
98
98
  error: {
99
99
  code: "UnknownError",
100
100
  message: "Unknown error in useStream"
@@ -103,124 +103,125 @@ const Z = (e) => {
103
103
  }
104
104
  };
105
105
  return t.eventManager.subscribe(
106
- a.current,
107
- c
106
+ o.current,
107
+ d
108
108
  );
109
109
  }, [t.eventManager, e]), {
110
110
  createStream: async () => {
111
111
  try {
112
- const c = await t.getOrCreateStream(3e4);
113
- return r(c), {
112
+ const d = await t.getOrCreateStream(3e4);
113
+ return r(d), {
114
114
  type: "success",
115
- stream: c
115
+ stream: d
116
116
  };
117
- } catch (c) {
117
+ } catch (d) {
118
118
  return {
119
119
  type: "error",
120
120
  error: {
121
121
  code: "UnknownError",
122
- message: c instanceof Error ? c.message : "Failed to create stream"
122
+ message: d instanceof Error ? d.message : "Failed to create stream"
123
123
  }
124
124
  };
125
125
  }
126
126
  },
127
127
  stream: n
128
128
  };
129
- }, Oe = (e) => {
130
- const t = M(), [n, r] = x([]), a = I(/* @__PURE__ */ new Set()), m = I(/* @__PURE__ */ new Map()), { createStream: c } = ae({
131
- onAgentTaskProgressItemUpdated: (i) => {
132
- var u;
133
- if (!a.current.has(i.agentTaskId)) return;
134
- const s = i.data;
135
- if (s.type === "GenericAgentTaskCompleted" || s.type === "StreamingChatCompletionCompleted" || s.type === "StructuredChatCompletionCompleted") {
136
- const b = m.current.get(i.agentTaskId);
137
- b && (m.current.delete(i.agentTaskId), b(s));
129
+ }, Be = (e) => {
130
+ const t = N(), [n, r] = C([]), o = E(/* @__PURE__ */ new Set()), g = E(/* @__PURE__ */ new Map()), { createStream: d } = ie({
131
+ onAgentTaskProgressItemUpdated: (a) => {
132
+ var m;
133
+ if (!o.current.has(a.agentTaskId)) return;
134
+ const l = a.data;
135
+ if (l.taskType === "GenericAgentTask" && l.eventType === "Completed" || l.taskType === "StreamingChatCompletion" && l.eventType === "Completed" || l.taskType === "StructuredChatCompletion" && l.eventType === "Completed" || l.taskType === "StreamingMemoryTypeChatCompletion" && l.eventType === "Completed") {
136
+ const T = g.current.get(a.agentTaskId);
137
+ T && (g.current.delete(a.agentTaskId), T(l));
138
138
  return;
139
139
  }
140
- (u = e.onAgentTaskProgressItemUpdated) == null || u.call(e, i), r(
141
- (b) => b.map((y) => {
140
+ (m = e.onAgentTaskProgressItemUpdated) == null || m.call(e, a), r(
141
+ (T) => T.map((y) => {
142
142
  var h;
143
- if (((h = y.confirmedData) == null ? void 0 : h.taskId) !== i.agentTaskId) return y;
143
+ if (((h = y.confirmedData) == null ? void 0 : h.taskId) !== a.agentTaskId) return y;
144
144
  const f = y.progressItems.some(
145
- (k) => k.progressItemId === i.progressItemId
145
+ (k) => k.progressItemId === a.progressItemId
146
146
  ) ? y.progressItems.map(
147
- (k) => k.progressItemId === i.progressItemId ? i : k
148
- ) : [...y.progressItems, i];
147
+ (k) => k.progressItemId === a.progressItemId ? a : k
148
+ ) : [...y.progressItems, a];
149
149
  return { ...y, progressItems: f };
150
150
  })
151
151
  );
152
152
  },
153
- onStreamError: (i) => {
154
- var s;
155
- (s = e == null ? void 0 : e.onStreamError) == null || s.call(e, i), r((d) => {
156
- const u = d.find((b) => b.streamId === i.streamId);
157
- return u ? [
158
- ...d.filter((b) => b.streamId !== i.streamId),
153
+ onStreamError: (a) => {
154
+ var l;
155
+ (l = e == null ? void 0 : e.onStreamError) == null || l.call(e, a), r((u) => {
156
+ const m = u.find((T) => T.streamId === a.streamId);
157
+ return m ? [
158
+ ...u.filter((T) => T.streamId !== a.streamId),
159
159
  {
160
- ...u,
160
+ ...m,
161
161
  loading: !1,
162
- error: i.error
162
+ error: a.error
163
163
  }
164
- ] : d;
164
+ ] : u;
165
165
  });
166
166
  },
167
- onStreamNotFound: (i) => {
168
- var s;
169
- (s = e == null ? void 0 : e.onStreamNotFound) == null || s.call(e, i);
167
+ onStreamNotFound: (a) => {
168
+ var l;
169
+ (l = e == null ? void 0 : e.onStreamNotFound) == null || l.call(e, a);
170
170
  },
171
- onStreamTimeout: (i) => {
172
- var s;
173
- (s = e == null ? void 0 : e.onStreamTimeout) == null || s.call(e, i);
171
+ onStreamTimeout: (a) => {
172
+ var l;
173
+ (l = e == null ? void 0 : e.onStreamTimeout) == null || l.call(e, a);
174
174
  }
175
- }), o = U(
176
- async (i, s) => {
177
- const d = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, u = await c();
178
- if (u.type === "success") {
175
+ }), s = U(
176
+ async (a, l) => {
177
+ const u = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, m = await d();
178
+ if (m.type === "success") {
179
179
  r([
180
180
  ...n,
181
181
  {
182
- taskKey: d,
183
- streamId: u.stream.id,
182
+ taskKey: u,
183
+ streamId: m.stream.id,
184
184
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
185
185
  confirmedData: null,
186
186
  error: null,
187
- params: i,
187
+ params: a,
188
188
  progressItems: [],
189
189
  loading: !0,
190
190
  doneStreaming: !1,
191
- loadingText: s == null ? void 0 : s.loadingText
191
+ loadingText: l == null ? void 0 : l.loadingText
192
192
  }
193
193
  ]);
194
- const { clientToken: b } = await e.fetchCreateAgentTaskClientToken(i.type), y = await q({
194
+ const { clientToken: T } = await e.fetchCreateAgentTaskClientToken(a.type), y = await J({
195
195
  pk: t.fency.publishableKey,
196
196
  baseUrl: t.fency.baseUrl,
197
- clientToken: b,
198
- streamToken: u.stream.token,
197
+ clientToken: T,
198
+ streamToken: m.stream.token,
199
199
  request: {
200
- genericTask: i.type === "genericAgentTask" ? { query: i.query, jsonSchema: i.jsonSchema } : void 0,
201
- streamingChatCompletionTask: i.type === "streamingChatCompletion" ? { messages: i.messages, model: i.model } : void 0,
202
- structuredChatCompletionTask: i.type === "structuredChatCompletion" ? { messages: i.messages, jsonSchema: i.jsonSchema, model: i.model } : void 0
200
+ genericTask: a.type === "genericAgentTask" ? { query: a.query, jsonSchema: a.jsonSchema } : void 0,
201
+ streamingChatCompletionTask: a.type === "streamingChatCompletion" ? { messages: a.messages, model: a.model } : void 0,
202
+ structuredChatCompletionTask: a.type === "structuredChatCompletion" ? { messages: a.messages, jsonSchema: a.jsonSchema, model: a.model } : void 0,
203
+ streamingMemoryTypeChatCompletionTask: a.type === "streamingMemoryTypeChatCompletion" ? { messages: a.messages, model: a.model } : void 0
203
204
  }
204
205
  });
205
206
  if (y.type === "success" && y.agentTask) {
206
- a.current.add(
207
+ o.current.add(
207
208
  y.agentTask.id
208
209
  ), r((f) => [
209
210
  ...f.filter(
210
- (h) => h.taskKey !== d
211
+ (h) => h.taskKey !== u
211
212
  ),
212
213
  {
213
- taskKey: d,
214
- streamId: u.stream.id,
214
+ taskKey: u,
215
+ streamId: m.stream.id,
215
216
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
216
217
  taskId: y.agentTask.id,
217
218
  createdAt: y.agentTask.createdAt,
218
219
  error: null,
219
- params: i,
220
+ params: a,
220
221
  progressItems: [],
221
222
  doneStreaming: !1,
222
223
  loading: !0,
223
- loadingText: s == null ? void 0 : s.loadingText,
224
+ loadingText: l == null ? void 0 : l.loadingText,
224
225
  confirmedData: {
225
226
  taskId: y.agentTask.id,
226
227
  createdAt: y.agentTask.createdAt
@@ -229,7 +230,7 @@ const Z = (e) => {
229
230
  ]);
230
231
  const S = await new Promise(
231
232
  (f) => {
232
- m.current.set(
233
+ g.current.set(
233
234
  y.agentTask.id,
234
235
  f
235
236
  );
@@ -237,7 +238,7 @@ const Z = (e) => {
237
238
  );
238
239
  return {
239
240
  type: "success",
240
- streamId: u.stream.id,
241
+ streamId: m.stream.id,
241
242
  agentTaskId: y.agentTask.id,
242
243
  response: S
243
244
  };
@@ -245,18 +246,18 @@ const Z = (e) => {
245
246
  if (y.type === "error")
246
247
  return r((S) => [
247
248
  ...S.filter(
248
- (f) => f.taskKey !== d
249
+ (f) => f.taskKey !== u
249
250
  ),
250
251
  {
251
- taskKey: d,
252
+ taskKey: u,
252
253
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
253
- streamId: u.stream.id,
254
- params: i,
254
+ streamId: m.stream.id,
255
+ params: a,
255
256
  error: y.error,
256
257
  progressItems: [],
257
258
  loading: !1,
258
259
  doneStreaming: !1,
259
- loadingText: s == null ? void 0 : s.loadingText,
260
+ loadingText: l == null ? void 0 : l.loadingText,
260
261
  confirmedData: null
261
262
  }
262
263
  ]), {
@@ -270,18 +271,18 @@ const Z = (e) => {
270
271
  };
271
272
  return r((f) => [
272
273
  ...f.filter(
273
- (h) => h.taskKey !== d
274
+ (h) => h.taskKey !== u
274
275
  ),
275
276
  {
276
- taskKey: d,
277
+ taskKey: u,
277
278
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
278
- streamId: u.stream.id,
279
+ streamId: m.stream.id,
279
280
  error: S,
280
- params: i,
281
+ params: a,
281
282
  progressItems: [],
282
283
  loading: !1,
283
284
  doneStreaming: !1,
284
- loadingText: s == null ? void 0 : s.loadingText,
285
+ loadingText: l == null ? void 0 : l.loadingText,
285
286
  confirmedData: null
286
287
  }
287
288
  ]), {
@@ -291,86 +292,86 @@ const Z = (e) => {
291
292
  }
292
293
  }
293
294
  } else
294
- return console.error(u.error), u;
295
+ return console.error(m.error), m;
295
296
  },
296
- [t, n, c]
297
- ), g = j(() => {
297
+ [t, n, d]
298
+ ), c = j(() => {
298
299
  if (n.length !== 0)
299
- return [...n].sort((i, s) => new Date(s.triggeredAt).getTime() - new Date(i.triggeredAt).getTime())[0];
300
+ return [...n].sort((a, l) => new Date(l.triggeredAt).getTime() - new Date(a.triggeredAt).getTime())[0];
300
301
  }, [n]);
301
- return w(() => () => {
302
- a.current.clear(), m.current.clear();
302
+ return p(() => () => {
303
+ o.current.clear(), g.current.clear();
303
304
  }, []), {
304
305
  agentTasks: n,
305
- createAgentTask: o,
306
- latest: g
306
+ createAgentTask: s,
307
+ latest: c
307
308
  };
308
309
  };
309
- async function oe(e, t) {
310
+ async function se(e, t) {
310
311
  const n = e.getReader();
311
312
  let r;
312
313
  for (; !(r = await n.read()).done; )
313
314
  t(r.value);
314
315
  }
315
- function ie(e) {
316
- let t, n, r, a = !1;
317
- return function(c) {
318
- t === void 0 ? (t = c, n = 0, r = -1) : t = ce(t, c);
319
- const o = t.length;
320
- let g = 0;
321
- for (; n < o; ) {
322
- a && (t[n] === 10 && (g = ++n), a = !1);
323
- let i = -1;
324
- for (; n < o && i === -1; ++n)
316
+ function ce(e) {
317
+ let t, n, r, o = !1;
318
+ return function(d) {
319
+ t === void 0 ? (t = d, n = 0, r = -1) : t = de(t, d);
320
+ const s = t.length;
321
+ let c = 0;
322
+ for (; n < s; ) {
323
+ o && (t[n] === 10 && (c = ++n), o = !1);
324
+ let a = -1;
325
+ for (; n < s && a === -1; ++n)
325
326
  switch (t[n]) {
326
327
  case 58:
327
- r === -1 && (r = n - g);
328
+ r === -1 && (r = n - c);
328
329
  break;
329
330
  case 13:
330
- a = !0;
331
+ o = !0;
331
332
  case 10:
332
- i = n;
333
+ a = n;
333
334
  break;
334
335
  }
335
- if (i === -1)
336
+ if (a === -1)
336
337
  break;
337
- e(t.subarray(g, i), r), g = n, r = -1;
338
+ e(t.subarray(c, a), r), c = n, r = -1;
338
339
  }
339
- g === o ? t = void 0 : g !== 0 && (t = t.subarray(g), n -= g);
340
+ c === s ? t = void 0 : c !== 0 && (t = t.subarray(c), n -= c);
340
341
  };
341
342
  }
342
- function se(e, t, n) {
343
- let r = L();
344
- const a = new TextDecoder();
345
- return function(c, o) {
346
- if (c.length === 0)
347
- n == null || n(r), r = L();
348
- else if (o > 0) {
349
- const g = a.decode(c.subarray(0, o)), i = o + (c[o + 1] === 32 ? 2 : 1), s = a.decode(c.subarray(i));
350
- switch (g) {
343
+ function le(e, t, n) {
344
+ let r = $();
345
+ const o = new TextDecoder();
346
+ return function(d, s) {
347
+ if (d.length === 0)
348
+ n == null || n(r), r = $();
349
+ else if (s > 0) {
350
+ const c = o.decode(d.subarray(0, s)), a = s + (d[s + 1] === 32 ? 2 : 1), l = o.decode(d.subarray(a));
351
+ switch (c) {
351
352
  case "data":
352
353
  r.data = r.data ? r.data + `
353
- ` + s : s;
354
+ ` + l : l;
354
355
  break;
355
356
  case "event":
356
- r.event = s;
357
+ r.event = l;
357
358
  break;
358
359
  case "id":
359
- e(r.id = s);
360
+ e(r.id = l);
360
361
  break;
361
362
  case "retry":
362
- const d = parseInt(s, 10);
363
- isNaN(d) || t(r.retry = d);
363
+ const u = parseInt(l, 10);
364
+ isNaN(u) || t(r.retry = u);
364
365
  break;
365
366
  }
366
367
  }
367
368
  };
368
369
  }
369
- function ce(e, t) {
370
+ function de(e, t) {
370
371
  const n = new Uint8Array(e.length + t.length);
371
372
  return n.set(e), n.set(t, e.length), n;
372
373
  }
373
- function L() {
374
+ function $() {
374
375
  return {
375
376
  data: "",
376
377
  event: "",
@@ -378,82 +379,82 @@ function L() {
378
379
  retry: void 0
379
380
  };
380
381
  }
381
- var le = function(e, t) {
382
+ var ue = function(e, t) {
382
383
  var n = {};
383
384
  for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
384
385
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
385
- for (var a = 0, r = Object.getOwnPropertySymbols(e); a < r.length; a++)
386
- t.indexOf(r[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[a]) && (n[r[a]] = e[r[a]]);
386
+ for (var o = 0, r = Object.getOwnPropertySymbols(e); o < r.length; o++)
387
+ t.indexOf(r[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[o]) && (n[r[o]] = e[r[o]]);
387
388
  return n;
388
389
  };
389
- const D = "text/event-stream", de = 1e3, _ = "last-event-id";
390
- function H(e, t) {
391
- var { signal: n, headers: r, onopen: a, onmessage: m, onclose: c, onerror: o, openWhenHidden: g, fetch: i } = t, s = le(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
392
- return new Promise((d, u) => {
393
- const b = Object.assign({}, r);
394
- b.accept || (b.accept = D);
390
+ const O = "text/event-stream", me = 1e3, W = "last-event-id";
391
+ function K(e, t) {
392
+ var { signal: n, headers: r, onopen: o, onmessage: g, onclose: d, onerror: s, openWhenHidden: c, fetch: a } = t, l = ue(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
393
+ return new Promise((u, m) => {
394
+ const T = Object.assign({}, r);
395
+ T.accept || (T.accept = O);
395
396
  let y;
396
397
  function S() {
397
- y.abort(), document.hidden || E();
398
+ y.abort(), document.hidden || I();
398
399
  }
399
- g || document.addEventListener("visibilitychange", S);
400
- let f = de, h = 0;
400
+ c || document.addEventListener("visibilitychange", S);
401
+ let f = me, h = 0;
401
402
  function k() {
402
403
  document.removeEventListener("visibilitychange", S), window.clearTimeout(h), y.abort();
403
404
  }
404
405
  n == null || n.addEventListener("abort", () => {
405
- k(), d();
406
+ k(), u();
406
407
  });
407
- const P = i ?? window.fetch, A = a ?? ue;
408
- async function E() {
409
- var F;
408
+ const A = a ?? window.fetch, w = o ?? ge;
409
+ async function I() {
410
+ var R;
410
411
  y = new AbortController();
411
412
  try {
412
- const p = await P(e, Object.assign(Object.assign({}, s), { headers: b, signal: y.signal }));
413
- await A(p), await oe(p.body, ie(se((v) => {
414
- v ? b[_] = v : delete b[_];
415
- }, (v) => {
416
- f = v;
417
- }, m))), c == null || c(), k(), d();
418
- } catch (p) {
413
+ const P = await A(e, Object.assign(Object.assign({}, l), { headers: T, signal: y.signal }));
414
+ await w(P), await se(P.body, ce(le((x) => {
415
+ x ? T[W] = x : delete T[W];
416
+ }, (x) => {
417
+ f = x;
418
+ }, g))), d == null || d(), k(), u();
419
+ } catch (P) {
419
420
  if (!y.signal.aborted)
420
421
  try {
421
- const v = (F = o == null ? void 0 : o(p)) !== null && F !== void 0 ? F : f;
422
- window.clearTimeout(h), h = window.setTimeout(E, v);
423
- } catch (v) {
424
- k(), u(v);
422
+ const x = (R = s == null ? void 0 : s(P)) !== null && R !== void 0 ? R : f;
423
+ window.clearTimeout(h), h = window.setTimeout(I, x);
424
+ } catch (x) {
425
+ k(), m(x);
425
426
  }
426
427
  }
427
428
  }
428
- E();
429
+ I();
429
430
  });
430
431
  }
431
- function ue(e) {
432
+ function ge(e) {
432
433
  const t = e.headers.get("content-type");
433
- if (!(t != null && t.startsWith(D)))
434
- throw new Error(`Expected content-type to be ${D}, Actual: ${t}`);
434
+ if (!(t != null && t.startsWith(O)))
435
+ throw new Error(`Expected content-type to be ${O}, Actual: ${t}`);
435
436
  }
436
- function De(e) {
437
- const [t, n] = x(null);
438
- return w(() => {
437
+ function _e(e) {
438
+ const [t, n] = C(null);
439
+ return p(() => {
439
440
  if (!t)
440
441
  return;
441
442
  const r = new AbortController();
442
- return H(t, {
443
+ return K(t, {
443
444
  headers: e == null ? void 0 : e.headers,
444
445
  signal: r.signal,
445
- async onopen(a) {
446
- if (!a.ok && a.status >= 400 && a.status < 500 && a.status !== 429)
447
- throw new Error(`Client error ${a.status}`);
446
+ async onopen(o) {
447
+ if (!o.ok && o.status >= 400 && o.status < 500 && o.status !== 429)
448
+ throw new Error(`Client error ${o.status}`);
448
449
  },
449
- onmessage(a) {
450
- a.data && (e == null || e.onMessage({
450
+ onmessage(o) {
451
+ o.data && (e == null || e.onMessage({
451
452
  url: t,
452
- data: K(a.data)
453
+ data: q(o.data)
453
454
  }));
454
455
  },
455
- onerror(a) {
456
- throw console.error("EventSource error:", a), e == null || e.onError(t), n(null), a;
456
+ onerror(o) {
457
+ throw console.error("EventSource error:", o), e == null || e.onError(t), n(null), o;
457
458
  },
458
459
  onclose() {
459
460
  }
@@ -465,22 +466,22 @@ function De(e) {
465
466
  sourceUrl: t
466
467
  };
467
468
  }
468
- function K(e) {
469
+ function q(e) {
469
470
  const t = atob(e), n = new Uint8Array(t.length);
470
471
  for (let r = 0; r < t.length; r++)
471
472
  n[r] = t.charCodeAt(r);
472
473
  return new TextDecoder("utf-8").decode(n);
473
474
  }
474
- function Ue(e, t) {
475
- const [n, r] = x(
475
+ function je(e, t) {
476
+ const [n, r] = C(
476
477
  null
477
- ), [a, m] = x(
478
+ ), [o, g] = C(
478
479
  null
479
- ), c = M(), o = async (d) => {
480
- const u = await d.fetchTokens(), { fetchTokens: b, nextPageToken: y, previousPageToken: S, ...f } = d, h = await e({
481
- pk: c.fency.publishableKey,
482
- clientToken: u.clientToken,
483
- streamToken: u.streamToken,
480
+ ), d = N(), s = async (u) => {
481
+ const m = await u.fetchTokens(), { fetchTokens: T, nextPageToken: y, previousPageToken: S, ...f } = u, h = await e({
482
+ pk: d.fency.publishableKey,
483
+ clientToken: m.clientToken,
484
+ streamToken: m.streamToken,
484
485
  request: {
485
486
  ...f,
486
487
  limit: (t == null ? void 0 : t.pageSize) ?? 50,
@@ -489,7 +490,7 @@ function Ue(e, t) {
489
490
  previousPageToken: S
490
491
  }
491
492
  },
492
- baseUrl: c.fency.baseUrl
493
+ baseUrl: d.fency.baseUrl
493
494
  });
494
495
  return h.type === "success" && h.items && h.pagination ? {
495
496
  type: "success",
@@ -508,16 +509,16 @@ function Ue(e, t) {
508
509
  };
509
510
  };
510
511
  return {
511
- fetchFirstPage: async (d) => {
512
- const u = await o({
513
- ...d,
512
+ fetchFirstPage: async (u) => {
513
+ const m = await s({
514
+ ...u,
514
515
  nextPageToken: void 0,
515
516
  previousPageToken: void 0
516
517
  });
517
- return u.type === "success" && (m(u.page), r(d)), u;
518
+ return m.type === "success" && (g(m.page), r(u)), m;
518
519
  },
519
- fetchNextPage: async (d) => {
520
- if (a == null)
520
+ fetchNextPage: async (u) => {
521
+ if (o == null)
521
522
  return {
522
523
  type: "error",
523
524
  error: {
@@ -525,7 +526,7 @@ function Ue(e, t) {
525
526
  message: "No current page"
526
527
  }
527
528
  };
528
- if (a.pagination.nextPageToken == null)
529
+ if (o.pagination.nextPageToken == null)
529
530
  return {
530
531
  type: "error",
531
532
  error: {
@@ -533,15 +534,15 @@ function Ue(e, t) {
533
534
  message: "No next page"
534
535
  }
535
536
  };
536
- const u = await o({
537
- ...d,
538
- nextPageToken: a.pagination.nextPageToken,
537
+ const m = await s({
538
+ ...u,
539
+ nextPageToken: o.pagination.nextPageToken,
539
540
  previousPageToken: void 0
540
541
  });
541
- return u.type === "success" && (m(u.page), r(d)), u;
542
+ return m.type === "success" && (g(m.page), r(u)), m;
542
543
  },
543
- fetchPreviousPage: async (d) => {
544
- if (a == null)
544
+ fetchPreviousPage: async (u) => {
545
+ if (o == null)
545
546
  return {
546
547
  type: "error",
547
548
  error: {
@@ -549,7 +550,7 @@ function Ue(e, t) {
549
550
  message: "No current page"
550
551
  }
551
552
  };
552
- if (a.pagination.previousPageToken == null)
553
+ if (o.pagination.previousPageToken == null)
553
554
  return {
554
555
  type: "error",
555
556
  error: {
@@ -557,12 +558,12 @@ function Ue(e, t) {
557
558
  message: "No previous page"
558
559
  }
559
560
  };
560
- const u = await o({
561
- ...d,
561
+ const m = await s({
562
+ ...u,
562
563
  nextPageToken: void 0,
563
- previousPageToken: a.pagination.previousPageToken
564
+ previousPageToken: o.pagination.previousPageToken
564
565
  });
565
- return u.type === "success" && (m(u.page), r(d)), u;
566
+ return m.type === "success" && (g(m.page), r(u)), m;
566
567
  },
567
568
  refetchCurrentPage: async () => n == null ? {
568
569
  type: "error",
@@ -570,47 +571,47 @@ function Ue(e, t) {
570
571
  code: "NO_CURRENT_PAGE",
571
572
  message: "No current page, please call fetchFirstPage first."
572
573
  }
573
- } : o(n),
574
- currentPage: a
574
+ } : s(n),
575
+ currentPage: o
575
576
  };
576
577
  }
577
- function me(e) {
578
+ function ye(e) {
578
579
  return e.progressItems.map((t, n) => {
579
- const r = e.progressItems[n + 1], a = r != null;
580
- let m;
580
+ const r = e.progressItems[n + 1], o = r != null;
581
+ let g;
581
582
  if (r != null && r.createdAt) {
582
- const c = new Date(t.createdAt).getTime(), o = new Date(r.createdAt).getTime();
583
- m = Math.round((o - c) / 1e3);
583
+ const d = new Date(t.createdAt).getTime(), s = new Date(r.createdAt).getTime();
584
+ g = Math.round((s - d) / 1e3);
584
585
  }
585
586
  return {
586
587
  item: t,
587
- completed: a,
588
+ completed: o,
588
589
  isLatest: n === e.progressItems.length - 1,
589
- durationSeconds: m
590
+ durationSeconds: g
590
591
  };
591
592
  });
592
593
  }
593
- function N({
594
+ function M({
594
595
  text: e,
595
596
  duration: t = 2,
596
597
  delay: n = 0,
597
598
  repeat: r = !0,
598
- repeatDelay: a = 0.5,
599
- className: m,
600
- startOnView: c = !1,
601
- once: o = !1,
602
- inViewMargin: g,
603
- spread: i = 2,
604
- color: s = "#999",
605
- shimmerColor: d = "#000",
606
- direction: u = "fromBottom"
599
+ repeatDelay: o = 0.5,
600
+ className: g,
601
+ startOnView: d = !1,
602
+ once: s = !1,
603
+ inViewMargin: c,
604
+ spread: a = 2,
605
+ color: l = "#999",
606
+ shimmerColor: u = "#000",
607
+ direction: m = "fromBottom"
607
608
  }) {
608
- const b = I(null), y = Y(b, { once: o, margin: g }), S = j(() => e.length * i, [e, i]), f = !c || y, h = u === "fromBottom" ? "100% center" : "-100% center", k = u === "fromBottom" ? "0% center" : "200% center";
609
- return /* @__PURE__ */ l(
610
- T.span,
609
+ const T = E(null), y = ee(T, { once: s, margin: c }), S = j(() => e.length * a, [e, a]), f = !d || y, h = m === "fromBottom" ? "100% center" : "-100% center", k = m === "fromBottom" ? "0% center" : "200% center";
610
+ return /* @__PURE__ */ i(
611
+ v.span,
611
612
  {
612
- ref: b,
613
- className: m,
613
+ ref: T,
614
+ className: g,
614
615
  style: {
615
616
  position: "relative",
616
617
  display: "inline-block",
@@ -621,8 +622,8 @@ function N({
621
622
  WebkitTextFillColor: "transparent",
622
623
  backgroundRepeat: "no-repeat, padding-box",
623
624
  "--spread": `${S}px`,
624
- "--base-color": s,
625
- "--shimmer-color": d,
625
+ "--base-color": l,
626
+ "--shimmer-color": u,
626
627
  "--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
627
628
  backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
628
629
  },
@@ -639,7 +640,7 @@ function N({
639
640
  repeat: r ? 1 / 0 : 0,
640
641
  duration: t,
641
642
  delay: n,
642
- repeatDelay: a,
643
+ repeatDelay: o,
643
644
  ease: "linear"
644
645
  },
645
646
  opacity: {
@@ -651,57 +652,67 @@ function N({
651
652
  }
652
653
  );
653
654
  }
654
- function ge(e) {
655
+ function fe(e) {
655
656
  const t = e.item.data;
656
- switch (t.type) {
657
- case "GenericAgentTaskExecution":
658
- return t.title;
659
- case "GenericAgentTaskReasoning":
660
- return t.title;
661
- case "GenericAgentTaskFinalResponse":
662
- return "Generating answer...";
663
- case "GenericAgentTaskCompleted":
664
- return "Completed";
665
- case "StreamingChatCompletionText":
666
- return "Streaming...";
667
- case "StructuredChatCompletionJson":
668
- return "Generating...";
669
- case "StreamingMemoryTypeChatCompletionText":
670
- return "Streaming...";
671
- case "StreamingMemoryTypeChatCompletionSearch":
672
- return "Searching...";
673
- case "StreamingMemoryTypeChatCompletionFindSources":
674
- return "Finding sources...";
675
- case "StreamingMemoryTypeChatCompletionSourcesResult":
676
- return "Sources found...";
677
- case "StreamingMemoryTypeChatCompletionCompleted":
678
- return "Completed";
679
- case "StreamingChatCompletionCompleted":
680
- return "Completed";
681
- case "StructuredChatCompletionCompleted":
682
- return "Completed";
657
+ if (t.taskType === "GenericAgentTask")
658
+ switch (t.eventType) {
659
+ case "Execution":
660
+ case "Reasoning":
661
+ return t.title;
662
+ case "FinalResponse":
663
+ return "Generating answer...";
664
+ case "Completed":
665
+ return "Completed";
666
+ }
667
+ if (t.taskType === "StreamingChatCompletion") {
668
+ if (t.eventType === "Text") return "Streaming...";
669
+ if (t.eventType === "Completed") return "Completed";
683
670
  }
671
+ if (t.taskType === "StructuredChatCompletion") {
672
+ if (t.eventType === "Json") return "Generating...";
673
+ if (t.eventType === "Completed") return "Completed";
674
+ }
675
+ if (t.taskType === "StreamingMemoryTypeChatCompletion")
676
+ switch (t.eventType) {
677
+ case "Text":
678
+ return "Streaming...";
679
+ case "Search":
680
+ return "Searching...";
681
+ case "FindSources":
682
+ return "Adding sources...";
683
+ case "SourcesResult":
684
+ return "Sources added...";
685
+ case "ExploreMemoryStart":
686
+ return "Exploring memory...";
687
+ case "ExploreMemoryResult":
688
+ return "Memory explored";
689
+ case "ExploreMemoryError":
690
+ return "Memory exploration failed";
691
+ case "Completed":
692
+ return "Completed";
693
+ }
694
+ return "Processing...";
684
695
  }
685
- const ye = ({ progressViewItems: e }) => {
696
+ const he = ({ progressViewItems: e }) => {
686
697
  const t = e[e.length - 1];
687
698
  if (!t) return null;
688
- const n = ge(t);
689
- return /* @__PURE__ */ l("div", { className: "simple-mode-container", children: /* @__PURE__ */ l(W, { mode: "wait", children: /* @__PURE__ */ l(
690
- T.div,
699
+ const n = fe(t);
700
+ return /* @__PURE__ */ i("div", { className: "simple-mode-container", children: /* @__PURE__ */ i(H, { mode: "wait", children: /* @__PURE__ */ i(
701
+ v.div,
691
702
  {
692
703
  initial: { opacity: 0, y: 10 },
693
704
  animate: { opacity: 1, y: 0 },
694
705
  exit: { opacity: 0, y: -10 },
695
706
  transition: { duration: 0.3 },
696
- children: t.completed ? /* @__PURE__ */ l(
707
+ children: t.completed ? /* @__PURE__ */ i(
697
708
  "div",
698
709
  {
699
710
  className: "simple-mode-title",
700
711
  style: { color: "#666" },
701
712
  children: n
702
713
  }
703
- ) : /* @__PURE__ */ l(
704
- N,
714
+ ) : /* @__PURE__ */ i(
715
+ M,
705
716
  {
706
717
  text: n,
707
718
  className: "simple-mode-title",
@@ -714,13 +725,13 @@ const ye = ({ progressViewItems: e }) => {
714
725
  },
715
726
  t.item.progressItemId
716
727
  ) }) });
717
- }, fe = ({
728
+ }, Te = ({
718
729
  data: e,
719
730
  isLatest: t = !1,
720
731
  durationSeconds: n
721
- }) => /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
722
- /* @__PURE__ */ l(
723
- T.div,
732
+ }) => /* @__PURE__ */ b("div", { style: { padding: "16px" }, children: [
733
+ /* @__PURE__ */ i(
734
+ v.div,
724
735
  {
725
736
  style: {
726
737
  display: "flex",
@@ -731,8 +742,8 @@ const ye = ({ progressViewItems: e }) => {
731
742
  initial: { opacity: 0, y: -10 },
732
743
  animate: { opacity: 1, y: 0 },
733
744
  transition: { duration: 0.3, delay: 0 },
734
- children: t && !n ? /* @__PURE__ */ l(
735
- N,
745
+ children: t && !n ? /* @__PURE__ */ i(
746
+ M,
736
747
  {
737
748
  text: e.title,
738
749
  duration: 2.5,
@@ -740,10 +751,10 @@ const ye = ({ progressViewItems: e }) => {
740
751
  color: "#999",
741
752
  shimmerColor: "#000"
742
753
  }
743
- ) : /* @__PURE__ */ l("span", { style: { color: "#666" }, children: e.title })
754
+ ) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: e.title })
744
755
  }
745
756
  ),
746
- n !== void 0 && /* @__PURE__ */ C(
757
+ n !== void 0 && /* @__PURE__ */ b(
747
758
  "div",
748
759
  {
749
760
  style: {
@@ -759,7 +770,7 @@ const ye = ({ progressViewItems: e }) => {
759
770
  ]
760
771
  }
761
772
  )
762
- ] }), O = {
773
+ ] }), D = {
763
774
  'code[class*="language-"]': {
764
775
  color: "#f8f8f2",
765
776
  background: "none",
@@ -910,70 +921,70 @@ const ye = ({ progressViewItems: e }) => {
910
921
  italic: {
911
922
  fontStyle: "italic"
912
923
  }
913
- }, he = ({
924
+ }, Se = ({
914
925
  data: e,
915
926
  streamToken: t,
916
927
  fetchClientToken: n,
917
928
  durationSeconds: r
918
929
  }) => {
919
- const { fency: a } = M(), m = U(
920
- async (c) => {
930
+ const { fency: o } = N(), g = U(
931
+ async (d) => {
921
932
  try {
922
- const { clientToken: o } = await n(), g = await J({
923
- pk: a.publishableKey,
924
- baseUrl: a.baseUrl,
925
- clientToken: o,
933
+ const { clientToken: s } = await n(), c = await V({
934
+ pk: o.publishableKey,
935
+ baseUrl: o.baseUrl,
936
+ clientToken: s,
926
937
  streamToken: t,
927
- request: { fileId: c }
938
+ request: { fileId: d }
928
939
  });
929
- g.type === "success" && window.open(g.downloadLink, "_blank");
930
- } catch (o) {
931
- console.error("Failed to download file:", o);
940
+ c.type === "success" && window.open(c.downloadLink, "_blank");
941
+ } catch (s) {
942
+ console.error("Failed to download file:", s);
932
943
  }
933
944
  },
934
- [a, t, n]
945
+ [o, t, n]
935
946
  );
936
- return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
937
- /* @__PURE__ */ l(
938
- T.div,
947
+ return /* @__PURE__ */ b("div", { style: { padding: "16px" }, children: [
948
+ /* @__PURE__ */ i(
949
+ v.div,
939
950
  {
940
951
  className: "fency-markdown-body-raw",
941
952
  initial: { opacity: 0, y: -10 },
942
953
  animate: { opacity: 1, y: 0 },
943
954
  transition: { duration: 0.3, delay: 0 },
944
- children: /* @__PURE__ */ l(
945
- B,
955
+ children: /* @__PURE__ */ i(
956
+ z,
946
957
  {
947
- remarkPlugins: [z],
958
+ remarkPlugins: [L],
948
959
  components: {
949
- code(c) {
950
- const { children: o, className: g, node: i, ref: s, ...d } = c, u = /language-(\w+)/.exec(g || "");
951
- return u ? /* @__PURE__ */ l(
952
- R,
960
+ code(d) {
961
+ const { children: s, className: c, node: a, ref: l, ...u } = d, m = /language-(\w+)/.exec(c || "");
962
+ return m ? /* @__PURE__ */ i(
963
+ F,
953
964
  {
954
- ...d,
965
+ ...u,
955
966
  PreTag: "div",
956
- children: String(o).replace(/\n$/, ""),
957
- language: u[1],
958
- style: O
967
+ children: String(s).replace(/\n$/, ""),
968
+ language: m[1],
969
+ style: D
959
970
  }
960
- ) : /* @__PURE__ */ l("code", { ...d, className: g, children: String(o) });
971
+ ) : /* @__PURE__ */ i("code", { ...u, className: c, children: String(s) });
961
972
  },
962
- a(c) {
963
- const { children: o, href: g, ...i } = c;
964
- return /* @__PURE__ */ l(
973
+ a(d) {
974
+ const { children: s, href: c, ...a } = d;
975
+ return /* @__PURE__ */ i(
965
976
  "a",
966
977
  {
967
- ...i,
968
- href: g,
969
- onClick: (s) => {
970
- if (!g) return;
971
- const d = g.match(
978
+ ...a,
979
+ href: c,
980
+ onClick: (l) => {
981
+ if (!c) return;
982
+ const u = c.match(
972
983
  /\/files\/(fil_[a-zA-Z0-9]+)\/download/
973
984
  );
974
- d && (s.preventDefault(), m(d[1]));
985
+ u && (l.preventDefault(), g(u[1]));
975
986
  },
976
- children: o
987
+ children: s
977
988
  }
978
989
  );
979
990
  }
@@ -983,7 +994,7 @@ const ye = ({ progressViewItems: e }) => {
983
994
  )
984
995
  }
985
996
  ),
986
- r !== void 0 && /* @__PURE__ */ C(
997
+ r !== void 0 && /* @__PURE__ */ b(
987
998
  "div",
988
999
  {
989
1000
  style: {
@@ -1000,25 +1011,25 @@ const ye = ({ progressViewItems: e }) => {
1000
1011
  }
1001
1012
  )
1002
1013
  ] });
1003
- }, be = ({
1014
+ }, ke = ({
1004
1015
  data: e,
1005
1016
  completed: t,
1006
1017
  isLatest: n = !1,
1007
1018
  durationSeconds: r
1008
1019
  }) => {
1009
- const a = I(null);
1010
- return w(() => {
1011
- a.current && !t && (a.current.scrollTop = a.current.scrollHeight);
1012
- }, [e.reasoning, t]), /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
1013
- /* @__PURE__ */ l(
1014
- T.h3,
1020
+ const o = E(null);
1021
+ return p(() => {
1022
+ o.current && !t && (o.current.scrollTop = o.current.scrollHeight);
1023
+ }, [e.reasoning, t]), /* @__PURE__ */ b("div", { style: { padding: "16px" }, children: [
1024
+ /* @__PURE__ */ i(
1025
+ v.h3,
1015
1026
  {
1016
1027
  style: { marginBottom: "10px", color: "#666" },
1017
1028
  initial: { opacity: 0, y: -10 },
1018
1029
  animate: { opacity: 1, y: 0 },
1019
1030
  transition: { duration: 0.3, delay: 0 },
1020
- children: n && !r ? /* @__PURE__ */ l(
1021
- N,
1031
+ children: n && !r ? /* @__PURE__ */ i(
1032
+ M,
1022
1033
  {
1023
1034
  text: e.title,
1024
1035
  duration: 2.5,
@@ -1029,10 +1040,10 @@ const ye = ({ progressViewItems: e }) => {
1029
1040
  ) : e.title
1030
1041
  }
1031
1042
  ),
1032
- /* @__PURE__ */ l(
1033
- T.div,
1043
+ /* @__PURE__ */ i(
1044
+ v.div,
1034
1045
  {
1035
- ref: a,
1046
+ ref: o,
1036
1047
  style: {
1037
1048
  maxHeight: "100px",
1038
1049
  overflowY: "auto",
@@ -1045,23 +1056,23 @@ const ye = ({ progressViewItems: e }) => {
1045
1056
  initial: { opacity: 0, y: -10 },
1046
1057
  animate: { opacity: 0.5, y: 0 },
1047
1058
  transition: { duration: 0.3, delay: 0.1 },
1048
- children: /* @__PURE__ */ l("div", { className: "fency-markdown-body-raw", children: /* @__PURE__ */ l(
1049
- B,
1059
+ children: /* @__PURE__ */ i("div", { className: "fency-markdown-body-raw", children: /* @__PURE__ */ i(
1060
+ z,
1050
1061
  {
1051
- remarkPlugins: [z],
1062
+ remarkPlugins: [L],
1052
1063
  components: {
1053
- code(m) {
1054
- const { children: c, className: o, node: g, ref: i, ...s } = m, d = /language-(\w+)/.exec(o || "");
1055
- return d ? /* @__PURE__ */ l(
1056
- R,
1064
+ code(g) {
1065
+ const { children: d, className: s, node: c, ref: a, ...l } = g, u = /language-(\w+)/.exec(s || "");
1066
+ return u ? /* @__PURE__ */ i(
1067
+ F,
1057
1068
  {
1058
- ...s,
1069
+ ...l,
1059
1070
  PreTag: "div",
1060
- children: String(c).replace(/\n$/, ""),
1061
- language: d[1],
1062
- style: O
1071
+ children: String(d).replace(/\n$/, ""),
1072
+ language: u[1],
1073
+ style: D
1063
1074
  }
1064
- ) : /* @__PURE__ */ l("code", { ...s, className: o, children: String(c) });
1075
+ ) : /* @__PURE__ */ i("code", { ...l, className: s, children: String(d) });
1065
1076
  }
1066
1077
  },
1067
1078
  children: e.reasoning
@@ -1069,7 +1080,7 @@ const ye = ({ progressViewItems: e }) => {
1069
1080
  ) })
1070
1081
  }
1071
1082
  ),
1072
- r !== void 0 && /* @__PURE__ */ C(
1083
+ r !== void 0 && /* @__PURE__ */ b(
1073
1084
  "div",
1074
1085
  {
1075
1086
  style: {
@@ -1086,54 +1097,54 @@ const ye = ({ progressViewItems: e }) => {
1086
1097
  }
1087
1098
  )
1088
1099
  ] });
1089
- }, G = ({
1100
+ }, B = ({
1090
1101
  text: e
1091
- }) => /* @__PURE__ */ l("div", { style: { padding: "16px" }, children: /* @__PURE__ */ l(
1092
- T.div,
1102
+ }) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
1103
+ v.div,
1093
1104
  {
1094
1105
  className: "fency-markdown-body-raw",
1095
1106
  initial: { opacity: 0, y: -10 },
1096
1107
  animate: { opacity: 1, y: 0 },
1097
1108
  transition: { duration: 0.3, delay: 0 },
1098
- children: /* @__PURE__ */ l(
1099
- B,
1109
+ children: /* @__PURE__ */ i(
1110
+ z,
1100
1111
  {
1101
- remarkPlugins: [z],
1112
+ remarkPlugins: [L],
1102
1113
  components: {
1103
1114
  code(t) {
1104
- const { children: n, className: r, node: a, ref: m, ...c } = t, o = /language-(\w+)/.exec(r || "");
1105
- return o ? /* @__PURE__ */ l(
1106
- R,
1115
+ const { children: n, className: r, node: o, ref: g, ...d } = t, s = /language-(\w+)/.exec(r || "");
1116
+ return s ? /* @__PURE__ */ i(
1117
+ F,
1107
1118
  {
1108
- ...c,
1119
+ ...d,
1109
1120
  PreTag: "div",
1110
1121
  children: String(n).replace(/\n$/, ""),
1111
- language: o[1],
1112
- style: O
1122
+ language: s[1],
1123
+ style: D
1113
1124
  }
1114
- ) : /* @__PURE__ */ l("code", { ...c, className: r, children: String(n) });
1125
+ ) : /* @__PURE__ */ i("code", { ...d, className: r, children: String(n) });
1115
1126
  }
1116
1127
  },
1117
1128
  children: e
1118
1129
  }
1119
1130
  )
1120
1131
  }
1121
- ) }), Se = ({ data: e }) => {
1132
+ ) }), be = ({ data: e }) => {
1122
1133
  const t = JSON.stringify(e.json, null, 2);
1123
- return /* @__PURE__ */ l("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ l(
1124
- T.div,
1134
+ return /* @__PURE__ */ i("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ i(
1135
+ v.div,
1125
1136
  {
1126
1137
  initial: { opacity: 0, y: -10 },
1127
1138
  animate: { opacity: 1, y: 0 },
1128
1139
  transition: { duration: 0.3, delay: 0 },
1129
- children: /* @__PURE__ */ l(R, { language: "json", style: O, PreTag: "div", children: t })
1140
+ children: /* @__PURE__ */ i(F, { language: "json", style: D, PreTag: "div", children: t })
1130
1141
  }
1131
1142
  ) });
1132
- }, ke = ({ data: e, isLatest: t = !1, durationSeconds: n }) => {
1143
+ }, ve = ({ data: e, isLatest: t = !1, durationSeconds: n }) => {
1133
1144
  const r = `Searching: ${e.queryDescription}`;
1134
- return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
1135
- /* @__PURE__ */ l(
1136
- T.div,
1145
+ return /* @__PURE__ */ b("div", { style: { padding: "16px" }, children: [
1146
+ /* @__PURE__ */ i(
1147
+ v.div,
1137
1148
  {
1138
1149
  style: {
1139
1150
  display: "flex",
@@ -1144,8 +1155,8 @@ const ye = ({ progressViewItems: e }) => {
1144
1155
  initial: { opacity: 0, y: -10 },
1145
1156
  animate: { opacity: 1, y: 0 },
1146
1157
  transition: { duration: 0.3, delay: 0 },
1147
- children: t && !n ? /* @__PURE__ */ l(
1148
- N,
1158
+ children: t && !n ? /* @__PURE__ */ i(
1159
+ M,
1149
1160
  {
1150
1161
  text: r,
1151
1162
  duration: 2.5,
@@ -1153,10 +1164,10 @@ const ye = ({ progressViewItems: e }) => {
1153
1164
  color: "#999",
1154
1165
  shimmerColor: "#000"
1155
1166
  }
1156
- ) : /* @__PURE__ */ l("span", { style: { color: "#666" }, children: r })
1167
+ ) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: r })
1157
1168
  }
1158
1169
  ),
1159
- n !== void 0 && /* @__PURE__ */ C(
1170
+ n !== void 0 && /* @__PURE__ */ b(
1160
1171
  "div",
1161
1172
  {
1162
1173
  style: {
@@ -1174,10 +1185,10 @@ const ye = ({ progressViewItems: e }) => {
1174
1185
  )
1175
1186
  ] });
1176
1187
  }, Ce = ({ isLatest: e = !1, durationSeconds: t }) => {
1177
- const n = "Finding sources...";
1178
- return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
1179
- /* @__PURE__ */ l(
1180
- T.div,
1188
+ const n = "Adding sources...";
1189
+ return /* @__PURE__ */ b("div", { style: { padding: "16px" }, children: [
1190
+ /* @__PURE__ */ i(
1191
+ v.div,
1181
1192
  {
1182
1193
  style: {
1183
1194
  display: "flex",
@@ -1188,8 +1199,8 @@ const ye = ({ progressViewItems: e }) => {
1188
1199
  initial: { opacity: 0, y: -10 },
1189
1200
  animate: { opacity: 1, y: 0 },
1190
1201
  transition: { duration: 0.3, delay: 0 },
1191
- children: e && !t ? /* @__PURE__ */ l(
1192
- N,
1202
+ children: e && !t ? /* @__PURE__ */ i(
1203
+ M,
1193
1204
  {
1194
1205
  text: n,
1195
1206
  duration: 2.5,
@@ -1197,10 +1208,10 @@ const ye = ({ progressViewItems: e }) => {
1197
1208
  color: "#999",
1198
1209
  shimmerColor: "#000"
1199
1210
  }
1200
- ) : /* @__PURE__ */ l("span", { style: { color: "#666" }, children: n })
1211
+ ) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: n })
1201
1212
  }
1202
1213
  ),
1203
- t !== void 0 && /* @__PURE__ */ C(
1214
+ t !== void 0 && /* @__PURE__ */ b(
1204
1215
  "div",
1205
1216
  {
1206
1217
  style: {
@@ -1217,9 +1228,9 @@ const ye = ({ progressViewItems: e }) => {
1217
1228
  }
1218
1229
  )
1219
1230
  ] });
1220
- }, Te = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
1221
- /* @__PURE__ */ l(
1222
- T.div,
1231
+ }, xe = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ b("div", { style: { padding: "16px" }, children: [
1232
+ /* @__PURE__ */ i(
1233
+ v.div,
1223
1234
  {
1224
1235
  style: { color: "#666", marginBottom: "10px", fontSize: "14px" },
1225
1236
  initial: { opacity: 0, y: -10 },
@@ -1228,8 +1239,8 @@ const ye = ({ progressViewItems: e }) => {
1228
1239
  children: "Sources"
1229
1240
  }
1230
1241
  ),
1231
- /* @__PURE__ */ l("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.map((n, r) => /* @__PURE__ */ l(
1232
- ve,
1242
+ /* @__PURE__ */ i("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.length === 0 ? /* @__PURE__ */ i("span", { style: { fontSize: "13px", color: "#888" }, children: "No sources" }) : e.sources.map((n, r) => /* @__PURE__ */ i(
1243
+ we,
1233
1244
  {
1234
1245
  source: n,
1235
1246
  index: r,
@@ -1237,17 +1248,26 @@ const ye = ({ progressViewItems: e }) => {
1237
1248
  },
1238
1249
  n.memoryId
1239
1250
  )) })
1240
- ] }), ve = ({ source: e, index: t, onSourceClick: n }) => {
1241
- const [r, a] = x(!1), m = !!n;
1242
- return /* @__PURE__ */ C(
1243
- T.div,
1251
+ ] });
1252
+ function pe(e, t) {
1253
+ if (t.length === 0) return e;
1254
+ if (t.length === 1) return `${e} page ${t[0]}`;
1255
+ if (t.length === 2)
1256
+ return `${e} pages ${t[0]} and ${t[1]}`;
1257
+ const n = t[t.length - 1], r = t.slice(0, -1).join(", ");
1258
+ return `${e} pages ${r} and ${n}`;
1259
+ }
1260
+ const we = ({ source: e, index: t, onSourceClick: n }) => {
1261
+ const [r, o] = C(!1), g = !!n, d = pe(e.memoryTitle, e.pageNumbers);
1262
+ return /* @__PURE__ */ i(
1263
+ v.div,
1244
1264
  {
1245
1265
  initial: { opacity: 0, scale: 0.9 },
1246
1266
  animate: { opacity: 1, scale: 1 },
1247
1267
  transition: { duration: 0.25, delay: t * 0.05 },
1248
- onClick: m ? () => n(e.memoryId) : void 0,
1249
- onMouseEnter: m ? () => a(!0) : void 0,
1250
- onMouseLeave: m ? () => a(!1) : void 0,
1268
+ onClick: g ? () => n(e.memoryId) : void 0,
1269
+ onMouseEnter: g ? () => o(!0) : void 0,
1270
+ onMouseLeave: g ? () => o(!1) : void 0,
1251
1271
  style: {
1252
1272
  display: "inline-flex",
1253
1273
  flexDirection: "column",
@@ -1256,91 +1276,218 @@ const ye = ({ progressViewItems: e }) => {
1256
1276
  borderRadius: "8px",
1257
1277
  border: "1px solid #e0e0e0",
1258
1278
  backgroundColor: r ? "#f0f0f0" : "#f9f9f9",
1259
- cursor: m ? "pointer" : "default",
1279
+ cursor: g ? "pointer" : "default",
1260
1280
  transition: "background-color 0.15s ease",
1261
1281
  userSelect: "none"
1262
1282
  },
1263
- children: [
1264
- /* @__PURE__ */ l("span", { style: { fontSize: "13px", fontWeight: 500, color: "#333" }, children: e.memoryId }),
1265
- e.pageNumbers.length > 0 && /* @__PURE__ */ l("span", { style: { fontSize: "11px", color: "#888" }, children: e.pageNumbers.length === 1 ? `p. ${e.pageNumbers[0]}` : `pp. ${e.pageNumbers.join(", ")}` })
1266
- ]
1283
+ children: /* @__PURE__ */ i("span", { style: { fontSize: "13px", fontWeight: 500, color: "#333" }, children: d })
1267
1284
  }
1268
1285
  );
1269
- }, xe = ({ progressViewItems: e, streamToken: t, fetchClientToken: n, loadingText: r, onSourceClick: a }) => {
1270
- const m = I(null);
1271
- w(() => {
1272
- m.current && (m.current.scrollTop = m.current.scrollHeight);
1273
- }, [e.length]);
1274
- const c = (o) => {
1275
- switch (o.item.data.type) {
1276
- case "GenericAgentTaskExecution":
1277
- return /* @__PURE__ */ l(
1278
- fe,
1279
- {
1280
- data: o.item.data,
1281
- completed: o.completed,
1282
- isLatest: o.isLatest,
1283
- durationSeconds: o.durationSeconds
1284
- }
1285
- );
1286
- case "GenericAgentTaskReasoning":
1287
- return /* @__PURE__ */ l(
1288
- be,
1289
- {
1290
- data: o.item.data,
1291
- completed: o.completed,
1292
- isLatest: o.isLatest,
1293
- durationSeconds: o.durationSeconds
1294
- }
1295
- );
1296
- case "GenericAgentTaskFinalResponse":
1297
- return /* @__PURE__ */ l(
1298
- he,
1299
- {
1300
- data: o.item.data,
1301
- streamToken: t,
1302
- fetchClientToken: n,
1303
- durationSeconds: o.durationSeconds
1304
- }
1305
- );
1306
- case "StreamingChatCompletionText":
1307
- return /* @__PURE__ */ l(G, { text: o.item.data.text });
1308
- case "StructuredChatCompletionJson":
1309
- return /* @__PURE__ */ l(Se, { data: o.item.data });
1310
- case "StreamingMemoryTypeChatCompletionText":
1311
- return /* @__PURE__ */ l(G, { text: o.item.data.text });
1312
- case "StreamingMemoryTypeChatCompletionSearch":
1313
- return /* @__PURE__ */ l(
1314
- ke,
1315
- {
1316
- data: o.item.data,
1317
- isLatest: o.isLatest,
1318
- durationSeconds: o.durationSeconds
1319
- }
1320
- );
1321
- case "StreamingMemoryTypeChatCompletionFindSources":
1322
- return /* @__PURE__ */ l(
1323
- Ce,
1286
+ }, Ee = `
1287
+ @keyframes explore-memory-spinner {
1288
+ to { transform: rotate(360deg); }
1289
+ }
1290
+ `;
1291
+ function Ae() {
1292
+ return /* @__PURE__ */ b(Z, { children: [
1293
+ /* @__PURE__ */ i("style", { children: Ee }),
1294
+ /* @__PURE__ */ i(
1295
+ "div",
1296
+ {
1297
+ style: {
1298
+ width: 12,
1299
+ height: 12,
1300
+ border: "2px solid #e0e0e0",
1301
+ borderTopColor: "#666",
1302
+ borderRadius: "50%",
1303
+ animation: "explore-memory-spinner 0.8s linear infinite"
1304
+ }
1305
+ }
1306
+ )
1307
+ ] });
1308
+ }
1309
+ function Ie({
1310
+ eventType: e,
1311
+ completed: t
1312
+ }) {
1313
+ return e === "ExploreMemoryError" ? /* @__PURE__ */ i("span", { style: { color: "#c62828", fontSize: 14, fontWeight: 600 }, children: "✗" }) : e === "ExploreMemoryResult" ? /* @__PURE__ */ i("span", { style: { color: "#2e7d32", fontSize: 14, fontWeight: 600 }, children: "✓" }) : e === "ExploreMemoryStart" ? t ? /* @__PURE__ */ i("span", { style: { color: "#2e7d32", fontSize: 14, fontWeight: 600 }, children: "✓" }) : /* @__PURE__ */ i(Ae, {}) : null;
1314
+ }
1315
+ const _ = 80, Pe = ({ data: e, completed: t }) => {
1316
+ const [n, r] = C(!1), o = e.eventType === "ExploreMemoryResult" ? e.result : void 0, g = o != null && o.length > _, d = o != null ? n || !g ? o : `${o.slice(0, _)}...` : void 0, s = g;
1317
+ return /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ b(
1318
+ v.div,
1319
+ {
1320
+ initial: { opacity: 0, scale: 0.9 },
1321
+ animate: { opacity: 1, scale: 1 },
1322
+ transition: { duration: 0.25, delay: 0 },
1323
+ onClick: s ? () => r((c) => !c) : void 0,
1324
+ style: {
1325
+ display: "inline-flex",
1326
+ flexDirection: "row",
1327
+ alignItems: "flex-start",
1328
+ gap: "10px",
1329
+ padding: "8px 12px",
1330
+ borderRadius: "8px",
1331
+ border: "1px solid #e0e0e0",
1332
+ backgroundColor: "#f9f9f9",
1333
+ minWidth: 0,
1334
+ cursor: s ? "pointer" : "default",
1335
+ transition: "background-color 0.15s ease"
1336
+ },
1337
+ onMouseEnter: s ? (c) => {
1338
+ c.currentTarget.style.backgroundColor = "#f0f0f0";
1339
+ } : void 0,
1340
+ onMouseLeave: s ? (c) => {
1341
+ c.currentTarget.style.backgroundColor = "#f9f9f9";
1342
+ } : void 0,
1343
+ children: [
1344
+ /* @__PURE__ */ i(
1345
+ "div",
1324
1346
  {
1325
- data: o.item.data,
1326
- isLatest: o.isLatest,
1327
- durationSeconds: o.durationSeconds
1347
+ style: {
1348
+ display: "flex",
1349
+ alignItems: "center",
1350
+ justifyContent: "center",
1351
+ flexShrink: 0,
1352
+ width: 20
1353
+ },
1354
+ children: /* @__PURE__ */ i(Ie, { eventType: e.eventType, completed: t })
1328
1355
  }
1329
- );
1330
- case "StreamingMemoryTypeChatCompletionSourcesResult":
1331
- return /* @__PURE__ */ l(
1332
- Te,
1356
+ ),
1357
+ /* @__PURE__ */ b(
1358
+ "div",
1333
1359
  {
1334
- data: o.item.data,
1335
- onSourceClick: a
1360
+ style: {
1361
+ display: "flex",
1362
+ flexDirection: "column",
1363
+ gap: "4px",
1364
+ minWidth: 0
1365
+ },
1366
+ children: [
1367
+ /* @__PURE__ */ i("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1368
+ d != null && /* @__PURE__ */ i(
1369
+ "span",
1370
+ {
1371
+ style: {
1372
+ fontSize: 12,
1373
+ color: "#666",
1374
+ lineHeight: 1.4,
1375
+ whiteSpace: n ? "pre-wrap" : void 0
1376
+ },
1377
+ children: d
1378
+ }
1379
+ ),
1380
+ s && /* @__PURE__ */ i(
1381
+ "span",
1382
+ {
1383
+ style: {
1384
+ fontSize: 11,
1385
+ color: "#999",
1386
+ marginTop: 2
1387
+ },
1388
+ children: n ? "Click to collapse" : "Click to expand"
1389
+ }
1390
+ )
1391
+ ]
1336
1392
  }
1337
- );
1338
- default:
1339
- return null;
1393
+ )
1394
+ ]
1340
1395
  }
1396
+ ) });
1397
+ }, Me = ({ progressViewItems: e, streamToken: t, fetchClientToken: n, loadingText: r, onSourceClick: o }) => {
1398
+ const g = E(null);
1399
+ p(() => {
1400
+ g.current && (g.current.scrollTop = g.current.scrollHeight);
1401
+ }, [e.length]);
1402
+ const d = (s) => {
1403
+ const c = s.item.data;
1404
+ if (c.taskType === "GenericAgentTask")
1405
+ switch (c.eventType) {
1406
+ case "Execution":
1407
+ return /* @__PURE__ */ i(
1408
+ Te,
1409
+ {
1410
+ data: c,
1411
+ completed: s.completed,
1412
+ isLatest: s.isLatest,
1413
+ durationSeconds: s.durationSeconds
1414
+ }
1415
+ );
1416
+ case "Reasoning":
1417
+ return /* @__PURE__ */ i(
1418
+ ke,
1419
+ {
1420
+ data: c,
1421
+ completed: s.completed,
1422
+ isLatest: s.isLatest,
1423
+ durationSeconds: s.durationSeconds
1424
+ }
1425
+ );
1426
+ case "FinalResponse":
1427
+ return /* @__PURE__ */ i(
1428
+ Se,
1429
+ {
1430
+ data: c,
1431
+ streamToken: t,
1432
+ fetchClientToken: n,
1433
+ durationSeconds: s.durationSeconds
1434
+ }
1435
+ );
1436
+ case "Completed":
1437
+ return null;
1438
+ }
1439
+ if (c.taskType === "StreamingChatCompletion" && c.eventType === "Text")
1440
+ return /* @__PURE__ */ i(B, { text: c.text });
1441
+ if (c.taskType === "StructuredChatCompletion" && c.eventType === "Json")
1442
+ return /* @__PURE__ */ i(be, { data: c });
1443
+ if (c.taskType === "StreamingMemoryTypeChatCompletion")
1444
+ switch (c.eventType) {
1445
+ case "Text":
1446
+ return /* @__PURE__ */ i(B, { text: c.text });
1447
+ case "Search":
1448
+ return /* @__PURE__ */ i(
1449
+ ve,
1450
+ {
1451
+ data: c,
1452
+ isLatest: s.isLatest,
1453
+ durationSeconds: s.durationSeconds
1454
+ }
1455
+ );
1456
+ case "FindSources":
1457
+ return /* @__PURE__ */ i(
1458
+ Ce,
1459
+ {
1460
+ data: c,
1461
+ isLatest: s.isLatest,
1462
+ durationSeconds: s.durationSeconds
1463
+ }
1464
+ );
1465
+ case "SourcesResult":
1466
+ return /* @__PURE__ */ i(
1467
+ xe,
1468
+ {
1469
+ data: c,
1470
+ onSourceClick: o
1471
+ }
1472
+ );
1473
+ case "ExploreMemoryStart":
1474
+ case "ExploreMemoryResult":
1475
+ case "ExploreMemoryError":
1476
+ return /* @__PURE__ */ i(
1477
+ Pe,
1478
+ {
1479
+ data: c,
1480
+ completed: s.completed,
1481
+ isLatest: s.isLatest
1482
+ }
1483
+ );
1484
+ case "Completed":
1485
+ return null;
1486
+ }
1487
+ return c.taskType === "StreamingChatCompletion" && c.eventType === "Completed" || c.taskType === "StructuredChatCompletion" && c.eventType === "Completed", null;
1341
1488
  };
1342
- return e.length === 0 ? /* @__PURE__ */ l("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ l(
1343
- N,
1489
+ return e.length === 0 ? /* @__PURE__ */ i("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ i(
1490
+ M,
1344
1491
  {
1345
1492
  text: r ?? "Processing your task...",
1346
1493
  duration: 1.5,
@@ -1349,39 +1496,41 @@ const ye = ({ progressViewItems: e }) => {
1349
1496
  color: "#999",
1350
1497
  shimmerColor: "#000"
1351
1498
  }
1352
- ) }) : /* @__PURE__ */ l("div", { id: "agent-task-progress-verbose", ref: m, children: /* @__PURE__ */ l(W, { children: e.map((o, g) => /* @__PURE__ */ l(
1353
- T.div,
1499
+ ) }) : /* @__PURE__ */ i("div", { id: "agent-task-progress-verbose", ref: g, children: /* @__PURE__ */ i(H, { children: e.map((s, c) => /* @__PURE__ */ i(
1500
+ v.div,
1354
1501
  {
1355
- id: `agent-task-progress-item-${o.item.progressItemId}`,
1502
+ id: `agent-task-progress-item-${s.item.progressItemId}`,
1356
1503
  initial: { opacity: 0, y: -20 },
1357
1504
  animate: { opacity: 1, y: 0 },
1358
1505
  transition: {
1359
1506
  duration: 0.4,
1360
- delay: g * 0.1,
1507
+ delay: c * 0.1,
1361
1508
  ease: "easeOut"
1362
1509
  },
1363
- children: c(o)
1510
+ children: d(s)
1364
1511
  },
1365
- o.item.progressItemId
1512
+ s.item.progressItemId
1366
1513
  )) }) });
1367
- }, Be = ({
1514
+ }, He = ({
1368
1515
  agentTask: e,
1369
1516
  mode: t = "verbose",
1370
1517
  streamToken: n,
1371
- fetchClientToken: r
1518
+ fetchClientToken: r,
1519
+ onSourceClick: o
1372
1520
  }) => {
1373
- const a = me(e);
1374
- return t === "simple" ? /* @__PURE__ */ l(ye, { progressViewItems: a }) : /* @__PURE__ */ l(
1375
- xe,
1521
+ const g = ye(e);
1522
+ return t === "simple" ? /* @__PURE__ */ i(he, { progressViewItems: g }) : /* @__PURE__ */ i(
1523
+ Me,
1376
1524
  {
1377
- progressViewItems: a,
1525
+ progressViewItems: g,
1378
1526
  streamToken: n,
1379
1527
  fetchClientToken: r,
1380
- loadingText: e.loadingText
1528
+ loadingText: e.loadingText,
1529
+ onSourceClick: o
1381
1530
  }
1382
1531
  );
1383
1532
  };
1384
- class we {
1533
+ class Re {
1385
1534
  constructor(t) {
1386
1535
  this.eventSources = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Map(), this.fency = t;
1387
1536
  }
@@ -1391,36 +1540,36 @@ class we {
1391
1540
  */
1392
1541
  updateStreams(t) {
1393
1542
  t.forEach((r) => {
1394
- const a = r.stream.id;
1395
- this.eventSources.has(a) || this.connectStream(r);
1543
+ const o = r.stream.id;
1544
+ this.eventSources.has(o) || this.connectStream(r);
1396
1545
  });
1397
1546
  const n = new Set(t.map((r) => r.stream.id));
1398
- this.eventSources.forEach((r, a) => {
1399
- n.has(a) || (r.abort(), this.eventSources.delete(a));
1547
+ this.eventSources.forEach((r, o) => {
1548
+ n.has(o) || (r.abort(), this.eventSources.delete(o));
1400
1549
  });
1401
1550
  }
1402
1551
  connectStream(t) {
1403
1552
  const n = t.stream.id, r = new AbortController();
1404
1553
  this.eventSources.set(n, r);
1405
- const a = `${this.fency.baseUrl}/sse/streams/${n}`, m = {
1554
+ const o = `${this.fency.baseUrl}/sse/streams/${n}`, g = {
1406
1555
  "X-Fency-Publishable-Key": this.fency.publishableKey,
1407
1556
  "X-Fency-Stream-Token": t.stream.token
1408
1557
  };
1409
- H(a, {
1410
- headers: m,
1558
+ K(o, {
1559
+ headers: g,
1411
1560
  signal: r.signal,
1412
- async onopen(c) {
1413
- if (!c.ok && c.status >= 400 && c.status < 500 && c.status !== 429)
1414
- throw new Error(`Client error ${c.status}`);
1561
+ async onopen(d) {
1562
+ if (!d.ok && d.status >= 400 && d.status < 500 && d.status !== 429)
1563
+ throw new Error(`Client error ${d.status}`);
1415
1564
  },
1416
- onmessage: (c) => {
1417
- if (c.data) {
1418
- const o = K(c.data);
1419
- this.broadcast(o, n);
1565
+ onmessage: (d) => {
1566
+ if (d.data) {
1567
+ const s = q(d.data);
1568
+ this.broadcast(s, n);
1420
1569
  }
1421
1570
  },
1422
- onerror: (c) => {
1423
- throw console.error("EventSource error for stream", n, ":", c), this.broadcastError(n), c;
1571
+ onerror: (d) => {
1572
+ throw console.error("EventSource error for stream", n, ":", d), this.broadcastError(n), d;
1424
1573
  },
1425
1574
  onclose() {
1426
1575
  }
@@ -1452,94 +1601,95 @@ class we {
1452
1601
  this.eventSources.forEach((t) => t.abort()), this.eventSources.clear(), this.subscribers.clear();
1453
1602
  }
1454
1603
  }
1455
- const Ae = 12e4, Ie = (e) => {
1604
+ const Fe = 12e4, Ne = (e) => {
1456
1605
  const t = Date.now();
1457
- return e.filter((n) => t - n.createdAt < Ae);
1606
+ return e.filter((n) => t - n.createdAt < Fe);
1458
1607
  };
1459
- function ze({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
1460
- const [r, a] = x(
1608
+ function Ge({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
1609
+ const [r, o] = C(
1461
1610
  null
1462
- ), [m, c] = x(!0), [o, g] = x(null), [i, s] = x([]), d = I(null), u = I(null);
1463
- w(() => {
1611
+ ), [g, d] = C(!0), [s, c] = C(null), [a, l] = C([]), u = E(null), m = E(null);
1612
+ p(() => {
1464
1613
  e.then((f) => {
1465
- a(f), c(!1);
1614
+ o(f), d(!1);
1466
1615
  }).catch((f) => {
1467
- g(f), c(!1);
1616
+ c(f), d(!1);
1468
1617
  });
1469
- }, [e]), w(() => {
1470
- r && !u.current && (u.current = new we(r));
1471
- }, [r]), w(() => {
1472
- u.current && u.current.updateStreams(i);
1473
- }, [i]), w(() => () => {
1618
+ }, [e]), p(() => {
1619
+ r && !m.current && (m.current = new Re(r));
1620
+ }, [r]), p(() => {
1621
+ m.current && m.current.updateStreams(a);
1622
+ }, [a]), p(() => () => {
1474
1623
  var f;
1475
- (f = u.current) == null || f.cleanup();
1624
+ (f = m.current) == null || f.cleanup();
1476
1625
  }, []);
1477
- const b = U(
1626
+ const T = U(
1478
1627
  async (f = 3e4) => {
1479
- if (d.current)
1480
- return d.current;
1481
- const h = Date.now(), k = i.length > 0 ? i[i.length - 1] : null;
1628
+ if (u.current)
1629
+ return u.current;
1630
+ const h = Date.now(), k = a.length > 0 ? a[a.length - 1] : null;
1482
1631
  if (k && h - k.createdAt < f)
1483
1632
  return k.stream;
1484
- const P = (async () => {
1633
+ const A = (async () => {
1485
1634
  if (!r)
1486
1635
  throw new Error("Fency instance not initialized");
1487
- const A = await t(), E = await V({
1636
+ const w = await t(), I = await X({
1488
1637
  pk: r.publishableKey,
1489
1638
  baseUrl: r.baseUrl,
1490
- clientToken: (A == null ? void 0 : A.clientToken) ?? ""
1639
+ clientToken: (w == null ? void 0 : w.clientToken) ?? ""
1491
1640
  });
1492
- if (E.type === "success") {
1493
- const F = {
1494
- stream: E.stream,
1641
+ if (I.type === "success") {
1642
+ const R = {
1643
+ stream: I.stream,
1495
1644
  createdAt: Date.now()
1496
1645
  };
1497
- return s((p) => {
1498
- const v = [...p, F];
1499
- return Ie(v);
1500
- }), d.current = null, E.stream;
1646
+ return l((P) => {
1647
+ const x = [...P, R];
1648
+ return Ne(x);
1649
+ }), u.current = null, I.stream;
1501
1650
  } else
1502
- throw d.current = null, new Error("Failed to create stream");
1651
+ throw u.current = null, new Error("Failed to create stream");
1503
1652
  })();
1504
- return d.current = P, P;
1653
+ return u.current = A, A;
1505
1654
  },
1506
- [r, i]
1655
+ [r, a]
1507
1656
  );
1508
- if (o)
1509
- return /* @__PURE__ */ C("div", { children: [
1657
+ if (s)
1658
+ return /* @__PURE__ */ b("div", { children: [
1510
1659
  "Fency error: ",
1511
- o.message
1660
+ s.message
1512
1661
  ] });
1513
1662
  if (!r)
1514
1663
  return null;
1515
- const y = i.length > 0 ? i[i.length - 1] : null, S = {
1664
+ const y = a.length > 0 ? a[a.length - 1] : null, S = {
1516
1665
  fency: r,
1517
- loading: m,
1518
- error: o,
1519
- activeStreams: i,
1666
+ loading: g,
1667
+ error: s,
1668
+ activeStreams: a,
1520
1669
  latestStream: y,
1521
- eventManager: u.current,
1522
- getOrCreateStream: b
1670
+ eventManager: m.current,
1671
+ getOrCreateStream: T
1523
1672
  };
1524
- return /* @__PURE__ */ l($.Provider, { value: S, children: n });
1673
+ return /* @__PURE__ */ i(G.Provider, { value: S, children: n });
1525
1674
  }
1526
1675
  export {
1527
- Be as AgentTaskProgress,
1528
- ye as AgentTaskProgressSimple,
1529
- xe as AgentTaskProgressVerbose,
1530
- ze as FencyProvider,
1531
- fe as GenericAgentTaskExecution,
1532
- he as GenericAgentTaskFinalResponse,
1533
- be as GenericAgentTaskReasoning,
1534
- N as ShimmeringText,
1535
- G as StreamingChatCompletionText,
1676
+ He as AgentTaskProgress,
1677
+ he as AgentTaskProgressSimple,
1678
+ Me as AgentTaskProgressVerbose,
1679
+ Ge as FencyProvider,
1680
+ Te as GenericAgentTaskExecution,
1681
+ Se as GenericAgentTaskFinalResponse,
1682
+ ke as GenericAgentTaskReasoning,
1683
+ M as ShimmeringText,
1684
+ B as StreamingChatCompletionText,
1685
+ Pe as StreamingMemoryTypeChatCompletionExploreMemory,
1536
1686
  Ce as StreamingMemoryTypeChatCompletionFindSources,
1537
- ke as StreamingMemoryTypeChatCompletionSearch,
1538
- Te as StreamingMemoryTypeChatCompletionSourcesResult,
1539
- Se as StructuredChatCompletionJson,
1540
- Oe as useAgentTasks,
1541
- M as useFencyContext,
1542
- De as useFencyEventSource,
1543
- Ue as usePaginatedQuery,
1544
- ae as useStream
1687
+ ve as StreamingMemoryTypeChatCompletionSearch,
1688
+ xe as StreamingMemoryTypeChatCompletionSourcesResult,
1689
+ be as StructuredChatCompletionJson,
1690
+ Be as useAgentTasks,
1691
+ N as useFencyContext,
1692
+ _e as useFencyEventSource,
1693
+ je as usePaginatedQuery,
1694
+ ie as useStream
1545
1695
  };