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