@useago/sdk 1.4.4 → 1.5.2
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 +63 -1
- package/dist/AgoClient-5VGybmvz.cjs +8 -0
- package/dist/AgoClient-DXrH2AMi.js +964 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +124 -5
- package/dist/angular.d.ts +124 -5
- package/dist/angular.js +5 -1
- package/dist/autoContinue-CC8K9mBU.js +63 -0
- package/dist/autoContinue-CP9pJR-V.cjs +1 -0
- package/dist/{createConversationSession-CUkNp6mZ.cjs → createConversationSession-0WTqcCLK.cjs} +1 -1
- package/dist/{createConversationSession-QIBN0gLx.js → createConversationSession-DPrrr70o.js} +1 -1
- package/dist/createFormCollector-1GKKwQV_.cjs +1 -0
- package/dist/{createFormCollector-F3YJfsbg.js → createFormCollector-DYh90kiG.js} +97 -91
- package/dist/devtools.d.cts +82 -5
- package/dist/devtools.d.ts +82 -5
- package/dist/functions-CPs7omgM.cjs +1 -0
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.d.cts +5 -0
- package/dist/helpers.d.ts +5 -0
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +147 -7
- package/dist/index.d.ts +147 -7
- package/dist/index.js +45 -43
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +191 -21
- package/dist/react.d.ts +191 -21
- package/dist/react.js +666 -529
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +82 -5
- package/dist/testing.d.ts +82 -5
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +82 -5
- package/dist/vue.d.ts +82 -5
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +82 -5
- package/dist/widget.d.ts +82 -5
- package/dist/widget.js +437 -423
- package/llms-full.txt +100 -6
- package/package.json +1 -1
- package/dist/AgoClient-CLmtYTJx.cjs +0 -8
- package/dist/AgoClient-Ozz2b1dQ.js +0 -912
- package/dist/createFormCollector-DHT1ObOb.cjs +0 -1
- package/dist/functions-Djnq-JAo.cjs +0 -1
- package/dist/rolldown-runtime-16Nf8qvH.cjs +0 -1
- /package/dist/{createMockClient-BSr-UV8R.cjs → createMockClient-C-wrjb2C.cjs} +0 -0
- /package/dist/{createMockClient-bAZ9KBHC.js → createMockClient-we-XoPom.js} +0 -0
- /package/dist/{functions-CApuQZ2b.js → functions-tzyOZNp6.js} +0 -0
package/dist/react.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { a as V, i as Y, m as X, o as Z, s as Q, t as ee } from "./AgoClient-DXrH2AMi.js";
|
|
2
|
+
import { t as te } from "./autoContinue-CC8K9mBU.js";
|
|
3
|
+
import { i as ne, n as He, r as O, t as j } from "./createFormCollector-DYh90kiG.js";
|
|
4
|
+
import { t as qe } from "./createMockClient-we-XoPom.js";
|
|
5
|
+
import re, { createContext as oe, useCallback as R, useContext as B, useEffect as N, useId as ae, useMemo as D, useRef as T, useState as E, useSyncExternalStore as se } from "react";
|
|
6
|
+
import { Fragment as G, jsx as l, jsxs as F } from "react/jsx-runtime";
|
|
7
|
+
import ie from "react-markdown";
|
|
8
|
+
import le from "remark-gfm";
|
|
9
|
+
function ce(e) {
|
|
10
|
+
const [t, r] = E(!1), o = T(null), n = D(() => {
|
|
11
|
+
if (o.current && (o.current.destroy(), o.current = null), !e) return null;
|
|
12
|
+
const s = new ee(e);
|
|
13
|
+
return o.current = s, s;
|
|
13
14
|
}, [e?.baseUrl, e?.widgetId]);
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
}), [
|
|
17
|
-
|
|
15
|
+
return N(() => (r(!0), () => {
|
|
16
|
+
o.current?.destroy(), o.current = null;
|
|
17
|
+
}), [n]), N(() => {
|
|
18
|
+
o.current && e && o.current.updateConfig({
|
|
18
19
|
agent: e.agent,
|
|
19
20
|
defaultAgentId: e.defaultAgentId,
|
|
20
21
|
permission: e.permission,
|
|
@@ -32,139 +33,139 @@ function ae(e) {
|
|
|
32
33
|
e?.debug,
|
|
33
34
|
e?.warnOnEmptyReply
|
|
34
35
|
]), {
|
|
35
|
-
client:
|
|
36
|
-
isReady:
|
|
36
|
+
client: n,
|
|
37
|
+
isReady: t
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
|
-
var
|
|
40
|
-
const { client:
|
|
41
|
-
return
|
|
40
|
+
var z = oe(null), Ke = ({ children: e, client: t, tools: r, helpers: o, pageContext: n, ...s }) => {
|
|
41
|
+
const { client: f } = ce(t ? null : s), i = t || f;
|
|
42
|
+
return N(() => {
|
|
42
43
|
if (!(!r || r.length === 0)) {
|
|
43
|
-
for (const
|
|
44
|
+
for (const m of r) i.register(m);
|
|
44
45
|
return () => {
|
|
45
|
-
for (const
|
|
46
|
+
for (const m of r) i.unregisterFunction(m.name);
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
|
-
}, [
|
|
49
|
-
if (!
|
|
50
|
-
const
|
|
51
|
-
return import("./functions-
|
|
52
|
-
for (const [
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
55
|
-
console.warn(`[AGO] Unknown helper: "${
|
|
49
|
+
}, [i, r]), N(() => {
|
|
50
|
+
if (!o) return;
|
|
51
|
+
const m = [];
|
|
52
|
+
return import("./functions-tzyOZNp6.js").then((u) => u.n).then((u) => {
|
|
53
|
+
for (const [g, C] of Object.entries(o)) {
|
|
54
|
+
const A = u[g];
|
|
55
|
+
if (!A) {
|
|
56
|
+
console.warn(`[AGO] Unknown helper: "${g}"`);
|
|
56
57
|
continue;
|
|
57
58
|
}
|
|
58
|
-
const
|
|
59
|
-
...
|
|
60
|
-
handler:
|
|
59
|
+
const S = C === !0 ? A : {
|
|
60
|
+
...A,
|
|
61
|
+
handler: C
|
|
61
62
|
};
|
|
62
|
-
|
|
63
|
+
i.register(S), m.push(S.name);
|
|
63
64
|
}
|
|
64
65
|
}), () => {
|
|
65
|
-
for (const
|
|
66
|
+
for (const u of m) i.unregisterFunction(u);
|
|
66
67
|
};
|
|
67
|
-
}, [
|
|
68
|
-
|
|
69
|
-
}, [
|
|
70
|
-
value:
|
|
68
|
+
}, [i, o]), N(() => {
|
|
69
|
+
n === "auto" && i.enableAutoPageContext();
|
|
70
|
+
}, [i, n]), /* @__PURE__ */ l(z.Provider, {
|
|
71
|
+
value: i,
|
|
71
72
|
children: e
|
|
72
73
|
});
|
|
73
74
|
};
|
|
74
|
-
function
|
|
75
|
-
const e = B(
|
|
75
|
+
function W() {
|
|
76
|
+
const e = B(z);
|
|
76
77
|
if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
|
|
77
78
|
return e;
|
|
78
79
|
}
|
|
79
|
-
function
|
|
80
|
-
return B(
|
|
80
|
+
function L() {
|
|
81
|
+
return B(z);
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
-
const r =
|
|
84
|
-
if (!
|
|
85
|
-
const [
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}, [
|
|
89
|
-
const
|
|
83
|
+
function K({ client: e, conversationId: t } = {}) {
|
|
84
|
+
const r = L(), o = e || r;
|
|
85
|
+
if (!o) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
86
|
+
const [n, s] = E([]), [f, i] = E(t), [m, u] = E(!1), [g, C] = E(null);
|
|
87
|
+
N(() => {
|
|
88
|
+
t && t !== f && (i(t), A(t));
|
|
89
|
+
}, [t]);
|
|
90
|
+
const A = async (S) => {
|
|
90
91
|
try {
|
|
91
|
-
s((await
|
|
92
|
-
} catch (
|
|
93
|
-
|
|
92
|
+
s((await o.getMessages(S)).filter((k) => !k.hidden));
|
|
93
|
+
} catch (k) {
|
|
94
|
+
C(k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to load messages"));
|
|
94
95
|
}
|
|
95
96
|
};
|
|
96
|
-
return
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
return
|
|
101
|
-
...
|
|
97
|
+
return N(() => {
|
|
98
|
+
const S = (c) => c === "IN_PROGRESS" || c === "WAITING_CLIENT", k = (c) => {
|
|
99
|
+
f || i(c.conversationId), u(!0), s((h) => {
|
|
100
|
+
const w = h.findIndex((b) => b.id === c.messageId);
|
|
101
|
+
return w >= 0 ? h.map((b, _) => _ === w ? {
|
|
102
|
+
...b,
|
|
102
103
|
status: "IN_PROGRESS"
|
|
103
|
-
} :
|
|
104
|
-
id:
|
|
105
|
-
conversationId:
|
|
104
|
+
} : b) : h.some((b) => b.role === "assistant" && S(b.status)) ? h : [...h, {
|
|
105
|
+
id: c.messageId,
|
|
106
|
+
conversationId: c.conversationId,
|
|
106
107
|
content: "",
|
|
107
108
|
role: "assistant",
|
|
108
109
|
status: "IN_PROGRESS",
|
|
109
110
|
createdAt: /* @__PURE__ */ new Date()
|
|
110
111
|
}];
|
|
111
112
|
});
|
|
112
|
-
},
|
|
113
|
-
s((
|
|
114
|
-
const
|
|
115
|
-
return
|
|
116
|
-
...
|
|
117
|
-
content:
|
|
118
|
-
} :
|
|
113
|
+
}, d = (c) => {
|
|
114
|
+
s((h) => {
|
|
115
|
+
const w = h.findIndex((b) => b.id === c.messageId);
|
|
116
|
+
return w < 0 ? h : h.map((b, _) => _ === w ? {
|
|
117
|
+
...b,
|
|
118
|
+
content: b.content + c.content
|
|
119
|
+
} : b);
|
|
119
120
|
});
|
|
120
|
-
},
|
|
121
|
-
s((
|
|
122
|
-
let
|
|
123
|
-
for (let
|
|
124
|
-
|
|
121
|
+
}, x = (c) => {
|
|
122
|
+
s((h) => {
|
|
123
|
+
let w = -1;
|
|
124
|
+
for (let b = h.length - 1; b >= 0; b--) if (h[b].role === "assistant" && S(h[b].status)) {
|
|
125
|
+
w = b;
|
|
125
126
|
break;
|
|
126
127
|
}
|
|
127
|
-
return
|
|
128
|
-
...
|
|
128
|
+
return w < 0 ? h : [
|
|
129
|
+
...h.slice(0, w),
|
|
129
130
|
{
|
|
130
|
-
...
|
|
131
|
-
...
|
|
131
|
+
...h[w],
|
|
132
|
+
...c
|
|
132
133
|
},
|
|
133
|
-
...
|
|
134
|
+
...h.slice(w + 1)
|
|
134
135
|
];
|
|
135
136
|
});
|
|
136
|
-
}, a = (
|
|
137
|
-
s((
|
|
138
|
-
const
|
|
139
|
-
return
|
|
140
|
-
...
|
|
141
|
-
|
|
142
|
-
...
|
|
143
|
-
] : [...
|
|
144
|
-
}),
|
|
145
|
-
},
|
|
146
|
-
|
|
137
|
+
}, a = (c) => {
|
|
138
|
+
s((h) => {
|
|
139
|
+
const w = h.findIndex((b) => b.id === c.id);
|
|
140
|
+
return w >= 0 ? [
|
|
141
|
+
...h.slice(0, w),
|
|
142
|
+
c,
|
|
143
|
+
...h.slice(w + 1)
|
|
144
|
+
] : [...h, c];
|
|
145
|
+
}), u(!1);
|
|
146
|
+
}, v = (c) => {
|
|
147
|
+
C(new Error(c.error)), u(!1);
|
|
147
148
|
};
|
|
148
|
-
return
|
|
149
|
-
|
|
149
|
+
return o.on("message:start", k), o.on("message:chunk", d), o.on("message:answer-complete", x), o.on("message:complete", a), o.on("message:error", v), () => {
|
|
150
|
+
o.off("message:start", k), o.off("message:chunk", d), o.off("message:answer-complete", x), o.off("message:complete", a), o.off("message:error", v);
|
|
150
151
|
};
|
|
151
|
-
}, [
|
|
152
|
-
messages:
|
|
153
|
-
isLoading:
|
|
154
|
-
error:
|
|
155
|
-
sendMessage:
|
|
156
|
-
|
|
157
|
-
const
|
|
152
|
+
}, [o, f]), {
|
|
153
|
+
messages: n,
|
|
154
|
+
isLoading: m,
|
|
155
|
+
error: g,
|
|
156
|
+
sendMessage: R(async (S, k) => {
|
|
157
|
+
u(!0), C(null);
|
|
158
|
+
const d = {
|
|
158
159
|
id: `temp-${Date.now()}`,
|
|
159
|
-
conversationId:
|
|
160
|
-
content:
|
|
160
|
+
conversationId: f || "",
|
|
161
|
+
content: S,
|
|
161
162
|
role: "user",
|
|
162
163
|
status: "DONE",
|
|
163
|
-
attachments:
|
|
164
|
+
attachments: k && k.length > 0 ? Y(k) : void 0,
|
|
164
165
|
createdAt: /* @__PURE__ */ new Date()
|
|
165
|
-
},
|
|
166
|
+
}, x = {
|
|
166
167
|
id: `temp-assistant-${Date.now()}`,
|
|
167
|
-
conversationId:
|
|
168
|
+
conversationId: f || "",
|
|
168
169
|
content: "",
|
|
169
170
|
role: "assistant",
|
|
170
171
|
status: "IN_PROGRESS",
|
|
@@ -172,60 +173,60 @@ function U({ client: e, conversationId: n } = {}) {
|
|
|
172
173
|
};
|
|
173
174
|
s((a) => [
|
|
174
175
|
...a,
|
|
175
|
-
|
|
176
|
-
|
|
176
|
+
d,
|
|
177
|
+
x
|
|
177
178
|
]);
|
|
178
179
|
try {
|
|
179
|
-
const a = await
|
|
180
|
-
conversationId:
|
|
181
|
-
files:
|
|
180
|
+
const a = await o.sendMessage(S, {
|
|
181
|
+
conversationId: f,
|
|
182
|
+
files: k
|
|
182
183
|
});
|
|
183
|
-
return a.conversationId && !
|
|
184
|
-
const
|
|
185
|
-
...
|
|
186
|
-
id:
|
|
184
|
+
return a.conversationId && !f && i(a.conversationId), s((v) => {
|
|
185
|
+
const c = v.filter((w) => !w.id.startsWith("temp-")), h = {
|
|
186
|
+
...d,
|
|
187
|
+
id: d.id.replace("temp-", "user-"),
|
|
187
188
|
conversationId: a.conversationId
|
|
188
189
|
};
|
|
189
|
-
return
|
|
190
|
-
...
|
|
191
|
-
|
|
190
|
+
return c.some((w) => w.id === a.id) ? [...c, h].sort((w, b) => new Date(w.createdAt).getTime() - new Date(b.createdAt).getTime()) : [
|
|
191
|
+
...c,
|
|
192
|
+
h,
|
|
192
193
|
a
|
|
193
194
|
];
|
|
194
195
|
}), a;
|
|
195
196
|
} catch (a) {
|
|
196
|
-
return
|
|
197
|
+
return C(a instanceof Error ? a : /* @__PURE__ */ new Error("Failed to send message")), u(!1), s((v) => v.filter((c) => !c.id.startsWith("temp-"))), null;
|
|
197
198
|
}
|
|
198
|
-
}, [
|
|
199
|
-
clearMessages:
|
|
200
|
-
s([]),
|
|
199
|
+
}, [o, f]),
|
|
200
|
+
clearMessages: R(() => {
|
|
201
|
+
s([]), i(void 0), C(null);
|
|
201
202
|
}, []),
|
|
202
|
-
conversationId:
|
|
203
|
+
conversationId: f
|
|
203
204
|
};
|
|
204
205
|
}
|
|
205
|
-
var
|
|
206
|
-
const [s,
|
|
207
|
-
const a =
|
|
206
|
+
var de = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", allowFiles: o = !1, className: n = "" }) => {
|
|
207
|
+
const [s, f] = E(""), [i, m] = E([]), u = T(null), g = T(null), C = R(() => {
|
|
208
|
+
const a = g.current;
|
|
208
209
|
if (!a) return;
|
|
209
|
-
const
|
|
210
|
-
a.style.height = "auto", a.style.height = `${Math.min(a.scrollHeight + 2,
|
|
211
|
-
}, []),
|
|
212
|
-
a.preventDefault(), (s.trim() ||
|
|
210
|
+
const v = 110;
|
|
211
|
+
a.style.height = "auto", a.style.height = `${Math.min(a.scrollHeight + 2, v)}px`, a.style.overflowY = a.scrollHeight + 2 > v ? "auto" : "hidden";
|
|
212
|
+
}, []), A = R((a) => {
|
|
213
|
+
a.preventDefault(), (s.trim() || i.length > 0) && (e(s.trim(), i.length > 0 ? i : void 0), f(""), m([]), requestAnimationFrame(C));
|
|
213
214
|
}, [
|
|
214
215
|
s,
|
|
215
|
-
|
|
216
|
+
i,
|
|
216
217
|
e,
|
|
217
|
-
|
|
218
|
-
]),
|
|
219
|
-
a.key === "Enter" && !a.shiftKey && (a.preventDefault(),
|
|
220
|
-
}, [
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
}, []),
|
|
224
|
-
|
|
225
|
-
}, []),
|
|
226
|
-
return /* @__PURE__ */
|
|
227
|
-
onSubmit:
|
|
228
|
-
className: `ago-chat-input ${
|
|
218
|
+
C
|
|
219
|
+
]), S = R((a) => {
|
|
220
|
+
a.key === "Enter" && !a.shiftKey && (a.preventDefault(), A(a));
|
|
221
|
+
}, [A]), k = R((a) => {
|
|
222
|
+
const v = Array.from(a.target.files || []);
|
|
223
|
+
m((c) => [...c, ...v]);
|
|
224
|
+
}, []), d = R((a) => {
|
|
225
|
+
m((v) => v.filter((c, h) => h !== a));
|
|
226
|
+
}, []), x = s.trim() || i.length > 0;
|
|
227
|
+
return /* @__PURE__ */ F("form", {
|
|
228
|
+
onSubmit: A,
|
|
229
|
+
className: `ago-chat-input ${n}`,
|
|
229
230
|
style: {
|
|
230
231
|
display: "flex",
|
|
231
232
|
flexDirection: "column",
|
|
@@ -234,14 +235,14 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
234
235
|
borderTop: "1px solid #dee3e8",
|
|
235
236
|
backgroundColor: "#fff"
|
|
236
237
|
},
|
|
237
|
-
children: [
|
|
238
|
+
children: [i.length > 0 && /* @__PURE__ */ l("div", {
|
|
238
239
|
className: "ago-chat-input__files",
|
|
239
240
|
style: {
|
|
240
241
|
display: "flex",
|
|
241
242
|
flexWrap: "wrap",
|
|
242
243
|
gap: "6px"
|
|
243
244
|
},
|
|
244
|
-
children:
|
|
245
|
+
children: i.map((a, v) => /* @__PURE__ */ F("div", {
|
|
245
246
|
style: {
|
|
246
247
|
display: "flex",
|
|
247
248
|
alignItems: "center",
|
|
@@ -252,7 +253,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
252
253
|
fontSize: "12px",
|
|
253
254
|
color: "#30373e"
|
|
254
255
|
},
|
|
255
|
-
children: [/* @__PURE__ */
|
|
256
|
+
children: [/* @__PURE__ */ l("span", {
|
|
256
257
|
style: {
|
|
257
258
|
maxWidth: "120px",
|
|
258
259
|
overflow: "hidden",
|
|
@@ -260,9 +261,9 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
260
261
|
whiteSpace: "nowrap"
|
|
261
262
|
},
|
|
262
263
|
children: a.name
|
|
263
|
-
}), /* @__PURE__ */
|
|
264
|
+
}), /* @__PURE__ */ l("button", {
|
|
264
265
|
type: "button",
|
|
265
|
-
onClick: () =>
|
|
266
|
+
onClick: () => d(v),
|
|
266
267
|
"aria-label": `Remove ${a.name}`,
|
|
267
268
|
style: {
|
|
268
269
|
border: "none",
|
|
@@ -275,47 +276,47 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
275
276
|
},
|
|
276
277
|
children: "×"
|
|
277
278
|
})]
|
|
278
|
-
},
|
|
279
|
-
}), /* @__PURE__ */
|
|
279
|
+
}, v))
|
|
280
|
+
}), /* @__PURE__ */ F("div", {
|
|
280
281
|
style: {
|
|
281
282
|
display: "flex",
|
|
282
283
|
gap: "8px",
|
|
283
284
|
alignItems: "flex-end"
|
|
284
285
|
},
|
|
285
286
|
children: [
|
|
286
|
-
|
|
287
|
+
o && /* @__PURE__ */ F(G, { children: [/* @__PURE__ */ l("button", {
|
|
287
288
|
type: "button",
|
|
288
|
-
onClick: () =>
|
|
289
|
-
disabled:
|
|
289
|
+
onClick: () => u.current?.click(),
|
|
290
|
+
disabled: t,
|
|
290
291
|
"aria-label": "Attach file",
|
|
291
292
|
style: {
|
|
292
293
|
padding: "8px",
|
|
293
294
|
border: "1px solid #dee3e8",
|
|
294
295
|
borderRadius: "8px",
|
|
295
296
|
backgroundColor: "#fff",
|
|
296
|
-
cursor:
|
|
297
|
+
cursor: t ? "not-allowed" : "pointer",
|
|
297
298
|
color: "#6b6d6f",
|
|
298
299
|
fontSize: "16px",
|
|
299
300
|
lineHeight: 1
|
|
300
301
|
},
|
|
301
302
|
children: "+"
|
|
302
|
-
}), /* @__PURE__ */
|
|
303
|
-
ref:
|
|
303
|
+
}), /* @__PURE__ */ l("input", {
|
|
304
|
+
ref: u,
|
|
304
305
|
type: "file",
|
|
305
306
|
multiple: !0,
|
|
306
|
-
onChange:
|
|
307
|
+
onChange: k,
|
|
307
308
|
style: { display: "none" }
|
|
308
309
|
})] }),
|
|
309
|
-
/* @__PURE__ */
|
|
310
|
-
ref:
|
|
310
|
+
/* @__PURE__ */ l("textarea", {
|
|
311
|
+
ref: g,
|
|
311
312
|
value: s,
|
|
312
313
|
onChange: (a) => {
|
|
313
|
-
|
|
314
|
+
f(a.target.value), C();
|
|
314
315
|
},
|
|
315
|
-
onKeyDown:
|
|
316
|
+
onKeyDown: S,
|
|
316
317
|
placeholder: r,
|
|
317
318
|
"aria-label": r,
|
|
318
|
-
disabled:
|
|
319
|
+
disabled: t,
|
|
319
320
|
rows: 1,
|
|
320
321
|
style: {
|
|
321
322
|
flex: 1,
|
|
@@ -341,16 +342,16 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
341
342
|
a.currentTarget.style.borderColor = "#dee3e8";
|
|
342
343
|
}
|
|
343
344
|
}),
|
|
344
|
-
/* @__PURE__ */
|
|
345
|
+
/* @__PURE__ */ l("button", {
|
|
345
346
|
type: "submit",
|
|
346
|
-
disabled:
|
|
347
|
+
disabled: t || !x,
|
|
347
348
|
style: {
|
|
348
349
|
padding: "10px 18px",
|
|
349
350
|
border: "none",
|
|
350
351
|
borderRadius: "20px",
|
|
351
|
-
backgroundColor:
|
|
352
|
+
backgroundColor: t || !x ? "#b5bfc8" : "#03182f",
|
|
352
353
|
color: "#fff",
|
|
353
|
-
cursor:
|
|
354
|
+
cursor: t || !x ? "not-allowed" : "pointer",
|
|
354
355
|
fontWeight: 500,
|
|
355
356
|
fontSize: "16px",
|
|
356
357
|
transition: "background-color 0.15s"
|
|
@@ -360,7 +361,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
360
361
|
]
|
|
361
362
|
})]
|
|
362
363
|
});
|
|
363
|
-
},
|
|
364
|
+
}, ue = ({ href: e, children: t, ...r }) => /* @__PURE__ */ l("a", {
|
|
364
365
|
href: e,
|
|
365
366
|
target: "_blank",
|
|
366
367
|
rel: "noopener noreferrer",
|
|
@@ -369,53 +370,53 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
369
370
|
textDecoration: "underline"
|
|
370
371
|
},
|
|
371
372
|
...r,
|
|
372
|
-
children:
|
|
373
|
-
}),
|
|
373
|
+
children: t
|
|
374
|
+
}), fe = ({ children: e, ...t }) => /* @__PURE__ */ l("p", {
|
|
374
375
|
style: {
|
|
375
376
|
margin: "0 0 8px 0",
|
|
376
377
|
lineHeight: "1.6"
|
|
377
378
|
},
|
|
378
|
-
...
|
|
379
|
+
...t,
|
|
379
380
|
children: e
|
|
380
|
-
}), P = (e,
|
|
381
|
-
const r = ({ children:
|
|
381
|
+
}), P = (e, t) => {
|
|
382
|
+
const r = ({ children: o, ...n }) => re.createElement(`h${e}`, {
|
|
382
383
|
style: {
|
|
383
384
|
margin: "16px 0 8px 0",
|
|
384
|
-
fontSize:
|
|
385
|
+
fontSize: t,
|
|
385
386
|
fontWeight: 600,
|
|
386
387
|
lineHeight: "1.3"
|
|
387
388
|
},
|
|
388
|
-
...
|
|
389
|
-
},
|
|
389
|
+
...n
|
|
390
|
+
}, o);
|
|
390
391
|
return r.displayName = `MarkdownHeading${e}`, r;
|
|
391
|
-
},
|
|
392
|
+
}, pe = ({ children: e, ...t }) => /* @__PURE__ */ l("ul", {
|
|
392
393
|
style: {
|
|
393
394
|
margin: "0 0 8px 0",
|
|
394
395
|
paddingLeft: "20px",
|
|
395
396
|
listStyleType: "disc",
|
|
396
397
|
listStylePosition: "outside"
|
|
397
398
|
},
|
|
398
|
-
...
|
|
399
|
+
...t,
|
|
399
400
|
children: e
|
|
400
|
-
}),
|
|
401
|
+
}), ge = ({ children: e, ...t }) => /* @__PURE__ */ l("ol", {
|
|
401
402
|
style: {
|
|
402
403
|
margin: "0 0 8px 0",
|
|
403
404
|
paddingLeft: "20px",
|
|
404
405
|
listStyleType: "decimal",
|
|
405
406
|
listStylePosition: "outside"
|
|
406
407
|
},
|
|
407
|
-
...
|
|
408
|
+
...t,
|
|
408
409
|
children: e
|
|
409
|
-
}),
|
|
410
|
+
}), me = ({ children: e, ...t }) => /* @__PURE__ */ l("li", {
|
|
410
411
|
style: {
|
|
411
412
|
display: "list-item",
|
|
412
413
|
margin: "2px 0",
|
|
413
414
|
lineHeight: "1.6"
|
|
414
415
|
},
|
|
415
|
-
...
|
|
416
|
+
...t,
|
|
416
417
|
children: e
|
|
417
|
-
}),
|
|
418
|
-
`) ? /* @__PURE__ */
|
|
418
|
+
}), xe = ({ className: e, children: t, ...r }) => e !== void 0 || String(t).includes(`
|
|
419
|
+
`) ? /* @__PURE__ */ l("code", {
|
|
419
420
|
style: {
|
|
420
421
|
display: "block",
|
|
421
422
|
background: "#f5f5f5",
|
|
@@ -426,8 +427,8 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
426
427
|
fontFamily: '"IBM Plex Mono", monospace'
|
|
427
428
|
},
|
|
428
429
|
...r,
|
|
429
|
-
children:
|
|
430
|
-
}) : /* @__PURE__ */
|
|
430
|
+
children: t
|
|
431
|
+
}) : /* @__PURE__ */ l("code", {
|
|
431
432
|
style: {
|
|
432
433
|
background: "#f0f2f5",
|
|
433
434
|
padding: "2px 5px",
|
|
@@ -436,12 +437,12 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
436
437
|
fontFamily: '"IBM Plex Mono", monospace'
|
|
437
438
|
},
|
|
438
439
|
...r,
|
|
439
|
-
children:
|
|
440
|
-
}),
|
|
440
|
+
children: t
|
|
441
|
+
}), he = ({ children: e, ...t }) => /* @__PURE__ */ l("pre", {
|
|
441
442
|
style: { margin: "0 0 8px 0" },
|
|
442
|
-
...
|
|
443
|
+
...t,
|
|
443
444
|
children: e
|
|
444
|
-
}),
|
|
445
|
+
}), ye = ({ children: e, ...t }) => /* @__PURE__ */ l("blockquote", {
|
|
445
446
|
style: {
|
|
446
447
|
borderLeft: "4px solid #dee3e8",
|
|
447
448
|
paddingLeft: "12px",
|
|
@@ -449,23 +450,23 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
449
450
|
fontStyle: "italic",
|
|
450
451
|
color: "#6b6d6f"
|
|
451
452
|
},
|
|
452
|
-
...
|
|
453
|
+
...t,
|
|
453
454
|
children: e
|
|
454
|
-
}),
|
|
455
|
+
}), ve = ({ children: e, ...t }) => /* @__PURE__ */ l("div", {
|
|
455
456
|
style: {
|
|
456
457
|
overflowX: "auto",
|
|
457
458
|
margin: "0 0 8px 0"
|
|
458
459
|
},
|
|
459
|
-
children: /* @__PURE__ */
|
|
460
|
+
children: /* @__PURE__ */ l("table", {
|
|
460
461
|
style: {
|
|
461
462
|
borderCollapse: "collapse",
|
|
462
463
|
width: "100%",
|
|
463
464
|
fontSize: "13px"
|
|
464
465
|
},
|
|
465
|
-
...
|
|
466
|
+
...t,
|
|
466
467
|
children: e
|
|
467
468
|
})
|
|
468
|
-
}),
|
|
469
|
+
}), be = ({ children: e, ...t }) => /* @__PURE__ */ l("th", {
|
|
469
470
|
style: {
|
|
470
471
|
border: "1px solid #dee3e8",
|
|
471
472
|
padding: "6px 10px",
|
|
@@ -473,57 +474,57 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
473
474
|
backgroundColor: "#f5f7fa",
|
|
474
475
|
fontWeight: 600
|
|
475
476
|
},
|
|
476
|
-
...
|
|
477
|
+
...t,
|
|
477
478
|
children: e
|
|
478
|
-
}),
|
|
479
|
+
}), we = ({ children: e, ...t }) => /* @__PURE__ */ l("td", {
|
|
479
480
|
style: {
|
|
480
481
|
border: "1px solid #dee3e8",
|
|
481
482
|
padding: "6px 10px"
|
|
482
483
|
},
|
|
483
|
-
...
|
|
484
|
+
...t,
|
|
484
485
|
children: e
|
|
485
|
-
}),
|
|
486
|
+
}), Ce = ({ alt: e, ...t }) => /* @__PURE__ */ l("img", {
|
|
486
487
|
alt: e ?? "",
|
|
487
488
|
style: {
|
|
488
489
|
maxWidth: "100%",
|
|
489
490
|
borderRadius: "8px",
|
|
490
491
|
margin: "4px 0"
|
|
491
492
|
},
|
|
492
|
-
...
|
|
493
|
-
}),
|
|
493
|
+
...t
|
|
494
|
+
}), Se = (e) => /* @__PURE__ */ l("hr", {
|
|
494
495
|
style: {
|
|
495
496
|
border: "none",
|
|
496
497
|
borderTop: "1px solid #dee3e8",
|
|
497
498
|
margin: "12px 0"
|
|
498
499
|
},
|
|
499
500
|
...e
|
|
500
|
-
}),
|
|
501
|
-
a:
|
|
502
|
-
p:
|
|
501
|
+
}), ke = {
|
|
502
|
+
a: ue,
|
|
503
|
+
p: fe,
|
|
503
504
|
h1: P(1, "20px"),
|
|
504
505
|
h2: P(2, "18px"),
|
|
505
506
|
h3: P(3, "16px"),
|
|
506
507
|
h4: P(4, "15px"),
|
|
507
508
|
h5: P(5, "14px"),
|
|
508
509
|
h6: P(6, "13px"),
|
|
509
|
-
ul:
|
|
510
|
-
ol:
|
|
511
|
-
li:
|
|
512
|
-
code:
|
|
513
|
-
pre:
|
|
514
|
-
blockquote:
|
|
515
|
-
table:
|
|
516
|
-
th:
|
|
517
|
-
td:
|
|
518
|
-
img:
|
|
519
|
-
hr:
|
|
520
|
-
},
|
|
521
|
-
remarkPlugins:
|
|
522
|
-
components:
|
|
510
|
+
ul: pe,
|
|
511
|
+
ol: ge,
|
|
512
|
+
li: me,
|
|
513
|
+
code: xe,
|
|
514
|
+
pre: he,
|
|
515
|
+
blockquote: ye,
|
|
516
|
+
table: ve,
|
|
517
|
+
th: be,
|
|
518
|
+
td: we,
|
|
519
|
+
img: Ce,
|
|
520
|
+
hr: Se
|
|
521
|
+
}, Ie = [le], Ae = ({ content: e }) => /* @__PURE__ */ l(ie, {
|
|
522
|
+
remarkPlugins: Ie,
|
|
523
|
+
components: ke,
|
|
523
524
|
children: e
|
|
524
|
-
}),
|
|
525
|
-
const r =
|
|
526
|
-
if (
|
|
525
|
+
}), Ne = ({ attachment: e, isUser: t }) => {
|
|
526
|
+
const r = Q(e.url);
|
|
527
|
+
if (V(e)) return /* @__PURE__ */ l("a", {
|
|
527
528
|
href: r,
|
|
528
529
|
target: "_blank",
|
|
529
530
|
rel: "noopener noreferrer",
|
|
@@ -531,7 +532,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
531
532
|
display: "inline-block",
|
|
532
533
|
textDecoration: "none"
|
|
533
534
|
},
|
|
534
|
-
children: /* @__PURE__ */
|
|
535
|
+
children: /* @__PURE__ */ l("img", {
|
|
535
536
|
src: r,
|
|
536
537
|
alt: e.name,
|
|
537
538
|
loading: "lazy",
|
|
@@ -545,7 +546,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
545
546
|
}
|
|
546
547
|
})
|
|
547
548
|
});
|
|
548
|
-
const
|
|
549
|
+
const o = Z(e.fileSize), n = /* @__PURE__ */ F(G, { children: [/* @__PURE__ */ l("span", {
|
|
549
550
|
style: {
|
|
550
551
|
fontSize: "16px",
|
|
551
552
|
lineHeight: 1,
|
|
@@ -553,13 +554,13 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
553
554
|
},
|
|
554
555
|
"aria-hidden": !0,
|
|
555
556
|
children: "📄"
|
|
556
|
-
}), /* @__PURE__ */
|
|
557
|
+
}), /* @__PURE__ */ F("span", {
|
|
557
558
|
style: {
|
|
558
559
|
display: "flex",
|
|
559
560
|
flexDirection: "column",
|
|
560
561
|
minWidth: 0
|
|
561
562
|
},
|
|
562
|
-
children: [/* @__PURE__ */
|
|
563
|
+
children: [/* @__PURE__ */ l("span", {
|
|
563
564
|
style: {
|
|
564
565
|
overflow: "hidden",
|
|
565
566
|
textOverflow: "ellipsis",
|
|
@@ -568,12 +569,12 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
568
569
|
},
|
|
569
570
|
title: e.name,
|
|
570
571
|
children: e.name
|
|
571
|
-
}),
|
|
572
|
+
}), o && /* @__PURE__ */ l("span", {
|
|
572
573
|
style: {
|
|
573
574
|
fontSize: "11px",
|
|
574
575
|
color: "#6b6d6f"
|
|
575
576
|
},
|
|
576
|
-
children:
|
|
577
|
+
children: o
|
|
577
578
|
})]
|
|
578
579
|
})] }), s = {
|
|
579
580
|
display: "inline-flex",
|
|
@@ -582,24 +583,24 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
582
583
|
padding: "8px 12px",
|
|
583
584
|
borderRadius: "10px",
|
|
584
585
|
border: "1px solid #dee3e8",
|
|
585
|
-
backgroundColor:
|
|
586
|
-
color:
|
|
586
|
+
backgroundColor: t ? "rgba(255,255,255,0.12)" : "#fff",
|
|
587
|
+
color: t ? "#fff" : "#30373e",
|
|
587
588
|
fontSize: "13px",
|
|
588
589
|
textDecoration: "none",
|
|
589
590
|
maxWidth: "220px"
|
|
590
591
|
};
|
|
591
|
-
return r ? /* @__PURE__ */
|
|
592
|
+
return r ? /* @__PURE__ */ l("a", {
|
|
592
593
|
href: r,
|
|
593
594
|
target: "_blank",
|
|
594
595
|
rel: "noopener noreferrer",
|
|
595
596
|
style: s,
|
|
596
|
-
children:
|
|
597
|
-
}) : /* @__PURE__ */
|
|
597
|
+
children: n
|
|
598
|
+
}) : /* @__PURE__ */ l("div", {
|
|
598
599
|
style: s,
|
|
599
|
-
children:
|
|
600
|
+
children: n
|
|
600
601
|
});
|
|
601
|
-
},
|
|
602
|
-
const r = /* @__PURE__ */
|
|
602
|
+
}, Re = ({ source: e, index: t }) => {
|
|
603
|
+
const r = /* @__PURE__ */ F("div", {
|
|
603
604
|
style: {
|
|
604
605
|
display: "flex",
|
|
605
606
|
alignItems: "center",
|
|
@@ -607,7 +608,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
607
608
|
width: "100%",
|
|
608
609
|
minWidth: 0
|
|
609
610
|
},
|
|
610
|
-
children: [/* @__PURE__ */
|
|
611
|
+
children: [/* @__PURE__ */ l("div", {
|
|
611
612
|
style: {
|
|
612
613
|
flexShrink: 0,
|
|
613
614
|
width: "18px",
|
|
@@ -622,8 +623,8 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
622
623
|
justifyContent: "center",
|
|
623
624
|
backgroundColor: "#f0f4ff"
|
|
624
625
|
},
|
|
625
|
-
children:
|
|
626
|
-
}), /* @__PURE__ */
|
|
626
|
+
children: t + 1
|
|
627
|
+
}), /* @__PURE__ */ l("div", {
|
|
627
628
|
style: {
|
|
628
629
|
fontSize: "12px",
|
|
629
630
|
overflow: "hidden",
|
|
@@ -634,7 +635,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
634
635
|
title: e.title,
|
|
635
636
|
children: e.title
|
|
636
637
|
})]
|
|
637
|
-
}),
|
|
638
|
+
}), o = {
|
|
638
639
|
display: "flex",
|
|
639
640
|
alignItems: "center",
|
|
640
641
|
padding: "8px 10px",
|
|
@@ -647,23 +648,23 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
647
648
|
minWidth: 0,
|
|
648
649
|
transition: "border-color 0.15s"
|
|
649
650
|
};
|
|
650
|
-
return e.url ? /* @__PURE__ */
|
|
651
|
+
return e.url ? /* @__PURE__ */ l("a", {
|
|
651
652
|
href: e.url,
|
|
652
653
|
target: "_blank",
|
|
653
654
|
rel: "noopener noreferrer",
|
|
654
|
-
style:
|
|
655
|
-
onMouseEnter: (
|
|
656
|
-
|
|
655
|
+
style: o,
|
|
656
|
+
onMouseEnter: (n) => {
|
|
657
|
+
n.currentTarget.style.borderColor = "#1b5fc4";
|
|
657
658
|
},
|
|
658
|
-
onMouseLeave: (
|
|
659
|
-
|
|
659
|
+
onMouseLeave: (n) => {
|
|
660
|
+
n.currentTarget.style.borderColor = "#dee3e8";
|
|
660
661
|
},
|
|
661
662
|
children: r
|
|
662
|
-
}) : /* @__PURE__ */
|
|
663
|
-
style:
|
|
663
|
+
}) : /* @__PURE__ */ l("div", {
|
|
664
|
+
style: o,
|
|
664
665
|
children: r
|
|
665
666
|
});
|
|
666
|
-
},
|
|
667
|
+
}, Me = () => /* @__PURE__ */ F("div", {
|
|
667
668
|
style: {
|
|
668
669
|
display: "flex",
|
|
669
670
|
gap: "4px",
|
|
@@ -673,23 +674,23 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
673
674
|
0,
|
|
674
675
|
1,
|
|
675
676
|
2
|
|
676
|
-
].map((e) => /* @__PURE__ */
|
|
677
|
+
].map((e) => /* @__PURE__ */ l("div", { style: {
|
|
677
678
|
width: "6px",
|
|
678
679
|
height: "6px",
|
|
679
680
|
borderRadius: "50%",
|
|
680
681
|
backgroundColor: "#b5bfc8",
|
|
681
682
|
animation: "ago-pulse 1.2s ease-in-out infinite",
|
|
682
683
|
animationDelay: `${e * 0.2}s`
|
|
683
|
-
} }, e)), /* @__PURE__ */
|
|
684
|
+
} }, e)), /* @__PURE__ */ l("style", { children: `
|
|
684
685
|
@keyframes ago-pulse {
|
|
685
686
|
0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
|
|
686
687
|
40% { opacity: 1; transform: scale(1); }
|
|
687
688
|
}
|
|
688
689
|
` })]
|
|
689
|
-
}),
|
|
690
|
-
const s = e.role === "user",
|
|
691
|
-
return /* @__PURE__ */
|
|
692
|
-
className: `ago-message ago-message--${e.role} ${
|
|
690
|
+
}), Ee = ({ message: e, className: t = "", showAgentName: r = !1, isLast: o = !1, onFollowUpClick: n }) => {
|
|
691
|
+
const s = e.role === "user", f = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
|
|
692
|
+
return /* @__PURE__ */ F("div", {
|
|
693
|
+
className: `ago-message ago-message--${e.role} ${t}`,
|
|
693
694
|
style: {
|
|
694
695
|
display: "flex",
|
|
695
696
|
flexDirection: "column",
|
|
@@ -697,7 +698,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
697
698
|
marginBottom: "16px"
|
|
698
699
|
},
|
|
699
700
|
children: [
|
|
700
|
-
!s && r && e.agent && /* @__PURE__ */
|
|
701
|
+
!s && r && e.agent && /* @__PURE__ */ l("div", {
|
|
701
702
|
className: "ago-message__agent",
|
|
702
703
|
style: {
|
|
703
704
|
display: "flex",
|
|
@@ -711,7 +712,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
711
712
|
},
|
|
712
713
|
children: e.agent.displayName || e.agent.name
|
|
713
714
|
}),
|
|
714
|
-
!s && e.sources && e.sources.length > 0 && /* @__PURE__ */
|
|
715
|
+
!s && e.sources && e.sources.length > 0 && /* @__PURE__ */ l("div", {
|
|
715
716
|
className: "ago-message__sources",
|
|
716
717
|
style: {
|
|
717
718
|
display: "grid",
|
|
@@ -721,12 +722,12 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
721
722
|
width: "100%",
|
|
722
723
|
maxWidth: "85%"
|
|
723
724
|
},
|
|
724
|
-
children: e.sources.map((
|
|
725
|
-
source:
|
|
726
|
-
index:
|
|
727
|
-
},
|
|
725
|
+
children: e.sources.map((i, m) => /* @__PURE__ */ l(Re, {
|
|
726
|
+
source: i,
|
|
727
|
+
index: m
|
|
728
|
+
}, i.id))
|
|
728
729
|
}),
|
|
729
|
-
e.attachments && e.attachments.length > 0 && /* @__PURE__ */
|
|
730
|
+
e.attachments && e.attachments.length > 0 && /* @__PURE__ */ l("div", {
|
|
730
731
|
className: "ago-message__attachments",
|
|
731
732
|
style: {
|
|
732
733
|
display: "flex",
|
|
@@ -736,12 +737,12 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
736
737
|
justifyContent: s ? "flex-end" : "flex-start",
|
|
737
738
|
maxWidth: "75%"
|
|
738
739
|
},
|
|
739
|
-
children: e.attachments.map((
|
|
740
|
-
attachment:
|
|
740
|
+
children: e.attachments.map((i) => /* @__PURE__ */ l(Ne, {
|
|
741
|
+
attachment: i,
|
|
741
742
|
isUser: s
|
|
742
|
-
},
|
|
743
|
+
}, i.id))
|
|
743
744
|
}),
|
|
744
|
-
(e.content ||
|
|
745
|
+
(e.content || f) && /* @__PURE__ */ l("div", {
|
|
745
746
|
className: "ago-message__content",
|
|
746
747
|
style: {
|
|
747
748
|
maxWidth: s ? "75%" : "100%",
|
|
@@ -753,9 +754,9 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
753
754
|
fontSize: "16px",
|
|
754
755
|
lineHeight: "1.6"
|
|
755
756
|
},
|
|
756
|
-
children: e.content ? /* @__PURE__ */
|
|
757
|
+
children: e.content ? /* @__PURE__ */ l(Ae, { content: e.content }) : f && /* @__PURE__ */ l(Me, {})
|
|
757
758
|
}),
|
|
758
|
-
|
|
759
|
+
o && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ l("div", {
|
|
759
760
|
className: "ago-message__followups",
|
|
760
761
|
style: {
|
|
761
762
|
display: "flex",
|
|
@@ -763,11 +764,11 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
763
764
|
gap: "8px",
|
|
764
765
|
marginTop: "10px"
|
|
765
766
|
},
|
|
766
|
-
children: e.followUpReplies.map((
|
|
767
|
+
children: e.followUpReplies.map((i, m) => /* @__PURE__ */ l("button", {
|
|
767
768
|
type: "button",
|
|
768
769
|
className: "ago-message__followup-btn",
|
|
769
|
-
disabled: !
|
|
770
|
-
onClick:
|
|
770
|
+
disabled: !n,
|
|
771
|
+
onClick: n ? () => n(i) : void 0,
|
|
771
772
|
style: {
|
|
772
773
|
minHeight: "36px",
|
|
773
774
|
padding: "6px 14px",
|
|
@@ -776,59 +777,59 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
776
777
|
border: "1px solid #dee3e8",
|
|
777
778
|
backgroundColor: "#fff",
|
|
778
779
|
color: "#30373e",
|
|
779
|
-
cursor:
|
|
780
|
+
cursor: n ? "pointer" : "default",
|
|
780
781
|
transition: "border-color 0.15s"
|
|
781
782
|
},
|
|
782
|
-
onMouseEnter: (
|
|
783
|
-
|
|
783
|
+
onMouseEnter: (u) => {
|
|
784
|
+
u.currentTarget.style.borderColor = "#1b5fc4";
|
|
784
785
|
},
|
|
785
|
-
onMouseLeave: (
|
|
786
|
-
|
|
786
|
+
onMouseLeave: (u) => {
|
|
787
|
+
u.currentTarget.style.borderColor = "#dee3e8";
|
|
787
788
|
},
|
|
788
|
-
children:
|
|
789
|
-
},
|
|
789
|
+
children: i
|
|
790
|
+
}, m))
|
|
790
791
|
})
|
|
791
792
|
]
|
|
792
793
|
});
|
|
793
|
-
},
|
|
794
|
-
const
|
|
794
|
+
}, Ue = ({ client: e, conversationId: t, title: r = "Chat", welcomeMessage: o = "Hello! How can I help you today?", placeholder: n = "Type a message...", allowFiles: s = !1, height: f = 500, logoUrl: i, showAgentName: m = !1, forms: u, onFollowUpClick: g, className: C = "", onMessageSent: A, onMessageReceived: S }) => {
|
|
795
|
+
const k = T(null), d = L(), x = e ?? d, { messages: a, isLoading: v, error: c, sendMessage: h } = K({
|
|
795
796
|
client: e,
|
|
796
|
-
conversationId:
|
|
797
|
+
conversationId: t
|
|
797
798
|
});
|
|
798
|
-
|
|
799
|
-
if (!
|
|
800
|
-
let
|
|
801
|
-
const
|
|
802
|
-
return Promise.all(
|
|
803
|
-
if (!
|
|
804
|
-
for (const
|
|
799
|
+
N(() => {
|
|
800
|
+
if (!x || !u || u.length === 0) return;
|
|
801
|
+
let p = !1;
|
|
802
|
+
const I = [];
|
|
803
|
+
return Promise.all(u.map((M) => M.schema != null ? Promise.resolve(j(M)) : O(x, M))).then((M) => {
|
|
804
|
+
if (!p)
|
|
805
|
+
for (const J of M) I.push(J.install(x));
|
|
805
806
|
}).catch(() => {
|
|
806
807
|
}), () => {
|
|
807
|
-
|
|
808
|
+
p = !0, I.forEach((M) => M());
|
|
808
809
|
};
|
|
809
|
-
}, [
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
])) : ""]),
|
|
815
|
-
|
|
816
|
-
}, [a]),
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
id:
|
|
820
|
-
content:
|
|
810
|
+
}, [x, u ? JSON.stringify(u.map((p) => [
|
|
811
|
+
p.name,
|
|
812
|
+
p.schema ?? null,
|
|
813
|
+
p.submit ?? !1,
|
|
814
|
+
p.description ?? null
|
|
815
|
+
])) : ""]), N(() => {
|
|
816
|
+
k.current?.scrollIntoView({ behavior: "smooth" });
|
|
817
|
+
}, [a]), N(() => {
|
|
818
|
+
const p = a[a.length - 1];
|
|
819
|
+
p && p.role === "assistant" && p.status === "DONE" && S && S({
|
|
820
|
+
id: p.id,
|
|
821
|
+
content: p.content
|
|
821
822
|
});
|
|
822
|
-
}, [a,
|
|
823
|
-
const
|
|
824
|
-
|
|
825
|
-
},
|
|
826
|
-
return /* @__PURE__ */
|
|
827
|
-
className: `ago-chat-widget ${
|
|
823
|
+
}, [a, S]);
|
|
824
|
+
const w = async (p, I) => {
|
|
825
|
+
A?.(p), await h(p, I);
|
|
826
|
+
}, b = a[a.length - 1], _ = v && b?.role === "assistant" && (b.status === "IN_PROGRESS" || b.status === "WAITING_CLIENT"), y = g === !1 ? void 0 : g ?? ((p) => w(p));
|
|
827
|
+
return /* @__PURE__ */ F("div", {
|
|
828
|
+
className: `ago-chat-widget ${C}`,
|
|
828
829
|
style: {
|
|
829
830
|
display: "flex",
|
|
830
831
|
flexDirection: "column",
|
|
831
|
-
height: typeof
|
|
832
|
+
height: typeof f == "number" ? `${f}px` : f,
|
|
832
833
|
border: "1px solid #dee3e8",
|
|
833
834
|
borderRadius: "16px",
|
|
834
835
|
overflow: "hidden",
|
|
@@ -838,7 +839,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
838
839
|
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
|
|
839
840
|
},
|
|
840
841
|
children: [
|
|
841
|
-
/* @__PURE__ */
|
|
842
|
+
/* @__PURE__ */ F("div", {
|
|
842
843
|
className: "ago-chat-widget__header",
|
|
843
844
|
style: {
|
|
844
845
|
padding: "14px 16px",
|
|
@@ -849,14 +850,14 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
849
850
|
alignItems: "center",
|
|
850
851
|
gap: "10px"
|
|
851
852
|
},
|
|
852
|
-
children: [
|
|
853
|
-
src:
|
|
853
|
+
children: [i && /* @__PURE__ */ l("img", {
|
|
854
|
+
src: i,
|
|
854
855
|
alt: "Logo",
|
|
855
856
|
style: {
|
|
856
857
|
height: "24px",
|
|
857
858
|
width: "auto"
|
|
858
859
|
}
|
|
859
|
-
}), /* @__PURE__ */
|
|
860
|
+
}), /* @__PURE__ */ l("h3", {
|
|
860
861
|
style: {
|
|
861
862
|
margin: 0,
|
|
862
863
|
fontSize: "15px",
|
|
@@ -865,7 +866,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
865
866
|
children: r
|
|
866
867
|
})]
|
|
867
868
|
}),
|
|
868
|
-
/* @__PURE__ */
|
|
869
|
+
/* @__PURE__ */ F("div", {
|
|
869
870
|
className: "ago-chat-widget__messages",
|
|
870
871
|
role: "log",
|
|
871
872
|
"aria-live": "polite",
|
|
@@ -878,7 +879,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
878
879
|
backgroundColor: "#fbfbfb"
|
|
879
880
|
},
|
|
880
881
|
children: [
|
|
881
|
-
a.length === 0 ? /* @__PURE__ */
|
|
882
|
+
a.length === 0 ? /* @__PURE__ */ l("div", {
|
|
882
883
|
style: {
|
|
883
884
|
textAlign: "center",
|
|
884
885
|
color: "#6b6d6f",
|
|
@@ -886,14 +887,14 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
886
887
|
fontSize: "16px",
|
|
887
888
|
lineHeight: "1.5"
|
|
888
889
|
},
|
|
889
|
-
children:
|
|
890
|
-
}) : a.map((
|
|
891
|
-
message:
|
|
892
|
-
showAgentName:
|
|
893
|
-
isLast:
|
|
894
|
-
onFollowUpClick:
|
|
895
|
-
},
|
|
896
|
-
|
|
890
|
+
children: o
|
|
891
|
+
}) : a.map((p, I) => /* @__PURE__ */ l(Ee, {
|
|
892
|
+
message: p,
|
|
893
|
+
showAgentName: m,
|
|
894
|
+
isLast: I === a.length - 1,
|
|
895
|
+
onFollowUpClick: y
|
|
896
|
+
}, p.id)),
|
|
897
|
+
c && /* @__PURE__ */ l("div", {
|
|
897
898
|
role: "alert",
|
|
898
899
|
style: {
|
|
899
900
|
padding: "10px 14px",
|
|
@@ -904,281 +905,416 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
904
905
|
fontSize: "13px",
|
|
905
906
|
border: "1px solid #fecaca"
|
|
906
907
|
},
|
|
907
|
-
children:
|
|
908
|
+
children: c.message
|
|
908
909
|
}),
|
|
909
|
-
/* @__PURE__ */
|
|
910
|
+
/* @__PURE__ */ l("div", { ref: k })
|
|
910
911
|
]
|
|
911
912
|
}),
|
|
912
|
-
/* @__PURE__ */
|
|
913
|
-
onSend:
|
|
914
|
-
disabled:
|
|
915
|
-
placeholder:
|
|
913
|
+
/* @__PURE__ */ l(de, {
|
|
914
|
+
onSend: w,
|
|
915
|
+
disabled: _,
|
|
916
|
+
placeholder: n,
|
|
916
917
|
allowFiles: s
|
|
917
918
|
})
|
|
918
919
|
]
|
|
919
920
|
});
|
|
920
921
|
};
|
|
921
|
-
function
|
|
922
|
-
const r =
|
|
923
|
-
if (!
|
|
924
|
-
const [
|
|
925
|
-
|
|
922
|
+
function Fe({ client: e, autoLoad: t = !0 } = {}) {
|
|
923
|
+
const r = L(), o = e || r;
|
|
924
|
+
if (!o) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
925
|
+
const [n, s] = E([]), [f, i] = E(null), [m, u] = E(!1), [g, C] = E(null), A = R(async () => {
|
|
926
|
+
u(!0), C(null);
|
|
926
927
|
try {
|
|
927
|
-
s(await
|
|
928
|
-
} catch (
|
|
929
|
-
|
|
928
|
+
s(await o.getConversations());
|
|
929
|
+
} catch (d) {
|
|
930
|
+
C(d instanceof Error ? d : /* @__PURE__ */ new Error("Failed to load conversations"));
|
|
930
931
|
} finally {
|
|
931
|
-
|
|
932
|
+
u(!1);
|
|
932
933
|
}
|
|
933
|
-
}, [
|
|
934
|
-
|
|
934
|
+
}, [o]), S = R(async (d) => {
|
|
935
|
+
u(!0), C(null);
|
|
935
936
|
try {
|
|
936
|
-
|
|
937
|
-
} catch (
|
|
938
|
-
|
|
937
|
+
i(await o.getConversation(d));
|
|
938
|
+
} catch (x) {
|
|
939
|
+
C(x instanceof Error ? x : /* @__PURE__ */ new Error("Failed to load conversation"));
|
|
939
940
|
} finally {
|
|
940
|
-
|
|
941
|
+
u(!1);
|
|
941
942
|
}
|
|
942
|
-
}, [
|
|
943
|
-
|
|
943
|
+
}, [o]), k = R(() => {
|
|
944
|
+
i(null);
|
|
944
945
|
}, []);
|
|
945
|
-
return
|
|
946
|
-
|
|
947
|
-
}, [
|
|
948
|
-
conversations:
|
|
949
|
-
currentConversation:
|
|
950
|
-
isLoading:
|
|
951
|
-
error:
|
|
952
|
-
selectConversation:
|
|
953
|
-
startNewConversation:
|
|
954
|
-
refreshConversations:
|
|
946
|
+
return N(() => {
|
|
947
|
+
t && A();
|
|
948
|
+
}, [t, A]), {
|
|
949
|
+
conversations: n,
|
|
950
|
+
currentConversation: f,
|
|
951
|
+
isLoading: m,
|
|
952
|
+
error: g,
|
|
953
|
+
selectConversation: S,
|
|
954
|
+
startNewConversation: k,
|
|
955
|
+
refreshConversations: A
|
|
955
956
|
};
|
|
956
957
|
}
|
|
957
|
-
function
|
|
958
|
-
const
|
|
958
|
+
function Je(e = {}) {
|
|
959
|
+
const t = L(), r = e.client || t;
|
|
959
960
|
if (!r) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
960
|
-
const
|
|
961
|
+
const o = K({
|
|
961
962
|
client: r,
|
|
962
963
|
conversationId: e.conversationId
|
|
963
|
-
}),
|
|
964
|
+
}), n = Fe({
|
|
964
965
|
client: r,
|
|
965
966
|
autoLoad: e.autoLoad
|
|
966
967
|
});
|
|
967
968
|
return {
|
|
968
|
-
messages:
|
|
969
|
-
isLoading:
|
|
970
|
-
error:
|
|
971
|
-
sendMessage:
|
|
972
|
-
clearMessages:
|
|
973
|
-
conversationId:
|
|
974
|
-
conversations:
|
|
975
|
-
currentConversation:
|
|
976
|
-
isConversationsLoading:
|
|
977
|
-
selectConversation:
|
|
978
|
-
startNewConversation:
|
|
979
|
-
refreshConversations:
|
|
969
|
+
messages: o.messages,
|
|
970
|
+
isLoading: o.isLoading,
|
|
971
|
+
error: o.error || n.error,
|
|
972
|
+
sendMessage: o.sendMessage,
|
|
973
|
+
clearMessages: o.clearMessages,
|
|
974
|
+
conversationId: o.conversationId,
|
|
975
|
+
conversations: n.conversations,
|
|
976
|
+
currentConversation: n.currentConversation,
|
|
977
|
+
isConversationsLoading: n.isLoading,
|
|
978
|
+
selectConversation: n.selectConversation,
|
|
979
|
+
startNewConversation: n.startNewConversation,
|
|
980
|
+
refreshConversations: n.refreshConversations
|
|
980
981
|
};
|
|
981
982
|
}
|
|
982
|
-
function
|
|
983
|
-
const r =
|
|
983
|
+
function Ve(e, t) {
|
|
984
|
+
const r = W(), { name: o, description: n, parameters: s, handler: f, maxResultBytes: i, requiresApproval: m } = typeof e == "string" ? {
|
|
984
985
|
name: e,
|
|
985
|
-
...
|
|
986
|
-
} : e,
|
|
987
|
-
|
|
988
|
-
const
|
|
989
|
-
return r.registerFunction(
|
|
990
|
-
description:
|
|
986
|
+
...t
|
|
987
|
+
} : e, u = T(f);
|
|
988
|
+
u.current = f, N(() => {
|
|
989
|
+
const g = (C) => u.current(C);
|
|
990
|
+
return r.registerFunction(o, g, {
|
|
991
|
+
description: n,
|
|
991
992
|
parameters: s,
|
|
992
|
-
maxResultBytes:
|
|
993
|
+
maxResultBytes: i,
|
|
994
|
+
requiresApproval: m
|
|
993
995
|
}), () => {
|
|
994
|
-
r.unregisterFunction(
|
|
996
|
+
r.unregisterFunction(o);
|
|
995
997
|
};
|
|
996
998
|
}, [
|
|
997
999
|
r,
|
|
998
|
-
t,
|
|
999
1000
|
o,
|
|
1001
|
+
n,
|
|
1000
1002
|
s,
|
|
1001
|
-
|
|
1003
|
+
i,
|
|
1004
|
+
m
|
|
1002
1005
|
]);
|
|
1003
1006
|
}
|
|
1004
|
-
function
|
|
1005
|
-
const r =
|
|
1006
|
-
|
|
1007
|
+
function Ye(e, t) {
|
|
1008
|
+
const r = W(), o = T(e);
|
|
1009
|
+
o.current = e, N(() => (r.registerNavigationFunction((n) => o.current(n), t), () => {
|
|
1007
1010
|
r.unregisterNavigationFunction();
|
|
1008
|
-
}), [r,
|
|
1011
|
+
}), [r, t]);
|
|
1009
1012
|
}
|
|
1010
|
-
function
|
|
1011
|
-
const r =
|
|
1012
|
-
|
|
1013
|
-
const
|
|
1014
|
-
const
|
|
1013
|
+
function Xe(e, t) {
|
|
1014
|
+
const r = W(), o = t?.functionName ?? "setPageState", n = t?.requiresApproval, s = T(e);
|
|
1015
|
+
s.current = e, N(() => {
|
|
1016
|
+
const f = s.current.map((i) => {
|
|
1017
|
+
const m = () => s.current.find((u) => u.name === i.name) ?? i;
|
|
1015
1018
|
return {
|
|
1016
|
-
name:
|
|
1017
|
-
description:
|
|
1018
|
-
schema:
|
|
1019
|
-
get:
|
|
1020
|
-
set: (
|
|
1019
|
+
name: i.name,
|
|
1020
|
+
description: i.description,
|
|
1021
|
+
schema: i.schema,
|
|
1022
|
+
get: i.get ? () => m().get?.() : void 0,
|
|
1023
|
+
set: (u) => m().set(u)
|
|
1021
1024
|
};
|
|
1022
1025
|
});
|
|
1023
|
-
return r.registerPageStateFunction(
|
|
1024
|
-
|
|
1026
|
+
return r.registerPageStateFunction(f, {
|
|
1027
|
+
functionName: o,
|
|
1028
|
+
requiresApproval: n
|
|
1029
|
+
}), () => {
|
|
1030
|
+
r.unregisterPageStateFunction(o);
|
|
1025
1031
|
};
|
|
1026
|
-
}, [
|
|
1032
|
+
}, [
|
|
1033
|
+
r,
|
|
1034
|
+
o,
|
|
1035
|
+
n
|
|
1036
|
+
]);
|
|
1027
1037
|
}
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
navigationFunctions: e?.navigationFunctions ?? ["navigateToPage"],
|
|
1032
|
-
pageStateFunctionName: e?.pageStateFunctionName ?? "setPageState",
|
|
1033
|
-
continuationPrompt: e?.continuationPrompt ?? Ne,
|
|
1034
|
-
maxDepth: e?.maxDepth ?? 1,
|
|
1035
|
-
readinessTimeoutMs: e?.readinessTimeoutMs ?? 4e3,
|
|
1036
|
-
settleMs: e?.settleMs ?? 150,
|
|
1037
|
-
enabled: e?.enabled ?? !0
|
|
1038
|
-
};
|
|
1038
|
+
function Ze(e) {
|
|
1039
|
+
const t = W(), r = T(e);
|
|
1040
|
+
r.current = e, N(() => te(t, () => r.current), [t]);
|
|
1039
1041
|
}
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1042
|
+
var Te = /* @__PURE__ */ new Set(["awaiting-approval"]);
|
|
1043
|
+
function U(e) {
|
|
1044
|
+
switch (e) {
|
|
1045
|
+
case "progress_indicator":
|
|
1046
|
+
return "progress";
|
|
1047
|
+
case "reasoning":
|
|
1048
|
+
return "reasoning";
|
|
1049
|
+
case "confirmation_input":
|
|
1050
|
+
return "confirmation";
|
|
1051
|
+
case "form":
|
|
1052
|
+
return "form";
|
|
1053
|
+
default:
|
|
1054
|
+
return "status";
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
function _e(e) {
|
|
1058
|
+
return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : U(e.type);
|
|
1059
|
+
}
|
|
1060
|
+
function H(e, t) {
|
|
1061
|
+
const r = (e ?? "").toLowerCase();
|
|
1062
|
+
return r.includes("reject") ? "rejected" : r.includes("error") || r.includes("fail") ? "error" : r.includes("done") || r.includes("complet") ? "done" : (r.includes("waiting") || r.includes("pending")) && (t === "confirmation" || t === "form") ? "awaiting-approval" : "running";
|
|
1063
|
+
}
|
|
1064
|
+
function $(e) {
|
|
1065
|
+
return typeof e != "string" || !e ? "page" : e.replace(/[-_]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (t) => t.toUpperCase()).trim();
|
|
1066
|
+
}
|
|
1067
|
+
function Pe(e) {
|
|
1068
|
+
switch (e.kind) {
|
|
1069
|
+
case "navigation":
|
|
1070
|
+
return `Navigating to ${$(e.arguments?.page)}`;
|
|
1071
|
+
case "action":
|
|
1072
|
+
return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message || $(e.functionName) || "Working";
|
|
1073
|
+
case "progress":
|
|
1074
|
+
return e.message || "Working";
|
|
1075
|
+
case "reasoning":
|
|
1076
|
+
return e.message || "Thinking";
|
|
1077
|
+
case "confirmation":
|
|
1078
|
+
return e.message || "Waiting for your confirmation";
|
|
1079
|
+
case "form":
|
|
1080
|
+
return e.message || e.toolDisplayName || "Please fill in the form";
|
|
1081
|
+
default:
|
|
1082
|
+
return e.message || e.toolDisplayName || e.toolName || "Working";
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
function Qe(e = {}) {
|
|
1086
|
+
const { includeReasoning: t = !1, labelFor: r } = e, o = L(), n = e.client || o;
|
|
1087
|
+
if (!n) throw new X("useAgoActivity requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
|
|
1088
|
+
const [s, f] = E([]), i = T(/* @__PURE__ */ new Set()), m = T(void 0), u = T(r);
|
|
1089
|
+
u.current = r;
|
|
1090
|
+
const g = R((d, x) => {
|
|
1091
|
+
f((a) => {
|
|
1092
|
+
const v = a.findIndex((h) => h.id === d), c = {
|
|
1093
|
+
...v >= 0 ? a[v] : {
|
|
1094
|
+
id: d,
|
|
1095
|
+
kind: "status",
|
|
1096
|
+
label: "",
|
|
1097
|
+
status: "running",
|
|
1098
|
+
requiresApproval: !1,
|
|
1099
|
+
createdAt: /* @__PURE__ */ new Date()
|
|
1100
|
+
},
|
|
1101
|
+
...x
|
|
1102
|
+
};
|
|
1103
|
+
return c.label = u.current?.(c) ?? Pe(c), v >= 0 ? [
|
|
1104
|
+
...a.slice(0, v),
|
|
1105
|
+
c,
|
|
1106
|
+
...a.slice(v + 1)
|
|
1107
|
+
] : [...a, c];
|
|
1108
|
+
});
|
|
1109
|
+
}, []);
|
|
1110
|
+
N(() => {
|
|
1111
|
+
const d = (y) => {
|
|
1112
|
+
m.current = y.messageId;
|
|
1113
|
+
}, x = (y) => {
|
|
1114
|
+
const p = U(y.type);
|
|
1115
|
+
p === "reasoning" && !t || g(y.id, {
|
|
1116
|
+
kind: p,
|
|
1117
|
+
status: H(y.status, p),
|
|
1118
|
+
messageId: m.current,
|
|
1119
|
+
toolName: y.toolName,
|
|
1120
|
+
toolDisplayName: y.toolDisplayName,
|
|
1121
|
+
message: y.message,
|
|
1122
|
+
data: y.data,
|
|
1123
|
+
formSchema: y.formSchema,
|
|
1124
|
+
requiresApproval: p === "confirmation" || p === "form"
|
|
1125
|
+
});
|
|
1126
|
+
}, a = (y) => {
|
|
1127
|
+
y.invocationId && g(y.invocationId, {
|
|
1128
|
+
kind: y.functionName === "navigateToPage" ? "navigation" : "action",
|
|
1129
|
+
status: "running",
|
|
1130
|
+
messageId: m.current,
|
|
1131
|
+
functionName: y.functionName,
|
|
1132
|
+
arguments: y.arguments
|
|
1133
|
+
});
|
|
1134
|
+
}, v = (y) => {
|
|
1135
|
+
y.invocationId && g(y.invocationId, {
|
|
1136
|
+
kind: y.functionName === "navigateToPage" ? "navigation" : "action",
|
|
1137
|
+
status: "awaiting-approval",
|
|
1138
|
+
messageId: m.current,
|
|
1139
|
+
functionName: y.functionName,
|
|
1140
|
+
arguments: y.arguments,
|
|
1141
|
+
requiresApproval: !0
|
|
1142
|
+
});
|
|
1143
|
+
}, c = (y) => {
|
|
1144
|
+
if (!y.invocationId) return;
|
|
1145
|
+
const p = y.result, I = typeof y.result == "object" && p !== null && p.approved === !1 && p.reason === "user_rejected";
|
|
1146
|
+
g(y.invocationId, {
|
|
1147
|
+
status: y.error ? "error" : I ? "rejected" : "done",
|
|
1148
|
+
requiresApproval: !1
|
|
1149
|
+
});
|
|
1150
|
+
}, h = (y) => {
|
|
1151
|
+
for (const p of y.messages ?? [])
|
|
1152
|
+
if (p.role === "assistant")
|
|
1153
|
+
for (const I of p.toolCalls ?? []) {
|
|
1154
|
+
const M = _e(I);
|
|
1155
|
+
M === "reasoning" && !t || /waiting/i.test(I.status ?? "") || g(I.id, {
|
|
1156
|
+
kind: M,
|
|
1157
|
+
status: H(I.status, M),
|
|
1158
|
+
messageId: p.id,
|
|
1159
|
+
toolName: I.toolName,
|
|
1160
|
+
toolDisplayName: I.toolDisplayName,
|
|
1161
|
+
functionName: I.functionName,
|
|
1162
|
+
arguments: I.arguments,
|
|
1163
|
+
message: I.message,
|
|
1164
|
+
data: I.data,
|
|
1165
|
+
formSchema: I.formSchema,
|
|
1166
|
+
requiresApproval: M === "confirmation" || M === "form"
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
}, w = (y) => {
|
|
1170
|
+
f((p) => p.map((I) => I.status === "running" || I.status === "awaiting-approval" ? {
|
|
1171
|
+
...I,
|
|
1172
|
+
status: y
|
|
1173
|
+
} : I));
|
|
1174
|
+
}, b = () => w("done"), _ = () => w("error");
|
|
1175
|
+
return n.on("message:start", d), n.on("toolCall:received", x), n.on("function:invoke", a), n.on("function:awaiting-approval", v), n.on("function:result", c), n.on("conversation:loaded", h), n.on("message:complete", b), n.on("message:error", _), () => {
|
|
1176
|
+
n.off("message:start", d), n.off("toolCall:received", x), n.off("function:invoke", a), n.off("function:awaiting-approval", v), n.off("function:result", c), n.off("conversation:loaded", h), n.off("message:complete", b), n.off("message:error", _);
|
|
1088
1177
|
};
|
|
1089
|
-
}, [
|
|
1178
|
+
}, [
|
|
1179
|
+
n,
|
|
1180
|
+
t,
|
|
1181
|
+
g
|
|
1182
|
+
]);
|
|
1183
|
+
const C = R(async (d) => {
|
|
1184
|
+
const x = s.find((a) => a.id === d);
|
|
1185
|
+
!x || x.status !== "awaiting-approval" || i.current.has(d) || x.kind !== "form" && (i.current.add(d), g(d, {
|
|
1186
|
+
status: "running",
|
|
1187
|
+
requiresApproval: !1
|
|
1188
|
+
}), x.functionName ? await n.approveFunction(d) : await n.confirmToolCall(d));
|
|
1189
|
+
}, [
|
|
1190
|
+
n,
|
|
1191
|
+
s,
|
|
1192
|
+
g
|
|
1193
|
+
]), A = R(async (d) => {
|
|
1194
|
+
const x = s.find((a) => a.id === d);
|
|
1195
|
+
!x || x.status !== "awaiting-approval" || i.current.has(d) || (i.current.add(d), g(d, {
|
|
1196
|
+
status: "rejected",
|
|
1197
|
+
requiresApproval: !1
|
|
1198
|
+
}), x.functionName ? await n.rejectFunction(d) : await n.rejectToolCall(d));
|
|
1199
|
+
}, [
|
|
1200
|
+
n,
|
|
1201
|
+
s,
|
|
1202
|
+
g
|
|
1203
|
+
]), S = R(async (d, x) => {
|
|
1204
|
+
g(d, {
|
|
1205
|
+
status: "running",
|
|
1206
|
+
requiresApproval: !1
|
|
1207
|
+
}), await n.submitToolCallForm(d, x), g(d, { status: "done" });
|
|
1208
|
+
}, [n, g]), k = R(() => {
|
|
1209
|
+
i.current.clear(), f([]);
|
|
1210
|
+
}, []);
|
|
1211
|
+
return {
|
|
1212
|
+
items: s,
|
|
1213
|
+
latest: s.length > 0 ? s[s.length - 1] : void 0,
|
|
1214
|
+
isAwaitingApproval: s.some((d) => Te.has(d.status)),
|
|
1215
|
+
approve: C,
|
|
1216
|
+
reject: A,
|
|
1217
|
+
submitForm: S,
|
|
1218
|
+
clear: k
|
|
1219
|
+
};
|
|
1090
1220
|
}
|
|
1091
|
-
function
|
|
1092
|
-
const r =
|
|
1221
|
+
function et(e, t) {
|
|
1222
|
+
const r = W(), o = ae(), n = t ?? o, s = T(e);
|
|
1093
1223
|
s.current = e;
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1224
|
+
const f = typeof e == "function";
|
|
1225
|
+
N(() => {
|
|
1096
1226
|
if (typeof s.current == "function") {
|
|
1097
|
-
const
|
|
1098
|
-
return r.addDynamicContext(
|
|
1099
|
-
r.removeDynamicContext(
|
|
1227
|
+
const i = () => s.current();
|
|
1228
|
+
return r.addDynamicContext(n, i), () => {
|
|
1229
|
+
r.removeDynamicContext(n);
|
|
1100
1230
|
};
|
|
1101
1231
|
}
|
|
1102
|
-
return r.setContext(
|
|
1103
|
-
r.removeContext(
|
|
1232
|
+
return r.setContext(n, s.current), () => {
|
|
1233
|
+
r.removeContext(n);
|
|
1104
1234
|
};
|
|
1105
1235
|
}, [
|
|
1106
1236
|
r,
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1237
|
+
n,
|
|
1238
|
+
f,
|
|
1239
|
+
f ? "" : JSON.stringify(e)
|
|
1110
1240
|
]);
|
|
1111
1241
|
}
|
|
1112
|
-
function
|
|
1113
|
-
return
|
|
1242
|
+
function De(e) {
|
|
1243
|
+
return se(e.subscribe, e.get, e.get);
|
|
1114
1244
|
}
|
|
1115
|
-
var
|
|
1245
|
+
var q = {
|
|
1116
1246
|
missing: [],
|
|
1117
1247
|
complete: !1
|
|
1118
1248
|
};
|
|
1119
|
-
function
|
|
1120
|
-
const
|
|
1249
|
+
function tt(e) {
|
|
1250
|
+
const t = W(), r = e.schema != null, o = JSON.stringify(e.schema ?? null), n = e.submit, s = n ? typeof n == "string" ? `client:${n}` : n.via === "backend" ? "backend" : "handler" in n ? "client:handler" : `client:${n.url}` : "none", f = JSON.stringify(e.initialValues ?? null), i = D(() => r ? j(e) : null, [
|
|
1121
1251
|
r,
|
|
1122
1252
|
e.name,
|
|
1123
|
-
|
|
1253
|
+
o,
|
|
1124
1254
|
s,
|
|
1125
|
-
|
|
1255
|
+
f,
|
|
1126
1256
|
e.autoSubmit
|
|
1127
|
-
]), [
|
|
1257
|
+
]), [m, u] = E({
|
|
1128
1258
|
collector: null,
|
|
1129
1259
|
loading: !r,
|
|
1130
1260
|
error: null
|
|
1131
1261
|
});
|
|
1132
|
-
|
|
1262
|
+
N(() => {
|
|
1133
1263
|
if (r) return;
|
|
1134
|
-
let
|
|
1135
|
-
return
|
|
1264
|
+
let v = !1;
|
|
1265
|
+
return u({
|
|
1136
1266
|
collector: null,
|
|
1137
1267
|
loading: !0,
|
|
1138
1268
|
error: null
|
|
1139
|
-
}), O(
|
|
1140
|
-
|
|
1141
|
-
collector:
|
|
1269
|
+
}), O(t, e).then((c) => {
|
|
1270
|
+
v || u({
|
|
1271
|
+
collector: c,
|
|
1142
1272
|
loading: !1,
|
|
1143
1273
|
error: null
|
|
1144
1274
|
});
|
|
1145
|
-
}).catch((
|
|
1146
|
-
|
|
1275
|
+
}).catch((c) => {
|
|
1276
|
+
v || u({
|
|
1147
1277
|
collector: null,
|
|
1148
1278
|
loading: !1,
|
|
1149
|
-
error:
|
|
1279
|
+
error: c instanceof Error ? c : new Error(String(c))
|
|
1150
1280
|
});
|
|
1151
1281
|
}), () => {
|
|
1152
|
-
|
|
1282
|
+
v = !0;
|
|
1153
1283
|
};
|
|
1154
1284
|
}, [
|
|
1155
|
-
|
|
1285
|
+
t,
|
|
1156
1286
|
r,
|
|
1157
1287
|
e.name,
|
|
1158
1288
|
s,
|
|
1159
|
-
|
|
1289
|
+
f,
|
|
1160
1290
|
e.autoSubmit
|
|
1161
1291
|
]);
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1164
|
-
if (
|
|
1165
|
-
return
|
|
1166
|
-
}, [
|
|
1167
|
-
const
|
|
1292
|
+
const g = r ? i : m.collector, C = r ? !1 : m.loading, A = r ? null : m.error;
|
|
1293
|
+
N(() => {
|
|
1294
|
+
if (g)
|
|
1295
|
+
return g.install(t);
|
|
1296
|
+
}, [t, g]);
|
|
1297
|
+
const S = D(() => ne({
|
|
1168
1298
|
values: e.initialValues ?? {},
|
|
1169
1299
|
submitted: !1
|
|
1170
|
-
}), [
|
|
1171
|
-
...
|
|
1172
|
-
...
|
|
1173
|
-
}), [
|
|
1300
|
+
}), [f]), k = De(g?.store ?? S), d = D(() => g?.getStatus() ?? q, [k, g]), x = D(() => ({
|
|
1301
|
+
...k,
|
|
1302
|
+
...d
|
|
1303
|
+
}), [k, d]), a = D(() => ({
|
|
1174
1304
|
name: e.name,
|
|
1175
|
-
store:
|
|
1305
|
+
store: S,
|
|
1176
1306
|
functions: [],
|
|
1177
1307
|
contextKey: `form:${e.name}`,
|
|
1178
1308
|
contextProvider: () => ({
|
|
1179
1309
|
name: `Form: ${e.name}`,
|
|
1180
1310
|
description: ""
|
|
1181
1311
|
}),
|
|
1312
|
+
definitionContextKey: `form:${e.name}:definition`,
|
|
1313
|
+
definitionContextProvider: () => ({
|
|
1314
|
+
name: `Form definition: ${e.name}`,
|
|
1315
|
+
description: "",
|
|
1316
|
+
stable: !0
|
|
1317
|
+
}),
|
|
1182
1318
|
install: () => () => {
|
|
1183
1319
|
},
|
|
1184
1320
|
hydrate: () => {
|
|
@@ -1187,41 +1323,42 @@ function Je(e) {
|
|
|
1187
1323
|
ok: !1,
|
|
1188
1324
|
error: "Form definition not loaded yet."
|
|
1189
1325
|
}),
|
|
1190
|
-
getValues: () =>
|
|
1326
|
+
getValues: () => S.get().values,
|
|
1191
1327
|
setValues: () => {
|
|
1192
1328
|
},
|
|
1193
1329
|
reset: () => {
|
|
1194
1330
|
},
|
|
1195
|
-
getStatus: () =>
|
|
1196
|
-
}), [e.name,
|
|
1331
|
+
getStatus: () => q
|
|
1332
|
+
}), [e.name, S]);
|
|
1197
1333
|
return {
|
|
1198
|
-
...
|
|
1199
|
-
state:
|
|
1200
|
-
loading:
|
|
1201
|
-
error:
|
|
1334
|
+
...g ?? a,
|
|
1335
|
+
state: x,
|
|
1336
|
+
loading: C,
|
|
1337
|
+
error: A
|
|
1202
1338
|
};
|
|
1203
1339
|
}
|
|
1204
1340
|
export {
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1341
|
+
Ke as AgoProvider,
|
|
1342
|
+
de as ChatInput,
|
|
1343
|
+
Ue as ChatWidget,
|
|
1344
|
+
Ae as Markdown,
|
|
1345
|
+
Ee as Message,
|
|
1346
|
+
j as createFormCollector,
|
|
1347
|
+
qe as createMockClient,
|
|
1348
|
+
He as deriveFormStatus,
|
|
1213
1349
|
O as loadFormCollector,
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1350
|
+
ce as useAgo,
|
|
1351
|
+
Qe as useAgoActivity,
|
|
1352
|
+
Ze as useAgoAutoContinueAfterNavigation,
|
|
1353
|
+
W as useAgoClient,
|
|
1354
|
+
et as useAgoContext,
|
|
1355
|
+
Ve as useAgoFunction,
|
|
1356
|
+
Ye as useAgoNavigation,
|
|
1357
|
+
Xe as useAgoPageState,
|
|
1358
|
+
De as useAgoStore,
|
|
1359
|
+
Je as useChat,
|
|
1360
|
+
Fe as useConversation,
|
|
1361
|
+
tt as useFormCollector,
|
|
1362
|
+
K as useMessages,
|
|
1363
|
+
L as useOptionalAgoClient
|
|
1227
1364
|
};
|