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