@useago/sdk 1.5.3 → 1.5.4
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/CHANGELOG.md +18 -0
- package/README.md +10 -0
- package/dist/AgoClient-BW0YZsis.js +1681 -0
- package/dist/AgoClient-Ba3ICq4K.cjs +8 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +41 -0
- package/dist/angular.d.ts +41 -0
- package/dist/angular.js +2 -2
- package/dist/{createConversationSession-C7cnnWKW.js → createConversationSession-BjsgjL-v.js} +1 -1
- package/dist/{createConversationSession-BCb0D6bt.cjs → createConversationSession-okoz3teC.cjs} +1 -1
- package/dist/{createFormCollector-t_fGyuTD.cjs → createFormCollector-BWIh1pMl.cjs} +1 -1
- package/dist/{createFormCollector-iCDwAwYJ.js → createFormCollector-Bay2UpRv.js} +1 -1
- package/dist/devtools.d.cts +41 -0
- package/dist/devtools.d.ts +41 -0
- package/dist/functions-CPs7omgM.cjs +1 -0
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +54 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +64 -62
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +55 -0
- package/dist/react.d.ts +55 -0
- package/dist/react.js +142 -122
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +41 -0
- package/dist/testing.d.ts +41 -0
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +41 -0
- package/dist/vue.d.ts +41 -0
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +1 -1
- package/dist/widget.d.cts +41 -0
- package/dist/widget.d.ts +41 -0
- package/dist/widget.js +3 -3
- package/llms-full.txt +29 -0
- package/package.json +1 -1
- package/dist/AgoClient-BGkFSNZF.cjs +0 -8
- package/dist/AgoClient-CW-BLT1_.js +0 -1542
- package/dist/functions-IGSjjvF4.cjs +0 -1
- package/dist/rolldown-runtime-16Nf8qvH.cjs +0 -1
- /package/dist/{autoContinue-D3Mmaaca.js → autoContinue-CC8K9mBU.js} +0 -0
- /package/dist/{autoContinue-CcCTva-D.cjs → autoContinue-CP9pJR-V.cjs} +0 -0
- /package/dist/{createMockClient-Br0TWgLO.js → createMockClient-DcuNlufr.js} +0 -0
- /package/dist/{createMockClient-BwNLPjeT.cjs → createMockClient-Dw-cyISN.cjs} +0 -0
- /package/dist/{functions-CApuQZ2b.js → functions-tzyOZNp6.js} +0 -0
package/dist/react.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { a as Y, b as
|
|
2
|
-
import { t as ne } from "./autoContinue-
|
|
3
|
-
import { n as He, r as j, t as B } from "./createFormCollector-
|
|
4
|
-
import { t as
|
|
5
|
-
import re, { createContext as oe, useCallback as R, useContext as G, useEffect as
|
|
6
|
-
import { Fragment as U, jsx as l, jsxs as
|
|
1
|
+
import { a as Y, b as L, h as X, i as Z, o as Q, s as ee, t as te } from "./AgoClient-BW0YZsis.js";
|
|
2
|
+
import { t as ne } from "./autoContinue-CC8K9mBU.js";
|
|
3
|
+
import { n as He, r as j, t as B } from "./createFormCollector-Bay2UpRv.js";
|
|
4
|
+
import { t as Oe } from "./createMockClient-DcuNlufr.js";
|
|
5
|
+
import re, { createContext as oe, useCallback as R, useContext as G, useEffect as I, useId as ae, useMemo as D, useRef as M, useState as E, useSyncExternalStore as se } from "react";
|
|
6
|
+
import { Fragment as U, jsx as l, jsxs as _ } from "react/jsx-runtime";
|
|
7
7
|
import ie from "react-markdown";
|
|
8
8
|
import le from "remark-gfm";
|
|
9
9
|
function ce(e) {
|
|
10
|
-
const [r, t] = E(!1), o =
|
|
10
|
+
const [r, t] = E(!1), o = M(null), n = D(() => {
|
|
11
11
|
if (o.current && (o.current.destroy(), o.current = null), !e) return null;
|
|
12
12
|
const s = new te(e);
|
|
13
13
|
return o.current = s, s;
|
|
14
14
|
}, [e?.baseUrl, e?.widgetId]);
|
|
15
|
-
return
|
|
15
|
+
return I(() => (n && o.current === null && (o.current = n, n.reviveAfterDestroy()), t(!0), () => {
|
|
16
16
|
o.current?.destroy(), o.current = null;
|
|
17
|
-
}), [n]),
|
|
17
|
+
}), [n]), I(() => {
|
|
18
18
|
o.current && e && o.current.updateConfig({
|
|
19
19
|
agent: e.agent,
|
|
20
20
|
defaultAgentId: e.defaultAgentId,
|
|
@@ -37,19 +37,19 @@ function ce(e) {
|
|
|
37
37
|
isReady: r
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
var
|
|
40
|
+
var $ = oe(null), Ke = ({ children: e, client: r, tools: t, helpers: o, pageContext: n, ...s }) => {
|
|
41
41
|
const { client: c } = ce(r ? null : s), a = r || c;
|
|
42
|
-
return
|
|
42
|
+
return I(() => {
|
|
43
43
|
if (!(!t || t.length === 0)) {
|
|
44
44
|
for (const f of t) a.register(f);
|
|
45
45
|
return () => {
|
|
46
46
|
for (const f of t) a.unregisterFunction(f.name);
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
}, [a, t]),
|
|
49
|
+
}, [a, t]), I(() => {
|
|
50
50
|
if (!o) return;
|
|
51
51
|
const f = [];
|
|
52
|
-
return import("./functions-
|
|
52
|
+
return import("./functions-tzyOZNp6.js").then((d) => d.n).then((d) => {
|
|
53
53
|
for (const [g, C] of Object.entries(o)) {
|
|
54
54
|
const N = d[g];
|
|
55
55
|
if (!N) {
|
|
@@ -65,26 +65,26 @@ var L = oe(null), Ke = ({ children: e, client: r, tools: t, helpers: o, pageCont
|
|
|
65
65
|
}), () => {
|
|
66
66
|
for (const d of f) a.unregisterFunction(d);
|
|
67
67
|
};
|
|
68
|
-
}, [a, o]),
|
|
68
|
+
}, [a, o]), I(() => {
|
|
69
69
|
n === "auto" && a.enableAutoPageContext();
|
|
70
|
-
}, [a, n]), /* @__PURE__ */ l(
|
|
70
|
+
}, [a, n]), /* @__PURE__ */ l($.Provider, {
|
|
71
71
|
value: a,
|
|
72
72
|
children: e
|
|
73
73
|
});
|
|
74
74
|
};
|
|
75
|
-
function
|
|
76
|
-
const e = G(
|
|
75
|
+
function z() {
|
|
76
|
+
const e = G($);
|
|
77
77
|
if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
|
|
78
78
|
return e;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
return G(
|
|
80
|
+
function P() {
|
|
81
|
+
return G($);
|
|
82
82
|
}
|
|
83
83
|
function K({ client: e, conversationId: r } = {}) {
|
|
84
|
-
const t =
|
|
84
|
+
const t = P(), o = e || t;
|
|
85
85
|
if (!o) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
86
86
|
const [n, s] = E([]), [c, a] = E(r), [f, d] = E(!1), [g, C] = E(null);
|
|
87
|
-
|
|
87
|
+
I(() => {
|
|
88
88
|
r && r !== c && (a(r), N(r));
|
|
89
89
|
}, [r]);
|
|
90
90
|
const N = async (S) => {
|
|
@@ -94,7 +94,7 @@ function K({ client: e, conversationId: r } = {}) {
|
|
|
94
94
|
C(k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to load messages"));
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
-
return
|
|
97
|
+
return I(() => {
|
|
98
98
|
const S = (u) => u === "IN_PROGRESS" || u === "WAITING_CLIENT", k = (u) => {
|
|
99
99
|
c || a(u.conversationId), d(!0), s((h) => {
|
|
100
100
|
const w = h.findIndex((b) => b.id === u.messageId);
|
|
@@ -204,7 +204,7 @@ function K({ client: e, conversationId: r } = {}) {
|
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
206
|
var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", allowFiles: o = !1, className: n = "" }) => {
|
|
207
|
-
const [s, c] = E(""), [a, f] = E([]), d =
|
|
207
|
+
const [s, c] = E(""), [a, f] = E([]), d = M(null), g = M(null), C = R(() => {
|
|
208
208
|
const i = g.current;
|
|
209
209
|
if (!i) return;
|
|
210
210
|
const v = 110;
|
|
@@ -224,7 +224,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
224
224
|
}, []), p = R((i) => {
|
|
225
225
|
f((v) => v.filter((u, h) => h !== i));
|
|
226
226
|
}, []), x = s.trim() || a.length > 0;
|
|
227
|
-
return /* @__PURE__ */
|
|
227
|
+
return /* @__PURE__ */ _("form", {
|
|
228
228
|
onSubmit: N,
|
|
229
229
|
className: `ago-chat-input ${n}`,
|
|
230
230
|
style: {
|
|
@@ -242,7 +242,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
242
242
|
flexWrap: "wrap",
|
|
243
243
|
gap: "6px"
|
|
244
244
|
},
|
|
245
|
-
children: a.map((i, v) => /* @__PURE__ */
|
|
245
|
+
children: a.map((i, v) => /* @__PURE__ */ _("div", {
|
|
246
246
|
style: {
|
|
247
247
|
display: "flex",
|
|
248
248
|
alignItems: "center",
|
|
@@ -277,14 +277,14 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
277
277
|
children: "×"
|
|
278
278
|
})]
|
|
279
279
|
}, v))
|
|
280
|
-
}), /* @__PURE__ */
|
|
280
|
+
}), /* @__PURE__ */ _("div", {
|
|
281
281
|
style: {
|
|
282
282
|
display: "flex",
|
|
283
283
|
gap: "8px",
|
|
284
284
|
alignItems: "flex-end"
|
|
285
285
|
},
|
|
286
286
|
children: [
|
|
287
|
-
o && /* @__PURE__ */
|
|
287
|
+
o && /* @__PURE__ */ _(U, { children: [/* @__PURE__ */ l("button", {
|
|
288
288
|
type: "button",
|
|
289
289
|
onClick: () => d.current?.click(),
|
|
290
290
|
disabled: r,
|
|
@@ -378,7 +378,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
378
378
|
},
|
|
379
379
|
...r,
|
|
380
380
|
children: e
|
|
381
|
-
}),
|
|
381
|
+
}), W = (e, r) => {
|
|
382
382
|
const t = ({ children: o, ...n }) => re.createElement(`h${e}`, {
|
|
383
383
|
style: {
|
|
384
384
|
margin: "16px 0 8px 0",
|
|
@@ -501,12 +501,12 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
501
501
|
}), ke = {
|
|
502
502
|
a: ue,
|
|
503
503
|
p: fe,
|
|
504
|
-
h1:
|
|
505
|
-
h2:
|
|
506
|
-
h3:
|
|
507
|
-
h4:
|
|
508
|
-
h5:
|
|
509
|
-
h6:
|
|
504
|
+
h1: W(1, "20px"),
|
|
505
|
+
h2: W(2, "18px"),
|
|
506
|
+
h3: W(3, "16px"),
|
|
507
|
+
h4: W(4, "15px"),
|
|
508
|
+
h5: W(5, "14px"),
|
|
509
|
+
h6: W(6, "13px"),
|
|
510
510
|
ul: pe,
|
|
511
511
|
ol: ge,
|
|
512
512
|
li: me,
|
|
@@ -518,8 +518,8 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
518
518
|
td: we,
|
|
519
519
|
img: Ce,
|
|
520
520
|
hr: Se
|
|
521
|
-
},
|
|
522
|
-
remarkPlugins:
|
|
521
|
+
}, Ae = [le], Ie = ({ content: e }) => /* @__PURE__ */ l(ie, {
|
|
522
|
+
remarkPlugins: Ae,
|
|
523
523
|
components: ke,
|
|
524
524
|
children: e
|
|
525
525
|
}), Ne = ({ attachment: e, isUser: r }) => {
|
|
@@ -546,7 +546,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
546
546
|
}
|
|
547
547
|
})
|
|
548
548
|
});
|
|
549
|
-
const o = Q(e.fileSize), n = /* @__PURE__ */
|
|
549
|
+
const o = Q(e.fileSize), n = /* @__PURE__ */ _(U, { children: [/* @__PURE__ */ l("span", {
|
|
550
550
|
style: {
|
|
551
551
|
fontSize: "16px",
|
|
552
552
|
lineHeight: 1,
|
|
@@ -554,7 +554,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
554
554
|
},
|
|
555
555
|
"aria-hidden": !0,
|
|
556
556
|
children: "📄"
|
|
557
|
-
}), /* @__PURE__ */
|
|
557
|
+
}), /* @__PURE__ */ _("span", {
|
|
558
558
|
style: {
|
|
559
559
|
display: "flex",
|
|
560
560
|
flexDirection: "column",
|
|
@@ -600,7 +600,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
600
600
|
children: n
|
|
601
601
|
});
|
|
602
602
|
}, Re = ({ source: e, index: r }) => {
|
|
603
|
-
const t = /* @__PURE__ */
|
|
603
|
+
const t = /* @__PURE__ */ _("div", {
|
|
604
604
|
style: {
|
|
605
605
|
display: "flex",
|
|
606
606
|
alignItems: "center",
|
|
@@ -664,7 +664,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
664
664
|
style: o,
|
|
665
665
|
children: t
|
|
666
666
|
});
|
|
667
|
-
}, Ee = () => /* @__PURE__ */
|
|
667
|
+
}, Ee = () => /* @__PURE__ */ _("div", {
|
|
668
668
|
style: {
|
|
669
669
|
display: "flex",
|
|
670
670
|
gap: "4px",
|
|
@@ -687,9 +687,9 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
687
687
|
40% { opacity: 1; transform: scale(1); }
|
|
688
688
|
}
|
|
689
689
|
` })]
|
|
690
|
-
}),
|
|
690
|
+
}), _e = ({ message: e, className: r = "", showAgentName: t = !1, isLast: o = !1, onFollowUpClick: n }) => {
|
|
691
691
|
const s = e.role === "user", c = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
|
|
692
|
-
return /* @__PURE__ */
|
|
692
|
+
return /* @__PURE__ */ _("div", {
|
|
693
693
|
className: `ago-message ago-message--${e.role} ${r}`,
|
|
694
694
|
style: {
|
|
695
695
|
display: "flex",
|
|
@@ -754,7 +754,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
754
754
|
fontSize: "16px",
|
|
755
755
|
lineHeight: "1.6"
|
|
756
756
|
},
|
|
757
|
-
children: e.content ? /* @__PURE__ */ l(
|
|
757
|
+
children: e.content ? /* @__PURE__ */ l(Ie, { content: e.content }) : c && /* @__PURE__ */ l(Ee, {})
|
|
758
758
|
}),
|
|
759
759
|
o && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ l("div", {
|
|
760
760
|
className: "ago-message__followups",
|
|
@@ -792,39 +792,39 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
792
792
|
]
|
|
793
793
|
});
|
|
794
794
|
}, Je = ({ client: e, conversationId: r, title: t = "Chat", welcomeMessage: o = "Hello! How can I help you today?", placeholder: n = "Type a message...", allowFiles: s = !1, height: c = 500, logoUrl: a, showAgentName: f = !1, forms: d, onFollowUpClick: g, className: C = "", onMessageSent: N, onMessageReceived: S }) => {
|
|
795
|
-
const k =
|
|
795
|
+
const k = M(null), p = P(), x = e ?? p, { messages: i, isLoading: v, error: u, sendMessage: h } = K({
|
|
796
796
|
client: e,
|
|
797
797
|
conversationId: r
|
|
798
798
|
});
|
|
799
|
-
|
|
799
|
+
I(() => {
|
|
800
800
|
if (!x || !d || d.length === 0) return;
|
|
801
801
|
let m = !1;
|
|
802
|
-
const
|
|
802
|
+
const A = [];
|
|
803
803
|
return Promise.all(d.map((F) => F.schema != null ? Promise.resolve(B(F)) : j(x, F))).then((F) => {
|
|
804
804
|
if (!m)
|
|
805
|
-
for (const V of F)
|
|
805
|
+
for (const V of F) A.push(V.install(x));
|
|
806
806
|
}).catch(() => {
|
|
807
807
|
}), () => {
|
|
808
|
-
m = !0,
|
|
808
|
+
m = !0, A.forEach((F) => F());
|
|
809
809
|
};
|
|
810
810
|
}, [x, d ? JSON.stringify(d.map((m) => [
|
|
811
811
|
m.name,
|
|
812
812
|
m.schema ?? null,
|
|
813
813
|
m.submit ?? !1,
|
|
814
814
|
m.description ?? null
|
|
815
|
-
])) : ""]),
|
|
815
|
+
])) : ""]), I(() => {
|
|
816
816
|
k.current?.scrollIntoView({ behavior: "smooth" });
|
|
817
|
-
}, [i]),
|
|
817
|
+
}, [i]), I(() => {
|
|
818
818
|
const m = i[i.length - 1];
|
|
819
819
|
m && m.role === "assistant" && m.status === "DONE" && S && S({
|
|
820
820
|
id: m.id,
|
|
821
821
|
content: m.content
|
|
822
822
|
});
|
|
823
823
|
}, [i, S]);
|
|
824
|
-
const w = async (m,
|
|
825
|
-
N?.(m), await h(m,
|
|
824
|
+
const w = async (m, A) => {
|
|
825
|
+
N?.(m), await h(m, A);
|
|
826
826
|
}, b = i[i.length - 1], T = v && b?.role === "assistant" && (b.status === "IN_PROGRESS" || b.status === "WAITING_CLIENT"), y = g === !1 ? void 0 : g ?? ((m) => w(m));
|
|
827
|
-
return /* @__PURE__ */
|
|
827
|
+
return /* @__PURE__ */ _("div", {
|
|
828
828
|
className: `ago-chat-widget ${C}`,
|
|
829
829
|
style: {
|
|
830
830
|
display: "flex",
|
|
@@ -839,7 +839,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
839
839
|
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
|
|
840
840
|
},
|
|
841
841
|
children: [
|
|
842
|
-
/* @__PURE__ */
|
|
842
|
+
/* @__PURE__ */ _("div", {
|
|
843
843
|
className: "ago-chat-widget__header",
|
|
844
844
|
style: {
|
|
845
845
|
padding: "14px 16px",
|
|
@@ -866,7 +866,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
866
866
|
children: t
|
|
867
867
|
})]
|
|
868
868
|
}),
|
|
869
|
-
/* @__PURE__ */
|
|
869
|
+
/* @__PURE__ */ _("div", {
|
|
870
870
|
className: "ago-chat-widget__messages",
|
|
871
871
|
role: "log",
|
|
872
872
|
"aria-live": "polite",
|
|
@@ -888,10 +888,10 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
888
888
|
lineHeight: "1.5"
|
|
889
889
|
},
|
|
890
890
|
children: o
|
|
891
|
-
}) : i.map((m,
|
|
891
|
+
}) : i.map((m, A) => /* @__PURE__ */ l(_e, {
|
|
892
892
|
message: m,
|
|
893
893
|
showAgentName: f,
|
|
894
|
-
isLast:
|
|
894
|
+
isLast: A === i.length - 1,
|
|
895
895
|
onFollowUpClick: y
|
|
896
896
|
}, m.id)),
|
|
897
897
|
u && /* @__PURE__ */ l("div", {
|
|
@@ -919,13 +919,13 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
919
919
|
]
|
|
920
920
|
});
|
|
921
921
|
};
|
|
922
|
-
function
|
|
923
|
-
const r =
|
|
924
|
-
if (!t) throw new
|
|
925
|
-
const [o, n] = E(null), s =
|
|
922
|
+
function Me(e = {}) {
|
|
923
|
+
const r = P(), t = e.client ?? r;
|
|
924
|
+
if (!t) throw new L("useProactiveNudge: no AgoClient. Pass one via options.client or wrap your tree with <AgoProvider>.", "proactive_missing_client");
|
|
925
|
+
const [o, n] = E(null), s = M(o);
|
|
926
926
|
s.current = o;
|
|
927
|
-
const c =
|
|
928
|
-
return c.current = e.onExpand,
|
|
927
|
+
const c = M(e.onExpand);
|
|
928
|
+
return c.current = e.onExpand, I(() => {
|
|
929
929
|
const a = (d) => {
|
|
930
930
|
n(d), t.proactive?.shown(d);
|
|
931
931
|
}, f = ({ nudge: d }) => {
|
|
@@ -947,11 +947,11 @@ function _e(e = {}) {
|
|
|
947
947
|
};
|
|
948
948
|
}
|
|
949
949
|
var Ve = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right", openChatLabel: n = "Open chat", className: s = "" }) => {
|
|
950
|
-
const { nudge: c, accept: a, dismiss: f } =
|
|
950
|
+
const { nudge: c, accept: a, dismiss: f } = Me({
|
|
951
951
|
client: e,
|
|
952
952
|
onExpand: r
|
|
953
953
|
});
|
|
954
|
-
if (
|
|
954
|
+
if (I(() => {
|
|
955
955
|
if (!c || !t) return;
|
|
956
956
|
const g = setTimeout(() => f(), t);
|
|
957
957
|
return () => clearTimeout(g);
|
|
@@ -961,7 +961,7 @@ var Ve = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
|
|
|
961
961
|
f
|
|
962
962
|
]), !c) return null;
|
|
963
963
|
const d = c.source === "agent" || !!c.goal;
|
|
964
|
-
return /* @__PURE__ */
|
|
964
|
+
return /* @__PURE__ */ _("div", {
|
|
965
965
|
className: `ago-nudge ${s}`,
|
|
966
966
|
role: "status",
|
|
967
967
|
"aria-live": "polite",
|
|
@@ -1007,7 +1007,7 @@ var Ve = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
|
|
|
1007
1007
|
style: { paddingRight: "16px" },
|
|
1008
1008
|
children: c.message
|
|
1009
1009
|
}),
|
|
1010
|
-
(c.action || d) && /* @__PURE__ */
|
|
1010
|
+
(c.action || d) && /* @__PURE__ */ _("div", {
|
|
1011
1011
|
className: "ago-nudge__actions",
|
|
1012
1012
|
style: {
|
|
1013
1013
|
display: "flex",
|
|
@@ -1055,7 +1055,7 @@ var Ve = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
|
|
|
1055
1055
|
});
|
|
1056
1056
|
};
|
|
1057
1057
|
function Fe({ client: e, autoLoad: r = !0 } = {}) {
|
|
1058
|
-
const t =
|
|
1058
|
+
const t = P(), o = e || t;
|
|
1059
1059
|
if (!o) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
1060
1060
|
const [n, s] = E([]), [c, a] = E(null), [f, d] = E(!1), [g, C] = E(null), N = R(async () => {
|
|
1061
1061
|
d(!0), C(null);
|
|
@@ -1078,7 +1078,7 @@ function Fe({ client: e, autoLoad: r = !0 } = {}) {
|
|
|
1078
1078
|
}, [o]), k = R(() => {
|
|
1079
1079
|
a(null);
|
|
1080
1080
|
}, []);
|
|
1081
|
-
return
|
|
1081
|
+
return I(() => {
|
|
1082
1082
|
r && N();
|
|
1083
1083
|
}, [r, N]), {
|
|
1084
1084
|
conversations: n,
|
|
@@ -1091,7 +1091,7 @@ function Fe({ client: e, autoLoad: r = !0 } = {}) {
|
|
|
1091
1091
|
};
|
|
1092
1092
|
}
|
|
1093
1093
|
function Ye(e = {}) {
|
|
1094
|
-
const r =
|
|
1094
|
+
const r = P(), t = e.client || r;
|
|
1095
1095
|
if (!t) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
1096
1096
|
const o = K({
|
|
1097
1097
|
client: t,
|
|
@@ -1116,11 +1116,11 @@ function Ye(e = {}) {
|
|
|
1116
1116
|
};
|
|
1117
1117
|
}
|
|
1118
1118
|
function Xe(e, r) {
|
|
1119
|
-
const t =
|
|
1119
|
+
const t = z(), { name: o, description: n, parameters: s, handler: c, maxResultBytes: a, requiresApproval: f } = typeof e == "string" ? {
|
|
1120
1120
|
name: e,
|
|
1121
1121
|
...r
|
|
1122
|
-
} : e, d =
|
|
1123
|
-
d.current = c,
|
|
1122
|
+
} : e, d = M(c);
|
|
1123
|
+
d.current = c, I(() => {
|
|
1124
1124
|
const g = (C) => d.current(C);
|
|
1125
1125
|
return t.registerFunction(o, g, {
|
|
1126
1126
|
description: n,
|
|
@@ -1140,14 +1140,14 @@ function Xe(e, r) {
|
|
|
1140
1140
|
]);
|
|
1141
1141
|
}
|
|
1142
1142
|
function Ze(e, r) {
|
|
1143
|
-
const t =
|
|
1144
|
-
o.current = e,
|
|
1143
|
+
const t = z(), o = M(e);
|
|
1144
|
+
o.current = e, I(() => (t.registerNavigationFunction((n) => o.current(n), r), () => {
|
|
1145
1145
|
t.unregisterNavigationFunction();
|
|
1146
1146
|
}), [t, r]);
|
|
1147
1147
|
}
|
|
1148
1148
|
function Qe(e, r) {
|
|
1149
|
-
const t =
|
|
1150
|
-
s.current = e,
|
|
1149
|
+
const t = z(), o = r?.functionName ?? "setPageState", n = r?.requiresApproval, s = M(e);
|
|
1150
|
+
s.current = e, I(() => {
|
|
1151
1151
|
const c = s.current.map((a) => {
|
|
1152
1152
|
const f = () => s.current.find((d) => d.name === a.name) ?? a;
|
|
1153
1153
|
return {
|
|
@@ -1171,8 +1171,8 @@ function Qe(e, r) {
|
|
|
1171
1171
|
]);
|
|
1172
1172
|
}
|
|
1173
1173
|
function et(e) {
|
|
1174
|
-
const r =
|
|
1175
|
-
t.current = e,
|
|
1174
|
+
const r = z(), t = M(e);
|
|
1175
|
+
t.current = e, I(() => ne(r, () => t.current), [r]);
|
|
1176
1176
|
}
|
|
1177
1177
|
var Te = /* @__PURE__ */ new Set(["awaiting-approval"]);
|
|
1178
1178
|
function J(e) {
|
|
@@ -1192,19 +1192,19 @@ function J(e) {
|
|
|
1192
1192
|
function Pe(e) {
|
|
1193
1193
|
return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : J(e.type);
|
|
1194
1194
|
}
|
|
1195
|
-
function
|
|
1195
|
+
function H(e, r) {
|
|
1196
1196
|
const t = (e ?? "").toLowerCase();
|
|
1197
1197
|
return t.includes("reject") ? "rejected" : t.includes("error") || t.includes("fail") ? "error" : t.includes("done") || t.includes("complet") ? "done" : (t.includes("waiting") || t.includes("pending")) && (r === "confirmation" || r === "form") ? "awaiting-approval" : "running";
|
|
1198
1198
|
}
|
|
1199
|
-
function
|
|
1199
|
+
function q(e) {
|
|
1200
1200
|
return typeof e != "string" || !e ? "page" : e.replace(/[-_]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (r) => r.toUpperCase()).trim();
|
|
1201
1201
|
}
|
|
1202
1202
|
function We(e) {
|
|
1203
1203
|
switch (e.kind) {
|
|
1204
1204
|
case "navigation":
|
|
1205
|
-
return `Navigating to ${
|
|
1205
|
+
return `Navigating to ${q(e.arguments?.page)}`;
|
|
1206
1206
|
case "action":
|
|
1207
|
-
return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message ||
|
|
1207
|
+
return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message || q(e.functionName) || "Working";
|
|
1208
1208
|
case "progress":
|
|
1209
1209
|
return e.message || "Working";
|
|
1210
1210
|
case "reasoning":
|
|
@@ -1218,9 +1218,9 @@ function We(e) {
|
|
|
1218
1218
|
}
|
|
1219
1219
|
}
|
|
1220
1220
|
function tt(e = {}) {
|
|
1221
|
-
const { includeReasoning: r = !1, labelFor: t } = e, o =
|
|
1222
|
-
if (!n) throw new
|
|
1223
|
-
const [s, c] = E([]), a =
|
|
1221
|
+
const { includeReasoning: r = !1, labelFor: t } = e, o = P(), n = e.client || o;
|
|
1222
|
+
if (!n) throw new L("useAgoActivity requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
|
|
1223
|
+
const [s, c] = E([]), a = M(/* @__PURE__ */ new Set()), f = M(void 0), d = M(t);
|
|
1224
1224
|
d.current = t;
|
|
1225
1225
|
const g = R((p, x) => {
|
|
1226
1226
|
c((i) => {
|
|
@@ -1242,14 +1242,14 @@ function tt(e = {}) {
|
|
|
1242
1242
|
] : [...i, u];
|
|
1243
1243
|
});
|
|
1244
1244
|
}, []);
|
|
1245
|
-
|
|
1245
|
+
I(() => {
|
|
1246
1246
|
const p = (y) => {
|
|
1247
1247
|
f.current = y.messageId;
|
|
1248
1248
|
}, x = (y) => {
|
|
1249
1249
|
const m = J(y.type);
|
|
1250
1250
|
m === "reasoning" && !r || g(y.id, {
|
|
1251
1251
|
kind: m,
|
|
1252
|
-
status:
|
|
1252
|
+
status: H(y.status, m),
|
|
1253
1253
|
messageId: f.current,
|
|
1254
1254
|
toolName: y.toolName,
|
|
1255
1255
|
toolDisplayName: y.toolDisplayName,
|
|
@@ -1277,35 +1277,35 @@ function tt(e = {}) {
|
|
|
1277
1277
|
});
|
|
1278
1278
|
}, u = (y) => {
|
|
1279
1279
|
if (!y.invocationId) return;
|
|
1280
|
-
const m = y.result,
|
|
1280
|
+
const m = y.result, A = typeof y.result == "object" && m !== null && m.approved === !1 && m.reason === "user_rejected";
|
|
1281
1281
|
g(y.invocationId, {
|
|
1282
|
-
status: y.error ? "error" :
|
|
1282
|
+
status: y.error ? "error" : A ? "rejected" : "done",
|
|
1283
1283
|
requiresApproval: !1
|
|
1284
1284
|
});
|
|
1285
1285
|
}, h = (y) => {
|
|
1286
1286
|
for (const m of y.messages ?? [])
|
|
1287
1287
|
if (m.role === "assistant")
|
|
1288
|
-
for (const
|
|
1289
|
-
const F = Pe(
|
|
1290
|
-
F === "reasoning" && !r || /waiting/i.test(
|
|
1288
|
+
for (const A of m.toolCalls ?? []) {
|
|
1289
|
+
const F = Pe(A);
|
|
1290
|
+
F === "reasoning" && !r || /waiting/i.test(A.status ?? "") || g(A.id, {
|
|
1291
1291
|
kind: F,
|
|
1292
|
-
status:
|
|
1292
|
+
status: H(A.status, F),
|
|
1293
1293
|
messageId: m.id,
|
|
1294
|
-
toolName:
|
|
1295
|
-
toolDisplayName:
|
|
1296
|
-
functionName:
|
|
1297
|
-
arguments:
|
|
1298
|
-
message:
|
|
1299
|
-
data:
|
|
1300
|
-
formSchema:
|
|
1294
|
+
toolName: A.toolName,
|
|
1295
|
+
toolDisplayName: A.toolDisplayName,
|
|
1296
|
+
functionName: A.functionName,
|
|
1297
|
+
arguments: A.arguments,
|
|
1298
|
+
message: A.message,
|
|
1299
|
+
data: A.data,
|
|
1300
|
+
formSchema: A.formSchema,
|
|
1301
1301
|
requiresApproval: F === "confirmation" || F === "form"
|
|
1302
1302
|
});
|
|
1303
1303
|
}
|
|
1304
1304
|
}, w = (y) => {
|
|
1305
|
-
c((m) => m.map((
|
|
1306
|
-
...
|
|
1305
|
+
c((m) => m.map((A) => A.status === "running" || A.status === "awaiting-approval" ? {
|
|
1306
|
+
...A,
|
|
1307
1307
|
status: y
|
|
1308
|
-
} :
|
|
1308
|
+
} : A));
|
|
1309
1309
|
}, b = () => w("done"), T = () => w("error");
|
|
1310
1310
|
return n.on("message:start", p), n.on("toolCall:received", x), n.on("function:invoke", i), n.on("function:awaiting-approval", v), n.on("function:result", u), n.on("conversation:loaded", h), n.on("message:complete", b), n.on("message:error", T), () => {
|
|
1311
1311
|
n.off("message:start", p), n.off("toolCall:received", x), n.off("function:invoke", i), n.off("function:awaiting-approval", v), n.off("function:result", u), n.off("conversation:loaded", h), n.off("message:complete", b), n.off("message:error", T);
|
|
@@ -1353,11 +1353,30 @@ function tt(e = {}) {
|
|
|
1353
1353
|
clear: k
|
|
1354
1354
|
};
|
|
1355
1355
|
}
|
|
1356
|
-
function nt(e
|
|
1357
|
-
const
|
|
1356
|
+
function nt(e = {}) {
|
|
1357
|
+
const r = P(), t = e.client || r;
|
|
1358
|
+
if (!t) throw new L("useAgoActivityLog requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
|
|
1359
|
+
const [o, n] = E(() => t.getRecentActivity());
|
|
1360
|
+
I(() => {
|
|
1361
|
+
n(t.getRecentActivity());
|
|
1362
|
+
const a = () => n(t.getRecentActivity());
|
|
1363
|
+
return t.on("activity:recorded", a), () => t.off("activity:recorded", a);
|
|
1364
|
+
}, [t]);
|
|
1365
|
+
const s = R((a) => t.recordActivity(a), [t]), c = R(() => {
|
|
1366
|
+
t.clearActivity(), n([]);
|
|
1367
|
+
}, [t]);
|
|
1368
|
+
return {
|
|
1369
|
+
entries: o,
|
|
1370
|
+
latest: o.length > 0 ? o[o.length - 1] : void 0,
|
|
1371
|
+
record: s,
|
|
1372
|
+
clear: c
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
function rt(e, r) {
|
|
1376
|
+
const t = z(), o = ae(), n = r ?? o, s = M(e);
|
|
1358
1377
|
s.current = e;
|
|
1359
1378
|
const c = typeof e == "function";
|
|
1360
|
-
|
|
1379
|
+
I(() => {
|
|
1361
1380
|
if (typeof s.current == "function") {
|
|
1362
1381
|
const a = () => s.current();
|
|
1363
1382
|
return t.addDynamicContext(n, a), () => {
|
|
@@ -1381,8 +1400,8 @@ var O = {
|
|
|
1381
1400
|
missing: [],
|
|
1382
1401
|
complete: !1
|
|
1383
1402
|
};
|
|
1384
|
-
function
|
|
1385
|
-
const r =
|
|
1403
|
+
function ot(e) {
|
|
1404
|
+
const r = z(), t = e.schema != null, o = JSON.stringify(e.schema ?? null), n = e.submit, s = n ? typeof n == "string" ? `client:${n}` : n.via === "backend" ? "backend" : "handler" in n ? "client:handler" : `client:${n.url}` : "none", c = JSON.stringify(e.initialValues ?? null), a = D(() => t ? B(e) : null, [
|
|
1386
1405
|
t,
|
|
1387
1406
|
e.name,
|
|
1388
1407
|
o,
|
|
@@ -1394,7 +1413,7 @@ function rt(e) {
|
|
|
1394
1413
|
loading: !t,
|
|
1395
1414
|
error: null
|
|
1396
1415
|
});
|
|
1397
|
-
|
|
1416
|
+
I(() => {
|
|
1398
1417
|
if (t) return;
|
|
1399
1418
|
let v = !1;
|
|
1400
1419
|
return d({
|
|
@@ -1425,17 +1444,17 @@ function rt(e) {
|
|
|
1425
1444
|
e.autoSubmit
|
|
1426
1445
|
]);
|
|
1427
1446
|
const g = t ? a : f.collector, C = t ? !1 : f.loading, N = t ? null : f.error;
|
|
1428
|
-
|
|
1447
|
+
I(() => {
|
|
1429
1448
|
if (g)
|
|
1430
1449
|
return g.install(r);
|
|
1431
1450
|
}, [r, g]);
|
|
1432
|
-
const S =
|
|
1451
|
+
const S = D(() => X({
|
|
1433
1452
|
values: e.initialValues ?? {},
|
|
1434
1453
|
submitted: !1
|
|
1435
|
-
}), [c]), k = De(g?.store ?? S), p =
|
|
1454
|
+
}), [c]), k = De(g?.store ?? S), p = D(() => g?.getStatus() ?? O, [k, g]), x = D(() => ({
|
|
1436
1455
|
...k,
|
|
1437
1456
|
...p
|
|
1438
|
-
}), [k, p]), i =
|
|
1457
|
+
}), [k, p]), i = D(() => ({
|
|
1439
1458
|
name: e.name,
|
|
1440
1459
|
store: S,
|
|
1441
1460
|
functions: [],
|
|
@@ -1477,25 +1496,26 @@ export {
|
|
|
1477
1496
|
Ke as AgoProvider,
|
|
1478
1497
|
de as ChatInput,
|
|
1479
1498
|
Je as ChatWidget,
|
|
1480
|
-
|
|
1481
|
-
|
|
1499
|
+
Ie as Markdown,
|
|
1500
|
+
_e as Message,
|
|
1482
1501
|
B as createFormCollector,
|
|
1483
|
-
|
|
1502
|
+
Oe as createMockClient,
|
|
1484
1503
|
He as deriveFormStatus,
|
|
1485
1504
|
j as loadFormCollector,
|
|
1486
1505
|
ce as useAgo,
|
|
1487
1506
|
tt as useAgoActivity,
|
|
1507
|
+
nt as useAgoActivityLog,
|
|
1488
1508
|
et as useAgoAutoContinueAfterNavigation,
|
|
1489
|
-
|
|
1490
|
-
|
|
1509
|
+
z as useAgoClient,
|
|
1510
|
+
rt as useAgoContext,
|
|
1491
1511
|
Xe as useAgoFunction,
|
|
1492
1512
|
Ze as useAgoNavigation,
|
|
1493
1513
|
Qe as useAgoPageState,
|
|
1494
1514
|
De as useAgoStore,
|
|
1495
1515
|
Ye as useChat,
|
|
1496
1516
|
Fe as useConversation,
|
|
1497
|
-
|
|
1517
|
+
ot as useFormCollector,
|
|
1498
1518
|
K as useMessages,
|
|
1499
|
-
|
|
1500
|
-
|
|
1519
|
+
P as useOptionalAgoClient,
|
|
1520
|
+
Me as useProactiveNudge
|
|
1501
1521
|
};
|
package/dist/testing.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./createMockClient-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./createMockClient-Dw-cyISN.cjs");exports.createMockClient=e.createMockClient;
|