@useago/sdk 1.5.2 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgoClient-BGkFSNZF.cjs +8 -0
- package/dist/AgoClient-CW-BLT1_.js +1542 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +311 -0
- package/dist/angular.d.ts +311 -0
- package/dist/angular.js +2 -2
- package/dist/createConversationSession-BCb0D6bt.cjs +1 -0
- package/dist/{createConversationSession-DPrrr70o.js → createConversationSession-C7cnnWKW.js} +3 -3
- package/dist/createFormCollector-iCDwAwYJ.js +279 -0
- package/dist/createFormCollector-t_fGyuTD.cjs +1 -0
- package/dist/createMockClient-Br0TWgLO.js +97 -0
- package/dist/createMockClient-BwNLPjeT.cjs +1 -0
- package/dist/devtools.d.cts +311 -0
- package/dist/devtools.d.ts +311 -0
- package/dist/functions-IGSjjvF4.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 +510 -0
- package/dist/index.d.ts +510 -0
- package/dist/index.js +95 -90
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +375 -0
- package/dist/react.d.ts +375 -0
- package/dist/react.js +559 -422
- package/dist/rolldown-runtime-16Nf8qvH.cjs +1 -0
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +311 -0
- package/dist/testing.d.ts +311 -0
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +332 -0
- package/dist/vue.d.ts +332 -0
- package/dist/vue.js +133 -110
- package/dist/widget.cjs +1 -1
- package/dist/widget.d.cts +308 -0
- package/dist/widget.d.ts +308 -0
- package/dist/widget.js +7 -7
- package/package.json +1 -1
- package/dist/AgoClient-5VGybmvz.cjs +0 -8
- package/dist/AgoClient-DXrH2AMi.js +0 -964
- package/dist/createConversationSession-0WTqcCLK.cjs +0 -1
- package/dist/createFormCollector-1GKKwQV_.cjs +0 -1
- package/dist/createFormCollector-DYh90kiG.js +0 -305
- package/dist/createMockClient-C-wrjb2C.cjs +0 -1
- package/dist/createMockClient-we-XoPom.js +0 -79
- package/dist/functions-CPs7omgM.cjs +0 -1
- /package/dist/{autoContinue-CP9pJR-V.cjs → autoContinue-CcCTva-D.cjs} +0 -0
- /package/dist/{autoContinue-CC8K9mBU.js → autoContinue-D3Mmaaca.js} +0 -0
- /package/dist/{functions-tzyOZNp6.js → functions-CApuQZ2b.js} +0 -0
package/dist/react.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import { t as qe } from "./createMockClient-
|
|
5
|
-
import re, { createContext as oe, useCallback as R, useContext as
|
|
6
|
-
import { Fragment as
|
|
1
|
+
import { a as Y, b as q, h as X, i as Z, o as Q, s as ee, t as te } from "./AgoClient-CW-BLT1_.js";
|
|
2
|
+
import { t as ne } from "./autoContinue-D3Mmaaca.js";
|
|
3
|
+
import { n as He, r as j, t as B } from "./createFormCollector-iCDwAwYJ.js";
|
|
4
|
+
import { t as qe } from "./createMockClient-Br0TWgLO.js";
|
|
5
|
+
import re, { createContext as oe, useCallback as R, useContext as G, useEffect as A, useId as ae, useMemo as W, useRef as _, useState as E, useSyncExternalStore as se } from "react";
|
|
6
|
+
import { Fragment as U, jsx as l, jsxs as M } 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 [
|
|
10
|
+
const [r, t] = E(!1), o = _(null), n = W(() => {
|
|
11
11
|
if (o.current && (o.current.destroy(), o.current = null), !e) return null;
|
|
12
|
-
const s = new
|
|
12
|
+
const s = new te(e);
|
|
13
13
|
return o.current = s, s;
|
|
14
14
|
}, [e?.baseUrl, e?.widgetId]);
|
|
15
|
-
return
|
|
15
|
+
return A(() => (n && o.current === null && (o.current = n, n.reviveAfterDestroy()), t(!0), () => {
|
|
16
16
|
o.current?.destroy(), o.current = null;
|
|
17
|
-
}), [n]),
|
|
17
|
+
}), [n]), A(() => {
|
|
18
18
|
o.current && e && o.current.updateConfig({
|
|
19
19
|
agent: e.agent,
|
|
20
20
|
defaultAgentId: e.defaultAgentId,
|
|
@@ -34,91 +34,91 @@ function ce(e) {
|
|
|
34
34
|
e?.warnOnEmptyReply
|
|
35
35
|
]), {
|
|
36
36
|
client: n,
|
|
37
|
-
isReady:
|
|
37
|
+
isReady: r
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
var
|
|
41
|
-
const { client:
|
|
42
|
-
return
|
|
43
|
-
if (!(!
|
|
44
|
-
for (const
|
|
40
|
+
var L = oe(null), Ke = ({ children: e, client: r, tools: t, helpers: o, pageContext: n, ...s }) => {
|
|
41
|
+
const { client: c } = ce(r ? null : s), a = r || c;
|
|
42
|
+
return A(() => {
|
|
43
|
+
if (!(!t || t.length === 0)) {
|
|
44
|
+
for (const f of t) a.register(f);
|
|
45
45
|
return () => {
|
|
46
|
-
for (const
|
|
46
|
+
for (const f of t) a.unregisterFunction(f.name);
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
}, [
|
|
49
|
+
}, [a, t]), A(() => {
|
|
50
50
|
if (!o) return;
|
|
51
|
-
const
|
|
52
|
-
return import("./functions-
|
|
51
|
+
const f = [];
|
|
52
|
+
return import("./functions-CApuQZ2b.js").then((d) => d.n).then((d) => {
|
|
53
53
|
for (const [g, C] of Object.entries(o)) {
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
54
|
+
const N = d[g];
|
|
55
|
+
if (!N) {
|
|
56
56
|
console.warn(`[AGO] Unknown helper: "${g}"`);
|
|
57
57
|
continue;
|
|
58
58
|
}
|
|
59
|
-
const S = C === !0 ?
|
|
60
|
-
...
|
|
59
|
+
const S = C === !0 ? N : {
|
|
60
|
+
...N,
|
|
61
61
|
handler: C
|
|
62
62
|
};
|
|
63
|
-
|
|
63
|
+
a.register(S), f.push(S.name);
|
|
64
64
|
}
|
|
65
65
|
}), () => {
|
|
66
|
-
for (const
|
|
66
|
+
for (const d of f) a.unregisterFunction(d);
|
|
67
67
|
};
|
|
68
|
-
}, [
|
|
69
|
-
n === "auto" &&
|
|
70
|
-
}, [
|
|
71
|
-
value:
|
|
68
|
+
}, [a, o]), A(() => {
|
|
69
|
+
n === "auto" && a.enableAutoPageContext();
|
|
70
|
+
}, [a, n]), /* @__PURE__ */ l(L.Provider, {
|
|
71
|
+
value: a,
|
|
72
72
|
children: e
|
|
73
73
|
});
|
|
74
74
|
};
|
|
75
|
-
function
|
|
76
|
-
const e =
|
|
75
|
+
function D() {
|
|
76
|
+
const e = G(L);
|
|
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
|
|
80
|
+
function z() {
|
|
81
|
+
return G(L);
|
|
82
82
|
}
|
|
83
|
-
function K({ client: e, conversationId:
|
|
84
|
-
const
|
|
83
|
+
function K({ client: e, conversationId: r } = {}) {
|
|
84
|
+
const t = z(), 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([]), [
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}, [
|
|
90
|
-
const
|
|
86
|
+
const [n, s] = E([]), [c, a] = E(r), [f, d] = E(!1), [g, C] = E(null);
|
|
87
|
+
A(() => {
|
|
88
|
+
r && r !== c && (a(r), N(r));
|
|
89
|
+
}, [r]);
|
|
90
|
+
const N = async (S) => {
|
|
91
91
|
try {
|
|
92
92
|
s((await o.getMessages(S)).filter((k) => !k.hidden));
|
|
93
93
|
} catch (k) {
|
|
94
94
|
C(k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to load messages"));
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
-
return
|
|
98
|
-
const S = (
|
|
99
|
-
|
|
100
|
-
const w = h.findIndex((b) => b.id ===
|
|
101
|
-
return w >= 0 ? h.map((b,
|
|
97
|
+
return A(() => {
|
|
98
|
+
const S = (u) => u === "IN_PROGRESS" || u === "WAITING_CLIENT", k = (u) => {
|
|
99
|
+
c || a(u.conversationId), d(!0), s((h) => {
|
|
100
|
+
const w = h.findIndex((b) => b.id === u.messageId);
|
|
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: u.messageId,
|
|
106
|
+
conversationId: u.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
|
+
}, p = (u) => {
|
|
114
114
|
s((h) => {
|
|
115
|
-
const w = h.findIndex((b) => b.id ===
|
|
116
|
-
return w < 0 ? h : h.map((b,
|
|
115
|
+
const w = h.findIndex((b) => b.id === u.messageId);
|
|
116
|
+
return w < 0 ? h : h.map((b, T) => T === w ? {
|
|
117
117
|
...b,
|
|
118
|
-
content: b.content +
|
|
118
|
+
content: b.content + u.content
|
|
119
119
|
} : b);
|
|
120
120
|
});
|
|
121
|
-
}, x = (
|
|
121
|
+
}, x = (u) => {
|
|
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,103 +129,103 @@ function K({ client: e, conversationId: t } = {}) {
|
|
|
129
129
|
...h.slice(0, w),
|
|
130
130
|
{
|
|
131
131
|
...h[w],
|
|
132
|
-
...
|
|
132
|
+
...u
|
|
133
133
|
},
|
|
134
134
|
...h.slice(w + 1)
|
|
135
135
|
];
|
|
136
136
|
});
|
|
137
|
-
},
|
|
137
|
+
}, i = (u) => {
|
|
138
138
|
s((h) => {
|
|
139
|
-
const w = h.findIndex((b) => b.id ===
|
|
139
|
+
const w = h.findIndex((b) => b.id === u.id);
|
|
140
140
|
return w >= 0 ? [
|
|
141
141
|
...h.slice(0, w),
|
|
142
|
-
|
|
142
|
+
u,
|
|
143
143
|
...h.slice(w + 1)
|
|
144
|
-
] : [...h,
|
|
145
|
-
}),
|
|
146
|
-
}, v = (
|
|
147
|
-
C(new Error(
|
|
144
|
+
] : [...h, u];
|
|
145
|
+
}), d(!1);
|
|
146
|
+
}, v = (u) => {
|
|
147
|
+
C(new Error(u.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", p), 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", p), o.off("message:answer-complete", x), o.off("message:complete", i), o.off("message:error", v);
|
|
151
151
|
};
|
|
152
|
-
}, [o,
|
|
152
|
+
}, [o, c]), {
|
|
153
153
|
messages: n,
|
|
154
|
-
isLoading:
|
|
154
|
+
isLoading: f,
|
|
155
155
|
error: g,
|
|
156
156
|
sendMessage: R(async (S, k) => {
|
|
157
|
-
|
|
158
|
-
const
|
|
157
|
+
d(!0), C(null);
|
|
158
|
+
const p = {
|
|
159
159
|
id: `temp-${Date.now()}`,
|
|
160
|
-
conversationId:
|
|
160
|
+
conversationId: c || "",
|
|
161
161
|
content: S,
|
|
162
162
|
role: "user",
|
|
163
163
|
status: "DONE",
|
|
164
|
-
attachments: k && k.length > 0 ?
|
|
164
|
+
attachments: k && k.length > 0 ? Z(k) : void 0,
|
|
165
165
|
createdAt: /* @__PURE__ */ new Date()
|
|
166
166
|
}, x = {
|
|
167
167
|
id: `temp-assistant-${Date.now()}`,
|
|
168
|
-
conversationId:
|
|
168
|
+
conversationId: c || "",
|
|
169
169
|
content: "",
|
|
170
170
|
role: "assistant",
|
|
171
171
|
status: "IN_PROGRESS",
|
|
172
172
|
createdAt: /* @__PURE__ */ new Date()
|
|
173
173
|
};
|
|
174
|
-
s((
|
|
175
|
-
...
|
|
176
|
-
|
|
174
|
+
s((i) => [
|
|
175
|
+
...i,
|
|
176
|
+
p,
|
|
177
177
|
x
|
|
178
178
|
]);
|
|
179
179
|
try {
|
|
180
|
-
const
|
|
181
|
-
conversationId:
|
|
180
|
+
const i = await o.sendMessage(S, {
|
|
181
|
+
conversationId: c,
|
|
182
182
|
files: k
|
|
183
183
|
});
|
|
184
|
-
return
|
|
185
|
-
const
|
|
186
|
-
...
|
|
187
|
-
id:
|
|
188
|
-
conversationId:
|
|
184
|
+
return i.conversationId && !c && a(i.conversationId), s((v) => {
|
|
185
|
+
const u = v.filter((w) => !w.id.startsWith("temp-")), h = {
|
|
186
|
+
...p,
|
|
187
|
+
id: p.id.replace("temp-", "user-"),
|
|
188
|
+
conversationId: i.conversationId
|
|
189
189
|
};
|
|
190
|
-
return
|
|
191
|
-
...
|
|
190
|
+
return u.some((w) => w.id === i.id) ? [...u, h].sort((w, b) => new Date(w.createdAt).getTime() - new Date(b.createdAt).getTime()) : [
|
|
191
|
+
...u,
|
|
192
192
|
h,
|
|
193
|
-
|
|
193
|
+
i
|
|
194
194
|
];
|
|
195
|
-
}),
|
|
196
|
-
} catch (
|
|
197
|
-
return C(
|
|
195
|
+
}), i;
|
|
196
|
+
} catch (i) {
|
|
197
|
+
return C(i instanceof Error ? i : /* @__PURE__ */ new Error("Failed to send message")), d(!1), s((v) => v.filter((u) => !u.id.startsWith("temp-"))), null;
|
|
198
198
|
}
|
|
199
|
-
}, [o,
|
|
199
|
+
}, [o, c]),
|
|
200
200
|
clearMessages: R(() => {
|
|
201
|
-
s([]),
|
|
201
|
+
s([]), a(void 0), C(null);
|
|
202
202
|
}, []),
|
|
203
|
-
conversationId:
|
|
203
|
+
conversationId: c
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
|
-
var de = ({ onSend: e, disabled:
|
|
207
|
-
const [s,
|
|
208
|
-
const
|
|
209
|
-
if (!
|
|
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 = _(null), g = _(null), C = R(() => {
|
|
208
|
+
const i = g.current;
|
|
209
|
+
if (!i) return;
|
|
210
210
|
const v = 110;
|
|
211
|
-
|
|
212
|
-
}, []),
|
|
213
|
-
|
|
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
|
+
}, []), N = R((i) => {
|
|
213
|
+
i.preventDefault(), (s.trim() || a.length > 0) && (e(s.trim(), a.length > 0 ? a : void 0), c(""), f([]), requestAnimationFrame(C));
|
|
214
214
|
}, [
|
|
215
215
|
s,
|
|
216
|
-
|
|
216
|
+
a,
|
|
217
217
|
e,
|
|
218
218
|
C
|
|
219
|
-
]), S = R((
|
|
220
|
-
|
|
221
|
-
}, [
|
|
222
|
-
const v = Array.from(
|
|
223
|
-
|
|
224
|
-
}, []),
|
|
225
|
-
|
|
226
|
-
}, []), x = s.trim() ||
|
|
227
|
-
return /* @__PURE__ */
|
|
228
|
-
onSubmit:
|
|
219
|
+
]), S = R((i) => {
|
|
220
|
+
i.key === "Enter" && !i.shiftKey && (i.preventDefault(), N(i));
|
|
221
|
+
}, [N]), k = R((i) => {
|
|
222
|
+
const v = Array.from(i.target.files || []);
|
|
223
|
+
f((u) => [...u, ...v]);
|
|
224
|
+
}, []), p = R((i) => {
|
|
225
|
+
f((v) => v.filter((u, h) => h !== i));
|
|
226
|
+
}, []), x = s.trim() || a.length > 0;
|
|
227
|
+
return /* @__PURE__ */ M("form", {
|
|
228
|
+
onSubmit: N,
|
|
229
229
|
className: `ago-chat-input ${n}`,
|
|
230
230
|
style: {
|
|
231
231
|
display: "flex",
|
|
@@ -235,14 +235,14 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
235
235
|
borderTop: "1px solid #dee3e8",
|
|
236
236
|
backgroundColor: "#fff"
|
|
237
237
|
},
|
|
238
|
-
children: [
|
|
238
|
+
children: [a.length > 0 && /* @__PURE__ */ l("div", {
|
|
239
239
|
className: "ago-chat-input__files",
|
|
240
240
|
style: {
|
|
241
241
|
display: "flex",
|
|
242
242
|
flexWrap: "wrap",
|
|
243
243
|
gap: "6px"
|
|
244
244
|
},
|
|
245
|
-
children:
|
|
245
|
+
children: a.map((i, v) => /* @__PURE__ */ M("div", {
|
|
246
246
|
style: {
|
|
247
247
|
display: "flex",
|
|
248
248
|
alignItems: "center",
|
|
@@ -260,11 +260,11 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
260
260
|
textOverflow: "ellipsis",
|
|
261
261
|
whiteSpace: "nowrap"
|
|
262
262
|
},
|
|
263
|
-
children:
|
|
263
|
+
children: i.name
|
|
264
264
|
}), /* @__PURE__ */ l("button", {
|
|
265
265
|
type: "button",
|
|
266
|
-
onClick: () =>
|
|
267
|
-
"aria-label": `Remove ${
|
|
266
|
+
onClick: () => p(v),
|
|
267
|
+
"aria-label": `Remove ${i.name}`,
|
|
268
268
|
style: {
|
|
269
269
|
border: "none",
|
|
270
270
|
background: "none",
|
|
@@ -277,31 +277,31 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
277
277
|
children: "×"
|
|
278
278
|
})]
|
|
279
279
|
}, v))
|
|
280
|
-
}), /* @__PURE__ */
|
|
280
|
+
}), /* @__PURE__ */ M("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__ */ M(U, { children: [/* @__PURE__ */ l("button", {
|
|
288
288
|
type: "button",
|
|
289
|
-
onClick: () =>
|
|
290
|
-
disabled:
|
|
289
|
+
onClick: () => d.current?.click(),
|
|
290
|
+
disabled: r,
|
|
291
291
|
"aria-label": "Attach file",
|
|
292
292
|
style: {
|
|
293
293
|
padding: "8px",
|
|
294
294
|
border: "1px solid #dee3e8",
|
|
295
295
|
borderRadius: "8px",
|
|
296
296
|
backgroundColor: "#fff",
|
|
297
|
-
cursor:
|
|
297
|
+
cursor: r ? "not-allowed" : "pointer",
|
|
298
298
|
color: "#6b6d6f",
|
|
299
299
|
fontSize: "16px",
|
|
300
300
|
lineHeight: 1
|
|
301
301
|
},
|
|
302
302
|
children: "+"
|
|
303
303
|
}), /* @__PURE__ */ l("input", {
|
|
304
|
-
ref:
|
|
304
|
+
ref: d,
|
|
305
305
|
type: "file",
|
|
306
306
|
multiple: !0,
|
|
307
307
|
onChange: k,
|
|
@@ -310,13 +310,13 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
310
310
|
/* @__PURE__ */ l("textarea", {
|
|
311
311
|
ref: g,
|
|
312
312
|
value: s,
|
|
313
|
-
onChange: (
|
|
314
|
-
|
|
313
|
+
onChange: (i) => {
|
|
314
|
+
c(i.target.value), C();
|
|
315
315
|
},
|
|
316
316
|
onKeyDown: S,
|
|
317
|
-
placeholder:
|
|
318
|
-
"aria-label":
|
|
319
|
-
disabled:
|
|
317
|
+
placeholder: t,
|
|
318
|
+
"aria-label": t,
|
|
319
|
+
disabled: r,
|
|
320
320
|
rows: 1,
|
|
321
321
|
style: {
|
|
322
322
|
flex: 1,
|
|
@@ -335,23 +335,23 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
335
335
|
backgroundColor: "#f8f8f8",
|
|
336
336
|
transition: "border-color 0.15s"
|
|
337
337
|
},
|
|
338
|
-
onFocus: (
|
|
339
|
-
|
|
338
|
+
onFocus: (i) => {
|
|
339
|
+
i.currentTarget.style.borderColor = "#1b5fc4";
|
|
340
340
|
},
|
|
341
|
-
onBlur: (
|
|
342
|
-
|
|
341
|
+
onBlur: (i) => {
|
|
342
|
+
i.currentTarget.style.borderColor = "#dee3e8";
|
|
343
343
|
}
|
|
344
344
|
}),
|
|
345
345
|
/* @__PURE__ */ l("button", {
|
|
346
346
|
type: "submit",
|
|
347
|
-
disabled:
|
|
347
|
+
disabled: r || !x,
|
|
348
348
|
style: {
|
|
349
349
|
padding: "10px 18px",
|
|
350
350
|
border: "none",
|
|
351
351
|
borderRadius: "20px",
|
|
352
|
-
backgroundColor:
|
|
352
|
+
backgroundColor: r || !x ? "#b5bfc8" : "#03182f",
|
|
353
353
|
color: "#fff",
|
|
354
|
-
cursor:
|
|
354
|
+
cursor: r || !x ? "not-allowed" : "pointer",
|
|
355
355
|
fontWeight: 500,
|
|
356
356
|
fontSize: "16px",
|
|
357
357
|
transition: "background-color 0.15s"
|
|
@@ -361,7 +361,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
361
361
|
]
|
|
362
362
|
})]
|
|
363
363
|
});
|
|
364
|
-
}, ue = ({ href: e, children:
|
|
364
|
+
}, ue = ({ href: e, children: r, ...t }) => /* @__PURE__ */ l("a", {
|
|
365
365
|
href: e,
|
|
366
366
|
target: "_blank",
|
|
367
367
|
rel: "noopener noreferrer",
|
|
@@ -369,53 +369,53 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
369
369
|
color: "#1b5fc4",
|
|
370
370
|
textDecoration: "underline"
|
|
371
371
|
},
|
|
372
|
-
...
|
|
373
|
-
children:
|
|
374
|
-
}), fe = ({ children: e, ...
|
|
372
|
+
...t,
|
|
373
|
+
children: r
|
|
374
|
+
}), fe = ({ children: e, ...r }) => /* @__PURE__ */ l("p", {
|
|
375
375
|
style: {
|
|
376
376
|
margin: "0 0 8px 0",
|
|
377
377
|
lineHeight: "1.6"
|
|
378
378
|
},
|
|
379
|
-
...
|
|
379
|
+
...r,
|
|
380
380
|
children: e
|
|
381
|
-
}), P = (e,
|
|
382
|
-
const
|
|
381
|
+
}), P = (e, r) => {
|
|
382
|
+
const t = ({ children: o, ...n }) => re.createElement(`h${e}`, {
|
|
383
383
|
style: {
|
|
384
384
|
margin: "16px 0 8px 0",
|
|
385
|
-
fontSize:
|
|
385
|
+
fontSize: r,
|
|
386
386
|
fontWeight: 600,
|
|
387
387
|
lineHeight: "1.3"
|
|
388
388
|
},
|
|
389
389
|
...n
|
|
390
390
|
}, o);
|
|
391
|
-
return
|
|
392
|
-
}, pe = ({ children: e, ...
|
|
391
|
+
return t.displayName = `MarkdownHeading${e}`, t;
|
|
392
|
+
}, pe = ({ children: e, ...r }) => /* @__PURE__ */ l("ul", {
|
|
393
393
|
style: {
|
|
394
394
|
margin: "0 0 8px 0",
|
|
395
395
|
paddingLeft: "20px",
|
|
396
396
|
listStyleType: "disc",
|
|
397
397
|
listStylePosition: "outside"
|
|
398
398
|
},
|
|
399
|
-
...
|
|
399
|
+
...r,
|
|
400
400
|
children: e
|
|
401
|
-
}), ge = ({ children: e, ...
|
|
401
|
+
}), ge = ({ children: e, ...r }) => /* @__PURE__ */ l("ol", {
|
|
402
402
|
style: {
|
|
403
403
|
margin: "0 0 8px 0",
|
|
404
404
|
paddingLeft: "20px",
|
|
405
405
|
listStyleType: "decimal",
|
|
406
406
|
listStylePosition: "outside"
|
|
407
407
|
},
|
|
408
|
-
...
|
|
408
|
+
...r,
|
|
409
409
|
children: e
|
|
410
|
-
}), me = ({ children: e, ...
|
|
410
|
+
}), me = ({ children: e, ...r }) => /* @__PURE__ */ l("li", {
|
|
411
411
|
style: {
|
|
412
412
|
display: "list-item",
|
|
413
413
|
margin: "2px 0",
|
|
414
414
|
lineHeight: "1.6"
|
|
415
415
|
},
|
|
416
|
-
...
|
|
416
|
+
...r,
|
|
417
417
|
children: e
|
|
418
|
-
}), xe = ({ className: e, children:
|
|
418
|
+
}), xe = ({ className: e, children: r, ...t }) => e !== void 0 || String(r).includes(`
|
|
419
419
|
`) ? /* @__PURE__ */ l("code", {
|
|
420
420
|
style: {
|
|
421
421
|
display: "block",
|
|
@@ -426,8 +426,8 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
426
426
|
overflowX: "auto",
|
|
427
427
|
fontFamily: '"IBM Plex Mono", monospace'
|
|
428
428
|
},
|
|
429
|
-
...
|
|
430
|
-
children:
|
|
429
|
+
...t,
|
|
430
|
+
children: r
|
|
431
431
|
}) : /* @__PURE__ */ l("code", {
|
|
432
432
|
style: {
|
|
433
433
|
background: "#f0f2f5",
|
|
@@ -436,13 +436,13 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
436
436
|
fontSize: "13px",
|
|
437
437
|
fontFamily: '"IBM Plex Mono", monospace'
|
|
438
438
|
},
|
|
439
|
-
...r,
|
|
440
|
-
children: t
|
|
441
|
-
}), he = ({ children: e, ...t }) => /* @__PURE__ */ l("pre", {
|
|
442
|
-
style: { margin: "0 0 8px 0" },
|
|
443
439
|
...t,
|
|
440
|
+
children: r
|
|
441
|
+
}), he = ({ children: e, ...r }) => /* @__PURE__ */ l("pre", {
|
|
442
|
+
style: { margin: "0 0 8px 0" },
|
|
443
|
+
...r,
|
|
444
444
|
children: e
|
|
445
|
-
}), ye = ({ children: e, ...
|
|
445
|
+
}), ye = ({ children: e, ...r }) => /* @__PURE__ */ l("blockquote", {
|
|
446
446
|
style: {
|
|
447
447
|
borderLeft: "4px solid #dee3e8",
|
|
448
448
|
paddingLeft: "12px",
|
|
@@ -450,9 +450,9 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
450
450
|
fontStyle: "italic",
|
|
451
451
|
color: "#6b6d6f"
|
|
452
452
|
},
|
|
453
|
-
...
|
|
453
|
+
...r,
|
|
454
454
|
children: e
|
|
455
|
-
}), ve = ({ children: e, ...
|
|
455
|
+
}), ve = ({ children: e, ...r }) => /* @__PURE__ */ l("div", {
|
|
456
456
|
style: {
|
|
457
457
|
overflowX: "auto",
|
|
458
458
|
margin: "0 0 8px 0"
|
|
@@ -463,10 +463,10 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
463
463
|
width: "100%",
|
|
464
464
|
fontSize: "13px"
|
|
465
465
|
},
|
|
466
|
-
...
|
|
466
|
+
...r,
|
|
467
467
|
children: e
|
|
468
468
|
})
|
|
469
|
-
}), be = ({ children: e, ...
|
|
469
|
+
}), be = ({ children: e, ...r }) => /* @__PURE__ */ l("th", {
|
|
470
470
|
style: {
|
|
471
471
|
border: "1px solid #dee3e8",
|
|
472
472
|
padding: "6px 10px",
|
|
@@ -474,23 +474,23 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
474
474
|
backgroundColor: "#f5f7fa",
|
|
475
475
|
fontWeight: 600
|
|
476
476
|
},
|
|
477
|
-
...
|
|
477
|
+
...r,
|
|
478
478
|
children: e
|
|
479
|
-
}), we = ({ children: e, ...
|
|
479
|
+
}), we = ({ children: e, ...r }) => /* @__PURE__ */ l("td", {
|
|
480
480
|
style: {
|
|
481
481
|
border: "1px solid #dee3e8",
|
|
482
482
|
padding: "6px 10px"
|
|
483
483
|
},
|
|
484
|
-
...
|
|
484
|
+
...r,
|
|
485
485
|
children: e
|
|
486
|
-
}), Ce = ({ alt: e, ...
|
|
486
|
+
}), Ce = ({ alt: e, ...r }) => /* @__PURE__ */ l("img", {
|
|
487
487
|
alt: e ?? "",
|
|
488
488
|
style: {
|
|
489
489
|
maxWidth: "100%",
|
|
490
490
|
borderRadius: "8px",
|
|
491
491
|
margin: "4px 0"
|
|
492
492
|
},
|
|
493
|
-
...
|
|
493
|
+
...r
|
|
494
494
|
}), Se = (e) => /* @__PURE__ */ l("hr", {
|
|
495
495
|
style: {
|
|
496
496
|
border: "none",
|
|
@@ -522,10 +522,10 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
522
522
|
remarkPlugins: Ie,
|
|
523
523
|
components: ke,
|
|
524
524
|
children: e
|
|
525
|
-
}), Ne = ({ attachment: e, isUser:
|
|
526
|
-
const
|
|
527
|
-
if (
|
|
528
|
-
href:
|
|
525
|
+
}), Ne = ({ attachment: e, isUser: r }) => {
|
|
526
|
+
const t = ee(e.url);
|
|
527
|
+
if (Y(e)) return /* @__PURE__ */ l("a", {
|
|
528
|
+
href: t,
|
|
529
529
|
target: "_blank",
|
|
530
530
|
rel: "noopener noreferrer",
|
|
531
531
|
style: {
|
|
@@ -533,7 +533,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
533
533
|
textDecoration: "none"
|
|
534
534
|
},
|
|
535
535
|
children: /* @__PURE__ */ l("img", {
|
|
536
|
-
src:
|
|
536
|
+
src: t,
|
|
537
537
|
alt: e.name,
|
|
538
538
|
loading: "lazy",
|
|
539
539
|
style: {
|
|
@@ -546,7 +546,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
546
546
|
}
|
|
547
547
|
})
|
|
548
548
|
});
|
|
549
|
-
const o =
|
|
549
|
+
const o = Q(e.fileSize), n = /* @__PURE__ */ M(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: t = !1, placeholder: r = "Type a message...", a
|
|
|
554
554
|
},
|
|
555
555
|
"aria-hidden": !0,
|
|
556
556
|
children: "📄"
|
|
557
|
-
}), /* @__PURE__ */
|
|
557
|
+
}), /* @__PURE__ */ M("span", {
|
|
558
558
|
style: {
|
|
559
559
|
display: "flex",
|
|
560
560
|
flexDirection: "column",
|
|
@@ -583,14 +583,14 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
583
583
|
padding: "8px 12px",
|
|
584
584
|
borderRadius: "10px",
|
|
585
585
|
border: "1px solid #dee3e8",
|
|
586
|
-
backgroundColor:
|
|
587
|
-
color:
|
|
586
|
+
backgroundColor: r ? "rgba(255,255,255,0.12)" : "#fff",
|
|
587
|
+
color: r ? "#fff" : "#30373e",
|
|
588
588
|
fontSize: "13px",
|
|
589
589
|
textDecoration: "none",
|
|
590
590
|
maxWidth: "220px"
|
|
591
591
|
};
|
|
592
|
-
return
|
|
593
|
-
href:
|
|
592
|
+
return t ? /* @__PURE__ */ l("a", {
|
|
593
|
+
href: t,
|
|
594
594
|
target: "_blank",
|
|
595
595
|
rel: "noopener noreferrer",
|
|
596
596
|
style: s,
|
|
@@ -599,8 +599,8 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
599
599
|
style: s,
|
|
600
600
|
children: n
|
|
601
601
|
});
|
|
602
|
-
}, Re = ({ source: e, index:
|
|
603
|
-
const
|
|
602
|
+
}, Re = ({ source: e, index: r }) => {
|
|
603
|
+
const t = /* @__PURE__ */ M("div", {
|
|
604
604
|
style: {
|
|
605
605
|
display: "flex",
|
|
606
606
|
alignItems: "center",
|
|
@@ -623,7 +623,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
623
623
|
justifyContent: "center",
|
|
624
624
|
backgroundColor: "#f0f4ff"
|
|
625
625
|
},
|
|
626
|
-
children:
|
|
626
|
+
children: r + 1
|
|
627
627
|
}), /* @__PURE__ */ l("div", {
|
|
628
628
|
style: {
|
|
629
629
|
fontSize: "12px",
|
|
@@ -659,12 +659,12 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
659
659
|
onMouseLeave: (n) => {
|
|
660
660
|
n.currentTarget.style.borderColor = "#dee3e8";
|
|
661
661
|
},
|
|
662
|
-
children:
|
|
662
|
+
children: t
|
|
663
663
|
}) : /* @__PURE__ */ l("div", {
|
|
664
664
|
style: o,
|
|
665
|
-
children:
|
|
665
|
+
children: t
|
|
666
666
|
});
|
|
667
|
-
},
|
|
667
|
+
}, Ee = () => /* @__PURE__ */ M("div", {
|
|
668
668
|
style: {
|
|
669
669
|
display: "flex",
|
|
670
670
|
gap: "4px",
|
|
@@ -687,10 +687,10 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
687
687
|
40% { opacity: 1; transform: scale(1); }
|
|
688
688
|
}
|
|
689
689
|
` })]
|
|
690
|
-
}),
|
|
691
|
-
const s = e.role === "user",
|
|
692
|
-
return /* @__PURE__ */
|
|
693
|
-
className: `ago-message ago-message--${e.role} ${
|
|
690
|
+
}), Me = ({ message: e, className: r = "", showAgentName: t = !1, isLast: o = !1, onFollowUpClick: n }) => {
|
|
691
|
+
const s = e.role === "user", c = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
|
|
692
|
+
return /* @__PURE__ */ M("div", {
|
|
693
|
+
className: `ago-message ago-message--${e.role} ${r}`,
|
|
694
694
|
style: {
|
|
695
695
|
display: "flex",
|
|
696
696
|
flexDirection: "column",
|
|
@@ -698,7 +698,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
698
698
|
marginBottom: "16px"
|
|
699
699
|
},
|
|
700
700
|
children: [
|
|
701
|
-
!s &&
|
|
701
|
+
!s && t && e.agent && /* @__PURE__ */ l("div", {
|
|
702
702
|
className: "ago-message__agent",
|
|
703
703
|
style: {
|
|
704
704
|
display: "flex",
|
|
@@ -722,10 +722,10 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
722
722
|
width: "100%",
|
|
723
723
|
maxWidth: "85%"
|
|
724
724
|
},
|
|
725
|
-
children: e.sources.map((
|
|
726
|
-
source:
|
|
727
|
-
index:
|
|
728
|
-
},
|
|
725
|
+
children: e.sources.map((a, f) => /* @__PURE__ */ l(Re, {
|
|
726
|
+
source: a,
|
|
727
|
+
index: f
|
|
728
|
+
}, a.id))
|
|
729
729
|
}),
|
|
730
730
|
e.attachments && e.attachments.length > 0 && /* @__PURE__ */ l("div", {
|
|
731
731
|
className: "ago-message__attachments",
|
|
@@ -737,12 +737,12 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
737
737
|
justifyContent: s ? "flex-end" : "flex-start",
|
|
738
738
|
maxWidth: "75%"
|
|
739
739
|
},
|
|
740
|
-
children: e.attachments.map((
|
|
741
|
-
attachment:
|
|
740
|
+
children: e.attachments.map((a) => /* @__PURE__ */ l(Ne, {
|
|
741
|
+
attachment: a,
|
|
742
742
|
isUser: s
|
|
743
|
-
},
|
|
743
|
+
}, a.id))
|
|
744
744
|
}),
|
|
745
|
-
(e.content ||
|
|
745
|
+
(e.content || c) && /* @__PURE__ */ l("div", {
|
|
746
746
|
className: "ago-message__content",
|
|
747
747
|
style: {
|
|
748
748
|
maxWidth: s ? "75%" : "100%",
|
|
@@ -754,7 +754,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
754
754
|
fontSize: "16px",
|
|
755
755
|
lineHeight: "1.6"
|
|
756
756
|
},
|
|
757
|
-
children: e.content ? /* @__PURE__ */ l(Ae, { content: e.content }) :
|
|
757
|
+
children: e.content ? /* @__PURE__ */ l(Ae, { 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,11 +764,11 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
764
764
|
gap: "8px",
|
|
765
765
|
marginTop: "10px"
|
|
766
766
|
},
|
|
767
|
-
children: e.followUpReplies.map((
|
|
767
|
+
children: e.followUpReplies.map((a, f) => /* @__PURE__ */ l("button", {
|
|
768
768
|
type: "button",
|
|
769
769
|
className: "ago-message__followup-btn",
|
|
770
770
|
disabled: !n,
|
|
771
|
-
onClick: n ? () => n(
|
|
771
|
+
onClick: n ? () => n(a) : void 0,
|
|
772
772
|
style: {
|
|
773
773
|
minHeight: "36px",
|
|
774
774
|
padding: "6px 14px",
|
|
@@ -780,56 +780,56 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
780
780
|
cursor: n ? "pointer" : "default",
|
|
781
781
|
transition: "border-color 0.15s"
|
|
782
782
|
},
|
|
783
|
-
onMouseEnter: (
|
|
784
|
-
|
|
783
|
+
onMouseEnter: (d) => {
|
|
784
|
+
d.currentTarget.style.borderColor = "#1b5fc4";
|
|
785
785
|
},
|
|
786
|
-
onMouseLeave: (
|
|
787
|
-
|
|
786
|
+
onMouseLeave: (d) => {
|
|
787
|
+
d.currentTarget.style.borderColor = "#dee3e8";
|
|
788
788
|
},
|
|
789
|
-
children:
|
|
790
|
-
},
|
|
789
|
+
children: a
|
|
790
|
+
}, f))
|
|
791
791
|
})
|
|
792
792
|
]
|
|
793
793
|
});
|
|
794
|
-
},
|
|
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: f = !1, forms: d, onFollowUpClick: g, className: C = "", onMessageSent: N, onMessageReceived: S }) => {
|
|
795
|
+
const k = _(null), p = z(), x = e ?? p, { messages: i, isLoading: v, error: u, sendMessage: h } = K({
|
|
796
796
|
client: e,
|
|
797
|
-
conversationId:
|
|
797
|
+
conversationId: r
|
|
798
798
|
});
|
|
799
|
-
|
|
800
|
-
if (!x || !
|
|
801
|
-
let
|
|
799
|
+
A(() => {
|
|
800
|
+
if (!x || !d || d.length === 0) return;
|
|
801
|
+
let m = !1;
|
|
802
802
|
const I = [];
|
|
803
|
-
return Promise.all(
|
|
804
|
-
if (!
|
|
805
|
-
for (const
|
|
803
|
+
return Promise.all(d.map((F) => F.schema != null ? Promise.resolve(B(F)) : j(x, F))).then((F) => {
|
|
804
|
+
if (!m)
|
|
805
|
+
for (const V of F) I.push(V.install(x));
|
|
806
806
|
}).catch(() => {
|
|
807
807
|
}), () => {
|
|
808
|
-
|
|
808
|
+
m = !0, I.forEach((F) => F());
|
|
809
809
|
};
|
|
810
|
-
}, [x,
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
])) : ""]),
|
|
810
|
+
}, [x, d ? JSON.stringify(d.map((m) => [
|
|
811
|
+
m.name,
|
|
812
|
+
m.schema ?? null,
|
|
813
|
+
m.submit ?? !1,
|
|
814
|
+
m.description ?? null
|
|
815
|
+
])) : ""]), A(() => {
|
|
816
816
|
k.current?.scrollIntoView({ behavior: "smooth" });
|
|
817
|
-
}, [
|
|
818
|
-
const
|
|
819
|
-
|
|
820
|
-
id:
|
|
821
|
-
content:
|
|
817
|
+
}, [i]), A(() => {
|
|
818
|
+
const m = i[i.length - 1];
|
|
819
|
+
m && m.role === "assistant" && m.status === "DONE" && S && S({
|
|
820
|
+
id: m.id,
|
|
821
|
+
content: m.content
|
|
822
822
|
});
|
|
823
|
-
}, [
|
|
824
|
-
const w = async (
|
|
825
|
-
|
|
826
|
-
}, b =
|
|
827
|
-
return /* @__PURE__ */
|
|
823
|
+
}, [i, S]);
|
|
824
|
+
const w = async (m, I) => {
|
|
825
|
+
N?.(m), await h(m, I);
|
|
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__ */ M("div", {
|
|
828
828
|
className: `ago-chat-widget ${C}`,
|
|
829
829
|
style: {
|
|
830
830
|
display: "flex",
|
|
831
831
|
flexDirection: "column",
|
|
832
|
-
height: typeof
|
|
832
|
+
height: typeof c == "number" ? `${c}px` : c,
|
|
833
833
|
border: "1px solid #dee3e8",
|
|
834
834
|
borderRadius: "16px",
|
|
835
835
|
overflow: "hidden",
|
|
@@ -839,7 +839,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "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__ */ M("div", {
|
|
843
843
|
className: "ago-chat-widget__header",
|
|
844
844
|
style: {
|
|
845
845
|
padding: "14px 16px",
|
|
@@ -850,8 +850,8 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
850
850
|
alignItems: "center",
|
|
851
851
|
gap: "10px"
|
|
852
852
|
},
|
|
853
|
-
children: [
|
|
854
|
-
src:
|
|
853
|
+
children: [a && /* @__PURE__ */ l("img", {
|
|
854
|
+
src: a,
|
|
855
855
|
alt: "Logo",
|
|
856
856
|
style: {
|
|
857
857
|
height: "24px",
|
|
@@ -863,10 +863,10 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
863
863
|
fontSize: "15px",
|
|
864
864
|
fontWeight: 600
|
|
865
865
|
},
|
|
866
|
-
children:
|
|
866
|
+
children: t
|
|
867
867
|
})]
|
|
868
868
|
}),
|
|
869
|
-
/* @__PURE__ */
|
|
869
|
+
/* @__PURE__ */ M("div", {
|
|
870
870
|
className: "ago-chat-widget__messages",
|
|
871
871
|
role: "log",
|
|
872
872
|
"aria-live": "polite",
|
|
@@ -879,7 +879,7 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
879
879
|
backgroundColor: "#fbfbfb"
|
|
880
880
|
},
|
|
881
881
|
children: [
|
|
882
|
-
|
|
882
|
+
i.length === 0 ? /* @__PURE__ */ l("div", {
|
|
883
883
|
style: {
|
|
884
884
|
textAlign: "center",
|
|
885
885
|
color: "#6b6d6f",
|
|
@@ -888,13 +888,13 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
888
888
|
lineHeight: "1.5"
|
|
889
889
|
},
|
|
890
890
|
children: o
|
|
891
|
-
}) :
|
|
892
|
-
message:
|
|
893
|
-
showAgentName:
|
|
894
|
-
isLast: I ===
|
|
891
|
+
}) : i.map((m, I) => /* @__PURE__ */ l(Me, {
|
|
892
|
+
message: m,
|
|
893
|
+
showAgentName: f,
|
|
894
|
+
isLast: I === i.length - 1,
|
|
895
895
|
onFollowUpClick: y
|
|
896
|
-
},
|
|
897
|
-
|
|
896
|
+
}, m.id)),
|
|
897
|
+
u && /* @__PURE__ */ l("div", {
|
|
898
898
|
role: "alert",
|
|
899
899
|
style: {
|
|
900
900
|
padding: "10px 14px",
|
|
@@ -905,64 +905,199 @@ var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
905
905
|
fontSize: "13px",
|
|
906
906
|
border: "1px solid #fecaca"
|
|
907
907
|
},
|
|
908
|
-
children:
|
|
908
|
+
children: u.message
|
|
909
909
|
}),
|
|
910
910
|
/* @__PURE__ */ l("div", { ref: k })
|
|
911
911
|
]
|
|
912
912
|
}),
|
|
913
913
|
/* @__PURE__ */ l(de, {
|
|
914
914
|
onSend: w,
|
|
915
|
-
disabled:
|
|
915
|
+
disabled: T,
|
|
916
916
|
placeholder: n,
|
|
917
917
|
allowFiles: s
|
|
918
918
|
})
|
|
919
919
|
]
|
|
920
920
|
});
|
|
921
921
|
};
|
|
922
|
-
function
|
|
923
|
-
const r =
|
|
922
|
+
function _e(e = {}) {
|
|
923
|
+
const r = z(), t = e.client ?? r;
|
|
924
|
+
if (!t) throw new q("useProactiveNudge: no AgoClient. Pass one via options.client or wrap your tree with <AgoProvider>.", "proactive_missing_client");
|
|
925
|
+
const [o, n] = E(null), s = _(o);
|
|
926
|
+
s.current = o;
|
|
927
|
+
const c = _(e.onExpand);
|
|
928
|
+
return c.current = e.onExpand, A(() => {
|
|
929
|
+
const a = (d) => {
|
|
930
|
+
n(d), t.proactive?.shown(d);
|
|
931
|
+
}, f = ({ nudge: d }) => {
|
|
932
|
+
n((g) => g?.id === d.id ? null : g);
|
|
933
|
+
};
|
|
934
|
+
return t.on("nudge:ready", a), t.on("nudge:accepted", f), t.on("nudge:dismissed", f), () => {
|
|
935
|
+
t.off("nudge:ready", a), t.off("nudge:accepted", f), t.off("nudge:dismissed", f);
|
|
936
|
+
};
|
|
937
|
+
}, [t]), {
|
|
938
|
+
nudge: o,
|
|
939
|
+
accept: R(async () => {
|
|
940
|
+
const a = s.current;
|
|
941
|
+
a && (n(null), await t.proactive?.accept(a), (a.source === "agent" || a.goal) && c.current?.(a));
|
|
942
|
+
}, [t]),
|
|
943
|
+
dismiss: R(() => {
|
|
944
|
+
const a = s.current;
|
|
945
|
+
a && (n(null), t.proactive?.dismiss(a));
|
|
946
|
+
}, [t])
|
|
947
|
+
};
|
|
948
|
+
}
|
|
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 } = _e({
|
|
951
|
+
client: e,
|
|
952
|
+
onExpand: r
|
|
953
|
+
});
|
|
954
|
+
if (A(() => {
|
|
955
|
+
if (!c || !t) return;
|
|
956
|
+
const g = setTimeout(() => f(), t);
|
|
957
|
+
return () => clearTimeout(g);
|
|
958
|
+
}, [
|
|
959
|
+
c,
|
|
960
|
+
t,
|
|
961
|
+
f
|
|
962
|
+
]), !c) return null;
|
|
963
|
+
const d = c.source === "agent" || !!c.goal;
|
|
964
|
+
return /* @__PURE__ */ M("div", {
|
|
965
|
+
className: `ago-nudge ${s}`,
|
|
966
|
+
role: "status",
|
|
967
|
+
"aria-live": "polite",
|
|
968
|
+
style: {
|
|
969
|
+
position: "fixed",
|
|
970
|
+
bottom: "90px",
|
|
971
|
+
...o === "bottom-left" ? { left: "20px" } : { right: "20px" },
|
|
972
|
+
zIndex: 2147483e3,
|
|
973
|
+
maxWidth: "320px",
|
|
974
|
+
padding: "14px 16px",
|
|
975
|
+
backgroundColor: "#fff",
|
|
976
|
+
color: "#03182f",
|
|
977
|
+
border: "1px solid #dee3e8",
|
|
978
|
+
borderRadius: "16px",
|
|
979
|
+
boxShadow: "rgba(15, 15, 15, 0.12) 0px 4px 20px 0px",
|
|
980
|
+
fontFamily: '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
981
|
+
fontSize: "14px",
|
|
982
|
+
lineHeight: 1.5,
|
|
983
|
+
textAlign: "left"
|
|
984
|
+
},
|
|
985
|
+
children: [
|
|
986
|
+
/* @__PURE__ */ l("button", {
|
|
987
|
+
type: "button",
|
|
988
|
+
className: "ago-nudge__close",
|
|
989
|
+
"aria-label": "Dismiss",
|
|
990
|
+
onClick: f,
|
|
991
|
+
style: {
|
|
992
|
+
position: "absolute",
|
|
993
|
+
top: "6px",
|
|
994
|
+
right: "8px",
|
|
995
|
+
border: "none",
|
|
996
|
+
background: "transparent",
|
|
997
|
+
color: "#6b6d6f",
|
|
998
|
+
fontSize: "16px",
|
|
999
|
+
lineHeight: 1,
|
|
1000
|
+
cursor: "pointer",
|
|
1001
|
+
padding: "4px"
|
|
1002
|
+
},
|
|
1003
|
+
children: "×"
|
|
1004
|
+
}),
|
|
1005
|
+
/* @__PURE__ */ l("div", {
|
|
1006
|
+
className: "ago-nudge__message",
|
|
1007
|
+
style: { paddingRight: "16px" },
|
|
1008
|
+
children: c.message
|
|
1009
|
+
}),
|
|
1010
|
+
(c.action || d) && /* @__PURE__ */ M("div", {
|
|
1011
|
+
className: "ago-nudge__actions",
|
|
1012
|
+
style: {
|
|
1013
|
+
display: "flex",
|
|
1014
|
+
gap: "8px",
|
|
1015
|
+
marginTop: "10px",
|
|
1016
|
+
flexWrap: "wrap"
|
|
1017
|
+
},
|
|
1018
|
+
children: [c.action && /* @__PURE__ */ l("button", {
|
|
1019
|
+
type: "button",
|
|
1020
|
+
className: "ago-nudge__action",
|
|
1021
|
+
onClick: () => {
|
|
1022
|
+
a();
|
|
1023
|
+
},
|
|
1024
|
+
style: {
|
|
1025
|
+
border: "none",
|
|
1026
|
+
borderRadius: "10px",
|
|
1027
|
+
padding: "6px 12px",
|
|
1028
|
+
backgroundColor: "#03182f",
|
|
1029
|
+
color: "#e8f0fe",
|
|
1030
|
+
fontSize: "13px",
|
|
1031
|
+
fontWeight: 600,
|
|
1032
|
+
cursor: "pointer"
|
|
1033
|
+
},
|
|
1034
|
+
children: c.action.label
|
|
1035
|
+
}), d && /* @__PURE__ */ l("button", {
|
|
1036
|
+
type: "button",
|
|
1037
|
+
className: "ago-nudge__expand",
|
|
1038
|
+
onClick: () => {
|
|
1039
|
+
a();
|
|
1040
|
+
},
|
|
1041
|
+
style: {
|
|
1042
|
+
border: "1px solid #dee3e8",
|
|
1043
|
+
borderRadius: "10px",
|
|
1044
|
+
padding: "6px 12px",
|
|
1045
|
+
backgroundColor: "#fff",
|
|
1046
|
+
color: "#03182f",
|
|
1047
|
+
fontSize: "13px",
|
|
1048
|
+
fontWeight: 600,
|
|
1049
|
+
cursor: "pointer"
|
|
1050
|
+
},
|
|
1051
|
+
children: n
|
|
1052
|
+
})]
|
|
1053
|
+
})
|
|
1054
|
+
]
|
|
1055
|
+
});
|
|
1056
|
+
};
|
|
1057
|
+
function Fe({ client: e, autoLoad: r = !0 } = {}) {
|
|
1058
|
+
const t = z(), o = e || t;
|
|
924
1059
|
if (!o) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
925
|
-
const [n, s] = E([]), [
|
|
926
|
-
|
|
1060
|
+
const [n, s] = E([]), [c, a] = E(null), [f, d] = E(!1), [g, C] = E(null), N = R(async () => {
|
|
1061
|
+
d(!0), C(null);
|
|
927
1062
|
try {
|
|
928
1063
|
s(await o.getConversations());
|
|
929
|
-
} catch (
|
|
930
|
-
C(
|
|
1064
|
+
} catch (p) {
|
|
1065
|
+
C(p instanceof Error ? p : /* @__PURE__ */ new Error("Failed to load conversations"));
|
|
931
1066
|
} finally {
|
|
932
|
-
|
|
1067
|
+
d(!1);
|
|
933
1068
|
}
|
|
934
|
-
}, [o]), S = R(async (
|
|
935
|
-
|
|
1069
|
+
}, [o]), S = R(async (p) => {
|
|
1070
|
+
d(!0), C(null);
|
|
936
1071
|
try {
|
|
937
|
-
|
|
1072
|
+
a(await o.getConversation(p));
|
|
938
1073
|
} catch (x) {
|
|
939
1074
|
C(x instanceof Error ? x : /* @__PURE__ */ new Error("Failed to load conversation"));
|
|
940
1075
|
} finally {
|
|
941
|
-
|
|
1076
|
+
d(!1);
|
|
942
1077
|
}
|
|
943
1078
|
}, [o]), k = R(() => {
|
|
944
|
-
|
|
1079
|
+
a(null);
|
|
945
1080
|
}, []);
|
|
946
|
-
return
|
|
947
|
-
|
|
948
|
-
}, [
|
|
1081
|
+
return A(() => {
|
|
1082
|
+
r && N();
|
|
1083
|
+
}, [r, N]), {
|
|
949
1084
|
conversations: n,
|
|
950
|
-
currentConversation:
|
|
951
|
-
isLoading:
|
|
1085
|
+
currentConversation: c,
|
|
1086
|
+
isLoading: f,
|
|
952
1087
|
error: g,
|
|
953
1088
|
selectConversation: S,
|
|
954
1089
|
startNewConversation: k,
|
|
955
|
-
refreshConversations:
|
|
1090
|
+
refreshConversations: N
|
|
956
1091
|
};
|
|
957
1092
|
}
|
|
958
|
-
function
|
|
959
|
-
const
|
|
960
|
-
if (!
|
|
1093
|
+
function Ye(e = {}) {
|
|
1094
|
+
const r = z(), t = e.client || r;
|
|
1095
|
+
if (!t) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
961
1096
|
const o = K({
|
|
962
|
-
client:
|
|
1097
|
+
client: t,
|
|
963
1098
|
conversationId: e.conversationId
|
|
964
1099
|
}), n = Fe({
|
|
965
|
-
client:
|
|
1100
|
+
client: t,
|
|
966
1101
|
autoLoad: e.autoLoad
|
|
967
1102
|
});
|
|
968
1103
|
return {
|
|
@@ -980,67 +1115,67 @@ function Je(e = {}) {
|
|
|
980
1115
|
refreshConversations: n.refreshConversations
|
|
981
1116
|
};
|
|
982
1117
|
}
|
|
983
|
-
function
|
|
984
|
-
const
|
|
1118
|
+
function Xe(e, r) {
|
|
1119
|
+
const t = D(), { name: o, description: n, parameters: s, handler: c, maxResultBytes: a, requiresApproval: f } = typeof e == "string" ? {
|
|
985
1120
|
name: e,
|
|
986
|
-
...
|
|
987
|
-
} : e,
|
|
988
|
-
|
|
989
|
-
const g = (C) =>
|
|
990
|
-
return
|
|
1121
|
+
...r
|
|
1122
|
+
} : e, d = _(c);
|
|
1123
|
+
d.current = c, A(() => {
|
|
1124
|
+
const g = (C) => d.current(C);
|
|
1125
|
+
return t.registerFunction(o, g, {
|
|
991
1126
|
description: n,
|
|
992
1127
|
parameters: s,
|
|
993
|
-
maxResultBytes:
|
|
994
|
-
requiresApproval:
|
|
1128
|
+
maxResultBytes: a,
|
|
1129
|
+
requiresApproval: f
|
|
995
1130
|
}), () => {
|
|
996
|
-
|
|
1131
|
+
t.unregisterFunction(o);
|
|
997
1132
|
};
|
|
998
1133
|
}, [
|
|
999
|
-
|
|
1134
|
+
t,
|
|
1000
1135
|
o,
|
|
1001
1136
|
n,
|
|
1002
1137
|
s,
|
|
1003
|
-
|
|
1004
|
-
|
|
1138
|
+
a,
|
|
1139
|
+
f
|
|
1005
1140
|
]);
|
|
1006
1141
|
}
|
|
1007
|
-
function
|
|
1008
|
-
const
|
|
1009
|
-
o.current = e,
|
|
1010
|
-
|
|
1011
|
-
}), [
|
|
1142
|
+
function Ze(e, r) {
|
|
1143
|
+
const t = D(), o = _(e);
|
|
1144
|
+
o.current = e, A(() => (t.registerNavigationFunction((n) => o.current(n), r), () => {
|
|
1145
|
+
t.unregisterNavigationFunction();
|
|
1146
|
+
}), [t, r]);
|
|
1012
1147
|
}
|
|
1013
|
-
function
|
|
1014
|
-
const
|
|
1015
|
-
s.current = e,
|
|
1016
|
-
const
|
|
1017
|
-
const
|
|
1148
|
+
function Qe(e, r) {
|
|
1149
|
+
const t = D(), o = r?.functionName ?? "setPageState", n = r?.requiresApproval, s = _(e);
|
|
1150
|
+
s.current = e, A(() => {
|
|
1151
|
+
const c = s.current.map((a) => {
|
|
1152
|
+
const f = () => s.current.find((d) => d.name === a.name) ?? a;
|
|
1018
1153
|
return {
|
|
1019
|
-
name:
|
|
1020
|
-
description:
|
|
1021
|
-
schema:
|
|
1022
|
-
get:
|
|
1023
|
-
set: (
|
|
1154
|
+
name: a.name,
|
|
1155
|
+
description: a.description,
|
|
1156
|
+
schema: a.schema,
|
|
1157
|
+
get: a.get ? () => f().get?.() : void 0,
|
|
1158
|
+
set: (d) => f().set(d)
|
|
1024
1159
|
};
|
|
1025
1160
|
});
|
|
1026
|
-
return
|
|
1161
|
+
return t.registerPageStateFunction(c, {
|
|
1027
1162
|
functionName: o,
|
|
1028
1163
|
requiresApproval: n
|
|
1029
1164
|
}), () => {
|
|
1030
|
-
|
|
1165
|
+
t.unregisterPageStateFunction(o);
|
|
1031
1166
|
};
|
|
1032
1167
|
}, [
|
|
1033
|
-
|
|
1168
|
+
t,
|
|
1034
1169
|
o,
|
|
1035
1170
|
n
|
|
1036
1171
|
]);
|
|
1037
1172
|
}
|
|
1038
|
-
function
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1173
|
+
function et(e) {
|
|
1174
|
+
const r = D(), t = _(e);
|
|
1175
|
+
t.current = e, A(() => ne(r, () => t.current), [r]);
|
|
1041
1176
|
}
|
|
1042
1177
|
var Te = /* @__PURE__ */ new Set(["awaiting-approval"]);
|
|
1043
|
-
function
|
|
1178
|
+
function J(e) {
|
|
1044
1179
|
switch (e) {
|
|
1045
1180
|
case "progress_indicator":
|
|
1046
1181
|
return "progress";
|
|
@@ -1054,22 +1189,22 @@ function U(e) {
|
|
|
1054
1189
|
return "status";
|
|
1055
1190
|
}
|
|
1056
1191
|
}
|
|
1057
|
-
function
|
|
1058
|
-
return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" :
|
|
1192
|
+
function Pe(e) {
|
|
1193
|
+
return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : J(e.type);
|
|
1059
1194
|
}
|
|
1060
|
-
function
|
|
1061
|
-
const
|
|
1062
|
-
return
|
|
1195
|
+
function $(e, r) {
|
|
1196
|
+
const t = (e ?? "").toLowerCase();
|
|
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";
|
|
1063
1198
|
}
|
|
1064
|
-
function
|
|
1065
|
-
return typeof e != "string" || !e ? "page" : e.replace(/[-_]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (
|
|
1199
|
+
function H(e) {
|
|
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();
|
|
1066
1201
|
}
|
|
1067
|
-
function
|
|
1202
|
+
function We(e) {
|
|
1068
1203
|
switch (e.kind) {
|
|
1069
1204
|
case "navigation":
|
|
1070
|
-
return `Navigating to ${
|
|
1205
|
+
return `Navigating to ${H(e.arguments?.page)}`;
|
|
1071
1206
|
case "action":
|
|
1072
|
-
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 || H(e.functionName) || "Working";
|
|
1073
1208
|
case "progress":
|
|
1074
1209
|
return e.message || "Working";
|
|
1075
1210
|
case "reasoning":
|
|
@@ -1082,16 +1217,16 @@ function Pe(e) {
|
|
|
1082
1217
|
return e.message || e.toolDisplayName || e.toolName || "Working";
|
|
1083
1218
|
}
|
|
1084
1219
|
}
|
|
1085
|
-
function
|
|
1086
|
-
const { includeReasoning:
|
|
1087
|
-
if (!n) throw new
|
|
1088
|
-
const [s,
|
|
1089
|
-
|
|
1090
|
-
const g = R((
|
|
1091
|
-
|
|
1092
|
-
const v =
|
|
1093
|
-
...v >= 0 ?
|
|
1094
|
-
id:
|
|
1220
|
+
function tt(e = {}) {
|
|
1221
|
+
const { includeReasoning: r = !1, labelFor: t } = e, o = z(), n = e.client || o;
|
|
1222
|
+
if (!n) throw new q("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 = _(/* @__PURE__ */ new Set()), f = _(void 0), d = _(t);
|
|
1224
|
+
d.current = t;
|
|
1225
|
+
const g = R((p, x) => {
|
|
1226
|
+
c((i) => {
|
|
1227
|
+
const v = i.findIndex((h) => h.id === p), u = {
|
|
1228
|
+
...v >= 0 ? i[v] : {
|
|
1229
|
+
id: p,
|
|
1095
1230
|
kind: "status",
|
|
1096
1231
|
label: "",
|
|
1097
1232
|
status: "running",
|
|
@@ -1100,34 +1235,34 @@ function Qe(e = {}) {
|
|
|
1100
1235
|
},
|
|
1101
1236
|
...x
|
|
1102
1237
|
};
|
|
1103
|
-
return
|
|
1104
|
-
...
|
|
1105
|
-
|
|
1106
|
-
...
|
|
1107
|
-
] : [...
|
|
1238
|
+
return u.label = d.current?.(u) ?? We(u), v >= 0 ? [
|
|
1239
|
+
...i.slice(0, v),
|
|
1240
|
+
u,
|
|
1241
|
+
...i.slice(v + 1)
|
|
1242
|
+
] : [...i, u];
|
|
1108
1243
|
});
|
|
1109
1244
|
}, []);
|
|
1110
|
-
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1245
|
+
A(() => {
|
|
1246
|
+
const p = (y) => {
|
|
1247
|
+
f.current = y.messageId;
|
|
1113
1248
|
}, x = (y) => {
|
|
1114
|
-
const
|
|
1115
|
-
|
|
1116
|
-
kind:
|
|
1117
|
-
status:
|
|
1118
|
-
messageId:
|
|
1249
|
+
const m = J(y.type);
|
|
1250
|
+
m === "reasoning" && !r || g(y.id, {
|
|
1251
|
+
kind: m,
|
|
1252
|
+
status: $(y.status, m),
|
|
1253
|
+
messageId: f.current,
|
|
1119
1254
|
toolName: y.toolName,
|
|
1120
1255
|
toolDisplayName: y.toolDisplayName,
|
|
1121
1256
|
message: y.message,
|
|
1122
1257
|
data: y.data,
|
|
1123
1258
|
formSchema: y.formSchema,
|
|
1124
|
-
requiresApproval:
|
|
1259
|
+
requiresApproval: m === "confirmation" || m === "form"
|
|
1125
1260
|
});
|
|
1126
|
-
},
|
|
1261
|
+
}, i = (y) => {
|
|
1127
1262
|
y.invocationId && g(y.invocationId, {
|
|
1128
1263
|
kind: y.functionName === "navigateToPage" ? "navigation" : "action",
|
|
1129
1264
|
status: "running",
|
|
1130
|
-
messageId:
|
|
1265
|
+
messageId: f.current,
|
|
1131
1266
|
functionName: y.functionName,
|
|
1132
1267
|
arguments: y.arguments
|
|
1133
1268
|
});
|
|
@@ -1135,27 +1270,27 @@ function Qe(e = {}) {
|
|
|
1135
1270
|
y.invocationId && g(y.invocationId, {
|
|
1136
1271
|
kind: y.functionName === "navigateToPage" ? "navigation" : "action",
|
|
1137
1272
|
status: "awaiting-approval",
|
|
1138
|
-
messageId:
|
|
1273
|
+
messageId: f.current,
|
|
1139
1274
|
functionName: y.functionName,
|
|
1140
1275
|
arguments: y.arguments,
|
|
1141
1276
|
requiresApproval: !0
|
|
1142
1277
|
});
|
|
1143
|
-
},
|
|
1278
|
+
}, u = (y) => {
|
|
1144
1279
|
if (!y.invocationId) return;
|
|
1145
|
-
const
|
|
1280
|
+
const m = y.result, I = typeof y.result == "object" && m !== null && m.approved === !1 && m.reason === "user_rejected";
|
|
1146
1281
|
g(y.invocationId, {
|
|
1147
1282
|
status: y.error ? "error" : I ? "rejected" : "done",
|
|
1148
1283
|
requiresApproval: !1
|
|
1149
1284
|
});
|
|
1150
1285
|
}, h = (y) => {
|
|
1151
|
-
for (const
|
|
1152
|
-
if (
|
|
1153
|
-
for (const I of
|
|
1154
|
-
const
|
|
1155
|
-
|
|
1156
|
-
kind:
|
|
1157
|
-
status:
|
|
1158
|
-
messageId:
|
|
1286
|
+
for (const m of y.messages ?? [])
|
|
1287
|
+
if (m.role === "assistant")
|
|
1288
|
+
for (const I of m.toolCalls ?? []) {
|
|
1289
|
+
const F = Pe(I);
|
|
1290
|
+
F === "reasoning" && !r || /waiting/i.test(I.status ?? "") || g(I.id, {
|
|
1291
|
+
kind: F,
|
|
1292
|
+
status: $(I.status, F),
|
|
1293
|
+
messageId: m.id,
|
|
1159
1294
|
toolName: I.toolName,
|
|
1160
1295
|
toolDisplayName: I.toolDisplayName,
|
|
1161
1296
|
functionName: I.functionName,
|
|
@@ -1163,144 +1298,144 @@ function Qe(e = {}) {
|
|
|
1163
1298
|
message: I.message,
|
|
1164
1299
|
data: I.data,
|
|
1165
1300
|
formSchema: I.formSchema,
|
|
1166
|
-
requiresApproval:
|
|
1301
|
+
requiresApproval: F === "confirmation" || F === "form"
|
|
1167
1302
|
});
|
|
1168
1303
|
}
|
|
1169
1304
|
}, w = (y) => {
|
|
1170
|
-
|
|
1305
|
+
c((m) => m.map((I) => I.status === "running" || I.status === "awaiting-approval" ? {
|
|
1171
1306
|
...I,
|
|
1172
1307
|
status: y
|
|
1173
1308
|
} : I));
|
|
1174
|
-
}, b = () => w("done"),
|
|
1175
|
-
return n.on("message:start",
|
|
1176
|
-
n.off("message:start",
|
|
1309
|
+
}, b = () => w("done"), T = () => w("error");
|
|
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
|
+
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);
|
|
1177
1312
|
};
|
|
1178
1313
|
}, [
|
|
1179
1314
|
n,
|
|
1180
|
-
|
|
1315
|
+
r,
|
|
1181
1316
|
g
|
|
1182
1317
|
]);
|
|
1183
|
-
const C = R(async (
|
|
1184
|
-
const x = s.find((
|
|
1185
|
-
!x || x.status !== "awaiting-approval" ||
|
|
1318
|
+
const C = R(async (p) => {
|
|
1319
|
+
const x = s.find((i) => i.id === p);
|
|
1320
|
+
!x || x.status !== "awaiting-approval" || a.current.has(p) || x.kind !== "form" && (a.current.add(p), g(p, {
|
|
1186
1321
|
status: "running",
|
|
1187
1322
|
requiresApproval: !1
|
|
1188
|
-
}), x.functionName ? await n.approveFunction(
|
|
1323
|
+
}), x.functionName ? await n.approveFunction(p) : await n.confirmToolCall(p));
|
|
1189
1324
|
}, [
|
|
1190
1325
|
n,
|
|
1191
1326
|
s,
|
|
1192
1327
|
g
|
|
1193
|
-
]),
|
|
1194
|
-
const x = s.find((
|
|
1195
|
-
!x || x.status !== "awaiting-approval" ||
|
|
1328
|
+
]), N = R(async (p) => {
|
|
1329
|
+
const x = s.find((i) => i.id === p);
|
|
1330
|
+
!x || x.status !== "awaiting-approval" || a.current.has(p) || (a.current.add(p), g(p, {
|
|
1196
1331
|
status: "rejected",
|
|
1197
1332
|
requiresApproval: !1
|
|
1198
|
-
}), x.functionName ? await n.rejectFunction(
|
|
1333
|
+
}), x.functionName ? await n.rejectFunction(p) : await n.rejectToolCall(p));
|
|
1199
1334
|
}, [
|
|
1200
1335
|
n,
|
|
1201
1336
|
s,
|
|
1202
1337
|
g
|
|
1203
|
-
]), S = R(async (
|
|
1204
|
-
g(
|
|
1338
|
+
]), S = R(async (p, x) => {
|
|
1339
|
+
g(p, {
|
|
1205
1340
|
status: "running",
|
|
1206
1341
|
requiresApproval: !1
|
|
1207
|
-
}), await n.submitToolCallForm(
|
|
1342
|
+
}), await n.submitToolCallForm(p, x), g(p, { status: "done" });
|
|
1208
1343
|
}, [n, g]), k = R(() => {
|
|
1209
|
-
|
|
1344
|
+
a.current.clear(), c([]);
|
|
1210
1345
|
}, []);
|
|
1211
1346
|
return {
|
|
1212
1347
|
items: s,
|
|
1213
1348
|
latest: s.length > 0 ? s[s.length - 1] : void 0,
|
|
1214
|
-
isAwaitingApproval: s.some((
|
|
1349
|
+
isAwaitingApproval: s.some((p) => Te.has(p.status)),
|
|
1215
1350
|
approve: C,
|
|
1216
|
-
reject:
|
|
1351
|
+
reject: N,
|
|
1217
1352
|
submitForm: S,
|
|
1218
1353
|
clear: k
|
|
1219
1354
|
};
|
|
1220
1355
|
}
|
|
1221
|
-
function
|
|
1222
|
-
const
|
|
1356
|
+
function nt(e, r) {
|
|
1357
|
+
const t = D(), o = ae(), n = r ?? o, s = _(e);
|
|
1223
1358
|
s.current = e;
|
|
1224
|
-
const
|
|
1225
|
-
|
|
1359
|
+
const c = typeof e == "function";
|
|
1360
|
+
A(() => {
|
|
1226
1361
|
if (typeof s.current == "function") {
|
|
1227
|
-
const
|
|
1228
|
-
return
|
|
1229
|
-
|
|
1362
|
+
const a = () => s.current();
|
|
1363
|
+
return t.addDynamicContext(n, a), () => {
|
|
1364
|
+
t.removeDynamicContext(n);
|
|
1230
1365
|
};
|
|
1231
1366
|
}
|
|
1232
|
-
return
|
|
1233
|
-
|
|
1367
|
+
return t.setContext(n, s.current), () => {
|
|
1368
|
+
t.removeContext(n);
|
|
1234
1369
|
};
|
|
1235
1370
|
}, [
|
|
1236
|
-
|
|
1371
|
+
t,
|
|
1237
1372
|
n,
|
|
1238
|
-
|
|
1239
|
-
|
|
1373
|
+
c,
|
|
1374
|
+
c ? "" : JSON.stringify(e)
|
|
1240
1375
|
]);
|
|
1241
1376
|
}
|
|
1242
1377
|
function De(e) {
|
|
1243
1378
|
return se(e.subscribe, e.get, e.get);
|
|
1244
1379
|
}
|
|
1245
|
-
var
|
|
1380
|
+
var O = {
|
|
1246
1381
|
missing: [],
|
|
1247
1382
|
complete: !1
|
|
1248
1383
|
};
|
|
1249
|
-
function
|
|
1250
|
-
const
|
|
1251
|
-
|
|
1384
|
+
function rt(e) {
|
|
1385
|
+
const r = D(), 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 = W(() => t ? B(e) : null, [
|
|
1386
|
+
t,
|
|
1252
1387
|
e.name,
|
|
1253
1388
|
o,
|
|
1254
1389
|
s,
|
|
1255
|
-
|
|
1390
|
+
c,
|
|
1256
1391
|
e.autoSubmit
|
|
1257
|
-
]), [
|
|
1392
|
+
]), [f, d] = E({
|
|
1258
1393
|
collector: null,
|
|
1259
|
-
loading: !
|
|
1394
|
+
loading: !t,
|
|
1260
1395
|
error: null
|
|
1261
1396
|
});
|
|
1262
|
-
|
|
1263
|
-
if (
|
|
1397
|
+
A(() => {
|
|
1398
|
+
if (t) return;
|
|
1264
1399
|
let v = !1;
|
|
1265
|
-
return
|
|
1400
|
+
return d({
|
|
1266
1401
|
collector: null,
|
|
1267
1402
|
loading: !0,
|
|
1268
1403
|
error: null
|
|
1269
|
-
}),
|
|
1270
|
-
v ||
|
|
1271
|
-
collector:
|
|
1404
|
+
}), j(r, e).then((u) => {
|
|
1405
|
+
v || d({
|
|
1406
|
+
collector: u,
|
|
1272
1407
|
loading: !1,
|
|
1273
1408
|
error: null
|
|
1274
1409
|
});
|
|
1275
|
-
}).catch((
|
|
1276
|
-
v ||
|
|
1410
|
+
}).catch((u) => {
|
|
1411
|
+
v || d({
|
|
1277
1412
|
collector: null,
|
|
1278
1413
|
loading: !1,
|
|
1279
|
-
error:
|
|
1414
|
+
error: u instanceof Error ? u : new Error(String(u))
|
|
1280
1415
|
});
|
|
1281
1416
|
}), () => {
|
|
1282
1417
|
v = !0;
|
|
1283
1418
|
};
|
|
1284
1419
|
}, [
|
|
1285
|
-
t,
|
|
1286
1420
|
r,
|
|
1421
|
+
t,
|
|
1287
1422
|
e.name,
|
|
1288
1423
|
s,
|
|
1289
|
-
|
|
1424
|
+
c,
|
|
1290
1425
|
e.autoSubmit
|
|
1291
1426
|
]);
|
|
1292
|
-
const g =
|
|
1293
|
-
|
|
1427
|
+
const g = t ? a : f.collector, C = t ? !1 : f.loading, N = t ? null : f.error;
|
|
1428
|
+
A(() => {
|
|
1294
1429
|
if (g)
|
|
1295
|
-
return g.install(
|
|
1296
|
-
}, [
|
|
1297
|
-
const S =
|
|
1430
|
+
return g.install(r);
|
|
1431
|
+
}, [r, g]);
|
|
1432
|
+
const S = W(() => X({
|
|
1298
1433
|
values: e.initialValues ?? {},
|
|
1299
1434
|
submitted: !1
|
|
1300
|
-
}), [
|
|
1435
|
+
}), [c]), k = De(g?.store ?? S), p = W(() => g?.getStatus() ?? O, [k, g]), x = W(() => ({
|
|
1301
1436
|
...k,
|
|
1302
|
-
...
|
|
1303
|
-
}), [k,
|
|
1437
|
+
...p
|
|
1438
|
+
}), [k, p]), i = W(() => ({
|
|
1304
1439
|
name: e.name,
|
|
1305
1440
|
store: S,
|
|
1306
1441
|
functions: [],
|
|
@@ -1328,37 +1463,39 @@ function tt(e) {
|
|
|
1328
1463
|
},
|
|
1329
1464
|
reset: () => {
|
|
1330
1465
|
},
|
|
1331
|
-
getStatus: () =>
|
|
1466
|
+
getStatus: () => O
|
|
1332
1467
|
}), [e.name, S]);
|
|
1333
1468
|
return {
|
|
1334
|
-
...g ??
|
|
1469
|
+
...g ?? i,
|
|
1335
1470
|
state: x,
|
|
1336
1471
|
loading: C,
|
|
1337
|
-
error:
|
|
1472
|
+
error: N
|
|
1338
1473
|
};
|
|
1339
1474
|
}
|
|
1340
1475
|
export {
|
|
1476
|
+
Ve as AgoNudge,
|
|
1341
1477
|
Ke as AgoProvider,
|
|
1342
1478
|
de as ChatInput,
|
|
1343
|
-
|
|
1479
|
+
Je as ChatWidget,
|
|
1344
1480
|
Ae as Markdown,
|
|
1345
|
-
|
|
1346
|
-
|
|
1481
|
+
Me as Message,
|
|
1482
|
+
B as createFormCollector,
|
|
1347
1483
|
qe as createMockClient,
|
|
1348
1484
|
He as deriveFormStatus,
|
|
1349
|
-
|
|
1485
|
+
j as loadFormCollector,
|
|
1350
1486
|
ce as useAgo,
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1487
|
+
tt as useAgoActivity,
|
|
1488
|
+
et as useAgoAutoContinueAfterNavigation,
|
|
1489
|
+
D as useAgoClient,
|
|
1490
|
+
nt as useAgoContext,
|
|
1491
|
+
Xe as useAgoFunction,
|
|
1492
|
+
Ze as useAgoNavigation,
|
|
1493
|
+
Qe as useAgoPageState,
|
|
1358
1494
|
De as useAgoStore,
|
|
1359
|
-
|
|
1495
|
+
Ye as useChat,
|
|
1360
1496
|
Fe as useConversation,
|
|
1361
|
-
|
|
1497
|
+
rt as useFormCollector,
|
|
1362
1498
|
K as useMessages,
|
|
1363
|
-
|
|
1499
|
+
z as useOptionalAgoClient,
|
|
1500
|
+
_e as useProactiveNudge
|
|
1364
1501
|
};
|