@gengage/assistant-fe 0.6.12 → 0.6.13

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 (50) hide show
  1. package/dist/agentic/adaptor/mount.d.ts +1 -0
  2. package/dist/agentic/context/context-store.d.ts +2 -1
  3. package/dist/agentic/context/persistence.d.ts +2 -1
  4. package/dist/agentic/index.d.ts +3 -2
  5. package/dist/agentic/index.js +244 -240
  6. package/dist/agentic/types.d.ts +28 -20
  7. package/dist/agentic/util/browser-memory.d.ts +2 -2
  8. package/dist/agentic/util/cache-key.d.ts +15 -0
  9. package/dist/agentic/worker/be-client.d.ts +3 -1
  10. package/dist/agentic/worker.d.ts +3 -2
  11. package/dist/agentic/worker.js +92 -86
  12. package/dist/agentic.iife.js +5 -5
  13. package/dist/{api-paths-Cth1szY1.js → api-paths-ChCMvKkx.js} +1 -1
  14. package/dist/{chat-CrEa2W-e.js → chat-BP-yXukW.js} +1 -1
  15. package/dist/chat-runtime.js +1 -1
  16. package/dist/chat.iife.js +17 -17
  17. package/dist/chat.js +2 -2
  18. package/dist/common/request-response-cache.d.ts +9 -0
  19. package/dist/{common-CmPjQ9RK.js → common-BD_DSsqY.js} +3 -3
  20. package/dist/common.js +7 -7
  21. package/dist/{connection-warning-Bx1TJaU9.js → connection-warning-CPeEsQ35.js} +1 -1
  22. package/dist/{fastIntent-nZXiT9DG.js → fastIntent-C1WeEqW8.js} +1 -1
  23. package/dist/index.js +12 -12
  24. package/dist/{native-webview-BlHM7cLs.js → native-webview-DbKq9lN8.js} +1 -1
  25. package/dist/native.iife.js +14 -14
  26. package/dist/native.js +1 -1
  27. package/dist/overlay.js +1 -1
  28. package/dist/{qna-BNvttR6s.js → qna-B3lMzHvS.js} +1 -1
  29. package/dist/qna-runtime.js +1 -1
  30. package/dist/qna.iife.js +13 -13
  31. package/dist/qna.js +2 -2
  32. package/dist/request-response-cache-zsgz3Awp.js +154 -0
  33. package/dist/request-text-su3Vlhrs.js +1318 -0
  34. package/dist/{runtime-xlTFF9HS.js → runtime-Dbwwd8yF.js} +38 -37
  35. package/dist/{runtime-B0v76aJ5.js → runtime-DclobJaN.js} +365 -364
  36. package/dist/{runtime-Dt6FUotQ.js → runtime-Duvrignh.js} +69 -68
  37. package/dist/{simbut-pTonQlCT.js → simbut-5C5EAfoM.js} +1 -1
  38. package/dist/simbut.iife.js +1 -1
  39. package/dist/simbut.js +1 -1
  40. package/dist/{simrel-C3ZJHVIW.js → simrel-DCcSBFez.js} +3 -3
  41. package/dist/simrel-runtime.js +1 -1
  42. package/dist/simrel.iife.js +12 -12
  43. package/dist/simrel.js +2 -2
  44. package/dist/{widget-base-C6H3cDSW.js → widget-base-BolzGV28.js} +1 -1
  45. package/package.json +1 -1
  46. package/dist/agentic/flow/beauty-consulting-turn.d.ts +0 -1
  47. package/dist/similarity-qMH5-do-.js +0 -1262
  48. /package/dist/{overlay-fgrzmFTR.js → overlay-CyoB1K0w.js} +0 -0
  49. /package/dist/{price-formatter-xI3g9Cd4.js → price-formatter-CFsWT0lP.js} +0 -0
  50. /package/dist/{schemas-CLo8wCjs.js → schemas-Cq2blsO_.js} +0 -0
@@ -1,9 +1,9 @@
1
- import { A as B, C as Ae, D as I, E as Pe, F as Re, I as Ue, M as k, O as ve, P as F, R as G, S as Te, T as xe, _ as _e, a as Le, b as je, c as Ce, d as Me, f as $e, g as De, h as Oe, i as qe, j as Be, k as Ie, l as ke, m as Fe, n as Ge, o as Ne, p as He, r as Je, s as ze, t as We, u as Ke, v as N, w as Qe, x as Ye, y as H, z as J } from "../similarity-qMH5-do-.js";
2
- var z = 512, W = 0.74;
3
- function K({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: s, defaultLocale: i, tools: d = {}, beacon: w }) {
1
+ import { A as Pe, B as Re, C as F, D as ve, E as Ue, F as xe, H as I, I as O, M as Te, N as _e, O as Le, P as $, R as G, S as N, T as Ce, U as K, _ as je, a as H, b as Me, c as De, d as Be, f as ke, g as qe, h as Fe, i as Ie, j as z, k as Oe, l as $e, m as Ge, n as Ne, o as Ke, p as He, r as ze, s as We, t as Je, u as Qe, v as Ye, w as Ve, x as Xe, y as Ze, z as et } from "../request-text-su3Vlhrs.js";
2
+ var W = 512, J = 0.74;
3
+ function Q({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: a, defaultLocale: i, tools: d = {}, beacon: w }) {
4
4
  let m = 1;
5
5
  const u = /* @__PURE__ */ new Map();
6
- return G({
6
+ return I({
7
7
  worker: t,
8
8
  tools: d,
9
9
  beacon: (l) => w?.({
@@ -12,29 +12,29 @@ function K({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl:
12
12
  }),
13
13
  memory: sessionStorage
14
14
  }), t.addEventListener("message", (l) => {
15
- const a = l.data || {}, c = typeof a.id == "number" ? a.id : null;
15
+ const s = l.data || {}, c = typeof s.id == "number" ? s.id : null;
16
16
  if (c == null) return;
17
17
  const f = u.get(c);
18
18
  if (f) {
19
- if (a.type === "event" && a.event) {
20
- S(f, a.event);
19
+ if (s.type === "event" && s.event) {
20
+ E(f, s.event);
21
21
  return;
22
22
  }
23
- if (a.type === "error") {
24
- f.onError(new Error(a.message || "Agent worker failed")), u.delete(c);
23
+ if (s.type === "error") {
24
+ f.onError(new Error(s.message || "Agent worker failed")), u.delete(c);
25
25
  return;
26
26
  }
27
- a.type === "end" && u.delete(c);
27
+ s.type === "end" && u.delete(c);
28
28
  }
29
- }), (l, a, c, f) => {
29
+ }), (l, s, c, f) => {
30
30
  const p = m++;
31
- u.set(p, a);
31
+ u.set(p, s);
32
32
  const g = () => {
33
33
  u.delete(p), t.postMessage({
34
34
  id: p,
35
35
  type: "abort"
36
36
  });
37
- }, h = (y) => {
37
+ }, y = (h) => {
38
38
  if (c.aborted) {
39
39
  g();
40
40
  return;
@@ -46,9 +46,9 @@ function K({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl:
46
46
  beUrl: r,
47
47
  devJwtSecret: n,
48
48
  tokenBrokerUrl: o,
49
- tokenBrokerAudience: s,
49
+ tokenBrokerAudience: a,
50
50
  defaultLocale: i,
51
- request: y,
51
+ request: h,
52
52
  parentUrl: window.location.href
53
53
  });
54
54
  };
@@ -57,80 +57,82 @@ function K({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl:
57
57
  return;
58
58
  }
59
59
  if (c.addEventListener("abort", g, { once: !0 }), f) {
60
- j(l, f).then(h).catch((y) => {
61
- u.delete(p), a.onError(y instanceof Error ? y : /* @__PURE__ */ new Error("Failed to read image attachment"));
60
+ L(l, f).then(y).catch((h) => {
61
+ u.delete(p), s.onError(h instanceof Error ? h : /* @__PURE__ */ new Error("Failed to read image attachment"));
62
62
  });
63
63
  return;
64
64
  }
65
- h(l);
65
+ y(l);
66
66
  };
67
67
  }
68
- function Q({ accountId: e, accountModule: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: s, defaultLocale: i, tools: d = {}, beacon: w }) {
68
+ function Y({ accountId: e, accountModule: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: a, defaultLocale: i, tools: d = {}, beacon: w }) {
69
69
  let m = null;
70
- const u = Y({
70
+ const u = V({
71
71
  accountId: e,
72
72
  tools: d,
73
73
  beacon: w
74
- }), l = N(u), a = k({
74
+ }), l = N(u), s = O({
75
75
  accountId: e,
76
76
  ...n ? { devJwtSecret: n } : {},
77
77
  ...o ? { tokenBrokerUrl: o } : {},
78
- ...s ? { tokenBrokerAudience: s } : {}
78
+ ...a ? { tokenBrokerAudience: a } : {}
79
79
  });
80
80
  return async (c, f, p, g) => {
81
- const h = await j(c || {}, g);
82
- m ||= new F({
81
+ const y = await L(c || {}, g);
82
+ m ||= new G({
83
83
  accountId: e,
84
- locale: h?.locale || i,
84
+ locale: y?.locale || i,
85
85
  parentUrl: window.location.href,
86
- rpc: u
86
+ rpc: u,
87
+ persistentPanelKeys: t.contextPersistence?.panelKeys
87
88
  });
88
89
  try {
89
- await H({
90
- request: h,
90
+ await F({
91
+ request: y,
91
92
  accountModule: {
92
93
  ...t,
93
94
  accountId: e
94
95
  },
95
96
  contextStore: m,
96
- beClient: { invoke({ op: y, input: b, signal: U, cacheTtlS: O, cacheKey: q }) {
97
- return I({
97
+ beClient: { invoke({ op: h, input: S, signal: v, cacheTtlS: B, cacheKey: k, browserCache: q }) {
98
+ return z({
98
99
  beUrl: r,
99
100
  accountId: e,
100
- jwtProvider: a,
101
+ jwtProvider: s,
101
102
  parentUrl: window.location.href,
102
- op: y,
103
- input: b,
104
- cacheTtlS: O,
105
- cacheKey: q,
106
- ...U ? { signal: U } : {}
103
+ op: h,
104
+ input: S,
105
+ cacheTtlS: B,
106
+ cacheKey: k,
107
+ browserCache: q,
108
+ ...v ? { signal: v } : {}
107
109
  });
108
110
  } },
109
111
  toolBridge: l,
110
- emit: (y) => S(f, y),
112
+ emit: (h) => E(f, h),
111
113
  rpc: u,
112
114
  signal: p
113
115
  });
114
- } catch (y) {
115
- p?.aborted || (S(f, B(y)), f.onDone());
116
+ } catch (h) {
117
+ p?.aborted || (E(f, $(h)), f.onDone());
116
118
  }
117
119
  };
118
120
  }
119
- function Y({ accountId: e, tools: t, beacon: r }) {
121
+ function V({ accountId: e, tools: t, beacon: r }) {
120
122
  const n = (o) => r?.({
121
123
  ...o,
122
124
  accountId: o.accountId || e
123
125
  });
124
- return ((o, s) => J(o, s, {
126
+ return ((o, a) => K(o, a, {
125
127
  tools: t,
126
128
  beacon: n,
127
129
  memory: sessionStorage
128
130
  }));
129
131
  }
130
- async function j(e, t) {
132
+ async function L(e, t) {
131
133
  if (!t || !t.type?.startsWith("image/")) return e;
132
- const r = await Z(t), n = {
133
- ...V(e.payload ?? e.action?.payload),
134
+ const r = await ee(t), n = {
135
+ ...X(e.payload ?? e.action?.payload),
134
136
  image_data_url: r.dataUrl,
135
137
  image_mime: r.mime
136
138
  };
@@ -143,30 +145,30 @@ async function j(e, t) {
143
145
  } } : {}
144
146
  };
145
147
  }
146
- function V(e) {
147
- return X(e) ? { ...e } : typeof e == "string" ? { text: e } : {};
148
- }
149
148
  function X(e) {
149
+ return Z(e) ? { ...e } : typeof e == "string" ? { text: e } : {};
150
+ }
151
+ function Z(e) {
150
152
  return typeof e == "object" && e !== null && !Array.isArray(e);
151
153
  }
152
- async function Z(e) {
153
- const t = await ee(e);
154
+ async function ee(e) {
155
+ const t = await te(e);
154
156
  return t || {
155
157
  dataUrl: await C(e),
156
158
  mime: e.type
157
159
  };
158
160
  }
159
- async function ee(e) {
161
+ async function te(e) {
160
162
  if (typeof createImageBitmap != "function" || typeof document > "u") return null;
161
163
  let t = null;
162
164
  try {
163
165
  t = await createImageBitmap(e);
164
- const r = Math.min(1, z / Math.max(t.width, t.height)), n = Math.max(1, Math.round(t.width * r)), o = Math.max(1, Math.round(t.height * r)), s = document.createElement("canvas");
165
- s.width = n, s.height = o;
166
- const i = s.getContext("2d");
166
+ const r = Math.min(1, W / Math.max(t.width, t.height)), n = Math.max(1, Math.round(t.width * r)), o = Math.max(1, Math.round(t.height * r)), a = document.createElement("canvas");
167
+ a.width = n, a.height = o;
168
+ const i = a.getContext("2d");
167
169
  if (!i) return null;
168
170
  i.drawImage(t, 0, 0, n, o);
169
- const d = await new Promise((w) => s.toBlob(w, "image/jpeg", W));
171
+ const d = await new Promise((w) => a.toBlob(w, "image/jpeg", J));
170
172
  return d ? {
171
173
  dataUrl: await C(d),
172
174
  mime: d.type || "image/jpeg"
@@ -184,7 +186,7 @@ async function C(e) {
184
186
  for (let o = 0; o < t.length; o += n) r += String.fromCharCode(...t.subarray(o, o + n));
185
187
  return `data:${e.type};base64,${btoa(r)}`;
186
188
  }
187
- function S(e, t) {
189
+ function E(e, t) {
188
190
  switch (t?.type) {
189
191
  case "text_chunk": {
190
192
  const r = t;
@@ -203,7 +205,7 @@ function S(e, t) {
203
205
  e.onMetadata(t);
204
206
  break;
205
207
  case "error":
206
- e.onError(te(t));
208
+ e.onError(re(t));
207
209
  break;
208
210
  case "done":
209
211
  e.onDone();
@@ -212,17 +214,17 @@ function S(e, t) {
212
214
  break;
213
215
  }
214
216
  }
215
- function te(e) {
217
+ function re(e) {
216
218
  const t = new Error(e.message || e.code || "Agent error");
217
219
  return e.code && (t.code = e.code), t;
218
220
  }
219
- var v = "__gengageAgentFetchBridge";
220
- function Ve({ accountId: e, streamTransport: t, endpoints: r = {} }) {
221
+ var b = "__gengageAgentFetchBridge";
222
+ function tt({ accountId: e, streamTransport: t, endpoints: r = {} }) {
221
223
  if (!e) throw new Error("accountId is required.");
222
224
  if (typeof t != "function") throw new Error("streamTransport is required.");
223
- const n = re(), o = `https://gengage-injector.invalid/${encodeURIComponent(e)}`, s = /* @__PURE__ */ new Set(), i = (d) => {
225
+ const n = ne(), o = `https://gengage-injector.invalid/${encodeURIComponent(e)}`, a = /* @__PURE__ */ new Set(), i = (d) => {
224
226
  const w = `${o}/chat/${d}`;
225
- s.add(w);
227
+ a.add(w);
226
228
  const m = r[d], u = {
227
229
  streamTransport: t,
228
230
  endpoint: d
@@ -234,56 +236,63 @@ function Ve({ accountId: e, streamTransport: t, endpoints: r = {} }) {
234
236
  return {
235
237
  middlewareUrl: o,
236
238
  stop() {
237
- for (const d of s) n.routes.delete(d);
239
+ for (const d of a) n.routes.delete(d);
240
+ oe(n);
238
241
  }
239
242
  };
240
243
  }
241
- function re() {
242
- const e = window, t = e[v];
244
+ function ne() {
245
+ const e = window, t = e[b];
243
246
  if (t) return t;
244
247
  const r = e.fetch.bind(e), n = {
245
248
  routes: /* @__PURE__ */ new Map(),
246
- originalFetch: r
249
+ originalFetch: r,
250
+ installedFetch: r
247
251
  };
248
- return e.fetch = (o, s) => {
249
- const i = M(o), d = n.routes.get(i);
250
- return d ? oe(d, o, s) : r(o, s);
251
- }, e[v] = n, n;
252
+ return n.installedFetch = (o, a) => {
253
+ const i = j(o), d = n.routes.get(i);
254
+ return d ? se(d, o, a) : r(o, a);
255
+ }, e.fetch = n.installedFetch, e[b] = n, n;
256
+ }
257
+ function oe(e) {
258
+ if (e.routes.size > 0) return;
259
+ const t = window;
260
+ t.fetch === e.installedFetch && (t.fetch = e.originalFetch), t[b] === e && delete t[b];
252
261
  }
253
- function M(e) {
262
+ function j(e) {
254
263
  return typeof e == "string" ? e : e instanceof URL ? e.href : e?.url || "";
255
264
  }
256
- function T(e, t) {
265
+ function U(e, t) {
257
266
  if (t?.signal) return t.signal;
258
267
  if (typeof Request < "u" && e instanceof Request) return e.signal;
259
268
  }
260
- function $(e, t) {
269
+ function M(e, t) {
261
270
  return t?.body !== void 0 && t?.body !== null ? t.body : typeof Request < "u" && e instanceof Request ? e.clone().text() : null;
262
271
  }
263
- async function ne(e, t) {
264
- const r = $(e, t);
272
+ async function ae(e, t) {
273
+ const r = M(e, t);
265
274
  if (r instanceof FormData) {
266
- const o = r.get("request"), s = r.get("attachment");
275
+ const o = r.get("request"), a = r.get("attachment");
267
276
  return {
268
277
  request: JSON.parse(String(o || "{}")),
269
- ...s instanceof File ? { attachment: s } : {}
278
+ ...a instanceof File ? { attachment: a } : {}
270
279
  };
271
280
  }
272
281
  const n = await Promise.resolve(r);
273
282
  return typeof n == "string" ? { request: JSON.parse(n || "{}") } : { request: {} };
274
283
  }
275
- async function oe(e, t, r) {
284
+ async function se(e, t, r) {
276
285
  if (e.endpoint && e.endpoint !== "process_action" && e.endpointHandler) {
277
- const m = new AbortController(), u = T(t, r);
286
+ const m = new AbortController(), u = U(t, r);
278
287
  let l = null;
279
288
  if (u) {
280
- const a = () => m.abort();
281
- u.aborted && a(), u.addEventListener("abort", a, { once: !0 }), l = () => u.removeEventListener("abort", a);
289
+ const s = () => m.abort();
290
+ u.aborted && s(), u.addEventListener("abort", s, { once: !0 }), l = () => u.removeEventListener("abort", s);
282
291
  }
283
292
  try {
284
- const a = await ae(t, r);
285
- return await e.endpointHandler(a, {
286
- accountId: se(t),
293
+ const s = await ie(t, r);
294
+ return await e.endpointHandler(s, {
295
+ accountId: ce(t),
287
296
  endpoint: e.endpoint,
288
297
  signal: m.signal
289
298
  });
@@ -291,7 +300,7 @@ async function oe(e, t, r) {
291
300
  l?.();
292
301
  }
293
302
  }
294
- const n = new TextEncoder(), o = new AbortController(), s = T(t, r);
303
+ const n = new TextEncoder(), o = new AbortController(), a = U(t, r);
295
304
  let i = !1, d = null;
296
305
  const w = new ReadableStream({
297
306
  async start(m) {
@@ -300,37 +309,37 @@ async function oe(e, t, r) {
300
309
  `));
301
310
  }, l = () => {
302
311
  i || (i = !0, d?.(), m.close());
303
- }, a = (c) => {
312
+ }, s = (c) => {
304
313
  u({
305
314
  type: "error",
306
315
  code: c?.code || "agent_bridge_error",
307
316
  message: c instanceof Error ? c.message : String(c)
308
317
  }), u({ type: "done" }), l();
309
318
  };
310
- if (s) {
319
+ if (a) {
311
320
  const c = () => {
312
321
  o.abort(), i || (i = !0, d?.(), m.error(new DOMException("Aborted", "AbortError")));
313
322
  };
314
- if (s.aborted) {
323
+ if (a.aborted) {
315
324
  c();
316
325
  return;
317
326
  }
318
- s.addEventListener("abort", c, { once: !0 }), d = () => s.removeEventListener("abort", c);
327
+ a.addEventListener("abort", c, { once: !0 }), d = () => a.removeEventListener("abort", c);
319
328
  }
320
329
  try {
321
- const { request: c, attachment: f } = await ne(t, r), p = e.streamTransport(c, {
322
- onTextChunk: (g, h, y = {}) => u({
330
+ const { request: c, attachment: f } = await ae(t, r), p = e.streamTransport(c, {
331
+ onTextChunk: (g, y, h = {}) => u({
323
332
  type: "text_chunk",
324
333
  content: g,
325
- final: h === !0,
326
- ...y
334
+ final: y === !0,
335
+ ...h
327
336
  }),
328
- onUISpec: (g, h, y, b) => u({
337
+ onUISpec: (g, y, h, S) => u({
329
338
  type: "ui_spec",
330
339
  spec: g,
331
- widget: h,
332
- ...y ? { panelHint: y } : {},
333
- ...b ? { clearPanel: !0 } : {}
340
+ widget: y,
341
+ ...h ? { panelHint: h } : {},
342
+ ...S ? { clearPanel: !0 } : {}
334
343
  }),
335
344
  onAction: (g) => {
336
345
  u(g?.type === "action" ? g : {
@@ -344,14 +353,14 @@ async function oe(e, t, r) {
344
353
  ...g
345
354
  });
346
355
  },
347
- onError: a,
356
+ onError: s,
348
357
  onDone: () => {
349
358
  u({ type: "done" }), l();
350
359
  }
351
360
  }, o.signal, f);
352
- ie(p) && (await p, o.signal.aborted || (u({ type: "done" }), l()));
361
+ le(p) && (await p, o.signal.aborted || (u({ type: "done" }), l()));
353
362
  } catch (c) {
354
- o.signal.aborted || a(c);
363
+ o.signal.aborted || s(c);
355
364
  }
356
365
  },
357
366
  cancel() {
@@ -363,29 +372,35 @@ async function oe(e, t, r) {
363
372
  headers: { "Content-Type": "application/x-ndjson" }
364
373
  });
365
374
  }
366
- async function ae(e, t) {
367
- const r = await Promise.resolve($(e, t));
375
+ async function ie(e, t) {
376
+ const r = await Promise.resolve(M(e, t));
368
377
  return typeof r != "string" || r.trim() === "" ? {} : JSON.parse(r);
369
378
  }
370
- function se(e) {
379
+ function ce(e) {
371
380
  try {
372
- const [t] = new URL(M(e)).pathname.split("/").filter(Boolean);
381
+ const [t] = new URL(j(e)).pathname.split("/").filter(Boolean);
373
382
  return decodeURIComponent(t || "");
374
383
  } catch {
375
384
  return "";
376
385
  }
377
386
  }
378
- function ie(e) {
387
+ function le(e) {
379
388
  return e !== null && (typeof e == "object" || typeof e == "function") && typeof e.then == "function";
380
389
  }
381
- function Xe({ accountId: e, beUrl: t, devJwtSecret: r, tokenBrokerUrl: n, tokenBrokerAudience: o, workerUrl: s, defaultLocale: i = "en-GB", accountModule: d, tools: w = {}, beacon: m, allowBlobWorker: u = !1 }) {
390
+ function rt({ accountId: e, beUrl: t, devJwtSecret: r, tokenBrokerUrl: n, tokenBrokerAudience: o, workerUrl: a, defaultLocale: i = "en-GB", accountModule: d, tools: w = {}, beacon: m, allowBlobWorker: u = !1 }) {
382
391
  if (!e) throw new Error("accountId is required.");
383
392
  if (!t) throw new Error("beUrl is required. The injector owns backend URLs; the SDK has no default.");
384
- if (!s) throw new Error("workerUrl is required.");
385
- const l = window, a = l.GengageAssistantInjector || (l.GengageAssistantInjector = {}), c = a[e] || (a[e] = {});
393
+ if (!a) throw new Error("workerUrl is required.");
394
+ const l = window, s = l.GengageAssistantInjector || (l.GengageAssistantInjector = {}), c = s[e] || (s[e] = {});
386
395
  if (c.agentController) return c.agentController;
387
- const f = D(s) || u ? ce(s, `gengage-${e}-agent`, { allowBlobWorker: u }) : null;
388
- c.streamTransport = f ? K({
396
+ const f = D(a) || u ? ue(a, `gengage-${e}-agent`, { allowBlobWorker: u }) : null;
397
+ f || m?.({
398
+ type: "agentRuntime",
399
+ accountId: e,
400
+ transport: "main-thread",
401
+ reason: "cross-origin-worker-url",
402
+ workerUrl: a
403
+ }), c.streamTransport = f ? Q({
389
404
  accountId: e,
390
405
  worker: f.worker,
391
406
  beUrl: t,
@@ -395,7 +410,7 @@ function Xe({ accountId: e, beUrl: t, devJwtSecret: r, tokenBrokerUrl: n, tokenB
395
410
  defaultLocale: i,
396
411
  tools: w,
397
412
  ...m ? { beacon: m } : {}
398
- }) : Q({
413
+ }) : Y({
399
414
  accountId: e,
400
415
  accountModule: d,
401
416
  beUrl: t,
@@ -415,9 +430,10 @@ function Xe({ accountId: e, beUrl: t, devJwtSecret: r, tokenBrokerUrl: n, tokenB
415
430
  return {
416
431
  accountId: e,
417
432
  beUrl: t,
418
- workerUrl: s,
433
+ workerUrl: a,
419
434
  mounted: !0,
420
435
  transport: f ? "worker" : "main-thread",
436
+ transportReason: f ? "module-worker" : "cross-origin-worker-url",
421
437
  flows: Object.keys(d?.flows || {})
422
438
  };
423
439
  }
@@ -428,7 +444,7 @@ function D(e) {
428
444
  const t = new URL(e, window.location.href);
429
445
  return t.origin === window.location.origin || t.protocol === "blob:";
430
446
  }
431
- function ce(e, t, r = {}) {
447
+ function ue(e, t, r = {}) {
432
448
  const n = new URL(e, window.location.href);
433
449
  if (D(e)) return {
434
450
  worker: new Worker(n.href, {
@@ -440,38 +456,38 @@ function ce(e, t, r = {}) {
440
456
  };
441
457
  if (!r.allowBlobWorker) throw new Error("Cross-origin agent workers require allowBlobWorker=true or a same-origin workerUrl.");
442
458
  const o = new Blob([`import ${JSON.stringify(n.href)};
443
- `], { type: "text/javascript" }), s = URL.createObjectURL(o);
459
+ `], { type: "text/javascript" }), a = URL.createObjectURL(o);
444
460
  try {
445
461
  return {
446
- worker: new Worker(s, {
462
+ worker: new Worker(a, {
447
463
  type: "module",
448
464
  name: t
449
465
  }),
450
466
  cleanup() {
451
- URL.revokeObjectURL(s);
467
+ URL.revokeObjectURL(a);
452
468
  }
453
469
  };
454
470
  } catch (i) {
455
- throw URL.revokeObjectURL(s), i;
471
+ throw URL.revokeObjectURL(a), i;
456
472
  }
457
473
  }
458
- function le(e) {
474
+ function de(e) {
459
475
  const t = (e?.chat || e?._chat)?.root || e?._chat?.root;
460
476
  return t ? t.getRootNode?.()?.host || t : Array.from(document.querySelectorAll("*")).find((r) => r.shadowRoot?.querySelector?.(".gengage-chat-root, .gengage-chat-launcher-container"));
461
477
  }
462
- function Ze(e, t) {
463
- const r = le(e);
478
+ function nt(e, t) {
479
+ const r = de(e);
464
480
  r?.style && (t ? r.style.removeProperty("display") : r.style.setProperty("display", "none", "important")), t || (e?.chat || e?._chat)?.close?.();
465
481
  }
466
- var ue = "nd_be_url";
467
- function et(e, t) {
468
- const r = de() || e.beUrl || t;
482
+ var fe = "nd_be_url";
483
+ function ot(e, t) {
484
+ const r = ge() || e.beUrl || t;
469
485
  if (!r) throw new Error("resolveBeUrl: backend URL is required. The injector must supply a fallback URL; the SDK has no default.");
470
486
  return r;
471
487
  }
472
- function de() {
488
+ function ge() {
473
489
  try {
474
- const e = new URLSearchParams(window.location.search).get(ue)?.trim();
490
+ const e = new URLSearchParams(window.location.search).get(fe)?.trim();
475
491
  if (!e) return null;
476
492
  const t = new URL(e);
477
493
  return t.protocol !== "https:" && t.protocol !== "http:" ? null : t.toString().replace(/\/+$/u, "");
@@ -479,26 +495,26 @@ function de() {
479
495
  return null;
480
496
  }
481
497
  }
482
- var fe = "entries", ge = 1, me = {
498
+ var me = "entries", pe = 1, we = {
483
499
  volatile: "Hot per-page state and sensitive request context.",
484
500
  session: "Current-visit tool context without raw tokens or PII-heavy payloads.",
485
501
  local: "Small, non-sensitive capability facts or user preferences.",
486
502
  indexedDb: "Larger product/search payload caches with short TTLs."
487
503
  }, x = /* @__PURE__ */ new Map();
488
- function E() {
504
+ function A() {
489
505
  return Date.now();
490
506
  }
491
507
  function P(e) {
492
- return e?.expiresAt != null && e.expiresAt <= E();
508
+ return e?.expiresAt != null && e.expiresAt <= A();
493
509
  }
494
510
  function R(e, t) {
495
511
  return {
496
512
  value: e,
497
- createdAt: E(),
498
- expiresAt: t ? E() + t : null
513
+ createdAt: A(),
514
+ expiresAt: t ? A() + t : null
499
515
  };
500
516
  }
501
- function pe(e, t, r) {
517
+ function he(e, t, r) {
502
518
  try {
503
519
  const n = e.getItem(`${t}${r}`);
504
520
  if (!n) return null;
@@ -508,31 +524,31 @@ function pe(e, t, r) {
508
524
  return null;
509
525
  }
510
526
  }
511
- function we(e, t, r, n, o) {
527
+ function ye(e, t, r, n, o) {
512
528
  try {
513
529
  return e.setItem(`${t}${r}`, JSON.stringify(R(n, o))), !0;
514
530
  } catch {
515
531
  return !1;
516
532
  }
517
533
  }
518
- function ye(e, t, r) {
534
+ function be(e, t, r) {
519
535
  try {
520
536
  e.removeItem(`${t}${r}`);
521
537
  } catch {
522
538
  }
523
539
  }
524
- function _(e) {
540
+ function T(e) {
525
541
  try {
526
542
  return window[e];
527
543
  } catch {
528
544
  return null;
529
545
  }
530
546
  }
531
- function L(e, t) {
547
+ function _(e, t) {
532
548
  return e ? {
533
- get: (r) => pe(e, t, r),
534
- set: (r, n, o = {}) => we(e, t, r, n, o.ttlMs),
535
- remove: (r) => ye(e, t, r)
549
+ get: (r) => he(e, t, r),
550
+ set: (r, n, o = {}) => ye(e, t, r, n, o.ttlMs),
551
+ remove: (r) => be(e, t, r)
536
552
  } : {
537
553
  get: () => null,
538
554
  set: () => !1,
@@ -540,36 +556,21 @@ function L(e, t) {
540
556
  }
541
557
  };
542
558
  }
543
- function A(e) {
544
- if (Array.isArray(e)) return `[${e.map(A).join(",")}]`;
545
- if (e && typeof e == "object") {
546
- const t = e;
547
- return `{${Object.keys(t).sort().map((r) => `${JSON.stringify(r)}:${A(t[r])}`).join(",")}}`;
548
- }
549
- return JSON.stringify(e);
550
- }
551
- function he(e) {
552
- let t = 2166136261;
553
- const r = A(e);
554
- for (let n = 0; n < r.length; n += 1)
555
- t ^= r.charCodeAt(n), t = Math.imul(t, 16777619);
556
- return (t >>> 0).toString(36);
557
- }
558
- function be(e, t) {
559
- const r = t.dbName || `gengage-${e}`, n = t.dbStore || fe, o = t.dbVersion || ge, s = /* @__PURE__ */ new Map();
559
+ function Se(e, t) {
560
+ const r = t.dbName || `gengage-${e}`, n = t.dbStore || me, o = t.dbVersion || pe, a = /* @__PURE__ */ new Map();
560
561
  let i = null;
561
562
  const d = () => "indexedDB" in window ? i || (i = new Promise((l) => {
562
- const a = indexedDB.open(r, o);
563
- a.onupgradeneeded = () => {
564
- a.result.createObjectStore(n, { keyPath: "key" });
565
- }, a.onsuccess = () => l(a.result), a.onerror = () => l(null), a.onblocked = () => l(null);
563
+ const s = indexedDB.open(r, o);
564
+ s.onupgradeneeded = () => {
565
+ s.result.createObjectStore(n, { keyPath: "key" });
566
+ }, s.onsuccess = () => l(s.result), s.onerror = () => l(null), s.onblocked = () => l(null);
566
567
  }), i) : Promise.resolve(null);
567
568
  return {
568
- volatileEntries: s,
569
+ volatileEntries: a,
569
570
  idbGet: async (l) => {
570
- const a = await d();
571
- return a ? new Promise((c) => {
572
- const f = a.transaction(n, "readwrite").objectStore(n), p = f.get(l);
571
+ const s = await d();
572
+ return s ? new Promise((c) => {
573
+ const f = s.transaction(n, "readwrite").objectStore(n), p = f.get(l);
573
574
  p.onsuccess = () => {
574
575
  const g = p.result;
575
576
  if (!g || P(g)) {
@@ -580,26 +581,26 @@ function be(e, t) {
580
581
  }, p.onerror = () => c(null);
581
582
  }) : null;
582
583
  },
583
- idbSet: async (l, a, c = {}) => {
584
+ idbSet: async (l, s, c = {}) => {
584
585
  const f = await d();
585
586
  return f ? new Promise((p) => {
586
587
  const g = f.transaction(n, "readwrite");
587
588
  g.oncomplete = () => p(!0), g.onerror = () => p(!1), g.objectStore(n).put({
588
589
  key: l,
589
- ...R(a, c.ttlMs)
590
+ ...R(s, c.ttlMs)
590
591
  });
591
592
  }) : !1;
592
593
  },
593
594
  idbRemove: async (l) => {
594
- const a = await d();
595
- a && a.transaction(n, "readwrite").objectStore(n).delete(l);
595
+ const s = await d();
596
+ s && s.transaction(n, "readwrite").objectStore(n).delete(l);
596
597
  }
597
598
  };
598
599
  }
599
- function tt(e, t = {}) {
600
- const r = window, n = r.gengage || (r.gengage = {}), o = n.memory || (n.memory = {}), s = o[e];
601
- if (s) return s;
602
- const i = x.get(e) || be(e, t);
600
+ function at(e, t = {}) {
601
+ const r = window, n = r.gengage || (r.gengage = {}), o = n.memory || (n.memory = {}), a = o[e];
602
+ if (a) return a;
603
+ const i = x.get(e) || Se(e, t);
603
604
  x.set(e, i);
604
605
  const d = t.sessionPrefix || `gengage:${e}:session:`, w = t.localPrefix || `gengage:${e}:local:`, u = {
605
606
  get: (c) => {
@@ -615,23 +616,23 @@ function tt(e, t = {}) {
615
616
  get: i.idbGet,
616
617
  set: i.idbSet,
617
618
  remove: i.idbRemove
618
- }, a = {
619
+ }, s = {
619
620
  accountId: e,
620
621
  volatile: u,
621
- session: L(_("sessionStorage"), d),
622
- local: L(_("localStorage"), w),
622
+ session: _(T("sessionStorage"), d),
623
+ local: _(T("localStorage"), w),
623
624
  indexedDb: l,
624
- stableKey: he,
625
+ stableKey: H,
625
626
  policy: {
626
- ...me,
627
+ ...we,
627
628
  ...t.policy || {}
628
629
  }
629
630
  };
630
- o[e] = a;
631
- for (const c of t.aliases || []) o[c] = a;
632
- return a;
631
+ o[e] = s;
632
+ for (const c of t.aliases || []) o[c] = s;
633
+ return s;
633
634
  }
634
- var Se = [
635
+ var Ee = [
635
636
  "addToCart",
636
637
  "search",
637
638
  "searchKeyword",
@@ -639,17 +640,17 @@ var Se = [
639
640
  "searchGiftOptions",
640
641
  "similaritySearch"
641
642
  ];
642
- function rt(e, t, r = {}) {
643
- const n = window, o = n.gengage || (n.gengage = {}), s = o.tools || (o.tools = {});
644
- s[e] = t;
645
- for (const i of r.accountAliases || []) s[i] = t;
646
- if (r.exposeStandardAliases !== !1) for (const i of r.standardAliases || Se) {
643
+ function st(e, t, r = {}) {
644
+ const n = window, o = n.gengage || (n.gengage = {}), a = o.tools || (o.tools = {});
645
+ a[e] = t;
646
+ for (const i of r.accountAliases || []) a[i] = t;
647
+ if (r.exposeStandardAliases !== !1) for (const i of r.standardAliases || Ee) {
647
648
  const d = t[i];
648
- typeof d == "function" && (s[i] = s[i] || d);
649
+ typeof d == "function" && (a[i] = a[i] || d);
649
650
  }
650
651
  return t;
651
652
  }
652
- function nt({ getPageType: e, getProduct: t }) {
653
+ function it({ getPageType: e, getProduct: t }) {
653
654
  return () => ({
654
655
  url: window.location.href,
655
656
  title: document.title,
@@ -657,7 +658,7 @@ function nt({ getPageType: e, getProduct: t }) {
657
658
  product: t()
658
659
  });
659
660
  }
660
- function ot({ accountId: e, getPageType: t, getProduct: r, getToolNames: n, getSearchCapabilities: o, getMemory: s }) {
661
+ function ct({ accountId: e, getPageType: t, getProduct: r, getToolNames: n, getSearchCapabilities: o, getMemory: a }) {
661
662
  return async () => ({
662
663
  accountId: e,
663
664
  url: window.location.href,
@@ -665,80 +666,83 @@ function ot({ accountId: e, getPageType: t, getProduct: r, getToolNames: n, getS
665
666
  productSku: r()?.sku ?? null,
666
667
  toolNames: n(),
667
668
  ...o ? { searchCapabilities: o() } : {},
668
- ...s ? { memoryPolicy: s().policy } : {},
669
+ ...a ? { memoryPolicy: a().policy } : {},
669
670
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
670
671
  });
671
672
  }
672
- function at({ accountId: e, runtimeFile: t = "runtime.js", startExport: r = "start", globalBaseUrlKey: n, errorLabel: o } = {}) {
673
+ function lt({ accountId: e, runtimeFile: t = "runtime.js", startExport: r = "start", globalBaseUrlKey: n, errorLabel: o } = {}) {
673
674
  if (!e) throw new Error("accountId is required.");
674
- const s = o || e, i = window, d = () => {
675
- const l = i.GengageInjectorConfig || {}, a = l[e] || {};
675
+ const a = o || e, i = window, d = () => {
676
+ const l = i.GengageInjectorConfig || {}, s = l[e] || {};
676
677
  return {
677
678
  ...l,
678
- ...a
679
+ ...s
679
680
  };
680
681
  }, w = () => {
681
682
  const l = d();
682
683
  if (l.runtimeUrl) return l.runtimeUrl;
683
- const a = l.assetBaseUrl || l.baseUrl || document.currentScript?.getAttribute("src") || (n ? i[n] : null);
684
- if (!a) throw new Error(`${s} runtime URL cannot be resolved.`);
685
- return new URL(t, a).href;
684
+ const s = l.assetBaseUrl || l.baseUrl || document.currentScript?.getAttribute("src") || (n ? i[n] : null);
685
+ if (!s) throw new Error(`${a} runtime URL cannot be resolved.`);
686
+ return new URL(t, s).href;
686
687
  }, m = i.GengageAssistantInjector || (i.GengageAssistantInjector = {}), u = m[e] || (m[e] = {});
687
688
  return u.loaderPromise || (u.loaderPromise = import(
688
689
  /* @vite-ignore */
689
690
  w()
690
691
  ).then((l) => {
691
- const a = l[r];
692
- if (typeof a != "function") throw new Error(`${s} runtime export ${r} is unavailable.`);
693
- return a();
692
+ const s = l[r];
693
+ if (typeof s != "function") throw new Error(`${a} runtime export ${r} is unavailable.`);
694
+ return s();
694
695
  }).catch((l) => {
695
696
  throw delete u.loaderPromise, console.error(`[Gengage][${e}] runtime load failed`, l), l;
696
697
  })), u.loaderPromise;
697
698
  }
698
699
  export {
699
- ve as AgentError,
700
- F as ContextStore,
701
- Ye as action,
702
- Me as actionButtonsUiSpec,
703
- Ie as beErrorToAgentError,
704
- Ce as beautyConsultingTurnFlow,
700
+ Te as AgentError,
701
+ G as ContextStore,
702
+ Ce as action,
703
+ Fe as actionButtonsUiSpec,
704
+ _e as beErrorToAgentError,
705
705
  We as buildPhotoSimilarityProfile,
706
- Ge as buildProductSimilarityProfile,
707
- Je as buildSimilarityQueries,
706
+ De as buildProductSimilarityProfile,
707
+ $e as buildSimilarityQueries,
708
708
  D as canUseModuleWorker,
709
- B as caughtToStreamError,
710
- $e as comparisonUiSpec,
711
- tt as createBrowserMemory,
712
- ot as createDiagnosticsTool,
713
- ke as createFlow,
714
- K as createInjectorAdapter,
715
- Q as createMainThreadInjectorAdapter,
716
- ce as createModuleWorker,
717
- nt as createReadPageTool,
718
- Te as done,
719
- Re as elapsedMs,
720
- Ae as error,
721
- Be as httpErrorToAgentError,
722
- rt as installBrowserTools,
723
- Ve as installFetchTransportBridge,
724
- Qe as metadata,
725
- Xe as mountAccount,
726
- Oe as normalizeProduct,
727
- qe as normalizeSimilarityText,
728
- Ue as nowIso,
729
- He as productDetailsUiSpec,
730
- Fe as productsUiSpec,
731
- Le as rankSimilarProducts,
732
- Ke as requestText,
733
- et as resolveBeUrl,
734
- je as resolveFlow,
735
- Ne as scoreSimilarityCandidate,
736
- Ze as setAssistantHostVisible,
737
- he as stableKey,
738
- at as startLazyRuntimeLoader,
739
- xe as textChunk,
740
- ze as tokenizeSimilarityText,
741
- De as trimProductFactsCore,
742
- _e as trimProductFactsListCore,
709
+ $ as caughtToStreamError,
710
+ qe as comparisonUiSpec,
711
+ at as createBrowserMemory,
712
+ ct as createDiagnosticsTool,
713
+ Ge as createFlow,
714
+ Q as createInjectorAdapter,
715
+ Y as createMainThreadInjectorAdapter,
716
+ ue as createModuleWorker,
717
+ it as createReadPageTool,
718
+ Ue as done,
719
+ et as elapsedMs,
720
+ ve as error,
721
+ xe as httpErrorToAgentError,
722
+ st as installBrowserTools,
723
+ tt as installFetchTransportBridge,
724
+ Ne as llmCacheKey,
725
+ Le as metadata,
726
+ rt as mountAccount,
727
+ Ze as normalizeProduct,
728
+ Qe as normalizeSimilarityText,
729
+ Re as nowIso,
730
+ je as productDetailsUiSpec,
731
+ ze as productFactsKey,
732
+ Ie as productSkuKey,
733
+ Ye as productsUiSpec,
734
+ Be as rankSimilarProducts,
735
+ Je as requestText,
736
+ ot as resolveBeUrl,
737
+ Ve as resolveFlow,
738
+ ke as scoreSimilarityCandidate,
739
+ nt as setAssistantHostVisible,
740
+ H as stableKey,
741
+ lt as startLazyRuntimeLoader,
742
+ Oe as textChunk,
743
+ Ke as textKey,
744
+ He as tokenizeSimilarityText,
745
+ Me as trimProductFactsCore,
746
+ Xe as trimProductFactsListCore,
743
747
  Pe as uiSpec
744
748
  };