@useago/sdk 1.5.3 → 1.5.5
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 +33 -0
- package/README.md +10 -0
- package/dist/AgoClient-BI5esqbd.js +1694 -0
- package/dist/AgoClient-CQh8YovA.cjs +8 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +70 -3
- package/dist/angular.d.ts +70 -3
- package/dist/angular.js +3 -3
- package/dist/{createConversationSession-BCb0D6bt.cjs → createConversationSession-0zVkMdYj.cjs} +1 -1
- package/dist/{createConversationSession-C7cnnWKW.js → createConversationSession-BlYTpxwz.js} +1 -1
- package/dist/{createFormCollector-iCDwAwYJ.js → createFormCollector-Bgs94NyR.js} +1 -1
- package/dist/{createFormCollector-t_fGyuTD.cjs → createFormCollector-DiCe_8ik.cjs} +1 -1
- package/dist/devtools.d.cts +69 -2
- package/dist/devtools.d.ts +69 -2
- 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 +90 -2
- package/dist/index.d.ts +90 -2
- package/dist/index.js +64 -62
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +83 -2
- package/dist/react.d.ts +83 -2
- package/dist/react.js +240 -219
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +69 -2
- package/dist/testing.d.ts +69 -2
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +69 -2
- package/dist/vue.d.ts +69 -2
- package/dist/vue.js +2 -2
- package/dist/widget.cjs +2 -2
- package/dist/widget.d.cts +69 -2
- package/dist/widget.d.ts +69 -2
- package/dist/widget.js +4 -4
- 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-BI5esqbd.js";
|
|
2
|
+
import { t as ne } from "./autoContinue-CC8K9mBU.js";
|
|
3
|
+
import { n as He, r as j, t as B } from "./createFormCollector-Bgs94NyR.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
|
-
for (const
|
|
44
|
+
for (const p of t) a.register(p);
|
|
45
45
|
return () => {
|
|
46
|
-
for (const
|
|
46
|
+
for (const p of t) a.unregisterFunction(p.name);
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
}, [a, t]),
|
|
49
|
+
}, [a, t]), I(() => {
|
|
50
50
|
if (!o) return;
|
|
51
|
-
const
|
|
52
|
-
return import("./functions-
|
|
51
|
+
const p = [];
|
|
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) {
|
|
@@ -60,31 +60,31 @@ var L = oe(null), Ke = ({ children: e, client: r, tools: t, helpers: o, pageCont
|
|
|
60
60
|
...N,
|
|
61
61
|
handler: C
|
|
62
62
|
};
|
|
63
|
-
a.register(S),
|
|
63
|
+
a.register(S), p.push(S.name);
|
|
64
64
|
}
|
|
65
65
|
}), () => {
|
|
66
|
-
for (const d of
|
|
66
|
+
for (const d of p) 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
|
-
const [n, s] = E([]), [c, a] = E(r), [
|
|
87
|
-
|
|
86
|
+
const [n, s] = E([]), [c, a] = E(r), [p, d] = E(!1), [g, C] = E(null);
|
|
87
|
+
I(() => {
|
|
88
88
|
r && r !== c && (a(r), N(r));
|
|
89
89
|
}, [r]);
|
|
90
90
|
const N = async (S) => {
|
|
@@ -94,31 +94,31 @@ 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
|
|
98
|
-
const S = (
|
|
99
|
-
c || a(
|
|
100
|
-
const w = h.findIndex((b) => b.id ===
|
|
97
|
+
return I(() => {
|
|
98
|
+
const S = (f) => f === "IN_PROGRESS" || f === "WAITING_CLIENT", k = (f) => {
|
|
99
|
+
c || a(f.conversationId), d(!0), s((h) => {
|
|
100
|
+
const w = h.findIndex((b) => b.id === f.messageId);
|
|
101
101
|
return w >= 0 ? h.map((b, T) => T === w ? {
|
|
102
102
|
...b,
|
|
103
103
|
status: "IN_PROGRESS"
|
|
104
104
|
} : b) : h.some((b) => b.role === "assistant" && S(b.status)) ? h : [...h, {
|
|
105
|
-
id:
|
|
106
|
-
conversationId:
|
|
105
|
+
id: f.messageId,
|
|
106
|
+
conversationId: f.conversationId,
|
|
107
107
|
content: "",
|
|
108
108
|
role: "assistant",
|
|
109
109
|
status: "IN_PROGRESS",
|
|
110
110
|
createdAt: /* @__PURE__ */ new Date()
|
|
111
111
|
}];
|
|
112
112
|
});
|
|
113
|
-
},
|
|
113
|
+
}, u = (f) => {
|
|
114
114
|
s((h) => {
|
|
115
|
-
const w = h.findIndex((b) => b.id ===
|
|
115
|
+
const w = h.findIndex((b) => b.id === f.messageId);
|
|
116
116
|
return w < 0 ? h : h.map((b, T) => T === w ? {
|
|
117
117
|
...b,
|
|
118
|
-
content: b.content +
|
|
118
|
+
content: b.content + f.content
|
|
119
119
|
} : b);
|
|
120
120
|
});
|
|
121
|
-
}, x = (
|
|
121
|
+
}, x = (f) => {
|
|
122
122
|
s((h) => {
|
|
123
123
|
let w = -1;
|
|
124
124
|
for (let b = h.length - 1; b >= 0; b--) if (h[b].role === "assistant" && S(h[b].status)) {
|
|
@@ -129,33 +129,33 @@ function K({ client: e, conversationId: r } = {}) {
|
|
|
129
129
|
...h.slice(0, w),
|
|
130
130
|
{
|
|
131
131
|
...h[w],
|
|
132
|
-
...
|
|
132
|
+
...f
|
|
133
133
|
},
|
|
134
134
|
...h.slice(w + 1)
|
|
135
135
|
];
|
|
136
136
|
});
|
|
137
|
-
}, i = (
|
|
137
|
+
}, i = (f) => {
|
|
138
138
|
s((h) => {
|
|
139
|
-
const w = h.findIndex((b) => b.id ===
|
|
139
|
+
const w = h.findIndex((b) => b.id === f.id);
|
|
140
140
|
return w >= 0 ? [
|
|
141
141
|
...h.slice(0, w),
|
|
142
|
-
|
|
142
|
+
f,
|
|
143
143
|
...h.slice(w + 1)
|
|
144
|
-
] : [...h,
|
|
144
|
+
] : [...h, f];
|
|
145
145
|
}), d(!1);
|
|
146
|
-
}, v = (
|
|
147
|
-
C(new Error(
|
|
146
|
+
}, v = (f) => {
|
|
147
|
+
C(new Error(f.error)), d(!1);
|
|
148
148
|
};
|
|
149
|
-
return o.on("message:start", k), o.on("message:chunk",
|
|
150
|
-
o.off("message:start", k), o.off("message:chunk",
|
|
149
|
+
return o.on("message:start", k), o.on("message:chunk", u), o.on("message:answer-complete", x), o.on("message:complete", i), o.on("message:error", v), () => {
|
|
150
|
+
o.off("message:start", k), o.off("message:chunk", u), o.off("message:answer-complete", x), o.off("message:complete", i), o.off("message:error", v);
|
|
151
151
|
};
|
|
152
152
|
}, [o, c]), {
|
|
153
153
|
messages: n,
|
|
154
|
-
isLoading:
|
|
154
|
+
isLoading: p,
|
|
155
155
|
error: g,
|
|
156
156
|
sendMessage: R(async (S, k) => {
|
|
157
157
|
d(!0), C(null);
|
|
158
|
-
const
|
|
158
|
+
const u = {
|
|
159
159
|
id: `temp-${Date.now()}`,
|
|
160
160
|
conversationId: c || "",
|
|
161
161
|
content: S,
|
|
@@ -173,7 +173,7 @@ function K({ client: e, conversationId: r } = {}) {
|
|
|
173
173
|
};
|
|
174
174
|
s((i) => [
|
|
175
175
|
...i,
|
|
176
|
-
|
|
176
|
+
u,
|
|
177
177
|
x
|
|
178
178
|
]);
|
|
179
179
|
try {
|
|
@@ -182,19 +182,19 @@ function K({ client: e, conversationId: r } = {}) {
|
|
|
182
182
|
files: k
|
|
183
183
|
});
|
|
184
184
|
return i.conversationId && !c && a(i.conversationId), s((v) => {
|
|
185
|
-
const
|
|
186
|
-
...
|
|
187
|
-
id:
|
|
185
|
+
const f = v.filter((w) => !w.id.startsWith("temp-")), h = {
|
|
186
|
+
...u,
|
|
187
|
+
id: u.id.replace("temp-", "user-"),
|
|
188
188
|
conversationId: i.conversationId
|
|
189
189
|
};
|
|
190
|
-
return
|
|
191
|
-
...
|
|
190
|
+
return f.some((w) => w.id === i.id) ? [...f, h].sort((w, b) => new Date(w.createdAt).getTime() - new Date(b.createdAt).getTime()) : [
|
|
191
|
+
...f,
|
|
192
192
|
h,
|
|
193
193
|
i
|
|
194
194
|
];
|
|
195
195
|
}), i;
|
|
196
196
|
} catch (i) {
|
|
197
|
-
return C(i instanceof Error ? i : /* @__PURE__ */ new Error("Failed to send message")), d(!1), s((v) => v.filter((
|
|
197
|
+
return C(i instanceof Error ? i : /* @__PURE__ */ new Error("Failed to send message")), d(!1), s((v) => v.filter((f) => !f.id.startsWith("temp-"))), null;
|
|
198
198
|
}
|
|
199
199
|
}, [o, c]),
|
|
200
200
|
clearMessages: R(() => {
|
|
@@ -204,13 +204,13 @@ 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,
|
|
207
|
+
const [s, c] = E(""), [a, p] = 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;
|
|
211
211
|
i.style.height = "auto", i.style.height = `${Math.min(i.scrollHeight + 2, v)}px`, i.style.overflowY = i.scrollHeight + 2 > v ? "auto" : "hidden";
|
|
212
212
|
}, []), N = R((i) => {
|
|
213
|
-
i.preventDefault(), (s.trim() || a.length > 0) && (e(s.trim(), a.length > 0 ? a : void 0), c(""),
|
|
213
|
+
i.preventDefault(), (s.trim() || a.length > 0) && (e(s.trim(), a.length > 0 ? a : void 0), c(""), p([]), requestAnimationFrame(C));
|
|
214
214
|
}, [
|
|
215
215
|
s,
|
|
216
216
|
a,
|
|
@@ -220,11 +220,11 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
220
220
|
i.key === "Enter" && !i.shiftKey && (i.preventDefault(), N(i));
|
|
221
221
|
}, [N]), k = R((i) => {
|
|
222
222
|
const v = Array.from(i.target.files || []);
|
|
223
|
-
|
|
224
|
-
}, []),
|
|
225
|
-
|
|
223
|
+
p((f) => [...f, ...v]);
|
|
224
|
+
}, []), u = R((i) => {
|
|
225
|
+
p((v) => v.filter((f, 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",
|
|
@@ -263,7 +263,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
263
263
|
children: i.name
|
|
264
264
|
}), /* @__PURE__ */ l("button", {
|
|
265
265
|
type: "button",
|
|
266
|
-
onClick: () =>
|
|
266
|
+
onClick: () => u(v),
|
|
267
267
|
"aria-label": `Remove ${i.name}`,
|
|
268
268
|
style: {
|
|
269
269
|
border: "none",
|
|
@@ -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",
|
|
@@ -722,9 +722,9 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
722
722
|
width: "100%",
|
|
723
723
|
maxWidth: "85%"
|
|
724
724
|
},
|
|
725
|
-
children: e.sources.map((a,
|
|
725
|
+
children: e.sources.map((a, p) => /* @__PURE__ */ l(Re, {
|
|
726
726
|
source: a,
|
|
727
|
-
index:
|
|
727
|
+
index: p
|
|
728
728
|
}, a.id))
|
|
729
729
|
}),
|
|
730
730
|
e.attachments && e.attachments.length > 0 && /* @__PURE__ */ l("div", {
|
|
@@ -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",
|
|
@@ -764,7 +764,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
764
764
|
gap: "8px",
|
|
765
765
|
marginTop: "10px"
|
|
766
766
|
},
|
|
767
|
-
children: e.followUpReplies.map((a,
|
|
767
|
+
children: e.followUpReplies.map((a, p) => /* @__PURE__ */ l("button", {
|
|
768
768
|
type: "button",
|
|
769
769
|
className: "ago-message__followup-btn",
|
|
770
770
|
disabled: !n,
|
|
@@ -787,44 +787,44 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
787
787
|
d.currentTarget.style.borderColor = "#dee3e8";
|
|
788
788
|
},
|
|
789
789
|
children: a
|
|
790
|
-
},
|
|
790
|
+
}, p))
|
|
791
791
|
})
|
|
792
792
|
]
|
|
793
793
|
});
|
|
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:
|
|
795
|
-
const k =
|
|
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: p = !1, forms: d, onFollowUpClick: g, className: C = "", onMessageSent: N, onMessageReceived: S }) => {
|
|
795
|
+
const k = M(null), u = P(), x = e ?? u, { messages: i, isLoading: v, error: f, 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,13 +888,13 @@ 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
|
-
showAgentName:
|
|
894
|
-
isLast:
|
|
893
|
+
showAgentName: p,
|
|
894
|
+
isLast: A === i.length - 1,
|
|
895
895
|
onFollowUpClick: y
|
|
896
896
|
}, m.id)),
|
|
897
|
-
|
|
897
|
+
f && /* @__PURE__ */ l("div", {
|
|
898
898
|
role: "alert",
|
|
899
899
|
style: {
|
|
900
900
|
padding: "10px 14px",
|
|
@@ -905,7 +905,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
905
905
|
fontSize: "13px",
|
|
906
906
|
border: "1px solid #fecaca"
|
|
907
907
|
},
|
|
908
|
-
children:
|
|
908
|
+
children: f.message
|
|
909
909
|
}),
|
|
910
910
|
/* @__PURE__ */ l("div", { ref: k })
|
|
911
911
|
]
|
|
@@ -919,20 +919,20 @@ 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
|
+
}, p = ({ nudge: d }) => {
|
|
932
932
|
n((g) => g?.id === d.id ? null : g);
|
|
933
933
|
};
|
|
934
|
-
return t.on("nudge:ready", a), t.on("nudge:accepted",
|
|
935
|
-
t.off("nudge:ready", a), t.off("nudge:accepted",
|
|
934
|
+
return t.on("nudge:ready", a), t.on("nudge:accepted", p), t.on("nudge:dismissed", p), () => {
|
|
935
|
+
t.off("nudge:ready", a), t.off("nudge:accepted", p), t.off("nudge:dismissed", p);
|
|
936
936
|
};
|
|
937
937
|
}, [t]), {
|
|
938
938
|
nudge: o,
|
|
@@ -947,21 +947,21 @@ 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:
|
|
950
|
+
const { nudge: c, accept: a, dismiss: p } = Me({
|
|
951
951
|
client: e,
|
|
952
952
|
onExpand: r
|
|
953
953
|
});
|
|
954
|
-
if (
|
|
954
|
+
if (I(() => {
|
|
955
955
|
if (!c || !t) return;
|
|
956
|
-
const g = setTimeout(() =>
|
|
956
|
+
const g = setTimeout(() => p(), t);
|
|
957
957
|
return () => clearTimeout(g);
|
|
958
958
|
}, [
|
|
959
959
|
c,
|
|
960
960
|
t,
|
|
961
|
-
|
|
961
|
+
p
|
|
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",
|
|
@@ -987,7 +987,7 @@ var Ve = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
|
|
|
987
987
|
type: "button",
|
|
988
988
|
className: "ago-nudge__close",
|
|
989
989
|
"aria-label": "Dismiss",
|
|
990
|
-
onClick:
|
|
990
|
+
onClick: p,
|
|
991
991
|
style: {
|
|
992
992
|
position: "absolute",
|
|
993
993
|
top: "6px",
|
|
@@ -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,21 +1055,22 @@ 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
|
-
const [n, s] = E([]), [c, a] = E(null), [
|
|
1060
|
+
const [n, s] = E([]), [c, a] = E(null), [p, d] = E(!1), [g, C] = E(null), N = R(async () => {
|
|
1061
1061
|
d(!0), C(null);
|
|
1062
1062
|
try {
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1063
|
+
const { data: u } = await o.getConversations();
|
|
1064
|
+
s(u);
|
|
1065
|
+
} catch (u) {
|
|
1066
|
+
C(u instanceof Error ? u : /* @__PURE__ */ new Error("Failed to load conversations"));
|
|
1066
1067
|
} finally {
|
|
1067
1068
|
d(!1);
|
|
1068
1069
|
}
|
|
1069
|
-
}, [o]), S = R(async (
|
|
1070
|
+
}, [o]), S = R(async (u) => {
|
|
1070
1071
|
d(!0), C(null);
|
|
1071
1072
|
try {
|
|
1072
|
-
a(await o.getConversation(
|
|
1073
|
+
a(await o.getConversation(u));
|
|
1073
1074
|
} catch (x) {
|
|
1074
1075
|
C(x instanceof Error ? x : /* @__PURE__ */ new Error("Failed to load conversation"));
|
|
1075
1076
|
} finally {
|
|
@@ -1078,12 +1079,12 @@ function Fe({ client: e, autoLoad: r = !0 } = {}) {
|
|
|
1078
1079
|
}, [o]), k = R(() => {
|
|
1079
1080
|
a(null);
|
|
1080
1081
|
}, []);
|
|
1081
|
-
return
|
|
1082
|
+
return I(() => {
|
|
1082
1083
|
r && N();
|
|
1083
1084
|
}, [r, N]), {
|
|
1084
1085
|
conversations: n,
|
|
1085
1086
|
currentConversation: c,
|
|
1086
|
-
isLoading:
|
|
1087
|
+
isLoading: p,
|
|
1087
1088
|
error: g,
|
|
1088
1089
|
selectConversation: S,
|
|
1089
1090
|
startNewConversation: k,
|
|
@@ -1091,7 +1092,7 @@ function Fe({ client: e, autoLoad: r = !0 } = {}) {
|
|
|
1091
1092
|
};
|
|
1092
1093
|
}
|
|
1093
1094
|
function Ye(e = {}) {
|
|
1094
|
-
const r =
|
|
1095
|
+
const r = P(), t = e.client || r;
|
|
1095
1096
|
if (!t) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
1096
1097
|
const o = K({
|
|
1097
1098
|
client: t,
|
|
@@ -1116,17 +1117,17 @@ function Ye(e = {}) {
|
|
|
1116
1117
|
};
|
|
1117
1118
|
}
|
|
1118
1119
|
function Xe(e, r) {
|
|
1119
|
-
const t =
|
|
1120
|
+
const t = z(), { name: o, description: n, parameters: s, handler: c, maxResultBytes: a, requiresApproval: p } = typeof e == "string" ? {
|
|
1120
1121
|
name: e,
|
|
1121
1122
|
...r
|
|
1122
|
-
} : e, d =
|
|
1123
|
-
d.current = c,
|
|
1123
|
+
} : e, d = M(c);
|
|
1124
|
+
d.current = c, I(() => {
|
|
1124
1125
|
const g = (C) => d.current(C);
|
|
1125
1126
|
return t.registerFunction(o, g, {
|
|
1126
1127
|
description: n,
|
|
1127
1128
|
parameters: s,
|
|
1128
1129
|
maxResultBytes: a,
|
|
1129
|
-
requiresApproval:
|
|
1130
|
+
requiresApproval: p
|
|
1130
1131
|
}), () => {
|
|
1131
1132
|
t.unregisterFunction(o);
|
|
1132
1133
|
};
|
|
@@ -1136,26 +1137,26 @@ function Xe(e, r) {
|
|
|
1136
1137
|
n,
|
|
1137
1138
|
s,
|
|
1138
1139
|
a,
|
|
1139
|
-
|
|
1140
|
+
p
|
|
1140
1141
|
]);
|
|
1141
1142
|
}
|
|
1142
1143
|
function Ze(e, r) {
|
|
1143
|
-
const t =
|
|
1144
|
-
o.current = e,
|
|
1144
|
+
const t = z(), o = M(e);
|
|
1145
|
+
o.current = e, I(() => (t.registerNavigationFunction((n) => o.current(n), r), () => {
|
|
1145
1146
|
t.unregisterNavigationFunction();
|
|
1146
1147
|
}), [t, r]);
|
|
1147
1148
|
}
|
|
1148
1149
|
function Qe(e, r) {
|
|
1149
|
-
const t =
|
|
1150
|
-
s.current = e,
|
|
1150
|
+
const t = z(), o = r?.functionName ?? "setPageState", n = r?.requiresApproval, s = M(e);
|
|
1151
|
+
s.current = e, I(() => {
|
|
1151
1152
|
const c = s.current.map((a) => {
|
|
1152
|
-
const
|
|
1153
|
+
const p = () => s.current.find((d) => d.name === a.name) ?? a;
|
|
1153
1154
|
return {
|
|
1154
1155
|
name: a.name,
|
|
1155
1156
|
description: a.description,
|
|
1156
1157
|
schema: a.schema,
|
|
1157
|
-
get: a.get ? () =>
|
|
1158
|
-
set: (d) =>
|
|
1158
|
+
get: a.get ? () => p().get?.() : void 0,
|
|
1159
|
+
set: (d) => p().set(d)
|
|
1159
1160
|
};
|
|
1160
1161
|
});
|
|
1161
1162
|
return t.registerPageStateFunction(c, {
|
|
@@ -1171,8 +1172,8 @@ function Qe(e, r) {
|
|
|
1171
1172
|
]);
|
|
1172
1173
|
}
|
|
1173
1174
|
function et(e) {
|
|
1174
|
-
const r =
|
|
1175
|
-
t.current = e,
|
|
1175
|
+
const r = z(), t = M(e);
|
|
1176
|
+
t.current = e, I(() => ne(r, () => t.current), [r]);
|
|
1176
1177
|
}
|
|
1177
1178
|
var Te = /* @__PURE__ */ new Set(["awaiting-approval"]);
|
|
1178
1179
|
function J(e) {
|
|
@@ -1192,19 +1193,19 @@ function J(e) {
|
|
|
1192
1193
|
function Pe(e) {
|
|
1193
1194
|
return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : J(e.type);
|
|
1194
1195
|
}
|
|
1195
|
-
function
|
|
1196
|
+
function H(e, r) {
|
|
1196
1197
|
const t = (e ?? "").toLowerCase();
|
|
1197
1198
|
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
1199
|
}
|
|
1199
|
-
function
|
|
1200
|
+
function q(e) {
|
|
1200
1201
|
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
1202
|
}
|
|
1202
1203
|
function We(e) {
|
|
1203
1204
|
switch (e.kind) {
|
|
1204
1205
|
case "navigation":
|
|
1205
|
-
return `Navigating to ${
|
|
1206
|
+
return `Navigating to ${q(e.arguments?.page)}`;
|
|
1206
1207
|
case "action":
|
|
1207
|
-
return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message ||
|
|
1208
|
+
return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message || q(e.functionName) || "Working";
|
|
1208
1209
|
case "progress":
|
|
1209
1210
|
return e.message || "Working";
|
|
1210
1211
|
case "reasoning":
|
|
@@ -1218,15 +1219,15 @@ function We(e) {
|
|
|
1218
1219
|
}
|
|
1219
1220
|
}
|
|
1220
1221
|
function tt(e = {}) {
|
|
1221
|
-
const { includeReasoning: r = !1, labelFor: t } = e, o =
|
|
1222
|
-
if (!n) throw new
|
|
1223
|
-
const [s, c] = E([]), a =
|
|
1222
|
+
const { includeReasoning: r = !1, labelFor: t } = e, o = P(), n = e.client || o;
|
|
1223
|
+
if (!n) throw new L("useAgoActivity requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
|
|
1224
|
+
const [s, c] = E([]), a = M(/* @__PURE__ */ new Set()), p = M(void 0), d = M(t);
|
|
1224
1225
|
d.current = t;
|
|
1225
|
-
const g = R((
|
|
1226
|
+
const g = R((u, x) => {
|
|
1226
1227
|
c((i) => {
|
|
1227
|
-
const v = i.findIndex((h) => h.id ===
|
|
1228
|
+
const v = i.findIndex((h) => h.id === u), f = {
|
|
1228
1229
|
...v >= 0 ? i[v] : {
|
|
1229
|
-
id:
|
|
1230
|
+
id: u,
|
|
1230
1231
|
kind: "status",
|
|
1231
1232
|
label: "",
|
|
1232
1233
|
status: "running",
|
|
@@ -1235,22 +1236,22 @@ function tt(e = {}) {
|
|
|
1235
1236
|
},
|
|
1236
1237
|
...x
|
|
1237
1238
|
};
|
|
1238
|
-
return
|
|
1239
|
+
return f.label = d.current?.(f) ?? We(f), v >= 0 ? [
|
|
1239
1240
|
...i.slice(0, v),
|
|
1240
|
-
|
|
1241
|
+
f,
|
|
1241
1242
|
...i.slice(v + 1)
|
|
1242
|
-
] : [...i,
|
|
1243
|
+
] : [...i, f];
|
|
1243
1244
|
});
|
|
1244
1245
|
}, []);
|
|
1245
|
-
|
|
1246
|
-
const
|
|
1247
|
-
|
|
1246
|
+
I(() => {
|
|
1247
|
+
const u = (y) => {
|
|
1248
|
+
p.current = y.messageId;
|
|
1248
1249
|
}, x = (y) => {
|
|
1249
1250
|
const m = J(y.type);
|
|
1250
1251
|
m === "reasoning" && !r || g(y.id, {
|
|
1251
1252
|
kind: m,
|
|
1252
|
-
status:
|
|
1253
|
-
messageId:
|
|
1253
|
+
status: H(y.status, m),
|
|
1254
|
+
messageId: p.current,
|
|
1254
1255
|
toolName: y.toolName,
|
|
1255
1256
|
toolDisplayName: y.toolDisplayName,
|
|
1256
1257
|
message: y.message,
|
|
@@ -1262,7 +1263,7 @@ function tt(e = {}) {
|
|
|
1262
1263
|
y.invocationId && g(y.invocationId, {
|
|
1263
1264
|
kind: y.functionName === "navigateToPage" ? "navigation" : "action",
|
|
1264
1265
|
status: "running",
|
|
1265
|
-
messageId:
|
|
1266
|
+
messageId: p.current,
|
|
1266
1267
|
functionName: y.functionName,
|
|
1267
1268
|
arguments: y.arguments
|
|
1268
1269
|
});
|
|
@@ -1270,94 +1271,113 @@ function tt(e = {}) {
|
|
|
1270
1271
|
y.invocationId && g(y.invocationId, {
|
|
1271
1272
|
kind: y.functionName === "navigateToPage" ? "navigation" : "action",
|
|
1272
1273
|
status: "awaiting-approval",
|
|
1273
|
-
messageId:
|
|
1274
|
+
messageId: p.current,
|
|
1274
1275
|
functionName: y.functionName,
|
|
1275
1276
|
arguments: y.arguments,
|
|
1276
1277
|
requiresApproval: !0
|
|
1277
1278
|
});
|
|
1278
|
-
},
|
|
1279
|
+
}, f = (y) => {
|
|
1279
1280
|
if (!y.invocationId) return;
|
|
1280
|
-
const m = y.result,
|
|
1281
|
+
const m = y.result, A = typeof y.result == "object" && m !== null && m.approved === !1 && m.reason === "user_rejected";
|
|
1281
1282
|
g(y.invocationId, {
|
|
1282
|
-
status: y.error ? "error" :
|
|
1283
|
+
status: y.error ? "error" : A ? "rejected" : "done",
|
|
1283
1284
|
requiresApproval: !1
|
|
1284
1285
|
});
|
|
1285
1286
|
}, h = (y) => {
|
|
1286
1287
|
for (const m of y.messages ?? [])
|
|
1287
1288
|
if (m.role === "assistant")
|
|
1288
|
-
for (const
|
|
1289
|
-
const F = Pe(
|
|
1290
|
-
F === "reasoning" && !r || /waiting/i.test(
|
|
1289
|
+
for (const A of m.toolCalls ?? []) {
|
|
1290
|
+
const F = Pe(A);
|
|
1291
|
+
F === "reasoning" && !r || /waiting/i.test(A.status ?? "") || g(A.id, {
|
|
1291
1292
|
kind: F,
|
|
1292
|
-
status:
|
|
1293
|
+
status: H(A.status, F),
|
|
1293
1294
|
messageId: m.id,
|
|
1294
|
-
toolName:
|
|
1295
|
-
toolDisplayName:
|
|
1296
|
-
functionName:
|
|
1297
|
-
arguments:
|
|
1298
|
-
message:
|
|
1299
|
-
data:
|
|
1300
|
-
formSchema:
|
|
1295
|
+
toolName: A.toolName,
|
|
1296
|
+
toolDisplayName: A.toolDisplayName,
|
|
1297
|
+
functionName: A.functionName,
|
|
1298
|
+
arguments: A.arguments,
|
|
1299
|
+
message: A.message,
|
|
1300
|
+
data: A.data,
|
|
1301
|
+
formSchema: A.formSchema,
|
|
1301
1302
|
requiresApproval: F === "confirmation" || F === "form"
|
|
1302
1303
|
});
|
|
1303
1304
|
}
|
|
1304
1305
|
}, w = (y) => {
|
|
1305
|
-
c((m) => m.map((
|
|
1306
|
-
...
|
|
1306
|
+
c((m) => m.map((A) => A.status === "running" || A.status === "awaiting-approval" ? {
|
|
1307
|
+
...A,
|
|
1307
1308
|
status: y
|
|
1308
|
-
} :
|
|
1309
|
+
} : A));
|
|
1309
1310
|
}, b = () => w("done"), T = () => w("error");
|
|
1310
|
-
return n.on("message:start",
|
|
1311
|
-
n.off("message:start",
|
|
1311
|
+
return n.on("message:start", u), n.on("toolCall:received", x), n.on("function:invoke", i), n.on("function:awaiting-approval", v), n.on("function:result", f), n.on("conversation:loaded", h), n.on("message:complete", b), n.on("message:error", T), () => {
|
|
1312
|
+
n.off("message:start", u), n.off("toolCall:received", x), n.off("function:invoke", i), n.off("function:awaiting-approval", v), n.off("function:result", f), n.off("conversation:loaded", h), n.off("message:complete", b), n.off("message:error", T);
|
|
1312
1313
|
};
|
|
1313
1314
|
}, [
|
|
1314
1315
|
n,
|
|
1315
1316
|
r,
|
|
1316
1317
|
g
|
|
1317
1318
|
]);
|
|
1318
|
-
const C = R(async (
|
|
1319
|
-
const x = s.find((i) => i.id ===
|
|
1320
|
-
!x || x.status !== "awaiting-approval" || a.current.has(
|
|
1319
|
+
const C = R(async (u) => {
|
|
1320
|
+
const x = s.find((i) => i.id === u);
|
|
1321
|
+
!x || x.status !== "awaiting-approval" || a.current.has(u) || x.kind !== "form" && (a.current.add(u), g(u, {
|
|
1321
1322
|
status: "running",
|
|
1322
1323
|
requiresApproval: !1
|
|
1323
|
-
}), x.functionName ? await n.approveFunction(
|
|
1324
|
+
}), x.functionName ? await n.approveFunction(u) : await n.confirmToolCall(u));
|
|
1324
1325
|
}, [
|
|
1325
1326
|
n,
|
|
1326
1327
|
s,
|
|
1327
1328
|
g
|
|
1328
|
-
]), N = R(async (
|
|
1329
|
-
const x = s.find((i) => i.id ===
|
|
1330
|
-
!x || x.status !== "awaiting-approval" || a.current.has(
|
|
1329
|
+
]), N = R(async (u) => {
|
|
1330
|
+
const x = s.find((i) => i.id === u);
|
|
1331
|
+
!x || x.status !== "awaiting-approval" || a.current.has(u) || (a.current.add(u), g(u, {
|
|
1331
1332
|
status: "rejected",
|
|
1332
1333
|
requiresApproval: !1
|
|
1333
|
-
}), x.functionName ? await n.rejectFunction(
|
|
1334
|
+
}), x.functionName ? await n.rejectFunction(u) : await n.rejectToolCall(u));
|
|
1334
1335
|
}, [
|
|
1335
1336
|
n,
|
|
1336
1337
|
s,
|
|
1337
1338
|
g
|
|
1338
|
-
]), S = R(async (
|
|
1339
|
-
g(
|
|
1339
|
+
]), S = R(async (u, x) => {
|
|
1340
|
+
g(u, {
|
|
1340
1341
|
status: "running",
|
|
1341
1342
|
requiresApproval: !1
|
|
1342
|
-
}), await n.submitToolCallForm(
|
|
1343
|
+
}), await n.submitToolCallForm(u, x), g(u, { status: "done" });
|
|
1343
1344
|
}, [n, g]), k = R(() => {
|
|
1344
1345
|
a.current.clear(), c([]);
|
|
1345
1346
|
}, []);
|
|
1346
1347
|
return {
|
|
1347
1348
|
items: s,
|
|
1348
1349
|
latest: s.length > 0 ? s[s.length - 1] : void 0,
|
|
1349
|
-
isAwaitingApproval: s.some((
|
|
1350
|
+
isAwaitingApproval: s.some((u) => Te.has(u.status)),
|
|
1350
1351
|
approve: C,
|
|
1351
1352
|
reject: N,
|
|
1352
1353
|
submitForm: S,
|
|
1353
1354
|
clear: k
|
|
1354
1355
|
};
|
|
1355
1356
|
}
|
|
1356
|
-
function nt(e
|
|
1357
|
-
const
|
|
1357
|
+
function nt(e = {}) {
|
|
1358
|
+
const r = P(), t = e.client || r;
|
|
1359
|
+
if (!t) throw new L("useAgoActivityLog requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
|
|
1360
|
+
const [o, n] = E(() => t.getRecentActivity());
|
|
1361
|
+
I(() => {
|
|
1362
|
+
n(t.getRecentActivity());
|
|
1363
|
+
const a = () => n(t.getRecentActivity());
|
|
1364
|
+
return t.on("activity:recorded", a), () => t.off("activity:recorded", a);
|
|
1365
|
+
}, [t]);
|
|
1366
|
+
const s = R((a) => t.recordActivity(a), [t]), c = R(() => {
|
|
1367
|
+
t.clearActivity(), n([]);
|
|
1368
|
+
}, [t]);
|
|
1369
|
+
return {
|
|
1370
|
+
entries: o,
|
|
1371
|
+
latest: o.length > 0 ? o[o.length - 1] : void 0,
|
|
1372
|
+
record: s,
|
|
1373
|
+
clear: c
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
function rt(e, r) {
|
|
1377
|
+
const t = z(), o = ae(), n = r ?? o, s = M(e);
|
|
1358
1378
|
s.current = e;
|
|
1359
1379
|
const c = typeof e == "function";
|
|
1360
|
-
|
|
1380
|
+
I(() => {
|
|
1361
1381
|
if (typeof s.current == "function") {
|
|
1362
1382
|
const a = () => s.current();
|
|
1363
1383
|
return t.addDynamicContext(n, a), () => {
|
|
@@ -1381,37 +1401,37 @@ var O = {
|
|
|
1381
1401
|
missing: [],
|
|
1382
1402
|
complete: !1
|
|
1383
1403
|
};
|
|
1384
|
-
function
|
|
1385
|
-
const r =
|
|
1404
|
+
function ot(e) {
|
|
1405
|
+
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
1406
|
t,
|
|
1387
1407
|
e.name,
|
|
1388
1408
|
o,
|
|
1389
1409
|
s,
|
|
1390
1410
|
c,
|
|
1391
1411
|
e.autoSubmit
|
|
1392
|
-
]), [
|
|
1412
|
+
]), [p, d] = E({
|
|
1393
1413
|
collector: null,
|
|
1394
1414
|
loading: !t,
|
|
1395
1415
|
error: null
|
|
1396
1416
|
});
|
|
1397
|
-
|
|
1417
|
+
I(() => {
|
|
1398
1418
|
if (t) return;
|
|
1399
1419
|
let v = !1;
|
|
1400
1420
|
return d({
|
|
1401
1421
|
collector: null,
|
|
1402
1422
|
loading: !0,
|
|
1403
1423
|
error: null
|
|
1404
|
-
}), j(r, e).then((
|
|
1424
|
+
}), j(r, e).then((f) => {
|
|
1405
1425
|
v || d({
|
|
1406
|
-
collector:
|
|
1426
|
+
collector: f,
|
|
1407
1427
|
loading: !1,
|
|
1408
1428
|
error: null
|
|
1409
1429
|
});
|
|
1410
|
-
}).catch((
|
|
1430
|
+
}).catch((f) => {
|
|
1411
1431
|
v || d({
|
|
1412
1432
|
collector: null,
|
|
1413
1433
|
loading: !1,
|
|
1414
|
-
error:
|
|
1434
|
+
error: f instanceof Error ? f : new Error(String(f))
|
|
1415
1435
|
});
|
|
1416
1436
|
}), () => {
|
|
1417
1437
|
v = !0;
|
|
@@ -1424,18 +1444,18 @@ function rt(e) {
|
|
|
1424
1444
|
c,
|
|
1425
1445
|
e.autoSubmit
|
|
1426
1446
|
]);
|
|
1427
|
-
const g = t ? a :
|
|
1428
|
-
|
|
1447
|
+
const g = t ? a : p.collector, C = t ? !1 : p.loading, N = t ? null : p.error;
|
|
1448
|
+
I(() => {
|
|
1429
1449
|
if (g)
|
|
1430
1450
|
return g.install(r);
|
|
1431
1451
|
}, [r, g]);
|
|
1432
|
-
const S =
|
|
1452
|
+
const S = D(() => X({
|
|
1433
1453
|
values: e.initialValues ?? {},
|
|
1434
1454
|
submitted: !1
|
|
1435
|
-
}), [c]), k = De(g?.store ?? S),
|
|
1455
|
+
}), [c]), k = De(g?.store ?? S), u = D(() => g?.getStatus() ?? O, [k, g]), x = D(() => ({
|
|
1436
1456
|
...k,
|
|
1437
|
-
...
|
|
1438
|
-
}), [k,
|
|
1457
|
+
...u
|
|
1458
|
+
}), [k, u]), i = D(() => ({
|
|
1439
1459
|
name: e.name,
|
|
1440
1460
|
store: S,
|
|
1441
1461
|
functions: [],
|
|
@@ -1477,25 +1497,26 @@ export {
|
|
|
1477
1497
|
Ke as AgoProvider,
|
|
1478
1498
|
de as ChatInput,
|
|
1479
1499
|
Je as ChatWidget,
|
|
1480
|
-
|
|
1481
|
-
|
|
1500
|
+
Ie as Markdown,
|
|
1501
|
+
_e as Message,
|
|
1482
1502
|
B as createFormCollector,
|
|
1483
|
-
|
|
1503
|
+
Oe as createMockClient,
|
|
1484
1504
|
He as deriveFormStatus,
|
|
1485
1505
|
j as loadFormCollector,
|
|
1486
1506
|
ce as useAgo,
|
|
1487
1507
|
tt as useAgoActivity,
|
|
1508
|
+
nt as useAgoActivityLog,
|
|
1488
1509
|
et as useAgoAutoContinueAfterNavigation,
|
|
1489
|
-
|
|
1490
|
-
|
|
1510
|
+
z as useAgoClient,
|
|
1511
|
+
rt as useAgoContext,
|
|
1491
1512
|
Xe as useAgoFunction,
|
|
1492
1513
|
Ze as useAgoNavigation,
|
|
1493
1514
|
Qe as useAgoPageState,
|
|
1494
1515
|
De as useAgoStore,
|
|
1495
1516
|
Ye as useChat,
|
|
1496
1517
|
Fe as useConversation,
|
|
1497
|
-
|
|
1518
|
+
ot as useFormCollector,
|
|
1498
1519
|
K as useMessages,
|
|
1499
|
-
|
|
1500
|
-
|
|
1520
|
+
P as useOptionalAgoClient,
|
|
1521
|
+
Me as useProactiveNudge
|
|
1501
1522
|
};
|