@fencyai/react 0.1.121 → 0.1.122

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 (2) hide show
  1. package/dist/index.js +398 -396
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { createAgentTask as G, createStream as J } from "@fencyai/js";
2
- import { createContext as V, useContext as q, useState as k, useRef as p, useEffect as E, useCallback as W, useMemo as $ } from "react";
3
- import { jsx as c, jsxs as x, Fragment as X } from "react/jsx-runtime";
4
- import { useInView as Q, motion as v, AnimatePresence as B } from "motion/react";
5
- import Y from "react-markdown";
6
- import { Prism as L } from "react-syntax-highlighter";
7
- import Z from "remark-gfm";
2
+ import { createContext as V, useContext as q, useState as C, useRef as A, useEffect as E, useCallback as W, useMemo as B } from "react";
3
+ import { jsx as c, jsxs as x } from "react/jsx-runtime";
4
+ import { useInView as X, motion as v, AnimatePresence as L } from "motion/react";
5
+ import Q from "react-markdown";
6
+ import { Prism as $ } from "react-syntax-highlighter";
7
+ import Y from "remark-gfm";
8
8
  import './assets/index.css';const _ = V(
9
9
  void 0
10
10
  );
@@ -14,34 +14,34 @@ function N() {
14
14
  throw new Error("useFencyContext must be used within a FencyProvider");
15
15
  return e;
16
16
  }
17
- const ee = (e) => {
17
+ const Z = (e) => {
18
18
  try {
19
19
  const t = JSON.parse(e);
20
- return te(t);
20
+ return ee(t);
21
21
  } catch (t) {
22
22
  return console.error("Error parsing message:", t), null;
23
23
  }
24
- }, te = (e) => {
24
+ }, ee = (e) => {
25
25
  if (!(typeof e == "object" && e !== null && "type" in e && "streamId" in e && "timestamp" in e))
26
26
  return null;
27
27
  switch (e.type) {
28
28
  case "StreamTimeout":
29
- return ne(e);
29
+ return te(e);
30
30
  case "StreamNotFound":
31
- return re(e);
31
+ return ne(e);
32
32
  case "AgentTaskProgressItemUpdated":
33
- return ae(e);
33
+ return re(e);
34
34
  }
35
35
  return null;
36
- }, ne = (e) => ({
36
+ }, te = (e) => ({
37
37
  type: "StreamTimeout",
38
38
  streamId: e.streamId,
39
39
  timestamp: e.timestamp
40
- }), re = (e) => ({
40
+ }), ne = (e) => ({
41
41
  type: "StreamNotFound",
42
42
  streamId: e.streamId,
43
43
  timestamp: e.timestamp
44
- }), ae = (e) => ({
44
+ }), re = (e) => ({
45
45
  type: "AgentTaskProgressItemUpdated",
46
46
  streamId: e.streamId,
47
47
  agentTaskId: e.agentTaskId,
@@ -49,18 +49,18 @@ const ee = (e) => {
49
49
  timestamp: e.timestamp,
50
50
  createdAt: e.createdAt,
51
51
  data: JSON.parse(e.data)
52
- }), oe = (e) => {
53
- const t = N(), [n, r] = k(null), a = p(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
52
+ }), ae = (e) => {
53
+ const t = N(), [r, n] = C(null), o = A(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
54
54
  return E(() => {
55
55
  if (!t.eventManager) return;
56
56
  const s = {
57
- onMessage: (d, o) => {
58
- var m, u, S, y, T, f, h, b, I, w;
59
- const i = ee(d);
57
+ onMessage: (d, a) => {
58
+ var g, u, S, y, T, f, h, b, I, w;
59
+ const i = Z(d);
60
60
  if (i)
61
61
  switch (i.type) {
62
62
  case "NewChatCompletionStreamChunk":
63
- (m = e == null ? void 0 : e.onNewChatCompletionStreamChunk) == null || m.call(e, i);
63
+ (g = e == null ? void 0 : e.onNewChatCompletionStreamChunk) == null || g.call(e, i);
64
64
  break;
65
65
  case "ChatCompletionStreamCompleted":
66
66
  (u = e == null ? void 0 : e.onChatCompletionStreamCompleted) == null || u.call(e, i);
@@ -92,8 +92,8 @@ const ee = (e) => {
92
92
  }
93
93
  },
94
94
  onError: (d) => {
95
- var o;
96
- (o = e == null ? void 0 : e.onStreamError) == null || o.call(e, {
95
+ var a;
96
+ (a = e == null ? void 0 : e.onStreamError) == null || a.call(e, {
97
97
  streamId: d,
98
98
  error: {
99
99
  code: "UnknownError",
@@ -103,14 +103,14 @@ const ee = (e) => {
103
103
  }
104
104
  };
105
105
  return t.eventManager.subscribe(
106
- a.current,
106
+ o.current,
107
107
  s
108
108
  );
109
109
  }, [t.eventManager, e]), {
110
110
  createStream: async () => {
111
111
  try {
112
112
  const s = await t.getOrCreateStream(3e4);
113
- return r(s), {
113
+ return n(s), {
114
114
  type: "success",
115
115
  stream: s
116
116
  };
@@ -124,110 +124,110 @@ const ee = (e) => {
124
124
  };
125
125
  }
126
126
  },
127
- stream: n
127
+ stream: r
128
128
  };
129
- }, ze = (e) => {
130
- const t = N(), [n, r] = k([]), a = p(/* @__PURE__ */ new Set()), g = p(/* @__PURE__ */ new Map()), { createStream: s } = oe({
131
- onAgentTaskProgressItemUpdated: (o) => {
129
+ }, Oe = (e) => {
130
+ const t = N(), [r, n] = C([]), o = A(/* @__PURE__ */ new Set()), m = A(/* @__PURE__ */ new Map()), { createStream: s } = ae({
131
+ onAgentTaskProgressItemUpdated: (a) => {
132
132
  var u;
133
- if (!a.current.has(o.agentTaskId)) return;
134
- const i = o.data;
133
+ if (!o.current.has(a.agentTaskId)) return;
134
+ const i = a.data;
135
135
  if (i.taskType === "StreamingChatCompletion" && i.eventType === "Completed" || i.taskType === "StructuredChatCompletion" && i.eventType === "Completed" || i.taskType === "StreamingMemoryTypeChatCompletion" && i.eventType === "Completed") {
136
- const S = g.current.get(
137
- o.agentTaskId
136
+ const S = m.current.get(
137
+ a.agentTaskId
138
138
  );
139
- S && (g.current.delete(o.agentTaskId), S(i));
139
+ S && (m.current.delete(a.agentTaskId), S(i));
140
140
  return;
141
141
  }
142
- (u = e.onAgentTaskProgressItemUpdated) == null || u.call(e, o), r(
142
+ (u = e.onAgentTaskProgressItemUpdated) == null || u.call(e, a), n(
143
143
  (S) => S.map((y) => {
144
144
  var h;
145
- if (((h = y.confirmedData) == null ? void 0 : h.taskId) !== o.agentTaskId)
145
+ if (((h = y.confirmedData) == null ? void 0 : h.taskId) !== a.agentTaskId)
146
146
  return y;
147
147
  const f = y.progressItems.some(
148
- (b) => b.progressItemId === o.progressItemId
148
+ (b) => b.progressItemId === a.progressItemId
149
149
  ) ? y.progressItems.map(
150
- (b) => b.progressItemId === o.progressItemId ? o : b
151
- ) : [...y.progressItems, o];
150
+ (b) => b.progressItemId === a.progressItemId ? a : b
151
+ ) : [...y.progressItems, a];
152
152
  return { ...y, progressItems: f };
153
153
  })
154
154
  );
155
155
  },
156
- onStreamError: (o) => {
156
+ onStreamError: (a) => {
157
157
  var i;
158
- (i = e == null ? void 0 : e.onStreamError) == null || i.call(e, o), r((m) => {
159
- const u = m.find((S) => S.streamId === o.streamId);
158
+ (i = e == null ? void 0 : e.onStreamError) == null || i.call(e, a), n((g) => {
159
+ const u = g.find((S) => S.streamId === a.streamId);
160
160
  return u ? [
161
- ...m.filter((S) => S.streamId !== o.streamId),
161
+ ...g.filter((S) => S.streamId !== a.streamId),
162
162
  {
163
163
  ...u,
164
164
  loading: !1,
165
- error: o.error
165
+ error: a.error
166
166
  }
167
- ] : m;
167
+ ] : g;
168
168
  });
169
169
  },
170
- onStreamNotFound: (o) => {
170
+ onStreamNotFound: (a) => {
171
171
  var i;
172
- (i = e == null ? void 0 : e.onStreamNotFound) == null || i.call(e, o);
172
+ (i = e == null ? void 0 : e.onStreamNotFound) == null || i.call(e, a);
173
173
  },
174
- onStreamTimeout: (o) => {
174
+ onStreamTimeout: (a) => {
175
175
  var i;
176
- (i = e == null ? void 0 : e.onStreamTimeout) == null || i.call(e, o);
176
+ (i = e == null ? void 0 : e.onStreamTimeout) == null || i.call(e, a);
177
177
  }
178
178
  }), l = W(
179
- async (o, i) => {
180
- const m = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, u = await s();
179
+ async (a, i) => {
180
+ const g = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, u = await s();
181
181
  if (u.type === "success") {
182
- r([
183
- ...n,
182
+ n([
183
+ ...r,
184
184
  {
185
- taskKey: m,
185
+ taskKey: g,
186
186
  streamId: u.stream.id,
187
187
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
188
188
  confirmedData: null,
189
189
  error: null,
190
- params: o,
190
+ params: a,
191
191
  progressItems: [],
192
192
  loading: !0,
193
193
  doneStreaming: !1,
194
194
  loadingText: i == null ? void 0 : i.loadingText
195
195
  }
196
196
  ]);
197
- const { clientToken: S } = await e.fetchCreateAgentTaskClientToken(o.type), y = await G({
197
+ const { clientToken: S } = await e.fetchCreateAgentTaskClientToken(a.type), y = await G({
198
198
  pk: t.fency.publishableKey,
199
199
  baseUrl: t.fency.baseUrl,
200
200
  clientToken: S,
201
201
  streamToken: u.stream.token,
202
202
  request: {
203
- streamingChatCompletionTask: o.type === "streamingChatCompletion" ? {
204
- messages: o.messages,
205
- model: o.model
203
+ streamingChatCompletionTask: a.type === "streamingChatCompletion" ? {
204
+ messages: a.messages,
205
+ model: a.model
206
206
  } : void 0,
207
- structuredChatCompletionTask: o.type === "structuredChatCompletion" ? {
208
- messages: o.messages,
209
- jsonSchema: o.jsonSchema,
210
- model: o.model
207
+ structuredChatCompletionTask: a.type === "structuredChatCompletion" ? {
208
+ messages: a.messages,
209
+ jsonSchema: a.jsonSchema,
210
+ model: a.model
211
211
  } : void 0,
212
- streamingMemoryTypeChatCompletionTask: o.type === "streamingMemoryTypeChatCompletion" ? {
213
- messages: o.messages,
214
- model: o.model
212
+ streamingMemoryTypeChatCompletionTask: a.type === "streamingMemoryTypeChatCompletion" ? {
213
+ messages: a.messages,
214
+ model: a.model
215
215
  } : void 0
216
216
  }
217
217
  });
218
218
  if (y.type === "success" && y.agentTask) {
219
- a.current.add(
219
+ o.current.add(
220
220
  y.agentTask.id
221
- ), r((f) => [
222
- ...f.filter((h) => h.taskKey !== m),
221
+ ), n((f) => [
222
+ ...f.filter((h) => h.taskKey !== g),
223
223
  {
224
- taskKey: m,
224
+ taskKey: g,
225
225
  streamId: u.stream.id,
226
226
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
227
227
  taskId: y.agentTask.id,
228
228
  createdAt: y.agentTask.createdAt,
229
229
  error: null,
230
- params: o,
230
+ params: a,
231
231
  progressItems: [],
232
232
  doneStreaming: !1,
233
233
  loading: !0,
@@ -239,7 +239,7 @@ const ee = (e) => {
239
239
  }
240
240
  ]);
241
241
  const T = await new Promise((f) => {
242
- g.current.set(
242
+ m.current.set(
243
243
  y.agentTask.id,
244
244
  f
245
245
  );
@@ -252,13 +252,13 @@ const ee = (e) => {
252
252
  };
253
253
  } else {
254
254
  if (y.type === "error")
255
- return r((T) => [
256
- ...T.filter((f) => f.taskKey !== m),
255
+ return n((T) => [
256
+ ...T.filter((f) => f.taskKey !== g),
257
257
  {
258
- taskKey: m,
258
+ taskKey: g,
259
259
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
260
260
  streamId: u.stream.id,
261
- params: o,
261
+ params: a,
262
262
  error: y.error,
263
263
  progressItems: [],
264
264
  loading: !1,
@@ -275,14 +275,14 @@ const ee = (e) => {
275
275
  message: "No response received",
276
276
  code: "UnknownError"
277
277
  };
278
- return r((f) => [
279
- ...f.filter((h) => h.taskKey !== m),
278
+ return n((f) => [
279
+ ...f.filter((h) => h.taskKey !== g),
280
280
  {
281
- taskKey: m,
281
+ taskKey: g,
282
282
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
283
283
  streamId: u.stream.id,
284
284
  error: T,
285
- params: o,
285
+ params: a,
286
286
  progressItems: [],
287
287
  loading: !1,
288
288
  doneStreaming: !1,
@@ -298,82 +298,82 @@ const ee = (e) => {
298
298
  } else
299
299
  return console.error(u.error), u;
300
300
  },
301
- [t, n, s]
302
- ), d = $(() => {
303
- if (n.length !== 0)
304
- return [...n].sort((o, i) => new Date(i.triggeredAt).getTime() - new Date(o.triggeredAt).getTime())[0];
305
- }, [n]);
301
+ [t, r, s]
302
+ ), d = B(() => {
303
+ if (r.length !== 0)
304
+ return [...r].sort((a, i) => new Date(i.triggeredAt).getTime() - new Date(a.triggeredAt).getTime())[0];
305
+ }, [r]);
306
306
  return E(() => () => {
307
- a.current.clear(), g.current.clear();
307
+ o.current.clear(), m.current.clear();
308
308
  }, []), {
309
- agentTasks: n,
309
+ agentTasks: r,
310
310
  createAgentTask: l,
311
311
  latest: d
312
312
  };
313
313
  };
314
- async function ie(e, t) {
315
- const n = e.getReader();
316
- let r;
317
- for (; !(r = await n.read()).done; )
318
- t(r.value);
314
+ async function oe(e, t) {
315
+ const r = e.getReader();
316
+ let n;
317
+ for (; !(n = await r.read()).done; )
318
+ t(n.value);
319
319
  }
320
- function se(e) {
321
- let t, n, r, a = !1;
320
+ function ie(e) {
321
+ let t, r, n, o = !1;
322
322
  return function(s) {
323
- t === void 0 ? (t = s, n = 0, r = -1) : t = le(t, s);
323
+ t === void 0 ? (t = s, r = 0, n = -1) : t = ce(t, s);
324
324
  const l = t.length;
325
325
  let d = 0;
326
- for (; n < l; ) {
327
- a && (t[n] === 10 && (d = ++n), a = !1);
328
- let o = -1;
329
- for (; n < l && o === -1; ++n)
330
- switch (t[n]) {
326
+ for (; r < l; ) {
327
+ o && (t[r] === 10 && (d = ++r), o = !1);
328
+ let a = -1;
329
+ for (; r < l && a === -1; ++r)
330
+ switch (t[r]) {
331
331
  case 58:
332
- r === -1 && (r = n - d);
332
+ n === -1 && (n = r - d);
333
333
  break;
334
334
  case 13:
335
- a = !0;
335
+ o = !0;
336
336
  case 10:
337
- o = n;
337
+ a = r;
338
338
  break;
339
339
  }
340
- if (o === -1)
340
+ if (a === -1)
341
341
  break;
342
- e(t.subarray(d, o), r), d = n, r = -1;
342
+ e(t.subarray(d, a), n), d = r, n = -1;
343
343
  }
344
- d === l ? t = void 0 : d !== 0 && (t = t.subarray(d), n -= d);
344
+ d === l ? t = void 0 : d !== 0 && (t = t.subarray(d), r -= d);
345
345
  };
346
346
  }
347
- function ce(e, t, n) {
348
- let r = O();
349
- const a = new TextDecoder();
347
+ function se(e, t, r) {
348
+ let n = O();
349
+ const o = new TextDecoder();
350
350
  return function(s, l) {
351
351
  if (s.length === 0)
352
- n == null || n(r), r = O();
352
+ r == null || r(n), n = O();
353
353
  else if (l > 0) {
354
- const d = a.decode(s.subarray(0, l)), o = l + (s[l + 1] === 32 ? 2 : 1), i = a.decode(s.subarray(o));
354
+ const d = o.decode(s.subarray(0, l)), a = l + (s[l + 1] === 32 ? 2 : 1), i = o.decode(s.subarray(a));
355
355
  switch (d) {
356
356
  case "data":
357
- r.data = r.data ? r.data + `
357
+ n.data = n.data ? n.data + `
358
358
  ` + i : i;
359
359
  break;
360
360
  case "event":
361
- r.event = i;
361
+ n.event = i;
362
362
  break;
363
363
  case "id":
364
- e(r.id = i);
364
+ e(n.id = i);
365
365
  break;
366
366
  case "retry":
367
- const m = parseInt(i, 10);
368
- isNaN(m) || t(r.retry = m);
367
+ const g = parseInt(i, 10);
368
+ isNaN(g) || t(n.retry = g);
369
369
  break;
370
370
  }
371
371
  }
372
372
  };
373
373
  }
374
- function le(e, t) {
375
- const n = new Uint8Array(e.length + t.length);
376
- return n.set(e), n.set(t, e.length), n;
374
+ function ce(e, t) {
375
+ const r = new Uint8Array(e.length + t.length);
376
+ return r.set(e), r.set(t, e.length), r;
377
377
  }
378
378
  function O() {
379
379
  return {
@@ -383,106 +383,106 @@ function O() {
383
383
  retry: void 0
384
384
  };
385
385
  }
386
- var de = function(e, t) {
387
- var n = {};
388
- for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]);
386
+ var le = function(e, t) {
387
+ var r = {};
388
+ for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
389
389
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
390
- for (var a = 0, r = Object.getOwnPropertySymbols(e); a < r.length; a++)
391
- t.indexOf(r[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[a]) && (n[r[a]] = e[r[a]]);
392
- return n;
390
+ for (var o = 0, n = Object.getOwnPropertySymbols(e); o < n.length; o++)
391
+ t.indexOf(n[o]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[o]) && (r[n[o]] = e[n[o]]);
392
+ return r;
393
393
  };
394
- const F = "text/event-stream", ue = 1e3, D = "last-event-id";
394
+ const F = "text/event-stream", de = 1e3, D = "last-event-id";
395
395
  function j(e, t) {
396
- var { signal: n, headers: r, onopen: a, onmessage: g, onclose: s, onerror: l, openWhenHidden: d, fetch: o } = t, i = de(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
397
- return new Promise((m, u) => {
398
- const S = Object.assign({}, r);
396
+ var { signal: r, headers: n, onopen: o, onmessage: m, onclose: s, onerror: l, openWhenHidden: d, fetch: a } = t, i = le(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
397
+ return new Promise((g, u) => {
398
+ const S = Object.assign({}, n);
399
399
  S.accept || (S.accept = F);
400
400
  let y;
401
401
  function T() {
402
- y.abort(), document.hidden || A();
402
+ y.abort(), document.hidden || p();
403
403
  }
404
404
  d || document.addEventListener("visibilitychange", T);
405
- let f = ue, h = 0;
405
+ let f = de, h = 0;
406
406
  function b() {
407
407
  document.removeEventListener("visibilitychange", T), window.clearTimeout(h), y.abort();
408
408
  }
409
- n == null || n.addEventListener("abort", () => {
410
- b(), m();
409
+ r == null || r.addEventListener("abort", () => {
410
+ b(), g();
411
411
  });
412
- const I = o ?? window.fetch, w = a ?? me;
413
- async function A() {
412
+ const I = a ?? window.fetch, w = o ?? ue;
413
+ async function p() {
414
414
  var M;
415
415
  y = new AbortController();
416
416
  try {
417
417
  const P = await I(e, Object.assign(Object.assign({}, i), { headers: S, signal: y.signal }));
418
- await w(P), await ie(P.body, se(ce((C) => {
419
- C ? S[D] = C : delete S[D];
420
- }, (C) => {
421
- f = C;
422
- }, g))), s == null || s(), b(), m();
418
+ await w(P), await oe(P.body, ie(se((k) => {
419
+ k ? S[D] = k : delete S[D];
420
+ }, (k) => {
421
+ f = k;
422
+ }, m))), s == null || s(), b(), g();
423
423
  } catch (P) {
424
424
  if (!y.signal.aborted)
425
425
  try {
426
- const C = (M = l == null ? void 0 : l(P)) !== null && M !== void 0 ? M : f;
427
- window.clearTimeout(h), h = window.setTimeout(A, C);
428
- } catch (C) {
429
- b(), u(C);
426
+ const k = (M = l == null ? void 0 : l(P)) !== null && M !== void 0 ? M : f;
427
+ window.clearTimeout(h), h = window.setTimeout(p, k);
428
+ } catch (k) {
429
+ b(), u(k);
430
430
  }
431
431
  }
432
432
  }
433
- A();
433
+ p();
434
434
  });
435
435
  }
436
- function me(e) {
436
+ function ue(e) {
437
437
  const t = e.headers.get("content-type");
438
438
  if (!(t != null && t.startsWith(F)))
439
439
  throw new Error(`Expected content-type to be ${F}, Actual: ${t}`);
440
440
  }
441
- function We(e) {
442
- const [t, n] = k(null);
441
+ function De(e) {
442
+ const [t, r] = C(null);
443
443
  return E(() => {
444
444
  if (!t)
445
445
  return;
446
- const r = new AbortController();
446
+ const n = new AbortController();
447
447
  return j(t, {
448
448
  headers: e == null ? void 0 : e.headers,
449
- signal: r.signal,
450
- async onopen(a) {
451
- if (!a.ok && a.status >= 400 && a.status < 500 && a.status !== 429)
452
- throw new Error(`Client error ${a.status}`);
449
+ signal: n.signal,
450
+ async onopen(o) {
451
+ if (!o.ok && o.status >= 400 && o.status < 500 && o.status !== 429)
452
+ throw new Error(`Client error ${o.status}`);
453
453
  },
454
- onmessage(a) {
455
- a.data && (e == null || e.onMessage({
454
+ onmessage(o) {
455
+ o.data && (e == null || e.onMessage({
456
456
  url: t,
457
- data: H(a.data)
457
+ data: H(o.data)
458
458
  }));
459
459
  },
460
- onerror(a) {
461
- throw console.error("EventSource error:", a), e == null || e.onError(t), n(null), a;
460
+ onerror(o) {
461
+ throw console.error("EventSource error:", o), e == null || e.onError(t), r(null), o;
462
462
  },
463
463
  onclose() {
464
464
  }
465
465
  }), () => {
466
- r.abort();
466
+ n.abort();
467
467
  };
468
468
  }, [t, e == null ? void 0 : e.headers]), {
469
- setSourceUrl: n,
469
+ setSourceUrl: r,
470
470
  sourceUrl: t
471
471
  };
472
472
  }
473
473
  function H(e) {
474
- const t = atob(e), n = new Uint8Array(t.length);
475
- for (let r = 0; r < t.length; r++)
476
- n[r] = t.charCodeAt(r);
477
- return new TextDecoder("utf-8").decode(n);
474
+ const t = atob(e), r = new Uint8Array(t.length);
475
+ for (let n = 0; n < t.length; n++)
476
+ r[n] = t.charCodeAt(n);
477
+ return new TextDecoder("utf-8").decode(r);
478
478
  }
479
- function $e(e, t) {
480
- const [n, r] = k(
479
+ function Ue(e, t) {
480
+ const [r, n] = C(
481
481
  null
482
- ), [a, g] = k(
482
+ ), [o, m] = C(
483
483
  null
484
- ), s = N(), l = async (m) => {
485
- const u = await m.fetchTokens(), { fetchTokens: S, nextPageToken: y, previousPageToken: T, ...f } = m, h = await e({
484
+ ), s = N(), l = async (g) => {
485
+ const u = await g.fetchTokens(), { fetchTokens: S, nextPageToken: y, previousPageToken: T, ...f } = g, h = await e({
486
486
  pk: s.fency.publishableKey,
487
487
  clientToken: u.clientToken,
488
488
  streamToken: u.streamToken,
@@ -513,16 +513,16 @@ function $e(e, t) {
513
513
  };
514
514
  };
515
515
  return {
516
- fetchFirstPage: async (m) => {
516
+ fetchFirstPage: async (g) => {
517
517
  const u = await l({
518
- ...m,
518
+ ...g,
519
519
  nextPageToken: void 0,
520
520
  previousPageToken: void 0
521
521
  });
522
- return u.type === "success" && (g(u.page), r(m)), u;
522
+ return u.type === "success" && (m(u.page), n(g)), u;
523
523
  },
524
- fetchNextPage: async (m) => {
525
- if (a == null)
524
+ fetchNextPage: async (g) => {
525
+ if (o == null)
526
526
  return {
527
527
  type: "error",
528
528
  error: {
@@ -530,7 +530,7 @@ function $e(e, t) {
530
530
  message: "No current page"
531
531
  }
532
532
  };
533
- if (a.pagination.nextPageToken == null)
533
+ if (o.pagination.nextPageToken == null)
534
534
  return {
535
535
  type: "error",
536
536
  error: {
@@ -539,14 +539,14 @@ function $e(e, t) {
539
539
  }
540
540
  };
541
541
  const u = await l({
542
- ...m,
543
- nextPageToken: a.pagination.nextPageToken,
542
+ ...g,
543
+ nextPageToken: o.pagination.nextPageToken,
544
544
  previousPageToken: void 0
545
545
  });
546
- return u.type === "success" && (g(u.page), r(m)), u;
546
+ return u.type === "success" && (m(u.page), n(g)), u;
547
547
  },
548
- fetchPreviousPage: async (m) => {
549
- if (a == null)
548
+ fetchPreviousPage: async (g) => {
549
+ if (o == null)
550
550
  return {
551
551
  type: "error",
552
552
  error: {
@@ -554,7 +554,7 @@ function $e(e, t) {
554
554
  message: "No current page"
555
555
  }
556
556
  };
557
- if (a.pagination.previousPageToken == null)
557
+ if (o.pagination.previousPageToken == null)
558
558
  return {
559
559
  type: "error",
560
560
  error: {
@@ -563,59 +563,59 @@ function $e(e, t) {
563
563
  }
564
564
  };
565
565
  const u = await l({
566
- ...m,
566
+ ...g,
567
567
  nextPageToken: void 0,
568
- previousPageToken: a.pagination.previousPageToken
568
+ previousPageToken: o.pagination.previousPageToken
569
569
  });
570
- return u.type === "success" && (g(u.page), r(m)), u;
570
+ return u.type === "success" && (m(u.page), n(g)), u;
571
571
  },
572
- refetchCurrentPage: async () => n == null ? {
572
+ refetchCurrentPage: async () => r == null ? {
573
573
  type: "error",
574
574
  error: {
575
575
  code: "NO_CURRENT_PAGE",
576
576
  message: "No current page, please call fetchFirstPage first."
577
577
  }
578
- } : l(n),
579
- currentPage: a
578
+ } : l(r),
579
+ currentPage: o
580
580
  };
581
581
  }
582
- function ge(e) {
583
- return e.progressItems.map((t, n) => {
584
- const r = e.progressItems[n + 1], a = r != null;
585
- let g;
586
- if (r != null && r.createdAt) {
587
- const s = new Date(t.createdAt).getTime(), l = new Date(r.createdAt).getTime();
588
- g = Math.round((l - s) / 1e3);
582
+ function me(e) {
583
+ return e.progressItems.map((t, r) => {
584
+ const n = e.progressItems[r + 1], o = n != null;
585
+ let m;
586
+ if (n != null && n.createdAt) {
587
+ const s = new Date(t.createdAt).getTime(), l = new Date(n.createdAt).getTime();
588
+ m = Math.round((l - s) / 1e3);
589
589
  }
590
590
  return {
591
591
  item: t,
592
- completed: a,
593
- isLatest: n === e.progressItems.length - 1,
594
- durationSeconds: g
592
+ completed: o,
593
+ isLatest: r === e.progressItems.length - 1,
594
+ durationSeconds: m
595
595
  };
596
596
  });
597
597
  }
598
598
  function R({
599
599
  text: e,
600
600
  duration: t = 2,
601
- delay: n = 0,
602
- repeat: r = !0,
603
- repeatDelay: a = 0.5,
604
- className: g,
601
+ delay: r = 0,
602
+ repeat: n = !0,
603
+ repeatDelay: o = 0.5,
604
+ className: m,
605
605
  startOnView: s = !1,
606
606
  once: l = !1,
607
607
  inViewMargin: d,
608
- spread: o = 2,
608
+ spread: a = 2,
609
609
  color: i = "#999",
610
- shimmerColor: m = "#000",
610
+ shimmerColor: g = "#000",
611
611
  direction: u = "fromBottom"
612
612
  }) {
613
- const S = p(null), y = Q(S, { once: l, margin: d }), T = $(() => e.length * o, [e, o]), f = !s || y, h = u === "fromBottom" ? "100% center" : "-100% center", b = u === "fromBottom" ? "0% center" : "200% center";
613
+ const S = A(null), y = X(S, { once: l, margin: d }), T = B(() => e.length * a, [e, a]), f = !s || y, h = u === "fromBottom" ? "100% center" : "-100% center", b = u === "fromBottom" ? "0% center" : "200% center";
614
614
  return /* @__PURE__ */ c(
615
615
  v.span,
616
616
  {
617
617
  ref: S,
618
- className: g,
618
+ className: m,
619
619
  style: {
620
620
  position: "relative",
621
621
  display: "inline-block",
@@ -627,7 +627,7 @@ function R({
627
627
  backgroundRepeat: "no-repeat, padding-box",
628
628
  "--spread": `${T}px`,
629
629
  "--base-color": i,
630
- "--shimmer-color": m,
630
+ "--shimmer-color": g,
631
631
  "--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
632
632
  backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
633
633
  },
@@ -641,22 +641,22 @@ function R({
641
641
  } : {},
642
642
  transition: {
643
643
  backgroundPosition: {
644
- repeat: r ? 1 / 0 : 0,
644
+ repeat: n ? 1 / 0 : 0,
645
645
  duration: t,
646
- delay: n,
647
- repeatDelay: a,
646
+ delay: r,
647
+ repeatDelay: o,
648
648
  ease: "linear"
649
649
  },
650
650
  opacity: {
651
651
  duration: 0.3,
652
- delay: n
652
+ delay: r
653
653
  }
654
654
  },
655
655
  children: e
656
656
  }
657
657
  );
658
658
  }
659
- function ye(e) {
659
+ function ge(e) {
660
660
  const t = e.item.data;
661
661
  if (t.taskType === "StreamingChatCompletion") {
662
662
  if (t.eventType === "Text") return "Streaming...";
@@ -687,11 +687,11 @@ function ye(e) {
687
687
  }
688
688
  return "Processing...";
689
689
  }
690
- const fe = ({ progressViewItems: e }) => {
690
+ const ye = ({ progressViewItems: e }) => {
691
691
  const t = e[e.length - 1];
692
692
  if (!t) return null;
693
- const n = ye(t);
694
- return /* @__PURE__ */ c("div", { className: "simple-mode-container", children: /* @__PURE__ */ c(B, { mode: "wait", children: /* @__PURE__ */ c(
693
+ const r = ge(t);
694
+ return /* @__PURE__ */ c("div", { className: "simple-mode-container", children: /* @__PURE__ */ c(L, { mode: "wait", children: /* @__PURE__ */ c(
695
695
  v.div,
696
696
  {
697
697
  initial: { opacity: 0, y: 10 },
@@ -703,12 +703,12 @@ const fe = ({ progressViewItems: e }) => {
703
703
  {
704
704
  className: "simple-mode-title",
705
705
  style: { color: "#666" },
706
- children: n
706
+ children: r
707
707
  }
708
708
  ) : /* @__PURE__ */ c(
709
709
  R,
710
710
  {
711
- text: n,
711
+ text: r,
712
712
  className: "simple-mode-title",
713
713
  duration: 2.5,
714
714
  repeat: !0,
@@ -880,29 +880,29 @@ const fe = ({ progressViewItems: e }) => {
880
880
  animate: { opacity: 1, y: 0 },
881
881
  transition: { duration: 0.3, delay: 0 },
882
882
  children: /* @__PURE__ */ c(
883
- Y,
883
+ Q,
884
884
  {
885
- remarkPlugins: [Z],
885
+ remarkPlugins: [Y],
886
886
  components: {
887
887
  code(t) {
888
- const { children: n, className: r, node: a, ref: g, ...s } = t, l = /language-(\w+)/.exec(r || "");
888
+ const { children: r, className: n, node: o, ref: m, ...s } = t, l = /language-(\w+)/.exec(n || "");
889
889
  return l ? /* @__PURE__ */ c(
890
- L,
890
+ $,
891
891
  {
892
892
  ...s,
893
893
  PreTag: "div",
894
- children: String(n).replace(/\n$/, ""),
894
+ children: String(r).replace(/\n$/, ""),
895
895
  language: l[1],
896
896
  style: K
897
897
  }
898
- ) : /* @__PURE__ */ c("code", { ...s, className: r, children: String(n) });
898
+ ) : /* @__PURE__ */ c("code", { ...s, className: n, children: String(r) });
899
899
  }
900
900
  },
901
901
  children: e
902
902
  }
903
903
  )
904
904
  }
905
- ) }), he = ({ data: e }) => {
905
+ ) }), fe = ({ data: e }) => {
906
906
  const t = JSON.stringify(e.json, null, 2);
907
907
  return /* @__PURE__ */ c("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ c(
908
908
  v.div,
@@ -910,11 +910,11 @@ const fe = ({ progressViewItems: e }) => {
910
910
  initial: { opacity: 0, y: -10 },
911
911
  animate: { opacity: 1, y: 0 },
912
912
  transition: { duration: 0.3, delay: 0 },
913
- children: /* @__PURE__ */ c(L, { language: "json", style: K, PreTag: "div", children: t })
913
+ children: /* @__PURE__ */ c($, { language: "json", style: K, PreTag: "div", children: t })
914
914
  }
915
915
  ) });
916
- }, Se = ({ data: e, isLatest: t = !1, durationSeconds: n }) => {
917
- const r = `Searching: ${e.queryDescription}`;
916
+ }, he = ({ data: e, isLatest: t = !1, durationSeconds: r }) => {
917
+ const n = `Searching: ${e.queryDescription}`;
918
918
  return /* @__PURE__ */ x("div", { style: { padding: "16px" }, children: [
919
919
  /* @__PURE__ */ c(
920
920
  v.div,
@@ -928,19 +928,19 @@ const fe = ({ progressViewItems: e }) => {
928
928
  initial: { opacity: 0, y: -10 },
929
929
  animate: { opacity: 1, y: 0 },
930
930
  transition: { duration: 0.3, delay: 0 },
931
- children: t && !n ? /* @__PURE__ */ c(
931
+ children: t && !r ? /* @__PURE__ */ c(
932
932
  R,
933
933
  {
934
- text: r,
934
+ text: n,
935
935
  duration: 2.5,
936
936
  repeat: !0,
937
937
  color: "#999",
938
938
  shimmerColor: "#000"
939
939
  }
940
- ) : /* @__PURE__ */ c("span", { style: { color: "#666" }, children: r })
940
+ ) : /* @__PURE__ */ c("span", { style: { color: "#666" }, children: n })
941
941
  }
942
942
  ),
943
- n !== void 0 && /* @__PURE__ */ x(
943
+ r !== void 0 && /* @__PURE__ */ x(
944
944
  "div",
945
945
  {
946
946
  style: {
@@ -951,14 +951,14 @@ const fe = ({ progressViewItems: e }) => {
951
951
  },
952
952
  children: [
953
953
  "Took ",
954
- n,
954
+ r,
955
955
  " seconds"
956
956
  ]
957
957
  }
958
958
  )
959
959
  ] });
960
- }, Te = ({ isLatest: e = !1, durationSeconds: t }) => {
961
- const n = "Adding sources...";
960
+ }, Se = ({ isLatest: e = !1, durationSeconds: t }) => {
961
+ const r = "Adding sources...";
962
962
  return /* @__PURE__ */ x("div", { style: { padding: "16px" }, children: [
963
963
  /* @__PURE__ */ c(
964
964
  v.div,
@@ -975,13 +975,13 @@ const fe = ({ progressViewItems: e }) => {
975
975
  children: e && !t ? /* @__PURE__ */ c(
976
976
  R,
977
977
  {
978
- text: n,
978
+ text: r,
979
979
  duration: 2.5,
980
980
  repeat: !0,
981
981
  color: "#999",
982
982
  shimmerColor: "#000"
983
983
  }
984
- ) : /* @__PURE__ */ c("span", { style: { color: "#666" }, children: n })
984
+ ) : /* @__PURE__ */ c("span", { style: { color: "#666" }, children: r })
985
985
  }
986
986
  ),
987
987
  t !== void 0 && /* @__PURE__ */ x(
@@ -1001,118 +1001,120 @@ const fe = ({ progressViewItems: e }) => {
1001
1001
  }
1002
1002
  )
1003
1003
  ] });
1004
- }, be = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ x("div", { style: { padding: "16px" }, children: [
1004
+ }, Te = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ x("div", { style: { padding: "16px" }, children: [
1005
1005
  /* @__PURE__ */ c(
1006
1006
  v.div,
1007
1007
  {
1008
- style: { color: "#666", marginBottom: "10px", fontSize: "14px" },
1008
+ style: {
1009
+ marginBottom: "10px",
1010
+ fontSize: "11px",
1011
+ fontWeight: 500,
1012
+ letterSpacing: "0.05em",
1013
+ textTransform: "uppercase",
1014
+ color: "#999"
1015
+ },
1009
1016
  initial: { opacity: 0, y: -10 },
1010
1017
  animate: { opacity: 1, y: 0 },
1011
1018
  transition: { duration: 0.3, delay: 0 },
1012
1019
  children: "Sources"
1013
1020
  }
1014
1021
  ),
1015
- /* @__PURE__ */ c("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.length === 0 ? /* @__PURE__ */ c("span", { style: { fontSize: "13px", color: "#888" }, children: "No sources" }) : e.sources.map((n, r) => /* @__PURE__ */ c(
1022
+ /* @__PURE__ */ c("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.length === 0 ? /* @__PURE__ */ c("span", { style: { fontSize: "13px", color: "#888" }, children: "No sources" }) : e.sources.map((r, n) => /* @__PURE__ */ c(
1016
1023
  Ce,
1017
1024
  {
1018
- source: n,
1019
- index: r,
1025
+ source: r,
1026
+ index: n,
1020
1027
  onSourceClick: t
1021
1028
  },
1022
- n.memoryId
1029
+ r.memoryId
1023
1030
  )) })
1024
1031
  ] });
1025
- function ke(e, t) {
1026
- if (t.length === 0) return e;
1027
- if (t.length === 1) return `${e} page ${t[0]}`;
1028
- if (t.length === 2)
1029
- return `${e} pages ${t[0]} and ${t[1]}`;
1030
- const n = t[t.length - 1], r = t.slice(0, -1).join(", ");
1031
- return `${e} pages ${r} and ${n}`;
1032
+ function be(e) {
1033
+ if (e.length === 0) return "";
1034
+ if (e.length === 1) return `page ${e[0]}`;
1035
+ if (e.length === 2)
1036
+ return `pages ${e[0]} and ${e[1]}`;
1037
+ const t = e[e.length - 1];
1038
+ return `pages ${e.slice(0, -1).join(", ")} and ${t}`;
1032
1039
  }
1033
- const Ce = ({ source: e, index: t, onSourceClick: n }) => {
1034
- const [r, a] = k(!1), g = !!n, s = ke(e.memoryTitle, e.pageNumbers);
1035
- return /* @__PURE__ */ c(
1040
+ const Ce = ({ source: e, index: t, onSourceClick: r }) => {
1041
+ const [n, o] = C(!1), m = !!r, s = e.pageNumbers ?? [], l = be(s);
1042
+ return /* @__PURE__ */ x(
1036
1043
  v.div,
1037
1044
  {
1038
1045
  initial: { opacity: 0, scale: 0.9 },
1039
1046
  animate: { opacity: 1, scale: 1 },
1040
1047
  transition: { duration: 0.25, delay: t * 0.05 },
1041
- onClick: g ? () => n(e.memoryId) : void 0,
1042
- onMouseEnter: g ? () => a(!0) : void 0,
1043
- onMouseLeave: g ? () => a(!1) : void 0,
1048
+ onClick: m ? () => r(e.memoryId) : void 0,
1049
+ onMouseEnter: m ? () => o(!0) : void 0,
1050
+ onMouseLeave: m ? () => o(!1) : void 0,
1044
1051
  style: {
1045
1052
  display: "inline-flex",
1046
1053
  flexDirection: "column",
1047
1054
  gap: "4px",
1048
1055
  padding: "8px 12px",
1049
- borderRadius: "8px",
1056
+ borderRadius: "6px",
1050
1057
  border: "1px solid #e0e0e0",
1051
- backgroundColor: r ? "#f0f0f0" : "#f9f9f9",
1052
- cursor: g ? "pointer" : "default",
1058
+ backgroundColor: n ? "#f5f5f5" : "transparent",
1059
+ cursor: m ? "pointer" : "default",
1053
1060
  transition: "background-color 0.15s ease",
1054
1061
  userSelect: "none"
1055
1062
  },
1056
- children: /* @__PURE__ */ c("span", { style: { fontSize: "13px", fontWeight: 500, color: "#333" }, children: s })
1063
+ children: [
1064
+ /* @__PURE__ */ c("span", { style: { fontSize: "13px", fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1065
+ l && /* @__PURE__ */ c("span", { style: { fontSize: "12px", color: "#666" }, children: l })
1066
+ ]
1057
1067
  }
1058
1068
  );
1059
- }, ve = `
1060
- @keyframes explore-memory-spinner {
1061
- to { transform: rotate(360deg); }
1069
+ };
1070
+ function ke({
1071
+ eventType: e,
1072
+ completed: t
1073
+ }) {
1074
+ return e === "ExploreMemoryError" ? /* @__PURE__ */ c("span", { style: { color: "#c62828", fontSize: 14, fontWeight: 600 }, children: "✗" }) : e === "ExploreMemoryResult" ? /* @__PURE__ */ c("span", { style: { color: "#999", fontSize: 14, fontWeight: 600 }, children: "✓" }) : e === "ExploreMemoryStart" && t ? /* @__PURE__ */ c("span", { style: { color: "#999", fontSize: 14, fontWeight: 600 }, children: "✓" }) : null;
1062
1075
  }
1063
- `;
1064
- function xe() {
1065
- return /* @__PURE__ */ x(X, { children: [
1066
- /* @__PURE__ */ c("style", { children: ve }),
1067
- /* @__PURE__ */ c(
1076
+ const z = 80, ve = ({ data: e, completed: t, isLatest: r = !1 }) => {
1077
+ const [n, o] = C(!1), m = e.eventType === "ExploreMemoryResult" ? e.result : void 0, s = m != null && m.length > z, l = m != null ? n || !s ? m : `${m.slice(0, z)}...` : void 0, d = s;
1078
+ if (e.eventType === "ExploreMemoryStart" && !t) {
1079
+ const i = `Exploring ${e.memoryTitle}...`;
1080
+ return /* @__PURE__ */ c(
1068
1081
  "div",
1069
1082
  {
1070
1083
  style: {
1071
- width: 12,
1072
- height: 12,
1073
- border: "2px solid #e0e0e0",
1074
- borderTopColor: "#666",
1075
- borderRadius: "50%",
1076
- animation: "explore-memory-spinner 0.8s linear infinite"
1077
- }
1084
+ padding: "16px",
1085
+ display: "flex",
1086
+ alignItems: "center"
1087
+ },
1088
+ children: r ? /* @__PURE__ */ c(
1089
+ R,
1090
+ {
1091
+ text: i,
1092
+ duration: 2.5,
1093
+ repeat: !0,
1094
+ color: "#999",
1095
+ shimmerColor: "#000"
1096
+ }
1097
+ ) : /* @__PURE__ */ c("span", { style: { fontSize: 13, color: "#999" }, children: i })
1078
1098
  }
1079
- )
1080
- ] });
1081
- }
1082
- function we({
1083
- eventType: e,
1084
- completed: t
1085
- }) {
1086
- return e === "ExploreMemoryError" ? /* @__PURE__ */ c("span", { style: { color: "#c62828", fontSize: 14, fontWeight: 600 }, children: "✗" }) : e === "ExploreMemoryResult" ? /* @__PURE__ */ c("span", { style: { color: "#2e7d32", fontSize: 14, fontWeight: 600 }, children: "✓" }) : e === "ExploreMemoryStart" ? t ? /* @__PURE__ */ c("span", { style: { color: "#2e7d32", fontSize: 14, fontWeight: 600 }, children: "✓" }) : /* @__PURE__ */ c(xe, {}) : null;
1087
- }
1088
- const z = 80, Ee = ({ data: e, completed: t }) => {
1089
- const [n, r] = k(!1), a = e.eventType === "ExploreMemoryResult" ? e.result : void 0, g = a != null && a.length > z, s = a != null ? n || !g ? a : `${a.slice(0, z)}...` : void 0, l = g;
1099
+ );
1100
+ }
1090
1101
  return /* @__PURE__ */ c("div", { style: { padding: "16px" }, children: /* @__PURE__ */ x(
1091
1102
  v.div,
1092
1103
  {
1093
- initial: { opacity: 0, scale: 0.9 },
1094
- animate: { opacity: 1, scale: 1 },
1095
- transition: { duration: 0.25, delay: 0 },
1096
- onClick: l ? () => r((d) => !d) : void 0,
1104
+ initial: { opacity: 0 },
1105
+ animate: { opacity: 1 },
1106
+ transition: { duration: 0.25 },
1107
+ onClick: d ? () => o((i) => !i) : void 0,
1097
1108
  style: {
1098
- display: "inline-flex",
1109
+ paddingBottom: "12px",
1110
+ borderBottom: "1px solid #eee",
1111
+ display: "flex",
1099
1112
  flexDirection: "row",
1100
1113
  alignItems: "flex-start",
1101
1114
  gap: "10px",
1102
- padding: "8px 12px",
1103
- borderRadius: "8px",
1104
- border: "1px solid #e0e0e0",
1105
- backgroundColor: "#f9f9f9",
1106
1115
  minWidth: 0,
1107
- cursor: l ? "pointer" : "default",
1108
- transition: "background-color 0.15s ease"
1116
+ cursor: d ? "pointer" : "default"
1109
1117
  },
1110
- onMouseEnter: l ? (d) => {
1111
- d.currentTarget.style.backgroundColor = "#f0f0f0";
1112
- } : void 0,
1113
- onMouseLeave: l ? (d) => {
1114
- d.currentTarget.style.backgroundColor = "#f9f9f9";
1115
- } : void 0,
1116
1118
  children: [
1117
1119
  /* @__PURE__ */ c(
1118
1120
  "div",
@@ -1124,7 +1126,7 @@ const z = 80, Ee = ({ data: e, completed: t }) => {
1124
1126
  flexShrink: 0,
1125
1127
  width: 20
1126
1128
  },
1127
- children: /* @__PURE__ */ c(we, { eventType: e.eventType, completed: t })
1129
+ children: /* @__PURE__ */ c(ke, { eventType: e.eventType, completed: t })
1128
1130
  }
1129
1131
  ),
1130
1132
  /* @__PURE__ */ x(
@@ -1138,7 +1140,7 @@ const z = 80, Ee = ({ data: e, completed: t }) => {
1138
1140
  },
1139
1141
  children: [
1140
1142
  /* @__PURE__ */ c("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1141
- s != null && /* @__PURE__ */ c(
1143
+ l != null && /* @__PURE__ */ c(
1142
1144
  "span",
1143
1145
  {
1144
1146
  style: {
@@ -1147,10 +1149,10 @@ const z = 80, Ee = ({ data: e, completed: t }) => {
1147
1149
  lineHeight: 1.4,
1148
1150
  whiteSpace: n ? "pre-wrap" : void 0
1149
1151
  },
1150
- children: s
1152
+ children: l
1151
1153
  }
1152
1154
  ),
1153
- l && /* @__PURE__ */ c(
1155
+ d && /* @__PURE__ */ c(
1154
1156
  "span",
1155
1157
  {
1156
1158
  style: {
@@ -1167,30 +1169,30 @@ const z = 80, Ee = ({ data: e, completed: t }) => {
1167
1169
  ]
1168
1170
  }
1169
1171
  ) });
1170
- }, Ie = ({
1172
+ }, xe = ({
1171
1173
  progressViewItems: e,
1172
1174
  streamToken: t,
1173
- fetchClientToken: n,
1174
- loadingText: r,
1175
- onSourceClick: a
1175
+ fetchClientToken: r,
1176
+ loadingText: n,
1177
+ onSourceClick: o
1176
1178
  }) => {
1177
- const g = p(null);
1179
+ const m = A(null);
1178
1180
  E(() => {
1179
- g.current && (g.current.scrollTop = g.current.scrollHeight);
1181
+ m.current && (m.current.scrollTop = m.current.scrollHeight);
1180
1182
  }, [e.length]);
1181
1183
  const s = (l) => {
1182
1184
  const d = l.item.data;
1183
1185
  if (d.taskType === "StreamingChatCompletion" && d.eventType === "Text")
1184
1186
  return /* @__PURE__ */ c(U, { text: d.text });
1185
1187
  if (d.taskType === "StructuredChatCompletion" && d.eventType === "Json")
1186
- return /* @__PURE__ */ c(he, { data: d });
1188
+ return /* @__PURE__ */ c(fe, { data: d });
1187
1189
  if (d.taskType === "StreamingMemoryTypeChatCompletion")
1188
1190
  switch (d.eventType) {
1189
1191
  case "Text":
1190
1192
  return /* @__PURE__ */ c(U, { text: d.text });
1191
1193
  case "Search":
1192
1194
  return /* @__PURE__ */ c(
1193
- Se,
1195
+ he,
1194
1196
  {
1195
1197
  data: d,
1196
1198
  isLatest: l.isLatest,
@@ -1199,7 +1201,7 @@ const z = 80, Ee = ({ data: e, completed: t }) => {
1199
1201
  );
1200
1202
  case "FindSources":
1201
1203
  return /* @__PURE__ */ c(
1202
- Te,
1204
+ Se,
1203
1205
  {
1204
1206
  data: d,
1205
1207
  isLatest: l.isLatest,
@@ -1208,17 +1210,17 @@ const z = 80, Ee = ({ data: e, completed: t }) => {
1208
1210
  );
1209
1211
  case "SourcesResult":
1210
1212
  return /* @__PURE__ */ c(
1211
- be,
1213
+ Te,
1212
1214
  {
1213
1215
  data: d,
1214
- onSourceClick: a
1216
+ onSourceClick: o
1215
1217
  }
1216
1218
  );
1217
1219
  case "ExploreMemoryStart":
1218
1220
  case "ExploreMemoryResult":
1219
1221
  case "ExploreMemoryError":
1220
1222
  return /* @__PURE__ */ c(
1221
- Ee,
1223
+ ve,
1222
1224
  {
1223
1225
  data: d,
1224
1226
  completed: l.completed,
@@ -1233,14 +1235,14 @@ const z = 80, Ee = ({ data: e, completed: t }) => {
1233
1235
  return e.length === 0 ? /* @__PURE__ */ c("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ c(
1234
1236
  R,
1235
1237
  {
1236
- text: r ?? "Processing your task...",
1238
+ text: n ?? "Processing your task...",
1237
1239
  duration: 1.5,
1238
1240
  repeat: !0,
1239
1241
  repeatDelay: 0,
1240
1242
  color: "#999",
1241
1243
  shimmerColor: "#000"
1242
1244
  }
1243
- ) }) : /* @__PURE__ */ c("div", { id: "agent-task-progress-verbose", ref: g, children: /* @__PURE__ */ c(B, { children: e.map((l, d) => /* @__PURE__ */ c(
1245
+ ) }) : /* @__PURE__ */ c("div", { id: "agent-task-progress-verbose", ref: m, children: /* @__PURE__ */ c(L, { children: e.map((l, d) => /* @__PURE__ */ c(
1244
1246
  v.div,
1245
1247
  {
1246
1248
  id: `agent-task-progress-item-${l.item.progressItemId}`,
@@ -1255,26 +1257,26 @@ const z = 80, Ee = ({ data: e, completed: t }) => {
1255
1257
  },
1256
1258
  l.item.progressItemId
1257
1259
  )) }) });
1258
- }, Be = ({
1260
+ }, ze = ({
1259
1261
  agentTask: e,
1260
1262
  mode: t = "verbose",
1261
- streamToken: n,
1262
- fetchClientToken: r,
1263
- onSourceClick: a
1263
+ streamToken: r,
1264
+ fetchClientToken: n,
1265
+ onSourceClick: o
1264
1266
  }) => {
1265
- const g = ge(e);
1266
- return t === "simple" ? /* @__PURE__ */ c(fe, { progressViewItems: g }) : /* @__PURE__ */ c(
1267
- Ie,
1267
+ const m = me(e);
1268
+ return t === "simple" ? /* @__PURE__ */ c(ye, { progressViewItems: m }) : /* @__PURE__ */ c(
1269
+ xe,
1268
1270
  {
1269
- progressViewItems: g,
1270
- streamToken: n,
1271
- fetchClientToken: r,
1271
+ progressViewItems: m,
1272
+ streamToken: r,
1273
+ fetchClientToken: n,
1272
1274
  loadingText: e.loadingText,
1273
- onSourceClick: a
1275
+ onSourceClick: o
1274
1276
  }
1275
1277
  );
1276
1278
  };
1277
- class Ae {
1279
+ class we {
1278
1280
  constructor(t) {
1279
1281
  this.eventSources = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Map(), this.fency = t;
1280
1282
  }
@@ -1283,25 +1285,25 @@ class Ae {
1283
1285
  * Creates new connections and removes old ones.
1284
1286
  */
1285
1287
  updateStreams(t) {
1286
- t.forEach((r) => {
1287
- const a = r.stream.id;
1288
- this.eventSources.has(a) || this.connectStream(r);
1288
+ t.forEach((n) => {
1289
+ const o = n.stream.id;
1290
+ this.eventSources.has(o) || this.connectStream(n);
1289
1291
  });
1290
- const n = new Set(t.map((r) => r.stream.id));
1291
- this.eventSources.forEach((r, a) => {
1292
- n.has(a) || (r.abort(), this.eventSources.delete(a));
1292
+ const r = new Set(t.map((n) => n.stream.id));
1293
+ this.eventSources.forEach((n, o) => {
1294
+ r.has(o) || (n.abort(), this.eventSources.delete(o));
1293
1295
  });
1294
1296
  }
1295
1297
  connectStream(t) {
1296
- const n = t.stream.id, r = new AbortController();
1297
- this.eventSources.set(n, r);
1298
- const a = `${this.fency.baseUrl}/sse/streams/${n}`, g = {
1298
+ const r = t.stream.id, n = new AbortController();
1299
+ this.eventSources.set(r, n);
1300
+ const o = `${this.fency.baseUrl}/sse/streams/${r}`, m = {
1299
1301
  "X-Fency-Publishable-Key": this.fency.publishableKey,
1300
1302
  "X-Fency-Stream-Token": t.stream.token
1301
1303
  };
1302
- j(a, {
1303
- headers: g,
1304
- signal: r.signal,
1304
+ j(o, {
1305
+ headers: m,
1306
+ signal: n.signal,
1305
1307
  async onopen(s) {
1306
1308
  if (!s.ok && s.status >= 400 && s.status < 500 && s.status !== 429)
1307
1309
  throw new Error(`Client error ${s.status}`);
@@ -1309,11 +1311,11 @@ class Ae {
1309
1311
  onmessage: (s) => {
1310
1312
  if (s.data) {
1311
1313
  const l = H(s.data);
1312
- this.broadcast(l, n);
1314
+ this.broadcast(l, r);
1313
1315
  }
1314
1316
  },
1315
1317
  onerror: (s) => {
1316
- throw console.error("EventSource error for stream", n, ":", s), this.broadcastError(n), s;
1318
+ throw console.error("EventSource error for stream", r, ":", s), this.broadcastError(r), s;
1317
1319
  },
1318
1320
  onclose() {
1319
1321
  }
@@ -1323,19 +1325,19 @@ class Ae {
1323
1325
  * Subscribe to events from all active streams.
1324
1326
  * Returns an unsubscribe function.
1325
1327
  */
1326
- subscribe(t, n) {
1327
- return this.subscribers.set(t, n), () => {
1328
+ subscribe(t, r) {
1329
+ return this.subscribers.set(t, r), () => {
1328
1330
  this.subscribers.delete(t);
1329
1331
  };
1330
1332
  }
1331
- broadcast(t, n) {
1332
- this.subscribers.forEach((r) => {
1333
- r.onMessage(t, n);
1333
+ broadcast(t, r) {
1334
+ this.subscribers.forEach((n) => {
1335
+ n.onMessage(t, r);
1334
1336
  });
1335
1337
  }
1336
1338
  broadcastError(t) {
1337
- this.subscribers.forEach((n) => {
1338
- n.onError(t);
1339
+ this.subscribers.forEach((r) => {
1340
+ r.onError(t);
1339
1341
  });
1340
1342
  }
1341
1343
  /**
@@ -1345,92 +1347,92 @@ class Ae {
1345
1347
  this.eventSources.forEach((t) => t.abort()), this.eventSources.clear(), this.subscribers.clear();
1346
1348
  }
1347
1349
  }
1348
- const pe = 12e4, Pe = (e) => {
1350
+ const Ee = 12e4, Ie = (e) => {
1349
1351
  const t = Date.now();
1350
- return e.filter((n) => t - n.createdAt < pe);
1352
+ return e.filter((r) => t - r.createdAt < Ee);
1351
1353
  };
1352
- function Le({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
1353
- const [r, a] = k(
1354
+ function We({ fency: e, fetchCreateStreamClientToken: t, children: r }) {
1355
+ const [n, o] = C(
1354
1356
  null
1355
- ), [g, s] = k(!0), [l, d] = k(null), [o, i] = k([]), m = p(null), u = p(null);
1357
+ ), [m, s] = C(!0), [l, d] = C(null), [a, i] = C([]), g = A(null), u = A(null);
1356
1358
  E(() => {
1357
1359
  e.then((f) => {
1358
- a(f), s(!1);
1360
+ o(f), s(!1);
1359
1361
  }).catch((f) => {
1360
1362
  d(f), s(!1);
1361
1363
  });
1362
1364
  }, [e]), E(() => {
1363
- r && !u.current && (u.current = new Ae(r));
1364
- }, [r]), E(() => {
1365
- u.current && u.current.updateStreams(o);
1366
- }, [o]), E(() => () => {
1365
+ n && !u.current && (u.current = new we(n));
1366
+ }, [n]), E(() => {
1367
+ u.current && u.current.updateStreams(a);
1368
+ }, [a]), E(() => () => {
1367
1369
  var f;
1368
1370
  (f = u.current) == null || f.cleanup();
1369
1371
  }, []);
1370
1372
  const S = W(
1371
1373
  async (f = 3e4) => {
1372
- if (m.current)
1373
- return m.current;
1374
- const h = Date.now(), b = o.length > 0 ? o[o.length - 1] : null;
1374
+ if (g.current)
1375
+ return g.current;
1376
+ const h = Date.now(), b = a.length > 0 ? a[a.length - 1] : null;
1375
1377
  if (b && h - b.createdAt < f)
1376
1378
  return b.stream;
1377
1379
  const I = (async () => {
1378
- if (!r)
1380
+ if (!n)
1379
1381
  throw new Error("Fency instance not initialized");
1380
- const w = await t(), A = await J({
1381
- pk: r.publishableKey,
1382
- baseUrl: r.baseUrl,
1382
+ const w = await t(), p = await J({
1383
+ pk: n.publishableKey,
1384
+ baseUrl: n.baseUrl,
1383
1385
  clientToken: (w == null ? void 0 : w.clientToken) ?? ""
1384
1386
  });
1385
- if (A.type === "success") {
1387
+ if (p.type === "success") {
1386
1388
  const M = {
1387
- stream: A.stream,
1389
+ stream: p.stream,
1388
1390
  createdAt: Date.now()
1389
1391
  };
1390
1392
  return i((P) => {
1391
- const C = [...P, M];
1392
- return Pe(C);
1393
- }), m.current = null, A.stream;
1393
+ const k = [...P, M];
1394
+ return Ie(k);
1395
+ }), g.current = null, p.stream;
1394
1396
  } else
1395
- throw m.current = null, new Error("Failed to create stream");
1397
+ throw g.current = null, new Error("Failed to create stream");
1396
1398
  })();
1397
- return m.current = I, I;
1399
+ return g.current = I, I;
1398
1400
  },
1399
- [r, o]
1401
+ [n, a]
1400
1402
  );
1401
1403
  if (l)
1402
1404
  return /* @__PURE__ */ x("div", { children: [
1403
1405
  "Fency error: ",
1404
1406
  l.message
1405
1407
  ] });
1406
- if (!r)
1408
+ if (!n)
1407
1409
  return null;
1408
- const y = o.length > 0 ? o[o.length - 1] : null, T = {
1409
- fency: r,
1410
- loading: g,
1410
+ const y = a.length > 0 ? a[a.length - 1] : null, T = {
1411
+ fency: n,
1412
+ loading: m,
1411
1413
  error: l,
1412
- activeStreams: o,
1414
+ activeStreams: a,
1413
1415
  latestStream: y,
1414
1416
  eventManager: u.current,
1415
1417
  getOrCreateStream: S
1416
1418
  };
1417
- return /* @__PURE__ */ c(_.Provider, { value: T, children: n });
1419
+ return /* @__PURE__ */ c(_.Provider, { value: T, children: r });
1418
1420
  }
1419
1421
  export {
1420
- Be as AgentTaskProgress,
1421
- fe as AgentTaskProgressSimple,
1422
- Ie as AgentTaskProgressVerbose,
1423
- Le as FencyProvider,
1422
+ ze as AgentTaskProgress,
1423
+ ye as AgentTaskProgressSimple,
1424
+ xe as AgentTaskProgressVerbose,
1425
+ We as FencyProvider,
1424
1426
  R as ShimmeringText,
1425
1427
  U as StreamingChatCompletionText,
1426
- Ee as StreamingMemoryTypeChatCompletionExploreMemory,
1427
- Te as StreamingMemoryTypeChatCompletionFindSources,
1428
- Se as StreamingMemoryTypeChatCompletionSearch,
1429
- be as StreamingMemoryTypeChatCompletionSourcesResult,
1430
- he as StructuredChatCompletionJson,
1431
- ze as useAgentTasks,
1428
+ ve as StreamingMemoryTypeChatCompletionExploreMemory,
1429
+ Se as StreamingMemoryTypeChatCompletionFindSources,
1430
+ he as StreamingMemoryTypeChatCompletionSearch,
1431
+ Te as StreamingMemoryTypeChatCompletionSourcesResult,
1432
+ fe as StructuredChatCompletionJson,
1433
+ Oe as useAgentTasks,
1432
1434
  N as useFencyContext,
1433
- We as useFencyEventSource,
1434
- $e as usePaginatedQuery,
1435
- oe as useStream
1435
+ De as useFencyEventSource,
1436
+ Ue as usePaginatedQuery,
1437
+ ae as useStream
1436
1438
  };