@fencyai/react 0.1.105 → 0.1.106
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/index.js +30 -31
- package/dist/types/CreateAgentTaskParams.d.ts +2 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAgentTask as ke, searchMemories as Ae, listMemoryTypes as Pe, createFileDownloadLink as Ee, AgentTaskProgressItemType as ee, createStream as Ne } from "@fencyai/js";
|
|
2
|
-
import { createContext as Me, useContext as _e, useState as x, useEffect as N, useCallback as I, useMemo as
|
|
2
|
+
import { createContext as Me, useContext as _e, useState as x, useEffect as N, useCallback as I, useMemo as G, useRef as _, useLayoutEffect as pe } from "react";
|
|
3
3
|
import { jsxs as A, jsx as f, Fragment as fe } from "react/jsx-runtime";
|
|
4
4
|
import { motion as $, useInView as Fe, AnimatePresence as ye } from "motion/react";
|
|
5
5
|
import be from "react-markdown";
|
|
@@ -58,9 +58,9 @@ const Ue = (e) => {
|
|
|
58
58
|
case "ChatCompletionStreamCompleted":
|
|
59
59
|
return We(e);
|
|
60
60
|
case "StreamTimeout":
|
|
61
|
-
return Le(e);
|
|
62
|
-
case "StreamNotFound":
|
|
63
61
|
return Be(e);
|
|
62
|
+
case "StreamNotFound":
|
|
63
|
+
return Le(e);
|
|
64
64
|
case "FileUploadCompleted":
|
|
65
65
|
return He(e);
|
|
66
66
|
case "FileTextContentReady":
|
|
@@ -80,11 +80,11 @@ const Ue = (e) => {
|
|
|
80
80
|
streamId: e.streamId,
|
|
81
81
|
chatCompletionId: e.chatCompletionId,
|
|
82
82
|
timestamp: e.timestamp
|
|
83
|
-
}),
|
|
83
|
+
}), Be = (e) => ({
|
|
84
84
|
type: "StreamTimeout",
|
|
85
85
|
streamId: e.streamId,
|
|
86
86
|
timestamp: e.timestamp
|
|
87
|
-
}),
|
|
87
|
+
}), Le = (e) => ({
|
|
88
88
|
type: "StreamNotFound",
|
|
89
89
|
streamId: e.streamId,
|
|
90
90
|
timestamp: e.timestamp
|
|
@@ -173,7 +173,7 @@ const Ue = (e) => {
|
|
|
173
173
|
},
|
|
174
174
|
stream: s
|
|
175
175
|
};
|
|
176
|
-
},
|
|
176
|
+
}, je = (e) => {
|
|
177
177
|
const a = H(), [s, c] = x([]), { createStream: i } = Ke({
|
|
178
178
|
fetchClientSecret: e.fetchCreateStreamClientSecret,
|
|
179
179
|
onAgentTaskProgressItemUpdated: (t) => {
|
|
@@ -252,7 +252,9 @@ const Ue = (e) => {
|
|
|
252
252
|
clientSecret: m == null ? void 0 : m.clientSecret,
|
|
253
253
|
request: {
|
|
254
254
|
streamId: n.stream.id,
|
|
255
|
-
queryText: t.queryText
|
|
255
|
+
queryText: t.queryText,
|
|
256
|
+
jsonSchema: t.jsonSchema,
|
|
257
|
+
todos: t.todos
|
|
256
258
|
}
|
|
257
259
|
});
|
|
258
260
|
if (r.type === "success" && r.agentTask)
|
|
@@ -326,14 +328,14 @@ const Ue = (e) => {
|
|
|
326
328
|
return console.error(n.error), n;
|
|
327
329
|
},
|
|
328
330
|
[a, s, i]
|
|
329
|
-
), u =
|
|
331
|
+
), u = G(() => s.sort((t, n) => new Date(n.triggeredAt).getTime() - new Date(t.triggeredAt).getTime())[0], [s]);
|
|
330
332
|
return {
|
|
331
333
|
agentTasks: s,
|
|
332
334
|
createAgentTask: d,
|
|
333
335
|
latest: u
|
|
334
336
|
};
|
|
335
337
|
};
|
|
336
|
-
function
|
|
338
|
+
function Ge() {
|
|
337
339
|
const e = H();
|
|
338
340
|
return {
|
|
339
341
|
search: async (s) => {
|
|
@@ -647,10 +649,7 @@ const xe = {
|
|
|
647
649
|
const { fency: c } = H(), i = I(
|
|
648
650
|
async (d) => {
|
|
649
651
|
try {
|
|
650
|
-
|
|
651
|
-
const { clientSecret: u } = await a(d);
|
|
652
|
-
console.log("Got client secret");
|
|
653
|
-
const t = await Ee({
|
|
652
|
+
const { clientSecret: u } = await a(d), t = await Ee({
|
|
654
653
|
pk: c.publishableKey,
|
|
655
654
|
baseUrl: c.baseUrl,
|
|
656
655
|
clientSecret: u,
|
|
@@ -658,7 +657,7 @@ const xe = {
|
|
|
658
657
|
fileId: d
|
|
659
658
|
}
|
|
660
659
|
});
|
|
661
|
-
|
|
660
|
+
t.type === "success" && window.open(t.downloadLink, "_blank");
|
|
662
661
|
} catch (u) {
|
|
663
662
|
console.error("Failed to download file:", u);
|
|
664
663
|
}
|
|
@@ -761,7 +760,7 @@ function se({
|
|
|
761
760
|
shimmerColor: r = "#000",
|
|
762
761
|
direction: o = "fromBottom"
|
|
763
762
|
}) {
|
|
764
|
-
const l = _(null), g = Fe(l, { once: t, margin: n }), p =
|
|
763
|
+
const l = _(null), g = Fe(l, { once: t, margin: n }), p = G(() => e.length * h, [e, h]), C = !u || g, y = o === "fromBottom" ? "100% center" : "-100% center", S = o === "fromBottom" ? "0% center" : "200% center";
|
|
765
764
|
return /* @__PURE__ */ f(
|
|
766
765
|
$.span,
|
|
767
766
|
{
|
|
@@ -1574,7 +1573,7 @@ const gt = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20wid
|
|
|
1574
1573
|
memories: t
|
|
1575
1574
|
}) => {
|
|
1576
1575
|
var ge;
|
|
1577
|
-
const [n, h] = x(""), [m, r] = x(""), [o, l] = x(""), [g, p] = x(!1), [C, y] = x(0), [S, M] = x(0), [W, E] = x(null), [v, U] = x(0), [P, Q] = x(null), D = _(null), X = _(null), te = _(!1), [ce, At] = x([]), ne = _(/* @__PURE__ */ new Map()), re =
|
|
1576
|
+
const [n, h] = x(""), [m, r] = x(""), [o, l] = x(""), [g, p] = x(!1), [C, y] = x(0), [S, M] = x(0), [W, E] = x(null), [v, U] = x(0), [P, Q] = x(null), D = _(null), X = _(null), te = _(!1), [ce, At] = x([]), ne = _(/* @__PURE__ */ new Map()), re = G(() => {
|
|
1578
1577
|
const b = /* @__PURE__ */ new Map();
|
|
1579
1578
|
return ne.current.forEach((w, O) => {
|
|
1580
1579
|
b.set(O, w);
|
|
@@ -1593,7 +1592,7 @@ const gt = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20wid
|
|
|
1593
1592
|
clearTimeout(b);
|
|
1594
1593
|
};
|
|
1595
1594
|
}, [m]);
|
|
1596
|
-
const z =
|
|
1595
|
+
const z = G(() => {
|
|
1597
1596
|
const b = P !== null || m !== "", w = P === null && m === "";
|
|
1598
1597
|
return [
|
|
1599
1598
|
...b ? t.map((T) => ({
|
|
@@ -1642,11 +1641,11 @@ const gt = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20wid
|
|
|
1642
1641
|
Q(null);
|
|
1643
1642
|
const O = t.find((Y) => Y.id === w.id);
|
|
1644
1643
|
O && ne.current.set(O.id, O);
|
|
1645
|
-
const T = n, F = T.slice(0, C),
|
|
1646
|
-
if (
|
|
1647
|
-
const
|
|
1648
|
-
h(
|
|
1649
|
-
R(
|
|
1644
|
+
const T = n, F = T.slice(0, C), B = T.slice(C), L = F.lastIndexOf("@");
|
|
1645
|
+
if (L === -1) return;
|
|
1646
|
+
const j = F.slice(0, L) + "@" + w.label + " " + B, he = F.slice(0, L).length + w.label.length + 2;
|
|
1647
|
+
h(j), e(j), q(j), le(), K(j), requestAnimationFrame(() => {
|
|
1648
|
+
R(j, !1), requestAnimationFrame(() => {
|
|
1650
1649
|
var Y;
|
|
1651
1650
|
(Y = D.current) == null || Y.focus(), ae(he), y(he);
|
|
1652
1651
|
});
|
|
@@ -1704,7 +1703,7 @@ const gt = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20wid
|
|
|
1704
1703
|
onKeyDown: (b) => {
|
|
1705
1704
|
if (!(g && Te(b)) && b.key === "Enter" && !b.shiftKey && !g) {
|
|
1706
1705
|
if (b.preventDefault(), d && n.trim()) {
|
|
1707
|
-
const w = Ie(n), T = ve(n).map((F) => re.find((
|
|
1706
|
+
const w = Ie(n), T = ve(n).map((F) => re.find((B) => B.id === F)).filter((F) => F !== void 0);
|
|
1708
1707
|
d(n, w, T), h(""), e(""), q(""), R("", !1), ne.current.clear();
|
|
1709
1708
|
}
|
|
1710
1709
|
return;
|
|
@@ -1739,11 +1738,11 @@ const gt = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20wid
|
|
|
1739
1738
|
r(""), l(""), P && Q(null);
|
|
1740
1739
|
const b = n, w = b.slice(0, C), O = b.slice(C), T = w.lastIndexOf("@");
|
|
1741
1740
|
if (T !== -1) {
|
|
1742
|
-
const F = b.slice(0, T + 1) + O,
|
|
1741
|
+
const F = b.slice(0, T + 1) + O, B = T + 1;
|
|
1743
1742
|
h(F), e(F), q(F), requestAnimationFrame(() => {
|
|
1744
1743
|
R(F, !1), requestAnimationFrame(() => {
|
|
1745
|
-
var
|
|
1746
|
-
(
|
|
1744
|
+
var L;
|
|
1745
|
+
(L = D.current) == null || L.focus(), ae(B), y(B);
|
|
1747
1746
|
});
|
|
1748
1747
|
});
|
|
1749
1748
|
}
|
|
@@ -1759,10 +1758,10 @@ const gt = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20wid
|
|
|
1759
1758
|
fetchCreateStreamClientSecret: i,
|
|
1760
1759
|
fetchGetDownloadLinkClientSecret: d
|
|
1761
1760
|
}) => {
|
|
1762
|
-
const { createAgentTask: u, agentTasks: t } =
|
|
1761
|
+
const { createAgentTask: u, agentTasks: t } = je({
|
|
1763
1762
|
fetchCreateStreamClientSecret: i,
|
|
1764
1763
|
fetchCreateAgentTaskClientSecret: c
|
|
1765
|
-
}), [n, h] = x(""), [m, r] = x(null), [o, l] = x(null), { listFirstPage: g } = Qe(), { search: p } =
|
|
1764
|
+
}), [n, h] = x(""), [m, r] = x(null), [o, l] = x(null), { listFirstPage: g } = Qe(), { search: p } = Ge(), [C, y] = x(
|
|
1766
1765
|
null
|
|
1767
1766
|
), [S, M] = x(null), W = _(!1);
|
|
1768
1767
|
N(() => {
|
|
@@ -1780,7 +1779,7 @@ const gt = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20wid
|
|
|
1780
1779
|
v.type === "success" && M(v.items);
|
|
1781
1780
|
});
|
|
1782
1781
|
}, [m, o, n]);
|
|
1783
|
-
const E =
|
|
1782
|
+
const E = G(() => t.flatMap((v) => /* @__PURE__ */ f(et, { agentTask: v, fetchGetDownloadLinkClientSecret: d }, v.streamId)), [t]);
|
|
1784
1783
|
return /* @__PURE__ */ A(
|
|
1785
1784
|
"div",
|
|
1786
1785
|
{
|
|
@@ -1892,10 +1891,10 @@ export {
|
|
|
1892
1891
|
kt as MentionInput,
|
|
1893
1892
|
Tt as MentionPopover,
|
|
1894
1893
|
se as ShimmeringText,
|
|
1895
|
-
|
|
1894
|
+
je as useAgentTasks,
|
|
1896
1895
|
Re as useFencyEventSource,
|
|
1897
1896
|
Qe as useListMemoryTypes,
|
|
1898
1897
|
Ve as usePaginatedQuery,
|
|
1899
|
-
|
|
1898
|
+
Ge as useSearchMemories,
|
|
1900
1899
|
Ke as useStream
|
|
1901
1900
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fencyai/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.106",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "staklau <steinaageklaussen@gmail.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"prepublishOnly": "npm run build"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@fencyai/js": "^0.1.
|
|
35
|
+
"@fencyai/js": "^0.1.106",
|
|
36
36
|
"@types/jest": "^29.5.11",
|
|
37
37
|
"@types/node": "^20.10.5",
|
|
38
38
|
"@types/react": "^18.2.45",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@emotion/is-prop-valid": "^1.3.0",
|
|
50
|
-
"@fencyai/js": "^0.1.
|
|
50
|
+
"@fencyai/js": "^0.1.106",
|
|
51
51
|
"@radix-ui/react-popover": "^1.1.15",
|
|
52
52
|
"motion": "^11.15.0",
|
|
53
53
|
"react": ">=16.8.0",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"optional": false
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "e516e654cc331c80fb151ff035b29796ac736b26"
|
|
66
66
|
}
|