@useago/sdk 1.4.4 → 1.5.2

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