@fencyai/react 0.1.126 → 0.1.128
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.
|
@@ -2,10 +2,6 @@ import { AgentTask } from '../types/AgentTask';
|
|
|
2
2
|
export interface AgentTaskProgressProps {
|
|
3
3
|
agentTask: AgentTask;
|
|
4
4
|
mode?: 'simple' | 'verbose';
|
|
5
|
-
streamToken: string;
|
|
6
|
-
fetchClientToken: () => Promise<{
|
|
7
|
-
clientToken: string;
|
|
8
|
-
}>;
|
|
9
5
|
onSourceClick?: (memoryId: string) => void;
|
|
10
6
|
}
|
|
11
7
|
export declare const AgentTaskProgress: React.FC<AgentTaskProgressProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentTaskProgress.d.ts","sourceRoot":"","sources":["../../src/agent-task/AgentTaskProgress.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"AgentTaskProgress.d.ts","sourceRoot":"","sources":["../../src/agent-task/AgentTaskProgress.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAM9C,MAAM,WAAW,sBAAsB;IACnC,SAAS,EAAE,SAAS,CAAA;IACpB,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAA;IAC3B,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CAC7C;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAmB9D,CAAA"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { ProgressViewItem } from './ProgressViewItem';
|
|
2
2
|
export interface AgentTaskProgressVerboseProps {
|
|
3
3
|
progressViewItems: ProgressViewItem[];
|
|
4
|
-
streamToken: string;
|
|
5
|
-
fetchClientToken: () => Promise<{
|
|
6
|
-
clientToken: string;
|
|
7
|
-
}>;
|
|
8
4
|
loadingText?: string;
|
|
9
5
|
onSourceClick?: (memoryId: string) => void;
|
|
10
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentTaskProgressVerbose.d.ts","sourceRoot":"","sources":["../../src/agent-task/AgentTaskProgressVerbose.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AASrD,MAAM,WAAW,6BAA6B;IAC1C,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;IACrC,WAAW,
|
|
1
|
+
{"version":3,"file":"AgentTaskProgressVerbose.d.ts","sourceRoot":"","sources":["../../src/agent-task/AgentTaskProgressVerbose.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AASrD,MAAM,WAAW,6BAA6B;IAC1C,iBAAiB,EAAE,gBAAgB,EAAE,CAAA;IACrC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;CAC7C;AAED,eAAO,MAAM,wBAAwB,EAAE,KAAK,CAAC,EAAE,CAC3C,6BAA6B,CAsHhC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsxs as C, jsx as
|
|
1
|
+
import { jsxs as C, jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import { createStream as K, isStreamTimeoutEvent as _, isStreamNotFoundEvent as J, isAgentTaskProgressItemUpdatedEvent as V, createAgentTask as q } from "@fencyai/js";
|
|
3
|
-
import { createContext as G, useState as k, useRef as E, useEffect as w, useCallback as
|
|
4
|
-
import { useInView as Q, motion as T, AnimatePresence as
|
|
3
|
+
import { createContext as G, useState as k, useRef as E, useEffect as w, useCallback as U, useContext as X, useMemo as W } from "react";
|
|
4
|
+
import { useInView as Q, motion as T, AnimatePresence as $ } from "motion/react";
|
|
5
5
|
import Y from "react-markdown";
|
|
6
|
-
import { Prism as
|
|
6
|
+
import { Prism as N } from "react-syntax-highlighter";
|
|
7
7
|
import Z from "remark-gfm";
|
|
8
|
-
import './assets/index.css';const
|
|
8
|
+
import './assets/index.css';const j = G(
|
|
9
9
|
void 0
|
|
10
10
|
);
|
|
11
11
|
async function ee(e, t) {
|
|
@@ -16,53 +16,53 @@ async function ee(e, t) {
|
|
|
16
16
|
}
|
|
17
17
|
function te(e) {
|
|
18
18
|
let t, n, r, c = !1;
|
|
19
|
-
return function(
|
|
20
|
-
t === void 0 ? (t =
|
|
21
|
-
const
|
|
22
|
-
let
|
|
23
|
-
for (; n <
|
|
24
|
-
c && (t[n] === 10 && (
|
|
25
|
-
let
|
|
26
|
-
for (; n <
|
|
19
|
+
return function(o) {
|
|
20
|
+
t === void 0 ? (t = o, n = 0, r = -1) : t = ne(t, o);
|
|
21
|
+
const d = t.length;
|
|
22
|
+
let y = 0;
|
|
23
|
+
for (; n < d; ) {
|
|
24
|
+
c && (t[n] === 10 && (y = ++n), c = !1);
|
|
25
|
+
let a = -1;
|
|
26
|
+
for (; n < d && a === -1; ++n)
|
|
27
27
|
switch (t[n]) {
|
|
28
28
|
case 58:
|
|
29
|
-
r === -1 && (r = n -
|
|
29
|
+
r === -1 && (r = n - y);
|
|
30
30
|
break;
|
|
31
31
|
case 13:
|
|
32
32
|
c = !0;
|
|
33
33
|
case 10:
|
|
34
|
-
|
|
34
|
+
a = n;
|
|
35
35
|
break;
|
|
36
36
|
}
|
|
37
|
-
if (
|
|
37
|
+
if (a === -1)
|
|
38
38
|
break;
|
|
39
|
-
e(t.subarray(
|
|
39
|
+
e(t.subarray(y, a), r), y = n, r = -1;
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
y === d ? t = void 0 : y !== 0 && (t = t.subarray(y), n -= y);
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
function re(e, t, n) {
|
|
45
|
-
let r =
|
|
45
|
+
let r = R();
|
|
46
46
|
const c = new TextDecoder();
|
|
47
|
-
return function(
|
|
48
|
-
if (
|
|
49
|
-
n == null || n(r), r =
|
|
50
|
-
else if (
|
|
51
|
-
const
|
|
52
|
-
switch (
|
|
47
|
+
return function(o, d) {
|
|
48
|
+
if (o.length === 0)
|
|
49
|
+
n == null || n(r), r = R();
|
|
50
|
+
else if (d > 0) {
|
|
51
|
+
const y = c.decode(o.subarray(0, d)), a = d + (o[d + 1] === 32 ? 2 : 1), s = c.decode(o.subarray(a));
|
|
52
|
+
switch (y) {
|
|
53
53
|
case "data":
|
|
54
54
|
r.data = r.data ? r.data + `
|
|
55
|
-
` +
|
|
55
|
+
` + s : s;
|
|
56
56
|
break;
|
|
57
57
|
case "event":
|
|
58
|
-
r.event =
|
|
58
|
+
r.event = s;
|
|
59
59
|
break;
|
|
60
60
|
case "id":
|
|
61
|
-
e(r.id =
|
|
61
|
+
e(r.id = s);
|
|
62
62
|
break;
|
|
63
63
|
case "retry":
|
|
64
|
-
const
|
|
65
|
-
isNaN(
|
|
64
|
+
const m = parseInt(s, 10);
|
|
65
|
+
isNaN(m) || t(r.retry = m);
|
|
66
66
|
break;
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -72,7 +72,7 @@ function ne(e, t) {
|
|
|
72
72
|
const n = new Uint8Array(e.length + t.length);
|
|
73
73
|
return n.set(e), n.set(t, e.length), n;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function R() {
|
|
76
76
|
return {
|
|
77
77
|
data: "",
|
|
78
78
|
event: "",
|
|
@@ -88,42 +88,42 @@ var oe = function(e, t) {
|
|
|
88
88
|
t.indexOf(r[c]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[c]) && (n[r[c]] = e[r[c]]);
|
|
89
89
|
return n;
|
|
90
90
|
};
|
|
91
|
-
const O = "text/event-stream", ae = 1e3,
|
|
91
|
+
const O = "text/event-stream", ae = 1e3, z = "last-event-id";
|
|
92
92
|
function se(e, t) {
|
|
93
|
-
var { signal: n, headers: r, onopen: c, onmessage:
|
|
94
|
-
return new Promise((
|
|
93
|
+
var { signal: n, headers: r, onopen: c, onmessage: l, onclose: o, onerror: d, openWhenHidden: y, fetch: a } = t, s = oe(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
94
|
+
return new Promise((m, u) => {
|
|
95
95
|
const f = Object.assign({}, r);
|
|
96
96
|
f.accept || (f.accept = O);
|
|
97
|
-
let
|
|
97
|
+
let g;
|
|
98
98
|
function p() {
|
|
99
|
-
|
|
99
|
+
g.abort(), document.hidden || x();
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
y || document.addEventListener("visibilitychange", p);
|
|
102
102
|
let h = ae, S = 0;
|
|
103
103
|
function b() {
|
|
104
|
-
document.removeEventListener("visibilitychange", p), window.clearTimeout(S),
|
|
104
|
+
document.removeEventListener("visibilitychange", p), window.clearTimeout(S), g.abort();
|
|
105
105
|
}
|
|
106
106
|
n == null || n.addEventListener("abort", () => {
|
|
107
|
-
b(),
|
|
107
|
+
b(), m();
|
|
108
108
|
});
|
|
109
|
-
const P =
|
|
109
|
+
const P = a ?? window.fetch, A = c ?? ie;
|
|
110
110
|
async function x() {
|
|
111
111
|
var M;
|
|
112
|
-
|
|
112
|
+
g = new AbortController();
|
|
113
113
|
try {
|
|
114
|
-
const I = await P(e, Object.assign(Object.assign({},
|
|
114
|
+
const I = await P(e, Object.assign(Object.assign({}, s), { headers: f, signal: g.signal }));
|
|
115
115
|
await A(I), await ee(I.body, te(re((v) => {
|
|
116
|
-
v ? f[
|
|
116
|
+
v ? f[z] = v : delete f[z];
|
|
117
117
|
}, (v) => {
|
|
118
118
|
h = v;
|
|
119
|
-
},
|
|
119
|
+
}, l))), o == null || o(), b(), m();
|
|
120
120
|
} catch (I) {
|
|
121
|
-
if (!
|
|
121
|
+
if (!g.signal.aborted)
|
|
122
122
|
try {
|
|
123
|
-
const v = (M =
|
|
123
|
+
const v = (M = d == null ? void 0 : d(I)) !== null && M !== void 0 ? M : h;
|
|
124
124
|
window.clearTimeout(S), S = window.setTimeout(x, v);
|
|
125
125
|
} catch (v) {
|
|
126
|
-
b(),
|
|
126
|
+
b(), u(v);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -162,25 +162,25 @@ class le {
|
|
|
162
162
|
connectStream(t) {
|
|
163
163
|
const n = t.stream.id, r = new AbortController();
|
|
164
164
|
this.eventSources.set(n, r);
|
|
165
|
-
const c = `${this.fency.baseUrl}/sse/streams/${n}`,
|
|
165
|
+
const c = `${this.fency.baseUrl}/sse/streams/${n}`, l = {
|
|
166
166
|
"X-Fency-Publishable-Key": this.fency.publishableKey,
|
|
167
167
|
"X-Fency-Stream-Token": t.stream.token
|
|
168
168
|
};
|
|
169
169
|
se(c, {
|
|
170
|
-
headers:
|
|
170
|
+
headers: l,
|
|
171
171
|
signal: r.signal,
|
|
172
|
-
async onopen(
|
|
173
|
-
if (!
|
|
174
|
-
throw new Error(`Client error ${
|
|
172
|
+
async onopen(o) {
|
|
173
|
+
if (!o.ok && o.status >= 400 && o.status < 500 && o.status !== 429)
|
|
174
|
+
throw new Error(`Client error ${o.status}`);
|
|
175
175
|
},
|
|
176
|
-
onmessage: (
|
|
177
|
-
if (
|
|
178
|
-
const
|
|
179
|
-
this.broadcast(
|
|
176
|
+
onmessage: (o) => {
|
|
177
|
+
if (o.data) {
|
|
178
|
+
const d = ce(o.data);
|
|
179
|
+
this.broadcast(d, n);
|
|
180
180
|
}
|
|
181
181
|
},
|
|
182
|
-
onerror: (
|
|
183
|
-
throw console.error("EventSource error for stream", n, ":",
|
|
182
|
+
onerror: (o) => {
|
|
183
|
+
throw console.error("EventSource error for stream", n, ":", o), this.broadcastError(n), o;
|
|
184
184
|
},
|
|
185
185
|
onclose() {
|
|
186
186
|
}
|
|
@@ -219,26 +219,26 @@ const de = 12e4, ue = (e) => {
|
|
|
219
219
|
function Le({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
|
|
220
220
|
const [r, c] = k(
|
|
221
221
|
null
|
|
222
|
-
), [
|
|
222
|
+
), [l, o] = k(!0), [d, y] = k(null), [a, s] = k([]), m = E(null), u = E(null);
|
|
223
223
|
w(() => {
|
|
224
224
|
e.then((h) => {
|
|
225
|
-
c(h),
|
|
225
|
+
c(h), o(!1);
|
|
226
226
|
}).catch((h) => {
|
|
227
|
-
|
|
227
|
+
y(h), o(!1);
|
|
228
228
|
});
|
|
229
229
|
}, [e]), w(() => {
|
|
230
|
-
r && !
|
|
230
|
+
r && !u.current && (u.current = new le(r));
|
|
231
231
|
}, [r]), w(() => {
|
|
232
|
-
|
|
233
|
-
}, [
|
|
232
|
+
u.current && u.current.updateStreams(a);
|
|
233
|
+
}, [a]), w(() => () => {
|
|
234
234
|
var h;
|
|
235
|
-
(h =
|
|
235
|
+
(h = u.current) == null || h.cleanup();
|
|
236
236
|
}, []);
|
|
237
|
-
const f =
|
|
237
|
+
const f = U(
|
|
238
238
|
async (h = 3e4) => {
|
|
239
|
-
if (
|
|
240
|
-
return
|
|
241
|
-
const S = Date.now(), b =
|
|
239
|
+
if (m.current)
|
|
240
|
+
return m.current;
|
|
241
|
+
const S = Date.now(), b = a.length > 0 ? a[a.length - 1] : null;
|
|
242
242
|
if (b && S - b.createdAt < h)
|
|
243
243
|
return b.stream;
|
|
244
244
|
const P = (async () => {
|
|
@@ -254,37 +254,37 @@ function Le({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
|
|
|
254
254
|
stream: x.stream,
|
|
255
255
|
createdAt: Date.now()
|
|
256
256
|
};
|
|
257
|
-
return
|
|
257
|
+
return s((I) => {
|
|
258
258
|
const v = [...I, M];
|
|
259
259
|
return ue(v);
|
|
260
|
-
}),
|
|
260
|
+
}), m.current = null, x.stream;
|
|
261
261
|
} else
|
|
262
|
-
throw
|
|
262
|
+
throw m.current = null, new Error("Failed to create stream");
|
|
263
263
|
})();
|
|
264
|
-
return
|
|
264
|
+
return m.current = P, P;
|
|
265
265
|
},
|
|
266
|
-
[r,
|
|
266
|
+
[r, a]
|
|
267
267
|
);
|
|
268
|
-
if (
|
|
268
|
+
if (d)
|
|
269
269
|
return /* @__PURE__ */ C("div", { children: [
|
|
270
270
|
"Fency error: ",
|
|
271
|
-
|
|
271
|
+
d.message
|
|
272
272
|
] });
|
|
273
273
|
if (!r)
|
|
274
274
|
return null;
|
|
275
|
-
const
|
|
275
|
+
const g = a.length > 0 ? a[a.length - 1] : null, p = {
|
|
276
276
|
fency: r,
|
|
277
|
-
loading:
|
|
278
|
-
error:
|
|
279
|
-
activeStreams:
|
|
280
|
-
latestStream:
|
|
281
|
-
eventManager:
|
|
277
|
+
loading: l,
|
|
278
|
+
error: d,
|
|
279
|
+
activeStreams: a,
|
|
280
|
+
latestStream: g,
|
|
281
|
+
eventManager: u.current,
|
|
282
282
|
getOrCreateStream: f
|
|
283
283
|
};
|
|
284
|
-
return /* @__PURE__ */
|
|
284
|
+
return /* @__PURE__ */ i(j.Provider, { value: p, children: n });
|
|
285
285
|
}
|
|
286
|
-
function
|
|
287
|
-
const e = X(
|
|
286
|
+
function F() {
|
|
287
|
+
const e = X(j);
|
|
288
288
|
if (e === void 0)
|
|
289
289
|
throw new Error("useFencyContext must be used within a FencyProvider");
|
|
290
290
|
return e;
|
|
@@ -313,30 +313,30 @@ const me = (e) => {
|
|
|
313
313
|
createdAt: e.createdAt,
|
|
314
314
|
data: JSON.parse(e.data)
|
|
315
315
|
}), pe = (e) => {
|
|
316
|
-
const t =
|
|
316
|
+
const t = F(), [n, r] = k(null), c = E(`subscriber-${Math.random().toString(36).substr(2, 9)}`);
|
|
317
317
|
return w(() => {
|
|
318
318
|
if (!t.eventManager) return;
|
|
319
|
-
const
|
|
320
|
-
onMessage: (
|
|
321
|
-
var
|
|
322
|
-
const
|
|
323
|
-
if (
|
|
324
|
-
switch (
|
|
319
|
+
const o = {
|
|
320
|
+
onMessage: (y, a) => {
|
|
321
|
+
var m, u, f;
|
|
322
|
+
const s = me(y);
|
|
323
|
+
if (s)
|
|
324
|
+
switch (s.type) {
|
|
325
325
|
case "StreamTimeout":
|
|
326
|
-
(
|
|
326
|
+
(m = e == null ? void 0 : e.onStreamTimeout) == null || m.call(e, s);
|
|
327
327
|
break;
|
|
328
328
|
case "StreamNotFound":
|
|
329
|
-
(
|
|
329
|
+
(u = e == null ? void 0 : e.onStreamNotFound) == null || u.call(e, s);
|
|
330
330
|
break;
|
|
331
331
|
case "AgentTaskProgressItemUpdated":
|
|
332
|
-
(f = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || f.call(e,
|
|
332
|
+
(f = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || f.call(e, s);
|
|
333
333
|
break;
|
|
334
334
|
}
|
|
335
335
|
},
|
|
336
|
-
onError: (
|
|
337
|
-
var
|
|
338
|
-
(
|
|
339
|
-
streamId:
|
|
336
|
+
onError: (y) => {
|
|
337
|
+
var a;
|
|
338
|
+
(a = e == null ? void 0 : e.onStreamError) == null || a.call(e, {
|
|
339
|
+
streamId: y,
|
|
340
340
|
error: {
|
|
341
341
|
code: "UnknownError",
|
|
342
342
|
message: "Unknown error in useStream"
|
|
@@ -346,22 +346,22 @@ const me = (e) => {
|
|
|
346
346
|
};
|
|
347
347
|
return t.eventManager.subscribe(
|
|
348
348
|
c.current,
|
|
349
|
-
|
|
349
|
+
o
|
|
350
350
|
);
|
|
351
351
|
}, [t.eventManager, e]), {
|
|
352
352
|
createStream: async () => {
|
|
353
353
|
try {
|
|
354
|
-
const
|
|
355
|
-
return r(
|
|
354
|
+
const o = await t.getOrCreateStream(3e4);
|
|
355
|
+
return r(o), {
|
|
356
356
|
type: "success",
|
|
357
|
-
stream:
|
|
357
|
+
stream: o
|
|
358
358
|
};
|
|
359
|
-
} catch (
|
|
359
|
+
} catch (o) {
|
|
360
360
|
return {
|
|
361
361
|
type: "error",
|
|
362
362
|
error: {
|
|
363
363
|
code: "UnknownError",
|
|
364
|
-
message:
|
|
364
|
+
message: o instanceof Error ? o.message : "Failed to create stream"
|
|
365
365
|
}
|
|
366
366
|
};
|
|
367
367
|
}
|
|
@@ -369,145 +369,145 @@ const me = (e) => {
|
|
|
369
369
|
stream: n
|
|
370
370
|
};
|
|
371
371
|
}, Ue = (e) => {
|
|
372
|
-
const t =
|
|
373
|
-
onAgentTaskProgressItemUpdated: (
|
|
374
|
-
var
|
|
375
|
-
if (!c.current.has(
|
|
376
|
-
const
|
|
377
|
-
if (
|
|
378
|
-
const f =
|
|
379
|
-
|
|
372
|
+
const t = F(), [n, r] = k([]), c = E(/* @__PURE__ */ new Set()), l = E(/* @__PURE__ */ new Map()), { createStream: o } = pe({
|
|
373
|
+
onAgentTaskProgressItemUpdated: (a) => {
|
|
374
|
+
var u;
|
|
375
|
+
if (!c.current.has(a.agentTaskId)) return;
|
|
376
|
+
const s = a.data;
|
|
377
|
+
if (s.taskType === "StreamingChatCompletion" && s.eventType === "Completed" || s.taskType === "StructuredChatCompletion" && s.eventType === "Completed" || s.taskType === "MemoryChatCompletion" && s.eventType === "Completed") {
|
|
378
|
+
const f = l.current.get(
|
|
379
|
+
a.agentTaskId
|
|
380
380
|
);
|
|
381
|
-
f && (
|
|
381
|
+
f && (l.current.delete(a.agentTaskId), f(s));
|
|
382
382
|
return;
|
|
383
383
|
}
|
|
384
|
-
(
|
|
385
|
-
(f) => f.map((
|
|
384
|
+
(u = e.onAgentTaskProgressItemUpdated) == null || u.call(e, a), r(
|
|
385
|
+
(f) => f.map((g) => {
|
|
386
386
|
var S;
|
|
387
|
-
if (((S =
|
|
388
|
-
return
|
|
389
|
-
const h =
|
|
390
|
-
(b) => b.progressItemId ===
|
|
391
|
-
) ?
|
|
392
|
-
(b) => b.progressItemId ===
|
|
393
|
-
) : [...
|
|
394
|
-
return { ...
|
|
387
|
+
if (((S = g.confirmedData) == null ? void 0 : S.taskId) !== a.agentTaskId)
|
|
388
|
+
return g;
|
|
389
|
+
const h = g.progressItems.some(
|
|
390
|
+
(b) => b.progressItemId === a.progressItemId
|
|
391
|
+
) ? g.progressItems.map(
|
|
392
|
+
(b) => b.progressItemId === a.progressItemId ? a : b
|
|
393
|
+
) : [...g.progressItems, a];
|
|
394
|
+
return { ...g, progressItems: h };
|
|
395
395
|
})
|
|
396
396
|
);
|
|
397
397
|
},
|
|
398
|
-
onStreamError: (
|
|
399
|
-
var
|
|
400
|
-
(
|
|
401
|
-
const
|
|
402
|
-
return
|
|
403
|
-
...
|
|
398
|
+
onStreamError: (a) => {
|
|
399
|
+
var s;
|
|
400
|
+
(s = e == null ? void 0 : e.onStreamError) == null || s.call(e, a), r((m) => {
|
|
401
|
+
const u = m.find((f) => f.streamId === a.streamId);
|
|
402
|
+
return u ? [
|
|
403
|
+
...m.filter((f) => f.streamId !== a.streamId),
|
|
404
404
|
{
|
|
405
|
-
...
|
|
405
|
+
...u,
|
|
406
406
|
loading: !1,
|
|
407
|
-
error:
|
|
407
|
+
error: a.error
|
|
408
408
|
}
|
|
409
|
-
] :
|
|
409
|
+
] : m;
|
|
410
410
|
});
|
|
411
411
|
},
|
|
412
|
-
onStreamNotFound: (
|
|
413
|
-
var
|
|
414
|
-
(
|
|
412
|
+
onStreamNotFound: (a) => {
|
|
413
|
+
var s;
|
|
414
|
+
(s = e == null ? void 0 : e.onStreamNotFound) == null || s.call(e, a);
|
|
415
415
|
},
|
|
416
|
-
onStreamTimeout: (
|
|
417
|
-
var
|
|
418
|
-
(
|
|
416
|
+
onStreamTimeout: (a) => {
|
|
417
|
+
var s;
|
|
418
|
+
(s = e == null ? void 0 : e.onStreamTimeout) == null || s.call(e, a);
|
|
419
419
|
}
|
|
420
|
-
}),
|
|
421
|
-
async (
|
|
422
|
-
const
|
|
423
|
-
if (
|
|
420
|
+
}), d = U(
|
|
421
|
+
async (a, s) => {
|
|
422
|
+
const m = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, u = await o();
|
|
423
|
+
if (u.type === "success") {
|
|
424
424
|
r([
|
|
425
425
|
...n,
|
|
426
426
|
{
|
|
427
|
-
taskKey:
|
|
428
|
-
streamId:
|
|
427
|
+
taskKey: m,
|
|
428
|
+
streamId: u.stream.id,
|
|
429
429
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
430
430
|
confirmedData: null,
|
|
431
431
|
error: null,
|
|
432
|
-
params:
|
|
432
|
+
params: a,
|
|
433
433
|
progressItems: [],
|
|
434
434
|
loading: !0,
|
|
435
|
-
loadingText:
|
|
435
|
+
loadingText: s == null ? void 0 : s.loadingText
|
|
436
436
|
}
|
|
437
437
|
]);
|
|
438
|
-
const { clientToken: f } = await e.fetchCreateAgentTaskClientToken(
|
|
438
|
+
const { clientToken: f } = await e.fetchCreateAgentTaskClientToken(a.type), g = await q({
|
|
439
439
|
pk: t.fency.publishableKey,
|
|
440
440
|
baseUrl: t.fency.baseUrl,
|
|
441
441
|
clientToken: f,
|
|
442
|
-
streamToken:
|
|
442
|
+
streamToken: u.stream.token,
|
|
443
443
|
request: {
|
|
444
|
-
streamingChatCompletionTask:
|
|
445
|
-
messages:
|
|
446
|
-
model:
|
|
444
|
+
streamingChatCompletionTask: a.type === "StreamingChatCompletion" ? {
|
|
445
|
+
messages: a.messages,
|
|
446
|
+
model: a.model
|
|
447
447
|
} : void 0,
|
|
448
|
-
structuredChatCompletionTask:
|
|
449
|
-
messages:
|
|
450
|
-
jsonSchema:
|
|
451
|
-
model:
|
|
448
|
+
structuredChatCompletionTask: a.type === "StructuredChatCompletion" ? {
|
|
449
|
+
messages: a.messages,
|
|
450
|
+
jsonSchema: a.jsonSchema,
|
|
451
|
+
model: a.model
|
|
452
452
|
} : void 0,
|
|
453
|
-
memoryChatCompletionTask:
|
|
454
|
-
messages:
|
|
455
|
-
model:
|
|
453
|
+
memoryChatCompletionTask: a.type === "MemoryChatCompletion" ? {
|
|
454
|
+
messages: a.messages,
|
|
455
|
+
model: a.model
|
|
456
456
|
} : void 0
|
|
457
457
|
}
|
|
458
458
|
});
|
|
459
|
-
if (
|
|
459
|
+
if (g.type === "success" && g.agentTask) {
|
|
460
460
|
c.current.add(
|
|
461
|
-
|
|
461
|
+
g.agentTask.id
|
|
462
462
|
), r((h) => [
|
|
463
|
-
...h.filter((S) => S.taskKey !==
|
|
463
|
+
...h.filter((S) => S.taskKey !== m),
|
|
464
464
|
{
|
|
465
|
-
taskKey:
|
|
466
|
-
streamId:
|
|
465
|
+
taskKey: m,
|
|
466
|
+
streamId: u.stream.id,
|
|
467
467
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
468
|
-
taskId:
|
|
469
|
-
createdAt:
|
|
468
|
+
taskId: g.agentTask.id,
|
|
469
|
+
createdAt: g.agentTask.createdAt,
|
|
470
470
|
error: null,
|
|
471
|
-
params:
|
|
471
|
+
params: a,
|
|
472
472
|
progressItems: [],
|
|
473
473
|
loading: !0,
|
|
474
|
-
loadingText:
|
|
474
|
+
loadingText: s == null ? void 0 : s.loadingText,
|
|
475
475
|
confirmedData: {
|
|
476
|
-
taskId:
|
|
477
|
-
createdAt:
|
|
476
|
+
taskId: g.agentTask.id,
|
|
477
|
+
createdAt: g.agentTask.createdAt
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
480
|
]);
|
|
481
481
|
const p = await new Promise((h) => {
|
|
482
|
-
|
|
483
|
-
|
|
482
|
+
l.current.set(
|
|
483
|
+
g.agentTask.id,
|
|
484
484
|
h
|
|
485
485
|
);
|
|
486
486
|
});
|
|
487
487
|
return {
|
|
488
488
|
type: "success",
|
|
489
|
-
streamId:
|
|
490
|
-
agentTaskId:
|
|
489
|
+
streamId: u.stream.id,
|
|
490
|
+
agentTaskId: g.agentTask.id,
|
|
491
491
|
response: p
|
|
492
492
|
};
|
|
493
493
|
} else {
|
|
494
|
-
if (
|
|
494
|
+
if (g.type === "error")
|
|
495
495
|
return r((p) => [
|
|
496
|
-
...p.filter((h) => h.taskKey !==
|
|
496
|
+
...p.filter((h) => h.taskKey !== m),
|
|
497
497
|
{
|
|
498
|
-
taskKey:
|
|
498
|
+
taskKey: m,
|
|
499
499
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
500
|
-
streamId:
|
|
501
|
-
params:
|
|
502
|
-
error:
|
|
500
|
+
streamId: u.stream.id,
|
|
501
|
+
params: a,
|
|
502
|
+
error: g.error,
|
|
503
503
|
progressItems: [],
|
|
504
504
|
loading: !1,
|
|
505
|
-
loadingText:
|
|
505
|
+
loadingText: s == null ? void 0 : s.loadingText,
|
|
506
506
|
confirmedData: null
|
|
507
507
|
}
|
|
508
508
|
]), {
|
|
509
509
|
type: "error",
|
|
510
|
-
error:
|
|
510
|
+
error: g.error
|
|
511
511
|
};
|
|
512
512
|
{
|
|
513
513
|
const p = {
|
|
@@ -515,16 +515,16 @@ const me = (e) => {
|
|
|
515
515
|
code: "UnknownError"
|
|
516
516
|
};
|
|
517
517
|
return r((h) => [
|
|
518
|
-
...h.filter((S) => S.taskKey !==
|
|
518
|
+
...h.filter((S) => S.taskKey !== m),
|
|
519
519
|
{
|
|
520
|
-
taskKey:
|
|
520
|
+
taskKey: m,
|
|
521
521
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
522
|
-
streamId:
|
|
522
|
+
streamId: u.stream.id,
|
|
523
523
|
error: p,
|
|
524
|
-
params:
|
|
524
|
+
params: a,
|
|
525
525
|
progressItems: [],
|
|
526
526
|
loading: !1,
|
|
527
|
-
loadingText:
|
|
527
|
+
loadingText: s == null ? void 0 : s.loadingText,
|
|
528
528
|
confirmedData: null
|
|
529
529
|
}
|
|
530
530
|
]), {
|
|
@@ -534,34 +534,34 @@ const me = (e) => {
|
|
|
534
534
|
}
|
|
535
535
|
}
|
|
536
536
|
} else
|
|
537
|
-
return console.error(
|
|
537
|
+
return console.error(u.error), u;
|
|
538
538
|
},
|
|
539
|
-
[t, n,
|
|
540
|
-
),
|
|
539
|
+
[t, n, o]
|
|
540
|
+
), y = W(() => {
|
|
541
541
|
if (n.length !== 0)
|
|
542
|
-
return [...n].sort((
|
|
542
|
+
return [...n].sort((a, s) => new Date(s.triggeredAt).getTime() - new Date(a.triggeredAt).getTime())[0];
|
|
543
543
|
}, [n]);
|
|
544
544
|
return w(() => () => {
|
|
545
|
-
c.current.clear(),
|
|
545
|
+
c.current.clear(), l.current.clear();
|
|
546
546
|
}, []), {
|
|
547
547
|
agentTasks: n,
|
|
548
|
-
createAgentTask:
|
|
549
|
-
latest:
|
|
548
|
+
createAgentTask: d,
|
|
549
|
+
latest: y
|
|
550
550
|
};
|
|
551
551
|
};
|
|
552
552
|
function Se(e) {
|
|
553
553
|
return e.progressItems.map((t, n) => {
|
|
554
554
|
const r = e.progressItems[n + 1], c = r != null;
|
|
555
|
-
let
|
|
555
|
+
let l;
|
|
556
556
|
if (r != null && r.createdAt) {
|
|
557
|
-
const
|
|
558
|
-
|
|
557
|
+
const o = new Date(t.createdAt).getTime(), d = new Date(r.createdAt).getTime();
|
|
558
|
+
l = Math.round((d - o) / 1e3);
|
|
559
559
|
}
|
|
560
560
|
return {
|
|
561
561
|
item: t,
|
|
562
562
|
completed: c,
|
|
563
563
|
isLatest: n === e.progressItems.length - 1,
|
|
564
|
-
durationSeconds:
|
|
564
|
+
durationSeconds: l
|
|
565
565
|
};
|
|
566
566
|
});
|
|
567
567
|
}
|
|
@@ -571,21 +571,21 @@ function D({
|
|
|
571
571
|
delay: n = 0,
|
|
572
572
|
repeat: r = !0,
|
|
573
573
|
repeatDelay: c = 0.5,
|
|
574
|
-
className:
|
|
575
|
-
startOnView:
|
|
576
|
-
once:
|
|
577
|
-
inViewMargin:
|
|
578
|
-
spread:
|
|
579
|
-
color:
|
|
580
|
-
shimmerColor:
|
|
581
|
-
direction:
|
|
574
|
+
className: l,
|
|
575
|
+
startOnView: o = !1,
|
|
576
|
+
once: d = !1,
|
|
577
|
+
inViewMargin: y,
|
|
578
|
+
spread: a = 2,
|
|
579
|
+
color: s = "#999",
|
|
580
|
+
shimmerColor: m = "#000",
|
|
581
|
+
direction: u = "fromBottom"
|
|
582
582
|
}) {
|
|
583
|
-
const f = E(null),
|
|
584
|
-
return /* @__PURE__ */
|
|
583
|
+
const f = E(null), g = Q(f, { once: d, margin: y }), p = W(() => e.length * a, [e, a]), h = !o || g, S = u === "fromBottom" ? "100% center" : "-100% center", b = u === "fromBottom" ? "0% center" : "200% center";
|
|
584
|
+
return /* @__PURE__ */ i(
|
|
585
585
|
T.span,
|
|
586
586
|
{
|
|
587
587
|
ref: f,
|
|
588
|
-
className:
|
|
588
|
+
className: l,
|
|
589
589
|
style: {
|
|
590
590
|
position: "relative",
|
|
591
591
|
display: "inline-block",
|
|
@@ -596,8 +596,8 @@ function D({
|
|
|
596
596
|
WebkitTextFillColor: "transparent",
|
|
597
597
|
backgroundRepeat: "no-repeat, padding-box",
|
|
598
598
|
"--spread": `${p}px`,
|
|
599
|
-
"--base-color":
|
|
600
|
-
"--shimmer-color":
|
|
599
|
+
"--base-color": s,
|
|
600
|
+
"--shimmer-color": m,
|
|
601
601
|
"--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
|
|
602
602
|
backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
|
|
603
603
|
},
|
|
@@ -661,21 +661,21 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
661
661
|
const t = e[e.length - 1];
|
|
662
662
|
if (!t) return null;
|
|
663
663
|
const n = be(t);
|
|
664
|
-
return /* @__PURE__ */
|
|
664
|
+
return /* @__PURE__ */ i("div", { className: "simple-mode-container", children: /* @__PURE__ */ i($, { mode: "wait", children: /* @__PURE__ */ i(
|
|
665
665
|
T.div,
|
|
666
666
|
{
|
|
667
667
|
initial: { opacity: 0, y: 10 },
|
|
668
668
|
animate: { opacity: 1, y: 0 },
|
|
669
669
|
exit: { opacity: 0, y: -10 },
|
|
670
670
|
transition: { duration: 0.3 },
|
|
671
|
-
children: t.completed ? /* @__PURE__ */
|
|
671
|
+
children: t.completed ? /* @__PURE__ */ i(
|
|
672
672
|
"div",
|
|
673
673
|
{
|
|
674
674
|
className: "simple-mode-title",
|
|
675
675
|
style: { color: "#666" },
|
|
676
676
|
children: n
|
|
677
677
|
}
|
|
678
|
-
) : /* @__PURE__ */
|
|
678
|
+
) : /* @__PURE__ */ i(
|
|
679
679
|
D,
|
|
680
680
|
{
|
|
681
681
|
text: n,
|
|
@@ -840,32 +840,32 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
840
840
|
italic: {
|
|
841
841
|
fontStyle: "italic"
|
|
842
842
|
}
|
|
843
|
-
},
|
|
843
|
+
}, B = ({
|
|
844
844
|
text: e
|
|
845
|
-
}) => /* @__PURE__ */
|
|
845
|
+
}) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
|
|
846
846
|
T.div,
|
|
847
847
|
{
|
|
848
848
|
className: "fency-markdown-body-raw",
|
|
849
849
|
initial: { opacity: 0, y: -10 },
|
|
850
850
|
animate: { opacity: 1, y: 0 },
|
|
851
851
|
transition: { duration: 0.3, delay: 0 },
|
|
852
|
-
children: /* @__PURE__ */
|
|
852
|
+
children: /* @__PURE__ */ i(
|
|
853
853
|
Y,
|
|
854
854
|
{
|
|
855
855
|
remarkPlugins: [Z],
|
|
856
856
|
components: {
|
|
857
857
|
code(t) {
|
|
858
|
-
const { children: n, className: r, node: c, ref:
|
|
859
|
-
return
|
|
860
|
-
|
|
858
|
+
const { children: n, className: r, node: c, ref: l, ...o } = t, d = /language-(\w+)/.exec(r || "");
|
|
859
|
+
return d ? /* @__PURE__ */ i(
|
|
860
|
+
N,
|
|
861
861
|
{
|
|
862
|
-
...
|
|
862
|
+
...o,
|
|
863
863
|
PreTag: "div",
|
|
864
864
|
children: String(n).replace(/\n$/, ""),
|
|
865
|
-
language:
|
|
865
|
+
language: d[1],
|
|
866
866
|
style: H
|
|
867
867
|
}
|
|
868
|
-
) : /* @__PURE__ */
|
|
868
|
+
) : /* @__PURE__ */ i("code", { ...o, className: r, children: String(n) });
|
|
869
869
|
}
|
|
870
870
|
},
|
|
871
871
|
children: e
|
|
@@ -874,19 +874,19 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
874
874
|
}
|
|
875
875
|
) }), Te = ({ data: e }) => {
|
|
876
876
|
const t = JSON.stringify(e.json, null, 2);
|
|
877
|
-
return /* @__PURE__ */
|
|
877
|
+
return /* @__PURE__ */ i("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ i(
|
|
878
878
|
T.div,
|
|
879
879
|
{
|
|
880
880
|
initial: { opacity: 0, y: -10 },
|
|
881
881
|
animate: { opacity: 1, y: 0 },
|
|
882
882
|
transition: { duration: 0.3, delay: 0 },
|
|
883
|
-
children: /* @__PURE__ */
|
|
883
|
+
children: /* @__PURE__ */ i(N, { language: "json", style: H, PreTag: "div", children: t })
|
|
884
884
|
}
|
|
885
885
|
) });
|
|
886
886
|
}, Ce = ({ data: e, isLatest: t = !1, durationSeconds: n }) => {
|
|
887
887
|
const r = `Searching: ${e.queryDescription}`;
|
|
888
888
|
return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
|
|
889
|
-
/* @__PURE__ */
|
|
889
|
+
/* @__PURE__ */ i(
|
|
890
890
|
T.div,
|
|
891
891
|
{
|
|
892
892
|
style: {
|
|
@@ -898,7 +898,7 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
898
898
|
initial: { opacity: 0, y: -10 },
|
|
899
899
|
animate: { opacity: 1, y: 0 },
|
|
900
900
|
transition: { duration: 0.3, delay: 0 },
|
|
901
|
-
children: t && !n ? /* @__PURE__ */
|
|
901
|
+
children: t && !n ? /* @__PURE__ */ i(
|
|
902
902
|
D,
|
|
903
903
|
{
|
|
904
904
|
text: r,
|
|
@@ -907,7 +907,7 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
907
907
|
color: "#999",
|
|
908
908
|
shimmerColor: "#000"
|
|
909
909
|
}
|
|
910
|
-
) : /* @__PURE__ */
|
|
910
|
+
) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: r })
|
|
911
911
|
}
|
|
912
912
|
),
|
|
913
913
|
n !== void 0 && /* @__PURE__ */ C(
|
|
@@ -930,7 +930,7 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
930
930
|
}, ke = ({ isLatest: e = !1, durationSeconds: t }) => {
|
|
931
931
|
const n = "Adding sources...";
|
|
932
932
|
return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
|
|
933
|
-
/* @__PURE__ */
|
|
933
|
+
/* @__PURE__ */ i(
|
|
934
934
|
T.div,
|
|
935
935
|
{
|
|
936
936
|
style: {
|
|
@@ -942,7 +942,7 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
942
942
|
initial: { opacity: 0, y: -10 },
|
|
943
943
|
animate: { opacity: 1, y: 0 },
|
|
944
944
|
transition: { duration: 0.3, delay: 0 },
|
|
945
|
-
children: e && !t ? /* @__PURE__ */
|
|
945
|
+
children: e && !t ? /* @__PURE__ */ i(
|
|
946
946
|
D,
|
|
947
947
|
{
|
|
948
948
|
text: n,
|
|
@@ -951,7 +951,7 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
951
951
|
color: "#999",
|
|
952
952
|
shimmerColor: "#000"
|
|
953
953
|
}
|
|
954
|
-
) : /* @__PURE__ */
|
|
954
|
+
) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: n })
|
|
955
955
|
}
|
|
956
956
|
),
|
|
957
957
|
t !== void 0 && /* @__PURE__ */ C(
|
|
@@ -972,7 +972,7 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
972
972
|
)
|
|
973
973
|
] });
|
|
974
974
|
}, xe = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
|
|
975
|
-
/* @__PURE__ */
|
|
975
|
+
/* @__PURE__ */ i(
|
|
976
976
|
T.div,
|
|
977
977
|
{
|
|
978
978
|
style: {
|
|
@@ -989,7 +989,7 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
989
989
|
children: "Sources"
|
|
990
990
|
}
|
|
991
991
|
),
|
|
992
|
-
/* @__PURE__ */
|
|
992
|
+
/* @__PURE__ */ i("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.length === 0 ? /* @__PURE__ */ i("span", { style: { fontSize: "13px", color: "#888" }, children: "No sources" }) : e.sources.map((n, r) => /* @__PURE__ */ i(
|
|
993
993
|
Ee,
|
|
994
994
|
{
|
|
995
995
|
source: n,
|
|
@@ -1008,16 +1008,16 @@ function we(e) {
|
|
|
1008
1008
|
return `pages ${e.slice(0, -1).join(", ")} and ${t}`;
|
|
1009
1009
|
}
|
|
1010
1010
|
const Ee = ({ source: e, index: t, onSourceClick: n }) => {
|
|
1011
|
-
const [r, c] = k(!1),
|
|
1011
|
+
const [r, c] = k(!1), l = !!n, o = e.pageNumbers ?? [], d = we(o);
|
|
1012
1012
|
return /* @__PURE__ */ C(
|
|
1013
1013
|
T.div,
|
|
1014
1014
|
{
|
|
1015
1015
|
initial: { opacity: 0, scale: 0.9 },
|
|
1016
1016
|
animate: { opacity: 1, scale: 1 },
|
|
1017
1017
|
transition: { duration: 0.25, delay: t * 0.05 },
|
|
1018
|
-
onClick:
|
|
1019
|
-
onMouseEnter:
|
|
1020
|
-
onMouseLeave:
|
|
1018
|
+
onClick: l ? () => n(e.memoryId) : void 0,
|
|
1019
|
+
onMouseEnter: l ? () => c(!0) : void 0,
|
|
1020
|
+
onMouseLeave: l ? () => c(!1) : void 0,
|
|
1021
1021
|
style: {
|
|
1022
1022
|
display: "inline-flex",
|
|
1023
1023
|
flexDirection: "column",
|
|
@@ -1026,13 +1026,13 @@ const Ee = ({ source: e, index: t, onSourceClick: n }) => {
|
|
|
1026
1026
|
borderRadius: "6px",
|
|
1027
1027
|
border: "1px solid #e0e0e0",
|
|
1028
1028
|
backgroundColor: r ? "#f5f5f5" : "transparent",
|
|
1029
|
-
cursor:
|
|
1029
|
+
cursor: l ? "pointer" : "default",
|
|
1030
1030
|
transition: "background-color 0.15s ease",
|
|
1031
1031
|
userSelect: "none"
|
|
1032
1032
|
},
|
|
1033
1033
|
children: [
|
|
1034
|
-
/* @__PURE__ */
|
|
1035
|
-
|
|
1034
|
+
/* @__PURE__ */ i("span", { style: { fontSize: "13px", fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
|
|
1035
|
+
d && /* @__PURE__ */ i("span", { style: { fontSize: "12px", color: "#666" }, children: d })
|
|
1036
1036
|
]
|
|
1037
1037
|
}
|
|
1038
1038
|
);
|
|
@@ -1041,13 +1041,13 @@ function Ie({
|
|
|
1041
1041
|
eventType: e,
|
|
1042
1042
|
completed: t
|
|
1043
1043
|
}) {
|
|
1044
|
-
return e === "ExploreMemoryError" ? /* @__PURE__ */
|
|
1044
|
+
return e === "ExploreMemoryError" ? /* @__PURE__ */ i("span", { style: { color: "#c62828", fontSize: 14, fontWeight: 600 }, children: "✗" }) : e === "ExploreMemoryResult" ? /* @__PURE__ */ i("span", { style: { color: "#999", fontSize: 14, fontWeight: 600 }, children: "✓" }) : e === "ExploreMemoryStart" && t ? /* @__PURE__ */ i("span", { style: { color: "#999", fontSize: 14, fontWeight: 600 }, children: "✓" }) : null;
|
|
1045
1045
|
}
|
|
1046
|
-
const
|
|
1047
|
-
const [r, c] = k(!1),
|
|
1046
|
+
const L = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
1047
|
+
const [r, c] = k(!1), l = e.eventType === "ExploreMemoryResult" ? e.result : void 0, o = l != null && l.length > L, d = l != null ? r || !o ? l : `${l.slice(0, L)}...` : void 0, y = o;
|
|
1048
1048
|
if (e.eventType === "ExploreMemoryStart" && !t) {
|
|
1049
|
-
const
|
|
1050
|
-
return /* @__PURE__ */
|
|
1049
|
+
const s = `Exploring ${e.memoryTitle}...`;
|
|
1050
|
+
return /* @__PURE__ */ i(
|
|
1051
1051
|
"div",
|
|
1052
1052
|
{
|
|
1053
1053
|
style: {
|
|
@@ -1055,26 +1055,26 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1055
1055
|
display: "flex",
|
|
1056
1056
|
alignItems: "center"
|
|
1057
1057
|
},
|
|
1058
|
-
children: n ? /* @__PURE__ */
|
|
1058
|
+
children: n ? /* @__PURE__ */ i(
|
|
1059
1059
|
D,
|
|
1060
1060
|
{
|
|
1061
|
-
text:
|
|
1061
|
+
text: s,
|
|
1062
1062
|
duration: 2.5,
|
|
1063
1063
|
repeat: !0,
|
|
1064
1064
|
color: "#999",
|
|
1065
1065
|
shimmerColor: "#000"
|
|
1066
1066
|
}
|
|
1067
|
-
) : /* @__PURE__ */
|
|
1067
|
+
) : /* @__PURE__ */ i("span", { style: { fontSize: 13, color: "#999" }, children: s })
|
|
1068
1068
|
}
|
|
1069
1069
|
);
|
|
1070
1070
|
}
|
|
1071
|
-
return /* @__PURE__ */
|
|
1071
|
+
return /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ C(
|
|
1072
1072
|
T.div,
|
|
1073
1073
|
{
|
|
1074
1074
|
initial: { opacity: 0 },
|
|
1075
1075
|
animate: { opacity: 1 },
|
|
1076
1076
|
transition: { duration: 0.25 },
|
|
1077
|
-
onClick:
|
|
1077
|
+
onClick: y ? () => c((s) => !s) : void 0,
|
|
1078
1078
|
style: {
|
|
1079
1079
|
paddingBottom: "12px",
|
|
1080
1080
|
borderBottom: "1px solid #eee",
|
|
@@ -1083,10 +1083,10 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1083
1083
|
alignItems: "flex-start",
|
|
1084
1084
|
gap: "10px",
|
|
1085
1085
|
minWidth: 0,
|
|
1086
|
-
cursor:
|
|
1086
|
+
cursor: y ? "pointer" : "default"
|
|
1087
1087
|
},
|
|
1088
1088
|
children: [
|
|
1089
|
-
/* @__PURE__ */
|
|
1089
|
+
/* @__PURE__ */ i(
|
|
1090
1090
|
"div",
|
|
1091
1091
|
{
|
|
1092
1092
|
style: {
|
|
@@ -1096,7 +1096,7 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1096
1096
|
flexShrink: 0,
|
|
1097
1097
|
width: 20
|
|
1098
1098
|
},
|
|
1099
|
-
children: /* @__PURE__ */
|
|
1099
|
+
children: /* @__PURE__ */ i(Ie, { eventType: e.eventType, completed: t })
|
|
1100
1100
|
}
|
|
1101
1101
|
),
|
|
1102
1102
|
/* @__PURE__ */ C(
|
|
@@ -1109,8 +1109,8 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1109
1109
|
minWidth: 0
|
|
1110
1110
|
},
|
|
1111
1111
|
children: [
|
|
1112
|
-
/* @__PURE__ */
|
|
1113
|
-
|
|
1112
|
+
/* @__PURE__ */ i("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
|
|
1113
|
+
d != null && /* @__PURE__ */ i(
|
|
1114
1114
|
"span",
|
|
1115
1115
|
{
|
|
1116
1116
|
style: {
|
|
@@ -1119,10 +1119,10 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1119
1119
|
lineHeight: 1.4,
|
|
1120
1120
|
whiteSpace: r ? "pre-wrap" : void 0
|
|
1121
1121
|
},
|
|
1122
|
-
children:
|
|
1122
|
+
children: d
|
|
1123
1123
|
}
|
|
1124
1124
|
),
|
|
1125
|
-
|
|
1125
|
+
y && /* @__PURE__ */ i(
|
|
1126
1126
|
"span",
|
|
1127
1127
|
{
|
|
1128
1128
|
style: {
|
|
@@ -1141,58 +1141,56 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1141
1141
|
) });
|
|
1142
1142
|
}, Me = ({
|
|
1143
1143
|
progressViewItems: e,
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
loadingText: r,
|
|
1147
|
-
onSourceClick: c
|
|
1144
|
+
loadingText: t,
|
|
1145
|
+
onSourceClick: n
|
|
1148
1146
|
}) => {
|
|
1149
|
-
const
|
|
1147
|
+
const r = E(null);
|
|
1150
1148
|
w(() => {
|
|
1151
|
-
|
|
1149
|
+
r.current && (r.current.scrollTop = r.current.scrollHeight);
|
|
1152
1150
|
}, [e.length]);
|
|
1153
|
-
const
|
|
1154
|
-
const
|
|
1155
|
-
if (
|
|
1156
|
-
return /* @__PURE__ */
|
|
1157
|
-
if (
|
|
1158
|
-
return /* @__PURE__ */
|
|
1159
|
-
if (
|
|
1160
|
-
switch (
|
|
1151
|
+
const c = (l) => {
|
|
1152
|
+
const o = l.item.data;
|
|
1153
|
+
if (o.taskType === "StreamingChatCompletion" && o.eventType === "Text")
|
|
1154
|
+
return /* @__PURE__ */ i(B, { text: o.text });
|
|
1155
|
+
if (o.taskType === "StructuredChatCompletion" && o.eventType === "Json")
|
|
1156
|
+
return /* @__PURE__ */ i(Te, { data: o });
|
|
1157
|
+
if (o.taskType === "MemoryChatCompletion")
|
|
1158
|
+
switch (o.eventType) {
|
|
1161
1159
|
case "Text":
|
|
1162
|
-
return /* @__PURE__ */
|
|
1160
|
+
return /* @__PURE__ */ i(B, { text: o.text });
|
|
1163
1161
|
case "Search":
|
|
1164
|
-
return /* @__PURE__ */
|
|
1162
|
+
return /* @__PURE__ */ i(
|
|
1165
1163
|
Ce,
|
|
1166
1164
|
{
|
|
1167
|
-
data:
|
|
1165
|
+
data: o,
|
|
1168
1166
|
isLatest: l.isLatest,
|
|
1169
1167
|
durationSeconds: l.durationSeconds
|
|
1170
1168
|
}
|
|
1171
1169
|
);
|
|
1172
1170
|
case "FindSources":
|
|
1173
|
-
return /* @__PURE__ */
|
|
1171
|
+
return /* @__PURE__ */ i(
|
|
1174
1172
|
ke,
|
|
1175
1173
|
{
|
|
1176
|
-
data:
|
|
1174
|
+
data: o,
|
|
1177
1175
|
isLatest: l.isLatest,
|
|
1178
1176
|
durationSeconds: l.durationSeconds
|
|
1179
1177
|
}
|
|
1180
1178
|
);
|
|
1181
1179
|
case "SourcesResult":
|
|
1182
|
-
return /* @__PURE__ */
|
|
1180
|
+
return /* @__PURE__ */ i(
|
|
1183
1181
|
xe,
|
|
1184
1182
|
{
|
|
1185
|
-
data:
|
|
1186
|
-
onSourceClick:
|
|
1183
|
+
data: o,
|
|
1184
|
+
onSourceClick: n
|
|
1187
1185
|
}
|
|
1188
1186
|
);
|
|
1189
1187
|
case "ExploreMemoryStart":
|
|
1190
1188
|
case "ExploreMemoryResult":
|
|
1191
1189
|
case "ExploreMemoryError":
|
|
1192
|
-
return /* @__PURE__ */
|
|
1190
|
+
return /* @__PURE__ */ i(
|
|
1193
1191
|
Ae,
|
|
1194
1192
|
{
|
|
1195
|
-
data:
|
|
1193
|
+
data: o,
|
|
1196
1194
|
completed: l.completed,
|
|
1197
1195
|
isLatest: l.isLatest
|
|
1198
1196
|
}
|
|
@@ -1200,19 +1198,19 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1200
1198
|
case "Completed":
|
|
1201
1199
|
return null;
|
|
1202
1200
|
}
|
|
1203
|
-
return
|
|
1201
|
+
return o.taskType === "StreamingChatCompletion" && o.eventType === "Completed" || o.taskType === "StructuredChatCompletion" && o.eventType === "Completed", null;
|
|
1204
1202
|
};
|
|
1205
|
-
return e.length === 0 ? /* @__PURE__ */
|
|
1203
|
+
return e.length === 0 ? /* @__PURE__ */ i("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ i(
|
|
1206
1204
|
D,
|
|
1207
1205
|
{
|
|
1208
|
-
text:
|
|
1206
|
+
text: t ?? "Processing your task...",
|
|
1209
1207
|
duration: 1.5,
|
|
1210
1208
|
repeat: !0,
|
|
1211
1209
|
repeatDelay: 0,
|
|
1212
1210
|
color: "#999",
|
|
1213
1211
|
shimmerColor: "#000"
|
|
1214
1212
|
}
|
|
1215
|
-
) }) : /* @__PURE__ */
|
|
1213
|
+
) }) : /* @__PURE__ */ i("div", { id: "agent-task-progress-verbose", ref: r, children: /* @__PURE__ */ i($, { children: e.map((l, o) => /* @__PURE__ */ i(
|
|
1216
1214
|
T.div,
|
|
1217
1215
|
{
|
|
1218
1216
|
id: `agent-task-progress-item-${l.item.progressItemId}`,
|
|
@@ -1220,29 +1218,26 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1220
1218
|
animate: { opacity: 1, y: 0 },
|
|
1221
1219
|
transition: {
|
|
1222
1220
|
duration: 0.4,
|
|
1223
|
-
delay:
|
|
1221
|
+
delay: o * 0.1,
|
|
1224
1222
|
ease: "easeOut"
|
|
1225
1223
|
},
|
|
1226
|
-
children:
|
|
1224
|
+
children: c(l)
|
|
1227
1225
|
},
|
|
1228
1226
|
l.item.progressItemId
|
|
1229
1227
|
)) }) });
|
|
1230
1228
|
}, We = ({
|
|
1231
1229
|
agentTask: e,
|
|
1232
1230
|
mode: t = "verbose",
|
|
1233
|
-
|
|
1234
|
-
fetchClientToken: r,
|
|
1235
|
-
onSourceClick: c
|
|
1231
|
+
onSourceClick: n
|
|
1236
1232
|
}) => {
|
|
1237
|
-
|
|
1238
|
-
|
|
1233
|
+
F();
|
|
1234
|
+
const r = Se(e);
|
|
1235
|
+
return t === "simple" ? /* @__PURE__ */ i(ve, { progressViewItems: r }) : /* @__PURE__ */ i(
|
|
1239
1236
|
Me,
|
|
1240
1237
|
{
|
|
1241
|
-
progressViewItems:
|
|
1242
|
-
streamToken: n,
|
|
1243
|
-
fetchClientToken: r,
|
|
1238
|
+
progressViewItems: r,
|
|
1244
1239
|
loadingText: e.loadingText,
|
|
1245
|
-
onSourceClick:
|
|
1240
|
+
onSourceClick: n
|
|
1246
1241
|
}
|
|
1247
1242
|
);
|
|
1248
1243
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fencyai/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.128",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "staklau <steinaageklaussen@gmail.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@microsoft/fetch-event-source": "^2.0.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@fencyai/js": "^0.1.
|
|
40
|
+
"@fencyai/js": "^0.1.128",
|
|
41
41
|
"@testing-library/react": "^16.3.2",
|
|
42
42
|
"@types/jest": "^29.5.11",
|
|
43
43
|
"@types/node": "^20.10.5",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@emotion/is-prop-valid": "^1.3.0",
|
|
57
|
-
"@fencyai/js": "^0.1.
|
|
57
|
+
"@fencyai/js": "^0.1.128",
|
|
58
58
|
"@radix-ui/react-popover": "^1.1.15",
|
|
59
59
|
"motion": "^11.15.0",
|
|
60
60
|
"react": ">=16.8.0",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"optional": false
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "433fe4d7d5816571d9ab7c5c04f080353dbe60a0"
|
|
73
73
|
}
|