@fencyai/react 0.1.152 → 0.1.154

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/agent-task/AgentTaskMemoryClickPayload.d.ts +6 -0
  2. package/dist/agent-task/AgentTaskMemoryClickPayload.d.ts.map +1 -0
  3. package/dist/agent-task/AgentTaskProgress.d.ts +3 -2
  4. package/dist/agent-task/AgentTaskProgress.d.ts.map +1 -1
  5. package/dist/agent-task/AgentTaskProgressSimple.d.ts.map +1 -1
  6. package/dist/agent-task/AgentTaskProgressVerbose.d.ts +3 -2
  7. package/dist/agent-task/AgentTaskProgressVerbose.d.ts.map +1 -1
  8. package/dist/agent-task/data-types/MemoryChatCompletionSourcesResult.d.ts +2 -1
  9. package/dist/agent-task/data-types/MemoryChatCompletionSourcesResult.d.ts.map +1 -1
  10. package/dist/agent-task/data-types/MemorySearchCompletedResults.d.ts +2 -1
  11. package/dist/agent-task/data-types/MemorySearchCompletedResults.d.ts.map +1 -1
  12. package/dist/agent-task/data-types/MemorySearchSearchMemoryTypes.d.ts.map +1 -1
  13. package/dist/agent-task/data-types/StructuredChatCompletionJson.d.ts +1 -1
  14. package/dist/agent-task/data-types/StructuredChatCompletionJson.d.ts.map +1 -1
  15. package/dist/agent-task/data-types/mergeOverlappingChunkContents.d.ts +9 -0
  16. package/dist/agent-task/data-types/mergeOverlappingChunkContents.d.ts.map +1 -0
  17. package/dist/agent-task/translations.d.ts +4 -1
  18. package/dist/agent-task/translations.d.ts.map +1 -1
  19. package/dist/hooks/useAgentTasks/index.d.ts.map +1 -1
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +409 -343
  23. package/dist/types/CreateAgentTaskParams.d.ts +7 -3
  24. package/dist/types/CreateAgentTaskParams.d.ts.map +1 -1
  25. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsxs as y, jsx as i, Fragment as E } from "react/jsx-runtime";
1
+ import { jsxs as f, jsx as i, Fragment as E } from "react/jsx-runtime";
2
2
  import { createStream as Q, isStreamTimeoutEvent as Z, isStreamNotFoundEvent as ee, isAgentTaskProgressItemUpdatedEvent as te, createAgentTask as ne } from "@fencyai/js";
3
3
  import { createContext as re, useState as v, useRef as F, useEffect as A, useCallback as K, useContext as oe, useMemo as W } from "react";
4
- import { useInView as ie, motion as x, AnimatePresence as q } from "motion/react";
4
+ import { useInView as ie, motion as k, AnimatePresence as q } from "motion/react";
5
5
  import ae from "react-markdown";
6
6
  import { Prism as G } from "react-syntax-highlighter";
7
7
  import se from "remark-gfm";
@@ -42,11 +42,11 @@ function ce(e) {
42
42
  };
43
43
  }
44
44
  function de(e, t, n) {
45
- let r = U();
45
+ let r = H();
46
46
  const l = new TextDecoder();
47
47
  return function(a, u) {
48
48
  if (a.length === 0)
49
- n == null || n(r), r = U();
49
+ n == null || n(r), r = H();
50
50
  else if (u > 0) {
51
51
  const d = l.decode(a.subarray(0, u)), o = u + (a[u + 1] === 32 ? 2 : 1), c = l.decode(a.subarray(o));
52
52
  switch (d) {
@@ -61,8 +61,8 @@ function de(e, t, n) {
61
61
  e(r.id = c);
62
62
  break;
63
63
  case "retry":
64
- const g = parseInt(c, 10);
65
- isNaN(g) || t(r.retry = g);
64
+ const m = parseInt(c, 10);
65
+ isNaN(m) || t(r.retry = m);
66
66
  break;
67
67
  }
68
68
  }
@@ -72,7 +72,7 @@ function ue(e, t) {
72
72
  const n = new Uint8Array(e.length + t.length);
73
73
  return n.set(e), n.set(t, e.length), n;
74
74
  }
75
- function U() {
75
+ function H() {
76
76
  return {
77
77
  data: "",
78
78
  event: "",
@@ -88,54 +88,54 @@ var me = function(e, t) {
88
88
  t.indexOf(r[l]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[l]) && (n[r[l]] = e[r[l]]);
89
89
  return n;
90
90
  };
91
- const $ = "text/event-stream", ge = 1e3, _ = "last-event-id";
91
+ const $ = "text/event-stream", ge = 1e3, N = "last-event-id";
92
92
  function pe(e, t) {
93
93
  var { signal: n, headers: r, onopen: l, onmessage: s, onclose: a, onerror: u, openWhenHidden: d, fetch: o } = t, c = me(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
94
- return new Promise((g, m) => {
95
- const f = Object.assign({}, r);
96
- f.accept || (f.accept = $);
97
- let h;
94
+ return new Promise((m, g) => {
95
+ const h = Object.assign({}, r);
96
+ h.accept || (h.accept = $);
97
+ let y;
98
98
  function T() {
99
- h.abort(), document.hidden || w();
99
+ y.abort(), document.hidden || w();
100
100
  }
101
101
  d || document.addEventListener("visibilitychange", T);
102
- let p = ge, k = 0;
102
+ let p = ge, x = 0;
103
103
  function b() {
104
- document.removeEventListener("visibilitychange", T), window.clearTimeout(k), h.abort();
104
+ document.removeEventListener("visibilitychange", T), window.clearTimeout(x), y.abort();
105
105
  }
106
106
  n == null || n.addEventListener("abort", () => {
107
- b(), g();
107
+ b(), m();
108
108
  });
109
- const I = o ?? window.fetch, C = l ?? he;
109
+ const I = o ?? window.fetch, C = l ?? ye;
110
110
  async function w() {
111
- var P;
112
- h = new AbortController();
111
+ var R;
112
+ y = new AbortController();
113
113
  try {
114
- const R = await I(e, Object.assign(Object.assign({}, c), { headers: f, signal: h.signal }));
115
- await C(R), await le(R.body, ce(de((M) => {
116
- M ? f[_] = M : delete f[_];
114
+ const D = await I(e, Object.assign(Object.assign({}, c), { headers: h, signal: y.signal }));
115
+ await C(D), await le(D.body, ce(de((M) => {
116
+ M ? h[N] = M : delete h[N];
117
117
  }, (M) => {
118
118
  p = M;
119
- }, s))), a == null || a(), b(), g();
120
- } catch (R) {
121
- if (!h.signal.aborted)
119
+ }, s))), a == null || a(), b(), m();
120
+ } catch (D) {
121
+ if (!y.signal.aborted)
122
122
  try {
123
- const M = (P = u == null ? void 0 : u(R)) !== null && P !== void 0 ? P : p;
124
- window.clearTimeout(k), k = window.setTimeout(w, M);
123
+ const M = (R = u == null ? void 0 : u(D)) !== null && R !== void 0 ? R : p;
124
+ window.clearTimeout(x), x = window.setTimeout(w, M);
125
125
  } catch (M) {
126
- b(), m(M);
126
+ b(), g(M);
127
127
  }
128
128
  }
129
129
  }
130
130
  w();
131
131
  });
132
132
  }
133
- function he(e) {
133
+ function ye(e) {
134
134
  const t = e.headers.get("content-type");
135
135
  if (!(t != null && t.startsWith($)))
136
136
  throw new Error(`Expected content-type to be ${$}, Actual: ${t}`);
137
137
  }
138
- function ye(e) {
138
+ function he(e) {
139
139
  const t = atob(e), n = new Uint8Array(t.length);
140
140
  for (let r = 0; r < t.length; r++)
141
141
  n[r] = t.charCodeAt(r);
@@ -175,7 +175,7 @@ class fe {
175
175
  },
176
176
  onmessage: (a) => {
177
177
  if (a.data) {
178
- const u = ye(a.data);
178
+ const u = he(a.data);
179
179
  this.broadcast(u, n);
180
180
  }
181
181
  },
@@ -216,10 +216,10 @@ const Se = 12e4, Te = (e) => {
216
216
  const t = Date.now();
217
217
  return e.filter((n) => t - n.createdAt < Se);
218
218
  };
219
- function at({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
219
+ function ut({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
220
220
  const [r, l] = v(
221
221
  null
222
- ), [s, a] = v(!0), [u, d] = v(null), [o, c] = v([]), g = F(null), m = F(null);
222
+ ), [s, a] = v(!0), [u, d] = v(null), [o, c] = v([]), m = F(null), g = F(null);
223
223
  A(() => {
224
224
  e.then((p) => {
225
225
  l(p), a(!1);
@@ -227,19 +227,19 @@ function at({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
227
227
  d(p), a(!1);
228
228
  });
229
229
  }, [e]), A(() => {
230
- r && !m.current && (m.current = new fe(r));
230
+ r && !g.current && (g.current = new fe(r));
231
231
  }, [r]), A(() => {
232
- m.current && m.current.updateStreams(o);
232
+ g.current && g.current.updateStreams(o);
233
233
  }, [o]), A(() => () => {
234
234
  var p;
235
- (p = m.current) == null || p.cleanup();
235
+ (p = g.current) == null || p.cleanup();
236
236
  }, []);
237
- const f = K(
237
+ const h = K(
238
238
  async (p = 3e4) => {
239
- if (g.current)
240
- return g.current;
241
- const k = Date.now(), b = o.length > 0 ? o[o.length - 1] : null;
242
- if (b && k - b.createdAt < p)
239
+ if (m.current)
240
+ return m.current;
241
+ const x = Date.now(), b = o.length > 0 ? o[o.length - 1] : null;
242
+ if (b && x - b.createdAt < p)
243
243
  return b.stream;
244
244
  const I = (async () => {
245
245
  if (!r)
@@ -250,53 +250,53 @@ function at({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
250
250
  clientToken: (C == null ? void 0 : C.clientToken) ?? ""
251
251
  });
252
252
  if (w.type === "success") {
253
- const P = {
253
+ const R = {
254
254
  stream: w.stream,
255
255
  createdAt: Date.now()
256
256
  };
257
- return c((R) => {
258
- const M = [...R, P];
257
+ return c((D) => {
258
+ const M = [...D, R];
259
259
  return Te(M);
260
- }), g.current = null, w.stream;
260
+ }), m.current = null, w.stream;
261
261
  } else
262
- throw g.current = null, new Error("Failed to create stream");
262
+ throw m.current = null, new Error("Failed to create stream");
263
263
  })();
264
- return g.current = I, I;
264
+ return m.current = I, I;
265
265
  },
266
266
  [r, o]
267
267
  );
268
268
  if (u)
269
- return /* @__PURE__ */ y("div", { children: [
269
+ return /* @__PURE__ */ f("div", { children: [
270
270
  "Fency error: ",
271
271
  u.message
272
272
  ] });
273
273
  if (!r)
274
274
  return null;
275
- const h = o.length > 0 ? o[o.length - 1] : null, T = {
275
+ const y = o.length > 0 ? o[o.length - 1] : null, T = {
276
276
  fency: r,
277
277
  loading: s,
278
278
  error: u,
279
279
  activeStreams: o,
280
- latestStream: h,
281
- eventManager: m.current,
282
- getOrCreateStream: f
280
+ latestStream: y,
281
+ eventManager: g.current,
282
+ getOrCreateStream: h
283
283
  };
284
284
  return /* @__PURE__ */ i(X.Provider, { value: T, children: n });
285
285
  }
286
- function J() {
286
+ function V() {
287
287
  const e = oe(X);
288
288
  if (e === void 0)
289
289
  throw new Error("useFencyContext must be used within a FencyProvider");
290
290
  return e;
291
291
  }
292
- const ke = (e) => {
292
+ const xe = (e) => {
293
293
  try {
294
294
  const t = JSON.parse(e);
295
- return xe(t);
295
+ return ke(t);
296
296
  } catch (t) {
297
297
  return console.error("Error parsing message:", t), null;
298
298
  }
299
- }, xe = (e) => Z(e) ? be(e) : ee(e) ? ve(e) : te(e) ? Ce(e) : null, be = (e) => ({
299
+ }, ke = (e) => Z(e) ? be(e) : ee(e) ? ve(e) : te(e) ? Ce(e) : null, be = (e) => ({
300
300
  type: "STREAM_TIMEOUT",
301
301
  streamId: e.streamId,
302
302
  timestamp: e.timestamp
@@ -313,23 +313,23 @@ const ke = (e) => {
313
313
  createdAt: e.createdAt,
314
314
  data: JSON.parse(e.data)
315
315
  }), Me = (e) => {
316
- const t = J(), [n, r] = v(null), l = F(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
316
+ const t = V(), [n, r] = v(null), l = F(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
317
317
  return A(() => {
318
318
  if (!t.eventManager) return;
319
319
  const a = {
320
320
  onMessage: (d, o) => {
321
- var g, m, f;
322
- const c = ke(d);
321
+ var m, g, h;
322
+ const c = xe(d);
323
323
  if (c)
324
324
  switch (c.type) {
325
325
  case "STREAM_TIMEOUT":
326
- (g = e == null ? void 0 : e.onStreamTimeout) == null || g.call(e, c);
326
+ (m = e == null ? void 0 : e.onStreamTimeout) == null || m.call(e, c);
327
327
  break;
328
328
  case "STREAM_NOT_FOUND":
329
- (m = e == null ? void 0 : e.onStreamNotFound) == null || m.call(e, c);
329
+ (g = e == null ? void 0 : e.onStreamNotFound) == null || g.call(e, c);
330
330
  break;
331
331
  case "AGENT_TASK_PROGRESS_ITEM_UPDATED":
332
- (f = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || f.call(e, c);
332
+ (h = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || h.call(e, c);
333
333
  break;
334
334
  }
335
335
  },
@@ -368,16 +368,16 @@ const ke = (e) => {
368
368
  },
369
369
  stream: n
370
370
  };
371
- }, st = (e) => {
372
- const t = J(), [n, r] = v([]), l = F(/* @__PURE__ */ new Set()), s = F(/* @__PURE__ */ new Map()), { createStream: a } = Me({
371
+ }, mt = (e) => {
372
+ const t = V(), [n, r] = v([]), l = F(/* @__PURE__ */ new Set()), s = F(/* @__PURE__ */ new Map()), { createStream: a } = Me({
373
373
  onAgentTaskProgressItemUpdated: (o) => {
374
- var m;
374
+ var g;
375
375
  if (!l.current.has(o.agentTaskId)) return;
376
376
  const c = o.data;
377
377
  if (c.taskType === "StreamingChatCompletion" && c.eventType === "Completed" || c.taskType === "StructuredChatCompletion" && c.eventType === "Completed" || c.taskType === "MemoryChatCompletion" && c.eventType === "Completed" || c.taskType === "MemorySearch" && c.eventType === "Completed") {
378
- const f = c.taskType === "MemorySearch" && c.eventType === "Completed";
378
+ const h = c.taskType === "MemorySearch" && c.eventType === "Completed" || c.taskType === "StructuredChatCompletion" && c.eventType === "Completed";
379
379
  r(
380
- f ? (T) => T.map((p) => {
380
+ h ? (T) => T.map((p) => {
381
381
  var I;
382
382
  if (((I = p.confirmedData) == null ? void 0 : I.taskId) !== o.agentTaskId)
383
383
  return p;
@@ -393,43 +393,43 @@ const ke = (e) => {
393
393
  };
394
394
  }) : (T) => T.map(
395
395
  (p) => {
396
- var k;
397
- return ((k = p.confirmedData) == null ? void 0 : k.taskId) === o.agentTaskId ? { ...p, loading: !1 } : p;
396
+ var x;
397
+ return ((x = p.confirmedData) == null ? void 0 : x.taskId) === o.agentTaskId ? { ...p, loading: !1 } : p;
398
398
  }
399
399
  )
400
400
  );
401
- const h = s.current.get(
401
+ const y = s.current.get(
402
402
  o.agentTaskId
403
403
  );
404
- h && (s.current.delete(o.agentTaskId), h(c));
404
+ y && (s.current.delete(o.agentTaskId), y(c));
405
405
  return;
406
406
  }
407
- (m = e.onAgentTaskProgressItemUpdated) == null || m.call(e, o), r(
408
- (f) => f.map((h) => {
409
- var k;
410
- if (((k = h.confirmedData) == null ? void 0 : k.taskId) !== o.agentTaskId)
411
- return h;
412
- const p = h.progressItems.some(
407
+ (g = e.onAgentTaskProgressItemUpdated) == null || g.call(e, o), r(
408
+ (h) => h.map((y) => {
409
+ var x;
410
+ if (((x = y.confirmedData) == null ? void 0 : x.taskId) !== o.agentTaskId)
411
+ return y;
412
+ const p = y.progressItems.some(
413
413
  (b) => b.progressItemId === o.progressItemId
414
- ) ? h.progressItems.map(
414
+ ) ? y.progressItems.map(
415
415
  (b) => b.progressItemId === o.progressItemId ? o : b
416
- ) : [...h.progressItems, o];
417
- return { ...h, progressItems: p };
416
+ ) : [...y.progressItems, o];
417
+ return { ...y, progressItems: p };
418
418
  })
419
419
  );
420
420
  },
421
421
  onStreamError: (o) => {
422
422
  var c;
423
- (c = e == null ? void 0 : e.onStreamError) == null || c.call(e, o), r((g) => {
424
- const m = g.find((f) => f.streamId === o.streamId);
425
- return m ? [
426
- ...g.filter((f) => f.streamId !== o.streamId),
423
+ (c = e == null ? void 0 : e.onStreamError) == null || c.call(e, o), r((m) => {
424
+ const g = m.find((h) => h.streamId === o.streamId);
425
+ return g ? [
426
+ ...m.filter((h) => h.streamId !== o.streamId),
427
427
  {
428
- ...m,
428
+ ...g,
429
429
  loading: !1,
430
430
  error: o.error
431
431
  }
432
- ] : g;
432
+ ] : m;
433
433
  });
434
434
  },
435
435
  onStreamNotFound: (o) => {
@@ -442,13 +442,13 @@ const ke = (e) => {
442
442
  }
443
443
  }), u = K(
444
444
  async (o, c) => {
445
- const g = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, m = await a();
446
- if (m.type === "success") {
445
+ const m = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, g = await a();
446
+ if (g.type === "success") {
447
447
  r([
448
448
  ...n,
449
449
  {
450
- taskKey: g,
451
- streamId: m.stream.id,
450
+ taskKey: m,
451
+ streamId: g.stream.id,
452
452
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
453
453
  confirmedData: null,
454
454
  error: null,
@@ -458,11 +458,11 @@ const ke = (e) => {
458
458
  loadingText: c == null ? void 0 : c.loadingText
459
459
  }
460
460
  ]);
461
- const { clientToken: f } = await e.fetchCreateAgentTaskClientToken(o.type), h = await ne({
461
+ const { clientToken: h } = await e.fetchCreateAgentTaskClientToken(o.type), y = await ne({
462
462
  pk: t.fency.publishableKey,
463
463
  baseUrl: t.fency.baseUrl,
464
- clientToken: f,
465
- streamToken: m.stream.token,
464
+ clientToken: h,
465
+ streamToken: g.stream.token,
466
466
  request: {
467
467
  streamingChatCompletionTask: o.type === "StreamingChatCompletion" ? {
468
468
  messages: o.messages,
@@ -484,54 +484,55 @@ const ke = (e) => {
484
484
  query: o.query,
485
485
  model: o.model,
486
486
  language: o.language ?? "en",
487
- chunkLimit: o.chunkLimit ?? 10
487
+ chunkLimit: o.chunkLimit ?? 10,
488
+ contextExpansion: o.contextExpansion
488
489
  } : void 0
489
490
  }
490
491
  });
491
- if (h.type === "success" && h.agentTask) {
492
+ if (y.type === "success" && y.agentTask) {
492
493
  l.current.add(
493
- h.agentTask.id
494
+ y.agentTask.id
494
495
  ), r((p) => [
495
- ...p.filter((k) => k.taskKey !== g),
496
+ ...p.filter((x) => x.taskKey !== m),
496
497
  {
497
- taskKey: g,
498
- streamId: m.stream.id,
498
+ taskKey: m,
499
+ streamId: g.stream.id,
499
500
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
500
- taskId: h.agentTask.id,
501
- createdAt: h.agentTask.createdAt,
501
+ taskId: y.agentTask.id,
502
+ createdAt: y.agentTask.createdAt,
502
503
  error: null,
503
504
  params: o,
504
505
  progressItems: [],
505
506
  loading: !0,
506
507
  loadingText: c == null ? void 0 : c.loadingText,
507
508
  confirmedData: {
508
- taskId: h.agentTask.id,
509
- createdAt: h.agentTask.createdAt
509
+ taskId: y.agentTask.id,
510
+ createdAt: y.agentTask.createdAt
510
511
  }
511
512
  }
512
513
  ]);
513
514
  const T = await new Promise((p) => {
514
515
  s.current.set(
515
- h.agentTask.id,
516
+ y.agentTask.id,
516
517
  p
517
518
  );
518
519
  });
519
520
  return {
520
521
  type: "success",
521
- streamId: m.stream.id,
522
- agentTaskId: h.agentTask.id,
522
+ streamId: g.stream.id,
523
+ agentTaskId: y.agentTask.id,
523
524
  response: T
524
525
  };
525
526
  } else {
526
- if (h.type === "error")
527
+ if (y.type === "error")
527
528
  return r((T) => [
528
- ...T.filter((p) => p.taskKey !== g),
529
+ ...T.filter((p) => p.taskKey !== m),
529
530
  {
530
- taskKey: g,
531
+ taskKey: m,
531
532
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
532
- streamId: m.stream.id,
533
+ streamId: g.stream.id,
533
534
  params: o,
534
- error: h.error,
535
+ error: y.error,
535
536
  progressItems: [],
536
537
  loading: !1,
537
538
  loadingText: c == null ? void 0 : c.loadingText,
@@ -539,7 +540,7 @@ const ke = (e) => {
539
540
  }
540
541
  ]), {
541
542
  type: "error",
542
- error: h.error
543
+ error: y.error
543
544
  };
544
545
  {
545
546
  const T = {
@@ -547,11 +548,11 @@ const ke = (e) => {
547
548
  code: "UnknownError"
548
549
  };
549
550
  return r((p) => [
550
- ...p.filter((k) => k.taskKey !== g),
551
+ ...p.filter((x) => x.taskKey !== m),
551
552
  {
552
- taskKey: g,
553
+ taskKey: m,
553
554
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
554
- streamId: m.stream.id,
555
+ streamId: g.stream.id,
555
556
  error: T,
556
557
  params: o,
557
558
  progressItems: [],
@@ -566,7 +567,7 @@ const ke = (e) => {
566
567
  }
567
568
  }
568
569
  } else
569
- return console.error(m.error), m;
570
+ return console.error(g.error), g;
570
571
  },
571
572
  [t, n, a]
572
573
  ), d = W(() => {
@@ -597,7 +598,7 @@ function Ee(e) {
597
598
  };
598
599
  });
599
600
  }
600
- function D({
601
+ function P({
601
602
  text: e,
602
603
  duration: t = 2,
603
604
  delay: n = 0,
@@ -609,14 +610,14 @@ function D({
609
610
  inViewMargin: d,
610
611
  spread: o = 2,
611
612
  color: c = "#999",
612
- shimmerColor: g = "#000",
613
- direction: m = "fromBottom"
613
+ shimmerColor: m = "#000",
614
+ direction: g = "fromBottom"
614
615
  }) {
615
- const f = F(null), h = ie(f, { once: u, margin: d }), T = W(() => e.length * o, [e, o]), p = !a || h, k = m === "fromBottom" ? "100% center" : "-100% center", b = m === "fromBottom" ? "0% center" : "200% center";
616
+ const h = F(null), y = ie(h, { once: u, margin: d }), T = W(() => e.length * o, [e, o]), p = !a || y, x = g === "fromBottom" ? "100% center" : "-100% center", b = g === "fromBottom" ? "0% center" : "200% center";
616
617
  return /* @__PURE__ */ i(
617
- x.span,
618
+ k.span,
618
619
  {
619
- ref: f,
620
+ ref: h,
620
621
  className: s,
621
622
  style: {
622
623
  position: "relative",
@@ -629,12 +630,12 @@ function D({
629
630
  backgroundRepeat: "no-repeat, padding-box",
630
631
  "--spread": `${T}px`,
631
632
  "--base-color": c,
632
- "--shimmer-color": g,
633
+ "--shimmer-color": m,
633
634
  "--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
634
635
  backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
635
636
  },
636
637
  initial: {
637
- backgroundPosition: k,
638
+ backgroundPosition: x,
638
639
  opacity: 0
639
640
  },
640
641
  animate: p ? {
@@ -666,10 +667,8 @@ function Ie(e, t) {
666
667
  if (n.eventType === "Text") return t.streaming;
667
668
  if (n.eventType === "Completed") return t.completed;
668
669
  }
669
- if (n.taskType === "StructuredChatCompletion") {
670
- if (n.eventType === "Json") return t.generating;
671
- if (n.eventType === "Completed") return t.completed;
672
- }
670
+ if (n.taskType === "StructuredChatCompletion" && n.eventType === "Completed")
671
+ return t.completed;
673
672
  if (n.taskType === "MemorySearch")
674
673
  switch (n.eventType) {
675
674
  case "SearchMemoryTypes":
@@ -705,7 +704,7 @@ const we = ({ progressViewItems: e, t }) => {
705
704
  if (!n) return null;
706
705
  const r = Ie(n, t);
707
706
  return /* @__PURE__ */ i("div", { className: "simple-mode-container", children: /* @__PURE__ */ i(q, { mode: "wait", children: /* @__PURE__ */ i(
708
- x.div,
707
+ k.div,
709
708
  {
710
709
  initial: { opacity: 0, y: 10 },
711
710
  animate: { opacity: 1, y: 0 },
@@ -719,7 +718,7 @@ const we = ({ progressViewItems: e, t }) => {
719
718
  children: r
720
719
  }
721
720
  ) : /* @__PURE__ */ i(
722
- D,
721
+ P,
723
722
  {
724
723
  text: r,
725
724
  className: "simple-mode-title",
@@ -732,7 +731,7 @@ const we = ({ progressViewItems: e, t }) => {
732
731
  },
733
732
  n.item.progressItemId
734
733
  ) }) });
735
- }, V = {
734
+ }, J = {
736
735
  'code[class*="language-"]': {
737
736
  color: "#f8f8f2",
738
737
  background: "none",
@@ -883,10 +882,10 @@ const we = ({ progressViewItems: e, t }) => {
883
882
  italic: {
884
883
  fontStyle: "italic"
885
884
  }
886
- }, j = ({
885
+ }, U = ({
887
886
  text: e
888
887
  }) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
889
- x.div,
888
+ k.div,
890
889
  {
891
890
  className: "fency-markdown-body-raw",
892
891
  initial: { opacity: 0, y: -10 },
@@ -908,7 +907,7 @@ const we = ({ progressViewItems: e, t }) => {
908
907
  PreTag: "div",
909
908
  children: String(n).replace(/\n$/, ""),
910
909
  language: u[1],
911
- style: V
910
+ style: J
912
911
  }
913
912
  )
914
913
  ) : /* @__PURE__ */ i("code", { ...a, className: r, children: String(n) });
@@ -919,14 +918,18 @@ const we = ({ progressViewItems: e, t }) => {
919
918
  )
920
919
  }
921
920
  ) }), Ae = ({ data: e }) => {
922
- const t = JSON.stringify(e.json, null, 2);
921
+ const t = JSON.stringify(
922
+ JSON.parse(e.response.jsonResponse),
923
+ null,
924
+ 2
925
+ );
923
926
  return /* @__PURE__ */ i("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ i(
924
- x.div,
927
+ k.div,
925
928
  {
926
929
  initial: { opacity: 0, y: -10 },
927
930
  animate: { opacity: 1, y: 0 },
928
931
  transition: { duration: 0.3, delay: 0 },
929
- children: /* @__PURE__ */ i(G, { language: "json", style: V, PreTag: "div", children: t })
932
+ children: /* @__PURE__ */ i(G, { language: "json", style: J, PreTag: "div", children: t })
930
933
  }
931
934
  ) });
932
935
  }, Fe = {
@@ -972,7 +975,9 @@ const we = ({ progressViewItems: e, t }) => {
972
975
  memorySearchTypeResultSummaryOne: "Found 1 result. Highest score was {score}",
973
976
  resultsHeading: "Results",
974
977
  viewButton: "View",
975
- pagesLabel: "Pages",
978
+ memorySearchPagesSingle: "Pages {n}",
979
+ memorySearchPagesTwo: "Pages {a} and {b}",
980
+ memorySearchPagesMultiple: "Pages {list} and {n}",
976
981
  pagesNotAvailable: "—",
977
982
  and: "and"
978
983
  },
@@ -1018,12 +1023,14 @@ const we = ({ progressViewItems: e, t }) => {
1018
1023
  memorySearchTypeResultSummaryOne: "Fant 1 resultat. Høyeste poengsum var {score}",
1019
1024
  resultsHeading: "Resultater",
1020
1025
  viewButton: "Vis",
1021
- pagesLabel: "Sider",
1026
+ memorySearchPagesSingle: "Side {n}",
1027
+ memorySearchPagesTwo: "Sider {a} og {b}",
1028
+ memorySearchPagesMultiple: "Sider {list} og {n}",
1022
1029
  pagesNotAvailable: "—",
1023
1030
  and: "og"
1024
1031
  }
1025
1032
  };
1026
- function De(e) {
1033
+ function Pe(e) {
1027
1034
  return Fe[e];
1028
1035
  }
1029
1036
  function S(e, t) {
@@ -1032,7 +1039,7 @@ function S(e, t) {
1032
1039
  e
1033
1040
  );
1034
1041
  }
1035
- function H(e, t) {
1042
+ function _(e, t) {
1036
1043
  const n = e.map((r) => `'${r}'`);
1037
1044
  if (t != null && n.length >= 2) {
1038
1045
  const r = n.pop();
@@ -1040,21 +1047,21 @@ function H(e, t) {
1040
1047
  }
1041
1048
  return n.join(", ");
1042
1049
  }
1043
- const L = 5, Re = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1044
- const [l, s] = v(!1), u = (e.memories ?? []).map((p) => p.memoryTitle), d = u.length > 0, o = d && u.length > L, c = o && !l ? u.slice(0, L) : u, g = u.length - L, m = !o || l, f = `${r.searchingFor}'${e.queryDescription}'`, h = d ? `${r.searchingIn}${H(
1050
+ const O = 5, De = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1051
+ const [l, s] = v(!1), u = (e.memories ?? []).map((p) => p.memoryTitle), d = u.length > 0, o = d && u.length > O, c = o && !l ? u.slice(0, O) : u, m = u.length - O, g = !o || l, h = `${r.searchingFor}'${e.queryDescription}'`, y = d ? `${r.searchingIn}${_(
1045
1052
  c,
1046
- m ? r.and : void 0
1047
- )}` : "", T = d ? `${f}${h}` : `${r.searchingPrefix}${e.queryDescription}`;
1048
- return /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
1053
+ g ? r.and : void 0
1054
+ )}` : "", T = d ? `${h}${y}` : `${r.searchingPrefix}${e.queryDescription}`;
1055
+ return /* @__PURE__ */ f("div", { style: { padding: "16px" }, children: [
1049
1056
  /* @__PURE__ */ i(
1050
- x.div,
1057
+ k.div,
1051
1058
  {
1052
1059
  style: { color: "#666" },
1053
1060
  initial: { opacity: 0, y: -10 },
1054
1061
  animate: { opacity: 1, y: 0 },
1055
1062
  transition: { duration: 0.3, delay: 0 },
1056
1063
  children: t && !n && !o ? /* @__PURE__ */ i(
1057
- D,
1064
+ P,
1058
1065
  {
1059
1066
  text: T,
1060
1067
  duration: 2.5,
@@ -1062,17 +1069,17 @@ const L = 5, Re = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1062
1069
  color: "#999",
1063
1070
  shimmerColor: "#000"
1064
1071
  }
1065
- ) : /* @__PURE__ */ y(E, { children: [
1066
- /* @__PURE__ */ i("span", { style: { color: "#666" }, children: d ? /* @__PURE__ */ y(E, { children: [
1072
+ ) : /* @__PURE__ */ f(E, { children: [
1073
+ /* @__PURE__ */ i("span", { style: { color: "#666" }, children: d ? /* @__PURE__ */ f(E, { children: [
1067
1074
  r.searchingFor,
1068
- /* @__PURE__ */ y("span", { style: { fontWeight: 600 }, children: [
1075
+ /* @__PURE__ */ f("span", { style: { fontWeight: 600 }, children: [
1069
1076
  "'",
1070
1077
  e.queryDescription,
1071
1078
  "'"
1072
1079
  ] }),
1073
- h
1080
+ y
1074
1081
  ] }) : `${r.searchingPrefix}${e.queryDescription}` }),
1075
- o && !l && /* @__PURE__ */ y(E, { children: [
1082
+ o && !l && /* @__PURE__ */ f(E, { children: [
1076
1083
  " ",
1077
1084
  /* @__PURE__ */ i(
1078
1085
  "button",
@@ -1091,12 +1098,12 @@ const L = 5, Re = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1091
1098
  fontFamily: "inherit"
1092
1099
  },
1093
1100
  children: S(r.moreMemories, {
1094
- n: g
1101
+ n: m
1095
1102
  })
1096
1103
  }
1097
1104
  )
1098
1105
  ] }),
1099
- o && l && /* @__PURE__ */ y(E, { children: [
1106
+ o && l && /* @__PURE__ */ f(E, { children: [
1100
1107
  " ",
1101
1108
  /* @__PURE__ */ i(
1102
1109
  "button",
@@ -1134,14 +1141,14 @@ const L = 5, Re = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1134
1141
  }
1135
1142
  )
1136
1143
  ] });
1137
- }, O = 5, Pe = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1138
- const [l, s] = v(!1), a = e.titles, u = a.length > 0, d = u && a.length > O, o = d && !l ? a.slice(0, O) : a, c = a.length - O, g = !d || l, m = u ? `${r.findingMemoriesIn}${H(
1144
+ }, L = 5, Re = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1145
+ const [l, s] = v(!1), a = e.titles, u = a.length > 0, d = u && a.length > L, o = d && !l ? a.slice(0, L) : a, c = a.length - L, m = !d || l, g = u ? `${r.findingMemoriesIn}${_(
1139
1146
  o,
1140
- g ? r.and : void 0
1147
+ m ? r.and : void 0
1141
1148
  )}` : r.findingMemories;
1142
- return /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
1149
+ return /* @__PURE__ */ f("div", { style: { padding: "16px" }, children: [
1143
1150
  /* @__PURE__ */ i(
1144
- x.div,
1151
+ k.div,
1145
1152
  {
1146
1153
  style: {
1147
1154
  color: "#666"
@@ -1150,17 +1157,17 @@ const L = 5, Re = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1150
1157
  animate: { opacity: 1, y: 0 },
1151
1158
  transition: { duration: 0.3, delay: 0 },
1152
1159
  children: t && !n && !d ? /* @__PURE__ */ i(
1153
- D,
1160
+ P,
1154
1161
  {
1155
- text: m,
1162
+ text: g,
1156
1163
  duration: 2.5,
1157
1164
  repeat: !0,
1158
1165
  color: "#999",
1159
1166
  shimmerColor: "#000"
1160
1167
  }
1161
- ) : /* @__PURE__ */ y(E, { children: [
1162
- /* @__PURE__ */ i("span", { style: { color: "#666" }, children: m }),
1163
- d && !l && /* @__PURE__ */ y(E, { children: [
1168
+ ) : /* @__PURE__ */ f(E, { children: [
1169
+ /* @__PURE__ */ i("span", { style: { color: "#666" }, children: g }),
1170
+ d && !l && /* @__PURE__ */ f(E, { children: [
1164
1171
  " ",
1165
1172
  /* @__PURE__ */ i(
1166
1173
  "button",
@@ -1184,7 +1191,7 @@ const L = 5, Re = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1184
1191
  }
1185
1192
  )
1186
1193
  ] }),
1187
- d && l && /* @__PURE__ */ y(E, { children: [
1194
+ d && l && /* @__PURE__ */ f(E, { children: [
1188
1195
  " ",
1189
1196
  /* @__PURE__ */ i(
1190
1197
  "button",
@@ -1222,21 +1229,21 @@ const L = 5, Re = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1222
1229
  }
1223
1230
  )
1224
1231
  ] });
1225
- }, z = 5, Le = ({ data: e, t }) => {
1226
- const [n, r] = v(!1), s = e.memories.map((f) => f.memoryTitle), a = s.length > 0, u = a && s.length > z, d = u && !n ? s.slice(0, z) : s, o = s.length - z, c = !u || n, g = s.length === 1 ? t.memoryFound : t.memoriesFoundPrefix, m = a ? `${g}${H(
1232
+ }, z = 5, Oe = ({ data: e, t }) => {
1233
+ const [n, r] = v(!1), s = e.memories.map((h) => h.memoryTitle), a = s.length > 0, u = a && s.length > z, d = u && !n ? s.slice(0, z) : s, o = s.length - z, c = !u || n, m = s.length === 1 ? t.memoryFound : t.memoriesFoundPrefix, g = a ? `${m}${_(
1227
1234
  d,
1228
1235
  c ? t.and : void 0
1229
1236
  )}` : t.memoriesFound;
1230
1237
  return /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
1231
- x.div,
1238
+ k.div,
1232
1239
  {
1233
1240
  style: { color: "#666" },
1234
1241
  initial: { opacity: 0, y: -10 },
1235
1242
  animate: { opacity: 1, y: 0 },
1236
1243
  transition: { duration: 0.3, delay: 0 },
1237
- children: /* @__PURE__ */ y(E, { children: [
1238
- /* @__PURE__ */ i("span", { style: { color: "#666" }, children: m }),
1239
- u && !n && /* @__PURE__ */ y(E, { children: [
1244
+ children: /* @__PURE__ */ f(E, { children: [
1245
+ /* @__PURE__ */ i("span", { style: { color: "#666" }, children: g }),
1246
+ u && !n && /* @__PURE__ */ f(E, { children: [
1240
1247
  " ",
1241
1248
  /* @__PURE__ */ i(
1242
1249
  "button",
@@ -1260,7 +1267,7 @@ const L = 5, Re = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1260
1267
  }
1261
1268
  )
1262
1269
  ] }),
1263
- u && n && /* @__PURE__ */ y(E, { children: [
1270
+ u && n && /* @__PURE__ */ f(E, { children: [
1264
1271
  " ",
1265
1272
  /* @__PURE__ */ i(
1266
1273
  "button",
@@ -1285,11 +1292,11 @@ const L = 5, Re = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1285
1292
  ] })
1286
1293
  }
1287
1294
  ) });
1288
- }, Oe = ({ isLatest: e = !1, durationSeconds: t, t: n }) => {
1295
+ }, Le = ({ isLatest: e = !1, durationSeconds: t, t: n }) => {
1289
1296
  const r = n.addingSources;
1290
- return /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
1297
+ return /* @__PURE__ */ f("div", { style: { padding: "16px" }, children: [
1291
1298
  /* @__PURE__ */ i(
1292
- x.div,
1299
+ k.div,
1293
1300
  {
1294
1301
  style: {
1295
1302
  display: "flex",
@@ -1301,7 +1308,7 @@ const L = 5, Re = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1301
1308
  animate: { opacity: 1, y: 0 },
1302
1309
  transition: { duration: 0.3, delay: 0 },
1303
1310
  children: e && !t ? /* @__PURE__ */ i(
1304
- D,
1311
+ P,
1305
1312
  {
1306
1313
  text: r,
1307
1314
  duration: 2.5,
@@ -1338,9 +1345,9 @@ function ze(e, t) {
1338
1345
  const n = e[e.length - 1], r = e.slice(0, -1).join(", ");
1339
1346
  return S(t.pageMultiple, { list: r, n });
1340
1347
  }
1341
- const $e = ({ data: e, onSourceClick: t, t: n }) => /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
1348
+ const $e = ({ data: e, onSourceClick: t, t: n }) => /* @__PURE__ */ f("div", { style: { padding: "16px" }, children: [
1342
1349
  /* @__PURE__ */ i(
1343
- x.div,
1350
+ k.div,
1344
1351
  {
1345
1352
  style: {
1346
1353
  marginBottom: "10px",
@@ -1373,13 +1380,16 @@ const $e = ({ data: e, onSourceClick: t, t: n }) => /* @__PURE__ */ y("div", { s
1373
1380
  t: r
1374
1381
  }) => {
1375
1382
  const [l, s] = v(!1), a = !!n, u = e.pageNumbers ?? [], d = ze(u, r);
1376
- return /* @__PURE__ */ y(
1377
- x.div,
1383
+ return /* @__PURE__ */ f(
1384
+ k.div,
1378
1385
  {
1379
1386
  initial: { opacity: 0, scale: 0.9 },
1380
1387
  animate: { opacity: 1, scale: 1 },
1381
1388
  transition: { duration: 0.25, delay: t * 0.05 },
1382
- onClick: a ? () => n(e.memoryId) : void 0,
1389
+ onClick: a ? () => n({
1390
+ memoryId: e.memoryId,
1391
+ pageNumbers: [...u]
1392
+ }) : void 0,
1383
1393
  onMouseEnter: a ? () => s(!0) : void 0,
1384
1394
  onMouseLeave: a ? () => s(!1) : void 0,
1385
1395
  style: {
@@ -1432,7 +1442,7 @@ const $e = ({ data: e, onSourceClick: t, t: n }) => /* @__PURE__ */ y("div", { s
1432
1442
  height: r,
1433
1443
  backgroundColor: e
1434
1444
  };
1435
- return /* @__PURE__ */ y(
1445
+ return /* @__PURE__ */ f(
1436
1446
  "span",
1437
1447
  {
1438
1448
  style: {
@@ -1470,15 +1480,15 @@ function We({
1470
1480
  }) {
1471
1481
  return e.error != null ? /* @__PURE__ */ i(Y, { color: "#c62828", size: 15, lineWidth: 2 }) : e.result != null ? /* @__PURE__ */ i(B, { color: "#999", size: 15, borderWidth: 2 }) : t ? /* @__PURE__ */ i(B, { color: "#999", size: 15, borderWidth: 2 }) : /* @__PURE__ */ i("span", { className: "explore-memory-loader" });
1472
1482
  }
1473
- const N = 80;
1474
- function He({
1483
+ const j = 80;
1484
+ function _e({
1475
1485
  memory: e,
1476
1486
  completed: t,
1477
1487
  t: n
1478
1488
  }) {
1479
- const [r, l] = v(!1), s = e.result ?? e.error, a = s != null && s.length > N, u = s != null ? r || !a ? s : `${s.slice(0, N)}...` : void 0, d = a, o = e.error != null;
1480
- return /* @__PURE__ */ y(
1481
- x.div,
1489
+ const [r, l] = v(!1), s = e.result ?? e.error, a = s != null && s.length > j, u = s != null ? r || !a ? s : `${s.slice(0, j)}...` : void 0, d = a, o = e.error != null;
1490
+ return /* @__PURE__ */ f(
1491
+ k.div,
1482
1492
  {
1483
1493
  initial: { opacity: 0 },
1484
1494
  animate: { opacity: 1 },
@@ -1509,7 +1519,7 @@ function He({
1509
1519
  children: /* @__PURE__ */ i(We, { memory: e, completed: t })
1510
1520
  }
1511
1521
  ),
1512
- /* @__PURE__ */ y(
1522
+ /* @__PURE__ */ f(
1513
1523
  "div",
1514
1524
  {
1515
1525
  style: {
@@ -1556,8 +1566,8 @@ function He({
1556
1566
  }
1557
1567
  );
1558
1568
  }
1559
- const Ue = ({ data: e, completed: t, t: n }) => /* @__PURE__ */ i("div", { style: { padding: "10px" }, children: e.memories.map((r) => /* @__PURE__ */ i(
1560
- He,
1569
+ const He = ({ data: e, completed: t, t: n }) => /* @__PURE__ */ i("div", { style: { padding: "10px" }, children: e.memories.map((r) => /* @__PURE__ */ i(
1570
+ _e,
1561
1571
  {
1562
1572
  memory: r,
1563
1573
  completed: t,
@@ -1565,7 +1575,7 @@ const Ue = ({ data: e, completed: t, t: n }) => /* @__PURE__ */ i("div", { style
1565
1575
  },
1566
1576
  r.memoryId
1567
1577
  )) });
1568
- function _e(e, t) {
1578
+ function Ne(e, t) {
1569
1579
  if (e.length === 0) return "";
1570
1580
  if (e.length === 1)
1571
1581
  return S(t.pageSingle, { n: e[0] });
@@ -1577,14 +1587,14 @@ function _e(e, t) {
1577
1587
  const n = e[e.length - 1], r = e.slice(0, -1).join(", ");
1578
1588
  return S(t.pageMultiple, { list: r, n });
1579
1589
  }
1580
- function je(e, t) {
1590
+ function Ue(e, t) {
1581
1591
  return e === 1 ? t.chunkFound : S(t.chunksFound, { n: e });
1582
1592
  }
1583
- const Ne = ({ data: e, t }) => {
1593
+ const je = ({ data: e, t }) => {
1584
1594
  const [n, r] = v(!1), l = e.chunks.length, s = l > 0;
1585
- return /* @__PURE__ */ y("div", { style: { padding: "10px" }, children: [
1586
- /* @__PURE__ */ y(
1587
- x.div,
1595
+ return /* @__PURE__ */ f("div", { style: { padding: "10px" }, children: [
1596
+ /* @__PURE__ */ f(
1597
+ k.div,
1588
1598
  {
1589
1599
  initial: { opacity: 0 },
1590
1600
  animate: { opacity: 1 },
@@ -1601,7 +1611,7 @@ const Ne = ({ data: e, t }) => {
1601
1611
  },
1602
1612
  children: [
1603
1613
  /* @__PURE__ */ i("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1604
- /* @__PURE__ */ i("span", { style: { fontSize: 12, color: "#666" }, children: je(l, t) }),
1614
+ /* @__PURE__ */ i("span", { style: { fontSize: 12, color: "#666" }, children: Ue(l, t) }),
1605
1615
  s && /* @__PURE__ */ i(
1606
1616
  "span",
1607
1617
  {
@@ -1617,7 +1627,7 @@ const Ne = ({ data: e, t }) => {
1617
1627
  }
1618
1628
  ),
1619
1629
  n && s && /* @__PURE__ */ i(
1620
- x.div,
1630
+ k.div,
1621
1631
  {
1622
1632
  initial: { opacity: 0, height: 0 },
1623
1633
  animate: { opacity: 1, height: "auto" },
@@ -1631,8 +1641,8 @@ const Ne = ({ data: e, t }) => {
1631
1641
  gap: 8
1632
1642
  },
1633
1643
  children: e.chunks.map((a, u) => {
1634
- const d = a.pageNumbers ?? [], o = _e(d, t);
1635
- return /* @__PURE__ */ y(
1644
+ const d = a.pageNumbers ?? [], o = Ne(d, t);
1645
+ return /* @__PURE__ */ f(
1636
1646
  "div",
1637
1647
  {
1638
1648
  style: {
@@ -1655,7 +1665,7 @@ const Ne = ({ data: e, t }) => {
1655
1665
  children: a.content
1656
1666
  }
1657
1667
  ),
1658
- /* @__PURE__ */ y(
1668
+ /* @__PURE__ */ f(
1659
1669
  "div",
1660
1670
  {
1661
1671
  style: {
@@ -1695,8 +1705,8 @@ function Ge({
1695
1705
  showShimmerForPrimary: n
1696
1706
  }) {
1697
1707
  const r = e.result != null, l = e.error != null, s = qe(e, t);
1698
- return /* @__PURE__ */ y(
1699
- x.div,
1708
+ return /* @__PURE__ */ f(
1709
+ k.div,
1700
1710
  {
1701
1711
  initial: { opacity: 0 },
1702
1712
  animate: { opacity: 1 },
@@ -1707,7 +1717,7 @@ function Ge({
1707
1717
  borderBottom: "1px solid #eee",
1708
1718
  display: "flex",
1709
1719
  flexDirection: "row",
1710
- alignItems: "flex-start",
1720
+ alignItems: "center",
1711
1721
  gap: "10px",
1712
1722
  minWidth: 0
1713
1723
  },
@@ -1720,13 +1730,12 @@ function Ge({
1720
1730
  alignItems: "center",
1721
1731
  justifyContent: "center",
1722
1732
  flexShrink: 0,
1723
- width: 32,
1724
- paddingTop: 2
1733
+ width: 32
1725
1734
  },
1726
1735
  children: /* @__PURE__ */ i(Ke, { item: e })
1727
1736
  }
1728
1737
  ),
1729
- /* @__PURE__ */ y(
1738
+ /* @__PURE__ */ f(
1730
1739
  "div",
1731
1740
  {
1732
1741
  style: {
@@ -1738,7 +1747,7 @@ function Ge({
1738
1747
  },
1739
1748
  children: [
1740
1749
  /* @__PURE__ */ i("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: !r && !l && n ? /* @__PURE__ */ i(
1741
- D,
1750
+ P,
1742
1751
  {
1743
1752
  text: s,
1744
1753
  duration: 2.5,
@@ -1778,9 +1787,9 @@ const Xe = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1778
1787
  a.result == null && a.error == null && (s = u);
1779
1788
  }), s;
1780
1789
  }, [e.memoryTypes]);
1781
- return /* @__PURE__ */ y("div", { style: { padding: "10px" }, children: [
1790
+ return /* @__PURE__ */ f("div", { style: { padding: "10px" }, children: [
1782
1791
  t && !n && e.memoryTypes.length === 0 ? /* @__PURE__ */ i(
1783
- D,
1792
+ P,
1784
1793
  {
1785
1794
  text: r.searchingMemoryTypes,
1786
1795
  duration: 2.5,
@@ -1811,29 +1820,70 @@ const Xe = ({ data: e, isLatest: t = !1, durationSeconds: n, t: r }) => {
1811
1820
  )
1812
1821
  ] });
1813
1822
  };
1814
- function Je(e, t) {
1823
+ function Ve(e, t) {
1824
+ const n = Math.min(e.length, t.length);
1825
+ for (let r = n; r >= 0; r--)
1826
+ if (e.slice(-r) === t.slice(0, r)) return r;
1827
+ return 0;
1828
+ }
1829
+ const Je = `
1830
+
1831
+ `;
1832
+ function Ye(e) {
1833
+ var n, r;
1834
+ if (e.length === 0) return "";
1835
+ let t = ((n = e[0]) == null ? void 0 : n.content) ?? "";
1836
+ for (let l = 1; l < e.length; l++) {
1837
+ const s = ((r = e[l]) == null ? void 0 : r.content) ?? "";
1838
+ if (s === "") continue;
1839
+ if (t === "") {
1840
+ t = s;
1841
+ continue;
1842
+ }
1843
+ const a = Ve(t, s);
1844
+ a === 0 ? t += Je + s : t += s.slice(a);
1845
+ }
1846
+ return t;
1847
+ }
1848
+ function Qe(e, t) {
1815
1849
  if (e.length === 0) return "";
1816
1850
  if (e.length === 1)
1817
- return S(t.pageSingle, { n: e[0] });
1851
+ return S(t.memorySearchPagesSingle, {
1852
+ n: e[0]
1853
+ });
1818
1854
  if (e.length === 2)
1819
- return S(t.pageTwo, {
1855
+ return S(t.memorySearchPagesTwo, {
1820
1856
  a: e[0],
1821
1857
  b: e[1]
1822
1858
  });
1823
1859
  const n = e[e.length - 1], r = e.slice(0, -1).join(", ");
1824
- return S(t.pageMultiple, { list: r, n });
1860
+ return S(t.memorySearchPagesMultiple, {
1861
+ list: r,
1862
+ n
1863
+ });
1864
+ }
1865
+ function Ze(e) {
1866
+ const t = /* @__PURE__ */ new Set();
1867
+ for (const n of e)
1868
+ for (const r of n.pageNumbers) t.add(r);
1869
+ return [...t].sort((n, r) => n - r);
1825
1870
  }
1826
- const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
1827
- const r = e.chunkResults.chunks, l = !!t;
1828
- return /* @__PURE__ */ y("div", { style: { padding: "16px" }, children: [
1871
+ function et(e) {
1872
+ const t = e.memoryTypeName.trim();
1873
+ if (t !== "") return t;
1874
+ if (e.memoryTypeId !== "") return e.memoryTypeId;
1875
+ }
1876
+ const tt = ({ data: e, onSearchResultClick: t, t: n }) => {
1877
+ const r = e.response.items, l = !!t;
1878
+ return /* @__PURE__ */ f("div", { style: { padding: "16px" }, children: [
1829
1879
  /* @__PURE__ */ i(
1830
- x.div,
1880
+ k.div,
1831
1881
  {
1832
1882
  style: {
1833
1883
  marginBottom: "12px",
1834
- fontSize: "13px",
1835
- fontWeight: 600,
1836
- color: "#333"
1884
+ fontSize: "12px",
1885
+ fontWeight: 500,
1886
+ color: "#9ca3af"
1837
1887
  },
1838
1888
  initial: { opacity: 0, y: -6 },
1839
1889
  animate: { opacity: 1, y: 0 },
@@ -1849,109 +1899,119 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
1849
1899
  flexDirection: "column",
1850
1900
  gap: 0
1851
1901
  },
1852
- children: r.map((s, a) => /* @__PURE__ */ y(
1853
- x.div,
1854
- {
1855
- initial: { opacity: 0 },
1856
- animate: { opacity: 1 },
1857
- transition: { duration: 0.2, delay: a * 0.04 },
1858
- style: {
1859
- display: "flex",
1860
- flexDirection: "row",
1861
- alignItems: "flex-start",
1862
- gap: "12px",
1863
- paddingTop: "12px",
1864
- paddingBottom: "12px",
1865
- borderBottom: a < r.length - 1 ? "1px solid #eee" : void 0,
1866
- minWidth: 0
1902
+ children: r.map((s, a) => {
1903
+ const u = s.memory.title != null && s.memory.title !== "" ? s.memory.title : s.memory.id, d = Ze(
1904
+ s.chunks
1905
+ ), o = [
1906
+ et(s.memory),
1907
+ S(n.scoreLabel, {
1908
+ n: s.score.toFixed(2)
1909
+ }),
1910
+ d.length > 0 ? Qe(d, n) : n.pagesNotAvailable
1911
+ ].filter(
1912
+ (m) => m != null && m !== ""
1913
+ ), c = {
1914
+ memoryId: s.memory.id,
1915
+ pageNumbers: d
1916
+ };
1917
+ return /* @__PURE__ */ f(
1918
+ k.div,
1919
+ {
1920
+ initial: { opacity: 0 },
1921
+ animate: { opacity: 1 },
1922
+ transition: { duration: 0.2, delay: a * 0.04 },
1923
+ style: {
1924
+ display: "flex",
1925
+ flexDirection: "row",
1926
+ alignItems: "flex-start",
1927
+ gap: "12px",
1928
+ paddingTop: "12px",
1929
+ paddingBottom: "12px",
1930
+ borderBottom: a < r.length - 1 ? "1px solid #eee" : void 0,
1931
+ minWidth: 0
1932
+ },
1933
+ children: [
1934
+ /* @__PURE__ */ f(
1935
+ "div",
1936
+ {
1937
+ style: {
1938
+ flex: 1,
1939
+ minWidth: 0,
1940
+ display: "flex",
1941
+ flexDirection: "column",
1942
+ gap: "6px"
1943
+ },
1944
+ children: [
1945
+ /* @__PURE__ */ i(
1946
+ "span",
1947
+ {
1948
+ style: {
1949
+ fontSize: 13,
1950
+ fontWeight: 600,
1951
+ color: "#333"
1952
+ },
1953
+ children: u
1954
+ }
1955
+ ),
1956
+ /* @__PURE__ */ i(
1957
+ "span",
1958
+ {
1959
+ style: {
1960
+ fontSize: 13,
1961
+ color: "#1f2937",
1962
+ lineHeight: 1.5,
1963
+ whiteSpace: "pre-wrap",
1964
+ wordBreak: "break-word"
1965
+ },
1966
+ children: Ye(s.chunks)
1967
+ }
1968
+ ),
1969
+ /* @__PURE__ */ i(
1970
+ "div",
1971
+ {
1972
+ style: {
1973
+ fontSize: 11,
1974
+ fontWeight: 400,
1975
+ color: "#94a3b8",
1976
+ lineHeight: 1.35
1977
+ },
1978
+ children: o.join(" · ")
1979
+ }
1980
+ )
1981
+ ]
1982
+ }
1983
+ ),
1984
+ l && /* @__PURE__ */ i(
1985
+ "button",
1986
+ {
1987
+ type: "button",
1988
+ onClick: () => t(c),
1989
+ style: {
1990
+ flexShrink: 0,
1991
+ alignSelf: "center",
1992
+ padding: "6px 12px",
1993
+ fontSize: 12,
1994
+ fontWeight: 600,
1995
+ color: "#2563eb",
1996
+ background: "#eff6ff",
1997
+ border: "1px solid #bfdbfe",
1998
+ borderRadius: 6,
1999
+ cursor: "pointer",
2000
+ fontFamily: "inherit"
2001
+ },
2002
+ children: n.viewButton
2003
+ }
2004
+ )
2005
+ ]
1867
2006
  },
1868
- children: [
1869
- /* @__PURE__ */ y(
1870
- "div",
1871
- {
1872
- style: {
1873
- flex: 1,
1874
- minWidth: 0,
1875
- display: "flex",
1876
- flexDirection: "column",
1877
- gap: "6px"
1878
- },
1879
- children: [
1880
- /* @__PURE__ */ i(
1881
- "span",
1882
- {
1883
- style: {
1884
- fontSize: 13,
1885
- fontWeight: 600,
1886
- color: "#333"
1887
- },
1888
- children: s.memoryTitle
1889
- }
1890
- ),
1891
- /* @__PURE__ */ y(
1892
- "div",
1893
- {
1894
- style: {
1895
- fontSize: 12,
1896
- color: "#444",
1897
- lineHeight: 1.4
1898
- },
1899
- children: [
1900
- /* @__PURE__ */ i("span", { style: { fontWeight: 600, color: "#555" }, children: n.pagesLabel }),
1901
- ": ",
1902
- s.pageNumbers.length > 0 ? Je(s.pageNumbers, n) : n.pagesNotAvailable
1903
- ]
1904
- }
1905
- ),
1906
- /* @__PURE__ */ i(
1907
- "span",
1908
- {
1909
- style: {
1910
- fontSize: 12,
1911
- color: "#666",
1912
- lineHeight: 1.45,
1913
- whiteSpace: "pre-wrap",
1914
- wordBreak: "break-word"
1915
- },
1916
- children: s.content
1917
- }
1918
- ),
1919
- /* @__PURE__ */ i("span", { style: { fontSize: 11, color: "#999" }, children: S(n.scoreLabel, {
1920
- n: s.score.toFixed(2)
1921
- }) })
1922
- ]
1923
- }
1924
- ),
1925
- l && /* @__PURE__ */ i(
1926
- "button",
1927
- {
1928
- type: "button",
1929
- onClick: () => t(s.memoryId),
1930
- style: {
1931
- flexShrink: 0,
1932
- alignSelf: "center",
1933
- padding: "6px 12px",
1934
- fontSize: 12,
1935
- fontWeight: 600,
1936
- color: "#2563eb",
1937
- background: "#eff6ff",
1938
- border: "1px solid #bfdbfe",
1939
- borderRadius: 6,
1940
- cursor: "pointer",
1941
- fontFamily: "inherit"
1942
- },
1943
- children: n.viewButton
1944
- }
1945
- )
1946
- ]
1947
- },
1948
- `${s.memoryId}-${a}`
1949
- ))
2007
+ `${s.memory.id}-${a}`
2008
+ );
2009
+ })
1950
2010
  }
1951
2011
  )
1952
2012
  ] });
1953
- }, Ye = ({ message: e }) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
1954
- x.div,
2013
+ }, nt = ({ message: e }) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
2014
+ k.div,
1955
2015
  {
1956
2016
  initial: { opacity: 0, y: -10 },
1957
2017
  animate: { opacity: 1, y: 0 },
@@ -1973,7 +2033,7 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
1973
2033
  }
1974
2034
  )
1975
2035
  }
1976
- ) }), Qe = ({
2036
+ ) }), rt = ({
1977
2037
  progressViewItems: e,
1978
2038
  loadingText: t,
1979
2039
  t: n,
@@ -1987,16 +2047,16 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
1987
2047
  const a = (d) => {
1988
2048
  const o = d.item.data;
1989
2049
  if (o.taskType === "StreamingChatCompletion" && o.eventType === "Text")
1990
- return /* @__PURE__ */ i(j, { text: o.text });
1991
- if (o.taskType === "StructuredChatCompletion" && o.eventType === "Json")
2050
+ return /* @__PURE__ */ i(U, { text: o.text });
2051
+ if (o.taskType === "StructuredChatCompletion" && o.eventType === "Completed")
1992
2052
  return /* @__PURE__ */ i(Ae, { data: o });
1993
2053
  if (o.taskType === "MemoryChatCompletion")
1994
2054
  switch (o.eventType) {
1995
2055
  case "Text":
1996
- return /* @__PURE__ */ i(j, { text: o.text });
2056
+ return /* @__PURE__ */ i(U, { text: o.text });
1997
2057
  case "FindMemories":
1998
2058
  return /* @__PURE__ */ i(
1999
- Pe,
2059
+ Re,
2000
2060
  {
2001
2061
  data: o,
2002
2062
  isLatest: d.isLatest,
@@ -2005,10 +2065,16 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
2005
2065
  }
2006
2066
  );
2007
2067
  case "FindMemoriesResult":
2008
- return /* @__PURE__ */ i(Le, { data: o, t: n });
2068
+ return /* @__PURE__ */ i(
2069
+ Oe,
2070
+ {
2071
+ data: o,
2072
+ t: n
2073
+ }
2074
+ );
2009
2075
  case "Search":
2010
2076
  return /* @__PURE__ */ i(
2011
- Re,
2077
+ De,
2012
2078
  {
2013
2079
  data: o,
2014
2080
  isLatest: d.isLatest,
@@ -2018,7 +2084,7 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
2018
2084
  );
2019
2085
  case "FindSources":
2020
2086
  return /* @__PURE__ */ i(
2021
- Oe,
2087
+ Le,
2022
2088
  {
2023
2089
  data: o,
2024
2090
  isLatest: d.isLatest,
@@ -2037,7 +2103,7 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
2037
2103
  );
2038
2104
  case "ExploreMemories":
2039
2105
  return /* @__PURE__ */ i(
2040
- Ue,
2106
+ He,
2041
2107
  {
2042
2108
  data: o,
2043
2109
  completed: d.completed,
@@ -2046,7 +2112,7 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
2046
2112
  }
2047
2113
  );
2048
2114
  case "ChunkResult":
2049
- return /* @__PURE__ */ i(Ne, { data: o, t: n });
2115
+ return /* @__PURE__ */ i(je, { data: o, t: n });
2050
2116
  case "Completed":
2051
2117
  return null;
2052
2118
  }
@@ -2064,7 +2130,7 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
2064
2130
  );
2065
2131
  case "Completed":
2066
2132
  return /* @__PURE__ */ i(
2067
- Ve,
2133
+ tt,
2068
2134
  {
2069
2135
  data: o,
2070
2136
  onSearchResultClick: l,
@@ -2072,11 +2138,11 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
2072
2138
  }
2073
2139
  );
2074
2140
  }
2075
- return o.taskType === "StreamingChatCompletion" && o.eventType === "Completed" || o.taskType === "StructuredChatCompletion" && o.eventType === "Completed" ? null : o.eventType === "Error" && "message" in o ? /* @__PURE__ */ i(Ye, { message: o.message }) : null;
2141
+ return o.taskType === "StreamingChatCompletion" && o.eventType === "Completed" ? null : o.eventType === "Error" && "message" in o ? /* @__PURE__ */ i(nt, { message: o.message }) : null;
2076
2142
  };
2077
2143
  if (e.length === 0)
2078
2144
  return /* @__PURE__ */ i("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ i(
2079
- D,
2145
+ P,
2080
2146
  {
2081
2147
  text: t ?? n.processingYourTask,
2082
2148
  duration: 1.5,
@@ -2089,11 +2155,11 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
2089
2155
  const u = e.filter((d, o) => {
2090
2156
  const c = d.item.data;
2091
2157
  return c.taskType === "MemoryChatCompletion" && c.eventType === "ExploreMemories" ? !e.slice(o + 1).some(
2092
- (f) => f.item.data.taskType === "MemoryChatCompletion" && f.item.data.eventType === "ExploreMemories"
2158
+ (h) => h.item.data.taskType === "MemoryChatCompletion" && h.item.data.eventType === "ExploreMemories"
2093
2159
  ) : !0;
2094
2160
  });
2095
2161
  return /* @__PURE__ */ i("div", { id: "agent-task-progress-verbose", ref: s, children: /* @__PURE__ */ i(q, { children: u.map((d, o) => /* @__PURE__ */ i(
2096
- x.div,
2162
+ k.div,
2097
2163
  {
2098
2164
  id: `agent-task-progress-item-${d.item.progressItemId}`,
2099
2165
  initial: { opacity: 0, y: -20 },
@@ -2107,14 +2173,14 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
2107
2173
  },
2108
2174
  d.item.progressItemId
2109
2175
  )) }) });
2110
- }, lt = ({
2176
+ }, gt = ({
2111
2177
  agentTask: e,
2112
2178
  mode: t = "verbose",
2113
2179
  language: n,
2114
2180
  onSourceClick: r,
2115
2181
  onSearchResultClick: l
2116
2182
  }) => {
2117
- const s = Ee(e), a = (e.params.type === "MemoryChatCompletion" || e.params.type === "MemorySearch") && "language" in e.params ? e.params.language ?? "en" : n ?? "en", u = De(a);
2183
+ const s = Ee(e), a = (e.params.type === "MemoryChatCompletion" || e.params.type === "MemorySearch") && "language" in e.params ? e.params.language ?? "en" : n ?? "en", u = Pe(a);
2118
2184
  return t === "simple" ? /* @__PURE__ */ i(
2119
2185
  we,
2120
2186
  {
@@ -2122,7 +2188,7 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
2122
2188
  t: u
2123
2189
  }
2124
2190
  ) : /* @__PURE__ */ i(
2125
- Qe,
2191
+ rt,
2126
2192
  {
2127
2193
  progressViewItems: s,
2128
2194
  loadingText: e.loadingText,
@@ -2133,10 +2199,10 @@ const Ve = ({ data: e, onSearchResultClick: t, t: n }) => {
2133
2199
  );
2134
2200
  };
2135
2201
  export {
2136
- lt as AgentTaskProgress,
2202
+ gt as AgentTaskProgress,
2137
2203
  B as Checkmark,
2138
- at as FencyProvider,
2139
- Ve as MemorySearchCompletedResults,
2204
+ ut as FencyProvider,
2205
+ tt as MemorySearchCompletedResults,
2140
2206
  Y as XMark,
2141
- st as useAgentTasks
2207
+ mt as useAgentTasks
2142
2208
  };