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