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