@fencyai/react 0.1.120 → 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/index.d.ts +0 -3
- package/dist/index.js +464 -723
- package/dist/types/CreateAgentTaskParams.d.ts +0 -4
- package/dist/types/CreateAgentTaskResponse.d.ts +0 -3
- package/dist/types/UseAgentTasksProps.d.ts +1 -1
- package/package.json +4 -4
- package/dist/agent-task/data-types/GenericAgentTaskExecution.d.ts +0 -12
- package/dist/agent-task/data-types/GenericAgentTaskFinalResponse.d.ts +0 -14
- package/dist/agent-task/data-types/GenericAgentTaskReasoning.d.ts +0 -11
package/dist/index.js
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
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
|
|
29
|
+
return ne(e);
|
|
30
30
|
case "StreamNotFound":
|
|
31
|
-
return
|
|
31
|
+
return re(e);
|
|
32
32
|
case "AgentTaskProgressItemUpdated":
|
|
33
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
|
|
@@ -49,52 +49,52 @@ const te = (e) => {
|
|
|
49
49
|
timestamp: e.timestamp,
|
|
50
50
|
createdAt: e.createdAt,
|
|
51
51
|
data: JSON.parse(e.data)
|
|
52
|
-
}),
|
|
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
|
-
(
|
|
66
|
+
(u = e == null ? void 0 : e.onChatCompletionStreamCompleted) == null || u.call(e, i);
|
|
67
67
|
break;
|
|
68
68
|
case "StreamTimeout":
|
|
69
|
-
(
|
|
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
|
-
(w = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || w.call(e,
|
|
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 te = (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: (
|
|
132
|
-
var
|
|
133
|
-
if (!
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
const
|
|
137
|
-
|
|
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
|
+
var u;
|
|
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
|
-
(
|
|
141
|
-
(
|
|
142
|
+
(u = e.onAgentTaskProgressItemUpdated) == null || u.call(e, o), r(
|
|
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
|
|
157
|
-
return
|
|
158
|
-
...
|
|
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);
|
|
160
|
+
return u ? [
|
|
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
|
-
if (
|
|
178
|
+
}), l = W(
|
|
179
|
+
async (o, i) => {
|
|
180
|
+
const m = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, u = await s();
|
|
181
|
+
if (u.type === "success") {
|
|
179
182
|
r([
|
|
180
183
|
...n,
|
|
181
184
|
{
|
|
182
|
-
taskKey:
|
|
183
|
-
streamId:
|
|
185
|
+
taskKey: m,
|
|
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:
|
|
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
|
-
clientToken:
|
|
198
|
-
streamToken:
|
|
200
|
+
clientToken: S,
|
|
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 !== u
|
|
212
|
-
),
|
|
222
|
+
...f.filter((h) => h.taskKey !== m),
|
|
213
223
|
{
|
|
214
|
-
taskKey:
|
|
215
|
-
streamId:
|
|
224
|
+
taskKey: m,
|
|
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
|
-
streamId:
|
|
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 !== u
|
|
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
|
-
streamId:
|
|
255
|
-
params:
|
|
260
|
+
streamId: u.stream.id,
|
|
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 te = (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 !== u
|
|
275
|
-
),
|
|
279
|
+
...f.filter((h) => h.taskKey !== m),
|
|
276
280
|
{
|
|
277
|
-
taskKey:
|
|
281
|
+
taskKey: m,
|
|
278
282
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
279
|
-
streamId:
|
|
280
|
-
error:
|
|
281
|
-
params:
|
|
283
|
+
streamId: u.stream.id,
|
|
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
|
-
return console.error(
|
|
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 $() {
|
|
|
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
|
|
395
|
-
|
|
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) => {
|
|
398
|
+
const S = Object.assign({}, r);
|
|
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 P = await
|
|
414
|
-
await w(P), await
|
|
415
|
-
|
|
416
|
-
}, (
|
|
417
|
-
f =
|
|
418
|
-
}, g))),
|
|
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();
|
|
419
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,31 +470,31 @@ function _e(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
|
-
function
|
|
476
|
-
const [n, r] =
|
|
479
|
+
function $e(e, t) {
|
|
480
|
+
const [n, r] = k(
|
|
477
481
|
null
|
|
478
|
-
), [
|
|
482
|
+
), [a, g] = k(
|
|
479
483
|
null
|
|
480
|
-
),
|
|
481
|
-
const
|
|
482
|
-
pk:
|
|
483
|
-
clientToken:
|
|
484
|
-
streamToken:
|
|
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,
|
|
487
|
+
clientToken: u.clientToken,
|
|
488
|
+
streamToken: u.streamToken,
|
|
485
489
|
request: {
|
|
486
490
|
...f,
|
|
487
491
|
limit: (t == null ? void 0 : t.pageSize) ?? 50,
|
|
488
492
|
pagination: {
|
|
489
493
|
nextPageToken: y,
|
|
490
|
-
previousPageToken:
|
|
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 je(e, t) {
|
|
|
509
513
|
};
|
|
510
514
|
};
|
|
511
515
|
return {
|
|
512
|
-
fetchFirstPage: async (
|
|
513
|
-
const
|
|
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
|
|
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 je(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 je(e, t) {
|
|
|
534
538
|
message: "No next page"
|
|
535
539
|
}
|
|
536
540
|
};
|
|
537
|
-
const
|
|
538
|
-
...
|
|
539
|
-
nextPageToken:
|
|
541
|
+
const u = await l({
|
|
542
|
+
...m,
|
|
543
|
+
nextPageToken: a.pagination.nextPageToken,
|
|
540
544
|
previousPageToken: void 0
|
|
541
545
|
});
|
|
542
|
-
return
|
|
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 je(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 je(e, t) {
|
|
|
558
562
|
message: "No previous page"
|
|
559
563
|
}
|
|
560
564
|
};
|
|
561
|
-
const
|
|
562
|
-
...
|
|
565
|
+
const u = await l({
|
|
566
|
+
...m,
|
|
563
567
|
nextPageToken: void 0,
|
|
564
|
-
previousPageToken:
|
|
568
|
+
previousPageToken: a.pagination.previousPageToken
|
|
565
569
|
});
|
|
566
|
-
return
|
|
570
|
+
return u.type === "success" && (g(u.page), r(m)), u;
|
|
567
571
|
},
|
|
568
572
|
refetchCurrentPage: async () => n == null ? {
|
|
569
573
|
type: "error",
|
|
@@ -571,46 +575,46 @@ function je(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],
|
|
584
|
+
const r = e.progressItems[n + 1], a = r != null;
|
|
581
585
|
let g;
|
|
582
586
|
if (r != null && r.createdAt) {
|
|
583
|
-
const
|
|
584
|
-
g = Math.round((
|
|
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
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:
|
|
603
|
+
repeatDelay: a = 0.5,
|
|
600
604
|
className: g,
|
|
601
|
-
startOnView:
|
|
602
|
-
once:
|
|
603
|
-
inViewMargin:
|
|
604
|
-
spread:
|
|
605
|
-
color:
|
|
606
|
-
shimmerColor:
|
|
607
|
-
direction:
|
|
605
|
+
startOnView: s = !1,
|
|
606
|
+
once: l = !1,
|
|
607
|
+
inViewMargin: d,
|
|
608
|
+
spread: o = 2,
|
|
609
|
+
color: i = "#999",
|
|
610
|
+
shimmerColor: m = "#000",
|
|
611
|
+
direction: u = "fromBottom"
|
|
608
612
|
}) {
|
|
609
|
-
const
|
|
610
|
-
return /* @__PURE__ */
|
|
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(
|
|
611
615
|
v.span,
|
|
612
616
|
{
|
|
613
|
-
ref:
|
|
617
|
+
ref: S,
|
|
614
618
|
className: g,
|
|
615
619
|
style: {
|
|
616
620
|
position: "relative",
|
|
@@ -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,18 +656,8 @@ function M({
|
|
|
652
656
|
}
|
|
653
657
|
);
|
|
654
658
|
}
|
|
655
|
-
function
|
|
659
|
+
function ye(e) {
|
|
656
660
|
const t = e.item.data;
|
|
657
|
-
if (t.taskType === "GenericAgentTask")
|
|
658
|
-
switch (t.eventType) {
|
|
659
|
-
case "Execution":
|
|
660
|
-
case "Reasoning":
|
|
661
|
-
return t.title;
|
|
662
|
-
case "FinalResponse":
|
|
663
|
-
return "Generating answer...";
|
|
664
|
-
case "Completed":
|
|
665
|
-
return "Completed";
|
|
666
|
-
}
|
|
667
661
|
if (t.taskType === "StreamingChatCompletion") {
|
|
668
662
|
if (t.eventType === "Text") return "Streaming...";
|
|
669
663
|
if (t.eventType === "Completed") return "Completed";
|
|
@@ -693,26 +687,26 @@ function fe(e) {
|
|
|
693
687
|
}
|
|
694
688
|
return "Processing...";
|
|
695
689
|
}
|
|
696
|
-
const
|
|
690
|
+
const fe = ({ progressViewItems: e }) => {
|
|
697
691
|
const t = e[e.length - 1];
|
|
698
692
|
if (!t) return null;
|
|
699
|
-
const n =
|
|
700
|
-
return /* @__PURE__ */
|
|
693
|
+
const n = ye(t);
|
|
694
|
+
return /* @__PURE__ */ c("div", { className: "simple-mode-container", children: /* @__PURE__ */ c(B, { mode: "wait", children: /* @__PURE__ */ c(
|
|
701
695
|
v.div,
|
|
702
696
|
{
|
|
703
697
|
initial: { opacity: 0, y: 10 },
|
|
704
698
|
animate: { opacity: 1, y: 0 },
|
|
705
699
|
exit: { opacity: 0, y: -10 },
|
|
706
700
|
transition: { duration: 0.3 },
|
|
707
|
-
children: t.completed ? /* @__PURE__ */
|
|
701
|
+
children: t.completed ? /* @__PURE__ */ c(
|
|
708
702
|
"div",
|
|
709
703
|
{
|
|
710
704
|
className: "simple-mode-title",
|
|
711
705
|
style: { color: "#666" },
|
|
712
706
|
children: n
|
|
713
707
|
}
|
|
714
|
-
) : /* @__PURE__ */
|
|
715
|
-
|
|
708
|
+
) : /* @__PURE__ */ c(
|
|
709
|
+
R,
|
|
716
710
|
{
|
|
717
711
|
text: n,
|
|
718
712
|
className: "simple-mode-title",
|
|
@@ -725,52 +719,7 @@ const he = ({ progressViewItems: e }) => {
|
|
|
725
719
|
},
|
|
726
720
|
t.item.progressItemId
|
|
727
721
|
) }) });
|
|
728
|
-
},
|
|
729
|
-
data: e,
|
|
730
|
-
isLatest: t = !1,
|
|
731
|
-
durationSeconds: n
|
|
732
|
-
}) => /* @__PURE__ */ b("div", { style: { padding: "16px" }, children: [
|
|
733
|
-
/* @__PURE__ */ i(
|
|
734
|
-
v.div,
|
|
735
|
-
{
|
|
736
|
-
style: {
|
|
737
|
-
display: "flex",
|
|
738
|
-
alignItems: "center",
|
|
739
|
-
gap: "10px",
|
|
740
|
-
color: "#666"
|
|
741
|
-
},
|
|
742
|
-
initial: { opacity: 0, y: -10 },
|
|
743
|
-
animate: { opacity: 1, y: 0 },
|
|
744
|
-
transition: { duration: 0.3, delay: 0 },
|
|
745
|
-
children: t && !n ? /* @__PURE__ */ i(
|
|
746
|
-
M,
|
|
747
|
-
{
|
|
748
|
-
text: e.title,
|
|
749
|
-
duration: 2.5,
|
|
750
|
-
repeat: !0,
|
|
751
|
-
color: "#999",
|
|
752
|
-
shimmerColor: "#000"
|
|
753
|
-
}
|
|
754
|
-
) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: e.title })
|
|
755
|
-
}
|
|
756
|
-
),
|
|
757
|
-
n !== void 0 && /* @__PURE__ */ b(
|
|
758
|
-
"div",
|
|
759
|
-
{
|
|
760
|
-
style: {
|
|
761
|
-
fontSize: "12px",
|
|
762
|
-
color: "#999",
|
|
763
|
-
marginTop: "4px",
|
|
764
|
-
fontStyle: "italic"
|
|
765
|
-
},
|
|
766
|
-
children: [
|
|
767
|
-
"Took ",
|
|
768
|
-
n,
|
|
769
|
-
" seconds"
|
|
770
|
-
]
|
|
771
|
-
}
|
|
772
|
-
)
|
|
773
|
-
] }), D = {
|
|
722
|
+
}, K = {
|
|
774
723
|
'code[class*="language-"]': {
|
|
775
724
|
color: "#f8f8f2",
|
|
776
725
|
background: "none",
|
|
@@ -921,229 +870,53 @@ const he = ({ progressViewItems: e }) => {
|
|
|
921
870
|
italic: {
|
|
922
871
|
fontStyle: "italic"
|
|
923
872
|
}
|
|
924
|
-
},
|
|
925
|
-
data: e,
|
|
926
|
-
streamToken: t,
|
|
927
|
-
fetchClientToken: n,
|
|
928
|
-
durationSeconds: r
|
|
929
|
-
}) => {
|
|
930
|
-
const { fency: o } = N(), g = U(
|
|
931
|
-
async (d) => {
|
|
932
|
-
try {
|
|
933
|
-
const { clientToken: s } = await n(), c = await V({
|
|
934
|
-
pk: o.publishableKey,
|
|
935
|
-
baseUrl: o.baseUrl,
|
|
936
|
-
clientToken: s,
|
|
937
|
-
streamToken: t,
|
|
938
|
-
request: { fileId: d }
|
|
939
|
-
});
|
|
940
|
-
c.type === "success" && window.open(c.downloadLink, "_blank");
|
|
941
|
-
} catch (s) {
|
|
942
|
-
console.error("Failed to download file:", s);
|
|
943
|
-
}
|
|
944
|
-
},
|
|
945
|
-
[o, t, n]
|
|
946
|
-
);
|
|
947
|
-
return /* @__PURE__ */ b("div", { style: { padding: "16px" }, children: [
|
|
948
|
-
/* @__PURE__ */ i(
|
|
949
|
-
v.div,
|
|
950
|
-
{
|
|
951
|
-
className: "fency-markdown-body-raw",
|
|
952
|
-
initial: { opacity: 0, y: -10 },
|
|
953
|
-
animate: { opacity: 1, y: 0 },
|
|
954
|
-
transition: { duration: 0.3, delay: 0 },
|
|
955
|
-
children: /* @__PURE__ */ i(
|
|
956
|
-
z,
|
|
957
|
-
{
|
|
958
|
-
remarkPlugins: [L],
|
|
959
|
-
components: {
|
|
960
|
-
code(d) {
|
|
961
|
-
const { children: s, className: c, node: a, ref: l, ...u } = d, m = /language-(\w+)/.exec(c || "");
|
|
962
|
-
return m ? /* @__PURE__ */ i(
|
|
963
|
-
F,
|
|
964
|
-
{
|
|
965
|
-
...u,
|
|
966
|
-
PreTag: "div",
|
|
967
|
-
children: String(s).replace(/\n$/, ""),
|
|
968
|
-
language: m[1],
|
|
969
|
-
style: D
|
|
970
|
-
}
|
|
971
|
-
) : /* @__PURE__ */ i("code", { ...u, className: c, children: String(s) });
|
|
972
|
-
},
|
|
973
|
-
a(d) {
|
|
974
|
-
const { children: s, href: c, ...a } = d;
|
|
975
|
-
return /* @__PURE__ */ i(
|
|
976
|
-
"a",
|
|
977
|
-
{
|
|
978
|
-
...a,
|
|
979
|
-
href: c,
|
|
980
|
-
onClick: (l) => {
|
|
981
|
-
if (!c) return;
|
|
982
|
-
const u = c.match(
|
|
983
|
-
/\/files\/(fil_[a-zA-Z0-9]+)\/download/
|
|
984
|
-
);
|
|
985
|
-
u && (l.preventDefault(), g(u[1]));
|
|
986
|
-
},
|
|
987
|
-
children: s
|
|
988
|
-
}
|
|
989
|
-
);
|
|
990
|
-
}
|
|
991
|
-
},
|
|
992
|
-
children: e.response
|
|
993
|
-
}
|
|
994
|
-
)
|
|
995
|
-
}
|
|
996
|
-
),
|
|
997
|
-
r !== void 0 && /* @__PURE__ */ b(
|
|
998
|
-
"div",
|
|
999
|
-
{
|
|
1000
|
-
style: {
|
|
1001
|
-
fontSize: "12px",
|
|
1002
|
-
color: "#999",
|
|
1003
|
-
marginTop: "8px",
|
|
1004
|
-
fontStyle: "italic"
|
|
1005
|
-
},
|
|
1006
|
-
children: [
|
|
1007
|
-
"Thought for ",
|
|
1008
|
-
r,
|
|
1009
|
-
" seconds"
|
|
1010
|
-
]
|
|
1011
|
-
}
|
|
1012
|
-
)
|
|
1013
|
-
] });
|
|
1014
|
-
}, ke = ({
|
|
1015
|
-
data: e,
|
|
1016
|
-
completed: t,
|
|
1017
|
-
isLatest: n = !1,
|
|
1018
|
-
durationSeconds: r
|
|
1019
|
-
}) => {
|
|
1020
|
-
const o = E(null);
|
|
1021
|
-
return p(() => {
|
|
1022
|
-
o.current && !t && (o.current.scrollTop = o.current.scrollHeight);
|
|
1023
|
-
}, [e.reasoning, t]), /* @__PURE__ */ b("div", { style: { padding: "16px" }, children: [
|
|
1024
|
-
/* @__PURE__ */ i(
|
|
1025
|
-
v.h3,
|
|
1026
|
-
{
|
|
1027
|
-
style: { marginBottom: "10px", color: "#666" },
|
|
1028
|
-
initial: { opacity: 0, y: -10 },
|
|
1029
|
-
animate: { opacity: 1, y: 0 },
|
|
1030
|
-
transition: { duration: 0.3, delay: 0 },
|
|
1031
|
-
children: n && !r ? /* @__PURE__ */ i(
|
|
1032
|
-
M,
|
|
1033
|
-
{
|
|
1034
|
-
text: e.title,
|
|
1035
|
-
duration: 2.5,
|
|
1036
|
-
repeat: !0,
|
|
1037
|
-
color: "#999",
|
|
1038
|
-
shimmerColor: "#000"
|
|
1039
|
-
}
|
|
1040
|
-
) : e.title
|
|
1041
|
-
}
|
|
1042
|
-
),
|
|
1043
|
-
/* @__PURE__ */ i(
|
|
1044
|
-
v.div,
|
|
1045
|
-
{
|
|
1046
|
-
ref: o,
|
|
1047
|
-
style: {
|
|
1048
|
-
maxHeight: "100px",
|
|
1049
|
-
overflowY: "auto",
|
|
1050
|
-
border: "1px solid #e0e0e0",
|
|
1051
|
-
borderRadius: "8px",
|
|
1052
|
-
padding: "12px",
|
|
1053
|
-
opacity: 0.5,
|
|
1054
|
-
backgroundColor: "#f9f9f9"
|
|
1055
|
-
},
|
|
1056
|
-
initial: { opacity: 0, y: -10 },
|
|
1057
|
-
animate: { opacity: 0.5, y: 0 },
|
|
1058
|
-
transition: { duration: 0.3, delay: 0.1 },
|
|
1059
|
-
children: /* @__PURE__ */ i("div", { className: "fency-markdown-body-raw", children: /* @__PURE__ */ i(
|
|
1060
|
-
z,
|
|
1061
|
-
{
|
|
1062
|
-
remarkPlugins: [L],
|
|
1063
|
-
components: {
|
|
1064
|
-
code(g) {
|
|
1065
|
-
const { children: d, className: s, node: c, ref: a, ...l } = g, u = /language-(\w+)/.exec(s || "");
|
|
1066
|
-
return u ? /* @__PURE__ */ i(
|
|
1067
|
-
F,
|
|
1068
|
-
{
|
|
1069
|
-
...l,
|
|
1070
|
-
PreTag: "div",
|
|
1071
|
-
children: String(d).replace(/\n$/, ""),
|
|
1072
|
-
language: u[1],
|
|
1073
|
-
style: D
|
|
1074
|
-
}
|
|
1075
|
-
) : /* @__PURE__ */ i("code", { ...l, className: s, children: String(d) });
|
|
1076
|
-
}
|
|
1077
|
-
},
|
|
1078
|
-
children: e.reasoning
|
|
1079
|
-
}
|
|
1080
|
-
) })
|
|
1081
|
-
}
|
|
1082
|
-
),
|
|
1083
|
-
r !== void 0 && /* @__PURE__ */ b(
|
|
1084
|
-
"div",
|
|
1085
|
-
{
|
|
1086
|
-
style: {
|
|
1087
|
-
fontSize: "12px",
|
|
1088
|
-
color: "#999",
|
|
1089
|
-
marginTop: "8px",
|
|
1090
|
-
fontStyle: "italic"
|
|
1091
|
-
},
|
|
1092
|
-
children: [
|
|
1093
|
-
"Thought for ",
|
|
1094
|
-
r,
|
|
1095
|
-
" seconds"
|
|
1096
|
-
]
|
|
1097
|
-
}
|
|
1098
|
-
)
|
|
1099
|
-
] });
|
|
1100
|
-
}, B = ({
|
|
873
|
+
}, U = ({
|
|
1101
874
|
text: e
|
|
1102
|
-
}) => /* @__PURE__ */
|
|
875
|
+
}) => /* @__PURE__ */ c("div", { style: { padding: "16px" }, children: /* @__PURE__ */ c(
|
|
1103
876
|
v.div,
|
|
1104
877
|
{
|
|
1105
878
|
className: "fency-markdown-body-raw",
|
|
1106
879
|
initial: { opacity: 0, y: -10 },
|
|
1107
880
|
animate: { opacity: 1, y: 0 },
|
|
1108
881
|
transition: { duration: 0.3, delay: 0 },
|
|
1109
|
-
children: /* @__PURE__ */
|
|
1110
|
-
|
|
882
|
+
children: /* @__PURE__ */ c(
|
|
883
|
+
Y,
|
|
1111
884
|
{
|
|
1112
|
-
remarkPlugins: [
|
|
885
|
+
remarkPlugins: [Z],
|
|
1113
886
|
components: {
|
|
1114
887
|
code(t) {
|
|
1115
|
-
const { children: n, className: r, node:
|
|
1116
|
-
return
|
|
1117
|
-
|
|
888
|
+
const { children: n, className: r, node: a, ref: g, ...s } = t, l = /language-(\w+)/.exec(r || "");
|
|
889
|
+
return l ? /* @__PURE__ */ c(
|
|
890
|
+
L,
|
|
1118
891
|
{
|
|
1119
|
-
...
|
|
892
|
+
...s,
|
|
1120
893
|
PreTag: "div",
|
|
1121
894
|
children: String(n).replace(/\n$/, ""),
|
|
1122
|
-
language:
|
|
1123
|
-
style:
|
|
895
|
+
language: l[1],
|
|
896
|
+
style: K
|
|
1124
897
|
}
|
|
1125
|
-
) : /* @__PURE__ */
|
|
898
|
+
) : /* @__PURE__ */ c("code", { ...s, className: r, children: String(n) });
|
|
1126
899
|
}
|
|
1127
900
|
},
|
|
1128
901
|
children: e
|
|
1129
902
|
}
|
|
1130
903
|
)
|
|
1131
904
|
}
|
|
1132
|
-
) }),
|
|
905
|
+
) }), he = ({ data: e }) => {
|
|
1133
906
|
const t = JSON.stringify(e.json, null, 2);
|
|
1134
|
-
return /* @__PURE__ */
|
|
907
|
+
return /* @__PURE__ */ c("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ c(
|
|
1135
908
|
v.div,
|
|
1136
909
|
{
|
|
1137
910
|
initial: { opacity: 0, y: -10 },
|
|
1138
911
|
animate: { opacity: 1, y: 0 },
|
|
1139
912
|
transition: { duration: 0.3, delay: 0 },
|
|
1140
|
-
children: /* @__PURE__ */
|
|
913
|
+
children: /* @__PURE__ */ c(L, { language: "json", style: K, PreTag: "div", children: t })
|
|
1141
914
|
}
|
|
1142
915
|
) });
|
|
1143
|
-
},
|
|
916
|
+
}, Se = ({ data: e, isLatest: t = !1, durationSeconds: n }) => {
|
|
1144
917
|
const r = `Searching: ${e.queryDescription}`;
|
|
1145
|
-
return /* @__PURE__ */
|
|
1146
|
-
/* @__PURE__ */
|
|
918
|
+
return /* @__PURE__ */ x("div", { style: { padding: "16px" }, children: [
|
|
919
|
+
/* @__PURE__ */ c(
|
|
1147
920
|
v.div,
|
|
1148
921
|
{
|
|
1149
922
|
style: {
|
|
@@ -1155,8 +928,8 @@ const he = ({ progressViewItems: e }) => {
|
|
|
1155
928
|
initial: { opacity: 0, y: -10 },
|
|
1156
929
|
animate: { opacity: 1, y: 0 },
|
|
1157
930
|
transition: { duration: 0.3, delay: 0 },
|
|
1158
|
-
children: t && !n ? /* @__PURE__ */
|
|
1159
|
-
|
|
931
|
+
children: t && !n ? /* @__PURE__ */ c(
|
|
932
|
+
R,
|
|
1160
933
|
{
|
|
1161
934
|
text: r,
|
|
1162
935
|
duration: 2.5,
|
|
@@ -1164,10 +937,10 @@ const he = ({ progressViewItems: e }) => {
|
|
|
1164
937
|
color: "#999",
|
|
1165
938
|
shimmerColor: "#000"
|
|
1166
939
|
}
|
|
1167
|
-
) : /* @__PURE__ */
|
|
940
|
+
) : /* @__PURE__ */ c("span", { style: { color: "#666" }, children: r })
|
|
1168
941
|
}
|
|
1169
942
|
),
|
|
1170
|
-
n !== void 0 && /* @__PURE__ */
|
|
943
|
+
n !== void 0 && /* @__PURE__ */ x(
|
|
1171
944
|
"div",
|
|
1172
945
|
{
|
|
1173
946
|
style: {
|
|
@@ -1184,10 +957,10 @@ const he = ({ progressViewItems: e }) => {
|
|
|
1184
957
|
}
|
|
1185
958
|
)
|
|
1186
959
|
] });
|
|
1187
|
-
},
|
|
960
|
+
}, Te = ({ isLatest: e = !1, durationSeconds: t }) => {
|
|
1188
961
|
const n = "Adding sources...";
|
|
1189
|
-
return /* @__PURE__ */
|
|
1190
|
-
/* @__PURE__ */
|
|
962
|
+
return /* @__PURE__ */ x("div", { style: { padding: "16px" }, children: [
|
|
963
|
+
/* @__PURE__ */ c(
|
|
1191
964
|
v.div,
|
|
1192
965
|
{
|
|
1193
966
|
style: {
|
|
@@ -1199,8 +972,8 @@ const he = ({ progressViewItems: e }) => {
|
|
|
1199
972
|
initial: { opacity: 0, y: -10 },
|
|
1200
973
|
animate: { opacity: 1, y: 0 },
|
|
1201
974
|
transition: { duration: 0.3, delay: 0 },
|
|
1202
|
-
children: e && !t ? /* @__PURE__ */
|
|
1203
|
-
|
|
975
|
+
children: e && !t ? /* @__PURE__ */ c(
|
|
976
|
+
R,
|
|
1204
977
|
{
|
|
1205
978
|
text: n,
|
|
1206
979
|
duration: 2.5,
|
|
@@ -1208,10 +981,10 @@ const he = ({ progressViewItems: e }) => {
|
|
|
1208
981
|
color: "#999",
|
|
1209
982
|
shimmerColor: "#000"
|
|
1210
983
|
}
|
|
1211
|
-
) : /* @__PURE__ */
|
|
984
|
+
) : /* @__PURE__ */ c("span", { style: { color: "#666" }, children: n })
|
|
1212
985
|
}
|
|
1213
986
|
),
|
|
1214
|
-
t !== void 0 && /* @__PURE__ */
|
|
987
|
+
t !== void 0 && /* @__PURE__ */ x(
|
|
1215
988
|
"div",
|
|
1216
989
|
{
|
|
1217
990
|
style: {
|
|
@@ -1228,8 +1001,8 @@ const he = ({ progressViewItems: e }) => {
|
|
|
1228
1001
|
}
|
|
1229
1002
|
)
|
|
1230
1003
|
] });
|
|
1231
|
-
},
|
|
1232
|
-
/* @__PURE__ */
|
|
1004
|
+
}, be = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ x("div", { style: { padding: "16px" }, children: [
|
|
1005
|
+
/* @__PURE__ */ c(
|
|
1233
1006
|
v.div,
|
|
1234
1007
|
{
|
|
1235
1008
|
style: { color: "#666", marginBottom: "10px", fontSize: "14px" },
|
|
@@ -1239,8 +1012,8 @@ const he = ({ progressViewItems: e }) => {
|
|
|
1239
1012
|
children: "Sources"
|
|
1240
1013
|
}
|
|
1241
1014
|
),
|
|
1242
|
-
/* @__PURE__ */
|
|
1243
|
-
|
|
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,
|
|
1244
1017
|
{
|
|
1245
1018
|
source: n,
|
|
1246
1019
|
index: r,
|
|
@@ -1249,7 +1022,7 @@ const he = ({ progressViewItems: e }) => {
|
|
|
1249
1022
|
n.memoryId
|
|
1250
1023
|
)) })
|
|
1251
1024
|
] });
|
|
1252
|
-
function
|
|
1025
|
+
function ke(e, t) {
|
|
1253
1026
|
if (t.length === 0) return e;
|
|
1254
1027
|
if (t.length === 1) return `${e} page ${t[0]}`;
|
|
1255
1028
|
if (t.length === 2)
|
|
@@ -1257,17 +1030,17 @@ function pe(e, t) {
|
|
|
1257
1030
|
const n = t[t.length - 1], r = t.slice(0, -1).join(", ");
|
|
1258
1031
|
return `${e} pages ${r} and ${n}`;
|
|
1259
1032
|
}
|
|
1260
|
-
const
|
|
1261
|
-
const [r,
|
|
1262
|
-
return /* @__PURE__ */
|
|
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(
|
|
1263
1036
|
v.div,
|
|
1264
1037
|
{
|
|
1265
1038
|
initial: { opacity: 0, scale: 0.9 },
|
|
1266
1039
|
animate: { opacity: 1, scale: 1 },
|
|
1267
1040
|
transition: { duration: 0.25, delay: t * 0.05 },
|
|
1268
1041
|
onClick: g ? () => n(e.memoryId) : void 0,
|
|
1269
|
-
onMouseEnter: g ? () =>
|
|
1270
|
-
onMouseLeave: g ? () =>
|
|
1042
|
+
onMouseEnter: g ? () => a(!0) : void 0,
|
|
1043
|
+
onMouseLeave: g ? () => a(!1) : void 0,
|
|
1271
1044
|
style: {
|
|
1272
1045
|
display: "inline-flex",
|
|
1273
1046
|
flexDirection: "column",
|
|
@@ -1280,18 +1053,18 @@ const we = ({ source: e, index: t, onSourceClick: n }) => {
|
|
|
1280
1053
|
transition: "background-color 0.15s ease",
|
|
1281
1054
|
userSelect: "none"
|
|
1282
1055
|
},
|
|
1283
|
-
children: /* @__PURE__ */
|
|
1056
|
+
children: /* @__PURE__ */ c("span", { style: { fontSize: "13px", fontWeight: 500, color: "#333" }, children: s })
|
|
1284
1057
|
}
|
|
1285
1058
|
);
|
|
1286
|
-
},
|
|
1059
|
+
}, ve = `
|
|
1287
1060
|
@keyframes explore-memory-spinner {
|
|
1288
1061
|
to { transform: rotate(360deg); }
|
|
1289
1062
|
}
|
|
1290
1063
|
`;
|
|
1291
|
-
function
|
|
1292
|
-
return /* @__PURE__ */
|
|
1293
|
-
/* @__PURE__ */
|
|
1294
|
-
/* @__PURE__ */
|
|
1064
|
+
function xe() {
|
|
1065
|
+
return /* @__PURE__ */ x(X, { children: [
|
|
1066
|
+
/* @__PURE__ */ c("style", { children: ve }),
|
|
1067
|
+
/* @__PURE__ */ c(
|
|
1295
1068
|
"div",
|
|
1296
1069
|
{
|
|
1297
1070
|
style: {
|
|
@@ -1306,21 +1079,21 @@ function Ae() {
|
|
|
1306
1079
|
)
|
|
1307
1080
|
] });
|
|
1308
1081
|
}
|
|
1309
|
-
function
|
|
1082
|
+
function we({
|
|
1310
1083
|
eventType: e,
|
|
1311
1084
|
completed: t
|
|
1312
1085
|
}) {
|
|
1313
|
-
return e === "ExploreMemoryError" ? /* @__PURE__ */
|
|
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;
|
|
1314
1087
|
}
|
|
1315
|
-
const
|
|
1316
|
-
const [n, r] =
|
|
1317
|
-
return /* @__PURE__ */
|
|
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(
|
|
1318
1091
|
v.div,
|
|
1319
1092
|
{
|
|
1320
1093
|
initial: { opacity: 0, scale: 0.9 },
|
|
1321
1094
|
animate: { opacity: 1, scale: 1 },
|
|
1322
1095
|
transition: { duration: 0.25, delay: 0 },
|
|
1323
|
-
onClick:
|
|
1096
|
+
onClick: l ? () => r((d) => !d) : void 0,
|
|
1324
1097
|
style: {
|
|
1325
1098
|
display: "inline-flex",
|
|
1326
1099
|
flexDirection: "row",
|
|
@@ -1331,17 +1104,17 @@ const _ = 80, Pe = ({ data: e, completed: t }) => {
|
|
|
1331
1104
|
border: "1px solid #e0e0e0",
|
|
1332
1105
|
backgroundColor: "#f9f9f9",
|
|
1333
1106
|
minWidth: 0,
|
|
1334
|
-
cursor:
|
|
1107
|
+
cursor: l ? "pointer" : "default",
|
|
1335
1108
|
transition: "background-color 0.15s ease"
|
|
1336
1109
|
},
|
|
1337
|
-
onMouseEnter:
|
|
1338
|
-
|
|
1110
|
+
onMouseEnter: l ? (d) => {
|
|
1111
|
+
d.currentTarget.style.backgroundColor = "#f0f0f0";
|
|
1339
1112
|
} : void 0,
|
|
1340
|
-
onMouseLeave:
|
|
1341
|
-
|
|
1113
|
+
onMouseLeave: l ? (d) => {
|
|
1114
|
+
d.currentTarget.style.backgroundColor = "#f9f9f9";
|
|
1342
1115
|
} : void 0,
|
|
1343
1116
|
children: [
|
|
1344
|
-
/* @__PURE__ */
|
|
1117
|
+
/* @__PURE__ */ c(
|
|
1345
1118
|
"div",
|
|
1346
1119
|
{
|
|
1347
1120
|
style: {
|
|
@@ -1351,10 +1124,10 @@ const _ = 80, Pe = ({ data: e, completed: t }) => {
|
|
|
1351
1124
|
flexShrink: 0,
|
|
1352
1125
|
width: 20
|
|
1353
1126
|
},
|
|
1354
|
-
children: /* @__PURE__ */
|
|
1127
|
+
children: /* @__PURE__ */ c(we, { eventType: e.eventType, completed: t })
|
|
1355
1128
|
}
|
|
1356
1129
|
),
|
|
1357
|
-
/* @__PURE__ */
|
|
1130
|
+
/* @__PURE__ */ x(
|
|
1358
1131
|
"div",
|
|
1359
1132
|
{
|
|
1360
1133
|
style: {
|
|
@@ -1364,8 +1137,8 @@ const _ = 80, Pe = ({ data: e, completed: t }) => {
|
|
|
1364
1137
|
minWidth: 0
|
|
1365
1138
|
},
|
|
1366
1139
|
children: [
|
|
1367
|
-
/* @__PURE__ */
|
|
1368
|
-
|
|
1140
|
+
/* @__PURE__ */ c("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
|
|
1141
|
+
s != null && /* @__PURE__ */ c(
|
|
1369
1142
|
"span",
|
|
1370
1143
|
{
|
|
1371
1144
|
style: {
|
|
@@ -1374,10 +1147,10 @@ const _ = 80, Pe = ({ data: e, completed: t }) => {
|
|
|
1374
1147
|
lineHeight: 1.4,
|
|
1375
1148
|
whiteSpace: n ? "pre-wrap" : void 0
|
|
1376
1149
|
},
|
|
1377
|
-
children:
|
|
1150
|
+
children: s
|
|
1378
1151
|
}
|
|
1379
1152
|
),
|
|
1380
|
-
|
|
1153
|
+
l && /* @__PURE__ */ c(
|
|
1381
1154
|
"span",
|
|
1382
1155
|
{
|
|
1383
1156
|
style: {
|
|
@@ -1394,100 +1167,71 @@ const _ = 80, Pe = ({ data: e, completed: t }) => {
|
|
|
1394
1167
|
]
|
|
1395
1168
|
}
|
|
1396
1169
|
) });
|
|
1397
|
-
},
|
|
1398
|
-
|
|
1399
|
-
|
|
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(() => {
|
|
1400
1179
|
g.current && (g.current.scrollTop = g.current.scrollHeight);
|
|
1401
1180
|
}, [e.length]);
|
|
1402
|
-
const
|
|
1403
|
-
const
|
|
1404
|
-
if (
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
data: c,
|
|
1411
|
-
completed: s.completed,
|
|
1412
|
-
isLatest: s.isLatest,
|
|
1413
|
-
durationSeconds: s.durationSeconds
|
|
1414
|
-
}
|
|
1415
|
-
);
|
|
1416
|
-
case "Reasoning":
|
|
1417
|
-
return /* @__PURE__ */ i(
|
|
1418
|
-
ke,
|
|
1419
|
-
{
|
|
1420
|
-
data: c,
|
|
1421
|
-
completed: s.completed,
|
|
1422
|
-
isLatest: s.isLatest,
|
|
1423
|
-
durationSeconds: s.durationSeconds
|
|
1424
|
-
}
|
|
1425
|
-
);
|
|
1426
|
-
case "FinalResponse":
|
|
1427
|
-
return /* @__PURE__ */ i(
|
|
1428
|
-
Se,
|
|
1429
|
-
{
|
|
1430
|
-
data: c,
|
|
1431
|
-
streamToken: t,
|
|
1432
|
-
fetchClientToken: n,
|
|
1433
|
-
durationSeconds: s.durationSeconds
|
|
1434
|
-
}
|
|
1435
|
-
);
|
|
1436
|
-
case "Completed":
|
|
1437
|
-
return null;
|
|
1438
|
-
}
|
|
1439
|
-
if (c.taskType === "StreamingChatCompletion" && c.eventType === "Text")
|
|
1440
|
-
return /* @__PURE__ */ i(B, { text: c.text });
|
|
1441
|
-
if (c.taskType === "StructuredChatCompletion" && c.eventType === "Json")
|
|
1442
|
-
return /* @__PURE__ */ i(be, { data: c });
|
|
1443
|
-
if (c.taskType === "StreamingMemoryTypeChatCompletion")
|
|
1444
|
-
switch (c.eventType) {
|
|
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) {
|
|
1445
1189
|
case "Text":
|
|
1446
|
-
return /* @__PURE__ */
|
|
1190
|
+
return /* @__PURE__ */ c(U, { text: d.text });
|
|
1447
1191
|
case "Search":
|
|
1448
|
-
return /* @__PURE__ */
|
|
1449
|
-
|
|
1192
|
+
return /* @__PURE__ */ c(
|
|
1193
|
+
Se,
|
|
1450
1194
|
{
|
|
1451
|
-
data:
|
|
1452
|
-
isLatest:
|
|
1453
|
-
durationSeconds:
|
|
1195
|
+
data: d,
|
|
1196
|
+
isLatest: l.isLatest,
|
|
1197
|
+
durationSeconds: l.durationSeconds
|
|
1454
1198
|
}
|
|
1455
1199
|
);
|
|
1456
1200
|
case "FindSources":
|
|
1457
|
-
return /* @__PURE__ */
|
|
1458
|
-
|
|
1201
|
+
return /* @__PURE__ */ c(
|
|
1202
|
+
Te,
|
|
1459
1203
|
{
|
|
1460
|
-
data:
|
|
1461
|
-
isLatest:
|
|
1462
|
-
durationSeconds:
|
|
1204
|
+
data: d,
|
|
1205
|
+
isLatest: l.isLatest,
|
|
1206
|
+
durationSeconds: l.durationSeconds
|
|
1463
1207
|
}
|
|
1464
1208
|
);
|
|
1465
1209
|
case "SourcesResult":
|
|
1466
|
-
return /* @__PURE__ */
|
|
1467
|
-
|
|
1210
|
+
return /* @__PURE__ */ c(
|
|
1211
|
+
be,
|
|
1468
1212
|
{
|
|
1469
|
-
data:
|
|
1470
|
-
onSourceClick:
|
|
1213
|
+
data: d,
|
|
1214
|
+
onSourceClick: a
|
|
1471
1215
|
}
|
|
1472
1216
|
);
|
|
1473
1217
|
case "ExploreMemoryStart":
|
|
1474
1218
|
case "ExploreMemoryResult":
|
|
1475
1219
|
case "ExploreMemoryError":
|
|
1476
|
-
return /* @__PURE__ */
|
|
1477
|
-
|
|
1220
|
+
return /* @__PURE__ */ c(
|
|
1221
|
+
Ee,
|
|
1478
1222
|
{
|
|
1479
|
-
data:
|
|
1480
|
-
completed:
|
|
1481
|
-
isLatest:
|
|
1223
|
+
data: d,
|
|
1224
|
+
completed: l.completed,
|
|
1225
|
+
isLatest: l.isLatest
|
|
1482
1226
|
}
|
|
1483
1227
|
);
|
|
1484
1228
|
case "Completed":
|
|
1485
1229
|
return null;
|
|
1486
1230
|
}
|
|
1487
|
-
return
|
|
1231
|
+
return d.taskType === "StreamingChatCompletion" && d.eventType === "Completed" || d.taskType === "StructuredChatCompletion" && d.eventType === "Completed", null;
|
|
1488
1232
|
};
|
|
1489
|
-
return e.length === 0 ? /* @__PURE__ */
|
|
1490
|
-
|
|
1233
|
+
return e.length === 0 ? /* @__PURE__ */ c("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ c(
|
|
1234
|
+
R,
|
|
1491
1235
|
{
|
|
1492
1236
|
text: r ?? "Processing your task...",
|
|
1493
1237
|
duration: 1.5,
|
|
@@ -1496,41 +1240,41 @@ const _ = 80, Pe = ({ data: e, completed: t }) => {
|
|
|
1496
1240
|
color: "#999",
|
|
1497
1241
|
shimmerColor: "#000"
|
|
1498
1242
|
}
|
|
1499
|
-
) }) : /* @__PURE__ */
|
|
1243
|
+
) }) : /* @__PURE__ */ c("div", { id: "agent-task-progress-verbose", ref: g, children: /* @__PURE__ */ c(B, { children: e.map((l, d) => /* @__PURE__ */ c(
|
|
1500
1244
|
v.div,
|
|
1501
1245
|
{
|
|
1502
|
-
id: `agent-task-progress-item-${
|
|
1246
|
+
id: `agent-task-progress-item-${l.item.progressItemId}`,
|
|
1503
1247
|
initial: { opacity: 0, y: -20 },
|
|
1504
1248
|
animate: { opacity: 1, y: 0 },
|
|
1505
1249
|
transition: {
|
|
1506
1250
|
duration: 0.4,
|
|
1507
|
-
delay:
|
|
1251
|
+
delay: d * 0.1,
|
|
1508
1252
|
ease: "easeOut"
|
|
1509
1253
|
},
|
|
1510
|
-
children:
|
|
1254
|
+
children: s(l)
|
|
1511
1255
|
},
|
|
1512
|
-
|
|
1256
|
+
l.item.progressItemId
|
|
1513
1257
|
)) }) });
|
|
1514
|
-
},
|
|
1258
|
+
}, Be = ({
|
|
1515
1259
|
agentTask: e,
|
|
1516
1260
|
mode: t = "verbose",
|
|
1517
1261
|
streamToken: n,
|
|
1518
1262
|
fetchClientToken: r,
|
|
1519
|
-
onSourceClick:
|
|
1263
|
+
onSourceClick: a
|
|
1520
1264
|
}) => {
|
|
1521
|
-
const g =
|
|
1522
|
-
return t === "simple" ? /* @__PURE__ */
|
|
1523
|
-
|
|
1265
|
+
const g = ge(e);
|
|
1266
|
+
return t === "simple" ? /* @__PURE__ */ c(fe, { progressViewItems: g }) : /* @__PURE__ */ c(
|
|
1267
|
+
Ie,
|
|
1524
1268
|
{
|
|
1525
1269
|
progressViewItems: g,
|
|
1526
1270
|
streamToken: n,
|
|
1527
1271
|
fetchClientToken: r,
|
|
1528
1272
|
loadingText: e.loadingText,
|
|
1529
|
-
onSourceClick:
|
|
1273
|
+
onSourceClick: a
|
|
1530
1274
|
}
|
|
1531
1275
|
);
|
|
1532
1276
|
};
|
|
1533
|
-
class
|
|
1277
|
+
class Ae {
|
|
1534
1278
|
constructor(t) {
|
|
1535
1279
|
this.eventSources = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Map(), this.fency = t;
|
|
1536
1280
|
}
|
|
@@ -1540,36 +1284,36 @@ class Re {
|
|
|
1540
1284
|
*/
|
|
1541
1285
|
updateStreams(t) {
|
|
1542
1286
|
t.forEach((r) => {
|
|
1543
|
-
const
|
|
1544
|
-
this.eventSources.has(
|
|
1287
|
+
const a = r.stream.id;
|
|
1288
|
+
this.eventSources.has(a) || this.connectStream(r);
|
|
1545
1289
|
});
|
|
1546
1290
|
const n = new Set(t.map((r) => r.stream.id));
|
|
1547
|
-
this.eventSources.forEach((r,
|
|
1548
|
-
n.has(
|
|
1291
|
+
this.eventSources.forEach((r, a) => {
|
|
1292
|
+
n.has(a) || (r.abort(), this.eventSources.delete(a));
|
|
1549
1293
|
});
|
|
1550
1294
|
}
|
|
1551
1295
|
connectStream(t) {
|
|
1552
1296
|
const n = t.stream.id, r = new AbortController();
|
|
1553
1297
|
this.eventSources.set(n, r);
|
|
1554
|
-
const
|
|
1298
|
+
const a = `${this.fency.baseUrl}/sse/streams/${n}`, g = {
|
|
1555
1299
|
"X-Fency-Publishable-Key": this.fency.publishableKey,
|
|
1556
1300
|
"X-Fency-Stream-Token": t.stream.token
|
|
1557
1301
|
};
|
|
1558
|
-
|
|
1302
|
+
j(a, {
|
|
1559
1303
|
headers: g,
|
|
1560
1304
|
signal: r.signal,
|
|
1561
|
-
async onopen(
|
|
1562
|
-
if (!
|
|
1563
|
-
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}`);
|
|
1564
1308
|
},
|
|
1565
|
-
onmessage: (
|
|
1566
|
-
if (
|
|
1567
|
-
const
|
|
1568
|
-
this.broadcast(
|
|
1309
|
+
onmessage: (s) => {
|
|
1310
|
+
if (s.data) {
|
|
1311
|
+
const l = H(s.data);
|
|
1312
|
+
this.broadcast(l, n);
|
|
1569
1313
|
}
|
|
1570
1314
|
},
|
|
1571
|
-
onerror: (
|
|
1572
|
-
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;
|
|
1573
1317
|
},
|
|
1574
1318
|
onclose() {
|
|
1575
1319
|
}
|
|
@@ -1601,95 +1345,92 @@ class Re {
|
|
|
1601
1345
|
this.eventSources.forEach((t) => t.abort()), this.eventSources.clear(), this.subscribers.clear();
|
|
1602
1346
|
}
|
|
1603
1347
|
}
|
|
1604
|
-
const
|
|
1348
|
+
const pe = 12e4, Pe = (e) => {
|
|
1605
1349
|
const t = Date.now();
|
|
1606
|
-
return e.filter((n) => t - n.createdAt <
|
|
1350
|
+
return e.filter((n) => t - n.createdAt < pe);
|
|
1607
1351
|
};
|
|
1608
|
-
function
|
|
1609
|
-
const [r,
|
|
1352
|
+
function Le({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
|
|
1353
|
+
const [r, a] = k(
|
|
1610
1354
|
null
|
|
1611
|
-
), [g,
|
|
1612
|
-
|
|
1355
|
+
), [g, s] = k(!0), [l, d] = k(null), [o, i] = k([]), m = p(null), u = p(null);
|
|
1356
|
+
E(() => {
|
|
1613
1357
|
e.then((f) => {
|
|
1614
|
-
|
|
1358
|
+
a(f), s(!1);
|
|
1615
1359
|
}).catch((f) => {
|
|
1616
|
-
|
|
1360
|
+
d(f), s(!1);
|
|
1617
1361
|
});
|
|
1618
|
-
}, [e]),
|
|
1619
|
-
r && !
|
|
1620
|
-
}, [r]),
|
|
1621
|
-
|
|
1622
|
-
}, [
|
|
1362
|
+
}, [e]), E(() => {
|
|
1363
|
+
r && !u.current && (u.current = new Ae(r));
|
|
1364
|
+
}, [r]), E(() => {
|
|
1365
|
+
u.current && u.current.updateStreams(o);
|
|
1366
|
+
}, [o]), E(() => () => {
|
|
1623
1367
|
var f;
|
|
1624
|
-
(f =
|
|
1368
|
+
(f = u.current) == null || f.cleanup();
|
|
1625
1369
|
}, []);
|
|
1626
|
-
const
|
|
1370
|
+
const S = W(
|
|
1627
1371
|
async (f = 3e4) => {
|
|
1628
|
-
if (
|
|
1629
|
-
return
|
|
1630
|
-
const h = Date.now(),
|
|
1631
|
-
if (
|
|
1632
|
-
return
|
|
1633
|
-
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 () => {
|
|
1634
1378
|
if (!r)
|
|
1635
1379
|
throw new Error("Fency instance not initialized");
|
|
1636
|
-
const w = await t(),
|
|
1380
|
+
const w = await t(), A = await J({
|
|
1637
1381
|
pk: r.publishableKey,
|
|
1638
1382
|
baseUrl: r.baseUrl,
|
|
1639
1383
|
clientToken: (w == null ? void 0 : w.clientToken) ?? ""
|
|
1640
1384
|
});
|
|
1641
|
-
if (
|
|
1642
|
-
const
|
|
1643
|
-
stream:
|
|
1385
|
+
if (A.type === "success") {
|
|
1386
|
+
const M = {
|
|
1387
|
+
stream: A.stream,
|
|
1644
1388
|
createdAt: Date.now()
|
|
1645
1389
|
};
|
|
1646
|
-
return
|
|
1647
|
-
const
|
|
1648
|
-
return
|
|
1649
|
-
}),
|
|
1390
|
+
return i((P) => {
|
|
1391
|
+
const C = [...P, M];
|
|
1392
|
+
return Pe(C);
|
|
1393
|
+
}), m.current = null, A.stream;
|
|
1650
1394
|
} else
|
|
1651
|
-
throw
|
|
1395
|
+
throw m.current = null, new Error("Failed to create stream");
|
|
1652
1396
|
})();
|
|
1653
|
-
return
|
|
1397
|
+
return m.current = I, I;
|
|
1654
1398
|
},
|
|
1655
|
-
[r,
|
|
1399
|
+
[r, o]
|
|
1656
1400
|
);
|
|
1657
|
-
if (
|
|
1658
|
-
return /* @__PURE__ */
|
|
1401
|
+
if (l)
|
|
1402
|
+
return /* @__PURE__ */ x("div", { children: [
|
|
1659
1403
|
"Fency error: ",
|
|
1660
|
-
|
|
1404
|
+
l.message
|
|
1661
1405
|
] });
|
|
1662
1406
|
if (!r)
|
|
1663
1407
|
return null;
|
|
1664
|
-
const y =
|
|
1408
|
+
const y = o.length > 0 ? o[o.length - 1] : null, T = {
|
|
1665
1409
|
fency: r,
|
|
1666
1410
|
loading: g,
|
|
1667
|
-
error:
|
|
1668
|
-
activeStreams:
|
|
1411
|
+
error: l,
|
|
1412
|
+
activeStreams: o,
|
|
1669
1413
|
latestStream: y,
|
|
1670
|
-
eventManager:
|
|
1671
|
-
getOrCreateStream:
|
|
1414
|
+
eventManager: u.current,
|
|
1415
|
+
getOrCreateStream: S
|
|
1672
1416
|
};
|
|
1673
|
-
return /* @__PURE__ */
|
|
1417
|
+
return /* @__PURE__ */ c(_.Provider, { value: T, children: n });
|
|
1674
1418
|
}
|
|
1675
1419
|
export {
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
xe as StreamingMemoryTypeChatCompletionSourcesResult,
|
|
1689
|
-
be as StructuredChatCompletionJson,
|
|
1690
|
-
Be as useAgentTasks,
|
|
1420
|
+
Be as AgentTaskProgress,
|
|
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,
|
|
1691
1432
|
N as useFencyContext,
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1433
|
+
We as useFencyEventSource,
|
|
1434
|
+
$e as usePaginatedQuery,
|
|
1435
|
+
oe as useStream
|
|
1695
1436
|
};
|