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