@useago/sdk 1.5.6 → 1.7.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 +223 -0
- package/README.md +59 -0
- package/dist/AgoClient-BHegN73y.cjs +9 -0
- package/dist/{AgoClient-B_R_qi2s.js → AgoClient-PWPaekcg.js} +656 -387
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +230 -5
- package/dist/angular.d.ts +230 -5
- package/dist/angular.js +10 -1
- package/dist/{createConversationSession-Dqh7NXK4.cjs → createConversationSession-BbUUukV0.cjs} +1 -1
- package/dist/{createConversationSession-CdtI4vrf.js → createConversationSession-BkruoOVm.js} +1 -1
- package/dist/{createFormCollector-BjO3oB63.cjs → createFormCollector-C1ixsjV0.cjs} +1 -1
- package/dist/{createFormCollector-YwaZ78wU.js → createFormCollector-CvVFNkp6.js} +1 -1
- package/dist/{createMockClient-DcuNlufr.js → createMockClient-BDLW6tVc.js} +5 -2
- package/dist/createMockClient-BSNuN3ys.cjs +1 -0
- package/dist/devtools.d.cts +220 -5
- package/dist/devtools.d.ts +220 -5
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +238 -6
- package/dist/index.d.ts +238 -6
- package/dist/index.js +111 -109
- package/dist/react.cjs +40 -3
- package/dist/react.d.cts +419 -7
- package/dist/react.d.ts +419 -7
- package/dist/react.js +1195 -743
- package/dist/sheetController-CBUVOroo.js +205 -0
- package/dist/sheetController-DY-sC13T.cjs +1 -0
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +220 -5
- package/dist/testing.d.ts +220 -5
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +235 -5
- package/dist/vue.d.ts +235 -5
- package/dist/vue.js +121 -100
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +328 -5
- package/dist/widget.d.ts +328 -5
- package/dist/widget.js +721 -629
- package/llms-full.txt +202 -14
- package/package.json +1 -1
- package/dist/AgoClient-DLB9icvv.cjs +0 -8
- package/dist/createMockClient-Dw-cyISN.cjs +0 -1
package/dist/react.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as
|
|
3
|
-
import { n as
|
|
4
|
-
import { t as
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { a as Ee, b as Z, h as Me, i as Te, o as Fe, s as We, t as ze } from "./AgoClient-PWPaekcg.js";
|
|
2
|
+
import { t as Pe } from "./autoContinue-CC8K9mBU.js";
|
|
3
|
+
import { n as Et, r as ue, t as pe } from "./createFormCollector-CvVFNkp6.js";
|
|
4
|
+
import { t as Tt } from "./createMockClient-BDLW6tVc.js";
|
|
5
|
+
import { C as De, S as Le, n as He } from "./sheetController-CBUVOroo.js";
|
|
6
|
+
import Be, { createContext as Oe, forwardRef as je, useCallback as R, useContext as fe, useEffect as N, useId as $e, useImperativeHandle as qe, useMemo as H, useRef as W, useState as z, useSyncExternalStore as ge } from "react";
|
|
7
|
+
import { Fragment as me, jsx as a, jsxs as T } from "react/jsx-runtime";
|
|
8
|
+
import Ke from "react-markdown";
|
|
9
|
+
import Ue from "remark-gfm";
|
|
10
|
+
function Ge(e) {
|
|
11
|
+
const [o, t] = z(!1), r = W(null), n = H(() => {
|
|
12
|
+
if (r.current && (r.current.destroy(), r.current = null), !e) return null;
|
|
13
|
+
const s = new ze(e);
|
|
14
|
+
return r.current = s, s;
|
|
14
15
|
}, [e?.baseUrl, e?.widgetId]);
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
}), [n]),
|
|
18
|
-
|
|
16
|
+
return N(() => (n && r.current === null && (r.current = n, n.reviveAfterDestroy()), t(!0), () => {
|
|
17
|
+
r.current?.destroy(), r.current = null;
|
|
18
|
+
}), [n]), N(() => {
|
|
19
|
+
r.current && e && r.current.updateConfig({
|
|
19
20
|
agent: e.agent,
|
|
20
21
|
defaultAgentId: e.defaultAgentId,
|
|
21
22
|
permission: e.permission,
|
|
@@ -34,199 +35,521 @@ function ce(e) {
|
|
|
34
35
|
e?.warnOnEmptyReply
|
|
35
36
|
]), {
|
|
36
37
|
client: n,
|
|
37
|
-
isReady:
|
|
38
|
+
isReady: o
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
|
-
var
|
|
41
|
-
const { client:
|
|
42
|
-
return
|
|
41
|
+
var Q = Oe(null), Lt = ({ children: e, client: o, tools: t, helpers: r, pageContext: n, ...s }) => {
|
|
42
|
+
const { client: i } = Ge(o ? null : s), l = o || i;
|
|
43
|
+
return N(() => {
|
|
43
44
|
if (!(!t || t.length === 0)) {
|
|
44
|
-
for (const
|
|
45
|
+
for (const c of t) l.register(c);
|
|
45
46
|
return () => {
|
|
46
|
-
for (const
|
|
47
|
+
for (const c of t) l.unregisterFunction(c.name);
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
|
-
}, [
|
|
50
|
-
if (!
|
|
51
|
-
const
|
|
52
|
-
return import("./functions-tzyOZNp6.js").then((
|
|
53
|
-
for (const [
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
56
|
-
console.warn(`[AGO] Unknown helper: "${
|
|
50
|
+
}, [l, t]), N(() => {
|
|
51
|
+
if (!r) return;
|
|
52
|
+
const c = [];
|
|
53
|
+
return import("./functions-tzyOZNp6.js").then((p) => p.n).then((p) => {
|
|
54
|
+
for (const [f, k] of Object.entries(r)) {
|
|
55
|
+
const _ = p[f];
|
|
56
|
+
if (!_) {
|
|
57
|
+
console.warn(`[AGO] Unknown helper: "${f}"`);
|
|
57
58
|
continue;
|
|
58
59
|
}
|
|
59
|
-
const
|
|
60
|
-
...
|
|
61
|
-
handler:
|
|
60
|
+
const C = k === !0 ? _ : {
|
|
61
|
+
..._,
|
|
62
|
+
handler: k
|
|
62
63
|
};
|
|
63
|
-
|
|
64
|
+
l.register(C), c.push(C.name);
|
|
64
65
|
}
|
|
65
66
|
}), () => {
|
|
66
|
-
for (const
|
|
67
|
+
for (const p of c) l.unregisterFunction(p);
|
|
67
68
|
};
|
|
68
|
-
}, [
|
|
69
|
-
n === "auto" &&
|
|
70
|
-
}, [
|
|
71
|
-
value:
|
|
69
|
+
}, [l, r]), N(() => {
|
|
70
|
+
n === "auto" && l.enableAutoPageContext();
|
|
71
|
+
}, [l, n]), /* @__PURE__ */ a(Q.Provider, {
|
|
72
|
+
value: l,
|
|
72
73
|
children: e
|
|
73
74
|
});
|
|
74
75
|
};
|
|
75
|
-
function
|
|
76
|
-
const e =
|
|
76
|
+
function $() {
|
|
77
|
+
const e = fe(Q);
|
|
77
78
|
if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
|
|
78
79
|
return e;
|
|
79
80
|
}
|
|
80
|
-
function
|
|
81
|
-
return
|
|
81
|
+
function O() {
|
|
82
|
+
return fe(Q);
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
var Je = /* @__PURE__ */ new Set(["awaiting-approval"]);
|
|
85
|
+
function he(e) {
|
|
86
|
+
switch (e) {
|
|
87
|
+
case "progress_indicator":
|
|
88
|
+
return "progress";
|
|
89
|
+
case "reasoning":
|
|
90
|
+
return "reasoning";
|
|
91
|
+
case "confirmation_input":
|
|
92
|
+
return "confirmation";
|
|
93
|
+
case "form":
|
|
94
|
+
return "form";
|
|
95
|
+
default:
|
|
96
|
+
return "status";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function Ve(e) {
|
|
100
|
+
return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : he(e.type);
|
|
101
|
+
}
|
|
102
|
+
function se(e, o) {
|
|
103
|
+
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")) && (o === "confirmation" || o === "form") ? "awaiting-approval" : "running";
|
|
105
|
+
}
|
|
106
|
+
function le(e) {
|
|
107
|
+
return typeof e != "string" || !e ? "page" : e.replace(/[-_]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (o) => o.toUpperCase()).trim();
|
|
108
|
+
}
|
|
109
|
+
function Ye(e) {
|
|
110
|
+
switch (e.kind) {
|
|
111
|
+
case "navigation":
|
|
112
|
+
return `Navigating to ${le(e.arguments?.page)}`;
|
|
113
|
+
case "action":
|
|
114
|
+
return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message || le(e.functionName) || "Working";
|
|
115
|
+
case "progress":
|
|
116
|
+
return e.message || "Working";
|
|
117
|
+
case "reasoning":
|
|
118
|
+
return e.message || "Thinking";
|
|
119
|
+
case "confirmation":
|
|
120
|
+
return e.message || "Waiting for your confirmation";
|
|
121
|
+
case "form":
|
|
122
|
+
return e.message || e.toolDisplayName || "Please fill in the form";
|
|
123
|
+
default:
|
|
124
|
+
return e.message || e.toolDisplayName || e.toolName || "Working";
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function Xe(e = {}) {
|
|
128
|
+
const { includeReasoning: o = !1, labelFor: t } = e, r = O(), n = e.client || r;
|
|
129
|
+
if (!n) throw new Z("useAgoActivity requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
|
|
130
|
+
const [s, i] = z([]), l = W(/* @__PURE__ */ new Set()), c = W(void 0), p = W(t);
|
|
131
|
+
p.current = t;
|
|
132
|
+
const f = R((u, A) => {
|
|
133
|
+
i((b) => {
|
|
134
|
+
const d = b.findIndex((m) => m.id === u), y = {
|
|
135
|
+
...d >= 0 ? b[d] : {
|
|
136
|
+
id: u,
|
|
137
|
+
kind: "status",
|
|
138
|
+
label: "",
|
|
139
|
+
status: "running",
|
|
140
|
+
requiresApproval: !1,
|
|
141
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
142
|
+
},
|
|
143
|
+
...A
|
|
144
|
+
};
|
|
145
|
+
return y.label = p.current?.(y) ?? Ye(y), d >= 0 ? [
|
|
146
|
+
...b.slice(0, d),
|
|
147
|
+
y,
|
|
148
|
+
...b.slice(d + 1)
|
|
149
|
+
] : [...b, y];
|
|
150
|
+
});
|
|
151
|
+
}, []);
|
|
152
|
+
N(() => {
|
|
153
|
+
const u = (x) => {
|
|
154
|
+
c.current = x.messageId;
|
|
155
|
+
}, A = (x) => {
|
|
156
|
+
const M = he(x.type);
|
|
157
|
+
M === "reasoning" && !o || f(x.id, {
|
|
158
|
+
kind: M,
|
|
159
|
+
status: se(x.status, M),
|
|
160
|
+
messageId: c.current,
|
|
161
|
+
toolName: x.toolName,
|
|
162
|
+
toolDisplayName: x.toolDisplayName,
|
|
163
|
+
message: x.message,
|
|
164
|
+
data: x.data,
|
|
165
|
+
formSchema: x.formSchema,
|
|
166
|
+
requiresApproval: M === "confirmation" || M === "form"
|
|
167
|
+
});
|
|
168
|
+
}, b = (x) => {
|
|
169
|
+
x.invocationId && f(x.invocationId, {
|
|
170
|
+
kind: x.functionName === "navigateToPage" ? "navigation" : "action",
|
|
171
|
+
status: "running",
|
|
172
|
+
messageId: c.current,
|
|
173
|
+
functionName: x.functionName,
|
|
174
|
+
arguments: x.arguments
|
|
175
|
+
});
|
|
176
|
+
}, d = (x) => {
|
|
177
|
+
x.invocationId && f(x.invocationId, {
|
|
178
|
+
kind: x.functionName === "navigateToPage" ? "navigation" : "action",
|
|
179
|
+
status: "awaiting-approval",
|
|
180
|
+
messageId: c.current,
|
|
181
|
+
functionName: x.functionName,
|
|
182
|
+
arguments: x.arguments,
|
|
183
|
+
requiresApproval: !0
|
|
184
|
+
});
|
|
185
|
+
}, y = (x) => {
|
|
186
|
+
if (!x.invocationId) return;
|
|
187
|
+
const M = x.result, v = typeof x.result == "object" && M !== null && M.approved === !1 && M.reason === "user_rejected";
|
|
188
|
+
f(x.invocationId, {
|
|
189
|
+
status: x.error ? "error" : v ? "rejected" : "done",
|
|
190
|
+
requiresApproval: !1
|
|
191
|
+
});
|
|
192
|
+
}, m = (x) => {
|
|
193
|
+
for (const M of x.messages ?? [])
|
|
194
|
+
if (M.role === "assistant")
|
|
195
|
+
for (const v of M.toolCalls ?? []) {
|
|
196
|
+
const D = Ve(v);
|
|
197
|
+
D === "reasoning" && !o || /waiting/i.test(v.status ?? "") || f(v.id, {
|
|
198
|
+
kind: D,
|
|
199
|
+
status: se(v.status, D),
|
|
200
|
+
messageId: M.id,
|
|
201
|
+
toolName: v.toolName,
|
|
202
|
+
toolDisplayName: v.toolDisplayName,
|
|
203
|
+
functionName: v.functionName,
|
|
204
|
+
arguments: v.arguments,
|
|
205
|
+
message: v.message,
|
|
206
|
+
data: v.data,
|
|
207
|
+
formSchema: v.formSchema,
|
|
208
|
+
requiresApproval: D === "confirmation" || D === "form"
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
}, g = (x) => {
|
|
212
|
+
i((M) => M.map((v) => v.status === "running" || v.status === "awaiting-approval" ? {
|
|
213
|
+
...v,
|
|
214
|
+
status: x
|
|
215
|
+
} : v));
|
|
216
|
+
}, w = () => g("done"), S = () => g("error");
|
|
217
|
+
return n.on("message:start", u), n.on("toolCall:received", A), n.on("function:invoke", b), n.on("function:awaiting-approval", d), n.on("function:result", y), n.on("conversation:loaded", m), n.on("message:complete", w), n.on("message:error", S), () => {
|
|
218
|
+
n.off("message:start", u), n.off("toolCall:received", A), n.off("function:invoke", b), n.off("function:awaiting-approval", d), n.off("function:result", y), n.off("conversation:loaded", m), n.off("message:complete", w), n.off("message:error", S);
|
|
219
|
+
};
|
|
220
|
+
}, [
|
|
221
|
+
n,
|
|
222
|
+
o,
|
|
223
|
+
f
|
|
224
|
+
]);
|
|
225
|
+
const k = R(async (u) => {
|
|
226
|
+
const A = s.find((b) => b.id === u);
|
|
227
|
+
!A || A.status !== "awaiting-approval" || l.current.has(u) || A.kind !== "form" && (l.current.add(u), f(u, {
|
|
228
|
+
status: "running",
|
|
229
|
+
requiresApproval: !1
|
|
230
|
+
}), A.functionName ? await n.approveFunction(u) : await n.confirmToolCall(u));
|
|
231
|
+
}, [
|
|
232
|
+
n,
|
|
233
|
+
s,
|
|
234
|
+
f
|
|
235
|
+
]), _ = R(async (u) => {
|
|
236
|
+
const A = s.find((b) => b.id === u);
|
|
237
|
+
!A || A.status !== "awaiting-approval" || l.current.has(u) || (l.current.add(u), f(u, {
|
|
238
|
+
status: "rejected",
|
|
239
|
+
requiresApproval: !1
|
|
240
|
+
}), A.functionName ? await n.rejectFunction(u) : await n.rejectToolCall(u));
|
|
241
|
+
}, [
|
|
242
|
+
n,
|
|
243
|
+
s,
|
|
244
|
+
f
|
|
245
|
+
]), C = R(async (u, A) => {
|
|
246
|
+
f(u, {
|
|
247
|
+
status: "running",
|
|
248
|
+
requiresApproval: !1
|
|
249
|
+
}), await n.submitToolCallForm(u, A), f(u, { status: "done" });
|
|
250
|
+
}, [n, f]), I = R(() => {
|
|
251
|
+
l.current.clear(), i([]);
|
|
252
|
+
}, []);
|
|
253
|
+
return {
|
|
254
|
+
items: s,
|
|
255
|
+
latest: s.length > 0 ? s[s.length - 1] : void 0,
|
|
256
|
+
isAwaitingApproval: s.some((u) => Je.has(u.status)),
|
|
257
|
+
approve: k,
|
|
258
|
+
reject: _,
|
|
259
|
+
submitForm: C,
|
|
260
|
+
clear: I
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function xe({ client: e, conversationId: o } = {}) {
|
|
264
|
+
const t = O(), r = e || t;
|
|
265
|
+
if (!r) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
266
|
+
const [n, s] = z([]), [i, l] = z(o), [c, p] = z(!1), [f, k] = z(null);
|
|
267
|
+
N(() => {
|
|
268
|
+
o && o !== i && (l(o), _(o));
|
|
269
|
+
}, [o]);
|
|
270
|
+
const _ = async (C) => {
|
|
91
271
|
try {
|
|
92
|
-
s((await
|
|
93
|
-
} catch (
|
|
94
|
-
|
|
272
|
+
s((await r.getMessages(C)).filter((I) => !I.hidden));
|
|
273
|
+
} catch (I) {
|
|
274
|
+
k(I instanceof Error ? I : /* @__PURE__ */ new Error("Failed to load messages"));
|
|
95
275
|
}
|
|
96
276
|
};
|
|
97
|
-
return
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
const w =
|
|
101
|
-
return w >= 0 ?
|
|
102
|
-
...
|
|
277
|
+
return N(() => {
|
|
278
|
+
const C = (m) => m === "IN_PROGRESS" || m === "WAITING_CLIENT", I = (m) => {
|
|
279
|
+
i || l(m.conversationId), p(!0), s((g) => {
|
|
280
|
+
const w = g.findIndex((S) => S.id === m.messageId);
|
|
281
|
+
return w >= 0 ? g.map((S, x) => x === w ? {
|
|
282
|
+
...S,
|
|
103
283
|
status: "IN_PROGRESS"
|
|
104
|
-
} :
|
|
105
|
-
id:
|
|
106
|
-
conversationId:
|
|
284
|
+
} : S) : g.some((S) => S.role === "assistant" && C(S.status)) ? g : [...g, {
|
|
285
|
+
id: m.messageId,
|
|
286
|
+
conversationId: m.conversationId,
|
|
107
287
|
content: "",
|
|
108
288
|
role: "assistant",
|
|
109
289
|
status: "IN_PROGRESS",
|
|
110
290
|
createdAt: /* @__PURE__ */ new Date()
|
|
111
291
|
}];
|
|
112
292
|
});
|
|
113
|
-
}, u = (
|
|
114
|
-
s((
|
|
115
|
-
const w =
|
|
116
|
-
return w < 0 ?
|
|
117
|
-
...
|
|
118
|
-
content:
|
|
119
|
-
} :
|
|
293
|
+
}, u = (m) => {
|
|
294
|
+
s((g) => {
|
|
295
|
+
const w = g.findIndex((S) => S.id === m.messageId);
|
|
296
|
+
return w < 0 ? g : g.map((S, x) => x === w ? {
|
|
297
|
+
...S,
|
|
298
|
+
content: S.content + m.content
|
|
299
|
+
} : S);
|
|
120
300
|
});
|
|
121
|
-
},
|
|
122
|
-
s((
|
|
301
|
+
}, A = (m) => {
|
|
302
|
+
s((g) => {
|
|
123
303
|
let w = -1;
|
|
124
|
-
for (let
|
|
125
|
-
w =
|
|
304
|
+
for (let S = g.length - 1; S >= 0; S--) if (g[S].role === "assistant" && C(g[S].status)) {
|
|
305
|
+
w = S;
|
|
126
306
|
break;
|
|
127
307
|
}
|
|
128
|
-
return w < 0 ?
|
|
129
|
-
...
|
|
308
|
+
return w < 0 ? g : [
|
|
309
|
+
...g.slice(0, w),
|
|
130
310
|
{
|
|
131
|
-
...
|
|
132
|
-
...
|
|
311
|
+
...g[w],
|
|
312
|
+
...m
|
|
133
313
|
},
|
|
134
|
-
...
|
|
314
|
+
...g.slice(w + 1)
|
|
135
315
|
];
|
|
136
316
|
});
|
|
137
|
-
},
|
|
138
|
-
s((
|
|
139
|
-
const w =
|
|
317
|
+
}, b = (m) => {
|
|
318
|
+
s((g) => {
|
|
319
|
+
const w = g.findIndex((S) => S.id === m.id);
|
|
140
320
|
return w >= 0 ? [
|
|
141
|
-
...
|
|
142
|
-
|
|
143
|
-
...
|
|
144
|
-
] : [...
|
|
145
|
-
}),
|
|
146
|
-
},
|
|
147
|
-
|
|
321
|
+
...g.slice(0, w),
|
|
322
|
+
m,
|
|
323
|
+
...g.slice(w + 1)
|
|
324
|
+
] : [...g, m];
|
|
325
|
+
}), p(!1);
|
|
326
|
+
}, d = (m) => {
|
|
327
|
+
k(new Error(m.error)), p(!1);
|
|
328
|
+
}, y = () => {
|
|
329
|
+
s((m) => {
|
|
330
|
+
let g = -1;
|
|
331
|
+
for (let w = m.length - 1; w >= 0; w--) if (m[w].role === "assistant" && C(m[w].status)) {
|
|
332
|
+
g = w;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
return g < 0 ? m : m[g].content ? m.map((w, S) => S === g ? {
|
|
336
|
+
...w,
|
|
337
|
+
status: "CANCELED"
|
|
338
|
+
} : w) : m.filter((w, S) => S !== g);
|
|
339
|
+
}), p(!1);
|
|
148
340
|
};
|
|
149
|
-
return
|
|
150
|
-
|
|
341
|
+
return r.on("message:start", I), r.on("message:chunk", u), r.on("message:answer-complete", A), r.on("message:complete", b), r.on("message:error", d), r.on("message:stopped", y), () => {
|
|
342
|
+
r.off("message:start", I), r.off("message:chunk", u), r.off("message:answer-complete", A), r.off("message:complete", b), r.off("message:error", d), r.off("message:stopped", y);
|
|
151
343
|
};
|
|
152
|
-
}, [
|
|
344
|
+
}, [r, i]), {
|
|
153
345
|
messages: n,
|
|
154
|
-
isLoading:
|
|
155
|
-
error:
|
|
156
|
-
sendMessage: R(async (
|
|
157
|
-
|
|
346
|
+
isLoading: c,
|
|
347
|
+
error: f,
|
|
348
|
+
sendMessage: R(async (C, I) => {
|
|
349
|
+
p(!0), k(null);
|
|
158
350
|
const u = {
|
|
159
351
|
id: `temp-${Date.now()}`,
|
|
160
|
-
conversationId:
|
|
161
|
-
content:
|
|
352
|
+
conversationId: i || "",
|
|
353
|
+
content: C,
|
|
162
354
|
role: "user",
|
|
163
355
|
status: "DONE",
|
|
164
|
-
attachments:
|
|
356
|
+
attachments: I && I.length > 0 ? Te(I) : void 0,
|
|
165
357
|
createdAt: /* @__PURE__ */ new Date()
|
|
166
|
-
},
|
|
358
|
+
}, A = {
|
|
167
359
|
id: `temp-assistant-${Date.now()}`,
|
|
168
|
-
conversationId:
|
|
360
|
+
conversationId: i || "",
|
|
169
361
|
content: "",
|
|
170
362
|
role: "assistant",
|
|
171
363
|
status: "IN_PROGRESS",
|
|
172
364
|
createdAt: /* @__PURE__ */ new Date()
|
|
173
365
|
};
|
|
174
|
-
s((
|
|
175
|
-
...
|
|
366
|
+
s((b) => [
|
|
367
|
+
...b,
|
|
176
368
|
u,
|
|
177
|
-
|
|
369
|
+
A
|
|
178
370
|
]);
|
|
179
371
|
try {
|
|
180
|
-
const
|
|
181
|
-
conversationId:
|
|
182
|
-
files:
|
|
372
|
+
const b = await r.sendMessage(C, {
|
|
373
|
+
conversationId: i,
|
|
374
|
+
files: I
|
|
183
375
|
});
|
|
184
|
-
return
|
|
185
|
-
const
|
|
376
|
+
return b.conversationId && !i && l(b.conversationId), s((d) => {
|
|
377
|
+
const y = d.filter((g) => !g.id.startsWith("temp-")), m = {
|
|
186
378
|
...u,
|
|
187
379
|
id: u.id.replace("temp-", "user-"),
|
|
188
|
-
conversationId:
|
|
380
|
+
conversationId: b.conversationId
|
|
189
381
|
};
|
|
190
|
-
return
|
|
191
|
-
...
|
|
192
|
-
|
|
193
|
-
|
|
382
|
+
return y.some((g) => g.id === b.id) ? [...y, m].sort((g, w) => new Date(g.createdAt).getTime() - new Date(w.createdAt).getTime()) : [
|
|
383
|
+
...y,
|
|
384
|
+
m,
|
|
385
|
+
b
|
|
194
386
|
];
|
|
195
|
-
}),
|
|
196
|
-
} catch (
|
|
197
|
-
return
|
|
387
|
+
}), b;
|
|
388
|
+
} catch (b) {
|
|
389
|
+
return k(b instanceof Error ? b : /* @__PURE__ */ new Error("Failed to send message")), p(!1), s((d) => d.filter((y) => !y.id.startsWith("temp-"))), null;
|
|
198
390
|
}
|
|
199
|
-
}, [
|
|
391
|
+
}, [r, i]),
|
|
392
|
+
stop: R(async () => {
|
|
393
|
+
await r.stop();
|
|
394
|
+
}, [r]),
|
|
200
395
|
clearMessages: R(() => {
|
|
201
|
-
s([]),
|
|
396
|
+
s([]), l(void 0), k(null);
|
|
202
397
|
}, []),
|
|
203
|
-
conversationId:
|
|
398
|
+
conversationId: i
|
|
204
399
|
};
|
|
205
400
|
}
|
|
206
|
-
var
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
401
|
+
var ce = {
|
|
402
|
+
compact: !1,
|
|
403
|
+
state: "peek",
|
|
404
|
+
isModal: !1,
|
|
405
|
+
surface: {
|
|
406
|
+
style: {},
|
|
407
|
+
attrs: {}
|
|
408
|
+
}
|
|
409
|
+
}, Ze = { tabindex: "tabIndex" };
|
|
410
|
+
function Qe(e) {
|
|
411
|
+
const o = {};
|
|
412
|
+
for (const [t, r] of Object.entries(e)) o[Ze[t] ?? t] = r;
|
|
413
|
+
return o;
|
|
414
|
+
}
|
|
415
|
+
function et(e) {
|
|
416
|
+
const o = e !== !1, t = o ? e ?? {} : void 0, r = W(t?.onStateChange);
|
|
417
|
+
r.current = t?.onStateChange;
|
|
418
|
+
const n = H(() => {
|
|
419
|
+
if (o)
|
|
420
|
+
return He({
|
|
421
|
+
breakpoint: t?.breakpoint,
|
|
422
|
+
initialState: t?.initialState,
|
|
423
|
+
bottomOffset: t?.bottomOffset,
|
|
424
|
+
peekHeight: t?.peekHeight,
|
|
425
|
+
onStateChange: (i, l) => r.current?.(i, l)
|
|
426
|
+
});
|
|
214
427
|
}, [
|
|
215
|
-
|
|
216
|
-
|
|
428
|
+
o,
|
|
429
|
+
t?.breakpoint,
|
|
430
|
+
t?.initialState,
|
|
431
|
+
t?.bottomOffset,
|
|
432
|
+
t?.peekHeight
|
|
433
|
+
]), s = ge(R((i) => n?.subscribe(i) ?? (() => {
|
|
434
|
+
}), [n]), R(() => n?.getSnapshot() ?? ce, [n]), R(() => n?.getServerSnapshot() ?? ce, [n]));
|
|
435
|
+
return {
|
|
436
|
+
sheet: H(() => ({
|
|
437
|
+
...s,
|
|
438
|
+
surface: {
|
|
439
|
+
...s.surface,
|
|
440
|
+
attrs: Qe(s.surface.attrs)
|
|
441
|
+
}
|
|
442
|
+
}), [s]),
|
|
443
|
+
expand: R((i) => n?.expand(i), [n]),
|
|
444
|
+
collapse: R((i) => n?.collapse(i), [n]),
|
|
445
|
+
toggle: R((i) => n?.toggle(i), [n])
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
var tt = /(`[^`\n]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|_[^_\n]+_)/g;
|
|
449
|
+
function ye(e) {
|
|
450
|
+
const o = e.split(tt);
|
|
451
|
+
return o.length === 1 ? e : o.map((t, r) => r % 2 === 0 || !t ? t : t.startsWith("`") ? /* @__PURE__ */ a("code", {
|
|
452
|
+
style: {
|
|
453
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
454
|
+
fontSize: "0.92em",
|
|
455
|
+
padding: "0 3px",
|
|
456
|
+
borderRadius: "3px",
|
|
457
|
+
backgroundColor: "rgba(0, 0, 0, 0.06)"
|
|
458
|
+
},
|
|
459
|
+
children: t.slice(1, -1)
|
|
460
|
+
}, r) : t.startsWith("**") ? /* @__PURE__ */ a("strong", {
|
|
461
|
+
style: { fontWeight: 600 },
|
|
462
|
+
children: t.slice(2, -2)
|
|
463
|
+
}, r) : /* @__PURE__ */ a("em", { children: t.slice(1, -1) }, r));
|
|
464
|
+
}
|
|
465
|
+
var nt = `
|
|
466
|
+
@keyframes ago-activity-enter {
|
|
467
|
+
from { opacity: 0; transform: translateY(4px); }
|
|
468
|
+
to { opacity: 1; transform: none; }
|
|
469
|
+
}
|
|
470
|
+
@keyframes ago-activity-sweep {
|
|
471
|
+
from { background-position: 200% 0; }
|
|
472
|
+
to { background-position: -200% 0; }
|
|
473
|
+
}
|
|
474
|
+
.ago-activity__label {
|
|
475
|
+
animation: ago-activity-enter 260ms ease-out both;
|
|
476
|
+
}
|
|
477
|
+
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
|
|
478
|
+
.ago-activity__label {
|
|
479
|
+
background-image: linear-gradient(
|
|
480
|
+
90deg,
|
|
481
|
+
var(--ago-activity-color, #5b5d5f) 0%,
|
|
482
|
+
var(--ago-activity-color, #5b5d5f) 35%,
|
|
483
|
+
var(--ago-activity-sheen, #adb1b5) 50%,
|
|
484
|
+
var(--ago-activity-color, #5b5d5f) 65%,
|
|
485
|
+
var(--ago-activity-color, #5b5d5f) 100%
|
|
486
|
+
);
|
|
487
|
+
background-size: 200% 100%;
|
|
488
|
+
-webkit-background-clip: text;
|
|
489
|
+
background-clip: text;
|
|
490
|
+
color: transparent;
|
|
491
|
+
animation:
|
|
492
|
+
ago-activity-enter 260ms ease-out both,
|
|
493
|
+
ago-activity-sweep 2.4s linear infinite;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
@media (prefers-reduced-motion: reduce) {
|
|
497
|
+
.ago-activity__label {
|
|
498
|
+
animation: none;
|
|
499
|
+
color: var(--ago-activity-color, #5b5d5f);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
`, ot = ({ label: e }) => /* @__PURE__ */ T("div", {
|
|
503
|
+
className: "ago-activity",
|
|
504
|
+
role: "status",
|
|
505
|
+
"aria-live": "polite",
|
|
506
|
+
style: {
|
|
507
|
+
display: "block",
|
|
508
|
+
margin: "4px 0 0",
|
|
509
|
+
padding: "6px 12px",
|
|
510
|
+
borderRadius: "999px",
|
|
511
|
+
width: "fit-content",
|
|
512
|
+
maxWidth: "100%",
|
|
513
|
+
fontSize: "13px",
|
|
514
|
+
lineHeight: 1.5,
|
|
515
|
+
color: "var(--ago-activity-color, #5b5d5f)",
|
|
516
|
+
backgroundColor: "var(--ago-activity-bg, #f1f2f3)",
|
|
517
|
+
overflow: "hidden",
|
|
518
|
+
textOverflow: "ellipsis",
|
|
519
|
+
whiteSpace: "nowrap"
|
|
520
|
+
},
|
|
521
|
+
children: [/* @__PURE__ */ a("span", {
|
|
522
|
+
className: "ago-activity__label",
|
|
523
|
+
children: ye(e)
|
|
524
|
+
}, e), /* @__PURE__ */ a("style", { children: nt })]
|
|
525
|
+
}), rt = ({ onSend: e, onStop: o, disabled: t = !1, placeholder: r = "Type a message...", allowFiles: n = !1, className: s = "" }) => {
|
|
526
|
+
const [i, l] = z(""), [c, p] = z([]), f = W(null), k = W(null), _ = R(() => {
|
|
527
|
+
const d = k.current;
|
|
528
|
+
if (!d) return;
|
|
529
|
+
const y = 110;
|
|
530
|
+
d.style.height = "auto", d.style.height = `${Math.min(d.scrollHeight + 2, y)}px`, d.style.overflowY = d.scrollHeight + 2 > y ? "auto" : "hidden";
|
|
531
|
+
}, []), C = R(async (d) => {
|
|
532
|
+
if (d.preventDefault(), !i.trim() && c.length === 0) return;
|
|
533
|
+
const y = i.trim(), m = c.length > 0 ? c : void 0;
|
|
534
|
+
l(""), p([]), requestAnimationFrame(_), await e(y, m) === !1 && (l((g) => g.trim() ? g : y), m && p((g) => [...m, ...g]), requestAnimationFrame(_));
|
|
535
|
+
}, [
|
|
536
|
+
i,
|
|
537
|
+
c,
|
|
217
538
|
e,
|
|
218
|
-
|
|
219
|
-
]),
|
|
220
|
-
|
|
221
|
-
}, [
|
|
222
|
-
const
|
|
223
|
-
p((
|
|
224
|
-
}, []),
|
|
225
|
-
p((
|
|
226
|
-
}, []),
|
|
227
|
-
return /* @__PURE__ */
|
|
228
|
-
onSubmit:
|
|
229
|
-
|
|
539
|
+
_
|
|
540
|
+
]), I = R((d) => {
|
|
541
|
+
d.key === "Enter" && !d.shiftKey && (d.preventDefault(), C(d));
|
|
542
|
+
}, [C]), u = R((d) => {
|
|
543
|
+
const y = Array.from(d.target.files || []);
|
|
544
|
+
p((m) => [...m, ...y]);
|
|
545
|
+
}, []), A = R((d) => {
|
|
546
|
+
p((y) => y.filter((m, g) => g !== d));
|
|
547
|
+
}, []), b = i.trim() || c.length > 0;
|
|
548
|
+
return /* @__PURE__ */ T("form", {
|
|
549
|
+
onSubmit: (d) => {
|
|
550
|
+
C(d);
|
|
551
|
+
},
|
|
552
|
+
className: `ago-chat-input ${s}`,
|
|
230
553
|
style: {
|
|
231
554
|
display: "flex",
|
|
232
555
|
flexDirection: "column",
|
|
@@ -235,14 +558,14 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
235
558
|
borderTop: "1px solid #dee3e8",
|
|
236
559
|
backgroundColor: "#fff"
|
|
237
560
|
},
|
|
238
|
-
children: [
|
|
561
|
+
children: [c.length > 0 && /* @__PURE__ */ a("div", {
|
|
239
562
|
className: "ago-chat-input__files",
|
|
240
563
|
style: {
|
|
241
564
|
display: "flex",
|
|
242
565
|
flexWrap: "wrap",
|
|
243
566
|
gap: "6px"
|
|
244
567
|
},
|
|
245
|
-
children:
|
|
568
|
+
children: c.map((d, y) => /* @__PURE__ */ T("div", {
|
|
246
569
|
style: {
|
|
247
570
|
display: "flex",
|
|
248
571
|
alignItems: "center",
|
|
@@ -253,19 +576,26 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
253
576
|
fontSize: "12px",
|
|
254
577
|
color: "#30373e"
|
|
255
578
|
},
|
|
256
|
-
children: [/* @__PURE__ */
|
|
579
|
+
children: [/* @__PURE__ */ a("span", {
|
|
257
580
|
style: {
|
|
258
581
|
maxWidth: "120px",
|
|
259
582
|
overflow: "hidden",
|
|
260
583
|
textOverflow: "ellipsis",
|
|
261
584
|
whiteSpace: "nowrap"
|
|
262
585
|
},
|
|
263
|
-
children:
|
|
264
|
-
}), /* @__PURE__ */
|
|
586
|
+
children: d.name
|
|
587
|
+
}), /* @__PURE__ */ a("button", {
|
|
265
588
|
type: "button",
|
|
266
|
-
onClick: () =>
|
|
267
|
-
"aria-label": `Remove ${
|
|
589
|
+
onClick: () => A(y),
|
|
590
|
+
"aria-label": `Remove ${d.name}`,
|
|
268
591
|
style: {
|
|
592
|
+
flexShrink: 0,
|
|
593
|
+
width: "44px",
|
|
594
|
+
height: "44px",
|
|
595
|
+
margin: "-14px -12px -14px -4px",
|
|
596
|
+
display: "flex",
|
|
597
|
+
alignItems: "center",
|
|
598
|
+
justifyContent: "center",
|
|
269
599
|
border: "none",
|
|
270
600
|
background: "none",
|
|
271
601
|
cursor: "pointer",
|
|
@@ -276,47 +606,54 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
276
606
|
},
|
|
277
607
|
children: "×"
|
|
278
608
|
})]
|
|
279
|
-
},
|
|
280
|
-
}), /* @__PURE__ */
|
|
609
|
+
}, y))
|
|
610
|
+
}), /* @__PURE__ */ T("div", {
|
|
281
611
|
style: {
|
|
282
612
|
display: "flex",
|
|
283
613
|
gap: "8px",
|
|
284
614
|
alignItems: "flex-end"
|
|
285
615
|
},
|
|
286
616
|
children: [
|
|
287
|
-
|
|
617
|
+
n && /* @__PURE__ */ T(me, { children: [/* @__PURE__ */ a("button", {
|
|
288
618
|
type: "button",
|
|
289
|
-
onClick: () =>
|
|
290
|
-
disabled:
|
|
619
|
+
onClick: () => f.current?.click(),
|
|
620
|
+
disabled: t,
|
|
291
621
|
"aria-label": "Attach file",
|
|
292
622
|
style: {
|
|
623
|
+
flexShrink: 0,
|
|
624
|
+
minWidth: "44px",
|
|
625
|
+
minHeight: "44px",
|
|
626
|
+
display: "flex",
|
|
627
|
+
alignItems: "center",
|
|
628
|
+
justifyContent: "center",
|
|
293
629
|
padding: "8px",
|
|
294
630
|
border: "1px solid #dee3e8",
|
|
295
631
|
borderRadius: "8px",
|
|
296
632
|
backgroundColor: "#fff",
|
|
297
|
-
cursor:
|
|
633
|
+
cursor: t ? "not-allowed" : "pointer",
|
|
298
634
|
color: "#6b6d6f",
|
|
299
635
|
fontSize: "16px",
|
|
300
636
|
lineHeight: 1
|
|
301
637
|
},
|
|
302
638
|
children: "+"
|
|
303
|
-
}), /* @__PURE__ */
|
|
304
|
-
ref:
|
|
639
|
+
}), /* @__PURE__ */ a("input", {
|
|
640
|
+
ref: f,
|
|
305
641
|
type: "file",
|
|
306
642
|
multiple: !0,
|
|
307
|
-
onChange:
|
|
643
|
+
onChange: u,
|
|
308
644
|
style: { display: "none" }
|
|
309
645
|
})] }),
|
|
310
|
-
/* @__PURE__ */
|
|
311
|
-
ref:
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
646
|
+
/* @__PURE__ */ a("textarea", {
|
|
647
|
+
ref: k,
|
|
648
|
+
className: "ago-chat-input__field",
|
|
649
|
+
value: i,
|
|
650
|
+
onChange: (d) => {
|
|
651
|
+
l(d.target.value), _();
|
|
315
652
|
},
|
|
316
|
-
onKeyDown:
|
|
317
|
-
placeholder:
|
|
318
|
-
"aria-label":
|
|
319
|
-
disabled:
|
|
653
|
+
onKeyDown: I,
|
|
654
|
+
placeholder: r,
|
|
655
|
+
"aria-label": r,
|
|
656
|
+
disabled: t,
|
|
320
657
|
rows: 1,
|
|
321
658
|
style: {
|
|
322
659
|
flex: 1,
|
|
@@ -335,23 +672,41 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
335
672
|
backgroundColor: "#f8f8f8",
|
|
336
673
|
transition: "border-color 0.15s"
|
|
337
674
|
},
|
|
338
|
-
onFocus: (
|
|
339
|
-
|
|
675
|
+
onFocus: (d) => {
|
|
676
|
+
d.currentTarget.style.borderColor = "#1b5fc4";
|
|
340
677
|
},
|
|
341
|
-
onBlur: (
|
|
342
|
-
|
|
678
|
+
onBlur: (d) => {
|
|
679
|
+
d.currentTarget.style.borderColor = "#dee3e8";
|
|
343
680
|
}
|
|
344
681
|
}),
|
|
345
|
-
/* @__PURE__ */
|
|
682
|
+
t && o ? /* @__PURE__ */ a("button", {
|
|
683
|
+
type: "button",
|
|
684
|
+
onClick: o,
|
|
685
|
+
"aria-label": "Stop generating",
|
|
686
|
+
style: {
|
|
687
|
+
minHeight: "44px",
|
|
688
|
+
padding: "10px 18px",
|
|
689
|
+
border: "none",
|
|
690
|
+
borderRadius: "20px",
|
|
691
|
+
backgroundColor: "#03182f",
|
|
692
|
+
color: "#fff",
|
|
693
|
+
cursor: "pointer",
|
|
694
|
+
fontWeight: 500,
|
|
695
|
+
fontSize: "16px",
|
|
696
|
+
transition: "background-color 0.15s"
|
|
697
|
+
},
|
|
698
|
+
children: "Stop"
|
|
699
|
+
}) : /* @__PURE__ */ a("button", {
|
|
346
700
|
type: "submit",
|
|
347
|
-
disabled:
|
|
701
|
+
disabled: t || !b,
|
|
348
702
|
style: {
|
|
703
|
+
minHeight: "44px",
|
|
349
704
|
padding: "10px 18px",
|
|
350
705
|
border: "none",
|
|
351
706
|
borderRadius: "20px",
|
|
352
|
-
backgroundColor:
|
|
707
|
+
backgroundColor: t || !b ? "#b5bfc8" : "#03182f",
|
|
353
708
|
color: "#fff",
|
|
354
|
-
cursor:
|
|
709
|
+
cursor: t || !b ? "not-allowed" : "pointer",
|
|
355
710
|
fontWeight: 500,
|
|
356
711
|
fontSize: "16px",
|
|
357
712
|
transition: "background-color 0.15s"
|
|
@@ -361,7 +716,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
361
716
|
]
|
|
362
717
|
})]
|
|
363
718
|
});
|
|
364
|
-
},
|
|
719
|
+
}, at = ({ href: e, children: o, ...t }) => /* @__PURE__ */ a("a", {
|
|
365
720
|
href: e,
|
|
366
721
|
target: "_blank",
|
|
367
722
|
rel: "noopener noreferrer",
|
|
@@ -370,53 +725,53 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
370
725
|
textDecoration: "underline"
|
|
371
726
|
},
|
|
372
727
|
...t,
|
|
373
|
-
children:
|
|
374
|
-
}),
|
|
728
|
+
children: o
|
|
729
|
+
}), it = ({ children: e, ...o }) => /* @__PURE__ */ a("p", {
|
|
375
730
|
style: {
|
|
376
731
|
margin: "0 0 8px 0",
|
|
377
732
|
lineHeight: "1.6"
|
|
378
733
|
},
|
|
379
|
-
...
|
|
734
|
+
...o,
|
|
380
735
|
children: e
|
|
381
|
-
}),
|
|
382
|
-
const t = ({ children:
|
|
736
|
+
}), j = (e, o) => {
|
|
737
|
+
const t = ({ children: r, ...n }) => Be.createElement(`h${e}`, {
|
|
383
738
|
style: {
|
|
384
739
|
margin: "16px 0 8px 0",
|
|
385
|
-
fontSize:
|
|
740
|
+
fontSize: o,
|
|
386
741
|
fontWeight: 600,
|
|
387
742
|
lineHeight: "1.3"
|
|
388
743
|
},
|
|
389
744
|
...n
|
|
390
|
-
},
|
|
745
|
+
}, r);
|
|
391
746
|
return t.displayName = `MarkdownHeading${e}`, t;
|
|
392
|
-
},
|
|
747
|
+
}, st = ({ children: e, ...o }) => /* @__PURE__ */ a("ul", {
|
|
393
748
|
style: {
|
|
394
749
|
margin: "0 0 8px 0",
|
|
395
750
|
paddingLeft: "20px",
|
|
396
751
|
listStyleType: "disc",
|
|
397
752
|
listStylePosition: "outside"
|
|
398
753
|
},
|
|
399
|
-
...
|
|
754
|
+
...o,
|
|
400
755
|
children: e
|
|
401
|
-
}),
|
|
756
|
+
}), lt = ({ children: e, ...o }) => /* @__PURE__ */ a("ol", {
|
|
402
757
|
style: {
|
|
403
758
|
margin: "0 0 8px 0",
|
|
404
759
|
paddingLeft: "20px",
|
|
405
760
|
listStyleType: "decimal",
|
|
406
761
|
listStylePosition: "outside"
|
|
407
762
|
},
|
|
408
|
-
...
|
|
763
|
+
...o,
|
|
409
764
|
children: e
|
|
410
|
-
}),
|
|
765
|
+
}), ct = ({ children: e, ...o }) => /* @__PURE__ */ a("li", {
|
|
411
766
|
style: {
|
|
412
767
|
display: "list-item",
|
|
413
768
|
margin: "2px 0",
|
|
414
769
|
lineHeight: "1.6"
|
|
415
770
|
},
|
|
416
|
-
...
|
|
771
|
+
...o,
|
|
417
772
|
children: e
|
|
418
|
-
}),
|
|
419
|
-
`) ? /* @__PURE__ */
|
|
773
|
+
}), dt = ({ className: e, children: o, ...t }) => e !== void 0 || String(o).includes(`
|
|
774
|
+
`) ? /* @__PURE__ */ a("code", {
|
|
420
775
|
style: {
|
|
421
776
|
display: "block",
|
|
422
777
|
background: "#f5f5f5",
|
|
@@ -427,8 +782,8 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
427
782
|
fontFamily: '"IBM Plex Mono", monospace'
|
|
428
783
|
},
|
|
429
784
|
...t,
|
|
430
|
-
children:
|
|
431
|
-
}) : /* @__PURE__ */
|
|
785
|
+
children: o
|
|
786
|
+
}) : /* @__PURE__ */ a("code", {
|
|
432
787
|
style: {
|
|
433
788
|
background: "#f0f2f5",
|
|
434
789
|
padding: "2px 5px",
|
|
@@ -437,12 +792,12 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
437
792
|
fontFamily: '"IBM Plex Mono", monospace'
|
|
438
793
|
},
|
|
439
794
|
...t,
|
|
440
|
-
children:
|
|
441
|
-
}),
|
|
795
|
+
children: o
|
|
796
|
+
}), ut = ({ children: e, ...o }) => /* @__PURE__ */ a("pre", {
|
|
442
797
|
style: { margin: "0 0 8px 0" },
|
|
443
|
-
...
|
|
798
|
+
...o,
|
|
444
799
|
children: e
|
|
445
|
-
}),
|
|
800
|
+
}), pt = ({ children: e, ...o }) => /* @__PURE__ */ a("blockquote", {
|
|
446
801
|
style: {
|
|
447
802
|
borderLeft: "4px solid #dee3e8",
|
|
448
803
|
paddingLeft: "12px",
|
|
@@ -450,23 +805,23 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
450
805
|
fontStyle: "italic",
|
|
451
806
|
color: "#6b6d6f"
|
|
452
807
|
},
|
|
453
|
-
...
|
|
808
|
+
...o,
|
|
454
809
|
children: e
|
|
455
|
-
}),
|
|
810
|
+
}), ft = ({ children: e, ...o }) => /* @__PURE__ */ a("div", {
|
|
456
811
|
style: {
|
|
457
812
|
overflowX: "auto",
|
|
458
813
|
margin: "0 0 8px 0"
|
|
459
814
|
},
|
|
460
|
-
children: /* @__PURE__ */
|
|
815
|
+
children: /* @__PURE__ */ a("table", {
|
|
461
816
|
style: {
|
|
462
817
|
borderCollapse: "collapse",
|
|
463
818
|
width: "100%",
|
|
464
819
|
fontSize: "13px"
|
|
465
820
|
},
|
|
466
|
-
...
|
|
821
|
+
...o,
|
|
467
822
|
children: e
|
|
468
823
|
})
|
|
469
|
-
}),
|
|
824
|
+
}), gt = ({ children: e, ...o }) => /* @__PURE__ */ a("th", {
|
|
470
825
|
style: {
|
|
471
826
|
border: "1px solid #dee3e8",
|
|
472
827
|
padding: "6px 10px",
|
|
@@ -474,57 +829,57 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
474
829
|
backgroundColor: "#f5f7fa",
|
|
475
830
|
fontWeight: 600
|
|
476
831
|
},
|
|
477
|
-
...
|
|
832
|
+
...o,
|
|
478
833
|
children: e
|
|
479
|
-
}),
|
|
834
|
+
}), mt = ({ children: e, ...o }) => /* @__PURE__ */ a("td", {
|
|
480
835
|
style: {
|
|
481
836
|
border: "1px solid #dee3e8",
|
|
482
837
|
padding: "6px 10px"
|
|
483
838
|
},
|
|
484
|
-
...
|
|
839
|
+
...o,
|
|
485
840
|
children: e
|
|
486
|
-
}),
|
|
841
|
+
}), ht = ({ alt: e, ...o }) => /* @__PURE__ */ a("img", {
|
|
487
842
|
alt: e ?? "",
|
|
488
843
|
style: {
|
|
489
844
|
maxWidth: "100%",
|
|
490
845
|
borderRadius: "8px",
|
|
491
846
|
margin: "4px 0"
|
|
492
847
|
},
|
|
493
|
-
...
|
|
494
|
-
}),
|
|
848
|
+
...o
|
|
849
|
+
}), xt = (e) => /* @__PURE__ */ a("hr", {
|
|
495
850
|
style: {
|
|
496
851
|
border: "none",
|
|
497
852
|
borderTop: "1px solid #dee3e8",
|
|
498
853
|
margin: "12px 0"
|
|
499
854
|
},
|
|
500
855
|
...e
|
|
501
|
-
}),
|
|
502
|
-
a:
|
|
503
|
-
p:
|
|
504
|
-
h1:
|
|
505
|
-
h2:
|
|
506
|
-
h3:
|
|
507
|
-
h4:
|
|
508
|
-
h5:
|
|
509
|
-
h6:
|
|
510
|
-
ul:
|
|
511
|
-
ol:
|
|
512
|
-
li:
|
|
513
|
-
code:
|
|
514
|
-
pre:
|
|
515
|
-
blockquote:
|
|
516
|
-
table:
|
|
517
|
-
th:
|
|
518
|
-
td:
|
|
519
|
-
img:
|
|
520
|
-
hr:
|
|
521
|
-
},
|
|
522
|
-
remarkPlugins:
|
|
523
|
-
components:
|
|
856
|
+
}), yt = {
|
|
857
|
+
a: at,
|
|
858
|
+
p: it,
|
|
859
|
+
h1: j(1, "20px"),
|
|
860
|
+
h2: j(2, "18px"),
|
|
861
|
+
h3: j(3, "16px"),
|
|
862
|
+
h4: j(4, "15px"),
|
|
863
|
+
h5: j(5, "14px"),
|
|
864
|
+
h6: j(6, "13px"),
|
|
865
|
+
ul: st,
|
|
866
|
+
ol: lt,
|
|
867
|
+
li: ct,
|
|
868
|
+
code: dt,
|
|
869
|
+
pre: ut,
|
|
870
|
+
blockquote: pt,
|
|
871
|
+
table: ft,
|
|
872
|
+
th: gt,
|
|
873
|
+
td: mt,
|
|
874
|
+
img: ht,
|
|
875
|
+
hr: xt
|
|
876
|
+
}, vt = [Ue], bt = ({ content: e }) => /* @__PURE__ */ a(Ke, {
|
|
877
|
+
remarkPlugins: vt,
|
|
878
|
+
components: yt,
|
|
524
879
|
children: e
|
|
525
|
-
}),
|
|
526
|
-
const t =
|
|
527
|
-
if (
|
|
880
|
+
}), wt = ({ attachment: e, isUser: o }) => {
|
|
881
|
+
const t = We(e.url);
|
|
882
|
+
if (Ee(e)) return /* @__PURE__ */ a("a", {
|
|
528
883
|
href: t,
|
|
529
884
|
target: "_blank",
|
|
530
885
|
rel: "noopener noreferrer",
|
|
@@ -532,7 +887,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
532
887
|
display: "inline-block",
|
|
533
888
|
textDecoration: "none"
|
|
534
889
|
},
|
|
535
|
-
children: /* @__PURE__ */
|
|
890
|
+
children: /* @__PURE__ */ a("img", {
|
|
536
891
|
src: t,
|
|
537
892
|
alt: e.name,
|
|
538
893
|
loading: "lazy",
|
|
@@ -546,7 +901,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
546
901
|
}
|
|
547
902
|
})
|
|
548
903
|
});
|
|
549
|
-
const
|
|
904
|
+
const r = Fe(e.fileSize), n = /* @__PURE__ */ T(me, { children: [/* @__PURE__ */ a("span", {
|
|
550
905
|
style: {
|
|
551
906
|
fontSize: "16px",
|
|
552
907
|
lineHeight: 1,
|
|
@@ -554,13 +909,13 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
554
909
|
},
|
|
555
910
|
"aria-hidden": !0,
|
|
556
911
|
children: "📄"
|
|
557
|
-
}), /* @__PURE__ */
|
|
912
|
+
}), /* @__PURE__ */ T("span", {
|
|
558
913
|
style: {
|
|
559
914
|
display: "flex",
|
|
560
915
|
flexDirection: "column",
|
|
561
916
|
minWidth: 0
|
|
562
917
|
},
|
|
563
|
-
children: [/* @__PURE__ */
|
|
918
|
+
children: [/* @__PURE__ */ a("span", {
|
|
564
919
|
style: {
|
|
565
920
|
overflow: "hidden",
|
|
566
921
|
textOverflow: "ellipsis",
|
|
@@ -569,12 +924,12 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
569
924
|
},
|
|
570
925
|
title: e.name,
|
|
571
926
|
children: e.name
|
|
572
|
-
}),
|
|
927
|
+
}), r && /* @__PURE__ */ a("span", {
|
|
573
928
|
style: {
|
|
574
929
|
fontSize: "11px",
|
|
575
930
|
color: "#6b6d6f"
|
|
576
931
|
},
|
|
577
|
-
children:
|
|
932
|
+
children: r
|
|
578
933
|
})]
|
|
579
934
|
})] }), s = {
|
|
580
935
|
display: "inline-flex",
|
|
@@ -583,24 +938,24 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
583
938
|
padding: "8px 12px",
|
|
584
939
|
borderRadius: "10px",
|
|
585
940
|
border: "1px solid #dee3e8",
|
|
586
|
-
backgroundColor:
|
|
587
|
-
color:
|
|
941
|
+
backgroundColor: o ? "rgba(255,255,255,0.12)" : "#fff",
|
|
942
|
+
color: o ? "#fff" : "#30373e",
|
|
588
943
|
fontSize: "13px",
|
|
589
944
|
textDecoration: "none",
|
|
590
945
|
maxWidth: "220px"
|
|
591
946
|
};
|
|
592
|
-
return t ? /* @__PURE__ */
|
|
947
|
+
return t ? /* @__PURE__ */ a("a", {
|
|
593
948
|
href: t,
|
|
594
949
|
target: "_blank",
|
|
595
950
|
rel: "noopener noreferrer",
|
|
596
951
|
style: s,
|
|
597
952
|
children: n
|
|
598
|
-
}) : /* @__PURE__ */
|
|
953
|
+
}) : /* @__PURE__ */ a("div", {
|
|
599
954
|
style: s,
|
|
600
955
|
children: n
|
|
601
956
|
});
|
|
602
|
-
},
|
|
603
|
-
const t = /* @__PURE__ */
|
|
957
|
+
}, Ct = ({ source: e, index: o }) => {
|
|
958
|
+
const t = /* @__PURE__ */ T("div", {
|
|
604
959
|
style: {
|
|
605
960
|
display: "flex",
|
|
606
961
|
alignItems: "center",
|
|
@@ -608,7 +963,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
608
963
|
width: "100%",
|
|
609
964
|
minWidth: 0
|
|
610
965
|
},
|
|
611
|
-
children: [/* @__PURE__ */
|
|
966
|
+
children: [/* @__PURE__ */ a("div", {
|
|
612
967
|
style: {
|
|
613
968
|
flexShrink: 0,
|
|
614
969
|
width: "18px",
|
|
@@ -623,8 +978,8 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
623
978
|
justifyContent: "center",
|
|
624
979
|
backgroundColor: "#f0f4ff"
|
|
625
980
|
},
|
|
626
|
-
children:
|
|
627
|
-
}), /* @__PURE__ */
|
|
981
|
+
children: o + 1
|
|
982
|
+
}), /* @__PURE__ */ a("div", {
|
|
628
983
|
style: {
|
|
629
984
|
fontSize: "12px",
|
|
630
985
|
overflow: "hidden",
|
|
@@ -635,7 +990,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
635
990
|
title: e.title,
|
|
636
991
|
children: e.title
|
|
637
992
|
})]
|
|
638
|
-
}),
|
|
993
|
+
}), r = {
|
|
639
994
|
display: "flex",
|
|
640
995
|
alignItems: "center",
|
|
641
996
|
padding: "8px 10px",
|
|
@@ -648,11 +1003,11 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
648
1003
|
minWidth: 0,
|
|
649
1004
|
transition: "border-color 0.15s"
|
|
650
1005
|
};
|
|
651
|
-
return e.url ? /* @__PURE__ */
|
|
1006
|
+
return e.url ? /* @__PURE__ */ a("a", {
|
|
652
1007
|
href: e.url,
|
|
653
1008
|
target: "_blank",
|
|
654
1009
|
rel: "noopener noreferrer",
|
|
655
|
-
style:
|
|
1010
|
+
style: r,
|
|
656
1011
|
onMouseEnter: (n) => {
|
|
657
1012
|
n.currentTarget.style.borderColor = "#1b5fc4";
|
|
658
1013
|
},
|
|
@@ -660,11 +1015,11 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
660
1015
|
n.currentTarget.style.borderColor = "#dee3e8";
|
|
661
1016
|
},
|
|
662
1017
|
children: t
|
|
663
|
-
}) : /* @__PURE__ */
|
|
664
|
-
style:
|
|
1018
|
+
}) : /* @__PURE__ */ a("div", {
|
|
1019
|
+
style: r,
|
|
665
1020
|
children: t
|
|
666
1021
|
});
|
|
667
|
-
},
|
|
1022
|
+
}, ve = () => /* @__PURE__ */ T("div", {
|
|
668
1023
|
style: {
|
|
669
1024
|
display: "flex",
|
|
670
1025
|
gap: "4px",
|
|
@@ -674,31 +1029,32 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
674
1029
|
0,
|
|
675
1030
|
1,
|
|
676
1031
|
2
|
|
677
|
-
].map((e) => /* @__PURE__ */
|
|
1032
|
+
].map((e) => /* @__PURE__ */ a("div", { style: {
|
|
678
1033
|
width: "6px",
|
|
679
1034
|
height: "6px",
|
|
680
1035
|
borderRadius: "50%",
|
|
681
|
-
backgroundColor: "
|
|
1036
|
+
backgroundColor: "currentColor",
|
|
1037
|
+
opacity: 0.55,
|
|
682
1038
|
animation: "ago-pulse 1.2s ease-in-out infinite",
|
|
683
1039
|
animationDelay: `${e * 0.2}s`
|
|
684
|
-
} }, e)), /* @__PURE__ */
|
|
1040
|
+
} }, e)), /* @__PURE__ */ a("style", { children: `
|
|
685
1041
|
@keyframes ago-pulse {
|
|
686
1042
|
0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
|
|
687
1043
|
40% { opacity: 1; transform: scale(1); }
|
|
688
1044
|
}
|
|
689
1045
|
` })]
|
|
690
|
-
}),
|
|
691
|
-
const
|
|
692
|
-
return /* @__PURE__ */
|
|
693
|
-
className: `ago-message ago-message--${e.role} ${
|
|
1046
|
+
}), kt = ({ message: e, className: o = "", showAgentName: t = !1, isLast: r = !1, onFollowUpClick: n, showStreamingDots: s = !0 }) => {
|
|
1047
|
+
const i = e.role === "user", l = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
|
|
1048
|
+
return /* @__PURE__ */ T("div", {
|
|
1049
|
+
className: `ago-message ago-message--${e.role} ${o}`,
|
|
694
1050
|
style: {
|
|
695
1051
|
display: "flex",
|
|
696
1052
|
flexDirection: "column",
|
|
697
|
-
alignItems:
|
|
1053
|
+
alignItems: i ? "flex-end" : "flex-start",
|
|
698
1054
|
marginBottom: "16px"
|
|
699
1055
|
},
|
|
700
1056
|
children: [
|
|
701
|
-
!
|
|
1057
|
+
!i && t && e.agent && /* @__PURE__ */ a("div", {
|
|
702
1058
|
className: "ago-message__agent",
|
|
703
1059
|
style: {
|
|
704
1060
|
display: "flex",
|
|
@@ -712,7 +1068,7 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
712
1068
|
},
|
|
713
1069
|
children: e.agent.displayName || e.agent.name
|
|
714
1070
|
}),
|
|
715
|
-
!
|
|
1071
|
+
!i && e.sources && e.sources.length > 0 && /* @__PURE__ */ a("div", {
|
|
716
1072
|
className: "ago-message__sources",
|
|
717
1073
|
style: {
|
|
718
1074
|
display: "grid",
|
|
@@ -722,41 +1078,41 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
722
1078
|
width: "100%",
|
|
723
1079
|
maxWidth: "85%"
|
|
724
1080
|
},
|
|
725
|
-
children: e.sources.map((
|
|
726
|
-
source:
|
|
1081
|
+
children: e.sources.map((c, p) => /* @__PURE__ */ a(Ct, {
|
|
1082
|
+
source: c,
|
|
727
1083
|
index: p
|
|
728
|
-
},
|
|
1084
|
+
}, c.id))
|
|
729
1085
|
}),
|
|
730
|
-
e.attachments && e.attachments.length > 0 && /* @__PURE__ */
|
|
1086
|
+
e.attachments && e.attachments.length > 0 && /* @__PURE__ */ a("div", {
|
|
731
1087
|
className: "ago-message__attachments",
|
|
732
1088
|
style: {
|
|
733
1089
|
display: "flex",
|
|
734
1090
|
flexWrap: "wrap",
|
|
735
1091
|
gap: "6px",
|
|
736
1092
|
marginBottom: "6px",
|
|
737
|
-
justifyContent:
|
|
1093
|
+
justifyContent: i ? "flex-end" : "flex-start",
|
|
738
1094
|
maxWidth: "75%"
|
|
739
1095
|
},
|
|
740
|
-
children: e.attachments.map((
|
|
741
|
-
attachment:
|
|
742
|
-
isUser:
|
|
743
|
-
},
|
|
1096
|
+
children: e.attachments.map((c) => /* @__PURE__ */ a(wt, {
|
|
1097
|
+
attachment: c,
|
|
1098
|
+
isUser: i
|
|
1099
|
+
}, c.id))
|
|
744
1100
|
}),
|
|
745
|
-
(e.content ||
|
|
1101
|
+
(e.content || l && s) && /* @__PURE__ */ a("div", {
|
|
746
1102
|
className: "ago-message__content",
|
|
747
1103
|
style: {
|
|
748
|
-
maxWidth:
|
|
749
|
-
padding:
|
|
750
|
-
borderRadius:
|
|
751
|
-
backgroundColor:
|
|
752
|
-
color:
|
|
1104
|
+
maxWidth: i ? "75%" : "100%",
|
|
1105
|
+
padding: i ? "10px 14px" : "2px 8px",
|
|
1106
|
+
borderRadius: i ? "16px" : "0",
|
|
1107
|
+
backgroundColor: i ? "#03182f" : "transparent",
|
|
1108
|
+
color: i ? "#fff" : "#30373e",
|
|
753
1109
|
wordBreak: "break-word",
|
|
754
1110
|
fontSize: "16px",
|
|
755
1111
|
lineHeight: "1.6"
|
|
756
1112
|
},
|
|
757
|
-
children: e.content ? /* @__PURE__ */
|
|
1113
|
+
children: e.content ? /* @__PURE__ */ a(bt, { content: e.content }) : l && s && /* @__PURE__ */ a(ve, {})
|
|
758
1114
|
}),
|
|
759
|
-
|
|
1115
|
+
r && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ a("div", {
|
|
760
1116
|
className: "ago-message__followups",
|
|
761
1117
|
style: {
|
|
762
1118
|
display: "flex",
|
|
@@ -764,13 +1120,13 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
764
1120
|
gap: "8px",
|
|
765
1121
|
marginTop: "10px"
|
|
766
1122
|
},
|
|
767
|
-
children: e.followUpReplies.map((
|
|
1123
|
+
children: e.followUpReplies.map((c, p) => /* @__PURE__ */ a("button", {
|
|
768
1124
|
type: "button",
|
|
769
1125
|
className: "ago-message__followup-btn",
|
|
770
1126
|
disabled: !n,
|
|
771
|
-
onClick: n ? () => n(
|
|
1127
|
+
onClick: n ? () => n(c) : void 0,
|
|
772
1128
|
style: {
|
|
773
|
-
minHeight: "
|
|
1129
|
+
minHeight: "44px",
|
|
774
1130
|
padding: "6px 14px",
|
|
775
1131
|
fontSize: "13px",
|
|
776
1132
|
borderRadius: "16px",
|
|
@@ -780,52 +1136,117 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
780
1136
|
cursor: n ? "pointer" : "default",
|
|
781
1137
|
transition: "border-color 0.15s"
|
|
782
1138
|
},
|
|
783
|
-
onMouseEnter: (
|
|
784
|
-
|
|
1139
|
+
onMouseEnter: (f) => {
|
|
1140
|
+
f.currentTarget.style.borderColor = "#1b5fc4";
|
|
785
1141
|
},
|
|
786
|
-
onMouseLeave: (
|
|
787
|
-
|
|
1142
|
+
onMouseLeave: (f) => {
|
|
1143
|
+
f.currentTarget.style.borderColor = "#dee3e8";
|
|
788
1144
|
},
|
|
789
|
-
children:
|
|
1145
|
+
children: c
|
|
790
1146
|
}, p))
|
|
791
1147
|
})
|
|
792
1148
|
]
|
|
793
1149
|
});
|
|
794
|
-
},
|
|
795
|
-
const
|
|
796
|
-
client:
|
|
797
|
-
conversationId:
|
|
1150
|
+
}, Ht = je(function({ client: o, conversationId: t, title: r = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: s = "Type a message...", allowFiles: i = !1, allowStop: l = !0, height: c = 500, logoUrl: p, showAgentName: f = !1, forms: k, onFollowUpClick: _, className: C = "", onMessageSent: I, onMessageReceived: u, sheet: A = !1, thinkingLabel: b = "Thinking...", functionLabels: d, showReasoning: y = !0 }, m) {
|
|
1151
|
+
const g = W(null), w = W(!0), [S, x] = z(!0), M = W(null), { sheet: v, expand: D, collapse: q, toggle: ee } = et(A), [be, Y] = z(!1), X = v.compact && v.state === "peek", we = O(), K = o ?? we, { messages: P, isLoading: Ce, error: te, sendMessage: ke, stop: Se } = xe({
|
|
1152
|
+
client: o,
|
|
1153
|
+
conversationId: t
|
|
798
1154
|
});
|
|
799
|
-
|
|
800
|
-
if (!
|
|
801
|
-
let
|
|
802
|
-
const
|
|
803
|
-
return Promise.all(
|
|
804
|
-
if (!
|
|
805
|
-
for (const
|
|
1155
|
+
N(() => {
|
|
1156
|
+
if (!K || !k || k.length === 0) return;
|
|
1157
|
+
let h = !1;
|
|
1158
|
+
const F = [];
|
|
1159
|
+
return Promise.all(k.map((E) => E.schema != null ? Promise.resolve(pe(E)) : ue(K, E))).then((E) => {
|
|
1160
|
+
if (!h)
|
|
1161
|
+
for (const L of E) F.push(L.install(K));
|
|
806
1162
|
}).catch(() => {
|
|
807
1163
|
}), () => {
|
|
808
|
-
|
|
1164
|
+
h = !0, F.forEach((E) => E());
|
|
809
1165
|
};
|
|
810
|
-
}, [
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
])) : ""]),
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
1166
|
+
}, [K, k ? JSON.stringify(k.map((h) => [
|
|
1167
|
+
h.name,
|
|
1168
|
+
h.schema ?? null,
|
|
1169
|
+
h.submit ?? !1,
|
|
1170
|
+
h.description ?? null
|
|
1171
|
+
])) : ""]), N(() => {
|
|
1172
|
+
const h = g.current;
|
|
1173
|
+
!h || !w.current || (h.scrollTop = h.scrollHeight);
|
|
1174
|
+
}, [P]);
|
|
1175
|
+
const Ae = () => {
|
|
1176
|
+
const h = g.current;
|
|
1177
|
+
h && (w.current = !0, x(!0), h.scrollTop = h.scrollHeight);
|
|
1178
|
+
};
|
|
1179
|
+
N(() => {
|
|
1180
|
+
const h = P[P.length - 1];
|
|
1181
|
+
h && h.role === "assistant" && h.status === "DONE" && u && u({
|
|
1182
|
+
id: h.id,
|
|
1183
|
+
content: h.content
|
|
822
1184
|
});
|
|
823
|
-
}, [
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
1185
|
+
}, [P, u]), N(() => {
|
|
1186
|
+
Y(!!X);
|
|
1187
|
+
}, [P.length]), N(() => {
|
|
1188
|
+
const h = M.current;
|
|
1189
|
+
if (!v.compact || !h) return;
|
|
1190
|
+
const F = document.documentElement;
|
|
1191
|
+
if (v.state !== "peek") return;
|
|
1192
|
+
const E = () => {
|
|
1193
|
+
F.style.setProperty("--ago-sheet-height", `${Math.round(h.getBoundingClientRect().height)}px`);
|
|
1194
|
+
};
|
|
1195
|
+
E();
|
|
1196
|
+
const L = typeof ResizeObserver == "function" ? new ResizeObserver(E) : null;
|
|
1197
|
+
return L?.observe(h), () => L?.disconnect();
|
|
1198
|
+
}, [v.compact, v.state]), N(() => {
|
|
1199
|
+
v.compact || document.documentElement.style.removeProperty("--ago-sheet-height");
|
|
1200
|
+
}, [v.compact]), N(() => () => {
|
|
1201
|
+
document.documentElement.style.removeProperty("--ago-sheet-height");
|
|
1202
|
+
}, []), qe(m, () => ({
|
|
1203
|
+
expand: D,
|
|
1204
|
+
collapse: q,
|
|
1205
|
+
toggle: ee,
|
|
1206
|
+
state: v.state
|
|
1207
|
+
}), [
|
|
1208
|
+
D,
|
|
1209
|
+
q,
|
|
1210
|
+
ee,
|
|
1211
|
+
v.state
|
|
1212
|
+
]), N(() => {
|
|
1213
|
+
if (!v.isModal) return;
|
|
1214
|
+
const h = /* @__PURE__ */ Symbol("ago-react-sheet");
|
|
1215
|
+
Le(h);
|
|
1216
|
+
const F = (E) => {
|
|
1217
|
+
if (E.key === "Escape") {
|
|
1218
|
+
q("user");
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
1221
|
+
if (E.key !== "Tab") return;
|
|
1222
|
+
const L = M.current;
|
|
1223
|
+
if (!L) return;
|
|
1224
|
+
const J = Array.from(L.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((_e) => _e.getClientRects().length > 0);
|
|
1225
|
+
if (J.length === 0) {
|
|
1226
|
+
E.preventDefault();
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1229
|
+
const ae = J[0], ie = J[J.length - 1], V = document.activeElement;
|
|
1230
|
+
E.shiftKey && (V === ae || !L.contains(V)) ? (E.preventDefault(), ie.focus()) : !E.shiftKey && (V === ie || !L.contains(V)) && (E.preventDefault(), ae.focus());
|
|
1231
|
+
};
|
|
1232
|
+
return document.addEventListener("keydown", F), M.current?.focus({ preventScroll: !0 }), () => {
|
|
1233
|
+
document.removeEventListener("keydown", F), De(h);
|
|
1234
|
+
};
|
|
1235
|
+
}, [v.isModal, q]);
|
|
1236
|
+
const ne = async (h, F) => (w.current = !0, x(!0), I?.(h), await ke(h, F) !== null), B = P[P.length - 1], G = Ce && B?.role === "assistant" && (B.status === "IN_PROGRESS" || B.status === "WAITING_CLIENT"), Ie = R((h) => {
|
|
1237
|
+
const F = h.functionName;
|
|
1238
|
+
if (!(!d || !F))
|
|
1239
|
+
return typeof d == "function" ? d(F, h.arguments ?? {}) : d[F];
|
|
1240
|
+
}, [d]), { items: Ne } = Xe({
|
|
1241
|
+
client: K ?? void 0,
|
|
1242
|
+
labelFor: Ie,
|
|
1243
|
+
includeReasoning: y
|
|
1244
|
+
}), oe = Ne.filter((h) => B?.id !== void 0 && h.messageId === B.id), U = d === !1 ? void 0 : oe[oe.length - 1]?.label, re = !!(G && U), Re = _ === !1 ? void 0 : _ ?? ((h) => ne(h));
|
|
1245
|
+
return /* @__PURE__ */ T("div", {
|
|
1246
|
+
ref: M,
|
|
828
1247
|
className: `ago-chat-widget ${C}`,
|
|
1248
|
+
...v.surface.attrs,
|
|
1249
|
+
"data-ago-sheet-state": v.compact ? v.state : void 0,
|
|
829
1250
|
style: {
|
|
830
1251
|
display: "flex",
|
|
831
1252
|
flexDirection: "column",
|
|
@@ -836,10 +1257,11 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
836
1257
|
backgroundColor: "#fff",
|
|
837
1258
|
fontFamily: '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
838
1259
|
textAlign: "left",
|
|
839
|
-
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
|
|
1260
|
+
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px",
|
|
1261
|
+
...v.surface.style
|
|
840
1262
|
},
|
|
841
1263
|
children: [
|
|
842
|
-
/* @__PURE__ */
|
|
1264
|
+
!v.compact && /* @__PURE__ */ T("div", {
|
|
843
1265
|
className: "ago-chat-widget__header",
|
|
844
1266
|
style: {
|
|
845
1267
|
padding: "14px 16px",
|
|
@@ -850,125 +1272,319 @@ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", a
|
|
|
850
1272
|
alignItems: "center",
|
|
851
1273
|
gap: "10px"
|
|
852
1274
|
},
|
|
853
|
-
children: [
|
|
854
|
-
src:
|
|
1275
|
+
children: [p && /* @__PURE__ */ a("img", {
|
|
1276
|
+
src: p,
|
|
855
1277
|
alt: "Logo",
|
|
856
1278
|
style: {
|
|
857
1279
|
height: "24px",
|
|
858
1280
|
width: "auto"
|
|
859
1281
|
}
|
|
860
|
-
}), /* @__PURE__ */
|
|
1282
|
+
}), /* @__PURE__ */ a("h3", {
|
|
861
1283
|
style: {
|
|
862
1284
|
margin: 0,
|
|
863
1285
|
fontSize: "15px",
|
|
864
1286
|
fontWeight: 600
|
|
865
1287
|
},
|
|
866
|
-
children:
|
|
1288
|
+
children: r
|
|
867
1289
|
})]
|
|
868
1290
|
}),
|
|
869
|
-
/* @__PURE__ */
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
"aria-
|
|
873
|
-
"aria-
|
|
874
|
-
|
|
1291
|
+
X && /* @__PURE__ */ T("button", {
|
|
1292
|
+
type: "button",
|
|
1293
|
+
className: "ago-chat-widget__peek",
|
|
1294
|
+
"aria-expanded": !1,
|
|
1295
|
+
"aria-label": "Open the conversation",
|
|
1296
|
+
onClick: () => {
|
|
1297
|
+
Y(!1), D("user");
|
|
1298
|
+
},
|
|
875
1299
|
style: {
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
1300
|
+
display: "flex",
|
|
1301
|
+
flexDirection: "column",
|
|
1302
|
+
alignItems: "stretch",
|
|
1303
|
+
gap: "8px",
|
|
1304
|
+
padding: "14px 18px 10px",
|
|
1305
|
+
border: "none",
|
|
1306
|
+
borderBottom: "1px solid currentColor",
|
|
1307
|
+
borderBottomColor: "rgba(128,128,128,0.25)",
|
|
1308
|
+
background: "transparent",
|
|
1309
|
+
textAlign: "left",
|
|
1310
|
+
cursor: "pointer",
|
|
1311
|
+
font: "inherit",
|
|
1312
|
+
color: "inherit"
|
|
880
1313
|
},
|
|
881
|
-
children: [
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
1314
|
+
children: [/* @__PURE__ */ T("span", {
|
|
1315
|
+
style: {
|
|
1316
|
+
display: "flex",
|
|
1317
|
+
alignItems: "center",
|
|
1318
|
+
gap: "6px",
|
|
1319
|
+
fontSize: "12px",
|
|
1320
|
+
fontWeight: 600,
|
|
1321
|
+
letterSpacing: "0.04em",
|
|
1322
|
+
textTransform: "uppercase",
|
|
1323
|
+
color: "inherit",
|
|
1324
|
+
opacity: 0.7
|
|
1325
|
+
},
|
|
1326
|
+
children: [
|
|
1327
|
+
r,
|
|
1328
|
+
be && /* @__PURE__ */ a("span", {
|
|
1329
|
+
"aria-label": "New message",
|
|
1330
|
+
style: {
|
|
1331
|
+
width: "6px",
|
|
1332
|
+
height: "6px",
|
|
1333
|
+
borderRadius: "50%",
|
|
1334
|
+
backgroundColor: "#1b5fc4"
|
|
1335
|
+
}
|
|
1336
|
+
}),
|
|
1337
|
+
/* @__PURE__ */ a("span", {
|
|
1338
|
+
style: {
|
|
1339
|
+
marginLeft: "auto",
|
|
1340
|
+
fontSize: "14px"
|
|
1341
|
+
},
|
|
1342
|
+
"aria-hidden": !0,
|
|
1343
|
+
children: "↑"
|
|
1344
|
+
})
|
|
1345
|
+
]
|
|
1346
|
+
}), G && !B?.content ? /* @__PURE__ */ T("span", {
|
|
1347
|
+
style: {
|
|
1348
|
+
display: "flex",
|
|
1349
|
+
alignItems: "center",
|
|
1350
|
+
gap: "8px"
|
|
1351
|
+
},
|
|
1352
|
+
children: [!U && /* @__PURE__ */ a(ve, {}), /* @__PURE__ */ a("span", {
|
|
899
1353
|
style: {
|
|
900
|
-
padding: "10px 14px",
|
|
901
|
-
backgroundColor: "#fef2f2",
|
|
902
|
-
color: "#dc2626",
|
|
903
|
-
borderRadius: "12px",
|
|
904
|
-
marginTop: "8px",
|
|
905
1354
|
fontSize: "13px",
|
|
906
|
-
|
|
1355
|
+
opacity: 0.7,
|
|
1356
|
+
overflow: "hidden",
|
|
1357
|
+
textOverflow: "ellipsis",
|
|
1358
|
+
whiteSpace: "nowrap"
|
|
907
1359
|
},
|
|
908
|
-
children:
|
|
909
|
-
})
|
|
910
|
-
|
|
911
|
-
|
|
1360
|
+
children: U ? ye(U) : b
|
|
1361
|
+
})]
|
|
1362
|
+
}) : /* @__PURE__ */ a("span", {
|
|
1363
|
+
style: {
|
|
1364
|
+
display: "-webkit-box",
|
|
1365
|
+
WebkitLineClamp: 2,
|
|
1366
|
+
WebkitBoxOrient: "vertical",
|
|
1367
|
+
overflow: "hidden",
|
|
1368
|
+
fontSize: "13px",
|
|
1369
|
+
lineHeight: 1.5,
|
|
1370
|
+
color: "inherit",
|
|
1371
|
+
minHeight: "calc(2 * 1.5 * 13px)"
|
|
1372
|
+
},
|
|
1373
|
+
children: B?.content || n
|
|
1374
|
+
})]
|
|
1375
|
+
}),
|
|
1376
|
+
v.compact && v.state === "full" && /* @__PURE__ */ T("div", {
|
|
1377
|
+
className: "ago-chat-widget__sheet-header",
|
|
1378
|
+
style: {
|
|
1379
|
+
display: "flex",
|
|
1380
|
+
alignItems: "center",
|
|
1381
|
+
gap: "8px",
|
|
1382
|
+
padding: "6px 10px 6px 18px",
|
|
1383
|
+
borderBottom: "1px solid rgba(128,128,128,0.25)",
|
|
1384
|
+
flexShrink: 0
|
|
1385
|
+
},
|
|
1386
|
+
children: [/* @__PURE__ */ a("span", {
|
|
1387
|
+
style: {
|
|
1388
|
+
fontSize: "12px",
|
|
1389
|
+
fontWeight: 600,
|
|
1390
|
+
letterSpacing: "0.04em",
|
|
1391
|
+
textTransform: "uppercase",
|
|
1392
|
+
color: "inherit",
|
|
1393
|
+
opacity: 0.7,
|
|
1394
|
+
overflow: "hidden",
|
|
1395
|
+
whiteSpace: "nowrap",
|
|
1396
|
+
textOverflow: "ellipsis"
|
|
1397
|
+
},
|
|
1398
|
+
children: r
|
|
1399
|
+
}), /* @__PURE__ */ a("button", {
|
|
1400
|
+
type: "button",
|
|
1401
|
+
"aria-label": "Collapse the conversation",
|
|
1402
|
+
onClick: () => q("user"),
|
|
1403
|
+
style: {
|
|
1404
|
+
marginLeft: "auto",
|
|
1405
|
+
flexShrink: 0,
|
|
1406
|
+
width: "44px",
|
|
1407
|
+
height: "44px",
|
|
1408
|
+
display: "flex",
|
|
1409
|
+
alignItems: "center",
|
|
1410
|
+
justifyContent: "center",
|
|
1411
|
+
border: "none",
|
|
1412
|
+
background: "transparent",
|
|
1413
|
+
color: "inherit",
|
|
1414
|
+
cursor: "pointer"
|
|
1415
|
+
},
|
|
1416
|
+
children: /* @__PURE__ */ a("svg", {
|
|
1417
|
+
width: "20",
|
|
1418
|
+
height: "20",
|
|
1419
|
+
viewBox: "0 0 24 24",
|
|
1420
|
+
fill: "none",
|
|
1421
|
+
stroke: "currentColor",
|
|
1422
|
+
strokeWidth: "2",
|
|
1423
|
+
strokeLinecap: "round",
|
|
1424
|
+
strokeLinejoin: "round",
|
|
1425
|
+
"aria-hidden": "true",
|
|
1426
|
+
children: /* @__PURE__ */ a("path", { d: "M6 9l6 6 6-6" })
|
|
1427
|
+
})
|
|
1428
|
+
})]
|
|
1429
|
+
}),
|
|
1430
|
+
/* @__PURE__ */ T("div", {
|
|
1431
|
+
style: {
|
|
1432
|
+
position: "relative",
|
|
1433
|
+
flex: 1,
|
|
1434
|
+
display: X ? "none" : "flex",
|
|
1435
|
+
minHeight: 0
|
|
1436
|
+
},
|
|
1437
|
+
children: [/* @__PURE__ */ T("div", {
|
|
1438
|
+
ref: g,
|
|
1439
|
+
className: "ago-chat-widget__messages",
|
|
1440
|
+
onScroll: (h) => {
|
|
1441
|
+
const F = h.currentTarget, E = F.scrollHeight - F.scrollTop - F.clientHeight <= 48;
|
|
1442
|
+
w.current = E, x(E);
|
|
1443
|
+
},
|
|
1444
|
+
role: "log",
|
|
1445
|
+
"aria-live": "polite",
|
|
1446
|
+
"aria-relevant": "additions text",
|
|
1447
|
+
"aria-atomic": !1,
|
|
1448
|
+
"aria-busy": G,
|
|
1449
|
+
style: {
|
|
1450
|
+
flex: 1,
|
|
1451
|
+
overflow: "auto",
|
|
1452
|
+
overscrollBehavior: "contain",
|
|
1453
|
+
padding: "16px",
|
|
1454
|
+
backgroundColor: "#fbfbfb"
|
|
1455
|
+
},
|
|
1456
|
+
children: [
|
|
1457
|
+
P.length === 0 ? /* @__PURE__ */ a("div", {
|
|
1458
|
+
style: {
|
|
1459
|
+
textAlign: "center",
|
|
1460
|
+
color: "#6b6d6f",
|
|
1461
|
+
padding: "24px 16px",
|
|
1462
|
+
fontSize: "16px",
|
|
1463
|
+
lineHeight: "1.5"
|
|
1464
|
+
},
|
|
1465
|
+
children: n
|
|
1466
|
+
}) : P.map((h, F) => /* @__PURE__ */ a(kt, {
|
|
1467
|
+
message: h,
|
|
1468
|
+
showAgentName: f,
|
|
1469
|
+
isLast: F === P.length - 1,
|
|
1470
|
+
onFollowUpClick: Re,
|
|
1471
|
+
showStreamingDots: !re
|
|
1472
|
+
}, h.id)),
|
|
1473
|
+
re && /* @__PURE__ */ a(ot, { label: U ?? "" }),
|
|
1474
|
+
te && /* @__PURE__ */ a("div", {
|
|
1475
|
+
role: "alert",
|
|
1476
|
+
style: {
|
|
1477
|
+
padding: "10px 14px",
|
|
1478
|
+
backgroundColor: "#fef2f2",
|
|
1479
|
+
color: "#dc2626",
|
|
1480
|
+
borderRadius: "12px",
|
|
1481
|
+
marginTop: "8px",
|
|
1482
|
+
fontSize: "13px",
|
|
1483
|
+
border: "1px solid #fecaca"
|
|
1484
|
+
},
|
|
1485
|
+
children: te.message
|
|
1486
|
+
}),
|
|
1487
|
+
/* @__PURE__ */ a("div", {})
|
|
1488
|
+
]
|
|
1489
|
+
}), !S && /* @__PURE__ */ a("button", {
|
|
1490
|
+
type: "button",
|
|
1491
|
+
className: "ago-chat-widget__jump",
|
|
1492
|
+
"aria-label": "Jump to latest message",
|
|
1493
|
+
onClick: Ae,
|
|
1494
|
+
style: {
|
|
1495
|
+
position: "absolute",
|
|
1496
|
+
left: "50%",
|
|
1497
|
+
bottom: "12px",
|
|
1498
|
+
transform: "translateX(-50%)",
|
|
1499
|
+
width: "44px",
|
|
1500
|
+
height: "44px",
|
|
1501
|
+
display: "flex",
|
|
1502
|
+
alignItems: "center",
|
|
1503
|
+
justifyContent: "center",
|
|
1504
|
+
border: "1px solid #dee3e8",
|
|
1505
|
+
borderRadius: "50%",
|
|
1506
|
+
backgroundColor: "#fff",
|
|
1507
|
+
color: "#0b1b2b",
|
|
1508
|
+
boxShadow: "rgba(15, 15, 15, 0.16) 0px 2px 10px 0px",
|
|
1509
|
+
cursor: "pointer",
|
|
1510
|
+
zIndex: 2
|
|
1511
|
+
},
|
|
1512
|
+
children: /* @__PURE__ */ a("svg", {
|
|
1513
|
+
width: "18",
|
|
1514
|
+
height: "18",
|
|
1515
|
+
viewBox: "0 0 24 24",
|
|
1516
|
+
fill: "none",
|
|
1517
|
+
stroke: "currentColor",
|
|
1518
|
+
strokeWidth: "2",
|
|
1519
|
+
strokeLinecap: "round",
|
|
1520
|
+
strokeLinejoin: "round",
|
|
1521
|
+
"aria-hidden": "true",
|
|
1522
|
+
children: /* @__PURE__ */ a("path", { d: "M12 5v14M19 12l-7 7-7-7" })
|
|
1523
|
+
})
|
|
1524
|
+
})]
|
|
912
1525
|
}),
|
|
913
|
-
/* @__PURE__ */
|
|
914
|
-
onSend:
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
1526
|
+
/* @__PURE__ */ a(rt, {
|
|
1527
|
+
onSend: ne,
|
|
1528
|
+
onStop: l ? () => {
|
|
1529
|
+
Se();
|
|
1530
|
+
} : void 0,
|
|
1531
|
+
disabled: G,
|
|
1532
|
+
placeholder: s,
|
|
1533
|
+
allowFiles: i
|
|
918
1534
|
})
|
|
919
1535
|
]
|
|
920
1536
|
});
|
|
921
|
-
};
|
|
922
|
-
function
|
|
923
|
-
const
|
|
924
|
-
if (!t) throw new
|
|
925
|
-
const [
|
|
926
|
-
s.current =
|
|
927
|
-
const
|
|
928
|
-
return
|
|
929
|
-
const
|
|
930
|
-
n(
|
|
931
|
-
},
|
|
932
|
-
n((
|
|
1537
|
+
});
|
|
1538
|
+
function St(e = {}) {
|
|
1539
|
+
const o = O(), t = e.client ?? o;
|
|
1540
|
+
if (!t) throw new Z("useProactiveNudge: no AgoClient. Pass one via options.client or wrap your tree with <AgoProvider>.", "proactive_missing_client");
|
|
1541
|
+
const [r, n] = z(null), s = W(r);
|
|
1542
|
+
s.current = r;
|
|
1543
|
+
const i = W(e.onExpand);
|
|
1544
|
+
return i.current = e.onExpand, N(() => {
|
|
1545
|
+
const l = (p) => {
|
|
1546
|
+
n(p), t.proactive?.shown(p);
|
|
1547
|
+
}, c = ({ nudge: p }) => {
|
|
1548
|
+
n((f) => f?.id === p.id ? null : f);
|
|
933
1549
|
};
|
|
934
|
-
return t.on("nudge:ready",
|
|
935
|
-
t.off("nudge:ready",
|
|
1550
|
+
return t.on("nudge:ready", l), t.on("nudge:accepted", c), t.on("nudge:dismissed", c), () => {
|
|
1551
|
+
t.off("nudge:ready", l), t.off("nudge:accepted", c), t.off("nudge:dismissed", c);
|
|
936
1552
|
};
|
|
937
1553
|
}, [t]), {
|
|
938
|
-
nudge:
|
|
1554
|
+
nudge: r,
|
|
939
1555
|
accept: R(async () => {
|
|
940
|
-
const
|
|
941
|
-
|
|
1556
|
+
const l = s.current;
|
|
1557
|
+
l && (n(null), await t.proactive?.accept(l), (l.source === "agent" || l.goal) && i.current?.(l));
|
|
942
1558
|
}, [t]),
|
|
943
1559
|
dismiss: R(() => {
|
|
944
|
-
const
|
|
945
|
-
|
|
1560
|
+
const l = s.current;
|
|
1561
|
+
l && (n(null), t.proactive?.dismiss(l));
|
|
946
1562
|
}, [t])
|
|
947
1563
|
};
|
|
948
1564
|
}
|
|
949
|
-
var
|
|
950
|
-
const { nudge:
|
|
1565
|
+
var Bt = ({ client: e, onExpand: o, autoHideMs: t, position: r = "bottom-right", openChatLabel: n = "Open chat", className: s = "" }) => {
|
|
1566
|
+
const { nudge: i, accept: l, dismiss: c } = St({
|
|
951
1567
|
client: e,
|
|
952
|
-
onExpand:
|
|
1568
|
+
onExpand: o
|
|
953
1569
|
});
|
|
954
|
-
if (
|
|
955
|
-
if (!
|
|
956
|
-
const
|
|
957
|
-
return () => clearTimeout(
|
|
1570
|
+
if (N(() => {
|
|
1571
|
+
if (!i || !t) return;
|
|
1572
|
+
const f = setTimeout(() => c(), t);
|
|
1573
|
+
return () => clearTimeout(f);
|
|
958
1574
|
}, [
|
|
959
|
-
|
|
1575
|
+
i,
|
|
960
1576
|
t,
|
|
961
|
-
|
|
962
|
-
]), !
|
|
963
|
-
const
|
|
964
|
-
return /* @__PURE__ */
|
|
1577
|
+
c
|
|
1578
|
+
]), !i) return null;
|
|
1579
|
+
const p = i.source === "agent" || !!i.goal;
|
|
1580
|
+
return /* @__PURE__ */ T("div", {
|
|
965
1581
|
className: `ago-nudge ${s}`,
|
|
966
1582
|
role: "status",
|
|
967
1583
|
"aria-live": "polite",
|
|
968
1584
|
style: {
|
|
969
1585
|
position: "fixed",
|
|
970
1586
|
bottom: "90px",
|
|
971
|
-
...
|
|
1587
|
+
...r === "bottom-left" ? { left: "20px" } : { right: "20px" },
|
|
972
1588
|
zIndex: 2147483e3,
|
|
973
1589
|
maxWidth: "320px",
|
|
974
1590
|
padding: "14px 16px",
|
|
@@ -983,11 +1599,11 @@ var Ve = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
|
|
|
983
1599
|
textAlign: "left"
|
|
984
1600
|
},
|
|
985
1601
|
children: [
|
|
986
|
-
/* @__PURE__ */
|
|
1602
|
+
/* @__PURE__ */ a("button", {
|
|
987
1603
|
type: "button",
|
|
988
1604
|
className: "ago-nudge__close",
|
|
989
1605
|
"aria-label": "Dismiss",
|
|
990
|
-
onClick:
|
|
1606
|
+
onClick: c,
|
|
991
1607
|
style: {
|
|
992
1608
|
position: "absolute",
|
|
993
1609
|
top: "6px",
|
|
@@ -1002,12 +1618,12 @@ var Ve = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
|
|
|
1002
1618
|
},
|
|
1003
1619
|
children: "×"
|
|
1004
1620
|
}),
|
|
1005
|
-
/* @__PURE__ */
|
|
1621
|
+
/* @__PURE__ */ a("div", {
|
|
1006
1622
|
className: "ago-nudge__message",
|
|
1007
1623
|
style: { paddingRight: "16px" },
|
|
1008
|
-
children:
|
|
1624
|
+
children: i.message
|
|
1009
1625
|
}),
|
|
1010
|
-
(
|
|
1626
|
+
(i.action || p) && /* @__PURE__ */ T("div", {
|
|
1011
1627
|
className: "ago-nudge__actions",
|
|
1012
1628
|
style: {
|
|
1013
1629
|
display: "flex",
|
|
@@ -1015,11 +1631,11 @@ var Ve = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
|
|
|
1015
1631
|
marginTop: "10px",
|
|
1016
1632
|
flexWrap: "wrap"
|
|
1017
1633
|
},
|
|
1018
|
-
children: [
|
|
1634
|
+
children: [i.action && /* @__PURE__ */ a("button", {
|
|
1019
1635
|
type: "button",
|
|
1020
1636
|
className: "ago-nudge__action",
|
|
1021
1637
|
onClick: () => {
|
|
1022
|
-
|
|
1638
|
+
l();
|
|
1023
1639
|
},
|
|
1024
1640
|
style: {
|
|
1025
1641
|
border: "none",
|
|
@@ -1031,12 +1647,12 @@ var Ve = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
|
|
|
1031
1647
|
fontWeight: 600,
|
|
1032
1648
|
cursor: "pointer"
|
|
1033
1649
|
},
|
|
1034
|
-
children:
|
|
1035
|
-
}),
|
|
1650
|
+
children: i.action.label
|
|
1651
|
+
}), p && /* @__PURE__ */ a("button", {
|
|
1036
1652
|
type: "button",
|
|
1037
1653
|
className: "ago-nudge__expand",
|
|
1038
1654
|
onClick: () => {
|
|
1039
|
-
|
|
1655
|
+
l();
|
|
1040
1656
|
},
|
|
1041
1657
|
style: {
|
|
1042
1658
|
border: "1px solid #dee3e8",
|
|
@@ -1054,60 +1670,61 @@ var Ve = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
|
|
|
1054
1670
|
]
|
|
1055
1671
|
});
|
|
1056
1672
|
};
|
|
1057
|
-
function
|
|
1058
|
-
const t =
|
|
1059
|
-
if (!
|
|
1060
|
-
const [n, s] =
|
|
1061
|
-
|
|
1673
|
+
function At({ client: e, autoLoad: o = !0 } = {}) {
|
|
1674
|
+
const t = O(), r = e || t;
|
|
1675
|
+
if (!r) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
1676
|
+
const [n, s] = z([]), [i, l] = z(null), [c, p] = z(!1), [f, k] = z(null), _ = R(async () => {
|
|
1677
|
+
p(!0), k(null);
|
|
1062
1678
|
try {
|
|
1063
|
-
const { data: u } = await
|
|
1679
|
+
const { data: u } = await r.getConversations();
|
|
1064
1680
|
s(u);
|
|
1065
1681
|
} catch (u) {
|
|
1066
|
-
|
|
1682
|
+
k(u instanceof Error ? u : /* @__PURE__ */ new Error("Failed to load conversations"));
|
|
1067
1683
|
} finally {
|
|
1068
|
-
|
|
1684
|
+
p(!1);
|
|
1069
1685
|
}
|
|
1070
|
-
}, [
|
|
1071
|
-
|
|
1686
|
+
}, [r]), C = R(async (u) => {
|
|
1687
|
+
p(!0), k(null);
|
|
1072
1688
|
try {
|
|
1073
|
-
|
|
1074
|
-
} catch (
|
|
1075
|
-
|
|
1689
|
+
l(await r.getConversation(u));
|
|
1690
|
+
} catch (A) {
|
|
1691
|
+
k(A instanceof Error ? A : /* @__PURE__ */ new Error("Failed to load conversation"));
|
|
1076
1692
|
} finally {
|
|
1077
|
-
|
|
1693
|
+
p(!1);
|
|
1078
1694
|
}
|
|
1079
|
-
}, [
|
|
1080
|
-
|
|
1695
|
+
}, [r]), I = R(() => {
|
|
1696
|
+
l(null);
|
|
1081
1697
|
}, []);
|
|
1082
|
-
return
|
|
1083
|
-
|
|
1084
|
-
}, [
|
|
1698
|
+
return N(() => {
|
|
1699
|
+
o && _();
|
|
1700
|
+
}, [o, _]), {
|
|
1085
1701
|
conversations: n,
|
|
1086
|
-
currentConversation:
|
|
1087
|
-
isLoading:
|
|
1088
|
-
error:
|
|
1089
|
-
selectConversation:
|
|
1090
|
-
startNewConversation:
|
|
1091
|
-
refreshConversations:
|
|
1702
|
+
currentConversation: i,
|
|
1703
|
+
isLoading: c,
|
|
1704
|
+
error: f,
|
|
1705
|
+
selectConversation: C,
|
|
1706
|
+
startNewConversation: I,
|
|
1707
|
+
refreshConversations: _
|
|
1092
1708
|
};
|
|
1093
1709
|
}
|
|
1094
|
-
function
|
|
1095
|
-
const
|
|
1710
|
+
function Ot(e = {}) {
|
|
1711
|
+
const o = O(), t = e.client || o;
|
|
1096
1712
|
if (!t) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
1097
|
-
const
|
|
1713
|
+
const r = xe({
|
|
1098
1714
|
client: t,
|
|
1099
1715
|
conversationId: e.conversationId
|
|
1100
|
-
}), n =
|
|
1716
|
+
}), n = At({
|
|
1101
1717
|
client: t,
|
|
1102
1718
|
autoLoad: e.autoLoad
|
|
1103
1719
|
});
|
|
1104
1720
|
return {
|
|
1105
|
-
messages:
|
|
1106
|
-
isLoading:
|
|
1107
|
-
error:
|
|
1108
|
-
sendMessage:
|
|
1109
|
-
|
|
1110
|
-
|
|
1721
|
+
messages: r.messages,
|
|
1722
|
+
isLoading: r.isLoading,
|
|
1723
|
+
error: r.error || n.error,
|
|
1724
|
+
sendMessage: r.sendMessage,
|
|
1725
|
+
stop: r.stop,
|
|
1726
|
+
clearMessages: r.clearMessages,
|
|
1727
|
+
conversationId: r.conversationId,
|
|
1111
1728
|
conversations: n.conversations,
|
|
1112
1729
|
currentConversation: n.currentConversation,
|
|
1113
1730
|
isConversationsLoading: n.isLoading,
|
|
@@ -1116,271 +1733,105 @@ function Ye(e = {}) {
|
|
|
1116
1733
|
refreshConversations: n.refreshConversations
|
|
1117
1734
|
};
|
|
1118
1735
|
}
|
|
1119
|
-
function
|
|
1120
|
-
const t =
|
|
1736
|
+
function jt(e, o) {
|
|
1737
|
+
const t = $(), { name: r, description: n, parameters: s, handler: i, maxResultBytes: l, requiresApproval: c } = typeof e == "string" ? {
|
|
1121
1738
|
name: e,
|
|
1122
|
-
...
|
|
1123
|
-
} : e,
|
|
1124
|
-
|
|
1125
|
-
const
|
|
1126
|
-
return t.registerFunction(
|
|
1739
|
+
...o
|
|
1740
|
+
} : e, p = W(i);
|
|
1741
|
+
p.current = i, N(() => {
|
|
1742
|
+
const f = (k) => p.current(k);
|
|
1743
|
+
return t.registerFunction(r, f, {
|
|
1127
1744
|
description: n,
|
|
1128
1745
|
parameters: s,
|
|
1129
|
-
maxResultBytes:
|
|
1130
|
-
requiresApproval:
|
|
1746
|
+
maxResultBytes: l,
|
|
1747
|
+
requiresApproval: c
|
|
1131
1748
|
}), () => {
|
|
1132
|
-
t.unregisterFunction(
|
|
1749
|
+
t.unregisterFunction(r);
|
|
1133
1750
|
};
|
|
1134
1751
|
}, [
|
|
1135
1752
|
t,
|
|
1136
|
-
|
|
1753
|
+
r,
|
|
1137
1754
|
n,
|
|
1138
1755
|
s,
|
|
1139
|
-
|
|
1140
|
-
|
|
1756
|
+
l,
|
|
1757
|
+
c
|
|
1141
1758
|
]);
|
|
1142
1759
|
}
|
|
1143
|
-
function
|
|
1144
|
-
const t =
|
|
1145
|
-
|
|
1760
|
+
function $t(e, o) {
|
|
1761
|
+
const t = $(), r = W(e);
|
|
1762
|
+
r.current = e, N(() => (t.registerNavigationFunction((n) => r.current(n), o), () => {
|
|
1146
1763
|
t.unregisterNavigationFunction();
|
|
1147
|
-
}), [t,
|
|
1764
|
+
}), [t, o]);
|
|
1148
1765
|
}
|
|
1149
|
-
function
|
|
1150
|
-
const t =
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1766
|
+
function qt(e, o) {
|
|
1767
|
+
const t = $(), r = o?.functionName ?? "setPageState", n = o?.requiresApproval, s = o?.data !== void 0, i = o?.data?.description, l = o?.data?.maxResultBytes, c = o?.settleTimeoutMs, p = W(e);
|
|
1768
|
+
p.current = e;
|
|
1769
|
+
const f = W(o);
|
|
1770
|
+
f.current = o, N(() => {
|
|
1771
|
+
const k = p.current.map((C) => {
|
|
1772
|
+
const I = () => p.current.find((u) => u.name === C.name) ?? C;
|
|
1154
1773
|
return {
|
|
1155
|
-
name:
|
|
1156
|
-
description:
|
|
1157
|
-
schema:
|
|
1158
|
-
get:
|
|
1159
|
-
set: (
|
|
1774
|
+
name: C.name,
|
|
1775
|
+
description: C.description,
|
|
1776
|
+
schema: C.schema,
|
|
1777
|
+
get: C.get ? () => I().get?.() : void 0,
|
|
1778
|
+
set: (u) => I().set(u)
|
|
1160
1779
|
};
|
|
1161
|
-
})
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1780
|
+
}), _ = s ? {
|
|
1781
|
+
description: i ?? "What the page is currently showing.",
|
|
1782
|
+
maxResultBytes: l,
|
|
1783
|
+
get: () => f.current?.data?.get(),
|
|
1784
|
+
isLoading: () => f.current?.data?.isLoading?.() ?? !1
|
|
1785
|
+
} : void 0;
|
|
1786
|
+
return t.registerPageStateFunction(k, {
|
|
1787
|
+
functionName: r,
|
|
1788
|
+
requiresApproval: n,
|
|
1789
|
+
data: _,
|
|
1790
|
+
settleTimeoutMs: c
|
|
1165
1791
|
}), () => {
|
|
1166
|
-
t.unregisterPageStateFunction(
|
|
1792
|
+
t.unregisterPageStateFunction(r);
|
|
1167
1793
|
};
|
|
1168
1794
|
}, [
|
|
1169
1795
|
t,
|
|
1170
|
-
o,
|
|
1171
|
-
n
|
|
1172
|
-
]);
|
|
1173
|
-
}
|
|
1174
|
-
function et(e) {
|
|
1175
|
-
const r = z(), t = M(e);
|
|
1176
|
-
t.current = e, I(() => ne(r, () => t.current), [r]);
|
|
1177
|
-
}
|
|
1178
|
-
var Te = /* @__PURE__ */ new Set(["awaiting-approval"]);
|
|
1179
|
-
function J(e) {
|
|
1180
|
-
switch (e) {
|
|
1181
|
-
case "progress_indicator":
|
|
1182
|
-
return "progress";
|
|
1183
|
-
case "reasoning":
|
|
1184
|
-
return "reasoning";
|
|
1185
|
-
case "confirmation_input":
|
|
1186
|
-
return "confirmation";
|
|
1187
|
-
case "form":
|
|
1188
|
-
return "form";
|
|
1189
|
-
default:
|
|
1190
|
-
return "status";
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
function Pe(e) {
|
|
1194
|
-
return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : J(e.type);
|
|
1195
|
-
}
|
|
1196
|
-
function H(e, r) {
|
|
1197
|
-
const t = (e ?? "").toLowerCase();
|
|
1198
|
-
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";
|
|
1199
|
-
}
|
|
1200
|
-
function q(e) {
|
|
1201
|
-
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();
|
|
1202
|
-
}
|
|
1203
|
-
function We(e) {
|
|
1204
|
-
switch (e.kind) {
|
|
1205
|
-
case "navigation":
|
|
1206
|
-
return `Navigating to ${q(e.arguments?.page)}`;
|
|
1207
|
-
case "action":
|
|
1208
|
-
return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message || q(e.functionName) || "Working";
|
|
1209
|
-
case "progress":
|
|
1210
|
-
return e.message || "Working";
|
|
1211
|
-
case "reasoning":
|
|
1212
|
-
return e.message || "Thinking";
|
|
1213
|
-
case "confirmation":
|
|
1214
|
-
return e.message || "Waiting for your confirmation";
|
|
1215
|
-
case "form":
|
|
1216
|
-
return e.message || e.toolDisplayName || "Please fill in the form";
|
|
1217
|
-
default:
|
|
1218
|
-
return e.message || e.toolDisplayName || e.toolName || "Working";
|
|
1219
|
-
}
|
|
1220
|
-
}
|
|
1221
|
-
function tt(e = {}) {
|
|
1222
|
-
const { includeReasoning: r = !1, labelFor: t } = e, o = P(), n = e.client || o;
|
|
1223
|
-
if (!n) throw new L("useAgoActivity requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
|
|
1224
|
-
const [s, c] = E([]), a = M(/* @__PURE__ */ new Set()), p = M(void 0), d = M(t);
|
|
1225
|
-
d.current = t;
|
|
1226
|
-
const g = R((u, x) => {
|
|
1227
|
-
c((i) => {
|
|
1228
|
-
const v = i.findIndex((h) => h.id === u), f = {
|
|
1229
|
-
...v >= 0 ? i[v] : {
|
|
1230
|
-
id: u,
|
|
1231
|
-
kind: "status",
|
|
1232
|
-
label: "",
|
|
1233
|
-
status: "running",
|
|
1234
|
-
requiresApproval: !1,
|
|
1235
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
1236
|
-
},
|
|
1237
|
-
...x
|
|
1238
|
-
};
|
|
1239
|
-
return f.label = d.current?.(f) ?? We(f), v >= 0 ? [
|
|
1240
|
-
...i.slice(0, v),
|
|
1241
|
-
f,
|
|
1242
|
-
...i.slice(v + 1)
|
|
1243
|
-
] : [...i, f];
|
|
1244
|
-
});
|
|
1245
|
-
}, []);
|
|
1246
|
-
I(() => {
|
|
1247
|
-
const u = (y) => {
|
|
1248
|
-
p.current = y.messageId;
|
|
1249
|
-
}, x = (y) => {
|
|
1250
|
-
const m = J(y.type);
|
|
1251
|
-
m === "reasoning" && !r || g(y.id, {
|
|
1252
|
-
kind: m,
|
|
1253
|
-
status: H(y.status, m),
|
|
1254
|
-
messageId: p.current,
|
|
1255
|
-
toolName: y.toolName,
|
|
1256
|
-
toolDisplayName: y.toolDisplayName,
|
|
1257
|
-
message: y.message,
|
|
1258
|
-
data: y.data,
|
|
1259
|
-
formSchema: y.formSchema,
|
|
1260
|
-
requiresApproval: m === "confirmation" || m === "form"
|
|
1261
|
-
});
|
|
1262
|
-
}, i = (y) => {
|
|
1263
|
-
y.invocationId && g(y.invocationId, {
|
|
1264
|
-
kind: y.functionName === "navigateToPage" ? "navigation" : "action",
|
|
1265
|
-
status: "running",
|
|
1266
|
-
messageId: p.current,
|
|
1267
|
-
functionName: y.functionName,
|
|
1268
|
-
arguments: y.arguments
|
|
1269
|
-
});
|
|
1270
|
-
}, v = (y) => {
|
|
1271
|
-
y.invocationId && g(y.invocationId, {
|
|
1272
|
-
kind: y.functionName === "navigateToPage" ? "navigation" : "action",
|
|
1273
|
-
status: "awaiting-approval",
|
|
1274
|
-
messageId: p.current,
|
|
1275
|
-
functionName: y.functionName,
|
|
1276
|
-
arguments: y.arguments,
|
|
1277
|
-
requiresApproval: !0
|
|
1278
|
-
});
|
|
1279
|
-
}, f = (y) => {
|
|
1280
|
-
if (!y.invocationId) return;
|
|
1281
|
-
const m = y.result, A = typeof y.result == "object" && m !== null && m.approved === !1 && m.reason === "user_rejected";
|
|
1282
|
-
g(y.invocationId, {
|
|
1283
|
-
status: y.error ? "error" : A ? "rejected" : "done",
|
|
1284
|
-
requiresApproval: !1
|
|
1285
|
-
});
|
|
1286
|
-
}, h = (y) => {
|
|
1287
|
-
for (const m of y.messages ?? [])
|
|
1288
|
-
if (m.role === "assistant")
|
|
1289
|
-
for (const A of m.toolCalls ?? []) {
|
|
1290
|
-
const F = Pe(A);
|
|
1291
|
-
F === "reasoning" && !r || /waiting/i.test(A.status ?? "") || g(A.id, {
|
|
1292
|
-
kind: F,
|
|
1293
|
-
status: H(A.status, F),
|
|
1294
|
-
messageId: m.id,
|
|
1295
|
-
toolName: A.toolName,
|
|
1296
|
-
toolDisplayName: A.toolDisplayName,
|
|
1297
|
-
functionName: A.functionName,
|
|
1298
|
-
arguments: A.arguments,
|
|
1299
|
-
message: A.message,
|
|
1300
|
-
data: A.data,
|
|
1301
|
-
formSchema: A.formSchema,
|
|
1302
|
-
requiresApproval: F === "confirmation" || F === "form"
|
|
1303
|
-
});
|
|
1304
|
-
}
|
|
1305
|
-
}, w = (y) => {
|
|
1306
|
-
c((m) => m.map((A) => A.status === "running" || A.status === "awaiting-approval" ? {
|
|
1307
|
-
...A,
|
|
1308
|
-
status: y
|
|
1309
|
-
} : A));
|
|
1310
|
-
}, b = () => w("done"), T = () => w("error");
|
|
1311
|
-
return n.on("message:start", u), n.on("toolCall:received", x), n.on("function:invoke", i), n.on("function:awaiting-approval", v), n.on("function:result", f), n.on("conversation:loaded", h), n.on("message:complete", b), n.on("message:error", T), () => {
|
|
1312
|
-
n.off("message:start", u), n.off("toolCall:received", x), n.off("function:invoke", i), n.off("function:awaiting-approval", v), n.off("function:result", f), n.off("conversation:loaded", h), n.off("message:complete", b), n.off("message:error", T);
|
|
1313
|
-
};
|
|
1314
|
-
}, [
|
|
1315
|
-
n,
|
|
1316
1796
|
r,
|
|
1317
|
-
g
|
|
1318
|
-
]);
|
|
1319
|
-
const C = R(async (u) => {
|
|
1320
|
-
const x = s.find((i) => i.id === u);
|
|
1321
|
-
!x || x.status !== "awaiting-approval" || a.current.has(u) || x.kind !== "form" && (a.current.add(u), g(u, {
|
|
1322
|
-
status: "running",
|
|
1323
|
-
requiresApproval: !1
|
|
1324
|
-
}), x.functionName ? await n.approveFunction(u) : await n.confirmToolCall(u));
|
|
1325
|
-
}, [
|
|
1326
|
-
n,
|
|
1327
|
-
s,
|
|
1328
|
-
g
|
|
1329
|
-
]), N = R(async (u) => {
|
|
1330
|
-
const x = s.find((i) => i.id === u);
|
|
1331
|
-
!x || x.status !== "awaiting-approval" || a.current.has(u) || (a.current.add(u), g(u, {
|
|
1332
|
-
status: "rejected",
|
|
1333
|
-
requiresApproval: !1
|
|
1334
|
-
}), x.functionName ? await n.rejectFunction(u) : await n.rejectToolCall(u));
|
|
1335
|
-
}, [
|
|
1336
1797
|
n,
|
|
1337
1798
|
s,
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
requiresApproval: !1
|
|
1343
|
-
}), await n.submitToolCallForm(u, x), g(u, { status: "done" });
|
|
1344
|
-
}, [n, g]), k = R(() => {
|
|
1345
|
-
a.current.clear(), c([]);
|
|
1346
|
-
}, []);
|
|
1347
|
-
return {
|
|
1348
|
-
items: s,
|
|
1349
|
-
latest: s.length > 0 ? s[s.length - 1] : void 0,
|
|
1350
|
-
isAwaitingApproval: s.some((u) => Te.has(u.status)),
|
|
1351
|
-
approve: C,
|
|
1352
|
-
reject: N,
|
|
1353
|
-
submitForm: S,
|
|
1354
|
-
clear: k
|
|
1355
|
-
};
|
|
1799
|
+
i,
|
|
1800
|
+
l,
|
|
1801
|
+
c
|
|
1802
|
+
]);
|
|
1356
1803
|
}
|
|
1357
|
-
function
|
|
1358
|
-
const
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1804
|
+
function Kt(e) {
|
|
1805
|
+
const o = $(), t = W(e);
|
|
1806
|
+
t.current = e, N(() => Pe(o, () => t.current), [o]);
|
|
1807
|
+
}
|
|
1808
|
+
function Ut(e = {}) {
|
|
1809
|
+
const o = O(), t = e.client || o;
|
|
1810
|
+
if (!t) throw new Z("useAgoActivityLog requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
|
|
1811
|
+
const [r, n] = z(() => t.getRecentActivity());
|
|
1812
|
+
N(() => {
|
|
1362
1813
|
n(t.getRecentActivity());
|
|
1363
|
-
const
|
|
1364
|
-
return t.on("activity:recorded",
|
|
1814
|
+
const l = () => n(t.getRecentActivity());
|
|
1815
|
+
return t.on("activity:recorded", l), () => t.off("activity:recorded", l);
|
|
1365
1816
|
}, [t]);
|
|
1366
|
-
const s = R((
|
|
1817
|
+
const s = R((l) => t.recordActivity(l), [t]), i = R(() => {
|
|
1367
1818
|
t.clearActivity(), n([]);
|
|
1368
1819
|
}, [t]);
|
|
1369
1820
|
return {
|
|
1370
|
-
entries:
|
|
1371
|
-
latest:
|
|
1821
|
+
entries: r,
|
|
1822
|
+
latest: r.length > 0 ? r[r.length - 1] : void 0,
|
|
1372
1823
|
record: s,
|
|
1373
|
-
clear:
|
|
1824
|
+
clear: i
|
|
1374
1825
|
};
|
|
1375
1826
|
}
|
|
1376
|
-
function
|
|
1377
|
-
const t =
|
|
1827
|
+
function Gt(e, o) {
|
|
1828
|
+
const t = $(), r = $e(), n = o ?? r, s = W(e);
|
|
1378
1829
|
s.current = e;
|
|
1379
|
-
const
|
|
1380
|
-
|
|
1830
|
+
const i = typeof e == "function";
|
|
1831
|
+
N(() => {
|
|
1381
1832
|
if (typeof s.current == "function") {
|
|
1382
|
-
const
|
|
1383
|
-
return t.addDynamicContext(n,
|
|
1833
|
+
const l = () => s.current();
|
|
1834
|
+
return t.addDynamicContext(n, l), () => {
|
|
1384
1835
|
t.removeDynamicContext(n);
|
|
1385
1836
|
};
|
|
1386
1837
|
}
|
|
@@ -1390,74 +1841,74 @@ function rt(e, r) {
|
|
|
1390
1841
|
}, [
|
|
1391
1842
|
t,
|
|
1392
1843
|
n,
|
|
1393
|
-
|
|
1394
|
-
|
|
1844
|
+
i,
|
|
1845
|
+
i ? "" : JSON.stringify(e)
|
|
1395
1846
|
]);
|
|
1396
1847
|
}
|
|
1397
|
-
function
|
|
1398
|
-
return
|
|
1848
|
+
function It(e) {
|
|
1849
|
+
return ge(e.subscribe, e.get, e.get);
|
|
1399
1850
|
}
|
|
1400
|
-
var
|
|
1851
|
+
var de = {
|
|
1401
1852
|
missing: [],
|
|
1402
1853
|
complete: !1
|
|
1403
1854
|
};
|
|
1404
|
-
function
|
|
1405
|
-
const
|
|
1855
|
+
function Jt(e) {
|
|
1856
|
+
const o = $(), t = e.schema != null, r = JSON.stringify(e.schema ?? null), n = e.submit, s = n ? typeof n == "string" ? `client:${n}` : n.via === "backend" ? "backend" : "handler" in n ? "client:handler" : `client:${n.url}` : "none", i = JSON.stringify(e.initialValues ?? null), l = H(() => t ? pe(e) : null, [
|
|
1406
1857
|
t,
|
|
1407
1858
|
e.name,
|
|
1408
|
-
|
|
1859
|
+
r,
|
|
1409
1860
|
s,
|
|
1410
|
-
|
|
1861
|
+
i,
|
|
1411
1862
|
e.autoSubmit
|
|
1412
|
-
]), [
|
|
1863
|
+
]), [c, p] = z({
|
|
1413
1864
|
collector: null,
|
|
1414
1865
|
loading: !t,
|
|
1415
1866
|
error: null
|
|
1416
1867
|
});
|
|
1417
|
-
|
|
1868
|
+
N(() => {
|
|
1418
1869
|
if (t) return;
|
|
1419
|
-
let
|
|
1420
|
-
return
|
|
1870
|
+
let d = !1;
|
|
1871
|
+
return p({
|
|
1421
1872
|
collector: null,
|
|
1422
1873
|
loading: !0,
|
|
1423
1874
|
error: null
|
|
1424
|
-
}),
|
|
1425
|
-
|
|
1426
|
-
collector:
|
|
1875
|
+
}), ue(o, e).then((y) => {
|
|
1876
|
+
d || p({
|
|
1877
|
+
collector: y,
|
|
1427
1878
|
loading: !1,
|
|
1428
1879
|
error: null
|
|
1429
1880
|
});
|
|
1430
|
-
}).catch((
|
|
1431
|
-
|
|
1881
|
+
}).catch((y) => {
|
|
1882
|
+
d || p({
|
|
1432
1883
|
collector: null,
|
|
1433
1884
|
loading: !1,
|
|
1434
|
-
error:
|
|
1885
|
+
error: y instanceof Error ? y : new Error(String(y))
|
|
1435
1886
|
});
|
|
1436
1887
|
}), () => {
|
|
1437
|
-
|
|
1888
|
+
d = !0;
|
|
1438
1889
|
};
|
|
1439
1890
|
}, [
|
|
1440
|
-
|
|
1891
|
+
o,
|
|
1441
1892
|
t,
|
|
1442
1893
|
e.name,
|
|
1443
1894
|
s,
|
|
1444
|
-
|
|
1895
|
+
i,
|
|
1445
1896
|
e.autoSubmit
|
|
1446
1897
|
]);
|
|
1447
|
-
const
|
|
1448
|
-
|
|
1449
|
-
if (
|
|
1450
|
-
return
|
|
1451
|
-
}, [
|
|
1452
|
-
const
|
|
1898
|
+
const f = t ? l : c.collector, k = t ? !1 : c.loading, _ = t ? null : c.error;
|
|
1899
|
+
N(() => {
|
|
1900
|
+
if (f)
|
|
1901
|
+
return f.install(o);
|
|
1902
|
+
}, [o, f]);
|
|
1903
|
+
const C = H(() => Me({
|
|
1453
1904
|
values: e.initialValues ?? {},
|
|
1454
1905
|
submitted: !1
|
|
1455
|
-
}), [
|
|
1456
|
-
...
|
|
1906
|
+
}), [i]), I = It(f?.store ?? C), u = H(() => f?.getStatus() ?? de, [I, f]), A = H(() => ({
|
|
1907
|
+
...I,
|
|
1457
1908
|
...u
|
|
1458
|
-
}), [
|
|
1909
|
+
}), [I, u]), b = H(() => ({
|
|
1459
1910
|
name: e.name,
|
|
1460
|
-
store:
|
|
1911
|
+
store: C,
|
|
1461
1912
|
functions: [],
|
|
1462
1913
|
contextKey: `form:${e.name}`,
|
|
1463
1914
|
contextProvider: () => ({
|
|
@@ -1478,45 +1929,46 @@ function ot(e) {
|
|
|
1478
1929
|
ok: !1,
|
|
1479
1930
|
error: "Form definition not loaded yet."
|
|
1480
1931
|
}),
|
|
1481
|
-
getValues: () =>
|
|
1932
|
+
getValues: () => C.get().values,
|
|
1482
1933
|
setValues: () => {
|
|
1483
1934
|
},
|
|
1484
1935
|
reset: () => {
|
|
1485
1936
|
},
|
|
1486
|
-
getStatus: () =>
|
|
1487
|
-
}), [e.name,
|
|
1937
|
+
getStatus: () => de
|
|
1938
|
+
}), [e.name, C]);
|
|
1488
1939
|
return {
|
|
1489
|
-
...
|
|
1490
|
-
state:
|
|
1491
|
-
loading:
|
|
1492
|
-
error:
|
|
1940
|
+
...f ?? b,
|
|
1941
|
+
state: A,
|
|
1942
|
+
loading: k,
|
|
1943
|
+
error: _
|
|
1493
1944
|
};
|
|
1494
1945
|
}
|
|
1495
1946
|
export {
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1947
|
+
Bt as AgoNudge,
|
|
1948
|
+
Lt as AgoProvider,
|
|
1949
|
+
rt as ChatInput,
|
|
1950
|
+
Ht as ChatWidget,
|
|
1951
|
+
bt as Markdown,
|
|
1952
|
+
kt as Message,
|
|
1953
|
+
pe as createFormCollector,
|
|
1954
|
+
Tt as createMockClient,
|
|
1955
|
+
Et as deriveFormStatus,
|
|
1956
|
+
ue as loadFormCollector,
|
|
1957
|
+
Ge as useAgo,
|
|
1958
|
+
Xe as useAgoActivity,
|
|
1959
|
+
Ut as useAgoActivityLog,
|
|
1960
|
+
Kt as useAgoAutoContinueAfterNavigation,
|
|
1961
|
+
$ as useAgoClient,
|
|
1962
|
+
Gt as useAgoContext,
|
|
1963
|
+
jt as useAgoFunction,
|
|
1964
|
+
$t as useAgoNavigation,
|
|
1965
|
+
qt as useAgoPageState,
|
|
1966
|
+
It as useAgoStore,
|
|
1967
|
+
Ot as useChat,
|
|
1968
|
+
At as useConversation,
|
|
1969
|
+
Jt as useFormCollector,
|
|
1970
|
+
xe as useMessages,
|
|
1971
|
+
O as useOptionalAgoClient,
|
|
1972
|
+
St as useProactiveNudge,
|
|
1973
|
+
et as useSheet
|
|
1522
1974
|
};
|