@gengage/assistant-fe 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/agentic/adaptor/fetch-bridge.d.ts +3 -2
  2. package/dist/agentic/index.d.ts +1 -0
  3. package/dist/agentic/index.js +324 -276
  4. package/dist/agentic/similarity.d.ts +77 -0
  5. package/dist/agentic/types.d.ts +2 -0
  6. package/dist/agentic/worker/be-client.d.ts +2 -1
  7. package/dist/agentic/worker.d.ts +1 -0
  8. package/dist/agentic/worker.js +65 -57
  9. package/dist/agentic.iife.js +5 -5
  10. package/dist/{api-paths-C4WzXzyY.js → api-paths-B1sFG4Tn.js} +1 -1
  11. package/dist/chat-runtime.js +1 -1
  12. package/dist/chat.iife.js +1 -1
  13. package/dist/chat.js +1 -1
  14. package/dist/common/transport.d.ts +7 -0
  15. package/dist/{common-DstAcheX.js → common-BML75wCP.js} +1 -1
  16. package/dist/common.js +5 -5
  17. package/dist/{connection-warning-Ddr91Y9x.js → connection-warning-Qy4APv0U.js} +1 -1
  18. package/dist/{fastIntent-XtUvISni.js → fastIntent-CXqUDc50.js} +1 -1
  19. package/dist/index.js +10 -10
  20. package/dist/native.iife.js +1 -1
  21. package/dist/qna-runtime.js +1 -1
  22. package/dist/qna.iife.js +1 -1
  23. package/dist/qna.js +1 -1
  24. package/dist/{runtime-C66Wp6OR.js → runtime-C5FjeLrv.js} +3 -3
  25. package/dist/{runtime-CcA_r8pw.js → runtime-DmZ325aj.js} +3 -3
  26. package/dist/{runtime-DJMUL882.js → runtime-U8DOh3fb.js} +3 -3
  27. package/dist/{simbut-B6L3fwI7.js → simbut-BJpWnq1J.js} +1 -1
  28. package/dist/simbut.iife.js +1 -1
  29. package/dist/simbut.js +1 -1
  30. package/dist/{beauty-consulting-turn-BmPXbkQg.js → similarity-DcfZ0CKT.js} +515 -295
  31. package/dist/{simrel-BB4Jrr32.js → simrel-B7RQY06h.js} +1 -1
  32. package/dist/simrel-runtime.js +1 -1
  33. package/dist/simrel.iife.js +1 -1
  34. package/dist/simrel.js +2 -2
  35. package/dist/{widget-base-B3Oq8pjs.js → widget-base-d-dDGkr7.js} +1 -1
  36. package/package.json +1 -1
@@ -1,45 +1,45 @@
1
- import { C as j, D as q, M as _, O as ue, S as le, T as D, _ as de, a as fe, b as O, c as ge, d as $, f as C, g as pe, h as we, i as me, j as M, k as he, l as ye, m as be, n as Se, o as Ee, p as Re, r as Ae, s as ve, t as Te, u as Ue, v as xe, w as Pe, x as Le, y as je } from "../beauty-consulting-turn-BmPXbkQg.js";
2
- function B({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: i, defaultLocale: c, tools: g = {}, beacon: m }) {
3
- let w = 1;
4
- const d = /* @__PURE__ */ new Map();
5
- return M({
1
+ import { A as C, C as de, D as O, E as fe, F as ge, I as pe, M as $, O as me, P as D, R as k, S as we, T as ye, _ as he, a as be, b as Se, c as Ee, d as Ae, f as Re, g as ve, h as Ue, i as Pe, j as Te, k as xe, l as Le, m as _e, n as je, o as qe, p as Ce, r as Oe, s as $e, t as De, u as ke, v as B, w as Be, x as Me, y as M, z as F } from "../similarity-DcfZ0CKT.js";
2
+ function N({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: i, defaultLocale: c, tools: d = {}, beacon: w }) {
3
+ let p = 1;
4
+ const u = /* @__PURE__ */ new Map();
5
+ return k({
6
6
  worker: t,
7
- tools: g,
8
- beacon: (u) => m?.({
9
- ...u,
10
- accountId: u.accountId || e
7
+ tools: d,
8
+ beacon: (l) => w?.({
9
+ ...l,
10
+ accountId: l.accountId || e
11
11
  }),
12
12
  memory: sessionStorage
13
- }), t.addEventListener("message", (u) => {
14
- const a = u.data || {}, s = typeof a.id == "number" ? a.id : null;
15
- if (s == null) return;
16
- const l = d.get(s);
17
- if (l) {
18
- if (a.type === "event" && a.event) {
19
- b(l, a.event);
13
+ }), t.addEventListener("message", (l) => {
14
+ const s = l.data || {}, a = typeof s.id == "number" ? s.id : null;
15
+ if (a == null) return;
16
+ const f = u.get(a);
17
+ if (f) {
18
+ if (s.type === "event" && s.event) {
19
+ S(f, s.event);
20
20
  return;
21
21
  }
22
- if (a.type === "error") {
23
- l.onError(new Error(a.message || "Agent worker failed")), d.delete(s);
22
+ if (s.type === "error") {
23
+ f.onError(new Error(s.message || "Agent worker failed")), u.delete(a);
24
24
  return;
25
25
  }
26
- a.type === "end" && d.delete(s);
26
+ s.type === "end" && u.delete(a);
27
27
  }
28
- }), (u, a, s) => {
29
- const l = w++;
30
- d.set(l, a);
31
- const p = () => {
32
- d.delete(l), t.postMessage({
33
- id: l,
28
+ }), (l, s, a) => {
29
+ const f = p++;
30
+ u.set(f, s);
31
+ const m = () => {
32
+ u.delete(f), t.postMessage({
33
+ id: f,
34
34
  type: "abort"
35
35
  });
36
36
  };
37
- if (s.aborted) {
38
- p();
37
+ if (a.aborted) {
38
+ m();
39
39
  return;
40
40
  }
41
- s.addEventListener("abort", p, { once: !0 }), t.postMessage({
42
- id: l,
41
+ a.addEventListener("abort", m, { once: !0 }), t.postMessage({
42
+ id: f,
43
43
  type: "invoke",
44
44
  accountId: e,
45
45
  beUrl: r,
@@ -47,71 +47,72 @@ function B({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl:
47
47
  tokenBrokerUrl: o,
48
48
  tokenBrokerAudience: i,
49
49
  defaultLocale: c,
50
- request: u,
50
+ request: l,
51
51
  parentUrl: window.location.href
52
52
  });
53
53
  };
54
54
  }
55
- function k({ accountId: e, accountModule: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: i, defaultLocale: c, tools: g = {}, beacon: m }) {
56
- let w = null;
57
- const d = F({
55
+ function G({ accountId: e, accountModule: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: i, defaultLocale: c, tools: d = {}, beacon: w }) {
56
+ let p = null;
57
+ const u = I({
58
58
  accountId: e,
59
- tools: g,
60
- beacon: m
61
- }), u = $(d), a = D({
59
+ tools: d,
60
+ beacon: w
61
+ }), l = B(u), s = $({
62
62
  accountId: e,
63
63
  ...n ? { devJwtSecret: n } : {},
64
64
  ...o ? { tokenBrokerUrl: o } : {},
65
65
  ...i ? { tokenBrokerAudience: i } : {}
66
66
  });
67
- return async (s, l, p) => {
68
- w ||= new q({
67
+ return async (a, f, m) => {
68
+ p ||= new D({
69
69
  accountId: e,
70
- locale: s?.locale || c,
70
+ locale: a?.locale || c,
71
71
  parentUrl: window.location.href,
72
- rpc: d
72
+ rpc: u
73
73
  });
74
74
  try {
75
- await C({
76
- request: s || {},
75
+ await M({
76
+ request: a || {},
77
77
  accountModule: {
78
78
  ...t,
79
79
  accountId: e
80
80
  },
81
- contextStore: w,
82
- beClient: { invoke({ op: f, input: y, signal: h }) {
81
+ contextStore: p,
82
+ beClient: { invoke({ op: g, input: h, signal: y, cacheTtlS: b }) {
83
83
  return O({
84
84
  beUrl: r,
85
85
  accountId: e,
86
- jwtProvider: a,
86
+ jwtProvider: s,
87
87
  parentUrl: window.location.href,
88
- op: f,
89
- input: y,
90
- ...h ? { signal: h } : {}
88
+ op: g,
89
+ input: h,
90
+ cacheTtlS: b,
91
+ ...y ? { signal: y } : {}
91
92
  });
92
93
  } },
93
- toolBridge: u,
94
- emit: (f) => b(l, f),
95
- rpc: d,
96
- signal: p
94
+ toolBridge: l,
95
+ emit: (g) => S(f, g),
96
+ rpc: u,
97
+ signal: m
97
98
  });
98
- } catch (f) {
99
- p?.aborted || (b(l, j(f)), l.onDone());
99
+ } catch (g) {
100
+ m?.aborted || (S(f, C(g)), f.onDone());
100
101
  }
101
102
  };
102
103
  }
103
- function F({ accountId: e, tools: t, beacon: r }) {
104
+ function I({ accountId: e, tools: t, beacon: r }) {
104
105
  const n = (o) => r?.({
105
106
  ...o,
106
107
  accountId: o.accountId || e
107
108
  });
108
- return ((o, i) => _(o, i, {
109
+ return ((o, i) => F(o, i, {
109
110
  tools: t,
110
111
  beacon: n,
111
112
  memory: sessionStorage
112
113
  }));
113
114
  }
114
- function b(e, t) {
115
+ function S(e, t) {
115
116
  switch (t?.type) {
116
117
  case "text_chunk": {
117
118
  const r = t;
@@ -130,7 +131,7 @@ function b(e, t) {
130
131
  e.onMetadata(t);
131
132
  break;
132
133
  case "error":
133
- e.onError(N(t));
134
+ e.onError(H(t));
134
135
  break;
135
136
  case "done":
136
137
  e.onDone();
@@ -139,46 +140,56 @@ function b(e, t) {
139
140
  break;
140
141
  }
141
142
  }
142
- function N(e) {
143
+ function H(e) {
143
144
  const t = new Error(e.message || e.code || "Agent error");
144
145
  return e.code && (t.code = e.code), t;
145
146
  }
146
- var v = "__gengageAgentFetchBridge";
147
- function qe({ accountId: e, streamTransport: t }) {
147
+ var U = "__gengageAgentFetchBridge";
148
+ function Fe({ accountId: e, streamTransport: t, endpoints: r = {} }) {
148
149
  if (!e) throw new Error("accountId is required.");
149
150
  if (typeof t != "function") throw new Error("streamTransport is required.");
150
- const r = G(), n = `https://gengage-injector.invalid/${encodeURIComponent(e)}`, o = `${n}/chat/process_action`;
151
- return r.routes.set(o, { streamTransport: t }), {
152
- middlewareUrl: n,
151
+ const n = J(), o = `https://gengage-injector.invalid/${encodeURIComponent(e)}`, i = /* @__PURE__ */ new Set(), c = (d) => {
152
+ const w = `${o}/chat/${d}`;
153
+ i.add(w);
154
+ const p = r[d], u = {
155
+ streamTransport: t,
156
+ endpoint: d
157
+ };
158
+ p && (u.endpointHandler = p), n.routes.set(w, u);
159
+ };
160
+ c("process_action");
161
+ for (const d of Object.keys(r)) d !== "process_action" && c(d);
162
+ return {
163
+ middlewareUrl: o,
153
164
  stop() {
154
- r.routes.delete(o);
165
+ for (const d of i) n.routes.delete(d);
155
166
  }
156
167
  };
157
168
  }
158
- function G() {
159
- const e = window, t = e[v];
169
+ function J() {
170
+ const e = window, t = e[U];
160
171
  if (t) return t;
161
172
  const r = e.fetch.bind(e), n = {
162
173
  routes: /* @__PURE__ */ new Map(),
163
174
  originalFetch: r
164
175
  };
165
176
  return e.fetch = (o, i) => {
166
- const c = I(o), g = n.routes.get(c);
167
- return g ? K(g, o, i) : r(o, i);
168
- }, e[v] = n, n;
177
+ const c = _(o), d = n.routes.get(c);
178
+ return d ? W(d, o, i) : r(o, i);
179
+ }, e[U] = n, n;
169
180
  }
170
- function I(e) {
181
+ function _(e) {
171
182
  return typeof e == "string" ? e : e instanceof URL ? e.href : e?.url || "";
172
183
  }
173
- function J(e, t) {
184
+ function P(e, t) {
174
185
  if (t?.signal) return t.signal;
175
186
  if (typeof Request < "u" && e instanceof Request) return e.signal;
176
187
  }
177
- function W(e, t) {
188
+ function j(e, t) {
178
189
  return t?.body !== void 0 && t?.body !== null ? t.body : typeof Request < "u" && e instanceof Request ? e.clone().text() : null;
179
190
  }
180
- async function H(e, t) {
181
- const r = W(e, t);
191
+ async function z(e, t) {
192
+ const r = j(e, t);
182
193
  if (r instanceof FormData) {
183
194
  const o = r.get("request"), i = r.get("attachment");
184
195
  return {
@@ -189,114 +200,144 @@ async function H(e, t) {
189
200
  const n = await Promise.resolve(r);
190
201
  return typeof n == "string" ? { request: JSON.parse(n || "{}") } : { request: {} };
191
202
  }
192
- function K(e, t, r) {
193
- const n = new TextEncoder(), o = new AbortController(), i = J(t, r);
194
- let c = !1, g = null;
195
- const m = new ReadableStream({
196
- async start(w) {
197
- const d = (s) => {
198
- c || w.enqueue(n.encode(`${JSON.stringify(s)}
203
+ async function W(e, t, r) {
204
+ if (e.endpoint && e.endpoint !== "process_action" && e.endpointHandler) {
205
+ const p = new AbortController(), u = P(t, r);
206
+ let l = null;
207
+ if (u) {
208
+ const s = () => p.abort();
209
+ u.aborted && s(), u.addEventListener("abort", s, { once: !0 }), l = () => u.removeEventListener("abort", s);
210
+ }
211
+ try {
212
+ const s = await K(t, r);
213
+ return await e.endpointHandler(s, {
214
+ accountId: Q(t),
215
+ endpoint: e.endpoint,
216
+ signal: p.signal
217
+ });
218
+ } finally {
219
+ l?.();
220
+ }
221
+ }
222
+ const n = new TextEncoder(), o = new AbortController(), i = P(t, r);
223
+ let c = !1, d = null;
224
+ const w = new ReadableStream({
225
+ async start(p) {
226
+ const u = (a) => {
227
+ c || p.enqueue(n.encode(`${JSON.stringify(a)}
199
228
  `));
200
- }, u = () => {
201
- c || (c = !0, g?.(), w.close());
202
- }, a = (s) => {
203
- d({
229
+ }, l = () => {
230
+ c || (c = !0, d?.(), p.close());
231
+ }, s = (a) => {
232
+ u({
204
233
  type: "error",
205
- code: s?.code || "agent_bridge_error",
206
- message: s instanceof Error ? s.message : String(s)
207
- }), d({ type: "done" }), u();
234
+ code: a?.code || "agent_bridge_error",
235
+ message: a instanceof Error ? a.message : String(a)
236
+ }), u({ type: "done" }), l();
208
237
  };
209
238
  if (i) {
210
- const s = () => {
211
- o.abort(), c || (c = !0, g?.(), w.error(new DOMException("Aborted", "AbortError")));
239
+ const a = () => {
240
+ o.abort(), c || (c = !0, d?.(), p.error(new DOMException("Aborted", "AbortError")));
212
241
  };
213
242
  if (i.aborted) {
214
- s();
243
+ a();
215
244
  return;
216
245
  }
217
- i.addEventListener("abort", s, { once: !0 }), g = () => i.removeEventListener("abort", s);
246
+ i.addEventListener("abort", a, { once: !0 }), d = () => i.removeEventListener("abort", a);
218
247
  }
219
248
  try {
220
- const { request: s, attachment: l } = await H(t, r), p = e.streamTransport(s, {
221
- onTextChunk: (f, y, h = {}) => d({
249
+ const { request: a, attachment: f } = await z(t, r), m = e.streamTransport(a, {
250
+ onTextChunk: (g, h, y = {}) => u({
222
251
  type: "text_chunk",
223
- content: f,
224
- final: y === !0,
225
- ...h
252
+ content: g,
253
+ final: h === !0,
254
+ ...y
226
255
  }),
227
- onUISpec: (f, y, h, L) => d({
256
+ onUISpec: (g, h, y, b) => u({
228
257
  type: "ui_spec",
229
- spec: f,
230
- widget: y,
231
- ...h ? { panelHint: h } : {},
232
- ...L ? { clearPanel: !0 } : {}
258
+ spec: g,
259
+ widget: h,
260
+ ...y ? { panelHint: y } : {},
261
+ ...b ? { clearPanel: !0 } : {}
233
262
  }),
234
- onAction: (f) => {
235
- d(f?.type === "action" ? f : {
263
+ onAction: (g) => {
264
+ u(g?.type === "action" ? g : {
236
265
  type: "action",
237
- action: f
266
+ action: g
238
267
  });
239
268
  },
240
- onMetadata: (f) => {
241
- d(f?.type === "metadata" ? f : {
269
+ onMetadata: (g) => {
270
+ u(g?.type === "metadata" ? g : {
242
271
  type: "metadata",
243
- ...f
272
+ ...g
244
273
  });
245
274
  },
246
- onError: a,
275
+ onError: s,
247
276
  onDone: () => {
248
- d({ type: "done" }), u();
277
+ u({ type: "done" }), l();
249
278
  }
250
- }, o.signal, l);
251
- V(p) && (await p, o.signal.aborted || (d({ type: "done" }), u()));
252
- } catch (s) {
253
- o.signal.aborted || a(s);
279
+ }, o.signal, f);
280
+ V(m) && (await m, o.signal.aborted || (u({ type: "done" }), l()));
281
+ } catch (a) {
282
+ o.signal.aborted || s(a);
254
283
  }
255
284
  },
256
285
  cancel() {
257
- o.abort(), g?.(), c = !0;
286
+ o.abort(), d?.(), c = !0;
258
287
  }
259
288
  });
260
- return Promise.resolve(new Response(m, {
289
+ return new Response(w, {
261
290
  status: 200,
262
291
  headers: { "Content-Type": "application/x-ndjson" }
263
- }));
292
+ });
293
+ }
294
+ async function K(e, t) {
295
+ const r = await Promise.resolve(j(e, t));
296
+ return typeof r != "string" || r.trim() === "" ? {} : JSON.parse(r);
297
+ }
298
+ function Q(e) {
299
+ try {
300
+ const [t] = new URL(_(e)).pathname.split("/").filter(Boolean);
301
+ return decodeURIComponent(t || "");
302
+ } catch {
303
+ return "";
304
+ }
264
305
  }
265
306
  function V(e) {
266
307
  return e !== null && (typeof e == "object" || typeof e == "function") && typeof e.then == "function";
267
308
  }
268
- function _e({ accountId: e, beUrl: t, devJwtSecret: r, tokenBrokerUrl: n, tokenBrokerAudience: o, workerUrl: i, defaultLocale: c = "en-GB", accountModule: g, tools: m = {}, beacon: w, allowBlobWorker: d = !1 }) {
309
+ function Ne({ accountId: e, beUrl: t, devJwtSecret: r, tokenBrokerUrl: n, tokenBrokerAudience: o, workerUrl: i, defaultLocale: c = "en-GB", accountModule: d, tools: w = {}, beacon: p, allowBlobWorker: u = !1 }) {
269
310
  if (!e) throw new Error("accountId is required.");
270
311
  if (!t) throw new Error("beUrl is required. The injector owns backend URLs; the SDK has no default.");
271
312
  if (!i) throw new Error("workerUrl is required.");
272
- const u = window, a = u.GengageAssistantInjector || (u.GengageAssistantInjector = {}), s = a[e] || (a[e] = {});
273
- if (s.agentController) return s.agentController;
274
- const l = P(i) || d ? Y(i, `gengage-${e}-agent`, { allowBlobWorker: d }) : null;
275
- s.streamTransport = l ? B({
313
+ const l = window, s = l.GengageAssistantInjector || (l.GengageAssistantInjector = {}), a = s[e] || (s[e] = {});
314
+ if (a.agentController) return a.agentController;
315
+ const f = q(i) || u ? Y(i, `gengage-${e}-agent`, { allowBlobWorker: u }) : null;
316
+ a.streamTransport = f ? N({
276
317
  accountId: e,
277
- worker: l.worker,
318
+ worker: f.worker,
278
319
  beUrl: t,
279
320
  ...r ? { devJwtSecret: r } : {},
280
321
  ...n ? { tokenBrokerUrl: n } : {},
281
322
  ...o ? { tokenBrokerAudience: o } : {},
282
323
  defaultLocale: c,
283
- tools: m,
284
- ...w ? { beacon: w } : {}
285
- }) : k({
324
+ tools: w,
325
+ ...p ? { beacon: p } : {}
326
+ }) : G({
286
327
  accountId: e,
287
- accountModule: g,
328
+ accountModule: d,
288
329
  beUrl: t,
289
330
  ...r ? { devJwtSecret: r } : {},
290
331
  ...n ? { tokenBrokerUrl: n } : {},
291
332
  ...o ? { tokenBrokerAudience: o } : {},
292
333
  defaultLocale: c,
293
- tools: m,
294
- ...w ? { beacon: w } : {}
334
+ tools: w,
335
+ ...p ? { beacon: p } : {}
295
336
  });
296
- const p = {
337
+ const m = {
297
338
  type: "agent",
298
339
  stop() {
299
- delete s.streamTransport, l?.worker.terminate(), l?.cleanup(), delete s.agentController;
340
+ delete a.streamTransport, f?.worker.terminate(), f?.cleanup(), delete a.agentController;
300
341
  },
301
342
  diagnostics() {
302
343
  return {
@@ -304,20 +345,20 @@ function _e({ accountId: e, beUrl: t, devJwtSecret: r, tokenBrokerUrl: n, tokenB
304
345
  beUrl: t,
305
346
  workerUrl: i,
306
347
  mounted: !0,
307
- transport: l ? "worker" : "main-thread",
308
- flows: Object.keys(g?.flows || {})
348
+ transport: f ? "worker" : "main-thread",
349
+ flows: Object.keys(d?.flows || {})
309
350
  };
310
351
  }
311
352
  };
312
- return s.agentController = p, p;
353
+ return a.agentController = m, m;
313
354
  }
314
- function P(e) {
355
+ function q(e) {
315
356
  const t = new URL(e, window.location.href);
316
357
  return t.origin === window.location.origin || t.protocol === "blob:";
317
358
  }
318
359
  function Y(e, t, r = {}) {
319
360
  const n = new URL(e, window.location.href);
320
- if (P(e)) return {
361
+ if (q(e)) return {
321
362
  worker: new Worker(n.href, {
322
363
  type: "module",
323
364
  name: t
@@ -342,23 +383,23 @@ function Y(e, t, r = {}) {
342
383
  throw URL.revokeObjectURL(i), c;
343
384
  }
344
385
  }
345
- function z(e) {
386
+ function X(e) {
346
387
  const t = (e?.chat || e?._chat)?.root || e?._chat?.root;
347
388
  return t ? t.getRootNode?.()?.host || t : Array.from(document.querySelectorAll("*")).find((r) => r.shadowRoot?.querySelector?.(".gengage-chat-root, .gengage-chat-launcher-container"));
348
389
  }
349
- function De(e, t) {
350
- const r = z(e);
390
+ function Ge(e, t) {
391
+ const r = X(e);
351
392
  r?.style && (t ? r.style.removeProperty("display") : r.style.setProperty("display", "none", "important")), t || (e?.chat || e?._chat)?.close?.();
352
393
  }
353
- var Q = "nd_be_url";
354
- function Oe(e, t) {
355
- const r = X() || e.beUrl || t;
394
+ var Z = "nd_be_url";
395
+ function Ie(e, t) {
396
+ const r = ee() || e.beUrl || t;
356
397
  if (!r) throw new Error("resolveBeUrl: backend URL is required. The injector must supply a fallback URL; the SDK has no default.");
357
398
  return r;
358
399
  }
359
- function X() {
400
+ function ee() {
360
401
  try {
361
- const e = new URLSearchParams(window.location.search).get(Q)?.trim();
402
+ const e = new URLSearchParams(window.location.search).get(Z)?.trim();
362
403
  if (!e) return null;
363
404
  const t = new URL(e);
364
405
  return t.protocol !== "https:" && t.protocol !== "http:" ? null : t.toString().replace(/\/+$/u, "");
@@ -366,26 +407,26 @@ function X() {
366
407
  return null;
367
408
  }
368
409
  }
369
- var Z = "entries", ee = 1, te = {
410
+ var te = "entries", re = 1, ne = {
370
411
  volatile: "Hot per-page state and sensitive request context.",
371
412
  session: "Current-visit tool context without raw tokens or PII-heavy payloads.",
372
413
  local: "Small, non-sensitive capability facts or user preferences.",
373
414
  indexedDb: "Larger product/search payload caches with short TTLs."
374
415
  }, T = /* @__PURE__ */ new Map();
375
- function S() {
416
+ function E() {
376
417
  return Date.now();
377
418
  }
378
419
  function R(e) {
379
- return e?.expiresAt != null && e.expiresAt <= S();
420
+ return e?.expiresAt != null && e.expiresAt <= E();
380
421
  }
381
- function A(e, t) {
422
+ function v(e, t) {
382
423
  return {
383
424
  value: e,
384
- createdAt: S(),
385
- expiresAt: t ? S() + t : null
425
+ createdAt: E(),
426
+ expiresAt: t ? E() + t : null
386
427
  };
387
428
  }
388
- function re(e, t, r) {
429
+ function oe(e, t, r) {
389
430
  try {
390
431
  const n = e.getItem(`${t}${r}`);
391
432
  if (!n) return null;
@@ -395,31 +436,31 @@ function re(e, t, r) {
395
436
  return null;
396
437
  }
397
438
  }
398
- function ne(e, t, r, n, o) {
439
+ function se(e, t, r, n, o) {
399
440
  try {
400
- return e.setItem(`${t}${r}`, JSON.stringify(A(n, o))), !0;
441
+ return e.setItem(`${t}${r}`, JSON.stringify(v(n, o))), !0;
401
442
  } catch {
402
443
  return !1;
403
444
  }
404
445
  }
405
- function oe(e, t, r) {
446
+ function ae(e, t, r) {
406
447
  try {
407
448
  e.removeItem(`${t}${r}`);
408
449
  } catch {
409
450
  }
410
451
  }
411
- function U(e) {
452
+ function x(e) {
412
453
  try {
413
454
  return window[e];
414
455
  } catch {
415
456
  return null;
416
457
  }
417
458
  }
418
- function x(e, t) {
459
+ function L(e, t) {
419
460
  return e ? {
420
- get: (r) => re(e, t, r),
421
- set: (r, n, o = {}) => ne(e, t, r, n, o.ttlMs),
422
- remove: (r) => oe(e, t, r)
461
+ get: (r) => oe(e, t, r),
462
+ set: (r, n, o = {}) => se(e, t, r, n, o.ttlMs),
463
+ remove: (r) => ae(e, t, r)
423
464
  } : {
424
465
  get: () => null,
425
466
  set: () => !1,
@@ -427,98 +468,98 @@ function x(e, t) {
427
468
  }
428
469
  };
429
470
  }
430
- function E(e) {
431
- if (Array.isArray(e)) return `[${e.map(E).join(",")}]`;
471
+ function A(e) {
472
+ if (Array.isArray(e)) return `[${e.map(A).join(",")}]`;
432
473
  if (e && typeof e == "object") {
433
474
  const t = e;
434
- return `{${Object.keys(t).sort().map((r) => `${JSON.stringify(r)}:${E(t[r])}`).join(",")}}`;
475
+ return `{${Object.keys(t).sort().map((r) => `${JSON.stringify(r)}:${A(t[r])}`).join(",")}}`;
435
476
  }
436
477
  return JSON.stringify(e);
437
478
  }
438
- function se(e) {
479
+ function ie(e) {
439
480
  let t = 2166136261;
440
- const r = E(e);
481
+ const r = A(e);
441
482
  for (let n = 0; n < r.length; n += 1)
442
483
  t ^= r.charCodeAt(n), t = Math.imul(t, 16777619);
443
484
  return (t >>> 0).toString(36);
444
485
  }
445
- function ae(e, t) {
446
- const r = t.dbName || `gengage-${e}`, n = t.dbStore || Z, o = t.dbVersion || ee, i = /* @__PURE__ */ new Map();
486
+ function ce(e, t) {
487
+ const r = t.dbName || `gengage-${e}`, n = t.dbStore || te, o = t.dbVersion || re, i = /* @__PURE__ */ new Map();
447
488
  let c = null;
448
- const g = () => "indexedDB" in window ? c || (c = new Promise((u) => {
449
- const a = indexedDB.open(r, o);
450
- a.onupgradeneeded = () => {
451
- a.result.createObjectStore(n, { keyPath: "key" });
452
- }, a.onsuccess = () => u(a.result), a.onerror = () => u(null), a.onblocked = () => u(null);
489
+ const d = () => "indexedDB" in window ? c || (c = new Promise((l) => {
490
+ const s = indexedDB.open(r, o);
491
+ s.onupgradeneeded = () => {
492
+ s.result.createObjectStore(n, { keyPath: "key" });
493
+ }, s.onsuccess = () => l(s.result), s.onerror = () => l(null), s.onblocked = () => l(null);
453
494
  }), c) : Promise.resolve(null);
454
495
  return {
455
496
  volatileEntries: i,
456
- idbGet: async (u) => {
457
- const a = await g();
458
- return a ? new Promise((s) => {
459
- const l = a.transaction(n, "readwrite").objectStore(n), p = l.get(u);
460
- p.onsuccess = () => {
461
- const f = p.result;
462
- if (!f || R(f)) {
463
- f && l.delete(u), s(null);
497
+ idbGet: async (l) => {
498
+ const s = await d();
499
+ return s ? new Promise((a) => {
500
+ const f = s.transaction(n, "readwrite").objectStore(n), m = f.get(l);
501
+ m.onsuccess = () => {
502
+ const g = m.result;
503
+ if (!g || R(g)) {
504
+ g && f.delete(l), a(null);
464
505
  return;
465
506
  }
466
- s(f.value);
467
- }, p.onerror = () => s(null);
507
+ a(g.value);
508
+ }, m.onerror = () => a(null);
468
509
  }) : null;
469
510
  },
470
- idbSet: async (u, a, s = {}) => {
471
- const l = await g();
472
- return l ? new Promise((p) => {
473
- const f = l.transaction(n, "readwrite");
474
- f.oncomplete = () => p(!0), f.onerror = () => p(!1), f.objectStore(n).put({
475
- key: u,
476
- ...A(a, s.ttlMs)
511
+ idbSet: async (l, s, a = {}) => {
512
+ const f = await d();
513
+ return f ? new Promise((m) => {
514
+ const g = f.transaction(n, "readwrite");
515
+ g.oncomplete = () => m(!0), g.onerror = () => m(!1), g.objectStore(n).put({
516
+ key: l,
517
+ ...v(s, a.ttlMs)
477
518
  });
478
519
  }) : !1;
479
520
  },
480
- idbRemove: async (u) => {
481
- const a = await g();
482
- a && a.transaction(n, "readwrite").objectStore(n).delete(u);
521
+ idbRemove: async (l) => {
522
+ const s = await d();
523
+ s && s.transaction(n, "readwrite").objectStore(n).delete(l);
483
524
  }
484
525
  };
485
526
  }
486
- function $e(e, t = {}) {
527
+ function He(e, t = {}) {
487
528
  const r = window, n = r.gengage || (r.gengage = {}), o = n.memory || (n.memory = {}), i = o[e];
488
529
  if (i) return i;
489
- const c = T.get(e) || ae(e, t);
530
+ const c = T.get(e) || ce(e, t);
490
531
  T.set(e, c);
491
- const g = t.sessionPrefix || `gengage:${e}:session:`, m = t.localPrefix || `gengage:${e}:local:`, d = {
492
- get: (s) => {
493
- const l = c.volatileEntries.get(s);
494
- return l ? R(l) ? (c.volatileEntries.delete(s), null) : l.value : null;
532
+ const d = t.sessionPrefix || `gengage:${e}:session:`, w = t.localPrefix || `gengage:${e}:local:`, u = {
533
+ get: (a) => {
534
+ const f = c.volatileEntries.get(a);
535
+ return f ? R(f) ? (c.volatileEntries.delete(a), null) : f.value : null;
495
536
  },
496
- set: (s, l, p = {}) => (c.volatileEntries.set(s, A(l, p.ttlMs)), !0),
497
- remove: (s) => {
498
- c.volatileEntries.delete(s);
537
+ set: (a, f, m = {}) => (c.volatileEntries.set(a, v(f, m.ttlMs)), !0),
538
+ remove: (a) => {
539
+ c.volatileEntries.delete(a);
499
540
  },
500
541
  clear: () => c.volatileEntries.clear()
501
- }, u = {
542
+ }, l = {
502
543
  get: c.idbGet,
503
544
  set: c.idbSet,
504
545
  remove: c.idbRemove
505
- }, a = {
546
+ }, s = {
506
547
  accountId: e,
507
- volatile: d,
508
- session: x(U("sessionStorage"), g),
509
- local: x(U("localStorage"), m),
510
- indexedDb: u,
511
- stableKey: se,
548
+ volatile: u,
549
+ session: L(x("sessionStorage"), d),
550
+ local: L(x("localStorage"), w),
551
+ indexedDb: l,
552
+ stableKey: ie,
512
553
  policy: {
513
- ...te,
554
+ ...ne,
514
555
  ...t.policy || {}
515
556
  }
516
557
  };
517
- o[e] = a;
518
- for (const s of t.aliases || []) o[s] = a;
519
- return a;
558
+ o[e] = s;
559
+ for (const a of t.aliases || []) o[a] = s;
560
+ return s;
520
561
  }
521
- var ie = [
562
+ var le = [
522
563
  "addToCart",
523
564
  "search",
524
565
  "searchKeyword",
@@ -526,17 +567,17 @@ var ie = [
526
567
  "searchGiftOptions",
527
568
  "similaritySearch"
528
569
  ];
529
- function Ce(e, t, r = {}) {
570
+ function Je(e, t, r = {}) {
530
571
  const n = window, o = n.gengage || (n.gengage = {}), i = o.tools || (o.tools = {});
531
572
  i[e] = t;
532
573
  for (const c of r.accountAliases || []) i[c] = t;
533
- if (r.exposeStandardAliases !== !1) for (const c of r.standardAliases || ie) {
534
- const g = t[c];
535
- typeof g == "function" && (i[c] = i[c] || g);
574
+ if (r.exposeStandardAliases !== !1) for (const c of r.standardAliases || le) {
575
+ const d = t[c];
576
+ typeof d == "function" && (i[c] = i[c] || d);
536
577
  }
537
578
  return t;
538
579
  }
539
- function Me({ getPageType: e, getProduct: t }) {
580
+ function ze({ getPageType: e, getProduct: t }) {
540
581
  return () => ({
541
582
  url: window.location.href,
542
583
  title: document.title,
@@ -544,7 +585,7 @@ function Me({ getPageType: e, getProduct: t }) {
544
585
  product: t()
545
586
  });
546
587
  }
547
- function Be({ accountId: e, getPageType: t, getProduct: r, getToolNames: n, getSearchCapabilities: o, getMemory: i }) {
588
+ function We({ accountId: e, getPageType: t, getProduct: r, getToolNames: n, getSearchCapabilities: o, getMemory: i }) {
548
589
  return async () => ({
549
590
  accountId: e,
550
591
  url: window.location.href,
@@ -556,69 +597,76 @@ function Be({ accountId: e, getPageType: t, getProduct: r, getToolNames: n, getS
556
597
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
557
598
  });
558
599
  }
559
- function ke({ accountId: e, runtimeFile: t = "runtime.js", startExport: r = "start", globalBaseUrlKey: n, errorLabel: o } = {}) {
600
+ function Ke({ accountId: e, runtimeFile: t = "runtime.js", startExport: r = "start", globalBaseUrlKey: n, errorLabel: o } = {}) {
560
601
  if (!e) throw new Error("accountId is required.");
561
- const i = o || e, c = window, g = () => {
562
- const u = c.GengageInjectorConfig || {}, a = u[e] || {};
602
+ const i = o || e, c = window, d = () => {
603
+ const l = c.GengageInjectorConfig || {}, s = l[e] || {};
563
604
  return {
564
- ...u,
565
- ...a
605
+ ...l,
606
+ ...s
566
607
  };
567
- }, m = () => {
568
- const u = g();
569
- if (u.runtimeUrl) return u.runtimeUrl;
570
- const a = u.assetBaseUrl || u.baseUrl || document.currentScript?.getAttribute("src") || (n ? c[n] : null);
571
- if (!a) throw new Error(`${i} runtime URL cannot be resolved.`);
572
- return new URL(t, a).href;
573
- }, w = c.GengageAssistantInjector || (c.GengageAssistantInjector = {}), d = w[e] || (w[e] = {});
574
- return d.loaderPromise || (d.loaderPromise = import(
608
+ }, w = () => {
609
+ const l = d();
610
+ if (l.runtimeUrl) return l.runtimeUrl;
611
+ const s = l.assetBaseUrl || l.baseUrl || document.currentScript?.getAttribute("src") || (n ? c[n] : null);
612
+ if (!s) throw new Error(`${i} runtime URL cannot be resolved.`);
613
+ return new URL(t, s).href;
614
+ }, p = c.GengageAssistantInjector || (c.GengageAssistantInjector = {}), u = p[e] || (p[e] = {});
615
+ return u.loaderPromise || (u.loaderPromise = import(
575
616
  /* @vite-ignore */
576
- m()
577
- ).then((u) => {
578
- const a = u[r];
579
- if (typeof a != "function") throw new Error(`${i} runtime export ${r} is unavailable.`);
580
- return a();
581
- }).catch((u) => {
582
- throw console.error(`[Gengage][${e}] runtime load failed`, u), u;
583
- })), d.loaderPromise;
617
+ w()
618
+ ).then((l) => {
619
+ const s = l[r];
620
+ if (typeof s != "function") throw new Error(`${i} runtime export ${r} is unavailable.`);
621
+ return s();
622
+ }).catch((l) => {
623
+ throw console.error(`[Gengage][${e}] runtime load failed`, l), l;
624
+ })), u.loaderPromise;
584
625
  }
585
626
  export {
586
- Le as AgentError,
587
- q as ContextStore,
588
- be as action,
589
- me as actionButtonsUiSpec,
590
- le as beErrorToAgentError,
591
- Te as beautyConsultingTurnFlow,
592
- P as canUseModuleWorker,
593
- j as caughtToStreamError,
594
- fe as comparisonUiSpec,
595
- $e as createBrowserMemory,
596
- Be as createDiagnosticsTool,
597
- Se as createFlow,
598
- B as createInjectorAdapter,
599
- k as createMainThreadInjectorAdapter,
627
+ me as AgentError,
628
+ D as ContextStore,
629
+ Me as action,
630
+ Ae as actionButtonsUiSpec,
631
+ xe as beErrorToAgentError,
632
+ Ee as beautyConsultingTurnFlow,
633
+ De as buildPhotoSimilarityProfile,
634
+ je as buildProductSimilarityProfile,
635
+ Oe as buildSimilarityQueries,
636
+ q as canUseModuleWorker,
637
+ C as caughtToStreamError,
638
+ Re as comparisonUiSpec,
639
+ He as createBrowserMemory,
640
+ We as createDiagnosticsTool,
641
+ Le as createFlow,
642
+ N as createInjectorAdapter,
643
+ G as createMainThreadInjectorAdapter,
600
644
  Y as createModuleWorker,
601
- Me as createReadPageTool,
645
+ ze as createReadPageTool,
602
646
  we as done,
603
- ue as elapsedMs,
604
- pe as error,
605
- Pe as httpErrorToAgentError,
606
- Ce as installBrowserTools,
607
- qe as installFetchTransportBridge,
608
- de as metadata,
609
- _e as mountAccount,
610
- ge as normalizeProduct,
611
- he as nowIso,
612
- Ee as productDetailsUiSpec,
613
- ve as productsUiSpec,
614
- Ae as requestText,
615
- Oe as resolveBeUrl,
616
- Re as resolveFlow,
617
- De as setAssistantHostVisible,
618
- se as stableKey,
619
- ke as startLazyRuntimeLoader,
620
- xe as textChunk,
621
- ye as trimProductFactsCore,
622
- Ue as trimProductFactsListCore,
623
- je as uiSpec
647
+ ge as elapsedMs,
648
+ de as error,
649
+ Te as httpErrorToAgentError,
650
+ Je as installBrowserTools,
651
+ Fe as installFetchTransportBridge,
652
+ Be as metadata,
653
+ Ne as mountAccount,
654
+ Ue as normalizeProduct,
655
+ Pe as normalizeSimilarityText,
656
+ pe as nowIso,
657
+ Ce as productDetailsUiSpec,
658
+ _e as productsUiSpec,
659
+ be as rankSimilarProducts,
660
+ ke as requestText,
661
+ Ie as resolveBeUrl,
662
+ Se as resolveFlow,
663
+ qe as scoreSimilarityCandidate,
664
+ Ge as setAssistantHostVisible,
665
+ ie as stableKey,
666
+ Ke as startLazyRuntimeLoader,
667
+ ye as textChunk,
668
+ $e as tokenizeSimilarityText,
669
+ ve as trimProductFactsCore,
670
+ he as trimProductFactsListCore,
671
+ fe as uiSpec
624
672
  };