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