@fencyai/react 0.1.125 → 0.1.127
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-task/AgentTaskProgress.d.ts +0 -4
- package/dist/agent-task/AgentTaskProgress.d.ts.map +1 -1
- package/dist/agent-task/AgentTaskProgressVerbose.d.ts +0 -4
- package/dist/agent-task/AgentTaskProgressVerbose.d.ts.map +1 -1
- package/dist/hooks/useAgentTasks/index.d.ts.map +1 -1
- package/dist/index.js +291 -300
- package/dist/types/AgentTask.d.ts +0 -1
- package/dist/types/AgentTask.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAgentTasks/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAYnE,eAAO,MAAM,aAAa,GAAI,OAAO,kBAAkB,KAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAgentTasks/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAYnE,eAAO,MAAM,aAAa,GAAI,OAAO,kBAAkB,KAAG,aAoQzD,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,148 +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
|
-
|
|
436
|
-
loadingText: a == null ? void 0 : a.loadingText
|
|
435
|
+
loadingText: s == null ? void 0 : s.loadingText
|
|
437
436
|
}
|
|
438
437
|
]);
|
|
439
|
-
const { clientToken: f } = await e.fetchCreateAgentTaskClientToken(
|
|
438
|
+
const { clientToken: f } = await e.fetchCreateAgentTaskClientToken(a.type), g = await q({
|
|
440
439
|
pk: t.fency.publishableKey,
|
|
441
440
|
baseUrl: t.fency.baseUrl,
|
|
442
441
|
clientToken: f,
|
|
443
|
-
streamToken:
|
|
442
|
+
streamToken: u.stream.token,
|
|
444
443
|
request: {
|
|
445
|
-
streamingChatCompletionTask:
|
|
446
|
-
messages:
|
|
447
|
-
model:
|
|
444
|
+
streamingChatCompletionTask: a.type === "StreamingChatCompletion" ? {
|
|
445
|
+
messages: a.messages,
|
|
446
|
+
model: a.model
|
|
448
447
|
} : void 0,
|
|
449
|
-
structuredChatCompletionTask:
|
|
450
|
-
messages:
|
|
451
|
-
jsonSchema:
|
|
452
|
-
model:
|
|
448
|
+
structuredChatCompletionTask: a.type === "StructuredChatCompletion" ? {
|
|
449
|
+
messages: a.messages,
|
|
450
|
+
jsonSchema: a.jsonSchema,
|
|
451
|
+
model: a.model
|
|
453
452
|
} : void 0,
|
|
454
|
-
memoryChatCompletionTask:
|
|
455
|
-
messages:
|
|
456
|
-
model:
|
|
453
|
+
memoryChatCompletionTask: a.type === "MemoryChatCompletion" ? {
|
|
454
|
+
messages: a.messages,
|
|
455
|
+
model: a.model
|
|
457
456
|
} : void 0
|
|
458
457
|
}
|
|
459
458
|
});
|
|
460
|
-
if (
|
|
459
|
+
if (g.type === "success" && g.agentTask) {
|
|
461
460
|
c.current.add(
|
|
462
|
-
|
|
461
|
+
g.agentTask.id
|
|
463
462
|
), r((h) => [
|
|
464
|
-
...h.filter((S) => S.taskKey !==
|
|
463
|
+
...h.filter((S) => S.taskKey !== m),
|
|
465
464
|
{
|
|
466
|
-
taskKey:
|
|
467
|
-
streamId:
|
|
465
|
+
taskKey: m,
|
|
466
|
+
streamId: u.stream.id,
|
|
468
467
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
469
|
-
taskId:
|
|
470
|
-
createdAt:
|
|
468
|
+
taskId: g.agentTask.id,
|
|
469
|
+
createdAt: g.agentTask.createdAt,
|
|
471
470
|
error: null,
|
|
472
|
-
params:
|
|
471
|
+
params: a,
|
|
473
472
|
progressItems: [],
|
|
474
|
-
doneStreaming: !1,
|
|
475
473
|
loading: !0,
|
|
476
|
-
loadingText:
|
|
474
|
+
loadingText: s == null ? void 0 : s.loadingText,
|
|
477
475
|
confirmedData: {
|
|
478
|
-
taskId:
|
|
479
|
-
createdAt:
|
|
476
|
+
taskId: g.agentTask.id,
|
|
477
|
+
createdAt: g.agentTask.createdAt
|
|
480
478
|
}
|
|
481
479
|
}
|
|
482
480
|
]);
|
|
483
481
|
const p = await new Promise((h) => {
|
|
484
|
-
|
|
485
|
-
|
|
482
|
+
l.current.set(
|
|
483
|
+
g.agentTask.id,
|
|
486
484
|
h
|
|
487
485
|
);
|
|
488
486
|
});
|
|
489
487
|
return {
|
|
490
488
|
type: "success",
|
|
491
|
-
streamId:
|
|
492
|
-
agentTaskId:
|
|
489
|
+
streamId: u.stream.id,
|
|
490
|
+
agentTaskId: g.agentTask.id,
|
|
493
491
|
response: p
|
|
494
492
|
};
|
|
495
493
|
} else {
|
|
496
|
-
if (
|
|
494
|
+
if (g.type === "error")
|
|
497
495
|
return r((p) => [
|
|
498
|
-
...p.filter((h) => h.taskKey !==
|
|
496
|
+
...p.filter((h) => h.taskKey !== m),
|
|
499
497
|
{
|
|
500
|
-
taskKey:
|
|
498
|
+
taskKey: m,
|
|
501
499
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
502
|
-
streamId:
|
|
503
|
-
params:
|
|
504
|
-
error:
|
|
500
|
+
streamId: u.stream.id,
|
|
501
|
+
params: a,
|
|
502
|
+
error: g.error,
|
|
505
503
|
progressItems: [],
|
|
506
504
|
loading: !1,
|
|
507
|
-
|
|
508
|
-
loadingText: a == null ? void 0 : a.loadingText,
|
|
505
|
+
loadingText: s == null ? void 0 : s.loadingText,
|
|
509
506
|
confirmedData: null
|
|
510
507
|
}
|
|
511
508
|
]), {
|
|
512
509
|
type: "error",
|
|
513
|
-
error:
|
|
510
|
+
error: g.error
|
|
514
511
|
};
|
|
515
512
|
{
|
|
516
513
|
const p = {
|
|
@@ -518,17 +515,16 @@ const me = (e) => {
|
|
|
518
515
|
code: "UnknownError"
|
|
519
516
|
};
|
|
520
517
|
return r((h) => [
|
|
521
|
-
...h.filter((S) => S.taskKey !==
|
|
518
|
+
...h.filter((S) => S.taskKey !== m),
|
|
522
519
|
{
|
|
523
|
-
taskKey:
|
|
520
|
+
taskKey: m,
|
|
524
521
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
525
|
-
streamId:
|
|
522
|
+
streamId: u.stream.id,
|
|
526
523
|
error: p,
|
|
527
|
-
params:
|
|
524
|
+
params: a,
|
|
528
525
|
progressItems: [],
|
|
529
526
|
loading: !1,
|
|
530
|
-
|
|
531
|
-
loadingText: a == null ? void 0 : a.loadingText,
|
|
527
|
+
loadingText: s == null ? void 0 : s.loadingText,
|
|
532
528
|
confirmedData: null
|
|
533
529
|
}
|
|
534
530
|
]), {
|
|
@@ -538,34 +534,34 @@ const me = (e) => {
|
|
|
538
534
|
}
|
|
539
535
|
}
|
|
540
536
|
} else
|
|
541
|
-
return console.error(
|
|
537
|
+
return console.error(u.error), u;
|
|
542
538
|
},
|
|
543
|
-
[t, n,
|
|
544
|
-
),
|
|
539
|
+
[t, n, o]
|
|
540
|
+
), y = W(() => {
|
|
545
541
|
if (n.length !== 0)
|
|
546
|
-
return [...n].sort((
|
|
542
|
+
return [...n].sort((a, s) => new Date(s.triggeredAt).getTime() - new Date(a.triggeredAt).getTime())[0];
|
|
547
543
|
}, [n]);
|
|
548
544
|
return w(() => () => {
|
|
549
|
-
c.current.clear(),
|
|
545
|
+
c.current.clear(), l.current.clear();
|
|
550
546
|
}, []), {
|
|
551
547
|
agentTasks: n,
|
|
552
|
-
createAgentTask:
|
|
553
|
-
latest:
|
|
548
|
+
createAgentTask: d,
|
|
549
|
+
latest: y
|
|
554
550
|
};
|
|
555
551
|
};
|
|
556
552
|
function Se(e) {
|
|
557
553
|
return e.progressItems.map((t, n) => {
|
|
558
554
|
const r = e.progressItems[n + 1], c = r != null;
|
|
559
|
-
let
|
|
555
|
+
let l;
|
|
560
556
|
if (r != null && r.createdAt) {
|
|
561
|
-
const
|
|
562
|
-
|
|
557
|
+
const o = new Date(t.createdAt).getTime(), d = new Date(r.createdAt).getTime();
|
|
558
|
+
l = Math.round((d - o) / 1e3);
|
|
563
559
|
}
|
|
564
560
|
return {
|
|
565
561
|
item: t,
|
|
566
562
|
completed: c,
|
|
567
563
|
isLatest: n === e.progressItems.length - 1,
|
|
568
|
-
durationSeconds:
|
|
564
|
+
durationSeconds: l
|
|
569
565
|
};
|
|
570
566
|
});
|
|
571
567
|
}
|
|
@@ -575,21 +571,21 @@ function D({
|
|
|
575
571
|
delay: n = 0,
|
|
576
572
|
repeat: r = !0,
|
|
577
573
|
repeatDelay: c = 0.5,
|
|
578
|
-
className:
|
|
579
|
-
startOnView:
|
|
580
|
-
once:
|
|
581
|
-
inViewMargin:
|
|
582
|
-
spread:
|
|
583
|
-
color:
|
|
584
|
-
shimmerColor:
|
|
585
|
-
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"
|
|
586
582
|
}) {
|
|
587
|
-
const f = E(null),
|
|
588
|
-
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(
|
|
589
585
|
T.span,
|
|
590
586
|
{
|
|
591
587
|
ref: f,
|
|
592
|
-
className:
|
|
588
|
+
className: l,
|
|
593
589
|
style: {
|
|
594
590
|
position: "relative",
|
|
595
591
|
display: "inline-block",
|
|
@@ -600,8 +596,8 @@ function D({
|
|
|
600
596
|
WebkitTextFillColor: "transparent",
|
|
601
597
|
backgroundRepeat: "no-repeat, padding-box",
|
|
602
598
|
"--spread": `${p}px`,
|
|
603
|
-
"--base-color":
|
|
604
|
-
"--shimmer-color":
|
|
599
|
+
"--base-color": s,
|
|
600
|
+
"--shimmer-color": m,
|
|
605
601
|
"--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
|
|
606
602
|
backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
|
|
607
603
|
},
|
|
@@ -665,21 +661,21 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
665
661
|
const t = e[e.length - 1];
|
|
666
662
|
if (!t) return null;
|
|
667
663
|
const n = be(t);
|
|
668
|
-
return /* @__PURE__ */
|
|
664
|
+
return /* @__PURE__ */ i("div", { className: "simple-mode-container", children: /* @__PURE__ */ i($, { mode: "wait", children: /* @__PURE__ */ i(
|
|
669
665
|
T.div,
|
|
670
666
|
{
|
|
671
667
|
initial: { opacity: 0, y: 10 },
|
|
672
668
|
animate: { opacity: 1, y: 0 },
|
|
673
669
|
exit: { opacity: 0, y: -10 },
|
|
674
670
|
transition: { duration: 0.3 },
|
|
675
|
-
children: t.completed ? /* @__PURE__ */
|
|
671
|
+
children: t.completed ? /* @__PURE__ */ i(
|
|
676
672
|
"div",
|
|
677
673
|
{
|
|
678
674
|
className: "simple-mode-title",
|
|
679
675
|
style: { color: "#666" },
|
|
680
676
|
children: n
|
|
681
677
|
}
|
|
682
|
-
) : /* @__PURE__ */
|
|
678
|
+
) : /* @__PURE__ */ i(
|
|
683
679
|
D,
|
|
684
680
|
{
|
|
685
681
|
text: n,
|
|
@@ -844,32 +840,32 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
844
840
|
italic: {
|
|
845
841
|
fontStyle: "italic"
|
|
846
842
|
}
|
|
847
|
-
},
|
|
843
|
+
}, B = ({
|
|
848
844
|
text: e
|
|
849
|
-
}) => /* @__PURE__ */
|
|
845
|
+
}) => /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ i(
|
|
850
846
|
T.div,
|
|
851
847
|
{
|
|
852
848
|
className: "fency-markdown-body-raw",
|
|
853
849
|
initial: { opacity: 0, y: -10 },
|
|
854
850
|
animate: { opacity: 1, y: 0 },
|
|
855
851
|
transition: { duration: 0.3, delay: 0 },
|
|
856
|
-
children: /* @__PURE__ */
|
|
852
|
+
children: /* @__PURE__ */ i(
|
|
857
853
|
Y,
|
|
858
854
|
{
|
|
859
855
|
remarkPlugins: [Z],
|
|
860
856
|
components: {
|
|
861
857
|
code(t) {
|
|
862
|
-
const { children: n, className: r, node: c, ref:
|
|
863
|
-
return
|
|
864
|
-
|
|
858
|
+
const { children: n, className: r, node: c, ref: l, ...o } = t, d = /language-(\w+)/.exec(r || "");
|
|
859
|
+
return d ? /* @__PURE__ */ i(
|
|
860
|
+
N,
|
|
865
861
|
{
|
|
866
|
-
...
|
|
862
|
+
...o,
|
|
867
863
|
PreTag: "div",
|
|
868
864
|
children: String(n).replace(/\n$/, ""),
|
|
869
|
-
language:
|
|
865
|
+
language: d[1],
|
|
870
866
|
style: H
|
|
871
867
|
}
|
|
872
|
-
) : /* @__PURE__ */
|
|
868
|
+
) : /* @__PURE__ */ i("code", { ...o, className: r, children: String(n) });
|
|
873
869
|
}
|
|
874
870
|
},
|
|
875
871
|
children: e
|
|
@@ -878,19 +874,19 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
878
874
|
}
|
|
879
875
|
) }), Te = ({ data: e }) => {
|
|
880
876
|
const t = JSON.stringify(e.json, null, 2);
|
|
881
|
-
return /* @__PURE__ */
|
|
877
|
+
return /* @__PURE__ */ i("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ i(
|
|
882
878
|
T.div,
|
|
883
879
|
{
|
|
884
880
|
initial: { opacity: 0, y: -10 },
|
|
885
881
|
animate: { opacity: 1, y: 0 },
|
|
886
882
|
transition: { duration: 0.3, delay: 0 },
|
|
887
|
-
children: /* @__PURE__ */
|
|
883
|
+
children: /* @__PURE__ */ i(N, { language: "json", style: H, PreTag: "div", children: t })
|
|
888
884
|
}
|
|
889
885
|
) });
|
|
890
886
|
}, Ce = ({ data: e, isLatest: t = !1, durationSeconds: n }) => {
|
|
891
887
|
const r = `Searching: ${e.queryDescription}`;
|
|
892
888
|
return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
|
|
893
|
-
/* @__PURE__ */
|
|
889
|
+
/* @__PURE__ */ i(
|
|
894
890
|
T.div,
|
|
895
891
|
{
|
|
896
892
|
style: {
|
|
@@ -902,7 +898,7 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
902
898
|
initial: { opacity: 0, y: -10 },
|
|
903
899
|
animate: { opacity: 1, y: 0 },
|
|
904
900
|
transition: { duration: 0.3, delay: 0 },
|
|
905
|
-
children: t && !n ? /* @__PURE__ */
|
|
901
|
+
children: t && !n ? /* @__PURE__ */ i(
|
|
906
902
|
D,
|
|
907
903
|
{
|
|
908
904
|
text: r,
|
|
@@ -911,7 +907,7 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
911
907
|
color: "#999",
|
|
912
908
|
shimmerColor: "#000"
|
|
913
909
|
}
|
|
914
|
-
) : /* @__PURE__ */
|
|
910
|
+
) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: r })
|
|
915
911
|
}
|
|
916
912
|
),
|
|
917
913
|
n !== void 0 && /* @__PURE__ */ C(
|
|
@@ -934,7 +930,7 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
934
930
|
}, ke = ({ isLatest: e = !1, durationSeconds: t }) => {
|
|
935
931
|
const n = "Adding sources...";
|
|
936
932
|
return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
|
|
937
|
-
/* @__PURE__ */
|
|
933
|
+
/* @__PURE__ */ i(
|
|
938
934
|
T.div,
|
|
939
935
|
{
|
|
940
936
|
style: {
|
|
@@ -946,7 +942,7 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
946
942
|
initial: { opacity: 0, y: -10 },
|
|
947
943
|
animate: { opacity: 1, y: 0 },
|
|
948
944
|
transition: { duration: 0.3, delay: 0 },
|
|
949
|
-
children: e && !t ? /* @__PURE__ */
|
|
945
|
+
children: e && !t ? /* @__PURE__ */ i(
|
|
950
946
|
D,
|
|
951
947
|
{
|
|
952
948
|
text: n,
|
|
@@ -955,7 +951,7 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
955
951
|
color: "#999",
|
|
956
952
|
shimmerColor: "#000"
|
|
957
953
|
}
|
|
958
|
-
) : /* @__PURE__ */
|
|
954
|
+
) : /* @__PURE__ */ i("span", { style: { color: "#666" }, children: n })
|
|
959
955
|
}
|
|
960
956
|
),
|
|
961
957
|
t !== void 0 && /* @__PURE__ */ C(
|
|
@@ -976,7 +972,7 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
976
972
|
)
|
|
977
973
|
] });
|
|
978
974
|
}, xe = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
|
|
979
|
-
/* @__PURE__ */
|
|
975
|
+
/* @__PURE__ */ i(
|
|
980
976
|
T.div,
|
|
981
977
|
{
|
|
982
978
|
style: {
|
|
@@ -993,7 +989,7 @@ const ve = ({ progressViewItems: e }) => {
|
|
|
993
989
|
children: "Sources"
|
|
994
990
|
}
|
|
995
991
|
),
|
|
996
|
-
/* @__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(
|
|
997
993
|
Ee,
|
|
998
994
|
{
|
|
999
995
|
source: n,
|
|
@@ -1012,16 +1008,16 @@ function we(e) {
|
|
|
1012
1008
|
return `pages ${e.slice(0, -1).join(", ")} and ${t}`;
|
|
1013
1009
|
}
|
|
1014
1010
|
const Ee = ({ source: e, index: t, onSourceClick: n }) => {
|
|
1015
|
-
const [r, c] = k(!1),
|
|
1011
|
+
const [r, c] = k(!1), l = !!n, o = e.pageNumbers ?? [], d = we(o);
|
|
1016
1012
|
return /* @__PURE__ */ C(
|
|
1017
1013
|
T.div,
|
|
1018
1014
|
{
|
|
1019
1015
|
initial: { opacity: 0, scale: 0.9 },
|
|
1020
1016
|
animate: { opacity: 1, scale: 1 },
|
|
1021
1017
|
transition: { duration: 0.25, delay: t * 0.05 },
|
|
1022
|
-
onClick:
|
|
1023
|
-
onMouseEnter:
|
|
1024
|
-
onMouseLeave:
|
|
1018
|
+
onClick: l ? () => n(e.memoryId) : void 0,
|
|
1019
|
+
onMouseEnter: l ? () => c(!0) : void 0,
|
|
1020
|
+
onMouseLeave: l ? () => c(!1) : void 0,
|
|
1025
1021
|
style: {
|
|
1026
1022
|
display: "inline-flex",
|
|
1027
1023
|
flexDirection: "column",
|
|
@@ -1030,13 +1026,13 @@ const Ee = ({ source: e, index: t, onSourceClick: n }) => {
|
|
|
1030
1026
|
borderRadius: "6px",
|
|
1031
1027
|
border: "1px solid #e0e0e0",
|
|
1032
1028
|
backgroundColor: r ? "#f5f5f5" : "transparent",
|
|
1033
|
-
cursor:
|
|
1029
|
+
cursor: l ? "pointer" : "default",
|
|
1034
1030
|
transition: "background-color 0.15s ease",
|
|
1035
1031
|
userSelect: "none"
|
|
1036
1032
|
},
|
|
1037
1033
|
children: [
|
|
1038
|
-
/* @__PURE__ */
|
|
1039
|
-
|
|
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 })
|
|
1040
1036
|
]
|
|
1041
1037
|
}
|
|
1042
1038
|
);
|
|
@@ -1045,13 +1041,13 @@ function Ie({
|
|
|
1045
1041
|
eventType: e,
|
|
1046
1042
|
completed: t
|
|
1047
1043
|
}) {
|
|
1048
|
-
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;
|
|
1049
1045
|
}
|
|
1050
|
-
const
|
|
1051
|
-
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;
|
|
1052
1048
|
if (e.eventType === "ExploreMemoryStart" && !t) {
|
|
1053
|
-
const
|
|
1054
|
-
return /* @__PURE__ */
|
|
1049
|
+
const s = `Exploring ${e.memoryTitle}...`;
|
|
1050
|
+
return /* @__PURE__ */ i(
|
|
1055
1051
|
"div",
|
|
1056
1052
|
{
|
|
1057
1053
|
style: {
|
|
@@ -1059,26 +1055,26 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1059
1055
|
display: "flex",
|
|
1060
1056
|
alignItems: "center"
|
|
1061
1057
|
},
|
|
1062
|
-
children: n ? /* @__PURE__ */
|
|
1058
|
+
children: n ? /* @__PURE__ */ i(
|
|
1063
1059
|
D,
|
|
1064
1060
|
{
|
|
1065
|
-
text:
|
|
1061
|
+
text: s,
|
|
1066
1062
|
duration: 2.5,
|
|
1067
1063
|
repeat: !0,
|
|
1068
1064
|
color: "#999",
|
|
1069
1065
|
shimmerColor: "#000"
|
|
1070
1066
|
}
|
|
1071
|
-
) : /* @__PURE__ */
|
|
1067
|
+
) : /* @__PURE__ */ i("span", { style: { fontSize: 13, color: "#999" }, children: s })
|
|
1072
1068
|
}
|
|
1073
1069
|
);
|
|
1074
1070
|
}
|
|
1075
|
-
return /* @__PURE__ */
|
|
1071
|
+
return /* @__PURE__ */ i("div", { style: { padding: "16px" }, children: /* @__PURE__ */ C(
|
|
1076
1072
|
T.div,
|
|
1077
1073
|
{
|
|
1078
1074
|
initial: { opacity: 0 },
|
|
1079
1075
|
animate: { opacity: 1 },
|
|
1080
1076
|
transition: { duration: 0.25 },
|
|
1081
|
-
onClick:
|
|
1077
|
+
onClick: y ? () => c((s) => !s) : void 0,
|
|
1082
1078
|
style: {
|
|
1083
1079
|
paddingBottom: "12px",
|
|
1084
1080
|
borderBottom: "1px solid #eee",
|
|
@@ -1087,10 +1083,10 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1087
1083
|
alignItems: "flex-start",
|
|
1088
1084
|
gap: "10px",
|
|
1089
1085
|
minWidth: 0,
|
|
1090
|
-
cursor:
|
|
1086
|
+
cursor: y ? "pointer" : "default"
|
|
1091
1087
|
},
|
|
1092
1088
|
children: [
|
|
1093
|
-
/* @__PURE__ */
|
|
1089
|
+
/* @__PURE__ */ i(
|
|
1094
1090
|
"div",
|
|
1095
1091
|
{
|
|
1096
1092
|
style: {
|
|
@@ -1100,7 +1096,7 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1100
1096
|
flexShrink: 0,
|
|
1101
1097
|
width: 20
|
|
1102
1098
|
},
|
|
1103
|
-
children: /* @__PURE__ */
|
|
1099
|
+
children: /* @__PURE__ */ i(Ie, { eventType: e.eventType, completed: t })
|
|
1104
1100
|
}
|
|
1105
1101
|
),
|
|
1106
1102
|
/* @__PURE__ */ C(
|
|
@@ -1113,8 +1109,8 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1113
1109
|
minWidth: 0
|
|
1114
1110
|
},
|
|
1115
1111
|
children: [
|
|
1116
|
-
/* @__PURE__ */
|
|
1117
|
-
|
|
1112
|
+
/* @__PURE__ */ i("span", { style: { fontSize: 13, fontWeight: 500, color: "#333" }, children: e.memoryTitle }),
|
|
1113
|
+
d != null && /* @__PURE__ */ i(
|
|
1118
1114
|
"span",
|
|
1119
1115
|
{
|
|
1120
1116
|
style: {
|
|
@@ -1123,10 +1119,10 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1123
1119
|
lineHeight: 1.4,
|
|
1124
1120
|
whiteSpace: r ? "pre-wrap" : void 0
|
|
1125
1121
|
},
|
|
1126
|
-
children:
|
|
1122
|
+
children: d
|
|
1127
1123
|
}
|
|
1128
1124
|
),
|
|
1129
|
-
|
|
1125
|
+
y && /* @__PURE__ */ i(
|
|
1130
1126
|
"span",
|
|
1131
1127
|
{
|
|
1132
1128
|
style: {
|
|
@@ -1145,58 +1141,56 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1145
1141
|
) });
|
|
1146
1142
|
}, Me = ({
|
|
1147
1143
|
progressViewItems: e,
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
loadingText: r,
|
|
1151
|
-
onSourceClick: c
|
|
1144
|
+
loadingText: t,
|
|
1145
|
+
onSourceClick: n
|
|
1152
1146
|
}) => {
|
|
1153
|
-
const
|
|
1147
|
+
const r = E(null);
|
|
1154
1148
|
w(() => {
|
|
1155
|
-
|
|
1149
|
+
r.current && (r.current.scrollTop = r.current.scrollHeight);
|
|
1156
1150
|
}, [e.length]);
|
|
1157
|
-
const
|
|
1158
|
-
const
|
|
1159
|
-
if (
|
|
1160
|
-
return /* @__PURE__ */
|
|
1161
|
-
if (
|
|
1162
|
-
return /* @__PURE__ */
|
|
1163
|
-
if (
|
|
1164
|
-
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) {
|
|
1165
1159
|
case "Text":
|
|
1166
|
-
return /* @__PURE__ */
|
|
1160
|
+
return /* @__PURE__ */ i(B, { text: o.text });
|
|
1167
1161
|
case "Search":
|
|
1168
|
-
return /* @__PURE__ */
|
|
1162
|
+
return /* @__PURE__ */ i(
|
|
1169
1163
|
Ce,
|
|
1170
1164
|
{
|
|
1171
|
-
data:
|
|
1165
|
+
data: o,
|
|
1172
1166
|
isLatest: l.isLatest,
|
|
1173
1167
|
durationSeconds: l.durationSeconds
|
|
1174
1168
|
}
|
|
1175
1169
|
);
|
|
1176
1170
|
case "FindSources":
|
|
1177
|
-
return /* @__PURE__ */
|
|
1171
|
+
return /* @__PURE__ */ i(
|
|
1178
1172
|
ke,
|
|
1179
1173
|
{
|
|
1180
|
-
data:
|
|
1174
|
+
data: o,
|
|
1181
1175
|
isLatest: l.isLatest,
|
|
1182
1176
|
durationSeconds: l.durationSeconds
|
|
1183
1177
|
}
|
|
1184
1178
|
);
|
|
1185
1179
|
case "SourcesResult":
|
|
1186
|
-
return /* @__PURE__ */
|
|
1180
|
+
return /* @__PURE__ */ i(
|
|
1187
1181
|
xe,
|
|
1188
1182
|
{
|
|
1189
|
-
data:
|
|
1190
|
-
onSourceClick:
|
|
1183
|
+
data: o,
|
|
1184
|
+
onSourceClick: n
|
|
1191
1185
|
}
|
|
1192
1186
|
);
|
|
1193
1187
|
case "ExploreMemoryStart":
|
|
1194
1188
|
case "ExploreMemoryResult":
|
|
1195
1189
|
case "ExploreMemoryError":
|
|
1196
|
-
return /* @__PURE__ */
|
|
1190
|
+
return /* @__PURE__ */ i(
|
|
1197
1191
|
Ae,
|
|
1198
1192
|
{
|
|
1199
|
-
data:
|
|
1193
|
+
data: o,
|
|
1200
1194
|
completed: l.completed,
|
|
1201
1195
|
isLatest: l.isLatest
|
|
1202
1196
|
}
|
|
@@ -1204,19 +1198,19 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1204
1198
|
case "Completed":
|
|
1205
1199
|
return null;
|
|
1206
1200
|
}
|
|
1207
|
-
return
|
|
1201
|
+
return o.taskType === "StreamingChatCompletion" && o.eventType === "Completed" || o.taskType === "StructuredChatCompletion" && o.eventType === "Completed", null;
|
|
1208
1202
|
};
|
|
1209
|
-
return e.length === 0 ? /* @__PURE__ */
|
|
1203
|
+
return e.length === 0 ? /* @__PURE__ */ i("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ i(
|
|
1210
1204
|
D,
|
|
1211
1205
|
{
|
|
1212
|
-
text:
|
|
1206
|
+
text: t ?? "Processing your task...",
|
|
1213
1207
|
duration: 1.5,
|
|
1214
1208
|
repeat: !0,
|
|
1215
1209
|
repeatDelay: 0,
|
|
1216
1210
|
color: "#999",
|
|
1217
1211
|
shimmerColor: "#000"
|
|
1218
1212
|
}
|
|
1219
|
-
) }) : /* @__PURE__ */
|
|
1213
|
+
) }) : /* @__PURE__ */ i("div", { id: "agent-task-progress-verbose", ref: r, children: /* @__PURE__ */ i($, { children: e.map((l, o) => /* @__PURE__ */ i(
|
|
1220
1214
|
T.div,
|
|
1221
1215
|
{
|
|
1222
1216
|
id: `agent-task-progress-item-${l.item.progressItemId}`,
|
|
@@ -1224,29 +1218,26 @@ const B = 80, Ae = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1224
1218
|
animate: { opacity: 1, y: 0 },
|
|
1225
1219
|
transition: {
|
|
1226
1220
|
duration: 0.4,
|
|
1227
|
-
delay:
|
|
1221
|
+
delay: o * 0.1,
|
|
1228
1222
|
ease: "easeOut"
|
|
1229
1223
|
},
|
|
1230
|
-
children:
|
|
1224
|
+
children: c(l)
|
|
1231
1225
|
},
|
|
1232
1226
|
l.item.progressItemId
|
|
1233
1227
|
)) }) });
|
|
1234
1228
|
}, We = ({
|
|
1235
1229
|
agentTask: e,
|
|
1236
1230
|
mode: t = "verbose",
|
|
1237
|
-
|
|
1238
|
-
fetchClientToken: r,
|
|
1239
|
-
onSourceClick: c
|
|
1231
|
+
onSourceClick: n
|
|
1240
1232
|
}) => {
|
|
1241
|
-
|
|
1242
|
-
|
|
1233
|
+
F();
|
|
1234
|
+
const r = Se(e);
|
|
1235
|
+
return t === "simple" ? /* @__PURE__ */ i(ve, { progressViewItems: r }) : /* @__PURE__ */ i(
|
|
1243
1236
|
Me,
|
|
1244
1237
|
{
|
|
1245
|
-
progressViewItems:
|
|
1246
|
-
streamToken: n,
|
|
1247
|
-
fetchClientToken: r,
|
|
1238
|
+
progressViewItems: r,
|
|
1248
1239
|
loadingText: e.loadingText,
|
|
1249
|
-
onSourceClick:
|
|
1240
|
+
onSourceClick: n
|
|
1250
1241
|
}
|
|
1251
1242
|
);
|
|
1252
1243
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentTask.d.ts","sourceRoot":"","sources":["../../src/types/AgentTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D,MAAM,WAAW,SAAS;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,qBAAqB,CAAA;IAC7B,aAAa,EAAE,4BAA4B,EAAE,CAAA;IAC7C,OAAO,EAAE,OAAO,CAAA;IAChB,
|
|
1
|
+
{"version":3,"file":"AgentTask.d.ts","sourceRoot":"","sources":["../../src/types/AgentTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAA;AAE3D,MAAM,WAAW,SAAS;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,qBAAqB,CAAA;IAC7B,aAAa,EAAE,4BAA4B,EAAE,CAAA;IAC7C,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE;QACX,MAAM,EAAE,MAAM,CAAA;QACd,SAAS,EAAE,MAAM,CAAA;KACpB,GAAG,IAAI,CAAA;CACX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fencyai/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.127",
|
|
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.127",
|
|
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.127",
|
|
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": "39bd4b03266c484ed4ec88f8b8e34c110184ab6f"
|
|
73
73
|
}
|