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