@fencyai/react 0.1.111 → 0.1.113
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/{chat → agent-task}/AgentTaskProgress.d.ts +2 -3
- package/dist/agent-task/AgentTaskProgressSimple.d.ts +5 -0
- package/dist/agent-task/AgentTaskProgressVerbose.d.ts +9 -0
- package/dist/agent-task/ProgressViewItem.d.ts +9 -0
- package/dist/agent-task/data-types/GenericAgentTaskExecution.d.ts +11 -0
- package/dist/agent-task/data-types/GenericAgentTaskFinalResponse.d.ts +13 -0
- package/dist/agent-task/data-types/GenericAgentTaskReasoning.d.ts +11 -0
- package/dist/agent-task/data-types/StreamingChatCompletionResponse.d.ts +8 -0
- package/dist/assets/index.css +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.js +709 -755
- package/dist/provider/FencyProvider.d.ts +1 -1
- package/dist/types/{StreamingAgentTask.d.ts → AgentTask.d.ts} +6 -4
- package/dist/types/{StreamingAgentTaskData.d.ts → AgentTaskData.d.ts} +1 -1
- package/dist/types/AgentTaskEventData.d.ts +14 -0
- package/dist/types/CreateAgentTaskParams.d.ts +7 -4
- package/dist/types/FencyContext.d.ts +1 -4
- package/dist/types/FencyProviderProps.d.ts +3 -0
- package/dist/types/StreamData.d.ts +2 -4
- package/dist/types/UseAgentTasks.d.ts +3 -3
- package/dist/types/UseAgentTasksProps.d.ts +1 -5
- package/dist/types/UseStreamProps.d.ts +0 -4
- package/dist/types/index.d.ts +2 -2
- package/package.json +4 -4
- package/dist/chat/ChatResponse.d.ts +0 -22
- package/dist/chat/ChatResponseComplete.d.ts +0 -10
- package/dist/chat/ChatResponseLoading.d.ts +0 -8
- package/dist/chat/ChatResponseThinking.d.ts +0 -8
- package/dist/chat/EditableContent.d.ts +0 -11
- package/dist/chat/GhostWrapper.d.ts +0 -10
- /package/dist/{chat → agent-task}/ShimmeringText.d.ts +0 -0
- /package/dist/{chat → agent-task}/hooks/useContentEditable.d.ts +0 -0
- /package/dist/{chat → agent-task}/hooks/useMentionParser.d.ts +0 -0
- /package/dist/{chat → agent-task}/hooks/useMentionRenderer.d.ts +0 -0
- /package/dist/{chat → agent-task}/hooks/useMentionState.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,102 +1,100 @@
|
|
|
1
|
-
import { createAgentTask as
|
|
2
|
-
import { createContext as J, useContext as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { Prism as
|
|
7
|
-
import
|
|
8
|
-
import './assets/index.css';const
|
|
1
|
+
import { createAgentTask as q, createFileDownloadLink as V, createStream as X } from "@fencyai/js";
|
|
2
|
+
import { createContext as J, useContext as Y, useState as w, useRef as P, useEffect as T, useCallback as U, useMemo as L } from "react";
|
|
3
|
+
import { jsx as g, jsxs as E } from "react/jsx-runtime";
|
|
4
|
+
import { useInView as Q, motion as A, AnimatePresence as W } from "motion/react";
|
|
5
|
+
import D from "react-markdown";
|
|
6
|
+
import { Prism as M } from "react-syntax-highlighter";
|
|
7
|
+
import B from "remark-gfm";
|
|
8
|
+
import './assets/index.css';const j = J(
|
|
9
9
|
void 0
|
|
10
10
|
);
|
|
11
11
|
function F() {
|
|
12
|
-
const e =
|
|
12
|
+
const e = Y(j);
|
|
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 Z = (e) => {
|
|
18
18
|
try {
|
|
19
19
|
const t = JSON.parse(e);
|
|
20
|
-
return
|
|
20
|
+
return p(t);
|
|
21
21
|
} catch (t) {
|
|
22
22
|
return console.error("Error parsing message:", t), null;
|
|
23
23
|
}
|
|
24
|
-
},
|
|
24
|
+
}, p = (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 ee(e);
|
|
30
30
|
case "StreamNotFound":
|
|
31
|
-
return
|
|
31
|
+
return te(e);
|
|
32
32
|
case "AgentTaskProgressItemUpdated":
|
|
33
|
-
return
|
|
33
|
+
return ne(e);
|
|
34
34
|
}
|
|
35
35
|
return null;
|
|
36
|
-
},
|
|
36
|
+
}, ee = (e) => ({
|
|
37
37
|
type: "StreamTimeout",
|
|
38
38
|
streamId: e.streamId,
|
|
39
39
|
timestamp: e.timestamp
|
|
40
|
-
}),
|
|
40
|
+
}), te = (e) => ({
|
|
41
41
|
type: "StreamNotFound",
|
|
42
42
|
streamId: e.streamId,
|
|
43
43
|
timestamp: e.timestamp
|
|
44
|
-
}),
|
|
44
|
+
}), ne = (e) => ({
|
|
45
45
|
type: "AgentTaskProgressItemUpdated",
|
|
46
46
|
streamId: e.streamId,
|
|
47
47
|
agentTaskId: e.agentTaskId,
|
|
48
48
|
progressItemId: e.progressItemId,
|
|
49
|
-
title: e.title,
|
|
50
49
|
timestamp: e.timestamp,
|
|
51
50
|
createdAt: e.createdAt,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const t = F(), [n, o] = v(null), a = E(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
|
|
51
|
+
data: JSON.parse(e.data)
|
|
52
|
+
}), re = (e) => {
|
|
53
|
+
const t = F(), [r, n] = w(null), a = P(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
|
|
56
54
|
return T(() => {
|
|
57
55
|
if (!t.eventManager) return;
|
|
58
|
-
const
|
|
59
|
-
onMessage: (
|
|
60
|
-
var s,
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
switch (
|
|
56
|
+
const c = {
|
|
57
|
+
onMessage: (o, i) => {
|
|
58
|
+
var s, d, f, y, S, b, h, k, I, C;
|
|
59
|
+
const m = Z(o);
|
|
60
|
+
if (m)
|
|
61
|
+
switch (m.type) {
|
|
64
62
|
case "NewChatCompletionStreamChunk":
|
|
65
|
-
(s = e == null ? void 0 : e.onNewChatCompletionStreamChunk) == null || s.call(e,
|
|
63
|
+
(s = e == null ? void 0 : e.onNewChatCompletionStreamChunk) == null || s.call(e, m);
|
|
66
64
|
break;
|
|
67
65
|
case "ChatCompletionStreamCompleted":
|
|
68
|
-
(
|
|
66
|
+
(d = e == null ? void 0 : e.onChatCompletionStreamCompleted) == null || d.call(e, m);
|
|
69
67
|
break;
|
|
70
68
|
case "StreamTimeout":
|
|
71
|
-
(
|
|
69
|
+
(f = e == null ? void 0 : e.onStreamTimeout) == null || f.call(e, m);
|
|
72
70
|
break;
|
|
73
71
|
case "StreamNotFound":
|
|
74
|
-
(
|
|
72
|
+
(y = e == null ? void 0 : e.onStreamNotFound) == null || y.call(e, m);
|
|
75
73
|
break;
|
|
76
74
|
case "FileUploadCompleted":
|
|
77
|
-
(
|
|
75
|
+
(S = e == null ? void 0 : e.onFileUploadCompleted) == null || S.call(e, m);
|
|
78
76
|
break;
|
|
79
77
|
case "FileTextContentReady":
|
|
80
|
-
(
|
|
78
|
+
(b = e == null ? void 0 : e.onFileTextContentReady) == null || b.call(e, m);
|
|
81
79
|
break;
|
|
82
80
|
case "WebsiteHtmlContentReady":
|
|
83
|
-
(
|
|
81
|
+
(h = e == null ? void 0 : e.onWebsiteHtmlContentReady) == null || h.call(e, m);
|
|
84
82
|
break;
|
|
85
83
|
case "WebsiteTextContentReady":
|
|
86
|
-
(
|
|
84
|
+
(k = e == null ? void 0 : e.onWebsiteTextContentReady) == null || k.call(e, m);
|
|
87
85
|
break;
|
|
88
86
|
case "FileSearchIndexReady":
|
|
89
|
-
(I = e == null ? void 0 : e.onFileSearchIndexReady) == null || I.call(e,
|
|
87
|
+
(I = e == null ? void 0 : e.onFileSearchIndexReady) == null || I.call(e, m);
|
|
90
88
|
break;
|
|
91
89
|
case "AgentTaskProgressItemUpdated":
|
|
92
|
-
(C = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || C.call(e,
|
|
90
|
+
(C = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || C.call(e, m);
|
|
93
91
|
break;
|
|
94
92
|
}
|
|
95
93
|
},
|
|
96
|
-
onError: (
|
|
94
|
+
onError: (o) => {
|
|
97
95
|
var i;
|
|
98
96
|
(i = e == null ? void 0 : e.onStreamError) == null || i.call(e, {
|
|
99
|
-
streamId:
|
|
97
|
+
streamId: o,
|
|
100
98
|
error: {
|
|
101
99
|
code: "UnknownError",
|
|
102
100
|
message: "Unknown error in useStream"
|
|
@@ -106,130 +104,114 @@ const p = (e) => {
|
|
|
106
104
|
};
|
|
107
105
|
return t.eventManager.subscribe(
|
|
108
106
|
a.current,
|
|
109
|
-
|
|
107
|
+
c
|
|
110
108
|
);
|
|
111
109
|
}, [t.eventManager, e]), {
|
|
112
110
|
createStream: async () => {
|
|
113
111
|
try {
|
|
114
|
-
const
|
|
115
|
-
return
|
|
112
|
+
const c = await t.getOrCreateStream(3e4);
|
|
113
|
+
return n(c), {
|
|
116
114
|
type: "success",
|
|
117
|
-
stream:
|
|
115
|
+
stream: c
|
|
118
116
|
};
|
|
119
|
-
} catch (
|
|
117
|
+
} catch (c) {
|
|
120
118
|
return {
|
|
121
119
|
type: "error",
|
|
122
120
|
error: {
|
|
123
121
|
code: "UnknownError",
|
|
124
|
-
message:
|
|
122
|
+
message: c instanceof Error ? c.message : "Failed to create stream"
|
|
125
123
|
}
|
|
126
124
|
};
|
|
127
125
|
}
|
|
128
126
|
},
|
|
129
|
-
stream:
|
|
127
|
+
stream: r
|
|
130
128
|
};
|
|
131
|
-
},
|
|
132
|
-
const t = F(), [
|
|
133
|
-
|
|
134
|
-
onAgentTaskProgressItemUpdated: (r) => {
|
|
129
|
+
}, Re = (e) => {
|
|
130
|
+
const t = F(), [r, n] = w([]), a = P(/* @__PURE__ */ new Set()), { createStream: u } = re({
|
|
131
|
+
onAgentTaskProgressItemUpdated: (o) => {
|
|
135
132
|
var i;
|
|
136
|
-
a.current.has(
|
|
137
|
-
|
|
138
|
-
(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
{
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
(m) => m.progressItemId === r.progressItemId ? r : m
|
|
148
|
-
)
|
|
149
|
-
}
|
|
150
|
-
] : [
|
|
151
|
-
...d.filter(
|
|
152
|
-
(m) => m.streamId !== r.streamId
|
|
153
|
-
),
|
|
154
|
-
{
|
|
155
|
-
...s,
|
|
156
|
-
progressItems: [
|
|
157
|
-
...s.progressItems,
|
|
158
|
-
r
|
|
159
|
-
]
|
|
160
|
-
}
|
|
161
|
-
] : d;
|
|
162
|
-
}));
|
|
133
|
+
a.current.has(o.agentTaskId) && ((i = e.onAgentTaskProgressItemUpdated) == null || i.call(e, o), n(
|
|
134
|
+
(m) => m.map((s) => {
|
|
135
|
+
if (s.streamId !== o.streamId) return s;
|
|
136
|
+
const f = s.progressItems.some(
|
|
137
|
+
(y) => y.progressItemId === o.progressItemId
|
|
138
|
+
) ? s.progressItems.map(
|
|
139
|
+
(y) => y.progressItemId === o.progressItemId ? o : y
|
|
140
|
+
) : [...s.progressItems, o];
|
|
141
|
+
return { ...s, progressItems: f };
|
|
142
|
+
})
|
|
143
|
+
));
|
|
163
144
|
},
|
|
164
|
-
onStreamError: (
|
|
145
|
+
onStreamError: (o) => {
|
|
165
146
|
var i;
|
|
166
|
-
(i = e == null ? void 0 : e.onStreamError) == null || i.call(e,
|
|
167
|
-
const s =
|
|
147
|
+
(i = e == null ? void 0 : e.onStreamError) == null || i.call(e, o), n((m) => {
|
|
148
|
+
const s = m.find((d) => d.streamId === o.streamId);
|
|
168
149
|
return s ? [
|
|
169
|
-
...
|
|
150
|
+
...m.filter((d) => d.streamId !== o.streamId),
|
|
170
151
|
{
|
|
171
152
|
...s,
|
|
172
153
|
loading: !1,
|
|
173
|
-
error:
|
|
154
|
+
error: o.error
|
|
174
155
|
}
|
|
175
|
-
] :
|
|
156
|
+
] : m;
|
|
176
157
|
});
|
|
177
158
|
},
|
|
178
|
-
onStreamNotFound: (
|
|
159
|
+
onStreamNotFound: (o) => {
|
|
179
160
|
var i;
|
|
180
|
-
(i = e == null ? void 0 : e.onStreamNotFound) == null || i.call(e,
|
|
161
|
+
(i = e == null ? void 0 : e.onStreamNotFound) == null || i.call(e, o);
|
|
181
162
|
},
|
|
182
|
-
onStreamTimeout: (
|
|
163
|
+
onStreamTimeout: (o) => {
|
|
183
164
|
var i;
|
|
184
|
-
(i = e == null ? void 0 : e.onStreamTimeout) == null || i.call(e,
|
|
165
|
+
(i = e == null ? void 0 : e.onStreamTimeout) == null || i.call(e, o);
|
|
185
166
|
}
|
|
186
|
-
}),
|
|
187
|
-
async (
|
|
188
|
-
const i = await
|
|
167
|
+
}), c = U(
|
|
168
|
+
async (o) => {
|
|
169
|
+
const i = await u();
|
|
189
170
|
if (i.type === "success") {
|
|
190
|
-
|
|
191
|
-
...
|
|
171
|
+
n([
|
|
172
|
+
...r,
|
|
192
173
|
{
|
|
193
174
|
streamId: i.stream.id,
|
|
194
175
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
195
|
-
|
|
176
|
+
confirmedData: null,
|
|
196
177
|
error: null,
|
|
197
|
-
|
|
178
|
+
params: o,
|
|
198
179
|
progressItems: [],
|
|
199
180
|
loading: !0,
|
|
200
181
|
doneStreaming: !1
|
|
201
182
|
}
|
|
202
183
|
]);
|
|
203
|
-
const { clientToken:
|
|
184
|
+
const { clientToken: m } = await e.fetchCreateAgentTaskClientToken(o.type), s = await q({
|
|
204
185
|
pk: t.fency.publishableKey,
|
|
205
186
|
baseUrl: t.fency.baseUrl,
|
|
206
|
-
clientToken:
|
|
187
|
+
clientToken: m,
|
|
207
188
|
streamToken: i.stream.token,
|
|
208
189
|
request: {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
jsonSchema: r.jsonSchema,
|
|
212
|
-
todos: r.todos
|
|
190
|
+
genericTask: o.type === "genericAgentTask" ? { queryText: o.query, jsonSchema: o.jsonSchema } : void 0,
|
|
191
|
+
streamingChatCompletionTask: o.type === "streamingChatCompletion" ? { prompt: o.prompt } : void 0
|
|
213
192
|
}
|
|
214
193
|
});
|
|
215
194
|
if (s.type === "success" && s.agentTask)
|
|
216
|
-
return a.current.add(
|
|
217
|
-
|
|
218
|
-
|
|
195
|
+
return a.current.add(
|
|
196
|
+
s.agentTask.id
|
|
197
|
+
), n((d) => [
|
|
198
|
+
...d.filter(
|
|
199
|
+
(f) => f.streamId !== i.stream.id
|
|
219
200
|
),
|
|
220
201
|
{
|
|
221
202
|
streamId: i.stream.id,
|
|
222
203
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
createdAt: s.agentTask.createdAt,
|
|
226
|
-
streamId: i.stream.id
|
|
227
|
-
},
|
|
204
|
+
taskId: s.agentTask.id,
|
|
205
|
+
createdAt: s.agentTask.createdAt,
|
|
228
206
|
error: null,
|
|
229
|
-
|
|
207
|
+
params: o,
|
|
230
208
|
progressItems: [],
|
|
231
209
|
doneStreaming: !1,
|
|
232
|
-
loading: !0
|
|
210
|
+
loading: !0,
|
|
211
|
+
confirmedData: {
|
|
212
|
+
taskId: s.agentTask.id,
|
|
213
|
+
createdAt: s.agentTask.createdAt
|
|
214
|
+
}
|
|
233
215
|
}
|
|
234
216
|
]), {
|
|
235
217
|
type: "success",
|
|
@@ -237,126 +219,126 @@ const p = (e) => {
|
|
|
237
219
|
agentTaskId: s.agentTask.id
|
|
238
220
|
};
|
|
239
221
|
if (s.type === "error")
|
|
240
|
-
return
|
|
241
|
-
...
|
|
242
|
-
(
|
|
222
|
+
return n((d) => [
|
|
223
|
+
...d.filter(
|
|
224
|
+
(f) => f.streamId !== i.stream.id
|
|
243
225
|
),
|
|
244
226
|
{
|
|
245
227
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
246
228
|
streamId: i.stream.id,
|
|
247
|
-
|
|
229
|
+
params: o,
|
|
248
230
|
error: s.error,
|
|
249
231
|
progressItems: [],
|
|
250
232
|
loading: !1,
|
|
251
233
|
doneStreaming: !1,
|
|
252
|
-
|
|
234
|
+
confirmedData: null
|
|
253
235
|
}
|
|
254
236
|
]), {
|
|
255
237
|
type: "error",
|
|
256
238
|
error: s.error
|
|
257
239
|
};
|
|
258
240
|
{
|
|
259
|
-
const
|
|
241
|
+
const d = {
|
|
260
242
|
message: "No response received",
|
|
261
243
|
code: "UnknownError"
|
|
262
244
|
};
|
|
263
|
-
return
|
|
264
|
-
...
|
|
265
|
-
(
|
|
245
|
+
return n((f) => [
|
|
246
|
+
...f.filter(
|
|
247
|
+
(y) => y.streamId !== i.stream.id
|
|
266
248
|
),
|
|
267
249
|
{
|
|
268
250
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
269
251
|
streamId: i.stream.id,
|
|
270
|
-
error:
|
|
271
|
-
|
|
252
|
+
error: d,
|
|
253
|
+
params: o,
|
|
272
254
|
progressItems: [],
|
|
273
255
|
loading: !1,
|
|
274
256
|
doneStreaming: !1,
|
|
275
|
-
|
|
257
|
+
confirmedData: null
|
|
276
258
|
}
|
|
277
259
|
]), {
|
|
278
260
|
type: "error",
|
|
279
|
-
error:
|
|
261
|
+
error: d
|
|
280
262
|
};
|
|
281
263
|
}
|
|
282
264
|
} else
|
|
283
265
|
return console.error(i.error), i;
|
|
284
266
|
},
|
|
285
|
-
[t,
|
|
286
|
-
),
|
|
267
|
+
[t, r, u]
|
|
268
|
+
), l = L(() => r.sort((o, i) => new Date(i.triggeredAt).getTime() - new Date(o.triggeredAt).getTime())[0], [r]);
|
|
287
269
|
return T(() => () => {
|
|
288
270
|
a.current.clear();
|
|
289
271
|
}, []), {
|
|
290
|
-
agentTasks:
|
|
291
|
-
createAgentTask:
|
|
292
|
-
latest:
|
|
272
|
+
agentTasks: r,
|
|
273
|
+
createAgentTask: c,
|
|
274
|
+
latest: l
|
|
293
275
|
};
|
|
294
276
|
};
|
|
295
277
|
async function ae(e, t) {
|
|
296
|
-
const
|
|
297
|
-
let
|
|
298
|
-
for (; !(
|
|
299
|
-
t(
|
|
278
|
+
const r = e.getReader();
|
|
279
|
+
let n;
|
|
280
|
+
for (; !(n = await r.read()).done; )
|
|
281
|
+
t(n.value);
|
|
300
282
|
}
|
|
301
|
-
function
|
|
302
|
-
let t,
|
|
303
|
-
return function(
|
|
304
|
-
t === void 0 ? (t =
|
|
305
|
-
const
|
|
306
|
-
let
|
|
307
|
-
for (;
|
|
308
|
-
a && (t[
|
|
283
|
+
function oe(e) {
|
|
284
|
+
let t, r, n, a = !1;
|
|
285
|
+
return function(c) {
|
|
286
|
+
t === void 0 ? (t = c, r = 0, n = -1) : t = se(t, c);
|
|
287
|
+
const l = t.length;
|
|
288
|
+
let o = 0;
|
|
289
|
+
for (; r < l; ) {
|
|
290
|
+
a && (t[r] === 10 && (o = ++r), a = !1);
|
|
309
291
|
let i = -1;
|
|
310
|
-
for (;
|
|
311
|
-
switch (t[
|
|
292
|
+
for (; r < l && i === -1; ++r)
|
|
293
|
+
switch (t[r]) {
|
|
312
294
|
case 58:
|
|
313
|
-
|
|
295
|
+
n === -1 && (n = r - o);
|
|
314
296
|
break;
|
|
315
297
|
case 13:
|
|
316
298
|
a = !0;
|
|
317
299
|
case 10:
|
|
318
|
-
i =
|
|
300
|
+
i = r;
|
|
319
301
|
break;
|
|
320
302
|
}
|
|
321
303
|
if (i === -1)
|
|
322
304
|
break;
|
|
323
|
-
e(t.subarray(
|
|
305
|
+
e(t.subarray(o, i), n), o = r, n = -1;
|
|
324
306
|
}
|
|
325
|
-
|
|
307
|
+
o === l ? t = void 0 : o !== 0 && (t = t.subarray(o), r -= o);
|
|
326
308
|
};
|
|
327
309
|
}
|
|
328
|
-
function
|
|
329
|
-
let
|
|
310
|
+
function ie(e, t, r) {
|
|
311
|
+
let n = H();
|
|
330
312
|
const a = new TextDecoder();
|
|
331
|
-
return function(
|
|
332
|
-
if (
|
|
333
|
-
|
|
334
|
-
else if (
|
|
335
|
-
const
|
|
336
|
-
switch (
|
|
313
|
+
return function(c, l) {
|
|
314
|
+
if (c.length === 0)
|
|
315
|
+
r == null || r(n), n = H();
|
|
316
|
+
else if (l > 0) {
|
|
317
|
+
const o = a.decode(c.subarray(0, l)), i = l + (c[l + 1] === 32 ? 2 : 1), m = a.decode(c.subarray(i));
|
|
318
|
+
switch (o) {
|
|
337
319
|
case "data":
|
|
338
|
-
|
|
339
|
-
` +
|
|
320
|
+
n.data = n.data ? n.data + `
|
|
321
|
+
` + m : m;
|
|
340
322
|
break;
|
|
341
323
|
case "event":
|
|
342
|
-
|
|
324
|
+
n.event = m;
|
|
343
325
|
break;
|
|
344
326
|
case "id":
|
|
345
|
-
e(
|
|
327
|
+
e(n.id = m);
|
|
346
328
|
break;
|
|
347
329
|
case "retry":
|
|
348
|
-
const s = parseInt(
|
|
349
|
-
isNaN(s) || t(
|
|
330
|
+
const s = parseInt(m, 10);
|
|
331
|
+
isNaN(s) || t(n.retry = s);
|
|
350
332
|
break;
|
|
351
333
|
}
|
|
352
334
|
}
|
|
353
335
|
};
|
|
354
336
|
}
|
|
355
|
-
function
|
|
356
|
-
const
|
|
357
|
-
return
|
|
337
|
+
function se(e, t) {
|
|
338
|
+
const r = new Uint8Array(e.length + t.length);
|
|
339
|
+
return r.set(e), r.set(t, e.length), r;
|
|
358
340
|
}
|
|
359
|
-
function
|
|
341
|
+
function H() {
|
|
360
342
|
return {
|
|
361
343
|
data: "",
|
|
362
344
|
event: "",
|
|
@@ -364,70 +346,70 @@ function _() {
|
|
|
364
346
|
retry: void 0
|
|
365
347
|
};
|
|
366
348
|
}
|
|
367
|
-
var
|
|
368
|
-
var
|
|
369
|
-
for (var
|
|
349
|
+
var ce = function(e, t) {
|
|
350
|
+
var r = {};
|
|
351
|
+
for (var n in e) Object.prototype.hasOwnProperty.call(e, n) && t.indexOf(n) < 0 && (r[n] = e[n]);
|
|
370
352
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
371
|
-
for (var a = 0,
|
|
372
|
-
t.indexOf(
|
|
373
|
-
return
|
|
353
|
+
for (var a = 0, n = Object.getOwnPropertySymbols(e); a < n.length; a++)
|
|
354
|
+
t.indexOf(n[a]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[a]) && (r[n[a]] = e[n[a]]);
|
|
355
|
+
return r;
|
|
374
356
|
};
|
|
375
|
-
const
|
|
376
|
-
function
|
|
377
|
-
var { signal:
|
|
378
|
-
return new Promise((s,
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
let
|
|
382
|
-
function
|
|
383
|
-
|
|
357
|
+
const O = "text/event-stream", le = 1e3, G = "last-event-id";
|
|
358
|
+
function $(e, t) {
|
|
359
|
+
var { signal: r, headers: n, onopen: a, onmessage: u, onclose: c, onerror: l, openWhenHidden: o, fetch: i } = t, m = ce(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
360
|
+
return new Promise((s, d) => {
|
|
361
|
+
const f = Object.assign({}, n);
|
|
362
|
+
f.accept || (f.accept = O);
|
|
363
|
+
let y;
|
|
364
|
+
function S() {
|
|
365
|
+
y.abort(), document.hidden || x();
|
|
384
366
|
}
|
|
385
|
-
|
|
386
|
-
let
|
|
387
|
-
function
|
|
388
|
-
document.removeEventListener("visibilitychange",
|
|
367
|
+
o || document.addEventListener("visibilitychange", S);
|
|
368
|
+
let b = le, h = 0;
|
|
369
|
+
function k() {
|
|
370
|
+
document.removeEventListener("visibilitychange", S), window.clearTimeout(h), y.abort();
|
|
389
371
|
}
|
|
390
|
-
|
|
391
|
-
|
|
372
|
+
r == null || r.addEventListener("abort", () => {
|
|
373
|
+
k(), s();
|
|
392
374
|
});
|
|
393
|
-
const I = i ?? window.fetch, C = a ??
|
|
394
|
-
async function
|
|
395
|
-
var
|
|
396
|
-
|
|
375
|
+
const I = i ?? window.fetch, C = a ?? de;
|
|
376
|
+
async function x() {
|
|
377
|
+
var N;
|
|
378
|
+
y = new AbortController();
|
|
397
379
|
try {
|
|
398
|
-
const
|
|
399
|
-
await C(
|
|
400
|
-
|
|
401
|
-
}, (
|
|
402
|
-
|
|
403
|
-
},
|
|
404
|
-
} catch (
|
|
405
|
-
if (!
|
|
380
|
+
const R = await I(e, Object.assign(Object.assign({}, m), { headers: f, signal: y.signal }));
|
|
381
|
+
await C(R), await ae(R.body, oe(ie((v) => {
|
|
382
|
+
v ? f[G] = v : delete f[G];
|
|
383
|
+
}, (v) => {
|
|
384
|
+
b = v;
|
|
385
|
+
}, u))), c == null || c(), k(), s();
|
|
386
|
+
} catch (R) {
|
|
387
|
+
if (!y.signal.aborted)
|
|
406
388
|
try {
|
|
407
|
-
const
|
|
408
|
-
window.clearTimeout(
|
|
409
|
-
} catch (
|
|
410
|
-
|
|
389
|
+
const v = (N = l == null ? void 0 : l(R)) !== null && N !== void 0 ? N : b;
|
|
390
|
+
window.clearTimeout(h), h = window.setTimeout(x, v);
|
|
391
|
+
} catch (v) {
|
|
392
|
+
k(), d(v);
|
|
411
393
|
}
|
|
412
394
|
}
|
|
413
395
|
}
|
|
414
|
-
|
|
396
|
+
x();
|
|
415
397
|
});
|
|
416
398
|
}
|
|
417
|
-
function
|
|
399
|
+
function de(e) {
|
|
418
400
|
const t = e.headers.get("content-type");
|
|
419
|
-
if (!(t != null && t.startsWith(
|
|
420
|
-
throw new Error(`Expected content-type to be ${
|
|
401
|
+
if (!(t != null && t.startsWith(O)))
|
|
402
|
+
throw new Error(`Expected content-type to be ${O}, Actual: ${t}`);
|
|
421
403
|
}
|
|
422
|
-
function
|
|
423
|
-
const [t,
|
|
404
|
+
function Ne(e) {
|
|
405
|
+
const [t, r] = w(null);
|
|
424
406
|
return T(() => {
|
|
425
407
|
if (!t)
|
|
426
408
|
return;
|
|
427
|
-
const
|
|
428
|
-
return
|
|
409
|
+
const n = new AbortController();
|
|
410
|
+
return $(t, {
|
|
429
411
|
headers: e == null ? void 0 : e.headers,
|
|
430
|
-
signal:
|
|
412
|
+
signal: n.signal,
|
|
431
413
|
async onopen(a) {
|
|
432
414
|
if (!a.ok && a.status >= 400 && a.status < 500 && a.status !== 429)
|
|
433
415
|
throw new Error(`Client error ${a.status}`);
|
|
@@ -435,59 +417,59 @@ function xe(e) {
|
|
|
435
417
|
onmessage(a) {
|
|
436
418
|
a.data && (e == null || e.onMessage({
|
|
437
419
|
url: t,
|
|
438
|
-
data:
|
|
420
|
+
data: K(a.data)
|
|
439
421
|
}));
|
|
440
422
|
},
|
|
441
423
|
onerror(a) {
|
|
442
|
-
throw console.error("EventSource error:", a), e == null || e.onError(t),
|
|
424
|
+
throw console.error("EventSource error:", a), e == null || e.onError(t), r(null), a;
|
|
443
425
|
},
|
|
444
426
|
onclose() {
|
|
445
427
|
}
|
|
446
428
|
}), () => {
|
|
447
|
-
|
|
429
|
+
n.abort();
|
|
448
430
|
};
|
|
449
431
|
}, [t, e == null ? void 0 : e.headers]), {
|
|
450
|
-
setSourceUrl:
|
|
432
|
+
setSourceUrl: r,
|
|
451
433
|
sourceUrl: t
|
|
452
434
|
};
|
|
453
435
|
}
|
|
454
|
-
function
|
|
455
|
-
const t = atob(e),
|
|
456
|
-
for (let
|
|
457
|
-
n
|
|
458
|
-
return new TextDecoder("utf-8").decode(
|
|
436
|
+
function K(e) {
|
|
437
|
+
const t = atob(e), r = new Uint8Array(t.length);
|
|
438
|
+
for (let n = 0; n < t.length; n++)
|
|
439
|
+
r[n] = t.charCodeAt(n);
|
|
440
|
+
return new TextDecoder("utf-8").decode(r);
|
|
459
441
|
}
|
|
460
|
-
function
|
|
461
|
-
const [
|
|
442
|
+
function Fe(e, t) {
|
|
443
|
+
const [r, n] = w(
|
|
462
444
|
null
|
|
463
|
-
), [a,
|
|
445
|
+
), [a, u] = w(
|
|
464
446
|
null
|
|
465
|
-
),
|
|
466
|
-
const
|
|
467
|
-
pk:
|
|
468
|
-
clientToken:
|
|
469
|
-
streamToken:
|
|
447
|
+
), c = F(), l = async (s) => {
|
|
448
|
+
const d = await s.fetchTokens(), { fetchTokens: f, nextPageToken: y, previousPageToken: S, ...b } = s, h = await e({
|
|
449
|
+
pk: c.fency.publishableKey,
|
|
450
|
+
clientToken: d.clientToken,
|
|
451
|
+
streamToken: d.streamToken,
|
|
470
452
|
request: {
|
|
471
|
-
...
|
|
453
|
+
...b,
|
|
472
454
|
limit: (t == null ? void 0 : t.pageSize) ?? 50,
|
|
473
455
|
pagination: {
|
|
474
|
-
nextPageToken:
|
|
475
|
-
previousPageToken:
|
|
456
|
+
nextPageToken: y,
|
|
457
|
+
previousPageToken: S
|
|
476
458
|
}
|
|
477
459
|
},
|
|
478
|
-
baseUrl:
|
|
460
|
+
baseUrl: c.fency.baseUrl
|
|
479
461
|
});
|
|
480
|
-
return
|
|
462
|
+
return h.type === "success" && h.items && h.pagination ? {
|
|
481
463
|
type: "success",
|
|
482
464
|
page: {
|
|
483
|
-
items:
|
|
484
|
-
hasNextPage:
|
|
485
|
-
hasPreviousPage:
|
|
486
|
-
pagination:
|
|
465
|
+
items: h.items,
|
|
466
|
+
hasNextPage: h.pagination.nextPageToken != null,
|
|
467
|
+
hasPreviousPage: h.pagination.previousPageToken != null,
|
|
468
|
+
pagination: h.pagination
|
|
487
469
|
}
|
|
488
470
|
} : {
|
|
489
471
|
type: "error",
|
|
490
|
-
error:
|
|
472
|
+
error: h.error ?? {
|
|
491
473
|
code: "UNKNOWN_ERROR",
|
|
492
474
|
message: "An unknown error occurred"
|
|
493
475
|
}
|
|
@@ -495,12 +477,12 @@ function Pe(e, t) {
|
|
|
495
477
|
};
|
|
496
478
|
return {
|
|
497
479
|
fetchFirstPage: async (s) => {
|
|
498
|
-
const
|
|
480
|
+
const d = await l({
|
|
499
481
|
...s,
|
|
500
482
|
nextPageToken: void 0,
|
|
501
483
|
previousPageToken: void 0
|
|
502
484
|
});
|
|
503
|
-
return
|
|
485
|
+
return d.type === "success" && (u(d.page), n(s)), d;
|
|
504
486
|
},
|
|
505
487
|
fetchNextPage: async (s) => {
|
|
506
488
|
if (a == null)
|
|
@@ -519,12 +501,12 @@ function Pe(e, t) {
|
|
|
519
501
|
message: "No next page"
|
|
520
502
|
}
|
|
521
503
|
};
|
|
522
|
-
const
|
|
504
|
+
const d = await l({
|
|
523
505
|
...s,
|
|
524
506
|
nextPageToken: a.pagination.nextPageToken,
|
|
525
507
|
previousPageToken: void 0
|
|
526
508
|
});
|
|
527
|
-
return
|
|
509
|
+
return d.type === "success" && (u(d.page), n(s)), d;
|
|
528
510
|
},
|
|
529
511
|
fetchPreviousPage: async (s) => {
|
|
530
512
|
if (a == null)
|
|
@@ -543,24 +525,186 @@ function Pe(e, t) {
|
|
|
543
525
|
message: "No previous page"
|
|
544
526
|
}
|
|
545
527
|
};
|
|
546
|
-
const
|
|
528
|
+
const d = await l({
|
|
547
529
|
...s,
|
|
548
530
|
nextPageToken: void 0,
|
|
549
531
|
previousPageToken: a.pagination.previousPageToken
|
|
550
532
|
});
|
|
551
|
-
return
|
|
533
|
+
return d.type === "success" && (u(d.page), n(s)), d;
|
|
552
534
|
},
|
|
553
|
-
refetchCurrentPage: async () =>
|
|
535
|
+
refetchCurrentPage: async () => r == null ? {
|
|
554
536
|
type: "error",
|
|
555
537
|
error: {
|
|
556
538
|
code: "NO_CURRENT_PAGE",
|
|
557
539
|
message: "No current page, please call fetchFirstPage first."
|
|
558
540
|
}
|
|
559
|
-
} :
|
|
541
|
+
} : l(r),
|
|
560
542
|
currentPage: a
|
|
561
543
|
};
|
|
562
544
|
}
|
|
563
|
-
|
|
545
|
+
function ue(e) {
|
|
546
|
+
return e.progressItems.map((t, r) => {
|
|
547
|
+
const n = e.progressItems[r + 1], a = n != null;
|
|
548
|
+
let u;
|
|
549
|
+
if (n != null && n.createdAt) {
|
|
550
|
+
const c = new Date(t.createdAt).getTime(), l = new Date(n.createdAt).getTime();
|
|
551
|
+
u = Math.round((l - c) / 1e3);
|
|
552
|
+
}
|
|
553
|
+
return {
|
|
554
|
+
item: t,
|
|
555
|
+
completed: a,
|
|
556
|
+
isLatest: r === e.progressItems.length - 1,
|
|
557
|
+
durationSeconds: u
|
|
558
|
+
};
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
function _({
|
|
562
|
+
text: e,
|
|
563
|
+
duration: t = 2,
|
|
564
|
+
delay: r = 0,
|
|
565
|
+
repeat: n = !0,
|
|
566
|
+
repeatDelay: a = 0.5,
|
|
567
|
+
className: u,
|
|
568
|
+
startOnView: c = !1,
|
|
569
|
+
once: l = !1,
|
|
570
|
+
inViewMargin: o,
|
|
571
|
+
spread: i = 2,
|
|
572
|
+
color: m = "#999",
|
|
573
|
+
shimmerColor: s = "#000",
|
|
574
|
+
direction: d = "fromBottom"
|
|
575
|
+
}) {
|
|
576
|
+
const f = P(null), y = Q(f, { once: l, margin: o }), S = L(() => e.length * i, [e, i]), b = !c || y, h = d === "fromBottom" ? "100% center" : "-100% center", k = d === "fromBottom" ? "0% center" : "200% center";
|
|
577
|
+
return /* @__PURE__ */ g(
|
|
578
|
+
A.span,
|
|
579
|
+
{
|
|
580
|
+
ref: f,
|
|
581
|
+
className: u,
|
|
582
|
+
style: {
|
|
583
|
+
position: "relative",
|
|
584
|
+
display: "inline-block",
|
|
585
|
+
backgroundSize: "250% 100%, auto",
|
|
586
|
+
backgroundClip: "text",
|
|
587
|
+
WebkitBackgroundClip: "text",
|
|
588
|
+
color: "transparent",
|
|
589
|
+
WebkitTextFillColor: "transparent",
|
|
590
|
+
backgroundRepeat: "no-repeat, padding-box",
|
|
591
|
+
"--spread": `${S}px`,
|
|
592
|
+
"--base-color": m,
|
|
593
|
+
"--shimmer-color": s,
|
|
594
|
+
"--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
|
|
595
|
+
backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
|
|
596
|
+
},
|
|
597
|
+
initial: {
|
|
598
|
+
backgroundPosition: h,
|
|
599
|
+
opacity: 0
|
|
600
|
+
},
|
|
601
|
+
animate: b ? {
|
|
602
|
+
backgroundPosition: k,
|
|
603
|
+
opacity: 1
|
|
604
|
+
} : {},
|
|
605
|
+
transition: {
|
|
606
|
+
backgroundPosition: {
|
|
607
|
+
repeat: n ? 1 / 0 : 0,
|
|
608
|
+
duration: t,
|
|
609
|
+
delay: r,
|
|
610
|
+
repeatDelay: a,
|
|
611
|
+
ease: "linear"
|
|
612
|
+
},
|
|
613
|
+
opacity: {
|
|
614
|
+
duration: 0.3,
|
|
615
|
+
delay: r
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
children: e
|
|
619
|
+
}
|
|
620
|
+
);
|
|
621
|
+
}
|
|
622
|
+
function me(e) {
|
|
623
|
+
const t = e.item.data;
|
|
624
|
+
switch (t.type) {
|
|
625
|
+
case "GenericAgentTaskExecution":
|
|
626
|
+
return t.title;
|
|
627
|
+
case "GenericAgentTaskReasoning":
|
|
628
|
+
return t.title;
|
|
629
|
+
case "GenericAgentTaskFinalResponse":
|
|
630
|
+
return "Generating answer...";
|
|
631
|
+
case "StreamingChatCompletionResponse":
|
|
632
|
+
return "Streaming...";
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
const ge = ({
|
|
636
|
+
progressViewItems: e
|
|
637
|
+
}) => {
|
|
638
|
+
const t = e[e.length - 1];
|
|
639
|
+
if (!t) return null;
|
|
640
|
+
const r = me(t);
|
|
641
|
+
return /* @__PURE__ */ g("div", { className: "simple-mode-container", children: /* @__PURE__ */ g(W, { mode: "wait", children: /* @__PURE__ */ g(
|
|
642
|
+
A.div,
|
|
643
|
+
{
|
|
644
|
+
initial: { opacity: 0, y: 10 },
|
|
645
|
+
animate: { opacity: 1, y: 0 },
|
|
646
|
+
exit: { opacity: 0, y: -10 },
|
|
647
|
+
transition: { duration: 0.3 },
|
|
648
|
+
children: t.completed ? /* @__PURE__ */ g("div", { className: "simple-mode-title", style: { color: "#666" }, children: r }) : /* @__PURE__ */ g(
|
|
649
|
+
_,
|
|
650
|
+
{
|
|
651
|
+
text: r,
|
|
652
|
+
className: "simple-mode-title",
|
|
653
|
+
duration: 2.5,
|
|
654
|
+
repeat: !0,
|
|
655
|
+
color: "#999",
|
|
656
|
+
shimmerColor: "#000"
|
|
657
|
+
}
|
|
658
|
+
)
|
|
659
|
+
},
|
|
660
|
+
t.item.progressItemId
|
|
661
|
+
) }) });
|
|
662
|
+
}, fe = ({
|
|
663
|
+
data: e,
|
|
664
|
+
isLatest: t = !1,
|
|
665
|
+
durationSeconds: r
|
|
666
|
+
}) => /* @__PURE__ */ E("div", { style: { padding: "16px" }, children: [
|
|
667
|
+
/* @__PURE__ */ g(
|
|
668
|
+
A.div,
|
|
669
|
+
{
|
|
670
|
+
style: {
|
|
671
|
+
display: "flex",
|
|
672
|
+
alignItems: "center",
|
|
673
|
+
gap: "10px",
|
|
674
|
+
color: "#666"
|
|
675
|
+
},
|
|
676
|
+
initial: { opacity: 0, y: -10 },
|
|
677
|
+
animate: { opacity: 1, y: 0 },
|
|
678
|
+
transition: { duration: 0.3, delay: 0 },
|
|
679
|
+
children: t && !r ? /* @__PURE__ */ g(
|
|
680
|
+
_,
|
|
681
|
+
{
|
|
682
|
+
text: e.title,
|
|
683
|
+
duration: 2.5,
|
|
684
|
+
repeat: !0,
|
|
685
|
+
color: "#999",
|
|
686
|
+
shimmerColor: "#000"
|
|
687
|
+
}
|
|
688
|
+
) : /* @__PURE__ */ g("span", { style: { color: "#666" }, children: e.title })
|
|
689
|
+
}
|
|
690
|
+
),
|
|
691
|
+
r !== void 0 && /* @__PURE__ */ E(
|
|
692
|
+
"div",
|
|
693
|
+
{
|
|
694
|
+
style: {
|
|
695
|
+
fontSize: "12px",
|
|
696
|
+
color: "#999",
|
|
697
|
+
marginTop: "4px",
|
|
698
|
+
fontStyle: "italic"
|
|
699
|
+
},
|
|
700
|
+
children: [
|
|
701
|
+
"Took ",
|
|
702
|
+
r,
|
|
703
|
+
" seconds"
|
|
704
|
+
]
|
|
705
|
+
}
|
|
706
|
+
)
|
|
707
|
+
] }), z = {
|
|
564
708
|
'code[class*="language-"]': {
|
|
565
709
|
color: "#f8f8f2",
|
|
566
710
|
background: "none",
|
|
@@ -711,489 +855,297 @@ const K = {
|
|
|
711
855
|
italic: {
|
|
712
856
|
fontStyle: "italic"
|
|
713
857
|
}
|
|
714
|
-
},
|
|
715
|
-
|
|
858
|
+
}, ye = ({
|
|
859
|
+
data: e,
|
|
716
860
|
streamToken: t,
|
|
717
|
-
fetchClientToken:
|
|
718
|
-
durationSeconds:
|
|
861
|
+
fetchClientToken: r,
|
|
862
|
+
durationSeconds: n
|
|
719
863
|
}) => {
|
|
720
|
-
const { fency: a } = F(),
|
|
721
|
-
async (
|
|
864
|
+
const { fency: a } = F(), u = U(
|
|
865
|
+
async (c) => {
|
|
722
866
|
try {
|
|
723
|
-
const { clientToken:
|
|
867
|
+
const { clientToken: l } = await r(), o = await V({
|
|
724
868
|
pk: a.publishableKey,
|
|
725
869
|
baseUrl: a.baseUrl,
|
|
726
|
-
clientToken:
|
|
870
|
+
clientToken: l,
|
|
727
871
|
streamToken: t,
|
|
728
|
-
request: {
|
|
729
|
-
fileId: l
|
|
730
|
-
}
|
|
872
|
+
request: { fileId: c }
|
|
731
873
|
});
|
|
732
|
-
|
|
733
|
-
} catch (
|
|
734
|
-
console.error("Failed to download file:",
|
|
874
|
+
o.type === "success" && window.open(o.downloadLink, "_blank");
|
|
875
|
+
} catch (l) {
|
|
876
|
+
console.error("Failed to download file:", l);
|
|
735
877
|
}
|
|
736
878
|
},
|
|
737
|
-
[a, t,
|
|
879
|
+
[a, t, r]
|
|
738
880
|
);
|
|
739
|
-
return /* @__PURE__ */
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
881
|
+
return /* @__PURE__ */ E("div", { style: { padding: "16px" }, children: [
|
|
882
|
+
/* @__PURE__ */ g(
|
|
883
|
+
A.div,
|
|
884
|
+
{
|
|
885
|
+
className: "fency-markdown-body-raw",
|
|
886
|
+
initial: { opacity: 0, y: -10 },
|
|
887
|
+
animate: { opacity: 1, y: 0 },
|
|
888
|
+
transition: { duration: 0.3, delay: 0 },
|
|
889
|
+
children: /* @__PURE__ */ g(
|
|
890
|
+
D,
|
|
748
891
|
{
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
...i,
|
|
780
|
-
href: r,
|
|
781
|
-
onClick: (d) => {
|
|
782
|
-
if (!r) return;
|
|
783
|
-
const s = r.match(/\/files\/(fil_[a-zA-Z0-9]+)\/download/);
|
|
784
|
-
if (s) {
|
|
785
|
-
d.preventDefault();
|
|
786
|
-
const c = s[1];
|
|
787
|
-
g(c);
|
|
788
|
-
}
|
|
789
|
-
},
|
|
790
|
-
children: u
|
|
791
|
-
}
|
|
792
|
-
);
|
|
892
|
+
remarkPlugins: [B],
|
|
893
|
+
components: {
|
|
894
|
+
code(c) {
|
|
895
|
+
const { children: l, className: o, node: i, ref: m, ...s } = c, d = /language-(\w+)/.exec(o || "");
|
|
896
|
+
return d ? /* @__PURE__ */ g(
|
|
897
|
+
M,
|
|
898
|
+
{
|
|
899
|
+
...s,
|
|
900
|
+
PreTag: "div",
|
|
901
|
+
children: String(l).replace(/\n$/, ""),
|
|
902
|
+
language: d[1],
|
|
903
|
+
style: z
|
|
904
|
+
}
|
|
905
|
+
) : /* @__PURE__ */ g("code", { ...s, className: o, children: String(l) });
|
|
906
|
+
},
|
|
907
|
+
a(c) {
|
|
908
|
+
const { children: l, href: o, ...i } = c;
|
|
909
|
+
return /* @__PURE__ */ g(
|
|
910
|
+
"a",
|
|
911
|
+
{
|
|
912
|
+
...i,
|
|
913
|
+
href: o,
|
|
914
|
+
onClick: (m) => {
|
|
915
|
+
if (!o) return;
|
|
916
|
+
const s = o.match(
|
|
917
|
+
/\/files\/(fil_[a-zA-Z0-9]+)\/download/
|
|
918
|
+
);
|
|
919
|
+
s && (m.preventDefault(), u(s[1]));
|
|
920
|
+
},
|
|
921
|
+
children: l
|
|
793
922
|
}
|
|
794
|
-
|
|
795
|
-
children: e
|
|
923
|
+
);
|
|
796
924
|
}
|
|
797
|
-
)
|
|
798
|
-
}
|
|
799
|
-
),
|
|
800
|
-
o !== void 0 && /* @__PURE__ */ x(
|
|
801
|
-
"div",
|
|
802
|
-
{
|
|
803
|
-
style: {
|
|
804
|
-
fontSize: "12px",
|
|
805
|
-
color: "#999",
|
|
806
|
-
marginTop: "8px",
|
|
807
|
-
fontStyle: "italic"
|
|
808
925
|
},
|
|
809
|
-
children:
|
|
810
|
-
"Thought for ",
|
|
811
|
-
o,
|
|
812
|
-
" seconds"
|
|
813
|
-
]
|
|
926
|
+
children: e.response
|
|
814
927
|
}
|
|
815
928
|
)
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
className: g,
|
|
827
|
-
startOnView: l = !1,
|
|
828
|
-
once: u = !1,
|
|
829
|
-
inViewMargin: r,
|
|
830
|
-
spread: i = 2,
|
|
831
|
-
color: d = "#999",
|
|
832
|
-
shimmerColor: s = "#000",
|
|
833
|
-
direction: c = "fromBottom"
|
|
834
|
-
}) {
|
|
835
|
-
const m = E(null), b = Z(m, { once: u, margin: r }), h = H(() => e.length * i, [e, i]), k = !l || b, y = c === "fromBottom" ? "100% center" : "-100% center", w = c === "fromBottom" ? "0% center" : "200% center";
|
|
836
|
-
return /* @__PURE__ */ f(
|
|
837
|
-
P.span,
|
|
838
|
-
{
|
|
839
|
-
ref: m,
|
|
840
|
-
className: g,
|
|
841
|
-
style: {
|
|
842
|
-
position: "relative",
|
|
843
|
-
display: "inline-block",
|
|
844
|
-
backgroundSize: "250% 100%, auto",
|
|
845
|
-
backgroundClip: "text",
|
|
846
|
-
WebkitBackgroundClip: "text",
|
|
847
|
-
color: "transparent",
|
|
848
|
-
WebkitTextFillColor: "transparent",
|
|
849
|
-
backgroundRepeat: "no-repeat, padding-box",
|
|
850
|
-
"--spread": `${h}px`,
|
|
851
|
-
"--base-color": d,
|
|
852
|
-
"--shimmer-color": s,
|
|
853
|
-
"--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
|
|
854
|
-
backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
|
|
855
|
-
},
|
|
856
|
-
initial: {
|
|
857
|
-
backgroundPosition: y,
|
|
858
|
-
opacity: 0
|
|
859
|
-
},
|
|
860
|
-
animate: k ? {
|
|
861
|
-
backgroundPosition: w,
|
|
862
|
-
opacity: 1
|
|
863
|
-
} : {},
|
|
864
|
-
transition: {
|
|
865
|
-
backgroundPosition: {
|
|
866
|
-
repeat: o ? 1 / 0 : 0,
|
|
867
|
-
duration: t,
|
|
868
|
-
delay: n,
|
|
869
|
-
repeatDelay: a,
|
|
870
|
-
ease: "linear"
|
|
929
|
+
}
|
|
930
|
+
),
|
|
931
|
+
n !== void 0 && /* @__PURE__ */ E(
|
|
932
|
+
"div",
|
|
933
|
+
{
|
|
934
|
+
style: {
|
|
935
|
+
fontSize: "12px",
|
|
936
|
+
color: "#999",
|
|
937
|
+
marginTop: "8px",
|
|
938
|
+
fontStyle: "italic"
|
|
871
939
|
},
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
);
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
title: e,
|
|
940
|
+
children: [
|
|
941
|
+
"Thought for ",
|
|
942
|
+
n,
|
|
943
|
+
" seconds"
|
|
944
|
+
]
|
|
945
|
+
}
|
|
946
|
+
)
|
|
947
|
+
] });
|
|
948
|
+
}, he = ({
|
|
949
|
+
data: e,
|
|
883
950
|
completed: t,
|
|
884
|
-
isLatest:
|
|
885
|
-
durationSeconds:
|
|
886
|
-
}) => /* @__PURE__ */ x(
|
|
887
|
-
"div",
|
|
888
|
-
{
|
|
889
|
-
style: {
|
|
890
|
-
padding: "16px"
|
|
891
|
-
},
|
|
892
|
-
children: [
|
|
893
|
-
/* @__PURE__ */ f(
|
|
894
|
-
P.div,
|
|
895
|
-
{
|
|
896
|
-
style: {
|
|
897
|
-
display: "flex",
|
|
898
|
-
alignItems: "center",
|
|
899
|
-
gap: "10px",
|
|
900
|
-
color: "#666"
|
|
901
|
-
},
|
|
902
|
-
initial: { opacity: 0, y: -10 },
|
|
903
|
-
animate: { opacity: 1, y: 0 },
|
|
904
|
-
transition: { duration: 0.3, delay: 0 },
|
|
905
|
-
children: n && !o ? /* @__PURE__ */ f(
|
|
906
|
-
D,
|
|
907
|
-
{
|
|
908
|
-
text: e,
|
|
909
|
-
duration: 2.5,
|
|
910
|
-
repeat: !0,
|
|
911
|
-
color: "#999",
|
|
912
|
-
shimmerColor: "#000"
|
|
913
|
-
}
|
|
914
|
-
) : /* @__PURE__ */ f("span", { style: { color: "#666" }, children: e })
|
|
915
|
-
}
|
|
916
|
-
),
|
|
917
|
-
o !== void 0 && /* @__PURE__ */ x(
|
|
918
|
-
"div",
|
|
919
|
-
{
|
|
920
|
-
style: {
|
|
921
|
-
fontSize: "12px",
|
|
922
|
-
color: "#999",
|
|
923
|
-
marginTop: "4px",
|
|
924
|
-
fontStyle: "italic"
|
|
925
|
-
},
|
|
926
|
-
children: [
|
|
927
|
-
"Thought for ",
|
|
928
|
-
o,
|
|
929
|
-
" seconds"
|
|
930
|
-
]
|
|
931
|
-
}
|
|
932
|
-
),
|
|
933
|
-
/* @__PURE__ */ f("style", { children: `
|
|
934
|
-
@keyframes spin {
|
|
935
|
-
to { transform: rotate(360deg); }
|
|
936
|
-
}
|
|
937
|
-
` })
|
|
938
|
-
]
|
|
939
|
-
}
|
|
940
|
-
), fe = ({
|
|
941
|
-
title: e,
|
|
942
|
-
markdown: t,
|
|
943
|
-
completed: n,
|
|
944
|
-
isLatest: o = !1,
|
|
945
|
-
durationSeconds: a
|
|
951
|
+
isLatest: r = !1,
|
|
952
|
+
durationSeconds: n
|
|
946
953
|
}) => {
|
|
947
|
-
const
|
|
954
|
+
const a = P(null);
|
|
948
955
|
return T(() => {
|
|
949
|
-
|
|
950
|
-
}, [
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
956
|
+
a.current && !t && (a.current.scrollTop = a.current.scrollHeight);
|
|
957
|
+
}, [e.reasoning, t]), /* @__PURE__ */ E("div", { style: { padding: "16px" }, children: [
|
|
958
|
+
/* @__PURE__ */ g(
|
|
959
|
+
A.h3,
|
|
960
|
+
{
|
|
961
|
+
style: { marginBottom: "10px", color: "#666" },
|
|
962
|
+
initial: { opacity: 0, y: -10 },
|
|
963
|
+
animate: { opacity: 1, y: 0 },
|
|
964
|
+
transition: { duration: 0.3, delay: 0 },
|
|
965
|
+
children: r && !n ? /* @__PURE__ */ g(
|
|
966
|
+
_,
|
|
959
967
|
{
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
D,
|
|
966
|
-
{
|
|
967
|
-
text: e,
|
|
968
|
-
duration: 2.5,
|
|
969
|
-
repeat: !0,
|
|
970
|
-
color: "#999",
|
|
971
|
-
shimmerColor: "#000"
|
|
972
|
-
}
|
|
973
|
-
) : e
|
|
968
|
+
text: e.title,
|
|
969
|
+
duration: 2.5,
|
|
970
|
+
repeat: !0,
|
|
971
|
+
color: "#999",
|
|
972
|
+
shimmerColor: "#000"
|
|
974
973
|
}
|
|
975
|
-
)
|
|
976
|
-
|
|
977
|
-
|
|
974
|
+
) : e.title
|
|
975
|
+
}
|
|
976
|
+
),
|
|
977
|
+
/* @__PURE__ */ g(
|
|
978
|
+
A.div,
|
|
979
|
+
{
|
|
980
|
+
ref: a,
|
|
981
|
+
style: {
|
|
982
|
+
maxHeight: "100px",
|
|
983
|
+
overflowY: "auto",
|
|
984
|
+
border: "1px solid #e0e0e0",
|
|
985
|
+
borderRadius: "8px",
|
|
986
|
+
padding: "12px",
|
|
987
|
+
opacity: 0.5,
|
|
988
|
+
backgroundColor: "#f9f9f9"
|
|
989
|
+
},
|
|
990
|
+
initial: { opacity: 0, y: -10 },
|
|
991
|
+
animate: { opacity: 0.5, y: 0 },
|
|
992
|
+
transition: { duration: 0.3, delay: 0.1 },
|
|
993
|
+
children: /* @__PURE__ */ g("div", { className: "fency-markdown-body-raw", children: /* @__PURE__ */ g(
|
|
994
|
+
D,
|
|
978
995
|
{
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
transition: { duration: 0.3, delay: 0.1 },
|
|
992
|
-
children: /* @__PURE__ */ f("div", { className: "fency-markdown-body-raw", children: /* @__PURE__ */ f(
|
|
993
|
-
W,
|
|
994
|
-
{
|
|
995
|
-
remarkPlugins: [L],
|
|
996
|
-
components: {
|
|
997
|
-
code(l) {
|
|
998
|
-
const {
|
|
999
|
-
children: u,
|
|
1000
|
-
className: r,
|
|
1001
|
-
node: i,
|
|
1002
|
-
ref: d,
|
|
1003
|
-
...s
|
|
1004
|
-
} = l, c = /language-(\w+)/.exec(
|
|
1005
|
-
r || ""
|
|
1006
|
-
);
|
|
1007
|
-
return c ? /* @__PURE__ */ f(
|
|
1008
|
-
j,
|
|
1009
|
-
{
|
|
1010
|
-
...s,
|
|
1011
|
-
PreTag: "div",
|
|
1012
|
-
children: String(u).replace(
|
|
1013
|
-
/\n$/,
|
|
1014
|
-
""
|
|
1015
|
-
),
|
|
1016
|
-
language: c[1],
|
|
1017
|
-
style: K
|
|
1018
|
-
}
|
|
1019
|
-
) : /* @__PURE__ */ f("code", { ...s, className: r, children: String(u) });
|
|
996
|
+
remarkPlugins: [B],
|
|
997
|
+
components: {
|
|
998
|
+
code(u) {
|
|
999
|
+
const { children: c, className: l, node: o, ref: i, ...m } = u, s = /language-(\w+)/.exec(l || "");
|
|
1000
|
+
return s ? /* @__PURE__ */ g(
|
|
1001
|
+
M,
|
|
1002
|
+
{
|
|
1003
|
+
...m,
|
|
1004
|
+
PreTag: "div",
|
|
1005
|
+
children: String(c).replace(/\n$/, ""),
|
|
1006
|
+
language: s[1],
|
|
1007
|
+
style: z
|
|
1020
1008
|
}
|
|
1021
|
-
}
|
|
1022
|
-
children: t
|
|
1009
|
+
) : /* @__PURE__ */ g("code", { ...m, className: l, children: String(c) });
|
|
1023
1010
|
}
|
|
1024
|
-
) })
|
|
1025
|
-
}
|
|
1026
|
-
),
|
|
1027
|
-
a !== void 0 && /* @__PURE__ */ x(
|
|
1028
|
-
"div",
|
|
1029
|
-
{
|
|
1030
|
-
style: {
|
|
1031
|
-
fontSize: "12px",
|
|
1032
|
-
color: "#999",
|
|
1033
|
-
marginTop: "8px",
|
|
1034
|
-
fontStyle: "italic"
|
|
1035
1011
|
},
|
|
1036
|
-
children:
|
|
1037
|
-
"Thought for ",
|
|
1038
|
-
a,
|
|
1039
|
-
" seconds"
|
|
1040
|
-
]
|
|
1012
|
+
children: e.reasoning
|
|
1041
1013
|
}
|
|
1042
|
-
)
|
|
1043
|
-
]
|
|
1044
|
-
}
|
|
1045
|
-
);
|
|
1046
|
-
}, he = ({ message: e, isLatest: t = !1, streamToken: n, fetchClientToken: o }) => {
|
|
1047
|
-
const a = e.state || "complete";
|
|
1048
|
-
if (a === O.EXECUTION)
|
|
1049
|
-
return /* @__PURE__ */ f(
|
|
1050
|
-
ge,
|
|
1051
|
-
{
|
|
1052
|
-
title: e.title,
|
|
1053
|
-
completed: e.completed,
|
|
1054
|
-
isLatest: t,
|
|
1055
|
-
durationSeconds: e.durationSeconds
|
|
1014
|
+
) })
|
|
1056
1015
|
}
|
|
1057
|
-
)
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
fe,
|
|
1016
|
+
),
|
|
1017
|
+
n !== void 0 && /* @__PURE__ */ E(
|
|
1018
|
+
"div",
|
|
1061
1019
|
{
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1020
|
+
style: {
|
|
1021
|
+
fontSize: "12px",
|
|
1022
|
+
color: "#999",
|
|
1023
|
+
marginTop: "8px",
|
|
1024
|
+
fontStyle: "italic"
|
|
1025
|
+
},
|
|
1026
|
+
children: [
|
|
1027
|
+
"Thought for ",
|
|
1028
|
+
n,
|
|
1029
|
+
" seconds"
|
|
1030
|
+
]
|
|
1067
1031
|
}
|
|
1068
|
-
)
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1032
|
+
)
|
|
1033
|
+
] });
|
|
1034
|
+
}, be = ({
|
|
1035
|
+
data: e
|
|
1036
|
+
}) => /* @__PURE__ */ g("div", { style: { padding: "16px" }, children: /* @__PURE__ */ g(
|
|
1037
|
+
A.div,
|
|
1038
|
+
{
|
|
1039
|
+
className: "fency-markdown-body-raw",
|
|
1040
|
+
initial: { opacity: 0, y: -10 },
|
|
1041
|
+
animate: { opacity: 1, y: 0 },
|
|
1042
|
+
transition: { duration: 0.3, delay: 0 },
|
|
1043
|
+
children: /* @__PURE__ */ g(
|
|
1044
|
+
D,
|
|
1072
1045
|
{
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
let b;
|
|
1091
|
-
const h = e.progressItems[m + 1];
|
|
1092
|
-
if (h != null && h.createdAt) {
|
|
1093
|
-
const y = new Date(c.createdAt).getTime(), w = new Date(h.createdAt).getTime();
|
|
1094
|
-
b = Math.round((w - y) / 1e3);
|
|
1046
|
+
remarkPlugins: [B],
|
|
1047
|
+
components: {
|
|
1048
|
+
code(t) {
|
|
1049
|
+
const { children: r, className: n, node: a, ref: u, ...c } = t, l = /language-(\w+)/.exec(n || "");
|
|
1050
|
+
return l ? /* @__PURE__ */ g(
|
|
1051
|
+
M,
|
|
1052
|
+
{
|
|
1053
|
+
...c,
|
|
1054
|
+
PreTag: "div",
|
|
1055
|
+
children: String(r).replace(/\n$/, ""),
|
|
1056
|
+
language: l[1],
|
|
1057
|
+
style: z
|
|
1058
|
+
}
|
|
1059
|
+
) : /* @__PURE__ */ g("code", { ...c, className: n, children: String(r) });
|
|
1060
|
+
}
|
|
1061
|
+
},
|
|
1062
|
+
children: e.response
|
|
1095
1063
|
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
const d = e.progressItems[0];
|
|
1109
|
-
if (d != null && d.createdAt) {
|
|
1110
|
-
const c = new Date(e.triggeredAt).getTime(), m = new Date(d.createdAt).getTime();
|
|
1111
|
-
i = Math.round((m - c) / 1e3);
|
|
1112
|
-
}
|
|
1113
|
-
const s = {
|
|
1114
|
-
id: "placeholder",
|
|
1115
|
-
title: n,
|
|
1116
|
-
markdown: "",
|
|
1117
|
-
state: O.EXECUTION,
|
|
1118
|
-
completed: d != null,
|
|
1119
|
-
durationSeconds: i
|
|
1120
|
-
};
|
|
1121
|
-
l([s, ...r]);
|
|
1122
|
-
}, [e, n]), T(() => {
|
|
1123
|
-
t === "verbose" && u.current && (u.current.scrollTop = u.current.scrollHeight);
|
|
1124
|
-
}, [g, t]), t === "simple") {
|
|
1125
|
-
const r = g[g.length - 1];
|
|
1126
|
-
if (!r)
|
|
1127
|
-
return null;
|
|
1128
|
-
const i = r.completed;
|
|
1129
|
-
return /* @__PURE__ */ f("div", { className: "simple-mode-container", children: /* @__PURE__ */ f(B, { mode: "wait", children: /* @__PURE__ */ f(
|
|
1130
|
-
P.div,
|
|
1131
|
-
{
|
|
1132
|
-
initial: { opacity: 0, y: 10 },
|
|
1133
|
-
animate: { opacity: 1, y: 0 },
|
|
1134
|
-
exit: { opacity: 0, y: -10 },
|
|
1135
|
-
transition: { duration: 0.3 },
|
|
1136
|
-
children: i ? /* @__PURE__ */ f(
|
|
1137
|
-
"div",
|
|
1064
|
+
)
|
|
1065
|
+
}
|
|
1066
|
+
) }), ke = ({ progressViewItems: e, streamToken: t, fetchClientToken: r }) => {
|
|
1067
|
+
const n = P(null);
|
|
1068
|
+
T(() => {
|
|
1069
|
+
n.current && (n.current.scrollTop = n.current.scrollHeight);
|
|
1070
|
+
}, [e.length]);
|
|
1071
|
+
const a = (u) => {
|
|
1072
|
+
switch (u.item.data.type) {
|
|
1073
|
+
case "GenericAgentTaskExecution":
|
|
1074
|
+
return /* @__PURE__ */ g(
|
|
1075
|
+
fe,
|
|
1138
1076
|
{
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
children: r.title
|
|
1077
|
+
data: u.item.data,
|
|
1078
|
+
completed: u.completed,
|
|
1079
|
+
isLatest: u.isLatest,
|
|
1080
|
+
durationSeconds: u.durationSeconds
|
|
1144
1081
|
}
|
|
1145
|
-
)
|
|
1146
|
-
|
|
1082
|
+
);
|
|
1083
|
+
case "GenericAgentTaskReasoning":
|
|
1084
|
+
return /* @__PURE__ */ g(
|
|
1085
|
+
he,
|
|
1147
1086
|
{
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
color: "#999",
|
|
1153
|
-
shimmerColor: "#000"
|
|
1087
|
+
data: u.item.data,
|
|
1088
|
+
completed: u.completed,
|
|
1089
|
+
isLatest: u.isLatest,
|
|
1090
|
+
durationSeconds: u.durationSeconds
|
|
1154
1091
|
}
|
|
1155
|
-
)
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1092
|
+
);
|
|
1093
|
+
case "GenericAgentTaskFinalResponse":
|
|
1094
|
+
return /* @__PURE__ */ g(
|
|
1095
|
+
ye,
|
|
1096
|
+
{
|
|
1097
|
+
data: u.item.data,
|
|
1098
|
+
streamToken: t,
|
|
1099
|
+
fetchClientToken: r,
|
|
1100
|
+
durationSeconds: u.durationSeconds
|
|
1101
|
+
}
|
|
1102
|
+
);
|
|
1103
|
+
case "StreamingChatCompletionResponse":
|
|
1104
|
+
return /* @__PURE__ */ g(be, { data: u.item.data });
|
|
1105
|
+
}
|
|
1106
|
+
};
|
|
1107
|
+
return /* @__PURE__ */ g(
|
|
1161
1108
|
"div",
|
|
1162
1109
|
{
|
|
1163
|
-
ref:
|
|
1110
|
+
ref: n,
|
|
1164
1111
|
style: {
|
|
1165
1112
|
flex: 1,
|
|
1166
1113
|
overflowY: "auto",
|
|
1167
1114
|
minHeight: 0
|
|
1168
|
-
// Important for flex scroll
|
|
1169
1115
|
},
|
|
1170
|
-
children: /* @__PURE__ */
|
|
1171
|
-
|
|
1116
|
+
children: /* @__PURE__ */ g(W, { children: e.map((u, c) => /* @__PURE__ */ g(
|
|
1117
|
+
A.div,
|
|
1172
1118
|
{
|
|
1173
1119
|
initial: { opacity: 0, y: -20 },
|
|
1174
1120
|
animate: { opacity: 1, y: 0 },
|
|
1175
1121
|
transition: {
|
|
1176
1122
|
duration: 0.4,
|
|
1177
|
-
delay:
|
|
1178
|
-
// Stagger effect
|
|
1123
|
+
delay: c * 0.1,
|
|
1179
1124
|
ease: "easeOut"
|
|
1180
1125
|
},
|
|
1181
|
-
children:
|
|
1182
|
-
he,
|
|
1183
|
-
{
|
|
1184
|
-
message: r,
|
|
1185
|
-
isLatest: i === g.length - 1,
|
|
1186
|
-
streamToken: o,
|
|
1187
|
-
fetchClientToken: a
|
|
1188
|
-
}
|
|
1189
|
-
)
|
|
1126
|
+
children: a(u)
|
|
1190
1127
|
},
|
|
1191
|
-
|
|
1128
|
+
u.item.progressItemId
|
|
1192
1129
|
)) })
|
|
1193
1130
|
}
|
|
1194
1131
|
);
|
|
1132
|
+
}, Oe = ({
|
|
1133
|
+
agentTask: e,
|
|
1134
|
+
mode: t = "verbose",
|
|
1135
|
+
streamToken: r,
|
|
1136
|
+
fetchClientToken: n
|
|
1137
|
+
}) => {
|
|
1138
|
+
const a = ue(e);
|
|
1139
|
+
return t === "simple" ? /* @__PURE__ */ g(ge, { progressViewItems: a }) : /* @__PURE__ */ g(
|
|
1140
|
+
ke,
|
|
1141
|
+
{
|
|
1142
|
+
progressViewItems: a,
|
|
1143
|
+
streamToken: r,
|
|
1144
|
+
fetchClientToken: n
|
|
1145
|
+
}
|
|
1146
|
+
);
|
|
1195
1147
|
};
|
|
1196
|
-
class
|
|
1148
|
+
class Se {
|
|
1197
1149
|
constructor(t) {
|
|
1198
1150
|
this.eventSources = /* @__PURE__ */ new Map(), this.subscribers = /* @__PURE__ */ new Map(), this.fency = t;
|
|
1199
1151
|
}
|
|
@@ -1202,37 +1154,37 @@ class ye {
|
|
|
1202
1154
|
* Creates new connections and removes old ones.
|
|
1203
1155
|
*/
|
|
1204
1156
|
updateStreams(t) {
|
|
1205
|
-
t.forEach((
|
|
1206
|
-
const a =
|
|
1207
|
-
this.eventSources.has(a) || this.connectStream(
|
|
1157
|
+
t.forEach((n) => {
|
|
1158
|
+
const a = n.stream.id;
|
|
1159
|
+
this.eventSources.has(a) || this.connectStream(n);
|
|
1208
1160
|
});
|
|
1209
|
-
const
|
|
1210
|
-
this.eventSources.forEach((
|
|
1211
|
-
|
|
1161
|
+
const r = new Set(t.map((n) => n.stream.id));
|
|
1162
|
+
this.eventSources.forEach((n, a) => {
|
|
1163
|
+
r.has(a) || (n.abort(), this.eventSources.delete(a));
|
|
1212
1164
|
});
|
|
1213
1165
|
}
|
|
1214
1166
|
connectStream(t) {
|
|
1215
|
-
const
|
|
1216
|
-
this.eventSources.set(
|
|
1217
|
-
const a = `${this.fency.baseUrl}/sse/streams/${
|
|
1167
|
+
const r = t.stream.id, n = new AbortController();
|
|
1168
|
+
this.eventSources.set(r, n);
|
|
1169
|
+
const a = `${this.fency.baseUrl}/sse/streams/${r}`, u = {
|
|
1218
1170
|
"X-Fency-Publishable-Key": this.fency.publishableKey,
|
|
1219
1171
|
"X-Fency-Stream-Token": t.stream.token
|
|
1220
1172
|
};
|
|
1221
|
-
|
|
1222
|
-
headers:
|
|
1223
|
-
signal:
|
|
1224
|
-
async onopen(
|
|
1225
|
-
if (!
|
|
1226
|
-
throw new Error(`Client error ${
|
|
1173
|
+
$(a, {
|
|
1174
|
+
headers: u,
|
|
1175
|
+
signal: n.signal,
|
|
1176
|
+
async onopen(c) {
|
|
1177
|
+
if (!c.ok && c.status >= 400 && c.status < 500 && c.status !== 429)
|
|
1178
|
+
throw new Error(`Client error ${c.status}`);
|
|
1227
1179
|
},
|
|
1228
|
-
onmessage: (
|
|
1229
|
-
if (
|
|
1230
|
-
const
|
|
1231
|
-
this.broadcast(
|
|
1180
|
+
onmessage: (c) => {
|
|
1181
|
+
if (c.data) {
|
|
1182
|
+
const l = K(c.data);
|
|
1183
|
+
this.broadcast(l, r);
|
|
1232
1184
|
}
|
|
1233
1185
|
},
|
|
1234
|
-
onerror: (
|
|
1235
|
-
throw console.error("EventSource error for stream",
|
|
1186
|
+
onerror: (c) => {
|
|
1187
|
+
throw console.error("EventSource error for stream", r, ":", c), this.broadcastError(r), c;
|
|
1236
1188
|
},
|
|
1237
1189
|
onclose() {
|
|
1238
1190
|
}
|
|
@@ -1242,19 +1194,19 @@ class ye {
|
|
|
1242
1194
|
* Subscribe to events from all active streams.
|
|
1243
1195
|
* Returns an unsubscribe function.
|
|
1244
1196
|
*/
|
|
1245
|
-
subscribe(t,
|
|
1246
|
-
return this.subscribers.set(t,
|
|
1197
|
+
subscribe(t, r) {
|
|
1198
|
+
return this.subscribers.set(t, r), () => {
|
|
1247
1199
|
this.subscribers.delete(t);
|
|
1248
1200
|
};
|
|
1249
1201
|
}
|
|
1250
|
-
broadcast(t,
|
|
1251
|
-
this.subscribers.forEach((
|
|
1252
|
-
|
|
1202
|
+
broadcast(t, r) {
|
|
1203
|
+
this.subscribers.forEach((n) => {
|
|
1204
|
+
n.onMessage(t, r);
|
|
1253
1205
|
});
|
|
1254
1206
|
}
|
|
1255
1207
|
broadcastError(t) {
|
|
1256
|
-
this.subscribers.forEach((
|
|
1257
|
-
|
|
1208
|
+
this.subscribers.forEach((r) => {
|
|
1209
|
+
r.onError(t);
|
|
1258
1210
|
});
|
|
1259
1211
|
}
|
|
1260
1212
|
/**
|
|
@@ -1264,88 +1216,90 @@ class ye {
|
|
|
1264
1216
|
this.eventSources.forEach((t) => t.abort()), this.eventSources.clear(), this.subscribers.clear();
|
|
1265
1217
|
}
|
|
1266
1218
|
}
|
|
1267
|
-
const
|
|
1219
|
+
const ve = 12e4, we = (e) => {
|
|
1268
1220
|
const t = Date.now();
|
|
1269
|
-
return e.filter((
|
|
1221
|
+
return e.filter((r) => t - r.createdAt < ve);
|
|
1270
1222
|
};
|
|
1271
|
-
function
|
|
1272
|
-
const [n,
|
|
1223
|
+
function Ue({ fency: e, fetchCreateStreamClientToken: t, children: r }) {
|
|
1224
|
+
const [n, a] = w(
|
|
1273
1225
|
null
|
|
1274
|
-
), [
|
|
1226
|
+
), [u, c] = w(!0), [l, o] = w(null), [i, m] = w([]), s = P(null), d = P(null);
|
|
1275
1227
|
T(() => {
|
|
1276
|
-
e.then((
|
|
1277
|
-
|
|
1278
|
-
}).catch((
|
|
1279
|
-
|
|
1228
|
+
e.then((b) => {
|
|
1229
|
+
a(b), c(!1);
|
|
1230
|
+
}).catch((b) => {
|
|
1231
|
+
o(b), c(!1);
|
|
1280
1232
|
});
|
|
1281
1233
|
}, [e]), T(() => {
|
|
1282
|
-
n && !
|
|
1234
|
+
n && !d.current && (d.current = new Se(n));
|
|
1283
1235
|
}, [n]), T(() => {
|
|
1284
|
-
|
|
1285
|
-
}, [
|
|
1286
|
-
var
|
|
1287
|
-
(
|
|
1236
|
+
d.current && d.current.updateStreams(i);
|
|
1237
|
+
}, [i]), T(() => () => {
|
|
1238
|
+
var b;
|
|
1239
|
+
(b = d.current) == null || b.cleanup();
|
|
1288
1240
|
}, []);
|
|
1289
|
-
const
|
|
1290
|
-
async (
|
|
1291
|
-
if (
|
|
1292
|
-
return
|
|
1293
|
-
const
|
|
1294
|
-
if (
|
|
1295
|
-
return
|
|
1241
|
+
const f = U(
|
|
1242
|
+
async (b = 3e4) => {
|
|
1243
|
+
if (s.current)
|
|
1244
|
+
return s.current;
|
|
1245
|
+
const h = Date.now(), k = i.length > 0 ? i[i.length - 1] : null;
|
|
1246
|
+
if (k && h - k.createdAt < b)
|
|
1247
|
+
return k.stream;
|
|
1296
1248
|
const I = (async () => {
|
|
1297
1249
|
if (!n)
|
|
1298
1250
|
throw new Error("Fency instance not initialized");
|
|
1299
|
-
const C = await
|
|
1251
|
+
const C = await t(), x = await X({
|
|
1300
1252
|
pk: n.publishableKey,
|
|
1301
1253
|
baseUrl: n.baseUrl,
|
|
1302
1254
|
clientToken: (C == null ? void 0 : C.clientToken) ?? ""
|
|
1303
1255
|
});
|
|
1304
|
-
if (
|
|
1305
|
-
const
|
|
1306
|
-
stream:
|
|
1256
|
+
if (x.type === "success") {
|
|
1257
|
+
const N = {
|
|
1258
|
+
stream: x.stream,
|
|
1307
1259
|
createdAt: Date.now()
|
|
1308
1260
|
};
|
|
1309
|
-
return
|
|
1310
|
-
const
|
|
1311
|
-
return we(
|
|
1312
|
-
}),
|
|
1261
|
+
return m((R) => {
|
|
1262
|
+
const v = [...R, N];
|
|
1263
|
+
return we(v);
|
|
1264
|
+
}), s.current = null, x.stream;
|
|
1313
1265
|
} else
|
|
1314
|
-
throw
|
|
1266
|
+
throw s.current = null, new Error("Failed to create stream");
|
|
1315
1267
|
})();
|
|
1316
|
-
return
|
|
1268
|
+
return s.current = I, I;
|
|
1317
1269
|
},
|
|
1318
|
-
[n,
|
|
1270
|
+
[n, i]
|
|
1319
1271
|
);
|
|
1320
1272
|
if (l)
|
|
1321
|
-
return /* @__PURE__ */
|
|
1273
|
+
return /* @__PURE__ */ E("div", { children: [
|
|
1322
1274
|
"Fency error: ",
|
|
1323
1275
|
l.message
|
|
1324
1276
|
] });
|
|
1325
1277
|
if (!n)
|
|
1326
1278
|
return null;
|
|
1327
|
-
const
|
|
1279
|
+
const y = i.length > 0 ? i[i.length - 1] : null, S = {
|
|
1328
1280
|
fency: n,
|
|
1329
|
-
loading:
|
|
1281
|
+
loading: u,
|
|
1330
1282
|
error: l,
|
|
1331
|
-
activeStreams:
|
|
1332
|
-
latestStream:
|
|
1333
|
-
eventManager:
|
|
1334
|
-
getOrCreateStream:
|
|
1283
|
+
activeStreams: i,
|
|
1284
|
+
latestStream: y,
|
|
1285
|
+
eventManager: d.current,
|
|
1286
|
+
getOrCreateStream: f
|
|
1335
1287
|
};
|
|
1336
|
-
return /* @__PURE__ */
|
|
1288
|
+
return /* @__PURE__ */ g(j.Provider, { value: S, children: r });
|
|
1337
1289
|
}
|
|
1338
1290
|
export {
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
fe as
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1291
|
+
Oe as AgentTaskProgress,
|
|
1292
|
+
ge as AgentTaskProgressSimple,
|
|
1293
|
+
ke as AgentTaskProgressVerbose,
|
|
1294
|
+
Ue as FencyProvider,
|
|
1295
|
+
fe as GenericAgentTaskExecution,
|
|
1296
|
+
ye as GenericAgentTaskFinalResponse,
|
|
1297
|
+
he as GenericAgentTaskReasoning,
|
|
1298
|
+
_ as ShimmeringText,
|
|
1299
|
+
be as StreamingChatCompletionResponse,
|
|
1300
|
+
Re as useAgentTasks,
|
|
1347
1301
|
F as useFencyContext,
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1302
|
+
Ne as useFencyEventSource,
|
|
1303
|
+
Fe as usePaginatedQuery,
|
|
1304
|
+
re as useStream
|
|
1351
1305
|
};
|