@useago/sdk 1.9.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +173 -2
  2. package/README.md +126 -0
  3. package/dist/angular.cjs +1 -1
  4. package/dist/angular.d.cts +408 -26
  5. package/dist/angular.d.ts +408 -26
  6. package/dist/angular.js +4 -1
  7. package/dist/{createConversationSession-BaaXBQ5b.js → createConversationSession-BfJg0WyA.js} +1 -1
  8. package/dist/{createConversationSession-CU0b-t1W.cjs → createConversationSession-CiOXKWl0.cjs} +1 -1
  9. package/dist/{createFormCollector-Cf7kGhCB.js → createFormCollector-DN1xjAv5.js} +1 -1
  10. package/dist/{createFormCollector-DfN1xZBy.cjs → createFormCollector-DnQl77Ko.cjs} +1 -1
  11. package/dist/createMockClient-BPt1gSve.cjs +1 -0
  12. package/dist/{createMockClient-5YF-ZbVu.js → createMockClient-YoYr3pQr.js} +16 -3
  13. package/dist/devtools.cjs +4 -4
  14. package/dist/devtools.d.cts +406 -26
  15. package/dist/devtools.d.ts +406 -26
  16. package/dist/devtools.js +87 -84
  17. package/dist/helpers.d.cts +42 -12
  18. package/dist/helpers.d.ts +42 -12
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.cts +486 -35
  21. package/dist/index.d.ts +486 -35
  22. package/dist/index.js +117 -112
  23. package/dist/react.cjs +4 -4
  24. package/dist/react.d.cts +458 -26
  25. package/dist/react.d.ts +458 -26
  26. package/dist/react.js +816 -727
  27. package/dist/speechToText-BV7qxqPF.js +704 -0
  28. package/dist/speechToText-ZciRyyJE.cjs +1 -0
  29. package/dist/testing.cjs +1 -1
  30. package/dist/testing.d.cts +406 -26
  31. package/dist/testing.d.ts +406 -26
  32. package/dist/testing.js +1 -1
  33. package/dist/types-Q7t1peH-.js +2584 -0
  34. package/dist/types-a7teDBnC.cjs +10 -0
  35. package/dist/vue.cjs +1 -1
  36. package/dist/vue.d.cts +608 -26
  37. package/dist/vue.d.ts +608 -26
  38. package/dist/vue.js +103 -101
  39. package/dist/widget.cjs +6 -4
  40. package/dist/widget.d.cts +710 -28
  41. package/dist/widget.d.ts +710 -28
  42. package/dist/widget.js +3911 -976
  43. package/llms-full.txt +254 -7
  44. package/package.json +1 -1
  45. package/dist/createMockClient-BZbOe-23.cjs +0 -1
  46. package/dist/sheetController-CBUVOroo.js +0 -205
  47. package/dist/sheetController-DY-sC13T.cjs +0 -1
  48. package/dist/types-CPga11Of.js +0 -2068
  49. package/dist/types-D3YQl1jx.cjs +0 -9
package/dist/react.js CHANGED
@@ -1,18 +1,18 @@
1
- import { a as Fe, c as We, g as ze, n as De, o as Pe, s as Le, t as He } from "./types-CPga11Of.js";
2
- import { n as X } from "./errors-BLfjXnLB.js";
3
- import { t as Be } from "./autoContinue-CC8K9mBU.js";
4
- import { n as Lt, r as ge, t as me } from "./createFormCollector-Cf7kGhCB.js";
5
- import { t as Bt } from "./createMockClient-5YF-ZbVu.js";
6
- import { C as Oe, S as qe, n as je } from "./sheetController-CBUVOroo.js";
7
- import $e, { createContext as Ke, forwardRef as Ue, useCallback as _, useContext as he, useEffect as E, useId as Ge, useImperativeHandle as Je, useMemo as B, useRef as D, useState as T, useSyncExternalStore as xe } from "react";
8
- import { Fragment as be, jsx as a, jsxs as M } from "react/jsx-runtime";
9
- import Ve from "react-markdown";
10
- import Ye from "remark-gfm";
11
- function Xe(e) {
12
- const [r, t] = T(!1), o = D(null), n = B(() => {
1
+ import { a as De, c as ze, g as Le, n as Pe, o as Be, s as He, t as Oe } from "./types-Q7t1peH-.js";
2
+ import { n as Q } from "./errors-BLfjXnLB.js";
3
+ import { t as $e } from "./autoContinue-CC8K9mBU.js";
4
+ import { n as jt, r as he, t as xe } from "./createFormCollector-DN1xjAv5.js";
5
+ import { t as Kt } from "./createMockClient-YoYr3pQr.js";
6
+ import { C as je, dt as qe, n as Ke, t as Jt, ut as Ue } from "./speechToText-BV7qxqPF.js";
7
+ import Ge, { createContext as Je, forwardRef as Ve, useCallback as T, useContext as be, useEffect as E, useId as Xe, useImperativeHandle as Ye, useLayoutEffect as Ze, useMemo as $, useRef as W, useState as M, useSyncExternalStore as ye } from "react";
8
+ import { Fragment as ve, jsx as a, jsxs as F } from "react/jsx-runtime";
9
+ import Qe from "react-markdown";
10
+ import et from "remark-gfm";
11
+ function tt(e) {
12
+ const [r, t] = M(!1), o = W(null), n = $(() => {
13
13
  if (o.current && (o.current.destroy(), o.current = null), !e) return null;
14
- const l = new De(e);
15
- return o.current = l, l;
14
+ const s = new Pe(e);
15
+ return o.current = s, s;
16
16
  }, [e?.baseUrl, e?.widgetId]);
17
17
  return E(() => (n && o.current === null && (o.current = n, n.reviveAfterDestroy()), t(!0), () => {
18
18
  o.current?.destroy(), o.current = null;
@@ -21,8 +21,10 @@ function Xe(e) {
21
21
  agent: e.agent,
22
22
  defaultAgentId: e.defaultAgentId,
23
23
  permission: e.permission,
24
+ language: e.language ?? null,
24
25
  userEmail: e.userEmail,
25
26
  userJwt: e.userJwt,
27
+ metadata: e.metadata ?? null,
26
28
  debug: e.debug,
27
29
  warnOnEmptyReply: e.warnOnEmptyReply
28
30
  });
@@ -30,8 +32,10 @@ function Xe(e) {
30
32
  e?.agent,
31
33
  e?.defaultAgentId,
32
34
  e?.permission,
35
+ e?.language,
33
36
  e?.userEmail,
34
37
  e?.userJwt,
38
+ e?.metadata,
35
39
  e?.debug,
36
40
  e?.warnOnEmptyReply
37
41
  ]), {
@@ -39,51 +43,51 @@ function Xe(e) {
39
43
  isReady: r
40
44
  };
41
45
  }
42
- var ee = Ke(null), Ut = ({ children: e, client: r, tools: t, helpers: o, pageContext: n, ...l }) => {
43
- const { client: s } = Xe(r ? null : l), i = r || s;
46
+ var ne = Je(null), Qt = ({ children: e, client: r, tools: t, helpers: o, pageContext: n, ...s }) => {
47
+ const { client: c } = tt(r ? null : s), i = r || c;
44
48
  return E(() => {
45
49
  if (!(!t || t.length === 0)) {
46
- for (const u of t) i.register(u);
50
+ for (const g of t) i.register(g);
47
51
  return () => {
48
- for (const u of t) i.unregisterFunction(u.name);
52
+ for (const g of t) i.unregisterFunction(g.name);
49
53
  };
50
54
  }
51
55
  }, [i, t]), E(() => {
52
56
  if (!o) return;
53
- const u = [];
54
- return import("./functions-tzyOZNp6.js").then((c) => c.n).then((c) => {
55
- for (const [p, v] of Object.entries(o)) {
56
- const S = c[p];
57
- if (!S) {
58
- console.warn(`[AGO] Unknown helper: "${p}"`);
57
+ const g = [];
58
+ return import("./functions-tzyOZNp6.js").then((d) => d.n).then((d) => {
59
+ for (const [f, x] of Object.entries(o)) {
60
+ const m = d[f];
61
+ if (!m) {
62
+ console.warn(`[AGO] Unknown helper: "${f}"`);
59
63
  continue;
60
64
  }
61
- const g = v === !0 ? S : {
62
- ...S,
63
- handler: v
65
+ const u = x === !0 ? m : {
66
+ ...m,
67
+ handler: x
64
68
  };
65
- i.register(g), u.push(g.name);
69
+ i.register(u), g.push(u.name);
66
70
  }
67
71
  }), () => {
68
- for (const c of u) i.unregisterFunction(c);
72
+ for (const d of g) i.unregisterFunction(d);
69
73
  };
70
74
  }, [i, o]), E(() => {
71
75
  n === "auto" && i.enableAutoPageContext();
72
- }, [i, n]), /* @__PURE__ */ a(ee.Provider, {
76
+ }, [i, n]), /* @__PURE__ */ a(ne.Provider, {
73
77
  value: i,
74
78
  children: e
75
79
  });
76
80
  };
77
- function $() {
78
- const e = he(ee);
81
+ function U() {
82
+ const e = be(ne);
79
83
  if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
80
84
  return e;
81
85
  }
82
86
  function O() {
83
- return he(ee);
87
+ return be(ne);
84
88
  }
85
- var Ze = /* @__PURE__ */ new Set(["awaiting-approval"]);
86
- function ye(e) {
89
+ var nt = /* @__PURE__ */ new Set(["awaiting-approval"]);
90
+ function we(e) {
87
91
  switch (e) {
88
92
  case "progress_indicator":
89
93
  return "progress";
@@ -97,22 +101,22 @@ function ye(e) {
97
101
  return "status";
98
102
  }
99
103
  }
100
- function Qe(e) {
101
- return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : ye(e.type);
104
+ function rt(e) {
105
+ return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : we(e.type);
102
106
  }
103
- function le(e, r) {
107
+ function de(e, r) {
104
108
  const t = (e ?? "").toLowerCase();
105
109
  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";
106
110
  }
107
- function ce(e) {
111
+ function ue(e) {
108
112
  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();
109
113
  }
110
- function et(e) {
114
+ function ot(e) {
111
115
  switch (e.kind) {
112
116
  case "navigation":
113
- return `Navigating to ${ce(e.arguments?.page)}`;
117
+ return `Navigating to ${ue(e.arguments?.page)}`;
114
118
  case "action":
115
- return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message || ce(e.functionName) || "Working";
119
+ return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message || ue(e.functionName) || "Working";
116
120
  case "progress":
117
121
  return e.message || "Working";
118
122
  case "reasoning":
@@ -125,164 +129,164 @@ function et(e) {
125
129
  return e.message || e.toolDisplayName || e.toolName || "Working";
126
130
  }
127
131
  }
128
- function tt(e = {}) {
132
+ function at(e = {}) {
129
133
  const { includeReasoning: r = !1, labelFor: t } = e, o = O(), n = e.client || o;
130
- if (!n) throw new X("useAgoActivity requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
131
- const [l, s] = T([]), i = D(/* @__PURE__ */ new Set()), u = D(void 0), c = D(t);
132
- c.current = t;
133
- const p = _((d, w) => {
134
- s((x) => {
135
- const f = x.findIndex((y) => y.id === d), h = {
136
- ...f >= 0 ? x[f] : {
137
- id: d,
134
+ if (!n) throw new Q("useAgoActivity requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
135
+ const [s, c] = M([]), i = W(/* @__PURE__ */ new Set()), g = W(void 0), d = W(t);
136
+ d.current = t;
137
+ const f = T((p, k) => {
138
+ c((b) => {
139
+ const R = b.findIndex((y) => y.id === p), _ = {
140
+ ...R >= 0 ? b[R] : {
141
+ id: p,
138
142
  kind: "status",
139
143
  label: "",
140
144
  status: "running",
141
145
  requiresApproval: !1,
142
146
  createdAt: /* @__PURE__ */ new Date()
143
147
  },
144
- ...w
148
+ ...k
145
149
  };
146
- return h.label = c.current?.(h) ?? et(h), f >= 0 ? [
147
- ...x.slice(0, f),
148
- h,
149
- ...x.slice(f + 1)
150
- ] : [...x, h];
150
+ return _.label = d.current?.(_) ?? ot(_), R >= 0 ? [
151
+ ...b.slice(0, R),
152
+ _,
153
+ ...b.slice(R + 1)
154
+ ] : [...b, _];
151
155
  });
152
156
  }, []);
153
157
  E(() => {
154
- const d = (k) => {
155
- u.current = k.messageId;
156
- }, w = (k) => {
157
- const F = ye(k.type);
158
- F === "reasoning" && !r || p(k.id, {
159
- kind: F,
160
- status: le(k.status, F),
161
- messageId: u.current,
162
- toolName: k.toolName,
163
- toolDisplayName: k.toolDisplayName,
164
- message: k.message,
165
- data: k.data,
166
- formSchema: k.formSchema,
167
- requiresApproval: F === "confirmation" || F === "form"
158
+ const p = (h) => {
159
+ g.current = h.messageId;
160
+ }, k = (h) => {
161
+ const D = we(h.type);
162
+ D === "reasoning" && !r || f(h.id, {
163
+ kind: D,
164
+ status: de(h.status, D),
165
+ messageId: g.current,
166
+ toolName: h.toolName,
167
+ toolDisplayName: h.toolDisplayName,
168
+ message: h.message,
169
+ data: h.data,
170
+ formSchema: h.formSchema,
171
+ requiresApproval: D === "confirmation" || D === "form"
168
172
  });
169
- }, x = (k) => {
170
- k.invocationId && p(k.invocationId, {
171
- kind: k.functionName === "navigateToPage" ? "navigation" : "action",
173
+ }, b = (h) => {
174
+ h.invocationId && f(h.invocationId, {
175
+ kind: h.functionName === "navigateToPage" ? "navigation" : "action",
172
176
  status: "running",
173
- messageId: u.current,
174
- functionName: k.functionName,
175
- arguments: k.arguments
177
+ messageId: g.current,
178
+ functionName: h.functionName,
179
+ arguments: h.arguments
176
180
  });
177
- }, f = (k) => {
178
- k.invocationId && p(k.invocationId, {
179
- kind: k.functionName === "navigateToPage" ? "navigation" : "action",
181
+ }, R = (h) => {
182
+ h.invocationId && f(h.invocationId, {
183
+ kind: h.functionName === "navigateToPage" ? "navigation" : "action",
180
184
  status: "awaiting-approval",
181
- messageId: u.current,
182
- functionName: k.functionName,
183
- arguments: k.arguments,
185
+ messageId: g.current,
186
+ functionName: h.functionName,
187
+ arguments: h.arguments,
184
188
  requiresApproval: !0
185
189
  });
186
- }, h = (k) => {
187
- if (!k.invocationId) return;
188
- const F = k.result, C = typeof k.result == "object" && F !== null && F.approved === !1 && F.reason === "user_rejected";
189
- p(k.invocationId, {
190
- status: k.error ? "error" : C ? "rejected" : "done",
190
+ }, _ = (h) => {
191
+ if (!h.invocationId) return;
192
+ const D = h.result, l = typeof h.result == "object" && D !== null && D.approved === !1 && D.reason === "user_rejected";
193
+ f(h.invocationId, {
194
+ status: h.error ? "error" : l ? "rejected" : "done",
191
195
  requiresApproval: !1
192
196
  });
193
- }, y = (k) => {
194
- for (const F of k.messages ?? [])
195
- if (F.role === "assistant")
196
- for (const C of F.toolCalls ?? []) {
197
- const I = Qe(C);
198
- I === "reasoning" && !r || /waiting/i.test(C.status ?? "") || p(C.id, {
199
- kind: I,
200
- status: le(C.status, I),
201
- messageId: F.id,
202
- toolName: C.toolName,
203
- toolDisplayName: C.toolDisplayName,
204
- functionName: C.functionName,
205
- arguments: C.arguments,
206
- message: C.message,
207
- data: C.data,
208
- formSchema: C.formSchema,
209
- requiresApproval: I === "confirmation" || I === "form"
197
+ }, y = (h) => {
198
+ for (const D of h.messages ?? [])
199
+ if (D.role === "assistant")
200
+ for (const l of D.toolCalls ?? []) {
201
+ const S = rt(l);
202
+ S === "reasoning" && !r || /waiting/i.test(l.status ?? "") || f(l.id, {
203
+ kind: S,
204
+ status: de(l.status, S),
205
+ messageId: D.id,
206
+ toolName: l.toolName,
207
+ toolDisplayName: l.toolDisplayName,
208
+ functionName: l.functionName,
209
+ arguments: l.arguments,
210
+ message: l.message,
211
+ data: l.data,
212
+ formSchema: l.formSchema,
213
+ requiresApproval: S === "confirmation" || S === "form"
210
214
  });
211
215
  }
212
- }, m = (k) => {
213
- s((F) => F.map((C) => C.status === "running" || C.status === "awaiting-approval" ? {
214
- ...C,
215
- status: k
216
- } : C));
217
- }, A = () => m("done"), N = () => m("error");
218
- return n.on("message:start", d), n.on("toolCall:received", w), n.on("function:invoke", x), n.on("function:awaiting-approval", f), n.on("function:result", h), n.on("conversation:loaded", y), n.on("message:complete", A), n.on("message:error", N), () => {
219
- n.off("message:start", d), n.off("toolCall:received", w), n.off("function:invoke", x), n.off("function:awaiting-approval", f), n.off("function:result", h), n.off("conversation:loaded", y), n.off("message:complete", A), n.off("message:error", N);
216
+ }, C = (h) => {
217
+ c((D) => D.map((l) => l.status === "running" || l.status === "awaiting-approval" ? {
218
+ ...l,
219
+ status: h
220
+ } : l));
221
+ }, A = () => C("done"), N = () => C("error");
222
+ return n.on("message:start", p), n.on("toolCall:received", k), n.on("function:invoke", b), n.on("function:awaiting-approval", R), n.on("function:result", _), n.on("conversation:loaded", y), n.on("message:complete", A), n.on("message:error", N), () => {
223
+ n.off("message:start", p), n.off("toolCall:received", k), n.off("function:invoke", b), n.off("function:awaiting-approval", R), n.off("function:result", _), n.off("conversation:loaded", y), n.off("message:complete", A), n.off("message:error", N);
220
224
  };
221
225
  }, [
222
226
  n,
223
227
  r,
224
- p
228
+ f
225
229
  ]);
226
- const v = _(async (d) => {
227
- const w = l.find((x) => x.id === d);
228
- !w || w.status !== "awaiting-approval" || i.current.has(d) || w.kind !== "form" && (i.current.add(d), p(d, {
230
+ const x = T(async (p) => {
231
+ const k = s.find((b) => b.id === p);
232
+ !k || k.status !== "awaiting-approval" || i.current.has(p) || k.kind !== "form" && (i.current.add(p), f(p, {
229
233
  status: "running",
230
234
  requiresApproval: !1
231
- }), w.functionName ? await n.approveFunction(d) : await n.confirmToolCall(d));
235
+ }), k.functionName ? await n.approveFunction(p) : await n.confirmToolCall(p));
232
236
  }, [
233
237
  n,
234
- l,
235
- p
236
- ]), S = _(async (d) => {
237
- const w = l.find((x) => x.id === d);
238
- !w || w.status !== "awaiting-approval" || i.current.has(d) || (i.current.add(d), p(d, {
238
+ s,
239
+ f
240
+ ]), m = T(async (p) => {
241
+ const k = s.find((b) => b.id === p);
242
+ !k || k.status !== "awaiting-approval" || i.current.has(p) || (i.current.add(p), f(p, {
239
243
  status: "rejected",
240
244
  requiresApproval: !1
241
- }), w.functionName ? await n.rejectFunction(d) : await n.rejectToolCall(d));
245
+ }), k.functionName ? await n.rejectFunction(p) : await n.rejectToolCall(p));
242
246
  }, [
243
247
  n,
244
- l,
245
- p
246
- ]), g = _(async (d, w) => {
247
- p(d, {
248
+ s,
249
+ f
250
+ ]), u = T(async (p, k) => {
251
+ f(p, {
248
252
  status: "running",
249
253
  requiresApproval: !1
250
- }), await n.submitToolCallForm(d, w), p(d, { status: "done" });
251
- }, [n, p]), R = _(() => {
252
- i.current.clear(), s([]);
254
+ }), await n.submitToolCallForm(p, k), f(p, { status: "done" });
255
+ }, [n, f]), v = T(() => {
256
+ i.current.clear(), c([]);
253
257
  }, []);
254
258
  return {
255
- items: l,
256
- latest: l.length > 0 ? l[l.length - 1] : void 0,
257
- isAwaitingApproval: l.some((d) => Ze.has(d.status)),
258
- approve: v,
259
- reject: S,
260
- submitForm: g,
261
- clear: R
259
+ items: s,
260
+ latest: s.length > 0 ? s[s.length - 1] : void 0,
261
+ isAwaitingApproval: s.some((p) => nt.has(p.status)),
262
+ approve: x,
263
+ reject: m,
264
+ submitForm: u,
265
+ clear: v
262
266
  };
263
267
  }
264
- function ve({ client: e, conversationId: r } = {}) {
268
+ function ke({ client: e, conversationId: r } = {}) {
265
269
  const t = O(), o = e || t;
266
270
  if (!o) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
267
- const [n, l] = T([]), [s, i] = T(r), [u, c] = T(!1), [p, v] = T(null);
271
+ const [n, s] = M([]), [c, i] = M(r), [g, d] = M(!1), [f, x] = M(null);
268
272
  E(() => {
269
- r && r !== s && (i(r), S(r));
273
+ r && r !== c && (i(r), m(r));
270
274
  }, [r]);
271
- const S = async (g) => {
275
+ const m = async (u) => {
272
276
  try {
273
- l((await o.getMessages(g)).filter((R) => !R.hidden));
274
- } catch (R) {
275
- v(R instanceof Error ? R : /* @__PURE__ */ new Error("Failed to load messages"));
277
+ s((await o.getMessages(u)).filter((v) => !v.hidden));
278
+ } catch (v) {
279
+ x(v instanceof Error ? v : /* @__PURE__ */ new Error("Failed to load messages"));
276
280
  }
277
281
  };
278
282
  return E(() => {
279
- const g = (y) => y === "IN_PROGRESS" || y === "WAITING_CLIENT", R = (y) => {
280
- s || i(y.conversationId), c(!0), l((m) => {
281
- const A = m.findIndex((N) => N.id === y.messageId);
282
- return A >= 0 ? m.map((N, k) => k === A ? {
283
+ const u = (y) => y === "IN_PROGRESS" || y === "WAITING_CLIENT", v = (y) => {
284
+ c || i(y.conversationId), d(!0), s((C) => {
285
+ const A = C.findIndex((N) => N.id === y.messageId);
286
+ return A >= 0 ? C.map((N, h) => h === A ? {
283
287
  ...N,
284
288
  status: "IN_PROGRESS"
285
- } : N) : m.some((N) => N.role === "assistant" && g(N.status)) ? m : [...m, {
289
+ } : N) : C.some((N) => N.role === "assistant" && u(N.status)) ? C : [...C, {
286
290
  id: y.messageId,
287
291
  conversationId: y.conversationId,
288
292
  content: "",
@@ -291,115 +295,115 @@ function ve({ client: e, conversationId: r } = {}) {
291
295
  createdAt: /* @__PURE__ */ new Date()
292
296
  }];
293
297
  });
294
- }, d = (y) => {
295
- l((m) => {
296
- const A = m.findIndex((N) => N.id === y.messageId);
297
- return A < 0 ? m : m.map((N, k) => k === A ? {
298
+ }, p = (y) => {
299
+ s((C) => {
300
+ const A = C.findIndex((N) => N.id === y.messageId);
301
+ return A < 0 ? C : C.map((N, h) => h === A ? {
298
302
  ...N,
299
303
  content: N.content + y.content
300
304
  } : N);
301
305
  });
302
- }, w = (y) => {
303
- l((m) => {
306
+ }, k = (y) => {
307
+ s((C) => {
304
308
  let A = -1;
305
- for (let N = m.length - 1; N >= 0; N--) if (m[N].role === "assistant" && g(m[N].status)) {
309
+ for (let N = C.length - 1; N >= 0; N--) if (C[N].role === "assistant" && u(C[N].status)) {
306
310
  A = N;
307
311
  break;
308
312
  }
309
- return A < 0 ? m : [
310
- ...m.slice(0, A),
313
+ return A < 0 ? C : [
314
+ ...C.slice(0, A),
311
315
  {
312
- ...m[A],
316
+ ...C[A],
313
317
  ...y
314
318
  },
315
- ...m.slice(A + 1)
319
+ ...C.slice(A + 1)
316
320
  ];
317
321
  });
318
- }, x = (y) => {
319
- l((m) => {
320
- const A = m.findIndex((N) => N.id === y.id);
322
+ }, b = (y) => {
323
+ s((C) => {
324
+ const A = C.findIndex((N) => N.id === y.id);
321
325
  return A >= 0 ? [
322
- ...m.slice(0, A),
326
+ ...C.slice(0, A),
323
327
  y,
324
- ...m.slice(A + 1)
325
- ] : [...m, y];
326
- }), c(!1);
327
- }, f = (y) => {
328
- v(new Error(y.error)), c(!1);
329
- }, h = () => {
330
- l((y) => {
331
- let m = -1;
332
- for (let A = y.length - 1; A >= 0; A--) if (y[A].role === "assistant" && g(y[A].status)) {
333
- m = A;
328
+ ...C.slice(A + 1)
329
+ ] : [...C, y];
330
+ }), d(!1);
331
+ }, R = (y) => {
332
+ x(new Error(y.error)), d(!1);
333
+ }, _ = () => {
334
+ s((y) => {
335
+ let C = -1;
336
+ for (let A = y.length - 1; A >= 0; A--) if (y[A].role === "assistant" && u(y[A].status)) {
337
+ C = A;
334
338
  break;
335
339
  }
336
- return m < 0 ? y : y[m].content ? y.map((A, N) => N === m ? {
340
+ return C < 0 ? y : y[C].content ? y.map((A, N) => N === C ? {
337
341
  ...A,
338
342
  status: "CANCELED"
339
- } : A) : y.filter((A, N) => N !== m);
340
- }), c(!1);
343
+ } : A) : y.filter((A, N) => N !== C);
344
+ }), d(!1);
341
345
  };
342
- return o.on("message:start", R), o.on("message:chunk", d), o.on("message:answer-complete", w), o.on("message:complete", x), o.on("message:error", f), o.on("message:stopped", h), () => {
343
- o.off("message:start", R), o.off("message:chunk", d), o.off("message:answer-complete", w), o.off("message:complete", x), o.off("message:error", f), o.off("message:stopped", h);
346
+ return o.on("message:start", v), o.on("message:chunk", p), o.on("message:answer-complete", k), o.on("message:complete", b), o.on("message:error", R), o.on("message:stopped", _), () => {
347
+ o.off("message:start", v), o.off("message:chunk", p), o.off("message:answer-complete", k), o.off("message:complete", b), o.off("message:error", R), o.off("message:stopped", _);
344
348
  };
345
- }, [o, s]), {
349
+ }, [o, c]), {
346
350
  messages: n,
347
- isLoading: u,
348
- error: p,
349
- sendMessage: _(async (g, R) => {
350
- c(!0), v(null);
351
- const d = {
351
+ isLoading: g,
352
+ error: f,
353
+ sendMessage: T(async (u, v) => {
354
+ d(!0), x(null);
355
+ const p = {
352
356
  id: `temp-${Date.now()}`,
353
- conversationId: s || "",
354
- content: g,
357
+ conversationId: c || "",
358
+ content: u,
355
359
  role: "user",
356
360
  status: "DONE",
357
- attachments: R && R.length > 0 ? Fe(R) : void 0,
361
+ attachments: v && v.length > 0 ? De(v) : void 0,
358
362
  createdAt: /* @__PURE__ */ new Date()
359
- }, w = {
363
+ }, k = {
360
364
  id: `temp-assistant-${Date.now()}`,
361
- conversationId: s || "",
365
+ conversationId: c || "",
362
366
  content: "",
363
367
  role: "assistant",
364
368
  status: "IN_PROGRESS",
365
369
  createdAt: /* @__PURE__ */ new Date()
366
370
  };
367
- l((x) => [
368
- ...x,
369
- d,
370
- w
371
+ s((b) => [
372
+ ...b,
373
+ p,
374
+ k
371
375
  ]);
372
376
  try {
373
- const x = await o.sendMessage(g, {
374
- conversationId: s,
375
- files: R
377
+ const b = await o.sendMessage(u, {
378
+ conversationId: c,
379
+ files: v
376
380
  });
377
- return x.conversationId && !s && i(x.conversationId), l((f) => {
378
- const h = f.filter((m) => !m.id.startsWith("temp-")), y = {
379
- ...d,
380
- id: d.id.replace("temp-", "user-"),
381
- conversationId: x.conversationId
381
+ return b.conversationId && !c && i(b.conversationId), s((R) => {
382
+ const _ = R.filter((C) => !C.id.startsWith("temp-")), y = {
383
+ ...p,
384
+ id: p.id.replace("temp-", "user-"),
385
+ conversationId: b.conversationId
382
386
  };
383
- return h.some((m) => m.id === x.id) ? [...h, y].sort((m, A) => new Date(m.createdAt).getTime() - new Date(A.createdAt).getTime()) : [
384
- ...h,
387
+ return _.some((C) => C.id === b.id) ? [..._, y].sort((C, A) => new Date(C.createdAt).getTime() - new Date(A.createdAt).getTime()) : [
388
+ ..._,
385
389
  y,
386
- x
390
+ b
387
391
  ];
388
- }), x;
389
- } catch (x) {
390
- return v(x instanceof Error ? x : /* @__PURE__ */ new Error("Failed to send message")), c(!1), l((f) => f.filter((h) => !h.id.startsWith("temp-"))), null;
392
+ }), b;
393
+ } catch (b) {
394
+ return x(b instanceof Error ? b : /* @__PURE__ */ new Error("Failed to send message")), d(!1), s((R) => R.filter((_) => !_.id.startsWith("temp-"))), null;
391
395
  }
392
- }, [o, s]),
393
- stop: _(async () => {
396
+ }, [o, c]),
397
+ stop: T(async () => {
394
398
  await o.stop();
395
399
  }, [o]),
396
- clearMessages: _(() => {
397
- l([]), i(void 0), v(null);
400
+ clearMessages: T(() => {
401
+ s([]), i(void 0), x(null);
398
402
  }, []),
399
- conversationId: s
403
+ conversationId: c
400
404
  };
401
405
  }
402
- var de = {
406
+ var pe = {
403
407
  compact: !1,
404
408
  state: "peek",
405
409
  isModal: !1,
@@ -407,23 +411,23 @@ var de = {
407
411
  style: {},
408
412
  attrs: {}
409
413
  }
410
- }, nt = { tabindex: "tabIndex" };
411
- function rt(e) {
414
+ }, it = { tabindex: "tabIndex" };
415
+ function st(e) {
412
416
  const r = {};
413
- for (const [t, o] of Object.entries(e)) r[nt[t] ?? t] = o;
417
+ for (const [t, o] of Object.entries(e)) r[it[t] ?? t] = o;
414
418
  return r;
415
419
  }
416
- function ot(e) {
417
- const r = e !== !1, t = r ? e ?? {} : void 0, o = D(t?.onStateChange);
420
+ function lt(e) {
421
+ const r = e !== !1, t = r ? e ?? {} : void 0, o = W(t?.onStateChange);
418
422
  o.current = t?.onStateChange;
419
- const n = B(() => {
423
+ const n = $(() => {
420
424
  if (r)
421
425
  return je({
422
426
  breakpoint: t?.breakpoint,
423
427
  initialState: t?.initialState,
424
428
  bottomOffset: t?.bottomOffset,
425
429
  peekHeight: t?.peekHeight,
426
- onStateChange: (s, i) => o.current?.(s, i)
430
+ onStateChange: (c, i) => o.current?.(c, i)
427
431
  });
428
432
  }, [
429
433
  r,
@@ -431,24 +435,24 @@ function ot(e) {
431
435
  t?.initialState,
432
436
  t?.bottomOffset,
433
437
  t?.peekHeight
434
- ]), l = xe(_((s) => n?.subscribe(s) ?? (() => {
435
- }), [n]), _(() => n?.getSnapshot() ?? de, [n]), _(() => n?.getServerSnapshot() ?? de, [n]));
438
+ ]), s = ye(T((c) => n?.subscribe(c) ?? (() => {
439
+ }), [n]), T(() => n?.getSnapshot() ?? pe, [n]), T(() => n?.getServerSnapshot() ?? pe, [n]));
436
440
  return {
437
- sheet: B(() => ({
438
- ...l,
441
+ sheet: $(() => ({
442
+ ...s,
439
443
  surface: {
440
- ...l.surface,
441
- attrs: rt(l.surface.attrs)
444
+ ...s.surface,
445
+ attrs: st(s.surface.attrs)
442
446
  }
443
- }), [l]),
444
- expand: _((s) => n?.expand(s), [n]),
445
- collapse: _((s) => n?.collapse(s), [n]),
446
- toggle: _((s) => n?.toggle(s), [n])
447
+ }), [s]),
448
+ expand: T((c) => n?.expand(c), [n]),
449
+ collapse: T((c) => n?.collapse(c), [n]),
450
+ toggle: T((c) => n?.toggle(c), [n])
447
451
  };
448
452
  }
449
- var at = /(`[^`\n]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|_[^_\n]+_)/g;
450
- function we(e) {
451
- const r = e.split(at);
453
+ var ct = /(`[^`\n]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|_[^_\n]+_)/g;
454
+ function Ce(e) {
455
+ const r = e.split(ct);
452
456
  return r.length === 1 ? e : r.map((t, o) => o % 2 === 0 || !t ? t : t.startsWith("`") ? /* @__PURE__ */ a("code", {
453
457
  style: {
454
458
  fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
@@ -463,7 +467,7 @@ function we(e) {
463
467
  children: t.slice(2, -2)
464
468
  }, o) : /* @__PURE__ */ a("em", { children: t.slice(1, -1) }, o));
465
469
  }
466
- var it = `
470
+ var dt = `
467
471
  @keyframes ago-activity-enter {
468
472
  from { opacity: 0; transform: translateY(4px); }
469
473
  to { opacity: 1; transform: none; }
@@ -500,7 +504,7 @@ var it = `
500
504
  color: var(--ago-activity-color, #5b5d5f);
501
505
  }
502
506
  }
503
- `, st = ({ label: e }) => /* @__PURE__ */ M("div", {
507
+ `, ut = ({ label: e }) => /* @__PURE__ */ F("div", {
504
508
  className: "ago-activity",
505
509
  role: "status",
506
510
  "aria-live": "polite",
@@ -521,36 +525,105 @@ var it = `
521
525
  },
522
526
  children: [/* @__PURE__ */ a("span", {
523
527
  className: "ago-activity__label",
524
- children: we(e)
525
- }, e), /* @__PURE__ */ a("style", { children: it })]
526
- }), lt = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a message...", allowFiles: n = !1, className: l = "" }) => {
527
- const [s, i] = T(""), [u, c] = T([]), p = D(null), v = D(null), S = _(() => {
528
- const f = v.current;
529
- if (!f) return;
530
- const h = 110;
531
- f.style.height = "auto", f.style.height = `${Math.min(f.scrollHeight + 2, h)}px`, f.style.overflowY = f.scrollHeight + 2 > h ? "auto" : "hidden";
532
- }, []), g = _(async (f) => {
533
- if (f.preventDefault(), !s.trim() && u.length === 0) return;
534
- const h = s.trim(), y = u.length > 0 ? u : void 0;
535
- i(""), c([]), requestAnimationFrame(S), await e(h, y) === !1 && (i((m) => m.trim() ? m : h), y && c((m) => [...y, ...m]), requestAnimationFrame(S));
528
+ children: Ce(e)
529
+ }, e), /* @__PURE__ */ a("style", { children: dt })]
530
+ }), V = typeof window > "u" ? E : Ze;
531
+ function pt(e) {
532
+ const r = O(), t = e.client ?? r, o = W(null), n = W(), s = W(e), [c, i] = M(!1), [g, d] = M(""), [f, x] = M(!1);
533
+ return V(() => {
534
+ s.current = e;
535
+ }), V(() => {
536
+ if (x(!1), i(!1), s.current.onBusyChange?.(!1), !t || !o.current) return;
537
+ let m = !0;
538
+ const u = Ke({
539
+ transcribe: (v, p) => t.transcribeAudio(v, p),
540
+ onText: (v) => {
541
+ m && s.current.onTranscript(v);
542
+ },
543
+ onBusy: (v) => {
544
+ m && (i(v), v && d(""), s.current.onBusyChange?.(v));
545
+ },
546
+ onError: (v) => {
547
+ m && d(v);
548
+ },
549
+ labels: s.current.labels
550
+ });
551
+ return o.current.append(u.el), n.current = u, u.setDisabled(!!s.current.disabled), t.getConfig().then(({ permissions: v }) => {
552
+ if (!m) return;
553
+ const p = v.some((k) => k.speechToTextEnabled) && typeof MediaRecorder < "u" && !!navigator.mediaDevices?.getUserMedia;
554
+ u.setEnabled(p), x(p);
555
+ }).catch(() => {
556
+ }), () => {
557
+ m = !1, u.destroy(), s.current.onBusyChange?.(!1), u.el.remove(), n.current = void 0;
558
+ };
559
+ }, [t]), V(() => {
560
+ n.current?.setDisabled(!!e.disabled);
561
+ }, [e.disabled]), V(() => {
562
+ n.current?.cancel();
563
+ }, [e.scopeKey, t]), V(() => {
564
+ n.current?.setLabels(e.labels);
565
+ }, [e.labels]), /* @__PURE__ */ F("div", {
566
+ className: `ago-speech-to-text ${e.className ?? ""}`,
567
+ style: {
568
+ display: f ? "flex" : "none",
569
+ flexDirection: "column",
570
+ minWidth: 0,
571
+ flex: c ? 1 : void 0
572
+ },
573
+ children: [/* @__PURE__ */ a("div", { ref: o }), g && /* @__PURE__ */ a("span", {
574
+ role: "alert",
575
+ style: {
576
+ color: "var(--ago-muted-text-color, #6b6d6f)",
577
+ fontSize: "13px"
578
+ },
579
+ children: g
580
+ })]
581
+ });
582
+ }
583
+ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a message...", allowFiles: n = !1, speechToText: s = !1, client: c, scopeKey: i, className: g = "" }) => {
584
+ const [d, f] = M(""), [x, m] = M([]), [u, v] = M(!1), p = W(null), k = W(null), b = !!s;
585
+ E(() => {
586
+ b || v(!1);
587
+ }, [b]);
588
+ const R = T(() => {
589
+ const l = k.current;
590
+ if (!l) return;
591
+ const S = 110;
592
+ l.style.height = "auto", l.style.height = `${Math.min(l.scrollHeight + 2, S)}px`, l.style.overflowY = l.scrollHeight + 2 > S ? "auto" : "hidden";
593
+ }, []), _ = W(!1);
594
+ E(() => {
595
+ _.current && !u && !t && (R(), k.current?.focus()), _.current = u;
536
596
  }, [
537
- s,
538
597
  u,
598
+ t,
599
+ R
600
+ ]);
601
+ const y = T(async (l) => {
602
+ if (l.preventDefault(), t || u || !d.trim() && x.length === 0) return;
603
+ const S = d.trim(), I = x.length > 0 ? x : void 0;
604
+ f(""), m([]), requestAnimationFrame(R), await e(S, I) === !1 && (f((B) => B.trim() ? B : S), I && m((B) => [...I, ...B]), requestAnimationFrame(R));
605
+ }, [
606
+ d,
607
+ x,
539
608
  e,
540
- S
541
- ]), R = _((f) => {
542
- f.key === "Enter" && !f.shiftKey && (f.preventDefault(), g(f));
543
- }, [g]), d = _((f) => {
544
- const h = Array.from(f.target.files || []);
545
- c((y) => [...y, ...h]);
546
- }, []), w = _((f) => {
547
- c((h) => h.filter((y, m) => m !== f));
548
- }, []), x = s.trim() || u.length > 0;
549
- return /* @__PURE__ */ M("form", {
550
- onSubmit: (f) => {
551
- g(f);
609
+ R,
610
+ t,
611
+ u
612
+ ]), C = T((l) => {
613
+ l.key === "Enter" && !l.shiftKey && (l.preventDefault(), y(l));
614
+ }, [y]), A = T((l) => {
615
+ const S = Array.from(l.target.files || []);
616
+ m((I) => [...I, ...S]);
617
+ }, []), N = T((l) => {
618
+ m((S) => S.filter((I, B) => B !== l));
619
+ }, []), h = d.trim() || x.length > 0, D = (l) => {
620
+ f((S) => `${S}${S && !/\s$/.test(S) ? " " : ""}${l}`);
621
+ };
622
+ return /* @__PURE__ */ F("form", {
623
+ onSubmit: (l) => {
624
+ y(l);
552
625
  },
553
- className: `ago-chat-input ${l}`,
626
+ className: `ago-chat-input ${g}`,
554
627
  style: {
555
628
  display: "flex",
556
629
  flexDirection: "column",
@@ -559,14 +632,14 @@ var it = `
559
632
  borderTop: "1px solid #dee3e8",
560
633
  backgroundColor: "#fff"
561
634
  },
562
- children: [u.length > 0 && /* @__PURE__ */ a("div", {
635
+ children: [x.length > 0 && !u && /* @__PURE__ */ a("div", {
563
636
  className: "ago-chat-input__files",
564
637
  style: {
565
638
  display: "flex",
566
639
  flexWrap: "wrap",
567
640
  gap: "6px"
568
641
  },
569
- children: u.map((f, h) => /* @__PURE__ */ M("div", {
642
+ children: x.map((l, S) => /* @__PURE__ */ F("div", {
570
643
  style: {
571
644
  display: "flex",
572
645
  alignItems: "center",
@@ -584,11 +657,11 @@ var it = `
584
657
  textOverflow: "ellipsis",
585
658
  whiteSpace: "nowrap"
586
659
  },
587
- children: f.name
660
+ children: l.name
588
661
  }), /* @__PURE__ */ a("button", {
589
662
  type: "button",
590
- onClick: () => w(h),
591
- "aria-label": `Remove ${f.name}`,
663
+ onClick: () => N(S),
664
+ "aria-label": `Remove ${l.name}`,
592
665
  style: {
593
666
  flexShrink: 0,
594
667
  width: "44px",
@@ -607,15 +680,15 @@ var it = `
607
680
  },
608
681
  children: "×"
609
682
  })]
610
- }, h))
611
- }), /* @__PURE__ */ M("div", {
683
+ }, S))
684
+ }), /* @__PURE__ */ F("div", {
612
685
  style: {
613
686
  display: "flex",
614
687
  gap: "8px",
615
688
  alignItems: "flex-end"
616
689
  },
617
690
  children: [
618
- n && /* @__PURE__ */ M(be, { children: [/* @__PURE__ */ a("button", {
691
+ n && !u && /* @__PURE__ */ F(ve, { children: [/* @__PURE__ */ a("button", {
619
692
  type: "button",
620
693
  onClick: () => p.current?.click(),
621
694
  disabled: t,
@@ -641,22 +714,23 @@ var it = `
641
714
  ref: p,
642
715
  type: "file",
643
716
  multiple: !0,
644
- onChange: d,
717
+ onChange: A,
645
718
  style: { display: "none" }
646
719
  })] }),
647
720
  /* @__PURE__ */ a("textarea", {
648
- ref: v,
721
+ ref: k,
649
722
  className: "ago-chat-input__field",
650
- value: s,
651
- onChange: (f) => {
652
- i(f.target.value), S();
723
+ value: d,
724
+ onChange: (l) => {
725
+ f(l.target.value), R();
653
726
  },
654
- onKeyDown: R,
727
+ onKeyDown: C,
655
728
  placeholder: o,
656
729
  "aria-label": o,
657
- disabled: t,
730
+ disabled: t || u,
658
731
  rows: 1,
659
732
  style: {
733
+ display: u ? "none" : void 0,
660
734
  flex: 1,
661
735
  padding: "10px 14px",
662
736
  border: "1px solid #dee3e8",
@@ -673,14 +747,22 @@ var it = `
673
747
  backgroundColor: "#f8f8f8",
674
748
  transition: "border-color 0.15s"
675
749
  },
676
- onFocus: (f) => {
677
- f.currentTarget.style.borderColor = "#1b5fc4";
750
+ onFocus: (l) => {
751
+ l.currentTarget.style.borderColor = "#1b5fc4";
678
752
  },
679
- onBlur: (f) => {
680
- f.currentTarget.style.borderColor = "#dee3e8";
753
+ onBlur: (l) => {
754
+ l.currentTarget.style.borderColor = "#dee3e8";
681
755
  }
682
756
  }),
683
- t && r ? /* @__PURE__ */ a("button", {
757
+ s && /* @__PURE__ */ a(pt, {
758
+ client: c,
759
+ disabled: t,
760
+ scopeKey: i,
761
+ labels: typeof s == "object" ? s.labels : void 0,
762
+ onTranscript: D,
763
+ onBusyChange: v
764
+ }),
765
+ !u && (t && r ? /* @__PURE__ */ a("button", {
684
766
  type: "button",
685
767
  onClick: r,
686
768
  "aria-label": "Stop generating",
@@ -699,25 +781,25 @@ var it = `
699
781
  children: "Stop"
700
782
  }) : /* @__PURE__ */ a("button", {
701
783
  type: "submit",
702
- disabled: t || !x,
784
+ disabled: t || !h,
703
785
  style: {
704
786
  minHeight: "44px",
705
787
  padding: "10px 18px",
706
788
  border: "none",
707
789
  borderRadius: "20px",
708
- backgroundColor: t || !x ? "#b5bfc8" : "#03182f",
790
+ backgroundColor: t || !h ? "#b5bfc8" : "#03182f",
709
791
  color: "#fff",
710
- cursor: t || !x ? "not-allowed" : "pointer",
792
+ cursor: t || !h ? "not-allowed" : "pointer",
711
793
  fontWeight: 500,
712
794
  fontSize: "16px",
713
795
  transition: "background-color 0.15s"
714
796
  },
715
797
  children: "Send"
716
- })
798
+ }))
717
799
  ]
718
800
  })]
719
801
  });
720
- }, ct = ({ href: e, children: r, ...t }) => /* @__PURE__ */ a("a", {
802
+ }, gt = ({ href: e, children: r, ...t }) => /* @__PURE__ */ a("a", {
721
803
  href: e,
722
804
  target: "_blank",
723
805
  rel: "noopener noreferrer",
@@ -727,15 +809,15 @@ var it = `
727
809
  },
728
810
  ...t,
729
811
  children: r
730
- }), dt = ({ children: e, ...r }) => /* @__PURE__ */ a("p", {
812
+ }), mt = ({ children: e, ...r }) => /* @__PURE__ */ a("p", {
731
813
  style: {
732
814
  margin: "0 0 8px 0",
733
815
  lineHeight: "1.6"
734
816
  },
735
817
  ...r,
736
818
  children: e
737
- }), j = (e, r) => {
738
- const t = ({ children: o, ...n }) => $e.createElement(`h${e}`, {
819
+ }), K = (e, r) => {
820
+ const t = ({ children: o, ...n }) => Ge.createElement(`h${e}`, {
739
821
  style: {
740
822
  margin: "16px 0 8px 0",
741
823
  fontSize: r,
@@ -745,7 +827,7 @@ var it = `
745
827
  ...n
746
828
  }, o);
747
829
  return t.displayName = `MarkdownHeading${e}`, t;
748
- }, ut = ({ children: e, ...r }) => /* @__PURE__ */ a("ul", {
830
+ }, ht = ({ children: e, ...r }) => /* @__PURE__ */ a("ul", {
749
831
  style: {
750
832
  margin: "0 0 8px 0",
751
833
  paddingLeft: "20px",
@@ -754,7 +836,7 @@ var it = `
754
836
  },
755
837
  ...r,
756
838
  children: e
757
- }), pt = ({ children: e, ...r }) => /* @__PURE__ */ a("ol", {
839
+ }), xt = ({ children: e, ...r }) => /* @__PURE__ */ a("ol", {
758
840
  style: {
759
841
  margin: "0 0 8px 0",
760
842
  paddingLeft: "20px",
@@ -763,7 +845,7 @@ var it = `
763
845
  },
764
846
  ...r,
765
847
  children: e
766
- }), ft = ({ children: e, ...r }) => /* @__PURE__ */ a("li", {
848
+ }), bt = ({ children: e, ...r }) => /* @__PURE__ */ a("li", {
767
849
  style: {
768
850
  display: "list-item",
769
851
  margin: "2px 0",
@@ -771,7 +853,7 @@ var it = `
771
853
  },
772
854
  ...r,
773
855
  children: e
774
- }), gt = ({ className: e, children: r, ...t }) => e !== void 0 || String(r).includes(`
856
+ }), yt = ({ className: e, children: r, ...t }) => e !== void 0 || String(r).includes(`
775
857
  `) ? /* @__PURE__ */ a("code", {
776
858
  style: {
777
859
  display: "block",
@@ -794,11 +876,11 @@ var it = `
794
876
  },
795
877
  ...t,
796
878
  children: r
797
- }), mt = ({ children: e, ...r }) => /* @__PURE__ */ a("pre", {
879
+ }), vt = ({ children: e, ...r }) => /* @__PURE__ */ a("pre", {
798
880
  style: { margin: "0 0 8px 0" },
799
881
  ...r,
800
882
  children: e
801
- }), ht = ({ children: e, ...r }) => /* @__PURE__ */ a("blockquote", {
883
+ }), wt = ({ children: e, ...r }) => /* @__PURE__ */ a("blockquote", {
802
884
  style: {
803
885
  borderLeft: "4px solid #dee3e8",
804
886
  paddingLeft: "12px",
@@ -808,7 +890,7 @@ var it = `
808
890
  },
809
891
  ...r,
810
892
  children: e
811
- }), xt = ({ children: e, ...r }) => /* @__PURE__ */ a("div", {
893
+ }), kt = ({ children: e, ...r }) => /* @__PURE__ */ a("div", {
812
894
  style: {
813
895
  overflowX: "auto",
814
896
  margin: "0 0 8px 0"
@@ -822,7 +904,7 @@ var it = `
822
904
  ...r,
823
905
  children: e
824
906
  })
825
- }), bt = ({ children: e, ...r }) => /* @__PURE__ */ a("th", {
907
+ }), Ct = ({ children: e, ...r }) => /* @__PURE__ */ a("th", {
826
908
  style: {
827
909
  border: "1px solid #dee3e8",
828
910
  padding: "6px 10px",
@@ -832,14 +914,14 @@ var it = `
832
914
  },
833
915
  ...r,
834
916
  children: e
835
- }), yt = ({ children: e, ...r }) => /* @__PURE__ */ a("td", {
917
+ }), St = ({ children: e, ...r }) => /* @__PURE__ */ a("td", {
836
918
  style: {
837
919
  border: "1px solid #dee3e8",
838
920
  padding: "6px 10px"
839
921
  },
840
922
  ...r,
841
923
  children: e
842
- }), vt = ({ alt: e, ...r }) => /* @__PURE__ */ a("img", {
924
+ }), At = ({ alt: e, ...r }) => /* @__PURE__ */ a("img", {
843
925
  alt: e ?? "",
844
926
  style: {
845
927
  maxWidth: "100%",
@@ -847,40 +929,40 @@ var it = `
847
929
  margin: "4px 0"
848
930
  },
849
931
  ...r
850
- }), wt = (e) => /* @__PURE__ */ a("hr", {
932
+ }), Nt = (e) => /* @__PURE__ */ a("hr", {
851
933
  style: {
852
934
  border: "none",
853
935
  borderTop: "1px solid #dee3e8",
854
936
  margin: "12px 0"
855
937
  },
856
938
  ...e
857
- }), kt = {
858
- a: ct,
859
- p: dt,
860
- h1: j(1, "20px"),
861
- h2: j(2, "18px"),
862
- h3: j(3, "16px"),
863
- h4: j(4, "15px"),
864
- h5: j(5, "14px"),
865
- h6: j(6, "13px"),
866
- ul: ut,
867
- ol: pt,
868
- li: ft,
869
- code: gt,
870
- pre: mt,
871
- blockquote: ht,
872
- table: xt,
873
- th: bt,
874
- td: yt,
875
- img: vt,
876
- hr: wt
877
- }, Ct = [Ye], St = ({ content: e }) => /* @__PURE__ */ a(Ve, {
878
- remarkPlugins: Ct,
879
- components: kt,
939
+ }), _t = {
940
+ a: gt,
941
+ p: mt,
942
+ h1: K(1, "20px"),
943
+ h2: K(2, "18px"),
944
+ h3: K(3, "16px"),
945
+ h4: K(4, "15px"),
946
+ h5: K(5, "14px"),
947
+ h6: K(6, "13px"),
948
+ ul: ht,
949
+ ol: xt,
950
+ li: bt,
951
+ code: yt,
952
+ pre: vt,
953
+ blockquote: wt,
954
+ table: kt,
955
+ th: Ct,
956
+ td: St,
957
+ img: At,
958
+ hr: Nt
959
+ }, It = [et], Rt = ({ content: e }) => /* @__PURE__ */ a(Qe, {
960
+ remarkPlugins: It,
961
+ components: _t,
880
962
  children: e
881
- }), At = ({ attachment: e, isUser: r }) => {
882
- const t = We(e.url);
883
- if (Pe(e)) return /* @__PURE__ */ a("a", {
963
+ }), Et = ({ attachment: e, isUser: r }) => {
964
+ const t = ze(e.url);
965
+ if (Be(e)) return /* @__PURE__ */ a("a", {
884
966
  href: t,
885
967
  target: "_blank",
886
968
  rel: "noopener noreferrer",
@@ -902,7 +984,7 @@ var it = `
902
984
  }
903
985
  })
904
986
  });
905
- const o = Le(e.fileSize), n = /* @__PURE__ */ M(be, { children: [/* @__PURE__ */ a("span", {
987
+ const o = He(e.fileSize), n = /* @__PURE__ */ F(ve, { children: [/* @__PURE__ */ a("span", {
906
988
  style: {
907
989
  fontSize: "16px",
908
990
  lineHeight: 1,
@@ -910,7 +992,7 @@ var it = `
910
992
  },
911
993
  "aria-hidden": !0,
912
994
  children: "📄"
913
- }), /* @__PURE__ */ M("span", {
995
+ }), /* @__PURE__ */ F("span", {
914
996
  style: {
915
997
  display: "flex",
916
998
  flexDirection: "column",
@@ -932,7 +1014,7 @@ var it = `
932
1014
  },
933
1015
  children: o
934
1016
  })]
935
- })] }), l = {
1017
+ })] }), s = {
936
1018
  display: "inline-flex",
937
1019
  alignItems: "center",
938
1020
  gap: "8px",
@@ -949,14 +1031,14 @@ var it = `
949
1031
  href: t,
950
1032
  target: "_blank",
951
1033
  rel: "noopener noreferrer",
952
- style: l,
1034
+ style: s,
953
1035
  children: n
954
1036
  }) : /* @__PURE__ */ a("div", {
955
- style: l,
1037
+ style: s,
956
1038
  children: n
957
1039
  });
958
- }, It = ({ source: e, index: r }) => {
959
- const t = /* @__PURE__ */ M("div", {
1040
+ }, Tt = ({ source: e, index: r }) => {
1041
+ const t = /* @__PURE__ */ F("div", {
960
1042
  style: {
961
1043
  display: "flex",
962
1044
  alignItems: "center",
@@ -1020,7 +1102,7 @@ var it = `
1020
1102
  style: o,
1021
1103
  children: t
1022
1104
  });
1023
- }, ke = () => /* @__PURE__ */ M("div", {
1105
+ }, Se = () => /* @__PURE__ */ F("div", {
1024
1106
  style: {
1025
1107
  display: "flex",
1026
1108
  gap: "4px",
@@ -1044,9 +1126,9 @@ var it = `
1044
1126
  40% { opacity: 1; transform: scale(1); }
1045
1127
  }
1046
1128
  ` })]
1047
- }), Nt = ({ message: e, className: r = "", showAgentName: t = !1, isLast: o = !1, onFollowUpClick: n, showStreamingDots: l = !0, feedback: s }) => {
1048
- const i = e.role === "user", u = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
1049
- return /* @__PURE__ */ M("div", {
1129
+ }), Mt = ({ message: e, className: r = "", showAgentName: t = !1, isLast: o = !1, onFollowUpClick: n, showStreamingDots: s = !0, feedback: c }) => {
1130
+ const i = e.role === "user", g = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
1131
+ return /* @__PURE__ */ F("div", {
1050
1132
  className: `ago-message ago-message--${e.role} ${r}`,
1051
1133
  style: {
1052
1134
  display: "flex",
@@ -1079,10 +1161,10 @@ var it = `
1079
1161
  width: "100%",
1080
1162
  maxWidth: "85%"
1081
1163
  },
1082
- children: e.sources.map((c, p) => /* @__PURE__ */ a(It, {
1083
- source: c,
1084
- index: p
1085
- }, c.id))
1164
+ children: e.sources.map((d, f) => /* @__PURE__ */ a(Tt, {
1165
+ source: d,
1166
+ index: f
1167
+ }, d.id))
1086
1168
  }),
1087
1169
  e.attachments && e.attachments.length > 0 && /* @__PURE__ */ a("div", {
1088
1170
  className: "ago-message__attachments",
@@ -1094,12 +1176,12 @@ var it = `
1094
1176
  justifyContent: i ? "flex-end" : "flex-start",
1095
1177
  maxWidth: "75%"
1096
1178
  },
1097
- children: e.attachments.map((c) => /* @__PURE__ */ a(At, {
1098
- attachment: c,
1179
+ children: e.attachments.map((d) => /* @__PURE__ */ a(Et, {
1180
+ attachment: d,
1099
1181
  isUser: i
1100
- }, c.id))
1182
+ }, d.id))
1101
1183
  }),
1102
- (e.content || u && l) && /* @__PURE__ */ a("div", {
1184
+ (e.content || g && s) && /* @__PURE__ */ a("div", {
1103
1185
  className: "ago-message__content",
1104
1186
  style: {
1105
1187
  maxWidth: i ? "75%" : "100%",
@@ -1111,9 +1193,9 @@ var it = `
1111
1193
  fontSize: "16px",
1112
1194
  lineHeight: "1.6"
1113
1195
  },
1114
- children: e.content ? /* @__PURE__ */ a(St, { content: e.content }) : u && l && /* @__PURE__ */ a(ke, {})
1196
+ children: e.content ? /* @__PURE__ */ a(Rt, { content: e.content }) : g && s && /* @__PURE__ */ a(Se, {})
1115
1197
  }),
1116
- !i && s,
1198
+ !i && c,
1117
1199
  o && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ a("div", {
1118
1200
  className: "ago-message__followups",
1119
1201
  style: {
@@ -1122,11 +1204,11 @@ var it = `
1122
1204
  gap: "8px",
1123
1205
  marginTop: "10px"
1124
1206
  },
1125
- children: e.followUpReplies.map((c, p) => /* @__PURE__ */ a("button", {
1207
+ children: e.followUpReplies.map((d, f) => /* @__PURE__ */ a("button", {
1126
1208
  type: "button",
1127
1209
  className: "ago-message__followup-btn",
1128
1210
  disabled: !n,
1129
- onClick: n ? () => n(c) : void 0,
1211
+ onClick: n ? () => n(d) : void 0,
1130
1212
  style: {
1131
1213
  minHeight: "44px",
1132
1214
  padding: "6px 14px",
@@ -1138,63 +1220,63 @@ var it = `
1138
1220
  cursor: n ? "pointer" : "default",
1139
1221
  transition: "border-color 0.15s"
1140
1222
  },
1141
- onMouseEnter: (v) => {
1142
- v.currentTarget.style.borderColor = "#1b5fc4";
1223
+ onMouseEnter: (x) => {
1224
+ x.currentTarget.style.borderColor = "#1b5fc4";
1143
1225
  },
1144
- onMouseLeave: (v) => {
1145
- v.currentTarget.style.borderColor = "#dee3e8";
1226
+ onMouseLeave: (x) => {
1227
+ x.currentTarget.style.borderColor = "#dee3e8";
1146
1228
  },
1147
- children: c
1148
- }, p))
1229
+ children: d
1230
+ }, f))
1149
1231
  })
1150
1232
  ]
1151
1233
  });
1152
1234
  };
1153
- function Rt({ client: e } = {}) {
1235
+ function Ft({ client: e } = {}) {
1154
1236
  const r = O(), t = e || r;
1155
- if (!t) throw new X("useFeedback requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "missing_client");
1156
- const [o, n] = T({}), [l, s] = T(!1), [i, u] = T(null), c = D(/* @__PURE__ */ new Map()), p = (S) => {
1157
- const g = (c.current.get(S) ?? 0) + 1;
1158
- return c.current.set(S, g), g;
1159
- }, v = (S, g) => c.current.get(S) === g;
1237
+ if (!t) throw new Q("useFeedback requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "missing_client");
1238
+ const [o, n] = M({}), [s, c] = M(!1), [i, g] = M(null), d = W(/* @__PURE__ */ new Map()), f = (m) => {
1239
+ const u = (d.current.get(m) ?? 0) + 1;
1240
+ return d.current.set(m, u), u;
1241
+ }, x = (m, u) => d.current.get(m) === u;
1160
1242
  return {
1161
1243
  ratings: o,
1162
- submitFeedback: _(async (S, g, R) => {
1163
- const d = p(S);
1164
- s(!0), u(null);
1244
+ submitFeedback: T(async (m, u, v) => {
1245
+ const p = f(m);
1246
+ c(!0), g(null);
1165
1247
  try {
1166
- await t.submitFeedback(S, g, R), v(S, d) && n((w) => ({
1167
- ...w,
1168
- [S]: g
1248
+ await t.submitFeedback(m, u, v), x(m, p) && n((k) => ({
1249
+ ...k,
1250
+ [m]: u
1169
1251
  }));
1170
- } catch (w) {
1171
- const x = w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to submit feedback");
1172
- throw u(x), x;
1252
+ } catch (k) {
1253
+ const b = k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to submit feedback");
1254
+ throw g(b), b;
1173
1255
  } finally {
1174
- s(!1);
1256
+ c(!1);
1175
1257
  }
1176
1258
  }, [t]),
1177
- submitConversationFeedback: _(async (S, g, R) => {
1178
- const d = p(S);
1179
- s(!0), u(null);
1259
+ submitConversationFeedback: T(async (m, u, v) => {
1260
+ const p = f(m);
1261
+ c(!0), g(null);
1180
1262
  try {
1181
- const w = await t.submitConversationFeedback(S, g, R);
1182
- return v(S, d) && n((x) => ({
1183
- ...x,
1184
- [w]: g
1185
- })), w;
1186
- } catch (w) {
1187
- const x = w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to submit feedback");
1188
- throw u(x), x;
1263
+ const k = await t.submitConversationFeedback(m, u, v);
1264
+ return x(m, p) && n((b) => ({
1265
+ ...b,
1266
+ [k]: u
1267
+ })), k;
1268
+ } catch (k) {
1269
+ const b = k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to submit feedback");
1270
+ throw g(b), b;
1189
1271
  } finally {
1190
- s(!1);
1272
+ c(!1);
1191
1273
  }
1192
1274
  }, [t]),
1193
- isSubmitting: l,
1275
+ isSubmitting: s,
1194
1276
  error: i
1195
1277
  };
1196
1278
  }
1197
- var ue = {
1279
+ var fe = {
1198
1280
  helpful: "Helpful",
1199
1281
  notHelpful: "Not helpful",
1200
1282
  whatWentWrong: "What went wrong?",
@@ -1207,7 +1289,7 @@ var ue = {
1207
1289
  commentPlaceholder: "Anything else? (optional)",
1208
1290
  send: "Send",
1209
1291
  thanks: "Thanks, this was reported."
1210
- }, _t = {
1292
+ }, Wt = {
1211
1293
  display: "inline-flex",
1212
1294
  alignItems: "center",
1213
1295
  justifyContent: "center",
@@ -1220,65 +1302,65 @@ var ue = {
1220
1302
  background: "transparent",
1221
1303
  cursor: "pointer",
1222
1304
  lineHeight: 1
1223
- }, Et = ({ messageId: e, client: r, askWhy: t = !0, labels: o, onSubmit: n, onError: l, className: s = "" }) => {
1305
+ }, Dt = ({ messageId: e, client: r, askWhy: t = !0, labels: o, onSubmit: n, onError: s, className: c = "" }) => {
1224
1306
  const i = {
1225
- ...ue,
1307
+ ...fe,
1226
1308
  ...o,
1227
1309
  reasons: {
1228
- ...ue.reasons,
1310
+ ...fe.reasons,
1229
1311
  ...o?.reasons
1230
1312
  }
1231
- }, { ratings: u, submitFeedback: c } = Rt({ client: r }), p = u[e], [v, S] = T(!1), [g, R] = T([]), [d, w] = T(""), [x, f] = T(!1), [h, y] = T(!1), m = async (C, I) => {
1313
+ }, { ratings: g, submitFeedback: d } = Ft({ client: r }), f = g[e], [x, m] = M(!1), [u, v] = M([]), [p, k] = M(""), [b, R] = M(!1), [_, y] = M(!1), C = async (l, S) => {
1232
1314
  try {
1233
- return await c(e, C, I), n?.({
1315
+ return await d(e, l, S), n?.({
1234
1316
  messageId: e,
1235
- rating: C,
1236
- reasons: I?.reasons ?? [],
1237
- comment: I?.comment || void 0
1317
+ rating: l,
1318
+ reasons: S?.reasons ?? [],
1319
+ comment: S?.comment || void 0
1238
1320
  }), !0;
1239
- } catch (L) {
1240
- return l?.(L instanceof Error ? L : new Error(String(L))), !1;
1321
+ } catch (I) {
1322
+ return s?.(I instanceof Error ? I : new Error(String(I))), !1;
1241
1323
  }
1242
- }, A = (C) => {
1243
- m(C), S(C === "negative" && t && !x);
1244
- }, N = (C) => {
1245
- R((I) => I.includes(C) ? I.filter((L) => L !== C) : [...I, C]);
1246
- }, k = g.length > 0 || d.trim().length > 0, F = () => {
1247
- !k || h || (y(!0), m(p ?? "negative", {
1248
- reasons: g,
1249
- comment: d.trim()
1250
- }).then((C) => {
1251
- y(!1), C && (f(!0), S(!1));
1324
+ }, A = (l) => {
1325
+ C(l), m(l === "negative" && t && !b);
1326
+ }, N = (l) => {
1327
+ v((S) => S.includes(l) ? S.filter((I) => I !== l) : [...S, l]);
1328
+ }, h = u.length > 0 || p.trim().length > 0, D = () => {
1329
+ !h || _ || (y(!0), C(f ?? "negative", {
1330
+ reasons: u,
1331
+ comment: p.trim()
1332
+ }).then((l) => {
1333
+ y(!1), l && (R(!0), m(!1));
1252
1334
  }));
1253
1335
  };
1254
- return /* @__PURE__ */ M("div", {
1255
- className: `ago-feedback ${s}`,
1336
+ return /* @__PURE__ */ F("div", {
1337
+ className: `ago-feedback ${c}`,
1256
1338
  style: {
1257
1339
  marginTop: "6px",
1258
1340
  width: "100%",
1259
1341
  maxWidth: "85%"
1260
1342
  },
1261
1343
  children: [
1262
- /* @__PURE__ */ M("div", {
1344
+ /* @__PURE__ */ F("div", {
1263
1345
  className: "ago-feedback__actions",
1264
1346
  style: {
1265
1347
  display: "flex",
1266
1348
  alignItems: "center",
1267
1349
  gap: "2px"
1268
1350
  },
1269
- children: [/* @__PURE__ */ a(pe, {
1351
+ children: [/* @__PURE__ */ a(ge, {
1270
1352
  direction: "up",
1271
1353
  label: i.helpful,
1272
- selected: p === "positive",
1354
+ selected: f === "positive",
1273
1355
  onClick: () => A("positive")
1274
- }), /* @__PURE__ */ a(pe, {
1356
+ }), /* @__PURE__ */ a(ge, {
1275
1357
  direction: "down",
1276
1358
  label: i.notHelpful,
1277
- selected: p === "negative",
1359
+ selected: f === "negative",
1278
1360
  onClick: () => A("negative")
1279
1361
  })]
1280
1362
  }),
1281
- x && /* @__PURE__ */ a("div", {
1363
+ b && /* @__PURE__ */ a("div", {
1282
1364
  className: "ago-feedback__thanks",
1283
1365
  role: "status",
1284
1366
  style: {
@@ -1288,7 +1370,7 @@ var ue = {
1288
1370
  },
1289
1371
  children: i.thanks
1290
1372
  }),
1291
- v && !x && /* @__PURE__ */ M("div", {
1373
+ x && !b && /* @__PURE__ */ F("div", {
1292
1374
  className: "ago-feedback__panel",
1293
1375
  role: "group",
1294
1376
  "aria-label": i.whatWentWrong,
@@ -1317,35 +1399,35 @@ var ue = {
1317
1399
  gap: "6px",
1318
1400
  marginBottom: "8px"
1319
1401
  },
1320
- children: He.map((C) => {
1321
- const I = g.includes(C);
1402
+ children: Oe.map((l) => {
1403
+ const S = u.includes(l);
1322
1404
  return /* @__PURE__ */ a("button", {
1323
1405
  type: "button",
1324
1406
  className: "ago-feedback__reason",
1325
- "aria-pressed": I,
1326
- onClick: () => N(C),
1407
+ "aria-pressed": S,
1408
+ onClick: () => N(l),
1327
1409
  style: {
1328
1410
  minHeight: "44px",
1329
1411
  padding: "4px 12px",
1330
1412
  fontSize: "13px",
1331
1413
  fontFamily: "inherit",
1332
1414
  borderRadius: "999px",
1333
- border: `1px solid ${I ? "#1b5fc4" : "#dee3e8"}`,
1415
+ border: `1px solid ${S ? "#1b5fc4" : "#dee3e8"}`,
1334
1416
  backgroundColor: "transparent",
1335
- color: I ? "#1b5fc4" : "#30373e",
1417
+ color: S ? "#1b5fc4" : "#30373e",
1336
1418
  cursor: "pointer"
1337
1419
  },
1338
- children: i.reasons[C]
1339
- }, C);
1420
+ children: i.reasons[l]
1421
+ }, l);
1340
1422
  })
1341
1423
  }),
1342
1424
  /* @__PURE__ */ a("textarea", {
1343
1425
  className: "ago-feedback__comment",
1344
1426
  rows: 2,
1345
- value: d,
1427
+ value: p,
1346
1428
  placeholder: i.commentPlaceholder,
1347
1429
  "aria-label": i.commentPlaceholder,
1348
- onChange: (C) => w(C.target.value),
1430
+ onChange: (l) => k(l.target.value),
1349
1431
  style: {
1350
1432
  width: "100%",
1351
1433
  boxSizing: "border-box",
@@ -1362,8 +1444,8 @@ var ue = {
1362
1444
  /* @__PURE__ */ a("button", {
1363
1445
  type: "button",
1364
1446
  className: "ago-feedback__send",
1365
- onClick: F,
1366
- disabled: !k || h,
1447
+ onClick: D,
1448
+ disabled: !h || _,
1367
1449
  style: {
1368
1450
  marginTop: "8px",
1369
1451
  minHeight: "44px",
@@ -1372,10 +1454,10 @@ var ue = {
1372
1454
  fontFamily: "inherit",
1373
1455
  borderRadius: "10px",
1374
1456
  border: "none",
1375
- backgroundColor: k ? "#03182f" : "#b5bfc8",
1457
+ backgroundColor: h ? "#03182f" : "#b5bfc8",
1376
1458
  color: "#fff",
1377
- opacity: h ? 0.6 : 1,
1378
- cursor: k && !h ? "pointer" : "default"
1459
+ opacity: _ ? 0.6 : 1,
1460
+ cursor: h && !_ ? "pointer" : "default"
1379
1461
  },
1380
1462
  children: i.send
1381
1463
  })
@@ -1383,7 +1465,7 @@ var ue = {
1383
1465
  })
1384
1466
  ]
1385
1467
  });
1386
- }, pe = ({ direction: e, label: r, selected: t, onClick: o }) => /* @__PURE__ */ a("button", {
1468
+ }, ge = ({ direction: e, label: r, selected: t, onClick: o }) => /* @__PURE__ */ a("button", {
1387
1469
  type: "button",
1388
1470
  className: `ago-feedback__thumb ago-feedback__thumb--${e}`,
1389
1471
  "aria-label": r,
@@ -1391,10 +1473,10 @@ var ue = {
1391
1473
  title: r,
1392
1474
  onClick: o,
1393
1475
  style: {
1394
- ..._t,
1476
+ ...Wt,
1395
1477
  color: t ? "#1b5fc4" : "#6b6d6f"
1396
1478
  },
1397
- children: /* @__PURE__ */ M("svg", {
1479
+ children: /* @__PURE__ */ F("svg", {
1398
1480
  width: "16",
1399
1481
  height: "16",
1400
1482
  viewBox: "0 0 24 24",
@@ -1413,110 +1495,110 @@ var ue = {
1413
1495
  strokeLinejoin: "round"
1414
1496
  })]
1415
1497
  })
1416
- }), Gt = Ue(function({ client: r, conversationId: t, title: o = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: l = "Type a message...", allowFiles: s = !1, allowStop: i = !0, height: u = 500, logoUrl: c, showAgentName: p = !1, forms: v, feedback: S = !1, onFollowUpClick: g, className: R = "", onMessageSent: d, onMessageReceived: w, sheet: x = !1, thinkingLabel: f = "Thinking...", functionLabels: h, showReasoning: y = !0 }, m) {
1417
- const A = D(null), N = D(!0), [k, F] = T(!0), C = D(null), { sheet: I, expand: L, collapse: K, toggle: te } = ot(x), [Ce, Z] = T(!1), Q = I.compact && I.state === "peek", Se = O(), U = r ?? Se, { messages: P, isLoading: Ae, error: ne, sendMessage: Ie, stop: Ne } = ve({
1498
+ }), en = Ve(function({ client: r, conversationId: t, title: o = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: s = "Type a message...", allowFiles: c = !1, speechToText: i = !1, allowStop: g = !0, height: d = 500, logoUrl: f, showAgentName: x = !1, forms: m, feedback: u = !1, onFollowUpClick: v, className: p = "", onMessageSent: k, onMessageReceived: b, sheet: R = !1, thinkingLabel: _ = "Thinking...", functionLabels: y, showReasoning: C = !0 }, A) {
1499
+ const N = W(null), h = W(!0), [D, l] = M(!0), S = W(null), { sheet: I, expand: B, collapse: G, toggle: re } = lt(R), [Ae, ee] = M(!1), te = I.compact && I.state === "peek", Ne = O(), q = r ?? Ne, { messages: P, isLoading: _e, error: oe, sendMessage: Ie, stop: Re } = ke({
1418
1500
  client: r,
1419
1501
  conversationId: t
1420
1502
  });
1421
1503
  E(() => {
1422
- if (!U || !v || v.length === 0) return;
1423
- let b = !1;
1424
- const z = [];
1425
- return Promise.all(v.map((W) => W.schema != null ? Promise.resolve(me(W)) : ge(U, W))).then((W) => {
1426
- if (!b)
1427
- for (const H of W) z.push(H.install(U));
1504
+ if (!q || !m || m.length === 0) return;
1505
+ let w = !1;
1506
+ const L = [];
1507
+ return Promise.all(m.map((z) => z.schema != null ? Promise.resolve(xe(z)) : he(q, z))).then((z) => {
1508
+ if (!w)
1509
+ for (const H of z) L.push(H.install(q));
1428
1510
  }).catch(() => {
1429
1511
  }), () => {
1430
- b = !0, z.forEach((W) => W());
1512
+ w = !0, L.forEach((z) => z());
1431
1513
  };
1432
- }, [U, v ? JSON.stringify(v.map((b) => [
1433
- b.name,
1434
- b.schema ?? null,
1435
- b.submit ?? !1,
1436
- b.description ?? null
1514
+ }, [q, m ? JSON.stringify(m.map((w) => [
1515
+ w.name,
1516
+ w.schema ?? null,
1517
+ w.submit ?? !1,
1518
+ w.description ?? null
1437
1519
  ])) : ""]), E(() => {
1438
- const b = A.current;
1439
- !b || !N.current || (b.scrollTop = b.scrollHeight);
1520
+ const w = N.current;
1521
+ !w || !h.current || (w.scrollTop = w.scrollHeight);
1440
1522
  }, [P]);
1441
- const Re = () => {
1442
- const b = A.current;
1443
- b && (N.current = !0, F(!0), b.scrollTop = b.scrollHeight);
1523
+ const Ee = () => {
1524
+ const w = N.current;
1525
+ w && (h.current = !0, l(!0), w.scrollTop = w.scrollHeight);
1444
1526
  };
1445
1527
  E(() => {
1446
- const b = P[P.length - 1];
1447
- b && b.role === "assistant" && b.status === "DONE" && w && w({
1448
- id: b.id,
1449
- content: b.content
1528
+ const w = P[P.length - 1];
1529
+ w && w.role === "assistant" && w.status === "DONE" && b && b({
1530
+ id: w.id,
1531
+ content: w.content
1450
1532
  });
1451
- }, [P, w]), E(() => {
1452
- Z(!!Q);
1533
+ }, [P, b]), E(() => {
1534
+ ee(!!te);
1453
1535
  }, [P.length]), E(() => {
1454
- const b = C.current;
1455
- if (!I.compact || !b) return;
1456
- const z = document.documentElement;
1536
+ const w = S.current;
1537
+ if (!I.compact || !w) return;
1538
+ const L = document.documentElement;
1457
1539
  if (I.state !== "peek") return;
1458
- const W = () => {
1459
- z.style.setProperty("--ago-sheet-height", `${Math.round(b.getBoundingClientRect().height)}px`);
1540
+ const z = () => {
1541
+ L.style.setProperty("--ago-sheet-height", `${Math.round(w.getBoundingClientRect().height)}px`);
1460
1542
  };
1461
- W();
1462
- const H = typeof ResizeObserver == "function" ? new ResizeObserver(W) : null;
1463
- return H?.observe(b), () => H?.disconnect();
1543
+ z();
1544
+ const H = typeof ResizeObserver == "function" ? new ResizeObserver(z) : null;
1545
+ return H?.observe(w), () => H?.disconnect();
1464
1546
  }, [I.compact, I.state]), E(() => {
1465
1547
  I.compact || document.documentElement.style.removeProperty("--ago-sheet-height");
1466
1548
  }, [I.compact]), E(() => () => {
1467
1549
  document.documentElement.style.removeProperty("--ago-sheet-height");
1468
- }, []), Je(m, () => ({
1469
- expand: L,
1470
- collapse: K,
1471
- toggle: te,
1550
+ }, []), Ye(A, () => ({
1551
+ expand: B,
1552
+ collapse: G,
1553
+ toggle: re,
1472
1554
  state: I.state
1473
1555
  }), [
1474
- L,
1475
- K,
1476
- te,
1556
+ B,
1557
+ G,
1558
+ re,
1477
1559
  I.state
1478
1560
  ]), E(() => {
1479
1561
  if (!I.isModal) return;
1480
- const b = /* @__PURE__ */ Symbol("ago-react-sheet");
1481
- qe(b);
1482
- const z = (W) => {
1483
- if (W.key === "Escape") {
1484
- K("user");
1562
+ const w = /* @__PURE__ */ Symbol("ago-react-sheet");
1563
+ Ue(w);
1564
+ const L = (z) => {
1565
+ if (z.key === "Escape") {
1566
+ G("user");
1485
1567
  return;
1486
1568
  }
1487
- if (W.key !== "Tab") return;
1488
- const H = C.current;
1569
+ if (z.key !== "Tab") return;
1570
+ const H = S.current;
1489
1571
  if (!H) return;
1490
- const V = Array.from(H.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((Me) => Me.getClientRects().length > 0);
1491
- if (V.length === 0) {
1492
- W.preventDefault();
1572
+ const Y = Array.from(H.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((We) => We.getClientRects().length > 0);
1573
+ if (Y.length === 0) {
1574
+ z.preventDefault();
1493
1575
  return;
1494
1576
  }
1495
- const ie = V[0], se = V[V.length - 1], Y = document.activeElement;
1496
- W.shiftKey && (Y === ie || !H.contains(Y)) ? (W.preventDefault(), se.focus()) : !W.shiftKey && (Y === se || !H.contains(Y)) && (W.preventDefault(), ie.focus());
1577
+ const le = Y[0], ce = Y[Y.length - 1], Z = document.activeElement;
1578
+ z.shiftKey && (Z === le || !H.contains(Z)) ? (z.preventDefault(), ce.focus()) : !z.shiftKey && (Z === ce || !H.contains(Z)) && (z.preventDefault(), le.focus());
1497
1579
  };
1498
- return document.addEventListener("keydown", z), C.current?.focus({ preventScroll: !0 }), () => {
1499
- document.removeEventListener("keydown", z), Oe(b);
1580
+ return document.addEventListener("keydown", L), S.current?.focus({ preventScroll: !0 }), () => {
1581
+ document.removeEventListener("keydown", L), qe(w);
1500
1582
  };
1501
- }, [I.isModal, K]);
1502
- const re = async (b, z) => (N.current = !0, F(!0), d?.(b), await Ie(b, z) !== null), q = P[P.length - 1], J = Ae && q?.role === "assistant" && (q.status === "IN_PROGRESS" || q.status === "WAITING_CLIENT"), _e = _((b) => {
1503
- const z = b.functionName;
1504
- if (!(!h || !z))
1505
- return typeof h == "function" ? h(z, b.arguments ?? {}) : h[z];
1506
- }, [h]), { items: Ee } = tt({
1507
- client: U ?? void 0,
1508
- labelFor: _e,
1509
- includeReasoning: y
1510
- }), oe = Ee.filter((b) => q?.id !== void 0 && b.messageId === q.id), G = h === !1 ? void 0 : oe[oe.length - 1]?.label, ae = !!(J && G), Te = g === !1 ? void 0 : g ?? ((b) => re(b));
1511
- return /* @__PURE__ */ M("div", {
1512
- ref: C,
1513
- className: `ago-chat-widget ${R}`,
1583
+ }, [I.isModal, G]);
1584
+ const ae = async (w, L) => (h.current = !0, l(!0), k?.(w), await Ie(w, L) !== null), j = P[P.length - 1], X = _e && j?.role === "assistant" && (j.status === "IN_PROGRESS" || j.status === "WAITING_CLIENT"), Te = T((w) => {
1585
+ const L = w.functionName;
1586
+ if (!(!y || !L))
1587
+ return typeof y == "function" ? y(L, w.arguments ?? {}) : y[L];
1588
+ }, [y]), { items: Me } = at({
1589
+ client: q ?? void 0,
1590
+ labelFor: Te,
1591
+ includeReasoning: C
1592
+ }), ie = Me.filter((w) => j?.id !== void 0 && w.messageId === j.id), J = y === !1 ? void 0 : ie[ie.length - 1]?.label, se = !!(X && J), Fe = v === !1 ? void 0 : v ?? ((w) => ae(w));
1593
+ return /* @__PURE__ */ F("div", {
1594
+ ref: S,
1595
+ className: `ago-chat-widget ${p}`,
1514
1596
  ...I.surface.attrs,
1515
1597
  "data-ago-sheet-state": I.compact ? I.state : void 0,
1516
1598
  style: {
1517
1599
  display: "flex",
1518
1600
  flexDirection: "column",
1519
- height: typeof u == "number" ? `${u}px` : u,
1601
+ height: typeof d == "number" ? `${d}px` : d,
1520
1602
  border: "1px solid #dee3e8",
1521
1603
  borderRadius: "16px",
1522
1604
  overflow: "hidden",
@@ -1527,7 +1609,7 @@ var ue = {
1527
1609
  ...I.surface.style
1528
1610
  },
1529
1611
  children: [
1530
- !I.compact && /* @__PURE__ */ M("div", {
1612
+ !I.compact && /* @__PURE__ */ F("div", {
1531
1613
  className: "ago-chat-widget__header",
1532
1614
  style: {
1533
1615
  padding: "14px 16px",
@@ -1538,8 +1620,8 @@ var ue = {
1538
1620
  alignItems: "center",
1539
1621
  gap: "10px"
1540
1622
  },
1541
- children: [c && /* @__PURE__ */ a("img", {
1542
- src: c,
1623
+ children: [f && /* @__PURE__ */ a("img", {
1624
+ src: f,
1543
1625
  alt: "Logo",
1544
1626
  style: {
1545
1627
  height: "24px",
@@ -1554,13 +1636,13 @@ var ue = {
1554
1636
  children: o
1555
1637
  })]
1556
1638
  }),
1557
- Q && /* @__PURE__ */ M("button", {
1639
+ te && /* @__PURE__ */ F("button", {
1558
1640
  type: "button",
1559
1641
  className: "ago-chat-widget__peek",
1560
1642
  "aria-expanded": !1,
1561
1643
  "aria-label": "Open the conversation",
1562
1644
  onClick: () => {
1563
- Z(!1), L("user");
1645
+ ee(!1), B("user");
1564
1646
  },
1565
1647
  style: {
1566
1648
  display: "flex",
@@ -1577,7 +1659,7 @@ var ue = {
1577
1659
  font: "inherit",
1578
1660
  color: "inherit"
1579
1661
  },
1580
- children: [/* @__PURE__ */ M("span", {
1662
+ children: [/* @__PURE__ */ F("span", {
1581
1663
  style: {
1582
1664
  display: "flex",
1583
1665
  alignItems: "center",
@@ -1591,7 +1673,7 @@ var ue = {
1591
1673
  },
1592
1674
  children: [
1593
1675
  o,
1594
- Ce && /* @__PURE__ */ a("span", {
1676
+ Ae && /* @__PURE__ */ a("span", {
1595
1677
  "aria-label": "New message",
1596
1678
  style: {
1597
1679
  width: "6px",
@@ -1609,13 +1691,13 @@ var ue = {
1609
1691
  children: "↑"
1610
1692
  })
1611
1693
  ]
1612
- }), J && !q?.content ? /* @__PURE__ */ M("span", {
1694
+ }), X && !j?.content ? /* @__PURE__ */ F("span", {
1613
1695
  style: {
1614
1696
  display: "flex",
1615
1697
  alignItems: "center",
1616
1698
  gap: "8px"
1617
1699
  },
1618
- children: [!G && /* @__PURE__ */ a(ke, {}), /* @__PURE__ */ a("span", {
1700
+ children: [!J && /* @__PURE__ */ a(Se, {}), /* @__PURE__ */ a("span", {
1619
1701
  style: {
1620
1702
  fontSize: "13px",
1621
1703
  opacity: 0.7,
@@ -1623,7 +1705,7 @@ var ue = {
1623
1705
  textOverflow: "ellipsis",
1624
1706
  whiteSpace: "nowrap"
1625
1707
  },
1626
- children: G ? we(G) : f
1708
+ children: J ? Ce(J) : _
1627
1709
  })]
1628
1710
  }) : /* @__PURE__ */ a("span", {
1629
1711
  style: {
@@ -1636,10 +1718,10 @@ var ue = {
1636
1718
  color: "inherit",
1637
1719
  minHeight: "calc(2 * 1.5 * 13px)"
1638
1720
  },
1639
- children: q?.content || n
1721
+ children: j?.content || n
1640
1722
  })]
1641
1723
  }),
1642
- I.compact && I.state === "full" && /* @__PURE__ */ M("div", {
1724
+ I.compact && I.state === "full" && /* @__PURE__ */ F("div", {
1643
1725
  className: "ago-chat-widget__sheet-header",
1644
1726
  style: {
1645
1727
  display: "flex",
@@ -1665,7 +1747,7 @@ var ue = {
1665
1747
  }), /* @__PURE__ */ a("button", {
1666
1748
  type: "button",
1667
1749
  "aria-label": "Collapse the conversation",
1668
- onClick: () => K("user"),
1750
+ onClick: () => G("user"),
1669
1751
  style: {
1670
1752
  marginLeft: "auto",
1671
1753
  flexShrink: 0,
@@ -1693,25 +1775,25 @@ var ue = {
1693
1775
  })
1694
1776
  })]
1695
1777
  }),
1696
- /* @__PURE__ */ M("div", {
1778
+ /* @__PURE__ */ F("div", {
1697
1779
  style: {
1698
1780
  position: "relative",
1699
1781
  flex: 1,
1700
- display: Q ? "none" : "flex",
1782
+ display: te ? "none" : "flex",
1701
1783
  minHeight: 0
1702
1784
  },
1703
- children: [/* @__PURE__ */ M("div", {
1704
- ref: A,
1785
+ children: [/* @__PURE__ */ F("div", {
1786
+ ref: N,
1705
1787
  className: "ago-chat-widget__messages",
1706
- onScroll: (b) => {
1707
- const z = b.currentTarget, W = z.scrollHeight - z.scrollTop - z.clientHeight <= 48;
1708
- N.current = W, F(W);
1788
+ onScroll: (w) => {
1789
+ const L = w.currentTarget, z = L.scrollHeight - L.scrollTop - L.clientHeight <= 48;
1790
+ h.current = z, l(z);
1709
1791
  },
1710
1792
  role: "log",
1711
1793
  "aria-live": "polite",
1712
1794
  "aria-relevant": "additions text",
1713
1795
  "aria-atomic": !1,
1714
- "aria-busy": J,
1796
+ "aria-busy": X,
1715
1797
  style: {
1716
1798
  flex: 1,
1717
1799
  overflow: "auto",
@@ -1729,20 +1811,20 @@ var ue = {
1729
1811
  lineHeight: "1.5"
1730
1812
  },
1731
1813
  children: n
1732
- }) : P.map((b, z) => /* @__PURE__ */ a(Nt, {
1733
- message: b,
1734
- showAgentName: p,
1735
- isLast: z === P.length - 1,
1736
- onFollowUpClick: Te,
1737
- showStreamingDots: !ae,
1738
- feedback: S && b.role === "assistant" && b.status === "DONE" && b.content ? /* @__PURE__ */ a(Et, {
1739
- messageId: b.id,
1814
+ }) : P.map((w, L) => /* @__PURE__ */ a(Mt, {
1815
+ message: w,
1816
+ showAgentName: x,
1817
+ isLast: L === P.length - 1,
1818
+ onFollowUpClick: Fe,
1819
+ showStreamingDots: !se,
1820
+ feedback: u && w.role === "assistant" && w.status === "DONE" && w.content ? /* @__PURE__ */ a(Dt, {
1821
+ messageId: w.id,
1740
1822
  client: r,
1741
- ...S === !0 ? {} : S
1823
+ ...u === !0 ? {} : u
1742
1824
  }) : void 0
1743
- }, b.id)),
1744
- ae && /* @__PURE__ */ a(st, { label: G ?? "" }),
1745
- ne && /* @__PURE__ */ a("div", {
1825
+ }, w.id)),
1826
+ se && /* @__PURE__ */ a(ut, { label: J ?? "" }),
1827
+ oe && /* @__PURE__ */ a("div", {
1746
1828
  role: "alert",
1747
1829
  style: {
1748
1830
  padding: "10px 14px",
@@ -1753,15 +1835,15 @@ var ue = {
1753
1835
  fontSize: "13px",
1754
1836
  border: "1px solid #fecaca"
1755
1837
  },
1756
- children: ne.message
1838
+ children: oe.message
1757
1839
  }),
1758
1840
  /* @__PURE__ */ a("div", {})
1759
1841
  ]
1760
- }), !k && /* @__PURE__ */ a("button", {
1842
+ }), !D && /* @__PURE__ */ a("button", {
1761
1843
  type: "button",
1762
1844
  className: "ago-chat-widget__jump",
1763
1845
  "aria-label": "Jump to latest message",
1764
- onClick: Re,
1846
+ onClick: Ee,
1765
1847
  style: {
1766
1848
  position: "absolute",
1767
1849
  left: "50%",
@@ -1794,62 +1876,65 @@ var ue = {
1794
1876
  })
1795
1877
  })]
1796
1878
  }),
1797
- /* @__PURE__ */ a(lt, {
1798
- onSend: re,
1799
- onStop: i ? () => {
1800
- Ne();
1879
+ /* @__PURE__ */ a(ft, {
1880
+ onSend: ae,
1881
+ onStop: g ? () => {
1882
+ Re();
1801
1883
  } : void 0,
1802
- disabled: J,
1803
- placeholder: l,
1804
- allowFiles: s
1884
+ disabled: X,
1885
+ placeholder: s,
1886
+ allowFiles: c,
1887
+ speechToText: i,
1888
+ client: q ?? void 0,
1889
+ scopeKey: `${t ?? P[0]?.conversationId ?? ""}:${I.state}`
1805
1890
  })
1806
1891
  ]
1807
1892
  });
1808
1893
  });
1809
- function Tt(e = {}) {
1894
+ function zt(e = {}) {
1810
1895
  const r = O(), t = e.client ?? r;
1811
- if (!t) throw new X("useProactiveNudge: no AgoClient. Pass one via options.client or wrap your tree with <AgoProvider>.", "proactive_missing_client");
1812
- const [o, n] = T(null), l = D(o);
1813
- l.current = o;
1814
- const s = D(e.onExpand);
1815
- return s.current = e.onExpand, E(() => {
1816
- const i = (c) => {
1817
- n(c), t.proactive?.shown(c);
1818
- }, u = ({ nudge: c }) => {
1819
- n((p) => p?.id === c.id ? null : p);
1896
+ if (!t) throw new Q("useProactiveNudge: no AgoClient. Pass one via options.client or wrap your tree with <AgoProvider>.", "proactive_missing_client");
1897
+ const [o, n] = M(null), s = W(o);
1898
+ s.current = o;
1899
+ const c = W(e.onExpand);
1900
+ return c.current = e.onExpand, E(() => {
1901
+ const i = (d) => {
1902
+ n(d), t.proactive?.shown(d);
1903
+ }, g = ({ nudge: d }) => {
1904
+ n((f) => f?.id === d.id ? null : f);
1820
1905
  };
1821
- return t.on("nudge:ready", i), t.on("nudge:accepted", u), t.on("nudge:dismissed", u), () => {
1822
- t.off("nudge:ready", i), t.off("nudge:accepted", u), t.off("nudge:dismissed", u);
1906
+ return t.on("nudge:ready", i), t.on("nudge:accepted", g), t.on("nudge:dismissed", g), () => {
1907
+ t.off("nudge:ready", i), t.off("nudge:accepted", g), t.off("nudge:dismissed", g);
1823
1908
  };
1824
1909
  }, [t]), {
1825
1910
  nudge: o,
1826
- accept: _(async () => {
1827
- const i = l.current;
1828
- i && (n(null), await t.proactive?.accept(i), (i.source === "agent" || i.goal) && s.current?.(i));
1911
+ accept: T(async () => {
1912
+ const i = s.current;
1913
+ i && (n(null), await t.proactive?.accept(i), (i.source === "agent" || i.goal) && c.current?.(i));
1829
1914
  }, [t]),
1830
- dismiss: _(() => {
1831
- const i = l.current;
1915
+ dismiss: T(() => {
1916
+ const i = s.current;
1832
1917
  i && (n(null), t.proactive?.dismiss(i));
1833
1918
  }, [t])
1834
1919
  };
1835
1920
  }
1836
- var Jt = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right", openChatLabel: n = "Open chat", className: l = "" }) => {
1837
- const { nudge: s, accept: i, dismiss: u } = Tt({
1921
+ var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right", openChatLabel: n = "Open chat", className: s = "" }) => {
1922
+ const { nudge: c, accept: i, dismiss: g } = zt({
1838
1923
  client: e,
1839
1924
  onExpand: r
1840
1925
  });
1841
1926
  if (E(() => {
1842
- if (!s || !t) return;
1843
- const p = setTimeout(() => u(), t);
1844
- return () => clearTimeout(p);
1927
+ if (!c || !t) return;
1928
+ const f = setTimeout(() => g(), t);
1929
+ return () => clearTimeout(f);
1845
1930
  }, [
1846
- s,
1931
+ c,
1847
1932
  t,
1848
- u
1849
- ]), !s) return null;
1850
- const c = s.source === "agent" || !!s.goal;
1851
- return /* @__PURE__ */ M("div", {
1852
- className: `ago-nudge ${l}`,
1933
+ g
1934
+ ]), !c) return null;
1935
+ const d = c.source === "agent" || !!c.goal;
1936
+ return /* @__PURE__ */ F("div", {
1937
+ className: `ago-nudge ${s}`,
1853
1938
  role: "status",
1854
1939
  "aria-live": "polite",
1855
1940
  style: {
@@ -1874,7 +1959,7 @@ var Jt = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
1874
1959
  type: "button",
1875
1960
  className: "ago-nudge__close",
1876
1961
  "aria-label": "Dismiss",
1877
- onClick: u,
1962
+ onClick: g,
1878
1963
  style: {
1879
1964
  position: "absolute",
1880
1965
  top: "6px",
@@ -1892,9 +1977,9 @@ var Jt = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
1892
1977
  /* @__PURE__ */ a("div", {
1893
1978
  className: "ago-nudge__message",
1894
1979
  style: { paddingRight: "16px" },
1895
- children: s.message
1980
+ children: c.message
1896
1981
  }),
1897
- (s.action || c) && /* @__PURE__ */ M("div", {
1982
+ (c.action || d) && /* @__PURE__ */ F("div", {
1898
1983
  className: "ago-nudge__actions",
1899
1984
  style: {
1900
1985
  display: "flex",
@@ -1902,7 +1987,7 @@ var Jt = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
1902
1987
  marginTop: "10px",
1903
1988
  flexWrap: "wrap"
1904
1989
  },
1905
- children: [s.action && /* @__PURE__ */ a("button", {
1990
+ children: [c.action && /* @__PURE__ */ a("button", {
1906
1991
  type: "button",
1907
1992
  className: "ago-nudge__action",
1908
1993
  onClick: () => {
@@ -1918,8 +2003,8 @@ var Jt = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
1918
2003
  fontWeight: 600,
1919
2004
  cursor: "pointer"
1920
2005
  },
1921
- children: s.action.label
1922
- }), c && /* @__PURE__ */ a("button", {
2006
+ children: c.action.label
2007
+ }), d && /* @__PURE__ */ a("button", {
1923
2008
  type: "button",
1924
2009
  className: "ago-nudge__expand",
1925
2010
  onClick: () => {
@@ -1941,50 +2026,50 @@ var Jt = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
1941
2026
  ]
1942
2027
  });
1943
2028
  };
1944
- function Mt({ client: e, autoLoad: r = !0 } = {}) {
2029
+ function Lt({ client: e, autoLoad: r = !0 } = {}) {
1945
2030
  const t = O(), o = e || t;
1946
2031
  if (!o) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
1947
- const [n, l] = T([]), [s, i] = T(null), [u, c] = T(!1), [p, v] = T(null), S = _(async () => {
1948
- c(!0), v(null);
2032
+ const [n, s] = M([]), [c, i] = M(null), [g, d] = M(!1), [f, x] = M(null), m = T(async () => {
2033
+ d(!0), x(null);
1949
2034
  try {
1950
- const { data: d } = await o.getConversations();
1951
- l(d);
1952
- } catch (d) {
1953
- v(d instanceof Error ? d : /* @__PURE__ */ new Error("Failed to load conversations"));
2035
+ const { data: p } = await o.getConversations();
2036
+ s(p);
2037
+ } catch (p) {
2038
+ x(p instanceof Error ? p : /* @__PURE__ */ new Error("Failed to load conversations"));
1954
2039
  } finally {
1955
- c(!1);
2040
+ d(!1);
1956
2041
  }
1957
- }, [o]), g = _(async (d) => {
1958
- c(!0), v(null);
2042
+ }, [o]), u = T(async (p) => {
2043
+ d(!0), x(null);
1959
2044
  try {
1960
- i(await o.getConversation(d));
1961
- } catch (w) {
1962
- v(w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to load conversation"));
2045
+ i(await o.getConversation(p));
2046
+ } catch (k) {
2047
+ x(k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to load conversation"));
1963
2048
  } finally {
1964
- c(!1);
2049
+ d(!1);
1965
2050
  }
1966
- }, [o]), R = _(() => {
2051
+ }, [o]), v = T(() => {
1967
2052
  i(null);
1968
2053
  }, []);
1969
2054
  return E(() => {
1970
- r && S();
1971
- }, [r, S]), {
2055
+ r && m();
2056
+ }, [r, m]), {
1972
2057
  conversations: n,
1973
- currentConversation: s,
1974
- isLoading: u,
1975
- error: p,
1976
- selectConversation: g,
1977
- startNewConversation: R,
1978
- refreshConversations: S
2058
+ currentConversation: c,
2059
+ isLoading: g,
2060
+ error: f,
2061
+ selectConversation: u,
2062
+ startNewConversation: v,
2063
+ refreshConversations: m
1979
2064
  };
1980
2065
  }
1981
- function Vt(e = {}) {
2066
+ function nn(e = {}) {
1982
2067
  const r = O(), t = e.client || r;
1983
2068
  if (!t) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
1984
- const o = ve({
2069
+ const o = ke({
1985
2070
  client: t,
1986
2071
  conversationId: e.conversationId
1987
- }), n = Mt({
2072
+ }), n = Lt({
1988
2073
  client: t,
1989
2074
  autoLoad: e.autoLoad
1990
2075
  });
@@ -2004,18 +2089,19 @@ function Vt(e = {}) {
2004
2089
  refreshConversations: n.refreshConversations
2005
2090
  };
2006
2091
  }
2007
- function Yt(e, r) {
2008
- const t = $(), { name: o, description: n, parameters: l, handler: s, maxResultBytes: i, requiresApproval: u } = typeof e == "string" ? {
2092
+ function rn(e, r) {
2093
+ const t = U(), { name: o, description: n, parameters: s, handler: c, maxResultBytes: i, requiresApproval: g, webmcp: d } = typeof e == "string" ? {
2009
2094
  name: e,
2010
2095
  ...r
2011
- } : e, c = D(s);
2012
- c.current = s, E(() => {
2013
- const p = (v) => c.current(v);
2014
- return t.registerFunction(o, p, {
2096
+ } : e, f = W(c);
2097
+ f.current = c, E(() => {
2098
+ const x = (m) => f.current(m);
2099
+ return t.registerFunction(o, x, {
2015
2100
  description: n,
2016
- parameters: l,
2101
+ parameters: s,
2017
2102
  maxResultBytes: i,
2018
- requiresApproval: u
2103
+ requiresApproval: g,
2104
+ webmcp: d
2019
2105
  }), () => {
2020
2106
  t.unregisterFunction(o);
2021
2107
  };
@@ -2023,43 +2109,44 @@ function Yt(e, r) {
2023
2109
  t,
2024
2110
  o,
2025
2111
  n,
2026
- l,
2112
+ s,
2027
2113
  i,
2028
- u
2114
+ g,
2115
+ JSON.stringify(d ?? null)
2029
2116
  ]);
2030
2117
  }
2031
- function Xt(e, r) {
2032
- const t = $(), o = D(e);
2118
+ function on(e, r) {
2119
+ const t = U(), o = W(e);
2033
2120
  o.current = e, E(() => (t.registerNavigationFunction((n) => o.current(n), r), () => {
2034
2121
  t.unregisterNavigationFunction();
2035
2122
  }), [t, r]);
2036
2123
  }
2037
- function Zt(e, r) {
2038
- const t = $(), o = r?.functionName ?? "setPageState", n = r?.requiresApproval, l = r?.data !== void 0, s = r?.data?.description, i = r?.data?.maxResultBytes, u = r?.settleTimeoutMs, c = D(e);
2039
- c.current = e;
2040
- const p = D(r);
2041
- p.current = r, E(() => {
2042
- const v = c.current.map((g) => {
2043
- const R = () => c.current.find((d) => d.name === g.name) ?? g;
2124
+ function an(e, r) {
2125
+ const t = U(), o = r?.functionName ?? "setPageState", n = r?.requiresApproval, s = r?.data !== void 0, c = r?.data?.description, i = r?.data?.maxResultBytes, g = r?.settleTimeoutMs, d = W(e);
2126
+ d.current = e;
2127
+ const f = W(r);
2128
+ f.current = r, E(() => {
2129
+ const x = d.current.map((u) => {
2130
+ const v = () => d.current.find((p) => p.name === u.name) ?? u;
2044
2131
  return {
2045
- name: g.name,
2046
- description: g.description,
2047
- schema: g.schema,
2048
- clearable: g.clearable,
2049
- get: g.get ? () => R().get?.() : void 0,
2050
- set: (d) => R().set(d)
2132
+ name: u.name,
2133
+ description: u.description,
2134
+ schema: u.schema,
2135
+ clearable: u.clearable,
2136
+ get: u.get ? () => v().get?.() : void 0,
2137
+ set: (p) => v().set(p)
2051
2138
  };
2052
- }), S = l ? {
2053
- description: s ?? "What the page is currently showing.",
2139
+ }), m = s ? {
2140
+ description: c ?? "What the page is currently showing.",
2054
2141
  maxResultBytes: i,
2055
- get: () => p.current?.data?.get(),
2056
- isLoading: () => p.current?.data?.isLoading?.() ?? !1
2142
+ get: () => f.current?.data?.get(),
2143
+ isLoading: () => f.current?.data?.isLoading?.() ?? !1
2057
2144
  } : void 0;
2058
- return t.registerPageStateFunction(v, {
2145
+ return t.registerPageStateFunction(x, {
2059
2146
  functionName: o,
2060
2147
  requiresApproval: n,
2061
- data: S,
2062
- settleTimeoutMs: u
2148
+ data: m,
2149
+ settleTimeoutMs: g
2063
2150
  }), () => {
2064
2151
  t.unregisterPageStateFunction(o);
2065
2152
  };
@@ -2067,126 +2154,126 @@ function Zt(e, r) {
2067
2154
  t,
2068
2155
  o,
2069
2156
  n,
2070
- l,
2071
2157
  s,
2158
+ c,
2072
2159
  i,
2073
- u,
2074
- JSON.stringify(e.map((v) => ({
2075
- name: v.name,
2076
- description: v.description,
2077
- schema: v.schema,
2078
- clearable: v.clearable
2160
+ g,
2161
+ JSON.stringify(e.map((x) => ({
2162
+ name: x.name,
2163
+ description: x.description,
2164
+ schema: x.schema,
2165
+ clearable: x.clearable
2079
2166
  })))
2080
2167
  ]);
2081
2168
  }
2082
- function Qt(e) {
2083
- const r = $(), t = D(e);
2084
- t.current = e, E(() => Be(r, () => t.current), [r]);
2169
+ function sn(e) {
2170
+ const r = U(), t = W(e);
2171
+ t.current = e, E(() => $e(r, () => t.current), [r]);
2085
2172
  }
2086
- function en(e = {}) {
2173
+ function ln(e = {}) {
2087
2174
  const r = O(), t = e.client || r;
2088
- if (!t) throw new X("useAgoActivityLog requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
2089
- const [o, n] = T(() => t.getRecentActivity());
2175
+ if (!t) throw new Q("useAgoActivityLog requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
2176
+ const [o, n] = M(() => t.getRecentActivity());
2090
2177
  E(() => {
2091
2178
  n(t.getRecentActivity());
2092
2179
  const i = () => n(t.getRecentActivity());
2093
2180
  return t.on("activity:recorded", i), () => t.off("activity:recorded", i);
2094
2181
  }, [t]);
2095
- const l = _((i) => t.recordActivity(i), [t]), s = _(() => {
2182
+ const s = T((i) => t.recordActivity(i), [t]), c = T(() => {
2096
2183
  t.clearActivity(), n([]);
2097
2184
  }, [t]);
2098
2185
  return {
2099
2186
  entries: o,
2100
2187
  latest: o.length > 0 ? o[o.length - 1] : void 0,
2101
- record: l,
2102
- clear: s
2188
+ record: s,
2189
+ clear: c
2103
2190
  };
2104
2191
  }
2105
- function tn(e, r) {
2106
- const t = $(), o = Ge(), n = r ?? o, l = D(e);
2107
- l.current = e;
2108
- const s = typeof e == "function";
2192
+ function cn(e, r) {
2193
+ const t = U(), o = Xe(), n = r ?? o, s = W(e);
2194
+ s.current = e;
2195
+ const c = typeof e == "function";
2109
2196
  E(() => {
2110
- if (typeof l.current == "function") {
2111
- const i = () => l.current();
2197
+ if (typeof s.current == "function") {
2198
+ const i = () => s.current();
2112
2199
  return t.addDynamicContext(n, i), () => {
2113
2200
  t.removeDynamicContext(n);
2114
2201
  };
2115
2202
  }
2116
- return t.setContext(n, l.current), () => {
2203
+ return t.setContext(n, s.current), () => {
2117
2204
  t.removeContext(n);
2118
2205
  };
2119
2206
  }, [
2120
2207
  t,
2121
2208
  n,
2122
- s,
2123
- s ? "" : JSON.stringify(e)
2209
+ c,
2210
+ c ? "" : JSON.stringify(e)
2124
2211
  ]);
2125
2212
  }
2126
- function Ft(e) {
2127
- return xe(e.subscribe, e.get, e.get);
2213
+ function Pt(e) {
2214
+ return ye(e.subscribe, e.get, e.get);
2128
2215
  }
2129
- var fe = {
2216
+ var me = {
2130
2217
  missing: [],
2131
2218
  complete: !1
2132
2219
  };
2133
- function nn(e) {
2134
- const r = $(), t = e.schema != null, o = JSON.stringify(e.schema ?? null), n = e.submit, l = n ? typeof n == "string" ? `client:${n}` : n.via === "backend" ? "backend" : "handler" in n ? "client:handler" : `client:${n.url}` : "none", s = JSON.stringify(e.initialValues ?? null), i = B(() => t ? me(e) : null, [
2220
+ function dn(e) {
2221
+ const r = U(), 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), i = $(() => t ? xe(e) : null, [
2135
2222
  t,
2136
2223
  e.name,
2137
2224
  o,
2138
- l,
2139
2225
  s,
2226
+ c,
2140
2227
  e.autoSubmit
2141
- ]), [u, c] = T({
2228
+ ]), [g, d] = M({
2142
2229
  collector: null,
2143
2230
  loading: !t,
2144
2231
  error: null
2145
2232
  });
2146
2233
  E(() => {
2147
2234
  if (t) return;
2148
- let f = !1;
2149
- return c({
2235
+ let R = !1;
2236
+ return d({
2150
2237
  collector: null,
2151
2238
  loading: !0,
2152
2239
  error: null
2153
- }), ge(r, e).then((h) => {
2154
- f || c({
2155
- collector: h,
2240
+ }), he(r, e).then((_) => {
2241
+ R || d({
2242
+ collector: _,
2156
2243
  loading: !1,
2157
2244
  error: null
2158
2245
  });
2159
- }).catch((h) => {
2160
- f || c({
2246
+ }).catch((_) => {
2247
+ R || d({
2161
2248
  collector: null,
2162
2249
  loading: !1,
2163
- error: h instanceof Error ? h : new Error(String(h))
2250
+ error: _ instanceof Error ? _ : new Error(String(_))
2164
2251
  });
2165
2252
  }), () => {
2166
- f = !0;
2253
+ R = !0;
2167
2254
  };
2168
2255
  }, [
2169
2256
  r,
2170
2257
  t,
2171
2258
  e.name,
2172
- l,
2173
2259
  s,
2260
+ c,
2174
2261
  e.autoSubmit
2175
2262
  ]);
2176
- const p = t ? i : u.collector, v = t ? !1 : u.loading, S = t ? null : u.error;
2263
+ const f = t ? i : g.collector, x = t ? !1 : g.loading, m = t ? null : g.error;
2177
2264
  E(() => {
2178
- if (p)
2179
- return p.install(r);
2180
- }, [r, p]);
2181
- const g = B(() => ze({
2265
+ if (f)
2266
+ return f.install(r);
2267
+ }, [r, f]);
2268
+ const u = $(() => Le({
2182
2269
  values: e.initialValues ?? {},
2183
2270
  submitted: !1
2184
- }), [s]), R = Ft(p?.store ?? g), d = B(() => p?.getStatus() ?? fe, [R, p]), w = B(() => ({
2185
- ...R,
2186
- ...d
2187
- }), [R, d]), x = B(() => ({
2271
+ }), [c]), v = Pt(f?.store ?? u), p = $(() => f?.getStatus() ?? me, [v, f]), k = $(() => ({
2272
+ ...v,
2273
+ ...p
2274
+ }), [v, p]), b = $(() => ({
2188
2275
  name: e.name,
2189
- store: g,
2276
+ store: u,
2190
2277
  functions: [],
2191
2278
  contextKey: `form:${e.name}`,
2192
2279
  contextProvider: () => ({
@@ -2207,50 +2294,52 @@ function nn(e) {
2207
2294
  ok: !1,
2208
2295
  error: "Form definition not loaded yet."
2209
2296
  }),
2210
- getValues: () => g.get().values,
2297
+ getValues: () => u.get().values,
2211
2298
  setValues: () => {
2212
2299
  },
2213
2300
  reset: () => {
2214
2301
  },
2215
- getStatus: () => fe
2216
- }), [e.name, g]);
2302
+ getStatus: () => me
2303
+ }), [e.name, u]);
2217
2304
  return {
2218
- ...p ?? x,
2219
- state: w,
2220
- loading: v,
2221
- error: S
2305
+ ...f ?? b,
2306
+ state: k,
2307
+ loading: x,
2308
+ error: m
2222
2309
  };
2223
2310
  }
2224
2311
  export {
2225
- Jt as AgoNudge,
2226
- Ut as AgoProvider,
2227
- lt as ChatInput,
2228
- Gt as ChatWidget,
2229
- ue as DEFAULT_MESSAGE_FEEDBACK_LABELS,
2230
- He as FEEDBACK_REASONS,
2231
- St as Markdown,
2232
- Nt as Message,
2233
- Et as MessageFeedback,
2234
- me as createFormCollector,
2235
- Bt as createMockClient,
2236
- Lt as deriveFormStatus,
2237
- ge as loadFormCollector,
2238
- Xe as useAgo,
2239
- tt as useAgoActivity,
2240
- en as useAgoActivityLog,
2241
- Qt as useAgoAutoContinueAfterNavigation,
2242
- $ as useAgoClient,
2243
- tn as useAgoContext,
2244
- Yt as useAgoFunction,
2245
- Xt as useAgoNavigation,
2246
- Zt as useAgoPageState,
2247
- Ft as useAgoStore,
2248
- Vt as useChat,
2249
- Mt as useConversation,
2250
- Rt as useFeedback,
2251
- nn as useFormCollector,
2252
- ve as useMessages,
2312
+ tn as AgoNudge,
2313
+ Qt as AgoProvider,
2314
+ ft as ChatInput,
2315
+ en as ChatWidget,
2316
+ fe as DEFAULT_MESSAGE_FEEDBACK_LABELS,
2317
+ Jt as DEFAULT_SPEECH_TO_TEXT_LABELS,
2318
+ Oe as FEEDBACK_REASONS,
2319
+ Rt as Markdown,
2320
+ Mt as Message,
2321
+ Dt as MessageFeedback,
2322
+ pt as SpeechToTextButton,
2323
+ xe as createFormCollector,
2324
+ Kt as createMockClient,
2325
+ jt as deriveFormStatus,
2326
+ he as loadFormCollector,
2327
+ tt as useAgo,
2328
+ at as useAgoActivity,
2329
+ ln as useAgoActivityLog,
2330
+ sn as useAgoAutoContinueAfterNavigation,
2331
+ U as useAgoClient,
2332
+ cn as useAgoContext,
2333
+ rn as useAgoFunction,
2334
+ on as useAgoNavigation,
2335
+ an as useAgoPageState,
2336
+ Pt as useAgoStore,
2337
+ nn as useChat,
2338
+ Lt as useConversation,
2339
+ Ft as useFeedback,
2340
+ dn as useFormCollector,
2341
+ ke as useMessages,
2253
2342
  O as useOptionalAgoClient,
2254
- Tt as useProactiveNudge,
2255
- ot as useSheet
2343
+ zt as useProactiveNudge,
2344
+ lt as useSheet
2256
2345
  };