@fencyai/react 0.1.120 → 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.
package/dist/index.js CHANGED
@@ -1,47 +1,47 @@
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 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
+ 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 Z = (e) => {
18
18
  try {
19
19
  const t = JSON.parse(e);
20
- return ne(t);
20
+ return ee(t);
21
21
  } catch (t) {
22
22
  return console.error("Error parsing message:", t), null;
23
23
  }
24
- }, ne = (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 re(e);
29
+ return te(e);
30
30
  case "StreamNotFound":
31
- return oe(e);
31
+ return ne(e);
32
32
  case "AgentTaskProgressItemUpdated":
33
- return ae(e);
33
+ return re(e);
34
34
  }
35
35
  return null;
36
- }, re = (e) => ({
36
+ }, te = (e) => ({
37
37
  type: "StreamTimeout",
38
38
  streamId: e.streamId,
39
39
  timestamp: e.timestamp
40
- }), oe = (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,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
+ }), ae = (e) => {
53
+ const t = N(), [r, n] = C(null), o = A(`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, a) => {
58
+ var g, u, S, y, T, f, h, b, I, w;
59
+ const i = Z(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
+ (g = e == null ? void 0 : e.onNewChatCompletionStreamChunk) == null || g.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) => {
94
+ onError: (d) => {
95
95
  var a;
96
96
  (a = e == null ? void 0 : e.onStreamError) == null || a.call(e, {
97
- streamId: c,
97
+ streamId: d,
98
98
  error: {
99
99
  code: "UnknownError",
100
100
  message: "Unknown error in useStream"
@@ -104,83 +104,86 @@ const te = (e) => {
104
104
  };
105
105
  return t.eventManager.subscribe(
106
106
  o.current,
107
- d
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 n(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
- stream: n
127
+ stream: r
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({
129
+ }, Oe = (e) => {
130
+ const t = N(), [r, n] = C([]), o = A(/* @__PURE__ */ new Set()), m = A(/* @__PURE__ */ new Map()), { createStream: s } = ae({
131
131
  onAgentTaskProgressItemUpdated: (a) => {
132
- var m;
132
+ var u;
133
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));
134
+ const i = a.data;
135
+ if (i.taskType === "StreamingChatCompletion" && i.eventType === "Completed" || i.taskType === "StructuredChatCompletion" && i.eventType === "Completed" || i.taskType === "StreamingMemoryTypeChatCompletion" && i.eventType === "Completed") {
136
+ const S = m.current.get(
137
+ a.agentTaskId
138
+ );
139
+ S && (m.current.delete(a.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, a), n(
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) !== a.agentTaskId)
146
+ return y;
144
147
  const f = y.progressItems.some(
145
- (k) => k.progressItemId === a.progressItemId
148
+ (b) => b.progressItemId === a.progressItemId
146
149
  ) ? y.progressItems.map(
147
- (k) => k.progressItemId === a.progressItemId ? a : k
150
+ (b) => b.progressItemId === a.progressItemId ? a : b
148
151
  ) : [...y.progressItems, a];
149
152
  return { ...y, progressItems: f };
150
153
  })
151
154
  );
152
155
  },
153
156
  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),
157
+ var i;
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
+ return u ? [
161
+ ...g.filter((S) => S.streamId !== a.streamId),
159
162
  {
160
- ...m,
163
+ ...u,
161
164
  loading: !1,
162
165
  error: a.error
163
166
  }
164
- ] : u;
167
+ ] : g;
165
168
  });
166
169
  },
167
170
  onStreamNotFound: (a) => {
168
- var l;
169
- (l = e == null ? void 0 : e.onStreamNotFound) == null || l.call(e, a);
171
+ var i;
172
+ (i = e == null ? void 0 : e.onStreamNotFound) == null || i.call(e, a);
170
173
  },
171
174
  onStreamTimeout: (a) => {
172
- var l;
173
- (l = e == null ? void 0 : e.onStreamTimeout) == null || l.call(e, a);
175
+ var i;
176
+ (i = e == null ? void 0 : e.onStreamTimeout) == null || i.call(e, a);
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") {
179
- r([
180
- ...n,
178
+ }), l = W(
179
+ async (a, i) => {
180
+ const g = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, u = await s();
181
+ if (u.type === "success") {
182
+ n([
183
+ ...r,
181
184
  {
182
- taskKey: u,
183
- streamId: m.stream.id,
185
+ taskKey: g,
186
+ streamId: u.stream.id,
184
187
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
185
188
  confirmedData: null,
186
189
  error: null,
@@ -188,31 +191,38 @@ const te = (e) => {
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(a.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: a.type === "streamingChatCompletion" ? {
204
+ messages: a.messages,
205
+ model: a.model
206
+ } : void 0,
207
+ structuredChatCompletionTask: a.type === "structuredChatCompletion" ? {
208
+ messages: a.messages,
209
+ jsonSchema: a.jsonSchema,
210
+ model: a.model
211
+ } : void 0,
212
+ streamingMemoryTypeChatCompletionTask: a.type === "streamingMemoryTypeChatCompletion" ? {
213
+ messages: a.messages,
214
+ model: a.model
215
+ } : void 0
204
216
  }
205
217
  });
206
218
  if (y.type === "success" && y.agentTask) {
207
219
  o.current.add(
208
220
  y.agentTask.id
209
- ), r((f) => [
210
- ...f.filter(
211
- (h) => h.taskKey !== u
212
- ),
221
+ ), n((f) => [
222
+ ...f.filter((h) => h.taskKey !== g),
213
223
  {
214
- taskKey: u,
215
- streamId: m.stream.id,
224
+ taskKey: g,
225
+ streamId: u.stream.id,
216
226
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
217
227
  taskId: y.agentTask.id,
218
228
  createdAt: y.agentTask.createdAt,
@@ -221,43 +231,39 @@ const te = (e) => {
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
+ m.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 n((T) => [
256
+ ...T.filter((f) => f.taskKey !== g),
251
257
  {
252
- taskKey: u,
258
+ taskKey: g,
253
259
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
254
- streamId: m.stream.id,
260
+ streamId: u.stream.id,
255
261
  params: a,
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
- return r((f) => [
273
- ...f.filter(
274
- (h) => h.taskKey !== u
275
- ),
278
+ return n((f) => [
279
+ ...f.filter((h) => h.taskKey !== g),
276
280
  {
277
- taskKey: u,
281
+ taskKey: g,
278
282
  triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
279
- streamId: m.stream.id,
280
- error: S,
283
+ streamId: u.stream.id,
284
+ error: T,
281
285
  params: a,
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(() => {
299
- if (n.length !== 0)
300
- return [...n].sort((a, l) => new Date(l.triggeredAt).getTime() - new Date(a.triggeredAt).getTime())[0];
301
- }, [n]);
302
- return p(() => () => {
303
- o.current.clear(), g.current.clear();
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
+ return E(() => () => {
307
+ o.current.clear(), m.current.clear();
304
308
  }, []), {
305
- agentTasks: n,
306
- createAgentTask: s,
307
- latest: c
309
+ agentTasks: r,
310
+ createAgentTask: l,
311
+ latest: d
308
312
  };
309
313
  };
310
- async function se(e, t) {
311
- const n = e.getReader();
312
- let r;
313
- for (; !(r = await n.read()).done; )
314
- 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);
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);
320
+ function ie(e) {
321
+ let t, r, n, o = !1;
322
+ return function(s) {
323
+ t === void 0 ? (t = s, r = 0, n = -1) : t = ce(t, s);
324
+ const l = t.length;
325
+ let d = 0;
326
+ for (; r < l; ) {
327
+ o && (t[r] === 10 && (d = ++r), o = !1);
324
328
  let a = -1;
325
- for (; n < s && a === -1; ++n)
326
- switch (t[n]) {
329
+ for (; r < l && a === -1; ++r)
330
+ switch (t[r]) {
327
331
  case 58:
328
- r === -1 && (r = n - c);
332
+ n === -1 && (n = r - d);
329
333
  break;
330
334
  case 13:
331
335
  o = !0;
332
336
  case 10:
333
- a = n;
337
+ a = r;
334
338
  break;
335
339
  }
336
340
  if (a === -1)
337
341
  break;
338
- e(t.subarray(c, a), r), c = n, r = -1;
342
+ e(t.subarray(d, a), n), d = r, n = -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), r -= d);
341
345
  };
342
346
  }
343
- function le(e, t, n) {
344
- let r = $();
347
+ function se(e, t, r) {
348
+ let n = O();
345
349
  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) {
350
+ return function(s, l) {
351
+ if (s.length === 0)
352
+ r == null || r(n), n = O();
353
+ else if (l > 0) {
354
+ const d = o.decode(s.subarray(0, l)), a = l + (s[l + 1] === 32 ? 2 : 1), i = o.decode(s.subarray(a));
355
+ switch (d) {
352
356
  case "data":
353
- r.data = r.data ? r.data + `
354
- ` + l : l;
357
+ n.data = n.data ? n.data + `
358
+ ` + i : i;
355
359
  break;
356
360
  case "event":
357
- r.event = l;
361
+ n.event = i;
358
362
  break;
359
363
  case "id":
360
- e(r.id = l);
364
+ e(n.id = i);
361
365
  break;
362
366
  case "retry":
363
- const u = parseInt(l, 10);
364
- isNaN(u) || t(r.retry = u);
367
+ const g = parseInt(i, 10);
368
+ isNaN(g) || t(n.retry = g);
365
369
  break;
366
370
  }
367
371
  }
368
372
  };
369
373
  }
370
- function de(e, t) {
371
- const n = new Uint8Array(e.length + t.length);
372
- 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;
373
377
  }
374
- function $() {
378
+ function O() {
375
379
  return {
376
380
  data: "",
377
381
  event: "",
@@ -379,70 +383,70 @@ function $() {
379
383
  retry: void 0
380
384
  };
381
385
  }
382
- var ue = function(e, t) {
383
- var n = {};
384
- 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]);
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]]);
388
- 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;
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", de = 1e3, D = "last-event-id";
395
+ function j(e, t) {
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
+ 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 || p();
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 = de, h = 0;
406
+ function b() {
407
+ document.removeEventListener("visibilitychange", T), window.clearTimeout(h), y.abort();
404
408
  }
405
- n == null || n.addEventListener("abort", () => {
406
- k(), u();
409
+ r == null || r.addEventListener("abort", () => {
410
+ b(), g();
407
411
  });
408
- const A = a ?? window.fetch, w = o ?? ge;
409
- async function I() {
410
- var R;
412
+ const I = a ?? window.fetch, w = o ?? ue;
413
+ async function p() {
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 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();
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 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);
426
430
  }
427
431
  }
428
432
  }
429
- I();
433
+ p();
430
434
  });
431
435
  }
432
- function ge(e) {
436
+ function ue(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 De(e) {
442
+ const [t, r] = C(null);
443
+ return E(() => {
440
444
  if (!t)
441
445
  return;
442
- const r = new AbortController();
443
- return K(t, {
446
+ const n = new AbortController();
447
+ return j(t, {
444
448
  headers: e == null ? void 0 : e.headers,
445
- signal: r.signal,
449
+ signal: n.signal,
446
450
  async onopen(o) {
447
451
  if (!o.ok && o.status >= 400 && o.status < 500 && o.status !== 429)
448
452
  throw new Error(`Client error ${o.status}`);
@@ -450,47 +454,47 @@ function _e(e) {
450
454
  onmessage(o) {
451
455
  o.data && (e == null || e.onMessage({
452
456
  url: t,
453
- data: q(o.data)
457
+ data: H(o.data)
454
458
  }));
455
459
  },
456
460
  onerror(o) {
457
- throw console.error("EventSource error:", o), e == null || e.onError(t), n(null), o;
461
+ throw console.error("EventSource error:", o), e == null || e.onError(t), r(null), o;
458
462
  },
459
463
  onclose() {
460
464
  }
461
465
  }), () => {
462
- r.abort();
466
+ n.abort();
463
467
  };
464
468
  }, [t, e == null ? void 0 : e.headers]), {
465
- setSourceUrl: n,
469
+ setSourceUrl: r,
466
470
  sourceUrl: t
467
471
  };
468
472
  }
469
- function q(e) {
470
- const t = atob(e), n = new Uint8Array(t.length);
471
- for (let r = 0; r < t.length; r++)
472
- n[r] = t.charCodeAt(r);
473
- return new TextDecoder("utf-8").decode(n);
473
+ function H(e) {
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);
474
478
  }
475
- function je(e, t) {
476
- const [n, r] = C(
479
+ function Ue(e, t) {
480
+ const [r, n] = C(
477
481
  null
478
- ), [o, g] = C(
482
+ ), [o, m] = C(
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 (g) => {
485
+ const u = await g.fetchTokens(), { fetchTokens: S, nextPageToken: y, previousPageToken: T, ...f } = g, 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,15 +513,15 @@ 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 (g) => {
517
+ const u = await l({
518
+ ...g,
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" && (m(u.page), n(g)), u;
519
523
  },
520
- fetchNextPage: async (u) => {
524
+ fetchNextPage: async (g) => {
521
525
  if (o == null)
522
526
  return {
523
527
  type: "error",
@@ -534,14 +538,14 @@ function je(e, t) {
534
538
  message: "No next page"
535
539
  }
536
540
  };
537
- const m = await s({
538
- ...u,
541
+ const u = await l({
542
+ ...g,
539
543
  nextPageToken: o.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" && (m(u.page), n(g)), u;
543
547
  },
544
- fetchPreviousPage: async (u) => {
548
+ fetchPreviousPage: async (g) => {
545
549
  if (o == null)
546
550
  return {
547
551
  type: "error",
@@ -558,60 +562,60 @@ 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
+ ...g,
563
567
  nextPageToken: void 0,
564
568
  previousPageToken: o.pagination.previousPageToken
565
569
  });
566
- return m.type === "success" && (g(m.page), r(u)), m;
570
+ return u.type === "success" && (m(u.page), n(g)), u;
567
571
  },
568
- refetchCurrentPage: async () => n == null ? {
572
+ refetchCurrentPage: async () => r == null ? {
569
573
  type: "error",
570
574
  error: {
571
575
  code: "NO_CURRENT_PAGE",
572
576
  message: "No current page, please call fetchFirstPage first."
573
577
  }
574
- } : s(n),
578
+ } : l(r),
575
579
  currentPage: o
576
580
  };
577
581
  }
578
- function ye(e) {
579
- return e.progressItems.map((t, n) => {
580
- const r = e.progressItems[n + 1], o = r != null;
581
- let g;
582
- 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);
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);
585
589
  }
586
590
  return {
587
591
  item: t,
588
592
  completed: o,
589
- isLatest: n === e.progressItems.length - 1,
590
- durationSeconds: g
593
+ isLatest: r === e.progressItems.length - 1,
594
+ durationSeconds: m
591
595
  };
592
596
  });
593
597
  }
594
- function M({
598
+ function R({
595
599
  text: e,
596
600
  duration: t = 2,
597
- delay: n = 0,
598
- repeat: r = !0,
601
+ delay: r = 0,
602
+ repeat: n = !0,
599
603
  repeatDelay: o = 0.5,
600
- className: g,
601
- startOnView: d = !1,
602
- once: s = !1,
603
- inViewMargin: c,
604
+ className: m,
605
+ startOnView: s = !1,
606
+ once: l = !1,
607
+ inViewMargin: d,
604
608
  spread: a = 2,
605
- color: l = "#999",
606
- shimmerColor: u = "#000",
607
- direction: m = "fromBottom"
609
+ color: i = "#999",
610
+ shimmerColor: g = "#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 = 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
+ return /* @__PURE__ */ c(
611
615
  v.span,
612
616
  {
613
- ref: T,
614
- className: g,
617
+ ref: S,
618
+ className: m,
615
619
  style: {
616
620
  position: "relative",
617
621
  display: "inline-block",
@@ -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": g,
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,38 +636,28 @@ 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: {
639
643
  backgroundPosition: {
640
- repeat: r ? 1 / 0 : 0,
644
+ repeat: n ? 1 / 0 : 0,
641
645
  duration: t,
642
- delay: n,
646
+ delay: r,
643
647
  repeatDelay: o,
644
648
  ease: "linear"
645
649
  },
646
650
  opacity: {
647
651
  duration: 0.3,
648
- delay: n
652
+ delay: r
649
653
  }
650
654
  },
651
655
  children: e
652
656
  }
653
657
  );
654
658
  }
655
- function fe(e) {
659
+ function ge(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,28 +687,28 @@ function fe(e) {
693
687
  }
694
688
  return "Processing...";
695
689
  }
696
- const he = ({ progressViewItems: e }) => {
690
+ const ye = ({ 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 r = ge(t);
694
+ return /* @__PURE__ */ c("div", { className: "simple-mode-container", children: /* @__PURE__ */ c(L, { 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
- children: n
706
+ children: r
713
707
  }
714
- ) : /* @__PURE__ */ i(
715
- M,
708
+ ) : /* @__PURE__ */ c(
709
+ R,
716
710
  {
717
- text: n,
711
+ text: r,
718
712
  className: "simple-mode-title",
719
713
  duration: 2.5,
720
714
  repeat: !0,
@@ -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
+ Q,
1111
884
  {
1112
- remarkPlugins: [L],
885
+ remarkPlugins: [Y],
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: r, className: n, node: o, ref: m, ...s } = t, l = /language-(\w+)/.exec(n || "");
889
+ return l ? /* @__PURE__ */ c(
890
+ $,
1118
891
  {
1119
- ...d,
892
+ ...s,
1120
893
  PreTag: "div",
1121
- children: String(n).replace(/\n$/, ""),
1122
- language: s[1],
1123
- style: D
894
+ children: String(r).replace(/\n$/, ""),
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: n, children: String(r) });
1126
899
  }
1127
900
  },
1128
901
  children: e
1129
902
  }
1130
903
  )
1131
904
  }
1132
- ) }), be = ({ data: e }) => {
905
+ ) }), fe = ({ 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($, { language: "json", style: K, PreTag: "div", children: t })
1141
914
  }
1142
915
  ) });
1143
- }, ve = ({ data: e, isLatest: t = !1, durationSeconds: n }) => {
1144
- const r = `Searching: ${e.queryDescription}`;
1145
- return /* @__PURE__ */ b("div", { style: { padding: "16px" }, children: [
1146
- /* @__PURE__ */ i(
916
+ }, he = ({ data: e, isLatest: t = !1, durationSeconds: r }) => {
917
+ const n = `Searching: ${e.queryDescription}`;
918
+ return /* @__PURE__ */ x("div", { style: { padding: "16px" }, children: [
919
+ /* @__PURE__ */ c(
1147
920
  v.div,
1148
921
  {
1149
922
  style: {
@@ -1155,19 +928,19 @@ 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 && !r ? /* @__PURE__ */ c(
932
+ R,
1160
933
  {
1161
- text: r,
934
+ text: n,
1162
935
  duration: 2.5,
1163
936
  repeat: !0,
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: n })
1168
941
  }
1169
942
  ),
1170
- n !== void 0 && /* @__PURE__ */ b(
943
+ r !== void 0 && /* @__PURE__ */ x(
1171
944
  "div",
1172
945
  {
1173
946
  style: {
@@ -1178,16 +951,16 @@ const he = ({ progressViewItems: e }) => {
1178
951
  },
1179
952
  children: [
1180
953
  "Took ",
1181
- n,
954
+ r,
1182
955
  " seconds"
1183
956
  ]
1184
957
  }
1185
958
  )
1186
959
  ] });
1187
- }, Ce = ({ isLatest: e = !1, durationSeconds: t }) => {
1188
- const n = "Adding sources...";
1189
- return /* @__PURE__ */ b("div", { style: { padding: "16px" }, children: [
1190
- /* @__PURE__ */ i(
960
+ }, Se = ({ isLatest: e = !1, durationSeconds: t }) => {
961
+ const r = "Adding sources...";
962
+ return /* @__PURE__ */ x("div", { style: { padding: "16px" }, children: [
963
+ /* @__PURE__ */ c(
1191
964
  v.div,
1192
965
  {
1193
966
  style: {
@@ -1199,19 +972,19 @@ 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
- text: n,
978
+ text: r,
1206
979
  duration: 2.5,
1207
980
  repeat: !0,
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: r })
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,120 +1001,122 @@ 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
+ }, Te = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ x("div", { style: { padding: "16px" }, children: [
1005
+ /* @__PURE__ */ c(
1233
1006
  v.div,
1234
1007
  {
1235
- 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
+ },
1236
1016
  initial: { opacity: 0, y: -10 },
1237
1017
  animate: { opacity: 1, y: 0 },
1238
1018
  transition: { duration: 0.3, delay: 0 },
1239
1019
  children: "Sources"
1240
1020
  }
1241
1021
  ),
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,
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(
1023
+ Ce,
1244
1024
  {
1245
- source: n,
1246
- index: r,
1025
+ source: r,
1026
+ index: n,
1247
1027
  onSourceClick: t
1248
1028
  },
1249
- n.memoryId
1029
+ r.memoryId
1250
1030
  )) })
1251
1031
  ] });
1252
- function pe(e, t) {
1253
- if (t.length === 0) return e;
1254
- if (t.length === 1) return `${e} page ${t[0]}`;
1255
- if (t.length === 2)
1256
- return `${e} pages ${t[0]} and ${t[1]}`;
1257
- const n = t[t.length - 1], r = t.slice(0, -1).join(", ");
1258
- return `${e} pages ${r} and ${n}`;
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}`;
1259
1039
  }
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(
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(
1263
1043
  v.div,
1264
1044
  {
1265
1045
  initial: { opacity: 0, scale: 0.9 },
1266
1046
  animate: { opacity: 1, scale: 1 },
1267
1047
  transition: { duration: 0.25, delay: t * 0.05 },
1268
- onClick: g ? () => n(e.memoryId) : void 0,
1269
- onMouseEnter: g ? () => o(!0) : void 0,
1270
- onMouseLeave: g ? () => o(!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,
1271
1051
  style: {
1272
1052
  display: "inline-flex",
1273
1053
  flexDirection: "column",
1274
1054
  gap: "4px",
1275
1055
  padding: "8px 12px",
1276
- borderRadius: "8px",
1056
+ borderRadius: "6px",
1277
1057
  border: "1px solid #e0e0e0",
1278
- backgroundColor: r ? "#f0f0f0" : "#f9f9f9",
1279
- cursor: g ? "pointer" : "default",
1058
+ backgroundColor: n ? "#f5f5f5" : "transparent",
1059
+ cursor: m ? "pointer" : "default",
1280
1060
  transition: "background-color 0.15s ease",
1281
1061
  userSelect: "none"
1282
1062
  },
1283
- children: /* @__PURE__ */ i("span", { style: { fontSize: "13px", fontWeight: 500, color: "#333" }, children: d })
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
+ ]
1284
1067
  }
1285
1068
  );
1286
- }, Ee = `
1287
- @keyframes explore-memory-spinner {
1288
- 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;
1289
1075
  }
1290
- `;
1291
- function Ae() {
1292
- return /* @__PURE__ */ b(Z, { children: [
1293
- /* @__PURE__ */ i("style", { children: Ee }),
1294
- /* @__PURE__ */ i(
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(
1295
1081
  "div",
1296
1082
  {
1297
1083
  style: {
1298
- width: 12,
1299
- height: 12,
1300
- border: "2px solid #e0e0e0",
1301
- borderTopColor: "#666",
1302
- borderRadius: "50%",
1303
- animation: "explore-memory-spinner 0.8s linear infinite"
1304
- }
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 })
1305
1098
  }
1306
- )
1307
- ] });
1308
- }
1309
- function Ie({
1310
- eventType: e,
1311
- completed: t
1312
- }) {
1313
- return e === "ExploreMemoryError" ? /* @__PURE__ */ i("span", { style: { color: "#c62828", fontSize: 14, fontWeight: 600 }, children: "✗" }) : e === "ExploreMemoryResult" ? /* @__PURE__ */ i("span", { style: { color: "#2e7d32", fontSize: 14, fontWeight: 600 }, children: "✓" }) : e === "ExploreMemoryStart" ? t ? /* @__PURE__ */ i("span", { style: { color: "#2e7d32", fontSize: 14, fontWeight: 600 }, children: "✓" }) : /* @__PURE__ */ i(Ae, {}) : null;
1314
- }
1315
- const _ = 80, Pe = ({ data: e, completed: t }) => {
1316
- const [n, r] = C(!1), o = e.eventType === "ExploreMemoryResult" ? e.result : void 0, g = o != null && o.length > _, d = o != null ? n || !g ? o : `${o.slice(0, _)}...` : void 0, s = g;
1317
- return /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ b(
1099
+ );
1100
+ }
1101
+ return /* @__PURE__ */ c("div", { style: { padding: "16px" }, children: /* @__PURE__ */ x(
1318
1102
  v.div,
1319
1103
  {
1320
- initial: { opacity: 0, scale: 0.9 },
1321
- animate: { opacity: 1, scale: 1 },
1322
- transition: { duration: 0.25, delay: 0 },
1323
- onClick: s ? () => r((c) => !c) : void 0,
1104
+ initial: { opacity: 0 },
1105
+ animate: { opacity: 1 },
1106
+ transition: { duration: 0.25 },
1107
+ onClick: d ? () => o((i) => !i) : void 0,
1324
1108
  style: {
1325
- display: "inline-flex",
1109
+ paddingBottom: "12px",
1110
+ borderBottom: "1px solid #eee",
1111
+ display: "flex",
1326
1112
  flexDirection: "row",
1327
1113
  alignItems: "flex-start",
1328
1114
  gap: "10px",
1329
- padding: "8px 12px",
1330
- borderRadius: "8px",
1331
- border: "1px solid #e0e0e0",
1332
- backgroundColor: "#f9f9f9",
1333
1115
  minWidth: 0,
1334
- cursor: s ? "pointer" : "default",
1335
- transition: "background-color 0.15s ease"
1116
+ cursor: d ? "pointer" : "default"
1336
1117
  },
1337
- onMouseEnter: s ? (c) => {
1338
- c.currentTarget.style.backgroundColor = "#f0f0f0";
1339
- } : void 0,
1340
- onMouseLeave: s ? (c) => {
1341
- c.currentTarget.style.backgroundColor = "#f9f9f9";
1342
- } : void 0,
1343
1118
  children: [
1344
- /* @__PURE__ */ i(
1119
+ /* @__PURE__ */ c(
1345
1120
  "div",
1346
1121
  {
1347
1122
  style: {
@@ -1351,10 +1126,10 @@ const _ = 80, Pe = ({ data: e, completed: t }) => {
1351
1126
  flexShrink: 0,
1352
1127
  width: 20
1353
1128
  },
1354
- children: /* @__PURE__ */ i(Ie, { eventType: e.eventType, completed: t })
1129
+ children: /* @__PURE__ */ c(ke, { eventType: e.eventType, completed: t })
1355
1130
  }
1356
1131
  ),
1357
- /* @__PURE__ */ b(
1132
+ /* @__PURE__ */ x(
1358
1133
  "div",
1359
1134
  {
1360
1135
  style: {
@@ -1364,8 +1139,8 @@ const _ = 80, Pe = ({ data: e, completed: t }) => {
1364
1139
  minWidth: 0
1365
1140
  },
1366
1141
  children: [
1367
- /* @__PURE__ */ i("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1368
- d != null && /* @__PURE__ */ i(
1142
+ /* @__PURE__ */ c("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
1143
+ l != null && /* @__PURE__ */ c(
1369
1144
  "span",
1370
1145
  {
1371
1146
  style: {
@@ -1374,10 +1149,10 @@ const _ = 80, Pe = ({ data: e, completed: t }) => {
1374
1149
  lineHeight: 1.4,
1375
1150
  whiteSpace: n ? "pre-wrap" : void 0
1376
1151
  },
1377
- children: d
1152
+ children: l
1378
1153
  }
1379
1154
  ),
1380
- s && /* @__PURE__ */ i(
1155
+ d && /* @__PURE__ */ c(
1381
1156
  "span",
1382
1157
  {
1383
1158
  style: {
@@ -1394,143 +1169,114 @@ const _ = 80, Pe = ({ data: e, completed: t }) => {
1394
1169
  ]
1395
1170
  }
1396
1171
  ) });
1397
- }, Me = ({ progressViewItems: e, streamToken: t, fetchClientToken: n, loadingText: r, onSourceClick: o }) => {
1398
- const g = E(null);
1399
- p(() => {
1400
- g.current && (g.current.scrollTop = g.current.scrollHeight);
1172
+ }, xe = ({
1173
+ progressViewItems: e,
1174
+ streamToken: t,
1175
+ fetchClientToken: r,
1176
+ loadingText: n,
1177
+ onSourceClick: o
1178
+ }) => {
1179
+ const m = A(null);
1180
+ E(() => {
1181
+ m.current && (m.current.scrollTop = m.current.scrollHeight);
1401
1182
  }, [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) {
1183
+ const s = (l) => {
1184
+ const d = l.item.data;
1185
+ if (d.taskType === "StreamingChatCompletion" && d.eventType === "Text")
1186
+ return /* @__PURE__ */ c(U, { text: d.text });
1187
+ if (d.taskType === "StructuredChatCompletion" && d.eventType === "Json")
1188
+ return /* @__PURE__ */ c(fe, { data: d });
1189
+ if (d.taskType === "StreamingMemoryTypeChatCompletion")
1190
+ switch (d.eventType) {
1445
1191
  case "Text":
1446
- return /* @__PURE__ */ i(B, { text: c.text });
1192
+ return /* @__PURE__ */ c(U, { text: d.text });
1447
1193
  case "Search":
1448
- return /* @__PURE__ */ i(
1449
- ve,
1194
+ return /* @__PURE__ */ c(
1195
+ he,
1450
1196
  {
1451
- data: c,
1452
- isLatest: s.isLatest,
1453
- durationSeconds: s.durationSeconds
1197
+ data: d,
1198
+ isLatest: l.isLatest,
1199
+ durationSeconds: l.durationSeconds
1454
1200
  }
1455
1201
  );
1456
1202
  case "FindSources":
1457
- return /* @__PURE__ */ i(
1458
- Ce,
1203
+ return /* @__PURE__ */ c(
1204
+ Se,
1459
1205
  {
1460
- data: c,
1461
- isLatest: s.isLatest,
1462
- durationSeconds: s.durationSeconds
1206
+ data: d,
1207
+ isLatest: l.isLatest,
1208
+ durationSeconds: l.durationSeconds
1463
1209
  }
1464
1210
  );
1465
1211
  case "SourcesResult":
1466
- return /* @__PURE__ */ i(
1467
- xe,
1212
+ return /* @__PURE__ */ c(
1213
+ Te,
1468
1214
  {
1469
- data: c,
1215
+ data: d,
1470
1216
  onSourceClick: o
1471
1217
  }
1472
1218
  );
1473
1219
  case "ExploreMemoryStart":
1474
1220
  case "ExploreMemoryResult":
1475
1221
  case "ExploreMemoryError":
1476
- return /* @__PURE__ */ i(
1477
- Pe,
1222
+ return /* @__PURE__ */ c(
1223
+ ve,
1478
1224
  {
1479
- data: c,
1480
- completed: s.completed,
1481
- isLatest: s.isLatest
1225
+ data: d,
1226
+ completed: l.completed,
1227
+ isLatest: l.isLatest
1482
1228
  }
1483
1229
  );
1484
1230
  case "Completed":
1485
1231
  return null;
1486
1232
  }
1487
- return c.taskType === "StreamingChatCompletion" && c.eventType === "Completed" || c.taskType === "StructuredChatCompletion" && c.eventType === "Completed", null;
1233
+ return d.taskType === "StreamingChatCompletion" && d.eventType === "Completed" || d.taskType === "StructuredChatCompletion" && d.eventType === "Completed", null;
1488
1234
  };
1489
- return e.length === 0 ? /* @__PURE__ */ i("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ i(
1490
- M,
1235
+ return e.length === 0 ? /* @__PURE__ */ c("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ c(
1236
+ R,
1491
1237
  {
1492
- text: r ?? "Processing your task...",
1238
+ text: n ?? "Processing your task...",
1493
1239
  duration: 1.5,
1494
1240
  repeat: !0,
1495
1241
  repeatDelay: 0,
1496
1242
  color: "#999",
1497
1243
  shimmerColor: "#000"
1498
1244
  }
1499
- ) }) : /* @__PURE__ */ i("div", { id: "agent-task-progress-verbose", ref: g, children: /* @__PURE__ */ i(H, { children: e.map((s, c) => /* @__PURE__ */ i(
1245
+ ) }) : /* @__PURE__ */ c("div", { id: "agent-task-progress-verbose", ref: m, children: /* @__PURE__ */ c(L, { children: e.map((l, d) => /* @__PURE__ */ c(
1500
1246
  v.div,
1501
1247
  {
1502
- id: `agent-task-progress-item-${s.item.progressItemId}`,
1248
+ id: `agent-task-progress-item-${l.item.progressItemId}`,
1503
1249
  initial: { opacity: 0, y: -20 },
1504
1250
  animate: { opacity: 1, y: 0 },
1505
1251
  transition: {
1506
1252
  duration: 0.4,
1507
- delay: c * 0.1,
1253
+ delay: d * 0.1,
1508
1254
  ease: "easeOut"
1509
1255
  },
1510
- children: d(s)
1256
+ children: s(l)
1511
1257
  },
1512
- s.item.progressItemId
1258
+ l.item.progressItemId
1513
1259
  )) }) });
1514
- }, He = ({
1260
+ }, ze = ({
1515
1261
  agentTask: e,
1516
1262
  mode: t = "verbose",
1517
- streamToken: n,
1518
- fetchClientToken: r,
1263
+ streamToken: r,
1264
+ fetchClientToken: n,
1519
1265
  onSourceClick: o
1520
1266
  }) => {
1521
- const g = ye(e);
1522
- return t === "simple" ? /* @__PURE__ */ i(he, { progressViewItems: g }) : /* @__PURE__ */ i(
1523
- Me,
1267
+ const m = me(e);
1268
+ return t === "simple" ? /* @__PURE__ */ c(ye, { progressViewItems: m }) : /* @__PURE__ */ c(
1269
+ xe,
1524
1270
  {
1525
- progressViewItems: g,
1526
- streamToken: n,
1527
- fetchClientToken: r,
1271
+ progressViewItems: m,
1272
+ streamToken: r,
1273
+ fetchClientToken: n,
1528
1274
  loadingText: e.loadingText,
1529
1275
  onSourceClick: o
1530
1276
  }
1531
1277
  );
1532
1278
  };
1533
- class Re {
1279
+ class we {
1534
1280
  constructor(t) {
1535
1281
  this.eventSources = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Map(), this.fency = t;
1536
1282
  }
@@ -1539,37 +1285,37 @@ class Re {
1539
1285
  * Creates new connections and removes old ones.
1540
1286
  */
1541
1287
  updateStreams(t) {
1542
- t.forEach((r) => {
1543
- const o = r.stream.id;
1544
- this.eventSources.has(o) || this.connectStream(r);
1288
+ t.forEach((n) => {
1289
+ const o = n.stream.id;
1290
+ this.eventSources.has(o) || this.connectStream(n);
1545
1291
  });
1546
- 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));
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));
1549
1295
  });
1550
1296
  }
1551
1297
  connectStream(t) {
1552
- const n = t.stream.id, r = new AbortController();
1553
- this.eventSources.set(n, r);
1554
- const o = `${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 = {
1555
1301
  "X-Fency-Publishable-Key": this.fency.publishableKey,
1556
1302
  "X-Fency-Stream-Token": t.stream.token
1557
1303
  };
1558
- K(o, {
1559
- headers: g,
1560
- 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}`);
1304
+ j(o, {
1305
+ headers: m,
1306
+ signal: n.signal,
1307
+ async onopen(s) {
1308
+ if (!s.ok && s.status >= 400 && s.status < 500 && s.status !== 429)
1309
+ throw new Error(`Client error ${s.status}`);
1564
1310
  },
1565
- onmessage: (d) => {
1566
- if (d.data) {
1567
- const s = q(d.data);
1568
- this.broadcast(s, n);
1311
+ onmessage: (s) => {
1312
+ if (s.data) {
1313
+ const l = H(s.data);
1314
+ this.broadcast(l, r);
1569
1315
  }
1570
1316
  },
1571
- onerror: (d) => {
1572
- throw console.error("EventSource error for stream", n, ":", d), this.broadcastError(n), d;
1317
+ onerror: (s) => {
1318
+ throw console.error("EventSource error for stream", r, ":", s), this.broadcastError(r), s;
1573
1319
  },
1574
1320
  onclose() {
1575
1321
  }
@@ -1579,19 +1325,19 @@ class Re {
1579
1325
  * Subscribe to events from all active streams.
1580
1326
  * Returns an unsubscribe function.
1581
1327
  */
1582
- subscribe(t, n) {
1583
- return this.subscribers.set(t, n), () => {
1328
+ subscribe(t, r) {
1329
+ return this.subscribers.set(t, r), () => {
1584
1330
  this.subscribers.delete(t);
1585
1331
  };
1586
1332
  }
1587
- broadcast(t, n) {
1588
- this.subscribers.forEach((r) => {
1589
- r.onMessage(t, n);
1333
+ broadcast(t, r) {
1334
+ this.subscribers.forEach((n) => {
1335
+ n.onMessage(t, r);
1590
1336
  });
1591
1337
  }
1592
1338
  broadcastError(t) {
1593
- this.subscribers.forEach((n) => {
1594
- n.onError(t);
1339
+ this.subscribers.forEach((r) => {
1340
+ r.onError(t);
1595
1341
  });
1596
1342
  }
1597
1343
  /**
@@ -1601,95 +1347,92 @@ class Re {
1601
1347
  this.eventSources.forEach((t) => t.abort()), this.eventSources.clear(), this.subscribers.clear();
1602
1348
  }
1603
1349
  }
1604
- const Fe = 12e4, Ne = (e) => {
1350
+ const Ee = 12e4, Ie = (e) => {
1605
1351
  const t = Date.now();
1606
- return e.filter((n) => t - n.createdAt < Fe);
1352
+ return e.filter((r) => t - r.createdAt < Ee);
1607
1353
  };
1608
- function Ge({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
1609
- const [r, o] = C(
1354
+ function We({ fency: e, fetchCreateStreamClientToken: t, children: r }) {
1355
+ const [n, o] = C(
1610
1356
  null
1611
- ), [g, d] = C(!0), [s, c] = C(null), [a, l] = C([]), u = E(null), m = E(null);
1612
- p(() => {
1357
+ ), [m, s] = C(!0), [l, d] = C(null), [a, i] = C([]), g = A(null), u = A(null);
1358
+ E(() => {
1613
1359
  e.then((f) => {
1614
- o(f), d(!1);
1360
+ o(f), s(!1);
1615
1361
  }).catch((f) => {
1616
- c(f), d(!1);
1362
+ d(f), s(!1);
1617
1363
  });
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(() => () => {
1364
+ }, [e]), E(() => {
1365
+ n && !u.current && (u.current = new we(n));
1366
+ }, [n]), E(() => {
1367
+ u.current && u.current.updateStreams(a);
1368
+ }, [a]), E(() => () => {
1623
1369
  var f;
1624
- (f = m.current) == null || f.cleanup();
1370
+ (f = u.current) == null || f.cleanup();
1625
1371
  }, []);
1626
- const T = U(
1372
+ const S = W(
1627
1373
  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 () => {
1634
- if (!r)
1374
+ if (g.current)
1375
+ return g.current;
1376
+ const h = Date.now(), b = a.length > 0 ? a[a.length - 1] : null;
1377
+ if (b && h - b.createdAt < f)
1378
+ return b.stream;
1379
+ const I = (async () => {
1380
+ if (!n)
1635
1381
  throw new Error("Fency instance not initialized");
1636
- const w = await t(), I = await X({
1637
- pk: r.publishableKey,
1638
- baseUrl: r.baseUrl,
1382
+ const w = await t(), p = await J({
1383
+ pk: n.publishableKey,
1384
+ baseUrl: n.baseUrl,
1639
1385
  clientToken: (w == null ? void 0 : w.clientToken) ?? ""
1640
1386
  });
1641
- if (I.type === "success") {
1642
- const R = {
1643
- stream: I.stream,
1387
+ if (p.type === "success") {
1388
+ const M = {
1389
+ stream: p.stream,
1644
1390
  createdAt: Date.now()
1645
1391
  };
1646
- return l((P) => {
1647
- const x = [...P, R];
1648
- return Ne(x);
1649
- }), u.current = null, I.stream;
1392
+ return i((P) => {
1393
+ const k = [...P, M];
1394
+ return Ie(k);
1395
+ }), g.current = null, p.stream;
1650
1396
  } else
1651
- throw u.current = null, new Error("Failed to create stream");
1397
+ throw g.current = null, new Error("Failed to create stream");
1652
1398
  })();
1653
- return u.current = A, A;
1399
+ return g.current = I, I;
1654
1400
  },
1655
- [r, a]
1401
+ [n, a]
1656
1402
  );
1657
- if (s)
1658
- return /* @__PURE__ */ b("div", { children: [
1403
+ if (l)
1404
+ return /* @__PURE__ */ x("div", { children: [
1659
1405
  "Fency error: ",
1660
- s.message
1406
+ l.message
1661
1407
  ] });
1662
- if (!r)
1408
+ if (!n)
1663
1409
  return null;
1664
- const y = a.length > 0 ? a[a.length - 1] : null, S = {
1665
- fency: r,
1666
- loading: g,
1667
- error: s,
1410
+ const y = a.length > 0 ? a[a.length - 1] : null, T = {
1411
+ fency: n,
1412
+ loading: m,
1413
+ error: l,
1668
1414
  activeStreams: a,
1669
1415
  latestStream: y,
1670
- eventManager: m.current,
1671
- getOrCreateStream: T
1416
+ eventManager: u.current,
1417
+ getOrCreateStream: S
1672
1418
  };
1673
- return /* @__PURE__ */ i(G.Provider, { value: S, children: n });
1419
+ return /* @__PURE__ */ c(_.Provider, { value: T, children: r });
1674
1420
  }
1675
1421
  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,
1422
+ ze as AgentTaskProgress,
1423
+ ye as AgentTaskProgressSimple,
1424
+ xe as AgentTaskProgressVerbose,
1425
+ We as FencyProvider,
1426
+ R as ShimmeringText,
1427
+ U as StreamingChatCompletionText,
1428
+ ve as StreamingMemoryTypeChatCompletionExploreMemory,
1429
+ Se as StreamingMemoryTypeChatCompletionFindSources,
1430
+ he as StreamingMemoryTypeChatCompletionSearch,
1431
+ Te as StreamingMemoryTypeChatCompletionSourcesResult,
1432
+ fe as StructuredChatCompletionJson,
1433
+ Oe as useAgentTasks,
1691
1434
  N as useFencyContext,
1692
- _e as useFencyEventSource,
1693
- je as usePaginatedQuery,
1694
- ie as useStream
1435
+ De as useFencyEventSource,
1436
+ Ue as usePaginatedQuery,
1437
+ ae as useStream
1695
1438
  };