@useago/sdk 1.5.0 → 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 +48 -0
- 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 +79 -2
- package/dist/angular.d.ts +79 -2
- package/dist/angular.js +2 -2
- package/dist/{createConversationSession-BBYfQLLS.cjs → createConversationSession-0WTqcCLK.cjs} +1 -1
- package/dist/{createConversationSession-DCSWShaW.js → createConversationSession-DPrrr70o.js} +1 -1
- package/dist/createFormCollector-1GKKwQV_.cjs +1 -0
- package/dist/{createFormCollector-sB6rMccD.js → createFormCollector-DYh90kiG.js} +97 -91
- package/dist/devtools.d.cts +79 -2
- package/dist/devtools.d.ts +79 -2
- 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 +95 -4
- package/dist/index.d.ts +95 -4
- package/dist/index.js +6 -6
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +186 -4
- package/dist/react.d.ts +186 -4
- package/dist/react.js +670 -475
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +79 -2
- package/dist/testing.d.ts +79 -2
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +79 -2
- package/dist/vue.d.ts +79 -2
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +79 -2
- package/dist/widget.d.ts +79 -2
- package/dist/widget.js +437 -423
- package/llms-full.txt +74 -2
- package/package.json +1 -1
- package/dist/AgoClient-q39FIjSC.js +0 -912
- package/dist/AgoClient-wcPRaIMs.cjs +0 -8
- package/dist/createFormCollector-eimwwWEi.cjs +0 -1
- package/dist/functions-IGSjjvF4.cjs +0 -1
- package/dist/rolldown-runtime-16Nf8qvH.cjs +0 -1
- /package/dist/{autoContinue-D3Mmaaca.js → autoContinue-CC8K9mBU.js} +0 -0
- /package/dist/{autoContinue-CcCTva-D.cjs → autoContinue-CP9pJR-V.cjs} +0 -0
- /package/dist/{createMockClient-CjdCqixj.cjs → createMockClient-C-wrjb2C.cjs} +0 -0
- /package/dist/{createMockClient-BUc9PSbo.js → createMockClient-we-XoPom.js} +0 -0
- /package/dist/{functions-CApuQZ2b.js → functions-tzyOZNp6.js} +0 -0
package/dist/react.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { t as
|
|
3
|
-
import { i as
|
|
4
|
-
import { t as
|
|
5
|
-
import
|
|
6
|
-
import { Fragment as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
function
|
|
10
|
-
const [t, r] =
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
return
|
|
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;
|
|
14
14
|
}, [e?.baseUrl, e?.widgetId]);
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
}), [
|
|
18
|
-
|
|
15
|
+
return N(() => (r(!0), () => {
|
|
16
|
+
o.current?.destroy(), o.current = null;
|
|
17
|
+
}), [n]), N(() => {
|
|
18
|
+
o.current && e && o.current.updateConfig({
|
|
19
19
|
agent: e.agent,
|
|
20
20
|
defaultAgentId: e.defaultAgentId,
|
|
21
21
|
permission: e.permission,
|
|
@@ -33,200 +33,200 @@ function ae(e) {
|
|
|
33
33
|
e?.debug,
|
|
34
34
|
e?.warnOnEmptyReply
|
|
35
35
|
]), {
|
|
36
|
-
client:
|
|
36
|
+
client: n,
|
|
37
37
|
isReady: t
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
var
|
|
41
|
-
const { client:
|
|
42
|
-
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(() => {
|
|
43
43
|
if (!(!r || r.length === 0)) {
|
|
44
|
-
for (const
|
|
44
|
+
for (const m of r) i.register(m);
|
|
45
45
|
return () => {
|
|
46
|
-
for (const
|
|
46
|
+
for (const m of r) i.unregisterFunction(m.name);
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
}, [
|
|
50
|
-
if (!
|
|
51
|
-
const
|
|
52
|
-
return import("./functions-
|
|
53
|
-
for (const [
|
|
54
|
-
const
|
|
55
|
-
if (!
|
|
56
|
-
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}"`);
|
|
57
57
|
continue;
|
|
58
58
|
}
|
|
59
|
-
const
|
|
60
|
-
...
|
|
61
|
-
handler:
|
|
59
|
+
const S = C === !0 ? A : {
|
|
60
|
+
...A,
|
|
61
|
+
handler: C
|
|
62
62
|
};
|
|
63
|
-
|
|
63
|
+
i.register(S), m.push(S.name);
|
|
64
64
|
}
|
|
65
65
|
}), () => {
|
|
66
|
-
for (const u of
|
|
66
|
+
for (const u of m) i.unregisterFunction(u);
|
|
67
67
|
};
|
|
68
|
-
}, [
|
|
69
|
-
|
|
70
|
-
}, [
|
|
71
|
-
value:
|
|
68
|
+
}, [i, o]), N(() => {
|
|
69
|
+
n === "auto" && i.enableAutoPageContext();
|
|
70
|
+
}, [i, n]), /* @__PURE__ */ l(z.Provider, {
|
|
71
|
+
value: i,
|
|
72
72
|
children: e
|
|
73
73
|
});
|
|
74
74
|
};
|
|
75
|
-
function
|
|
76
|
-
const e =
|
|
75
|
+
function W() {
|
|
76
|
+
const e = B(z);
|
|
77
77
|
if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
|
|
78
78
|
return e;
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
return
|
|
80
|
+
function L() {
|
|
81
|
+
return B(z);
|
|
82
82
|
}
|
|
83
|
-
function
|
|
84
|
-
const r =
|
|
85
|
-
if (!
|
|
86
|
-
const [
|
|
87
|
-
|
|
88
|
-
t && t !==
|
|
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
89
|
}, [t]);
|
|
90
|
-
const
|
|
90
|
+
const A = async (S) => {
|
|
91
91
|
try {
|
|
92
|
-
|
|
93
|
-
} catch (
|
|
94
|
-
|
|
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"));
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
-
return
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
return
|
|
102
|
-
...
|
|
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,
|
|
103
103
|
status: "IN_PROGRESS"
|
|
104
|
-
} :
|
|
105
|
-
id:
|
|
106
|
-
conversationId:
|
|
104
|
+
} : b) : h.some((b) => b.role === "assistant" && S(b.status)) ? h : [...h, {
|
|
105
|
+
id: c.messageId,
|
|
106
|
+
conversationId: c.conversationId,
|
|
107
107
|
content: "",
|
|
108
108
|
role: "assistant",
|
|
109
109
|
status: "IN_PROGRESS",
|
|
110
110
|
createdAt: /* @__PURE__ */ new Date()
|
|
111
111
|
}];
|
|
112
112
|
});
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
return
|
|
117
|
-
...
|
|
118
|
-
content:
|
|
119
|
-
} :
|
|
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);
|
|
120
120
|
});
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
let
|
|
124
|
-
for (let
|
|
125
|
-
|
|
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;
|
|
126
126
|
break;
|
|
127
127
|
}
|
|
128
|
-
return
|
|
129
|
-
...
|
|
128
|
+
return w < 0 ? h : [
|
|
129
|
+
...h.slice(0, w),
|
|
130
130
|
{
|
|
131
|
-
...
|
|
132
|
-
...
|
|
131
|
+
...h[w],
|
|
132
|
+
...c
|
|
133
133
|
},
|
|
134
|
-
...
|
|
134
|
+
...h.slice(w + 1)
|
|
135
135
|
];
|
|
136
136
|
});
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
return
|
|
141
|
-
...
|
|
142
|
-
|
|
143
|
-
...
|
|
144
|
-
] : [...
|
|
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
145
|
}), u(!1);
|
|
146
|
-
},
|
|
147
|
-
|
|
146
|
+
}, v = (c) => {
|
|
147
|
+
C(new Error(c.error)), u(!1);
|
|
148
148
|
};
|
|
149
|
-
return
|
|
150
|
-
|
|
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);
|
|
151
151
|
};
|
|
152
|
-
}, [
|
|
153
|
-
messages:
|
|
154
|
-
isLoading:
|
|
155
|
-
error:
|
|
156
|
-
sendMessage:
|
|
157
|
-
u(!0),
|
|
158
|
-
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 = {
|
|
159
159
|
id: `temp-${Date.now()}`,
|
|
160
|
-
conversationId:
|
|
161
|
-
content:
|
|
160
|
+
conversationId: f || "",
|
|
161
|
+
content: S,
|
|
162
162
|
role: "user",
|
|
163
163
|
status: "DONE",
|
|
164
|
-
attachments:
|
|
164
|
+
attachments: k && k.length > 0 ? Y(k) : void 0,
|
|
165
165
|
createdAt: /* @__PURE__ */ new Date()
|
|
166
|
-
},
|
|
166
|
+
}, x = {
|
|
167
167
|
id: `temp-assistant-${Date.now()}`,
|
|
168
|
-
conversationId:
|
|
168
|
+
conversationId: f || "",
|
|
169
169
|
content: "",
|
|
170
170
|
role: "assistant",
|
|
171
171
|
status: "IN_PROGRESS",
|
|
172
172
|
createdAt: /* @__PURE__ */ new Date()
|
|
173
173
|
};
|
|
174
|
-
|
|
175
|
-
...
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
s((a) => [
|
|
175
|
+
...a,
|
|
176
|
+
d,
|
|
177
|
+
x
|
|
178
178
|
]);
|
|
179
179
|
try {
|
|
180
|
-
const
|
|
181
|
-
conversationId:
|
|
182
|
-
files:
|
|
180
|
+
const a = await o.sendMessage(S, {
|
|
181
|
+
conversationId: f,
|
|
182
|
+
files: k
|
|
183
183
|
});
|
|
184
|
-
return
|
|
185
|
-
const
|
|
186
|
-
...C,
|
|
187
|
-
id: C.id.replace("temp-", "user-"),
|
|
188
|
-
conversationId: s.conversationId
|
|
189
|
-
};
|
|
190
|
-
return d.some((m) => m.id === s.id) ? [...d, p].sort((m, g) => new Date(m.createdAt).getTime() - new Date(g.createdAt).getTime()) : [
|
|
184
|
+
return a.conversationId && !f && i(a.conversationId), s((v) => {
|
|
185
|
+
const c = v.filter((w) => !w.id.startsWith("temp-")), h = {
|
|
191
186
|
...d,
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
id: d.id.replace("temp-", "user-"),
|
|
188
|
+
conversationId: a.conversationId
|
|
189
|
+
};
|
|
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,
|
|
193
|
+
a
|
|
194
194
|
];
|
|
195
|
-
}),
|
|
196
|
-
} catch (
|
|
197
|
-
return
|
|
195
|
+
}), a;
|
|
196
|
+
} catch (a) {
|
|
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;
|
|
198
198
|
}
|
|
199
|
-
}, [
|
|
200
|
-
clearMessages:
|
|
201
|
-
|
|
199
|
+
}, [o, f]),
|
|
200
|
+
clearMessages: R(() => {
|
|
201
|
+
s([]), i(void 0), C(null);
|
|
202
202
|
}, []),
|
|
203
|
-
conversationId:
|
|
203
|
+
conversationId: f
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
|
-
var
|
|
207
|
-
const [
|
|
208
|
-
const
|
|
209
|
-
if (!
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
}, []),
|
|
213
|
-
|
|
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;
|
|
209
|
+
if (!a) return;
|
|
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));
|
|
214
214
|
}, [
|
|
215
|
+
s,
|
|
215
216
|
i,
|
|
216
|
-
l,
|
|
217
217
|
e,
|
|
218
|
-
|
|
219
|
-
]),
|
|
220
|
-
|
|
221
|
-
}, [
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
}, []),
|
|
225
|
-
|
|
226
|
-
}, []),
|
|
227
|
-
return /* @__PURE__ */
|
|
228
|
-
onSubmit:
|
|
229
|
-
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}`,
|
|
230
230
|
style: {
|
|
231
231
|
display: "flex",
|
|
232
232
|
flexDirection: "column",
|
|
@@ -235,14 +235,14 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
235
235
|
borderTop: "1px solid #dee3e8",
|
|
236
236
|
backgroundColor: "#fff"
|
|
237
237
|
},
|
|
238
|
-
children: [
|
|
238
|
+
children: [i.length > 0 && /* @__PURE__ */ l("div", {
|
|
239
239
|
className: "ago-chat-input__files",
|
|
240
240
|
style: {
|
|
241
241
|
display: "flex",
|
|
242
242
|
flexWrap: "wrap",
|
|
243
243
|
gap: "6px"
|
|
244
244
|
},
|
|
245
|
-
children:
|
|
245
|
+
children: i.map((a, v) => /* @__PURE__ */ F("div", {
|
|
246
246
|
style: {
|
|
247
247
|
display: "flex",
|
|
248
248
|
alignItems: "center",
|
|
@@ -253,18 +253,18 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
253
253
|
fontSize: "12px",
|
|
254
254
|
color: "#30373e"
|
|
255
255
|
},
|
|
256
|
-
children: [/* @__PURE__ */
|
|
256
|
+
children: [/* @__PURE__ */ l("span", {
|
|
257
257
|
style: {
|
|
258
258
|
maxWidth: "120px",
|
|
259
259
|
overflow: "hidden",
|
|
260
260
|
textOverflow: "ellipsis",
|
|
261
261
|
whiteSpace: "nowrap"
|
|
262
262
|
},
|
|
263
|
-
children:
|
|
264
|
-
}), /* @__PURE__ */
|
|
263
|
+
children: a.name
|
|
264
|
+
}), /* @__PURE__ */ l("button", {
|
|
265
265
|
type: "button",
|
|
266
|
-
onClick: () =>
|
|
267
|
-
"aria-label": `Remove ${
|
|
266
|
+
onClick: () => d(v),
|
|
267
|
+
"aria-label": `Remove ${a.name}`,
|
|
268
268
|
style: {
|
|
269
269
|
border: "none",
|
|
270
270
|
background: "none",
|
|
@@ -276,15 +276,15 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
276
276
|
},
|
|
277
277
|
children: "×"
|
|
278
278
|
})]
|
|
279
|
-
},
|
|
280
|
-
}), /* @__PURE__ */
|
|
279
|
+
}, v))
|
|
280
|
+
}), /* @__PURE__ */ F("div", {
|
|
281
281
|
style: {
|
|
282
282
|
display: "flex",
|
|
283
283
|
gap: "8px",
|
|
284
284
|
alignItems: "flex-end"
|
|
285
285
|
},
|
|
286
286
|
children: [
|
|
287
|
-
|
|
287
|
+
o && /* @__PURE__ */ F(G, { children: [/* @__PURE__ */ l("button", {
|
|
288
288
|
type: "button",
|
|
289
289
|
onClick: () => u.current?.click(),
|
|
290
290
|
disabled: t,
|
|
@@ -300,20 +300,20 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
300
300
|
lineHeight: 1
|
|
301
301
|
},
|
|
302
302
|
children: "+"
|
|
303
|
-
}), /* @__PURE__ */
|
|
303
|
+
}), /* @__PURE__ */ l("input", {
|
|
304
304
|
ref: u,
|
|
305
305
|
type: "file",
|
|
306
306
|
multiple: !0,
|
|
307
|
-
onChange:
|
|
307
|
+
onChange: k,
|
|
308
308
|
style: { display: "none" }
|
|
309
309
|
})] }),
|
|
310
|
-
/* @__PURE__ */
|
|
311
|
-
ref:
|
|
312
|
-
value:
|
|
313
|
-
onChange: (
|
|
314
|
-
|
|
310
|
+
/* @__PURE__ */ l("textarea", {
|
|
311
|
+
ref: g,
|
|
312
|
+
value: s,
|
|
313
|
+
onChange: (a) => {
|
|
314
|
+
f(a.target.value), C();
|
|
315
315
|
},
|
|
316
|
-
onKeyDown:
|
|
316
|
+
onKeyDown: S,
|
|
317
317
|
placeholder: r,
|
|
318
318
|
"aria-label": r,
|
|
319
319
|
disabled: t,
|
|
@@ -335,23 +335,23 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
335
335
|
backgroundColor: "#f8f8f8",
|
|
336
336
|
transition: "border-color 0.15s"
|
|
337
337
|
},
|
|
338
|
-
onFocus: (
|
|
339
|
-
|
|
338
|
+
onFocus: (a) => {
|
|
339
|
+
a.currentTarget.style.borderColor = "#1b5fc4";
|
|
340
340
|
},
|
|
341
|
-
onBlur: (
|
|
342
|
-
|
|
341
|
+
onBlur: (a) => {
|
|
342
|
+
a.currentTarget.style.borderColor = "#dee3e8";
|
|
343
343
|
}
|
|
344
344
|
}),
|
|
345
|
-
/* @__PURE__ */
|
|
345
|
+
/* @__PURE__ */ l("button", {
|
|
346
346
|
type: "submit",
|
|
347
|
-
disabled: t || !
|
|
347
|
+
disabled: t || !x,
|
|
348
348
|
style: {
|
|
349
349
|
padding: "10px 18px",
|
|
350
350
|
border: "none",
|
|
351
351
|
borderRadius: "20px",
|
|
352
|
-
backgroundColor: t || !
|
|
352
|
+
backgroundColor: t || !x ? "#b5bfc8" : "#03182f",
|
|
353
353
|
color: "#fff",
|
|
354
|
-
cursor: t || !
|
|
354
|
+
cursor: t || !x ? "not-allowed" : "pointer",
|
|
355
355
|
fontWeight: 500,
|
|
356
356
|
fontSize: "16px",
|
|
357
357
|
transition: "background-color 0.15s"
|
|
@@ -361,7 +361,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
361
361
|
]
|
|
362
362
|
})]
|
|
363
363
|
});
|
|
364
|
-
},
|
|
364
|
+
}, ue = ({ href: e, children: t, ...r }) => /* @__PURE__ */ l("a", {
|
|
365
365
|
href: e,
|
|
366
366
|
target: "_blank",
|
|
367
367
|
rel: "noopener noreferrer",
|
|
@@ -371,25 +371,25 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
371
371
|
},
|
|
372
372
|
...r,
|
|
373
373
|
children: t
|
|
374
|
-
}),
|
|
374
|
+
}), fe = ({ children: e, ...t }) => /* @__PURE__ */ l("p", {
|
|
375
375
|
style: {
|
|
376
376
|
margin: "0 0 8px 0",
|
|
377
377
|
lineHeight: "1.6"
|
|
378
378
|
},
|
|
379
379
|
...t,
|
|
380
380
|
children: e
|
|
381
|
-
}),
|
|
382
|
-
const r = ({ children:
|
|
381
|
+
}), P = (e, t) => {
|
|
382
|
+
const r = ({ children: o, ...n }) => re.createElement(`h${e}`, {
|
|
383
383
|
style: {
|
|
384
384
|
margin: "16px 0 8px 0",
|
|
385
385
|
fontSize: t,
|
|
386
386
|
fontWeight: 600,
|
|
387
387
|
lineHeight: "1.3"
|
|
388
388
|
},
|
|
389
|
-
...
|
|
390
|
-
},
|
|
389
|
+
...n
|
|
390
|
+
}, o);
|
|
391
391
|
return r.displayName = `MarkdownHeading${e}`, r;
|
|
392
|
-
},
|
|
392
|
+
}, pe = ({ children: e, ...t }) => /* @__PURE__ */ l("ul", {
|
|
393
393
|
style: {
|
|
394
394
|
margin: "0 0 8px 0",
|
|
395
395
|
paddingLeft: "20px",
|
|
@@ -398,7 +398,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
398
398
|
},
|
|
399
399
|
...t,
|
|
400
400
|
children: e
|
|
401
|
-
}),
|
|
401
|
+
}), ge = ({ children: e, ...t }) => /* @__PURE__ */ l("ol", {
|
|
402
402
|
style: {
|
|
403
403
|
margin: "0 0 8px 0",
|
|
404
404
|
paddingLeft: "20px",
|
|
@@ -407,7 +407,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
407
407
|
},
|
|
408
408
|
...t,
|
|
409
409
|
children: e
|
|
410
|
-
}),
|
|
410
|
+
}), me = ({ children: e, ...t }) => /* @__PURE__ */ l("li", {
|
|
411
411
|
style: {
|
|
412
412
|
display: "list-item",
|
|
413
413
|
margin: "2px 0",
|
|
@@ -415,8 +415,8 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
415
415
|
},
|
|
416
416
|
...t,
|
|
417
417
|
children: e
|
|
418
|
-
}),
|
|
419
|
-
`) ? /* @__PURE__ */
|
|
418
|
+
}), xe = ({ className: e, children: t, ...r }) => e !== void 0 || String(t).includes(`
|
|
419
|
+
`) ? /* @__PURE__ */ l("code", {
|
|
420
420
|
style: {
|
|
421
421
|
display: "block",
|
|
422
422
|
background: "#f5f5f5",
|
|
@@ -428,7 +428,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
428
428
|
},
|
|
429
429
|
...r,
|
|
430
430
|
children: t
|
|
431
|
-
}) : /* @__PURE__ */
|
|
431
|
+
}) : /* @__PURE__ */ l("code", {
|
|
432
432
|
style: {
|
|
433
433
|
background: "#f0f2f5",
|
|
434
434
|
padding: "2px 5px",
|
|
@@ -438,11 +438,11 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
438
438
|
},
|
|
439
439
|
...r,
|
|
440
440
|
children: t
|
|
441
|
-
}),
|
|
441
|
+
}), he = ({ children: e, ...t }) => /* @__PURE__ */ l("pre", {
|
|
442
442
|
style: { margin: "0 0 8px 0" },
|
|
443
443
|
...t,
|
|
444
444
|
children: e
|
|
445
|
-
}),
|
|
445
|
+
}), ye = ({ children: e, ...t }) => /* @__PURE__ */ l("blockquote", {
|
|
446
446
|
style: {
|
|
447
447
|
borderLeft: "4px solid #dee3e8",
|
|
448
448
|
paddingLeft: "12px",
|
|
@@ -452,12 +452,12 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
452
452
|
},
|
|
453
453
|
...t,
|
|
454
454
|
children: e
|
|
455
|
-
}),
|
|
455
|
+
}), ve = ({ children: e, ...t }) => /* @__PURE__ */ l("div", {
|
|
456
456
|
style: {
|
|
457
457
|
overflowX: "auto",
|
|
458
458
|
margin: "0 0 8px 0"
|
|
459
459
|
},
|
|
460
|
-
children: /* @__PURE__ */
|
|
460
|
+
children: /* @__PURE__ */ l("table", {
|
|
461
461
|
style: {
|
|
462
462
|
borderCollapse: "collapse",
|
|
463
463
|
width: "100%",
|
|
@@ -466,7 +466,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
466
466
|
...t,
|
|
467
467
|
children: e
|
|
468
468
|
})
|
|
469
|
-
}),
|
|
469
|
+
}), be = ({ children: e, ...t }) => /* @__PURE__ */ l("th", {
|
|
470
470
|
style: {
|
|
471
471
|
border: "1px solid #dee3e8",
|
|
472
472
|
padding: "6px 10px",
|
|
@@ -476,14 +476,14 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
476
476
|
},
|
|
477
477
|
...t,
|
|
478
478
|
children: e
|
|
479
|
-
}),
|
|
479
|
+
}), we = ({ children: e, ...t }) => /* @__PURE__ */ l("td", {
|
|
480
480
|
style: {
|
|
481
481
|
border: "1px solid #dee3e8",
|
|
482
482
|
padding: "6px 10px"
|
|
483
483
|
},
|
|
484
484
|
...t,
|
|
485
485
|
children: e
|
|
486
|
-
}),
|
|
486
|
+
}), Ce = ({ alt: e, ...t }) => /* @__PURE__ */ l("img", {
|
|
487
487
|
alt: e ?? "",
|
|
488
488
|
style: {
|
|
489
489
|
maxWidth: "100%",
|
|
@@ -491,40 +491,40 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
491
491
|
margin: "4px 0"
|
|
492
492
|
},
|
|
493
493
|
...t
|
|
494
|
-
}),
|
|
494
|
+
}), Se = (e) => /* @__PURE__ */ l("hr", {
|
|
495
495
|
style: {
|
|
496
496
|
border: "none",
|
|
497
497
|
borderTop: "1px solid #dee3e8",
|
|
498
498
|
margin: "12px 0"
|
|
499
499
|
},
|
|
500
500
|
...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:
|
|
501
|
+
}), ke = {
|
|
502
|
+
a: ue,
|
|
503
|
+
p: fe,
|
|
504
|
+
h1: P(1, "20px"),
|
|
505
|
+
h2: P(2, "18px"),
|
|
506
|
+
h3: P(3, "16px"),
|
|
507
|
+
h4: P(4, "15px"),
|
|
508
|
+
h5: P(5, "14px"),
|
|
509
|
+
h6: P(6, "13px"),
|
|
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,
|
|
524
524
|
children: e
|
|
525
|
-
}),
|
|
526
|
-
const r =
|
|
527
|
-
if (
|
|
525
|
+
}), Ne = ({ attachment: e, isUser: t }) => {
|
|
526
|
+
const r = Q(e.url);
|
|
527
|
+
if (V(e)) return /* @__PURE__ */ l("a", {
|
|
528
528
|
href: r,
|
|
529
529
|
target: "_blank",
|
|
530
530
|
rel: "noopener noreferrer",
|
|
@@ -532,7 +532,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
532
532
|
display: "inline-block",
|
|
533
533
|
textDecoration: "none"
|
|
534
534
|
},
|
|
535
|
-
children: /* @__PURE__ */
|
|
535
|
+
children: /* @__PURE__ */ l("img", {
|
|
536
536
|
src: r,
|
|
537
537
|
alt: e.name,
|
|
538
538
|
loading: "lazy",
|
|
@@ -546,7 +546,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
546
546
|
}
|
|
547
547
|
})
|
|
548
548
|
});
|
|
549
|
-
const
|
|
549
|
+
const o = Z(e.fileSize), n = /* @__PURE__ */ F(G, { children: [/* @__PURE__ */ l("span", {
|
|
550
550
|
style: {
|
|
551
551
|
fontSize: "16px",
|
|
552
552
|
lineHeight: 1,
|
|
@@ -554,13 +554,13 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
554
554
|
},
|
|
555
555
|
"aria-hidden": !0,
|
|
556
556
|
children: "📄"
|
|
557
|
-
}), /* @__PURE__ */
|
|
557
|
+
}), /* @__PURE__ */ F("span", {
|
|
558
558
|
style: {
|
|
559
559
|
display: "flex",
|
|
560
560
|
flexDirection: "column",
|
|
561
561
|
minWidth: 0
|
|
562
562
|
},
|
|
563
|
-
children: [/* @__PURE__ */
|
|
563
|
+
children: [/* @__PURE__ */ l("span", {
|
|
564
564
|
style: {
|
|
565
565
|
overflow: "hidden",
|
|
566
566
|
textOverflow: "ellipsis",
|
|
@@ -569,14 +569,14 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
569
569
|
},
|
|
570
570
|
title: e.name,
|
|
571
571
|
children: e.name
|
|
572
|
-
}),
|
|
572
|
+
}), o && /* @__PURE__ */ l("span", {
|
|
573
573
|
style: {
|
|
574
574
|
fontSize: "11px",
|
|
575
575
|
color: "#6b6d6f"
|
|
576
576
|
},
|
|
577
|
-
children:
|
|
577
|
+
children: o
|
|
578
578
|
})]
|
|
579
|
-
})] }),
|
|
579
|
+
})] }), s = {
|
|
580
580
|
display: "inline-flex",
|
|
581
581
|
alignItems: "center",
|
|
582
582
|
gap: "8px",
|
|
@@ -589,18 +589,18 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
589
589
|
textDecoration: "none",
|
|
590
590
|
maxWidth: "220px"
|
|
591
591
|
};
|
|
592
|
-
return r ? /* @__PURE__ */
|
|
592
|
+
return r ? /* @__PURE__ */ l("a", {
|
|
593
593
|
href: r,
|
|
594
594
|
target: "_blank",
|
|
595
595
|
rel: "noopener noreferrer",
|
|
596
|
-
style:
|
|
597
|
-
children:
|
|
598
|
-
}) : /* @__PURE__ */
|
|
599
|
-
style:
|
|
600
|
-
children:
|
|
596
|
+
style: s,
|
|
597
|
+
children: n
|
|
598
|
+
}) : /* @__PURE__ */ l("div", {
|
|
599
|
+
style: s,
|
|
600
|
+
children: n
|
|
601
601
|
});
|
|
602
|
-
},
|
|
603
|
-
const r = /* @__PURE__ */
|
|
602
|
+
}, Re = ({ source: e, index: t }) => {
|
|
603
|
+
const r = /* @__PURE__ */ F("div", {
|
|
604
604
|
style: {
|
|
605
605
|
display: "flex",
|
|
606
606
|
alignItems: "center",
|
|
@@ -608,7 +608,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
608
608
|
width: "100%",
|
|
609
609
|
minWidth: 0
|
|
610
610
|
},
|
|
611
|
-
children: [/* @__PURE__ */
|
|
611
|
+
children: [/* @__PURE__ */ l("div", {
|
|
612
612
|
style: {
|
|
613
613
|
flexShrink: 0,
|
|
614
614
|
width: "18px",
|
|
@@ -624,7 +624,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
624
624
|
backgroundColor: "#f0f4ff"
|
|
625
625
|
},
|
|
626
626
|
children: t + 1
|
|
627
|
-
}), /* @__PURE__ */
|
|
627
|
+
}), /* @__PURE__ */ l("div", {
|
|
628
628
|
style: {
|
|
629
629
|
fontSize: "12px",
|
|
630
630
|
overflow: "hidden",
|
|
@@ -635,7 +635,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
635
635
|
title: e.title,
|
|
636
636
|
children: e.title
|
|
637
637
|
})]
|
|
638
|
-
}),
|
|
638
|
+
}), o = {
|
|
639
639
|
display: "flex",
|
|
640
640
|
alignItems: "center",
|
|
641
641
|
padding: "8px 10px",
|
|
@@ -648,23 +648,23 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
648
648
|
minWidth: 0,
|
|
649
649
|
transition: "border-color 0.15s"
|
|
650
650
|
};
|
|
651
|
-
return e.url ? /* @__PURE__ */
|
|
651
|
+
return e.url ? /* @__PURE__ */ l("a", {
|
|
652
652
|
href: e.url,
|
|
653
653
|
target: "_blank",
|
|
654
654
|
rel: "noopener noreferrer",
|
|
655
|
-
style:
|
|
656
|
-
onMouseEnter: (
|
|
657
|
-
|
|
655
|
+
style: o,
|
|
656
|
+
onMouseEnter: (n) => {
|
|
657
|
+
n.currentTarget.style.borderColor = "#1b5fc4";
|
|
658
658
|
},
|
|
659
|
-
onMouseLeave: (
|
|
660
|
-
|
|
659
|
+
onMouseLeave: (n) => {
|
|
660
|
+
n.currentTarget.style.borderColor = "#dee3e8";
|
|
661
661
|
},
|
|
662
662
|
children: r
|
|
663
|
-
}) : /* @__PURE__ */
|
|
664
|
-
style:
|
|
663
|
+
}) : /* @__PURE__ */ l("div", {
|
|
664
|
+
style: o,
|
|
665
665
|
children: r
|
|
666
666
|
});
|
|
667
|
-
},
|
|
667
|
+
}, Me = () => /* @__PURE__ */ F("div", {
|
|
668
668
|
style: {
|
|
669
669
|
display: "flex",
|
|
670
670
|
gap: "4px",
|
|
@@ -674,31 +674,31 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
674
674
|
0,
|
|
675
675
|
1,
|
|
676
676
|
2
|
|
677
|
-
].map((e) => /* @__PURE__ */
|
|
677
|
+
].map((e) => /* @__PURE__ */ l("div", { style: {
|
|
678
678
|
width: "6px",
|
|
679
679
|
height: "6px",
|
|
680
680
|
borderRadius: "50%",
|
|
681
681
|
backgroundColor: "#b5bfc8",
|
|
682
682
|
animation: "ago-pulse 1.2s ease-in-out infinite",
|
|
683
683
|
animationDelay: `${e * 0.2}s`
|
|
684
|
-
} }, e)), /* @__PURE__ */
|
|
684
|
+
} }, e)), /* @__PURE__ */ l("style", { children: `
|
|
685
685
|
@keyframes ago-pulse {
|
|
686
686
|
0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
|
|
687
687
|
40% { opacity: 1; transform: scale(1); }
|
|
688
688
|
}
|
|
689
689
|
` })]
|
|
690
|
-
}),
|
|
691
|
-
const
|
|
692
|
-
return /* @__PURE__ */
|
|
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
693
|
className: `ago-message ago-message--${e.role} ${t}`,
|
|
694
694
|
style: {
|
|
695
695
|
display: "flex",
|
|
696
696
|
flexDirection: "column",
|
|
697
|
-
alignItems:
|
|
697
|
+
alignItems: s ? "flex-end" : "flex-start",
|
|
698
698
|
marginBottom: "16px"
|
|
699
699
|
},
|
|
700
700
|
children: [
|
|
701
|
-
!
|
|
701
|
+
!s && r && e.agent && /* @__PURE__ */ l("div", {
|
|
702
702
|
className: "ago-message__agent",
|
|
703
703
|
style: {
|
|
704
704
|
display: "flex",
|
|
@@ -712,7 +712,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
712
712
|
},
|
|
713
713
|
children: e.agent.displayName || e.agent.name
|
|
714
714
|
}),
|
|
715
|
-
!
|
|
715
|
+
!s && e.sources && e.sources.length > 0 && /* @__PURE__ */ l("div", {
|
|
716
716
|
className: "ago-message__sources",
|
|
717
717
|
style: {
|
|
718
718
|
display: "grid",
|
|
@@ -722,41 +722,41 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
722
722
|
width: "100%",
|
|
723
723
|
maxWidth: "85%"
|
|
724
724
|
},
|
|
725
|
-
children: e.sources.map((
|
|
726
|
-
source:
|
|
727
|
-
index:
|
|
728
|
-
},
|
|
725
|
+
children: e.sources.map((i, m) => /* @__PURE__ */ l(Re, {
|
|
726
|
+
source: i,
|
|
727
|
+
index: m
|
|
728
|
+
}, i.id))
|
|
729
729
|
}),
|
|
730
|
-
e.attachments && e.attachments.length > 0 && /* @__PURE__ */
|
|
730
|
+
e.attachments && e.attachments.length > 0 && /* @__PURE__ */ l("div", {
|
|
731
731
|
className: "ago-message__attachments",
|
|
732
732
|
style: {
|
|
733
733
|
display: "flex",
|
|
734
734
|
flexWrap: "wrap",
|
|
735
735
|
gap: "6px",
|
|
736
736
|
marginBottom: "6px",
|
|
737
|
-
justifyContent:
|
|
737
|
+
justifyContent: s ? "flex-end" : "flex-start",
|
|
738
738
|
maxWidth: "75%"
|
|
739
739
|
},
|
|
740
|
-
children: e.attachments.map((
|
|
741
|
-
attachment:
|
|
742
|
-
isUser:
|
|
743
|
-
},
|
|
740
|
+
children: e.attachments.map((i) => /* @__PURE__ */ l(Ne, {
|
|
741
|
+
attachment: i,
|
|
742
|
+
isUser: s
|
|
743
|
+
}, i.id))
|
|
744
744
|
}),
|
|
745
|
-
(e.content ||
|
|
745
|
+
(e.content || f) && /* @__PURE__ */ l("div", {
|
|
746
746
|
className: "ago-message__content",
|
|
747
747
|
style: {
|
|
748
|
-
maxWidth:
|
|
749
|
-
padding:
|
|
750
|
-
borderRadius:
|
|
751
|
-
backgroundColor:
|
|
752
|
-
color:
|
|
748
|
+
maxWidth: s ? "75%" : "100%",
|
|
749
|
+
padding: s ? "10px 14px" : "2px 8px",
|
|
750
|
+
borderRadius: s ? "16px" : "0",
|
|
751
|
+
backgroundColor: s ? "#03182f" : "transparent",
|
|
752
|
+
color: s ? "#fff" : "#30373e",
|
|
753
753
|
wordBreak: "break-word",
|
|
754
754
|
fontSize: "16px",
|
|
755
755
|
lineHeight: "1.6"
|
|
756
756
|
},
|
|
757
|
-
children: e.content ? /* @__PURE__ */
|
|
757
|
+
children: e.content ? /* @__PURE__ */ l(Ae, { content: e.content }) : f && /* @__PURE__ */ l(Me, {})
|
|
758
758
|
}),
|
|
759
|
-
|
|
759
|
+
o && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ l("div", {
|
|
760
760
|
className: "ago-message__followups",
|
|
761
761
|
style: {
|
|
762
762
|
display: "flex",
|
|
@@ -764,11 +764,11 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
764
764
|
gap: "8px",
|
|
765
765
|
marginTop: "10px"
|
|
766
766
|
},
|
|
767
|
-
children: e.followUpReplies.map((
|
|
767
|
+
children: e.followUpReplies.map((i, m) => /* @__PURE__ */ l("button", {
|
|
768
768
|
type: "button",
|
|
769
769
|
className: "ago-message__followup-btn",
|
|
770
|
-
disabled: !
|
|
771
|
-
onClick:
|
|
770
|
+
disabled: !n,
|
|
771
|
+
onClick: n ? () => n(i) : void 0,
|
|
772
772
|
style: {
|
|
773
773
|
minHeight: "36px",
|
|
774
774
|
padding: "6px 14px",
|
|
@@ -777,7 +777,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
777
777
|
border: "1px solid #dee3e8",
|
|
778
778
|
backgroundColor: "#fff",
|
|
779
779
|
color: "#30373e",
|
|
780
|
-
cursor:
|
|
780
|
+
cursor: n ? "pointer" : "default",
|
|
781
781
|
transition: "border-color 0.15s"
|
|
782
782
|
},
|
|
783
783
|
onMouseEnter: (u) => {
|
|
@@ -786,50 +786,50 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
786
786
|
onMouseLeave: (u) => {
|
|
787
787
|
u.currentTarget.style.borderColor = "#dee3e8";
|
|
788
788
|
},
|
|
789
|
-
children:
|
|
790
|
-
},
|
|
789
|
+
children: i
|
|
790
|
+
}, m))
|
|
791
791
|
})
|
|
792
792
|
]
|
|
793
793
|
});
|
|
794
|
-
},
|
|
795
|
-
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({
|
|
796
796
|
client: e,
|
|
797
797
|
conversationId: t
|
|
798
798
|
});
|
|
799
|
-
|
|
800
|
-
if (!
|
|
801
|
-
let
|
|
802
|
-
const
|
|
803
|
-
return Promise.all(u.map((
|
|
804
|
-
if (!
|
|
805
|
-
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));
|
|
806
806
|
}).catch(() => {
|
|
807
807
|
}), () => {
|
|
808
|
-
|
|
808
|
+
p = !0, I.forEach((M) => M());
|
|
809
809
|
};
|
|
810
|
-
}, [
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
])) : ""]),
|
|
816
|
-
|
|
817
|
-
}, [
|
|
818
|
-
const
|
|
819
|
-
|
|
820
|
-
id:
|
|
821
|
-
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
|
|
822
822
|
});
|
|
823
|
-
}, [
|
|
824
|
-
const
|
|
825
|
-
|
|
826
|
-
},
|
|
827
|
-
return /* @__PURE__ */
|
|
828
|
-
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}`,
|
|
829
829
|
style: {
|
|
830
830
|
display: "flex",
|
|
831
831
|
flexDirection: "column",
|
|
832
|
-
height: typeof
|
|
832
|
+
height: typeof f == "number" ? `${f}px` : f,
|
|
833
833
|
border: "1px solid #dee3e8",
|
|
834
834
|
borderRadius: "16px",
|
|
835
835
|
overflow: "hidden",
|
|
@@ -839,7 +839,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
839
839
|
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
|
|
840
840
|
},
|
|
841
841
|
children: [
|
|
842
|
-
/* @__PURE__ */
|
|
842
|
+
/* @__PURE__ */ F("div", {
|
|
843
843
|
className: "ago-chat-widget__header",
|
|
844
844
|
style: {
|
|
845
845
|
padding: "14px 16px",
|
|
@@ -850,14 +850,14 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
850
850
|
alignItems: "center",
|
|
851
851
|
gap: "10px"
|
|
852
852
|
},
|
|
853
|
-
children: [
|
|
854
|
-
src:
|
|
853
|
+
children: [i && /* @__PURE__ */ l("img", {
|
|
854
|
+
src: i,
|
|
855
855
|
alt: "Logo",
|
|
856
856
|
style: {
|
|
857
857
|
height: "24px",
|
|
858
858
|
width: "auto"
|
|
859
859
|
}
|
|
860
|
-
}), /* @__PURE__ */
|
|
860
|
+
}), /* @__PURE__ */ l("h3", {
|
|
861
861
|
style: {
|
|
862
862
|
margin: 0,
|
|
863
863
|
fontSize: "15px",
|
|
@@ -866,7 +866,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
866
866
|
children: r
|
|
867
867
|
})]
|
|
868
868
|
}),
|
|
869
|
-
/* @__PURE__ */
|
|
869
|
+
/* @__PURE__ */ F("div", {
|
|
870
870
|
className: "ago-chat-widget__messages",
|
|
871
871
|
role: "log",
|
|
872
872
|
"aria-live": "polite",
|
|
@@ -879,7 +879,7 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
879
879
|
backgroundColor: "#fbfbfb"
|
|
880
880
|
},
|
|
881
881
|
children: [
|
|
882
|
-
|
|
882
|
+
a.length === 0 ? /* @__PURE__ */ l("div", {
|
|
883
883
|
style: {
|
|
884
884
|
textAlign: "center",
|
|
885
885
|
color: "#6b6d6f",
|
|
@@ -887,14 +887,14 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
887
887
|
fontSize: "16px",
|
|
888
888
|
lineHeight: "1.5"
|
|
889
889
|
},
|
|
890
|
-
children:
|
|
891
|
-
}) :
|
|
892
|
-
message:
|
|
893
|
-
showAgentName:
|
|
894
|
-
isLast:
|
|
895
|
-
onFollowUpClick:
|
|
896
|
-
},
|
|
897
|
-
|
|
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", {
|
|
898
898
|
role: "alert",
|
|
899
899
|
style: {
|
|
900
900
|
padding: "10px 14px",
|
|
@@ -905,222 +905,416 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
905
905
|
fontSize: "13px",
|
|
906
906
|
border: "1px solid #fecaca"
|
|
907
907
|
},
|
|
908
|
-
children:
|
|
908
|
+
children: c.message
|
|
909
909
|
}),
|
|
910
|
-
/* @__PURE__ */
|
|
910
|
+
/* @__PURE__ */ l("div", { ref: k })
|
|
911
911
|
]
|
|
912
912
|
}),
|
|
913
|
-
/* @__PURE__ */
|
|
914
|
-
onSend:
|
|
915
|
-
disabled:
|
|
916
|
-
placeholder:
|
|
917
|
-
allowFiles:
|
|
913
|
+
/* @__PURE__ */ l(de, {
|
|
914
|
+
onSend: w,
|
|
915
|
+
disabled: _,
|
|
916
|
+
placeholder: n,
|
|
917
|
+
allowFiles: s
|
|
918
918
|
})
|
|
919
919
|
]
|
|
920
920
|
});
|
|
921
921
|
};
|
|
922
|
-
function
|
|
923
|
-
const r =
|
|
924
|
-
if (!
|
|
925
|
-
const [
|
|
926
|
-
u(!0),
|
|
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);
|
|
927
927
|
try {
|
|
928
|
-
|
|
929
|
-
} catch (
|
|
930
|
-
|
|
928
|
+
s(await o.getConversations());
|
|
929
|
+
} catch (d) {
|
|
930
|
+
C(d instanceof Error ? d : /* @__PURE__ */ new Error("Failed to load conversations"));
|
|
931
931
|
} finally {
|
|
932
932
|
u(!1);
|
|
933
933
|
}
|
|
934
|
-
}, [
|
|
935
|
-
u(!0),
|
|
934
|
+
}, [o]), S = R(async (d) => {
|
|
935
|
+
u(!0), C(null);
|
|
936
936
|
try {
|
|
937
|
-
|
|
938
|
-
} catch (
|
|
939
|
-
|
|
937
|
+
i(await o.getConversation(d));
|
|
938
|
+
} catch (x) {
|
|
939
|
+
C(x instanceof Error ? x : /* @__PURE__ */ new Error("Failed to load conversation"));
|
|
940
940
|
} finally {
|
|
941
941
|
u(!1);
|
|
942
942
|
}
|
|
943
|
-
}, [
|
|
944
|
-
|
|
943
|
+
}, [o]), k = R(() => {
|
|
944
|
+
i(null);
|
|
945
945
|
}, []);
|
|
946
|
-
return
|
|
947
|
-
t &&
|
|
948
|
-
}, [t,
|
|
949
|
-
conversations:
|
|
950
|
-
currentConversation:
|
|
951
|
-
isLoading:
|
|
952
|
-
error:
|
|
953
|
-
selectConversation:
|
|
954
|
-
startNewConversation:
|
|
955
|
-
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
|
|
956
956
|
};
|
|
957
957
|
}
|
|
958
|
-
function
|
|
959
|
-
const t =
|
|
958
|
+
function Je(e = {}) {
|
|
959
|
+
const t = L(), r = e.client || t;
|
|
960
960
|
if (!r) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
961
|
-
const
|
|
961
|
+
const o = K({
|
|
962
962
|
client: r,
|
|
963
963
|
conversationId: e.conversationId
|
|
964
|
-
}),
|
|
964
|
+
}), n = Fe({
|
|
965
965
|
client: r,
|
|
966
966
|
autoLoad: e.autoLoad
|
|
967
967
|
});
|
|
968
968
|
return {
|
|
969
|
-
messages:
|
|
970
|
-
isLoading:
|
|
971
|
-
error:
|
|
972
|
-
sendMessage:
|
|
973
|
-
clearMessages:
|
|
974
|
-
conversationId:
|
|
975
|
-
conversations:
|
|
976
|
-
currentConversation:
|
|
977
|
-
isConversationsLoading:
|
|
978
|
-
selectConversation:
|
|
979
|
-
startNewConversation:
|
|
980
|
-
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
|
|
981
981
|
};
|
|
982
982
|
}
|
|
983
|
-
function
|
|
984
|
-
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" ? {
|
|
985
985
|
name: e,
|
|
986
986
|
...t
|
|
987
|
-
} : e,
|
|
988
|
-
|
|
989
|
-
const
|
|
990
|
-
return r.registerFunction(
|
|
991
|
-
description:
|
|
992
|
-
parameters:
|
|
993
|
-
maxResultBytes:
|
|
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,
|
|
992
|
+
parameters: s,
|
|
993
|
+
maxResultBytes: i,
|
|
994
|
+
requiresApproval: m
|
|
994
995
|
}), () => {
|
|
995
|
-
r.unregisterFunction(
|
|
996
|
+
r.unregisterFunction(o);
|
|
996
997
|
};
|
|
997
998
|
}, [
|
|
998
999
|
r,
|
|
999
|
-
n,
|
|
1000
1000
|
o,
|
|
1001
|
+
n,
|
|
1002
|
+
s,
|
|
1001
1003
|
i,
|
|
1002
|
-
|
|
1004
|
+
m
|
|
1003
1005
|
]);
|
|
1004
1006
|
}
|
|
1005
|
-
function
|
|
1006
|
-
const r =
|
|
1007
|
-
|
|
1007
|
+
function Ye(e, t) {
|
|
1008
|
+
const r = W(), o = T(e);
|
|
1009
|
+
o.current = e, N(() => (r.registerNavigationFunction((n) => o.current(n), t), () => {
|
|
1008
1010
|
r.unregisterNavigationFunction();
|
|
1009
1011
|
}), [r, t]);
|
|
1010
1012
|
}
|
|
1011
|
-
function
|
|
1012
|
-
const r =
|
|
1013
|
-
|
|
1014
|
-
const
|
|
1015
|
-
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;
|
|
1016
1018
|
return {
|
|
1017
|
-
name:
|
|
1018
|
-
description:
|
|
1019
|
-
schema:
|
|
1020
|
-
get:
|
|
1021
|
-
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)
|
|
1022
1024
|
};
|
|
1023
1025
|
});
|
|
1024
|
-
return r.registerPageStateFunction(
|
|
1025
|
-
|
|
1026
|
+
return r.registerPageStateFunction(f, {
|
|
1027
|
+
functionName: o,
|
|
1028
|
+
requiresApproval: n
|
|
1029
|
+
}), () => {
|
|
1030
|
+
r.unregisterPageStateFunction(o);
|
|
1026
1031
|
};
|
|
1027
|
-
}, [
|
|
1032
|
+
}, [
|
|
1033
|
+
r,
|
|
1034
|
+
o,
|
|
1035
|
+
n
|
|
1036
|
+
]);
|
|
1037
|
+
}
|
|
1038
|
+
function Ze(e) {
|
|
1039
|
+
const t = W(), r = T(e);
|
|
1040
|
+
r.current = e, N(() => te(t, () => r.current), [t]);
|
|
1041
|
+
}
|
|
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
|
+
}
|
|
1028
1056
|
}
|
|
1029
|
-
function
|
|
1030
|
-
|
|
1031
|
-
|
|
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", _);
|
|
1177
|
+
};
|
|
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
|
+
};
|
|
1032
1220
|
}
|
|
1033
|
-
function
|
|
1034
|
-
const r =
|
|
1035
|
-
|
|
1036
|
-
const
|
|
1037
|
-
|
|
1038
|
-
if (typeof
|
|
1039
|
-
const
|
|
1040
|
-
return r.addDynamicContext(
|
|
1041
|
-
r.removeDynamicContext(
|
|
1221
|
+
function et(e, t) {
|
|
1222
|
+
const r = W(), o = ae(), n = t ?? o, s = T(e);
|
|
1223
|
+
s.current = e;
|
|
1224
|
+
const f = typeof e == "function";
|
|
1225
|
+
N(() => {
|
|
1226
|
+
if (typeof s.current == "function") {
|
|
1227
|
+
const i = () => s.current();
|
|
1228
|
+
return r.addDynamicContext(n, i), () => {
|
|
1229
|
+
r.removeDynamicContext(n);
|
|
1042
1230
|
};
|
|
1043
1231
|
}
|
|
1044
|
-
return r.setContext(
|
|
1045
|
-
r.removeContext(
|
|
1232
|
+
return r.setContext(n, s.current), () => {
|
|
1233
|
+
r.removeContext(n);
|
|
1046
1234
|
};
|
|
1047
1235
|
}, [
|
|
1048
1236
|
r,
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1237
|
+
n,
|
|
1238
|
+
f,
|
|
1239
|
+
f ? "" : JSON.stringify(e)
|
|
1052
1240
|
]);
|
|
1053
1241
|
}
|
|
1054
|
-
function
|
|
1055
|
-
return
|
|
1242
|
+
function De(e) {
|
|
1243
|
+
return se(e.subscribe, e.get, e.get);
|
|
1056
1244
|
}
|
|
1057
|
-
var
|
|
1245
|
+
var q = {
|
|
1058
1246
|
missing: [],
|
|
1059
1247
|
complete: !1
|
|
1060
1248
|
};
|
|
1061
|
-
function
|
|
1062
|
-
const t =
|
|
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, [
|
|
1063
1251
|
r,
|
|
1064
1252
|
e.name,
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1253
|
+
o,
|
|
1254
|
+
s,
|
|
1255
|
+
f,
|
|
1068
1256
|
e.autoSubmit
|
|
1069
|
-
]), [
|
|
1257
|
+
]), [m, u] = E({
|
|
1070
1258
|
collector: null,
|
|
1071
1259
|
loading: !r,
|
|
1072
1260
|
error: null
|
|
1073
1261
|
});
|
|
1074
|
-
|
|
1262
|
+
N(() => {
|
|
1075
1263
|
if (r) return;
|
|
1076
|
-
let
|
|
1264
|
+
let v = !1;
|
|
1077
1265
|
return u({
|
|
1078
1266
|
collector: null,
|
|
1079
1267
|
loading: !0,
|
|
1080
1268
|
error: null
|
|
1081
|
-
}),
|
|
1082
|
-
|
|
1083
|
-
collector:
|
|
1269
|
+
}), O(t, e).then((c) => {
|
|
1270
|
+
v || u({
|
|
1271
|
+
collector: c,
|
|
1084
1272
|
loading: !1,
|
|
1085
1273
|
error: null
|
|
1086
1274
|
});
|
|
1087
|
-
}).catch((
|
|
1088
|
-
|
|
1275
|
+
}).catch((c) => {
|
|
1276
|
+
v || u({
|
|
1089
1277
|
collector: null,
|
|
1090
1278
|
loading: !1,
|
|
1091
|
-
error:
|
|
1279
|
+
error: c instanceof Error ? c : new Error(String(c))
|
|
1092
1280
|
});
|
|
1093
1281
|
}), () => {
|
|
1094
|
-
|
|
1282
|
+
v = !0;
|
|
1095
1283
|
};
|
|
1096
1284
|
}, [
|
|
1097
1285
|
t,
|
|
1098
1286
|
r,
|
|
1099
1287
|
e.name,
|
|
1100
|
-
|
|
1101
|
-
|
|
1288
|
+
s,
|
|
1289
|
+
f,
|
|
1102
1290
|
e.autoSubmit
|
|
1103
1291
|
]);
|
|
1104
|
-
const
|
|
1105
|
-
|
|
1106
|
-
if (
|
|
1107
|
-
return
|
|
1108
|
-
}, [t,
|
|
1109
|
-
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({
|
|
1110
1298
|
values: e.initialValues ?? {},
|
|
1111
1299
|
submitted: !1
|
|
1112
|
-
}), [
|
|
1113
|
-
...
|
|
1114
|
-
...
|
|
1115
|
-
}), [
|
|
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(() => ({
|
|
1116
1304
|
name: e.name,
|
|
1117
|
-
store:
|
|
1305
|
+
store: S,
|
|
1118
1306
|
functions: [],
|
|
1119
1307
|
contextKey: `form:${e.name}`,
|
|
1120
1308
|
contextProvider: () => ({
|
|
1121
1309
|
name: `Form: ${e.name}`,
|
|
1122
1310
|
description: ""
|
|
1123
1311
|
}),
|
|
1312
|
+
definitionContextKey: `form:${e.name}:definition`,
|
|
1313
|
+
definitionContextProvider: () => ({
|
|
1314
|
+
name: `Form definition: ${e.name}`,
|
|
1315
|
+
description: "",
|
|
1316
|
+
stable: !0
|
|
1317
|
+
}),
|
|
1124
1318
|
install: () => () => {
|
|
1125
1319
|
},
|
|
1126
1320
|
hydrate: () => {
|
|
@@ -1129,41 +1323,42 @@ function Je(e) {
|
|
|
1129
1323
|
ok: !1,
|
|
1130
1324
|
error: "Form definition not loaded yet."
|
|
1131
1325
|
}),
|
|
1132
|
-
getValues: () =>
|
|
1326
|
+
getValues: () => S.get().values,
|
|
1133
1327
|
setValues: () => {
|
|
1134
1328
|
},
|
|
1135
1329
|
reset: () => {
|
|
1136
1330
|
},
|
|
1137
|
-
getStatus: () =>
|
|
1138
|
-
}), [e.name,
|
|
1331
|
+
getStatus: () => q
|
|
1332
|
+
}), [e.name, S]);
|
|
1139
1333
|
return {
|
|
1140
|
-
...
|
|
1141
|
-
state:
|
|
1142
|
-
loading:
|
|
1143
|
-
error:
|
|
1334
|
+
...g ?? a,
|
|
1335
|
+
state: x,
|
|
1336
|
+
loading: C,
|
|
1337
|
+
error: A
|
|
1144
1338
|
};
|
|
1145
1339
|
}
|
|
1146
1340
|
export {
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
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,
|
|
1349
|
+
O as loadFormCollector,
|
|
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
|
|
1169
1364
|
};
|