@useago/sdk 1.0.10 → 1.1.0
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-QcTtrN7u.js → AgoClient-Cwx_eYSu.js} +182 -131
- package/dist/AgoClient-CzSmJQxl.cjs +6 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +23 -0
- package/dist/angular.d.ts +23 -0
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-CR-71aLR.js → createConversationSession-B3h567tt.js} +1 -1
- package/dist/{createConversationSession-C0diFTUk.cjs → createConversationSession-DV0Xp_3O.cjs} +1 -1
- package/dist/{createFormCollector-BI3DXaew.cjs → createFormCollector-BB3Uscuo.cjs} +1 -1
- package/dist/{createFormCollector-CFt1_QSL.js → createFormCollector-CyWisAkI.js} +1 -1
- package/dist/devtools.d.cts +23 -0
- package/dist/devtools.d.ts +23 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +43 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +58 -55
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +23 -0
- package/dist/react.d.ts +23 -0
- package/dist/react.js +482 -367
- package/dist/testing.d.cts +23 -0
- package/dist/testing.d.ts +23 -0
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +119 -0
- package/dist/vue.d.ts +119 -0
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +48 -2
- package/dist/widget.d.ts +48 -2
- package/dist/widget.js +538 -417
- package/package.json +1 -1
- package/dist/AgoClient-B3-WGVne.cjs +0 -6
package/dist/react.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as
|
|
3
|
-
import { t as
|
|
4
|
-
import
|
|
5
|
-
import { Fragment as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
function
|
|
9
|
-
const [t, r] = M(!1), n =
|
|
1
|
+
import { a as J, i as j, o as G, s as V, t as Y } from "./AgoClient-Cwx_eYSu.js";
|
|
2
|
+
import { i as X, n as Fe, r as H, t as L } from "./createFormCollector-CyWisAkI.js";
|
|
3
|
+
import { t as _e } from "./createMockClient-DwdxNwEn.js";
|
|
4
|
+
import Q, { createContext as Z, useCallback as R, useContext as $, useEffect as k, useId as ee, useMemo as _, useRef as A, useState as M, useSyncExternalStore as te } from "react";
|
|
5
|
+
import { Fragment as O, jsx as o, jsxs as I } from "react/jsx-runtime";
|
|
6
|
+
import ne from "react-markdown";
|
|
7
|
+
import re from "remark-gfm";
|
|
8
|
+
function oe(e) {
|
|
9
|
+
const [t, r] = M(!1), n = A(null), a = _(() => {
|
|
10
10
|
if (n.current && (n.current.destroy(), n.current = null), !e) return null;
|
|
11
|
-
const
|
|
12
|
-
return n.current =
|
|
11
|
+
const i = new Y(e);
|
|
12
|
+
return n.current = i, i;
|
|
13
13
|
}, [e?.baseUrl, e?.widgetId]);
|
|
14
|
-
return
|
|
14
|
+
return k(() => (r(!0), () => {
|
|
15
15
|
n.current?.destroy(), n.current = null;
|
|
16
|
-
}), [
|
|
16
|
+
}), [a]), k(() => {
|
|
17
17
|
n.current && e && n.current.updateConfig({
|
|
18
18
|
agent: e.agent,
|
|
19
19
|
defaultAgentId: e.defaultAgentId,
|
|
@@ -32,180 +32,187 @@ function ee(e) {
|
|
|
32
32
|
e?.debug,
|
|
33
33
|
e?.warnOnEmptyReply
|
|
34
34
|
]), {
|
|
35
|
-
client:
|
|
35
|
+
client: a,
|
|
36
36
|
isReady: t
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
var D =
|
|
40
|
-
const { client:
|
|
41
|
-
return
|
|
39
|
+
var D = Z(null), Pe = ({ children: e, client: t, tools: r, helpers: n, pageContext: a, ...i }) => {
|
|
40
|
+
const { client: u } = oe(t ? null : i), l = t || u;
|
|
41
|
+
return k(() => {
|
|
42
42
|
if (!(!r || r.length === 0)) {
|
|
43
|
-
for (const f of r)
|
|
43
|
+
for (const f of r) l.register(f);
|
|
44
44
|
return () => {
|
|
45
|
-
for (const f of r)
|
|
45
|
+
for (const f of r) l.unregisterFunction(f.name);
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
}, [
|
|
48
|
+
}, [l, r]), k(() => {
|
|
49
49
|
if (!n) return;
|
|
50
50
|
const f = [];
|
|
51
51
|
return import("./functions-CApuQZ2b.js").then((c) => c.n).then((c) => {
|
|
52
|
-
for (const [
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
55
|
-
console.warn(`[AGO] Unknown helper: "${
|
|
52
|
+
for (const [b, m] of Object.entries(n)) {
|
|
53
|
+
const C = c[b];
|
|
54
|
+
if (!C) {
|
|
55
|
+
console.warn(`[AGO] Unknown helper: "${b}"`);
|
|
56
56
|
continue;
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
...
|
|
60
|
-
handler:
|
|
58
|
+
const g = m === !0 ? C : {
|
|
59
|
+
...C,
|
|
60
|
+
handler: m
|
|
61
61
|
};
|
|
62
|
-
|
|
62
|
+
l.register(g), f.push(g.name);
|
|
63
63
|
}
|
|
64
64
|
}), () => {
|
|
65
|
-
for (const c of f)
|
|
65
|
+
for (const c of f) l.unregisterFunction(c);
|
|
66
66
|
};
|
|
67
|
-
}, [
|
|
68
|
-
|
|
69
|
-
}, [
|
|
70
|
-
value:
|
|
67
|
+
}, [l, n]), k(() => {
|
|
68
|
+
a === "auto" && l.enableAutoPageContext();
|
|
69
|
+
}, [l, a]), /* @__PURE__ */ o(D.Provider, {
|
|
70
|
+
value: l,
|
|
71
71
|
children: e
|
|
72
72
|
});
|
|
73
73
|
};
|
|
74
|
-
function
|
|
75
|
-
const e =
|
|
74
|
+
function T() {
|
|
75
|
+
const e = $(D);
|
|
76
76
|
if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
|
|
77
77
|
return e;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
return
|
|
79
|
+
function W() {
|
|
80
|
+
return $(D);
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
const r =
|
|
82
|
+
function B({ client: e, conversationId: t } = {}) {
|
|
83
|
+
const r = W(), n = e || r;
|
|
84
84
|
if (!n) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
85
|
-
const [
|
|
86
|
-
|
|
87
|
-
t && t !==
|
|
85
|
+
const [a, i] = M([]), [u, l] = M(t), [f, c] = M(!1), [b, m] = M(null);
|
|
86
|
+
k(() => {
|
|
87
|
+
t && t !== u && (l(t), C(t));
|
|
88
88
|
}, [t]);
|
|
89
|
-
const
|
|
89
|
+
const C = async (g) => {
|
|
90
90
|
try {
|
|
91
|
-
|
|
92
|
-
} catch (
|
|
93
|
-
|
|
91
|
+
i(await n.getMessages(g));
|
|
92
|
+
} catch (x) {
|
|
93
|
+
m(x instanceof Error ? x : /* @__PURE__ */ new Error("Failed to load messages"));
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
return
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
return
|
|
103
|
-
...
|
|
104
|
-
content:
|
|
105
|
-
}] :
|
|
96
|
+
return k(() => {
|
|
97
|
+
const g = (p) => {
|
|
98
|
+
u || l(p.conversationId);
|
|
99
|
+
}, x = (p) => {
|
|
100
|
+
i((d) => {
|
|
101
|
+
const h = d[d.length - 1];
|
|
102
|
+
return h && h.id === p.messageId ? [...d.slice(0, -1), {
|
|
103
|
+
...h,
|
|
104
|
+
content: h.content + p.content
|
|
105
|
+
}] : d;
|
|
106
106
|
});
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
let
|
|
110
|
-
for (let
|
|
111
|
-
|
|
107
|
+
}, v = (p) => {
|
|
108
|
+
i((d) => {
|
|
109
|
+
let h = -1;
|
|
110
|
+
for (let S = d.length - 1; S >= 0; S--) if (d[S].role === "assistant" && d[S].status === "IN_PROGRESS") {
|
|
111
|
+
h = S;
|
|
112
112
|
break;
|
|
113
113
|
}
|
|
114
|
-
return
|
|
115
|
-
...
|
|
114
|
+
return h < 0 ? d : [
|
|
115
|
+
...d.slice(0, h),
|
|
116
116
|
{
|
|
117
|
-
...
|
|
118
|
-
...
|
|
117
|
+
...d[h],
|
|
118
|
+
...p
|
|
119
119
|
},
|
|
120
|
-
...
|
|
120
|
+
...d.slice(h + 1)
|
|
121
121
|
];
|
|
122
122
|
});
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
return
|
|
127
|
-
...
|
|
128
|
-
|
|
129
|
-
...
|
|
130
|
-
] : [...
|
|
123
|
+
}, w = (p) => {
|
|
124
|
+
i((d) => {
|
|
125
|
+
const h = d.findIndex((S) => S.id === p.id);
|
|
126
|
+
return h >= 0 ? [
|
|
127
|
+
...d.slice(0, h),
|
|
128
|
+
p,
|
|
129
|
+
...d.slice(h + 1)
|
|
130
|
+
] : [...d, p];
|
|
131
131
|
}), c(!1);
|
|
132
|
-
},
|
|
133
|
-
|
|
132
|
+
}, s = (p) => {
|
|
133
|
+
m(new Error(p.error)), c(!1);
|
|
134
134
|
};
|
|
135
|
-
return n.on("message:start",
|
|
136
|
-
n.off("message:start",
|
|
135
|
+
return n.on("message:start", g), n.on("message:chunk", x), n.on("message:answer-complete", v), n.on("message:complete", w), n.on("message:error", s), () => {
|
|
136
|
+
n.off("message:start", g), n.off("message:chunk", x), n.off("message:answer-complete", v), n.off("message:complete", w), n.off("message:error", s);
|
|
137
137
|
};
|
|
138
|
-
}, [n,
|
|
139
|
-
messages:
|
|
138
|
+
}, [n, u]), {
|
|
139
|
+
messages: a,
|
|
140
140
|
isLoading: f,
|
|
141
|
-
error:
|
|
142
|
-
sendMessage:
|
|
143
|
-
c(!0),
|
|
144
|
-
const
|
|
141
|
+
error: b,
|
|
142
|
+
sendMessage: R(async (g, x) => {
|
|
143
|
+
c(!0), m(null);
|
|
144
|
+
const v = {
|
|
145
145
|
id: `temp-${Date.now()}`,
|
|
146
|
-
conversationId:
|
|
147
|
-
content:
|
|
146
|
+
conversationId: u || "",
|
|
147
|
+
content: g,
|
|
148
148
|
role: "user",
|
|
149
149
|
status: "DONE",
|
|
150
|
+
attachments: x && x.length > 0 ? j(x) : void 0,
|
|
150
151
|
createdAt: /* @__PURE__ */ new Date()
|
|
151
|
-
},
|
|
152
|
+
}, w = {
|
|
152
153
|
id: `temp-assistant-${Date.now()}`,
|
|
153
|
-
conversationId:
|
|
154
|
+
conversationId: u || "",
|
|
154
155
|
content: "",
|
|
155
156
|
role: "assistant",
|
|
156
157
|
status: "IN_PROGRESS",
|
|
157
158
|
createdAt: /* @__PURE__ */ new Date()
|
|
158
159
|
};
|
|
159
|
-
|
|
160
|
-
...
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
i((s) => [
|
|
161
|
+
...s,
|
|
162
|
+
v,
|
|
163
|
+
w
|
|
163
164
|
]);
|
|
164
165
|
try {
|
|
165
|
-
const
|
|
166
|
-
conversationId:
|
|
167
|
-
files:
|
|
166
|
+
const s = await n.sendMessage(g, {
|
|
167
|
+
conversationId: u,
|
|
168
|
+
files: x
|
|
168
169
|
});
|
|
169
|
-
return
|
|
170
|
-
const
|
|
171
|
-
...
|
|
172
|
-
id:
|
|
173
|
-
conversationId:
|
|
170
|
+
return s.conversationId && !u && l(s.conversationId), i((p) => {
|
|
171
|
+
const d = p.filter((S) => !S.id.startsWith("temp-")), h = {
|
|
172
|
+
...v,
|
|
173
|
+
id: v.id.replace("temp-", "user-"),
|
|
174
|
+
conversationId: s.conversationId
|
|
174
175
|
};
|
|
175
|
-
return
|
|
176
|
-
...
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
return d.some((S) => S.id === s.id) ? [...d, h].sort((S, z) => new Date(S.createdAt).getTime() - new Date(z.createdAt).getTime()) : [
|
|
177
|
+
...d,
|
|
178
|
+
h,
|
|
179
|
+
s
|
|
179
180
|
];
|
|
180
|
-
}),
|
|
181
|
-
} catch (
|
|
182
|
-
return
|
|
181
|
+
}), s;
|
|
182
|
+
} catch (s) {
|
|
183
|
+
return m(s instanceof Error ? s : /* @__PURE__ */ new Error("Failed to send message")), c(!1), i((p) => p.filter((d) => !d.id.startsWith("temp-"))), null;
|
|
183
184
|
}
|
|
184
|
-
}, [n,
|
|
185
|
-
clearMessages:
|
|
186
|
-
|
|
185
|
+
}, [n, u]),
|
|
186
|
+
clearMessages: R(() => {
|
|
187
|
+
i([]), l(void 0), m(null);
|
|
187
188
|
}, []),
|
|
188
|
-
conversationId:
|
|
189
|
+
conversationId: u
|
|
189
190
|
};
|
|
190
191
|
}
|
|
191
|
-
var
|
|
192
|
-
const [
|
|
193
|
-
|
|
192
|
+
var ae = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", allowFiles: n = !1, className: a = "" }) => {
|
|
193
|
+
const [i, u] = M(""), [l, f] = M([]), c = A(null), b = A(null), m = R(() => {
|
|
194
|
+
const s = b.current;
|
|
195
|
+
if (!s) return;
|
|
196
|
+
const p = 110;
|
|
197
|
+
s.style.height = "auto", s.style.height = `${Math.min(s.scrollHeight + 2, p)}px`, s.style.overflowY = s.scrollHeight + 2 > p ? "auto" : "hidden";
|
|
198
|
+
}, []), C = R((s) => {
|
|
199
|
+
s.preventDefault(), (i.trim() || l.length > 0) && (e(i.trim(), l.length > 0 ? l : void 0), u(""), f([]), requestAnimationFrame(m));
|
|
194
200
|
}, [
|
|
195
|
-
a,
|
|
196
201
|
i,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
f((
|
|
205
|
-
}, []),
|
|
202
|
+
l,
|
|
203
|
+
e,
|
|
204
|
+
m
|
|
205
|
+
]), g = R((s) => {
|
|
206
|
+
s.key === "Enter" && !s.shiftKey && (s.preventDefault(), C(s));
|
|
207
|
+
}, [C]), x = R((s) => {
|
|
208
|
+
const p = Array.from(s.target.files || []);
|
|
209
|
+
f((d) => [...d, ...p]);
|
|
210
|
+
}, []), v = R((s) => {
|
|
211
|
+
f((p) => p.filter((d, h) => h !== s));
|
|
212
|
+
}, []), w = i.trim() || l.length > 0;
|
|
206
213
|
return /* @__PURE__ */ I("form", {
|
|
207
|
-
onSubmit:
|
|
208
|
-
className: `ago-chat-input ${
|
|
214
|
+
onSubmit: C,
|
|
215
|
+
className: `ago-chat-input ${a}`,
|
|
209
216
|
style: {
|
|
210
217
|
display: "flex",
|
|
211
218
|
flexDirection: "column",
|
|
@@ -214,14 +221,14 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
214
221
|
borderTop: "1px solid #dee3e8",
|
|
215
222
|
backgroundColor: "#fff"
|
|
216
223
|
},
|
|
217
|
-
children: [
|
|
224
|
+
children: [l.length > 0 && /* @__PURE__ */ o("div", {
|
|
218
225
|
className: "ago-chat-input__files",
|
|
219
226
|
style: {
|
|
220
227
|
display: "flex",
|
|
221
228
|
flexWrap: "wrap",
|
|
222
229
|
gap: "6px"
|
|
223
230
|
},
|
|
224
|
-
children:
|
|
231
|
+
children: l.map((s, p) => /* @__PURE__ */ I("div", {
|
|
225
232
|
style: {
|
|
226
233
|
display: "flex",
|
|
227
234
|
alignItems: "center",
|
|
@@ -232,17 +239,18 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
232
239
|
fontSize: "12px",
|
|
233
240
|
color: "#30373e"
|
|
234
241
|
},
|
|
235
|
-
children: [/* @__PURE__ */
|
|
242
|
+
children: [/* @__PURE__ */ o("span", {
|
|
236
243
|
style: {
|
|
237
244
|
maxWidth: "120px",
|
|
238
245
|
overflow: "hidden",
|
|
239
246
|
textOverflow: "ellipsis",
|
|
240
247
|
whiteSpace: "nowrap"
|
|
241
248
|
},
|
|
242
|
-
children:
|
|
243
|
-
}), /* @__PURE__ */
|
|
249
|
+
children: s.name
|
|
250
|
+
}), /* @__PURE__ */ o("button", {
|
|
244
251
|
type: "button",
|
|
245
|
-
onClick: () =>
|
|
252
|
+
onClick: () => v(p),
|
|
253
|
+
"aria-label": `Remove ${s.name}`,
|
|
246
254
|
style: {
|
|
247
255
|
border: "none",
|
|
248
256
|
background: "none",
|
|
@@ -254,7 +262,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
254
262
|
},
|
|
255
263
|
children: "×"
|
|
256
264
|
})]
|
|
257
|
-
},
|
|
265
|
+
}, p))
|
|
258
266
|
}), /* @__PURE__ */ I("div", {
|
|
259
267
|
style: {
|
|
260
268
|
display: "flex",
|
|
@@ -262,10 +270,11 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
262
270
|
alignItems: "flex-end"
|
|
263
271
|
},
|
|
264
272
|
children: [
|
|
265
|
-
n && /* @__PURE__ */ I(
|
|
273
|
+
n && /* @__PURE__ */ I(O, { children: [/* @__PURE__ */ o("button", {
|
|
266
274
|
type: "button",
|
|
267
275
|
onClick: () => c.current?.click(),
|
|
268
276
|
disabled: t,
|
|
277
|
+
"aria-label": "Attach file",
|
|
269
278
|
style: {
|
|
270
279
|
padding: "8px",
|
|
271
280
|
border: "1px solid #dee3e8",
|
|
@@ -277,18 +286,22 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
277
286
|
lineHeight: 1
|
|
278
287
|
},
|
|
279
288
|
children: "+"
|
|
280
|
-
}), /* @__PURE__ */
|
|
289
|
+
}), /* @__PURE__ */ o("input", {
|
|
281
290
|
ref: c,
|
|
282
291
|
type: "file",
|
|
283
292
|
multiple: !0,
|
|
284
|
-
onChange:
|
|
293
|
+
onChange: x,
|
|
285
294
|
style: { display: "none" }
|
|
286
295
|
})] }),
|
|
287
|
-
/* @__PURE__ */
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
296
|
+
/* @__PURE__ */ o("textarea", {
|
|
297
|
+
ref: b,
|
|
298
|
+
value: i,
|
|
299
|
+
onChange: (s) => {
|
|
300
|
+
u(s.target.value), m();
|
|
301
|
+
},
|
|
302
|
+
onKeyDown: g,
|
|
291
303
|
placeholder: r,
|
|
304
|
+
"aria-label": r,
|
|
292
305
|
disabled: t,
|
|
293
306
|
rows: 1,
|
|
294
307
|
style: {
|
|
@@ -298,29 +311,33 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
298
311
|
borderRadius: "20px",
|
|
299
312
|
resize: "none",
|
|
300
313
|
outline: "none",
|
|
314
|
+
boxSizing: "border-box",
|
|
315
|
+
maxHeight: "110px",
|
|
316
|
+
overflowY: "hidden",
|
|
301
317
|
fontFamily: "inherit",
|
|
302
318
|
fontSize: "16px",
|
|
319
|
+
lineHeight: 1.4,
|
|
303
320
|
color: "#30373e",
|
|
304
321
|
backgroundColor: "#f8f8f8",
|
|
305
322
|
transition: "border-color 0.15s"
|
|
306
323
|
},
|
|
307
|
-
onFocus: (
|
|
308
|
-
|
|
324
|
+
onFocus: (s) => {
|
|
325
|
+
s.currentTarget.style.borderColor = "#1b5fc4";
|
|
309
326
|
},
|
|
310
|
-
onBlur: (
|
|
311
|
-
|
|
327
|
+
onBlur: (s) => {
|
|
328
|
+
s.currentTarget.style.borderColor = "#dee3e8";
|
|
312
329
|
}
|
|
313
330
|
}),
|
|
314
|
-
/* @__PURE__ */
|
|
331
|
+
/* @__PURE__ */ o("button", {
|
|
315
332
|
type: "submit",
|
|
316
|
-
disabled: t || !
|
|
333
|
+
disabled: t || !w,
|
|
317
334
|
style: {
|
|
318
335
|
padding: "10px 18px",
|
|
319
336
|
border: "none",
|
|
320
337
|
borderRadius: "20px",
|
|
321
|
-
backgroundColor: t || !
|
|
338
|
+
backgroundColor: t || !w ? "#b5bfc8" : "#03182f",
|
|
322
339
|
color: "#fff",
|
|
323
|
-
cursor: t || !
|
|
340
|
+
cursor: t || !w ? "not-allowed" : "pointer",
|
|
324
341
|
fontWeight: 500,
|
|
325
342
|
fontSize: "16px",
|
|
326
343
|
transition: "background-color 0.15s"
|
|
@@ -330,7 +347,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
330
347
|
]
|
|
331
348
|
})]
|
|
332
349
|
});
|
|
333
|
-
},
|
|
350
|
+
}, se = ({ href: e, children: t, ...r }) => /* @__PURE__ */ o("a", {
|
|
334
351
|
href: e,
|
|
335
352
|
target: "_blank",
|
|
336
353
|
rel: "noopener noreferrer",
|
|
@@ -340,7 +357,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
340
357
|
},
|
|
341
358
|
...r,
|
|
342
359
|
children: t
|
|
343
|
-
}),
|
|
360
|
+
}), ie = ({ children: e, ...t }) => /* @__PURE__ */ o("p", {
|
|
344
361
|
style: {
|
|
345
362
|
margin: "0 0 8px 0",
|
|
346
363
|
lineHeight: "1.6"
|
|
@@ -348,17 +365,17 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
348
365
|
...t,
|
|
349
366
|
children: e
|
|
350
367
|
}), N = (e, t) => {
|
|
351
|
-
const r = ({ children: n, ...
|
|
368
|
+
const r = ({ children: n, ...a }) => Q.createElement(`h${e}`, {
|
|
352
369
|
style: {
|
|
353
370
|
margin: "16px 0 8px 0",
|
|
354
371
|
fontSize: t,
|
|
355
372
|
fontWeight: 600,
|
|
356
373
|
lineHeight: "1.3"
|
|
357
374
|
},
|
|
358
|
-
...
|
|
375
|
+
...a
|
|
359
376
|
}, n);
|
|
360
377
|
return r.displayName = `MarkdownHeading${e}`, r;
|
|
361
|
-
},
|
|
378
|
+
}, le = ({ children: e, ...t }) => /* @__PURE__ */ o("ul", {
|
|
362
379
|
style: {
|
|
363
380
|
margin: "0 0 8px 0",
|
|
364
381
|
paddingLeft: "20px",
|
|
@@ -367,7 +384,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
367
384
|
},
|
|
368
385
|
...t,
|
|
369
386
|
children: e
|
|
370
|
-
}),
|
|
387
|
+
}), de = ({ children: e, ...t }) => /* @__PURE__ */ o("ol", {
|
|
371
388
|
style: {
|
|
372
389
|
margin: "0 0 8px 0",
|
|
373
390
|
paddingLeft: "20px",
|
|
@@ -376,7 +393,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
376
393
|
},
|
|
377
394
|
...t,
|
|
378
395
|
children: e
|
|
379
|
-
}),
|
|
396
|
+
}), ce = ({ children: e, ...t }) => /* @__PURE__ */ o("li", {
|
|
380
397
|
style: {
|
|
381
398
|
display: "list-item",
|
|
382
399
|
margin: "2px 0",
|
|
@@ -384,8 +401,8 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
384
401
|
},
|
|
385
402
|
...t,
|
|
386
403
|
children: e
|
|
387
|
-
}),
|
|
388
|
-
`) ? /* @__PURE__ */
|
|
404
|
+
}), ue = ({ className: e, children: t, ...r }) => e !== void 0 || String(t).includes(`
|
|
405
|
+
`) ? /* @__PURE__ */ o("code", {
|
|
389
406
|
style: {
|
|
390
407
|
display: "block",
|
|
391
408
|
background: "#f5f5f5",
|
|
@@ -397,7 +414,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
397
414
|
},
|
|
398
415
|
...r,
|
|
399
416
|
children: t
|
|
400
|
-
}) : /* @__PURE__ */
|
|
417
|
+
}) : /* @__PURE__ */ o("code", {
|
|
401
418
|
style: {
|
|
402
419
|
background: "#f0f2f5",
|
|
403
420
|
padding: "2px 5px",
|
|
@@ -407,11 +424,11 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
407
424
|
},
|
|
408
425
|
...r,
|
|
409
426
|
children: t
|
|
410
|
-
}),
|
|
427
|
+
}), pe = ({ children: e, ...t }) => /* @__PURE__ */ o("pre", {
|
|
411
428
|
style: { margin: "0 0 8px 0" },
|
|
412
429
|
...t,
|
|
413
430
|
children: e
|
|
414
|
-
}),
|
|
431
|
+
}), fe = ({ children: e, ...t }) => /* @__PURE__ */ o("blockquote", {
|
|
415
432
|
style: {
|
|
416
433
|
borderLeft: "4px solid #dee3e8",
|
|
417
434
|
paddingLeft: "12px",
|
|
@@ -421,12 +438,12 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
421
438
|
},
|
|
422
439
|
...t,
|
|
423
440
|
children: e
|
|
424
|
-
}),
|
|
441
|
+
}), ge = ({ children: e, ...t }) => /* @__PURE__ */ o("div", {
|
|
425
442
|
style: {
|
|
426
443
|
overflowX: "auto",
|
|
427
444
|
margin: "0 0 8px 0"
|
|
428
445
|
},
|
|
429
|
-
children: /* @__PURE__ */
|
|
446
|
+
children: /* @__PURE__ */ o("table", {
|
|
430
447
|
style: {
|
|
431
448
|
borderCollapse: "collapse",
|
|
432
449
|
width: "100%",
|
|
@@ -435,7 +452,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
435
452
|
...t,
|
|
436
453
|
children: e
|
|
437
454
|
})
|
|
438
|
-
}),
|
|
455
|
+
}), me = ({ children: e, ...t }) => /* @__PURE__ */ o("th", {
|
|
439
456
|
style: {
|
|
440
457
|
border: "1px solid #dee3e8",
|
|
441
458
|
padding: "6px 10px",
|
|
@@ -445,14 +462,14 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
445
462
|
},
|
|
446
463
|
...t,
|
|
447
464
|
children: e
|
|
448
|
-
}),
|
|
465
|
+
}), xe = ({ children: e, ...t }) => /* @__PURE__ */ o("td", {
|
|
449
466
|
style: {
|
|
450
467
|
border: "1px solid #dee3e8",
|
|
451
468
|
padding: "6px 10px"
|
|
452
469
|
},
|
|
453
470
|
...t,
|
|
454
471
|
children: e
|
|
455
|
-
}),
|
|
472
|
+
}), he = ({ alt: e, ...t }) => /* @__PURE__ */ o("img", {
|
|
456
473
|
alt: e ?? "",
|
|
457
474
|
style: {
|
|
458
475
|
maxWidth: "100%",
|
|
@@ -460,38 +477,115 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
460
477
|
margin: "4px 0"
|
|
461
478
|
},
|
|
462
479
|
...t
|
|
463
|
-
}),
|
|
480
|
+
}), ye = (e) => /* @__PURE__ */ o("hr", {
|
|
464
481
|
style: {
|
|
465
482
|
border: "none",
|
|
466
483
|
borderTop: "1px solid #dee3e8",
|
|
467
484
|
margin: "12px 0"
|
|
468
485
|
},
|
|
469
486
|
...e
|
|
470
|
-
}),
|
|
471
|
-
a:
|
|
472
|
-
p:
|
|
487
|
+
}), be = {
|
|
488
|
+
a: se,
|
|
489
|
+
p: ie,
|
|
473
490
|
h1: N(1, "20px"),
|
|
474
491
|
h2: N(2, "18px"),
|
|
475
492
|
h3: N(3, "16px"),
|
|
476
493
|
h4: N(4, "15px"),
|
|
477
494
|
h5: N(5, "14px"),
|
|
478
495
|
h6: N(6, "13px"),
|
|
479
|
-
ul:
|
|
480
|
-
ol:
|
|
481
|
-
li:
|
|
482
|
-
code:
|
|
483
|
-
pre:
|
|
484
|
-
blockquote:
|
|
485
|
-
table:
|
|
486
|
-
th:
|
|
487
|
-
td:
|
|
488
|
-
img:
|
|
489
|
-
hr:
|
|
490
|
-
},
|
|
491
|
-
remarkPlugins:
|
|
492
|
-
components:
|
|
496
|
+
ul: le,
|
|
497
|
+
ol: de,
|
|
498
|
+
li: ce,
|
|
499
|
+
code: ue,
|
|
500
|
+
pre: pe,
|
|
501
|
+
blockquote: fe,
|
|
502
|
+
table: ge,
|
|
503
|
+
th: me,
|
|
504
|
+
td: xe,
|
|
505
|
+
img: he,
|
|
506
|
+
hr: ye
|
|
507
|
+
}, ve = [re], we = ({ content: e }) => /* @__PURE__ */ o(ne, {
|
|
508
|
+
remarkPlugins: ve,
|
|
509
|
+
components: be,
|
|
493
510
|
children: e
|
|
494
|
-
}),
|
|
511
|
+
}), Ce = ({ attachment: e, isUser: t }) => {
|
|
512
|
+
const r = V(e.url);
|
|
513
|
+
if (J(e)) return /* @__PURE__ */ o("a", {
|
|
514
|
+
href: r,
|
|
515
|
+
target: "_blank",
|
|
516
|
+
rel: "noopener noreferrer",
|
|
517
|
+
style: {
|
|
518
|
+
display: "inline-block",
|
|
519
|
+
textDecoration: "none"
|
|
520
|
+
},
|
|
521
|
+
children: /* @__PURE__ */ o("img", {
|
|
522
|
+
src: r,
|
|
523
|
+
alt: e.name,
|
|
524
|
+
loading: "lazy",
|
|
525
|
+
style: {
|
|
526
|
+
maxWidth: "180px",
|
|
527
|
+
maxHeight: "160px",
|
|
528
|
+
objectFit: "cover",
|
|
529
|
+
borderRadius: "10px",
|
|
530
|
+
border: "1px solid #dee3e8",
|
|
531
|
+
display: "block"
|
|
532
|
+
}
|
|
533
|
+
})
|
|
534
|
+
});
|
|
535
|
+
const n = G(e.fileSize), a = /* @__PURE__ */ I(O, { children: [/* @__PURE__ */ o("span", {
|
|
536
|
+
style: {
|
|
537
|
+
fontSize: "16px",
|
|
538
|
+
lineHeight: 1,
|
|
539
|
+
flexShrink: 0
|
|
540
|
+
},
|
|
541
|
+
"aria-hidden": !0,
|
|
542
|
+
children: "📄"
|
|
543
|
+
}), /* @__PURE__ */ I("span", {
|
|
544
|
+
style: {
|
|
545
|
+
display: "flex",
|
|
546
|
+
flexDirection: "column",
|
|
547
|
+
minWidth: 0
|
|
548
|
+
},
|
|
549
|
+
children: [/* @__PURE__ */ o("span", {
|
|
550
|
+
style: {
|
|
551
|
+
overflow: "hidden",
|
|
552
|
+
textOverflow: "ellipsis",
|
|
553
|
+
whiteSpace: "nowrap",
|
|
554
|
+
maxWidth: "160px"
|
|
555
|
+
},
|
|
556
|
+
title: e.name,
|
|
557
|
+
children: e.name
|
|
558
|
+
}), n && /* @__PURE__ */ o("span", {
|
|
559
|
+
style: {
|
|
560
|
+
fontSize: "11px",
|
|
561
|
+
color: "#6b6d6f"
|
|
562
|
+
},
|
|
563
|
+
children: n
|
|
564
|
+
})]
|
|
565
|
+
})] }), i = {
|
|
566
|
+
display: "inline-flex",
|
|
567
|
+
alignItems: "center",
|
|
568
|
+
gap: "8px",
|
|
569
|
+
padding: "8px 12px",
|
|
570
|
+
borderRadius: "10px",
|
|
571
|
+
border: "1px solid #dee3e8",
|
|
572
|
+
backgroundColor: t ? "rgba(255,255,255,0.12)" : "#fff",
|
|
573
|
+
color: t ? "#fff" : "#30373e",
|
|
574
|
+
fontSize: "13px",
|
|
575
|
+
textDecoration: "none",
|
|
576
|
+
maxWidth: "220px"
|
|
577
|
+
};
|
|
578
|
+
return r ? /* @__PURE__ */ o("a", {
|
|
579
|
+
href: r,
|
|
580
|
+
target: "_blank",
|
|
581
|
+
rel: "noopener noreferrer",
|
|
582
|
+
style: i,
|
|
583
|
+
children: a
|
|
584
|
+
}) : /* @__PURE__ */ o("div", {
|
|
585
|
+
style: i,
|
|
586
|
+
children: a
|
|
587
|
+
});
|
|
588
|
+
}, Se = ({ source: e, index: t }) => {
|
|
495
589
|
const r = /* @__PURE__ */ I("div", {
|
|
496
590
|
style: {
|
|
497
591
|
display: "flex",
|
|
@@ -500,7 +594,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
500
594
|
width: "100%",
|
|
501
595
|
minWidth: 0
|
|
502
596
|
},
|
|
503
|
-
children: [/* @__PURE__ */
|
|
597
|
+
children: [/* @__PURE__ */ o("div", {
|
|
504
598
|
style: {
|
|
505
599
|
flexShrink: 0,
|
|
506
600
|
width: "18px",
|
|
@@ -516,7 +610,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
516
610
|
backgroundColor: "#f0f4ff"
|
|
517
611
|
},
|
|
518
612
|
children: t + 1
|
|
519
|
-
}), /* @__PURE__ */
|
|
613
|
+
}), /* @__PURE__ */ o("div", {
|
|
520
614
|
style: {
|
|
521
615
|
fontSize: "12px",
|
|
522
616
|
overflow: "hidden",
|
|
@@ -540,23 +634,23 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
540
634
|
minWidth: 0,
|
|
541
635
|
transition: "border-color 0.15s"
|
|
542
636
|
};
|
|
543
|
-
return e.url ? /* @__PURE__ */
|
|
637
|
+
return e.url ? /* @__PURE__ */ o("a", {
|
|
544
638
|
href: e.url,
|
|
545
639
|
target: "_blank",
|
|
546
640
|
rel: "noopener noreferrer",
|
|
547
641
|
style: n,
|
|
548
|
-
onMouseEnter: (
|
|
549
|
-
|
|
642
|
+
onMouseEnter: (a) => {
|
|
643
|
+
a.currentTarget.style.borderColor = "#1b5fc4";
|
|
550
644
|
},
|
|
551
|
-
onMouseLeave: (
|
|
552
|
-
|
|
645
|
+
onMouseLeave: (a) => {
|
|
646
|
+
a.currentTarget.style.borderColor = "#dee3e8";
|
|
553
647
|
},
|
|
554
648
|
children: r
|
|
555
|
-
}) : /* @__PURE__ */
|
|
649
|
+
}) : /* @__PURE__ */ o("div", {
|
|
556
650
|
style: n,
|
|
557
651
|
children: r
|
|
558
652
|
});
|
|
559
|
-
},
|
|
653
|
+
}, ke = () => /* @__PURE__ */ I("div", {
|
|
560
654
|
style: {
|
|
561
655
|
display: "flex",
|
|
562
656
|
gap: "4px",
|
|
@@ -566,31 +660,31 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
566
660
|
0,
|
|
567
661
|
1,
|
|
568
662
|
2
|
|
569
|
-
].map((e) => /* @__PURE__ */
|
|
663
|
+
].map((e) => /* @__PURE__ */ o("div", { style: {
|
|
570
664
|
width: "6px",
|
|
571
665
|
height: "6px",
|
|
572
666
|
borderRadius: "50%",
|
|
573
667
|
backgroundColor: "#b5bfc8",
|
|
574
668
|
animation: "ago-pulse 1.2s ease-in-out infinite",
|
|
575
669
|
animationDelay: `${e * 0.2}s`
|
|
576
|
-
} }, e)), /* @__PURE__ */
|
|
670
|
+
} }, e)), /* @__PURE__ */ o("style", { children: `
|
|
577
671
|
@keyframes ago-pulse {
|
|
578
672
|
0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
|
|
579
673
|
40% { opacity: 1; transform: scale(1); }
|
|
580
674
|
}
|
|
581
675
|
` })]
|
|
582
|
-
}),
|
|
583
|
-
const
|
|
676
|
+
}), Me = ({ message: e, className: t = "", showAgentName: r = !1, isLast: n = !1, onFollowUpClick: a }) => {
|
|
677
|
+
const i = e.role === "user", u = e.status === "IN_PROGRESS";
|
|
584
678
|
return /* @__PURE__ */ I("div", {
|
|
585
679
|
className: `ago-message ago-message--${e.role} ${t}`,
|
|
586
680
|
style: {
|
|
587
681
|
display: "flex",
|
|
588
682
|
flexDirection: "column",
|
|
589
|
-
alignItems:
|
|
683
|
+
alignItems: i ? "flex-end" : "flex-start",
|
|
590
684
|
marginBottom: "16px"
|
|
591
685
|
},
|
|
592
686
|
children: [
|
|
593
|
-
!
|
|
687
|
+
!i && r && e.agent && /* @__PURE__ */ o("div", {
|
|
594
688
|
className: "ago-message__agent",
|
|
595
689
|
style: {
|
|
596
690
|
display: "flex",
|
|
@@ -604,7 +698,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
604
698
|
},
|
|
605
699
|
children: e.agent.displayName || e.agent.name
|
|
606
700
|
}),
|
|
607
|
-
!
|
|
701
|
+
!i && e.sources && e.sources.length > 0 && /* @__PURE__ */ o("div", {
|
|
608
702
|
className: "ago-message__sources",
|
|
609
703
|
style: {
|
|
610
704
|
display: "grid",
|
|
@@ -614,26 +708,41 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
614
708
|
width: "100%",
|
|
615
709
|
maxWidth: "85%"
|
|
616
710
|
},
|
|
617
|
-
children: e.sources.map((
|
|
618
|
-
source:
|
|
711
|
+
children: e.sources.map((l, f) => /* @__PURE__ */ o(Se, {
|
|
712
|
+
source: l,
|
|
619
713
|
index: f
|
|
620
|
-
},
|
|
714
|
+
}, l.id))
|
|
621
715
|
}),
|
|
622
|
-
/* @__PURE__ */
|
|
716
|
+
e.attachments && e.attachments.length > 0 && /* @__PURE__ */ o("div", {
|
|
717
|
+
className: "ago-message__attachments",
|
|
718
|
+
style: {
|
|
719
|
+
display: "flex",
|
|
720
|
+
flexWrap: "wrap",
|
|
721
|
+
gap: "6px",
|
|
722
|
+
marginBottom: "6px",
|
|
723
|
+
justifyContent: i ? "flex-end" : "flex-start",
|
|
724
|
+
maxWidth: "75%"
|
|
725
|
+
},
|
|
726
|
+
children: e.attachments.map((l) => /* @__PURE__ */ o(Ce, {
|
|
727
|
+
attachment: l,
|
|
728
|
+
isUser: i
|
|
729
|
+
}, l.id))
|
|
730
|
+
}),
|
|
731
|
+
(e.content || u) && /* @__PURE__ */ o("div", {
|
|
623
732
|
className: "ago-message__content",
|
|
624
733
|
style: {
|
|
625
|
-
maxWidth:
|
|
626
|
-
padding:
|
|
627
|
-
borderRadius:
|
|
628
|
-
backgroundColor:
|
|
629
|
-
color:
|
|
734
|
+
maxWidth: i ? "75%" : "100%",
|
|
735
|
+
padding: i ? "10px 14px" : "2px 8px",
|
|
736
|
+
borderRadius: i ? "16px" : "0",
|
|
737
|
+
backgroundColor: i ? "#03182f" : "transparent",
|
|
738
|
+
color: i ? "#fff" : "#30373e",
|
|
630
739
|
wordBreak: "break-word",
|
|
631
740
|
fontSize: "16px",
|
|
632
741
|
lineHeight: "1.6"
|
|
633
742
|
},
|
|
634
|
-
children: e.content ? /* @__PURE__ */
|
|
743
|
+
children: e.content ? /* @__PURE__ */ o(we, { content: e.content }) : u && /* @__PURE__ */ o(ke, {})
|
|
635
744
|
}),
|
|
636
|
-
n && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */
|
|
745
|
+
n && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ o("div", {
|
|
637
746
|
className: "ago-message__followups",
|
|
638
747
|
style: {
|
|
639
748
|
display: "flex",
|
|
@@ -641,19 +750,20 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
641
750
|
gap: "8px",
|
|
642
751
|
marginTop: "10px"
|
|
643
752
|
},
|
|
644
|
-
children: e.followUpReplies.map((
|
|
753
|
+
children: e.followUpReplies.map((l, f) => /* @__PURE__ */ o("button", {
|
|
645
754
|
type: "button",
|
|
646
755
|
className: "ago-message__followup-btn",
|
|
647
|
-
disabled: !
|
|
648
|
-
onClick:
|
|
756
|
+
disabled: !a,
|
|
757
|
+
onClick: a ? () => a(l) : void 0,
|
|
649
758
|
style: {
|
|
759
|
+
minHeight: "36px",
|
|
650
760
|
padding: "6px 14px",
|
|
651
761
|
fontSize: "13px",
|
|
652
762
|
borderRadius: "16px",
|
|
653
763
|
border: "1px solid #dee3e8",
|
|
654
764
|
backgroundColor: "#fff",
|
|
655
765
|
color: "#30373e",
|
|
656
|
-
cursor:
|
|
766
|
+
cursor: a ? "pointer" : "default",
|
|
657
767
|
transition: "border-color 0.15s"
|
|
658
768
|
},
|
|
659
769
|
onMouseEnter: (c) => {
|
|
@@ -662,50 +772,50 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
662
772
|
onMouseLeave: (c) => {
|
|
663
773
|
c.currentTarget.style.borderColor = "#dee3e8";
|
|
664
774
|
},
|
|
665
|
-
children:
|
|
775
|
+
children: l
|
|
666
776
|
}, f))
|
|
667
777
|
})
|
|
668
778
|
]
|
|
669
779
|
});
|
|
670
|
-
},
|
|
671
|
-
const
|
|
780
|
+
}, He = ({ client: e, conversationId: t, title: r = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: a = "Type a message...", allowFiles: i = !1, height: u = 500, logoUrl: l, showAgentName: f = !1, forms: c, onFollowUpClick: b, className: m = "", onMessageSent: C, onMessageReceived: g }) => {
|
|
781
|
+
const x = A(null), v = W(), w = e ?? v, { messages: s, isLoading: p, error: d, sendMessage: h } = B({
|
|
672
782
|
client: e,
|
|
673
783
|
conversationId: t
|
|
674
784
|
});
|
|
675
|
-
|
|
676
|
-
if (!
|
|
785
|
+
k(() => {
|
|
786
|
+
if (!w || !c || c.length === 0) return;
|
|
677
787
|
let y = !1;
|
|
678
|
-
const
|
|
679
|
-
return Promise.all(c.map((
|
|
788
|
+
const F = [];
|
|
789
|
+
return Promise.all(c.map((E) => E.schema != null ? Promise.resolve(L(E)) : H(w, E))).then((E) => {
|
|
680
790
|
if (!y)
|
|
681
|
-
for (const
|
|
791
|
+
for (const q of E) F.push(q.install(w));
|
|
682
792
|
}).catch(() => {
|
|
683
793
|
}), () => {
|
|
684
|
-
y = !0,
|
|
794
|
+
y = !0, F.forEach((E) => E());
|
|
685
795
|
};
|
|
686
|
-
}, [
|
|
796
|
+
}, [w, c ? JSON.stringify(c.map((y) => [
|
|
687
797
|
y.name,
|
|
688
798
|
y.schema ?? null,
|
|
689
799
|
y.submit ?? !1,
|
|
690
800
|
y.description ?? null
|
|
691
|
-
])) : ""]),
|
|
692
|
-
|
|
693
|
-
}, [
|
|
694
|
-
const y =
|
|
695
|
-
y && y.role === "assistant" && y.status === "DONE" &&
|
|
801
|
+
])) : ""]), k(() => {
|
|
802
|
+
x.current?.scrollIntoView({ behavior: "smooth" });
|
|
803
|
+
}, [s]), k(() => {
|
|
804
|
+
const y = s[s.length - 1];
|
|
805
|
+
y && y.role === "assistant" && y.status === "DONE" && g && g({
|
|
696
806
|
id: y.id,
|
|
697
807
|
content: y.content
|
|
698
808
|
});
|
|
699
|
-
}, [
|
|
700
|
-
const
|
|
701
|
-
|
|
702
|
-
},
|
|
809
|
+
}, [s, g]);
|
|
810
|
+
const S = async (y, F) => {
|
|
811
|
+
C?.(y), await h(y, F);
|
|
812
|
+
}, z = s[s.length - 1], K = p && z?.role === "assistant" && z.status === "IN_PROGRESS", U = b === !1 ? void 0 : b ?? ((y) => S(y));
|
|
703
813
|
return /* @__PURE__ */ I("div", {
|
|
704
|
-
className: `ago-chat-widget ${
|
|
814
|
+
className: `ago-chat-widget ${m}`,
|
|
705
815
|
style: {
|
|
706
816
|
display: "flex",
|
|
707
817
|
flexDirection: "column",
|
|
708
|
-
height: typeof
|
|
818
|
+
height: typeof u == "number" ? `${u}px` : u,
|
|
709
819
|
border: "1px solid #dee3e8",
|
|
710
820
|
borderRadius: "16px",
|
|
711
821
|
overflow: "hidden",
|
|
@@ -726,14 +836,14 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
726
836
|
alignItems: "center",
|
|
727
837
|
gap: "10px"
|
|
728
838
|
},
|
|
729
|
-
children: [
|
|
730
|
-
src:
|
|
839
|
+
children: [l && /* @__PURE__ */ o("img", {
|
|
840
|
+
src: l,
|
|
731
841
|
alt: "Logo",
|
|
732
842
|
style: {
|
|
733
843
|
height: "24px",
|
|
734
844
|
width: "auto"
|
|
735
845
|
}
|
|
736
|
-
}), /* @__PURE__ */
|
|
846
|
+
}), /* @__PURE__ */ o("h3", {
|
|
737
847
|
style: {
|
|
738
848
|
margin: 0,
|
|
739
849
|
fontSize: "15px",
|
|
@@ -744,6 +854,10 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
744
854
|
}),
|
|
745
855
|
/* @__PURE__ */ I("div", {
|
|
746
856
|
className: "ago-chat-widget__messages",
|
|
857
|
+
role: "log",
|
|
858
|
+
"aria-live": "polite",
|
|
859
|
+
"aria-relevant": "additions text",
|
|
860
|
+
"aria-atomic": !1,
|
|
747
861
|
style: {
|
|
748
862
|
flex: 1,
|
|
749
863
|
overflow: "auto",
|
|
@@ -751,7 +865,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
751
865
|
backgroundColor: "#fbfbfb"
|
|
752
866
|
},
|
|
753
867
|
children: [
|
|
754
|
-
|
|
868
|
+
s.length === 0 ? /* @__PURE__ */ o("div", {
|
|
755
869
|
style: {
|
|
756
870
|
textAlign: "center",
|
|
757
871
|
color: "#6b6d6f",
|
|
@@ -760,13 +874,14 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
760
874
|
lineHeight: "1.5"
|
|
761
875
|
},
|
|
762
876
|
children: n
|
|
763
|
-
}) :
|
|
877
|
+
}) : s.map((y, F) => /* @__PURE__ */ o(Me, {
|
|
764
878
|
message: y,
|
|
765
879
|
showAgentName: f,
|
|
766
|
-
isLast:
|
|
767
|
-
onFollowUpClick:
|
|
880
|
+
isLast: F === s.length - 1,
|
|
881
|
+
onFollowUpClick: U
|
|
768
882
|
}, y.id)),
|
|
769
|
-
|
|
883
|
+
d && /* @__PURE__ */ o("div", {
|
|
884
|
+
role: "alert",
|
|
770
885
|
style: {
|
|
771
886
|
padding: "10px 14px",
|
|
772
887
|
backgroundColor: "#fef2f2",
|
|
@@ -776,192 +891,192 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
776
891
|
fontSize: "13px",
|
|
777
892
|
border: "1px solid #fecaca"
|
|
778
893
|
},
|
|
779
|
-
children:
|
|
894
|
+
children: d.message
|
|
780
895
|
}),
|
|
781
|
-
/* @__PURE__ */
|
|
896
|
+
/* @__PURE__ */ o("div", { ref: x })
|
|
782
897
|
]
|
|
783
898
|
}),
|
|
784
|
-
/* @__PURE__ */
|
|
785
|
-
onSend:
|
|
786
|
-
disabled:
|
|
787
|
-
placeholder:
|
|
788
|
-
allowFiles:
|
|
899
|
+
/* @__PURE__ */ o(ae, {
|
|
900
|
+
onSend: S,
|
|
901
|
+
disabled: K,
|
|
902
|
+
placeholder: a,
|
|
903
|
+
allowFiles: i
|
|
789
904
|
})
|
|
790
905
|
]
|
|
791
906
|
});
|
|
792
907
|
};
|
|
793
|
-
function
|
|
794
|
-
const r =
|
|
908
|
+
function Ie({ client: e, autoLoad: t = !0 } = {}) {
|
|
909
|
+
const r = W(), n = e || r;
|
|
795
910
|
if (!n) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
796
|
-
const [
|
|
797
|
-
c(!0),
|
|
911
|
+
const [a, i] = M([]), [u, l] = M(null), [f, c] = M(!1), [b, m] = M(null), C = R(async () => {
|
|
912
|
+
c(!0), m(null);
|
|
798
913
|
try {
|
|
799
|
-
|
|
800
|
-
} catch (
|
|
801
|
-
v
|
|
914
|
+
i(await n.getConversations());
|
|
915
|
+
} catch (v) {
|
|
916
|
+
m(v instanceof Error ? v : /* @__PURE__ */ new Error("Failed to load conversations"));
|
|
802
917
|
} finally {
|
|
803
918
|
c(!1);
|
|
804
919
|
}
|
|
805
|
-
}, [n]),
|
|
806
|
-
c(!0),
|
|
920
|
+
}, [n]), g = R(async (v) => {
|
|
921
|
+
c(!0), m(null);
|
|
807
922
|
try {
|
|
808
|
-
|
|
809
|
-
} catch (
|
|
810
|
-
|
|
923
|
+
l(await n.getConversation(v));
|
|
924
|
+
} catch (w) {
|
|
925
|
+
m(w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to load conversation"));
|
|
811
926
|
} finally {
|
|
812
927
|
c(!1);
|
|
813
928
|
}
|
|
814
|
-
}, [n]),
|
|
815
|
-
|
|
929
|
+
}, [n]), x = R(() => {
|
|
930
|
+
l(null);
|
|
816
931
|
}, []);
|
|
817
|
-
return
|
|
818
|
-
t &&
|
|
819
|
-
}, [t,
|
|
820
|
-
conversations:
|
|
821
|
-
currentConversation:
|
|
932
|
+
return k(() => {
|
|
933
|
+
t && C();
|
|
934
|
+
}, [t, C]), {
|
|
935
|
+
conversations: a,
|
|
936
|
+
currentConversation: u,
|
|
822
937
|
isLoading: f,
|
|
823
|
-
error:
|
|
824
|
-
selectConversation:
|
|
825
|
-
startNewConversation:
|
|
826
|
-
refreshConversations:
|
|
938
|
+
error: b,
|
|
939
|
+
selectConversation: g,
|
|
940
|
+
startNewConversation: x,
|
|
941
|
+
refreshConversations: C
|
|
827
942
|
};
|
|
828
943
|
}
|
|
829
|
-
function
|
|
830
|
-
const t =
|
|
944
|
+
function Le(e = {}) {
|
|
945
|
+
const t = W(), r = e.client || t;
|
|
831
946
|
if (!r) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
832
|
-
const n =
|
|
947
|
+
const n = B({
|
|
833
948
|
client: r,
|
|
834
949
|
conversationId: e.conversationId
|
|
835
|
-
}),
|
|
950
|
+
}), a = Ie({
|
|
836
951
|
client: r,
|
|
837
952
|
autoLoad: e.autoLoad
|
|
838
953
|
});
|
|
839
954
|
return {
|
|
840
955
|
messages: n.messages,
|
|
841
956
|
isLoading: n.isLoading,
|
|
842
|
-
error: n.error ||
|
|
957
|
+
error: n.error || a.error,
|
|
843
958
|
sendMessage: n.sendMessage,
|
|
844
959
|
clearMessages: n.clearMessages,
|
|
845
960
|
conversationId: n.conversationId,
|
|
846
|
-
conversations:
|
|
847
|
-
currentConversation:
|
|
848
|
-
isConversationsLoading:
|
|
849
|
-
selectConversation:
|
|
850
|
-
startNewConversation:
|
|
851
|
-
refreshConversations:
|
|
961
|
+
conversations: a.conversations,
|
|
962
|
+
currentConversation: a.currentConversation,
|
|
963
|
+
isConversationsLoading: a.isLoading,
|
|
964
|
+
selectConversation: a.selectConversation,
|
|
965
|
+
startNewConversation: a.startNewConversation,
|
|
966
|
+
refreshConversations: a.refreshConversations
|
|
852
967
|
};
|
|
853
968
|
}
|
|
854
|
-
function
|
|
855
|
-
const r =
|
|
969
|
+
function $e(e, t) {
|
|
970
|
+
const r = T(), { name: n, description: a, parameters: i, handler: u } = typeof e == "string" ? {
|
|
856
971
|
name: e,
|
|
857
972
|
...t
|
|
858
|
-
} : e,
|
|
859
|
-
|
|
860
|
-
const f = (c) =>
|
|
973
|
+
} : e, l = A(u);
|
|
974
|
+
l.current = u, k(() => {
|
|
975
|
+
const f = (c) => l.current(c);
|
|
861
976
|
return r.registerFunction(n, f, {
|
|
862
|
-
description:
|
|
863
|
-
parameters:
|
|
977
|
+
description: a,
|
|
978
|
+
parameters: i
|
|
864
979
|
}), () => {
|
|
865
980
|
r.unregisterFunction(n);
|
|
866
981
|
};
|
|
867
982
|
}, [
|
|
868
983
|
r,
|
|
869
984
|
n,
|
|
870
|
-
|
|
871
|
-
|
|
985
|
+
a,
|
|
986
|
+
i
|
|
872
987
|
]);
|
|
873
988
|
}
|
|
874
|
-
function
|
|
875
|
-
const r =
|
|
876
|
-
n.current = e,
|
|
989
|
+
function Oe(e, t) {
|
|
990
|
+
const r = T(), n = A(e);
|
|
991
|
+
n.current = e, k(() => (r.registerNavigationFunction((a) => n.current(a), t), () => {
|
|
877
992
|
r.unregisterFunction("navigateToPage");
|
|
878
993
|
}), [r, t]);
|
|
879
994
|
}
|
|
880
|
-
function
|
|
881
|
-
const r =
|
|
882
|
-
|
|
883
|
-
const
|
|
884
|
-
|
|
885
|
-
if (typeof
|
|
886
|
-
const
|
|
887
|
-
return r.addDynamicContext(
|
|
888
|
-
r.removeDynamicContext(
|
|
995
|
+
function Be(e, t) {
|
|
996
|
+
const r = T(), n = ee(), a = t ?? n, i = A(e);
|
|
997
|
+
i.current = e;
|
|
998
|
+
const u = typeof e == "function";
|
|
999
|
+
k(() => {
|
|
1000
|
+
if (typeof i.current == "function") {
|
|
1001
|
+
const l = () => i.current();
|
|
1002
|
+
return r.addDynamicContext(a, l), () => {
|
|
1003
|
+
r.removeDynamicContext(a);
|
|
889
1004
|
};
|
|
890
1005
|
}
|
|
891
|
-
return r.setContext(
|
|
892
|
-
r.removeContext(
|
|
1006
|
+
return r.setContext(a, i.current), () => {
|
|
1007
|
+
r.removeContext(a);
|
|
893
1008
|
};
|
|
894
1009
|
}, [
|
|
895
1010
|
r,
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
1011
|
+
a,
|
|
1012
|
+
u,
|
|
1013
|
+
u ? "" : JSON.stringify(e)
|
|
899
1014
|
]);
|
|
900
1015
|
}
|
|
901
|
-
function
|
|
902
|
-
return
|
|
1016
|
+
function Re(e) {
|
|
1017
|
+
return te(e.subscribe, e.get, e.get);
|
|
903
1018
|
}
|
|
904
|
-
var
|
|
1019
|
+
var P = {
|
|
905
1020
|
missing: [],
|
|
906
1021
|
complete: !1
|
|
907
1022
|
};
|
|
908
|
-
function
|
|
909
|
-
const t =
|
|
1023
|
+
function Ke(e) {
|
|
1024
|
+
const t = T(), r = e.schema != null, n = JSON.stringify(e.schema ?? null), a = e.submit, i = a ? typeof a == "string" ? `client:${a}` : a.via === "backend" ? "backend" : "handler" in a ? "client:handler" : `client:${a.url}` : "none", u = JSON.stringify(e.initialValues ?? null), l = _(() => r ? L(e) : null, [
|
|
910
1025
|
r,
|
|
911
1026
|
e.name,
|
|
912
1027
|
n,
|
|
913
|
-
|
|
914
|
-
|
|
1028
|
+
i,
|
|
1029
|
+
u,
|
|
915
1030
|
e.autoSubmit
|
|
916
1031
|
]), [f, c] = M({
|
|
917
1032
|
collector: null,
|
|
918
1033
|
loading: !r,
|
|
919
1034
|
error: null
|
|
920
1035
|
});
|
|
921
|
-
|
|
1036
|
+
k(() => {
|
|
922
1037
|
if (r) return;
|
|
923
|
-
let
|
|
1038
|
+
let p = !1;
|
|
924
1039
|
return c({
|
|
925
1040
|
collector: null,
|
|
926
1041
|
loading: !0,
|
|
927
1042
|
error: null
|
|
928
|
-
}),
|
|
929
|
-
|
|
930
|
-
collector:
|
|
1043
|
+
}), H(t, e).then((d) => {
|
|
1044
|
+
p || c({
|
|
1045
|
+
collector: d,
|
|
931
1046
|
loading: !1,
|
|
932
1047
|
error: null
|
|
933
1048
|
});
|
|
934
|
-
}).catch((
|
|
935
|
-
|
|
1049
|
+
}).catch((d) => {
|
|
1050
|
+
p || c({
|
|
936
1051
|
collector: null,
|
|
937
1052
|
loading: !1,
|
|
938
|
-
error:
|
|
1053
|
+
error: d instanceof Error ? d : new Error(String(d))
|
|
939
1054
|
});
|
|
940
1055
|
}), () => {
|
|
941
|
-
|
|
1056
|
+
p = !0;
|
|
942
1057
|
};
|
|
943
1058
|
}, [
|
|
944
1059
|
t,
|
|
945
1060
|
r,
|
|
946
1061
|
e.name,
|
|
947
|
-
|
|
948
|
-
|
|
1062
|
+
i,
|
|
1063
|
+
u,
|
|
949
1064
|
e.autoSubmit
|
|
950
1065
|
]);
|
|
951
|
-
const
|
|
952
|
-
|
|
953
|
-
if (
|
|
954
|
-
return
|
|
955
|
-
}, [t,
|
|
956
|
-
const
|
|
1066
|
+
const b = r ? l : f.collector, m = r ? !1 : f.loading, C = r ? null : f.error;
|
|
1067
|
+
k(() => {
|
|
1068
|
+
if (b)
|
|
1069
|
+
return b.install(t);
|
|
1070
|
+
}, [t, b]);
|
|
1071
|
+
const g = _(() => X({
|
|
957
1072
|
values: e.initialValues ?? {},
|
|
958
1073
|
submitted: !1
|
|
959
|
-
}), [
|
|
960
|
-
...
|
|
961
|
-
...
|
|
962
|
-
}), [
|
|
1074
|
+
}), [u]), x = Re(b?.store ?? g), v = _(() => b?.getStatus() ?? P, [x, b]), w = _(() => ({
|
|
1075
|
+
...x,
|
|
1076
|
+
...v
|
|
1077
|
+
}), [x, v]), s = _(() => ({
|
|
963
1078
|
name: e.name,
|
|
964
|
-
store:
|
|
1079
|
+
store: g,
|
|
965
1080
|
functions: [],
|
|
966
1081
|
contextKey: `form:${e.name}`,
|
|
967
1082
|
contextProvider: () => ({
|
|
@@ -976,39 +1091,39 @@ function ze(e) {
|
|
|
976
1091
|
ok: !1,
|
|
977
1092
|
error: "Form definition not loaded yet."
|
|
978
1093
|
}),
|
|
979
|
-
getValues: () =>
|
|
1094
|
+
getValues: () => g.get().values,
|
|
980
1095
|
setValues: () => {
|
|
981
1096
|
},
|
|
982
1097
|
reset: () => {
|
|
983
1098
|
},
|
|
984
|
-
getStatus: () =>
|
|
985
|
-
}), [e.name,
|
|
1099
|
+
getStatus: () => P
|
|
1100
|
+
}), [e.name, g]);
|
|
986
1101
|
return {
|
|
987
|
-
...
|
|
988
|
-
state:
|
|
989
|
-
loading:
|
|
990
|
-
error:
|
|
1102
|
+
...b ?? s,
|
|
1103
|
+
state: w,
|
|
1104
|
+
loading: m,
|
|
1105
|
+
error: C
|
|
991
1106
|
};
|
|
992
1107
|
}
|
|
993
1108
|
export {
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1109
|
+
Pe as AgoProvider,
|
|
1110
|
+
ae as ChatInput,
|
|
1111
|
+
He as ChatWidget,
|
|
1112
|
+
we as Markdown,
|
|
1113
|
+
Me as Message,
|
|
1114
|
+
L as createFormCollector,
|
|
1115
|
+
_e as createMockClient,
|
|
1116
|
+
Fe as deriveFormStatus,
|
|
1117
|
+
H as loadFormCollector,
|
|
1118
|
+
oe as useAgo,
|
|
1119
|
+
T as useAgoClient,
|
|
1120
|
+
Be as useAgoContext,
|
|
1121
|
+
$e as useAgoFunction,
|
|
1122
|
+
Oe as useAgoNavigation,
|
|
1123
|
+
Re as useAgoStore,
|
|
1124
|
+
Le as useChat,
|
|
1125
|
+
Ie as useConversation,
|
|
1126
|
+
Ke as useFormCollector,
|
|
1127
|
+
B as useMessages,
|
|
1128
|
+
W as useOptionalAgoClient
|
|
1014
1129
|
};
|