@useago/sdk 1.5.0 → 1.5.3

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 (46) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/AgoClient-BGkFSNZF.cjs +8 -0
  3. package/dist/AgoClient-CW-BLT1_.js +1542 -0
  4. package/dist/angular.cjs +1 -1
  5. package/dist/angular.d.cts +390 -2
  6. package/dist/angular.d.ts +390 -2
  7. package/dist/angular.js +1 -1
  8. package/dist/createConversationSession-BCb0D6bt.cjs +1 -0
  9. package/dist/{createConversationSession-DCSWShaW.js → createConversationSession-C7cnnWKW.js} +3 -3
  10. package/dist/createFormCollector-iCDwAwYJ.js +279 -0
  11. package/dist/createFormCollector-t_fGyuTD.cjs +1 -0
  12. package/dist/createMockClient-Br0TWgLO.js +97 -0
  13. package/dist/createMockClient-BwNLPjeT.cjs +1 -0
  14. package/dist/devtools.d.cts +390 -2
  15. package/dist/devtools.d.ts +390 -2
  16. package/dist/helpers.d.cts +5 -0
  17. package/dist/helpers.d.ts +5 -0
  18. package/dist/index.cjs +1 -1
  19. package/dist/index.d.cts +605 -4
  20. package/dist/index.d.ts +605 -4
  21. package/dist/index.js +95 -90
  22. package/dist/react.cjs +3 -3
  23. package/dist/react.d.cts +561 -4
  24. package/dist/react.d.ts +561 -4
  25. package/dist/react.js +849 -517
  26. package/dist/testing.cjs +1 -1
  27. package/dist/testing.d.cts +390 -2
  28. package/dist/testing.d.ts +390 -2
  29. package/dist/testing.js +1 -1
  30. package/dist/vue.cjs +1 -1
  31. package/dist/vue.d.cts +411 -2
  32. package/dist/vue.d.ts +411 -2
  33. package/dist/vue.js +133 -110
  34. package/dist/widget.cjs +4 -4
  35. package/dist/widget.d.cts +387 -2
  36. package/dist/widget.d.ts +387 -2
  37. package/dist/widget.js +437 -423
  38. package/llms-full.txt +74 -2
  39. package/package.json +1 -1
  40. package/dist/AgoClient-q39FIjSC.js +0 -912
  41. package/dist/AgoClient-wcPRaIMs.cjs +0 -8
  42. package/dist/createConversationSession-BBYfQLLS.cjs +0 -1
  43. package/dist/createFormCollector-eimwwWEi.cjs +0 -1
  44. package/dist/createFormCollector-sB6rMccD.js +0 -299
  45. package/dist/createMockClient-BUc9PSbo.js +0 -79
  46. package/dist/createMockClient-CjdCqixj.cjs +0 -1
package/dist/react.js CHANGED
@@ -1,21 +1,21 @@
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";
7
- import re from "react-markdown";
8
- import oe from "remark-gfm";
9
- function ae(e) {
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;
1
+ import { a as Y, b as q, h as X, i as Z, o as Q, s as ee, t as te } from "./AgoClient-CW-BLT1_.js";
2
+ import { t as ne } from "./autoContinue-D3Mmaaca.js";
3
+ import { n as He, r as j, t as B } from "./createFormCollector-iCDwAwYJ.js";
4
+ import { t as qe } from "./createMockClient-Br0TWgLO.js";
5
+ import re, { createContext as oe, useCallback as R, useContext as G, useEffect as A, useId as ae, useMemo as W, useRef as _, useState as E, useSyncExternalStore as se } from "react";
6
+ import { Fragment as U, jsx as l, jsxs as M } from "react/jsx-runtime";
7
+ import ie from "react-markdown";
8
+ import le from "remark-gfm";
9
+ function ce(e) {
10
+ const [r, t] = E(!1), o = _(null), n = W(() => {
11
+ if (o.current && (o.current.destroy(), o.current = null), !e) return null;
12
+ const s = new te(e);
13
+ return o.current = s, s;
14
14
  }, [e?.baseUrl, e?.widgetId]);
15
- return k(() => (r(!0), () => {
16
- n.current?.destroy(), n.current = null;
17
- }), [o]), k(() => {
18
- n.current && e && n.current.updateConfig({
15
+ return A(() => (n && o.current === null && (o.current = n, n.reviveAfterDestroy()), t(!0), () => {
16
+ o.current?.destroy(), o.current = null;
17
+ }), [n]), A(() => {
18
+ o.current && e && o.current.updateConfig({
19
19
  agent: e.agent,
20
20
  defaultAgentId: e.defaultAgentId,
21
21
  permission: e.permission,
@@ -33,137 +33,137 @@ function ae(e) {
33
33
  e?.debug,
34
34
  e?.warnOnEmptyReply
35
35
  ]), {
36
- client: o,
37
- isReady: t
36
+ client: n,
37
+ isReady: r
38
38
  };
39
39
  }
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;
42
- return k(() => {
43
- if (!(!r || r.length === 0)) {
44
- for (const f of r) l.register(f);
40
+ var L = oe(null), Ke = ({ children: e, client: r, tools: t, helpers: o, pageContext: n, ...s }) => {
41
+ const { client: c } = ce(r ? null : s), a = r || c;
42
+ return A(() => {
43
+ if (!(!t || t.length === 0)) {
44
+ for (const f of t) a.register(f);
45
45
  return () => {
46
- for (const f of r) l.unregisterFunction(f.name);
46
+ for (const f of t) a.unregisterFunction(f.name);
47
47
  };
48
48
  }
49
- }, [l, r]), k(() => {
50
- if (!n) return;
49
+ }, [a, t]), A(() => {
50
+ if (!o) return;
51
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];
55
- if (!I) {
56
- console.warn(`[AGO] Unknown helper: "${y}"`);
52
+ return import("./functions-CApuQZ2b.js").then((d) => d.n).then((d) => {
53
+ for (const [g, C] of Object.entries(o)) {
54
+ const N = d[g];
55
+ if (!N) {
56
+ console.warn(`[AGO] Unknown helper: "${g}"`);
57
57
  continue;
58
58
  }
59
- const x = v === !0 ? I : {
60
- ...I,
61
- handler: v
59
+ const S = C === !0 ? N : {
60
+ ...N,
61
+ handler: C
62
62
  };
63
- l.register(x), f.push(x.name);
63
+ a.register(S), f.push(S.name);
64
64
  }
65
65
  }), () => {
66
- for (const u of f) l.unregisterFunction(u);
66
+ for (const d of f) a.unregisterFunction(d);
67
67
  };
68
- }, [l, n]), k(() => {
69
- o === "auto" && l.enableAutoPageContext();
70
- }, [l, o]), /* @__PURE__ */ a(L.Provider, {
71
- value: l,
68
+ }, [a, o]), A(() => {
69
+ n === "auto" && a.enableAutoPageContext();
70
+ }, [a, n]), /* @__PURE__ */ l(L.Provider, {
71
+ value: a,
72
72
  children: e
73
73
  });
74
74
  };
75
- function P() {
76
- const e = $(L);
75
+ function D() {
76
+ const e = G(L);
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
80
  function z() {
81
- return $(L);
81
+ return G(L);
82
82
  }
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);
87
- k(() => {
88
- t && t !== c && (l(t), I(t));
89
- }, [t]);
90
- const I = async (x) => {
83
+ function K({ client: e, conversationId: r } = {}) {
84
+ const t = z(), o = e || t;
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([]), [c, a] = E(r), [f, d] = E(!1), [g, C] = E(null);
87
+ A(() => {
88
+ r && r !== c && (a(r), N(r));
89
+ }, [r]);
90
+ const N = async (S) => {
91
91
  try {
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"));
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 k(() => {
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,
97
+ return A(() => {
98
+ const S = (u) => u === "IN_PROGRESS" || u === "WAITING_CLIENT", k = (u) => {
99
+ c || a(u.conversationId), d(!0), s((h) => {
100
+ const w = h.findIndex((b) => b.id === u.messageId);
101
+ return w >= 0 ? h.map((b, T) => T === w ? {
102
+ ...b,
103
103
  status: "IN_PROGRESS"
104
- } : g) : p.some((g) => g.role === "assistant" && x(g.status)) ? p : [...p, {
105
- id: d.messageId,
106
- conversationId: d.conversationId,
104
+ } : b) : h.some((b) => b.role === "assistant" && S(b.status)) ? h : [...h, {
105
+ id: u.messageId,
106
+ conversationId: u.conversationId,
107
107
  content: "",
108
108
  role: "assistant",
109
109
  status: "IN_PROGRESS",
110
110
  createdAt: /* @__PURE__ */ new Date()
111
111
  }];
112
112
  });
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);
113
+ }, p = (u) => {
114
+ s((h) => {
115
+ const w = h.findIndex((b) => b.id === u.messageId);
116
+ return w < 0 ? h : h.map((b, T) => T === w ? {
117
+ ...b,
118
+ content: b.content + u.content
119
+ } : b);
120
120
  });
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;
121
+ }, x = (u) => {
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 m < 0 ? p : [
129
- ...p.slice(0, m),
128
+ return w < 0 ? h : [
129
+ ...h.slice(0, w),
130
130
  {
131
- ...p[m],
132
- ...d
131
+ ...h[w],
132
+ ...u
133
133
  },
134
- ...p.slice(m + 1)
134
+ ...h.slice(w + 1)
135
135
  ];
136
136
  });
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);
137
+ }, i = (u) => {
138
+ s((h) => {
139
+ const w = h.findIndex((b) => b.id === u.id);
140
+ return w >= 0 ? [
141
+ ...h.slice(0, w),
142
+ u,
143
+ ...h.slice(w + 1)
144
+ ] : [...h, u];
145
+ }), d(!1);
146
+ }, v = (u) => {
147
+ C(new Error(u.error)), d(!1);
148
148
  };
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);
149
+ return o.on("message:start", k), o.on("message:chunk", p), o.on("message:answer-complete", x), o.on("message:complete", i), o.on("message:error", v), () => {
150
+ o.off("message:start", k), o.off("message:chunk", p), o.off("message:answer-complete", x), o.off("message:complete", i), o.off("message:error", v);
151
151
  };
152
- }, [n, c]), {
153
- messages: o,
152
+ }, [o, c]), {
153
+ messages: n,
154
154
  isLoading: f,
155
- error: y,
156
- sendMessage: A(async (x, h) => {
157
- u(!0), v(null);
158
- const C = {
155
+ error: g,
156
+ sendMessage: R(async (S, k) => {
157
+ d(!0), C(null);
158
+ const p = {
159
159
  id: `temp-${Date.now()}`,
160
160
  conversationId: c || "",
161
- content: x,
161
+ content: S,
162
162
  role: "user",
163
163
  status: "DONE",
164
- attachments: h && h.length > 0 ? J(h) : void 0,
164
+ attachments: k && k.length > 0 ? Z(k) : void 0,
165
165
  createdAt: /* @__PURE__ */ new Date()
166
- }, S = {
166
+ }, x = {
167
167
  id: `temp-assistant-${Date.now()}`,
168
168
  conversationId: c || "",
169
169
  content: "",
@@ -171,62 +171,62 @@ function G({ client: e, conversationId: t } = {}) {
171
171
  status: "IN_PROGRESS",
172
172
  createdAt: /* @__PURE__ */ new Date()
173
173
  };
174
- i((s) => [
175
- ...s,
176
- C,
177
- S
174
+ s((i) => [
175
+ ...i,
176
+ p,
177
+ x
178
178
  ]);
179
179
  try {
180
- const s = await n.sendMessage(x, {
180
+ const i = await o.sendMessage(S, {
181
181
  conversationId: c,
182
- files: h
182
+ files: k
183
183
  });
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
184
+ return i.conversationId && !c && a(i.conversationId), s((v) => {
185
+ const u = v.filter((w) => !w.id.startsWith("temp-")), h = {
186
+ ...p,
187
+ id: p.id.replace("temp-", "user-"),
188
+ conversationId: i.conversationId
189
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()) : [
191
- ...d,
192
- p,
193
- s
190
+ return u.some((w) => w.id === i.id) ? [...u, h].sort((w, b) => new Date(w.createdAt).getTime() - new Date(b.createdAt).getTime()) : [
191
+ ...u,
192
+ h,
193
+ i
194
194
  ];
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;
195
+ }), i;
196
+ } catch (i) {
197
+ return C(i instanceof Error ? i : /* @__PURE__ */ new Error("Failed to send message")), d(!1), s((v) => v.filter((u) => !u.id.startsWith("temp-"))), null;
198
198
  }
199
- }, [n, c]),
200
- clearMessages: A(() => {
201
- i([]), l(void 0), v(null);
199
+ }, [o, c]),
200
+ clearMessages: R(() => {
201
+ s([]), a(void 0), C(null);
202
202
  }, []),
203
203
  conversationId: c
204
204
  };
205
205
  }
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));
206
+ var de = ({ onSend: e, disabled: r = !1, placeholder: t = "Type a message...", allowFiles: o = !1, className: n = "" }) => {
207
+ const [s, c] = E(""), [a, f] = E([]), d = _(null), g = _(null), C = R(() => {
208
+ const i = g.current;
209
+ if (!i) return;
210
+ const v = 110;
211
+ i.style.height = "auto", i.style.height = `${Math.min(i.scrollHeight + 2, v)}px`, i.style.overflowY = i.scrollHeight + 2 > v ? "auto" : "hidden";
212
+ }, []), N = R((i) => {
213
+ i.preventDefault(), (s.trim() || a.length > 0) && (e(s.trim(), a.length > 0 ? a : void 0), c(""), f([]), requestAnimationFrame(C));
214
214
  }, [
215
- i,
216
- l,
215
+ s,
216
+ a,
217
217
  e,
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;
227
- return /* @__PURE__ */ R("form", {
228
- onSubmit: I,
229
- className: `ago-chat-input ${o}`,
218
+ C
219
+ ]), S = R((i) => {
220
+ i.key === "Enter" && !i.shiftKey && (i.preventDefault(), N(i));
221
+ }, [N]), k = R((i) => {
222
+ const v = Array.from(i.target.files || []);
223
+ f((u) => [...u, ...v]);
224
+ }, []), p = R((i) => {
225
+ f((v) => v.filter((u, h) => h !== i));
226
+ }, []), x = s.trim() || a.length > 0;
227
+ return /* @__PURE__ */ M("form", {
228
+ onSubmit: N,
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: [l.length > 0 && /* @__PURE__ */ a("div", {
238
+ children: [a.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: l.map((s, b) => /* @__PURE__ */ R("div", {
245
+ children: a.map((i, v) => /* @__PURE__ */ M("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__ */ a("span", {
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: s.name
264
- }), /* @__PURE__ */ a("button", {
263
+ children: i.name
264
+ }), /* @__PURE__ */ l("button", {
265
265
  type: "button",
266
- onClick: () => C(b),
267
- "aria-label": `Remove ${s.name}`,
266
+ onClick: () => p(v),
267
+ "aria-label": `Remove ${i.name}`,
268
268
  style: {
269
269
  border: "none",
270
270
  background: "none",
@@ -276,47 +276,47 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
276
276
  },
277
277
  children: "×"
278
278
  })]
279
- }, b))
280
- }), /* @__PURE__ */ R("div", {
279
+ }, v))
280
+ }), /* @__PURE__ */ M("div", {
281
281
  style: {
282
282
  display: "flex",
283
283
  gap: "8px",
284
284
  alignItems: "flex-end"
285
285
  },
286
286
  children: [
287
- n && /* @__PURE__ */ R(B, { children: [/* @__PURE__ */ a("button", {
287
+ o && /* @__PURE__ */ M(U, { children: [/* @__PURE__ */ l("button", {
288
288
  type: "button",
289
- onClick: () => u.current?.click(),
290
- disabled: t,
289
+ onClick: () => d.current?.click(),
290
+ disabled: r,
291
291
  "aria-label": "Attach file",
292
292
  style: {
293
293
  padding: "8px",
294
294
  border: "1px solid #dee3e8",
295
295
  borderRadius: "8px",
296
296
  backgroundColor: "#fff",
297
- cursor: t ? "not-allowed" : "pointer",
297
+ cursor: r ? "not-allowed" : "pointer",
298
298
  color: "#6b6d6f",
299
299
  fontSize: "16px",
300
300
  lineHeight: 1
301
301
  },
302
302
  children: "+"
303
- }), /* @__PURE__ */ a("input", {
304
- ref: u,
303
+ }), /* @__PURE__ */ l("input", {
304
+ ref: d,
305
305
  type: "file",
306
306
  multiple: !0,
307
- onChange: h,
307
+ onChange: k,
308
308
  style: { display: "none" }
309
309
  })] }),
310
- /* @__PURE__ */ a("textarea", {
311
- ref: y,
312
- value: i,
313
- onChange: (s) => {
314
- c(s.target.value), v();
310
+ /* @__PURE__ */ l("textarea", {
311
+ ref: g,
312
+ value: s,
313
+ onChange: (i) => {
314
+ c(i.target.value), C();
315
315
  },
316
- onKeyDown: x,
317
- placeholder: r,
318
- "aria-label": r,
319
- disabled: t,
316
+ onKeyDown: S,
317
+ placeholder: t,
318
+ "aria-label": t,
319
+ disabled: r,
320
320
  rows: 1,
321
321
  style: {
322
322
  flex: 1,
@@ -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: (s) => {
339
- s.currentTarget.style.borderColor = "#1b5fc4";
338
+ onFocus: (i) => {
339
+ i.currentTarget.style.borderColor = "#1b5fc4";
340
340
  },
341
- onBlur: (s) => {
342
- s.currentTarget.style.borderColor = "#dee3e8";
341
+ onBlur: (i) => {
342
+ i.currentTarget.style.borderColor = "#dee3e8";
343
343
  }
344
344
  }),
345
- /* @__PURE__ */ a("button", {
345
+ /* @__PURE__ */ l("button", {
346
346
  type: "submit",
347
- disabled: t || !S,
347
+ disabled: r || !x,
348
348
  style: {
349
349
  padding: "10px 18px",
350
350
  border: "none",
351
351
  borderRadius: "20px",
352
- backgroundColor: t || !S ? "#b5bfc8" : "#03182f",
352
+ backgroundColor: r || !x ? "#b5bfc8" : "#03182f",
353
353
  color: "#fff",
354
- cursor: t || !S ? "not-allowed" : "pointer",
354
+ cursor: r || !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
- }, ie = ({ href: e, children: t, ...r }) => /* @__PURE__ */ a("a", {
364
+ }, ue = ({ href: e, children: r, ...t }) => /* @__PURE__ */ l("a", {
365
365
  href: e,
366
366
  target: "_blank",
367
367
  rel: "noopener noreferrer",
@@ -369,54 +369,54 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
369
369
  color: "#1b5fc4",
370
370
  textDecoration: "underline"
371
371
  },
372
- ...r,
373
- children: t
374
- }), le = ({ children: e, ...t }) => /* @__PURE__ */ a("p", {
372
+ ...t,
373
+ children: r
374
+ }), fe = ({ children: e, ...r }) => /* @__PURE__ */ l("p", {
375
375
  style: {
376
376
  margin: "0 0 8px 0",
377
377
  lineHeight: "1.6"
378
378
  },
379
- ...t,
379
+ ...r,
380
380
  children: e
381
- }), _ = (e, t) => {
382
- const r = ({ children: n, ...o }) => Z.createElement(`h${e}`, {
381
+ }), P = (e, r) => {
382
+ const t = ({ children: o, ...n }) => re.createElement(`h${e}`, {
383
383
  style: {
384
384
  margin: "16px 0 8px 0",
385
- fontSize: t,
385
+ fontSize: r,
386
386
  fontWeight: 600,
387
387
  lineHeight: "1.3"
388
388
  },
389
- ...o
390
- }, n);
391
- return r.displayName = `MarkdownHeading${e}`, r;
392
- }, ce = ({ children: e, ...t }) => /* @__PURE__ */ a("ul", {
389
+ ...n
390
+ }, o);
391
+ return t.displayName = `MarkdownHeading${e}`, t;
392
+ }, pe = ({ children: e, ...r }) => /* @__PURE__ */ l("ul", {
393
393
  style: {
394
394
  margin: "0 0 8px 0",
395
395
  paddingLeft: "20px",
396
396
  listStyleType: "disc",
397
397
  listStylePosition: "outside"
398
398
  },
399
- ...t,
399
+ ...r,
400
400
  children: e
401
- }), de = ({ children: e, ...t }) => /* @__PURE__ */ a("ol", {
401
+ }), ge = ({ children: e, ...r }) => /* @__PURE__ */ l("ol", {
402
402
  style: {
403
403
  margin: "0 0 8px 0",
404
404
  paddingLeft: "20px",
405
405
  listStyleType: "decimal",
406
406
  listStylePosition: "outside"
407
407
  },
408
- ...t,
408
+ ...r,
409
409
  children: e
410
- }), ue = ({ children: e, ...t }) => /* @__PURE__ */ a("li", {
410
+ }), me = ({ children: e, ...r }) => /* @__PURE__ */ l("li", {
411
411
  style: {
412
412
  display: "list-item",
413
413
  margin: "2px 0",
414
414
  lineHeight: "1.6"
415
415
  },
416
- ...t,
416
+ ...r,
417
417
  children: e
418
- }), fe = ({ className: e, children: t, ...r }) => e !== void 0 || String(t).includes(`
419
- `) ? /* @__PURE__ */ a("code", {
418
+ }), xe = ({ className: e, children: r, ...t }) => e !== void 0 || String(r).includes(`
419
+ `) ? /* @__PURE__ */ l("code", {
420
420
  style: {
421
421
  display: "block",
422
422
  background: "#f5f5f5",
@@ -426,9 +426,9 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
426
426
  overflowX: "auto",
427
427
  fontFamily: '"IBM Plex Mono", monospace'
428
428
  },
429
- ...r,
430
- children: t
431
- }) : /* @__PURE__ */ a("code", {
429
+ ...t,
430
+ children: r
431
+ }) : /* @__PURE__ */ l("code", {
432
432
  style: {
433
433
  background: "#f0f2f5",
434
434
  padding: "2px 5px",
@@ -436,13 +436,13 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
436
436
  fontSize: "13px",
437
437
  fontFamily: '"IBM Plex Mono", monospace'
438
438
  },
439
- ...r,
440
- children: t
441
- }), pe = ({ children: e, ...t }) => /* @__PURE__ */ a("pre", {
442
- style: { margin: "0 0 8px 0" },
443
439
  ...t,
440
+ children: r
441
+ }), he = ({ children: e, ...r }) => /* @__PURE__ */ l("pre", {
442
+ style: { margin: "0 0 8px 0" },
443
+ ...r,
444
444
  children: e
445
- }), ge = ({ children: e, ...t }) => /* @__PURE__ */ a("blockquote", {
445
+ }), ye = ({ children: e, ...r }) => /* @__PURE__ */ l("blockquote", {
446
446
  style: {
447
447
  borderLeft: "4px solid #dee3e8",
448
448
  paddingLeft: "12px",
@@ -450,23 +450,23 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
450
450
  fontStyle: "italic",
451
451
  color: "#6b6d6f"
452
452
  },
453
- ...t,
453
+ ...r,
454
454
  children: e
455
- }), me = ({ children: e, ...t }) => /* @__PURE__ */ a("div", {
455
+ }), ve = ({ children: e, ...r }) => /* @__PURE__ */ l("div", {
456
456
  style: {
457
457
  overflowX: "auto",
458
458
  margin: "0 0 8px 0"
459
459
  },
460
- children: /* @__PURE__ */ a("table", {
460
+ children: /* @__PURE__ */ l("table", {
461
461
  style: {
462
462
  borderCollapse: "collapse",
463
463
  width: "100%",
464
464
  fontSize: "13px"
465
465
  },
466
- ...t,
466
+ ...r,
467
467
  children: e
468
468
  })
469
- }), xe = ({ children: e, ...t }) => /* @__PURE__ */ a("th", {
469
+ }), be = ({ children: e, ...r }) => /* @__PURE__ */ l("th", {
470
470
  style: {
471
471
  border: "1px solid #dee3e8",
472
472
  padding: "6px 10px",
@@ -474,66 +474,66 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
474
474
  backgroundColor: "#f5f7fa",
475
475
  fontWeight: 600
476
476
  },
477
- ...t,
477
+ ...r,
478
478
  children: e
479
- }), he = ({ children: e, ...t }) => /* @__PURE__ */ a("td", {
479
+ }), we = ({ children: e, ...r }) => /* @__PURE__ */ l("td", {
480
480
  style: {
481
481
  border: "1px solid #dee3e8",
482
482
  padding: "6px 10px"
483
483
  },
484
- ...t,
484
+ ...r,
485
485
  children: e
486
- }), ye = ({ alt: e, ...t }) => /* @__PURE__ */ a("img", {
486
+ }), Ce = ({ alt: e, ...r }) => /* @__PURE__ */ l("img", {
487
487
  alt: e ?? "",
488
488
  style: {
489
489
  maxWidth: "100%",
490
490
  borderRadius: "8px",
491
491
  margin: "4px 0"
492
492
  },
493
- ...t
494
- }), be = (e) => /* @__PURE__ */ a("hr", {
493
+ ...r
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
- }), ve = {
502
- a: ie,
503
- p: le,
504
- h1: _(1, "20px"),
505
- h2: _(2, "18px"),
506
- h3: _(3, "16px"),
507
- h4: _(4, "15px"),
508
- h5: _(5, "14px"),
509
- h6: _(6, "13px"),
510
- ul: ce,
511
- ol: de,
512
- li: ue,
513
- code: fe,
514
- pre: pe,
515
- blockquote: ge,
516
- table: me,
517
- th: xe,
518
- td: he,
519
- img: ye,
520
- hr: be
521
- }, we = [oe], Ce = ({ content: e }) => /* @__PURE__ */ a(re, {
522
- remarkPlugins: we,
523
- components: ve,
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
- }), Se = ({ attachment: e, isUser: t }) => {
526
- const r = V(e.url);
527
- if (q(e)) return /* @__PURE__ */ a("a", {
528
- href: r,
525
+ }), Ne = ({ attachment: e, isUser: r }) => {
526
+ const t = ee(e.url);
527
+ if (Y(e)) return /* @__PURE__ */ l("a", {
528
+ href: t,
529
529
  target: "_blank",
530
530
  rel: "noopener noreferrer",
531
531
  style: {
532
532
  display: "inline-block",
533
533
  textDecoration: "none"
534
534
  },
535
- children: /* @__PURE__ */ a("img", {
536
- src: r,
535
+ children: /* @__PURE__ */ l("img", {
536
+ src: t,
537
537
  alt: e.name,
538
538
  loading: "lazy",
539
539
  style: {
@@ -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 n = j(e.fileSize), o = /* @__PURE__ */ R(B, { children: [/* @__PURE__ */ a("span", {
549
+ const o = Q(e.fileSize), n = /* @__PURE__ */ M(U, { 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__ */ R("span", {
557
+ }), /* @__PURE__ */ M("span", {
558
558
  style: {
559
559
  display: "flex",
560
560
  flexDirection: "column",
561
561
  minWidth: 0
562
562
  },
563
- children: [/* @__PURE__ */ a("span", {
563
+ children: [/* @__PURE__ */ l("span", {
564
564
  style: {
565
565
  overflow: "hidden",
566
566
  textOverflow: "ellipsis",
@@ -569,38 +569,38 @@ 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
- }), n && /* @__PURE__ */ a("span", {
572
+ }), o && /* @__PURE__ */ l("span", {
573
573
  style: {
574
574
  fontSize: "11px",
575
575
  color: "#6b6d6f"
576
576
  },
577
- children: n
577
+ children: o
578
578
  })]
579
- })] }), i = {
579
+ })] }), s = {
580
580
  display: "inline-flex",
581
581
  alignItems: "center",
582
582
  gap: "8px",
583
583
  padding: "8px 12px",
584
584
  borderRadius: "10px",
585
585
  border: "1px solid #dee3e8",
586
- backgroundColor: t ? "rgba(255,255,255,0.12)" : "#fff",
587
- color: t ? "#fff" : "#30373e",
586
+ backgroundColor: r ? "rgba(255,255,255,0.12)" : "#fff",
587
+ color: r ? "#fff" : "#30373e",
588
588
  fontSize: "13px",
589
589
  textDecoration: "none",
590
590
  maxWidth: "220px"
591
591
  };
592
- return r ? /* @__PURE__ */ a("a", {
593
- href: r,
592
+ return t ? /* @__PURE__ */ l("a", {
593
+ href: t,
594
594
  target: "_blank",
595
595
  rel: "noopener noreferrer",
596
- style: i,
597
- children: o
598
- }) : /* @__PURE__ */ a("div", {
599
- style: i,
600
- children: o
596
+ style: s,
597
+ children: n
598
+ }) : /* @__PURE__ */ l("div", {
599
+ style: s,
600
+ children: n
601
601
  });
602
- }, ke = ({ source: e, index: t }) => {
603
- const r = /* @__PURE__ */ R("div", {
602
+ }, Re = ({ source: e, index: r }) => {
603
+ const t = /* @__PURE__ */ M("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__ */ a("div", {
611
+ children: [/* @__PURE__ */ l("div", {
612
612
  style: {
613
613
  flexShrink: 0,
614
614
  width: "18px",
@@ -623,8 +623,8 @@ var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
623
623
  justifyContent: "center",
624
624
  backgroundColor: "#f0f4ff"
625
625
  },
626
- children: t + 1
627
- }), /* @__PURE__ */ a("div", {
626
+ children: r + 1
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
- }), n = {
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__ */ a("a", {
651
+ return e.url ? /* @__PURE__ */ l("a", {
652
652
  href: e.url,
653
653
  target: "_blank",
654
654
  rel: "noopener noreferrer",
655
- style: n,
656
- onMouseEnter: (o) => {
657
- o.currentTarget.style.borderColor = "#1b5fc4";
655
+ style: o,
656
+ onMouseEnter: (n) => {
657
+ n.currentTarget.style.borderColor = "#1b5fc4";
658
658
  },
659
- onMouseLeave: (o) => {
660
- o.currentTarget.style.borderColor = "#dee3e8";
659
+ onMouseLeave: (n) => {
660
+ n.currentTarget.style.borderColor = "#dee3e8";
661
661
  },
662
- children: r
663
- }) : /* @__PURE__ */ a("div", {
664
- style: n,
665
- children: r
662
+ children: t
663
+ }) : /* @__PURE__ */ l("div", {
664
+ style: o,
665
+ children: t
666
666
  });
667
- }, Ie = () => /* @__PURE__ */ R("div", {
667
+ }, Ee = () => /* @__PURE__ */ M("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__ */ a("div", { style: {
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__ */ a("style", { children: `
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
- }), 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";
692
- return /* @__PURE__ */ R("div", {
693
- className: `ago-message ago-message--${e.role} ${t}`,
690
+ }), Me = ({ message: e, className: r = "", showAgentName: t = !1, isLast: o = !1, onFollowUpClick: n }) => {
691
+ const s = e.role === "user", c = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
692
+ return /* @__PURE__ */ M("div", {
693
+ className: `ago-message ago-message--${e.role} ${r}`,
694
694
  style: {
695
695
  display: "flex",
696
696
  flexDirection: "column",
697
- alignItems: i ? "flex-end" : "flex-start",
697
+ alignItems: s ? "flex-end" : "flex-start",
698
698
  marginBottom: "16px"
699
699
  },
700
700
  children: [
701
- !i && r && e.agent && /* @__PURE__ */ a("div", {
701
+ !s && t && 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
- !i && e.sources && e.sources.length > 0 && /* @__PURE__ */ a("div", {
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((l, f) => /* @__PURE__ */ a(ke, {
726
- source: l,
725
+ children: e.sources.map((a, f) => /* @__PURE__ */ l(Re, {
726
+ source: a,
727
727
  index: f
728
- }, l.id))
728
+ }, a.id))
729
729
  }),
730
- e.attachments && e.attachments.length > 0 && /* @__PURE__ */ a("div", {
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: i ? "flex-end" : "flex-start",
737
+ justifyContent: s ? "flex-end" : "flex-start",
738
738
  maxWidth: "75%"
739
739
  },
740
- children: e.attachments.map((l) => /* @__PURE__ */ a(Se, {
741
- attachment: l,
742
- isUser: i
743
- }, l.id))
740
+ children: e.attachments.map((a) => /* @__PURE__ */ l(Ne, {
741
+ attachment: a,
742
+ isUser: s
743
+ }, a.id))
744
744
  }),
745
- (e.content || c) && /* @__PURE__ */ a("div", {
745
+ (e.content || c) && /* @__PURE__ */ l("div", {
746
746
  className: "ago-message__content",
747
747
  style: {
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",
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__ */ a(Ce, { content: e.content }) : c && /* @__PURE__ */ a(Ie, {})
757
+ children: e.content ? /* @__PURE__ */ l(Ae, { content: e.content }) : c && /* @__PURE__ */ l(Ee, {})
758
758
  }),
759
- n && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ a("div", {
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((l, f) => /* @__PURE__ */ a("button", {
767
+ children: e.followUpReplies.map((a, f) => /* @__PURE__ */ l("button", {
768
768
  type: "button",
769
769
  className: "ago-message__followup-btn",
770
- disabled: !o,
771
- onClick: o ? () => o(l) : void 0,
770
+ disabled: !n,
771
+ onClick: n ? () => n(a) : void 0,
772
772
  style: {
773
773
  minHeight: "36px",
774
774
  padding: "6px 14px",
@@ -777,55 +777,55 @@ 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: o ? "pointer" : "default",
780
+ cursor: n ? "pointer" : "default",
781
781
  transition: "border-color 0.15s"
782
782
  },
783
- onMouseEnter: (u) => {
784
- u.currentTarget.style.borderColor = "#1b5fc4";
783
+ onMouseEnter: (d) => {
784
+ d.currentTarget.style.borderColor = "#1b5fc4";
785
785
  },
786
- onMouseLeave: (u) => {
787
- u.currentTarget.style.borderColor = "#dee3e8";
786
+ onMouseLeave: (d) => {
787
+ d.currentTarget.style.borderColor = "#dee3e8";
788
788
  },
789
- children: l
789
+ children: a
790
790
  }, f))
791
791
  })
792
792
  ]
793
793
  });
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({
794
+ }, Je = ({ client: e, conversationId: r, title: t = "Chat", welcomeMessage: o = "Hello! How can I help you today?", placeholder: n = "Type a message...", allowFiles: s = !1, height: c = 500, logoUrl: a, showAgentName: f = !1, forms: d, onFollowUpClick: g, className: C = "", onMessageSent: N, onMessageReceived: S }) => {
795
+ const k = _(null), p = z(), x = e ?? p, { messages: i, isLoading: v, error: u, sendMessage: h } = K({
796
796
  client: e,
797
- conversationId: t
797
+ conversationId: r
798
798
  });
799
- k(() => {
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));
799
+ A(() => {
800
+ if (!x || !d || d.length === 0) return;
801
+ let m = !1;
802
+ const I = [];
803
+ return Promise.all(d.map((F) => F.schema != null ? Promise.resolve(B(F)) : j(x, F))).then((F) => {
804
+ if (!m)
805
+ for (const V of F) I.push(V.install(x));
806
806
  }).catch(() => {
807
807
  }), () => {
808
- w = !0, F.forEach((N) => N());
808
+ m = !0, I.forEach((F) => F());
809
809
  };
810
- }, [S, u ? JSON.stringify(u.map((w) => [
811
- w.name,
812
- w.schema ?? null,
813
- w.submit ?? !1,
814
- w.description ?? null
815
- ])) : ""]), k(() => {
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
810
+ }, [x, d ? JSON.stringify(d.map((m) => [
811
+ m.name,
812
+ m.schema ?? null,
813
+ m.submit ?? !1,
814
+ m.description ?? null
815
+ ])) : ""]), A(() => {
816
+ k.current?.scrollIntoView({ behavior: "smooth" });
817
+ }, [i]), A(() => {
818
+ const m = i[i.length - 1];
819
+ m && m.role === "assistant" && m.status === "DONE" && S && S({
820
+ id: m.id,
821
+ content: m.content
822
822
  });
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));
827
- return /* @__PURE__ */ R("div", {
828
- className: `ago-chat-widget ${v}`,
823
+ }, [i, S]);
824
+ const w = async (m, I) => {
825
+ N?.(m), await h(m, I);
826
+ }, b = i[i.length - 1], T = v && b?.role === "assistant" && (b.status === "IN_PROGRESS" || b.status === "WAITING_CLIENT"), y = g === !1 ? void 0 : g ?? ((m) => w(m));
827
+ return /* @__PURE__ */ M("div", {
828
+ className: `ago-chat-widget ${C}`,
829
829
  style: {
830
830
  display: "flex",
831
831
  flexDirection: "column",
@@ -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__ */ R("div", {
842
+ /* @__PURE__ */ M("div", {
843
843
  className: "ago-chat-widget__header",
844
844
  style: {
845
845
  padding: "14px 16px",
@@ -850,23 +850,23 @@ 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: [l && /* @__PURE__ */ a("img", {
854
- src: l,
853
+ children: [a && /* @__PURE__ */ l("img", {
854
+ src: a,
855
855
  alt: "Logo",
856
856
  style: {
857
857
  height: "24px",
858
858
  width: "auto"
859
859
  }
860
- }), /* @__PURE__ */ a("h3", {
860
+ }), /* @__PURE__ */ l("h3", {
861
861
  style: {
862
862
  margin: 0,
863
863
  fontSize: "15px",
864
864
  fontWeight: 600
865
865
  },
866
- children: r
866
+ children: t
867
867
  })]
868
868
  }),
869
- /* @__PURE__ */ R("div", {
869
+ /* @__PURE__ */ M("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
- s.length === 0 ? /* @__PURE__ */ a("div", {
882
+ i.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: n
891
- }) : s.map((w, F) => /* @__PURE__ */ a(Me, {
892
- message: w,
890
+ children: o
891
+ }) : i.map((m, I) => /* @__PURE__ */ l(Me, {
892
+ message: m,
893
893
  showAgentName: f,
894
- isLast: F === s.length - 1,
895
- onFollowUpClick: K
896
- }, w.id)),
897
- d && /* @__PURE__ */ a("div", {
894
+ isLast: I === i.length - 1,
895
+ onFollowUpClick: y
896
+ }, m.id)),
897
+ u && /* @__PURE__ */ l("div", {
898
898
  role: "alert",
899
899
  style: {
900
900
  padding: "10px 14px",
@@ -905,222 +905,551 @@ 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: d.message
908
+ children: u.message
909
909
  }),
910
- /* @__PURE__ */ a("div", { ref: h })
910
+ /* @__PURE__ */ l("div", { ref: k })
911
911
  ]
912
912
  }),
913
- /* @__PURE__ */ a(se, {
914
- onSend: m,
915
- disabled: W,
916
- placeholder: o,
917
- allowFiles: i
913
+ /* @__PURE__ */ l(de, {
914
+ onSend: w,
915
+ disabled: T,
916
+ placeholder: n,
917
+ allowFiles: s
918
918
  })
919
919
  ]
920
920
  });
921
921
  };
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);
922
+ function _e(e = {}) {
923
+ const r = z(), t = e.client ?? r;
924
+ if (!t) throw new q("useProactiveNudge: no AgoClient. Pass one via options.client or wrap your tree with <AgoProvider>.", "proactive_missing_client");
925
+ const [o, n] = E(null), s = _(o);
926
+ s.current = o;
927
+ const c = _(e.onExpand);
928
+ return c.current = e.onExpand, A(() => {
929
+ const a = (d) => {
930
+ n(d), t.proactive?.shown(d);
931
+ }, f = ({ nudge: d }) => {
932
+ n((g) => g?.id === d.id ? null : g);
933
+ };
934
+ return t.on("nudge:ready", a), t.on("nudge:accepted", f), t.on("nudge:dismissed", f), () => {
935
+ t.off("nudge:ready", a), t.off("nudge:accepted", f), t.off("nudge:dismissed", f);
936
+ };
937
+ }, [t]), {
938
+ nudge: o,
939
+ accept: R(async () => {
940
+ const a = s.current;
941
+ a && (n(null), await t.proactive?.accept(a), (a.source === "agent" || a.goal) && c.current?.(a));
942
+ }, [t]),
943
+ dismiss: R(() => {
944
+ const a = s.current;
945
+ a && (n(null), t.proactive?.dismiss(a));
946
+ }, [t])
947
+ };
948
+ }
949
+ var Ve = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right", openChatLabel: n = "Open chat", className: s = "" }) => {
950
+ const { nudge: c, accept: a, dismiss: f } = _e({
951
+ client: e,
952
+ onExpand: r
953
+ });
954
+ if (A(() => {
955
+ if (!c || !t) return;
956
+ const g = setTimeout(() => f(), t);
957
+ return () => clearTimeout(g);
958
+ }, [
959
+ c,
960
+ t,
961
+ f
962
+ ]), !c) return null;
963
+ const d = c.source === "agent" || !!c.goal;
964
+ return /* @__PURE__ */ M("div", {
965
+ className: `ago-nudge ${s}`,
966
+ role: "status",
967
+ "aria-live": "polite",
968
+ style: {
969
+ position: "fixed",
970
+ bottom: "90px",
971
+ ...o === "bottom-left" ? { left: "20px" } : { right: "20px" },
972
+ zIndex: 2147483e3,
973
+ maxWidth: "320px",
974
+ padding: "14px 16px",
975
+ backgroundColor: "#fff",
976
+ color: "#03182f",
977
+ border: "1px solid #dee3e8",
978
+ borderRadius: "16px",
979
+ boxShadow: "rgba(15, 15, 15, 0.12) 0px 4px 20px 0px",
980
+ fontFamily: '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
981
+ fontSize: "14px",
982
+ lineHeight: 1.5,
983
+ textAlign: "left"
984
+ },
985
+ children: [
986
+ /* @__PURE__ */ l("button", {
987
+ type: "button",
988
+ className: "ago-nudge__close",
989
+ "aria-label": "Dismiss",
990
+ onClick: f,
991
+ style: {
992
+ position: "absolute",
993
+ top: "6px",
994
+ right: "8px",
995
+ border: "none",
996
+ background: "transparent",
997
+ color: "#6b6d6f",
998
+ fontSize: "16px",
999
+ lineHeight: 1,
1000
+ cursor: "pointer",
1001
+ padding: "4px"
1002
+ },
1003
+ children: "×"
1004
+ }),
1005
+ /* @__PURE__ */ l("div", {
1006
+ className: "ago-nudge__message",
1007
+ style: { paddingRight: "16px" },
1008
+ children: c.message
1009
+ }),
1010
+ (c.action || d) && /* @__PURE__ */ M("div", {
1011
+ className: "ago-nudge__actions",
1012
+ style: {
1013
+ display: "flex",
1014
+ gap: "8px",
1015
+ marginTop: "10px",
1016
+ flexWrap: "wrap"
1017
+ },
1018
+ children: [c.action && /* @__PURE__ */ l("button", {
1019
+ type: "button",
1020
+ className: "ago-nudge__action",
1021
+ onClick: () => {
1022
+ a();
1023
+ },
1024
+ style: {
1025
+ border: "none",
1026
+ borderRadius: "10px",
1027
+ padding: "6px 12px",
1028
+ backgroundColor: "#03182f",
1029
+ color: "#e8f0fe",
1030
+ fontSize: "13px",
1031
+ fontWeight: 600,
1032
+ cursor: "pointer"
1033
+ },
1034
+ children: c.action.label
1035
+ }), d && /* @__PURE__ */ l("button", {
1036
+ type: "button",
1037
+ className: "ago-nudge__expand",
1038
+ onClick: () => {
1039
+ a();
1040
+ },
1041
+ style: {
1042
+ border: "1px solid #dee3e8",
1043
+ borderRadius: "10px",
1044
+ padding: "6px 12px",
1045
+ backgroundColor: "#fff",
1046
+ color: "#03182f",
1047
+ fontSize: "13px",
1048
+ fontWeight: 600,
1049
+ cursor: "pointer"
1050
+ },
1051
+ children: n
1052
+ })]
1053
+ })
1054
+ ]
1055
+ });
1056
+ };
1057
+ function Fe({ client: e, autoLoad: r = !0 } = {}) {
1058
+ const t = z(), o = e || t;
1059
+ if (!o) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
1060
+ const [n, s] = E([]), [c, a] = E(null), [f, d] = E(!1), [g, C] = E(null), N = R(async () => {
1061
+ d(!0), C(null);
927
1062
  try {
928
- i(await n.getConversations());
929
- } catch (C) {
930
- v(C instanceof Error ? C : /* @__PURE__ */ new Error("Failed to load conversations"));
1063
+ s(await o.getConversations());
1064
+ } catch (p) {
1065
+ C(p instanceof Error ? p : /* @__PURE__ */ new Error("Failed to load conversations"));
931
1066
  } finally {
932
- u(!1);
1067
+ d(!1);
933
1068
  }
934
- }, [n]), x = A(async (C) => {
935
- u(!0), v(null);
1069
+ }, [o]), S = R(async (p) => {
1070
+ d(!0), C(null);
936
1071
  try {
937
- l(await n.getConversation(C));
938
- } catch (S) {
939
- v(S instanceof Error ? S : /* @__PURE__ */ new Error("Failed to load conversation"));
1072
+ a(await o.getConversation(p));
1073
+ } catch (x) {
1074
+ C(x instanceof Error ? x : /* @__PURE__ */ new Error("Failed to load conversation"));
940
1075
  } finally {
941
- u(!1);
1076
+ d(!1);
942
1077
  }
943
- }, [n]), h = A(() => {
944
- l(null);
1078
+ }, [o]), k = R(() => {
1079
+ a(null);
945
1080
  }, []);
946
- return k(() => {
947
- t && I();
948
- }, [t, I]), {
949
- conversations: o,
1081
+ return A(() => {
1082
+ r && N();
1083
+ }, [r, N]), {
1084
+ conversations: n,
950
1085
  currentConversation: c,
951
1086
  isLoading: f,
952
- error: y,
953
- selectConversation: x,
954
- startNewConversation: h,
955
- refreshConversations: I
1087
+ error: g,
1088
+ selectConversation: S,
1089
+ startNewConversation: k,
1090
+ refreshConversations: N
956
1091
  };
957
1092
  }
958
- function $e(e = {}) {
959
- const t = z(), r = e.client || t;
960
- if (!r) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
961
- const n = G({
962
- client: r,
1093
+ function Ye(e = {}) {
1094
+ const r = z(), t = e.client || r;
1095
+ if (!t) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
1096
+ const o = K({
1097
+ client: t,
963
1098
  conversationId: e.conversationId
964
- }), o = Re({
965
- client: r,
1099
+ }), n = Fe({
1100
+ client: t,
966
1101
  autoLoad: e.autoLoad
967
1102
  });
968
1103
  return {
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,
975
- conversations: o.conversations,
976
- currentConversation: o.currentConversation,
977
- isConversationsLoading: o.isLoading,
978
- selectConversation: o.selectConversation,
979
- startNewConversation: o.startNewConversation,
980
- refreshConversations: o.refreshConversations
1104
+ messages: o.messages,
1105
+ isLoading: o.isLoading,
1106
+ error: o.error || n.error,
1107
+ sendMessage: o.sendMessage,
1108
+ clearMessages: o.clearMessages,
1109
+ conversationId: o.conversationId,
1110
+ conversations: n.conversations,
1111
+ currentConversation: n.currentConversation,
1112
+ isConversationsLoading: n.isLoading,
1113
+ selectConversation: n.selectConversation,
1114
+ startNewConversation: n.startNewConversation,
1115
+ refreshConversations: n.refreshConversations
981
1116
  };
982
1117
  }
983
- function Be(e, t) {
984
- const r = P(), { name: n, description: o, parameters: i, handler: c, maxResultBytes: l } = typeof e == "string" ? {
1118
+ function Xe(e, r) {
1119
+ const t = D(), { name: o, description: n, parameters: s, handler: c, maxResultBytes: a, requiresApproval: f } = typeof e == "string" ? {
985
1120
  name: e,
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, {
991
- description: o,
992
- parameters: i,
993
- maxResultBytes: l
1121
+ ...r
1122
+ } : e, d = _(c);
1123
+ d.current = c, A(() => {
1124
+ const g = (C) => d.current(C);
1125
+ return t.registerFunction(o, g, {
1126
+ description: n,
1127
+ parameters: s,
1128
+ maxResultBytes: a,
1129
+ requiresApproval: f
994
1130
  }), () => {
995
- r.unregisterFunction(n);
1131
+ t.unregisterFunction(o);
996
1132
  };
997
1133
  }, [
998
- r,
999
- n,
1134
+ t,
1000
1135
  o,
1001
- i,
1002
- l
1136
+ n,
1137
+ s,
1138
+ a,
1139
+ f
1003
1140
  ]);
1004
1141
  }
1005
- function Ge(e, t) {
1006
- const r = P(), n = E(e);
1007
- n.current = e, k(() => (r.registerNavigationFunction((o) => n.current(o), t), () => {
1008
- r.unregisterNavigationFunction();
1009
- }), [r, t]);
1142
+ function Ze(e, r) {
1143
+ const t = D(), o = _(e);
1144
+ o.current = e, A(() => (t.registerNavigationFunction((n) => o.current(n), r), () => {
1145
+ t.unregisterNavigationFunction();
1146
+ }), [t, r]);
1010
1147
  }
1011
- function Ke(e, t) {
1012
- const r = P(), n = t?.functionName ?? "setPageState", o = E(e);
1013
- o.current = e, k(() => {
1014
- const i = o.current.map((c) => {
1015
- const l = () => o.current.find((f) => f.name === c.name) ?? c;
1148
+ function Qe(e, r) {
1149
+ const t = D(), o = r?.functionName ?? "setPageState", n = r?.requiresApproval, s = _(e);
1150
+ s.current = e, A(() => {
1151
+ const c = s.current.map((a) => {
1152
+ const f = () => s.current.find((d) => d.name === a.name) ?? a;
1016
1153
  return {
1017
- name: c.name,
1018
- description: c.description,
1019
- schema: c.schema,
1020
- get: c.get ? () => l().get?.() : void 0,
1021
- set: (f) => l().set(f)
1154
+ name: a.name,
1155
+ description: a.description,
1156
+ schema: a.schema,
1157
+ get: a.get ? () => f().get?.() : void 0,
1158
+ set: (d) => f().set(d)
1022
1159
  };
1023
1160
  });
1024
- return r.registerPageStateFunction(i, { functionName: n }), () => {
1025
- r.unregisterPageStateFunction(n);
1161
+ return t.registerPageStateFunction(c, {
1162
+ functionName: o,
1163
+ requiresApproval: n
1164
+ }), () => {
1165
+ t.unregisterPageStateFunction(o);
1026
1166
  };
1027
- }, [r, n]);
1167
+ }, [
1168
+ t,
1169
+ o,
1170
+ n
1171
+ ]);
1172
+ }
1173
+ function et(e) {
1174
+ const r = D(), t = _(e);
1175
+ t.current = e, A(() => ne(r, () => t.current), [r]);
1176
+ }
1177
+ var Te = /* @__PURE__ */ new Set(["awaiting-approval"]);
1178
+ function J(e) {
1179
+ switch (e) {
1180
+ case "progress_indicator":
1181
+ return "progress";
1182
+ case "reasoning":
1183
+ return "reasoning";
1184
+ case "confirmation_input":
1185
+ return "confirmation";
1186
+ case "form":
1187
+ return "form";
1188
+ default:
1189
+ return "status";
1190
+ }
1191
+ }
1192
+ function Pe(e) {
1193
+ return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : J(e.type);
1194
+ }
1195
+ function $(e, r) {
1196
+ const t = (e ?? "").toLowerCase();
1197
+ return t.includes("reject") ? "rejected" : t.includes("error") || t.includes("fail") ? "error" : t.includes("done") || t.includes("complet") ? "done" : (t.includes("waiting") || t.includes("pending")) && (r === "confirmation" || r === "form") ? "awaiting-approval" : "running";
1028
1198
  }
1029
- function Ue(e) {
1030
- const t = P(), r = E(e);
1031
- r.current = e, k(() => X(t, () => r.current), [t]);
1199
+ function H(e) {
1200
+ return typeof e != "string" || !e ? "page" : e.replace(/[-_]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (r) => r.toUpperCase()).trim();
1201
+ }
1202
+ function We(e) {
1203
+ switch (e.kind) {
1204
+ case "navigation":
1205
+ return `Navigating to ${H(e.arguments?.page)}`;
1206
+ case "action":
1207
+ return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message || H(e.functionName) || "Working";
1208
+ case "progress":
1209
+ return e.message || "Working";
1210
+ case "reasoning":
1211
+ return e.message || "Thinking";
1212
+ case "confirmation":
1213
+ return e.message || "Waiting for your confirmation";
1214
+ case "form":
1215
+ return e.message || e.toolDisplayName || "Please fill in the form";
1216
+ default:
1217
+ return e.message || e.toolDisplayName || e.toolName || "Working";
1218
+ }
1219
+ }
1220
+ function tt(e = {}) {
1221
+ const { includeReasoning: r = !1, labelFor: t } = e, o = z(), n = e.client || o;
1222
+ if (!n) throw new q("useAgoActivity requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
1223
+ const [s, c] = E([]), a = _(/* @__PURE__ */ new Set()), f = _(void 0), d = _(t);
1224
+ d.current = t;
1225
+ const g = R((p, x) => {
1226
+ c((i) => {
1227
+ const v = i.findIndex((h) => h.id === p), u = {
1228
+ ...v >= 0 ? i[v] : {
1229
+ id: p,
1230
+ kind: "status",
1231
+ label: "",
1232
+ status: "running",
1233
+ requiresApproval: !1,
1234
+ createdAt: /* @__PURE__ */ new Date()
1235
+ },
1236
+ ...x
1237
+ };
1238
+ return u.label = d.current?.(u) ?? We(u), v >= 0 ? [
1239
+ ...i.slice(0, v),
1240
+ u,
1241
+ ...i.slice(v + 1)
1242
+ ] : [...i, u];
1243
+ });
1244
+ }, []);
1245
+ A(() => {
1246
+ const p = (y) => {
1247
+ f.current = y.messageId;
1248
+ }, x = (y) => {
1249
+ const m = J(y.type);
1250
+ m === "reasoning" && !r || g(y.id, {
1251
+ kind: m,
1252
+ status: $(y.status, m),
1253
+ messageId: f.current,
1254
+ toolName: y.toolName,
1255
+ toolDisplayName: y.toolDisplayName,
1256
+ message: y.message,
1257
+ data: y.data,
1258
+ formSchema: y.formSchema,
1259
+ requiresApproval: m === "confirmation" || m === "form"
1260
+ });
1261
+ }, i = (y) => {
1262
+ y.invocationId && g(y.invocationId, {
1263
+ kind: y.functionName === "navigateToPage" ? "navigation" : "action",
1264
+ status: "running",
1265
+ messageId: f.current,
1266
+ functionName: y.functionName,
1267
+ arguments: y.arguments
1268
+ });
1269
+ }, v = (y) => {
1270
+ y.invocationId && g(y.invocationId, {
1271
+ kind: y.functionName === "navigateToPage" ? "navigation" : "action",
1272
+ status: "awaiting-approval",
1273
+ messageId: f.current,
1274
+ functionName: y.functionName,
1275
+ arguments: y.arguments,
1276
+ requiresApproval: !0
1277
+ });
1278
+ }, u = (y) => {
1279
+ if (!y.invocationId) return;
1280
+ const m = y.result, I = typeof y.result == "object" && m !== null && m.approved === !1 && m.reason === "user_rejected";
1281
+ g(y.invocationId, {
1282
+ status: y.error ? "error" : I ? "rejected" : "done",
1283
+ requiresApproval: !1
1284
+ });
1285
+ }, h = (y) => {
1286
+ for (const m of y.messages ?? [])
1287
+ if (m.role === "assistant")
1288
+ for (const I of m.toolCalls ?? []) {
1289
+ const F = Pe(I);
1290
+ F === "reasoning" && !r || /waiting/i.test(I.status ?? "") || g(I.id, {
1291
+ kind: F,
1292
+ status: $(I.status, F),
1293
+ messageId: m.id,
1294
+ toolName: I.toolName,
1295
+ toolDisplayName: I.toolDisplayName,
1296
+ functionName: I.functionName,
1297
+ arguments: I.arguments,
1298
+ message: I.message,
1299
+ data: I.data,
1300
+ formSchema: I.formSchema,
1301
+ requiresApproval: F === "confirmation" || F === "form"
1302
+ });
1303
+ }
1304
+ }, w = (y) => {
1305
+ c((m) => m.map((I) => I.status === "running" || I.status === "awaiting-approval" ? {
1306
+ ...I,
1307
+ status: y
1308
+ } : I));
1309
+ }, b = () => w("done"), T = () => w("error");
1310
+ return n.on("message:start", p), n.on("toolCall:received", x), n.on("function:invoke", i), n.on("function:awaiting-approval", v), n.on("function:result", u), n.on("conversation:loaded", h), n.on("message:complete", b), n.on("message:error", T), () => {
1311
+ n.off("message:start", p), n.off("toolCall:received", x), n.off("function:invoke", i), n.off("function:awaiting-approval", v), n.off("function:result", u), n.off("conversation:loaded", h), n.off("message:complete", b), n.off("message:error", T);
1312
+ };
1313
+ }, [
1314
+ n,
1315
+ r,
1316
+ g
1317
+ ]);
1318
+ const C = R(async (p) => {
1319
+ const x = s.find((i) => i.id === p);
1320
+ !x || x.status !== "awaiting-approval" || a.current.has(p) || x.kind !== "form" && (a.current.add(p), g(p, {
1321
+ status: "running",
1322
+ requiresApproval: !1
1323
+ }), x.functionName ? await n.approveFunction(p) : await n.confirmToolCall(p));
1324
+ }, [
1325
+ n,
1326
+ s,
1327
+ g
1328
+ ]), N = R(async (p) => {
1329
+ const x = s.find((i) => i.id === p);
1330
+ !x || x.status !== "awaiting-approval" || a.current.has(p) || (a.current.add(p), g(p, {
1331
+ status: "rejected",
1332
+ requiresApproval: !1
1333
+ }), x.functionName ? await n.rejectFunction(p) : await n.rejectToolCall(p));
1334
+ }, [
1335
+ n,
1336
+ s,
1337
+ g
1338
+ ]), S = R(async (p, x) => {
1339
+ g(p, {
1340
+ status: "running",
1341
+ requiresApproval: !1
1342
+ }), await n.submitToolCallForm(p, x), g(p, { status: "done" });
1343
+ }, [n, g]), k = R(() => {
1344
+ a.current.clear(), c([]);
1345
+ }, []);
1346
+ return {
1347
+ items: s,
1348
+ latest: s.length > 0 ? s[s.length - 1] : void 0,
1349
+ isAwaitingApproval: s.some((p) => Te.has(p.status)),
1350
+ approve: C,
1351
+ reject: N,
1352
+ submitForm: S,
1353
+ clear: k
1354
+ };
1032
1355
  }
1033
- function qe(e, t) {
1034
- const r = P(), n = te(), o = t ?? n, i = E(e);
1035
- i.current = e;
1356
+ function nt(e, r) {
1357
+ const t = D(), o = ae(), n = r ?? o, s = _(e);
1358
+ s.current = e;
1036
1359
  const c = typeof e == "function";
1037
- k(() => {
1038
- if (typeof i.current == "function") {
1039
- const l = () => i.current();
1040
- return r.addDynamicContext(o, l), () => {
1041
- r.removeDynamicContext(o);
1360
+ A(() => {
1361
+ if (typeof s.current == "function") {
1362
+ const a = () => s.current();
1363
+ return t.addDynamicContext(n, a), () => {
1364
+ t.removeDynamicContext(n);
1042
1365
  };
1043
1366
  }
1044
- return r.setContext(o, i.current), () => {
1045
- r.removeContext(o);
1367
+ return t.setContext(n, s.current), () => {
1368
+ t.removeContext(n);
1046
1369
  };
1047
1370
  }, [
1048
- r,
1049
- o,
1371
+ t,
1372
+ n,
1050
1373
  c,
1051
1374
  c ? "" : JSON.stringify(e)
1052
1375
  ]);
1053
1376
  }
1054
- function Ae(e) {
1055
- return ne(e.subscribe, e.get, e.get);
1377
+ function De(e) {
1378
+ return se(e.subscribe, e.get, e.get);
1056
1379
  }
1057
- var D = {
1380
+ var O = {
1058
1381
  missing: [],
1059
1382
  complete: !1
1060
1383
  };
1061
- function Je(e) {
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, [
1063
- r,
1384
+ function rt(e) {
1385
+ const r = D(), t = 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", c = JSON.stringify(e.initialValues ?? null), a = W(() => t ? B(e) : null, [
1386
+ t,
1064
1387
  e.name,
1065
- n,
1066
- i,
1388
+ o,
1389
+ s,
1067
1390
  c,
1068
1391
  e.autoSubmit
1069
- ]), [f, u] = M({
1392
+ ]), [f, d] = E({
1070
1393
  collector: null,
1071
- loading: !r,
1394
+ loading: !t,
1072
1395
  error: null
1073
1396
  });
1074
- k(() => {
1075
- if (r) return;
1076
- let b = !1;
1077
- return u({
1397
+ A(() => {
1398
+ if (t) return;
1399
+ let v = !1;
1400
+ return d({
1078
1401
  collector: null,
1079
1402
  loading: !0,
1080
1403
  error: null
1081
- }), H(t, e).then((d) => {
1082
- b || u({
1083
- collector: d,
1404
+ }), j(r, e).then((u) => {
1405
+ v || d({
1406
+ collector: u,
1084
1407
  loading: !1,
1085
1408
  error: null
1086
1409
  });
1087
- }).catch((d) => {
1088
- b || u({
1410
+ }).catch((u) => {
1411
+ v || d({
1089
1412
  collector: null,
1090
1413
  loading: !1,
1091
- error: d instanceof Error ? d : new Error(String(d))
1414
+ error: u instanceof Error ? u : new Error(String(u))
1092
1415
  });
1093
1416
  }), () => {
1094
- b = !0;
1417
+ v = !0;
1095
1418
  };
1096
1419
  }, [
1097
- t,
1098
1420
  r,
1421
+ t,
1099
1422
  e.name,
1100
- i,
1423
+ s,
1101
1424
  c,
1102
1425
  e.autoSubmit
1103
1426
  ]);
1104
- const y = r ? l : f.collector, v = r ? !1 : f.loading, I = r ? null : f.error;
1105
- k(() => {
1106
- if (y)
1107
- return y.install(t);
1108
- }, [t, y]);
1109
- const x = T(() => Q({
1427
+ const g = t ? a : f.collector, C = t ? !1 : f.loading, N = t ? null : f.error;
1428
+ A(() => {
1429
+ if (g)
1430
+ return g.install(r);
1431
+ }, [r, g]);
1432
+ const S = W(() => X({
1110
1433
  values: e.initialValues ?? {},
1111
1434
  submitted: !1
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(() => ({
1435
+ }), [c]), k = De(g?.store ?? S), p = W(() => g?.getStatus() ?? O, [k, g]), x = W(() => ({
1436
+ ...k,
1437
+ ...p
1438
+ }), [k, p]), i = W(() => ({
1116
1439
  name: e.name,
1117
- store: x,
1440
+ store: S,
1118
1441
  functions: [],
1119
1442
  contextKey: `form:${e.name}`,
1120
1443
  contextProvider: () => ({
1121
1444
  name: `Form: ${e.name}`,
1122
1445
  description: ""
1123
1446
  }),
1447
+ definitionContextKey: `form:${e.name}:definition`,
1448
+ definitionContextProvider: () => ({
1449
+ name: `Form definition: ${e.name}`,
1450
+ description: "",
1451
+ stable: !0
1452
+ }),
1124
1453
  install: () => () => {
1125
1454
  },
1126
1455
  hydrate: () => {
@@ -1129,41 +1458,44 @@ function Je(e) {
1129
1458
  ok: !1,
1130
1459
  error: "Form definition not loaded yet."
1131
1460
  }),
1132
- getValues: () => x.get().values,
1461
+ getValues: () => S.get().values,
1133
1462
  setValues: () => {
1134
1463
  },
1135
1464
  reset: () => {
1136
1465
  },
1137
- getStatus: () => D
1138
- }), [e.name, x]);
1466
+ getStatus: () => O
1467
+ }), [e.name, S]);
1139
1468
  return {
1140
- ...y ?? s,
1141
- state: S,
1142
- loading: v,
1143
- error: I
1469
+ ...g ?? i,
1470
+ state: x,
1471
+ loading: C,
1472
+ error: N
1144
1473
  };
1145
1474
  }
1146
1475
  export {
1147
- He as AgoProvider,
1148
- se as ChatInput,
1149
- Oe as ChatWidget,
1150
- Ce as Markdown,
1476
+ Ve as AgoNudge,
1477
+ Ke as AgoProvider,
1478
+ de as ChatInput,
1479
+ Je as ChatWidget,
1480
+ Ae as Markdown,
1151
1481
  Me as Message,
1152
- O as createFormCollector,
1153
- Pe as createMockClient,
1154
- _e as deriveFormStatus,
1155
- H as loadFormCollector,
1156
- ae as useAgo,
1157
- Ue as useAgoAutoContinueAfterNavigation,
1158
- P as useAgoClient,
1159
- qe as useAgoContext,
1160
- Be as useAgoFunction,
1161
- Ge as useAgoNavigation,
1162
- Ke as useAgoPageState,
1163
- Ae as useAgoStore,
1164
- $e as useChat,
1165
- Re as useConversation,
1166
- Je as useFormCollector,
1167
- G as useMessages,
1168
- z as useOptionalAgoClient
1482
+ B as createFormCollector,
1483
+ qe as createMockClient,
1484
+ He as deriveFormStatus,
1485
+ j as loadFormCollector,
1486
+ ce as useAgo,
1487
+ tt as useAgoActivity,
1488
+ et as useAgoAutoContinueAfterNavigation,
1489
+ D as useAgoClient,
1490
+ nt as useAgoContext,
1491
+ Xe as useAgoFunction,
1492
+ Ze as useAgoNavigation,
1493
+ Qe as useAgoPageState,
1494
+ De as useAgoStore,
1495
+ Ye as useChat,
1496
+ Fe as useConversation,
1497
+ rt as useFormCollector,
1498
+ K as useMessages,
1499
+ z as useOptionalAgoClient,
1500
+ _e as useProactiveNudge
1169
1501
  };