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