@useago/sdk 1.5.4 → 1.5.6
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 +22 -0
- package/dist/{AgoClient-BW0YZsis.js → AgoClient-B_R_qi2s.js} +27 -13
- package/dist/{AgoClient-Ba3ICq4K.cjs → AgoClient-DLB9icvv.cjs} +4 -4
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +29 -3
- package/dist/angular.d.ts +29 -3
- package/dist/angular.js +2 -2
- package/dist/{createConversationSession-BjsgjL-v.js → createConversationSession-CdtI4vrf.js} +1 -1
- package/dist/{createConversationSession-okoz3teC.cjs → createConversationSession-Dqh7NXK4.cjs} +1 -1
- package/dist/{createFormCollector-BWIh1pMl.cjs → createFormCollector-BjO3oB63.cjs} +1 -1
- package/dist/{createFormCollector-Bay2UpRv.js → createFormCollector-YwaZ78wU.js} +1 -1
- package/dist/devtools.d.cts +28 -2
- package/dist/devtools.d.ts +28 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +36 -2
- package/dist/index.d.ts +36 -2
- package/dist/index.js +3 -3
- package/dist/react.cjs +2 -2
- package/dist/react.d.cts +28 -2
- package/dist/react.d.ts +28 -2
- package/dist/react.js +107 -106
- package/dist/testing.d.cts +28 -2
- package/dist/testing.d.ts +28 -2
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +28 -2
- package/dist/vue.d.ts +28 -2
- package/dist/vue.js +2 -2
- package/dist/widget.cjs +2 -2
- package/dist/widget.d.cts +28 -2
- package/dist/widget.d.ts +28 -2
- package/dist/widget.js +4 -4
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
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-B_R_qi2s.js";
|
|
2
2
|
import { t as ne } from "./autoContinue-CC8K9mBU.js";
|
|
3
|
-
import { n as He, r as j, t as B } from "./createFormCollector-
|
|
3
|
+
import { n as He, r as j, t as B } from "./createFormCollector-YwaZ78wU.js";
|
|
4
4
|
import { t as Oe } from "./createMockClient-DcuNlufr.js";
|
|
5
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
6
|
import { Fragment as U, jsx as l, jsxs as _ } from "react/jsx-runtime";
|
|
@@ -41,14 +41,14 @@ var $ = oe(null), Ke = ({ children: e, client: r, tools: t, helpers: o, pageCont
|
|
|
41
41
|
const { client: c } = ce(r ? null : s), a = r || c;
|
|
42
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
49
|
}, [a, t]), I(() => {
|
|
50
50
|
if (!o) return;
|
|
51
|
-
const
|
|
51
|
+
const p = [];
|
|
52
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];
|
|
@@ -60,10 +60,10 @@ var $ = 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
68
|
}, [a, o]), I(() => {
|
|
69
69
|
n === "auto" && a.enableAutoPageContext();
|
|
@@ -83,7 +83,7 @@ function P() {
|
|
|
83
83
|
function K({ client: e, conversationId: r } = {}) {
|
|
84
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), [
|
|
86
|
+
const [n, s] = E([]), [c, a] = E(r), [p, d] = E(!1), [g, C] = E(null);
|
|
87
87
|
I(() => {
|
|
88
88
|
r && r !== c && (a(r), N(r));
|
|
89
89
|
}, [r]);
|
|
@@ -95,30 +95,30 @@ function K({ client: e, conversationId: r } = {}) {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
return I(() => {
|
|
98
|
-
const S = (
|
|
99
|
-
c || a(
|
|
100
|
-
const w = h.findIndex((b) => b.id ===
|
|
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,9 +220,9 @@ 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
227
|
return /* @__PURE__ */ _("form", {
|
|
228
228
|
onSubmit: N,
|
|
@@ -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",
|
|
@@ -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", {
|
|
@@ -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,12 +787,12 @@ 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 = M(null),
|
|
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
|
});
|
|
@@ -890,11 +890,11 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
890
890
|
children: o
|
|
891
891
|
}) : i.map((m, A) => /* @__PURE__ */ l(_e, {
|
|
892
892
|
message: m,
|
|
893
|
-
showAgentName:
|
|
893
|
+
showAgentName: p,
|
|
894
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
|
]
|
|
@@ -928,11 +928,11 @@ function Me(e = {}) {
|
|
|
928
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,18 +947,18 @@ function Me(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
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
964
|
return /* @__PURE__ */ _("div", {
|
|
@@ -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",
|
|
@@ -1057,19 +1057,20 @@ var Ve = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
|
|
|
1057
1057
|
function Fe({ client: e, autoLoad: r = !0 } = {}) {
|
|
1058
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 {
|
|
@@ -1083,7 +1084,7 @@ function Fe({ client: e, autoLoad: r = !0 } = {}) {
|
|
|
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,
|
|
@@ -1116,7 +1117,7 @@ function Ye(e = {}) {
|
|
|
1116
1117
|
};
|
|
1117
1118
|
}
|
|
1118
1119
|
function Xe(e, r) {
|
|
1119
|
-
const t = z(), { name: o, description: n, parameters: s, handler: c, maxResultBytes: a, requiresApproval:
|
|
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
1123
|
} : e, d = M(c);
|
|
@@ -1126,7 +1127,7 @@ function Xe(e, r) {
|
|
|
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,7 +1137,7 @@ 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) {
|
|
@@ -1149,13 +1150,13 @@ function Qe(e, r) {
|
|
|
1149
1150
|
const t = z(), o = r?.functionName ?? "setPageState", n = r?.requiresApproval, s = M(e);
|
|
1150
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, {
|
|
@@ -1220,13 +1221,13 @@ function We(e) {
|
|
|
1220
1221
|
function tt(e = {}) {
|
|
1221
1222
|
const { includeReasoning: r = !1, labelFor: t } = e, o = P(), n = e.client || o;
|
|
1222
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");
|
|
1223
|
-
const [s, c] = E([]), a = M(/* @__PURE__ */ new Set()),
|
|
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
|
I(() => {
|
|
1246
|
-
const
|
|
1247
|
-
|
|
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
1253
|
status: H(y.status, m),
|
|
1253
|
-
messageId:
|
|
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,12 +1271,12 @@ 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
1281
|
const m = y.result, A = typeof y.result == "object" && m !== null && m.approved === !1 && m.reason === "user_rejected";
|
|
1281
1282
|
g(y.invocationId, {
|
|
@@ -1307,46 +1308,46 @@ function tt(e = {}) {
|
|
|
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,
|
|
@@ -1408,7 +1409,7 @@ function ot(e) {
|
|
|
1408
1409
|
s,
|
|
1409
1410
|
c,
|
|
1410
1411
|
e.autoSubmit
|
|
1411
|
-
]), [
|
|
1412
|
+
]), [p, d] = E({
|
|
1412
1413
|
collector: null,
|
|
1413
1414
|
loading: !t,
|
|
1414
1415
|
error: null
|
|
@@ -1420,17 +1421,17 @@ function ot(e) {
|
|
|
1420
1421
|
collector: null,
|
|
1421
1422
|
loading: !0,
|
|
1422
1423
|
error: null
|
|
1423
|
-
}), j(r, e).then((
|
|
1424
|
+
}), j(r, e).then((f) => {
|
|
1424
1425
|
v || d({
|
|
1425
|
-
collector:
|
|
1426
|
+
collector: f,
|
|
1426
1427
|
loading: !1,
|
|
1427
1428
|
error: null
|
|
1428
1429
|
});
|
|
1429
|
-
}).catch((
|
|
1430
|
+
}).catch((f) => {
|
|
1430
1431
|
v || d({
|
|
1431
1432
|
collector: null,
|
|
1432
1433
|
loading: !1,
|
|
1433
|
-
error:
|
|
1434
|
+
error: f instanceof Error ? f : new Error(String(f))
|
|
1434
1435
|
});
|
|
1435
1436
|
}), () => {
|
|
1436
1437
|
v = !0;
|
|
@@ -1443,7 +1444,7 @@ function ot(e) {
|
|
|
1443
1444
|
c,
|
|
1444
1445
|
e.autoSubmit
|
|
1445
1446
|
]);
|
|
1446
|
-
const g = t ? a :
|
|
1447
|
+
const g = t ? a : p.collector, C = t ? !1 : p.loading, N = t ? null : p.error;
|
|
1447
1448
|
I(() => {
|
|
1448
1449
|
if (g)
|
|
1449
1450
|
return g.install(r);
|
|
@@ -1451,10 +1452,10 @@ function ot(e) {
|
|
|
1451
1452
|
const S = D(() => X({
|
|
1452
1453
|
values: e.initialValues ?? {},
|
|
1453
1454
|
submitted: !1
|
|
1454
|
-
}), [c]), k = De(g?.store ?? S),
|
|
1455
|
+
}), [c]), k = De(g?.store ?? S), u = D(() => g?.getStatus() ?? O, [k, g]), x = D(() => ({
|
|
1455
1456
|
...k,
|
|
1456
|
-
...
|
|
1457
|
-
}), [k,
|
|
1457
|
+
...u
|
|
1458
|
+
}), [k, u]), i = D(() => ({
|
|
1458
1459
|
name: e.name,
|
|
1459
1460
|
store: S,
|
|
1460
1461
|
functions: [],
|
package/dist/testing.d.cts
CHANGED
|
@@ -140,9 +140,14 @@ declare class AgoClient {
|
|
|
140
140
|
*/
|
|
141
141
|
rejectFunction(invocationId: string): Promise<void>;
|
|
142
142
|
/**
|
|
143
|
-
* Get
|
|
143
|
+
* Get a page of conversations, newest-first. `pageSize` is capped at 100 by
|
|
144
|
+
* the backend (default 50). Returns the `{ data, has_more, total }` envelope
|
|
145
|
+
* so callers can page; `total` counts across all pages.
|
|
144
146
|
*/
|
|
145
|
-
getConversations(
|
|
147
|
+
getConversations(options?: {
|
|
148
|
+
page?: number;
|
|
149
|
+
pageSize?: number;
|
|
150
|
+
}): Promise<PaginatedResult<Conversation>>;
|
|
146
151
|
/**
|
|
147
152
|
* Get a specific conversation with messages
|
|
148
153
|
*/
|
|
@@ -488,6 +493,15 @@ declare interface AgoClientEvents {
|
|
|
488
493
|
* notably `createFormCollector` — can replay them to restore their state.
|
|
489
494
|
*/
|
|
490
495
|
"conversation:loaded": Conversation;
|
|
496
|
+
/**
|
|
497
|
+
* The conversation's title was generated and streamed during a live turn
|
|
498
|
+
* (the backend emits it once, at the end of the first turn). Lets the UI
|
|
499
|
+
* update a header without a refetch.
|
|
500
|
+
*/
|
|
501
|
+
"conversation:title": {
|
|
502
|
+
conversationId: string;
|
|
503
|
+
title: string;
|
|
504
|
+
};
|
|
491
505
|
"toolCall:received": ToolCallData;
|
|
492
506
|
"toolCall:form": ToolCallData;
|
|
493
507
|
"function:invoke": ClientFunctionInvocation;
|
|
@@ -1046,6 +1060,16 @@ declare type NudgeAction = {
|
|
|
1046
1060
|
setPageState: Record<string, unknown>;
|
|
1047
1061
|
};
|
|
1048
1062
|
|
|
1063
|
+
/**
|
|
1064
|
+
* A page of list results, mirroring the API's `{ data, has_more, total }`
|
|
1065
|
+
* envelope. `total` is the count across all pages, not just this page.
|
|
1066
|
+
*/
|
|
1067
|
+
declare interface PaginatedResult<T> {
|
|
1068
|
+
data: T[];
|
|
1069
|
+
hasMore: boolean;
|
|
1070
|
+
total: number;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1049
1073
|
/**
|
|
1050
1074
|
* Controller returned by {@link createAgoProactive} (also available as
|
|
1051
1075
|
* `client.proactive`).
|
|
@@ -1298,6 +1322,8 @@ declare interface SSEChunkData {
|
|
|
1298
1322
|
thread?: {
|
|
1299
1323
|
id: string;
|
|
1300
1324
|
};
|
|
1325
|
+
/** Generated conversation title, streamed once at the end of the first turn. */
|
|
1326
|
+
title?: string;
|
|
1301
1327
|
agent?: {
|
|
1302
1328
|
id: string;
|
|
1303
1329
|
name: string;
|