@fencyai/react 0.1.120 → 0.1.121

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