@useago/sdk 1.13.3 → 1.14.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/CHANGELOG.md +6 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +7 -0
- package/dist/angular.d.ts +7 -0
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-DrmOaZdO.js → createConversationSession-CybQdMpK.js} +1 -1
- package/dist/{createConversationSession-Digvn0GQ.cjs → createConversationSession-jwSXhTLe.cjs} +1 -1
- package/dist/{createFormCollector-D_5SDuk9.cjs → createFormCollector-B_hSKcLd.cjs} +1 -1
- package/dist/{createFormCollector-D6_N8wYq.js → createFormCollector-DJjms78E.js} +1 -1
- package/dist/devtools.d.cts +7 -0
- package/dist/devtools.d.ts +7 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -6
- package/dist/react.cjs +4 -4
- package/dist/react.d.cts +8 -1
- package/dist/react.d.ts +8 -1
- package/dist/react.js +901 -912
- package/dist/speechToText-BB25_zVM.cjs +7 -0
- package/dist/speechToText-BLvTis4S.js +1496 -0
- package/dist/testing.d.cts +7 -0
- package/dist/testing.d.ts +7 -0
- package/dist/{types-D1ZrqVhr.js → types-C39MJUE3.js} +284 -259
- package/dist/{types-DNr6XEwI.cjs → types-PGXnhAmQ.cjs} +7 -7
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +7 -0
- package/dist/vue.d.ts +7 -0
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +5 -6
- package/dist/widget.d.cts +12 -4
- package/dist/widget.d.ts +12 -4
- package/dist/widget.js +1868 -1841
- package/llms-full.txt +23 -3
- package/package.json +1 -1
- package/dist/speechToText-BV7qxqPF.js +0 -704
- package/dist/speechToText-ZciRyyJE.cjs +0 -1
package/dist/react.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { n as
|
|
3
|
-
import { t as
|
|
4
|
-
import { n as
|
|
5
|
-
import { t as
|
|
6
|
-
import { C as
|
|
7
|
-
import
|
|
8
|
-
import { Fragment as
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
function
|
|
12
|
-
const [
|
|
13
|
-
if (
|
|
14
|
-
const s = new
|
|
15
|
-
return
|
|
1
|
+
import { a as Oe, c as $e, g as je, n as qe, o as Ue, s as Ke, t as Ge } from "./types-C39MJUE3.js";
|
|
2
|
+
import { n as ae } from "./errors-BLfjXnLB.js";
|
|
3
|
+
import { t as Je } from "./autoContinue-Cb4_iEbO.js";
|
|
4
|
+
import { n as Yt, r as Ce, t as Se } from "./createFormCollector-DJjms78E.js";
|
|
5
|
+
import { t as Qt } from "./createMockClient-YoYr3pQr.js";
|
|
6
|
+
import { C as Ve, dt as Xe, ft as Ye, mt as Ze, n as Qe, pt as re, t as nn, ut as et } from "./speechToText-BLvTis4S.js";
|
|
7
|
+
import tt, { createContext as nt, forwardRef as ot, useCallback as R, useContext as Ae, useEffect as _, useId as rt, useImperativeHandle as at, useLayoutEffect as st, useMemo as U, useRef as D, useState as E, useSyncExternalStore as ce } from "react";
|
|
8
|
+
import { Fragment as Ne, jsx as a, jsxs as W } from "react/jsx-runtime";
|
|
9
|
+
import it from "react-markdown";
|
|
10
|
+
import lt from "remark-gfm";
|
|
11
|
+
function ct(e) {
|
|
12
|
+
const [o, t] = E(!1), r = D(null), n = U(() => {
|
|
13
|
+
if (r.current && (r.current.destroy(), r.current = null), !e) return null;
|
|
14
|
+
const s = new qe(e);
|
|
15
|
+
return r.current = s, s;
|
|
16
16
|
}, [e?.baseUrl, e?.widgetId]);
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
}), [n]),
|
|
20
|
-
|
|
17
|
+
return _(() => (n && r.current === null && (r.current = n, n.reviveAfterDestroy()), t(!0), () => {
|
|
18
|
+
r.current?.destroy(), r.current = null;
|
|
19
|
+
}), [n]), _(() => {
|
|
20
|
+
r.current && e && r.current.updateConfig({
|
|
21
21
|
agent: e.agent,
|
|
22
22
|
defaultAgentId: e.defaultAgentId,
|
|
23
23
|
permission: e.permission,
|
|
@@ -40,54 +40,60 @@ function tt(e) {
|
|
|
40
40
|
e?.warnOnEmptyReply
|
|
41
41
|
]), {
|
|
42
42
|
client: n,
|
|
43
|
-
isReady:
|
|
43
|
+
isReady: o
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
var
|
|
47
|
-
const { client:
|
|
48
|
-
return
|
|
46
|
+
var de = nt(null), ln = ({ children: e, client: o, tools: t, helpers: r, pageContext: n, ...s }) => {
|
|
47
|
+
const { client: c } = ct(o ? null : s), i = o || c;
|
|
48
|
+
return _(() => {
|
|
49
49
|
if (!(!t || t.length === 0)) {
|
|
50
|
-
for (const
|
|
50
|
+
for (const u of t) i.register(u);
|
|
51
51
|
return () => {
|
|
52
|
-
for (const
|
|
52
|
+
for (const u of t) i.unregisterFunction(u.name);
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
}, [i, t]),
|
|
56
|
-
if (!
|
|
57
|
-
const
|
|
55
|
+
}, [i, t]), _(() => {
|
|
56
|
+
if (!r) return;
|
|
57
|
+
const u = [];
|
|
58
58
|
return import("./functions-tzyOZNp6.js").then((d) => d.n).then((d) => {
|
|
59
|
-
for (const [
|
|
60
|
-
const
|
|
61
|
-
if (!
|
|
62
|
-
console.warn(`[AGO] Unknown helper: "${
|
|
59
|
+
for (const [p, m] of Object.entries(r)) {
|
|
60
|
+
const x = d[p];
|
|
61
|
+
if (!x) {
|
|
62
|
+
console.warn(`[AGO] Unknown helper: "${p}"`);
|
|
63
63
|
continue;
|
|
64
64
|
}
|
|
65
|
-
const
|
|
66
|
-
...
|
|
67
|
-
handler:
|
|
65
|
+
const f = m === !0 ? x : {
|
|
66
|
+
...x,
|
|
67
|
+
handler: m
|
|
68
68
|
};
|
|
69
|
-
i.register(
|
|
69
|
+
i.register(f), u.push(f.name);
|
|
70
70
|
}
|
|
71
71
|
}), () => {
|
|
72
|
-
for (const d of
|
|
72
|
+
for (const d of u) i.unregisterFunction(d);
|
|
73
73
|
};
|
|
74
|
-
}, [i,
|
|
74
|
+
}, [i, r]), _(() => {
|
|
75
75
|
n === "auto" && i.enableAutoPageContext();
|
|
76
|
-
}, [i, n]), /* @__PURE__ */ a(
|
|
76
|
+
}, [i, n]), /* @__PURE__ */ a(de.Provider, {
|
|
77
77
|
value: i,
|
|
78
78
|
children: e
|
|
79
79
|
});
|
|
80
80
|
};
|
|
81
|
-
function
|
|
82
|
-
const e =
|
|
81
|
+
function V() {
|
|
82
|
+
const e = Ae(de);
|
|
83
83
|
if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
|
|
84
84
|
return e;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
return
|
|
86
|
+
function $() {
|
|
87
|
+
return Ae(de);
|
|
88
|
+
}
|
|
89
|
+
function Q(e) {
|
|
90
|
+
const o = $(), t = e ?? o, r = R((s) => (t?.on("config:changed", s), () => {
|
|
91
|
+
t?.off("config:changed", s);
|
|
92
|
+
}), [t]), n = () => t?.getLanguage?.() ?? null;
|
|
93
|
+
return Ye(ce(r, n, n));
|
|
88
94
|
}
|
|
89
|
-
var
|
|
90
|
-
function
|
|
95
|
+
var dt = /* @__PURE__ */ new Set(["awaiting-approval"]);
|
|
96
|
+
function _e(e) {
|
|
91
97
|
switch (e) {
|
|
92
98
|
case "progress_indicator":
|
|
93
99
|
return "progress";
|
|
@@ -101,22 +107,22 @@ function we(e) {
|
|
|
101
107
|
return "status";
|
|
102
108
|
}
|
|
103
109
|
}
|
|
104
|
-
function
|
|
105
|
-
return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" :
|
|
110
|
+
function ut(e) {
|
|
111
|
+
return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : _e(e.type);
|
|
106
112
|
}
|
|
107
|
-
function
|
|
113
|
+
function be(e, o) {
|
|
108
114
|
const t = (e ?? "").toLowerCase();
|
|
109
|
-
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")) && (
|
|
115
|
+
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")) && (o === "confirmation" || o === "form") ? "awaiting-approval" : "running";
|
|
110
116
|
}
|
|
111
|
-
function
|
|
112
|
-
return typeof e != "string" || !e ? "page" : e.replace(/[-_]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (
|
|
117
|
+
function ye(e) {
|
|
118
|
+
return typeof e != "string" || !e ? "page" : e.replace(/[-_]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (o) => o.toUpperCase()).trim();
|
|
113
119
|
}
|
|
114
|
-
function
|
|
120
|
+
function pt(e) {
|
|
115
121
|
switch (e.kind) {
|
|
116
122
|
case "navigation":
|
|
117
|
-
return `Navigating to ${
|
|
123
|
+
return `Navigating to ${ye(e.arguments?.page)}`;
|
|
118
124
|
case "action":
|
|
119
|
-
return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message ||
|
|
125
|
+
return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message || ye(e.functionName) || "Working";
|
|
120
126
|
case "progress":
|
|
121
127
|
return e.message || "Working";
|
|
122
128
|
case "reasoning":
|
|
@@ -129,281 +135,281 @@ function ot(e) {
|
|
|
129
135
|
return e.message || e.toolDisplayName || e.toolName || "Working";
|
|
130
136
|
}
|
|
131
137
|
}
|
|
132
|
-
function
|
|
133
|
-
const { includeReasoning:
|
|
134
|
-
if (!n) throw new
|
|
135
|
-
const [s,
|
|
138
|
+
function ft(e = {}) {
|
|
139
|
+
const { includeReasoning: o = !1, labelFor: t } = e, r = $(), n = e.client || r;
|
|
140
|
+
if (!n) throw new ae("useAgoActivity requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
|
|
141
|
+
const [s, c] = E([]), i = D(/* @__PURE__ */ new Set()), u = D(void 0), d = D(t);
|
|
136
142
|
d.current = t;
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
...
|
|
141
|
-
id:
|
|
143
|
+
const p = R((l, h) => {
|
|
144
|
+
c((b) => {
|
|
145
|
+
const I = b.findIndex((g) => g.id === l), N = {
|
|
146
|
+
...I >= 0 ? b[I] : {
|
|
147
|
+
id: l,
|
|
142
148
|
kind: "status",
|
|
143
149
|
label: "",
|
|
144
150
|
status: "running",
|
|
145
151
|
requiresApproval: !1,
|
|
146
152
|
createdAt: /* @__PURE__ */ new Date()
|
|
147
153
|
},
|
|
148
|
-
...
|
|
154
|
+
...h
|
|
149
155
|
};
|
|
150
|
-
return
|
|
151
|
-
...
|
|
152
|
-
|
|
153
|
-
...
|
|
154
|
-
] : [...
|
|
156
|
+
return N.label = d.current?.(N) ?? pt(N), I >= 0 ? [
|
|
157
|
+
...b.slice(0, I),
|
|
158
|
+
N,
|
|
159
|
+
...b.slice(I + 1)
|
|
160
|
+
] : [...b, N];
|
|
155
161
|
});
|
|
156
162
|
}, []);
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
},
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
kind:
|
|
164
|
-
status:
|
|
165
|
-
messageId:
|
|
166
|
-
toolName:
|
|
167
|
-
toolDisplayName:
|
|
168
|
-
message:
|
|
169
|
-
data:
|
|
170
|
-
formSchema:
|
|
171
|
-
requiresApproval:
|
|
163
|
+
_(() => {
|
|
164
|
+
const l = (C) => {
|
|
165
|
+
u.current = C.messageId;
|
|
166
|
+
}, h = (C) => {
|
|
167
|
+
const L = _e(C.type);
|
|
168
|
+
L === "reasoning" && !o || p(C.id, {
|
|
169
|
+
kind: L,
|
|
170
|
+
status: be(C.status, L),
|
|
171
|
+
messageId: u.current,
|
|
172
|
+
toolName: C.toolName,
|
|
173
|
+
toolDisplayName: C.toolDisplayName,
|
|
174
|
+
message: C.message,
|
|
175
|
+
data: C.data,
|
|
176
|
+
formSchema: C.formSchema,
|
|
177
|
+
requiresApproval: L === "confirmation" || L === "form"
|
|
172
178
|
});
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
kind:
|
|
179
|
+
}, b = (C) => {
|
|
180
|
+
C.invocationId && p(C.invocationId, {
|
|
181
|
+
kind: C.functionName === "navigateToPage" ? "navigation" : "action",
|
|
176
182
|
status: "running",
|
|
177
|
-
messageId:
|
|
178
|
-
functionName:
|
|
179
|
-
arguments:
|
|
183
|
+
messageId: u.current,
|
|
184
|
+
functionName: C.functionName,
|
|
185
|
+
arguments: C.arguments
|
|
180
186
|
});
|
|
181
|
-
},
|
|
182
|
-
|
|
183
|
-
kind:
|
|
187
|
+
}, I = (C) => {
|
|
188
|
+
C.invocationId && p(C.invocationId, {
|
|
189
|
+
kind: C.functionName === "navigateToPage" ? "navigation" : "action",
|
|
184
190
|
status: "awaiting-approval",
|
|
185
|
-
messageId:
|
|
186
|
-
functionName:
|
|
187
|
-
arguments:
|
|
191
|
+
messageId: u.current,
|
|
192
|
+
functionName: C.functionName,
|
|
193
|
+
arguments: C.arguments,
|
|
188
194
|
requiresApproval: !0
|
|
189
195
|
});
|
|
190
|
-
},
|
|
191
|
-
if (!
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
status:
|
|
196
|
+
}, N = (C) => {
|
|
197
|
+
if (!C.invocationId) return;
|
|
198
|
+
const L = C.result, F = typeof C.result == "object" && L !== null && L.approved === !1 && L.reason === "user_rejected";
|
|
199
|
+
p(C.invocationId, {
|
|
200
|
+
status: C.error ? "error" : F ? "rejected" : "done",
|
|
195
201
|
requiresApproval: !1
|
|
196
202
|
});
|
|
197
|
-
},
|
|
198
|
-
for (const
|
|
199
|
-
if (
|
|
200
|
-
for (const
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
kind:
|
|
204
|
-
status:
|
|
205
|
-
messageId:
|
|
206
|
-
toolName:
|
|
207
|
-
toolDisplayName:
|
|
208
|
-
functionName:
|
|
209
|
-
arguments:
|
|
210
|
-
message:
|
|
211
|
-
data:
|
|
212
|
-
formSchema:
|
|
213
|
-
requiresApproval:
|
|
203
|
+
}, g = (C) => {
|
|
204
|
+
for (const L of C.messages ?? [])
|
|
205
|
+
if (L.role === "assistant")
|
|
206
|
+
for (const F of L.toolCalls ?? []) {
|
|
207
|
+
const M = ut(F);
|
|
208
|
+
M === "reasoning" && !o || /waiting/i.test(F.status ?? "") || p(F.id, {
|
|
209
|
+
kind: M,
|
|
210
|
+
status: be(F.status, M),
|
|
211
|
+
messageId: L.id,
|
|
212
|
+
toolName: F.toolName,
|
|
213
|
+
toolDisplayName: F.toolDisplayName,
|
|
214
|
+
functionName: F.functionName,
|
|
215
|
+
arguments: F.arguments,
|
|
216
|
+
message: F.message,
|
|
217
|
+
data: F.data,
|
|
218
|
+
formSchema: F.formSchema,
|
|
219
|
+
requiresApproval: M === "confirmation" || M === "form"
|
|
214
220
|
});
|
|
215
221
|
}
|
|
216
|
-
},
|
|
217
|
-
|
|
218
|
-
...
|
|
219
|
-
status:
|
|
220
|
-
} :
|
|
221
|
-
}, A = () =>
|
|
222
|
-
return n.on("message:start",
|
|
223
|
-
n.off("message:start",
|
|
222
|
+
}, k = (C) => {
|
|
223
|
+
c((L) => L.map((F) => F.status === "running" || F.status === "awaiting-approval" ? {
|
|
224
|
+
...F,
|
|
225
|
+
status: C
|
|
226
|
+
} : F));
|
|
227
|
+
}, A = () => k("done"), S = () => k("error");
|
|
228
|
+
return n.on("message:start", l), n.on("toolCall:received", h), n.on("function:invoke", b), n.on("function:awaiting-approval", I), n.on("function:result", N), n.on("conversation:loaded", g), n.on("message:complete", A), n.on("message:error", S), () => {
|
|
229
|
+
n.off("message:start", l), n.off("toolCall:received", h), n.off("function:invoke", b), n.off("function:awaiting-approval", I), n.off("function:result", N), n.off("conversation:loaded", g), n.off("message:complete", A), n.off("message:error", S);
|
|
224
230
|
};
|
|
225
231
|
}, [
|
|
226
232
|
n,
|
|
227
|
-
|
|
228
|
-
|
|
233
|
+
o,
|
|
234
|
+
p
|
|
229
235
|
]);
|
|
230
|
-
const
|
|
231
|
-
const
|
|
232
|
-
!
|
|
236
|
+
const m = R(async (l) => {
|
|
237
|
+
const h = s.find((b) => b.id === l);
|
|
238
|
+
!h || h.status !== "awaiting-approval" || i.current.has(l) || h.kind !== "form" && (i.current.add(l), p(l, {
|
|
233
239
|
status: "running",
|
|
234
240
|
requiresApproval: !1
|
|
235
|
-
}),
|
|
241
|
+
}), h.functionName ? await n.approveFunction(l) : await n.confirmToolCall(l));
|
|
236
242
|
}, [
|
|
237
243
|
n,
|
|
238
244
|
s,
|
|
239
|
-
|
|
240
|
-
]),
|
|
241
|
-
const
|
|
242
|
-
!
|
|
245
|
+
p
|
|
246
|
+
]), x = R(async (l) => {
|
|
247
|
+
const h = s.find((b) => b.id === l);
|
|
248
|
+
!h || h.status !== "awaiting-approval" || i.current.has(l) || (i.current.add(l), p(l, {
|
|
243
249
|
status: "rejected",
|
|
244
250
|
requiresApproval: !1
|
|
245
|
-
}),
|
|
251
|
+
}), h.functionName ? await n.rejectFunction(l) : await n.rejectToolCall(l));
|
|
246
252
|
}, [
|
|
247
253
|
n,
|
|
248
254
|
s,
|
|
249
|
-
|
|
250
|
-
]),
|
|
251
|
-
|
|
255
|
+
p
|
|
256
|
+
]), f = R(async (l, h) => {
|
|
257
|
+
p(l, {
|
|
252
258
|
status: "running",
|
|
253
259
|
requiresApproval: !1
|
|
254
|
-
}), await n.submitToolCallForm(
|
|
255
|
-
}, [n,
|
|
256
|
-
i.current.clear(),
|
|
260
|
+
}), await n.submitToolCallForm(l, h), p(l, { status: "done" });
|
|
261
|
+
}, [n, p]), v = R(() => {
|
|
262
|
+
i.current.clear(), c([]);
|
|
257
263
|
}, []);
|
|
258
264
|
return {
|
|
259
265
|
items: s,
|
|
260
266
|
latest: s.length > 0 ? s[s.length - 1] : void 0,
|
|
261
|
-
isAwaitingApproval: s.some((
|
|
262
|
-
approve:
|
|
263
|
-
reject:
|
|
264
|
-
submitForm:
|
|
265
|
-
clear:
|
|
267
|
+
isAwaitingApproval: s.some((l) => dt.has(l.status)),
|
|
268
|
+
approve: m,
|
|
269
|
+
reject: x,
|
|
270
|
+
submitForm: f,
|
|
271
|
+
clear: v
|
|
266
272
|
};
|
|
267
273
|
}
|
|
268
|
-
function
|
|
269
|
-
const t =
|
|
270
|
-
if (!
|
|
271
|
-
const [n, s] =
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}, [
|
|
275
|
-
const
|
|
274
|
+
function Re({ client: e, conversationId: o } = {}) {
|
|
275
|
+
const t = $(), r = e || t;
|
|
276
|
+
if (!r) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
277
|
+
const [n, s] = E([]), [c, i] = E(o), [u, d] = E(!1), [p, m] = E(null);
|
|
278
|
+
_(() => {
|
|
279
|
+
o && o !== c && (i(o), x(o));
|
|
280
|
+
}, [o]);
|
|
281
|
+
const x = async (f) => {
|
|
276
282
|
try {
|
|
277
|
-
s((await
|
|
278
|
-
} catch (
|
|
279
|
-
|
|
283
|
+
s((await r.getMessages(f)).filter((v) => !v.hidden));
|
|
284
|
+
} catch (v) {
|
|
285
|
+
m(v instanceof Error ? v : /* @__PURE__ */ new Error("Failed to load messages"));
|
|
280
286
|
}
|
|
281
287
|
};
|
|
282
|
-
return
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
const A =
|
|
286
|
-
return A >= 0 ?
|
|
287
|
-
...
|
|
288
|
+
return _(() => {
|
|
289
|
+
const f = (g) => g === "IN_PROGRESS" || g === "WAITING_CLIENT", v = (g) => {
|
|
290
|
+
c || i(g.conversationId), d(!0), s((k) => {
|
|
291
|
+
const A = k.findIndex((S) => S.id === g.messageId);
|
|
292
|
+
return A >= 0 ? k.map((S, C) => C === A ? {
|
|
293
|
+
...S,
|
|
288
294
|
status: "IN_PROGRESS"
|
|
289
|
-
} :
|
|
290
|
-
id:
|
|
291
|
-
conversationId:
|
|
295
|
+
} : S) : k.some((S) => S.role === "assistant" && f(S.status)) ? k : [...k, {
|
|
296
|
+
id: g.messageId,
|
|
297
|
+
conversationId: g.conversationId,
|
|
292
298
|
content: "",
|
|
293
299
|
role: "assistant",
|
|
294
300
|
status: "IN_PROGRESS",
|
|
295
301
|
createdAt: /* @__PURE__ */ new Date()
|
|
296
302
|
}];
|
|
297
303
|
});
|
|
298
|
-
},
|
|
299
|
-
s((
|
|
300
|
-
const A =
|
|
301
|
-
return A < 0 ?
|
|
302
|
-
...
|
|
303
|
-
content:
|
|
304
|
-
} :
|
|
304
|
+
}, l = (g) => {
|
|
305
|
+
s((k) => {
|
|
306
|
+
const A = k.findIndex((S) => S.id === g.messageId);
|
|
307
|
+
return A < 0 ? k : k.map((S, C) => C === A ? {
|
|
308
|
+
...S,
|
|
309
|
+
content: S.content + g.content
|
|
310
|
+
} : S);
|
|
305
311
|
});
|
|
306
|
-
},
|
|
307
|
-
s((
|
|
312
|
+
}, h = (g) => {
|
|
313
|
+
s((k) => {
|
|
308
314
|
let A = -1;
|
|
309
|
-
for (let
|
|
310
|
-
A =
|
|
315
|
+
for (let S = k.length - 1; S >= 0; S--) if (k[S].role === "assistant" && f(k[S].status)) {
|
|
316
|
+
A = S;
|
|
311
317
|
break;
|
|
312
318
|
}
|
|
313
|
-
return A < 0 ?
|
|
314
|
-
...
|
|
319
|
+
return A < 0 ? k : [
|
|
320
|
+
...k.slice(0, A),
|
|
315
321
|
{
|
|
316
|
-
...
|
|
317
|
-
...
|
|
322
|
+
...k[A],
|
|
323
|
+
...g
|
|
318
324
|
},
|
|
319
|
-
...
|
|
325
|
+
...k.slice(A + 1)
|
|
320
326
|
];
|
|
321
327
|
});
|
|
322
|
-
},
|
|
323
|
-
s((
|
|
324
|
-
const A =
|
|
328
|
+
}, b = (g) => {
|
|
329
|
+
s((k) => {
|
|
330
|
+
const A = k.findIndex((S) => S.id === g.id);
|
|
325
331
|
return A >= 0 ? [
|
|
326
|
-
...
|
|
327
|
-
|
|
328
|
-
...
|
|
329
|
-
] : [...
|
|
332
|
+
...k.slice(0, A),
|
|
333
|
+
g,
|
|
334
|
+
...k.slice(A + 1)
|
|
335
|
+
] : [...k, g];
|
|
330
336
|
}), d(!1);
|
|
331
|
-
},
|
|
332
|
-
|
|
333
|
-
},
|
|
334
|
-
s((
|
|
335
|
-
let
|
|
336
|
-
for (let A =
|
|
337
|
-
|
|
337
|
+
}, I = (g) => {
|
|
338
|
+
m(new Error(g.error)), d(!1);
|
|
339
|
+
}, N = () => {
|
|
340
|
+
s((g) => {
|
|
341
|
+
let k = -1;
|
|
342
|
+
for (let A = g.length - 1; A >= 0; A--) if (g[A].role === "assistant" && f(g[A].status)) {
|
|
343
|
+
k = A;
|
|
338
344
|
break;
|
|
339
345
|
}
|
|
340
|
-
return
|
|
346
|
+
return k < 0 ? g : g[k].content ? g.map((A, S) => S === k ? {
|
|
341
347
|
...A,
|
|
342
348
|
status: "CANCELED"
|
|
343
|
-
} : A) :
|
|
349
|
+
} : A) : g.filter((A, S) => S !== k);
|
|
344
350
|
}), d(!1);
|
|
345
351
|
};
|
|
346
|
-
return
|
|
347
|
-
|
|
352
|
+
return r.on("message:start", v), r.on("message:chunk", l), r.on("message:answer-complete", h), r.on("message:complete", b), r.on("message:error", I), r.on("message:stopped", N), () => {
|
|
353
|
+
r.off("message:start", v), r.off("message:chunk", l), r.off("message:answer-complete", h), r.off("message:complete", b), r.off("message:error", I), r.off("message:stopped", N);
|
|
348
354
|
};
|
|
349
|
-
}, [
|
|
355
|
+
}, [r, c]), {
|
|
350
356
|
messages: n,
|
|
351
|
-
isLoading:
|
|
352
|
-
error:
|
|
353
|
-
sendMessage:
|
|
354
|
-
d(!0),
|
|
355
|
-
const
|
|
357
|
+
isLoading: u,
|
|
358
|
+
error: p,
|
|
359
|
+
sendMessage: R(async (f, v) => {
|
|
360
|
+
d(!0), m(null);
|
|
361
|
+
const l = {
|
|
356
362
|
id: `temp-${Date.now()}`,
|
|
357
|
-
conversationId:
|
|
358
|
-
content:
|
|
363
|
+
conversationId: c || "",
|
|
364
|
+
content: f,
|
|
359
365
|
role: "user",
|
|
360
366
|
status: "DONE",
|
|
361
|
-
attachments:
|
|
367
|
+
attachments: v && v.length > 0 ? Oe(v) : void 0,
|
|
362
368
|
createdAt: /* @__PURE__ */ new Date()
|
|
363
|
-
},
|
|
369
|
+
}, h = {
|
|
364
370
|
id: `temp-assistant-${Date.now()}`,
|
|
365
|
-
conversationId:
|
|
371
|
+
conversationId: c || "",
|
|
366
372
|
content: "",
|
|
367
373
|
role: "assistant",
|
|
368
374
|
status: "IN_PROGRESS",
|
|
369
375
|
createdAt: /* @__PURE__ */ new Date()
|
|
370
376
|
};
|
|
371
|
-
s((
|
|
372
|
-
...
|
|
373
|
-
|
|
374
|
-
|
|
377
|
+
s((b) => [
|
|
378
|
+
...b,
|
|
379
|
+
l,
|
|
380
|
+
h
|
|
375
381
|
]);
|
|
376
382
|
try {
|
|
377
|
-
const
|
|
378
|
-
conversationId:
|
|
379
|
-
files:
|
|
383
|
+
const b = await r.sendMessage(f, {
|
|
384
|
+
conversationId: c,
|
|
385
|
+
files: v
|
|
380
386
|
});
|
|
381
|
-
return
|
|
382
|
-
const
|
|
383
|
-
...
|
|
384
|
-
id:
|
|
385
|
-
conversationId:
|
|
387
|
+
return b.conversationId && !c && i(b.conversationId), s((I) => {
|
|
388
|
+
const N = I.filter((k) => !k.id.startsWith("temp-")), g = {
|
|
389
|
+
...l,
|
|
390
|
+
id: l.id.replace("temp-", "user-"),
|
|
391
|
+
conversationId: b.conversationId
|
|
386
392
|
};
|
|
387
|
-
return
|
|
388
|
-
...
|
|
389
|
-
|
|
390
|
-
|
|
393
|
+
return N.some((k) => k.id === b.id) ? [...N, g].sort((k, A) => new Date(k.createdAt).getTime() - new Date(A.createdAt).getTime()) : [
|
|
394
|
+
...N,
|
|
395
|
+
g,
|
|
396
|
+
b
|
|
391
397
|
];
|
|
392
|
-
}),
|
|
393
|
-
} catch (
|
|
394
|
-
return
|
|
398
|
+
}), b;
|
|
399
|
+
} catch (b) {
|
|
400
|
+
return m(b instanceof Error ? b : /* @__PURE__ */ new Error("Failed to send message")), d(!1), s((I) => I.filter((N) => !N.id.startsWith("temp-"))), null;
|
|
395
401
|
}
|
|
396
|
-
}, [
|
|
397
|
-
stop:
|
|
398
|
-
await
|
|
399
|
-
}, [
|
|
400
|
-
clearMessages:
|
|
401
|
-
s([]), i(void 0),
|
|
402
|
+
}, [r, c]),
|
|
403
|
+
stop: R(async () => {
|
|
404
|
+
await r.stop();
|
|
405
|
+
}, [r]),
|
|
406
|
+
clearMessages: R(() => {
|
|
407
|
+
s([]), i(void 0), m(null);
|
|
402
408
|
}, []),
|
|
403
|
-
conversationId:
|
|
409
|
+
conversationId: c
|
|
404
410
|
};
|
|
405
411
|
}
|
|
406
|
-
var
|
|
412
|
+
var ve = {
|
|
407
413
|
compact: !1,
|
|
408
414
|
state: "peek",
|
|
409
415
|
isModal: !1,
|
|
@@ -411,49 +417,49 @@ var pe = {
|
|
|
411
417
|
style: {},
|
|
412
418
|
attrs: {}
|
|
413
419
|
}
|
|
414
|
-
},
|
|
415
|
-
function
|
|
416
|
-
const
|
|
417
|
-
for (const [t,
|
|
418
|
-
return
|
|
420
|
+
}, gt = { tabindex: "tabIndex" };
|
|
421
|
+
function mt(e) {
|
|
422
|
+
const o = {};
|
|
423
|
+
for (const [t, r] of Object.entries(e)) o[gt[t] ?? t] = r;
|
|
424
|
+
return o;
|
|
419
425
|
}
|
|
420
|
-
function
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
const n =
|
|
424
|
-
if (
|
|
425
|
-
return
|
|
426
|
+
function ht(e) {
|
|
427
|
+
const o = e !== !1, t = o ? e ?? {} : void 0, r = D(t?.onStateChange);
|
|
428
|
+
r.current = t?.onStateChange;
|
|
429
|
+
const n = U(() => {
|
|
430
|
+
if (o)
|
|
431
|
+
return Ve({
|
|
426
432
|
breakpoint: t?.breakpoint,
|
|
427
433
|
initialState: t?.initialState,
|
|
428
434
|
bottomOffset: t?.bottomOffset,
|
|
429
435
|
peekHeight: t?.peekHeight,
|
|
430
|
-
onStateChange: (
|
|
436
|
+
onStateChange: (c, i) => r.current?.(c, i)
|
|
431
437
|
});
|
|
432
438
|
}, [
|
|
433
|
-
|
|
439
|
+
o,
|
|
434
440
|
t?.breakpoint,
|
|
435
441
|
t?.initialState,
|
|
436
442
|
t?.bottomOffset,
|
|
437
443
|
t?.peekHeight
|
|
438
|
-
]), s =
|
|
439
|
-
}), [n]),
|
|
444
|
+
]), s = ce(R((c) => n?.subscribe(c) ?? (() => {
|
|
445
|
+
}), [n]), R(() => n?.getSnapshot() ?? ve, [n]), R(() => n?.getServerSnapshot() ?? ve, [n]));
|
|
440
446
|
return {
|
|
441
|
-
sheet:
|
|
447
|
+
sheet: U(() => ({
|
|
442
448
|
...s,
|
|
443
449
|
surface: {
|
|
444
450
|
...s.surface,
|
|
445
|
-
attrs:
|
|
451
|
+
attrs: mt(s.surface.attrs)
|
|
446
452
|
}
|
|
447
453
|
}), [s]),
|
|
448
|
-
expand:
|
|
449
|
-
collapse:
|
|
450
|
-
toggle:
|
|
454
|
+
expand: R((c) => n?.expand(c), [n]),
|
|
455
|
+
collapse: R((c) => n?.collapse(c), [n]),
|
|
456
|
+
toggle: R((c) => n?.toggle(c), [n])
|
|
451
457
|
};
|
|
452
458
|
}
|
|
453
|
-
var
|
|
454
|
-
function
|
|
455
|
-
const
|
|
456
|
-
return
|
|
459
|
+
var xt = /(`[^`\n]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|_[^_\n]+_)/g;
|
|
460
|
+
function Ie(e) {
|
|
461
|
+
const o = e.split(xt);
|
|
462
|
+
return o.length === 1 ? e : o.map((t, r) => r % 2 === 0 || !t ? t : t.startsWith("`") ? /* @__PURE__ */ a("code", {
|
|
457
463
|
style: {
|
|
458
464
|
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
459
465
|
fontSize: "0.92em",
|
|
@@ -462,12 +468,12 @@ function Ce(e) {
|
|
|
462
468
|
backgroundColor: "rgba(0, 0, 0, 0.06)"
|
|
463
469
|
},
|
|
464
470
|
children: t.slice(1, -1)
|
|
465
|
-
},
|
|
471
|
+
}, r) : t.startsWith("**") ? /* @__PURE__ */ a("strong", {
|
|
466
472
|
style: { fontWeight: 600 },
|
|
467
473
|
children: t.slice(2, -2)
|
|
468
|
-
},
|
|
474
|
+
}, r) : /* @__PURE__ */ a("em", { children: t.slice(1, -1) }, r));
|
|
469
475
|
}
|
|
470
|
-
var
|
|
476
|
+
var bt = `
|
|
471
477
|
@keyframes ago-activity-enter {
|
|
472
478
|
from { opacity: 0; transform: translateY(4px); }
|
|
473
479
|
to { opacity: 1; transform: none; }
|
|
@@ -504,7 +510,7 @@ var dt = `
|
|
|
504
510
|
color: var(--ago-activity-color, #5b5d5f);
|
|
505
511
|
}
|
|
506
512
|
}
|
|
507
|
-
`,
|
|
513
|
+
`, yt = ({ label: e }) => /* @__PURE__ */ W("div", {
|
|
508
514
|
className: "ago-activity",
|
|
509
515
|
role: "status",
|
|
510
516
|
"aria-live": "polite",
|
|
@@ -525,105 +531,105 @@ var dt = `
|
|
|
525
531
|
},
|
|
526
532
|
children: [/* @__PURE__ */ a("span", {
|
|
527
533
|
className: "ago-activity__label",
|
|
528
|
-
children:
|
|
529
|
-
}, e), /* @__PURE__ */ a("style", { children:
|
|
530
|
-
}),
|
|
531
|
-
function
|
|
532
|
-
const
|
|
533
|
-
return
|
|
534
|
-
|
|
535
|
-
}),
|
|
536
|
-
if (
|
|
537
|
-
let
|
|
538
|
-
const
|
|
539
|
-
transcribe: (
|
|
540
|
-
onText: (
|
|
541
|
-
|
|
534
|
+
children: Ie(e)
|
|
535
|
+
}, e), /* @__PURE__ */ a("style", { children: bt })]
|
|
536
|
+
}), Z = typeof window > "u" ? _ : st;
|
|
537
|
+
function vt(e) {
|
|
538
|
+
const o = $(), t = e.client ?? o, r = Q(t), n = D(null), s = D(), c = D(e), [i, u] = E(!1), [d, p] = E(""), [m, x] = E(!1);
|
|
539
|
+
return Z(() => {
|
|
540
|
+
c.current = e;
|
|
541
|
+
}), Z(() => {
|
|
542
|
+
if (x(!1), u(!1), c.current.onBusyChange?.(!1), !t || !n.current) return;
|
|
543
|
+
let f = !0;
|
|
544
|
+
const v = Qe({
|
|
545
|
+
transcribe: (l, h) => t.transcribeAudio(l, h),
|
|
546
|
+
onText: (l) => {
|
|
547
|
+
f && c.current.onTranscript(l);
|
|
542
548
|
},
|
|
543
|
-
onBusy: (
|
|
544
|
-
|
|
549
|
+
onBusy: (l) => {
|
|
550
|
+
f && (u(l), l && p(""), c.current.onBusyChange?.(l));
|
|
545
551
|
},
|
|
546
|
-
onError: (
|
|
547
|
-
|
|
552
|
+
onError: (l) => {
|
|
553
|
+
f && p(l);
|
|
548
554
|
},
|
|
549
|
-
labels:
|
|
555
|
+
labels: re(r.speech, c.current.labels)
|
|
550
556
|
});
|
|
551
|
-
return
|
|
552
|
-
if (!
|
|
553
|
-
const
|
|
554
|
-
|
|
557
|
+
return n.current.append(v.el), s.current = v, v.setDisabled(!!c.current.disabled), t.getConfig().then(({ permissions: l }) => {
|
|
558
|
+
if (!f) return;
|
|
559
|
+
const h = l.some((b) => b.speechToTextEnabled) && typeof MediaRecorder < "u" && !!navigator.mediaDevices?.getUserMedia;
|
|
560
|
+
v.setEnabled(h), x(h);
|
|
555
561
|
}).catch(() => {
|
|
556
562
|
}), () => {
|
|
557
|
-
|
|
563
|
+
f = !1, v.destroy(), c.current.onBusyChange?.(!1), v.el.remove(), s.current = void 0;
|
|
558
564
|
};
|
|
559
|
-
}, [t]),
|
|
560
|
-
|
|
561
|
-
}, [e.disabled]),
|
|
562
|
-
|
|
563
|
-
}, [e.scopeKey, t]),
|
|
564
|
-
|
|
565
|
-
}, [e.labels]), /* @__PURE__ */
|
|
565
|
+
}, [t]), Z(() => {
|
|
566
|
+
s.current?.setDisabled(!!e.disabled);
|
|
567
|
+
}, [e.disabled]), Z(() => {
|
|
568
|
+
s.current?.cancel();
|
|
569
|
+
}, [e.scopeKey, t]), Z(() => {
|
|
570
|
+
s.current?.setLabels(re(r.speech, e.labels));
|
|
571
|
+
}, [r, e.labels]), /* @__PURE__ */ W("div", {
|
|
566
572
|
className: `ago-speech-to-text ${e.className ?? ""}`,
|
|
567
573
|
style: {
|
|
568
|
-
display:
|
|
574
|
+
display: m ? "flex" : "none",
|
|
569
575
|
flexDirection: "column",
|
|
570
576
|
minWidth: 0,
|
|
571
|
-
flex:
|
|
577
|
+
flex: i ? 1 : void 0
|
|
572
578
|
},
|
|
573
|
-
children: [/* @__PURE__ */ a("div", { ref:
|
|
579
|
+
children: [/* @__PURE__ */ a("div", { ref: n }), d && /* @__PURE__ */ a("span", {
|
|
574
580
|
role: "alert",
|
|
575
581
|
style: {
|
|
576
582
|
color: "var(--ago-muted-text-color, #6b6d6f)",
|
|
577
583
|
fontSize: "13px"
|
|
578
584
|
},
|
|
579
|
-
children:
|
|
585
|
+
children: d
|
|
580
586
|
})]
|
|
581
587
|
});
|
|
582
588
|
}
|
|
583
|
-
var
|
|
584
|
-
const
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
}, [
|
|
588
|
-
const
|
|
589
|
-
const
|
|
590
|
-
if (!
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
}, []),
|
|
594
|
-
|
|
595
|
-
|
|
589
|
+
var wt = ({ onSend: e, onStop: o, disabled: t = !1, placeholder: r, allowFiles: n = !1, speechToText: s = !1, client: c, scopeKey: i, className: u = "" }) => {
|
|
590
|
+
const d = Q(c), p = r ?? d.common.placeholder, [m, x] = E(""), [f, v] = E([]), [l, h] = E(!1), b = D(null), I = D(null), N = !!s;
|
|
591
|
+
_(() => {
|
|
592
|
+
N || h(!1);
|
|
593
|
+
}, [N]);
|
|
594
|
+
const g = R(() => {
|
|
595
|
+
const w = I.current;
|
|
596
|
+
if (!w) return;
|
|
597
|
+
const T = 110;
|
|
598
|
+
w.style.height = "auto", w.style.height = `${Math.min(w.scrollHeight + 2, T)}px`, w.style.overflowY = w.scrollHeight + 2 > T ? "auto" : "hidden";
|
|
599
|
+
}, []), k = D(!1);
|
|
600
|
+
_(() => {
|
|
601
|
+
k.current && !l && !t && (g(), I.current?.focus()), k.current = l;
|
|
596
602
|
}, [
|
|
597
|
-
|
|
603
|
+
l,
|
|
598
604
|
t,
|
|
599
|
-
|
|
605
|
+
g
|
|
600
606
|
]);
|
|
601
|
-
const
|
|
602
|
-
if (
|
|
603
|
-
const
|
|
604
|
-
|
|
607
|
+
const A = R(async (w) => {
|
|
608
|
+
if (w.preventDefault(), t || l || !m.trim()) return;
|
|
609
|
+
const T = m.trim(), q = f.length > 0 ? f : void 0;
|
|
610
|
+
x(""), v([]), requestAnimationFrame(g), await e(T, q) === !1 && (x((O) => O.trim() ? O : T), q && v((O) => [...q, ...O]), requestAnimationFrame(g));
|
|
605
611
|
}, [
|
|
606
|
-
|
|
607
|
-
|
|
612
|
+
m,
|
|
613
|
+
f,
|
|
608
614
|
e,
|
|
609
|
-
|
|
615
|
+
g,
|
|
610
616
|
t,
|
|
611
|
-
|
|
612
|
-
]),
|
|
613
|
-
|
|
614
|
-
}, [
|
|
615
|
-
const
|
|
616
|
-
|
|
617
|
-
}, []),
|
|
618
|
-
|
|
619
|
-
}, []),
|
|
620
|
-
|
|
617
|
+
l
|
|
618
|
+
]), S = R((w) => {
|
|
619
|
+
w.key === "Enter" && !w.shiftKey && (w.preventDefault(), A(w));
|
|
620
|
+
}, [A]), C = R((w) => {
|
|
621
|
+
const T = Array.from(w.target.files || []);
|
|
622
|
+
v((q) => [...q, ...T]);
|
|
623
|
+
}, []), L = R((w) => {
|
|
624
|
+
v((T) => T.filter((q, O) => O !== w));
|
|
625
|
+
}, []), F = m.trim().length > 0, M = (w) => {
|
|
626
|
+
x((T) => `${T}${T && !/\s$/.test(T) ? " " : ""}${w}`);
|
|
621
627
|
};
|
|
622
|
-
return /* @__PURE__ */
|
|
623
|
-
onSubmit: (
|
|
624
|
-
|
|
628
|
+
return /* @__PURE__ */ W("form", {
|
|
629
|
+
onSubmit: (w) => {
|
|
630
|
+
A(w);
|
|
625
631
|
},
|
|
626
|
-
className: `ago-chat-input ${
|
|
632
|
+
className: `ago-chat-input ${u}`,
|
|
627
633
|
style: {
|
|
628
634
|
display: "flex",
|
|
629
635
|
flexDirection: "column",
|
|
@@ -632,14 +638,14 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
632
638
|
borderTop: "1px solid #dee3e8",
|
|
633
639
|
backgroundColor: "#fff"
|
|
634
640
|
},
|
|
635
|
-
children: [
|
|
641
|
+
children: [f.length > 0 && !l && /* @__PURE__ */ a("div", {
|
|
636
642
|
className: "ago-chat-input__files",
|
|
637
643
|
style: {
|
|
638
644
|
display: "flex",
|
|
639
645
|
flexWrap: "wrap",
|
|
640
646
|
gap: "6px"
|
|
641
647
|
},
|
|
642
|
-
children:
|
|
648
|
+
children: f.map((w, T) => /* @__PURE__ */ W("div", {
|
|
643
649
|
style: {
|
|
644
650
|
display: "flex",
|
|
645
651
|
alignItems: "center",
|
|
@@ -657,11 +663,11 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
657
663
|
textOverflow: "ellipsis",
|
|
658
664
|
whiteSpace: "nowrap"
|
|
659
665
|
},
|
|
660
|
-
children:
|
|
666
|
+
children: w.name
|
|
661
667
|
}), /* @__PURE__ */ a("button", {
|
|
662
668
|
type: "button",
|
|
663
|
-
onClick: () =>
|
|
664
|
-
"aria-label":
|
|
669
|
+
onClick: () => L(T),
|
|
670
|
+
"aria-label": d.form.removeFile.replace("{filename}", () => w.name),
|
|
665
671
|
style: {
|
|
666
672
|
flexShrink: 0,
|
|
667
673
|
width: "44px",
|
|
@@ -680,19 +686,19 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
680
686
|
},
|
|
681
687
|
children: "×"
|
|
682
688
|
})]
|
|
683
|
-
},
|
|
684
|
-
}), /* @__PURE__ */
|
|
689
|
+
}, T))
|
|
690
|
+
}), /* @__PURE__ */ W("div", {
|
|
685
691
|
style: {
|
|
686
692
|
display: "flex",
|
|
687
693
|
gap: "8px",
|
|
688
694
|
alignItems: "flex-end"
|
|
689
695
|
},
|
|
690
696
|
children: [
|
|
691
|
-
n && !
|
|
697
|
+
n && !l && /* @__PURE__ */ W(Ne, { children: [/* @__PURE__ */ a("button", {
|
|
692
698
|
type: "button",
|
|
693
|
-
onClick: () =>
|
|
699
|
+
onClick: () => b.current?.click(),
|
|
694
700
|
disabled: t,
|
|
695
|
-
"aria-label":
|
|
701
|
+
"aria-label": d.common.attachFile,
|
|
696
702
|
style: {
|
|
697
703
|
flexShrink: 0,
|
|
698
704
|
minWidth: "44px",
|
|
@@ -711,26 +717,26 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
711
717
|
},
|
|
712
718
|
children: "+"
|
|
713
719
|
}), /* @__PURE__ */ a("input", {
|
|
714
|
-
ref:
|
|
720
|
+
ref: b,
|
|
715
721
|
type: "file",
|
|
716
722
|
multiple: !0,
|
|
717
|
-
onChange:
|
|
723
|
+
onChange: C,
|
|
718
724
|
style: { display: "none" }
|
|
719
725
|
})] }),
|
|
720
726
|
/* @__PURE__ */ a("textarea", {
|
|
721
|
-
ref:
|
|
727
|
+
ref: I,
|
|
722
728
|
className: "ago-chat-input__field",
|
|
723
|
-
value:
|
|
724
|
-
onChange: (
|
|
725
|
-
|
|
729
|
+
value: m,
|
|
730
|
+
onChange: (w) => {
|
|
731
|
+
x(w.target.value), g();
|
|
726
732
|
},
|
|
727
|
-
onKeyDown:
|
|
728
|
-
placeholder:
|
|
729
|
-
"aria-label":
|
|
730
|
-
disabled: t ||
|
|
733
|
+
onKeyDown: S,
|
|
734
|
+
placeholder: p,
|
|
735
|
+
"aria-label": p,
|
|
736
|
+
disabled: t || l,
|
|
731
737
|
rows: 1,
|
|
732
738
|
style: {
|
|
733
|
-
display:
|
|
739
|
+
display: l ? "none" : void 0,
|
|
734
740
|
flex: 1,
|
|
735
741
|
padding: "10px 14px",
|
|
736
742
|
border: "1px solid #dee3e8",
|
|
@@ -747,25 +753,25 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
747
753
|
backgroundColor: "#f8f8f8",
|
|
748
754
|
transition: "border-color 0.15s"
|
|
749
755
|
},
|
|
750
|
-
onFocus: (
|
|
751
|
-
|
|
756
|
+
onFocus: (w) => {
|
|
757
|
+
w.currentTarget.style.borderColor = "#1b5fc4";
|
|
752
758
|
},
|
|
753
|
-
onBlur: (
|
|
754
|
-
|
|
759
|
+
onBlur: (w) => {
|
|
760
|
+
w.currentTarget.style.borderColor = "#dee3e8";
|
|
755
761
|
}
|
|
756
762
|
}),
|
|
757
|
-
s && /* @__PURE__ */ a(
|
|
758
|
-
client:
|
|
763
|
+
s && /* @__PURE__ */ a(vt, {
|
|
764
|
+
client: c,
|
|
759
765
|
disabled: t,
|
|
760
766
|
scopeKey: i,
|
|
761
767
|
labels: typeof s == "object" ? s.labels : void 0,
|
|
762
|
-
onTranscript:
|
|
763
|
-
onBusyChange:
|
|
768
|
+
onTranscript: M,
|
|
769
|
+
onBusyChange: h
|
|
764
770
|
}),
|
|
765
|
-
!
|
|
771
|
+
!l && (t && o ? /* @__PURE__ */ a("button", {
|
|
766
772
|
type: "button",
|
|
767
|
-
onClick:
|
|
768
|
-
"aria-label":
|
|
773
|
+
onClick: o,
|
|
774
|
+
"aria-label": d.common.stop,
|
|
769
775
|
style: {
|
|
770
776
|
minHeight: "44px",
|
|
771
777
|
padding: "10px 18px",
|
|
@@ -778,28 +784,28 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
778
784
|
fontSize: "16px",
|
|
779
785
|
transition: "background-color 0.15s"
|
|
780
786
|
},
|
|
781
|
-
children:
|
|
787
|
+
children: d.common.stopButton
|
|
782
788
|
}) : /* @__PURE__ */ a("button", {
|
|
783
789
|
type: "submit",
|
|
784
|
-
disabled: t || !
|
|
790
|
+
disabled: t || !F,
|
|
785
791
|
style: {
|
|
786
792
|
minHeight: "44px",
|
|
787
793
|
padding: "10px 18px",
|
|
788
794
|
border: "none",
|
|
789
795
|
borderRadius: "20px",
|
|
790
|
-
backgroundColor: t || !
|
|
796
|
+
backgroundColor: t || !F ? "#b5bfc8" : "#03182f",
|
|
791
797
|
color: "#fff",
|
|
792
|
-
cursor: t || !
|
|
798
|
+
cursor: t || !F ? "not-allowed" : "pointer",
|
|
793
799
|
fontWeight: 500,
|
|
794
800
|
fontSize: "16px",
|
|
795
801
|
transition: "background-color 0.15s"
|
|
796
802
|
},
|
|
797
|
-
children:
|
|
803
|
+
children: d.common.send
|
|
798
804
|
}))
|
|
799
805
|
]
|
|
800
806
|
})]
|
|
801
807
|
});
|
|
802
|
-
},
|
|
808
|
+
}, kt = ({ href: e, children: o, ...t }) => /* @__PURE__ */ a("a", {
|
|
803
809
|
href: e,
|
|
804
810
|
target: "_blank",
|
|
805
811
|
rel: "noopener noreferrer",
|
|
@@ -808,52 +814,52 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
808
814
|
textDecoration: "underline"
|
|
809
815
|
},
|
|
810
816
|
...t,
|
|
811
|
-
children:
|
|
812
|
-
}),
|
|
817
|
+
children: o
|
|
818
|
+
}), Ct = ({ children: e, ...o }) => /* @__PURE__ */ a("p", {
|
|
813
819
|
style: {
|
|
814
820
|
margin: "0 0 8px 0",
|
|
815
821
|
lineHeight: "1.6"
|
|
816
822
|
},
|
|
817
|
-
...
|
|
823
|
+
...o,
|
|
818
824
|
children: e
|
|
819
|
-
}),
|
|
820
|
-
const t = ({ children:
|
|
825
|
+
}), J = (e, o) => {
|
|
826
|
+
const t = ({ children: r, ...n }) => tt.createElement(`h${e}`, {
|
|
821
827
|
style: {
|
|
822
828
|
margin: "16px 0 8px 0",
|
|
823
|
-
fontSize:
|
|
829
|
+
fontSize: o,
|
|
824
830
|
fontWeight: 600,
|
|
825
831
|
lineHeight: "1.3"
|
|
826
832
|
},
|
|
827
833
|
...n
|
|
828
|
-
},
|
|
834
|
+
}, r);
|
|
829
835
|
return t.displayName = `MarkdownHeading${e}`, t;
|
|
830
|
-
},
|
|
836
|
+
}, St = ({ children: e, ...o }) => /* @__PURE__ */ a("ul", {
|
|
831
837
|
style: {
|
|
832
838
|
margin: "0 0 8px 0",
|
|
833
839
|
paddingLeft: "20px",
|
|
834
840
|
listStyleType: "disc",
|
|
835
841
|
listStylePosition: "outside"
|
|
836
842
|
},
|
|
837
|
-
...
|
|
843
|
+
...o,
|
|
838
844
|
children: e
|
|
839
|
-
}),
|
|
845
|
+
}), At = ({ children: e, ...o }) => /* @__PURE__ */ a("ol", {
|
|
840
846
|
style: {
|
|
841
847
|
margin: "0 0 8px 0",
|
|
842
848
|
paddingLeft: "20px",
|
|
843
849
|
listStyleType: "decimal",
|
|
844
850
|
listStylePosition: "outside"
|
|
845
851
|
},
|
|
846
|
-
...
|
|
852
|
+
...o,
|
|
847
853
|
children: e
|
|
848
|
-
}),
|
|
854
|
+
}), Nt = ({ children: e, ...o }) => /* @__PURE__ */ a("li", {
|
|
849
855
|
style: {
|
|
850
856
|
display: "list-item",
|
|
851
857
|
margin: "2px 0",
|
|
852
858
|
lineHeight: "1.6"
|
|
853
859
|
},
|
|
854
|
-
...
|
|
860
|
+
...o,
|
|
855
861
|
children: e
|
|
856
|
-
}),
|
|
862
|
+
}), _t = ({ className: e, children: o, ...t }) => e !== void 0 || String(o).includes(`
|
|
857
863
|
`) ? /* @__PURE__ */ a("code", {
|
|
858
864
|
style: {
|
|
859
865
|
display: "block",
|
|
@@ -865,7 +871,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
865
871
|
fontFamily: '"IBM Plex Mono", monospace'
|
|
866
872
|
},
|
|
867
873
|
...t,
|
|
868
|
-
children:
|
|
874
|
+
children: o
|
|
869
875
|
}) : /* @__PURE__ */ a("code", {
|
|
870
876
|
style: {
|
|
871
877
|
background: "#f0f2f5",
|
|
@@ -875,12 +881,12 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
875
881
|
fontFamily: '"IBM Plex Mono", monospace'
|
|
876
882
|
},
|
|
877
883
|
...t,
|
|
878
|
-
children:
|
|
879
|
-
}),
|
|
884
|
+
children: o
|
|
885
|
+
}), Rt = ({ children: e, ...o }) => /* @__PURE__ */ a("pre", {
|
|
880
886
|
style: { margin: "0 0 8px 0" },
|
|
881
|
-
...
|
|
887
|
+
...o,
|
|
882
888
|
children: e
|
|
883
|
-
}),
|
|
889
|
+
}), It = ({ children: e, ...o }) => /* @__PURE__ */ a("blockquote", {
|
|
884
890
|
style: {
|
|
885
891
|
borderLeft: "4px solid #dee3e8",
|
|
886
892
|
paddingLeft: "12px",
|
|
@@ -888,9 +894,9 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
888
894
|
fontStyle: "italic",
|
|
889
895
|
color: "#6b6d6f"
|
|
890
896
|
},
|
|
891
|
-
...
|
|
897
|
+
...o,
|
|
892
898
|
children: e
|
|
893
|
-
}),
|
|
899
|
+
}), Et = ({ children: e, ...o }) => /* @__PURE__ */ a("div", {
|
|
894
900
|
style: {
|
|
895
901
|
overflowX: "auto",
|
|
896
902
|
margin: "0 0 8px 0"
|
|
@@ -901,10 +907,10 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
901
907
|
width: "100%",
|
|
902
908
|
fontSize: "13px"
|
|
903
909
|
},
|
|
904
|
-
...
|
|
910
|
+
...o,
|
|
905
911
|
children: e
|
|
906
912
|
})
|
|
907
|
-
}),
|
|
913
|
+
}), Mt = ({ children: e, ...o }) => /* @__PURE__ */ a("th", {
|
|
908
914
|
style: {
|
|
909
915
|
border: "1px solid #dee3e8",
|
|
910
916
|
padding: "6px 10px",
|
|
@@ -912,57 +918,57 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
912
918
|
backgroundColor: "#f5f7fa",
|
|
913
919
|
fontWeight: 600
|
|
914
920
|
},
|
|
915
|
-
...
|
|
921
|
+
...o,
|
|
916
922
|
children: e
|
|
917
|
-
}),
|
|
923
|
+
}), Tt = ({ children: e, ...o }) => /* @__PURE__ */ a("td", {
|
|
918
924
|
style: {
|
|
919
925
|
border: "1px solid #dee3e8",
|
|
920
926
|
padding: "6px 10px"
|
|
921
927
|
},
|
|
922
|
-
...
|
|
928
|
+
...o,
|
|
923
929
|
children: e
|
|
924
|
-
}),
|
|
930
|
+
}), Ft = ({ alt: e, ...o }) => /* @__PURE__ */ a("img", {
|
|
925
931
|
alt: e ?? "",
|
|
926
932
|
style: {
|
|
927
933
|
maxWidth: "100%",
|
|
928
934
|
borderRadius: "8px",
|
|
929
935
|
margin: "4px 0"
|
|
930
936
|
},
|
|
931
|
-
...
|
|
932
|
-
}),
|
|
937
|
+
...o
|
|
938
|
+
}), Lt = (e) => /* @__PURE__ */ a("hr", {
|
|
933
939
|
style: {
|
|
934
940
|
border: "none",
|
|
935
941
|
borderTop: "1px solid #dee3e8",
|
|
936
942
|
margin: "12px 0"
|
|
937
943
|
},
|
|
938
944
|
...e
|
|
939
|
-
}),
|
|
940
|
-
a:
|
|
941
|
-
p:
|
|
942
|
-
h1:
|
|
943
|
-
h2:
|
|
944
|
-
h3:
|
|
945
|
-
h4:
|
|
946
|
-
h5:
|
|
947
|
-
h6:
|
|
948
|
-
ul:
|
|
949
|
-
ol:
|
|
950
|
-
li:
|
|
951
|
-
code:
|
|
952
|
-
pre:
|
|
953
|
-
blockquote:
|
|
954
|
-
table:
|
|
955
|
-
th:
|
|
956
|
-
td:
|
|
957
|
-
img:
|
|
958
|
-
hr:
|
|
959
|
-
},
|
|
960
|
-
remarkPlugins:
|
|
961
|
-
components:
|
|
945
|
+
}), Wt = {
|
|
946
|
+
a: kt,
|
|
947
|
+
p: Ct,
|
|
948
|
+
h1: J(1, "20px"),
|
|
949
|
+
h2: J(2, "18px"),
|
|
950
|
+
h3: J(3, "16px"),
|
|
951
|
+
h4: J(4, "15px"),
|
|
952
|
+
h5: J(5, "14px"),
|
|
953
|
+
h6: J(6, "13px"),
|
|
954
|
+
ul: St,
|
|
955
|
+
ol: At,
|
|
956
|
+
li: Nt,
|
|
957
|
+
code: _t,
|
|
958
|
+
pre: Rt,
|
|
959
|
+
blockquote: It,
|
|
960
|
+
table: Et,
|
|
961
|
+
th: Mt,
|
|
962
|
+
td: Tt,
|
|
963
|
+
img: Ft,
|
|
964
|
+
hr: Lt
|
|
965
|
+
}, Dt = [lt], zt = ({ content: e }) => /* @__PURE__ */ a(it, {
|
|
966
|
+
remarkPlugins: Dt,
|
|
967
|
+
components: Wt,
|
|
962
968
|
children: e
|
|
963
|
-
}),
|
|
964
|
-
const t =
|
|
965
|
-
if (
|
|
969
|
+
}), Bt = ({ attachment: e, isUser: o }) => {
|
|
970
|
+
const t = $e(e.url);
|
|
971
|
+
if (Ue(e)) return /* @__PURE__ */ a("a", {
|
|
966
972
|
href: t,
|
|
967
973
|
target: "_blank",
|
|
968
974
|
rel: "noopener noreferrer",
|
|
@@ -984,7 +990,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
984
990
|
}
|
|
985
991
|
})
|
|
986
992
|
});
|
|
987
|
-
const
|
|
993
|
+
const r = Ke(e.fileSize), n = /* @__PURE__ */ W(Ne, { children: [/* @__PURE__ */ a("span", {
|
|
988
994
|
style: {
|
|
989
995
|
fontSize: "16px",
|
|
990
996
|
lineHeight: 1,
|
|
@@ -992,7 +998,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
992
998
|
},
|
|
993
999
|
"aria-hidden": !0,
|
|
994
1000
|
children: "📄"
|
|
995
|
-
}), /* @__PURE__ */
|
|
1001
|
+
}), /* @__PURE__ */ W("span", {
|
|
996
1002
|
style: {
|
|
997
1003
|
display: "flex",
|
|
998
1004
|
flexDirection: "column",
|
|
@@ -1007,12 +1013,12 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
1007
1013
|
},
|
|
1008
1014
|
title: e.name,
|
|
1009
1015
|
children: e.name
|
|
1010
|
-
}),
|
|
1016
|
+
}), r && /* @__PURE__ */ a("span", {
|
|
1011
1017
|
style: {
|
|
1012
1018
|
fontSize: "11px",
|
|
1013
1019
|
color: "#6b6d6f"
|
|
1014
1020
|
},
|
|
1015
|
-
children:
|
|
1021
|
+
children: r
|
|
1016
1022
|
})]
|
|
1017
1023
|
})] }), s = {
|
|
1018
1024
|
display: "inline-flex",
|
|
@@ -1021,8 +1027,8 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
1021
1027
|
padding: "8px 12px",
|
|
1022
1028
|
borderRadius: "10px",
|
|
1023
1029
|
border: "1px solid #dee3e8",
|
|
1024
|
-
backgroundColor:
|
|
1025
|
-
color:
|
|
1030
|
+
backgroundColor: o ? "rgba(255,255,255,0.12)" : "#fff",
|
|
1031
|
+
color: o ? "#fff" : "#30373e",
|
|
1026
1032
|
fontSize: "13px",
|
|
1027
1033
|
textDecoration: "none",
|
|
1028
1034
|
maxWidth: "220px"
|
|
@@ -1037,8 +1043,8 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
1037
1043
|
style: s,
|
|
1038
1044
|
children: n
|
|
1039
1045
|
});
|
|
1040
|
-
},
|
|
1041
|
-
const t = /* @__PURE__ */
|
|
1046
|
+
}, Pt = ({ source: e, index: o }) => {
|
|
1047
|
+
const t = /* @__PURE__ */ W("div", {
|
|
1042
1048
|
style: {
|
|
1043
1049
|
display: "flex",
|
|
1044
1050
|
alignItems: "center",
|
|
@@ -1061,7 +1067,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
1061
1067
|
justifyContent: "center",
|
|
1062
1068
|
backgroundColor: "#f0f4ff"
|
|
1063
1069
|
},
|
|
1064
|
-
children:
|
|
1070
|
+
children: o + 1
|
|
1065
1071
|
}), /* @__PURE__ */ a("div", {
|
|
1066
1072
|
style: {
|
|
1067
1073
|
fontSize: "12px",
|
|
@@ -1073,7 +1079,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
1073
1079
|
title: e.title,
|
|
1074
1080
|
children: e.title
|
|
1075
1081
|
})]
|
|
1076
|
-
}),
|
|
1082
|
+
}), r = {
|
|
1077
1083
|
display: "flex",
|
|
1078
1084
|
alignItems: "center",
|
|
1079
1085
|
padding: "8px 10px",
|
|
@@ -1090,7 +1096,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
1090
1096
|
href: e.url,
|
|
1091
1097
|
target: "_blank",
|
|
1092
1098
|
rel: "noopener noreferrer",
|
|
1093
|
-
style:
|
|
1099
|
+
style: r,
|
|
1094
1100
|
onMouseEnter: (n) => {
|
|
1095
1101
|
n.currentTarget.style.borderColor = "#1b5fc4";
|
|
1096
1102
|
},
|
|
@@ -1099,10 +1105,10 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
1099
1105
|
},
|
|
1100
1106
|
children: t
|
|
1101
1107
|
}) : /* @__PURE__ */ a("div", {
|
|
1102
|
-
style:
|
|
1108
|
+
style: r,
|
|
1103
1109
|
children: t
|
|
1104
1110
|
});
|
|
1105
|
-
},
|
|
1111
|
+
}, Ee = () => /* @__PURE__ */ W("div", {
|
|
1106
1112
|
style: {
|
|
1107
1113
|
display: "flex",
|
|
1108
1114
|
gap: "4px",
|
|
@@ -1126,10 +1132,10 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
1126
1132
|
40% { opacity: 1; transform: scale(1); }
|
|
1127
1133
|
}
|
|
1128
1134
|
` })]
|
|
1129
|
-
}),
|
|
1130
|
-
const i = e.role === "user",
|
|
1131
|
-
return /* @__PURE__ */
|
|
1132
|
-
className: `ago-message ago-message--${e.role} ${
|
|
1135
|
+
}), Ht = ({ message: e, className: o = "", showAgentName: t = !1, isLast: r = !1, onFollowUpClick: n, showStreamingDots: s = !0, feedback: c }) => {
|
|
1136
|
+
const i = e.role === "user", u = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
|
|
1137
|
+
return /* @__PURE__ */ W("div", {
|
|
1138
|
+
className: `ago-message ago-message--${e.role} ${o}`,
|
|
1133
1139
|
style: {
|
|
1134
1140
|
display: "flex",
|
|
1135
1141
|
flexDirection: "column",
|
|
@@ -1161,9 +1167,9 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
1161
1167
|
width: "100%",
|
|
1162
1168
|
maxWidth: "85%"
|
|
1163
1169
|
},
|
|
1164
|
-
children: e.sources.map((d,
|
|
1170
|
+
children: e.sources.map((d, p) => /* @__PURE__ */ a(Pt, {
|
|
1165
1171
|
source: d,
|
|
1166
|
-
index:
|
|
1172
|
+
index: p
|
|
1167
1173
|
}, d.id))
|
|
1168
1174
|
}),
|
|
1169
1175
|
e.attachments && e.attachments.length > 0 && /* @__PURE__ */ a("div", {
|
|
@@ -1176,12 +1182,12 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
1176
1182
|
justifyContent: i ? "flex-end" : "flex-start",
|
|
1177
1183
|
maxWidth: "75%"
|
|
1178
1184
|
},
|
|
1179
|
-
children: e.attachments.map((d) => /* @__PURE__ */ a(
|
|
1185
|
+
children: e.attachments.map((d) => /* @__PURE__ */ a(Bt, {
|
|
1180
1186
|
attachment: d,
|
|
1181
1187
|
isUser: i
|
|
1182
1188
|
}, d.id))
|
|
1183
1189
|
}),
|
|
1184
|
-
(e.content ||
|
|
1190
|
+
(e.content || u && s) && /* @__PURE__ */ a("div", {
|
|
1185
1191
|
className: "ago-message__content",
|
|
1186
1192
|
style: {
|
|
1187
1193
|
maxWidth: i ? "75%" : "100%",
|
|
@@ -1193,10 +1199,10 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
1193
1199
|
fontSize: "16px",
|
|
1194
1200
|
lineHeight: "1.6"
|
|
1195
1201
|
},
|
|
1196
|
-
children: e.content ? /* @__PURE__ */ a(
|
|
1202
|
+
children: e.content ? /* @__PURE__ */ a(zt, { content: e.content }) : u && s && /* @__PURE__ */ a(Ee, {})
|
|
1197
1203
|
}),
|
|
1198
|
-
!i &&
|
|
1199
|
-
|
|
1204
|
+
!i && c,
|
|
1205
|
+
r && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ a("div", {
|
|
1200
1206
|
className: "ago-message__followups",
|
|
1201
1207
|
style: {
|
|
1202
1208
|
display: "flex",
|
|
@@ -1204,7 +1210,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
1204
1210
|
gap: "8px",
|
|
1205
1211
|
marginTop: "10px"
|
|
1206
1212
|
},
|
|
1207
|
-
children: e.followUpReplies.map((d,
|
|
1213
|
+
children: e.followUpReplies.map((d, p) => /* @__PURE__ */ a("button", {
|
|
1208
1214
|
type: "button",
|
|
1209
1215
|
className: "ago-message__followup-btn",
|
|
1210
1216
|
disabled: !n,
|
|
@@ -1220,76 +1226,63 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
|
|
|
1220
1226
|
cursor: n ? "pointer" : "default",
|
|
1221
1227
|
transition: "border-color 0.15s"
|
|
1222
1228
|
},
|
|
1223
|
-
onMouseEnter: (
|
|
1224
|
-
|
|
1229
|
+
onMouseEnter: (m) => {
|
|
1230
|
+
m.currentTarget.style.borderColor = "#1b5fc4";
|
|
1225
1231
|
},
|
|
1226
|
-
onMouseLeave: (
|
|
1227
|
-
|
|
1232
|
+
onMouseLeave: (m) => {
|
|
1233
|
+
m.currentTarget.style.borderColor = "#dee3e8";
|
|
1228
1234
|
},
|
|
1229
1235
|
children: d
|
|
1230
|
-
},
|
|
1236
|
+
}, p))
|
|
1231
1237
|
})
|
|
1232
1238
|
]
|
|
1233
1239
|
});
|
|
1234
1240
|
};
|
|
1235
|
-
function
|
|
1236
|
-
const
|
|
1237
|
-
if (!t) throw new
|
|
1238
|
-
const [
|
|
1239
|
-
const
|
|
1240
|
-
return d.current.set(
|
|
1241
|
-
},
|
|
1241
|
+
function Ot({ client: e } = {}) {
|
|
1242
|
+
const o = $(), t = e || o;
|
|
1243
|
+
if (!t) throw new ae("useFeedback requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "missing_client");
|
|
1244
|
+
const [r, n] = E({}), [s, c] = E(!1), [i, u] = E(null), d = D(/* @__PURE__ */ new Map()), p = (x) => {
|
|
1245
|
+
const f = (d.current.get(x) ?? 0) + 1;
|
|
1246
|
+
return d.current.set(x, f), f;
|
|
1247
|
+
}, m = (x, f) => d.current.get(x) === f;
|
|
1242
1248
|
return {
|
|
1243
|
-
ratings:
|
|
1244
|
-
submitFeedback:
|
|
1245
|
-
const
|
|
1246
|
-
|
|
1249
|
+
ratings: r,
|
|
1250
|
+
submitFeedback: R(async (x, f, v) => {
|
|
1251
|
+
const l = p(x);
|
|
1252
|
+
c(!0), u(null);
|
|
1247
1253
|
try {
|
|
1248
|
-
await t.submitFeedback(
|
|
1249
|
-
...
|
|
1250
|
-
[
|
|
1254
|
+
await t.submitFeedback(x, f, v), m(x, l) && n((h) => ({
|
|
1255
|
+
...h,
|
|
1256
|
+
[x]: f
|
|
1251
1257
|
}));
|
|
1252
|
-
} catch (
|
|
1253
|
-
const
|
|
1254
|
-
throw
|
|
1258
|
+
} catch (h) {
|
|
1259
|
+
const b = h instanceof Error ? h : /* @__PURE__ */ new Error("Failed to submit feedback");
|
|
1260
|
+
throw u(b), b;
|
|
1255
1261
|
} finally {
|
|
1256
|
-
|
|
1262
|
+
c(!1);
|
|
1257
1263
|
}
|
|
1258
1264
|
}, [t]),
|
|
1259
|
-
submitConversationFeedback:
|
|
1260
|
-
const
|
|
1261
|
-
|
|
1265
|
+
submitConversationFeedback: R(async (x, f, v) => {
|
|
1266
|
+
const l = p(x);
|
|
1267
|
+
c(!0), u(null);
|
|
1262
1268
|
try {
|
|
1263
|
-
const
|
|
1264
|
-
return
|
|
1265
|
-
...
|
|
1266
|
-
[
|
|
1267
|
-
})),
|
|
1268
|
-
} catch (
|
|
1269
|
-
const
|
|
1270
|
-
throw
|
|
1269
|
+
const h = await t.submitConversationFeedback(x, f, v);
|
|
1270
|
+
return m(x, l) && n((b) => ({
|
|
1271
|
+
...b,
|
|
1272
|
+
[h]: f
|
|
1273
|
+
})), h;
|
|
1274
|
+
} catch (h) {
|
|
1275
|
+
const b = h instanceof Error ? h : /* @__PURE__ */ new Error("Failed to submit feedback");
|
|
1276
|
+
throw u(b), b;
|
|
1271
1277
|
} finally {
|
|
1272
|
-
|
|
1278
|
+
c(!1);
|
|
1273
1279
|
}
|
|
1274
1280
|
}, [t]),
|
|
1275
1281
|
isSubmitting: s,
|
|
1276
1282
|
error: i
|
|
1277
1283
|
};
|
|
1278
1284
|
}
|
|
1279
|
-
var
|
|
1280
|
-
helpful: "Helpful",
|
|
1281
|
-
notHelpful: "Not helpful",
|
|
1282
|
-
whatWentWrong: "What went wrong?",
|
|
1283
|
-
reasons: {
|
|
1284
|
-
inaccurate: "Inaccurate",
|
|
1285
|
-
incomplete: "Incomplete",
|
|
1286
|
-
information_not_found: "Information not found",
|
|
1287
|
-
technical_issue: "Technical issue"
|
|
1288
|
-
},
|
|
1289
|
-
commentPlaceholder: "Anything else? (optional)",
|
|
1290
|
-
send: "Send",
|
|
1291
|
-
thanks: "Thanks, this was reported."
|
|
1292
|
-
}, Wt = {
|
|
1285
|
+
var cn = Ze.feedback, $t = {
|
|
1293
1286
|
display: "inline-flex",
|
|
1294
1287
|
alignItems: "center",
|
|
1295
1288
|
justifyContent: "center",
|
|
@@ -1302,65 +1295,61 @@ var fe = {
|
|
|
1302
1295
|
background: "transparent",
|
|
1303
1296
|
cursor: "pointer",
|
|
1304
1297
|
lineHeight: 1
|
|
1305
|
-
},
|
|
1306
|
-
const i = {
|
|
1307
|
-
...
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
...fe.reasons,
|
|
1311
|
-
...o?.reasons
|
|
1312
|
-
}
|
|
1313
|
-
}, { ratings: g, submitFeedback: d } = Ft({ client: r }), f = g[e], [w, m] = M(!1), [u, y] = M([]), [p, k] = M(""), [x, R] = M(!1), [_, b] = M(!1), C = async (c, S) => {
|
|
1298
|
+
}, jt = ({ messageId: e, client: o, askWhy: t = !0, labels: r, onSubmit: n, onError: s, className: c = "" }) => {
|
|
1299
|
+
const i = Q(o), u = {
|
|
1300
|
+
...re(i.feedback, r),
|
|
1301
|
+
reasons: re(i.feedback.reasons, r?.reasons)
|
|
1302
|
+
}, { ratings: d, submitFeedback: p } = Ot({ client: o }), m = d[e], [x, f] = E(!1), [v, l] = E([]), [h, b] = E(""), [I, N] = E(!1), [g, k] = E(!1), A = async (M, w) => {
|
|
1314
1303
|
try {
|
|
1315
|
-
return await
|
|
1304
|
+
return await p(e, M, w), n?.({
|
|
1316
1305
|
messageId: e,
|
|
1317
|
-
rating:
|
|
1318
|
-
reasons:
|
|
1319
|
-
comment:
|
|
1306
|
+
rating: M,
|
|
1307
|
+
reasons: w?.reasons ?? [],
|
|
1308
|
+
comment: w?.comment || void 0
|
|
1320
1309
|
}), !0;
|
|
1321
|
-
} catch (
|
|
1322
|
-
return s?.(
|
|
1310
|
+
} catch (T) {
|
|
1311
|
+
return s?.(T instanceof Error ? T : new Error(String(T))), !1;
|
|
1323
1312
|
}
|
|
1324
|
-
},
|
|
1325
|
-
|
|
1326
|
-
},
|
|
1327
|
-
|
|
1328
|
-
},
|
|
1329
|
-
!
|
|
1330
|
-
reasons:
|
|
1331
|
-
comment:
|
|
1332
|
-
}).then((
|
|
1333
|
-
|
|
1313
|
+
}, S = (M) => {
|
|
1314
|
+
A(M), f(M === "negative" && t && !I);
|
|
1315
|
+
}, C = (M) => {
|
|
1316
|
+
l((w) => w.includes(M) ? w.filter((T) => T !== M) : [...w, M]);
|
|
1317
|
+
}, L = v.length > 0 || h.trim().length > 0, F = () => {
|
|
1318
|
+
!L || g || (k(!0), A(m ?? "negative", {
|
|
1319
|
+
reasons: v,
|
|
1320
|
+
comment: h.trim()
|
|
1321
|
+
}).then((M) => {
|
|
1322
|
+
k(!1), M && (N(!0), f(!1));
|
|
1334
1323
|
}));
|
|
1335
1324
|
};
|
|
1336
|
-
return /* @__PURE__ */
|
|
1337
|
-
className: `ago-feedback ${
|
|
1325
|
+
return /* @__PURE__ */ W("div", {
|
|
1326
|
+
className: `ago-feedback ${c}`,
|
|
1338
1327
|
style: {
|
|
1339
1328
|
marginTop: "6px",
|
|
1340
1329
|
width: "100%",
|
|
1341
1330
|
maxWidth: "85%"
|
|
1342
1331
|
},
|
|
1343
1332
|
children: [
|
|
1344
|
-
/* @__PURE__ */
|
|
1333
|
+
/* @__PURE__ */ W("div", {
|
|
1345
1334
|
className: "ago-feedback__actions",
|
|
1346
1335
|
style: {
|
|
1347
1336
|
display: "flex",
|
|
1348
1337
|
alignItems: "center",
|
|
1349
1338
|
gap: "2px"
|
|
1350
1339
|
},
|
|
1351
|
-
children: [/* @__PURE__ */ a(
|
|
1340
|
+
children: [/* @__PURE__ */ a(we, {
|
|
1352
1341
|
direction: "up",
|
|
1353
|
-
label:
|
|
1354
|
-
selected:
|
|
1355
|
-
onClick: () =>
|
|
1356
|
-
}), /* @__PURE__ */ a(
|
|
1342
|
+
label: u.helpful,
|
|
1343
|
+
selected: m === "positive",
|
|
1344
|
+
onClick: () => S("positive")
|
|
1345
|
+
}), /* @__PURE__ */ a(we, {
|
|
1357
1346
|
direction: "down",
|
|
1358
|
-
label:
|
|
1359
|
-
selected:
|
|
1360
|
-
onClick: () =>
|
|
1347
|
+
label: u.notHelpful,
|
|
1348
|
+
selected: m === "negative",
|
|
1349
|
+
onClick: () => S("negative")
|
|
1361
1350
|
})]
|
|
1362
1351
|
}),
|
|
1363
|
-
|
|
1352
|
+
I && /* @__PURE__ */ a("div", {
|
|
1364
1353
|
className: "ago-feedback__thanks",
|
|
1365
1354
|
role: "status",
|
|
1366
1355
|
style: {
|
|
@@ -1368,12 +1357,12 @@ var fe = {
|
|
|
1368
1357
|
fontSize: "13px",
|
|
1369
1358
|
color: "#6b6d6f"
|
|
1370
1359
|
},
|
|
1371
|
-
children:
|
|
1360
|
+
children: u.thanks
|
|
1372
1361
|
}),
|
|
1373
|
-
|
|
1362
|
+
x && !I && /* @__PURE__ */ W("div", {
|
|
1374
1363
|
className: "ago-feedback__panel",
|
|
1375
1364
|
role: "group",
|
|
1376
|
-
"aria-label":
|
|
1365
|
+
"aria-label": u.whatWentWrong,
|
|
1377
1366
|
style: {
|
|
1378
1367
|
marginTop: "8px",
|
|
1379
1368
|
padding: "12px",
|
|
@@ -1389,7 +1378,7 @@ var fe = {
|
|
|
1389
1378
|
color: "#30373e",
|
|
1390
1379
|
marginBottom: "8px"
|
|
1391
1380
|
},
|
|
1392
|
-
children:
|
|
1381
|
+
children: u.whatWentWrong
|
|
1393
1382
|
}),
|
|
1394
1383
|
/* @__PURE__ */ a("div", {
|
|
1395
1384
|
className: "ago-feedback__reasons",
|
|
@@ -1399,35 +1388,35 @@ var fe = {
|
|
|
1399
1388
|
gap: "6px",
|
|
1400
1389
|
marginBottom: "8px"
|
|
1401
1390
|
},
|
|
1402
|
-
children:
|
|
1403
|
-
const
|
|
1391
|
+
children: Ge.map((M) => {
|
|
1392
|
+
const w = v.includes(M);
|
|
1404
1393
|
return /* @__PURE__ */ a("button", {
|
|
1405
1394
|
type: "button",
|
|
1406
1395
|
className: "ago-feedback__reason",
|
|
1407
|
-
"aria-pressed":
|
|
1408
|
-
onClick: () =>
|
|
1396
|
+
"aria-pressed": w,
|
|
1397
|
+
onClick: () => C(M),
|
|
1409
1398
|
style: {
|
|
1410
1399
|
minHeight: "44px",
|
|
1411
1400
|
padding: "4px 12px",
|
|
1412
1401
|
fontSize: "13px",
|
|
1413
1402
|
fontFamily: "inherit",
|
|
1414
1403
|
borderRadius: "999px",
|
|
1415
|
-
border: `1px solid ${
|
|
1404
|
+
border: `1px solid ${w ? "#1b5fc4" : "#dee3e8"}`,
|
|
1416
1405
|
backgroundColor: "transparent",
|
|
1417
|
-
color:
|
|
1406
|
+
color: w ? "#1b5fc4" : "#30373e",
|
|
1418
1407
|
cursor: "pointer"
|
|
1419
1408
|
},
|
|
1420
|
-
children:
|
|
1421
|
-
},
|
|
1409
|
+
children: u.reasons[M]
|
|
1410
|
+
}, M);
|
|
1422
1411
|
})
|
|
1423
1412
|
}),
|
|
1424
1413
|
/* @__PURE__ */ a("textarea", {
|
|
1425
1414
|
className: "ago-feedback__comment",
|
|
1426
1415
|
rows: 2,
|
|
1427
|
-
value:
|
|
1428
|
-
placeholder:
|
|
1429
|
-
"aria-label":
|
|
1430
|
-
onChange: (
|
|
1416
|
+
value: h,
|
|
1417
|
+
placeholder: u.commentPlaceholder,
|
|
1418
|
+
"aria-label": u.commentPlaceholder,
|
|
1419
|
+
onChange: (M) => b(M.target.value),
|
|
1431
1420
|
style: {
|
|
1432
1421
|
width: "100%",
|
|
1433
1422
|
boxSizing: "border-box",
|
|
@@ -1444,8 +1433,8 @@ var fe = {
|
|
|
1444
1433
|
/* @__PURE__ */ a("button", {
|
|
1445
1434
|
type: "button",
|
|
1446
1435
|
className: "ago-feedback__send",
|
|
1447
|
-
onClick:
|
|
1448
|
-
disabled: !
|
|
1436
|
+
onClick: F,
|
|
1437
|
+
disabled: !L || g,
|
|
1449
1438
|
style: {
|
|
1450
1439
|
marginTop: "8px",
|
|
1451
1440
|
minHeight: "44px",
|
|
@@ -1454,29 +1443,29 @@ var fe = {
|
|
|
1454
1443
|
fontFamily: "inherit",
|
|
1455
1444
|
borderRadius: "10px",
|
|
1456
1445
|
border: "none",
|
|
1457
|
-
backgroundColor:
|
|
1446
|
+
backgroundColor: L ? "#03182f" : "#b5bfc8",
|
|
1458
1447
|
color: "#fff",
|
|
1459
|
-
opacity:
|
|
1460
|
-
cursor:
|
|
1448
|
+
opacity: g ? 0.6 : 1,
|
|
1449
|
+
cursor: L && !g ? "pointer" : "default"
|
|
1461
1450
|
},
|
|
1462
|
-
children:
|
|
1451
|
+
children: u.send
|
|
1463
1452
|
})
|
|
1464
1453
|
]
|
|
1465
1454
|
})
|
|
1466
1455
|
]
|
|
1467
1456
|
});
|
|
1468
|
-
},
|
|
1457
|
+
}, we = ({ direction: e, label: o, selected: t, onClick: r }) => /* @__PURE__ */ a("button", {
|
|
1469
1458
|
type: "button",
|
|
1470
1459
|
className: `ago-feedback__thumb ago-feedback__thumb--${e}`,
|
|
1471
|
-
"aria-label":
|
|
1460
|
+
"aria-label": o,
|
|
1472
1461
|
"aria-pressed": t,
|
|
1473
|
-
title:
|
|
1474
|
-
onClick:
|
|
1462
|
+
title: o,
|
|
1463
|
+
onClick: r,
|
|
1475
1464
|
style: {
|
|
1476
|
-
|
|
1465
|
+
...$t,
|
|
1477
1466
|
color: t ? "#1b5fc4" : "#6b6d6f"
|
|
1478
1467
|
},
|
|
1479
|
-
children: /* @__PURE__ */
|
|
1468
|
+
children: /* @__PURE__ */ W("svg", {
|
|
1480
1469
|
width: "16",
|
|
1481
1470
|
height: "16",
|
|
1482
1471
|
viewBox: "0 0 24 24",
|
|
@@ -1495,106 +1484,106 @@ var fe = {
|
|
|
1495
1484
|
strokeLinejoin: "round"
|
|
1496
1485
|
})]
|
|
1497
1486
|
})
|
|
1498
|
-
}),
|
|
1499
|
-
const N =
|
|
1500
|
-
client:
|
|
1487
|
+
}), dn = ot(function({ client: o, conversationId: t, title: r, welcomeMessage: n, placeholder: s, allowFiles: c = !1, speechToText: i = !1, allowStop: u = !0, height: d = 500, logoUrl: p, showAgentName: m = !1, forms: x, feedback: f = !1, onFollowUpClick: v, className: l = "", onMessageSent: h, onMessageReceived: b, sheet: I = !1, thinkingLabel: N, functionLabels: g, showReasoning: k = !0 }, A) {
|
|
1488
|
+
const S = Q(o), C = r ?? S.common.chat, L = n ?? S.common.welcome, F = s ?? S.common.placeholder, M = N ?? S.common.thinking, w = D(null), T = D(!0), [q, O] = E(!0), ee = D(null), { sheet: B, expand: se, collapse: X, toggle: ue } = ht(I), [Me, ie] = E(!1), le = B.compact && B.state === "peek", Te = $(), G = o ?? Te, { messages: H, isLoading: Fe, error: pe, sendMessage: Le, stop: We } = Re({
|
|
1489
|
+
client: o,
|
|
1501
1490
|
conversationId: t
|
|
1502
1491
|
});
|
|
1503
|
-
|
|
1504
|
-
if (!
|
|
1505
|
-
let
|
|
1506
|
-
const
|
|
1507
|
-
return Promise.all(
|
|
1508
|
-
if (!
|
|
1509
|
-
for (const
|
|
1492
|
+
_(() => {
|
|
1493
|
+
if (!G || !x || x.length === 0) return;
|
|
1494
|
+
let y = !1;
|
|
1495
|
+
const P = [];
|
|
1496
|
+
return Promise.all(x.map((z) => z.schema != null ? Promise.resolve(Se(z)) : Ce(G, z))).then((z) => {
|
|
1497
|
+
if (!y)
|
|
1498
|
+
for (const j of z) P.push(j.install(G));
|
|
1510
1499
|
}).catch(() => {
|
|
1511
1500
|
}), () => {
|
|
1512
|
-
|
|
1501
|
+
y = !0, P.forEach((z) => z());
|
|
1513
1502
|
};
|
|
1514
|
-
}, [
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
])) : ""]),
|
|
1520
|
-
const
|
|
1521
|
-
!
|
|
1522
|
-
}, [
|
|
1523
|
-
const
|
|
1524
|
-
const
|
|
1525
|
-
|
|
1503
|
+
}, [G, x ? JSON.stringify(x.map((y) => [
|
|
1504
|
+
y.name,
|
|
1505
|
+
y.schema ?? null,
|
|
1506
|
+
y.submit ?? !1,
|
|
1507
|
+
y.description ?? null
|
|
1508
|
+
])) : ""]), _(() => {
|
|
1509
|
+
const y = w.current;
|
|
1510
|
+
!y || !T.current || (y.scrollTop = y.scrollHeight);
|
|
1511
|
+
}, [H]);
|
|
1512
|
+
const De = () => {
|
|
1513
|
+
const y = w.current;
|
|
1514
|
+
y && (T.current = !0, O(!0), y.scrollTop = y.scrollHeight);
|
|
1526
1515
|
};
|
|
1527
|
-
|
|
1528
|
-
const
|
|
1529
|
-
|
|
1530
|
-
id:
|
|
1531
|
-
content:
|
|
1516
|
+
_(() => {
|
|
1517
|
+
const y = H[H.length - 1];
|
|
1518
|
+
y && y.role === "assistant" && y.status === "DONE" && b && b({
|
|
1519
|
+
id: y.id,
|
|
1520
|
+
content: y.content
|
|
1532
1521
|
});
|
|
1533
|
-
}, [
|
|
1534
|
-
|
|
1535
|
-
}, [
|
|
1536
|
-
const
|
|
1537
|
-
if (!
|
|
1538
|
-
const
|
|
1539
|
-
if (
|
|
1522
|
+
}, [H, b]), _(() => {
|
|
1523
|
+
ie(!!le);
|
|
1524
|
+
}, [H.length]), _(() => {
|
|
1525
|
+
const y = ee.current;
|
|
1526
|
+
if (!B.compact || !y) return;
|
|
1527
|
+
const P = document.documentElement;
|
|
1528
|
+
if (B.state !== "peek") return;
|
|
1540
1529
|
const z = () => {
|
|
1541
|
-
|
|
1530
|
+
P.style.setProperty("--ago-sheet-height", `${Math.round(y.getBoundingClientRect().height)}px`);
|
|
1542
1531
|
};
|
|
1543
1532
|
z();
|
|
1544
|
-
const
|
|
1545
|
-
return
|
|
1546
|
-
}, [
|
|
1547
|
-
|
|
1548
|
-
}, [
|
|
1533
|
+
const j = typeof ResizeObserver == "function" ? new ResizeObserver(z) : null;
|
|
1534
|
+
return j?.observe(y), () => j?.disconnect();
|
|
1535
|
+
}, [B.compact, B.state]), _(() => {
|
|
1536
|
+
B.compact || document.documentElement.style.removeProperty("--ago-sheet-height");
|
|
1537
|
+
}, [B.compact]), _(() => () => {
|
|
1549
1538
|
document.documentElement.style.removeProperty("--ago-sheet-height");
|
|
1550
|
-
}, []),
|
|
1551
|
-
expand:
|
|
1552
|
-
collapse:
|
|
1553
|
-
toggle:
|
|
1554
|
-
state:
|
|
1539
|
+
}, []), at(A, () => ({
|
|
1540
|
+
expand: se,
|
|
1541
|
+
collapse: X,
|
|
1542
|
+
toggle: ue,
|
|
1543
|
+
state: B.state
|
|
1555
1544
|
}), [
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
]),
|
|
1561
|
-
if (!
|
|
1562
|
-
const
|
|
1563
|
-
|
|
1564
|
-
const
|
|
1545
|
+
se,
|
|
1546
|
+
X,
|
|
1547
|
+
ue,
|
|
1548
|
+
B.state
|
|
1549
|
+
]), _(() => {
|
|
1550
|
+
if (!B.isModal) return;
|
|
1551
|
+
const y = /* @__PURE__ */ Symbol("ago-react-sheet");
|
|
1552
|
+
et(y);
|
|
1553
|
+
const P = (z) => {
|
|
1565
1554
|
if (z.key === "Escape") {
|
|
1566
|
-
|
|
1555
|
+
X("user");
|
|
1567
1556
|
return;
|
|
1568
1557
|
}
|
|
1569
1558
|
if (z.key !== "Tab") return;
|
|
1570
|
-
const
|
|
1571
|
-
if (!
|
|
1572
|
-
const
|
|
1573
|
-
if (
|
|
1559
|
+
const j = ee.current;
|
|
1560
|
+
if (!j) return;
|
|
1561
|
+
const ne = Array.from(j.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((He) => He.getClientRects().length > 0);
|
|
1562
|
+
if (ne.length === 0) {
|
|
1574
1563
|
z.preventDefault();
|
|
1575
1564
|
return;
|
|
1576
1565
|
}
|
|
1577
|
-
const
|
|
1578
|
-
z.shiftKey && (
|
|
1566
|
+
const he = ne[0], xe = ne[ne.length - 1], oe = document.activeElement;
|
|
1567
|
+
z.shiftKey && (oe === he || !j.contains(oe)) ? (z.preventDefault(), xe.focus()) : !z.shiftKey && (oe === xe || !j.contains(oe)) && (z.preventDefault(), he.focus());
|
|
1579
1568
|
};
|
|
1580
|
-
return document.addEventListener("keydown",
|
|
1581
|
-
document.removeEventListener("keydown",
|
|
1569
|
+
return document.addEventListener("keydown", P), ee.current?.focus({ preventScroll: !0 }), () => {
|
|
1570
|
+
document.removeEventListener("keydown", P), Xe(y);
|
|
1582
1571
|
};
|
|
1583
|
-
}, [
|
|
1584
|
-
const
|
|
1585
|
-
const
|
|
1586
|
-
if (!(!
|
|
1587
|
-
return typeof
|
|
1588
|
-
}, [
|
|
1589
|
-
client:
|
|
1590
|
-
labelFor:
|
|
1591
|
-
includeReasoning:
|
|
1592
|
-
}),
|
|
1593
|
-
return /* @__PURE__ */
|
|
1594
|
-
ref:
|
|
1595
|
-
className: `ago-chat-widget ${
|
|
1596
|
-
...
|
|
1597
|
-
"data-ago-sheet-state":
|
|
1572
|
+
}, [B.isModal, X]);
|
|
1573
|
+
const fe = async (y, P) => (T.current = !0, O(!0), h?.(y), await Le(y, P) !== null), K = H[H.length - 1], te = Fe && K?.role === "assistant" && (K.status === "IN_PROGRESS" || K.status === "WAITING_CLIENT"), ze = R((y) => {
|
|
1574
|
+
const P = y.functionName;
|
|
1575
|
+
if (!(!g || !P))
|
|
1576
|
+
return typeof g == "function" ? g(P, y.arguments ?? {}) : g[P];
|
|
1577
|
+
}, [g]), { items: Be } = ft({
|
|
1578
|
+
client: G ?? void 0,
|
|
1579
|
+
labelFor: ze,
|
|
1580
|
+
includeReasoning: k
|
|
1581
|
+
}), ge = Be.filter((y) => K?.id !== void 0 && y.messageId === K.id), Y = g === !1 ? void 0 : ge[ge.length - 1]?.label, me = !!(te && Y), Pe = v === !1 ? void 0 : v ?? ((y) => fe(y));
|
|
1582
|
+
return /* @__PURE__ */ W("div", {
|
|
1583
|
+
ref: ee,
|
|
1584
|
+
className: `ago-chat-widget ${l}`,
|
|
1585
|
+
...B.surface.attrs,
|
|
1586
|
+
"data-ago-sheet-state": B.compact ? B.state : void 0,
|
|
1598
1587
|
style: {
|
|
1599
1588
|
display: "flex",
|
|
1600
1589
|
flexDirection: "column",
|
|
@@ -1606,10 +1595,10 @@ var fe = {
|
|
|
1606
1595
|
fontFamily: '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
1607
1596
|
textAlign: "left",
|
|
1608
1597
|
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px",
|
|
1609
|
-
...
|
|
1598
|
+
...B.surface.style
|
|
1610
1599
|
},
|
|
1611
1600
|
children: [
|
|
1612
|
-
!
|
|
1601
|
+
!B.compact && /* @__PURE__ */ W("div", {
|
|
1613
1602
|
className: "ago-chat-widget__header",
|
|
1614
1603
|
style: {
|
|
1615
1604
|
padding: "14px 16px",
|
|
@@ -1620,8 +1609,8 @@ var fe = {
|
|
|
1620
1609
|
alignItems: "center",
|
|
1621
1610
|
gap: "10px"
|
|
1622
1611
|
},
|
|
1623
|
-
children: [
|
|
1624
|
-
src:
|
|
1612
|
+
children: [p && /* @__PURE__ */ a("img", {
|
|
1613
|
+
src: p,
|
|
1625
1614
|
alt: "Logo",
|
|
1626
1615
|
style: {
|
|
1627
1616
|
height: "24px",
|
|
@@ -1633,16 +1622,16 @@ var fe = {
|
|
|
1633
1622
|
fontSize: "15px",
|
|
1634
1623
|
fontWeight: 600
|
|
1635
1624
|
},
|
|
1636
|
-
children:
|
|
1625
|
+
children: C
|
|
1637
1626
|
})]
|
|
1638
1627
|
}),
|
|
1639
|
-
|
|
1628
|
+
le && /* @__PURE__ */ W("button", {
|
|
1640
1629
|
type: "button",
|
|
1641
1630
|
className: "ago-chat-widget__peek",
|
|
1642
1631
|
"aria-expanded": !1,
|
|
1643
|
-
"aria-label":
|
|
1632
|
+
"aria-label": S.common.openConversation,
|
|
1644
1633
|
onClick: () => {
|
|
1645
|
-
|
|
1634
|
+
ie(!1), se("user");
|
|
1646
1635
|
},
|
|
1647
1636
|
style: {
|
|
1648
1637
|
display: "flex",
|
|
@@ -1659,7 +1648,7 @@ var fe = {
|
|
|
1659
1648
|
font: "inherit",
|
|
1660
1649
|
color: "inherit"
|
|
1661
1650
|
},
|
|
1662
|
-
children: [/* @__PURE__ */
|
|
1651
|
+
children: [/* @__PURE__ */ W("span", {
|
|
1663
1652
|
style: {
|
|
1664
1653
|
display: "flex",
|
|
1665
1654
|
alignItems: "center",
|
|
@@ -1672,9 +1661,9 @@ var fe = {
|
|
|
1672
1661
|
opacity: 0.7
|
|
1673
1662
|
},
|
|
1674
1663
|
children: [
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
"aria-label":
|
|
1664
|
+
C,
|
|
1665
|
+
Me && /* @__PURE__ */ a("span", {
|
|
1666
|
+
"aria-label": S.common.newMessage,
|
|
1678
1667
|
style: {
|
|
1679
1668
|
width: "6px",
|
|
1680
1669
|
height: "6px",
|
|
@@ -1691,13 +1680,13 @@ var fe = {
|
|
|
1691
1680
|
children: "↑"
|
|
1692
1681
|
})
|
|
1693
1682
|
]
|
|
1694
|
-
}),
|
|
1683
|
+
}), te && !K?.content ? /* @__PURE__ */ W("span", {
|
|
1695
1684
|
style: {
|
|
1696
1685
|
display: "flex",
|
|
1697
1686
|
alignItems: "center",
|
|
1698
1687
|
gap: "8px"
|
|
1699
1688
|
},
|
|
1700
|
-
children: [!
|
|
1689
|
+
children: [!Y && /* @__PURE__ */ a(Ee, {}), /* @__PURE__ */ a("span", {
|
|
1701
1690
|
style: {
|
|
1702
1691
|
fontSize: "13px",
|
|
1703
1692
|
opacity: 0.7,
|
|
@@ -1705,7 +1694,7 @@ var fe = {
|
|
|
1705
1694
|
textOverflow: "ellipsis",
|
|
1706
1695
|
whiteSpace: "nowrap"
|
|
1707
1696
|
},
|
|
1708
|
-
children:
|
|
1697
|
+
children: Y ? Ie(Y) : M
|
|
1709
1698
|
})]
|
|
1710
1699
|
}) : /* @__PURE__ */ a("span", {
|
|
1711
1700
|
style: {
|
|
@@ -1718,10 +1707,10 @@ var fe = {
|
|
|
1718
1707
|
color: "inherit",
|
|
1719
1708
|
minHeight: "calc(2 * 1.5 * 13px)"
|
|
1720
1709
|
},
|
|
1721
|
-
children:
|
|
1710
|
+
children: K?.content || L
|
|
1722
1711
|
})]
|
|
1723
1712
|
}),
|
|
1724
|
-
|
|
1713
|
+
B.compact && B.state === "full" && /* @__PURE__ */ W("div", {
|
|
1725
1714
|
className: "ago-chat-widget__sheet-header",
|
|
1726
1715
|
style: {
|
|
1727
1716
|
display: "flex",
|
|
@@ -1743,11 +1732,11 @@ var fe = {
|
|
|
1743
1732
|
whiteSpace: "nowrap",
|
|
1744
1733
|
textOverflow: "ellipsis"
|
|
1745
1734
|
},
|
|
1746
|
-
children:
|
|
1735
|
+
children: C
|
|
1747
1736
|
}), /* @__PURE__ */ a("button", {
|
|
1748
1737
|
type: "button",
|
|
1749
|
-
"aria-label":
|
|
1750
|
-
onClick: () =>
|
|
1738
|
+
"aria-label": S.common.collapseConversation,
|
|
1739
|
+
onClick: () => X("user"),
|
|
1751
1740
|
style: {
|
|
1752
1741
|
marginLeft: "auto",
|
|
1753
1742
|
flexShrink: 0,
|
|
@@ -1775,25 +1764,25 @@ var fe = {
|
|
|
1775
1764
|
})
|
|
1776
1765
|
})]
|
|
1777
1766
|
}),
|
|
1778
|
-
/* @__PURE__ */
|
|
1767
|
+
/* @__PURE__ */ W("div", {
|
|
1779
1768
|
style: {
|
|
1780
1769
|
position: "relative",
|
|
1781
1770
|
flex: 1,
|
|
1782
|
-
display:
|
|
1771
|
+
display: le ? "none" : "flex",
|
|
1783
1772
|
minHeight: 0
|
|
1784
1773
|
},
|
|
1785
|
-
children: [/* @__PURE__ */
|
|
1786
|
-
ref:
|
|
1774
|
+
children: [/* @__PURE__ */ W("div", {
|
|
1775
|
+
ref: w,
|
|
1787
1776
|
className: "ago-chat-widget__messages",
|
|
1788
|
-
onScroll: (
|
|
1789
|
-
const
|
|
1790
|
-
|
|
1777
|
+
onScroll: (y) => {
|
|
1778
|
+
const P = y.currentTarget, z = P.scrollHeight - P.scrollTop - P.clientHeight <= 48;
|
|
1779
|
+
T.current = z, O(z);
|
|
1791
1780
|
},
|
|
1792
1781
|
role: "log",
|
|
1793
1782
|
"aria-live": "polite",
|
|
1794
1783
|
"aria-relevant": "additions text",
|
|
1795
1784
|
"aria-atomic": !1,
|
|
1796
|
-
"aria-busy":
|
|
1785
|
+
"aria-busy": te,
|
|
1797
1786
|
style: {
|
|
1798
1787
|
flex: 1,
|
|
1799
1788
|
overflow: "auto",
|
|
@@ -1802,7 +1791,7 @@ var fe = {
|
|
|
1802
1791
|
backgroundColor: "#fbfbfb"
|
|
1803
1792
|
},
|
|
1804
1793
|
children: [
|
|
1805
|
-
|
|
1794
|
+
H.length === 0 ? /* @__PURE__ */ a("div", {
|
|
1806
1795
|
style: {
|
|
1807
1796
|
textAlign: "center",
|
|
1808
1797
|
color: "#6b6d6f",
|
|
@@ -1810,21 +1799,21 @@ var fe = {
|
|
|
1810
1799
|
fontSize: "16px",
|
|
1811
1800
|
lineHeight: "1.5"
|
|
1812
1801
|
},
|
|
1813
|
-
children:
|
|
1814
|
-
}) :
|
|
1815
|
-
message:
|
|
1816
|
-
showAgentName:
|
|
1817
|
-
isLast:
|
|
1818
|
-
onFollowUpClick:
|
|
1819
|
-
showStreamingDots: !
|
|
1820
|
-
feedback:
|
|
1821
|
-
messageId:
|
|
1822
|
-
client:
|
|
1823
|
-
...
|
|
1802
|
+
children: L
|
|
1803
|
+
}) : H.map((y, P) => /* @__PURE__ */ a(Ht, {
|
|
1804
|
+
message: y,
|
|
1805
|
+
showAgentName: m,
|
|
1806
|
+
isLast: P === H.length - 1,
|
|
1807
|
+
onFollowUpClick: Pe,
|
|
1808
|
+
showStreamingDots: !me,
|
|
1809
|
+
feedback: f && y.role === "assistant" && y.status === "DONE" && y.content ? /* @__PURE__ */ a(jt, {
|
|
1810
|
+
messageId: y.id,
|
|
1811
|
+
client: o,
|
|
1812
|
+
...f === !0 ? {} : f
|
|
1824
1813
|
}) : void 0
|
|
1825
|
-
},
|
|
1826
|
-
|
|
1827
|
-
|
|
1814
|
+
}, y.id)),
|
|
1815
|
+
me && /* @__PURE__ */ a(yt, { label: Y ?? "" }),
|
|
1816
|
+
pe && /* @__PURE__ */ a("div", {
|
|
1828
1817
|
role: "alert",
|
|
1829
1818
|
style: {
|
|
1830
1819
|
padding: "10px 14px",
|
|
@@ -1835,15 +1824,15 @@ var fe = {
|
|
|
1835
1824
|
fontSize: "13px",
|
|
1836
1825
|
border: "1px solid #fecaca"
|
|
1837
1826
|
},
|
|
1838
|
-
children:
|
|
1827
|
+
children: pe.message
|
|
1839
1828
|
}),
|
|
1840
1829
|
/* @__PURE__ */ a("div", {})
|
|
1841
1830
|
]
|
|
1842
|
-
}), !
|
|
1831
|
+
}), !q && /* @__PURE__ */ a("button", {
|
|
1843
1832
|
type: "button",
|
|
1844
1833
|
className: "ago-chat-widget__jump",
|
|
1845
|
-
"aria-label":
|
|
1846
|
-
onClick:
|
|
1834
|
+
"aria-label": S.common.jumpToLatest,
|
|
1835
|
+
onClick: De,
|
|
1847
1836
|
style: {
|
|
1848
1837
|
position: "absolute",
|
|
1849
1838
|
left: "50%",
|
|
@@ -1876,71 +1865,71 @@ var fe = {
|
|
|
1876
1865
|
})
|
|
1877
1866
|
})]
|
|
1878
1867
|
}),
|
|
1879
|
-
/* @__PURE__ */ a(
|
|
1880
|
-
onSend:
|
|
1881
|
-
onStop:
|
|
1882
|
-
|
|
1868
|
+
/* @__PURE__ */ a(wt, {
|
|
1869
|
+
onSend: fe,
|
|
1870
|
+
onStop: u ? () => {
|
|
1871
|
+
We();
|
|
1883
1872
|
} : void 0,
|
|
1884
|
-
disabled:
|
|
1885
|
-
placeholder:
|
|
1886
|
-
allowFiles:
|
|
1873
|
+
disabled: te,
|
|
1874
|
+
placeholder: F,
|
|
1875
|
+
allowFiles: c,
|
|
1887
1876
|
speechToText: i,
|
|
1888
|
-
client:
|
|
1889
|
-
scopeKey: `${t ??
|
|
1877
|
+
client: G ?? void 0,
|
|
1878
|
+
scopeKey: `${t ?? H[0]?.conversationId ?? ""}:${B.state}`
|
|
1890
1879
|
})
|
|
1891
1880
|
]
|
|
1892
1881
|
});
|
|
1893
1882
|
});
|
|
1894
|
-
function
|
|
1895
|
-
const
|
|
1896
|
-
if (!t) throw new
|
|
1897
|
-
const [
|
|
1898
|
-
s.current =
|
|
1899
|
-
const
|
|
1900
|
-
return
|
|
1883
|
+
function qt(e = {}) {
|
|
1884
|
+
const o = $(), t = e.client ?? o;
|
|
1885
|
+
if (!t) throw new ae("useProactiveNudge: no AgoClient. Pass one via options.client or wrap your tree with <AgoProvider>.", "proactive_missing_client");
|
|
1886
|
+
const [r, n] = E(null), s = D(r);
|
|
1887
|
+
s.current = r;
|
|
1888
|
+
const c = D(e.onExpand);
|
|
1889
|
+
return c.current = e.onExpand, _(() => {
|
|
1901
1890
|
const i = (d) => {
|
|
1902
1891
|
n(d), t.proactive?.shown(d);
|
|
1903
|
-
},
|
|
1904
|
-
n((
|
|
1892
|
+
}, u = ({ nudge: d }) => {
|
|
1893
|
+
n((p) => p?.id === d.id ? null : p);
|
|
1905
1894
|
};
|
|
1906
|
-
return t.on("nudge:ready", i), t.on("nudge:accepted",
|
|
1907
|
-
t.off("nudge:ready", i), t.off("nudge:accepted",
|
|
1895
|
+
return t.on("nudge:ready", i), t.on("nudge:accepted", u), t.on("nudge:dismissed", u), () => {
|
|
1896
|
+
t.off("nudge:ready", i), t.off("nudge:accepted", u), t.off("nudge:dismissed", u);
|
|
1908
1897
|
};
|
|
1909
1898
|
}, [t]), {
|
|
1910
|
-
nudge:
|
|
1911
|
-
accept:
|
|
1899
|
+
nudge: r,
|
|
1900
|
+
accept: R(async () => {
|
|
1912
1901
|
const i = s.current;
|
|
1913
|
-
i && (n(null), await t.proactive?.accept(i), (i.source === "agent" || i.goal) &&
|
|
1902
|
+
i && (n(null), await t.proactive?.accept(i), (i.source === "agent" || i.goal) && c.current?.(i));
|
|
1914
1903
|
}, [t]),
|
|
1915
|
-
dismiss:
|
|
1904
|
+
dismiss: R(() => {
|
|
1916
1905
|
const i = s.current;
|
|
1917
1906
|
i && (n(null), t.proactive?.dismiss(i));
|
|
1918
1907
|
}, [t])
|
|
1919
1908
|
};
|
|
1920
1909
|
}
|
|
1921
|
-
var
|
|
1922
|
-
const { nudge:
|
|
1910
|
+
var un = ({ client: e, onExpand: o, autoHideMs: t, position: r = "bottom-right", openChatLabel: n, className: s = "" }) => {
|
|
1911
|
+
const c = Q(e), i = n ?? c.common.openChat, { nudge: u, accept: d, dismiss: p } = qt({
|
|
1923
1912
|
client: e,
|
|
1924
|
-
onExpand:
|
|
1913
|
+
onExpand: o
|
|
1925
1914
|
});
|
|
1926
|
-
if (
|
|
1927
|
-
if (!
|
|
1928
|
-
const
|
|
1929
|
-
return () => clearTimeout(
|
|
1915
|
+
if (_(() => {
|
|
1916
|
+
if (!u || !t) return;
|
|
1917
|
+
const x = setTimeout(() => p(), t);
|
|
1918
|
+
return () => clearTimeout(x);
|
|
1930
1919
|
}, [
|
|
1931
|
-
|
|
1920
|
+
u,
|
|
1932
1921
|
t,
|
|
1933
|
-
|
|
1934
|
-
]), !
|
|
1935
|
-
const
|
|
1936
|
-
return /* @__PURE__ */
|
|
1922
|
+
p
|
|
1923
|
+
]), !u) return null;
|
|
1924
|
+
const m = u.source === "agent" || !!u.goal;
|
|
1925
|
+
return /* @__PURE__ */ W("div", {
|
|
1937
1926
|
className: `ago-nudge ${s}`,
|
|
1938
1927
|
role: "status",
|
|
1939
1928
|
"aria-live": "polite",
|
|
1940
1929
|
style: {
|
|
1941
1930
|
position: "fixed",
|
|
1942
1931
|
bottom: "90px",
|
|
1943
|
-
...
|
|
1932
|
+
...r === "bottom-left" ? { left: "20px" } : { right: "20px" },
|
|
1944
1933
|
zIndex: 2147483e3,
|
|
1945
1934
|
maxWidth: "320px",
|
|
1946
1935
|
padding: "14px 16px",
|
|
@@ -1958,8 +1947,8 @@ var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
|
|
|
1958
1947
|
/* @__PURE__ */ a("button", {
|
|
1959
1948
|
type: "button",
|
|
1960
1949
|
className: "ago-nudge__close",
|
|
1961
|
-
"aria-label":
|
|
1962
|
-
onClick:
|
|
1950
|
+
"aria-label": c.widget.dismiss,
|
|
1951
|
+
onClick: p,
|
|
1963
1952
|
style: {
|
|
1964
1953
|
position: "absolute",
|
|
1965
1954
|
top: "6px",
|
|
@@ -1977,9 +1966,9 @@ var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
|
|
|
1977
1966
|
/* @__PURE__ */ a("div", {
|
|
1978
1967
|
className: "ago-nudge__message",
|
|
1979
1968
|
style: { paddingRight: "16px" },
|
|
1980
|
-
children:
|
|
1969
|
+
children: u.message
|
|
1981
1970
|
}),
|
|
1982
|
-
(
|
|
1971
|
+
(u.action || m) && /* @__PURE__ */ W("div", {
|
|
1983
1972
|
className: "ago-nudge__actions",
|
|
1984
1973
|
style: {
|
|
1985
1974
|
display: "flex",
|
|
@@ -1987,11 +1976,11 @@ var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
|
|
|
1987
1976
|
marginTop: "10px",
|
|
1988
1977
|
flexWrap: "wrap"
|
|
1989
1978
|
},
|
|
1990
|
-
children: [
|
|
1979
|
+
children: [u.action && /* @__PURE__ */ a("button", {
|
|
1991
1980
|
type: "button",
|
|
1992
1981
|
className: "ago-nudge__action",
|
|
1993
1982
|
onClick: () => {
|
|
1994
|
-
|
|
1983
|
+
d();
|
|
1995
1984
|
},
|
|
1996
1985
|
style: {
|
|
1997
1986
|
border: "none",
|
|
@@ -2003,12 +1992,12 @@ var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
|
|
|
2003
1992
|
fontWeight: 600,
|
|
2004
1993
|
cursor: "pointer"
|
|
2005
1994
|
},
|
|
2006
|
-
children:
|
|
2007
|
-
}),
|
|
1995
|
+
children: u.action.label
|
|
1996
|
+
}), m && /* @__PURE__ */ a("button", {
|
|
2008
1997
|
type: "button",
|
|
2009
1998
|
className: "ago-nudge__expand",
|
|
2010
1999
|
onClick: () => {
|
|
2011
|
-
|
|
2000
|
+
d();
|
|
2012
2001
|
},
|
|
2013
2002
|
style: {
|
|
2014
2003
|
border: "1px solid #dee3e8",
|
|
@@ -2020,67 +2009,67 @@ var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
|
|
|
2020
2009
|
fontWeight: 600,
|
|
2021
2010
|
cursor: "pointer"
|
|
2022
2011
|
},
|
|
2023
|
-
children:
|
|
2012
|
+
children: i
|
|
2024
2013
|
})]
|
|
2025
2014
|
})
|
|
2026
2015
|
]
|
|
2027
2016
|
});
|
|
2028
2017
|
};
|
|
2029
|
-
function
|
|
2030
|
-
const t =
|
|
2031
|
-
if (!
|
|
2032
|
-
const [n, s] =
|
|
2033
|
-
d(!0),
|
|
2018
|
+
function Ut({ client: e, autoLoad: o = !0 } = {}) {
|
|
2019
|
+
const t = $(), r = e || t;
|
|
2020
|
+
if (!r) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
2021
|
+
const [n, s] = E([]), [c, i] = E(null), [u, d] = E(!1), [p, m] = E(null), x = R(async () => {
|
|
2022
|
+
d(!0), m(null);
|
|
2034
2023
|
try {
|
|
2035
|
-
const { data:
|
|
2036
|
-
s(
|
|
2037
|
-
} catch (
|
|
2038
|
-
|
|
2024
|
+
const { data: l } = await r.getConversations();
|
|
2025
|
+
s(l);
|
|
2026
|
+
} catch (l) {
|
|
2027
|
+
m(l instanceof Error ? l : /* @__PURE__ */ new Error("Failed to load conversations"));
|
|
2039
2028
|
} finally {
|
|
2040
2029
|
d(!1);
|
|
2041
2030
|
}
|
|
2042
|
-
}, [
|
|
2043
|
-
d(!0),
|
|
2031
|
+
}, [r]), f = R(async (l) => {
|
|
2032
|
+
d(!0), m(null);
|
|
2044
2033
|
try {
|
|
2045
|
-
i(await
|
|
2046
|
-
} catch (
|
|
2047
|
-
|
|
2034
|
+
i(await r.getConversation(l));
|
|
2035
|
+
} catch (h) {
|
|
2036
|
+
m(h instanceof Error ? h : /* @__PURE__ */ new Error("Failed to load conversation"));
|
|
2048
2037
|
} finally {
|
|
2049
2038
|
d(!1);
|
|
2050
2039
|
}
|
|
2051
|
-
}, [
|
|
2040
|
+
}, [r]), v = R(() => {
|
|
2052
2041
|
i(null);
|
|
2053
2042
|
}, []);
|
|
2054
|
-
return
|
|
2055
|
-
|
|
2056
|
-
}, [
|
|
2043
|
+
return _(() => {
|
|
2044
|
+
o && x();
|
|
2045
|
+
}, [o, x]), {
|
|
2057
2046
|
conversations: n,
|
|
2058
|
-
currentConversation:
|
|
2059
|
-
isLoading:
|
|
2060
|
-
error:
|
|
2061
|
-
selectConversation:
|
|
2062
|
-
startNewConversation:
|
|
2063
|
-
refreshConversations:
|
|
2047
|
+
currentConversation: c,
|
|
2048
|
+
isLoading: u,
|
|
2049
|
+
error: p,
|
|
2050
|
+
selectConversation: f,
|
|
2051
|
+
startNewConversation: v,
|
|
2052
|
+
refreshConversations: x
|
|
2064
2053
|
};
|
|
2065
2054
|
}
|
|
2066
|
-
function
|
|
2067
|
-
const
|
|
2055
|
+
function pn(e = {}) {
|
|
2056
|
+
const o = $(), t = e.client || o;
|
|
2068
2057
|
if (!t) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
2069
|
-
const
|
|
2058
|
+
const r = Re({
|
|
2070
2059
|
client: t,
|
|
2071
2060
|
conversationId: e.conversationId
|
|
2072
|
-
}), n =
|
|
2061
|
+
}), n = Ut({
|
|
2073
2062
|
client: t,
|
|
2074
2063
|
autoLoad: e.autoLoad
|
|
2075
2064
|
});
|
|
2076
2065
|
return {
|
|
2077
|
-
messages:
|
|
2078
|
-
isLoading:
|
|
2079
|
-
error:
|
|
2080
|
-
sendMessage:
|
|
2081
|
-
stop:
|
|
2082
|
-
clearMessages:
|
|
2083
|
-
conversationId:
|
|
2066
|
+
messages: r.messages,
|
|
2067
|
+
isLoading: r.isLoading,
|
|
2068
|
+
error: r.error || n.error,
|
|
2069
|
+
sendMessage: r.sendMessage,
|
|
2070
|
+
stop: r.stop,
|
|
2071
|
+
clearMessages: r.clearMessages,
|
|
2072
|
+
conversationId: r.conversationId,
|
|
2084
2073
|
conversations: n.conversations,
|
|
2085
2074
|
currentConversation: n.currentConversation,
|
|
2086
2075
|
isConversationsLoading: n.isLoading,
|
|
@@ -2089,117 +2078,117 @@ function nn(e = {}) {
|
|
|
2089
2078
|
refreshConversations: n.refreshConversations
|
|
2090
2079
|
};
|
|
2091
2080
|
}
|
|
2092
|
-
function
|
|
2093
|
-
const t =
|
|
2081
|
+
function fn(e, o) {
|
|
2082
|
+
const t = V(), { name: r, description: n, parameters: s, handler: c, maxResultBytes: i, requiresApproval: u, webmcp: d } = typeof e == "string" ? {
|
|
2094
2083
|
name: e,
|
|
2095
|
-
...
|
|
2096
|
-
} : e,
|
|
2097
|
-
|
|
2098
|
-
const
|
|
2099
|
-
return t.registerFunction(
|
|
2084
|
+
...o
|
|
2085
|
+
} : e, p = D(c);
|
|
2086
|
+
p.current = c, _(() => {
|
|
2087
|
+
const m = (x) => p.current(x);
|
|
2088
|
+
return t.registerFunction(r, m, {
|
|
2100
2089
|
description: n,
|
|
2101
2090
|
parameters: s,
|
|
2102
2091
|
maxResultBytes: i,
|
|
2103
|
-
requiresApproval:
|
|
2092
|
+
requiresApproval: u,
|
|
2104
2093
|
webmcp: d
|
|
2105
2094
|
}), () => {
|
|
2106
|
-
t.unregisterFunction(
|
|
2095
|
+
t.unregisterFunction(r);
|
|
2107
2096
|
};
|
|
2108
2097
|
}, [
|
|
2109
2098
|
t,
|
|
2110
|
-
|
|
2099
|
+
r,
|
|
2111
2100
|
n,
|
|
2112
2101
|
JSON.stringify(s),
|
|
2113
2102
|
i,
|
|
2114
|
-
|
|
2103
|
+
u,
|
|
2115
2104
|
JSON.stringify(d ?? null)
|
|
2116
2105
|
]);
|
|
2117
2106
|
}
|
|
2118
|
-
function
|
|
2119
|
-
const
|
|
2107
|
+
function gn(e, o, t) {
|
|
2108
|
+
const r = V(), n = D(e);
|
|
2120
2109
|
n.current = e;
|
|
2121
2110
|
const s = t?.catalogue;
|
|
2122
|
-
|
|
2123
|
-
|
|
2111
|
+
_(() => (r.registerNavigationFunction((c) => n.current(c), o, { catalogue: s === "onDemand" ? "onDemand" : "inline" }), () => {
|
|
2112
|
+
r.unregisterNavigationFunction();
|
|
2124
2113
|
}), [
|
|
2125
|
-
o,
|
|
2126
2114
|
r,
|
|
2115
|
+
o,
|
|
2127
2116
|
s
|
|
2128
2117
|
]);
|
|
2129
2118
|
}
|
|
2130
|
-
function
|
|
2131
|
-
const t =
|
|
2119
|
+
function mn(e, o) {
|
|
2120
|
+
const t = V(), r = o?.functionName ?? "setPageState", n = o?.requiresApproval, s = o?.data !== void 0, c = o?.data?.description, i = o?.data?.maxResultBytes, u = o?.settleTimeoutMs, d = D(e);
|
|
2132
2121
|
d.current = e;
|
|
2133
|
-
const
|
|
2134
|
-
|
|
2135
|
-
const
|
|
2136
|
-
const
|
|
2122
|
+
const p = D(o);
|
|
2123
|
+
p.current = o, _(() => {
|
|
2124
|
+
const m = d.current.map((f) => {
|
|
2125
|
+
const v = () => d.current.find((l) => l.name === f.name) ?? f;
|
|
2137
2126
|
return {
|
|
2138
|
-
name:
|
|
2139
|
-
description:
|
|
2140
|
-
schema:
|
|
2141
|
-
clearable:
|
|
2142
|
-
get:
|
|
2143
|
-
set: (
|
|
2127
|
+
name: f.name,
|
|
2128
|
+
description: f.description,
|
|
2129
|
+
schema: f.schema,
|
|
2130
|
+
clearable: f.clearable,
|
|
2131
|
+
get: f.get ? () => v().get?.() : void 0,
|
|
2132
|
+
set: (l) => v().set(l)
|
|
2144
2133
|
};
|
|
2145
|
-
}),
|
|
2146
|
-
description:
|
|
2134
|
+
}), x = s ? {
|
|
2135
|
+
description: c ?? "What the page is currently showing.",
|
|
2147
2136
|
maxResultBytes: i,
|
|
2148
|
-
get: () =>
|
|
2149
|
-
isLoading: () =>
|
|
2137
|
+
get: () => p.current?.data?.get(),
|
|
2138
|
+
isLoading: () => p.current?.data?.isLoading?.() ?? !1
|
|
2150
2139
|
} : void 0;
|
|
2151
|
-
return t.registerPageStateFunction(
|
|
2152
|
-
functionName:
|
|
2140
|
+
return t.registerPageStateFunction(m, {
|
|
2141
|
+
functionName: r,
|
|
2153
2142
|
requiresApproval: n,
|
|
2154
|
-
data:
|
|
2155
|
-
settleTimeoutMs:
|
|
2143
|
+
data: x,
|
|
2144
|
+
settleTimeoutMs: u
|
|
2156
2145
|
}), () => {
|
|
2157
|
-
t.unregisterPageStateFunction(
|
|
2146
|
+
t.unregisterPageStateFunction(r);
|
|
2158
2147
|
};
|
|
2159
2148
|
}, [
|
|
2160
2149
|
t,
|
|
2161
|
-
|
|
2150
|
+
r,
|
|
2162
2151
|
n,
|
|
2163
2152
|
s,
|
|
2164
|
-
|
|
2153
|
+
c,
|
|
2165
2154
|
i,
|
|
2166
|
-
|
|
2167
|
-
JSON.stringify(e.map((
|
|
2168
|
-
name:
|
|
2169
|
-
description:
|
|
2170
|
-
schema:
|
|
2171
|
-
clearable:
|
|
2155
|
+
u,
|
|
2156
|
+
JSON.stringify(e.map((m) => ({
|
|
2157
|
+
name: m.name,
|
|
2158
|
+
description: m.description,
|
|
2159
|
+
schema: m.schema,
|
|
2160
|
+
clearable: m.clearable
|
|
2172
2161
|
})))
|
|
2173
2162
|
]);
|
|
2174
2163
|
}
|
|
2175
|
-
function
|
|
2176
|
-
const
|
|
2177
|
-
t.current = e,
|
|
2164
|
+
function hn(e) {
|
|
2165
|
+
const o = V(), t = D(e);
|
|
2166
|
+
t.current = e, _(() => Je(o, () => t.current), [o]);
|
|
2178
2167
|
}
|
|
2179
|
-
function
|
|
2180
|
-
const
|
|
2181
|
-
if (!t) throw new
|
|
2182
|
-
const [
|
|
2183
|
-
|
|
2168
|
+
function xn(e = {}) {
|
|
2169
|
+
const o = $(), t = e.client || o;
|
|
2170
|
+
if (!t) throw new ae("useAgoActivityLog requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
|
|
2171
|
+
const [r, n] = E(() => t.getRecentActivity());
|
|
2172
|
+
_(() => {
|
|
2184
2173
|
n(t.getRecentActivity());
|
|
2185
2174
|
const i = () => n(t.getRecentActivity());
|
|
2186
2175
|
return t.on("activity:recorded", i), () => t.off("activity:recorded", i);
|
|
2187
2176
|
}, [t]);
|
|
2188
|
-
const s =
|
|
2177
|
+
const s = R((i) => t.recordActivity(i), [t]), c = R(() => {
|
|
2189
2178
|
t.clearActivity(), n([]);
|
|
2190
2179
|
}, [t]);
|
|
2191
2180
|
return {
|
|
2192
|
-
entries:
|
|
2193
|
-
latest:
|
|
2181
|
+
entries: r,
|
|
2182
|
+
latest: r.length > 0 ? r[r.length - 1] : void 0,
|
|
2194
2183
|
record: s,
|
|
2195
|
-
clear:
|
|
2184
|
+
clear: c
|
|
2196
2185
|
};
|
|
2197
2186
|
}
|
|
2198
|
-
function
|
|
2199
|
-
const t =
|
|
2187
|
+
function bn(e, o) {
|
|
2188
|
+
const t = V(), r = rt(), n = o ?? r, s = D(e);
|
|
2200
2189
|
s.current = e;
|
|
2201
|
-
const
|
|
2202
|
-
|
|
2190
|
+
const c = typeof e == "function";
|
|
2191
|
+
_(() => {
|
|
2203
2192
|
if (typeof s.current == "function") {
|
|
2204
2193
|
const i = () => s.current();
|
|
2205
2194
|
return t.addDynamicContext(n, i), () => {
|
|
@@ -2212,74 +2201,74 @@ function cn(e, r) {
|
|
|
2212
2201
|
}, [
|
|
2213
2202
|
t,
|
|
2214
2203
|
n,
|
|
2215
|
-
|
|
2216
|
-
|
|
2204
|
+
c,
|
|
2205
|
+
c ? "" : JSON.stringify(e)
|
|
2217
2206
|
]);
|
|
2218
2207
|
}
|
|
2219
|
-
function
|
|
2220
|
-
return
|
|
2208
|
+
function Kt(e) {
|
|
2209
|
+
return ce(e.subscribe, e.get, e.get);
|
|
2221
2210
|
}
|
|
2222
|
-
var
|
|
2211
|
+
var ke = {
|
|
2223
2212
|
missing: [],
|
|
2224
2213
|
complete: !1
|
|
2225
2214
|
};
|
|
2226
|
-
function
|
|
2227
|
-
const
|
|
2215
|
+
function yn(e) {
|
|
2216
|
+
const o = V(), t = e.schema != null, r = 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), i = U(() => t ? Se(e) : null, [
|
|
2228
2217
|
t,
|
|
2229
2218
|
e.name,
|
|
2230
|
-
|
|
2219
|
+
r,
|
|
2231
2220
|
s,
|
|
2232
|
-
|
|
2221
|
+
c,
|
|
2233
2222
|
e.autoSubmit
|
|
2234
|
-
]), [
|
|
2223
|
+
]), [u, d] = E({
|
|
2235
2224
|
collector: null,
|
|
2236
2225
|
loading: !t,
|
|
2237
2226
|
error: null
|
|
2238
2227
|
});
|
|
2239
|
-
|
|
2228
|
+
_(() => {
|
|
2240
2229
|
if (t) return;
|
|
2241
|
-
let
|
|
2230
|
+
let I = !1;
|
|
2242
2231
|
return d({
|
|
2243
2232
|
collector: null,
|
|
2244
2233
|
loading: !0,
|
|
2245
2234
|
error: null
|
|
2246
|
-
}),
|
|
2247
|
-
|
|
2248
|
-
collector:
|
|
2235
|
+
}), Ce(o, e).then((N) => {
|
|
2236
|
+
I || d({
|
|
2237
|
+
collector: N,
|
|
2249
2238
|
loading: !1,
|
|
2250
2239
|
error: null
|
|
2251
2240
|
});
|
|
2252
|
-
}).catch((
|
|
2253
|
-
|
|
2241
|
+
}).catch((N) => {
|
|
2242
|
+
I || d({
|
|
2254
2243
|
collector: null,
|
|
2255
2244
|
loading: !1,
|
|
2256
|
-
error:
|
|
2245
|
+
error: N instanceof Error ? N : new Error(String(N))
|
|
2257
2246
|
});
|
|
2258
2247
|
}), () => {
|
|
2259
|
-
|
|
2248
|
+
I = !0;
|
|
2260
2249
|
};
|
|
2261
2250
|
}, [
|
|
2262
|
-
|
|
2251
|
+
o,
|
|
2263
2252
|
t,
|
|
2264
2253
|
e.name,
|
|
2265
2254
|
s,
|
|
2266
|
-
|
|
2255
|
+
c,
|
|
2267
2256
|
e.autoSubmit
|
|
2268
2257
|
]);
|
|
2269
|
-
const
|
|
2270
|
-
|
|
2271
|
-
if (
|
|
2272
|
-
return
|
|
2273
|
-
}, [
|
|
2274
|
-
const
|
|
2258
|
+
const p = t ? i : u.collector, m = t ? !1 : u.loading, x = t ? null : u.error;
|
|
2259
|
+
_(() => {
|
|
2260
|
+
if (p)
|
|
2261
|
+
return p.install(o);
|
|
2262
|
+
}, [o, p]);
|
|
2263
|
+
const f = U(() => je({
|
|
2275
2264
|
values: e.initialValues ?? {},
|
|
2276
2265
|
submitted: !1
|
|
2277
|
-
}), [
|
|
2278
|
-
...
|
|
2279
|
-
...
|
|
2280
|
-
}), [
|
|
2266
|
+
}), [c]), v = Kt(p?.store ?? f), l = U(() => p?.getStatus() ?? ke, [v, p]), h = U(() => ({
|
|
2267
|
+
...v,
|
|
2268
|
+
...l
|
|
2269
|
+
}), [v, l]), b = U(() => ({
|
|
2281
2270
|
name: e.name,
|
|
2282
|
-
store:
|
|
2271
|
+
store: f,
|
|
2283
2272
|
functions: [],
|
|
2284
2273
|
contextKey: `form:${e.name}`,
|
|
2285
2274
|
contextProvider: () => ({
|
|
@@ -2300,52 +2289,52 @@ function dn(e) {
|
|
|
2300
2289
|
ok: !1,
|
|
2301
2290
|
error: "Form definition not loaded yet."
|
|
2302
2291
|
}),
|
|
2303
|
-
getValues: () =>
|
|
2292
|
+
getValues: () => f.get().values,
|
|
2304
2293
|
setValues: () => {
|
|
2305
2294
|
},
|
|
2306
2295
|
reset: () => {
|
|
2307
2296
|
},
|
|
2308
|
-
getStatus: () =>
|
|
2309
|
-
}), [e.name,
|
|
2297
|
+
getStatus: () => ke
|
|
2298
|
+
}), [e.name, f]);
|
|
2310
2299
|
return {
|
|
2311
|
-
...
|
|
2312
|
-
state:
|
|
2313
|
-
loading:
|
|
2314
|
-
error:
|
|
2300
|
+
...p ?? b,
|
|
2301
|
+
state: h,
|
|
2302
|
+
loading: m,
|
|
2303
|
+
error: x
|
|
2315
2304
|
};
|
|
2316
2305
|
}
|
|
2317
2306
|
export {
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2307
|
+
un as AgoNudge,
|
|
2308
|
+
ln as AgoProvider,
|
|
2309
|
+
wt as ChatInput,
|
|
2310
|
+
dn as ChatWidget,
|
|
2311
|
+
cn as DEFAULT_MESSAGE_FEEDBACK_LABELS,
|
|
2312
|
+
nn as DEFAULT_SPEECH_TO_TEXT_LABELS,
|
|
2313
|
+
Ge as FEEDBACK_REASONS,
|
|
2314
|
+
zt as Markdown,
|
|
2315
|
+
Ht as Message,
|
|
2316
|
+
jt as MessageFeedback,
|
|
2317
|
+
vt as SpeechToTextButton,
|
|
2318
|
+
Se as createFormCollector,
|
|
2319
|
+
Qt as createMockClient,
|
|
2320
|
+
Yt as deriveFormStatus,
|
|
2321
|
+
Ce as loadFormCollector,
|
|
2322
|
+
ct as useAgo,
|
|
2323
|
+
ft as useAgoActivity,
|
|
2324
|
+
xn as useAgoActivityLog,
|
|
2325
|
+
hn as useAgoAutoContinueAfterNavigation,
|
|
2326
|
+
V as useAgoClient,
|
|
2327
|
+
bn as useAgoContext,
|
|
2328
|
+
fn as useAgoFunction,
|
|
2329
|
+
gn as useAgoNavigation,
|
|
2330
|
+
mn as useAgoPageState,
|
|
2331
|
+
Kt as useAgoStore,
|
|
2332
|
+
pn as useChat,
|
|
2333
|
+
Ut as useConversation,
|
|
2334
|
+
Ot as useFeedback,
|
|
2335
|
+
yn as useFormCollector,
|
|
2336
|
+
Re as useMessages,
|
|
2337
|
+
$ as useOptionalAgoClient,
|
|
2338
|
+
qt as useProactiveNudge,
|
|
2339
|
+
ht as useSheet
|
|
2351
2340
|
};
|