@useago/sdk 1.4.3 → 1.4.4

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.
package/dist/react.d.cts CHANGED
@@ -194,7 +194,7 @@ declare class AgoClient {
194
194
  * ```
195
195
  */
196
196
  registerFunction(definition: ClientFunctionDefinition): void;
197
- registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
197
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: ClientFunctionRegisterOptions): void;
198
198
  /**
199
199
  * Short alias for `registerFunction`. Also accepts an array of definitions.
200
200
  *
@@ -503,6 +503,14 @@ export declare interface AgoConfig {
503
503
  * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
504
504
  */
505
505
  clientFunctionsMode?: ClientFunctionsMode;
506
+ /**
507
+ * Max serialized size (bytes) of a client function result before the SDK
508
+ * replaces it with a flagged, truncated preview. Everything a handler
509
+ * returns is sent into the LLM context, so this caps runaway payloads
510
+ * (raw API responses, full tables). Default `50000`. Override per function
511
+ * with `maxResultBytes` on its definition; `Infinity` disables the guard.
512
+ */
513
+ maxFunctionResultBytes?: number;
506
514
  }
507
515
 
508
516
  /**
@@ -714,6 +722,12 @@ declare interface ClientFunctionDefinition {
714
722
  description: string;
715
723
  parameters: ClientFunctionSchema["parameters"];
716
724
  handler: ClientFunctionHandler;
725
+ /**
726
+ * Max serialized result size in bytes before the SDK truncates it to a
727
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
728
+ * `Infinity` disables the guard for this function.
729
+ */
730
+ maxResultBytes?: number;
717
731
  }
718
732
 
719
733
  /**
@@ -728,6 +742,20 @@ declare interface ClientFunctionInvocation {
728
742
  conversationId: string;
729
743
  }
730
744
 
745
+ /**
746
+ * Schema-plus-settings object accepted when registering a function: the schema
747
+ * (minus `name`) and SDK-side options that are NOT sent to the backend.
748
+ */
749
+ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & {
750
+ /**
751
+ * Max serialized result size in bytes before the SDK truncates it to a
752
+ * flagged preview. Overrides the client-level default
753
+ * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
754
+ * disables the guard for this function.
755
+ */
756
+ maxResultBytes?: number;
757
+ };
758
+
731
759
  /**
732
760
  * Schema for a client-side function that AGO can call
733
761
  */
@@ -1399,6 +1427,12 @@ export declare interface UseAgoFunctionOptions {
1399
1427
  required?: string[];
1400
1428
  };
1401
1429
  handler: ClientFunctionHandler;
1430
+ /**
1431
+ * Max serialized result size in bytes before the SDK truncates it to a
1432
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
1433
+ * `Infinity` disables the guard for this function.
1434
+ */
1435
+ maxResultBytes?: number;
1402
1436
  }
1403
1437
 
1404
1438
  /**
package/dist/react.d.ts CHANGED
@@ -194,7 +194,7 @@ declare class AgoClient {
194
194
  * ```
195
195
  */
196
196
  registerFunction(definition: ClientFunctionDefinition): void;
197
- registerFunction(name: string, handler: ClientFunctionHandler, schema: Omit<ClientFunctionSchema, "name">): void;
197
+ registerFunction(name: string, handler: ClientFunctionHandler, schema: ClientFunctionRegisterOptions): void;
198
198
  /**
199
199
  * Short alias for `registerFunction`. Also accepts an array of definitions.
200
200
  *
@@ -503,6 +503,14 @@ export declare interface AgoConfig {
503
503
  * Older backends ignore the flag, so `"pause"` degrades to legacy behavior.
504
504
  */
505
505
  clientFunctionsMode?: ClientFunctionsMode;
506
+ /**
507
+ * Max serialized size (bytes) of a client function result before the SDK
508
+ * replaces it with a flagged, truncated preview. Everything a handler
509
+ * returns is sent into the LLM context, so this caps runaway payloads
510
+ * (raw API responses, full tables). Default `50000`. Override per function
511
+ * with `maxResultBytes` on its definition; `Infinity` disables the guard.
512
+ */
513
+ maxFunctionResultBytes?: number;
506
514
  }
507
515
 
508
516
  /**
@@ -714,6 +722,12 @@ declare interface ClientFunctionDefinition {
714
722
  description: string;
715
723
  parameters: ClientFunctionSchema["parameters"];
716
724
  handler: ClientFunctionHandler;
725
+ /**
726
+ * Max serialized result size in bytes before the SDK truncates it to a
727
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
728
+ * `Infinity` disables the guard for this function.
729
+ */
730
+ maxResultBytes?: number;
717
731
  }
718
732
 
719
733
  /**
@@ -728,6 +742,20 @@ declare interface ClientFunctionInvocation {
728
742
  conversationId: string;
729
743
  }
730
744
 
745
+ /**
746
+ * Schema-plus-settings object accepted when registering a function: the schema
747
+ * (minus `name`) and SDK-side options that are NOT sent to the backend.
748
+ */
749
+ declare type ClientFunctionRegisterOptions = Omit<ClientFunctionSchema, "name"> & {
750
+ /**
751
+ * Max serialized result size in bytes before the SDK truncates it to a
752
+ * flagged preview. Overrides the client-level default
753
+ * (`AgoConfig.maxFunctionResultBytes`, 50 000 by default). `Infinity`
754
+ * disables the guard for this function.
755
+ */
756
+ maxResultBytes?: number;
757
+ };
758
+
731
759
  /**
732
760
  * Schema for a client-side function that AGO can call
733
761
  */
@@ -1399,6 +1427,12 @@ export declare interface UseAgoFunctionOptions {
1399
1427
  required?: string[];
1400
1428
  };
1401
1429
  handler: ClientFunctionHandler;
1430
+ /**
1431
+ * Max serialized result size in bytes before the SDK truncates it to a
1432
+ * flagged preview (default: `AgoConfig.maxFunctionResultBytes`, 50 000).
1433
+ * `Infinity` disables the guard for this function.
1434
+ */
1435
+ maxResultBytes?: number;
1402
1436
  }
1403
1437
 
1404
1438
  /**
package/dist/react.js CHANGED
@@ -1,8 +1,8 @@
1
- import { a as J, i as j, o as V, s as Y, t as X } from "./AgoClient-S8oeNnAE.js";
2
- import { i as Q, n as Pe, r as O, t as $ } from "./createFormCollector-vy-QvFja.js";
1
+ import { a as J, i as j, o as V, s as Y, t as X } from "./AgoClient-Ozz2b1dQ.js";
2
+ import { i as Q, n as Pe, r as O, t as $ } from "./createFormCollector-F3YJfsbg.js";
3
3
  import { t as _e } from "./createMockClient-bAZ9KBHC.js";
4
- import Z, { createContext as ee, useCallback as R, useContext as G, useEffect as k, useId as te, useMemo as F, useRef as A, useState as M, useSyncExternalStore as ne } from "react";
5
- import { Fragment as B, jsx as i, jsxs as N } from "react/jsx-runtime";
4
+ import Z, { createContext as ee, useCallback as N, useContext as B, useEffect as k, useId as te, useMemo as F, useRef as A, useState as M, useSyncExternalStore as ne } from "react";
5
+ import { Fragment as G, jsx as i, jsxs as R } from "react/jsx-runtime";
6
6
  import re from "react-markdown";
7
7
  import oe from "remark-gfm";
8
8
  function ae(e) {
@@ -49,15 +49,15 @@ var L = ee(null), He = ({ children: e, client: n, tools: r, helpers: t, pageCont
49
49
  if (!t) return;
50
50
  const g = [];
51
51
  return import("./functions-CApuQZ2b.js").then((d) => d.n).then((d) => {
52
- for (const [v, y] of Object.entries(t)) {
53
- const I = d[v];
52
+ for (const [y, b] of Object.entries(t)) {
53
+ const I = d[y];
54
54
  if (!I) {
55
- console.warn(`[AGO] Unknown helper: "${v}"`);
55
+ console.warn(`[AGO] Unknown helper: "${y}"`);
56
56
  continue;
57
57
  }
58
- const f = y === !0 ? I : {
58
+ const f = b === !0 ? I : {
59
59
  ...I,
60
- handler: y
60
+ handler: b
61
61
  };
62
62
  l.register(f), g.push(f.name);
63
63
  }
@@ -72,17 +72,17 @@ var L = ee(null), He = ({ children: e, client: n, tools: r, helpers: t, pageCont
72
72
  });
73
73
  };
74
74
  function _() {
75
- const e = G(L);
75
+ const e = B(L);
76
76
  if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
77
77
  return e;
78
78
  }
79
79
  function W() {
80
- return G(L);
80
+ return B(L);
81
81
  }
82
82
  function U({ client: e, conversationId: n } = {}) {
83
83
  const r = W(), t = e || r;
84
84
  if (!t) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
85
- const [o, s] = M([]), [c, l] = M(n), [g, d] = M(!1), [v, y] = M(null);
85
+ const [o, s] = M([]), [c, l] = M(n), [g, d] = M(!1), [y, b] = M(null);
86
86
  k(() => {
87
87
  n && n !== c && (l(n), I(n));
88
88
  }, [n]);
@@ -90,14 +90,14 @@ function U({ client: e, conversationId: n } = {}) {
90
90
  try {
91
91
  s((await t.getMessages(f)).filter((m) => !m.hidden));
92
92
  } catch (m) {
93
- y(m instanceof Error ? m : /* @__PURE__ */ new Error("Failed to load messages"));
93
+ b(m instanceof Error ? m : /* @__PURE__ */ new Error("Failed to load messages"));
94
94
  }
95
95
  };
96
96
  return k(() => {
97
97
  const f = (u) => u === "IN_PROGRESS" || u === "WAITING_CLIENT", m = (u) => {
98
98
  c || l(u.conversationId), d(!0), s((p) => {
99
- const b = p.findIndex((h) => h.id === u.messageId);
100
- return b >= 0 ? p.map((h, D) => D === b ? {
99
+ const v = p.findIndex((h) => h.id === u.messageId);
100
+ return v >= 0 ? p.map((h, D) => D === v ? {
101
101
  ...h,
102
102
  status: "IN_PROGRESS"
103
103
  } : h) : p.some((h) => h.role === "assistant" && f(h.status)) ? p : [...p, {
@@ -111,39 +111,39 @@ function U({ client: e, conversationId: n } = {}) {
111
111
  });
112
112
  }, S = (u) => {
113
113
  s((p) => {
114
- const b = p.findIndex((h) => h.id === u.messageId);
115
- return b < 0 ? p : p.map((h, D) => D === b ? {
114
+ const v = p.findIndex((h) => h.id === u.messageId);
115
+ return v < 0 ? p : p.map((h, D) => D === v ? {
116
116
  ...h,
117
117
  content: h.content + u.content
118
118
  } : h);
119
119
  });
120
120
  }, w = (u) => {
121
121
  s((p) => {
122
- let b = -1;
122
+ let v = -1;
123
123
  for (let h = p.length - 1; h >= 0; h--) if (p[h].role === "assistant" && f(p[h].status)) {
124
- b = h;
124
+ v = h;
125
125
  break;
126
126
  }
127
- return b < 0 ? p : [
128
- ...p.slice(0, b),
127
+ return v < 0 ? p : [
128
+ ...p.slice(0, v),
129
129
  {
130
- ...p[b],
130
+ ...p[v],
131
131
  ...u
132
132
  },
133
- ...p.slice(b + 1)
133
+ ...p.slice(v + 1)
134
134
  ];
135
135
  });
136
136
  }, a = (u) => {
137
137
  s((p) => {
138
- const b = p.findIndex((h) => h.id === u.id);
139
- return b >= 0 ? [
140
- ...p.slice(0, b),
138
+ const v = p.findIndex((h) => h.id === u.id);
139
+ return v >= 0 ? [
140
+ ...p.slice(0, v),
141
141
  u,
142
- ...p.slice(b + 1)
142
+ ...p.slice(v + 1)
143
143
  ] : [...p, u];
144
144
  }), d(!1);
145
145
  }, x = (u) => {
146
- y(new Error(u.error)), d(!1);
146
+ b(new Error(u.error)), d(!1);
147
147
  };
148
148
  return t.on("message:start", m), t.on("message:chunk", S), t.on("message:answer-complete", w), t.on("message:complete", a), t.on("message:error", x), () => {
149
149
  t.off("message:start", m), t.off("message:chunk", S), t.off("message:answer-complete", w), t.off("message:complete", a), t.off("message:error", x);
@@ -151,9 +151,9 @@ function U({ client: e, conversationId: n } = {}) {
151
151
  }, [t, c]), {
152
152
  messages: o,
153
153
  isLoading: g,
154
- error: v,
155
- sendMessage: R(async (f, m) => {
156
- d(!0), y(null);
154
+ error: y,
155
+ sendMessage: N(async (f, m) => {
156
+ d(!0), b(null);
157
157
  const S = {
158
158
  id: `temp-${Date.now()}`,
159
159
  conversationId: c || "",
@@ -181,49 +181,49 @@ function U({ client: e, conversationId: n } = {}) {
181
181
  files: m
182
182
  });
183
183
  return a.conversationId && !c && l(a.conversationId), s((x) => {
184
- const u = x.filter((b) => !b.id.startsWith("temp-")), p = {
184
+ const u = x.filter((v) => !v.id.startsWith("temp-")), p = {
185
185
  ...S,
186
186
  id: S.id.replace("temp-", "user-"),
187
187
  conversationId: a.conversationId
188
188
  };
189
- return u.some((b) => b.id === a.id) ? [...u, p].sort((b, h) => new Date(b.createdAt).getTime() - new Date(h.createdAt).getTime()) : [
189
+ return u.some((v) => v.id === a.id) ? [...u, p].sort((v, h) => new Date(v.createdAt).getTime() - new Date(h.createdAt).getTime()) : [
190
190
  ...u,
191
191
  p,
192
192
  a
193
193
  ];
194
194
  }), a;
195
195
  } catch (a) {
196
- return y(a instanceof Error ? a : /* @__PURE__ */ new Error("Failed to send message")), d(!1), s((x) => x.filter((u) => !u.id.startsWith("temp-"))), null;
196
+ return b(a instanceof Error ? a : /* @__PURE__ */ new Error("Failed to send message")), d(!1), s((x) => x.filter((u) => !u.id.startsWith("temp-"))), null;
197
197
  }
198
198
  }, [t, c]),
199
- clearMessages: R(() => {
200
- s([]), l(void 0), y(null);
199
+ clearMessages: N(() => {
200
+ s([]), l(void 0), b(null);
201
201
  }, []),
202
202
  conversationId: c
203
203
  };
204
204
  }
205
205
  var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", allowFiles: t = !1, className: o = "" }) => {
206
- const [s, c] = M(""), [l, g] = M([]), d = A(null), v = A(null), y = R(() => {
207
- const a = v.current;
206
+ const [s, c] = M(""), [l, g] = M([]), d = A(null), y = A(null), b = N(() => {
207
+ const a = y.current;
208
208
  if (!a) return;
209
209
  const x = 110;
210
210
  a.style.height = "auto", a.style.height = `${Math.min(a.scrollHeight + 2, x)}px`, a.style.overflowY = a.scrollHeight + 2 > x ? "auto" : "hidden";
211
- }, []), I = R((a) => {
212
- a.preventDefault(), (s.trim() || l.length > 0) && (e(s.trim(), l.length > 0 ? l : void 0), c(""), g([]), requestAnimationFrame(y));
211
+ }, []), I = N((a) => {
212
+ a.preventDefault(), (s.trim() || l.length > 0) && (e(s.trim(), l.length > 0 ? l : void 0), c(""), g([]), requestAnimationFrame(b));
213
213
  }, [
214
214
  s,
215
215
  l,
216
216
  e,
217
- y
218
- ]), f = R((a) => {
217
+ b
218
+ ]), f = N((a) => {
219
219
  a.key === "Enter" && !a.shiftKey && (a.preventDefault(), I(a));
220
- }, [I]), m = R((a) => {
220
+ }, [I]), m = N((a) => {
221
221
  const x = Array.from(a.target.files || []);
222
222
  g((u) => [...u, ...x]);
223
- }, []), S = R((a) => {
223
+ }, []), S = N((a) => {
224
224
  g((x) => x.filter((u, p) => p !== a));
225
225
  }, []), w = s.trim() || l.length > 0;
226
- return /* @__PURE__ */ N("form", {
226
+ return /* @__PURE__ */ R("form", {
227
227
  onSubmit: I,
228
228
  className: `ago-chat-input ${o}`,
229
229
  style: {
@@ -241,7 +241,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
241
241
  flexWrap: "wrap",
242
242
  gap: "6px"
243
243
  },
244
- children: l.map((a, x) => /* @__PURE__ */ N("div", {
244
+ children: l.map((a, x) => /* @__PURE__ */ R("div", {
245
245
  style: {
246
246
  display: "flex",
247
247
  alignItems: "center",
@@ -276,14 +276,14 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
276
276
  children: "×"
277
277
  })]
278
278
  }, x))
279
- }), /* @__PURE__ */ N("div", {
279
+ }), /* @__PURE__ */ R("div", {
280
280
  style: {
281
281
  display: "flex",
282
282
  gap: "8px",
283
283
  alignItems: "flex-end"
284
284
  },
285
285
  children: [
286
- t && /* @__PURE__ */ N(B, { children: [/* @__PURE__ */ i("button", {
286
+ t && /* @__PURE__ */ R(G, { children: [/* @__PURE__ */ i("button", {
287
287
  type: "button",
288
288
  onClick: () => d.current?.click(),
289
289
  disabled: n,
@@ -307,10 +307,10 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
307
307
  style: { display: "none" }
308
308
  })] }),
309
309
  /* @__PURE__ */ i("textarea", {
310
- ref: v,
310
+ ref: y,
311
311
  value: s,
312
312
  onChange: (a) => {
313
- c(a.target.value), y();
313
+ c(a.target.value), b();
314
314
  },
315
315
  onKeyDown: f,
316
316
  placeholder: r,
@@ -545,7 +545,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
545
545
  }
546
546
  })
547
547
  });
548
- const t = V(e.fileSize), o = /* @__PURE__ */ N(B, { children: [/* @__PURE__ */ i("span", {
548
+ const t = V(e.fileSize), o = /* @__PURE__ */ R(G, { children: [/* @__PURE__ */ i("span", {
549
549
  style: {
550
550
  fontSize: "16px",
551
551
  lineHeight: 1,
@@ -553,7 +553,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
553
553
  },
554
554
  "aria-hidden": !0,
555
555
  children: "📄"
556
- }), /* @__PURE__ */ N("span", {
556
+ }), /* @__PURE__ */ R("span", {
557
557
  style: {
558
558
  display: "flex",
559
559
  flexDirection: "column",
@@ -599,7 +599,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
599
599
  children: o
600
600
  });
601
601
  }, Ie = ({ source: e, index: n }) => {
602
- const r = /* @__PURE__ */ N("div", {
602
+ const r = /* @__PURE__ */ R("div", {
603
603
  style: {
604
604
  display: "flex",
605
605
  alignItems: "center",
@@ -663,7 +663,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
663
663
  style: t,
664
664
  children: r
665
665
  });
666
- }, ke = () => /* @__PURE__ */ N("div", {
666
+ }, ke = () => /* @__PURE__ */ R("div", {
667
667
  style: {
668
668
  display: "flex",
669
669
  gap: "4px",
@@ -688,7 +688,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
688
688
  ` })]
689
689
  }), Me = ({ message: e, className: n = "", showAgentName: r = !1, isLast: t = !1, onFollowUpClick: o }) => {
690
690
  const s = e.role === "user", c = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
691
- return /* @__PURE__ */ N("div", {
691
+ return /* @__PURE__ */ R("div", {
692
692
  className: `ago-message ago-message--${e.role} ${n}`,
693
693
  style: {
694
694
  display: "flex",
@@ -790,7 +790,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
790
790
  })
791
791
  ]
792
792
  });
793
- }, Oe = ({ client: e, conversationId: n, title: r = "Chat", welcomeMessage: t = "Hello! How can I help you today?", placeholder: o = "Type a message...", allowFiles: s = !1, height: c = 500, logoUrl: l, showAgentName: g = !1, forms: d, onFollowUpClick: v, className: y = "", onMessageSent: I, onMessageReceived: f }) => {
793
+ }, Oe = ({ client: e, conversationId: n, title: r = "Chat", welcomeMessage: t = "Hello! How can I help you today?", placeholder: o = "Type a message...", allowFiles: s = !1, height: c = 500, logoUrl: l, showAgentName: g = !1, forms: d, onFollowUpClick: y, className: b = "", onMessageSent: I, onMessageReceived: f }) => {
794
794
  const m = A(null), S = W(), w = e ?? S, { messages: a, isLoading: x, error: u, sendMessage: p } = U({
795
795
  client: e,
796
796
  conversationId: n
@@ -820,11 +820,11 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
820
820
  content: C.content
821
821
  });
822
822
  }, [a, f]);
823
- const b = async (C, T) => {
823
+ const v = async (C, T) => {
824
824
  I?.(C), await p(C, T);
825
- }, h = a[a.length - 1], D = x && h?.role === "assistant" && (h.status === "IN_PROGRESS" || h.status === "WAITING_CLIENT"), K = v === !1 ? void 0 : v ?? ((C) => b(C));
826
- return /* @__PURE__ */ N("div", {
827
- className: `ago-chat-widget ${y}`,
825
+ }, h = a[a.length - 1], D = x && h?.role === "assistant" && (h.status === "IN_PROGRESS" || h.status === "WAITING_CLIENT"), K = y === !1 ? void 0 : y ?? ((C) => v(C));
826
+ return /* @__PURE__ */ R("div", {
827
+ className: `ago-chat-widget ${b}`,
828
828
  style: {
829
829
  display: "flex",
830
830
  flexDirection: "column",
@@ -838,7 +838,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
838
838
  boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
839
839
  },
840
840
  children: [
841
- /* @__PURE__ */ N("div", {
841
+ /* @__PURE__ */ R("div", {
842
842
  className: "ago-chat-widget__header",
843
843
  style: {
844
844
  padding: "14px 16px",
@@ -865,7 +865,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
865
865
  children: r
866
866
  })]
867
867
  }),
868
- /* @__PURE__ */ N("div", {
868
+ /* @__PURE__ */ R("div", {
869
869
  className: "ago-chat-widget__messages",
870
870
  role: "log",
871
871
  "aria-live": "polite",
@@ -910,7 +910,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
910
910
  ]
911
911
  }),
912
912
  /* @__PURE__ */ i(se, {
913
- onSend: b,
913
+ onSend: v,
914
914
  disabled: D,
915
915
  placeholder: o,
916
916
  allowFiles: s
@@ -918,28 +918,28 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
918
918
  ]
919
919
  });
920
920
  };
921
- function Ne({ client: e, autoLoad: n = !0 } = {}) {
921
+ function Re({ client: e, autoLoad: n = !0 } = {}) {
922
922
  const r = W(), t = e || r;
923
923
  if (!t) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
924
- const [o, s] = M([]), [c, l] = M(null), [g, d] = M(!1), [v, y] = M(null), I = R(async () => {
925
- d(!0), y(null);
924
+ const [o, s] = M([]), [c, l] = M(null), [g, d] = M(!1), [y, b] = M(null), I = N(async () => {
925
+ d(!0), b(null);
926
926
  try {
927
927
  s(await t.getConversations());
928
928
  } catch (S) {
929
- y(S instanceof Error ? S : /* @__PURE__ */ new Error("Failed to load conversations"));
929
+ b(S instanceof Error ? S : /* @__PURE__ */ new Error("Failed to load conversations"));
930
930
  } finally {
931
931
  d(!1);
932
932
  }
933
- }, [t]), f = R(async (S) => {
934
- d(!0), y(null);
933
+ }, [t]), f = N(async (S) => {
934
+ d(!0), b(null);
935
935
  try {
936
936
  l(await t.getConversation(S));
937
937
  } catch (w) {
938
- y(w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to load conversation"));
938
+ b(w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to load conversation"));
939
939
  } finally {
940
940
  d(!1);
941
941
  }
942
- }, [t]), m = R(() => {
942
+ }, [t]), m = N(() => {
943
943
  l(null);
944
944
  }, []);
945
945
  return k(() => {
@@ -948,7 +948,7 @@ function Ne({ client: e, autoLoad: n = !0 } = {}) {
948
948
  conversations: o,
949
949
  currentConversation: c,
950
950
  isLoading: g,
951
- error: v,
951
+ error: y,
952
952
  selectConversation: f,
953
953
  startNewConversation: m,
954
954
  refreshConversations: I
@@ -960,7 +960,7 @@ function $e(e = {}) {
960
960
  const t = U({
961
961
  client: r,
962
962
  conversationId: e.conversationId
963
- }), o = Ne({
963
+ }), o = Re({
964
964
  client: r,
965
965
  autoLoad: e.autoLoad
966
966
  });
@@ -979,16 +979,17 @@ function $e(e = {}) {
979
979
  refreshConversations: o.refreshConversations
980
980
  };
981
981
  }
982
- function Ge(e, n) {
983
- const r = _(), { name: t, description: o, parameters: s, handler: c } = typeof e == "string" ? {
982
+ function Be(e, n) {
983
+ const r = _(), { name: t, description: o, parameters: s, handler: c, maxResultBytes: l } = typeof e == "string" ? {
984
984
  name: e,
985
985
  ...n
986
- } : e, l = A(c);
987
- l.current = c, k(() => {
988
- const g = (d) => l.current(d);
989
- return r.registerFunction(t, g, {
986
+ } : e, g = A(c);
987
+ g.current = c, k(() => {
988
+ const d = (y) => g.current(y);
989
+ return r.registerFunction(t, d, {
990
990
  description: o,
991
- parameters: s
991
+ parameters: s,
992
+ maxResultBytes: l
992
993
  }), () => {
993
994
  r.unregisterFunction(t);
994
995
  };
@@ -996,10 +997,11 @@ function Ge(e, n) {
996
997
  r,
997
998
  t,
998
999
  o,
999
- s
1000
+ s,
1001
+ l
1000
1002
  ]);
1001
1003
  }
1002
- function Be(e, n) {
1004
+ function Ge(e, n) {
1003
1005
  const r = _(), t = A(e);
1004
1006
  t.current = e, k(() => (r.registerNavigationFunction((o) => t.current(o), n), () => {
1005
1007
  r.unregisterNavigationFunction();
@@ -1023,12 +1025,12 @@ function Ue(e, n) {
1023
1025
  };
1024
1026
  }, [r, t]);
1025
1027
  }
1026
- var Re = "You have navigated the user to a new page. That page now exposes its editable state through the available setPageState function, and its current values in the page context. If the user's latest request also asked to change something on this page, call setPageState now to apply exactly those changes and nothing else. Otherwise, reply with a short confirmation only.";
1028
+ var Ne = "You have navigated the user to a new page. That page now exposes its editable state through the available setPageState function, and its current values in the page context. If the user's latest request also asked to change something on this page, call setPageState now to apply exactly those changes and nothing else. Otherwise, reply with a short confirmation only.";
1027
1029
  function z(e) {
1028
1030
  return {
1029
1031
  navigationFunctions: e?.navigationFunctions ?? ["navigateToPage"],
1030
1032
  pageStateFunctionName: e?.pageStateFunctionName ?? "setPageState",
1031
- continuationPrompt: e?.continuationPrompt ?? Re,
1033
+ continuationPrompt: e?.continuationPrompt ?? Ne,
1032
1034
  maxDepth: e?.maxDepth ?? 1,
1033
1035
  readinessTimeoutMs: e?.readinessTimeoutMs ?? 4e3,
1034
1036
  settleMs: e?.settleMs ?? 150,
@@ -1072,17 +1074,17 @@ function Ke(e) {
1072
1074
  r.current.enabled && t.pausedTurnNavigated && (t.pausedTurnNavigated = !1, await s(++t.runId));
1073
1075
  }), d = () => {
1074
1076
  t.pausedTurnNavigated = t.navigated, t.navigated = !1;
1075
- }, v = () => {
1077
+ }, y = () => {
1076
1078
  t.ourSendPending || (t.depth = 0, t.runId += 1);
1077
- }, y = (f) => {
1079
+ }, b = (f) => {
1078
1080
  t.ourSendPending = !1;
1079
1081
  const m = t.navigated;
1080
1082
  t.navigated = !1, r.current.enabled && m && (t.depth >= r.current.maxDepth || c(f.conversationId));
1081
1083
  }, I = () => {
1082
1084
  t.ourSendPending = !1;
1083
1085
  };
1084
- return n.on("function:invoke", l), n.on("message:start", v), n.on("message:waiting-client", d), n.on("message:complete", y), n.on("message:error", I), () => {
1085
- t.runId += 1, g(), n.off("function:invoke", l), n.off("message:start", v), n.off("message:waiting-client", d), n.off("message:complete", y), n.off("message:error", I);
1086
+ return n.on("function:invoke", l), n.on("message:start", y), n.on("message:waiting-client", d), n.on("message:complete", b), n.on("message:error", I), () => {
1087
+ t.runId += 1, g(), n.off("function:invoke", l), n.off("message:start", y), n.off("message:waiting-client", d), n.off("message:complete", b), n.off("message:error", I);
1086
1088
  };
1087
1089
  }, [n]);
1088
1090
  }
@@ -1157,15 +1159,15 @@ function Je(e) {
1157
1159
  c,
1158
1160
  e.autoSubmit
1159
1161
  ]);
1160
- const v = r ? l : g.collector, y = r ? !1 : g.loading, I = r ? null : g.error;
1162
+ const y = r ? l : g.collector, b = r ? !1 : g.loading, I = r ? null : g.error;
1161
1163
  k(() => {
1162
- if (v)
1163
- return v.install(n);
1164
- }, [n, v]);
1164
+ if (y)
1165
+ return y.install(n);
1166
+ }, [n, y]);
1165
1167
  const f = F(() => Q({
1166
1168
  values: e.initialValues ?? {},
1167
1169
  submitted: !1
1168
- }), [c]), m = Ae(v?.store ?? f), S = F(() => v?.getStatus() ?? H, [m, v]), w = F(() => ({
1170
+ }), [c]), m = Ae(y?.store ?? f), S = F(() => y?.getStatus() ?? H, [m, y]), w = F(() => ({
1169
1171
  ...m,
1170
1172
  ...S
1171
1173
  }), [m, S]), a = F(() => ({
@@ -1193,9 +1195,9 @@ function Je(e) {
1193
1195
  getStatus: () => H
1194
1196
  }), [e.name, f]);
1195
1197
  return {
1196
- ...v ?? a,
1198
+ ...y ?? a,
1197
1199
  state: w,
1198
- loading: y,
1200
+ loading: b,
1199
1201
  error: I
1200
1202
  };
1201
1203
  }
@@ -1213,12 +1215,12 @@ export {
1213
1215
  Ke as useAgoAutoContinueAfterNavigation,
1214
1216
  _ as useAgoClient,
1215
1217
  qe as useAgoContext,
1216
- Ge as useAgoFunction,
1217
- Be as useAgoNavigation,
1218
+ Be as useAgoFunction,
1219
+ Ge as useAgoNavigation,
1218
1220
  Ue as useAgoPageState,
1219
1221
  Ae as useAgoStore,
1220
1222
  $e as useChat,
1221
- Ne as useConversation,
1223
+ Re as useConversation,
1222
1224
  Je as useFormCollector,
1223
1225
  U as useMessages,
1224
1226
  W as useOptionalAgoClient