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