@gengage/assistant-fe 0.6.17 → 0.6.19

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 (51) hide show
  1. package/dist/account-config-D_EMuR0g.js +1479 -0
  2. package/dist/agentic/context/context-store.d.ts +2 -1
  3. package/dist/agentic/events/comparison.d.ts +6 -0
  4. package/dist/agentic/events/context-products.d.ts +6 -0
  5. package/dist/agentic/index.d.ts +7 -0
  6. package/dist/agentic/index.js +245 -188
  7. package/dist/agentic/types.d.ts +6 -1
  8. package/dist/agentic/util/account-config.d.ts +8 -0
  9. package/dist/agentic/util/privacy.d.ts +12 -0
  10. package/dist/agentic/widgets/endpoints.d.ts +12 -0
  11. package/dist/agentic/worker.d.ts +6 -0
  12. package/dist/agentic/worker.js +80 -69
  13. package/dist/agentic.iife.js +7 -5
  14. package/dist/{api-paths-xsHH9jtm.js → api-paths-lIioK7-S.js} +1 -1
  15. package/dist/chat/components/InlineLauncher.d.ts +1 -1
  16. package/dist/chat-runtime.js +1 -1
  17. package/dist/{chat-BP-yXukW.js → chat-rvSffJXw.js} +1 -1
  18. package/dist/chat.iife.js +11 -11
  19. package/dist/chat.js +2 -2
  20. package/dist/{common-O0BUdXOn.js → common-8WOyaL9-.js} +3 -3
  21. package/dist/common.js +8 -8
  22. package/dist/{connection-warning-DWMfjv0Y.js → connection-warning-CBR0CWsY.js} +1 -1
  23. package/dist/{fastIntent-RTSVRJhw.js → fastIntent-Dw79pmRK.js} +2 -2
  24. package/dist/index.js +13 -13
  25. package/dist/{native-webview-U9HtGabb.js → native-webview-NWc9LrJh.js} +1 -1
  26. package/dist/native.iife.js +2 -2
  27. package/dist/native.js +1 -1
  28. package/dist/{overlay-ClYgI2Kl.js → overlay-COzFFq0-.js} +1 -1
  29. package/dist/overlay.js +2 -2
  30. package/dist/{qna-B3lMzHvS.js → qna-DUs97irI.js} +1 -1
  31. package/dist/qna-runtime.js +1 -1
  32. package/dist/qna.iife.js +1 -1
  33. package/dist/qna.js +2 -2
  34. package/dist/{runtime-COh3CwNU.js → runtime-BsnZ6gt2.js} +8 -8
  35. package/dist/{runtime-n7fEJGDt.js → runtime-D5Sj-_tA.js} +6 -6
  36. package/dist/{runtime-BKU-NQXf.js → runtime-w0f2VkzL.js} +116 -116
  37. package/dist/{simbut-DaFCfvp7.js → simbut-BvdJtzCu.js} +3 -3
  38. package/dist/simbut.iife.js +1 -1
  39. package/dist/simbut.js +1 -1
  40. package/dist/{simrel-CX1JBDa5.js → simrel-DU6a27g9.js} +4 -4
  41. package/dist/simrel-runtime.js +1 -1
  42. package/dist/simrel.iife.js +2 -2
  43. package/dist/simrel.js +2 -2
  44. package/dist/{widget-base-DoZrhVze.js → widget-base-BeWuIxD6.js} +2 -2
  45. package/package.json +4 -2
  46. package/dist/request-text-DThlE-Xd.js +0 -1318
  47. /package/dist/{context-BBuSsXZ9.js → context-heG8hv5l.js} +0 -0
  48. /package/dist/{locale-CfqNifrU.js → locale-uQ5XZ2yS.js} +0 -0
  49. /package/dist/{price-formatter-CFsWT0lP.js → price-formatter-CHUmYq8I.js} +0 -0
  50. /package/dist/{request-response-cache-zsgz3Awp.js → request-response-cache-BxRsKGJ0.js} +0 -0
  51. /package/dist/{schemas-Cq2blsO_.js → schemas-BnYUhYSy.js} +0 -0
@@ -1,12 +1,12 @@
1
- import { A as Ne, B as Ge, C as J, D as He, E as Ke, F as Je, H as z, I as k, M as ze, N as We, O as Qe, P as W, R as Q, S as Y, T as Ye, U as V, _ as L, a as Ve, b as Xe, c as Ze, d as et, f as tt, g as rt, h as nt, i as ot, j as X, k as at, l as st, m as it, n as ct, o as lt, p as ut, r as dt, s as ft, t as pt, u as gt, v as wt, w as yt, x as ht, y as mt, z as bt } from "../request-text-DThlE-Xd.js";
1
+ import { $ as J, A as Ge, B as Ke, C as He, D as A, E as Je, F as ze, G as We, H as Qe, I as Ye, J as z, K as C, L as Ve, M as W, N as Q, O as Xe, P as Ze, Q as Y, R as et, S as tt, T as rt, U as nt, V, W as X, X as ot, Y as at, _ as st, a as it, b as ct, c as lt, d as ut, f as dt, g as ft, h as pt, i as gt, j as yt, k as mt, l as wt, m as ht, n as bt, o as St, p as Et, r as Pt, s as At, t as Rt, u as vt, v as Ut, w as xt, x as Tt, y as _t, z as kt } from "../account-config-D_EMuR0g.js";
2
2
  var Z = 512, ee = 0.74;
3
- function te({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: a, defaultLocale: c, tools: p = {}, beacon: y }) {
3
+ function te({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: a, defaultLocale: c, tools: p = {}, beacon: m }) {
4
4
  let f = 1;
5
5
  const u = /* @__PURE__ */ new Map();
6
- return z({
6
+ return Y({
7
7
  worker: t,
8
8
  tools: p,
9
- beacon: (l) => y?.({
9
+ beacon: (l) => m?.({
10
10
  ...l,
11
11
  accountId: l.accountId || e
12
12
  }),
@@ -27,20 +27,20 @@ function te({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl
27
27
  s.type === "end" && u.delete(i);
28
28
  }
29
29
  }), (l, s, i, d) => {
30
- const w = f++;
31
- u.set(w, s);
30
+ const y = f++;
31
+ u.set(y, s);
32
32
  const g = () => {
33
- u.delete(w), t.postMessage({
34
- id: w,
33
+ u.delete(y), t.postMessage({
34
+ id: y,
35
35
  type: "abort"
36
36
  });
37
- }, m = (h) => {
37
+ }, h = (w) => {
38
38
  if (i.aborted) {
39
39
  g();
40
40
  return;
41
41
  }
42
42
  t.postMessage({
43
- id: w,
43
+ id: y,
44
44
  type: "invoke",
45
45
  accountId: e,
46
46
  beUrl: r,
@@ -48,7 +48,7 @@ function te({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl
48
48
  tokenBrokerUrl: o,
49
49
  tokenBrokerAudience: a,
50
50
  defaultLocale: c,
51
- request: h,
51
+ request: w,
52
52
  parentUrl: window.location.href
53
53
  });
54
54
  };
@@ -57,64 +57,65 @@ function te({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl
57
57
  return;
58
58
  }
59
59
  if (i.addEventListener("abort", g, { once: !0 }), d) {
60
- C(l, d).then(m).catch((h) => {
61
- u.delete(w), s.onError(h instanceof Error ? h : /* @__PURE__ */ new Error("Failed to read image attachment"));
60
+ L(l, d).then(h).catch((w) => {
61
+ u.delete(y), s.onError(w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to read image attachment"));
62
62
  });
63
63
  return;
64
64
  }
65
- m(l);
65
+ h(l);
66
66
  };
67
67
  }
68
- function re({ accountId: e, accountModule: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: a, defaultLocale: c, tools: p = {}, beacon: y }) {
68
+ function re({ accountId: e, accountModule: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: a, defaultLocale: c, tools: p = {}, beacon: m }) {
69
69
  let f = null;
70
70
  const u = ne({
71
71
  accountId: e,
72
72
  tools: p,
73
- beacon: y
74
- }), l = Y(u), s = k({
73
+ beacon: m
74
+ }), l = W(u), s = C({
75
75
  accountId: e,
76
76
  ...n ? { devJwtSecret: n } : {},
77
77
  ...o ? { tokenBrokerUrl: o } : {},
78
78
  ...a ? { tokenBrokerAudience: a } : {}
79
79
  });
80
- return async (i, d, w, g) => {
81
- const m = await C(i || {}, g);
82
- f ||= new Q({
80
+ return async (i, d, y, g) => {
81
+ const h = await L(i || {}, g);
82
+ f ||= new z({
83
83
  accountId: e,
84
- locale: m?.locale || c,
84
+ locale: h?.locale || c,
85
85
  parentUrl: window.location.href,
86
86
  rpc: u,
87
- persistentPanelKeys: t.contextPersistence?.panelKeys
87
+ persistentPanelKeys: t.contextPersistence?.panelKeys,
88
+ panelKeyLimits: t.contextPersistence?.panelKeyLimits
88
89
  });
89
90
  try {
90
- await J({
91
- request: m,
91
+ await Q({
92
+ request: h,
92
93
  accountModule: {
93
94
  ...t,
94
95
  accountId: e
95
96
  },
96
97
  contextStore: f,
97
- beClient: { invoke({ op: h, input: S, signal: v, cacheTtlS: G, cacheKey: H, browserCache: K }) {
98
- return X({
98
+ beClient: { invoke({ op: w, input: S, signal: U, cacheTtlS: G, cacheKey: K, browserCache: H }) {
99
+ return V({
99
100
  beUrl: r,
100
101
  accountId: e,
101
102
  jwtProvider: s,
102
103
  parentUrl: window.location.href,
103
- op: h,
104
+ op: w,
104
105
  input: S,
105
106
  cacheTtlS: G,
106
- cacheKey: H,
107
- browserCache: K,
108
- ...v ? { signal: v } : {}
107
+ cacheKey: K,
108
+ browserCache: H,
109
+ ...U ? { signal: U } : {}
109
110
  });
110
111
  } },
111
112
  toolBridge: l,
112
- emit: (h) => E(d, h),
113
+ emit: (w) => E(d, w),
113
114
  rpc: u,
114
- signal: w
115
+ signal: y
115
116
  });
116
- } catch (h) {
117
- w?.aborted || (E(d, W(h)), d.onDone());
117
+ } catch (w) {
118
+ y?.aborted || (E(d, X(w)), d.onDone());
118
119
  }
119
120
  };
120
121
  }
@@ -123,13 +124,13 @@ function ne({ accountId: e, tools: t, beacon: r }) {
123
124
  ...o,
124
125
  accountId: o.accountId || e
125
126
  });
126
- return ((o, a) => V(o, a, {
127
+ return ((o, a) => J(o, a, {
127
128
  tools: t,
128
129
  beacon: n,
129
130
  memory: sessionStorage
130
131
  }));
131
132
  }
132
- async function C(e, t) {
133
+ async function L(e, t) {
133
134
  if (!t || !t.type?.startsWith("image/")) return e;
134
135
  const r = await se(t), n = {
135
136
  ...oe(e.payload ?? e.action?.payload),
@@ -154,7 +155,7 @@ function ae(e) {
154
155
  async function se(e) {
155
156
  const t = await ie(e);
156
157
  return t || {
157
- dataUrl: await M(e),
158
+ dataUrl: await j(e),
158
159
  mime: e.type
159
160
  };
160
161
  }
@@ -168,9 +169,9 @@ async function ie(e) {
168
169
  const c = a.getContext("2d");
169
170
  if (!c) return null;
170
171
  c.drawImage(t, 0, 0, n, o);
171
- const p = await new Promise((y) => a.toBlob(y, "image/jpeg", ee));
172
+ const p = await new Promise((m) => a.toBlob(m, "image/jpeg", ee));
172
173
  return p ? {
173
- dataUrl: await M(p),
174
+ dataUrl: await j(p),
174
175
  mime: p.type || "image/jpeg"
175
176
  } : null;
176
177
  } catch {
@@ -179,7 +180,7 @@ async function ie(e) {
179
180
  t?.close();
180
181
  }
181
182
  }
182
- async function M(e) {
183
+ async function j(e) {
183
184
  const t = new Uint8Array(await e.arrayBuffer());
184
185
  let r = "";
185
186
  const n = 32768;
@@ -223,18 +224,18 @@ var le = "entries", ue = 1, de = {
223
224
  session: "Current-visit tool context without raw tokens or PII-heavy payloads.",
224
225
  local: "Small, non-sensitive capability facts or user preferences.",
225
226
  indexedDb: "Larger product/search payload caches with short TTLs."
226
- }, P = /* @__PURE__ */ new Map();
227
- function A() {
227
+ }, x = /* @__PURE__ */ new Map();
228
+ function P() {
228
229
  return Date.now();
229
230
  }
230
- function U(e) {
231
- return e?.expiresAt != null && e.expiresAt <= A();
231
+ function R(e) {
232
+ return e?.expiresAt != null && e.expiresAt <= P();
232
233
  }
233
- function R(e, t) {
234
+ function v(e, t) {
234
235
  return {
235
236
  value: e,
236
- createdAt: A(),
237
- expiresAt: t ? A() + t : null
237
+ createdAt: P(),
238
+ expiresAt: t ? P() + t : null
238
239
  };
239
240
  }
240
241
  function fe(e, t, r) {
@@ -242,14 +243,14 @@ function fe(e, t, r) {
242
243
  const n = e.getItem(`${t}${r}`);
243
244
  if (!n) return null;
244
245
  const o = JSON.parse(n);
245
- return U(o) ? (e.removeItem(`${t}${r}`), null) : o.value;
246
+ return R(o) ? (e.removeItem(`${t}${r}`), null) : o.value;
246
247
  } catch {
247
248
  return null;
248
249
  }
249
250
  }
250
251
  function pe(e, t, r, n, o) {
251
252
  try {
252
- return e.setItem(`${t}${r}`, JSON.stringify(R(n, o))), !0;
253
+ return e.setItem(`${t}${r}`, JSON.stringify(v(n, o))), !0;
253
254
  } catch {
254
255
  return !1;
255
256
  }
@@ -267,7 +268,7 @@ function T(e) {
267
268
  return null;
268
269
  }
269
270
  }
270
- function x(e, t) {
271
+ function _(e, t) {
271
272
  return e ? {
272
273
  get: (r) => fe(e, t, r),
273
274
  set: (r, n, o = {}) => pe(e, t, r, n, o.ttlMs),
@@ -279,7 +280,7 @@ function x(e, t) {
279
280
  }
280
281
  };
281
282
  }
282
- function we(e, t) {
283
+ function ye(e, t) {
283
284
  const r = t.dbName || `gengage-${e}`, n = t.dbStore || le, o = t.dbVersion || ue, a = /* @__PURE__ */ new Map();
284
285
  let c = null;
285
286
  const p = () => "indexedDB" in window ? c || (c = new Promise((l) => {
@@ -293,24 +294,24 @@ function we(e, t) {
293
294
  idbGet: async (l) => {
294
295
  const s = await p();
295
296
  return s ? new Promise((i) => {
296
- const d = s.transaction(n, "readwrite").objectStore(n), w = d.get(l);
297
- w.onsuccess = () => {
298
- const g = w.result;
299
- if (!g || U(g)) {
297
+ const d = s.transaction(n, "readwrite").objectStore(n), y = d.get(l);
298
+ y.onsuccess = () => {
299
+ const g = y.result;
300
+ if (!g || R(g)) {
300
301
  g && d.delete(l), i(null);
301
302
  return;
302
303
  }
303
304
  i(g.value);
304
- }, w.onerror = () => i(null);
305
+ }, y.onerror = () => i(null);
305
306
  }) : null;
306
307
  },
307
308
  idbSet: async (l, s, i = {}) => {
308
309
  const d = await p();
309
- return d ? new Promise((w) => {
310
+ return d ? new Promise((y) => {
310
311
  const g = d.transaction(n, "readwrite");
311
- g.oncomplete = () => w(!0), g.onerror = () => w(!1), g.objectStore(n).put({
312
+ g.oncomplete = () => y(!0), g.onerror = () => y(!1), g.objectStore(n).put({
312
313
  key: l,
313
- ...R(s, i.ttlMs)
314
+ ...v(s, i.ttlMs)
314
315
  });
315
316
  }) : !1;
316
317
  },
@@ -320,17 +321,17 @@ function we(e, t) {
320
321
  }
321
322
  };
322
323
  }
323
- function j(e, t = {}) {
324
+ function M(e, t = {}) {
324
325
  const r = window, n = r.gengage || (r.gengage = {}), o = n.memory || (n.memory = {}), a = o[e];
325
326
  if (a) return a;
326
- const c = P.get(e) || we(e, t);
327
- P.set(e, c);
328
- const p = t.sessionPrefix || `gengage:${e}:session:`, y = t.localPrefix || `gengage:${e}:local:`, u = {
327
+ const c = x.get(e) || ye(e, t);
328
+ x.set(e, c);
329
+ const p = t.sessionPrefix || `gengage:${e}:session:`, m = t.localPrefix || `gengage:${e}:local:`, u = {
329
330
  get: (i) => {
330
331
  const d = c.volatileEntries.get(i);
331
- return d ? U(d) ? (c.volatileEntries.delete(i), null) : d.value : null;
332
+ return d ? R(d) ? (c.volatileEntries.delete(i), null) : d.value : null;
332
333
  },
333
- set: (i, d, w = {}) => (c.volatileEntries.set(i, R(d, w.ttlMs)), !0),
334
+ set: (i, d, y = {}) => (c.volatileEntries.set(i, v(d, y.ttlMs)), !0),
334
335
  remove: (i) => {
335
336
  c.volatileEntries.delete(i);
336
337
  },
@@ -342,10 +343,10 @@ function j(e, t = {}) {
342
343
  }, s = {
343
344
  accountId: e,
344
345
  volatile: u,
345
- session: x(T("sessionStorage"), p),
346
- local: x(T("localStorage"), y),
346
+ session: _(T("sessionStorage"), p),
347
+ local: _(T("localStorage"), m),
347
348
  indexedDb: l,
348
- stableKey: L,
349
+ stableKey: A,
349
350
  policy: {
350
351
  ...de,
351
352
  ...t.policy || {}
@@ -355,15 +356,15 @@ function j(e, t = {}) {
355
356
  for (const i of t.aliases || []) o[i] = s;
356
357
  return s;
357
358
  }
358
- var b = "__gengageAgentFetchBridge", ye = 1e3 * 60 * 60 * 24 * 14;
359
- function St({ accountId: e, streamTransport: t, endpoints: r = {}, endpointCache: n }) {
359
+ var b = "__gengageAgentFetchBridge", me = 1e3 * 60 * 60 * 24 * 14;
360
+ function Ct({ accountId: e, streamTransport: t, endpoints: r = {}, endpointCache: n }) {
360
361
  if (!e) throw new Error("accountId is required.");
361
362
  if (typeof t != "function") throw new Error("streamTransport is required.");
362
- const o = he(), a = `https://gengage-injector.invalid/${encodeURIComponent(e)}`, c = /* @__PURE__ */ new Set(), p = n ? Ue({
363
+ const o = we(), a = `https://gengage-injector.invalid/${encodeURIComponent(e)}`, c = /* @__PURE__ */ new Set(), p = n ? Ae({
363
364
  accountId: e,
364
365
  endpointCache: n,
365
366
  fetchImpl: o.originalFetch
366
- }) : void 0, y = (f) => {
367
+ }) : void 0, m = (f) => {
367
368
  const u = `${a}/chat/${f}`;
368
369
  c.add(u);
369
370
  const l = r[f], s = {
@@ -372,17 +373,17 @@ function St({ accountId: e, streamTransport: t, endpoints: r = {}, endpointCache
372
373
  };
373
374
  l && (s.endpointHandler = l), p && (s.endpointCache = p), o.routes.set(u, s);
374
375
  };
375
- y("process_action");
376
- for (const f of Object.keys(r)) f !== "process_action" && y(f);
376
+ m("process_action");
377
+ for (const f of Object.keys(r)) f !== "process_action" && m(f);
377
378
  return {
378
379
  middlewareUrl: a,
379
380
  stop() {
380
381
  for (const f of c) o.routes.delete(f);
381
- me(o);
382
+ he(o);
382
383
  }
383
384
  };
384
385
  }
385
- function he() {
386
+ function we() {
386
387
  const e = window, t = e[b];
387
388
  if (t) return t;
388
389
  const r = e.fetch.bind(e), n = {
@@ -395,7 +396,7 @@ function he() {
395
396
  return p ? Se(p, o, a) : r(o, a);
396
397
  }, e.fetch = n.installedFetch, e[b] = n, n;
397
398
  }
398
- function me(e) {
399
+ function he(e) {
399
400
  if (e.routes.size > 0) return;
400
401
  const t = window;
401
402
  t.fetch === e.installedFetch && (t.fetch = e.originalFetch), t[b] === e && delete t[b];
@@ -403,15 +404,15 @@ function me(e) {
403
404
  function B(e) {
404
405
  return typeof e == "string" ? e : e instanceof URL ? e.href : e?.url || "";
405
406
  }
406
- function _(e, t) {
407
+ function k(e, t) {
407
408
  if (t?.signal) return t.signal;
408
409
  if (typeof Request < "u" && e instanceof Request) return e.signal;
409
410
  }
410
- function I(e, t) {
411
+ function $(e, t) {
411
412
  return t?.body !== void 0 && t?.body !== null ? t.body : typeof Request < "u" && e instanceof Request ? e.clone().text() : null;
412
413
  }
413
414
  async function be(e, t) {
414
- const r = I(e, t);
415
+ const r = $(e, t);
415
416
  if (r instanceof FormData) {
416
417
  const o = r.get("request"), a = r.get("attachment");
417
418
  return {
@@ -424,7 +425,7 @@ async function be(e, t) {
424
425
  }
425
426
  async function Se(e, t, r) {
426
427
  if (e.endpoint && e.endpoint !== "process_action" && e.endpointHandler) {
427
- const f = new AbortController(), u = _(t, r);
428
+ const f = new AbortController(), u = k(t, r);
428
429
  let l = null;
429
430
  if (u) {
430
431
  const s = () => f.abort();
@@ -432,23 +433,23 @@ async function Se(e, t, r) {
432
433
  }
433
434
  try {
434
435
  const s = await Ee(t, r), i = {
435
- accountId: Ae(t),
436
+ accountId: Pe(t),
436
437
  endpoint: e.endpoint,
437
438
  signal: f.signal
438
439
  }, d = Re(e.endpointCache, e.endpoint, s, i.accountId);
439
440
  if (d) {
440
441
  const g = await ve(e.endpointCache, d, f.signal);
441
- if (g) return Le(g);
442
+ if (g) return Ce(g);
442
443
  }
443
- const w = await e.endpointHandler(s, i);
444
- return d && w.ok && await Pe(e.endpointCache, d, w.clone(), f.signal), w;
444
+ const y = await e.endpointHandler(s, i);
445
+ return d && y.ok && await Ue(e.endpointCache, d, y.clone(), f.signal), y;
445
446
  } finally {
446
447
  l?.();
447
448
  }
448
449
  }
449
- const n = new TextEncoder(), o = new AbortController(), a = _(t, r);
450
+ const n = new TextEncoder(), o = new AbortController(), a = k(t, r);
450
451
  let c = !1, p = null;
451
- const y = new ReadableStream({
452
+ const m = new ReadableStream({
452
453
  async start(f) {
453
454
  const u = (i) => {
454
455
  c || f.enqueue(n.encode(`${JSON.stringify(i)}
@@ -473,18 +474,18 @@ async function Se(e, t, r) {
473
474
  a.addEventListener("abort", i, { once: !0 }), p = () => a.removeEventListener("abort", i);
474
475
  }
475
476
  try {
476
- const { request: i, attachment: d } = await be(t, r), w = e.streamTransport(i, {
477
- onTextChunk: (g, m, h = {}) => u({
477
+ const { request: i, attachment: d } = await be(t, r), y = e.streamTransport(i, {
478
+ onTextChunk: (g, h, w = {}) => u({
478
479
  type: "text_chunk",
479
480
  content: g,
480
- final: m === !0,
481
- ...h
481
+ final: h === !0,
482
+ ...w
482
483
  }),
483
- onUISpec: (g, m, h, S) => u({
484
+ onUISpec: (g, h, w, S) => u({
484
485
  type: "ui_spec",
485
486
  spec: g,
486
- widget: m,
487
- ...h ? { panelHint: h } : {},
487
+ widget: h,
488
+ ...w ? { panelHint: w } : {},
488
489
  ...S ? { clearPanel: !0 } : {}
489
490
  }),
490
491
  onAction: (g) => {
@@ -504,7 +505,7 @@ async function Se(e, t, r) {
504
505
  u({ type: "done" }), l();
505
506
  }
506
507
  }, o.signal, d);
507
- Be(w) && (await w, o.signal.aborted || (u({ type: "done" }), l()));
508
+ Be(y) && (await y, o.signal.aborted || (u({ type: "done" }), l()));
508
509
  } catch (i) {
509
510
  o.signal.aborted || s(i);
510
511
  }
@@ -513,16 +514,16 @@ async function Se(e, t, r) {
513
514
  o.abort(), p?.(), c = !0;
514
515
  }
515
516
  });
516
- return new Response(y, {
517
+ return new Response(m, {
517
518
  status: 200,
518
519
  headers: { "Content-Type": "application/x-ndjson" }
519
520
  });
520
521
  }
521
522
  async function Ee(e, t) {
522
- const r = await Promise.resolve(I(e, t));
523
+ const r = await Promise.resolve($(e, t));
523
524
  return typeof r != "string" || r.trim() === "" ? {} : JSON.parse(r);
524
525
  }
525
- function Ae(e) {
526
+ function Pe(e) {
526
527
  try {
527
528
  const [t] = new URL(B(e)).pathname.split("/").filter(Boolean);
528
529
  return decodeURIComponent(t || "");
@@ -530,15 +531,15 @@ function Ae(e) {
530
531
  return "";
531
532
  }
532
533
  }
533
- function Ue({ accountId: e, endpointCache: t, fetchImpl: r }) {
534
+ function Ae({ accountId: e, endpointCache: t, fetchImpl: r }) {
534
535
  return {
535
536
  accountId: e,
536
537
  beUrl: t.beUrl,
537
538
  ...t.parentUrl ? { parentUrl: t.parentUrl } : {},
538
- ttlMs: t.ttlMs ?? ye,
539
+ ttlMs: t.ttlMs ?? me,
539
540
  policies: t.policies,
540
541
  fetchImpl: r,
541
- jwtProvider: k({
542
+ jwtProvider: C({
542
543
  accountId: e,
543
544
  ...t.devJwtSecret ? { devJwtSecret: t.devJwtSecret } : {},
544
545
  ...t.tokenBrokerUrl ? { tokenBrokerUrl: t.tokenBrokerUrl } : {},
@@ -562,25 +563,25 @@ function Re(e, t, r, n) {
562
563
  };
563
564
  }
564
565
  async function ve(e, t, r) {
565
- const n = F(e.accountId, t), o = await Ce(e.accountId, n);
566
- if ($(o)) return o;
567
- const a = await Te(e, t, r);
566
+ const n = F(e.accountId, t), o = await Le(e.accountId, n);
567
+ if (O(o)) return o;
568
+ const a = await xe(e, t, r);
568
569
  return a ? (await q(e.accountId, n, a, t.ttlMs), a) : null;
569
570
  }
570
- async function Pe(e, t, r, n) {
571
+ async function Ue(e, t, r, n) {
571
572
  try {
572
573
  const o = await ke(r);
573
- if (je(o.body)) return;
574
+ if (Me(o.body)) return;
574
575
  const a = F(e.accountId, t);
575
- await q(e.accountId, a, o, t.ttlMs), xe(e, t, o, n);
576
+ await q(e.accountId, a, o, t.ttlMs), Te(e, t, o, n);
576
577
  } catch {
577
578
  }
578
579
  }
579
- async function Te(e, t, r) {
580
+ async function xe(e, t, r) {
580
581
  try {
581
- const n = await e.fetchImpl(O(e.beUrl), {
582
+ const n = await e.fetchImpl(D(e.beUrl), {
582
583
  method: "POST",
583
- headers: await D(e, r),
584
+ headers: await I(e, r),
584
585
  body: JSON.stringify({
585
586
  partition: t.partition,
586
587
  key: t.key
@@ -589,16 +590,16 @@ async function Te(e, t, r) {
589
590
  });
590
591
  if (!n.ok) return null;
591
592
  const o = await n.json();
592
- return o.hit === !0 && $(o.payload) ? o.payload : null;
593
+ return o.hit === !0 && O(o.payload) ? o.payload : null;
593
594
  } catch {
594
595
  return null;
595
596
  }
596
597
  }
597
- async function xe(e, t, r, n) {
598
+ async function Te(e, t, r, n) {
598
599
  try {
599
- await e.fetchImpl(O(e.beUrl), {
600
+ await e.fetchImpl(D(e.beUrl), {
600
601
  method: "POST",
601
- headers: await D(e, n),
602
+ headers: await I(e, n),
602
603
  body: JSON.stringify({
603
604
  partition: t.partition,
604
605
  key: t.key,
@@ -610,7 +611,7 @@ async function xe(e, t, r, n) {
610
611
  } catch {
611
612
  }
612
613
  }
613
- async function D(e, t) {
614
+ async function I(e, t) {
614
615
  return {
615
616
  authorization: `Bearer ${await e.jwtProvider({
616
617
  signal: t,
@@ -627,60 +628,60 @@ function _e() {
627
628
  return "";
628
629
  }
629
630
  }
630
- function O(e) {
631
+ function D(e) {
631
632
  return `${String(e).replace(/\/+$/u, "")}/v1/cache`;
632
633
  }
633
634
  async function ke(e) {
634
635
  return {
635
636
  status: e.status,
636
637
  statusText: e.statusText,
637
- headers: [...e.headers.entries()].filter(([t]) => Me(t)),
638
+ headers: [...e.headers.entries()].filter(([t]) => je(t)),
638
639
  body: await e.text()
639
640
  };
640
641
  }
641
- function Le(e) {
642
+ function Ce(e) {
642
643
  return new Response(e.body, {
643
644
  status: e.status,
644
645
  statusText: e.statusText,
645
646
  headers: new Headers(e.headers)
646
647
  });
647
648
  }
648
- function $(e) {
649
+ function O(e) {
649
650
  if (!e || typeof e != "object" || Array.isArray(e)) return !1;
650
651
  const t = e;
651
652
  return typeof t.status == "number" && typeof t.statusText == "string" && typeof t.body == "string" && Array.isArray(t.headers);
652
653
  }
653
654
  function F(e, t) {
654
- return `endpoint-response:${L({
655
+ return `endpoint-response:${A({
655
656
  accountId: e,
656
657
  partition: t.partition,
657
658
  key: t.key
658
659
  })}`;
659
660
  }
660
- async function Ce(e, t) {
661
- const r = j(e);
661
+ async function Le(e, t) {
662
+ const r = M(e);
662
663
  return r.volatile.get(t) || await r.indexedDb.get(t) || r.local.get(t);
663
664
  }
664
665
  async function q(e, t, r, n) {
665
- const o = j(e);
666
+ const o = M(e);
666
667
  o.volatile.set(t, r, { ttlMs: n }), await o.indexedDb.set(t, r, { ttlMs: n }) || o.local.set(t, r, { ttlMs: n });
667
668
  }
668
- function Me(e) {
669
+ function je(e) {
669
670
  return ["content-type", "cache-control"].includes(e.toLowerCase());
670
671
  }
671
- function je(e) {
672
+ function Me(e) {
672
673
  return /"_error"\s*:/u.test(e) || /"type"\s*:\s*"error"/u.test(e);
673
674
  }
674
675
  function Be(e) {
675
676
  return e !== null && (typeof e == "object" || typeof e == "function") && typeof e.then == "function";
676
677
  }
677
- function Et({ accountId: e, beUrl: t, devJwtSecret: r, tokenBrokerUrl: n, tokenBrokerAudience: o, workerUrl: a, defaultLocale: c = "en-GB", accountModule: p, tools: y = {}, beacon: f, allowBlobWorker: u = !1 }) {
678
+ function Lt({ accountId: e, beUrl: t, devJwtSecret: r, tokenBrokerUrl: n, tokenBrokerAudience: o, workerUrl: a, defaultLocale: c = "en-GB", accountModule: p, tools: m = {}, beacon: f, allowBlobWorker: u = !1 }) {
678
679
  if (!e) throw new Error("accountId is required.");
679
680
  if (!t) throw new Error("beUrl is required. The injector owns backend URLs; the SDK has no default.");
680
681
  if (!a) throw new Error("workerUrl is required.");
681
682
  const l = window, s = l.GengageAssistantInjector || (l.GengageAssistantInjector = {}), i = s[e] || (s[e] = {});
682
683
  if (i.agentController) return i.agentController;
683
- const d = N(a) || u ? Ie(a, `gengage-${e}-agent`, { allowBlobWorker: u }) : null;
684
+ const d = N(a) || u ? $e(a, `gengage-${e}-agent`, { allowBlobWorker: u }) : null;
684
685
  d || f?.({
685
686
  type: "agentRuntime",
686
687
  accountId: e,
@@ -695,7 +696,7 @@ function Et({ accountId: e, beUrl: t, devJwtSecret: r, tokenBrokerUrl: n, tokenB
695
696
  ...n ? { tokenBrokerUrl: n } : {},
696
697
  ...o ? { tokenBrokerAudience: o } : {},
697
698
  defaultLocale: c,
698
- tools: y,
699
+ tools: m,
699
700
  ...f ? { beacon: f } : {}
700
701
  }) : re({
701
702
  accountId: e,
@@ -705,10 +706,10 @@ function Et({ accountId: e, beUrl: t, devJwtSecret: r, tokenBrokerUrl: n, tokenB
705
706
  ...n ? { tokenBrokerUrl: n } : {},
706
707
  ...o ? { tokenBrokerAudience: o } : {},
707
708
  defaultLocale: c,
708
- tools: y,
709
+ tools: m,
709
710
  ...f ? { beacon: f } : {}
710
711
  });
711
- const w = {
712
+ const y = {
712
713
  type: "agent",
713
714
  stop() {
714
715
  delete i.streamTransport, d?.worker.terminate(), d?.cleanup(), delete i.agentController;
@@ -725,13 +726,13 @@ function Et({ accountId: e, beUrl: t, devJwtSecret: r, tokenBrokerUrl: n, tokenB
725
726
  };
726
727
  }
727
728
  };
728
- return i.agentController = w, w;
729
+ return i.agentController = y, y;
729
730
  }
730
731
  function N(e) {
731
732
  const t = new URL(e, window.location.href);
732
733
  return t.origin === window.location.origin || t.protocol === "blob:";
733
734
  }
734
- function Ie(e, t, r = {}) {
735
+ function $e(e, t, r = {}) {
735
736
  const n = new URL(e, window.location.href);
736
737
  if (N(e)) return {
737
738
  worker: new Worker(n.href, {
@@ -758,21 +759,62 @@ function Ie(e, t, r = {}) {
758
759
  throw URL.revokeObjectURL(a), c;
759
760
  }
760
761
  }
762
+ function Ie(e, t, r = "v1") {
763
+ return `endpoint:${r}:${A({
764
+ endpoint: e,
765
+ request: t
766
+ })}`;
767
+ }
768
+ function jt(e) {
769
+ const t = e.version || "v1", r = (n) => (o) => ({
770
+ partition: `${e.partitionPrefix}/${n}`,
771
+ key: Ie(n, o, t),
772
+ ...e.ttlMs ? { ttlMs: e.ttlMs } : {}
773
+ });
774
+ return {
775
+ launcher_action: r("launcher_action"),
776
+ similar_products: r("similar_products"),
777
+ product_groupings: r("product_groupings")
778
+ };
779
+ }
780
+ function Mt(e) {
781
+ return { ...e };
782
+ }
783
+ function Bt(e, t = {}) {
784
+ return new Response(e.map((r) => JSON.stringify(r)).join(`
785
+ `) + `
786
+ `, {
787
+ ...t,
788
+ headers: {
789
+ "content-type": "application/x-ndjson",
790
+ ...t.headers || {}
791
+ }
792
+ });
793
+ }
794
+ function $t(e, t = {}) {
795
+ return new Response(JSON.stringify(e), {
796
+ ...t,
797
+ headers: {
798
+ "content-type": "application/json",
799
+ ...t.headers || {}
800
+ }
801
+ });
802
+ }
761
803
  function De(e) {
762
804
  const t = (e?.chat || e?._chat)?.root || e?._chat?.root;
763
805
  return t ? t.getRootNode?.()?.host || t : Array.from(document.querySelectorAll("*")).find((r) => r.shadowRoot?.querySelector?.(".gengage-chat-root, .gengage-chat-launcher-container"));
764
806
  }
765
- function At(e, t) {
807
+ function It(e, t) {
766
808
  const r = De(e);
767
809
  r?.style && (t ? r.style.removeProperty("display") : r.style.setProperty("display", "none", "important")), t || (e?.chat || e?._chat)?.close?.();
768
810
  }
769
811
  var Oe = "nd_be_url";
770
- function Ut(e, t) {
771
- const r = $e() || e.beUrl || t;
812
+ function Dt(e, t) {
813
+ const r = Fe() || e.beUrl || t;
772
814
  if (!r) throw new Error("resolveBeUrl: backend URL is required. The injector must supply a fallback URL; the SDK has no default.");
773
815
  return r;
774
816
  }
775
- function $e() {
817
+ function Fe() {
776
818
  try {
777
819
  const e = new URLSearchParams(window.location.search).get(Oe)?.trim();
778
820
  if (!e) return null;
@@ -782,7 +824,7 @@ function $e() {
782
824
  return null;
783
825
  }
784
826
  }
785
- var Fe = [
827
+ var qe = [
786
828
  "addToCart",
787
829
  "search",
788
830
  "searchKeyword",
@@ -790,17 +832,17 @@ var Fe = [
790
832
  "searchGiftOptions",
791
833
  "similaritySearch"
792
834
  ];
793
- function Rt(e, t, r = {}) {
835
+ function Ot(e, t, r = {}) {
794
836
  const n = window, o = n.gengage || (n.gengage = {}), a = o.tools || (o.tools = {});
795
837
  a[e] = t;
796
838
  for (const c of r.accountAliases || []) a[c] = t;
797
- if (r.exposeStandardAliases !== !1) for (const c of r.standardAliases || Fe) {
839
+ if (r.exposeStandardAliases !== !1) for (const c of r.standardAliases || qe) {
798
840
  const p = t[c];
799
841
  typeof p == "function" && (a[c] = a[c] || p);
800
842
  }
801
843
  return t;
802
844
  }
803
- function vt({ getPageType: e, getProduct: t }) {
845
+ function Ft({ getPageType: e, getProduct: t }) {
804
846
  return () => ({
805
847
  url: window.location.href,
806
848
  title: document.title,
@@ -808,7 +850,7 @@ function vt({ getPageType: e, getProduct: t }) {
808
850
  product: t()
809
851
  });
810
852
  }
811
- function Pt({ accountId: e, getPageType: t, getProduct: r, getToolNames: n, getSearchCapabilities: o, getMemory: a }) {
853
+ function qt({ accountId: e, getPageType: t, getProduct: r, getToolNames: n, getSearchCapabilities: o, getMemory: a }) {
812
854
  return async () => ({
813
855
  accountId: e,
814
856
  url: window.location.href,
@@ -820,7 +862,7 @@ function Pt({ accountId: e, getPageType: t, getProduct: r, getToolNames: n, getS
820
862
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
821
863
  });
822
864
  }
823
- function Tt({ accountId: e, runtimeFile: t = "runtime.js", startExport: r = "start", globalBaseUrlKey: n, errorLabel: o } = {}) {
865
+ function Nt({ accountId: e, runtimeFile: t = "runtime.js", startExport: r = "start", globalBaseUrlKey: n, errorLabel: o } = {}) {
824
866
  if (!e) throw new Error("accountId is required.");
825
867
  const a = o || e, c = window, p = () => {
826
868
  const l = c.GengageInjectorConfig || {}, s = l[e] || {};
@@ -828,7 +870,7 @@ function Tt({ accountId: e, runtimeFile: t = "runtime.js", startExport: r = "sta
828
870
  ...l,
829
871
  ...s
830
872
  };
831
- }, y = () => {
873
+ }, m = () => {
832
874
  const l = p();
833
875
  if (l.runtimeUrl) return l.runtimeUrl;
834
876
  const s = l.assetBaseUrl || l.baseUrl || document.currentScript?.getAttribute("src") || (n ? c[n] : null);
@@ -837,7 +879,7 @@ function Tt({ accountId: e, runtimeFile: t = "runtime.js", startExport: r = "sta
837
879
  }, f = c.GengageAssistantInjector || (c.GengageAssistantInjector = {}), u = f[e] || (f[e] = {});
838
880
  return u.loaderPromise || (u.loaderPromise = import(
839
881
  /* @vite-ignore */
840
- y()
882
+ m()
841
883
  ).then((l) => {
842
884
  const s = l[r];
843
885
  if (typeof s != "function") throw new Error(`${a} runtime export ${r} is unavailable.`);
@@ -847,52 +889,67 @@ function Tt({ accountId: e, runtimeFile: t = "runtime.js", startExport: r = "sta
847
889
  })), u.loaderPromise;
848
890
  }
849
891
  export {
850
- ze as AgentError,
851
- Q as ContextStore,
852
- Ye as action,
853
- gt as actionButtonsUiSpec,
854
- We as beErrorToAgentError,
855
- ct as buildPhotoSimilarityProfile,
856
- dt as buildProductSimilarityProfile,
857
- ot as buildSimilarityQueries,
892
+ Qe as AgentError,
893
+ z as ContextStore,
894
+ ze as action,
895
+ ft as actionButtonsUiSpec,
896
+ ct as alignProductsToTable,
897
+ Pt as anonymousRequestText,
898
+ nt as beErrorToAgentError,
899
+ lt as buildPhotoSimilarityProfile,
900
+ wt as buildProductSimilarityProfile,
901
+ vt as buildSimilarityQueries,
858
902
  N as canUseModuleWorker,
859
- W as caughtToStreamError,
860
- et as comparisonUiSpec,
861
- j as createBrowserMemory,
862
- Pt as createDiagnosticsTool,
863
- st as createFlow,
903
+ X as caughtToStreamError,
904
+ Rt as compactAccountConfig,
905
+ He as compactContextProducts,
906
+ Tt as comparisonResultForUi,
907
+ st as comparisonUiSpec,
908
+ M as createBrowserMemory,
909
+ qt as createDiagnosticsTool,
910
+ jt as createEndpointCachePolicies,
911
+ Mt as createEndpointHandlers,
912
+ pt as createFlow,
864
913
  te as createInjectorAdapter,
865
914
  re as createMainThreadInjectorAdapter,
866
- Ie as createModuleWorker,
867
- vt as createReadPageTool,
868
- Ke as done,
869
- bt as elapsedMs,
870
- He as error,
871
- Je as httpErrorToAgentError,
872
- Rt as installBrowserTools,
873
- St as installFetchTransportBridge,
874
- it as llmCacheKey,
875
- Qe as metadata,
876
- Et as mountAccount,
915
+ $e as createModuleWorker,
916
+ Ft as createReadPageTool,
917
+ gt as defaultPiiPatternPack,
918
+ it as defaultPiiPatterns,
919
+ Ye as done,
920
+ at as elapsedMs,
921
+ Ie as endpointStableKey,
922
+ Ve as error,
923
+ We as httpErrorToAgentError,
924
+ Ot as installBrowserTools,
925
+ Ct as installFetchTransportBridge,
926
+ $t as jsonResponse,
927
+ xt as llmCacheKey,
928
+ et as metadata,
929
+ Lt as mountAccount,
930
+ Bt as ndjsonResponse,
931
+ tt as normalizeComparisonTable,
877
932
  mt as normalizeProduct,
878
- Ve as normalizeSimilarityText,
879
- Ge as nowIso,
880
- tt as productDetailsUiSpec,
881
- nt as productFactsKey,
882
- rt as productSkuKey,
883
- ut as productsUiSpec,
884
- lt as rankSimilarProducts,
885
- pt as requestText,
886
- Ut as resolveBeUrl,
887
- yt as resolveFlow,
888
- ft as scoreSimilarityCandidate,
889
- At as setAssistantHostVisible,
890
- L as stableKey,
891
- Tt as startLazyRuntimeLoader,
892
- at as textChunk,
893
- wt as textKey,
894
- Ze as tokenizeSimilarityText,
895
- Xe as trimProductFactsCore,
896
- ht as trimProductFactsListCore,
897
- Ne as uiSpec
933
+ ut as normalizeSimilarityText,
934
+ ot as nowIso,
935
+ Ut as productDetailsUiSpec,
936
+ rt as productFactsKey,
937
+ Je as productSkuKey,
938
+ _t as productsUiSpec,
939
+ dt as rankSimilarProducts,
940
+ St as redactPii,
941
+ At as requestText,
942
+ Dt as resolveBeUrl,
943
+ Ze as resolveFlow,
944
+ Et as scoreSimilarityCandidate,
945
+ It as setAssistantHostVisible,
946
+ A as stableKey,
947
+ Nt as startLazyRuntimeLoader,
948
+ kt as textChunk,
949
+ Xe as textKey,
950
+ ht as tokenizeSimilarityText,
951
+ Ge as trimProductFactsCore,
952
+ yt as trimProductFactsListCore,
953
+ Ke as uiSpec,
954
+ bt as withAccountConfig
898
955
  };