@useago/sdk 1.13.3 → 1.14.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 (37) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/angular.cjs +1 -1
  3. package/dist/angular.d.cts +7 -0
  4. package/dist/angular.d.ts +7 -0
  5. package/dist/angular.js +1 -1
  6. package/dist/{createConversationSession-DrmOaZdO.js → createConversationSession-CybQdMpK.js} +1 -1
  7. package/dist/{createConversationSession-Digvn0GQ.cjs → createConversationSession-jwSXhTLe.cjs} +1 -1
  8. package/dist/{createFormCollector-D_5SDuk9.cjs → createFormCollector-B_hSKcLd.cjs} +1 -1
  9. package/dist/{createFormCollector-D6_N8wYq.js → createFormCollector-DJjms78E.js} +1 -1
  10. package/dist/devtools.d.cts +7 -0
  11. package/dist/devtools.d.ts +7 -0
  12. package/dist/index.cjs +1 -1
  13. package/dist/index.d.cts +7 -0
  14. package/dist/index.d.ts +7 -0
  15. package/dist/index.js +6 -6
  16. package/dist/react.cjs +4 -4
  17. package/dist/react.d.cts +8 -1
  18. package/dist/react.d.ts +8 -1
  19. package/dist/react.js +901 -912
  20. package/dist/speechToText-BB25_zVM.cjs +7 -0
  21. package/dist/speechToText-BLvTis4S.js +1496 -0
  22. package/dist/testing.d.cts +7 -0
  23. package/dist/testing.d.ts +7 -0
  24. package/dist/{types-D1ZrqVhr.js → types-C39MJUE3.js} +284 -259
  25. package/dist/{types-DNr6XEwI.cjs → types-PGXnhAmQ.cjs} +7 -7
  26. package/dist/vue.cjs +1 -1
  27. package/dist/vue.d.cts +7 -0
  28. package/dist/vue.d.ts +7 -0
  29. package/dist/vue.js +1 -1
  30. package/dist/widget.cjs +5 -6
  31. package/dist/widget.d.cts +12 -4
  32. package/dist/widget.d.ts +12 -4
  33. package/dist/widget.js +1868 -1841
  34. package/llms-full.txt +23 -3
  35. package/package.json +1 -1
  36. package/dist/speechToText-BV7qxqPF.js +0 -704
  37. package/dist/speechToText-ZciRyyJE.cjs +0 -1
@@ -1,11 +1,11 @@
1
- import { a as X, i as F, n as S, r as V, t as C } from "./errors-BLfjXnLB.js";
2
- var ts = 10, Y = 1e3;
3
- function Ae(e) {
1
+ import { a as X, i as D, n as _, r as V, t as A } from "./errors-BLfjXnLB.js";
2
+ var is = 10, Y = 1e3;
3
+ function ke(e) {
4
4
  if (typeof e != "object" || e === null) return !1;
5
5
  const t = Object.getPrototypeOf(e);
6
6
  return t === Object.prototype || t === null;
7
7
  }
8
- function P(e, t) {
8
+ function N(e, t) {
9
9
  if (typeof e == "string") {
10
10
  if (e.length <= 1e3) return e;
11
11
  const s = e.length - Y;
@@ -14,22 +14,22 @@ function P(e, t) {
14
14
  if (Array.isArray(e)) {
15
15
  if (t.has(e)) return "…[circular]";
16
16
  t.add(e);
17
- const s = e.slice(0, 50).map((i) => P(i, t));
17
+ const s = e.slice(0, 50).map((i) => N(i, t));
18
18
  return e.length > 50 && s.push(`…[+${e.length - 50} more]`), t.delete(e), s;
19
19
  }
20
- if (Ae(e)) {
20
+ if (ke(e)) {
21
21
  if (t.has(e)) return "…[circular]";
22
22
  t.add(e);
23
23
  const s = {};
24
- for (const [i, n] of Object.entries(e)) s[i] = P(n, t);
24
+ for (const [i, n] of Object.entries(e)) s[i] = N(n, t);
25
25
  return t.delete(e), s;
26
26
  }
27
27
  return e;
28
28
  }
29
29
  function me(e) {
30
- return P(e, /* @__PURE__ */ new WeakSet());
30
+ return N(e, /* @__PURE__ */ new WeakSet());
31
31
  }
32
- var ke = class {
32
+ var Re = class {
33
33
  constructor(e = 10) {
34
34
  this.entries = [];
35
35
  const t = Math.floor(e);
@@ -56,8 +56,23 @@ var ke = class {
56
56
  clear() {
57
57
  this.entries = [];
58
58
  }
59
- };
60
- function N(e) {
59
+ }, pe = [
60
+ "en",
61
+ "fr",
62
+ "de",
63
+ "es",
64
+ "it",
65
+ "pt"
66
+ ];
67
+ function ns(e) {
68
+ const t = e?.toLowerCase().split(/[-_]/)[0];
69
+ return pe.find((s) => s === t) ?? "en";
70
+ }
71
+ function Te(e) {
72
+ const t = S(e);
73
+ return t && pe.some((s) => t.split("-")[0] === s) ? t : "en";
74
+ }
75
+ function S(e) {
61
76
  if (e == null) return null;
62
77
  if (typeof e == "string") {
63
78
  const t = e.trim().replace(/_/g, "-");
@@ -67,9 +82,9 @@ function N(e) {
67
82
  } catch {
68
83
  }
69
84
  }
70
- throw new S('Use a language tag such as "fr", "de-DE", or "pt-BR", or null to clear it. See docs/general/configuration.md#language (config_invalid_language).', "config_invalid_language");
85
+ throw new _('Use a language tag such as "fr", "de-DE", or "pt-BR", or null to clear it. See docs/general/configuration.md#language (config_invalid_language).', "config_invalid_language");
71
86
  }
72
- var Re = class {
87
+ var Ie = class {
73
88
  constructor(e = !1) {
74
89
  this.enabled = e;
75
90
  }
@@ -91,11 +106,11 @@ var Re = class {
91
106
  debug(...e) {
92
107
  this.enabled && console.debug("[AGO SDK]", ...e);
93
108
  }
94
- }, c = new Re(), Q = "ago_widget_id";
109
+ }, c = new Ie(), Q = "ago_widget_id";
95
110
  function O(e) {
96
111
  return typeof DOMException < "u" && e instanceof DOMException && e.name === "AbortError" || e instanceof Error && e.name === "AbortError";
97
112
  }
98
- function Te() {
113
+ function xe() {
99
114
  if (typeof localStorage < "u") {
100
115
  const t = localStorage.getItem(Q);
101
116
  if (t) return t;
@@ -107,14 +122,14 @@ function Te() {
107
122
  }
108
123
  return e;
109
124
  }
110
- var Ie = class {
125
+ var Fe = class {
111
126
  constructor(e) {
112
- this.baseUrl = e.baseUrl.replace(/\/$/, ""), this.headers = { "X-User-Anon-Id": e.widgetId || Te() }, e.userEmail && (this.headers["X-User-Email"] = e.userEmail), e.userJwt && (this.headers.Authorization = `Bearer ${e.userJwt}`), e.permission && (this.headers["X-Widget-Permission"] = e.permission);
113
- const t = N(e.language);
127
+ this.baseUrl = e.baseUrl.replace(/\/$/, ""), this.headers = { "X-User-Anon-Id": e.widgetId || xe() }, e.userEmail && (this.headers["X-User-Email"] = e.userEmail), e.userJwt && (this.headers.Authorization = `Bearer ${e.userJwt}`), e.permission && (this.headers["X-Widget-Permission"] = e.permission);
128
+ const t = S(e.language);
114
129
  t && (this.headers["Accept-Language"] = t);
115
130
  }
116
131
  updateConfig(e) {
117
- const t = N(e.language);
132
+ const t = S(e.language);
118
133
  e.baseUrl && (this.baseUrl = e.baseUrl.replace(/\/$/, "")), e.widgetId && (this.headers["X-User-Anon-Id"] = e.widgetId), e.userEmail && (this.headers["X-User-Email"] = e.userEmail), e.userJwt && (this.headers.Authorization = `Bearer ${e.userJwt}`), e.permission !== void 0 && (e.permission ? this.headers["X-Widget-Permission"] = e.permission : delete this.headers["X-Widget-Permission"]), e.language !== void 0 && (t ? this.headers["Accept-Language"] = t : delete this.headers["Accept-Language"]);
119
134
  }
120
135
  async get(e) {
@@ -138,7 +153,7 @@ var Ie = class {
138
153
  });
139
154
  return n.ok || await this.handleErrorResponse(n), n;
140
155
  } catch (n) {
141
- throw n instanceof C || O(n) ? n : new F(`Network error: ${n instanceof Error ? n.message : "Unknown error"}. Check that \`baseUrl\` is reachable and includes the protocol (https://).`, n instanceof Error ? n : void 0);
156
+ throw n instanceof A || O(n) ? n : new D(`Network error: ${n instanceof Error ? n.message : "Unknown error"}. Check that \`baseUrl\` is reachable and includes the protocol (https://).`, n instanceof Error ? n : void 0);
142
157
  }
143
158
  }
144
159
  async postFormData(e, t, s) {
@@ -154,7 +169,7 @@ var Ie = class {
154
169
  });
155
170
  return r.ok || await this.handleErrorResponse(r), r;
156
171
  } catch (r) {
157
- throw r instanceof C || O(r) ? r : new F(`Network error: ${r instanceof Error ? r.message : "Unknown error"}. Check that \`baseUrl\` is reachable and includes the protocol (https://).`, r instanceof Error ? r : void 0);
172
+ throw r instanceof A || O(r) ? r : new D(`Network error: ${r instanceof Error ? r.message : "Unknown error"}. Check that \`baseUrl\` is reachable and includes the protocol (https://).`, r instanceof Error ? r : void 0);
158
173
  }
159
174
  }
160
175
  async request(e, t, s, i) {
@@ -172,7 +187,7 @@ var Ie = class {
172
187
  });
173
188
  return r.ok || await this.handleErrorResponse(r), r.status === 204 ? void 0 : r.json();
174
189
  } catch (r) {
175
- throw r instanceof C ? r : new F(`Network error: ${r instanceof Error ? r.message : "Unknown error"}. Check that \`baseUrl\` is reachable and includes the protocol (https://).`, r instanceof Error ? r : void 0);
190
+ throw r instanceof A ? r : new D(`Network error: ${r instanceof Error ? r.message : "Unknown error"}. Check that \`baseUrl\` is reachable and includes the protocol (https://).`, r instanceof Error ? r : void 0);
176
191
  }
177
192
  }
178
193
  async handleErrorResponse(e) {
@@ -181,39 +196,39 @@ var Ie = class {
181
196
  t = await e.json();
182
197
  } catch {
183
198
  }
184
- if (t?.error) throw C.fromResponse(t, e.status);
199
+ if (t?.error) throw A.fromResponse(t, e.status);
185
200
  let s = "";
186
- throw e.status === 401 || e.status === 403 ? s = " Check `userJwt` (and that it has not expired)." : e.status === 404 && (s = " Check that `baseUrl` points at your AGO API root."), new C(`HTTP ${e.status}: ${e.statusText}.${s}`, "http_error", e.status, "api_error");
201
+ throw e.status === 401 || e.status === 403 ? s = " Check `userJwt` (and that it has not expired)." : e.status === 404 && (s = " Check that `baseUrl` points at your AGO API root."), new A(`HTTP ${e.status}: ${e.statusText}.${s}`, "http_error", e.status, "api_error");
187
202
  }
188
- }, ss = 10, is = 6e5;
189
- var xe = "[AGO SDK]", Fe = 300;
203
+ }, rs = 10, os = 6e5;
204
+ var De = "[AGO SDK]", $e = 300;
190
205
  function L(e, t) {
191
206
  return e.length <= t ? e : e.slice(0, t) + `…[truncated ${e.length - t} chars]`;
192
207
  }
193
- function De(e) {
208
+ function Me(e) {
194
209
  const t = e.search(/[?#]/);
195
210
  return t === -1 ? e : e.slice(0, t);
196
211
  }
197
212
  function K(e) {
198
213
  return typeof e == "object" && e !== null && typeof e.message == "string";
199
214
  }
200
- function pe(e) {
215
+ function ye(e) {
201
216
  if (typeof e == "string") return e;
202
217
  if (K(e)) return (typeof e.name == "string" && e.name ? `${e.name}: ` : "") + e.message;
203
218
  if (typeof e == "object" && e !== null) try {
204
- return L(JSON.stringify(e), Fe);
219
+ return L(JSON.stringify(e), $e);
205
220
  } catch {
206
221
  return String(e);
207
222
  }
208
223
  return String(e);
209
224
  }
210
- function D(e) {
225
+ function $(e) {
211
226
  return K(e) ? {
212
227
  message: (typeof e.name == "string" && e.name && e.name !== "Error" ? `${e.name}: ` : "") + e.message,
213
228
  stack: typeof e.stack == "string" ? e.stack : void 0
214
- } : { message: pe(e) };
229
+ } : { message: ye(e) };
215
230
  }
216
- var $e = class {
231
+ var Pe = class {
217
232
  constructor(e = {}) {
218
233
  this.started = !1, this.teardowns = [], this.errors = [], this.listeners = /* @__PURE__ */ new Set(), this.capturing = !1;
219
234
  const t = Math.floor(e.maxErrors ?? 10);
@@ -232,7 +247,7 @@ var $e = class {
232
247
  this.teardowns = [], this.listeners.clear(), this.started = !1, c.log("ErrorWatcher destroyed");
233
248
  }
234
249
  report(e, t) {
235
- const s = D(e);
250
+ const s = $(e);
236
251
  this.capture({
237
252
  type: "manual",
238
253
  message: s.message,
@@ -253,18 +268,18 @@ var $e = class {
253
268
  }
254
269
  onErrorEvent(e) {
255
270
  if (typeof e.message != "string" && !e.error) return;
256
- const t = e.error !== void 0 && e.error !== null ? D(e.error) : { message: e.message ?? "" };
271
+ const t = e.error !== void 0 && e.error !== null ? $(e.error) : { message: e.message ?? "" };
257
272
  this.capture({
258
273
  type: "error",
259
274
  message: t.message || e.message || "Unknown error",
260
275
  stack: t.stack,
261
- source: e.filename ? De(e.filename) : void 0,
276
+ source: e.filename ? Me(e.filename) : void 0,
262
277
  line: e.lineno || void 0,
263
278
  col: e.colno || void 0
264
279
  });
265
280
  }
266
281
  onRejectionEvent(e) {
267
- const t = e.reason, s = D(t);
282
+ const t = e.reason, s = $(t);
268
283
  this.capture({
269
284
  type: "unhandledrejection",
270
285
  message: s.message || "Unhandled promise rejection",
@@ -287,8 +302,8 @@ var $e = class {
287
302
  onConsoleError(e) {
288
303
  if (e.length === 0) return;
289
304
  const t = e[0];
290
- if (typeof t == "string" && t.startsWith(xe)) return;
291
- const s = e.find(K), i = e.map(pe).join(" ");
305
+ if (typeof t == "string" && t.startsWith(De)) return;
306
+ const s = e.find(K), i = e.map(ye).join(" ");
292
307
  this.capture({
293
308
  type: "console",
294
309
  message: i,
@@ -357,26 +372,26 @@ var $e = class {
357
372
  function Z(e) {
358
373
  return `${e.type}|${e.message}|${e.source ?? ""}|${e.line ?? ""}`;
359
374
  }
360
- var k = {
375
+ var R = {
361
376
  name: 30,
362
377
  description: 500,
363
378
  parameterName: 30,
364
379
  parameterDescription: 150,
365
380
  resultBytes: 1500
366
381
  };
367
- function Me(e) {
382
+ function Ne(e) {
368
383
  const t = [], s = (i, n, r) => {
369
384
  const o = n?.length ?? 0;
370
385
  o > r && t.push(`${i} (${o}/${r})`);
371
386
  };
372
- s("name", e.name, k.name), s("description", e.description, k.description);
387
+ s("name", e.name, R.name), s("description", e.description, R.description);
373
388
  for (const [i, n] of Object.entries(e.parameters?.properties ?? {}))
374
- s(`"${i}" name`, i, k.parameterName), s(`"${i}" description`, n.description ?? "", k.parameterDescription);
389
+ s(`"${i}" name`, i, R.parameterName), s(`"${i}" description`, n.description ?? "", R.parameterDescription);
375
390
  return t;
376
391
  }
377
- var Pe = 5e4, Ne = 2e4, Oe = 2e3, Le = class {
392
+ var Oe = 5e4, Le = 2e4, Ue = 2e3, je = class {
378
393
  constructor(e) {
379
- this.functions = /* @__PURE__ */ new Map(), this.changeListeners = /* @__PURE__ */ new Set(), this.defaultMaxResultBytes = e?.maxResultBytes ?? Pe;
394
+ this.functions = /* @__PURE__ */ new Map(), this.changeListeners = /* @__PURE__ */ new Set(), this.defaultMaxResultBytes = e?.maxResultBytes ?? Oe;
380
395
  }
381
396
  onChange(e) {
382
397
  return this.changeListeners.add(e), () => {
@@ -408,7 +423,7 @@ var Pe = 5e4, Ne = 2e4, Oe = 2e3, Le = class {
408
423
  });
409
424
  }
410
425
  const i = e;
411
- if (!t || !s) throw new S(`registerFunction("${i}"): both a handler and a schema are required. Pass them as arguments or use the single-object form: registerFunction({ name, parameters, handler }).`, "function_invalid_registration");
426
+ if (!t || !s) throw new _(`registerFunction("${i}"): both a handler and a schema are required. Pass them as arguments or use the single-object form: registerFunction({ name, parameters, handler }).`, "function_invalid_registration");
412
427
  this.functions.has(i) && c.warn(`Function "${i}" is being overwritten`);
413
428
  const { maxResultBytes: n, requiresApproval: r, webmcp: o, ...a } = s, l = {
414
429
  ...a,
@@ -421,7 +436,7 @@ var Pe = 5e4, Ne = 2e4, Oe = 2e3, Le = class {
421
436
  requiresApproval: r,
422
437
  webmcp: o
423
438
  });
424
- const d = Me(l);
439
+ const d = Ne(l);
425
440
  d.length > 0 && c.warn(`Function "${i}" is over the per-tool budget on ${d.join(", ")}.`), c.log(`Registered function: ${i}`), this.emitChange();
426
441
  }
427
442
  unregister(e) {
@@ -467,9 +482,9 @@ var Pe = 5e4, Ne = 2e4, Oe = 2e3, Le = class {
467
482
  truncated: !0,
468
483
  originalBytes: n,
469
484
  maxBytes: r,
470
- preview: i.slice(0, Oe),
485
+ preview: i.slice(0, Ue),
471
486
  hint: `The result of "${e}" exceeded the ${r}-byte limit and was truncated. Request less data (use limit or filter parameters if available), or tell the user the result is too large to process.`
472
- }) : (n > Ne && c.warn(`Function "${e}" returned a large result (${Math.round(n / 1024)} KB). Large results consume LLM context: return fewer fields, paginate, or push the data to the UI and return a summary.`), t);
487
+ }) : (n > Le && c.warn(`Function "${e}" returned a large result (${Math.round(n / 1024)} KB). Large results consume LLM context: return fewer fields, paginate, or push the data to the UI and return a summary.`), t);
473
488
  }
474
489
  clear() {
475
490
  const e = this.functions.size > 0;
@@ -478,36 +493,36 @@ var Pe = 5e4, Ne = 2e4, Oe = 2e3, Le = class {
478
493
  get size() {
479
494
  return this.functions.size;
480
495
  }
481
- }, je = new TextEncoder();
496
+ }, We = new TextEncoder();
482
497
  function b(e) {
483
- return je.encode(e).length;
498
+ return We.encode(e).length;
484
499
  }
485
- function j(e) {
500
+ function U(e) {
486
501
  return b(JSON.stringify(e)) - 2;
487
502
  }
488
- function ye(e, t) {
503
+ function ve(e, t) {
489
504
  if (t <= 0) return "";
490
505
  let s = "", i = 0;
491
506
  for (const n of e) {
492
- const r = j(n);
507
+ const r = U(n);
493
508
  if (i + r > t) break;
494
509
  s += n, i += r;
495
510
  }
496
511
  return s;
497
512
  }
498
- var Ue = 50, We = 2;
499
- var Be = 2e3;
500
- function A(e) {
513
+ var Be = 50, Ge = 2;
514
+ var qe = 2e3;
515
+ function k(e) {
501
516
  try {
502
517
  return JSON.stringify(e);
503
518
  } catch {
504
519
  return;
505
520
  }
506
521
  }
507
- var U = /* @__PURE__ */ Symbol("ago.pageData.timeout");
508
- function Ge(e, t) {
509
- return t <= 0 ? Promise.resolve(U) : new Promise((s, i) => {
510
- const n = setTimeout(() => s(U), t);
522
+ var j = /* @__PURE__ */ Symbol("ago.pageData.timeout");
523
+ function Ke(e, t) {
524
+ return t <= 0 ? Promise.resolve(j) : new Promise((s, i) => {
525
+ const n = setTimeout(() => s(j), t);
511
526
  e.then((r) => {
512
527
  clearTimeout(n), s(r);
513
528
  }, (r) => {
@@ -515,15 +530,15 @@ function Ge(e, t) {
515
530
  });
516
531
  });
517
532
  }
518
- async function qe(e, t) {
533
+ async function Je(e, t) {
519
534
  const s = Date.now() + t;
520
535
  let i = 0;
521
- for (; Date.now() < s && i < We; )
522
- i = e().isLoading?.() ? 0 : i + 1, await new Promise((a) => setTimeout(a, Ue));
536
+ for (; Date.now() < s && i < Ge; )
537
+ i = e().isLoading?.() ? 0 : i + 1, await new Promise((a) => setTimeout(a, Be));
523
538
  const n = e().get();
524
539
  if (!ee(n)) return n;
525
- const r = await Ge(Promise.resolve(n), s - Date.now());
526
- if (r !== U) return r;
540
+ const r = await Ke(Promise.resolve(n), s - Date.now());
541
+ if (r !== j) return r;
527
542
  c.warn("Page data did not resolve within the settle timeout; returning what the page has now. Raise settleTimeoutMs if the work legitimately takes longer.");
528
543
  const o = e().get();
529
544
  if (!ee(o)) return o;
@@ -533,7 +548,7 @@ async function qe(e, t) {
533
548
  function ee(e) {
534
549
  return typeof e == "object" && e !== null && typeof e.then == "function";
535
550
  }
536
- function Ke(e) {
551
+ function He(e) {
537
552
  if (typeof e != "object" || e === null || Array.isArray(e)) return;
538
553
  const t = e;
539
554
  let s;
@@ -543,10 +558,10 @@ function Ke(e) {
543
558
  }
544
559
  return s;
545
560
  }
546
- function Je(e, t) {
561
+ function ze(e, t) {
547
562
  let s = 2, i = 0;
548
563
  for (const n of e) {
549
- const r = b(A(n) ?? "null") + (i > 0 ? 1 : 0);
564
+ const r = b(k(n) ?? "null") + (i > 0 ? 1 : 0);
550
565
  if (s + r > t) break;
551
566
  s += r, i++;
552
567
  }
@@ -555,21 +570,21 @@ function Je(e, t) {
555
570
  function W(e) {
556
571
  return `The page data returned by "${e}" was too large to send in full. Only the first items are included: ask for fewer rows or narrow the filters to see the rest.`;
557
572
  }
558
- function He(e, t, s, i) {
573
+ function Xe(e, t, s, i) {
559
574
  const n = {
560
575
  truncated: !0,
561
576
  originalBytes: s,
562
577
  maxBytes: i,
563
578
  preview: "",
564
579
  hint: W(e)
565
- }, r = b(A(n) ?? "{}");
580
+ }, r = b(k(n) ?? "{}");
566
581
  return {
567
582
  ...n,
568
- preview: ye(t, Math.min(Be, i - r))
583
+ preview: ve(t, Math.min(qe, i - r))
569
584
  };
570
585
  }
571
- function ze(e, t, s, i, n) {
572
- const r = s === void 0 ? {} : { ...t }, o = s ?? "items", a = b(A({
586
+ function Ve(e, t, s, i, n) {
587
+ const r = s === void 0 ? {} : { ...t }, o = s ?? "items", a = b(k({
573
588
  ...r,
574
589
  [o]: [],
575
590
  truncation: {
@@ -580,7 +595,7 @@ function ze(e, t, s, i, n) {
580
595
  }
581
596
  }) ?? "{}") - 2;
582
597
  if (a >= n) return;
583
- const l = i.slice(0, Je(i, n - a));
598
+ const l = i.slice(0, ze(i, n - a));
584
599
  return {
585
600
  ...r,
586
601
  [o]: l,
@@ -593,26 +608,26 @@ function ze(e, t, s, i, n) {
593
608
  };
594
609
  }
595
610
  function te(e, t, s) {
596
- const i = A(t);
611
+ const i = k(t);
597
612
  if (i === void 0) return t;
598
613
  const n = b(i);
599
614
  if (n <= s) return t;
600
615
  c.warn(`Page data for "${e}" is ${n} bytes, over the ${s}-byte limit; it was truncated to the first items that fit. Return fewer fields per item, paginate, or raise maxResultBytes on the data source.`);
601
- const r = Ke(t), o = Array.isArray(t) ? t : r !== void 0 ? t[r] : void 0;
616
+ const r = He(t), o = Array.isArray(t) ? t : r !== void 0 ? t[r] : void 0;
602
617
  if (o) {
603
- const a = ze(e, t, r, o, s), l = b(A(a) ?? "");
618
+ const a = Ve(e, t, r, o, s), l = b(k(a) ?? "");
604
619
  if (a !== void 0 && l <= s) return a;
605
620
  }
606
- return He(e, i, n, s);
621
+ return Xe(e, i, n, s);
607
622
  }
608
- var J = "navigateToPage", T = "listPages";
609
- function Xe(e) {
623
+ var J = "navigateToPage", I = "listPages";
624
+ function Ye(e) {
610
625
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
611
626
  }
612
627
  function B(e) {
613
628
  return e.split("/").filter((t) => t.startsWith(":")).map((t) => t.slice(1));
614
629
  }
615
- function Ve(e, t) {
630
+ function Qe(e, t) {
616
631
  const s = [];
617
632
  return {
618
633
  path: e.split("/").map((i) => {
@@ -623,28 +638,28 @@ function Ve(e, t) {
623
638
  missing: s
624
639
  };
625
640
  }
626
- function Ye(e, t) {
641
+ function Ze(e, t) {
627
642
  const s = t.find((n) => n.path === e);
628
643
  if (s) return s;
629
644
  const i = t.find((n) => {
630
645
  if (!n.path.includes(":")) return !1;
631
- const r = "^" + n.path.split("/").map((o) => o.startsWith(":") ? "[^/]+" : Xe(o)).join("/") + "/?$";
646
+ const r = "^" + n.path.split("/").map((o) => o.startsWith(":") ? "[^/]+" : Ye(o)).join("/") + "/?$";
632
647
  return new RegExp(r).test(e);
633
648
  });
634
649
  return i || t.filter((n) => n.path !== "/" && e.startsWith(n.path)).sort((n, r) => r.path.length - n.path.length)[0];
635
650
  }
636
- function ve(e) {
651
+ function we(e) {
637
652
  return [...new Set(e.map((t) => t.section).filter((t) => !!t))];
638
653
  }
639
- function Qe(e) {
654
+ function et(e) {
640
655
  const t = B(e.path), s = t.length > 0 ? ` (requires ${t.map((i) => `"${i}"`).join(", ")})` : "";
641
656
  return `- "${e.name}"${s}: ${e.description}`;
642
657
  }
643
- function Ze(e, t, s) {
644
- const i = s?.catalogue === "onDemand", n = ve(t);
658
+ function tt(e, t, s) {
659
+ const i = s?.catalogue === "onDemand", n = we(t);
645
660
  !i && n.length > 0 && c.log('registerNavigationFunction: routes declare "section" but catalogue is "inline", so it is unused. Set catalogue: "onDemand" to use it.');
646
- const r = "Available functions depend on the current page. After navigation, you will receive the destination page’s available functions and current state. Use them to complete any remaining actions in the user’s request.", o = i ? `Navigate the user to a page. Call ${T} for what a page name means. ${r}` : `Navigate the user to a page in the application. ${r} Available pages:
647
- ${t.map(Qe).join(`
661
+ const r = "Available functions depend on the current page. After navigation, you will receive the destination page’s available functions and current state. Use them to complete any remaining actions in the user’s request.", o = i ? `Navigate the user to a page. Call ${I} for what a page name means. ${r}` : `Navigate the user to a page in the application. ${r} Available pages:
662
+ ${t.map(et).join(`
648
663
  `)}`, a = /* @__PURE__ */ new Map();
649
664
  for (const u of t) for (const g of B(u.path)) a.set(g, [...a.get(g) ?? [], u.name]);
650
665
  const l = t.map((u) => u.name), d = { page: {
@@ -689,7 +704,7 @@ ${t.map(Qe).join(`
689
704
  else u.params && typeof u.params == "object" && (v = u.params);
690
705
  const y = {};
691
706
  for (const m of B(f.path)) y[m] = u[m] ?? v[m];
692
- const { path: h, missing: p } = Ve(f.path, y);
707
+ const { path: h, missing: p } = Qe(f.path, y);
693
708
  if (p.length > 0) {
694
709
  const m = p.map((w) => `"${w}": "..."`).join(", ");
695
710
  return {
@@ -704,13 +719,13 @@ ${t.map(Qe).join(`
704
719
  }
705
720
  };
706
721
  }
707
- function et(e) {
708
- const t = ve(e), s = (i) => ({
722
+ function st(e) {
723
+ const t = we(e), s = (i) => ({
709
724
  name: i.name,
710
725
  description: i.description
711
726
  });
712
727
  return {
713
- name: T,
728
+ name: I,
714
729
  description: `List what each page name of ${J} means.`,
715
730
  parameters: {
716
731
  type: "object",
@@ -733,59 +748,59 @@ function et(e) {
733
748
  }
734
749
  };
735
750
  }
736
- function I(e, t) {
751
+ function x(e, t) {
737
752
  if (e === t) return !0;
738
753
  if (e === null || t === null || typeof e != "object" || typeof t != "object" || Array.isArray(e) !== Array.isArray(t)) return !1;
739
754
  if (Array.isArray(e))
740
- return e.length !== t.length ? !1 : e.every((n, r) => I(n, t[r]));
755
+ return e.length !== t.length ? !1 : e.every((n, r) => x(n, t[r]));
741
756
  const s = Object.keys(e), i = Object.keys(t);
742
- return s.length !== i.length ? !1 : s.every((n) => n in t && I(e[n], t[n]));
757
+ return s.length !== i.length ? !1 : s.every((n) => n in t && x(e[n], t[n]));
743
758
  }
744
- var se = 100, $ = " … [truncated]", we = { truncated: !0 }, tt = b(',"data":' + JSON.stringify(we));
759
+ var se = 100, M = " … [truncated]", Ee = { truncated: !0 }, it = b(',"data":' + JSON.stringify(Ee));
745
760
  function G(e) {
746
761
  return b(JSON.stringify(e));
747
762
  }
748
763
  function ie(e, t) {
749
764
  if (G(e) <= t || !e.rejected) return e;
750
- const s = Object.entries(e.rejected), i = Object.fromEntries(s.map(([a]) => [a, $])), n = {
765
+ const s = Object.entries(e.rejected), i = Object.fromEntries(s.map(([a]) => [a, M])), n = {
751
766
  ...e,
752
767
  rejected: i
753
768
  };
754
769
  let r = G(n);
755
770
  if (r > t) return n;
756
- const o = j($);
771
+ const o = U(M);
757
772
  for (const [a, l] of s) {
758
- const d = j(l), u = t - r + o;
773
+ const d = U(l), u = t - r + o;
759
774
  if (d <= u) {
760
775
  i[a] = l, r += d - o;
761
776
  continue;
762
777
  }
763
- i[a] = ye(l, u - o) + $;
778
+ i[a] = ve(l, u - o) + M;
764
779
  break;
765
780
  }
766
781
  return n;
767
782
  }
768
- function _(e) {
783
+ function C(e) {
769
784
  return Array.isArray(e) ? "array" : typeof e;
770
785
  }
771
786
  function ne(e) {
772
- return typeof e != "number" ? `Expected type "number", got "${_(e)}".` : Number.isFinite(e) ? null : "Expected a finite number.";
787
+ return typeof e != "number" ? `Expected type "number", got "${C(e)}".` : Number.isFinite(e) ? null : "Expected a finite number.";
773
788
  }
774
- function Ee(e) {
789
+ function be(e) {
775
790
  const t = e.slice(0, se).map((i) => JSON.stringify(i)), s = e.length - se;
776
791
  return s > 0 ? `${t.join(", ")} (${s} more not shown)` : t.join(", ");
777
792
  }
778
793
  function re(e, t) {
779
- return t.includes(e) ? null : t.length === 0 ? "No values are currently allowed." : `${JSON.stringify(e)} is not an allowed value. Allowed values: ${Ee(t)}.`;
794
+ return t.includes(e) ? null : t.length === 0 ? "No values are currently allowed." : `${JSON.stringify(e)} is not an allowed value. Allowed values: ${be(t)}.`;
780
795
  }
781
- function st(e, t) {
796
+ function nt(e, t) {
782
797
  const { schema: s } = t;
783
798
  if (s.type === "array") {
784
- if (!Array.isArray(e)) return `Expected type "array", got "${_(e)}".`;
799
+ if (!Array.isArray(e)) return `Expected type "array", got "${C(e)}".`;
785
800
  for (let n = 0; n < e.length; n++) {
786
801
  const r = e[n];
787
802
  if (s.items?.type) {
788
- const o = s.items.type === "number" ? ne(r) : _(r) !== s.items.type ? `Expected type "${s.items.type}", got "${_(r)}".` : null;
803
+ const o = s.items.type === "number" ? ne(r) : C(r) !== s.items.type ? `Expected type "${s.items.type}", got "${C(r)}".` : null;
789
804
  if (o) return `Array item at index ${n}: ${o[0].toLowerCase()}${o.slice(1)}`;
790
805
  }
791
806
  if (s.items?.enum) {
@@ -798,29 +813,29 @@ function st(e, t) {
798
813
  if (s.type === "number") {
799
814
  const n = ne(e);
800
815
  if (n) return n;
801
- } else if (_(e) !== s.type) return `Expected type "${s.type}", got "${_(e)}".`;
802
- const i = be(t);
816
+ } else if (C(e) !== s.type) return `Expected type "${s.type}", got "${C(e)}".`;
817
+ const i = _e(t);
803
818
  return i ? re(e, i) : null;
804
819
  }
805
820
  function H(e) {
806
821
  return e.clearable === !0 && e.schema.type === "string";
807
822
  }
808
- function be(e) {
823
+ function _e(e) {
809
824
  const t = e.schema.enum;
810
825
  if (t)
811
826
  return H(e) && !t.includes("") ? [...t, ""] : t;
812
827
  }
813
- function it(e) {
828
+ function rt(e) {
814
829
  const t = {
815
830
  ...e.schema,
816
831
  ...e.schema.items ? { items: { ...e.schema.items } } : {},
817
832
  description: e.description
818
833
  };
819
834
  t.enum?.length === 0 && delete t.enum, t.items?.enum?.length === 0 && delete t.items.enum, H(e) && (t.description = `${e.description} Pass "" to clear it.`);
820
- const s = be(e);
835
+ const s = _e(e);
821
836
  return s?.length && (t.enum = s), t;
822
837
  }
823
- function nt(e, t) {
838
+ function ot(e, t) {
824
839
  const s = new Map(e.map((r) => [r.name, r])), i = e.map((r) => r.name), n = e.map((r) => `- "${r.name}": ${r.description}`).join(`
825
840
  `);
826
841
  return {
@@ -830,16 +845,16 @@ function nt(e, t) {
830
845
  for (const [h, p] of Object.entries(r)) {
831
846
  const m = s.get(h);
832
847
  if (!m) {
833
- l[h] = `"${h}" is not a registered control. Available controls: ${Ee(i)}.`;
848
+ l[h] = `"${h}" is not a registered control. Available controls: ${be(i)}.`;
834
849
  continue;
835
850
  }
836
851
  if (p == null || p === "" && !H(m)) continue;
837
- const w = st(p, m);
852
+ const w = nt(p, m);
838
853
  if (w) {
839
854
  l[h] = w;
840
855
  continue;
841
856
  }
842
- if (m.get && I(p, m.get())) {
857
+ if (m.get && x(p, m.get())) {
843
858
  a.push(h);
844
859
  continue;
845
860
  }
@@ -853,13 +868,13 @@ function nt(e, t) {
853
868
  ...d ? { rejected: l } : {}
854
869
  }, g = t.getResultBudget();
855
870
  if (!t.data) return ie(u, g);
856
- const f = ie(u, g - tt), v = await t.data.read(f), y = {
871
+ const f = ie(u, g - it), v = await t.data.read(f), y = {
857
872
  ...f,
858
873
  data: v
859
874
  };
860
875
  return G(y) <= g ? y : {
861
876
  ...f,
862
- data: we
877
+ data: Ee
863
878
  };
864
879
  },
865
880
  description: (e.length > 0 ? `Change the state of the current page. Set ONLY the controls the user explicitly asked for; leave the others unset. Available controls:
@@ -867,22 +882,22 @@ ${n}` : "The current page has no editable state — nothing to change here.") +
867
882
  Returns the resulting page data once it has loaded: ${t.data.description}` : ""),
868
883
  parameters: {
869
884
  type: "object",
870
- properties: Object.fromEntries(e.map((r) => [r.name, it(r)])),
885
+ properties: Object.fromEntries(e.map((r) => [r.name, rt(r)])),
871
886
  required: []
872
887
  },
873
888
  requiresApproval: t.requiresApproval,
874
889
  maxResultBytes: t.data?.maxResultBytes
875
890
  };
876
891
  }
877
- var rt = 250, ot = 3, at = 1e3, ct = 24, lt = 10, ut = 50, dt = [
892
+ var at = 250, ct = 3, lt = 1e3, ut = 24, dt = 10, ht = 50, gt = [
878
893
  "mousemove",
879
894
  "mousedown",
880
895
  "keydown",
881
896
  "scroll",
882
897
  "touchstart"
883
- ], ht = class {
898
+ ], ft = class {
884
899
  constructor(e = {}) {
885
- this.started = !1, this.teardowns = [], this.route = "", this.routeEnteredAt = 0, this.lastActivityAt = 0, this.lastHeavyActivityAt = 0, this.recentRoutes = [], this.routeBounces = 0, this.rageClicks = 0, this.jsErrors = 0, this.fieldErrors = {}, this.recentClicks = [], this.signals = [], this.listeners = /* @__PURE__ */ new Set(), this.getPageState = e.getPageState, this.activityThrottleMs = e.activityThrottleMs ?? rt, this.rageClickCount = e.rageClickCount ?? ot, this.rageClickWindowMs = e.rageClickWindowMs ?? at, this.rageClickRadiusPx = e.rageClickRadiusPx ?? ct, this.maxRecentRoutes = e.maxRecentRoutes ?? lt, this.maxSignals = e.maxSignals ?? ut;
900
+ this.started = !1, this.teardowns = [], this.route = "", this.routeEnteredAt = 0, this.lastActivityAt = 0, this.lastHeavyActivityAt = 0, this.recentRoutes = [], this.routeBounces = 0, this.rageClicks = 0, this.jsErrors = 0, this.fieldErrors = {}, this.recentClicks = [], this.signals = [], this.listeners = /* @__PURE__ */ new Set(), this.getPageState = e.getPageState, this.activityThrottleMs = e.activityThrottleMs ?? at, this.rageClickCount = e.rageClickCount ?? ct, this.rageClickWindowMs = e.rageClickWindowMs ?? lt, this.rageClickRadiusPx = e.rageClickRadiusPx ?? ut, this.maxRecentRoutes = e.maxRecentRoutes ?? dt, this.maxSignals = e.maxSignals ?? ht;
886
901
  }
887
902
  start() {
888
903
  if (this.started || typeof window > "u" || typeof document > "u") return;
@@ -892,7 +907,7 @@ var rt = 250, ot = 3, at = 1e3, ct = 24, lt = 10, ut = 50, dt = [
892
907
  const t = (i, n, r) => {
893
908
  i.addEventListener(n, r, { passive: !0 }), this.teardowns.push(() => i.removeEventListener(n, r));
894
909
  }, s = () => this.recordActivity();
895
- for (const i of dt) t(window, i, s);
910
+ for (const i of gt) t(window, i, s);
896
911
  t(document, "visibilitychange", () => {
897
912
  document.visibilityState === "visible" && this.recordActivity();
898
913
  }), t(window, "popstate", () => this.checkRoute()), t(window, "hashchange", () => this.checkRoute()), t(window, "click", (i) => this.onClick(i)), c.log("SignalCollector started");
@@ -1018,7 +1033,7 @@ var rt = 250, ot = 3, at = 1e3, ct = 24, lt = 10, ut = 50, dt = [
1018
1033
  }
1019
1034
  }
1020
1035
  };
1021
- function gt(e, t) {
1036
+ function mt(e, t) {
1022
1037
  const s = t ? t.storage ?? (typeof localStorage < "u" ? localStorage : void 0) : void 0;
1023
1038
  let i = e;
1024
1039
  if (t && s) try {
@@ -1043,23 +1058,23 @@ function gt(e, t) {
1043
1058
  })
1044
1059
  };
1045
1060
  }
1046
- var ft = 6e4, mt = 1440 * 60 * 1e3, pt = "ago_proactive";
1047
- function M(e) {
1061
+ var pt = 6e4, yt = 1440 * 60 * 1e3, vt = "ago_proactive";
1062
+ function P(e) {
1048
1063
  const t = new Date(e), s = String(t.getMonth() + 1).padStart(2, "0"), i = String(t.getDate()).padStart(2, "0");
1049
1064
  return `${t.getFullYear()}-${s}-${i}`;
1050
1065
  }
1051
- var yt = class {
1066
+ var wt = class {
1052
1067
  constructor(e = {}) {
1053
- this.killSwitchEnabled = !1, this.engaged = !1, this.turnInFlight = !1, this.slotOccupied = !1, this.sessionCount = 0, this.perSessionCap = e.frequencyCap?.perSession, this.perDayCap = e.frequencyCap?.perDay, this.store = gt({
1068
+ this.killSwitchEnabled = !1, this.engaged = !1, this.turnInFlight = !1, this.slotOccupied = !1, this.sessionCount = 0, this.perSessionCap = e.frequencyCap?.perSession, this.perDayCap = e.frequencyCap?.perDay, this.store = mt({
1054
1069
  optOut: !1,
1055
1070
  lastFiredAt: {},
1056
1071
  dismissedAt: {},
1057
1072
  day: {
1058
- date: M(Date.now()),
1073
+ date: P(Date.now()),
1059
1074
  count: 0
1060
1075
  }
1061
1076
  }, {
1062
- key: e.storageKey ?? pt,
1077
+ key: e.storageKey ?? vt,
1063
1078
  storage: e.storage
1064
1079
  });
1065
1080
  }
@@ -1103,9 +1118,9 @@ var yt = class {
1103
1118
  if (this.engaged) return this.deny(e, "user engaged (widget open)");
1104
1119
  if (this.turnInFlight) return this.deny(e, "message turn in flight");
1105
1120
  if (this.slotOccupied) return this.deny(e, "nudge slot occupied");
1106
- const i = s.lastFiredAt[e.id], n = e.cooldownMs ?? ft;
1121
+ const i = s.lastFiredAt[e.id], n = e.cooldownMs ?? pt;
1107
1122
  if (i !== void 0 && t - i < n) return this.deny(e, "cooldown");
1108
- const r = s.dismissedAt[e.id], o = e.resurfaceAfterMs ?? mt;
1123
+ const r = s.dismissedAt[e.id], o = e.resurfaceAfterMs ?? yt;
1109
1124
  return r !== void 0 && t - r < o ? this.deny(e, "dismissed recently") : this.perSessionCap !== void 0 && this.sessionCount >= this.perSessionCap ? this.deny(e, "perSession cap") : this.perDayCap !== void 0 && this.dayCount(t) >= this.perDayCap ? this.deny(e, "perDay cap") : !0;
1110
1125
  }
1111
1126
  recordFired(e, t = Date.now()) {
@@ -1120,7 +1135,7 @@ var yt = class {
1120
1135
  }
1121
1136
  recordNudgeShown(e = Date.now()) {
1122
1137
  this.sessionCount += 1;
1123
- const t = this.store.get(), s = M(e), i = t.day.date === s ? {
1138
+ const t = this.store.get(), s = P(e), i = t.day.date === s ? {
1124
1139
  date: s,
1125
1140
  count: t.day.count + 1
1126
1141
  } : {
@@ -1144,42 +1159,42 @@ var yt = class {
1144
1159
  }
1145
1160
  dayCount(e) {
1146
1161
  const t = this.store.get();
1147
- return t.day.date === M(e) ? t.day.count : 0;
1162
+ return t.day.date === P(e) ? t.day.count : 0;
1148
1163
  }
1149
1164
  deny(e, t) {
1150
1165
  return c.debug(`NudgeGovernor: trigger "${e.id}" blocked — ${t}`), !1;
1151
1166
  }
1152
1167
  };
1153
- function x() {
1168
+ function F() {
1154
1169
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
1155
1170
  const t = Math.floor(Math.random() * 16);
1156
1171
  return (e === "x" ? t : t & 3 | 8).toString(16);
1157
1172
  });
1158
1173
  }
1159
- function vt(e) {
1174
+ function Et(e) {
1160
1175
  return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1161
1176
  }
1162
- function wt(e, t) {
1177
+ function bt(e, t) {
1163
1178
  if (e === "*" || e === t) return !0;
1164
1179
  const s = e.split("/"), i = s.map((n, r) => {
1165
1180
  const o = r === s.length - 1;
1166
- return n === "*" ? o ? "[^/]+(?:/[^/]+)*" : "[^/]+" : n.startsWith(":") ? "[^/]+" : vt(n);
1181
+ return n === "*" ? o ? "[^/]+(?:/[^/]+)*" : "[^/]+" : n.startsWith(":") ? "[^/]+" : Et(n);
1167
1182
  });
1168
1183
  return new RegExp("^" + i.join("/") + "/?$").test(t);
1169
1184
  }
1170
1185
  function Se(e, t) {
1171
- return e === t ? !0 : e === null || t === null ? !1 : Array.isArray(e) ? !Array.isArray(t) || t.length !== e.length ? !1 : e.every((s, i) => I(s, t[i])) : typeof e == "object" ? typeof t != "object" || Array.isArray(t) ? !1 : Object.entries(e).every(([s, i]) => Se(i, t[s])) : !1;
1186
+ return e === t ? !0 : e === null || t === null ? !1 : Array.isArray(e) ? !Array.isArray(t) || t.length !== e.length ? !1 : e.every((s, i) => x(s, t[i])) : typeof e == "object" ? typeof t != "object" || Array.isArray(t) ? !1 : Object.entries(e).every(([s, i]) => Se(i, t[s])) : !1;
1172
1187
  }
1173
- function Et(e, t) {
1174
- if (e.route !== void 0 && !wt(e.route, t.route) || e.idleMs !== void 0 && t.idleMs < e.idleMs || e.dwellMs !== void 0 && t.dwellMs < e.dwellMs || e.rageClicks !== void 0 && t.rageClicks < e.rageClicks || e.jsErrors !== void 0 && (t.jsErrors ?? 0) < e.jsErrors || e.routeBounces !== void 0 && t.routeBounces < e.routeBounces) return !1;
1188
+ function _t(e, t) {
1189
+ if (e.route !== void 0 && !bt(e.route, t.route) || e.idleMs !== void 0 && t.idleMs < e.idleMs || e.dwellMs !== void 0 && t.dwellMs < e.dwellMs || e.rageClicks !== void 0 && t.rageClicks < e.rageClicks || e.jsErrors !== void 0 && (t.jsErrors ?? 0) < e.jsErrors || e.routeBounces !== void 0 && t.routeBounces < e.routeBounces) return !1;
1175
1190
  if (e.fieldErrors !== void 0) {
1176
1191
  for (const [s, i] of Object.entries(e.fieldErrors)) if ((t.fieldErrors[s] ?? 0) < i) return !1;
1177
1192
  }
1178
1193
  return !(e.pageState !== void 0 && !Se(e.pageState, t.pageState ?? {}));
1179
1194
  }
1180
- var bt = 1e3, St = "/api/sdk/v1/config", _t = "/api/sdk/v1/proactive/evaluate", Ct = class {
1195
+ var St = 1e3, Ct = "/api/sdk/v1/config", At = "/api/sdk/v1/proactive/evaluate", kt = class {
1181
1196
  constructor(e) {
1182
- this.tickTimer = null, this.teardowns = [], this.started = !1, this.activeNudge = null, this.lastConversationId = null, this.shownIds = /* @__PURE__ */ new Set(), this.resolvedIds = /* @__PURE__ */ new Set(), this.lastEvaluationAt = 0, this.client = e.client, this.collector = e.collector, this.governor = e.governor, this.tracker = e.tracker, this.options = e.options, this.tickMs = e.options.tickMs ?? bt;
1197
+ this.tickTimer = null, this.teardowns = [], this.started = !1, this.activeNudge = null, this.lastConversationId = null, this.shownIds = /* @__PURE__ */ new Set(), this.resolvedIds = /* @__PURE__ */ new Set(), this.lastEvaluationAt = 0, this.client = e.client, this.collector = e.collector, this.governor = e.governor, this.tracker = e.tracker, this.options = e.options, this.tickMs = e.options.tickMs ?? St;
1183
1198
  }
1184
1199
  start() {
1185
1200
  if (this.started) return;
@@ -1205,7 +1220,7 @@ var bt = 1e3, St = "/api/sdk/v1/config", _t = "/api/sdk/v1/proactive/evaluate",
1205
1220
  }
1206
1221
  async loadKillSwitch() {
1207
1222
  try {
1208
- const e = await this.client.getHttp().get(St);
1223
+ const e = await this.client.getHttp().get(Ct);
1209
1224
  this.governor.setKillSwitch(e?.proactive?.enabled === !0);
1210
1225
  } catch (e) {
1211
1226
  c.debug("Proactive config fetch failed; staying disabled:", e), this.governor.setKillSwitch(!1);
@@ -1215,7 +1230,7 @@ var bt = 1e3, St = "/api/sdk/v1/config", _t = "/api/sdk/v1/proactive/evaluate",
1215
1230
  if (this.lastEvaluationAt = Date.now(), typeof document < "u" && document.visibilityState === "hidden" || this.governor.isSlotOccupied()) return;
1216
1231
  const e = this.collector.getSnapshot();
1217
1232
  for (const t of this.options.triggers)
1218
- if (Et(t.when, e) && this.governor.canFire(t)) {
1233
+ if (_t(t.when, e) && this.governor.canFire(t)) {
1219
1234
  this.fire(t);
1220
1235
  return;
1221
1236
  }
@@ -1226,7 +1241,7 @@ var bt = 1e3, St = "/api/sdk/v1/config", _t = "/api/sdk/v1/proactive/evaluate",
1226
1241
  return;
1227
1242
  }
1228
1243
  this.setReady({
1229
- id: x(),
1244
+ id: F(),
1230
1245
  triggerId: e.id,
1231
1246
  source: "static",
1232
1247
  message: e.intervene.message,
@@ -1237,7 +1252,7 @@ var bt = 1e3, St = "/api/sdk/v1/config", _t = "/api/sdk/v1/proactive/evaluate",
1237
1252
  });
1238
1253
  }
1239
1254
  async evaluateWithAgent(e) {
1240
- const t = x(), s = {
1255
+ const t = F(), s = {
1241
1256
  client_nudge_id: t,
1242
1257
  trigger_id: e.id,
1243
1258
  goal: e.goal ?? "",
@@ -1248,7 +1263,7 @@ var bt = 1e3, St = "/api/sdk/v1/config", _t = "/api/sdk/v1/proactive/evaluate",
1248
1263
  };
1249
1264
  let i;
1250
1265
  try {
1251
- i = await this.client.getHttp().post(_t, s);
1266
+ i = await this.client.getHttp().post(At, s);
1252
1267
  } catch (n) {
1253
1268
  c.debug("Proactive evaluate failed (treated as no-intervene):", n), this.governor.releaseSlot();
1254
1269
  return;
@@ -1262,7 +1277,7 @@ var bt = 1e3, St = "/api/sdk/v1/config", _t = "/api/sdk/v1/proactive/evaluate",
1262
1277
  triggerId: e.id,
1263
1278
  source: "agent",
1264
1279
  message: i.message,
1265
- action: At(i.action),
1280
+ action: Rt(i.action),
1266
1281
  goal: e.goal,
1267
1282
  kickoff: e.kickoff,
1268
1283
  createdAt: /* @__PURE__ */ new Date(),
@@ -1298,7 +1313,7 @@ var bt = 1e3, St = "/api/sdk/v1/config", _t = "/api/sdk/v1/proactive/evaluate",
1298
1313
  source: e.source,
1299
1314
  type: "accepted",
1300
1315
  occurredAt: Date.now()
1301
- }), this.clearActive(e), this.client.emitProactiveEvent("nudge:accepted", { nudge: e }), (e.source === "agent" || e.goal) && (this.lastConversationId ? this.client.sendMessage(kt(e), {
1316
+ }), this.clearActive(e), this.client.emitProactiveEvent("nudge:accepted", { nudge: e }), (e.source === "agent" || e.goal) && (this.lastConversationId ? this.client.sendMessage(Tt(e), {
1302
1317
  hidden: !0,
1303
1318
  conversationId: this.lastConversationId
1304
1319
  }).catch((t) => c.debug("Nudge kickoff message failed:", t)) : e.kickoff ? this.client.sendMessage(e.kickoff).catch((t) => c.debug("Nudge kickoff message failed:", t)) : c.debug("Nudge accepted with no open conversation and no trigger.kickoff; skipping the chat pre-seed (a hidden message cannot open a conversation).")), e.action && await this.runAction(e.action));
@@ -1323,7 +1338,7 @@ var bt = 1e3, St = "/api/sdk/v1/config", _t = "/api/sdk/v1/proactive/evaluate",
1323
1338
  }
1324
1339
  }
1325
1340
  };
1326
- function At(e) {
1341
+ function Rt(e) {
1327
1342
  if (e)
1328
1343
  return {
1329
1344
  label: e.label,
@@ -1331,13 +1346,13 @@ function At(e) {
1331
1346
  arguments: e.arguments
1332
1347
  };
1333
1348
  }
1334
- function kt(e) {
1349
+ function Tt(e) {
1335
1350
  const t = e.goal ? ` Goal: ${e.goal}.` : "";
1336
1351
  return `The user accepted a proactive nudge that said: "${e.message}".${t} Recent friction signals are in the client context (friction_signals). Start helping with this now: briefly explain what you can do and take the first concrete step.`;
1337
1352
  }
1338
- var Rt = 5e3, Tt = "/api/sdk/v1/proactive/events", It = class {
1353
+ var It = 5e3, xt = "/api/sdk/v1/proactive/events", Ft = class {
1339
1354
  constructor(e) {
1340
- if (this.queue = [], this.flushTimer = null, this.teardowns = [], this.destroyed = !1, this.post = e.post, this.agent = e.agent, this.flushIntervalMs = e.flushIntervalMs ?? Rt, typeof document < "u") {
1355
+ if (this.queue = [], this.flushTimer = null, this.teardowns = [], this.destroyed = !1, this.post = e.post, this.agent = e.agent, this.flushIntervalMs = e.flushIntervalMs ?? It, typeof document < "u") {
1341
1356
  const t = () => {
1342
1357
  document.visibilityState === "hidden" && this.flush({ keepalive: !0 });
1343
1358
  };
@@ -1364,7 +1379,7 @@ var Rt = 5e3, Tt = "/api/sdk/v1/proactive/events", It = class {
1364
1379
  ...this.agent ? { agent: this.agent } : {},
1365
1380
  occurred_at: new Date(i.occurredAt).toISOString()
1366
1381
  })) };
1367
- this.post(Tt, s, e).catch((i) => {
1382
+ this.post(xt, s, e).catch((i) => {
1368
1383
  c.debug("Proactive event batch failed:", i);
1369
1384
  });
1370
1385
  }
@@ -1378,7 +1393,7 @@ var Rt = 5e3, Tt = "/api/sdk/v1/proactive/events", It = class {
1378
1393
  }, oe = "friction_signals";
1379
1394
  function ae(e, t) {
1380
1395
  e.proactive && (c.warn("createAgoProactive: a proactive controller is already attached; replacing it."), e.proactive.destroy());
1381
- const s = new ht({
1396
+ const s = new ft({
1382
1397
  ...t.signals,
1383
1398
  getPageState: () => {
1384
1399
  const l = e.getContextSnapshot();
@@ -1400,14 +1415,14 @@ function ae(e, t) {
1400
1415
  data: d
1401
1416
  };
1402
1417
  });
1403
- const n = new yt({
1418
+ const n = new wt({
1404
1419
  frequencyCap: t.frequencyCap,
1405
1420
  storage: t.storage,
1406
1421
  storageKey: t.storageKey
1407
- }), r = new It({
1422
+ }), r = new Ft({
1408
1423
  post: (l, d, u) => e.getHttp().post(l, d, u),
1409
1424
  agent: e.getConfiguredAgent()
1410
- }), o = new Ct({
1425
+ }), o = new kt({
1411
1426
  client: e,
1412
1427
  collector: s,
1413
1428
  governor: n,
@@ -1433,7 +1448,7 @@ function ae(e, t) {
1433
1448
  };
1434
1449
  return e.proactive = a, a;
1435
1450
  }
1436
- var xt = class {
1451
+ var Dt = class {
1437
1452
  constructor() {
1438
1453
  this.entries = /* @__PURE__ */ new Map(), this.dynamicProviders = /* @__PURE__ */ new Map();
1439
1454
  }
@@ -1466,33 +1481,33 @@ var xt = class {
1466
1481
  clear() {
1467
1482
  this.entries.clear(), this.dynamicProviders.clear(), c.log("ClientContext cleared");
1468
1483
  }
1469
- }, Ft = "page-state:";
1470
- function Dt(e) {
1484
+ }, $t = "page-state:";
1485
+ function Mt(e) {
1471
1486
  const t = {};
1472
- for (const [s, i] of Object.entries(e)) s.startsWith(Ft) && i.data && Object.assign(t, i.data);
1487
+ for (const [s, i] of Object.entries(e)) s.startsWith($t) && i.data && Object.assign(t, i.data);
1473
1488
  return t;
1474
1489
  }
1475
- function $t(e) {
1490
+ function Pt(e) {
1476
1491
  const t = e["current-page"]?.data;
1477
1492
  return t?.page ? t.page : t?.url ? t.url : e["browser-page"]?.data?.url;
1478
1493
  }
1479
- function Mt(e, t) {
1494
+ function Nt(e, t) {
1480
1495
  return e === t ? !0 : JSON.stringify(e) === JSON.stringify(t);
1481
1496
  }
1482
- function Pt(e, t) {
1497
+ function Ot(e, t) {
1483
1498
  const s = [];
1484
1499
  for (const i of Object.keys(t))
1485
- i in e && (Mt(e[i], t[i]) || s.push({
1500
+ i in e && (Nt(e[i], t[i]) || s.push({
1486
1501
  field: i,
1487
1502
  from: e[i],
1488
1503
  to: t[i]
1489
1504
  }));
1490
1505
  return s;
1491
1506
  }
1492
- function Nt(e, t) {
1493
- const s = Dt(t), i = $t(t);
1507
+ function Lt(e, t) {
1508
+ const s = Mt(t), i = Pt(t);
1494
1509
  return {
1495
- changes: e && e.page === i ? Pt(e.state, s) : [],
1510
+ changes: e && e.page === i ? Ot(e.state, s) : [],
1496
1511
  baseline: {
1497
1512
  page: i,
1498
1513
  state: s
@@ -1502,7 +1517,7 @@ function Nt(e, t) {
1502
1517
  function q(e) {
1503
1518
  return e === null || typeof e != "object" ? JSON.stringify(e) ?? "null" : Array.isArray(e) ? `[${e.map(q).join(",")}]` : `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${q(e[t])}`).join(",")}}`;
1504
1519
  }
1505
- var ce = "", Ot = class {
1520
+ var ce = "", Ut = class {
1506
1521
  constructor(e, t = {}) {
1507
1522
  this.callbacks = e, this.options = t, this.buffer = "", this.message = {}, this.toolCalls = [], this.sources = [], this.followUpReplies = [], this.isFirstChunk = !0, this.answerCompleteEmitted = !1, this.waitingClientEmitted = !1, this.firedClientFunctions = /* @__PURE__ */ new Map();
1508
1523
  }
@@ -1632,11 +1647,11 @@ var ce = "", Ot = class {
1632
1647
  return e.status !== "WAITING_CLIENT" && this.callbacks.onComplete?.(e), e;
1633
1648
  }
1634
1649
  };
1635
- function ns(e) {
1650
+ function as(e) {
1636
1651
  const t = e.message.toLowerCase();
1637
1652
  return t.includes("load failed") || t.includes("failed to fetch") || t.includes("network") || t.includes("abort");
1638
1653
  }
1639
- var Lt = /* @__PURE__ */ new Set([
1654
+ var jt = /* @__PURE__ */ new Set([
1640
1655
  "image/jpeg",
1641
1656
  "image/png",
1642
1657
  "image/gif",
@@ -1644,7 +1659,7 @@ var Lt = /* @__PURE__ */ new Set([
1644
1659
  "image/bmp",
1645
1660
  "image/tiff"
1646
1661
  ]);
1647
- function jt(e) {
1662
+ function Wt(e) {
1648
1663
  if (!e) return;
1649
1664
  const t = typeof window < "u" && window.location ? window.location.href : "https://ago.local/";
1650
1665
  try {
@@ -1653,16 +1668,16 @@ function jt(e) {
1653
1668
  } catch {
1654
1669
  }
1655
1670
  }
1656
- function rs(e) {
1657
- return e.isSafeImage === !0 && typeof e.contentType == "string" && e.contentType.startsWith("image/") && jt(e.url) !== void 0;
1671
+ function cs(e) {
1672
+ return e.isSafeImage === !0 && typeof e.contentType == "string" && e.contentType.startsWith("image/") && Wt(e.url) !== void 0;
1658
1673
  }
1659
- function os(e) {
1674
+ function ls(e) {
1660
1675
  if (e == null || e < 0) return "";
1661
1676
  if (e < 1024) return `${e} B`;
1662
1677
  const t = e / 1024;
1663
1678
  return t < 1024 ? `${t.toFixed(1)} KB` : `${(t / 1024).toFixed(1)} MB`;
1664
1679
  }
1665
- function Ut(e) {
1680
+ function Bt(e) {
1666
1681
  return {
1667
1682
  id: String(e.id ?? ""),
1668
1683
  name: typeof e.name == "string" && e.name ? e.name : "file",
@@ -1672,17 +1687,17 @@ function Ut(e) {
1672
1687
  isSafeImage: e.is_safe_image === !0
1673
1688
  };
1674
1689
  }
1675
- function as(e) {
1690
+ function us(e) {
1676
1691
  return e.map((t, s) => ({
1677
1692
  id: `local-${s}-${t.name}`,
1678
1693
  name: t.name,
1679
1694
  contentType: t.type || void 0,
1680
1695
  fileSize: t.size,
1681
1696
  url: typeof URL < "u" && URL.createObjectURL ? URL.createObjectURL(t) : void 0,
1682
- isSafeImage: Lt.has(t.type)
1697
+ isSafeImage: jt.has(t.type)
1683
1698
  }));
1684
1699
  }
1685
- var Wt = class {
1700
+ var Gt = class {
1686
1701
  constructor() {
1687
1702
  this.handlers = /* @__PURE__ */ new Map();
1688
1703
  }
@@ -1723,12 +1738,12 @@ var Wt = class {
1723
1738
  removeAllListeners(e) {
1724
1739
  e ? this.handlers.delete(e) : this.handlers.clear();
1725
1740
  }
1726
- }, Bt = 4e3, Gt = 150, qt = 600;
1727
- function Kt() {
1741
+ }, qt = 4e3, Kt = 150, Jt = 600;
1742
+ function Ht() {
1728
1743
  if (!(typeof document > "u"))
1729
1744
  return document.modelContext;
1730
1745
  }
1731
- function Jt(e, t) {
1746
+ function zt(e, t) {
1732
1747
  return new Promise((s) => {
1733
1748
  let i, n = !1;
1734
1749
  const r = () => {
@@ -1738,16 +1753,16 @@ function Jt(e, t) {
1738
1753
  d(), s();
1739
1754
  }
1740
1755
  }, o = () => {
1741
- clearTimeout(l), clearTimeout(i), i = setTimeout(r, Gt);
1742
- }, a = setTimeout(r, Bt), l = setTimeout(r, qt), d = e(o);
1756
+ clearTimeout(l), clearTimeout(i), i = setTimeout(r, Kt);
1757
+ }, a = setTimeout(r, qt), l = setTimeout(r, Jt), d = e(o);
1743
1758
  for (const u of t) {
1744
1759
  if (u?.aborted) return r();
1745
1760
  u?.addEventListener("abort", r);
1746
1761
  }
1747
1762
  });
1748
1763
  }
1749
- function Ht(e) {
1750
- const t = Kt();
1764
+ function Xt(e) {
1765
+ const t = Ht();
1751
1766
  if (!t)
1752
1767
  return c.log("WebMCP is not available in this browser; bridge not attached"), () => {
1753
1768
  };
@@ -1773,9 +1788,9 @@ function Ht(e) {
1773
1788
  description: h.schema.description,
1774
1789
  inputSchema: h.schema.parameters,
1775
1790
  annotations: p?.annotations,
1776
- execute: async (E, _e) => {
1791
+ execute: async (E, Ce) => {
1777
1792
  const z = await e.runExternalFunction(m, E ?? {});
1778
- return !o && d(m, z) && await Jt((Ce) => e.onFunctionsChanged(Ce), [_e?.signal, r.signal]), z;
1793
+ return !o && d(m, z) && await zt((Ae) => e.onFunctionsChanged(Ae), [Ce?.signal, r.signal]), z;
1779
1794
  }
1780
1795
  };
1781
1796
  y.set(m, {
@@ -1818,19 +1833,19 @@ function Ht(e) {
1818
1833
  }
1819
1834
  };
1820
1835
  }
1821
- var zt = "/api/sdk/v1/client-function-calls", le = "ago_webmcp_tab";
1822
- function Xt() {
1836
+ var Vt = "/api/sdk/v1/client-function-calls", le = "ago_webmcp_tab";
1837
+ function Yt() {
1823
1838
  try {
1824
1839
  const e = sessionStorage.getItem(le);
1825
1840
  if (e) return e;
1826
- const t = x();
1841
+ const t = F();
1827
1842
  return sessionStorage.setItem(le, t), t;
1828
1843
  } catch {
1829
1844
  return;
1830
1845
  }
1831
1846
  }
1832
- function Vt(e, t) {
1833
- const { name: s } = t.schema, i = Xt(), n = {
1847
+ function Qt(e, t) {
1848
+ const { name: s } = t.schema, i = Yt(), n = {
1834
1849
  function_name: s,
1835
1850
  arguments: t.args,
1836
1851
  result: t.error === void 0 ? t.result ?? null : null,
@@ -1839,34 +1854,34 @@ function Vt(e, t) {
1839
1854
  ...i ? { tab_id: i } : {},
1840
1855
  ...e.declared.has(s) ? {} : { client_functions: [t.schema] }
1841
1856
  };
1842
- e.post(zt, n, t.navigates ? { keepalive: !0 } : void 0).then(() => {
1857
+ e.post(Vt, n, t.navigates ? { keepalive: !0 } : void 0).then(() => {
1843
1858
  e.declared.add(s);
1844
1859
  }).catch((r) => {
1845
1860
  c.debug("External call report failed:", r);
1846
1861
  });
1847
1862
  }
1848
- var ue = '`baseUrl` is required, e.g. new AgoClient({ baseUrl: "https://YOUR-DOMAIN.api.useago.com" }). Try the public demo account https://playground.api.useago.com (agent generic-guide). See docs/general/configuration.md#error-codes (config_missing_base_url).', Yt = /^[a-z][a-z0-9+.-]*:\/\//i, de = !1;
1863
+ var ue = '`baseUrl` is required, e.g. new AgoClient({ baseUrl: "https://YOUR-DOMAIN.api.useago.com" }). Try the public demo account https://playground.api.useago.com (agent generic-guide). See docs/general/configuration.md#error-codes (config_missing_base_url).', Zt = /^[a-z][a-z0-9+.-]*:\/\//i, de = !1;
1849
1864
  function he(e, t = "AgoClient") {
1850
- if (typeof e != "object" || e === null) throw new S(`${t}: ${ue}`, "config_missing_base_url");
1865
+ if (typeof e != "object" || e === null) throw new _(`${t}: ${ue}`, "config_missing_base_url");
1851
1866
  const s = e.baseUrl;
1852
- if (typeof s != "string" || s.trim() === "") throw new S(`${t}: ${ue}`, "config_missing_base_url");
1853
- N(e.language), !s.startsWith("/") && !Yt.test(s) && (de || (de = !0, console.warn(`[AGO] ${t}: \`baseUrl\` has no protocol and is not a relative path (config_suspect_base_url). Requests will fail: Node throws a URL parse error, browsers fetch it as a relative path. Use "https://..." (or a "/path" for a same-origin proxy).`)));
1867
+ if (typeof s != "string" || s.trim() === "") throw new _(`${t}: ${ue}`, "config_missing_base_url");
1868
+ S(e.language), !s.startsWith("/") && !Zt.test(s) && (de || (de = !0, console.warn(`[AGO] ${t}: \`baseUrl\` has no protocol and is not a relative path (config_suspect_base_url). Requests will fail: Node throws a URL parse error, browsers fetch it as a relative path. Use "https://..." (or a "/path" for a same-origin proxy).`)));
1854
1869
  }
1855
- var Qt = "activity:recent", Zt = "state:delta", ge = "errors:recent";
1870
+ var es = "activity:recent", ts = "state:delta", ge = "errors:recent";
1856
1871
  function fe(e) {
1857
1872
  return e === "setPageState" ? "readPageData" : `read${e.charAt(0).toUpperCase()}${e.slice(1)}Data`;
1858
1873
  }
1859
- var cs = class R {
1874
+ var ds = class T {
1860
1875
  constructor(t) {
1861
- this.errorWatcher = null, this.lastSentPageState = null, this.warnedEmptyConversations = /* @__PURE__ */ new Set(), this.declaredExternally = /* @__PURE__ */ new Set(), this.warnedPageDataPlaceholder = !1, this.pageDataCompanions = /* @__PURE__ */ new Set(), this.pendingResumes = /* @__PURE__ */ new Map(), this.pendingApprovals = /* @__PURE__ */ new Map(), this.resumeGate = null, this.activeTurn = null, this.pausedTurn = null, this.stoppedTurnIds = /* @__PURE__ */ new Set(), this.proactive = null, this.detachWebMCP = null, this.listPagesRegistered = !1, he(t, "AgoClient"), this.config = t, this.activityLedger = new ke(t.maxActivityEntries), this.httpClient = new Ie(t), this.functionRegistry = new Le({ maxResultBytes: t.maxFunctionResultBytes }), this.contextRegistry = new xt(), this.eventEmitter = new Wt(), this.registerActivityContext(), this.functionRegistry.onChange(() => {
1876
+ this.errorWatcher = null, this.lastSentPageState = null, this.warnedEmptyConversations = /* @__PURE__ */ new Set(), this.declaredExternally = /* @__PURE__ */ new Set(), this.warnedPageDataPlaceholder = !1, this.pageDataCompanions = /* @__PURE__ */ new Set(), this.pendingResumes = /* @__PURE__ */ new Map(), this.pendingApprovals = /* @__PURE__ */ new Map(), this.resumeGate = null, this.activeTurn = null, this.pausedTurn = null, this.stoppedTurnIds = /* @__PURE__ */ new Set(), this.proactive = null, this.detachWebMCP = null, this.listPagesRegistered = !1, he(t, "AgoClient"), this.config = t, this.activityLedger = new Re(t.maxActivityEntries), this.httpClient = new Fe(t), this.functionRegistry = new je({ maxResultBytes: t.maxFunctionResultBytes }), this.contextRegistry = new Dt(), this.eventEmitter = new Gt(), this.registerActivityContext(), this.functionRegistry.onChange(() => {
1862
1877
  this.eventEmitter.emit("functions:changed", this.functionRegistry.getSchemas());
1863
1878
  }), t.debug && c.enable(), t.errorWatcher && this.enableErrorWatcher(t.errorWatcher === !0 ? void 0 : t.errorWatcher), t.proactive && ae(this, t.proactive), this.attachWebMCPBridge(), c.log("AgoClient initialized");
1864
1879
  }
1865
1880
  attachWebMCPBridge() {
1866
- !this.config.webmcp || this.detachWebMCP || (this.detachWebMCP = Ht(this));
1881
+ !this.config.webmcp || this.detachWebMCP || (this.detachWebMCP = Xt(this));
1867
1882
  }
1868
1883
  async sendMessage(t, s) {
1869
- if (typeof t != "string" || !t.trim()) throw new S("Add message text before sending, including when attaching files. See docs/general/core.md#file-attachments.", "message_empty_content");
1884
+ if (typeof t != "string" || !t.trim()) throw new _("Add message text before sending, including when attaching files. See docs/general/core.md#file-attachments.", "message_empty_content");
1870
1885
  const i = this.functionRegistry.getSchemas(), n = this.buildSendContext(), r = this.config.agent || this.config.defaultAgentId, o = this.resolveClientFunctionsMode(s), a = s?.metadata !== void 0 ? s.metadata : this.config.metadata, l = a != null ? JSON.stringify(a) : void 0, d = {
1871
1886
  content: t,
1872
1887
  conversation_id: s?.conversationId,
@@ -1893,7 +1908,7 @@ var cs = class R {
1893
1908
  }
1894
1909
  async processSSEResponse(t, s) {
1895
1910
  let i = !1;
1896
- const n = new Ot({
1911
+ const n = new Ut({
1897
1912
  onRawChunk: (r) => {
1898
1913
  s && (r.message_id && !s.messageId && (s.messageId = r.message_id), r.thread?.id && (s.conversationId = r.thread.id)), this.eventEmitter.emit("stream:message", r);
1899
1914
  },
@@ -1931,7 +1946,7 @@ var cs = class R {
1931
1946
  onError: (r) => {
1932
1947
  this.eventEmitter.emit("message:error", {
1933
1948
  error: r.message,
1934
- code: r instanceof S ? r.code : void 0
1949
+ code: r instanceof _ ? r.code : void 0
1935
1950
  });
1936
1951
  }
1937
1952
  }, { signal: s?.controller.signal });
@@ -2128,7 +2143,7 @@ var cs = class R {
2128
2143
  }
2129
2144
  async runExternalFunction(t, s) {
2130
2145
  const i = {
2131
- invocationId: `webmcp-${x()}`,
2146
+ invocationId: `webmcp-${F()}`,
2132
2147
  functionName: t,
2133
2148
  arguments: s,
2134
2149
  conversationId: ""
@@ -2152,7 +2167,7 @@ var cs = class R {
2152
2167
  }
2153
2168
  reportExternalCall(t, s, i, n) {
2154
2169
  const r = this.functionRegistry.get(t);
2155
- r && Vt({
2170
+ r && Qt({
2156
2171
  post: (o, a, l) => this.httpClient.post(o, a, l),
2157
2172
  declared: this.declaredExternally
2158
2173
  }, {
@@ -2195,8 +2210,8 @@ var cs = class R {
2195
2210
  title: o,
2196
2211
  url: a ?? void 0
2197
2212
  })) : void 0,
2198
- toolCalls: R.mapPersistedToolCalls(n.tool_call_data),
2199
- attachments: n.attachments && n.attachments.length > 0 ? n.attachments.map(Ut) : void 0,
2213
+ toolCalls: T.mapPersistedToolCalls(n.tool_call_data),
2214
+ attachments: n.attachments && n.attachments.length > 0 ? n.attachments.map(Bt) : void 0,
2200
2215
  followUpReplies: n.follow_up_replies && n.follow_up_replies.length > 0 ? n.follow_up_replies : void 0
2201
2216
  }))
2202
2217
  };
@@ -2229,24 +2244,29 @@ var cs = class R {
2229
2244
  const i = new FormData();
2230
2245
  return i.append("file", t, t.name), (await this.httpClient.postFormData("/api/sdk/v1/audio/transcriptions", i, s)).json();
2231
2246
  }
2247
+ getLanguage() {
2248
+ return S(this.config.language);
2249
+ }
2232
2250
  async getConfig() {
2233
- const t = await this.httpClient.get("/api/sdk/v1/config");
2251
+ const t = new URLSearchParams({ ticket_form_i18n: "1" });
2252
+ t.set("language", Te(this.config.language));
2253
+ const s = await this.httpClient.get(`/api/sdk/v1/config?${t}`);
2234
2254
  return {
2235
- permissions: (t.permissions ?? []).map((s) => ({
2236
- id: s.id ?? void 0,
2237
- name: s.name ?? void 0,
2238
- displayName: s.display_name ?? void 0,
2239
- agents: (s.agents ?? []).map((i) => ({
2240
- id: i.id,
2241
- name: i.name ?? void 0
2255
+ permissions: (s.permissions ?? []).map((i) => ({
2256
+ id: i.id ?? void 0,
2257
+ name: i.name ?? void 0,
2258
+ displayName: i.display_name ?? void 0,
2259
+ agents: (i.agents ?? []).map((n) => ({
2260
+ id: n.id,
2261
+ name: n.name ?? void 0
2242
2262
  })),
2243
- ticketForm: s.ticket_form ? R.mapTicketForm(s.ticket_form) : void 0,
2244
- homePage: s.home_page ? R.mapHomePage(s.home_page) : void 0,
2245
- fileAttachmentsEnabled: !!s.file_attachments_enabled,
2246
- voiceEnabled: !!s.voice_enabled,
2247
- speechToTextEnabled: !!s.speech_to_text_enabled
2263
+ ticketForm: i.ticket_form ? T.mapTicketForm(i.ticket_form) : void 0,
2264
+ homePage: i.home_page ? T.mapHomePage(i.home_page) : void 0,
2265
+ fileAttachmentsEnabled: !!i.file_attachments_enabled,
2266
+ voiceEnabled: !!i.voice_enabled,
2267
+ speechToTextEnabled: !!i.speech_to_text_enabled
2248
2268
  })),
2249
- proactive: { enabled: !!t.proactive?.enabled }
2269
+ proactive: { enabled: !!s.proactive?.enabled }
2250
2270
  };
2251
2271
  }
2252
2272
  static mapHomePage(t) {
@@ -2274,6 +2294,7 @@ var cs = class R {
2274
2294
  return {
2275
2295
  id: t.id,
2276
2296
  name: t.name ?? void 0,
2297
+ embedDescription: t.embed_description ?? void 0,
2277
2298
  mode: t.mode === "embed" ? "embed" : "form",
2278
2299
  showSubject: t.show_subject ?? !0,
2279
2300
  showBody: t.show_body ?? !0,
@@ -2286,6 +2307,7 @@ var cs = class R {
2286
2307
  id: s.id,
2287
2308
  externalId: s.external_id ?? void 0,
2288
2309
  title: s.title ?? void 0,
2310
+ prefillAliases: s.prefill_aliases,
2289
2311
  type: s.type ?? void 0,
2290
2312
  required: !!s.required,
2291
2313
  hidden: !!s.hidden,
@@ -2399,7 +2421,7 @@ var cs = class R {
2399
2421
  let n = i?.lastMessageId;
2400
2422
  if (!n) {
2401
2423
  const r = [...(await this.getConversation(t)).messages ?? []].reverse().find((o) => o.role === "assistant" && !o.hidden && !!o.content && o.status !== "IN_PROGRESS" && o.status !== "WAITING_CLIENT");
2402
- if (!r) throw new S(`Conversation ${t} has no finished answer to report feedback on. Wait for the turn to complete, or pass \`lastMessageId\`.`, "feedback_no_message");
2424
+ if (!r) throw new _(`Conversation ${t} has no finished answer to report feedback on. Wait for the turn to complete, or pass \`lastMessageId\`.`, "feedback_no_message");
2403
2425
  n = r.id;
2404
2426
  }
2405
2427
  return await this.submitFeedback(n, s, i), n;
@@ -2427,9 +2449,9 @@ var cs = class R {
2427
2449
  return this.functionRegistry.execute(t, s);
2428
2450
  }
2429
2451
  registerNavigationFunction(t, s, i) {
2430
- this.registerFunction(Ze(t, s, i)), i?.catalogue === "onDemand" ? (this.registerFunction(et(s)), this.listPagesRegistered = !0) : this.listPagesRegistered && (this.unregisterFunction(T), this.listPagesRegistered = !1), this.addDynamicContext("current-page", () => {
2452
+ this.registerFunction(tt(t, s, i)), i?.catalogue === "onDemand" ? (this.registerFunction(st(s)), this.listPagesRegistered = !0) : this.listPagesRegistered && (this.unregisterFunction(I), this.listPagesRegistered = !1), this.addDynamicContext("current-page", () => {
2431
2453
  if (typeof window > "u" || !window.location) return null;
2432
- const n = window.location.href, r = Ye(window.location.pathname, s), o = { url: n };
2454
+ const n = window.location.href, r = Ze(window.location.pathname, s), o = { url: n };
2433
2455
  return r && (o.page = r.name), {
2434
2456
  name: "Current page",
2435
2457
  description: "The page the user is currently viewing.",
@@ -2438,11 +2460,11 @@ var cs = class R {
2438
2460
  });
2439
2461
  }
2440
2462
  unregisterNavigationFunction() {
2441
- this.unregisterFunction(J), this.listPagesRegistered && (this.unregisterFunction(T), this.listPagesRegistered = !1), this.removeDynamicContext("current-page");
2463
+ this.unregisterFunction(J), this.listPagesRegistered && (this.unregisterFunction(I), this.listPagesRegistered = !1), this.removeDynamicContext("current-page");
2442
2464
  }
2443
2465
  registerPageStateFunction(t, s) {
2444
2466
  const i = s?.functionName ?? "setPageState", n = s?.data;
2445
- this.registerFunction(nt(t, {
2467
+ this.registerFunction(ot(t, {
2446
2468
  name: i,
2447
2469
  requiresApproval: s?.requiresApproval,
2448
2470
  getResultBudget: () => n ? this.pageDataBudget(n) : this.functionRegistry.getDefaultMaxResultBytes(),
@@ -2488,7 +2510,7 @@ var cs = class R {
2488
2510
  })) - 4;
2489
2511
  }
2490
2512
  readPageData(t, s, i) {
2491
- return qe(() => s, i?.settleTimeoutMs ?? 1e4).catch((n) => (c.warn(`Reading page data for "${t}" failed:`, n), {
2513
+ return Je(() => s, i?.settleTimeoutMs ?? 1e4).catch((n) => (c.warn(`Reading page data for "${t}" failed:`, n), {
2492
2514
  error: "page_data_unavailable",
2493
2515
  message: n instanceof Error ? n.message : String(n)
2494
2516
  }));
@@ -2548,10 +2570,10 @@ var cs = class R {
2548
2570
  return this.contextRegistry.getSnapshot();
2549
2571
  }
2550
2572
  buildSendContext() {
2551
- const t = this.contextRegistry.getSnapshot(), s = t?.entries ?? {}, { changes: i, baseline: n } = Nt(this.lastSentPageState, s);
2573
+ const t = this.contextRegistry.getSnapshot(), s = t?.entries ?? {}, { changes: i, baseline: n } = Lt(this.lastSentPageState, s);
2552
2574
  return this.lastSentPageState = n, i.length === 0 ? t : { entries: {
2553
2575
  ...s,
2554
- [Zt]: {
2576
+ [ts]: {
2555
2577
  name: "State changes",
2556
2578
  description: "Fields in the page state that changed since your last message, as field: <old> -> <new>.",
2557
2579
  data: { changes: i }
@@ -2586,7 +2608,7 @@ var cs = class R {
2586
2608
  });
2587
2609
  }
2588
2610
  registerActivityContext() {
2589
- this.contextRegistry.addDynamicProvider(Qt, () => {
2611
+ this.contextRegistry.addDynamicProvider(es, () => {
2590
2612
  const t = this.activityLedger.getRecent();
2591
2613
  return t.length === 0 ? null : {
2592
2614
  name: "Recent activity",
@@ -2597,7 +2619,7 @@ var cs = class R {
2597
2619
  }
2598
2620
  enableErrorWatcher(t) {
2599
2621
  this.disableErrorWatcher();
2600
- const s = new $e(t);
2622
+ const s = new Pe(t);
2601
2623
  this.errorWatcher = s, s.start(), s.subscribe((i) => {
2602
2624
  this.eventEmitter.emit("error:captured", i), this.notifyContextChanged();
2603
2625
  }), this.contextRegistry.addDynamicProvider(ge, () => {
@@ -2645,12 +2667,14 @@ var cs = class R {
2645
2667
  }
2646
2668
  updateConfig(t) {
2647
2669
  const s = {};
2648
- for (const [n, r] of Object.entries(t)) r !== void 0 && (s[n] = r);
2670
+ for (const [o, a] of Object.entries(t)) a !== void 0 && (s[o] = a);
2649
2671
  const i = {
2650
2672
  ...this.config,
2651
2673
  ...s
2652
2674
  };
2653
- he(i, "AgoClient.updateConfig"), this.config = i, this.httpClient.updateConfig(s), s.debug !== void 0 && (s.debug ? c.enable() : c.disable()), s.maxFunctionResultBytes !== void 0 && this.functionRegistry.setDefaultMaxResultBytes(s.maxFunctionResultBytes), s.errorWatcher !== void 0 && (s.errorWatcher ? this.enableErrorWatcher(s.errorWatcher === !0 ? void 0 : s.errorWatcher) : this.disableErrorWatcher());
2675
+ he(i, "AgoClient.updateConfig");
2676
+ const n = S(i.language), r = n !== S(this.config.language);
2677
+ this.config = i, this.httpClient.updateConfig(s), r && this.eventEmitter.emit("config:changed", { language: n }), s.debug !== void 0 && (s.debug ? c.enable() : c.disable()), s.maxFunctionResultBytes !== void 0 && this.functionRegistry.setDefaultMaxResultBytes(s.maxFunctionResultBytes), s.errorWatcher !== void 0 && (s.errorWatcher ? this.enableErrorWatcher(s.errorWatcher === !0 ? void 0 : s.errorWatcher) : this.disableErrorWatcher());
2654
2678
  }
2655
2679
  destroy() {
2656
2680
  this.proactive?.destroy(), this.proactive = null, this.errorWatcher?.destroy(), this.errorWatcher = null, this.detachWebMCP?.(), this.detachWebMCP = null, this.activeTurn?.controller.abort(), this.activeTurn = null, this.pausedTurn = null, this.stoppedTurnIds.clear(), this.eventEmitter.removeAllListeners(), this.functionRegistry.clear(), this.listPagesRegistered = !1, this.contextRegistry.clear(), this.pendingResumes.clear(), this.pendingApprovals.clear(), this.resumeGate = null, c.log("AgoClient destroyed");
@@ -2658,35 +2682,36 @@ var cs = class R {
2658
2682
  reviveAfterDestroy() {
2659
2683
  this.registerActivityContext(), this.config.errorWatcher && !this.errorWatcher && this.enableErrorWatcher(this.config.errorWatcher === !0 ? void 0 : this.config.errorWatcher), this.config.proactive && !this.proactive && ae(this, this.config.proactive), this.attachWebMCPBridge();
2660
2684
  }
2661
- }, ls = [
2685
+ }, hs = [
2662
2686
  "inaccurate",
2663
2687
  "incomplete",
2664
2688
  "information_not_found",
2665
2689
  "technical_issue"
2666
2690
  ];
2667
2691
  export {
2668
- ke as C,
2692
+ ns as C,
2669
2693
  c as S,
2670
- ht as _,
2671
- as as a,
2672
- is as b,
2673
- jt as c,
2674
- xt as d,
2694
+ is as T,
2695
+ ft as _,
2696
+ us as a,
2697
+ os as b,
2698
+ Wt as c,
2699
+ Dt as d,
2675
2700
  ae as f,
2676
- gt as g,
2701
+ mt as g,
2677
2702
  Se as h,
2678
- Wt as i,
2679
- Ot as l,
2680
- Et as m,
2681
- cs as n,
2682
- rs as o,
2683
- wt as p,
2703
+ Gt as i,
2704
+ Ut as l,
2705
+ _t as m,
2706
+ ds as n,
2707
+ cs as o,
2708
+ bt as p,
2684
2709
  he as r,
2685
- os as s,
2686
- ls as t,
2687
- ns as u,
2688
- Le as v,
2689
- ts as w,
2690
- $e as x,
2691
- ss as y
2710
+ ls as s,
2711
+ hs as t,
2712
+ as as u,
2713
+ je as v,
2714
+ Re as w,
2715
+ Pe as x,
2716
+ rs as y
2692
2717
  };