@fencyai/react 0.1.118 → 0.1.119

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,15 +1,15 @@
1
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";
2
+ import { createContext as X, useContext as Q, useState as x, useRef as I, useEffect as w, useCallback as U, useMemo as G } from "react";
3
+ import { jsx as l, jsxs as T } from "react/jsx-runtime";
4
+ import { useInView as Y, motion as k, AnimatePresence as j } from "motion/react";
5
+ import $ from "react-markdown";
6
6
  import { Prism as R } from "react-syntax-highlighter";
7
- import z from "remark-gfm";
8
- import './assets/index.css';const $ = X(
7
+ import B from "remark-gfm";
8
+ import './assets/index.css';const W = X(
9
9
  void 0
10
10
  );
11
- function M() {
12
- const e = Q($);
11
+ function N() {
12
+ const e = Q(W);
13
13
  if (e === void 0)
14
14
  throw new Error("useFencyContext must be used within a FencyProvider");
15
15
  return e;
@@ -50,12 +50,12 @@ const Z = (e) => {
50
50
  createdAt: e.createdAt,
51
51
  data: JSON.parse(e.data)
52
52
  }), ae = (e) => {
53
- const t = M(), [n, r] = x(null), a = I(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
53
+ const t = N(), [n, r] = x(null), o = I(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
54
54
  return w(() => {
55
55
  if (!t.eventManager) return;
56
56
  const c = {
57
- onMessage: (g, i) => {
58
- var d, u, b, y, S, f, h, k, P, A;
57
+ onMessage: (g, a) => {
58
+ var d, u, S, y, b, f, h, C, P, A;
59
59
  const s = Z(g);
60
60
  if (s)
61
61
  switch (s.type) {
@@ -66,13 +66,13 @@ const Z = (e) => {
66
66
  (u = e == null ? void 0 : e.onChatCompletionStreamCompleted) == null || u.call(e, s);
67
67
  break;
68
68
  case "StreamTimeout":
69
- (b = e == null ? void 0 : e.onStreamTimeout) == null || b.call(e, s);
69
+ (S = e == null ? void 0 : e.onStreamTimeout) == null || S.call(e, s);
70
70
  break;
71
71
  case "StreamNotFound":
72
72
  (y = e == null ? void 0 : e.onStreamNotFound) == null || y.call(e, s);
73
73
  break;
74
74
  case "FileUploadCompleted":
75
- (S = e == null ? void 0 : e.onFileUploadCompleted) == null || S.call(e, s);
75
+ (b = e == null ? void 0 : e.onFileUploadCompleted) == null || b.call(e, s);
76
76
  break;
77
77
  case "FileTextContentReady":
78
78
  (f = e == null ? void 0 : e.onFileTextContentReady) == null || f.call(e, s);
@@ -81,7 +81,7 @@ const Z = (e) => {
81
81
  (h = e == null ? void 0 : e.onWebsiteHtmlContentReady) == null || h.call(e, s);
82
82
  break;
83
83
  case "WebsiteTextContentReady":
84
- (k = e == null ? void 0 : e.onWebsiteTextContentReady) == null || k.call(e, s);
84
+ (C = e == null ? void 0 : e.onWebsiteTextContentReady) == null || C.call(e, s);
85
85
  break;
86
86
  case "FileSearchIndexReady":
87
87
  (P = e == null ? void 0 : e.onFileSearchIndexReady) == null || P.call(e, s);
@@ -92,8 +92,8 @@ const Z = (e) => {
92
92
  }
93
93
  },
94
94
  onError: (g) => {
95
- var i;
96
- (i = e == null ? void 0 : e.onStreamError) == null || i.call(e, {
95
+ var a;
96
+ (a = e == null ? void 0 : e.onStreamError) == null || a.call(e, {
97
97
  streamId: g,
98
98
  error: {
99
99
  code: "UnknownError",
@@ -103,7 +103,7 @@ const Z = (e) => {
103
103
  }
104
104
  };
105
105
  return t.eventManager.subscribe(
106
- a.current,
106
+ o.current,
107
107
  c
108
108
  );
109
109
  }, [t.eventManager, e]), {
@@ -126,54 +126,54 @@ const Z = (e) => {
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) => {
129
+ }, De = (e) => {
130
+ const t = N(), [n, r] = x([]), o = I(/* @__PURE__ */ new Set()), m = I(/* @__PURE__ */ new Map()), { createStream: c } = ae({
131
+ onAgentTaskProgressItemUpdated: (a) => {
132
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));
133
+ if (!o.current.has(a.agentTaskId)) return;
134
+ const s = a.data;
135
+ if (s.type === "GenericAgentTaskCompleted" || s.type === "StreamingChatCompletionCompleted" || s.type === "StructuredChatCompletionCompleted" || s.type === "StreamingMemoryTypeChatCompletionCompleted") {
136
+ const S = m.current.get(a.agentTaskId);
137
+ S && (m.current.delete(a.agentTaskId), S(s));
138
138
  return;
139
139
  }
140
- (u = e.onAgentTaskProgressItemUpdated) == null || u.call(e, i), r(
141
- (b) => b.map((y) => {
140
+ (u = e.onAgentTaskProgressItemUpdated) == null || u.call(e, a), r(
141
+ (S) => S.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
+ (C) => C.progressItemId === a.progressItemId
146
146
  ) ? y.progressItems.map(
147
- (k) => k.progressItemId === i.progressItemId ? i : k
148
- ) : [...y.progressItems, i];
147
+ (C) => C.progressItemId === a.progressItemId ? a : C
148
+ ) : [...y.progressItems, a];
149
149
  return { ...y, progressItems: f };
150
150
  })
151
151
  );
152
152
  },
153
- onStreamError: (i) => {
153
+ onStreamError: (a) => {
154
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);
155
+ (s = e == null ? void 0 : e.onStreamError) == null || s.call(e, a), r((d) => {
156
+ const u = d.find((S) => S.streamId === a.streamId);
157
157
  return u ? [
158
- ...d.filter((b) => b.streamId !== i.streamId),
158
+ ...d.filter((S) => S.streamId !== a.streamId),
159
159
  {
160
160
  ...u,
161
161
  loading: !1,
162
- error: i.error
162
+ error: a.error
163
163
  }
164
164
  ] : d;
165
165
  });
166
166
  },
167
- onStreamNotFound: (i) => {
167
+ onStreamNotFound: (a) => {
168
168
  var s;
169
- (s = e == null ? void 0 : e.onStreamNotFound) == null || s.call(e, i);
169
+ (s = e == null ? void 0 : e.onStreamNotFound) == null || s.call(e, a);
170
170
  },
171
- onStreamTimeout: (i) => {
171
+ onStreamTimeout: (a) => {
172
172
  var s;
173
- (s = e == null ? void 0 : e.onStreamTimeout) == null || s.call(e, i);
173
+ (s = e == null ? void 0 : e.onStreamTimeout) == null || s.call(e, a);
174
174
  }
175
- }), o = U(
176
- async (i, s) => {
175
+ }), i = U(
176
+ async (a, s) => {
177
177
  const d = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, u = await c();
178
178
  if (u.type === "success") {
179
179
  r([
@@ -184,26 +184,27 @@ const Z = (e) => {
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
191
  loadingText: s == null ? void 0 : s.loadingText
192
192
  }
193
193
  ]);
194
- const { clientToken: b } = await e.fetchCreateAgentTaskClientToken(i.type), y = await q({
194
+ const { clientToken: S } = await e.fetchCreateAgentTaskClientToken(a.type), y = await q({
195
195
  pk: t.fency.publishableKey,
196
196
  baseUrl: t.fency.baseUrl,
197
- clientToken: b,
197
+ clientToken: S,
198
198
  streamToken: u.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(
@@ -216,7 +217,7 @@ const Z = (e) => {
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,
@@ -227,7 +228,7 @@ const Z = (e) => {
227
228
  }
228
229
  }
229
230
  ]);
230
- const S = await new Promise(
231
+ const b = await new Promise(
231
232
  (f) => {
232
233
  m.current.set(
233
234
  y.agentTask.id,
@@ -239,19 +240,19 @@ const Z = (e) => {
239
240
  type: "success",
240
241
  streamId: u.stream.id,
241
242
  agentTaskId: y.agentTask.id,
242
- response: S
243
+ response: b
243
244
  };
244
245
  } else {
245
246
  if (y.type === "error")
246
- return r((S) => [
247
- ...S.filter(
247
+ return r((b) => [
248
+ ...b.filter(
248
249
  (f) => f.taskKey !== d
249
250
  ),
250
251
  {
251
252
  taskKey: d,
252
253
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
253
254
  streamId: u.stream.id,
254
- params: i,
255
+ params: a,
255
256
  error: y.error,
256
257
  progressItems: [],
257
258
  loading: !1,
@@ -264,7 +265,7 @@ const Z = (e) => {
264
265
  error: y.error
265
266
  };
266
267
  {
267
- const S = {
268
+ const b = {
268
269
  message: "No response received",
269
270
  code: "UnknownError"
270
271
  };
@@ -276,8 +277,8 @@ const Z = (e) => {
276
277
  taskKey: d,
277
278
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
278
279
  streamId: u.stream.id,
279
- error: S,
280
- params: i,
280
+ error: b,
281
+ params: a,
281
282
  progressItems: [],
282
283
  loading: !1,
283
284
  doneStreaming: !1,
@@ -286,7 +287,7 @@ const Z = (e) => {
286
287
  }
287
288
  ]), {
288
289
  type: "error",
289
- error: S
290
+ error: b
290
291
  };
291
292
  }
292
293
  }
@@ -294,15 +295,15 @@ const Z = (e) => {
294
295
  return console.error(u.error), u;
295
296
  },
296
297
  [t, n, c]
297
- ), g = j(() => {
298
+ ), g = G(() => {
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, s) => new Date(s.triggeredAt).getTime() - new Date(a.triggeredAt).getTime())[0];
300
301
  }, [n]);
301
302
  return w(() => () => {
302
- a.current.clear(), m.current.clear();
303
+ o.current.clear(), m.current.clear();
303
304
  }, []), {
304
305
  agentTasks: n,
305
- createAgentTask: o,
306
+ createAgentTask: i,
306
307
  latest: g
307
308
  };
308
309
  };
@@ -313,40 +314,40 @@ async function oe(e, t) {
313
314
  t(r.value);
314
315
  }
315
316
  function ie(e) {
316
- let t, n, r, a = !1;
317
+ let t, n, r, o = !1;
317
318
  return function(c) {
318
319
  t === void 0 ? (t = c, n = 0, r = -1) : t = ce(t, c);
319
- const o = t.length;
320
+ const i = t.length;
320
321
  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)
322
+ for (; n < i; ) {
323
+ o && (t[n] === 10 && (g = ++n), o = !1);
324
+ let a = -1;
325
+ for (; n < i && a === -1; ++n)
325
326
  switch (t[n]) {
326
327
  case 58:
327
328
  r === -1 && (r = n - g);
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(g, a), r), g = n, r = -1;
338
339
  }
339
- g === o ? t = void 0 : g !== 0 && (t = t.subarray(g), n -= g);
340
+ g === i ? t = void 0 : g !== 0 && (t = t.subarray(g), n -= g);
340
341
  };
341
342
  }
342
343
  function se(e, t, n) {
343
- let r = L();
344
- const a = new TextDecoder();
345
- return function(c, o) {
344
+ let r = z();
345
+ const o = new TextDecoder();
346
+ return function(c, i) {
346
347
  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));
348
+ n == null || n(r), r = z();
349
+ else if (i > 0) {
350
+ const g = o.decode(c.subarray(0, i)), a = i + (c[i + 1] === 32 ? 2 : 1), s = o.decode(c.subarray(a));
350
351
  switch (g) {
351
352
  case "data":
352
353
  r.data = r.data ? r.data + `
@@ -370,7 +371,7 @@ function ce(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 z() {
374
375
  return {
375
376
  data: "",
376
377
  event: "",
@@ -382,46 +383,46 @@ var le = 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
+ const D = "text/event-stream", de = 1e3, L = "last-event-id";
390
391
  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
+ var { signal: n, headers: r, onopen: o, onmessage: m, onclose: c, onerror: i, openWhenHidden: g, fetch: a } = t, s = le(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
392
393
  return new Promise((d, u) => {
393
- const b = Object.assign({}, r);
394
- b.accept || (b.accept = D);
394
+ const S = Object.assign({}, r);
395
+ S.accept || (S.accept = D);
395
396
  let y;
396
- function S() {
397
+ function b() {
397
398
  y.abort(), document.hidden || E();
398
399
  }
399
- g || document.addEventListener("visibilitychange", S);
400
+ g || document.addEventListener("visibilitychange", b);
400
401
  let f = de, h = 0;
401
- function k() {
402
- document.removeEventListener("visibilitychange", S), window.clearTimeout(h), y.abort();
402
+ function C() {
403
+ document.removeEventListener("visibilitychange", b), window.clearTimeout(h), y.abort();
403
404
  }
404
405
  n == null || n.addEventListener("abort", () => {
405
- k(), d();
406
+ C(), d();
406
407
  });
407
- const P = i ?? window.fetch, A = a ?? ue;
408
+ const P = a ?? window.fetch, A = o ?? ue;
408
409
  async function E() {
409
410
  var F;
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
+ const p = await P(e, Object.assign(Object.assign({}, s), { headers: S, signal: y.signal }));
413
414
  await A(p), await oe(p.body, ie(se((v) => {
414
- v ? b[_] = v : delete b[_];
415
+ v ? S[L] = v : delete S[L];
415
416
  }, (v) => {
416
417
  f = v;
417
- }, m))), c == null || c(), k(), d();
418
+ }, m))), c == null || c(), C(), d();
418
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
+ const v = (F = i == null ? void 0 : i(p)) !== null && F !== void 0 ? F : f;
422
423
  window.clearTimeout(h), h = window.setTimeout(E, v);
423
424
  } catch (v) {
424
- k(), u(v);
425
+ C(), u(v);
425
426
  }
426
427
  }
427
428
  }
@@ -433,7 +434,7 @@ function ue(e) {
433
434
  if (!(t != null && t.startsWith(D)))
434
435
  throw new Error(`Expected content-type to be ${D}, Actual: ${t}`);
435
436
  }
436
- function De(e) {
437
+ function Ue(e) {
437
438
  const [t, n] = x(null);
438
439
  return w(() => {
439
440
  if (!t)
@@ -442,18 +443,18 @@ function De(e) {
442
443
  return H(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: K(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
  }
@@ -471,13 +472,13 @@ function K(e) {
471
472
  n[r] = t.charCodeAt(r);
472
473
  return new TextDecoder("utf-8").decode(n);
473
474
  }
474
- function Ue(e, t) {
475
+ function $e(e, t) {
475
476
  const [n, r] = x(
476
477
  null
477
- ), [a, m] = x(
478
+ ), [o, m] = x(
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({
480
+ ), c = N(), i = async (d) => {
481
+ const u = await d.fetchTokens(), { fetchTokens: S, nextPageToken: y, previousPageToken: b, ...f } = d, h = await e({
481
482
  pk: c.fency.publishableKey,
482
483
  clientToken: u.clientToken,
483
484
  streamToken: u.streamToken,
@@ -486,7 +487,7 @@ function Ue(e, t) {
486
487
  limit: (t == null ? void 0 : t.pageSize) ?? 50,
487
488
  pagination: {
488
489
  nextPageToken: y,
489
- previousPageToken: S
490
+ previousPageToken: b
490
491
  }
491
492
  },
492
493
  baseUrl: c.fency.baseUrl
@@ -509,7 +510,7 @@ function Ue(e, t) {
509
510
  };
510
511
  return {
511
512
  fetchFirstPage: async (d) => {
512
- const u = await o({
513
+ const u = await i({
513
514
  ...d,
514
515
  nextPageToken: void 0,
515
516
  previousPageToken: void 0
@@ -517,7 +518,7 @@ function Ue(e, t) {
517
518
  return u.type === "success" && (m(u.page), r(d)), u;
518
519
  },
519
520
  fetchNextPage: async (d) => {
520
- if (a == null)
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
+ const u = await i({
537
538
  ...d,
538
- nextPageToken: a.pagination.nextPageToken,
539
+ nextPageToken: o.pagination.nextPageToken,
539
540
  previousPageToken: void 0
540
541
  });
541
542
  return u.type === "success" && (m(u.page), r(d)), u;
542
543
  },
543
544
  fetchPreviousPage: async (d) => {
544
- if (a == null)
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,10 +558,10 @@ function Ue(e, t) {
557
558
  message: "No previous page"
558
559
  }
559
560
  };
560
- const u = await o({
561
+ const u = await i({
561
562
  ...d,
562
563
  nextPageToken: void 0,
563
- previousPageToken: a.pagination.previousPageToken
564
+ previousPageToken: o.pagination.previousPageToken
564
565
  });
565
566
  return u.type === "success" && (m(u.page), r(d)), u;
566
567
  },
@@ -570,46 +571,46 @@ 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
+ } : i(n),
575
+ currentPage: o
575
576
  };
576
577
  }
577
578
  function me(e) {
578
579
  return e.progressItems.map((t, n) => {
579
- const r = e.progressItems[n + 1], a = r != null;
580
+ const r = e.progressItems[n + 1], o = r != null;
580
581
  let m;
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 c = new Date(t.createdAt).getTime(), i = new Date(r.createdAt).getTime();
584
+ m = Math.round((i - c) / 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
590
  durationSeconds: m
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
+ repeatDelay: o = 0.5,
599
600
  className: m,
600
601
  startOnView: c = !1,
601
- once: o = !1,
602
+ once: i = !1,
602
603
  inViewMargin: g,
603
- spread: i = 2,
604
+ spread: a = 2,
604
605
  color: s = "#999",
605
606
  shimmerColor: d = "#000",
606
607
  direction: u = "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
+ const S = I(null), y = Y(S, { once: i, margin: g }), b = G(() => e.length * a, [e, a]), f = !c || y, h = u === "fromBottom" ? "100% center" : "-100% center", C = u === "fromBottom" ? "0% center" : "200% center";
609
610
  return /* @__PURE__ */ l(
610
- T.span,
611
+ k.span,
611
612
  {
612
- ref: b,
613
+ ref: S,
613
614
  className: m,
614
615
  style: {
615
616
  position: "relative",
@@ -620,7 +621,7 @@ function N({
620
621
  color: "transparent",
621
622
  WebkitTextFillColor: "transparent",
622
623
  backgroundRepeat: "no-repeat, padding-box",
623
- "--spread": `${S}px`,
624
+ "--spread": `${b}px`,
624
625
  "--base-color": s,
625
626
  "--shimmer-color": d,
626
627
  "--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
@@ -631,7 +632,7 @@ function N({
631
632
  opacity: 0
632
633
  },
633
634
  animate: f ? {
634
- backgroundPosition: k,
635
+ backgroundPosition: C,
635
636
  opacity: 1
636
637
  } : {},
637
638
  transition: {
@@ -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: {
@@ -686,8 +687,8 @@ const ye = ({ progressViewItems: e }) => {
686
687
  const t = e[e.length - 1];
687
688
  if (!t) return null;
688
689
  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,
690
+ return /* @__PURE__ */ l("div", { className: "simple-mode-container", children: /* @__PURE__ */ l(j, { mode: "wait", children: /* @__PURE__ */ l(
691
+ k.div,
691
692
  {
692
693
  initial: { opacity: 0, y: 10 },
693
694
  animate: { opacity: 1, y: 0 },
@@ -701,7 +702,7 @@ const ye = ({ progressViewItems: e }) => {
701
702
  children: n
702
703
  }
703
704
  ) : /* @__PURE__ */ l(
704
- N,
705
+ M,
705
706
  {
706
707
  text: n,
707
708
  className: "simple-mode-title",
@@ -718,9 +719,9 @@ const ye = ({ progressViewItems: e }) => {
718
719
  data: e,
719
720
  isLatest: t = !1,
720
721
  durationSeconds: n
721
- }) => /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
722
+ }) => /* @__PURE__ */ T("div", { style: { padding: "16px" }, children: [
722
723
  /* @__PURE__ */ l(
723
- T.div,
724
+ k.div,
724
725
  {
725
726
  style: {
726
727
  display: "flex",
@@ -732,7 +733,7 @@ const ye = ({ progressViewItems: e }) => {
732
733
  animate: { opacity: 1, y: 0 },
733
734
  transition: { duration: 0.3, delay: 0 },
734
735
  children: t && !n ? /* @__PURE__ */ l(
735
- N,
736
+ M,
736
737
  {
737
738
  text: e.title,
738
739
  duration: 2.5,
@@ -743,7 +744,7 @@ const ye = ({ progressViewItems: e }) => {
743
744
  ) : /* @__PURE__ */ l("span", { style: { color: "#666" }, children: e.title })
744
745
  }
745
746
  ),
746
- n !== void 0 && /* @__PURE__ */ C(
747
+ n !== void 0 && /* @__PURE__ */ T(
747
748
  "div",
748
749
  {
749
750
  style: {
@@ -916,55 +917,55 @@ const ye = ({ progressViewItems: e }) => {
916
917
  fetchClientToken: n,
917
918
  durationSeconds: r
918
919
  }) => {
919
- const { fency: a } = M(), m = U(
920
+ const { fency: o } = N(), m = U(
920
921
  async (c) => {
921
922
  try {
922
- const { clientToken: o } = await n(), g = await J({
923
- pk: a.publishableKey,
924
- baseUrl: a.baseUrl,
925
- clientToken: o,
923
+ const { clientToken: i } = await n(), g = await J({
924
+ pk: o.publishableKey,
925
+ baseUrl: o.baseUrl,
926
+ clientToken: i,
926
927
  streamToken: t,
927
928
  request: { fileId: c }
928
929
  });
929
930
  g.type === "success" && window.open(g.downloadLink, "_blank");
930
- } catch (o) {
931
- console.error("Failed to download file:", o);
931
+ } catch (i) {
932
+ console.error("Failed to download file:", i);
932
933
  }
933
934
  },
934
- [a, t, n]
935
+ [o, t, n]
935
936
  );
936
- return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
937
+ return /* @__PURE__ */ T("div", { style: { padding: "16px" }, children: [
937
938
  /* @__PURE__ */ l(
938
- T.div,
939
+ k.div,
939
940
  {
940
941
  className: "fency-markdown-body-raw",
941
942
  initial: { opacity: 0, y: -10 },
942
943
  animate: { opacity: 1, y: 0 },
943
944
  transition: { duration: 0.3, delay: 0 },
944
945
  children: /* @__PURE__ */ l(
945
- B,
946
+ $,
946
947
  {
947
- remarkPlugins: [z],
948
+ remarkPlugins: [B],
948
949
  components: {
949
950
  code(c) {
950
- const { children: o, className: g, node: i, ref: s, ...d } = c, u = /language-(\w+)/.exec(g || "");
951
+ const { children: i, className: g, node: a, ref: s, ...d } = c, u = /language-(\w+)/.exec(g || "");
951
952
  return u ? /* @__PURE__ */ l(
952
953
  R,
953
954
  {
954
955
  ...d,
955
956
  PreTag: "div",
956
- children: String(o).replace(/\n$/, ""),
957
+ children: String(i).replace(/\n$/, ""),
957
958
  language: u[1],
958
959
  style: O
959
960
  }
960
- ) : /* @__PURE__ */ l("code", { ...d, className: g, children: String(o) });
961
+ ) : /* @__PURE__ */ l("code", { ...d, className: g, children: String(i) });
961
962
  },
962
963
  a(c) {
963
- const { children: o, href: g, ...i } = c;
964
+ const { children: i, href: g, ...a } = c;
964
965
  return /* @__PURE__ */ l(
965
966
  "a",
966
967
  {
967
- ...i,
968
+ ...a,
968
969
  href: g,
969
970
  onClick: (s) => {
970
971
  if (!g) return;
@@ -973,7 +974,7 @@ const ye = ({ progressViewItems: e }) => {
973
974
  );
974
975
  d && (s.preventDefault(), m(d[1]));
975
976
  },
976
- children: o
977
+ children: i
977
978
  }
978
979
  );
979
980
  }
@@ -983,7 +984,7 @@ const ye = ({ progressViewItems: e }) => {
983
984
  )
984
985
  }
985
986
  ),
986
- r !== void 0 && /* @__PURE__ */ C(
987
+ r !== void 0 && /* @__PURE__ */ T(
987
988
  "div",
988
989
  {
989
990
  style: {
@@ -1000,25 +1001,25 @@ const ye = ({ progressViewItems: e }) => {
1000
1001
  }
1001
1002
  )
1002
1003
  ] });
1003
- }, be = ({
1004
+ }, Se = ({
1004
1005
  data: e,
1005
1006
  completed: t,
1006
1007
  isLatest: n = !1,
1007
1008
  durationSeconds: r
1008
1009
  }) => {
1009
- const a = I(null);
1010
+ const o = I(null);
1010
1011
  return w(() => {
1011
- a.current && !t && (a.current.scrollTop = a.current.scrollHeight);
1012
- }, [e.reasoning, t]), /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
1012
+ o.current && !t && (o.current.scrollTop = o.current.scrollHeight);
1013
+ }, [e.reasoning, t]), /* @__PURE__ */ T("div", { style: { padding: "16px" }, children: [
1013
1014
  /* @__PURE__ */ l(
1014
- T.h3,
1015
+ k.h3,
1015
1016
  {
1016
1017
  style: { marginBottom: "10px", color: "#666" },
1017
1018
  initial: { opacity: 0, y: -10 },
1018
1019
  animate: { opacity: 1, y: 0 },
1019
1020
  transition: { duration: 0.3, delay: 0 },
1020
1021
  children: n && !r ? /* @__PURE__ */ l(
1021
- N,
1022
+ M,
1022
1023
  {
1023
1024
  text: e.title,
1024
1025
  duration: 2.5,
@@ -1030,9 +1031,9 @@ const ye = ({ progressViewItems: e }) => {
1030
1031
  }
1031
1032
  ),
1032
1033
  /* @__PURE__ */ l(
1033
- T.div,
1034
+ k.div,
1034
1035
  {
1035
- ref: a,
1036
+ ref: o,
1036
1037
  style: {
1037
1038
  maxHeight: "100px",
1038
1039
  overflowY: "auto",
@@ -1046,12 +1047,12 @@ const ye = ({ progressViewItems: e }) => {
1046
1047
  animate: { opacity: 0.5, y: 0 },
1047
1048
  transition: { duration: 0.3, delay: 0.1 },
1048
1049
  children: /* @__PURE__ */ l("div", { className: "fency-markdown-body-raw", children: /* @__PURE__ */ l(
1049
- B,
1050
+ $,
1050
1051
  {
1051
- remarkPlugins: [z],
1052
+ remarkPlugins: [B],
1052
1053
  components: {
1053
1054
  code(m) {
1054
- const { children: c, className: o, node: g, ref: i, ...s } = m, d = /language-(\w+)/.exec(o || "");
1055
+ const { children: c, className: i, node: g, ref: a, ...s } = m, d = /language-(\w+)/.exec(i || "");
1055
1056
  return d ? /* @__PURE__ */ l(
1056
1057
  R,
1057
1058
  {
@@ -1061,7 +1062,7 @@ const ye = ({ progressViewItems: e }) => {
1061
1062
  language: d[1],
1062
1063
  style: O
1063
1064
  }
1064
- ) : /* @__PURE__ */ l("code", { ...s, className: o, children: String(c) });
1065
+ ) : /* @__PURE__ */ l("code", { ...s, className: i, children: String(c) });
1065
1066
  }
1066
1067
  },
1067
1068
  children: e.reasoning
@@ -1069,7 +1070,7 @@ const ye = ({ progressViewItems: e }) => {
1069
1070
  ) })
1070
1071
  }
1071
1072
  ),
1072
- r !== void 0 && /* @__PURE__ */ C(
1073
+ r !== void 0 && /* @__PURE__ */ T(
1073
1074
  "div",
1074
1075
  {
1075
1076
  style: {
@@ -1086,29 +1087,29 @@ const ye = ({ progressViewItems: e }) => {
1086
1087
  }
1087
1088
  )
1088
1089
  ] });
1089
- }, G = ({
1090
+ }, _ = ({
1090
1091
  text: e
1091
1092
  }) => /* @__PURE__ */ l("div", { style: { padding: "16px" }, children: /* @__PURE__ */ l(
1092
- T.div,
1093
+ k.div,
1093
1094
  {
1094
1095
  className: "fency-markdown-body-raw",
1095
1096
  initial: { opacity: 0, y: -10 },
1096
1097
  animate: { opacity: 1, y: 0 },
1097
1098
  transition: { duration: 0.3, delay: 0 },
1098
1099
  children: /* @__PURE__ */ l(
1099
- B,
1100
+ $,
1100
1101
  {
1101
- remarkPlugins: [z],
1102
+ remarkPlugins: [B],
1102
1103
  components: {
1103
1104
  code(t) {
1104
- const { children: n, className: r, node: a, ref: m, ...c } = t, o = /language-(\w+)/.exec(r || "");
1105
- return o ? /* @__PURE__ */ l(
1105
+ const { children: n, className: r, node: o, ref: m, ...c } = t, i = /language-(\w+)/.exec(r || "");
1106
+ return i ? /* @__PURE__ */ l(
1106
1107
  R,
1107
1108
  {
1108
1109
  ...c,
1109
1110
  PreTag: "div",
1110
1111
  children: String(n).replace(/\n$/, ""),
1111
- language: o[1],
1112
+ language: i[1],
1112
1113
  style: O
1113
1114
  }
1114
1115
  ) : /* @__PURE__ */ l("code", { ...c, className: r, children: String(n) });
@@ -1118,10 +1119,10 @@ const ye = ({ progressViewItems: e }) => {
1118
1119
  }
1119
1120
  )
1120
1121
  }
1121
- ) }), Se = ({ data: e }) => {
1122
+ ) }), be = ({ data: e }) => {
1122
1123
  const t = JSON.stringify(e.json, null, 2);
1123
1124
  return /* @__PURE__ */ l("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ l(
1124
- T.div,
1125
+ k.div,
1125
1126
  {
1126
1127
  initial: { opacity: 0, y: -10 },
1127
1128
  animate: { opacity: 1, y: 0 },
@@ -1129,11 +1130,11 @@ const ye = ({ progressViewItems: e }) => {
1129
1130
  children: /* @__PURE__ */ l(R, { language: "json", style: O, PreTag: "div", children: t })
1130
1131
  }
1131
1132
  ) });
1132
- }, ke = ({ data: e, isLatest: t = !1, durationSeconds: n }) => {
1133
+ }, Ce = ({ data: e, isLatest: t = !1, durationSeconds: n }) => {
1133
1134
  const r = `Searching: ${e.queryDescription}`;
1134
- return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
1135
+ return /* @__PURE__ */ T("div", { style: { padding: "16px" }, children: [
1135
1136
  /* @__PURE__ */ l(
1136
- T.div,
1137
+ k.div,
1137
1138
  {
1138
1139
  style: {
1139
1140
  display: "flex",
@@ -1145,7 +1146,7 @@ const ye = ({ progressViewItems: e }) => {
1145
1146
  animate: { opacity: 1, y: 0 },
1146
1147
  transition: { duration: 0.3, delay: 0 },
1147
1148
  children: t && !n ? /* @__PURE__ */ l(
1148
- N,
1149
+ M,
1149
1150
  {
1150
1151
  text: r,
1151
1152
  duration: 2.5,
@@ -1156,7 +1157,7 @@ const ye = ({ progressViewItems: e }) => {
1156
1157
  ) : /* @__PURE__ */ l("span", { style: { color: "#666" }, children: r })
1157
1158
  }
1158
1159
  ),
1159
- n !== void 0 && /* @__PURE__ */ C(
1160
+ n !== void 0 && /* @__PURE__ */ T(
1160
1161
  "div",
1161
1162
  {
1162
1163
  style: {
@@ -1173,11 +1174,11 @@ const ye = ({ progressViewItems: e }) => {
1173
1174
  }
1174
1175
  )
1175
1176
  ] });
1176
- }, Ce = ({ isLatest: e = !1, durationSeconds: t }) => {
1177
+ }, ke = ({ isLatest: e = !1, durationSeconds: t }) => {
1177
1178
  const n = "Finding sources...";
1178
- return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
1179
+ return /* @__PURE__ */ T("div", { style: { padding: "16px" }, children: [
1179
1180
  /* @__PURE__ */ l(
1180
- T.div,
1181
+ k.div,
1181
1182
  {
1182
1183
  style: {
1183
1184
  display: "flex",
@@ -1189,7 +1190,7 @@ const ye = ({ progressViewItems: e }) => {
1189
1190
  animate: { opacity: 1, y: 0 },
1190
1191
  transition: { duration: 0.3, delay: 0 },
1191
1192
  children: e && !t ? /* @__PURE__ */ l(
1192
- N,
1193
+ M,
1193
1194
  {
1194
1195
  text: n,
1195
1196
  duration: 2.5,
@@ -1200,7 +1201,7 @@ const ye = ({ progressViewItems: e }) => {
1200
1201
  ) : /* @__PURE__ */ l("span", { style: { color: "#666" }, children: n })
1201
1202
  }
1202
1203
  ),
1203
- t !== void 0 && /* @__PURE__ */ C(
1204
+ t !== void 0 && /* @__PURE__ */ T(
1204
1205
  "div",
1205
1206
  {
1206
1207
  style: {
@@ -1217,9 +1218,9 @@ const ye = ({ progressViewItems: e }) => {
1217
1218
  }
1218
1219
  )
1219
1220
  ] });
1220
- }, Te = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
1221
+ }, Te = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ T("div", { style: { padding: "16px" }, children: [
1221
1222
  /* @__PURE__ */ l(
1222
- T.div,
1223
+ k.div,
1223
1224
  {
1224
1225
  style: { color: "#666", marginBottom: "10px", fontSize: "14px" },
1225
1226
  initial: { opacity: 0, y: -10 },
@@ -1228,8 +1229,8 @@ const ye = ({ progressViewItems: e }) => {
1228
1229
  children: "Sources"
1229
1230
  }
1230
1231
  ),
1231
- /* @__PURE__ */ l("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.map((n, r) => /* @__PURE__ */ l(
1232
- ve,
1232
+ /* @__PURE__ */ l("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.length === 0 ? /* @__PURE__ */ l("span", { style: { fontSize: "13px", color: "#888" }, children: "No sources" }) : e.sources.map((n, r) => /* @__PURE__ */ l(
1233
+ xe,
1233
1234
  {
1234
1235
  source: n,
1235
1236
  index: r,
@@ -1237,17 +1238,26 @@ const ye = ({ progressViewItems: e }) => {
1237
1238
  },
1238
1239
  n.memoryId
1239
1240
  )) })
1240
- ] }), ve = ({ source: e, index: t, onSourceClick: n }) => {
1241
- const [r, a] = x(!1), m = !!n;
1242
- return /* @__PURE__ */ C(
1243
- T.div,
1241
+ ] });
1242
+ function ve(e, t) {
1243
+ if (t.length === 0) return e;
1244
+ if (t.length === 1) return `${e} page ${t[0]}`;
1245
+ if (t.length === 2)
1246
+ return `${e} pages ${t[0]} and ${t[1]}`;
1247
+ const n = t[t.length - 1], r = t.slice(0, -1).join(", ");
1248
+ return `${e} pages ${r} and ${n}`;
1249
+ }
1250
+ const xe = ({ source: e, index: t, onSourceClick: n }) => {
1251
+ const [r, o] = x(!1), m = !!n, c = ve(e.memoryTitle, e.pageNumbers);
1252
+ return /* @__PURE__ */ l(
1253
+ k.div,
1244
1254
  {
1245
1255
  initial: { opacity: 0, scale: 0.9 },
1246
1256
  animate: { opacity: 1, scale: 1 },
1247
1257
  transition: { duration: 0.25, delay: t * 0.05 },
1248
1258
  onClick: m ? () => n(e.memoryId) : void 0,
1249
- onMouseEnter: m ? () => a(!0) : void 0,
1250
- onMouseLeave: m ? () => a(!1) : void 0,
1259
+ onMouseEnter: m ? () => o(!0) : void 0,
1260
+ onMouseLeave: m ? () => o(!1) : void 0,
1251
1261
  style: {
1252
1262
  display: "inline-flex",
1253
1263
  flexDirection: "column",
@@ -1260,79 +1270,76 @@ const ye = ({ progressViewItems: e }) => {
1260
1270
  transition: "background-color 0.15s ease",
1261
1271
  userSelect: "none"
1262
1272
  },
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
- ]
1273
+ children: /* @__PURE__ */ l("span", { style: { fontSize: "13px", fontWeight: 500, color: "#333" }, children: c })
1267
1274
  }
1268
1275
  );
1269
- }, xe = ({ progressViewItems: e, streamToken: t, fetchClientToken: n, loadingText: r, onSourceClick: a }) => {
1276
+ }, we = ({ progressViewItems: e, streamToken: t, fetchClientToken: n, loadingText: r, onSourceClick: o }) => {
1270
1277
  const m = I(null);
1271
1278
  w(() => {
1272
1279
  m.current && (m.current.scrollTop = m.current.scrollHeight);
1273
1280
  }, [e.length]);
1274
- const c = (o) => {
1275
- switch (o.item.data.type) {
1281
+ const c = (i) => {
1282
+ switch (i.item.data.type) {
1276
1283
  case "GenericAgentTaskExecution":
1277
1284
  return /* @__PURE__ */ l(
1278
1285
  fe,
1279
1286
  {
1280
- data: o.item.data,
1281
- completed: o.completed,
1282
- isLatest: o.isLatest,
1283
- durationSeconds: o.durationSeconds
1287
+ data: i.item.data,
1288
+ completed: i.completed,
1289
+ isLatest: i.isLatest,
1290
+ durationSeconds: i.durationSeconds
1284
1291
  }
1285
1292
  );
1286
1293
  case "GenericAgentTaskReasoning":
1287
1294
  return /* @__PURE__ */ l(
1288
- be,
1295
+ Se,
1289
1296
  {
1290
- data: o.item.data,
1291
- completed: o.completed,
1292
- isLatest: o.isLatest,
1293
- durationSeconds: o.durationSeconds
1297
+ data: i.item.data,
1298
+ completed: i.completed,
1299
+ isLatest: i.isLatest,
1300
+ durationSeconds: i.durationSeconds
1294
1301
  }
1295
1302
  );
1296
1303
  case "GenericAgentTaskFinalResponse":
1297
1304
  return /* @__PURE__ */ l(
1298
1305
  he,
1299
1306
  {
1300
- data: o.item.data,
1307
+ data: i.item.data,
1301
1308
  streamToken: t,
1302
1309
  fetchClientToken: n,
1303
- durationSeconds: o.durationSeconds
1310
+ durationSeconds: i.durationSeconds
1304
1311
  }
1305
1312
  );
1306
1313
  case "StreamingChatCompletionText":
1307
- return /* @__PURE__ */ l(G, { text: o.item.data.text });
1314
+ return /* @__PURE__ */ l(_, { text: i.item.data.text });
1308
1315
  case "StructuredChatCompletionJson":
1309
- return /* @__PURE__ */ l(Se, { data: o.item.data });
1316
+ return /* @__PURE__ */ l(be, { data: i.item.data });
1310
1317
  case "StreamingMemoryTypeChatCompletionText":
1311
- return /* @__PURE__ */ l(G, { text: o.item.data.text });
1318
+ return /* @__PURE__ */ l(_, { text: i.item.data.text });
1312
1319
  case "StreamingMemoryTypeChatCompletionSearch":
1313
1320
  return /* @__PURE__ */ l(
1314
- ke,
1321
+ Ce,
1315
1322
  {
1316
- data: o.item.data,
1317
- isLatest: o.isLatest,
1318
- durationSeconds: o.durationSeconds
1323
+ data: i.item.data,
1324
+ isLatest: i.isLatest,
1325
+ durationSeconds: i.durationSeconds
1319
1326
  }
1320
1327
  );
1321
1328
  case "StreamingMemoryTypeChatCompletionFindSources":
1322
1329
  return /* @__PURE__ */ l(
1323
- Ce,
1330
+ ke,
1324
1331
  {
1325
- data: o.item.data,
1326
- isLatest: o.isLatest,
1327
- durationSeconds: o.durationSeconds
1332
+ data: i.item.data,
1333
+ isLatest: i.isLatest,
1334
+ durationSeconds: i.durationSeconds
1328
1335
  }
1329
1336
  );
1330
1337
  case "StreamingMemoryTypeChatCompletionSourcesResult":
1331
1338
  return /* @__PURE__ */ l(
1332
1339
  Te,
1333
1340
  {
1334
- data: o.item.data,
1335
- onSourceClick: a
1341
+ data: i.item.data,
1342
+ onSourceClick: o
1336
1343
  }
1337
1344
  );
1338
1345
  default:
@@ -1340,7 +1347,7 @@ const ye = ({ progressViewItems: e }) => {
1340
1347
  }
1341
1348
  };
1342
1349
  return e.length === 0 ? /* @__PURE__ */ l("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ l(
1343
- N,
1350
+ M,
1344
1351
  {
1345
1352
  text: r ?? "Processing your task...",
1346
1353
  duration: 1.5,
@@ -1349,10 +1356,10 @@ const ye = ({ progressViewItems: e }) => {
1349
1356
  color: "#999",
1350
1357
  shimmerColor: "#000"
1351
1358
  }
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,
1359
+ ) }) : /* @__PURE__ */ l("div", { id: "agent-task-progress-verbose", ref: m, children: /* @__PURE__ */ l(j, { children: e.map((i, g) => /* @__PURE__ */ l(
1360
+ k.div,
1354
1361
  {
1355
- id: `agent-task-progress-item-${o.item.progressItemId}`,
1362
+ id: `agent-task-progress-item-${i.item.progressItemId}`,
1356
1363
  initial: { opacity: 0, y: -20 },
1357
1364
  animate: { opacity: 1, y: 0 },
1358
1365
  transition: {
@@ -1360,28 +1367,30 @@ const ye = ({ progressViewItems: e }) => {
1360
1367
  delay: g * 0.1,
1361
1368
  ease: "easeOut"
1362
1369
  },
1363
- children: c(o)
1370
+ children: c(i)
1364
1371
  },
1365
- o.item.progressItemId
1372
+ i.item.progressItemId
1366
1373
  )) }) });
1367
1374
  }, Be = ({
1368
1375
  agentTask: e,
1369
1376
  mode: t = "verbose",
1370
1377
  streamToken: n,
1371
- fetchClientToken: r
1378
+ fetchClientToken: r,
1379
+ onSourceClick: o
1372
1380
  }) => {
1373
- const a = me(e);
1374
- return t === "simple" ? /* @__PURE__ */ l(ye, { progressViewItems: a }) : /* @__PURE__ */ l(
1375
- xe,
1381
+ const m = me(e);
1382
+ return t === "simple" ? /* @__PURE__ */ l(ye, { progressViewItems: m }) : /* @__PURE__ */ l(
1383
+ we,
1376
1384
  {
1377
- progressViewItems: a,
1385
+ progressViewItems: m,
1378
1386
  streamToken: n,
1379
1387
  fetchClientToken: r,
1380
- loadingText: e.loadingText
1388
+ loadingText: e.loadingText,
1389
+ onSourceClick: o
1381
1390
  }
1382
1391
  );
1383
1392
  };
1384
- class we {
1393
+ class Ae {
1385
1394
  constructor(t) {
1386
1395
  this.eventSources = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Map(), this.fency = t;
1387
1396
  }
@@ -1391,22 +1400,22 @@ class we {
1391
1400
  */
1392
1401
  updateStreams(t) {
1393
1402
  t.forEach((r) => {
1394
- const a = r.stream.id;
1395
- this.eventSources.has(a) || this.connectStream(r);
1403
+ const o = r.stream.id;
1404
+ this.eventSources.has(o) || this.connectStream(r);
1396
1405
  });
1397
1406
  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));
1407
+ this.eventSources.forEach((r, o) => {
1408
+ n.has(o) || (r.abort(), this.eventSources.delete(o));
1400
1409
  });
1401
1410
  }
1402
1411
  connectStream(t) {
1403
1412
  const n = t.stream.id, r = new AbortController();
1404
1413
  this.eventSources.set(n, r);
1405
- const a = `${this.fency.baseUrl}/sse/streams/${n}`, m = {
1414
+ const o = `${this.fency.baseUrl}/sse/streams/${n}`, m = {
1406
1415
  "X-Fency-Publishable-Key": this.fency.publishableKey,
1407
1416
  "X-Fency-Stream-Token": t.stream.token
1408
1417
  };
1409
- H(a, {
1418
+ H(o, {
1410
1419
  headers: m,
1411
1420
  signal: r.signal,
1412
1421
  async onopen(c) {
@@ -1415,8 +1424,8 @@ class we {
1415
1424
  },
1416
1425
  onmessage: (c) => {
1417
1426
  if (c.data) {
1418
- const o = K(c.data);
1419
- this.broadcast(o, n);
1427
+ const i = K(c.data);
1428
+ this.broadcast(i, n);
1420
1429
  }
1421
1430
  },
1422
1431
  onerror: (c) => {
@@ -1452,35 +1461,35 @@ class we {
1452
1461
  this.eventSources.forEach((t) => t.abort()), this.eventSources.clear(), this.subscribers.clear();
1453
1462
  }
1454
1463
  }
1455
- const Ae = 12e4, Ie = (e) => {
1464
+ const Ie = 12e4, Pe = (e) => {
1456
1465
  const t = Date.now();
1457
- return e.filter((n) => t - n.createdAt < Ae);
1466
+ return e.filter((n) => t - n.createdAt < Ie);
1458
1467
  };
1459
1468
  function ze({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
1460
- const [r, a] = x(
1469
+ const [r, o] = x(
1461
1470
  null
1462
- ), [m, c] = x(!0), [o, g] = x(null), [i, s] = x([]), d = I(null), u = I(null);
1471
+ ), [m, c] = x(!0), [i, g] = x(null), [a, s] = x([]), d = I(null), u = I(null);
1463
1472
  w(() => {
1464
1473
  e.then((f) => {
1465
- a(f), c(!1);
1474
+ o(f), c(!1);
1466
1475
  }).catch((f) => {
1467
1476
  g(f), c(!1);
1468
1477
  });
1469
1478
  }, [e]), w(() => {
1470
- r && !u.current && (u.current = new we(r));
1479
+ r && !u.current && (u.current = new Ae(r));
1471
1480
  }, [r]), w(() => {
1472
- u.current && u.current.updateStreams(i);
1473
- }, [i]), w(() => () => {
1481
+ u.current && u.current.updateStreams(a);
1482
+ }, [a]), w(() => () => {
1474
1483
  var f;
1475
1484
  (f = u.current) == null || f.cleanup();
1476
1485
  }, []);
1477
- const b = U(
1486
+ const S = U(
1478
1487
  async (f = 3e4) => {
1479
1488
  if (d.current)
1480
1489
  return d.current;
1481
- const h = Date.now(), k = i.length > 0 ? i[i.length - 1] : null;
1482
- if (k && h - k.createdAt < f)
1483
- return k.stream;
1490
+ const h = Date.now(), C = a.length > 0 ? a[a.length - 1] : null;
1491
+ if (C && h - C.createdAt < f)
1492
+ return C.stream;
1484
1493
  const P = (async () => {
1485
1494
  if (!r)
1486
1495
  throw new Error("Fency instance not initialized");
@@ -1496,50 +1505,50 @@ function ze({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
1496
1505
  };
1497
1506
  return s((p) => {
1498
1507
  const v = [...p, F];
1499
- return Ie(v);
1508
+ return Pe(v);
1500
1509
  }), d.current = null, E.stream;
1501
1510
  } else
1502
1511
  throw d.current = null, new Error("Failed to create stream");
1503
1512
  })();
1504
1513
  return d.current = P, P;
1505
1514
  },
1506
- [r, i]
1515
+ [r, a]
1507
1516
  );
1508
- if (o)
1509
- return /* @__PURE__ */ C("div", { children: [
1517
+ if (i)
1518
+ return /* @__PURE__ */ T("div", { children: [
1510
1519
  "Fency error: ",
1511
- o.message
1520
+ i.message
1512
1521
  ] });
1513
1522
  if (!r)
1514
1523
  return null;
1515
- const y = i.length > 0 ? i[i.length - 1] : null, S = {
1524
+ const y = a.length > 0 ? a[a.length - 1] : null, b = {
1516
1525
  fency: r,
1517
1526
  loading: m,
1518
- error: o,
1519
- activeStreams: i,
1527
+ error: i,
1528
+ activeStreams: a,
1520
1529
  latestStream: y,
1521
1530
  eventManager: u.current,
1522
- getOrCreateStream: b
1531
+ getOrCreateStream: S
1523
1532
  };
1524
- return /* @__PURE__ */ l($.Provider, { value: S, children: n });
1533
+ return /* @__PURE__ */ l(W.Provider, { value: b, children: n });
1525
1534
  }
1526
1535
  export {
1527
1536
  Be as AgentTaskProgress,
1528
1537
  ye as AgentTaskProgressSimple,
1529
- xe as AgentTaskProgressVerbose,
1538
+ we as AgentTaskProgressVerbose,
1530
1539
  ze as FencyProvider,
1531
1540
  fe as GenericAgentTaskExecution,
1532
1541
  he as GenericAgentTaskFinalResponse,
1533
- be as GenericAgentTaskReasoning,
1534
- N as ShimmeringText,
1535
- G as StreamingChatCompletionText,
1536
- Ce as StreamingMemoryTypeChatCompletionFindSources,
1537
- ke as StreamingMemoryTypeChatCompletionSearch,
1542
+ Se as GenericAgentTaskReasoning,
1543
+ M as ShimmeringText,
1544
+ _ as StreamingChatCompletionText,
1545
+ ke as StreamingMemoryTypeChatCompletionFindSources,
1546
+ Ce as StreamingMemoryTypeChatCompletionSearch,
1538
1547
  Te as StreamingMemoryTypeChatCompletionSourcesResult,
1539
- Se as StructuredChatCompletionJson,
1540
- Oe as useAgentTasks,
1541
- M as useFencyContext,
1542
- De as useFencyEventSource,
1543
- Ue as usePaginatedQuery,
1548
+ be as StructuredChatCompletionJson,
1549
+ De as useAgentTasks,
1550
+ N as useFencyContext,
1551
+ Ue as useFencyEventSource,
1552
+ $e as usePaginatedQuery,
1544
1553
  ae as useStream
1545
1554
  };