@useago/sdk 1.13.0 → 1.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/angular.cjs +1 -1
  3. package/dist/angular.d.cts +43 -10
  4. package/dist/angular.d.ts +43 -10
  5. package/dist/angular.js +4 -4
  6. package/dist/autoContinue-C3UsCvT5.cjs +1 -0
  7. package/dist/{autoContinue-CC8K9mBU.js → autoContinue-Cb4_iEbO.js} +1 -1
  8. package/dist/{createConversationSession-CiOXKWl0.cjs → createConversationSession-Digvn0GQ.cjs} +1 -1
  9. package/dist/{createConversationSession-BfJg0WyA.js → createConversationSession-DrmOaZdO.js} +1 -1
  10. package/dist/{createFormCollector-DnQl77Ko.cjs → createFormCollector-Cq7HWjtU.cjs} +1 -1
  11. package/dist/{createFormCollector-DN1xjAv5.js → createFormCollector-ki_GTlp9.js} +1 -1
  12. package/dist/devtools.d.cts +34 -5
  13. package/dist/devtools.d.ts +34 -5
  14. package/dist/index.cjs +1 -1
  15. package/dist/index.d.cts +34 -5
  16. package/dist/index.d.ts +34 -5
  17. package/dist/index.js +4 -4
  18. package/dist/react.cjs +3 -3
  19. package/dist/react.d.cts +40 -6
  20. package/dist/react.d.ts +40 -6
  21. package/dist/react.js +290 -284
  22. package/dist/testing.d.cts +34 -5
  23. package/dist/testing.d.ts +34 -5
  24. package/dist/{types-Q7t1peH-.js → types-D1ZrqVhr.js} +884 -776
  25. package/dist/types-DNr6XEwI.cjs +10 -0
  26. package/dist/vue.cjs +1 -1
  27. package/dist/vue.d.cts +38 -7
  28. package/dist/vue.d.ts +38 -7
  29. package/dist/vue.js +57 -57
  30. package/dist/widget.cjs +6 -6
  31. package/dist/widget.d.cts +34 -5
  32. package/dist/widget.d.ts +34 -5
  33. package/dist/widget.js +136 -136
  34. package/llms-full.txt +56 -3
  35. package/package.json +1 -1
  36. package/dist/autoContinue-CP9pJR-V.cjs +0 -1
  37. package/dist/types-a7teDBnC.cjs +0 -10
package/dist/react.js CHANGED
@@ -1,7 +1,7 @@
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";
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-D1ZrqVhr.js";
2
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";
3
+ import { t as $e } from "./autoContinue-Cb4_iEbO.js";
4
+ import { n as jt, r as he, t as xe } from "./createFormCollector-ki_GTlp9.js";
5
5
  import { t as Kt } from "./createMockClient-YoYr3pQr.js";
6
6
  import { C as je, dt as qe, n as Ke, t as Jt, ut as Ue } from "./speechToText-BV7qxqPF.js";
7
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";
@@ -44,7 +44,7 @@ function tt(e) {
44
44
  };
45
45
  }
46
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;
47
+ const { client: l } = tt(r ? null : s), i = r || l;
48
48
  return E(() => {
49
49
  if (!(!t || t.length === 0)) {
50
50
  for (const g of t) i.register(g);
@@ -56,15 +56,15 @@ var ne = Je(null), Qt = ({ children: e, client: r, tools: t, helpers: o, pageCon
56
56
  if (!o) return;
57
57
  const g = [];
58
58
  return import("./functions-tzyOZNp6.js").then((d) => d.n).then((d) => {
59
- for (const [f, x] of Object.entries(o)) {
59
+ for (const [f, w] of Object.entries(o)) {
60
60
  const m = d[f];
61
61
  if (!m) {
62
62
  console.warn(`[AGO] Unknown helper: "${f}"`);
63
63
  continue;
64
64
  }
65
- const u = x === !0 ? m : {
65
+ const u = w === !0 ? m : {
66
66
  ...m,
67
- handler: x
67
+ handler: w
68
68
  };
69
69
  i.register(u), g.push(u.name);
70
70
  }
@@ -132,12 +132,12 @@ function ot(e) {
132
132
  function at(e = {}) {
133
133
  const { includeReasoning: r = !1, labelFor: t } = e, o = O(), n = e.client || o;
134
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);
135
+ const [s, l] = M([]), i = W(/* @__PURE__ */ new Set()), g = W(void 0), d = W(t);
136
136
  d.current = t;
137
137
  const f = T((p, k) => {
138
- c((b) => {
139
- const R = b.findIndex((y) => y.id === p), _ = {
140
- ...R >= 0 ? b[R] : {
138
+ l((x) => {
139
+ const R = x.findIndex((b) => b.id === p), _ = {
140
+ ...R >= 0 ? x[R] : {
141
141
  id: p,
142
142
  kind: "status",
143
143
  label: "",
@@ -148,10 +148,10 @@ function at(e = {}) {
148
148
  ...k
149
149
  };
150
150
  return _.label = d.current?.(_) ?? ot(_), R >= 0 ? [
151
- ...b.slice(0, R),
151
+ ...x.slice(0, R),
152
152
  _,
153
- ...b.slice(R + 1)
154
- ] : [...b, _];
153
+ ...x.slice(R + 1)
154
+ ] : [...x, _];
155
155
  });
156
156
  }, []);
157
157
  E(() => {
@@ -170,7 +170,7 @@ function at(e = {}) {
170
170
  formSchema: h.formSchema,
171
171
  requiresApproval: D === "confirmation" || D === "form"
172
172
  });
173
- }, b = (h) => {
173
+ }, x = (h) => {
174
174
  h.invocationId && f(h.invocationId, {
175
175
  kind: h.functionName === "navigateToPage" ? "navigation" : "action",
176
176
  status: "running",
@@ -189,46 +189,46 @@ function at(e = {}) {
189
189
  });
190
190
  }, _ = (h) => {
191
191
  if (!h.invocationId) return;
192
- const D = h.result, l = typeof h.result == "object" && D !== null && D.approved === !1 && D.reason === "user_rejected";
192
+ const D = h.result, c = typeof h.result == "object" && D !== null && D.approved === !1 && D.reason === "user_rejected";
193
193
  f(h.invocationId, {
194
- status: h.error ? "error" : l ? "rejected" : "done",
194
+ status: h.error ? "error" : c ? "rejected" : "done",
195
195
  requiresApproval: !1
196
196
  });
197
- }, y = (h) => {
197
+ }, b = (h) => {
198
198
  for (const D of h.messages ?? [])
199
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, {
200
+ for (const c of D.toolCalls ?? []) {
201
+ const S = rt(c);
202
+ S === "reasoning" && !r || /waiting/i.test(c.status ?? "") || f(c.id, {
203
203
  kind: S,
204
- status: de(l.status, S),
204
+ status: de(c.status, S),
205
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,
206
+ toolName: c.toolName,
207
+ toolDisplayName: c.toolDisplayName,
208
+ functionName: c.functionName,
209
+ arguments: c.arguments,
210
+ message: c.message,
211
+ data: c.data,
212
+ formSchema: c.formSchema,
213
213
  requiresApproval: S === "confirmation" || S === "form"
214
214
  });
215
215
  }
216
216
  }, C = (h) => {
217
- c((D) => D.map((l) => l.status === "running" || l.status === "awaiting-approval" ? {
218
- ...l,
217
+ l((D) => D.map((c) => c.status === "running" || c.status === "awaiting-approval" ? {
218
+ ...c,
219
219
  status: h
220
- } : l));
220
+ } : c));
221
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);
222
+ return n.on("message:start", p), n.on("toolCall:received", k), n.on("function:invoke", x), n.on("function:awaiting-approval", R), n.on("function:result", _), n.on("conversation:loaded", b), 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", x), n.off("function:awaiting-approval", R), n.off("function:result", _), n.off("conversation:loaded", b), n.off("message:complete", A), n.off("message:error", N);
224
224
  };
225
225
  }, [
226
226
  n,
227
227
  r,
228
228
  f
229
229
  ]);
230
- const x = T(async (p) => {
231
- const k = s.find((b) => b.id === p);
230
+ const w = T(async (p) => {
231
+ const k = s.find((x) => x.id === p);
232
232
  !k || k.status !== "awaiting-approval" || i.current.has(p) || k.kind !== "form" && (i.current.add(p), f(p, {
233
233
  status: "running",
234
234
  requiresApproval: !1
@@ -238,7 +238,7 @@ function at(e = {}) {
238
238
  s,
239
239
  f
240
240
  ]), m = T(async (p) => {
241
- const k = s.find((b) => b.id === p);
241
+ const k = s.find((x) => x.id === p);
242
242
  !k || k.status !== "awaiting-approval" || i.current.has(p) || (i.current.add(p), f(p, {
243
243
  status: "rejected",
244
244
  requiresApproval: !1
@@ -252,58 +252,58 @@ function at(e = {}) {
252
252
  status: "running",
253
253
  requiresApproval: !1
254
254
  }), await n.submitToolCallForm(p, k), f(p, { status: "done" });
255
- }, [n, f]), v = T(() => {
256
- i.current.clear(), c([]);
255
+ }, [n, f]), y = T(() => {
256
+ i.current.clear(), l([]);
257
257
  }, []);
258
258
  return {
259
259
  items: s,
260
260
  latest: s.length > 0 ? s[s.length - 1] : void 0,
261
261
  isAwaitingApproval: s.some((p) => nt.has(p.status)),
262
- approve: x,
262
+ approve: w,
263
263
  reject: m,
264
264
  submitForm: u,
265
- clear: v
265
+ clear: y
266
266
  };
267
267
  }
268
268
  function ke({ client: e, conversationId: r } = {}) {
269
269
  const t = O(), o = e || t;
270
270
  if (!o) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
271
- const [n, s] = M([]), [c, i] = M(r), [g, d] = M(!1), [f, x] = M(null);
271
+ const [n, s] = M([]), [l, i] = M(r), [g, d] = M(!1), [f, w] = M(null);
272
272
  E(() => {
273
- r && r !== c && (i(r), m(r));
273
+ r && r !== l && (i(r), m(r));
274
274
  }, [r]);
275
275
  const m = async (u) => {
276
276
  try {
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"));
277
+ s((await o.getMessages(u)).filter((y) => !y.hidden));
278
+ } catch (y) {
279
+ w(y instanceof Error ? y : /* @__PURE__ */ new Error("Failed to load messages"));
280
280
  }
281
281
  };
282
282
  return E(() => {
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);
283
+ const u = (b) => b === "IN_PROGRESS" || b === "WAITING_CLIENT", y = (b) => {
284
+ l || i(b.conversationId), d(!0), s((C) => {
285
+ const A = C.findIndex((N) => N.id === b.messageId);
286
286
  return A >= 0 ? C.map((N, h) => h === A ? {
287
287
  ...N,
288
288
  status: "IN_PROGRESS"
289
289
  } : N) : C.some((N) => N.role === "assistant" && u(N.status)) ? C : [...C, {
290
- id: y.messageId,
291
- conversationId: y.conversationId,
290
+ id: b.messageId,
291
+ conversationId: b.conversationId,
292
292
  content: "",
293
293
  role: "assistant",
294
294
  status: "IN_PROGRESS",
295
295
  createdAt: /* @__PURE__ */ new Date()
296
296
  }];
297
297
  });
298
- }, p = (y) => {
298
+ }, p = (b) => {
299
299
  s((C) => {
300
- const A = C.findIndex((N) => N.id === y.messageId);
300
+ const A = C.findIndex((N) => N.id === b.messageId);
301
301
  return A < 0 ? C : C.map((N, h) => h === A ? {
302
302
  ...N,
303
- content: N.content + y.content
303
+ content: N.content + b.content
304
304
  } : N);
305
305
  });
306
- }, k = (y) => {
306
+ }, k = (b) => {
307
307
  s((C) => {
308
308
  let A = -1;
309
309
  for (let N = C.length - 1; N >= 0; N--) if (C[N].role === "assistant" && u(C[N].status)) {
@@ -314,93 +314,93 @@ function ke({ client: e, conversationId: r } = {}) {
314
314
  ...C.slice(0, A),
315
315
  {
316
316
  ...C[A],
317
- ...y
317
+ ...b
318
318
  },
319
319
  ...C.slice(A + 1)
320
320
  ];
321
321
  });
322
- }, b = (y) => {
322
+ }, x = (b) => {
323
323
  s((C) => {
324
- const A = C.findIndex((N) => N.id === y.id);
324
+ const A = C.findIndex((N) => N.id === b.id);
325
325
  return A >= 0 ? [
326
326
  ...C.slice(0, A),
327
- y,
327
+ b,
328
328
  ...C.slice(A + 1)
329
- ] : [...C, y];
329
+ ] : [...C, b];
330
330
  }), d(!1);
331
- }, R = (y) => {
332
- x(new Error(y.error)), d(!1);
331
+ }, R = (b) => {
332
+ w(new Error(b.error)), d(!1);
333
333
  }, _ = () => {
334
- s((y) => {
334
+ s((b) => {
335
335
  let C = -1;
336
- for (let A = y.length - 1; A >= 0; A--) if (y[A].role === "assistant" && u(y[A].status)) {
336
+ for (let A = b.length - 1; A >= 0; A--) if (b[A].role === "assistant" && u(b[A].status)) {
337
337
  C = A;
338
338
  break;
339
339
  }
340
- return C < 0 ? y : y[C].content ? y.map((A, N) => N === C ? {
340
+ return C < 0 ? b : b[C].content ? b.map((A, N) => N === C ? {
341
341
  ...A,
342
342
  status: "CANCELED"
343
- } : A) : y.filter((A, N) => N !== C);
343
+ } : A) : b.filter((A, N) => N !== C);
344
344
  }), d(!1);
345
345
  };
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", _);
346
+ return o.on("message:start", y), o.on("message:chunk", p), o.on("message:answer-complete", k), o.on("message:complete", x), o.on("message:error", R), o.on("message:stopped", _), () => {
347
+ o.off("message:start", y), o.off("message:chunk", p), o.off("message:answer-complete", k), o.off("message:complete", x), o.off("message:error", R), o.off("message:stopped", _);
348
348
  };
349
- }, [o, c]), {
349
+ }, [o, l]), {
350
350
  messages: n,
351
351
  isLoading: g,
352
352
  error: f,
353
- sendMessage: T(async (u, v) => {
354
- d(!0), x(null);
353
+ sendMessage: T(async (u, y) => {
354
+ d(!0), w(null);
355
355
  const p = {
356
356
  id: `temp-${Date.now()}`,
357
- conversationId: c || "",
357
+ conversationId: l || "",
358
358
  content: u,
359
359
  role: "user",
360
360
  status: "DONE",
361
- attachments: v && v.length > 0 ? De(v) : void 0,
361
+ attachments: y && y.length > 0 ? De(y) : void 0,
362
362
  createdAt: /* @__PURE__ */ new Date()
363
363
  }, k = {
364
364
  id: `temp-assistant-${Date.now()}`,
365
- conversationId: c || "",
365
+ conversationId: l || "",
366
366
  content: "",
367
367
  role: "assistant",
368
368
  status: "IN_PROGRESS",
369
369
  createdAt: /* @__PURE__ */ new Date()
370
370
  };
371
- s((b) => [
372
- ...b,
371
+ s((x) => [
372
+ ...x,
373
373
  p,
374
374
  k
375
375
  ]);
376
376
  try {
377
- const b = await o.sendMessage(u, {
378
- conversationId: c,
379
- files: v
377
+ const x = await o.sendMessage(u, {
378
+ conversationId: l,
379
+ files: y
380
380
  });
381
- return b.conversationId && !c && i(b.conversationId), s((R) => {
382
- const _ = R.filter((C) => !C.id.startsWith("temp-")), y = {
381
+ return x.conversationId && !l && i(x.conversationId), s((R) => {
382
+ const _ = R.filter((C) => !C.id.startsWith("temp-")), b = {
383
383
  ...p,
384
384
  id: p.id.replace("temp-", "user-"),
385
- conversationId: b.conversationId
385
+ conversationId: x.conversationId
386
386
  };
387
- return _.some((C) => C.id === b.id) ? [..._, y].sort((C, A) => new Date(C.createdAt).getTime() - new Date(A.createdAt).getTime()) : [
387
+ return _.some((C) => C.id === x.id) ? [..._, b].sort((C, A) => new Date(C.createdAt).getTime() - new Date(A.createdAt).getTime()) : [
388
388
  ..._,
389
- y,
390
- b
389
+ b,
390
+ x
391
391
  ];
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;
392
+ }), x;
393
+ } catch (x) {
394
+ return w(x instanceof Error ? x : /* @__PURE__ */ new Error("Failed to send message")), d(!1), s((R) => R.filter((_) => !_.id.startsWith("temp-"))), null;
395
395
  }
396
- }, [o, c]),
396
+ }, [o, l]),
397
397
  stop: T(async () => {
398
398
  await o.stop();
399
399
  }, [o]),
400
400
  clearMessages: T(() => {
401
- s([]), i(void 0), x(null);
401
+ s([]), i(void 0), w(null);
402
402
  }, []),
403
- conversationId: c
403
+ conversationId: l
404
404
  };
405
405
  }
406
406
  var pe = {
@@ -427,7 +427,7 @@ function lt(e) {
427
427
  initialState: t?.initialState,
428
428
  bottomOffset: t?.bottomOffset,
429
429
  peekHeight: t?.peekHeight,
430
- onStateChange: (c, i) => o.current?.(c, i)
430
+ onStateChange: (l, i) => o.current?.(l, i)
431
431
  });
432
432
  }, [
433
433
  r,
@@ -435,7 +435,7 @@ function lt(e) {
435
435
  t?.initialState,
436
436
  t?.bottomOffset,
437
437
  t?.peekHeight
438
- ]), s = ye(T((c) => n?.subscribe(c) ?? (() => {
438
+ ]), s = ye(T((l) => n?.subscribe(l) ?? (() => {
439
439
  }), [n]), T(() => n?.getSnapshot() ?? pe, [n]), T(() => n?.getServerSnapshot() ?? pe, [n]));
440
440
  return {
441
441
  sheet: $(() => ({
@@ -445,9 +445,9 @@ function lt(e) {
445
445
  attrs: st(s.surface.attrs)
446
446
  }
447
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])
448
+ expand: T((l) => n?.expand(l), [n]),
449
+ collapse: T((l) => n?.collapse(l), [n]),
450
+ toggle: T((l) => n?.toggle(l), [n])
451
451
  };
452
452
  }
453
453
  var ct = /(`[^`\n]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|_[^_\n]+_)/g;
@@ -529,29 +529,29 @@ var dt = `
529
529
  }, e), /* @__PURE__ */ a("style", { children: dt })]
530
530
  }), V = typeof window > "u" ? E : Ze;
531
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);
532
+ const r = O(), t = e.client ?? r, o = W(null), n = W(), s = W(e), [l, i] = M(!1), [g, d] = M(""), [f, w] = M(!1);
533
533
  return V(() => {
534
534
  s.current = e;
535
535
  }), V(() => {
536
- if (x(!1), i(!1), s.current.onBusyChange?.(!1), !t || !o.current) return;
536
+ if (w(!1), i(!1), s.current.onBusyChange?.(!1), !t || !o.current) return;
537
537
  let m = !0;
538
538
  const u = Ke({
539
- transcribe: (v, p) => t.transcribeAudio(v, p),
540
- onText: (v) => {
541
- m && s.current.onTranscript(v);
539
+ transcribe: (y, p) => t.transcribeAudio(y, p),
540
+ onText: (y) => {
541
+ m && s.current.onTranscript(y);
542
542
  },
543
- onBusy: (v) => {
544
- m && (i(v), v && d(""), s.current.onBusyChange?.(v));
543
+ onBusy: (y) => {
544
+ m && (i(y), y && d(""), s.current.onBusyChange?.(y));
545
545
  },
546
- onError: (v) => {
547
- m && d(v);
546
+ onError: (y) => {
547
+ m && d(y);
548
548
  },
549
549
  labels: s.current.labels
550
550
  });
551
- return o.current.append(u.el), n.current = u, u.setDisabled(!!s.current.disabled), t.getConfig().then(({ permissions: v }) => {
551
+ return o.current.append(u.el), n.current = u, u.setDisabled(!!s.current.disabled), t.getConfig().then(({ permissions: y }) => {
552
552
  if (!m) return;
553
- const p = v.some((k) => k.speechToTextEnabled) && typeof MediaRecorder < "u" && !!navigator.mediaDevices?.getUserMedia;
554
- u.setEnabled(p), x(p);
553
+ const p = y.some((k) => k.speechToTextEnabled) && typeof MediaRecorder < "u" && !!navigator.mediaDevices?.getUserMedia;
554
+ u.setEnabled(p), w(p);
555
555
  }).catch(() => {
556
556
  }), () => {
557
557
  m = !1, u.destroy(), s.current.onBusyChange?.(!1), u.el.remove(), n.current = void 0;
@@ -568,7 +568,7 @@ function pt(e) {
568
568
  display: f ? "flex" : "none",
569
569
  flexDirection: "column",
570
570
  minWidth: 0,
571
- flex: c ? 1 : void 0
571
+ flex: l ? 1 : void 0
572
572
  },
573
573
  children: [/* @__PURE__ */ a("div", { ref: o }), g && /* @__PURE__ */ a("span", {
574
574
  role: "alert",
@@ -580,16 +580,16 @@ function pt(e) {
580
580
  })]
581
581
  });
582
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;
583
+ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a message...", allowFiles: n = !1, speechToText: s = !1, client: l, scopeKey: i, className: g = "" }) => {
584
+ const [d, f] = M(""), [w, m] = M([]), [u, y] = M(!1), p = W(null), k = W(null), x = !!s;
585
585
  E(() => {
586
- b || v(!1);
587
- }, [b]);
586
+ x || y(!1);
587
+ }, [x]);
588
588
  const R = T(() => {
589
- const l = k.current;
590
- if (!l) return;
589
+ const c = k.current;
590
+ if (!c) return;
591
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";
592
+ c.style.height = "auto", c.style.height = `${Math.min(c.scrollHeight + 2, S)}px`, c.style.overflowY = c.scrollHeight + 2 > S ? "auto" : "hidden";
593
593
  }, []), _ = W(!1);
594
594
  E(() => {
595
595
  _.current && !u && !t && (R(), k.current?.focus()), _.current = u;
@@ -598,30 +598,30 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
598
598
  t,
599
599
  R
600
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;
601
+ const b = T(async (c) => {
602
+ if (c.preventDefault(), t || u || !d.trim()) return;
603
+ const S = d.trim(), I = w.length > 0 ? w : void 0;
604
604
  f(""), m([]), requestAnimationFrame(R), await e(S, I) === !1 && (f((B) => B.trim() ? B : S), I && m((B) => [...I, ...B]), requestAnimationFrame(R));
605
605
  }, [
606
606
  d,
607
- x,
607
+ w,
608
608
  e,
609
609
  R,
610
610
  t,
611
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 || []);
612
+ ]), C = T((c) => {
613
+ c.key === "Enter" && !c.shiftKey && (c.preventDefault(), b(c));
614
+ }, [b]), A = T((c) => {
615
+ const S = Array.from(c.target.files || []);
616
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}`);
617
+ }, []), N = T((c) => {
618
+ m((S) => S.filter((I, B) => B !== c));
619
+ }, []), h = d.trim().length > 0, D = (c) => {
620
+ f((S) => `${S}${S && !/\s$/.test(S) ? " " : ""}${c}`);
621
621
  };
622
622
  return /* @__PURE__ */ F("form", {
623
- onSubmit: (l) => {
624
- y(l);
623
+ onSubmit: (c) => {
624
+ b(c);
625
625
  },
626
626
  className: `ago-chat-input ${g}`,
627
627
  style: {
@@ -632,14 +632,14 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
632
632
  borderTop: "1px solid #dee3e8",
633
633
  backgroundColor: "#fff"
634
634
  },
635
- children: [x.length > 0 && !u && /* @__PURE__ */ a("div", {
635
+ children: [w.length > 0 && !u && /* @__PURE__ */ a("div", {
636
636
  className: "ago-chat-input__files",
637
637
  style: {
638
638
  display: "flex",
639
639
  flexWrap: "wrap",
640
640
  gap: "6px"
641
641
  },
642
- children: x.map((l, S) => /* @__PURE__ */ F("div", {
642
+ children: w.map((c, S) => /* @__PURE__ */ F("div", {
643
643
  style: {
644
644
  display: "flex",
645
645
  alignItems: "center",
@@ -657,11 +657,11 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
657
657
  textOverflow: "ellipsis",
658
658
  whiteSpace: "nowrap"
659
659
  },
660
- children: l.name
660
+ children: c.name
661
661
  }), /* @__PURE__ */ a("button", {
662
662
  type: "button",
663
663
  onClick: () => N(S),
664
- "aria-label": `Remove ${l.name}`,
664
+ "aria-label": `Remove ${c.name}`,
665
665
  style: {
666
666
  flexShrink: 0,
667
667
  width: "44px",
@@ -721,8 +721,8 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
721
721
  ref: k,
722
722
  className: "ago-chat-input__field",
723
723
  value: d,
724
- onChange: (l) => {
725
- f(l.target.value), R();
724
+ onChange: (c) => {
725
+ f(c.target.value), R();
726
726
  },
727
727
  onKeyDown: C,
728
728
  placeholder: o,
@@ -747,20 +747,20 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
747
747
  backgroundColor: "#f8f8f8",
748
748
  transition: "border-color 0.15s"
749
749
  },
750
- onFocus: (l) => {
751
- l.currentTarget.style.borderColor = "#1b5fc4";
750
+ onFocus: (c) => {
751
+ c.currentTarget.style.borderColor = "#1b5fc4";
752
752
  },
753
- onBlur: (l) => {
754
- l.currentTarget.style.borderColor = "#dee3e8";
753
+ onBlur: (c) => {
754
+ c.currentTarget.style.borderColor = "#dee3e8";
755
755
  }
756
756
  }),
757
757
  s && /* @__PURE__ */ a(pt, {
758
- client: c,
758
+ client: l,
759
759
  disabled: t,
760
760
  scopeKey: i,
761
761
  labels: typeof s == "object" ? s.labels : void 0,
762
762
  onTranscript: D,
763
- onBusyChange: v
763
+ onBusyChange: y
764
764
  }),
765
765
  !u && (t && r ? /* @__PURE__ */ a("button", {
766
766
  type: "button",
@@ -1126,7 +1126,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1126
1126
  40% { opacity: 1; transform: scale(1); }
1127
1127
  }
1128
1128
  ` })]
1129
- }), Mt = ({ message: e, className: r = "", showAgentName: t = !1, isLast: o = !1, onFollowUpClick: n, showStreamingDots: s = !0, feedback: c }) => {
1129
+ }), Mt = ({ message: e, className: r = "", showAgentName: t = !1, isLast: o = !1, onFollowUpClick: n, showStreamingDots: s = !0, feedback: l }) => {
1130
1130
  const i = e.role === "user", g = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
1131
1131
  return /* @__PURE__ */ F("div", {
1132
1132
  className: `ago-message ago-message--${e.role} ${r}`,
@@ -1195,7 +1195,7 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1195
1195
  },
1196
1196
  children: e.content ? /* @__PURE__ */ a(Rt, { content: e.content }) : g && s && /* @__PURE__ */ a(Se, {})
1197
1197
  }),
1198
- !i && c,
1198
+ !i && l,
1199
1199
  o && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ a("div", {
1200
1200
  className: "ago-message__followups",
1201
1201
  style: {
@@ -1220,11 +1220,11 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1220
1220
  cursor: n ? "pointer" : "default",
1221
1221
  transition: "border-color 0.15s"
1222
1222
  },
1223
- onMouseEnter: (x) => {
1224
- x.currentTarget.style.borderColor = "#1b5fc4";
1223
+ onMouseEnter: (w) => {
1224
+ w.currentTarget.style.borderColor = "#1b5fc4";
1225
1225
  },
1226
- onMouseLeave: (x) => {
1227
- x.currentTarget.style.borderColor = "#dee3e8";
1226
+ onMouseLeave: (w) => {
1227
+ w.currentTarget.style.borderColor = "#dee3e8";
1228
1228
  },
1229
1229
  children: d
1230
1230
  }, f))
@@ -1235,41 +1235,41 @@ var ft = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a mes
1235
1235
  function Ft({ client: e } = {}) {
1236
1236
  const r = O(), t = e || r;
1237
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) => {
1238
+ const [o, n] = M({}), [s, l] = M(!1), [i, g] = M(null), d = W(/* @__PURE__ */ new Map()), f = (m) => {
1239
1239
  const u = (d.current.get(m) ?? 0) + 1;
1240
1240
  return d.current.set(m, u), u;
1241
- }, x = (m, u) => d.current.get(m) === u;
1241
+ }, w = (m, u) => d.current.get(m) === u;
1242
1242
  return {
1243
1243
  ratings: o,
1244
- submitFeedback: T(async (m, u, v) => {
1244
+ submitFeedback: T(async (m, u, y) => {
1245
1245
  const p = f(m);
1246
- c(!0), g(null);
1246
+ l(!0), g(null);
1247
1247
  try {
1248
- await t.submitFeedback(m, u, v), x(m, p) && n((k) => ({
1248
+ await t.submitFeedback(m, u, y), w(m, p) && n((k) => ({
1249
1249
  ...k,
1250
1250
  [m]: u
1251
1251
  }));
1252
1252
  } catch (k) {
1253
- const b = k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to submit feedback");
1254
- throw g(b), b;
1253
+ const x = k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to submit feedback");
1254
+ throw g(x), x;
1255
1255
  } finally {
1256
- c(!1);
1256
+ l(!1);
1257
1257
  }
1258
1258
  }, [t]),
1259
- submitConversationFeedback: T(async (m, u, v) => {
1259
+ submitConversationFeedback: T(async (m, u, y) => {
1260
1260
  const p = f(m);
1261
- c(!0), g(null);
1261
+ l(!0), g(null);
1262
1262
  try {
1263
- const k = await t.submitConversationFeedback(m, u, v);
1264
- return x(m, p) && n((b) => ({
1265
- ...b,
1263
+ const k = await t.submitConversationFeedback(m, u, y);
1264
+ return w(m, p) && n((x) => ({
1265
+ ...x,
1266
1266
  [k]: u
1267
1267
  })), k;
1268
1268
  } catch (k) {
1269
- const b = k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to submit feedback");
1270
- throw g(b), b;
1269
+ const x = k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to submit feedback");
1270
+ throw g(x), x;
1271
1271
  } finally {
1272
- c(!1);
1272
+ l(!1);
1273
1273
  }
1274
1274
  }, [t]),
1275
1275
  isSubmitting: s,
@@ -1302,7 +1302,7 @@ var fe = {
1302
1302
  background: "transparent",
1303
1303
  cursor: "pointer",
1304
1304
  lineHeight: 1
1305
- }, Dt = ({ messageId: e, client: r, askWhy: t = !0, labels: o, onSubmit: n, onError: s, className: c = "" }) => {
1305
+ }, Dt = ({ messageId: e, client: r, askWhy: t = !0, labels: o, onSubmit: n, onError: s, className: l = "" }) => {
1306
1306
  const i = {
1307
1307
  ...fe,
1308
1308
  ...o,
@@ -1310,31 +1310,31 @@ var fe = {
1310
1310
  ...fe.reasons,
1311
1311
  ...o?.reasons
1312
1312
  }
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) => {
1313
+ }, { ratings: g, submitFeedback: d } = Ft({ client: r }), f = g[e], [w, m] = M(!1), [u, y] = M([]), [p, k] = M(""), [x, R] = M(!1), [_, b] = M(!1), C = async (c, S) => {
1314
1314
  try {
1315
- return await d(e, l, S), n?.({
1315
+ return await d(e, c, S), n?.({
1316
1316
  messageId: e,
1317
- rating: l,
1317
+ rating: c,
1318
1318
  reasons: S?.reasons ?? [],
1319
1319
  comment: S?.comment || void 0
1320
1320
  }), !0;
1321
1321
  } catch (I) {
1322
1322
  return s?.(I instanceof Error ? I : new Error(String(I))), !1;
1323
1323
  }
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]);
1324
+ }, A = (c) => {
1325
+ C(c), m(c === "negative" && t && !x);
1326
+ }, N = (c) => {
1327
+ y((S) => S.includes(c) ? S.filter((I) => I !== c) : [...S, c]);
1328
1328
  }, h = u.length > 0 || p.trim().length > 0, D = () => {
1329
- !h || _ || (y(!0), C(f ?? "negative", {
1329
+ !h || _ || (b(!0), C(f ?? "negative", {
1330
1330
  reasons: u,
1331
1331
  comment: p.trim()
1332
- }).then((l) => {
1333
- y(!1), l && (R(!0), m(!1));
1332
+ }).then((c) => {
1333
+ b(!1), c && (R(!0), m(!1));
1334
1334
  }));
1335
1335
  };
1336
1336
  return /* @__PURE__ */ F("div", {
1337
- className: `ago-feedback ${c}`,
1337
+ className: `ago-feedback ${l}`,
1338
1338
  style: {
1339
1339
  marginTop: "6px",
1340
1340
  width: "100%",
@@ -1360,7 +1360,7 @@ var fe = {
1360
1360
  onClick: () => A("negative")
1361
1361
  })]
1362
1362
  }),
1363
- b && /* @__PURE__ */ a("div", {
1363
+ x && /* @__PURE__ */ a("div", {
1364
1364
  className: "ago-feedback__thanks",
1365
1365
  role: "status",
1366
1366
  style: {
@@ -1370,7 +1370,7 @@ var fe = {
1370
1370
  },
1371
1371
  children: i.thanks
1372
1372
  }),
1373
- x && !b && /* @__PURE__ */ F("div", {
1373
+ w && !x && /* @__PURE__ */ F("div", {
1374
1374
  className: "ago-feedback__panel",
1375
1375
  role: "group",
1376
1376
  "aria-label": i.whatWentWrong,
@@ -1399,13 +1399,13 @@ var fe = {
1399
1399
  gap: "6px",
1400
1400
  marginBottom: "8px"
1401
1401
  },
1402
- children: Oe.map((l) => {
1403
- const S = u.includes(l);
1402
+ children: Oe.map((c) => {
1403
+ const S = u.includes(c);
1404
1404
  return /* @__PURE__ */ a("button", {
1405
1405
  type: "button",
1406
1406
  className: "ago-feedback__reason",
1407
1407
  "aria-pressed": S,
1408
- onClick: () => N(l),
1408
+ onClick: () => N(c),
1409
1409
  style: {
1410
1410
  minHeight: "44px",
1411
1411
  padding: "4px 12px",
@@ -1417,8 +1417,8 @@ var fe = {
1417
1417
  color: S ? "#1b5fc4" : "#30373e",
1418
1418
  cursor: "pointer"
1419
1419
  },
1420
- children: i.reasons[l]
1421
- }, l);
1420
+ children: i.reasons[c]
1421
+ }, c);
1422
1422
  })
1423
1423
  }),
1424
1424
  /* @__PURE__ */ a("textarea", {
@@ -1427,7 +1427,7 @@ var fe = {
1427
1427
  value: p,
1428
1428
  placeholder: i.commentPlaceholder,
1429
1429
  "aria-label": i.commentPlaceholder,
1430
- onChange: (l) => k(l.target.value),
1430
+ onChange: (c) => k(c.target.value),
1431
1431
  style: {
1432
1432
  width: "100%",
1433
1433
  boxSizing: "border-box",
@@ -1495,54 +1495,54 @@ var fe = {
1495
1495
  strokeLinejoin: "round"
1496
1496
  })]
1497
1497
  })
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({
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: l = !1, speechToText: i = !1, allowStop: g = !0, height: d = 500, logoUrl: f, showAgentName: w = !1, forms: m, feedback: u = !1, onFollowUpClick: y, className: p = "", onMessageSent: k, onMessageReceived: x, sheet: R = !1, thinkingLabel: _ = "Thinking...", functionLabels: b, showReasoning: C = !0 }, A) {
1499
+ const N = W(null), h = W(!0), [D, c] = 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({
1500
1500
  client: r,
1501
1501
  conversationId: t
1502
1502
  });
1503
1503
  E(() => {
1504
1504
  if (!q || !m || m.length === 0) return;
1505
- let w = !1;
1505
+ let v = !1;
1506
1506
  const L = [];
1507
1507
  return Promise.all(m.map((z) => z.schema != null ? Promise.resolve(xe(z)) : he(q, z))).then((z) => {
1508
- if (!w)
1508
+ if (!v)
1509
1509
  for (const H of z) L.push(H.install(q));
1510
1510
  }).catch(() => {
1511
1511
  }), () => {
1512
- w = !0, L.forEach((z) => z());
1512
+ v = !0, L.forEach((z) => z());
1513
1513
  };
1514
- }, [q, m ? JSON.stringify(m.map((w) => [
1515
- w.name,
1516
- w.schema ?? null,
1517
- w.submit ?? !1,
1518
- w.description ?? null
1514
+ }, [q, m ? JSON.stringify(m.map((v) => [
1515
+ v.name,
1516
+ v.schema ?? null,
1517
+ v.submit ?? !1,
1518
+ v.description ?? null
1519
1519
  ])) : ""]), E(() => {
1520
- const w = N.current;
1521
- !w || !h.current || (w.scrollTop = w.scrollHeight);
1520
+ const v = N.current;
1521
+ !v || !h.current || (v.scrollTop = v.scrollHeight);
1522
1522
  }, [P]);
1523
1523
  const Ee = () => {
1524
- const w = N.current;
1525
- w && (h.current = !0, l(!0), w.scrollTop = w.scrollHeight);
1524
+ const v = N.current;
1525
+ v && (h.current = !0, c(!0), v.scrollTop = v.scrollHeight);
1526
1526
  };
1527
1527
  E(() => {
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
1528
+ const v = P[P.length - 1];
1529
+ v && v.role === "assistant" && v.status === "DONE" && x && x({
1530
+ id: v.id,
1531
+ content: v.content
1532
1532
  });
1533
- }, [P, b]), E(() => {
1533
+ }, [P, x]), E(() => {
1534
1534
  ee(!!te);
1535
1535
  }, [P.length]), E(() => {
1536
- const w = S.current;
1537
- if (!I.compact || !w) return;
1536
+ const v = S.current;
1537
+ if (!I.compact || !v) return;
1538
1538
  const L = document.documentElement;
1539
1539
  if (I.state !== "peek") return;
1540
1540
  const z = () => {
1541
- L.style.setProperty("--ago-sheet-height", `${Math.round(w.getBoundingClientRect().height)}px`);
1541
+ L.style.setProperty("--ago-sheet-height", `${Math.round(v.getBoundingClientRect().height)}px`);
1542
1542
  };
1543
1543
  z();
1544
1544
  const H = typeof ResizeObserver == "function" ? new ResizeObserver(z) : null;
1545
- return H?.observe(w), () => H?.disconnect();
1545
+ return H?.observe(v), () => H?.disconnect();
1546
1546
  }, [I.compact, I.state]), E(() => {
1547
1547
  I.compact || document.documentElement.style.removeProperty("--ago-sheet-height");
1548
1548
  }, [I.compact]), E(() => () => {
@@ -1559,8 +1559,8 @@ var fe = {
1559
1559
  I.state
1560
1560
  ]), E(() => {
1561
1561
  if (!I.isModal) return;
1562
- const w = /* @__PURE__ */ Symbol("ago-react-sheet");
1563
- Ue(w);
1562
+ const v = /* @__PURE__ */ Symbol("ago-react-sheet");
1563
+ Ue(v);
1564
1564
  const L = (z) => {
1565
1565
  if (z.key === "Escape") {
1566
1566
  G("user");
@@ -1578,18 +1578,18 @@ var fe = {
1578
1578
  z.shiftKey && (Z === le || !H.contains(Z)) ? (z.preventDefault(), ce.focus()) : !z.shiftKey && (Z === ce || !H.contains(Z)) && (z.preventDefault(), le.focus());
1579
1579
  };
1580
1580
  return document.addEventListener("keydown", L), S.current?.focus({ preventScroll: !0 }), () => {
1581
- document.removeEventListener("keydown", L), qe(w);
1581
+ document.removeEventListener("keydown", L), qe(v);
1582
1582
  };
1583
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({
1584
+ const ae = async (v, L) => (h.current = !0, c(!0), k?.(v), await Ie(v, L) !== null), j = P[P.length - 1], X = _e && j?.role === "assistant" && (j.status === "IN_PROGRESS" || j.status === "WAITING_CLIENT"), Te = T((v) => {
1585
+ const L = v.functionName;
1586
+ if (!(!b || !L))
1587
+ return typeof b == "function" ? b(L, v.arguments ?? {}) : b[L];
1588
+ }, [b]), { items: Me } = at({
1589
1589
  client: q ?? void 0,
1590
1590
  labelFor: Te,
1591
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));
1592
+ }), ie = Me.filter((v) => j?.id !== void 0 && v.messageId === j.id), J = b === !1 ? void 0 : ie[ie.length - 1]?.label, se = !!(X && J), Fe = y === !1 ? void 0 : y ?? ((v) => ae(v));
1593
1593
  return /* @__PURE__ */ F("div", {
1594
1594
  ref: S,
1595
1595
  className: `ago-chat-widget ${p}`,
@@ -1785,9 +1785,9 @@ var fe = {
1785
1785
  children: [/* @__PURE__ */ F("div", {
1786
1786
  ref: N,
1787
1787
  className: "ago-chat-widget__messages",
1788
- onScroll: (w) => {
1789
- const L = w.currentTarget, z = L.scrollHeight - L.scrollTop - L.clientHeight <= 48;
1790
- h.current = z, l(z);
1788
+ onScroll: (v) => {
1789
+ const L = v.currentTarget, z = L.scrollHeight - L.scrollTop - L.clientHeight <= 48;
1790
+ h.current = z, c(z);
1791
1791
  },
1792
1792
  role: "log",
1793
1793
  "aria-live": "polite",
@@ -1811,18 +1811,18 @@ var fe = {
1811
1811
  lineHeight: "1.5"
1812
1812
  },
1813
1813
  children: n
1814
- }) : P.map((w, L) => /* @__PURE__ */ a(Mt, {
1815
- message: w,
1816
- showAgentName: x,
1814
+ }) : P.map((v, L) => /* @__PURE__ */ a(Mt, {
1815
+ message: v,
1816
+ showAgentName: w,
1817
1817
  isLast: L === P.length - 1,
1818
1818
  onFollowUpClick: Fe,
1819
1819
  showStreamingDots: !se,
1820
- feedback: u && w.role === "assistant" && w.status === "DONE" && w.content ? /* @__PURE__ */ a(Dt, {
1821
- messageId: w.id,
1820
+ feedback: u && v.role === "assistant" && v.status === "DONE" && v.content ? /* @__PURE__ */ a(Dt, {
1821
+ messageId: v.id,
1822
1822
  client: r,
1823
1823
  ...u === !0 ? {} : u
1824
1824
  }) : void 0
1825
- }, w.id)),
1825
+ }, v.id)),
1826
1826
  se && /* @__PURE__ */ a(ut, { label: J ?? "" }),
1827
1827
  oe && /* @__PURE__ */ a("div", {
1828
1828
  role: "alert",
@@ -1883,7 +1883,7 @@ var fe = {
1883
1883
  } : void 0,
1884
1884
  disabled: X,
1885
1885
  placeholder: s,
1886
- allowFiles: c,
1886
+ allowFiles: l,
1887
1887
  speechToText: i,
1888
1888
  client: q ?? void 0,
1889
1889
  scopeKey: `${t ?? P[0]?.conversationId ?? ""}:${I.state}`
@@ -1896,8 +1896,8 @@ function zt(e = {}) {
1896
1896
  if (!t) throw new Q("useProactiveNudge: no AgoClient. Pass one via options.client or wrap your tree with <AgoProvider>.", "proactive_missing_client");
1897
1897
  const [o, n] = M(null), s = W(o);
1898
1898
  s.current = o;
1899
- const c = W(e.onExpand);
1900
- return c.current = e.onExpand, E(() => {
1899
+ const l = W(e.onExpand);
1900
+ return l.current = e.onExpand, E(() => {
1901
1901
  const i = (d) => {
1902
1902
  n(d), t.proactive?.shown(d);
1903
1903
  }, g = ({ nudge: d }) => {
@@ -1910,7 +1910,7 @@ function zt(e = {}) {
1910
1910
  nudge: o,
1911
1911
  accept: T(async () => {
1912
1912
  const i = s.current;
1913
- i && (n(null), await t.proactive?.accept(i), (i.source === "agent" || i.goal) && c.current?.(i));
1913
+ i && (n(null), await t.proactive?.accept(i), (i.source === "agent" || i.goal) && l.current?.(i));
1914
1914
  }, [t]),
1915
1915
  dismiss: T(() => {
1916
1916
  const i = s.current;
@@ -1919,20 +1919,20 @@ function zt(e = {}) {
1919
1919
  };
1920
1920
  }
1921
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({
1922
+ const { nudge: l, accept: i, dismiss: g } = zt({
1923
1923
  client: e,
1924
1924
  onExpand: r
1925
1925
  });
1926
1926
  if (E(() => {
1927
- if (!c || !t) return;
1927
+ if (!l || !t) return;
1928
1928
  const f = setTimeout(() => g(), t);
1929
1929
  return () => clearTimeout(f);
1930
1930
  }, [
1931
- c,
1931
+ l,
1932
1932
  t,
1933
1933
  g
1934
- ]), !c) return null;
1935
- const d = c.source === "agent" || !!c.goal;
1934
+ ]), !l) return null;
1935
+ const d = l.source === "agent" || !!l.goal;
1936
1936
  return /* @__PURE__ */ F("div", {
1937
1937
  className: `ago-nudge ${s}`,
1938
1938
  role: "status",
@@ -1977,9 +1977,9 @@ var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
1977
1977
  /* @__PURE__ */ a("div", {
1978
1978
  className: "ago-nudge__message",
1979
1979
  style: { paddingRight: "16px" },
1980
- children: c.message
1980
+ children: l.message
1981
1981
  }),
1982
- (c.action || d) && /* @__PURE__ */ F("div", {
1982
+ (l.action || d) && /* @__PURE__ */ F("div", {
1983
1983
  className: "ago-nudge__actions",
1984
1984
  style: {
1985
1985
  display: "flex",
@@ -1987,7 +1987,7 @@ var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
1987
1987
  marginTop: "10px",
1988
1988
  flexWrap: "wrap"
1989
1989
  },
1990
- children: [c.action && /* @__PURE__ */ a("button", {
1990
+ children: [l.action && /* @__PURE__ */ a("button", {
1991
1991
  type: "button",
1992
1992
  className: "ago-nudge__action",
1993
1993
  onClick: () => {
@@ -2003,7 +2003,7 @@ var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
2003
2003
  fontWeight: 600,
2004
2004
  cursor: "pointer"
2005
2005
  },
2006
- children: c.action.label
2006
+ children: l.action.label
2007
2007
  }), d && /* @__PURE__ */ a("button", {
2008
2008
  type: "button",
2009
2009
  className: "ago-nudge__expand",
@@ -2029,37 +2029,37 @@ var tn = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right",
2029
2029
  function Lt({ client: e, autoLoad: r = !0 } = {}) {
2030
2030
  const t = O(), o = e || t;
2031
2031
  if (!o) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
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);
2032
+ const [n, s] = M([]), [l, i] = M(null), [g, d] = M(!1), [f, w] = M(null), m = T(async () => {
2033
+ d(!0), w(null);
2034
2034
  try {
2035
2035
  const { data: p } = await o.getConversations();
2036
2036
  s(p);
2037
2037
  } catch (p) {
2038
- x(p instanceof Error ? p : /* @__PURE__ */ new Error("Failed to load conversations"));
2038
+ w(p instanceof Error ? p : /* @__PURE__ */ new Error("Failed to load conversations"));
2039
2039
  } finally {
2040
2040
  d(!1);
2041
2041
  }
2042
2042
  }, [o]), u = T(async (p) => {
2043
- d(!0), x(null);
2043
+ d(!0), w(null);
2044
2044
  try {
2045
2045
  i(await o.getConversation(p));
2046
2046
  } catch (k) {
2047
- x(k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to load conversation"));
2047
+ w(k instanceof Error ? k : /* @__PURE__ */ new Error("Failed to load conversation"));
2048
2048
  } finally {
2049
2049
  d(!1);
2050
2050
  }
2051
- }, [o]), v = T(() => {
2051
+ }, [o]), y = T(() => {
2052
2052
  i(null);
2053
2053
  }, []);
2054
2054
  return E(() => {
2055
2055
  r && m();
2056
2056
  }, [r, m]), {
2057
2057
  conversations: n,
2058
- currentConversation: c,
2058
+ currentConversation: l,
2059
2059
  isLoading: g,
2060
2060
  error: f,
2061
2061
  selectConversation: u,
2062
- startNewConversation: v,
2062
+ startNewConversation: y,
2063
2063
  refreshConversations: m
2064
2064
  };
2065
2065
  }
@@ -2090,13 +2090,13 @@ function nn(e = {}) {
2090
2090
  };
2091
2091
  }
2092
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" ? {
2093
+ const t = U(), { name: o, description: n, parameters: s, handler: l, maxResultBytes: i, requiresApproval: g, webmcp: d } = typeof e == "string" ? {
2094
2094
  name: e,
2095
2095
  ...r
2096
- } : e, f = W(c);
2097
- f.current = c, E(() => {
2098
- const x = (m) => f.current(m);
2099
- return t.registerFunction(o, x, {
2096
+ } : e, f = W(l);
2097
+ f.current = l, E(() => {
2098
+ const w = (m) => f.current(m);
2099
+ return t.registerFunction(o, w, {
2100
2100
  description: n,
2101
2101
  parameters: s,
2102
2102
  maxResultBytes: i,
@@ -2109,40 +2109,46 @@ function rn(e, r) {
2109
2109
  t,
2110
2110
  o,
2111
2111
  n,
2112
- s,
2112
+ JSON.stringify(s),
2113
2113
  i,
2114
2114
  g,
2115
2115
  JSON.stringify(d ?? null)
2116
2116
  ]);
2117
2117
  }
2118
- function on(e, r) {
2119
- const t = U(), o = W(e);
2120
- o.current = e, E(() => (t.registerNavigationFunction((n) => o.current(n), r), () => {
2121
- t.unregisterNavigationFunction();
2122
- }), [t, r]);
2118
+ function on(e, r, t) {
2119
+ const o = U(), n = W(e);
2120
+ n.current = e;
2121
+ const s = t?.catalogue;
2122
+ E(() => (o.registerNavigationFunction((l) => n.current(l), r, { catalogue: s === "onDemand" ? "onDemand" : "inline" }), () => {
2123
+ o.unregisterNavigationFunction();
2124
+ }), [
2125
+ o,
2126
+ r,
2127
+ s
2128
+ ]);
2123
2129
  }
2124
2130
  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);
2131
+ const t = U(), o = r?.functionName ?? "setPageState", n = r?.requiresApproval, s = r?.data !== void 0, l = r?.data?.description, i = r?.data?.maxResultBytes, g = r?.settleTimeoutMs, d = W(e);
2126
2132
  d.current = e;
2127
2133
  const f = W(r);
2128
2134
  f.current = r, E(() => {
2129
- const x = d.current.map((u) => {
2130
- const v = () => d.current.find((p) => p.name === u.name) ?? u;
2135
+ const w = d.current.map((u) => {
2136
+ const y = () => d.current.find((p) => p.name === u.name) ?? u;
2131
2137
  return {
2132
2138
  name: u.name,
2133
2139
  description: u.description,
2134
2140
  schema: u.schema,
2135
2141
  clearable: u.clearable,
2136
- get: u.get ? () => v().get?.() : void 0,
2137
- set: (p) => v().set(p)
2142
+ get: u.get ? () => y().get?.() : void 0,
2143
+ set: (p) => y().set(p)
2138
2144
  };
2139
2145
  }), m = s ? {
2140
- description: c ?? "What the page is currently showing.",
2146
+ description: l ?? "What the page is currently showing.",
2141
2147
  maxResultBytes: i,
2142
2148
  get: () => f.current?.data?.get(),
2143
2149
  isLoading: () => f.current?.data?.isLoading?.() ?? !1
2144
2150
  } : void 0;
2145
- return t.registerPageStateFunction(x, {
2151
+ return t.registerPageStateFunction(w, {
2146
2152
  functionName: o,
2147
2153
  requiresApproval: n,
2148
2154
  data: m,
@@ -2155,14 +2161,14 @@ function an(e, r) {
2155
2161
  o,
2156
2162
  n,
2157
2163
  s,
2158
- c,
2164
+ l,
2159
2165
  i,
2160
2166
  g,
2161
- JSON.stringify(e.map((x) => ({
2162
- name: x.name,
2163
- description: x.description,
2164
- schema: x.schema,
2165
- clearable: x.clearable
2167
+ JSON.stringify(e.map((w) => ({
2168
+ name: w.name,
2169
+ description: w.description,
2170
+ schema: w.schema,
2171
+ clearable: w.clearable
2166
2172
  })))
2167
2173
  ]);
2168
2174
  }
@@ -2179,20 +2185,20 @@ function ln(e = {}) {
2179
2185
  const i = () => n(t.getRecentActivity());
2180
2186
  return t.on("activity:recorded", i), () => t.off("activity:recorded", i);
2181
2187
  }, [t]);
2182
- const s = T((i) => t.recordActivity(i), [t]), c = T(() => {
2188
+ const s = T((i) => t.recordActivity(i), [t]), l = T(() => {
2183
2189
  t.clearActivity(), n([]);
2184
2190
  }, [t]);
2185
2191
  return {
2186
2192
  entries: o,
2187
2193
  latest: o.length > 0 ? o[o.length - 1] : void 0,
2188
2194
  record: s,
2189
- clear: c
2195
+ clear: l
2190
2196
  };
2191
2197
  }
2192
2198
  function cn(e, r) {
2193
2199
  const t = U(), o = Xe(), n = r ?? o, s = W(e);
2194
2200
  s.current = e;
2195
- const c = typeof e == "function";
2201
+ const l = typeof e == "function";
2196
2202
  E(() => {
2197
2203
  if (typeof s.current == "function") {
2198
2204
  const i = () => s.current();
@@ -2206,8 +2212,8 @@ function cn(e, r) {
2206
2212
  }, [
2207
2213
  t,
2208
2214
  n,
2209
- c,
2210
- c ? "" : JSON.stringify(e)
2215
+ l,
2216
+ l ? "" : JSON.stringify(e)
2211
2217
  ]);
2212
2218
  }
2213
2219
  function Pt(e) {
@@ -2218,12 +2224,12 @@ var me = {
2218
2224
  complete: !1
2219
2225
  };
2220
2226
  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, [
2227
+ 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", l = JSON.stringify(e.initialValues ?? null), i = $(() => t ? xe(e) : null, [
2222
2228
  t,
2223
2229
  e.name,
2224
2230
  o,
2225
2231
  s,
2226
- c,
2232
+ l,
2227
2233
  e.autoSubmit
2228
2234
  ]), [g, d] = M({
2229
2235
  collector: null,
@@ -2257,10 +2263,10 @@ function dn(e) {
2257
2263
  t,
2258
2264
  e.name,
2259
2265
  s,
2260
- c,
2266
+ l,
2261
2267
  e.autoSubmit
2262
2268
  ]);
2263
- const f = t ? i : g.collector, x = t ? !1 : g.loading, m = t ? null : g.error;
2269
+ const f = t ? i : g.collector, w = t ? !1 : g.loading, m = t ? null : g.error;
2264
2270
  E(() => {
2265
2271
  if (f)
2266
2272
  return f.install(r);
@@ -2268,10 +2274,10 @@ function dn(e) {
2268
2274
  const u = $(() => Le({
2269
2275
  values: e.initialValues ?? {},
2270
2276
  submitted: !1
2271
- }), [c]), v = Pt(f?.store ?? u), p = $(() => f?.getStatus() ?? me, [v, f]), k = $(() => ({
2272
- ...v,
2277
+ }), [l]), y = Pt(f?.store ?? u), p = $(() => f?.getStatus() ?? me, [y, f]), k = $(() => ({
2278
+ ...y,
2273
2279
  ...p
2274
- }), [v, p]), b = $(() => ({
2280
+ }), [y, p]), x = $(() => ({
2275
2281
  name: e.name,
2276
2282
  store: u,
2277
2283
  functions: [],
@@ -2302,9 +2308,9 @@ function dn(e) {
2302
2308
  getStatus: () => me
2303
2309
  }), [e.name, u]);
2304
2310
  return {
2305
- ...f ?? b,
2311
+ ...f ?? x,
2306
2312
  state: k,
2307
- loading: x,
2313
+ loading: w,
2308
2314
  error: m
2309
2315
  };
2310
2316
  }