@useago/sdk 1.4.4 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +15 -1
  2. package/dist/{AgoClient-Ozz2b1dQ.js → AgoClient-q39FIjSC.js} +1 -1
  3. package/dist/{AgoClient-CLmtYTJx.cjs → AgoClient-wcPRaIMs.cjs} +1 -1
  4. package/dist/angular.cjs +1 -1
  5. package/dist/angular.d.cts +45 -3
  6. package/dist/angular.d.ts +45 -3
  7. package/dist/angular.js +5 -1
  8. package/dist/autoContinue-CcCTva-D.cjs +1 -0
  9. package/dist/autoContinue-D3Mmaaca.js +63 -0
  10. package/dist/{createConversationSession-CUkNp6mZ.cjs → createConversationSession-BBYfQLLS.cjs} +1 -1
  11. package/dist/{createConversationSession-QIBN0gLx.js → createConversationSession-DCSWShaW.js} +1 -1
  12. package/dist/{createFormCollector-DHT1ObOb.cjs → createFormCollector-eimwwWEi.cjs} +1 -1
  13. package/dist/{createFormCollector-F3YJfsbg.js → createFormCollector-sB6rMccD.js} +1 -1
  14. package/dist/devtools.d.cts +3 -3
  15. package/dist/devtools.d.ts +3 -3
  16. package/dist/helpers.cjs +1 -1
  17. package/dist/index.cjs +1 -1
  18. package/dist/index.d.cts +52 -3
  19. package/dist/index.d.ts +52 -3
  20. package/dist/index.js +45 -43
  21. package/dist/react.cjs +3 -3
  22. package/dist/react.d.cts +5 -17
  23. package/dist/react.d.ts +5 -17
  24. package/dist/react.js +396 -454
  25. package/dist/testing.cjs +1 -1
  26. package/dist/testing.d.cts +3 -3
  27. package/dist/testing.d.ts +3 -3
  28. package/dist/testing.js +1 -1
  29. package/dist/vue.cjs +1 -1
  30. package/dist/vue.d.cts +3 -3
  31. package/dist/vue.d.ts +3 -3
  32. package/dist/vue.js +1 -1
  33. package/dist/widget.cjs +1 -1
  34. package/dist/widget.d.cts +3 -3
  35. package/dist/widget.d.ts +3 -3
  36. package/dist/widget.js +3 -3
  37. package/llms-full.txt +26 -4
  38. package/package.json +1 -1
  39. /package/dist/{createMockClient-bAZ9KBHC.js → createMockClient-BUc9PSbo.js} +0 -0
  40. /package/dist/{createMockClient-BSr-UV8R.cjs → createMockClient-CjdCqixj.cjs} +0 -0
  41. /package/dist/{functions-Djnq-JAo.cjs → functions-IGSjjvF4.cjs} +0 -0
package/dist/react.js CHANGED
@@ -1,20 +1,21 @@
1
- import { a as J, i as j, o as V, s as Y, t as X } from "./AgoClient-Ozz2b1dQ.js";
2
- import { i as Q, n as Pe, r as O, t as $ } from "./createFormCollector-F3YJfsbg.js";
3
- import { t as _e } from "./createMockClient-bAZ9KBHC.js";
4
- import Z, { createContext as ee, useCallback as N, useContext as B, useEffect as k, useId as te, useMemo as F, useRef as A, useState as M, useSyncExternalStore as ne } from "react";
5
- import { Fragment as G, jsx as i, jsxs as R } from "react/jsx-runtime";
1
+ import { a as q, i as J, o as j, s as V, t as Y } from "./AgoClient-q39FIjSC.js";
2
+ import { t as X } from "./autoContinue-D3Mmaaca.js";
3
+ import { i as Q, n as _e, r as H, t as O } from "./createFormCollector-sB6rMccD.js";
4
+ import { t as Pe } from "./createMockClient-BUc9PSbo.js";
5
+ import Z, { createContext as ee, useCallback as A, useContext as $, useEffect as k, useId as te, useMemo as T, useRef as E, useState as M, useSyncExternalStore as ne } from "react";
6
+ import { Fragment as B, jsx as a, jsxs as R } from "react/jsx-runtime";
6
7
  import re from "react-markdown";
7
8
  import oe from "remark-gfm";
8
9
  function ae(e) {
9
- const [n, r] = M(!1), t = A(null), o = F(() => {
10
- if (t.current && (t.current.destroy(), t.current = null), !e) return null;
11
- const s = new X(e);
12
- return t.current = s, s;
10
+ const [t, r] = M(!1), n = E(null), o = T(() => {
11
+ if (n.current && (n.current.destroy(), n.current = null), !e) return null;
12
+ const i = new Y(e);
13
+ return n.current = i, i;
13
14
  }, [e?.baseUrl, e?.widgetId]);
14
15
  return k(() => (r(!0), () => {
15
- t.current?.destroy(), t.current = null;
16
+ n.current?.destroy(), n.current = null;
16
17
  }), [o]), k(() => {
17
- t.current && e && t.current.updateConfig({
18
+ n.current && e && n.current.updateConfig({
18
19
  agent: e.agent,
19
20
  defaultAgentId: e.defaultAgentId,
20
21
  permission: e.permission,
@@ -33,136 +34,136 @@ function ae(e) {
33
34
  e?.warnOnEmptyReply
34
35
  ]), {
35
36
  client: o,
36
- isReady: n
37
+ isReady: t
37
38
  };
38
39
  }
39
- var L = ee(null), He = ({ children: e, client: n, tools: r, helpers: t, pageContext: o, ...s }) => {
40
- const { client: c } = ae(n ? null : s), l = n || c;
40
+ var L = ee(null), He = ({ children: e, client: t, tools: r, helpers: n, pageContext: o, ...i }) => {
41
+ const { client: c } = ae(t ? null : i), l = t || c;
41
42
  return k(() => {
42
43
  if (!(!r || r.length === 0)) {
43
- for (const g of r) l.register(g);
44
+ for (const f of r) l.register(f);
44
45
  return () => {
45
- for (const g of r) l.unregisterFunction(g.name);
46
+ for (const f of r) l.unregisterFunction(f.name);
46
47
  };
47
48
  }
48
49
  }, [l, r]), k(() => {
49
- if (!t) return;
50
- const g = [];
51
- return import("./functions-CApuQZ2b.js").then((d) => d.n).then((d) => {
52
- for (const [y, b] of Object.entries(t)) {
53
- const I = d[y];
50
+ if (!n) return;
51
+ const f = [];
52
+ return import("./functions-CApuQZ2b.js").then((u) => u.n).then((u) => {
53
+ for (const [y, v] of Object.entries(n)) {
54
+ const I = u[y];
54
55
  if (!I) {
55
56
  console.warn(`[AGO] Unknown helper: "${y}"`);
56
57
  continue;
57
58
  }
58
- const f = b === !0 ? I : {
59
+ const x = v === !0 ? I : {
59
60
  ...I,
60
- handler: b
61
+ handler: v
61
62
  };
62
- l.register(f), g.push(f.name);
63
+ l.register(x), f.push(x.name);
63
64
  }
64
65
  }), () => {
65
- for (const d of g) l.unregisterFunction(d);
66
+ for (const u of f) l.unregisterFunction(u);
66
67
  };
67
- }, [l, t]), k(() => {
68
+ }, [l, n]), k(() => {
68
69
  o === "auto" && l.enableAutoPageContext();
69
- }, [l, o]), /* @__PURE__ */ i(L.Provider, {
70
+ }, [l, o]), /* @__PURE__ */ a(L.Provider, {
70
71
  value: l,
71
72
  children: e
72
73
  });
73
74
  };
74
- function _() {
75
- const e = B(L);
75
+ function P() {
76
+ const e = $(L);
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 W() {
80
- return B(L);
80
+ function z() {
81
+ return $(L);
81
82
  }
82
- function U({ client: e, conversationId: n } = {}) {
83
- const r = W(), t = e || r;
84
- if (!t) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
85
- const [o, s] = M([]), [c, l] = M(n), [g, d] = M(!1), [y, b] = M(null);
83
+ function G({ client: e, conversationId: t } = {}) {
84
+ const r = z(), n = e || r;
85
+ if (!n) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
86
+ const [o, i] = M([]), [c, l] = M(t), [f, u] = M(!1), [y, v] = M(null);
86
87
  k(() => {
87
- n && n !== c && (l(n), I(n));
88
- }, [n]);
89
- const I = async (f) => {
88
+ t && t !== c && (l(t), I(t));
89
+ }, [t]);
90
+ const I = async (x) => {
90
91
  try {
91
- s((await t.getMessages(f)).filter((m) => !m.hidden));
92
- } catch (m) {
93
- b(m instanceof Error ? m : /* @__PURE__ */ new Error("Failed to load messages"));
92
+ i((await n.getMessages(x)).filter((h) => !h.hidden));
93
+ } catch (h) {
94
+ v(h instanceof Error ? h : /* @__PURE__ */ new Error("Failed to load messages"));
94
95
  }
95
96
  };
96
97
  return k(() => {
97
- const f = (u) => u === "IN_PROGRESS" || u === "WAITING_CLIENT", m = (u) => {
98
- c || l(u.conversationId), d(!0), s((p) => {
99
- const v = p.findIndex((h) => h.id === u.messageId);
100
- return v >= 0 ? p.map((h, D) => D === v ? {
101
- ...h,
98
+ const x = (d) => d === "IN_PROGRESS" || d === "WAITING_CLIENT", h = (d) => {
99
+ c || l(d.conversationId), u(!0), i((p) => {
100
+ const m = p.findIndex((g) => g.id === d.messageId);
101
+ return m >= 0 ? p.map((g, W) => W === m ? {
102
+ ...g,
102
103
  status: "IN_PROGRESS"
103
- } : h) : p.some((h) => h.role === "assistant" && f(h.status)) ? p : [...p, {
104
- id: u.messageId,
105
- conversationId: u.conversationId,
104
+ } : g) : p.some((g) => g.role === "assistant" && x(g.status)) ? p : [...p, {
105
+ id: d.messageId,
106
+ conversationId: d.conversationId,
106
107
  content: "",
107
108
  role: "assistant",
108
109
  status: "IN_PROGRESS",
109
110
  createdAt: /* @__PURE__ */ new Date()
110
111
  }];
111
112
  });
112
- }, S = (u) => {
113
- s((p) => {
114
- const v = p.findIndex((h) => h.id === u.messageId);
115
- return v < 0 ? p : p.map((h, D) => D === v ? {
116
- ...h,
117
- content: h.content + u.content
118
- } : h);
113
+ }, C = (d) => {
114
+ i((p) => {
115
+ const m = p.findIndex((g) => g.id === d.messageId);
116
+ return m < 0 ? p : p.map((g, W) => W === m ? {
117
+ ...g,
118
+ content: g.content + d.content
119
+ } : g);
119
120
  });
120
- }, w = (u) => {
121
- s((p) => {
122
- let v = -1;
123
- for (let h = p.length - 1; h >= 0; h--) if (p[h].role === "assistant" && f(p[h].status)) {
124
- v = h;
121
+ }, S = (d) => {
122
+ i((p) => {
123
+ let m = -1;
124
+ for (let g = p.length - 1; g >= 0; g--) if (p[g].role === "assistant" && x(p[g].status)) {
125
+ m = g;
125
126
  break;
126
127
  }
127
- return v < 0 ? p : [
128
- ...p.slice(0, v),
128
+ return m < 0 ? p : [
129
+ ...p.slice(0, m),
129
130
  {
130
- ...p[v],
131
- ...u
131
+ ...p[m],
132
+ ...d
132
133
  },
133
- ...p.slice(v + 1)
134
+ ...p.slice(m + 1)
134
135
  ];
135
136
  });
136
- }, a = (u) => {
137
- s((p) => {
138
- const v = p.findIndex((h) => h.id === u.id);
139
- return v >= 0 ? [
140
- ...p.slice(0, v),
141
- u,
142
- ...p.slice(v + 1)
143
- ] : [...p, u];
144
- }), d(!1);
145
- }, x = (u) => {
146
- b(new Error(u.error)), d(!1);
137
+ }, s = (d) => {
138
+ i((p) => {
139
+ const m = p.findIndex((g) => g.id === d.id);
140
+ return m >= 0 ? [
141
+ ...p.slice(0, m),
142
+ d,
143
+ ...p.slice(m + 1)
144
+ ] : [...p, d];
145
+ }), u(!1);
146
+ }, b = (d) => {
147
+ v(new Error(d.error)), u(!1);
147
148
  };
148
- return t.on("message:start", m), t.on("message:chunk", S), t.on("message:answer-complete", w), t.on("message:complete", a), t.on("message:error", x), () => {
149
- t.off("message:start", m), t.off("message:chunk", S), t.off("message:answer-complete", w), t.off("message:complete", a), t.off("message:error", x);
149
+ return n.on("message:start", h), n.on("message:chunk", C), n.on("message:answer-complete", S), n.on("message:complete", s), n.on("message:error", b), () => {
150
+ n.off("message:start", h), n.off("message:chunk", C), n.off("message:answer-complete", S), n.off("message:complete", s), n.off("message:error", b);
150
151
  };
151
- }, [t, c]), {
152
+ }, [n, c]), {
152
153
  messages: o,
153
- isLoading: g,
154
+ isLoading: f,
154
155
  error: y,
155
- sendMessage: N(async (f, m) => {
156
- d(!0), b(null);
157
- const S = {
156
+ sendMessage: A(async (x, h) => {
157
+ u(!0), v(null);
158
+ const C = {
158
159
  id: `temp-${Date.now()}`,
159
160
  conversationId: c || "",
160
- content: f,
161
+ content: x,
161
162
  role: "user",
162
163
  status: "DONE",
163
- attachments: m && m.length > 0 ? j(m) : void 0,
164
+ attachments: h && h.length > 0 ? J(h) : void 0,
164
165
  createdAt: /* @__PURE__ */ new Date()
165
- }, w = {
166
+ }, S = {
166
167
  id: `temp-assistant-${Date.now()}`,
167
168
  conversationId: c || "",
168
169
  content: "",
@@ -170,59 +171,59 @@ function U({ client: e, conversationId: n } = {}) {
170
171
  status: "IN_PROGRESS",
171
172
  createdAt: /* @__PURE__ */ new Date()
172
173
  };
173
- s((a) => [
174
- ...a,
175
- S,
176
- w
174
+ i((s) => [
175
+ ...s,
176
+ C,
177
+ S
177
178
  ]);
178
179
  try {
179
- const a = await t.sendMessage(f, {
180
+ const s = await n.sendMessage(x, {
180
181
  conversationId: c,
181
- files: m
182
+ files: h
182
183
  });
183
- return a.conversationId && !c && l(a.conversationId), s((x) => {
184
- const u = x.filter((v) => !v.id.startsWith("temp-")), p = {
185
- ...S,
186
- id: S.id.replace("temp-", "user-"),
187
- conversationId: a.conversationId
184
+ return s.conversationId && !c && l(s.conversationId), i((b) => {
185
+ const d = b.filter((m) => !m.id.startsWith("temp-")), p = {
186
+ ...C,
187
+ id: C.id.replace("temp-", "user-"),
188
+ conversationId: s.conversationId
188
189
  };
189
- return u.some((v) => v.id === a.id) ? [...u, p].sort((v, h) => new Date(v.createdAt).getTime() - new Date(h.createdAt).getTime()) : [
190
- ...u,
190
+ return d.some((m) => m.id === s.id) ? [...d, p].sort((m, g) => new Date(m.createdAt).getTime() - new Date(g.createdAt).getTime()) : [
191
+ ...d,
191
192
  p,
192
- a
193
+ s
193
194
  ];
194
- }), a;
195
- } catch (a) {
196
- return b(a instanceof Error ? a : /* @__PURE__ */ new Error("Failed to send message")), d(!1), s((x) => x.filter((u) => !u.id.startsWith("temp-"))), null;
195
+ }), s;
196
+ } catch (s) {
197
+ return v(s instanceof Error ? s : /* @__PURE__ */ new Error("Failed to send message")), u(!1), i((b) => b.filter((d) => !d.id.startsWith("temp-"))), null;
197
198
  }
198
- }, [t, c]),
199
- clearMessages: N(() => {
200
- s([]), l(void 0), b(null);
199
+ }, [n, c]),
200
+ clearMessages: A(() => {
201
+ i([]), l(void 0), v(null);
201
202
  }, []),
202
203
  conversationId: c
203
204
  };
204
205
  }
205
- var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", allowFiles: t = !1, className: o = "" }) => {
206
- const [s, c] = M(""), [l, g] = M([]), d = A(null), y = A(null), b = N(() => {
207
- const a = y.current;
208
- if (!a) return;
209
- const x = 110;
210
- a.style.height = "auto", a.style.height = `${Math.min(a.scrollHeight + 2, x)}px`, a.style.overflowY = a.scrollHeight + 2 > x ? "auto" : "hidden";
211
- }, []), I = N((a) => {
212
- a.preventDefault(), (s.trim() || l.length > 0) && (e(s.trim(), l.length > 0 ? l : void 0), c(""), g([]), requestAnimationFrame(b));
206
+ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", allowFiles: n = !1, className: o = "" }) => {
207
+ const [i, c] = M(""), [l, f] = M([]), u = E(null), y = E(null), v = A(() => {
208
+ const s = y.current;
209
+ if (!s) return;
210
+ const b = 110;
211
+ s.style.height = "auto", s.style.height = `${Math.min(s.scrollHeight + 2, b)}px`, s.style.overflowY = s.scrollHeight + 2 > b ? "auto" : "hidden";
212
+ }, []), I = A((s) => {
213
+ s.preventDefault(), (i.trim() || l.length > 0) && (e(i.trim(), l.length > 0 ? l : void 0), c(""), f([]), requestAnimationFrame(v));
213
214
  }, [
214
- s,
215
+ i,
215
216
  l,
216
217
  e,
217
- b
218
- ]), f = N((a) => {
219
- a.key === "Enter" && !a.shiftKey && (a.preventDefault(), I(a));
220
- }, [I]), m = N((a) => {
221
- const x = Array.from(a.target.files || []);
222
- g((u) => [...u, ...x]);
223
- }, []), S = N((a) => {
224
- g((x) => x.filter((u, p) => p !== a));
225
- }, []), w = s.trim() || l.length > 0;
218
+ v
219
+ ]), x = A((s) => {
220
+ s.key === "Enter" && !s.shiftKey && (s.preventDefault(), I(s));
221
+ }, [I]), h = A((s) => {
222
+ const b = Array.from(s.target.files || []);
223
+ f((d) => [...d, ...b]);
224
+ }, []), C = A((s) => {
225
+ f((b) => b.filter((d, p) => p !== s));
226
+ }, []), S = i.trim() || l.length > 0;
226
227
  return /* @__PURE__ */ R("form", {
227
228
  onSubmit: I,
228
229
  className: `ago-chat-input ${o}`,
@@ -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: [l.length > 0 && /* @__PURE__ */ i("div", {
238
+ children: [l.length > 0 && /* @__PURE__ */ a("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: l.map((a, x) => /* @__PURE__ */ R("div", {
245
+ children: l.map((s, b) => /* @__PURE__ */ R("div", {
245
246
  style: {
246
247
  display: "flex",
247
248
  alignItems: "center",
@@ -252,18 +253,18 @@ 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__ */ i("span", {
256
+ children: [/* @__PURE__ */ a("span", {
256
257
  style: {
257
258
  maxWidth: "120px",
258
259
  overflow: "hidden",
259
260
  textOverflow: "ellipsis",
260
261
  whiteSpace: "nowrap"
261
262
  },
262
- children: a.name
263
- }), /* @__PURE__ */ i("button", {
263
+ children: s.name
264
+ }), /* @__PURE__ */ a("button", {
264
265
  type: "button",
265
- onClick: () => S(x),
266
- "aria-label": `Remove ${a.name}`,
266
+ onClick: () => C(b),
267
+ "aria-label": `Remove ${s.name}`,
267
268
  style: {
268
269
  border: "none",
269
270
  background: "none",
@@ -275,7 +276,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
275
276
  },
276
277
  children: "×"
277
278
  })]
278
- }, x))
279
+ }, b))
279
280
  }), /* @__PURE__ */ R("div", {
280
281
  style: {
281
282
  display: "flex",
@@ -283,39 +284,39 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
283
284
  alignItems: "flex-end"
284
285
  },
285
286
  children: [
286
- t && /* @__PURE__ */ R(G, { children: [/* @__PURE__ */ i("button", {
287
+ n && /* @__PURE__ */ R(B, { children: [/* @__PURE__ */ a("button", {
287
288
  type: "button",
288
- onClick: () => d.current?.click(),
289
- disabled: n,
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: n ? "not-allowed" : "pointer",
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__ */ i("input", {
303
- ref: d,
303
+ }), /* @__PURE__ */ a("input", {
304
+ ref: u,
304
305
  type: "file",
305
306
  multiple: !0,
306
- onChange: m,
307
+ onChange: h,
307
308
  style: { display: "none" }
308
309
  })] }),
309
- /* @__PURE__ */ i("textarea", {
310
+ /* @__PURE__ */ a("textarea", {
310
311
  ref: y,
311
- value: s,
312
- onChange: (a) => {
313
- c(a.target.value), b();
312
+ value: i,
313
+ onChange: (s) => {
314
+ c(s.target.value), v();
314
315
  },
315
- onKeyDown: f,
316
+ onKeyDown: x,
316
317
  placeholder: r,
317
318
  "aria-label": r,
318
- disabled: n,
319
+ disabled: t,
319
320
  rows: 1,
320
321
  style: {
321
322
  flex: 1,
@@ -334,23 +335,23 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
334
335
  backgroundColor: "#f8f8f8",
335
336
  transition: "border-color 0.15s"
336
337
  },
337
- onFocus: (a) => {
338
- a.currentTarget.style.borderColor = "#1b5fc4";
338
+ onFocus: (s) => {
339
+ s.currentTarget.style.borderColor = "#1b5fc4";
339
340
  },
340
- onBlur: (a) => {
341
- a.currentTarget.style.borderColor = "#dee3e8";
341
+ onBlur: (s) => {
342
+ s.currentTarget.style.borderColor = "#dee3e8";
342
343
  }
343
344
  }),
344
- /* @__PURE__ */ i("button", {
345
+ /* @__PURE__ */ a("button", {
345
346
  type: "submit",
346
- disabled: n || !w,
347
+ disabled: t || !S,
347
348
  style: {
348
349
  padding: "10px 18px",
349
350
  border: "none",
350
351
  borderRadius: "20px",
351
- backgroundColor: n || !w ? "#b5bfc8" : "#03182f",
352
+ backgroundColor: t || !S ? "#b5bfc8" : "#03182f",
352
353
  color: "#fff",
353
- cursor: n || !w ? "not-allowed" : "pointer",
354
+ cursor: t || !S ? "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
- }, ie = ({ href: e, children: n, ...r }) => /* @__PURE__ */ i("a", {
364
+ }, ie = ({ href: e, children: t, ...r }) => /* @__PURE__ */ a("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: n
373
- }), le = ({ children: e, ...n }) => /* @__PURE__ */ i("p", {
373
+ children: t
374
+ }), le = ({ children: e, ...t }) => /* @__PURE__ */ a("p", {
374
375
  style: {
375
376
  margin: "0 0 8px 0",
376
377
  lineHeight: "1.6"
377
378
  },
378
- ...n,
379
+ ...t,
379
380
  children: e
380
- }), P = (e, n) => {
381
- const r = ({ children: t, ...o }) => Z.createElement(`h${e}`, {
381
+ }), _ = (e, t) => {
382
+ const r = ({ children: n, ...o }) => Z.createElement(`h${e}`, {
382
383
  style: {
383
384
  margin: "16px 0 8px 0",
384
- fontSize: n,
385
+ fontSize: t,
385
386
  fontWeight: 600,
386
387
  lineHeight: "1.3"
387
388
  },
388
389
  ...o
389
- }, t);
390
+ }, n);
390
391
  return r.displayName = `MarkdownHeading${e}`, r;
391
- }, ce = ({ children: e, ...n }) => /* @__PURE__ */ i("ul", {
392
+ }, ce = ({ children: e, ...t }) => /* @__PURE__ */ a("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
- ...n,
399
+ ...t,
399
400
  children: e
400
- }), de = ({ children: e, ...n }) => /* @__PURE__ */ i("ol", {
401
+ }), de = ({ children: e, ...t }) => /* @__PURE__ */ a("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
- ...n,
408
+ ...t,
408
409
  children: e
409
- }), ue = ({ children: e, ...n }) => /* @__PURE__ */ i("li", {
410
+ }), ue = ({ children: e, ...t }) => /* @__PURE__ */ a("li", {
410
411
  style: {
411
412
  display: "list-item",
412
413
  margin: "2px 0",
413
414
  lineHeight: "1.6"
414
415
  },
415
- ...n,
416
+ ...t,
416
417
  children: e
417
- }), fe = ({ className: e, children: n, ...r }) => e !== void 0 || String(n).includes(`
418
- `) ? /* @__PURE__ */ i("code", {
418
+ }), fe = ({ className: e, children: t, ...r }) => e !== void 0 || String(t).includes(`
419
+ `) ? /* @__PURE__ */ a("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: n
430
- }) : /* @__PURE__ */ i("code", {
430
+ children: t
431
+ }) : /* @__PURE__ */ a("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: n
440
- }), ge = ({ children: e, ...n }) => /* @__PURE__ */ i("pre", {
440
+ children: t
441
+ }), pe = ({ children: e, ...t }) => /* @__PURE__ */ a("pre", {
441
442
  style: { margin: "0 0 8px 0" },
442
- ...n,
443
+ ...t,
443
444
  children: e
444
- }), pe = ({ children: e, ...n }) => /* @__PURE__ */ i("blockquote", {
445
+ }), ge = ({ children: e, ...t }) => /* @__PURE__ */ a("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
- ...n,
453
+ ...t,
453
454
  children: e
454
- }), me = ({ children: e, ...n }) => /* @__PURE__ */ i("div", {
455
+ }), me = ({ children: e, ...t }) => /* @__PURE__ */ a("div", {
455
456
  style: {
456
457
  overflowX: "auto",
457
458
  margin: "0 0 8px 0"
458
459
  },
459
- children: /* @__PURE__ */ i("table", {
460
+ children: /* @__PURE__ */ a("table", {
460
461
  style: {
461
462
  borderCollapse: "collapse",
462
463
  width: "100%",
463
464
  fontSize: "13px"
464
465
  },
465
- ...n,
466
+ ...t,
466
467
  children: e
467
468
  })
468
- }), he = ({ children: e, ...n }) => /* @__PURE__ */ i("th", {
469
+ }), xe = ({ children: e, ...t }) => /* @__PURE__ */ a("th", {
469
470
  style: {
470
471
  border: "1px solid #dee3e8",
471
472
  padding: "6px 10px",
@@ -473,24 +474,24 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
473
474
  backgroundColor: "#f5f7fa",
474
475
  fontWeight: 600
475
476
  },
476
- ...n,
477
+ ...t,
477
478
  children: e
478
- }), xe = ({ children: e, ...n }) => /* @__PURE__ */ i("td", {
479
+ }), he = ({ children: e, ...t }) => /* @__PURE__ */ a("td", {
479
480
  style: {
480
481
  border: "1px solid #dee3e8",
481
482
  padding: "6px 10px"
482
483
  },
483
- ...n,
484
+ ...t,
484
485
  children: e
485
- }), ye = ({ alt: e, ...n }) => /* @__PURE__ */ i("img", {
486
+ }), ye = ({ alt: e, ...t }) => /* @__PURE__ */ a("img", {
486
487
  alt: e ?? "",
487
488
  style: {
488
489
  maxWidth: "100%",
489
490
  borderRadius: "8px",
490
491
  margin: "4px 0"
491
492
  },
492
- ...n
493
- }), be = (e) => /* @__PURE__ */ i("hr", {
493
+ ...t
494
+ }), be = (e) => /* @__PURE__ */ a("hr", {
494
495
  style: {
495
496
  border: "none",
496
497
  borderTop: "1px solid #dee3e8",
@@ -500,30 +501,30 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
500
501
  }), ve = {
501
502
  a: ie,
502
503
  p: le,
503
- h1: P(1, "20px"),
504
- h2: P(2, "18px"),
505
- h3: P(3, "16px"),
506
- h4: P(4, "15px"),
507
- h5: P(5, "14px"),
508
- h6: P(6, "13px"),
504
+ h1: _(1, "20px"),
505
+ h2: _(2, "18px"),
506
+ h3: _(3, "16px"),
507
+ h4: _(4, "15px"),
508
+ h5: _(5, "14px"),
509
+ h6: _(6, "13px"),
509
510
  ul: ce,
510
511
  ol: de,
511
512
  li: ue,
512
513
  code: fe,
513
- pre: ge,
514
- blockquote: pe,
514
+ pre: pe,
515
+ blockquote: ge,
515
516
  table: me,
516
- th: he,
517
- td: xe,
517
+ th: xe,
518
+ td: he,
518
519
  img: ye,
519
520
  hr: be
520
- }, we = [oe], Se = ({ content: e }) => /* @__PURE__ */ i(re, {
521
+ }, we = [oe], Ce = ({ content: e }) => /* @__PURE__ */ a(re, {
521
522
  remarkPlugins: we,
522
523
  components: ve,
523
524
  children: e
524
- }), Ce = ({ attachment: e, isUser: n }) => {
525
- const r = Y(e.url);
526
- if (J(e)) return /* @__PURE__ */ i("a", {
525
+ }), Se = ({ attachment: e, isUser: t }) => {
526
+ const r = V(e.url);
527
+ if (q(e)) return /* @__PURE__ */ a("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__ */ i("img", {
535
+ children: /* @__PURE__ */ a("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 t = V(e.fileSize), o = /* @__PURE__ */ R(G, { children: [/* @__PURE__ */ i("span", {
549
+ const n = j(e.fileSize), o = /* @__PURE__ */ R(B, { children: [/* @__PURE__ */ a("span", {
549
550
  style: {
550
551
  fontSize: "16px",
551
552
  lineHeight: 1,
@@ -559,7 +560,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
559
560
  flexDirection: "column",
560
561
  minWidth: 0
561
562
  },
562
- children: [/* @__PURE__ */ i("span", {
563
+ children: [/* @__PURE__ */ a("span", {
563
564
  style: {
564
565
  overflow: "hidden",
565
566
  textOverflow: "ellipsis",
@@ -568,37 +569,37 @@ 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
- }), t && /* @__PURE__ */ i("span", {
572
+ }), n && /* @__PURE__ */ a("span", {
572
573
  style: {
573
574
  fontSize: "11px",
574
575
  color: "#6b6d6f"
575
576
  },
576
- children: t
577
+ children: n
577
578
  })]
578
- })] }), s = {
579
+ })] }), i = {
579
580
  display: "inline-flex",
580
581
  alignItems: "center",
581
582
  gap: "8px",
582
583
  padding: "8px 12px",
583
584
  borderRadius: "10px",
584
585
  border: "1px solid #dee3e8",
585
- backgroundColor: n ? "rgba(255,255,255,0.12)" : "#fff",
586
- color: n ? "#fff" : "#30373e",
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__ */ i("a", {
592
+ return r ? /* @__PURE__ */ a("a", {
592
593
  href: r,
593
594
  target: "_blank",
594
595
  rel: "noopener noreferrer",
595
- style: s,
596
+ style: i,
596
597
  children: o
597
- }) : /* @__PURE__ */ i("div", {
598
- style: s,
598
+ }) : /* @__PURE__ */ a("div", {
599
+ style: i,
599
600
  children: o
600
601
  });
601
- }, Ie = ({ source: e, index: n }) => {
602
+ }, ke = ({ source: e, index: t }) => {
602
603
  const r = /* @__PURE__ */ R("div", {
603
604
  style: {
604
605
  display: "flex",
@@ -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__ */ i("div", {
611
+ children: [/* @__PURE__ */ a("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: n + 1
626
- }), /* @__PURE__ */ i("div", {
626
+ children: t + 1
627
+ }), /* @__PURE__ */ a("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
- }), t = {
638
+ }), n = {
638
639
  display: "flex",
639
640
  alignItems: "center",
640
641
  padding: "8px 10px",
@@ -647,11 +648,11 @@ 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__ */ i("a", {
651
+ return e.url ? /* @__PURE__ */ a("a", {
651
652
  href: e.url,
652
653
  target: "_blank",
653
654
  rel: "noopener noreferrer",
654
- style: t,
655
+ style: n,
655
656
  onMouseEnter: (o) => {
656
657
  o.currentTarget.style.borderColor = "#1b5fc4";
657
658
  },
@@ -659,11 +660,11 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
659
660
  o.currentTarget.style.borderColor = "#dee3e8";
660
661
  },
661
662
  children: r
662
- }) : /* @__PURE__ */ i("div", {
663
- style: t,
663
+ }) : /* @__PURE__ */ a("div", {
664
+ style: n,
664
665
  children: r
665
666
  });
666
- }, ke = () => /* @__PURE__ */ R("div", {
667
+ }, Ie = () => /* @__PURE__ */ R("div", {
667
668
  style: {
668
669
  display: "flex",
669
670
  gap: "4px",
@@ -673,31 +674,31 @@ 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__ */ i("div", { style: {
677
+ ].map((e) => /* @__PURE__ */ a("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__ */ i("style", { children: `
684
+ } }, e)), /* @__PURE__ */ a("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
- }), Me = ({ message: e, className: n = "", showAgentName: r = !1, isLast: t = !1, onFollowUpClick: o }) => {
690
- const s = e.role === "user", c = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
690
+ }), Me = ({ message: e, className: t = "", showAgentName: r = !1, isLast: n = !1, onFollowUpClick: o }) => {
691
+ const i = e.role === "user", c = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
691
692
  return /* @__PURE__ */ R("div", {
692
- className: `ago-message ago-message--${e.role} ${n}`,
693
+ className: `ago-message ago-message--${e.role} ${t}`,
693
694
  style: {
694
695
  display: "flex",
695
696
  flexDirection: "column",
696
- alignItems: s ? "flex-end" : "flex-start",
697
+ alignItems: i ? "flex-end" : "flex-start",
697
698
  marginBottom: "16px"
698
699
  },
699
700
  children: [
700
- !s && r && e.agent && /* @__PURE__ */ i("div", {
701
+ !i && r && e.agent && /* @__PURE__ */ a("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__ */ i("div", {
715
+ !i && e.sources && e.sources.length > 0 && /* @__PURE__ */ a("div", {
715
716
  className: "ago-message__sources",
716
717
  style: {
717
718
  display: "grid",
@@ -721,41 +722,41 @@ 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((l, g) => /* @__PURE__ */ i(Ie, {
725
+ children: e.sources.map((l, f) => /* @__PURE__ */ a(ke, {
725
726
  source: l,
726
- index: g
727
+ index: f
727
728
  }, l.id))
728
729
  }),
729
- e.attachments && e.attachments.length > 0 && /* @__PURE__ */ i("div", {
730
+ e.attachments && e.attachments.length > 0 && /* @__PURE__ */ a("div", {
730
731
  className: "ago-message__attachments",
731
732
  style: {
732
733
  display: "flex",
733
734
  flexWrap: "wrap",
734
735
  gap: "6px",
735
736
  marginBottom: "6px",
736
- justifyContent: s ? "flex-end" : "flex-start",
737
+ justifyContent: i ? "flex-end" : "flex-start",
737
738
  maxWidth: "75%"
738
739
  },
739
- children: e.attachments.map((l) => /* @__PURE__ */ i(Ce, {
740
+ children: e.attachments.map((l) => /* @__PURE__ */ a(Se, {
740
741
  attachment: l,
741
- isUser: s
742
+ isUser: i
742
743
  }, l.id))
743
744
  }),
744
- (e.content || c) && /* @__PURE__ */ i("div", {
745
+ (e.content || c) && /* @__PURE__ */ a("div", {
745
746
  className: "ago-message__content",
746
747
  style: {
747
- maxWidth: s ? "75%" : "100%",
748
- padding: s ? "10px 14px" : "2px 8px",
749
- borderRadius: s ? "16px" : "0",
750
- backgroundColor: s ? "#03182f" : "transparent",
751
- color: s ? "#fff" : "#30373e",
748
+ maxWidth: i ? "75%" : "100%",
749
+ padding: i ? "10px 14px" : "2px 8px",
750
+ borderRadius: i ? "16px" : "0",
751
+ backgroundColor: i ? "#03182f" : "transparent",
752
+ color: i ? "#fff" : "#30373e",
752
753
  wordBreak: "break-word",
753
754
  fontSize: "16px",
754
755
  lineHeight: "1.6"
755
756
  },
756
- children: e.content ? /* @__PURE__ */ i(Se, { content: e.content }) : c && /* @__PURE__ */ i(ke, {})
757
+ children: e.content ? /* @__PURE__ */ a(Ce, { content: e.content }) : c && /* @__PURE__ */ a(Ie, {})
757
758
  }),
758
- t && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ i("div", {
759
+ n && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ a("div", {
759
760
  className: "ago-message__followups",
760
761
  style: {
761
762
  display: "flex",
@@ -763,7 +764,7 @@ 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((l, g) => /* @__PURE__ */ i("button", {
767
+ children: e.followUpReplies.map((l, f) => /* @__PURE__ */ a("button", {
767
768
  type: "button",
768
769
  className: "ago-message__followup-btn",
769
770
  disabled: !o,
@@ -779,52 +780,52 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
779
780
  cursor: o ? "pointer" : "default",
780
781
  transition: "border-color 0.15s"
781
782
  },
782
- onMouseEnter: (d) => {
783
- d.currentTarget.style.borderColor = "#1b5fc4";
783
+ onMouseEnter: (u) => {
784
+ u.currentTarget.style.borderColor = "#1b5fc4";
784
785
  },
785
- onMouseLeave: (d) => {
786
- d.currentTarget.style.borderColor = "#dee3e8";
786
+ onMouseLeave: (u) => {
787
+ u.currentTarget.style.borderColor = "#dee3e8";
787
788
  },
788
789
  children: l
789
- }, g))
790
+ }, f))
790
791
  })
791
792
  ]
792
793
  });
793
- }, Oe = ({ client: e, conversationId: n, title: r = "Chat", welcomeMessage: t = "Hello! How can I help you today?", placeholder: o = "Type a message...", allowFiles: s = !1, height: c = 500, logoUrl: l, showAgentName: g = !1, forms: d, onFollowUpClick: y, className: b = "", onMessageSent: I, onMessageReceived: f }) => {
794
- const m = A(null), S = W(), w = e ?? S, { messages: a, isLoading: x, error: u, sendMessage: p } = U({
794
+ }, Oe = ({ client: e, conversationId: t, title: r = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: o = "Type a message...", allowFiles: i = !1, height: c = 500, logoUrl: l, showAgentName: f = !1, forms: u, onFollowUpClick: y, className: v = "", onMessageSent: I, onMessageReceived: x }) => {
795
+ const h = E(null), C = z(), S = e ?? C, { messages: s, isLoading: b, error: d, sendMessage: p } = G({
795
796
  client: e,
796
- conversationId: n
797
+ conversationId: t
797
798
  });
798
799
  k(() => {
799
- if (!w || !d || d.length === 0) return;
800
- let C = !1;
801
- const T = [];
802
- return Promise.all(d.map((E) => E.schema != null ? Promise.resolve($(E)) : O(w, E))).then((E) => {
803
- if (!C)
804
- for (const q of E) T.push(q.install(w));
800
+ if (!S || !u || u.length === 0) return;
801
+ let w = !1;
802
+ const F = [];
803
+ return Promise.all(u.map((N) => N.schema != null ? Promise.resolve(O(N)) : H(S, N))).then((N) => {
804
+ if (!w)
805
+ for (const U of N) F.push(U.install(S));
805
806
  }).catch(() => {
806
807
  }), () => {
807
- C = !0, T.forEach((E) => E());
808
+ w = !0, F.forEach((N) => N());
808
809
  };
809
- }, [w, d ? JSON.stringify(d.map((C) => [
810
- C.name,
811
- C.schema ?? null,
812
- C.submit ?? !1,
813
- C.description ?? null
810
+ }, [S, u ? JSON.stringify(u.map((w) => [
811
+ w.name,
812
+ w.schema ?? null,
813
+ w.submit ?? !1,
814
+ w.description ?? null
814
815
  ])) : ""]), k(() => {
815
- m.current?.scrollIntoView({ behavior: "smooth" });
816
- }, [a]), k(() => {
817
- const C = a[a.length - 1];
818
- C && C.role === "assistant" && C.status === "DONE" && f && f({
819
- id: C.id,
820
- content: C.content
816
+ h.current?.scrollIntoView({ behavior: "smooth" });
817
+ }, [s]), k(() => {
818
+ const w = s[s.length - 1];
819
+ w && w.role === "assistant" && w.status === "DONE" && x && x({
820
+ id: w.id,
821
+ content: w.content
821
822
  });
822
- }, [a, f]);
823
- const v = async (C, T) => {
824
- I?.(C), await p(C, T);
825
- }, h = a[a.length - 1], D = x && h?.role === "assistant" && (h.status === "IN_PROGRESS" || h.status === "WAITING_CLIENT"), K = y === !1 ? void 0 : y ?? ((C) => v(C));
823
+ }, [s, x]);
824
+ const m = async (w, F) => {
825
+ I?.(w), await p(w, F);
826
+ }, g = s[s.length - 1], W = b && g?.role === "assistant" && (g.status === "IN_PROGRESS" || g.status === "WAITING_CLIENT"), K = y === !1 ? void 0 : y ?? ((w) => m(w));
826
827
  return /* @__PURE__ */ R("div", {
827
- className: `ago-chat-widget ${b}`,
828
+ className: `ago-chat-widget ${v}`,
828
829
  style: {
829
830
  display: "flex",
830
831
  flexDirection: "column",
@@ -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: [l && /* @__PURE__ */ i("img", {
853
+ children: [l && /* @__PURE__ */ a("img", {
853
854
  src: l,
854
855
  alt: "Logo",
855
856
  style: {
856
857
  height: "24px",
857
858
  width: "auto"
858
859
  }
859
- }), /* @__PURE__ */ i("h3", {
860
+ }), /* @__PURE__ */ a("h3", {
860
861
  style: {
861
862
  margin: 0,
862
863
  fontSize: "15px",
@@ -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__ */ i("div", {
882
+ s.length === 0 ? /* @__PURE__ */ a("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: t
890
- }) : a.map((C, T) => /* @__PURE__ */ i(Me, {
891
- message: C,
892
- showAgentName: g,
893
- isLast: T === a.length - 1,
890
+ children: n
891
+ }) : s.map((w, F) => /* @__PURE__ */ a(Me, {
892
+ message: w,
893
+ showAgentName: f,
894
+ isLast: F === s.length - 1,
894
895
  onFollowUpClick: K
895
- }, C.id)),
896
- u && /* @__PURE__ */ i("div", {
896
+ }, w.id)),
897
+ d && /* @__PURE__ */ a("div", {
897
898
  role: "alert",
898
899
  style: {
899
900
  padding: "10px 14px",
@@ -904,60 +905,60 @@ 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: u.message
908
+ children: d.message
908
909
  }),
909
- /* @__PURE__ */ i("div", { ref: m })
910
+ /* @__PURE__ */ a("div", { ref: h })
910
911
  ]
911
912
  }),
912
- /* @__PURE__ */ i(se, {
913
- onSend: v,
914
- disabled: D,
913
+ /* @__PURE__ */ a(se, {
914
+ onSend: m,
915
+ disabled: W,
915
916
  placeholder: o,
916
- allowFiles: s
917
+ allowFiles: i
917
918
  })
918
919
  ]
919
920
  });
920
921
  };
921
- function Re({ client: e, autoLoad: n = !0 } = {}) {
922
- const r = W(), t = e || r;
923
- if (!t) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
924
- const [o, s] = M([]), [c, l] = M(null), [g, d] = M(!1), [y, b] = M(null), I = N(async () => {
925
- d(!0), b(null);
922
+ function Re({ client: e, autoLoad: t = !0 } = {}) {
923
+ const r = z(), n = e || r;
924
+ if (!n) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
925
+ const [o, i] = M([]), [c, l] = M(null), [f, u] = M(!1), [y, v] = M(null), I = A(async () => {
926
+ u(!0), v(null);
926
927
  try {
927
- s(await t.getConversations());
928
- } catch (S) {
929
- b(S instanceof Error ? S : /* @__PURE__ */ new Error("Failed to load conversations"));
928
+ i(await n.getConversations());
929
+ } catch (C) {
930
+ v(C instanceof Error ? C : /* @__PURE__ */ new Error("Failed to load conversations"));
930
931
  } finally {
931
- d(!1);
932
+ u(!1);
932
933
  }
933
- }, [t]), f = N(async (S) => {
934
- d(!0), b(null);
934
+ }, [n]), x = A(async (C) => {
935
+ u(!0), v(null);
935
936
  try {
936
- l(await t.getConversation(S));
937
- } catch (w) {
938
- b(w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to load conversation"));
937
+ l(await n.getConversation(C));
938
+ } catch (S) {
939
+ v(S instanceof Error ? S : /* @__PURE__ */ new Error("Failed to load conversation"));
939
940
  } finally {
940
- d(!1);
941
+ u(!1);
941
942
  }
942
- }, [t]), m = N(() => {
943
+ }, [n]), h = A(() => {
943
944
  l(null);
944
945
  }, []);
945
946
  return k(() => {
946
- n && I();
947
- }, [n, I]), {
947
+ t && I();
948
+ }, [t, I]), {
948
949
  conversations: o,
949
950
  currentConversation: c,
950
- isLoading: g,
951
+ isLoading: f,
951
952
  error: y,
952
- selectConversation: f,
953
- startNewConversation: m,
953
+ selectConversation: x,
954
+ startNewConversation: h,
954
955
  refreshConversations: I
955
956
  };
956
957
  }
957
958
  function $e(e = {}) {
958
- const n = W(), r = e.client || n;
959
+ const t = z(), 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 t = U({
961
+ const n = G({
961
962
  client: r,
962
963
  conversationId: e.conversationId
963
964
  }), o = Re({
@@ -965,12 +966,12 @@ function $e(e = {}) {
965
966
  autoLoad: e.autoLoad
966
967
  });
967
968
  return {
968
- messages: t.messages,
969
- isLoading: t.isLoading,
970
- error: t.error || o.error,
971
- sendMessage: t.sendMessage,
972
- clearMessages: t.clearMessages,
973
- conversationId: t.conversationId,
969
+ messages: n.messages,
970
+ isLoading: n.isLoading,
971
+ error: n.error || o.error,
972
+ sendMessage: n.sendMessage,
973
+ clearMessages: n.clearMessages,
974
+ conversationId: n.conversationId,
974
975
  conversations: o.conversations,
975
976
  currentConversation: o.currentConversation,
976
977
  isConversationsLoading: o.isLoading,
@@ -979,127 +980,68 @@ function $e(e = {}) {
979
980
  refreshConversations: o.refreshConversations
980
981
  };
981
982
  }
982
- function Be(e, n) {
983
- const r = _(), { name: t, description: o, parameters: s, handler: c, maxResultBytes: l } = typeof e == "string" ? {
983
+ function Be(e, t) {
984
+ const r = P(), { name: n, description: o, parameters: i, handler: c, maxResultBytes: l } = typeof e == "string" ? {
984
985
  name: e,
985
- ...n
986
- } : e, g = A(c);
987
- g.current = c, k(() => {
988
- const d = (y) => g.current(y);
989
- return r.registerFunction(t, d, {
986
+ ...t
987
+ } : e, f = E(c);
988
+ f.current = c, k(() => {
989
+ const u = (y) => f.current(y);
990
+ return r.registerFunction(n, u, {
990
991
  description: o,
991
- parameters: s,
992
+ parameters: i,
992
993
  maxResultBytes: l
993
994
  }), () => {
994
- r.unregisterFunction(t);
995
+ r.unregisterFunction(n);
995
996
  };
996
997
  }, [
997
998
  r,
998
- t,
999
+ n,
999
1000
  o,
1000
- s,
1001
+ i,
1001
1002
  l
1002
1003
  ]);
1003
1004
  }
1004
- function Ge(e, n) {
1005
- const r = _(), t = A(e);
1006
- t.current = e, k(() => (r.registerNavigationFunction((o) => t.current(o), n), () => {
1005
+ function Ge(e, t) {
1006
+ const r = P(), n = E(e);
1007
+ n.current = e, k(() => (r.registerNavigationFunction((o) => n.current(o), t), () => {
1007
1008
  r.unregisterNavigationFunction();
1008
- }), [r, n]);
1009
+ }), [r, t]);
1009
1010
  }
1010
- function Ue(e, n) {
1011
- const r = _(), t = n?.functionName ?? "setPageState", o = A(e);
1011
+ function Ke(e, t) {
1012
+ const r = P(), n = t?.functionName ?? "setPageState", o = E(e);
1012
1013
  o.current = e, k(() => {
1013
- const s = o.current.map((c) => {
1014
- const l = () => o.current.find((g) => g.name === c.name) ?? c;
1014
+ const i = o.current.map((c) => {
1015
+ const l = () => o.current.find((f) => f.name === c.name) ?? c;
1015
1016
  return {
1016
1017
  name: c.name,
1017
1018
  description: c.description,
1018
1019
  schema: c.schema,
1019
1020
  get: c.get ? () => l().get?.() : void 0,
1020
- set: (g) => l().set(g)
1021
+ set: (f) => l().set(f)
1021
1022
  };
1022
1023
  });
1023
- return r.registerPageStateFunction(s, { functionName: t }), () => {
1024
- r.unregisterPageStateFunction(t);
1024
+ return r.registerPageStateFunction(i, { functionName: n }), () => {
1025
+ r.unregisterPageStateFunction(n);
1025
1026
  };
1026
- }, [r, t]);
1027
+ }, [r, n]);
1027
1028
  }
1028
- var Ne = "You have navigated the user to a new page. That page now exposes its editable state through the available setPageState function, and its current values in the page context. If the user's latest request also asked to change something on this page, call setPageState now to apply exactly those changes and nothing else. Otherwise, reply with a short confirmation only.";
1029
- function z(e) {
1030
- return {
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
- };
1029
+ function Ue(e) {
1030
+ const t = P(), r = E(e);
1031
+ r.current = e, k(() => X(t, () => r.current), [t]);
1039
1032
  }
1040
- function Ke(e) {
1041
- const n = _(), r = A(z(e));
1042
- r.current = z(e), k(() => {
1043
- const t = {
1044
- navigated: !1,
1045
- pausedTurnNavigated: !1,
1046
- depth: 0,
1047
- runId: 0,
1048
- ourSendPending: !1
1049
- }, o = () => n.getRegisteredFunctions().some((f) => f.name === r.current.pageStateFunctionName), s = (f) => new Promise((m) => {
1050
- let S = !1;
1051
- const w = (p) => {
1052
- S || (S = !0, clearTimeout(u), n.off("context:changed", x), m(p));
1053
- }, a = () => setTimeout(() => w(f === t.runId && o()), r.current.settleMs), x = () => {
1054
- if (f !== t.runId) return w(!1);
1055
- o() && (n.off("context:changed", x), a());
1056
- }, u = setTimeout(() => w(!1), r.current.readinessTimeoutMs);
1057
- o() ? a() : n.on("context:changed", x);
1058
- }), c = async (f) => {
1059
- const m = ++t.runId;
1060
- if (!(!await s(m) || m !== t.runId)) {
1061
- t.depth += 1, t.ourSendPending = !0;
1062
- try {
1063
- await n.sendMessage(r.current.continuationPrompt, {
1064
- conversationId: f,
1065
- hidden: !0
1066
- });
1067
- } catch {
1068
- t.ourSendPending = !1;
1069
- }
1070
- }
1071
- }, l = (f) => {
1072
- r.current.navigationFunctions.includes(f.functionName) && (t.navigated = !0);
1073
- }, g = n.registerResumeGate(async () => {
1074
- r.current.enabled && t.pausedTurnNavigated && (t.pausedTurnNavigated = !1, await s(++t.runId));
1075
- }), d = () => {
1076
- t.pausedTurnNavigated = t.navigated, t.navigated = !1;
1077
- }, y = () => {
1078
- t.ourSendPending || (t.depth = 0, t.runId += 1);
1079
- }, b = (f) => {
1080
- t.ourSendPending = !1;
1081
- const m = t.navigated;
1082
- t.navigated = !1, r.current.enabled && m && (t.depth >= r.current.maxDepth || c(f.conversationId));
1083
- }, I = () => {
1084
- t.ourSendPending = !1;
1085
- };
1086
- return n.on("function:invoke", l), n.on("message:start", y), n.on("message:waiting-client", d), n.on("message:complete", b), n.on("message:error", I), () => {
1087
- t.runId += 1, g(), n.off("function:invoke", l), n.off("message:start", y), n.off("message:waiting-client", d), n.off("message:complete", b), n.off("message:error", I);
1088
- };
1089
- }, [n]);
1090
- }
1091
- function qe(e, n) {
1092
- const r = _(), t = te(), o = n ?? t, s = A(e);
1093
- s.current = e;
1033
+ function qe(e, t) {
1034
+ const r = P(), n = te(), o = t ?? n, i = E(e);
1035
+ i.current = e;
1094
1036
  const c = typeof e == "function";
1095
1037
  k(() => {
1096
- if (typeof s.current == "function") {
1097
- const l = () => s.current();
1038
+ if (typeof i.current == "function") {
1039
+ const l = () => i.current();
1098
1040
  return r.addDynamicContext(o, l), () => {
1099
1041
  r.removeDynamicContext(o);
1100
1042
  };
1101
1043
  }
1102
- return r.setContext(o, s.current), () => {
1044
+ return r.setContext(o, i.current), () => {
1103
1045
  r.removeContext(o);
1104
1046
  };
1105
1047
  }, [
@@ -1112,67 +1054,67 @@ function qe(e, n) {
1112
1054
  function Ae(e) {
1113
1055
  return ne(e.subscribe, e.get, e.get);
1114
1056
  }
1115
- var H = {
1057
+ var D = {
1116
1058
  missing: [],
1117
1059
  complete: !1
1118
1060
  };
1119
1061
  function Je(e) {
1120
- const n = _(), r = e.schema != null, t = JSON.stringify(e.schema ?? null), o = e.submit, s = o ? typeof o == "string" ? `client:${o}` : o.via === "backend" ? "backend" : "handler" in o ? "client:handler" : `client:${o.url}` : "none", c = JSON.stringify(e.initialValues ?? null), l = F(() => r ? $(e) : null, [
1062
+ const t = P(), r = e.schema != null, n = JSON.stringify(e.schema ?? null), o = e.submit, i = o ? typeof o == "string" ? `client:${o}` : o.via === "backend" ? "backend" : "handler" in o ? "client:handler" : `client:${o.url}` : "none", c = JSON.stringify(e.initialValues ?? null), l = T(() => r ? O(e) : null, [
1121
1063
  r,
1122
1064
  e.name,
1123
- t,
1124
- s,
1065
+ n,
1066
+ i,
1125
1067
  c,
1126
1068
  e.autoSubmit
1127
- ]), [g, d] = M({
1069
+ ]), [f, u] = M({
1128
1070
  collector: null,
1129
1071
  loading: !r,
1130
1072
  error: null
1131
1073
  });
1132
1074
  k(() => {
1133
1075
  if (r) return;
1134
- let x = !1;
1135
- return d({
1076
+ let b = !1;
1077
+ return u({
1136
1078
  collector: null,
1137
1079
  loading: !0,
1138
1080
  error: null
1139
- }), O(n, e).then((u) => {
1140
- x || d({
1141
- collector: u,
1081
+ }), H(t, e).then((d) => {
1082
+ b || u({
1083
+ collector: d,
1142
1084
  loading: !1,
1143
1085
  error: null
1144
1086
  });
1145
- }).catch((u) => {
1146
- x || d({
1087
+ }).catch((d) => {
1088
+ b || u({
1147
1089
  collector: null,
1148
1090
  loading: !1,
1149
- error: u instanceof Error ? u : new Error(String(u))
1091
+ error: d instanceof Error ? d : new Error(String(d))
1150
1092
  });
1151
1093
  }), () => {
1152
- x = !0;
1094
+ b = !0;
1153
1095
  };
1154
1096
  }, [
1155
- n,
1097
+ t,
1156
1098
  r,
1157
1099
  e.name,
1158
- s,
1100
+ i,
1159
1101
  c,
1160
1102
  e.autoSubmit
1161
1103
  ]);
1162
- const y = r ? l : g.collector, b = r ? !1 : g.loading, I = r ? null : g.error;
1104
+ const y = r ? l : f.collector, v = r ? !1 : f.loading, I = r ? null : f.error;
1163
1105
  k(() => {
1164
1106
  if (y)
1165
- return y.install(n);
1166
- }, [n, y]);
1167
- const f = F(() => Q({
1107
+ return y.install(t);
1108
+ }, [t, y]);
1109
+ const x = T(() => Q({
1168
1110
  values: e.initialValues ?? {},
1169
1111
  submitted: !1
1170
- }), [c]), m = Ae(y?.store ?? f), S = F(() => y?.getStatus() ?? H, [m, y]), w = F(() => ({
1171
- ...m,
1172
- ...S
1173
- }), [m, S]), a = F(() => ({
1112
+ }), [c]), h = Ae(y?.store ?? x), C = T(() => y?.getStatus() ?? D, [h, y]), S = T(() => ({
1113
+ ...h,
1114
+ ...C
1115
+ }), [h, C]), s = T(() => ({
1174
1116
  name: e.name,
1175
- store: f,
1117
+ store: x,
1176
1118
  functions: [],
1177
1119
  contextKey: `form:${e.name}`,
1178
1120
  contextProvider: () => ({
@@ -1187,17 +1129,17 @@ function Je(e) {
1187
1129
  ok: !1,
1188
1130
  error: "Form definition not loaded yet."
1189
1131
  }),
1190
- getValues: () => f.get().values,
1132
+ getValues: () => x.get().values,
1191
1133
  setValues: () => {
1192
1134
  },
1193
1135
  reset: () => {
1194
1136
  },
1195
- getStatus: () => H
1196
- }), [e.name, f]);
1137
+ getStatus: () => D
1138
+ }), [e.name, x]);
1197
1139
  return {
1198
- ...y ?? a,
1199
- state: w,
1200
- loading: b,
1140
+ ...y ?? s,
1141
+ state: S,
1142
+ loading: v,
1201
1143
  error: I
1202
1144
  };
1203
1145
  }
@@ -1205,23 +1147,23 @@ export {
1205
1147
  He as AgoProvider,
1206
1148
  se as ChatInput,
1207
1149
  Oe as ChatWidget,
1208
- Se as Markdown,
1150
+ Ce as Markdown,
1209
1151
  Me as Message,
1210
- $ as createFormCollector,
1211
- _e as createMockClient,
1212
- Pe as deriveFormStatus,
1213
- O as loadFormCollector,
1152
+ O as createFormCollector,
1153
+ Pe as createMockClient,
1154
+ _e as deriveFormStatus,
1155
+ H as loadFormCollector,
1214
1156
  ae as useAgo,
1215
- Ke as useAgoAutoContinueAfterNavigation,
1216
- _ as useAgoClient,
1157
+ Ue as useAgoAutoContinueAfterNavigation,
1158
+ P as useAgoClient,
1217
1159
  qe as useAgoContext,
1218
1160
  Be as useAgoFunction,
1219
1161
  Ge as useAgoNavigation,
1220
- Ue as useAgoPageState,
1162
+ Ke as useAgoPageState,
1221
1163
  Ae as useAgoStore,
1222
1164
  $e as useChat,
1223
1165
  Re as useConversation,
1224
1166
  Je as useFormCollector,
1225
- U as useMessages,
1226
- W as useOptionalAgoClient
1167
+ G as useMessages,
1168
+ z as useOptionalAgoClient
1227
1169
  };