@fencyai/react 0.1.134 → 0.1.136
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/data-types/StreamingChatCompletionText.d.ts.map +1 -1
- package/dist/agent-task/data-types/StructuredChatCompletionJson.d.ts.map +1 -1
- package/dist/index.js +118 -115
- package/dist/types/StreamData.d.ts +3 -3
- package/dist/types/StreamData.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StreamingChatCompletionText.d.ts","sourceRoot":"","sources":["../../../src/agent-task/data-types/StreamingChatCompletionText.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,6BAA6B,CAAA;AAEpC,MAAM,WAAW,gCAAgC;IAC7C,IAAI,EAAE,MAAM,CAAA;CACf;AAED,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAAC,gCAAgC,
|
|
1
|
+
{"version":3,"file":"StreamingChatCompletionText.d.ts","sourceRoot":"","sources":["../../../src/agent-task/data-types/StreamingChatCompletionText.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,OAAO,6BAA6B,CAAA;AAEpC,MAAM,WAAW,gCAAgC;IAC7C,IAAI,EAAE,MAAM,CAAA;CACf;AAED,eAAO,MAAM,2BAA2B,EAAE,KAAK,CAAC,EAAE,CAAC,gCAAgC,CAuClF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructuredChatCompletionJson.d.ts","sourceRoot":"","sources":["../../../src/agent-task/data-types/StructuredChatCompletionJson.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,MAAM,WAAW,iCAAiC;IAC9C,IAAI,EAAE,OAAO,CAAC,kBAAkB,EAAE;QAAE,QAAQ,EAAE,0BAA0B,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACjG;AAED,eAAO,MAAM,4BAA4B,EAAE,KAAK,CAAC,EAAE,CAC/C,iCAAiC,
|
|
1
|
+
{"version":3,"file":"StructuredChatCompletionJson.d.ts","sourceRoot":"","sources":["../../../src/agent-task/data-types/StructuredChatCompletionJson.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAErD,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,MAAM,WAAW,iCAAiC;IAC9C,IAAI,EAAE,OAAO,CAAC,kBAAkB,EAAE;QAAE,QAAQ,EAAE,0BAA0B,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACjG;AAED,eAAO,MAAM,4BAA4B,EAAE,KAAK,CAAC,EAAE,CAC/C,iCAAiC,CAkBpC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createStream as
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { useInView as Y, motion as v, AnimatePresence as
|
|
1
|
+
import { jsxs as C, jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { createStream as K, isStreamTimeoutEvent as G, isStreamNotFoundEvent as J, isAgentTaskProgressItemUpdatedEvent as V, createAgentTask as X } from "@fencyai/js";
|
|
3
|
+
import { createContext as q, useState as k, useRef as E, useEffect as w, useCallback as N, useContext as Q, useMemo as _ } from "react";
|
|
4
|
+
import { useInView as Y, motion as v, AnimatePresence as z } from "motion/react";
|
|
5
5
|
import Z from "react-markdown";
|
|
6
|
-
import { Prism as
|
|
6
|
+
import { Prism as L } from "react-syntax-highlighter";
|
|
7
7
|
import ee from "remark-gfm";
|
|
8
|
-
import './assets/index.css';const
|
|
8
|
+
import './assets/index.css';const W = q(
|
|
9
9
|
void 0
|
|
10
10
|
);
|
|
11
11
|
async function te(e, t) {
|
|
@@ -42,11 +42,11 @@ function re(e) {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
function ne(e, t, n) {
|
|
45
|
-
let r =
|
|
45
|
+
let r = R();
|
|
46
46
|
const c = new TextDecoder();
|
|
47
47
|
return function(o, d) {
|
|
48
48
|
if (o.length === 0)
|
|
49
|
-
n == null || n(r), r =
|
|
49
|
+
n == null || n(r), r = R();
|
|
50
50
|
else if (d > 0) {
|
|
51
51
|
const y = c.decode(o.subarray(0, d)), a = d + (o[d + 1] === 32 ? 2 : 1), i = c.decode(o.subarray(a));
|
|
52
52
|
switch (y) {
|
|
@@ -72,7 +72,7 @@ function oe(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 ae = 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
|
|
91
|
+
const P = "text/event-stream", se = 1e3, F = "last-event-id";
|
|
92
92
|
function ie(e, t) {
|
|
93
93
|
var { signal: n, headers: r, onopen: c, onmessage: l, onclose: o, onerror: d, openWhenHidden: y, fetch: a } = t, i = ae(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
94
94
|
return new Promise((m, u) => {
|
|
95
95
|
const f = Object.assign({}, r);
|
|
96
|
-
f.accept || (f.accept =
|
|
96
|
+
f.accept || (f.accept = P);
|
|
97
97
|
let g;
|
|
98
98
|
function p() {
|
|
99
99
|
g.abort(), document.hidden || x();
|
|
100
100
|
}
|
|
101
101
|
y || document.addEventListener("visibilitychange", p);
|
|
102
|
-
let h = se,
|
|
103
|
-
function
|
|
104
|
-
document.removeEventListener("visibilitychange", p), window.clearTimeout(
|
|
102
|
+
let h = se, S = 0;
|
|
103
|
+
function b() {
|
|
104
|
+
document.removeEventListener("visibilitychange", p), window.clearTimeout(S), g.abort();
|
|
105
105
|
}
|
|
106
106
|
n == null || n.addEventListener("abort", () => {
|
|
107
|
-
|
|
107
|
+
b(), m();
|
|
108
108
|
});
|
|
109
|
-
const D = a ?? window.fetch,
|
|
109
|
+
const D = a ?? window.fetch, I = c ?? ce;
|
|
110
110
|
async function x() {
|
|
111
111
|
var M;
|
|
112
112
|
g = new AbortController();
|
|
113
113
|
try {
|
|
114
|
-
const
|
|
115
|
-
await A
|
|
116
|
-
T ? f[
|
|
114
|
+
const A = await D(e, Object.assign(Object.assign({}, i), { headers: f, signal: g.signal }));
|
|
115
|
+
await I(A), await te(A.body, re(ne((T) => {
|
|
116
|
+
T ? f[F] = T : delete f[F];
|
|
117
117
|
}, (T) => {
|
|
118
118
|
h = T;
|
|
119
|
-
}, l))), o == null || o(),
|
|
120
|
-
} catch (
|
|
119
|
+
}, l))), o == null || o(), b(), m();
|
|
120
|
+
} catch (A) {
|
|
121
121
|
if (!g.signal.aborted)
|
|
122
122
|
try {
|
|
123
|
-
const T = (M = d == null ? void 0 : d(
|
|
124
|
-
window.clearTimeout(
|
|
123
|
+
const T = (M = d == null ? void 0 : d(A)) !== null && M !== void 0 ? M : h;
|
|
124
|
+
window.clearTimeout(S), S = window.setTimeout(x, T);
|
|
125
125
|
} catch (T) {
|
|
126
|
-
|
|
126
|
+
b(), u(T);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -132,8 +132,8 @@ function ie(e, t) {
|
|
|
132
132
|
}
|
|
133
133
|
function ce(e) {
|
|
134
134
|
const t = e.headers.get("content-type");
|
|
135
|
-
if (!(t != null && t.startsWith(
|
|
136
|
-
throw new Error(`Expected content-type to be ${
|
|
135
|
+
if (!(t != null && t.startsWith(P)))
|
|
136
|
+
throw new Error(`Expected content-type to be ${P}, Actual: ${t}`);
|
|
137
137
|
}
|
|
138
138
|
function le(e) {
|
|
139
139
|
const t = atob(e), n = new Uint8Array(t.length);
|
|
@@ -216,10 +216,10 @@ const ue = 12e4, me = (e) => {
|
|
|
216
216
|
const t = Date.now();
|
|
217
217
|
return e.filter((n) => t - n.createdAt < ue);
|
|
218
218
|
};
|
|
219
|
-
function
|
|
220
|
-
const [r, c] =
|
|
219
|
+
function ze({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
|
|
220
|
+
const [r, c] = k(
|
|
221
221
|
null
|
|
222
|
-
), [l, o] =
|
|
222
|
+
), [l, o] = k(!0), [d, y] = k(null), [a, i] = k([]), m = E(null), u = E(null);
|
|
223
223
|
w(() => {
|
|
224
224
|
e.then((h) => {
|
|
225
225
|
c(h), o(!1);
|
|
@@ -234,28 +234,28 @@ function Ne({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
|
|
|
234
234
|
var h;
|
|
235
235
|
(h = u.current) == null || h.cleanup();
|
|
236
236
|
}, []);
|
|
237
|
-
const f =
|
|
237
|
+
const f = N(
|
|
238
238
|
async (h = 3e4) => {
|
|
239
239
|
if (m.current)
|
|
240
240
|
return m.current;
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
243
|
-
return
|
|
241
|
+
const S = Date.now(), b = a.length > 0 ? a[a.length - 1] : null;
|
|
242
|
+
if (b && S - b.createdAt < h)
|
|
243
|
+
return b.stream;
|
|
244
244
|
const D = (async () => {
|
|
245
245
|
if (!r)
|
|
246
246
|
throw new Error("Fency instance not initialized");
|
|
247
|
-
const
|
|
247
|
+
const I = await t(), x = await K({
|
|
248
248
|
pk: r.publishableKey,
|
|
249
249
|
baseUrl: r.baseUrl,
|
|
250
|
-
clientToken: (
|
|
250
|
+
clientToken: (I == null ? void 0 : I.clientToken) ?? ""
|
|
251
251
|
});
|
|
252
252
|
if (x.type === "success") {
|
|
253
253
|
const M = {
|
|
254
254
|
stream: x.stream,
|
|
255
255
|
createdAt: Date.now()
|
|
256
256
|
};
|
|
257
|
-
return i((
|
|
258
|
-
const T = [...
|
|
257
|
+
return i((A) => {
|
|
258
|
+
const T = [...A, M];
|
|
259
259
|
return me(T);
|
|
260
260
|
}), m.current = null, x.stream;
|
|
261
261
|
} else
|
|
@@ -266,7 +266,7 @@ function Ne({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
|
|
|
266
266
|
[r, a]
|
|
267
267
|
);
|
|
268
268
|
if (d)
|
|
269
|
-
return /* @__PURE__ */
|
|
269
|
+
return /* @__PURE__ */ C("div", { children: [
|
|
270
270
|
"Fency error: ",
|
|
271
271
|
d.message
|
|
272
272
|
] });
|
|
@@ -281,10 +281,10 @@ function Ne({ fency: e, fetchCreateStreamClientToken: t, children: n }) {
|
|
|
281
281
|
eventManager: u.current,
|
|
282
282
|
getOrCreateStream: f
|
|
283
283
|
};
|
|
284
|
-
return /* @__PURE__ */ s(
|
|
284
|
+
return /* @__PURE__ */ s(W.Provider, { value: p, children: n });
|
|
285
285
|
}
|
|
286
|
-
function
|
|
287
|
-
const e = Q(
|
|
286
|
+
function H() {
|
|
287
|
+
const e = Q(W);
|
|
288
288
|
if (e === void 0)
|
|
289
289
|
throw new Error("useFencyContext must be used within a FencyProvider");
|
|
290
290
|
return e;
|
|
@@ -296,24 +296,24 @@ const ge = (e) => {
|
|
|
296
296
|
} catch (t) {
|
|
297
297
|
return console.error("Error parsing message:", t), null;
|
|
298
298
|
}
|
|
299
|
-
}, ye = (e) =>
|
|
300
|
-
type: "
|
|
299
|
+
}, ye = (e) => G(e) ? fe(e) : J(e) ? he(e) : V(e) ? pe(e) : null, fe = (e) => ({
|
|
300
|
+
type: "STREAM_TIMEOUT",
|
|
301
301
|
streamId: e.streamId,
|
|
302
302
|
timestamp: e.timestamp
|
|
303
303
|
}), he = (e) => ({
|
|
304
|
-
type: "
|
|
304
|
+
type: "STREAM_NOT_FOUND",
|
|
305
305
|
streamId: e.streamId,
|
|
306
306
|
timestamp: e.timestamp
|
|
307
307
|
}), pe = (e) => ({
|
|
308
|
-
type: "
|
|
308
|
+
type: "AGENT_TASK_PROGRESS_ITEM_UPDATED",
|
|
309
309
|
streamId: e.streamId,
|
|
310
310
|
agentTaskId: e.agentTaskId,
|
|
311
311
|
progressItemId: e.progressItemId,
|
|
312
312
|
timestamp: e.timestamp,
|
|
313
313
|
createdAt: e.createdAt,
|
|
314
314
|
data: JSON.parse(e.data)
|
|
315
|
-
}),
|
|
316
|
-
const t =
|
|
315
|
+
}), Se = (e) => {
|
|
316
|
+
const t = H(), [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
319
|
const o = {
|
|
@@ -322,13 +322,13 @@ const ge = (e) => {
|
|
|
322
322
|
const i = ge(y);
|
|
323
323
|
if (i)
|
|
324
324
|
switch (i.type) {
|
|
325
|
-
case "
|
|
325
|
+
case "STREAM_TIMEOUT":
|
|
326
326
|
(m = e == null ? void 0 : e.onStreamTimeout) == null || m.call(e, i);
|
|
327
327
|
break;
|
|
328
|
-
case "
|
|
328
|
+
case "STREAM_NOT_FOUND":
|
|
329
329
|
(u = e == null ? void 0 : e.onStreamNotFound) == null || u.call(e, i);
|
|
330
330
|
break;
|
|
331
|
-
case "
|
|
331
|
+
case "AGENT_TASK_PROGRESS_ITEM_UPDATED":
|
|
332
332
|
(f = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || f.call(e, i);
|
|
333
333
|
break;
|
|
334
334
|
}
|
|
@@ -368,8 +368,8 @@ const ge = (e) => {
|
|
|
368
368
|
},
|
|
369
369
|
stream: n
|
|
370
370
|
};
|
|
371
|
-
},
|
|
372
|
-
const t =
|
|
371
|
+
}, Le = (e) => {
|
|
372
|
+
const t = H(), [n, r] = k([]), c = E(/* @__PURE__ */ new Set()), l = E(/* @__PURE__ */ new Map()), { createStream: o } = Se({
|
|
373
373
|
onAgentTaskProgressItemUpdated: (a) => {
|
|
374
374
|
var u;
|
|
375
375
|
if (!c.current.has(a.agentTaskId)) return;
|
|
@@ -383,13 +383,13 @@ const ge = (e) => {
|
|
|
383
383
|
}
|
|
384
384
|
(u = e.onAgentTaskProgressItemUpdated) == null || u.call(e, a), r(
|
|
385
385
|
(f) => f.map((g) => {
|
|
386
|
-
var
|
|
387
|
-
if (((
|
|
386
|
+
var S;
|
|
387
|
+
if (((S = g.confirmedData) == null ? void 0 : S.taskId) !== a.agentTaskId)
|
|
388
388
|
return g;
|
|
389
389
|
const h = g.progressItems.some(
|
|
390
|
-
(
|
|
390
|
+
(b) => b.progressItemId === a.progressItemId
|
|
391
391
|
) ? g.progressItems.map(
|
|
392
|
-
(
|
|
392
|
+
(b) => b.progressItemId === a.progressItemId ? a : b
|
|
393
393
|
) : [...g.progressItems, a];
|
|
394
394
|
return { ...g, progressItems: h };
|
|
395
395
|
})
|
|
@@ -417,7 +417,7 @@ const ge = (e) => {
|
|
|
417
417
|
var i;
|
|
418
418
|
(i = e == null ? void 0 : e.onStreamTimeout) == null || i.call(e, a);
|
|
419
419
|
}
|
|
420
|
-
}), d =
|
|
420
|
+
}), d = N(
|
|
421
421
|
async (a, i) => {
|
|
422
422
|
const m = `task-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`, u = await o();
|
|
423
423
|
if (u.type === "success") {
|
|
@@ -435,7 +435,7 @@ const ge = (e) => {
|
|
|
435
435
|
loadingText: i == null ? void 0 : i.loadingText
|
|
436
436
|
}
|
|
437
437
|
]);
|
|
438
|
-
const { clientToken: f } = await e.fetchCreateAgentTaskClientToken(a.type), g = await
|
|
438
|
+
const { clientToken: f } = await e.fetchCreateAgentTaskClientToken(a.type), g = await X({
|
|
439
439
|
pk: t.fency.publishableKey,
|
|
440
440
|
baseUrl: t.fency.baseUrl,
|
|
441
441
|
clientToken: f,
|
|
@@ -460,7 +460,7 @@ const ge = (e) => {
|
|
|
460
460
|
c.current.add(
|
|
461
461
|
g.agentTask.id
|
|
462
462
|
), r((h) => [
|
|
463
|
-
...h.filter((
|
|
463
|
+
...h.filter((S) => S.taskKey !== m),
|
|
464
464
|
{
|
|
465
465
|
taskKey: m,
|
|
466
466
|
streamId: u.stream.id,
|
|
@@ -515,7 +515,7 @@ const ge = (e) => {
|
|
|
515
515
|
code: "UnknownError"
|
|
516
516
|
};
|
|
517
517
|
return r((h) => [
|
|
518
|
-
...h.filter((
|
|
518
|
+
...h.filter((S) => S.taskKey !== m),
|
|
519
519
|
{
|
|
520
520
|
taskKey: m,
|
|
521
521
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -537,7 +537,7 @@ const ge = (e) => {
|
|
|
537
537
|
return console.error(u.error), u;
|
|
538
538
|
},
|
|
539
539
|
[t, n, o]
|
|
540
|
-
), y =
|
|
540
|
+
), y = _(() => {
|
|
541
541
|
if (n.length !== 0)
|
|
542
542
|
return [...n].sort((a, i) => new Date(i.triggeredAt).getTime() - new Date(a.triggeredAt).getTime())[0];
|
|
543
543
|
}, [n]);
|
|
@@ -549,7 +549,7 @@ const ge = (e) => {
|
|
|
549
549
|
latest: y
|
|
550
550
|
};
|
|
551
551
|
};
|
|
552
|
-
function
|
|
552
|
+
function be(e) {
|
|
553
553
|
return e.progressItems.map((t, n) => {
|
|
554
554
|
const r = e.progressItems[n + 1], c = r != null;
|
|
555
555
|
let l;
|
|
@@ -565,7 +565,7 @@ function Se(e) {
|
|
|
565
565
|
};
|
|
566
566
|
});
|
|
567
567
|
}
|
|
568
|
-
function
|
|
568
|
+
function O({
|
|
569
569
|
text: e,
|
|
570
570
|
duration: t = 2,
|
|
571
571
|
delay: n = 0,
|
|
@@ -580,7 +580,7 @@ function P({
|
|
|
580
580
|
shimmerColor: m = "#000",
|
|
581
581
|
direction: u = "fromBottom"
|
|
582
582
|
}) {
|
|
583
|
-
const f = E(null), g = Y(f, { once: d, margin: y }), p =
|
|
583
|
+
const f = E(null), g = Y(f, { once: d, margin: y }), p = _(() => e.length * a, [e, a]), h = !o || g, S = u === "fromBottom" ? "100% center" : "-100% center", b = u === "fromBottom" ? "0% center" : "200% center";
|
|
584
584
|
return /* @__PURE__ */ s(
|
|
585
585
|
v.span,
|
|
586
586
|
{
|
|
@@ -602,11 +602,11 @@ function P({
|
|
|
602
602
|
backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
|
|
603
603
|
},
|
|
604
604
|
initial: {
|
|
605
|
-
backgroundPosition:
|
|
605
|
+
backgroundPosition: S,
|
|
606
606
|
opacity: 0
|
|
607
607
|
},
|
|
608
608
|
animate: h ? {
|
|
609
|
-
backgroundPosition:
|
|
609
|
+
backgroundPosition: b,
|
|
610
610
|
opacity: 1
|
|
611
611
|
} : {},
|
|
612
612
|
transition: {
|
|
@@ -663,7 +663,7 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
663
663
|
const t = e[e.length - 1];
|
|
664
664
|
if (!t) return null;
|
|
665
665
|
const n = ve(t);
|
|
666
|
-
return /* @__PURE__ */ s("div", { className: "simple-mode-container", children: /* @__PURE__ */ s(
|
|
666
|
+
return /* @__PURE__ */ s("div", { className: "simple-mode-container", children: /* @__PURE__ */ s(z, { mode: "wait", children: /* @__PURE__ */ s(
|
|
667
667
|
v.div,
|
|
668
668
|
{
|
|
669
669
|
initial: { opacity: 0, y: 10 },
|
|
@@ -678,7 +678,7 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
678
678
|
children: n
|
|
679
679
|
}
|
|
680
680
|
) : /* @__PURE__ */ s(
|
|
681
|
-
|
|
681
|
+
O,
|
|
682
682
|
{
|
|
683
683
|
text: n,
|
|
684
684
|
className: "simple-mode-title",
|
|
@@ -691,7 +691,7 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
691
691
|
},
|
|
692
692
|
t.item.progressItemId
|
|
693
693
|
) }) });
|
|
694
|
-
},
|
|
694
|
+
}, j = {
|
|
695
695
|
'code[class*="language-"]': {
|
|
696
696
|
color: "#f8f8f2",
|
|
697
697
|
background: "none",
|
|
@@ -858,15 +858,18 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
858
858
|
components: {
|
|
859
859
|
code(t) {
|
|
860
860
|
const { children: n, className: r, node: c, ref: l, ...o } = t, d = /language-(\w+)/.exec(r || "");
|
|
861
|
-
return d ?
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
861
|
+
return d ? (
|
|
862
|
+
// @ts-expect-error react-syntax-highlighter types incompatible with @types/react 18
|
|
863
|
+
/* @__PURE__ */ s(
|
|
864
|
+
L,
|
|
865
|
+
{
|
|
866
|
+
...o,
|
|
867
|
+
PreTag: "div",
|
|
868
|
+
children: String(n).replace(/\n$/, ""),
|
|
869
|
+
language: d[1],
|
|
870
|
+
style: j
|
|
871
|
+
}
|
|
872
|
+
)
|
|
870
873
|
) : /* @__PURE__ */ s("code", { ...o, className: r, children: String(n) });
|
|
871
874
|
}
|
|
872
875
|
},
|
|
@@ -874,7 +877,7 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
874
877
|
}
|
|
875
878
|
)
|
|
876
879
|
}
|
|
877
|
-
) }),
|
|
880
|
+
) }), Ce = ({ data: e }) => {
|
|
878
881
|
const t = JSON.stringify(e.json, null, 2);
|
|
879
882
|
return /* @__PURE__ */ s("div", { id: "structured-chat-completion-response", children: /* @__PURE__ */ s(
|
|
880
883
|
v.div,
|
|
@@ -882,12 +885,12 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
882
885
|
initial: { opacity: 0, y: -10 },
|
|
883
886
|
animate: { opacity: 1, y: 0 },
|
|
884
887
|
transition: { duration: 0.3, delay: 0 },
|
|
885
|
-
children: /* @__PURE__ */ s(
|
|
888
|
+
children: /* @__PURE__ */ s(L, { language: "json", style: j, PreTag: "div", children: t })
|
|
886
889
|
}
|
|
887
890
|
) });
|
|
888
|
-
},
|
|
891
|
+
}, ke = ({ data: e, isLatest: t = !1, durationSeconds: n }) => {
|
|
889
892
|
const r = `Searching: ${e.queryDescription}`;
|
|
890
|
-
return /* @__PURE__ */
|
|
893
|
+
return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
|
|
891
894
|
/* @__PURE__ */ s(
|
|
892
895
|
v.div,
|
|
893
896
|
{
|
|
@@ -901,7 +904,7 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
901
904
|
animate: { opacity: 1, y: 0 },
|
|
902
905
|
transition: { duration: 0.3, delay: 0 },
|
|
903
906
|
children: t && !n ? /* @__PURE__ */ s(
|
|
904
|
-
|
|
907
|
+
O,
|
|
905
908
|
{
|
|
906
909
|
text: r,
|
|
907
910
|
duration: 2.5,
|
|
@@ -912,7 +915,7 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
912
915
|
) : /* @__PURE__ */ s("span", { style: { color: "#666" }, children: r })
|
|
913
916
|
}
|
|
914
917
|
),
|
|
915
|
-
n !== void 0 && /* @__PURE__ */
|
|
918
|
+
n !== void 0 && /* @__PURE__ */ C(
|
|
916
919
|
"div",
|
|
917
920
|
{
|
|
918
921
|
style: {
|
|
@@ -931,7 +934,7 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
931
934
|
] });
|
|
932
935
|
}, xe = ({ isLatest: e = !1, durationSeconds: t }) => {
|
|
933
936
|
const n = "Adding sources...";
|
|
934
|
-
return /* @__PURE__ */
|
|
937
|
+
return /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
|
|
935
938
|
/* @__PURE__ */ s(
|
|
936
939
|
v.div,
|
|
937
940
|
{
|
|
@@ -945,7 +948,7 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
945
948
|
animate: { opacity: 1, y: 0 },
|
|
946
949
|
transition: { duration: 0.3, delay: 0 },
|
|
947
950
|
children: e && !t ? /* @__PURE__ */ s(
|
|
948
|
-
|
|
951
|
+
O,
|
|
949
952
|
{
|
|
950
953
|
text: n,
|
|
951
954
|
duration: 2.5,
|
|
@@ -956,7 +959,7 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
956
959
|
) : /* @__PURE__ */ s("span", { style: { color: "#666" }, children: n })
|
|
957
960
|
}
|
|
958
961
|
),
|
|
959
|
-
t !== void 0 && /* @__PURE__ */
|
|
962
|
+
t !== void 0 && /* @__PURE__ */ C(
|
|
960
963
|
"div",
|
|
961
964
|
{
|
|
962
965
|
style: {
|
|
@@ -973,7 +976,7 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
973
976
|
}
|
|
974
977
|
)
|
|
975
978
|
] });
|
|
976
|
-
}, we = ({ data: e, onSourceClick: t }) => /* @__PURE__ */
|
|
979
|
+
}, we = ({ data: e, onSourceClick: t }) => /* @__PURE__ */ C("div", { style: { padding: "16px" }, children: [
|
|
977
980
|
/* @__PURE__ */ s(
|
|
978
981
|
v.div,
|
|
979
982
|
{
|
|
@@ -992,7 +995,7 @@ const Te = ({ progressViewItems: e }) => {
|
|
|
992
995
|
}
|
|
993
996
|
),
|
|
994
997
|
/* @__PURE__ */ s("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: e.sources.length === 0 ? /* @__PURE__ */ s("span", { style: { fontSize: "13px", color: "#888" }, children: "No sources" }) : e.sources.map((n, r) => /* @__PURE__ */ s(
|
|
995
|
-
|
|
998
|
+
Ae,
|
|
996
999
|
{
|
|
997
1000
|
source: n,
|
|
998
1001
|
index: r,
|
|
@@ -1009,9 +1012,9 @@ function Ee(e) {
|
|
|
1009
1012
|
const t = e[e.length - 1];
|
|
1010
1013
|
return `pages ${e.slice(0, -1).join(", ")} and ${t}`;
|
|
1011
1014
|
}
|
|
1012
|
-
const
|
|
1013
|
-
const [r, c] =
|
|
1014
|
-
return /* @__PURE__ */
|
|
1015
|
+
const Ae = ({ source: e, index: t, onSourceClick: n }) => {
|
|
1016
|
+
const [r, c] = k(!1), l = !!n, o = e.pageNumbers ?? [], d = Ee(o);
|
|
1017
|
+
return /* @__PURE__ */ C(
|
|
1015
1018
|
v.div,
|
|
1016
1019
|
{
|
|
1017
1020
|
initial: { opacity: 0, scale: 0.9 },
|
|
@@ -1038,7 +1041,7 @@ const Ie = ({ source: e, index: t, onSourceClick: n }) => {
|
|
|
1038
1041
|
]
|
|
1039
1042
|
}
|
|
1040
1043
|
);
|
|
1041
|
-
},
|
|
1044
|
+
}, U = ({
|
|
1042
1045
|
color: e = "#78b13f",
|
|
1043
1046
|
size: t = 24,
|
|
1044
1047
|
borderWidth: n = 7
|
|
@@ -1057,7 +1060,7 @@ const Ie = ({ source: e, index: t, onSourceClick: n }) => {
|
|
|
1057
1060
|
}
|
|
1058
1061
|
}
|
|
1059
1062
|
);
|
|
1060
|
-
},
|
|
1063
|
+
}, Ie = ({
|
|
1061
1064
|
color: e = "#333",
|
|
1062
1065
|
size: t = 32,
|
|
1063
1066
|
lineWidth: n = 2
|
|
@@ -1070,7 +1073,7 @@ const Ie = ({ source: e, index: t, onSourceClick: n }) => {
|
|
|
1070
1073
|
height: r,
|
|
1071
1074
|
backgroundColor: e
|
|
1072
1075
|
};
|
|
1073
|
-
return /* @__PURE__ */
|
|
1076
|
+
return /* @__PURE__ */ C(
|
|
1074
1077
|
"span",
|
|
1075
1078
|
{
|
|
1076
1079
|
style: {
|
|
@@ -1106,11 +1109,11 @@ function Me({
|
|
|
1106
1109
|
eventType: e,
|
|
1107
1110
|
completed: t
|
|
1108
1111
|
}) {
|
|
1109
|
-
return e === "ExploreMemoryError" ? /* @__PURE__ */ s(
|
|
1112
|
+
return e === "ExploreMemoryError" ? /* @__PURE__ */ s(Ie, { color: "#c62828", size: 18, lineWidth: 3 }) : e === "ExploreMemoryResult" ? /* @__PURE__ */ s(U, { color: "#999", size: 20, borderWidth: 3 }) : e === "ExploreMemoryStart" ? t ? /* @__PURE__ */ s(U, { color: "#999", size: 20, borderWidth: 3 }) : /* @__PURE__ */ s("span", { className: "explore-memory-loader" }) : null;
|
|
1110
1113
|
}
|
|
1111
|
-
const
|
|
1112
|
-
const [r, c] =
|
|
1113
|
-
return /* @__PURE__ */ s("div", { style: { padding: "10px" }, children: /* @__PURE__ */
|
|
1114
|
+
const $ = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
1115
|
+
const [r, c] = k(!1), l = e.eventType === "ExploreMemoryResult" ? e.result : void 0, o = l != null && l.length > $, d = l != null ? r || !o ? l : `${l.slice(0, $)}...` : void 0, y = o;
|
|
1116
|
+
return /* @__PURE__ */ s("div", { style: { padding: "10px" }, children: /* @__PURE__ */ C(
|
|
1114
1117
|
v.div,
|
|
1115
1118
|
{
|
|
1116
1119
|
initial: { opacity: 0 },
|
|
@@ -1147,7 +1150,7 @@ const U = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1147
1150
|
)
|
|
1148
1151
|
}
|
|
1149
1152
|
),
|
|
1150
|
-
/* @__PURE__ */
|
|
1153
|
+
/* @__PURE__ */ C(
|
|
1151
1154
|
"div",
|
|
1152
1155
|
{
|
|
1153
1156
|
style: {
|
|
@@ -1193,7 +1196,7 @@ const U = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1193
1196
|
]
|
|
1194
1197
|
}
|
|
1195
1198
|
) });
|
|
1196
|
-
},
|
|
1199
|
+
}, Oe = ({ message: e }) => /* @__PURE__ */ s("div", { style: { padding: "16px" }, children: /* @__PURE__ */ s(
|
|
1197
1200
|
v.div,
|
|
1198
1201
|
{
|
|
1199
1202
|
initial: { opacity: 0, y: -10 },
|
|
@@ -1216,7 +1219,7 @@ const U = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1216
1219
|
}
|
|
1217
1220
|
)
|
|
1218
1221
|
}
|
|
1219
|
-
) }),
|
|
1222
|
+
) }), Pe = ({
|
|
1220
1223
|
progressViewItems: e,
|
|
1221
1224
|
loadingText: t,
|
|
1222
1225
|
onSourceClick: n
|
|
@@ -1230,14 +1233,14 @@ const U = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1230
1233
|
if (o.taskType === "StreamingChatCompletion" && o.eventType === "Text")
|
|
1231
1234
|
return /* @__PURE__ */ s(B, { text: o.text });
|
|
1232
1235
|
if (o.taskType === "StructuredChatCompletion" && o.eventType === "Json")
|
|
1233
|
-
return /* @__PURE__ */ s(
|
|
1236
|
+
return /* @__PURE__ */ s(Ce, { data: o });
|
|
1234
1237
|
if (o.taskType === "MemoryChatCompletion")
|
|
1235
1238
|
switch (o.eventType) {
|
|
1236
1239
|
case "Text":
|
|
1237
1240
|
return /* @__PURE__ */ s(B, { text: o.text });
|
|
1238
1241
|
case "Search":
|
|
1239
1242
|
return /* @__PURE__ */ s(
|
|
1240
|
-
|
|
1243
|
+
ke,
|
|
1241
1244
|
{
|
|
1242
1245
|
data: o,
|
|
1243
1246
|
isLatest: l.isLatest,
|
|
@@ -1275,10 +1278,10 @@ const U = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1275
1278
|
case "Completed":
|
|
1276
1279
|
return null;
|
|
1277
1280
|
}
|
|
1278
|
-
return o.taskType === "StreamingChatCompletion" && o.eventType === "Completed" || o.taskType === "StructuredChatCompletion" && o.eventType === "Completed" ? null : o.eventType === "Error" && "message" in o ? /* @__PURE__ */ s(
|
|
1281
|
+
return o.taskType === "StreamingChatCompletion" && o.eventType === "Completed" || o.taskType === "StructuredChatCompletion" && o.eventType === "Completed" ? null : o.eventType === "Error" && "message" in o ? /* @__PURE__ */ s(Oe, { message: o.message }) : null;
|
|
1279
1282
|
};
|
|
1280
1283
|
return e.length === 0 ? /* @__PURE__ */ s("div", { style: { width: "fit-content" }, children: /* @__PURE__ */ s(
|
|
1281
|
-
|
|
1284
|
+
O,
|
|
1282
1285
|
{
|
|
1283
1286
|
text: t ?? "Processing your task...",
|
|
1284
1287
|
duration: 1.5,
|
|
@@ -1287,7 +1290,7 @@ const U = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1287
1290
|
color: "#999",
|
|
1288
1291
|
shimmerColor: "#000"
|
|
1289
1292
|
}
|
|
1290
|
-
) }) : /* @__PURE__ */ s("div", { id: "agent-task-progress-verbose", ref: r, children: /* @__PURE__ */ s(
|
|
1293
|
+
) }) : /* @__PURE__ */ s("div", { id: "agent-task-progress-verbose", ref: r, children: /* @__PURE__ */ s(z, { children: e.map((l, o) => /* @__PURE__ */ s(
|
|
1291
1294
|
v.div,
|
|
1292
1295
|
{
|
|
1293
1296
|
id: `agent-task-progress-item-${l.item.progressItemId}`,
|
|
@@ -1302,14 +1305,14 @@ const U = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1302
1305
|
},
|
|
1303
1306
|
l.item.progressItemId
|
|
1304
1307
|
)) }) });
|
|
1305
|
-
},
|
|
1308
|
+
}, We = ({
|
|
1306
1309
|
agentTask: e,
|
|
1307
1310
|
mode: t = "verbose",
|
|
1308
1311
|
onSourceClick: n
|
|
1309
1312
|
}) => {
|
|
1310
|
-
const r =
|
|
1313
|
+
const r = be(e);
|
|
1311
1314
|
return t === "simple" ? /* @__PURE__ */ s(Te, { progressViewItems: r }) : /* @__PURE__ */ s(
|
|
1312
|
-
|
|
1315
|
+
Pe,
|
|
1313
1316
|
{
|
|
1314
1317
|
progressViewItems: r,
|
|
1315
1318
|
loadingText: e.loadingText,
|
|
@@ -1318,9 +1321,9 @@ const U = 80, De = ({ data: e, completed: t, isLatest: n = !1 }) => {
|
|
|
1318
1321
|
);
|
|
1319
1322
|
};
|
|
1320
1323
|
export {
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1324
|
+
We as AgentTaskProgress,
|
|
1325
|
+
U as Checkmark,
|
|
1326
|
+
ze as FencyProvider,
|
|
1327
|
+
Ie as XMark,
|
|
1328
|
+
Le as useAgentTasks
|
|
1326
1329
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { AgentTaskEventData } from '@fencyai/js';
|
|
2
2
|
export type StreamTimeout = {
|
|
3
|
-
type: '
|
|
3
|
+
type: 'STREAM_TIMEOUT';
|
|
4
4
|
streamId: string;
|
|
5
5
|
timestamp: string;
|
|
6
6
|
};
|
|
7
7
|
export type StreamNotFound = {
|
|
8
|
-
type: '
|
|
8
|
+
type: 'STREAM_NOT_FOUND';
|
|
9
9
|
streamId: string;
|
|
10
10
|
timestamp: string;
|
|
11
11
|
};
|
|
12
12
|
export type AgentTaskProgressItemUpdated = {
|
|
13
|
-
type: '
|
|
13
|
+
type: 'AGENT_TASK_PROGRESS_ITEM_UPDATED';
|
|
14
14
|
streamId: string;
|
|
15
15
|
agentTaskId: string;
|
|
16
16
|
progressItemId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StreamData.d.ts","sourceRoot":"","sources":["../../src/types/StreamData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,MAAM,MAAM,aAAa,GAAG;IACxB,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"StreamData.d.ts","sourceRoot":"","sources":["../../src/types/StreamData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,MAAM,MAAM,aAAa,GAAG;IACxB,IAAI,EAAE,gBAAgB,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IACzB,IAAI,EAAE,kBAAkB,CAAA;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG;IACvC,IAAI,EAAE,kCAAkC,CAAA;IACxC,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,kBAAkB,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,UAAU,GAChB,aAAa,GACb,cAAc,GACd,4BAA4B,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fencyai/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.136",
|
|
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.136",
|
|
41
41
|
"@testing-library/react": "^16.3.2",
|
|
42
42
|
"@types/jest": "^29.5.11",
|
|
43
43
|
"@types/node": "^20.10.5",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"vite-plugin-lib-inject-css": "^2.1.1"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@fencyai/js": "^0.1.
|
|
56
|
+
"@fencyai/js": "^0.1.136",
|
|
57
57
|
"motion": "^11.15.0",
|
|
58
58
|
"react": ">=16.8.0",
|
|
59
59
|
"react-markdown": "^10.1.0",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"optional": false
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "329df97e8c3ae4b8faf31cf75a4bd842cd7d61e0"
|
|
70
70
|
}
|