@gengage/assistant-fe 0.6.0 → 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.
- package/README.md +6 -22
- package/dist/agentic/adaptor/fetch-bridge.d.ts +3 -2
- package/dist/agentic/index.d.ts +1 -0
- package/dist/agentic/index.js +358 -306
- package/dist/agentic/similarity.d.ts +77 -0
- package/dist/agentic/types.d.ts +2 -0
- package/dist/agentic/util/be-url.d.ts +1 -1
- package/dist/agentic/worker/be-client.d.ts +2 -1
- package/dist/agentic/worker.d.ts +1 -0
- package/dist/agentic/worker.js +65 -57
- package/dist/agentic.iife.js +5 -5
- package/dist/{api-paths-DJFF9RuZ.js → api-paths-B1sFG4Tn.js} +1 -1
- package/dist/chat/runtime.d.ts +1 -0
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +2 -2
- package/dist/chat.js +1 -1
- package/dist/common/overlay.d.ts +1 -1
- package/dist/common/transport.d.ts +7 -0
- package/dist/{common-BydCGBNn.js → common-BML75wCP.js} +1 -1
- package/dist/common.js +5 -5
- package/dist/{connection-warning-Pbvk3J8k.js → connection-warning-Qy4APv0U.js} +1 -1
- package/dist/{fastIntent-CkYN2UOl.js → fastIntent-CXqUDc50.js} +1 -1
- package/dist/index.js +10 -10
- package/dist/native.iife.js +2 -2
- package/dist/qna/types.d.ts +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-OpNoB3cu.js → runtime-C5FjeLrv.js} +116 -113
- package/dist/{runtime-iCLkUjI3.js → runtime-DmZ325aj.js} +3 -3
- package/dist/{runtime-DbZO1qG5.js → runtime-U8DOh3fb.js} +3 -3
- package/dist/{simbut-FyXolmZY.js → simbut-BJpWnq1J.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/{beauty-consulting-turn-BmPXbkQg.js → similarity-DcfZ0CKT.js} +515 -295
- package/dist/{simrel-CbLe5OAr.js → simrel-B7RQY06h.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-COP8QwU3.js → widget-base-d-dDGkr7.js} +1 -1
- package/package.json +2 -34
package/dist/agentic/index.js
CHANGED
|
@@ -1,117 +1,118 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
function
|
|
3
|
-
let
|
|
4
|
-
const
|
|
5
|
-
return
|
|
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:
|
|
8
|
-
beacon: (
|
|
9
|
-
...
|
|
10
|
-
accountId:
|
|
7
|
+
tools: d,
|
|
8
|
+
beacon: (l) => w?.({
|
|
9
|
+
...l,
|
|
10
|
+
accountId: l.accountId || e
|
|
11
11
|
}),
|
|
12
12
|
memory: sessionStorage
|
|
13
|
-
}), t.addEventListener("message", (
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
if (
|
|
19
|
-
|
|
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 (
|
|
23
|
-
|
|
22
|
+
if (s.type === "error") {
|
|
23
|
+
f.onError(new Error(s.message || "Agent worker failed")), u.delete(a);
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
s.type === "end" && u.delete(a);
|
|
27
27
|
}
|
|
28
|
-
}), (
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
id:
|
|
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 (
|
|
38
|
-
|
|
37
|
+
if (a.aborted) {
|
|
38
|
+
m();
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
id:
|
|
41
|
+
a.addEventListener("abort", m, { once: !0 }), t.postMessage({
|
|
42
|
+
id: f,
|
|
43
43
|
type: "invoke",
|
|
44
44
|
accountId: e,
|
|
45
45
|
beUrl: r,
|
|
46
46
|
devJwtSecret: n,
|
|
47
47
|
tokenBrokerUrl: o,
|
|
48
|
-
tokenBrokerAudience:
|
|
49
|
-
defaultLocale:
|
|
50
|
-
request:
|
|
48
|
+
tokenBrokerAudience: i,
|
|
49
|
+
defaultLocale: c,
|
|
50
|
+
request: l,
|
|
51
51
|
parentUrl: window.location.href
|
|
52
52
|
});
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
let
|
|
57
|
-
const
|
|
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:
|
|
59
|
+
tools: d,
|
|
60
60
|
beacon: w
|
|
61
|
-
}),
|
|
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 (
|
|
68
|
-
|
|
67
|
+
return async (a, f, m) => {
|
|
68
|
+
p ||= new D({
|
|
69
69
|
accountId: e,
|
|
70
|
-
locale:
|
|
70
|
+
locale: a?.locale || c,
|
|
71
71
|
parentUrl: window.location.href,
|
|
72
|
-
rpc:
|
|
72
|
+
rpc: u
|
|
73
73
|
});
|
|
74
74
|
try {
|
|
75
|
-
await
|
|
76
|
-
request:
|
|
75
|
+
await M({
|
|
76
|
+
request: a || {},
|
|
77
77
|
accountModule: {
|
|
78
78
|
...t,
|
|
79
79
|
accountId: e
|
|
80
80
|
},
|
|
81
|
-
contextStore:
|
|
82
|
-
beClient: { invoke({ op:
|
|
83
|
-
return
|
|
81
|
+
contextStore: p,
|
|
82
|
+
beClient: { invoke({ op: g, input: h, signal: y, cacheTtlS: b }) {
|
|
83
|
+
return O({
|
|
84
84
|
beUrl: r,
|
|
85
85
|
accountId: e,
|
|
86
|
-
jwtProvider:
|
|
86
|
+
jwtProvider: s,
|
|
87
87
|
parentUrl: window.location.href,
|
|
88
|
-
op:
|
|
89
|
-
input:
|
|
90
|
-
|
|
88
|
+
op: g,
|
|
89
|
+
input: h,
|
|
90
|
+
cacheTtlS: b,
|
|
91
|
+
...y ? { signal: y } : {}
|
|
91
92
|
});
|
|
92
93
|
} },
|
|
93
|
-
toolBridge:
|
|
94
|
-
emit: (
|
|
95
|
-
rpc:
|
|
96
|
-
signal:
|
|
94
|
+
toolBridge: l,
|
|
95
|
+
emit: (g) => S(f, g),
|
|
96
|
+
rpc: u,
|
|
97
|
+
signal: m
|
|
97
98
|
});
|
|
98
|
-
} catch (
|
|
99
|
-
|
|
99
|
+
} catch (g) {
|
|
100
|
+
m?.aborted || (S(f, C(g)), f.onDone());
|
|
100
101
|
}
|
|
101
102
|
};
|
|
102
103
|
}
|
|
103
|
-
function
|
|
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,
|
|
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
|
|
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(
|
|
134
|
+
e.onError(H(t));
|
|
134
135
|
break;
|
|
135
136
|
case "done":
|
|
136
137
|
e.onDone();
|
|
@@ -139,183 +140,225 @@ function b(e, t) {
|
|
|
139
140
|
break;
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
|
-
function
|
|
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
|
|
147
|
-
function
|
|
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
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
|
|
165
|
+
for (const d of i) n.routes.delete(d);
|
|
155
166
|
}
|
|
156
167
|
};
|
|
157
168
|
}
|
|
158
|
-
function
|
|
159
|
-
const e = window, t = e[
|
|
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
|
-
return e.fetch = (o,
|
|
166
|
-
const
|
|
167
|
-
return
|
|
168
|
-
}, e[
|
|
176
|
+
return e.fetch = (o, i) => {
|
|
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
|
|
181
|
+
function _(e) {
|
|
171
182
|
return typeof e == "string" ? e : e instanceof URL ? e.href : e?.url || "";
|
|
172
183
|
}
|
|
173
|
-
function
|
|
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
|
|
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
|
|
181
|
-
const r =
|
|
191
|
+
async function z(e, t) {
|
|
192
|
+
const r = j(e, t);
|
|
182
193
|
if (r instanceof FormData) {
|
|
183
|
-
const o = r.get("request"),
|
|
194
|
+
const o = r.get("request"), i = r.get("attachment");
|
|
184
195
|
return {
|
|
185
196
|
request: JSON.parse(String(o || "{}")),
|
|
186
|
-
...
|
|
197
|
+
...i instanceof File ? { attachment: i } : {}
|
|
187
198
|
};
|
|
188
199
|
}
|
|
189
200
|
const n = await Promise.resolve(r);
|
|
190
201
|
return typeof n == "string" ? { request: JSON.parse(n || "{}") } : { request: {} };
|
|
191
202
|
}
|
|
192
|
-
function
|
|
193
|
-
|
|
194
|
-
|
|
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;
|
|
195
224
|
const w = new ReadableStream({
|
|
196
|
-
async start(
|
|
197
|
-
const
|
|
198
|
-
|
|
225
|
+
async start(p) {
|
|
226
|
+
const u = (a) => {
|
|
227
|
+
c || p.enqueue(n.encode(`${JSON.stringify(a)}
|
|
199
228
|
`));
|
|
200
|
-
},
|
|
201
|
-
|
|
202
|
-
},
|
|
203
|
-
|
|
229
|
+
}, l = () => {
|
|
230
|
+
c || (c = !0, d?.(), p.close());
|
|
231
|
+
}, s = (a) => {
|
|
232
|
+
u({
|
|
204
233
|
type: "error",
|
|
205
|
-
code:
|
|
206
|
-
message:
|
|
207
|
-
}),
|
|
234
|
+
code: a?.code || "agent_bridge_error",
|
|
235
|
+
message: a instanceof Error ? a.message : String(a)
|
|
236
|
+
}), u({ type: "done" }), l();
|
|
208
237
|
};
|
|
209
|
-
if (
|
|
210
|
-
const
|
|
211
|
-
o.abort(),
|
|
238
|
+
if (i) {
|
|
239
|
+
const a = () => {
|
|
240
|
+
o.abort(), c || (c = !0, d?.(), p.error(new DOMException("Aborted", "AbortError")));
|
|
212
241
|
};
|
|
213
|
-
if (
|
|
214
|
-
|
|
242
|
+
if (i.aborted) {
|
|
243
|
+
a();
|
|
215
244
|
return;
|
|
216
245
|
}
|
|
217
|
-
|
|
246
|
+
i.addEventListener("abort", a, { once: !0 }), d = () => i.removeEventListener("abort", a);
|
|
218
247
|
}
|
|
219
248
|
try {
|
|
220
|
-
const { request:
|
|
221
|
-
onTextChunk: (
|
|
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:
|
|
224
|
-
final:
|
|
225
|
-
...
|
|
252
|
+
content: g,
|
|
253
|
+
final: h === !0,
|
|
254
|
+
...y
|
|
226
255
|
}),
|
|
227
|
-
onUISpec: (
|
|
256
|
+
onUISpec: (g, h, y, b) => u({
|
|
228
257
|
type: "ui_spec",
|
|
229
|
-
spec:
|
|
230
|
-
widget:
|
|
231
|
-
...
|
|
232
|
-
...
|
|
258
|
+
spec: g,
|
|
259
|
+
widget: h,
|
|
260
|
+
...y ? { panelHint: y } : {},
|
|
261
|
+
...b ? { clearPanel: !0 } : {}
|
|
233
262
|
}),
|
|
234
|
-
onAction: (
|
|
235
|
-
|
|
263
|
+
onAction: (g) => {
|
|
264
|
+
u(g?.type === "action" ? g : {
|
|
236
265
|
type: "action",
|
|
237
|
-
action:
|
|
266
|
+
action: g
|
|
238
267
|
});
|
|
239
268
|
},
|
|
240
|
-
onMetadata: (
|
|
241
|
-
|
|
269
|
+
onMetadata: (g) => {
|
|
270
|
+
u(g?.type === "metadata" ? g : {
|
|
242
271
|
type: "metadata",
|
|
243
|
-
...
|
|
272
|
+
...g
|
|
244
273
|
});
|
|
245
274
|
},
|
|
246
|
-
onError:
|
|
275
|
+
onError: s,
|
|
247
276
|
onDone: () => {
|
|
248
|
-
|
|
277
|
+
u({ type: "done" }), l();
|
|
249
278
|
}
|
|
250
|
-
}, o.signal,
|
|
251
|
-
|
|
252
|
-
} catch (
|
|
253
|
-
o.signal.aborted || a
|
|
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(),
|
|
286
|
+
o.abort(), d?.(), c = !0;
|
|
258
287
|
}
|
|
259
288
|
});
|
|
260
|
-
return
|
|
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
|
-
function
|
|
306
|
+
function V(e) {
|
|
266
307
|
return e !== null && (typeof e == "object" || typeof e == "function") && typeof e.then == "function";
|
|
267
308
|
}
|
|
268
|
-
function
|
|
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
|
-
|
|
271
|
-
if (
|
|
272
|
-
const l =
|
|
273
|
-
|
|
311
|
+
if (!t) throw new Error("beUrl is required. The injector owns backend URLs; the SDK has no default.");
|
|
312
|
+
if (!i) throw new Error("workerUrl is required.");
|
|
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({
|
|
274
317
|
accountId: e,
|
|
275
|
-
worker:
|
|
318
|
+
worker: f.worker,
|
|
276
319
|
beUrl: t,
|
|
277
320
|
...r ? { devJwtSecret: r } : {},
|
|
278
321
|
...n ? { tokenBrokerUrl: n } : {},
|
|
279
322
|
...o ? { tokenBrokerAudience: o } : {},
|
|
280
|
-
defaultLocale:
|
|
323
|
+
defaultLocale: c,
|
|
281
324
|
tools: w,
|
|
282
|
-
...
|
|
283
|
-
}) :
|
|
325
|
+
...p ? { beacon: p } : {}
|
|
326
|
+
}) : G({
|
|
284
327
|
accountId: e,
|
|
285
|
-
accountModule:
|
|
328
|
+
accountModule: d,
|
|
286
329
|
beUrl: t,
|
|
287
330
|
...r ? { devJwtSecret: r } : {},
|
|
288
331
|
...n ? { tokenBrokerUrl: n } : {},
|
|
289
332
|
...o ? { tokenBrokerAudience: o } : {},
|
|
290
|
-
defaultLocale:
|
|
333
|
+
defaultLocale: c,
|
|
291
334
|
tools: w,
|
|
292
|
-
...
|
|
335
|
+
...p ? { beacon: p } : {}
|
|
293
336
|
});
|
|
294
|
-
const
|
|
337
|
+
const m = {
|
|
295
338
|
type: "agent",
|
|
296
339
|
stop() {
|
|
297
|
-
delete
|
|
340
|
+
delete a.streamTransport, f?.worker.terminate(), f?.cleanup(), delete a.agentController;
|
|
298
341
|
},
|
|
299
342
|
diagnostics() {
|
|
300
343
|
return {
|
|
301
344
|
accountId: e,
|
|
302
345
|
beUrl: t,
|
|
303
|
-
workerUrl:
|
|
346
|
+
workerUrl: i,
|
|
304
347
|
mounted: !0,
|
|
305
|
-
transport:
|
|
306
|
-
flows: Object.keys(
|
|
348
|
+
transport: f ? "worker" : "main-thread",
|
|
349
|
+
flows: Object.keys(d?.flows || {})
|
|
307
350
|
};
|
|
308
351
|
}
|
|
309
352
|
};
|
|
310
|
-
return
|
|
353
|
+
return a.agentController = m, m;
|
|
311
354
|
}
|
|
312
|
-
function
|
|
355
|
+
function q(e) {
|
|
313
356
|
const t = new URL(e, window.location.href);
|
|
314
357
|
return t.origin === window.location.origin || t.protocol === "blob:";
|
|
315
358
|
}
|
|
316
|
-
function
|
|
359
|
+
function Y(e, t, r = {}) {
|
|
317
360
|
const n = new URL(e, window.location.href);
|
|
318
|
-
if (
|
|
361
|
+
if (q(e)) return {
|
|
319
362
|
worker: new Worker(n.href, {
|
|
320
363
|
type: "module",
|
|
321
364
|
name: t
|
|
@@ -325,36 +368,38 @@ function z(e, t, r = {}) {
|
|
|
325
368
|
};
|
|
326
369
|
if (!r.allowBlobWorker) throw new Error("Cross-origin agent workers require allowBlobWorker=true or a same-origin workerUrl.");
|
|
327
370
|
const o = new Blob([`import ${JSON.stringify(n.href)};
|
|
328
|
-
`], { type: "text/javascript" }),
|
|
371
|
+
`], { type: "text/javascript" }), i = URL.createObjectURL(o);
|
|
329
372
|
try {
|
|
330
373
|
return {
|
|
331
|
-
worker: new Worker(
|
|
374
|
+
worker: new Worker(i, {
|
|
332
375
|
type: "module",
|
|
333
376
|
name: t
|
|
334
377
|
}),
|
|
335
378
|
cleanup() {
|
|
336
|
-
URL.revokeObjectURL(
|
|
379
|
+
URL.revokeObjectURL(i);
|
|
337
380
|
}
|
|
338
381
|
};
|
|
339
|
-
} catch (
|
|
340
|
-
throw URL.revokeObjectURL(
|
|
382
|
+
} catch (c) {
|
|
383
|
+
throw URL.revokeObjectURL(i), c;
|
|
341
384
|
}
|
|
342
385
|
}
|
|
343
|
-
function
|
|
386
|
+
function X(e) {
|
|
344
387
|
const t = (e?.chat || e?._chat)?.root || e?._chat?.root;
|
|
345
388
|
return t ? t.getRootNode?.()?.host || t : Array.from(document.querySelectorAll("*")).find((r) => r.shadowRoot?.querySelector?.(".gengage-chat-root, .gengage-chat-launcher-container"));
|
|
346
389
|
}
|
|
347
|
-
function
|
|
348
|
-
const r =
|
|
390
|
+
function Ge(e, t) {
|
|
391
|
+
const r = X(e);
|
|
349
392
|
r?.style && (t ? r.style.removeProperty("display") : r.style.setProperty("display", "none", "important")), t || (e?.chat || e?._chat)?.close?.();
|
|
350
393
|
}
|
|
351
|
-
var
|
|
352
|
-
function
|
|
353
|
-
|
|
394
|
+
var Z = "nd_be_url";
|
|
395
|
+
function Ie(e, t) {
|
|
396
|
+
const r = ee() || e.beUrl || t;
|
|
397
|
+
if (!r) throw new Error("resolveBeUrl: backend URL is required. The injector must supply a fallback URL; the SDK has no default.");
|
|
398
|
+
return r;
|
|
354
399
|
}
|
|
355
|
-
function
|
|
400
|
+
function ee() {
|
|
356
401
|
try {
|
|
357
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
402
|
+
const e = new URLSearchParams(window.location.search).get(Z)?.trim();
|
|
358
403
|
if (!e) return null;
|
|
359
404
|
const t = new URL(e);
|
|
360
405
|
return t.protocol !== "https:" && t.protocol !== "http:" ? null : t.toString().replace(/\/+$/u, "");
|
|
@@ -362,60 +407,60 @@ function Z() {
|
|
|
362
407
|
return null;
|
|
363
408
|
}
|
|
364
409
|
}
|
|
365
|
-
var
|
|
410
|
+
var te = "entries", re = 1, ne = {
|
|
366
411
|
volatile: "Hot per-page state and sensitive request context.",
|
|
367
412
|
session: "Current-visit tool context without raw tokens or PII-heavy payloads.",
|
|
368
413
|
local: "Small, non-sensitive capability facts or user preferences.",
|
|
369
414
|
indexedDb: "Larger product/search payload caches with short TTLs."
|
|
370
415
|
}, T = /* @__PURE__ */ new Map();
|
|
371
|
-
function
|
|
416
|
+
function E() {
|
|
372
417
|
return Date.now();
|
|
373
418
|
}
|
|
374
|
-
function
|
|
375
|
-
return e?.expiresAt != null && e.expiresAt <=
|
|
419
|
+
function R(e) {
|
|
420
|
+
return e?.expiresAt != null && e.expiresAt <= E();
|
|
376
421
|
}
|
|
377
|
-
function
|
|
422
|
+
function v(e, t) {
|
|
378
423
|
return {
|
|
379
424
|
value: e,
|
|
380
|
-
createdAt:
|
|
381
|
-
expiresAt: t ?
|
|
425
|
+
createdAt: E(),
|
|
426
|
+
expiresAt: t ? E() + t : null
|
|
382
427
|
};
|
|
383
428
|
}
|
|
384
|
-
function
|
|
429
|
+
function oe(e, t, r) {
|
|
385
430
|
try {
|
|
386
431
|
const n = e.getItem(`${t}${r}`);
|
|
387
432
|
if (!n) return null;
|
|
388
433
|
const o = JSON.parse(n);
|
|
389
|
-
return
|
|
434
|
+
return R(o) ? (e.removeItem(`${t}${r}`), null) : o.value;
|
|
390
435
|
} catch {
|
|
391
436
|
return null;
|
|
392
437
|
}
|
|
393
438
|
}
|
|
394
|
-
function
|
|
439
|
+
function se(e, t, r, n, o) {
|
|
395
440
|
try {
|
|
396
|
-
return e.setItem(`${t}${r}`, JSON.stringify(
|
|
441
|
+
return e.setItem(`${t}${r}`, JSON.stringify(v(n, o))), !0;
|
|
397
442
|
} catch {
|
|
398
443
|
return !1;
|
|
399
444
|
}
|
|
400
445
|
}
|
|
401
|
-
function
|
|
446
|
+
function ae(e, t, r) {
|
|
402
447
|
try {
|
|
403
448
|
e.removeItem(`${t}${r}`);
|
|
404
449
|
} catch {
|
|
405
450
|
}
|
|
406
451
|
}
|
|
407
|
-
function
|
|
452
|
+
function x(e) {
|
|
408
453
|
try {
|
|
409
454
|
return window[e];
|
|
410
455
|
} catch {
|
|
411
456
|
return null;
|
|
412
457
|
}
|
|
413
458
|
}
|
|
414
|
-
function
|
|
459
|
+
function L(e, t) {
|
|
415
460
|
return e ? {
|
|
416
|
-
get: (r) =>
|
|
417
|
-
set: (r, n, o = {}) =>
|
|
418
|
-
remove: (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)
|
|
419
464
|
} : {
|
|
420
465
|
get: () => null,
|
|
421
466
|
set: () => !1,
|
|
@@ -423,98 +468,98 @@ function x(e, t) {
|
|
|
423
468
|
}
|
|
424
469
|
};
|
|
425
470
|
}
|
|
426
|
-
function
|
|
427
|
-
if (Array.isArray(e)) return `[${e.map(
|
|
471
|
+
function A(e) {
|
|
472
|
+
if (Array.isArray(e)) return `[${e.map(A).join(",")}]`;
|
|
428
473
|
if (e && typeof e == "object") {
|
|
429
474
|
const t = e;
|
|
430
|
-
return `{${Object.keys(t).sort().map((r) => `${JSON.stringify(r)}:${
|
|
475
|
+
return `{${Object.keys(t).sort().map((r) => `${JSON.stringify(r)}:${A(t[r])}`).join(",")}}`;
|
|
431
476
|
}
|
|
432
477
|
return JSON.stringify(e);
|
|
433
478
|
}
|
|
434
|
-
function
|
|
479
|
+
function ie(e) {
|
|
435
480
|
let t = 2166136261;
|
|
436
|
-
const r =
|
|
481
|
+
const r = A(e);
|
|
437
482
|
for (let n = 0; n < r.length; n += 1)
|
|
438
483
|
t ^= r.charCodeAt(n), t = Math.imul(t, 16777619);
|
|
439
484
|
return (t >>> 0).toString(36);
|
|
440
485
|
}
|
|
441
|
-
function
|
|
442
|
-
const r = t.dbName || `gengage-${e}`, n = t.dbStore ||
|
|
443
|
-
let
|
|
444
|
-
const
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
},
|
|
449
|
-
}),
|
|
486
|
+
function ce(e, t) {
|
|
487
|
+
const r = t.dbName || `gengage-${e}`, n = t.dbStore || te, o = t.dbVersion || re, i = /* @__PURE__ */ new Map();
|
|
488
|
+
let c = 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);
|
|
494
|
+
}), c) : Promise.resolve(null);
|
|
450
495
|
return {
|
|
451
|
-
volatileEntries:
|
|
452
|
-
idbGet: async (
|
|
453
|
-
const
|
|
454
|
-
return
|
|
455
|
-
const
|
|
456
|
-
|
|
457
|
-
const
|
|
458
|
-
if (!
|
|
459
|
-
|
|
496
|
+
volatileEntries: i,
|
|
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);
|
|
460
505
|
return;
|
|
461
506
|
}
|
|
462
|
-
|
|
463
|
-
},
|
|
507
|
+
a(g.value);
|
|
508
|
+
}, m.onerror = () => a(null);
|
|
464
509
|
}) : null;
|
|
465
510
|
},
|
|
466
|
-
idbSet: async (
|
|
467
|
-
const
|
|
468
|
-
return
|
|
469
|
-
const
|
|
470
|
-
|
|
471
|
-
key:
|
|
472
|
-
...
|
|
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)
|
|
473
518
|
});
|
|
474
519
|
}) : !1;
|
|
475
520
|
},
|
|
476
|
-
idbRemove: async (
|
|
477
|
-
const
|
|
478
|
-
|
|
521
|
+
idbRemove: async (l) => {
|
|
522
|
+
const s = await d();
|
|
523
|
+
s && s.transaction(n, "readwrite").objectStore(n).delete(l);
|
|
479
524
|
}
|
|
480
525
|
};
|
|
481
526
|
}
|
|
482
|
-
function
|
|
483
|
-
const r = window, n = r.gengage || (r.gengage = {}), o = n.memory || (n.memory = {}),
|
|
484
|
-
if (
|
|
485
|
-
const
|
|
486
|
-
T.set(e,
|
|
487
|
-
const
|
|
488
|
-
get: (
|
|
489
|
-
const
|
|
490
|
-
return
|
|
527
|
+
function He(e, t = {}) {
|
|
528
|
+
const r = window, n = r.gengage || (r.gengage = {}), o = n.memory || (n.memory = {}), i = o[e];
|
|
529
|
+
if (i) return i;
|
|
530
|
+
const c = T.get(e) || ce(e, t);
|
|
531
|
+
T.set(e, c);
|
|
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;
|
|
491
536
|
},
|
|
492
|
-
set: (
|
|
493
|
-
remove: (
|
|
494
|
-
|
|
537
|
+
set: (a, f, m = {}) => (c.volatileEntries.set(a, v(f, m.ttlMs)), !0),
|
|
538
|
+
remove: (a) => {
|
|
539
|
+
c.volatileEntries.delete(a);
|
|
495
540
|
},
|
|
496
|
-
clear: () =>
|
|
497
|
-
},
|
|
498
|
-
get:
|
|
499
|
-
set:
|
|
500
|
-
remove:
|
|
501
|
-
},
|
|
541
|
+
clear: () => c.volatileEntries.clear()
|
|
542
|
+
}, l = {
|
|
543
|
+
get: c.idbGet,
|
|
544
|
+
set: c.idbSet,
|
|
545
|
+
remove: c.idbRemove
|
|
546
|
+
}, s = {
|
|
502
547
|
accountId: e,
|
|
503
|
-
volatile:
|
|
504
|
-
session: x(
|
|
505
|
-
local: x(
|
|
506
|
-
indexedDb:
|
|
507
|
-
stableKey:
|
|
548
|
+
volatile: u,
|
|
549
|
+
session: L(x("sessionStorage"), d),
|
|
550
|
+
local: L(x("localStorage"), w),
|
|
551
|
+
indexedDb: l,
|
|
552
|
+
stableKey: ie,
|
|
508
553
|
policy: {
|
|
509
|
-
...
|
|
554
|
+
...ne,
|
|
510
555
|
...t.policy || {}
|
|
511
556
|
}
|
|
512
557
|
};
|
|
513
|
-
o[e] =
|
|
514
|
-
for (const
|
|
515
|
-
return
|
|
558
|
+
o[e] = s;
|
|
559
|
+
for (const a of t.aliases || []) o[a] = s;
|
|
560
|
+
return s;
|
|
516
561
|
}
|
|
517
|
-
var
|
|
562
|
+
var le = [
|
|
518
563
|
"addToCart",
|
|
519
564
|
"search",
|
|
520
565
|
"searchKeyword",
|
|
@@ -522,17 +567,17 @@ var ce = [
|
|
|
522
567
|
"searchGiftOptions",
|
|
523
568
|
"similaritySearch"
|
|
524
569
|
];
|
|
525
|
-
function
|
|
526
|
-
const n = window, o = n.gengage || (n.gengage = {}),
|
|
527
|
-
|
|
528
|
-
for (const
|
|
529
|
-
if (r.exposeStandardAliases !== !1) for (const
|
|
530
|
-
const
|
|
531
|
-
typeof
|
|
570
|
+
function Je(e, t, r = {}) {
|
|
571
|
+
const n = window, o = n.gengage || (n.gengage = {}), i = o.tools || (o.tools = {});
|
|
572
|
+
i[e] = t;
|
|
573
|
+
for (const c of r.accountAliases || []) i[c] = t;
|
|
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);
|
|
532
577
|
}
|
|
533
578
|
return t;
|
|
534
579
|
}
|
|
535
|
-
function
|
|
580
|
+
function ze({ getPageType: e, getProduct: t }) {
|
|
536
581
|
return () => ({
|
|
537
582
|
url: window.location.href,
|
|
538
583
|
title: document.title,
|
|
@@ -540,7 +585,7 @@ function Be({ getPageType: e, getProduct: t }) {
|
|
|
540
585
|
product: t()
|
|
541
586
|
});
|
|
542
587
|
}
|
|
543
|
-
function
|
|
588
|
+
function We({ accountId: e, getPageType: t, getProduct: r, getToolNames: n, getSearchCapabilities: o, getMemory: i }) {
|
|
544
589
|
return async () => ({
|
|
545
590
|
accountId: e,
|
|
546
591
|
url: window.location.href,
|
|
@@ -548,73 +593,80 @@ function Fe({ accountId: e, getPageType: t, getProduct: r, getToolNames: n, getS
|
|
|
548
593
|
productSku: r()?.sku ?? null,
|
|
549
594
|
toolNames: n(),
|
|
550
595
|
...o ? { searchCapabilities: o() } : {},
|
|
551
|
-
...
|
|
596
|
+
...i ? { memoryPolicy: i().policy } : {},
|
|
552
597
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
553
598
|
});
|
|
554
599
|
}
|
|
555
|
-
function
|
|
600
|
+
function Ke({ accountId: e, runtimeFile: t = "runtime.js", startExport: r = "start", globalBaseUrlKey: n, errorLabel: o } = {}) {
|
|
556
601
|
if (!e) throw new Error("accountId is required.");
|
|
557
|
-
const
|
|
558
|
-
const
|
|
602
|
+
const i = o || e, c = window, d = () => {
|
|
603
|
+
const l = c.GengageInjectorConfig || {}, s = l[e] || {};
|
|
559
604
|
return {
|
|
560
|
-
...
|
|
561
|
-
...
|
|
605
|
+
...l,
|
|
606
|
+
...s
|
|
562
607
|
};
|
|
563
608
|
}, w = () => {
|
|
564
|
-
const
|
|
565
|
-
if (
|
|
566
|
-
const
|
|
567
|
-
if (!
|
|
568
|
-
return new URL(t,
|
|
569
|
-
},
|
|
570
|
-
return
|
|
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(
|
|
571
616
|
/* @vite-ignore */
|
|
572
617
|
w()
|
|
573
|
-
).then((
|
|
574
|
-
const
|
|
575
|
-
if (typeof
|
|
576
|
-
return
|
|
577
|
-
}).catch((
|
|
578
|
-
throw console.error(`[Gengage][${e}] runtime load failed`,
|
|
579
|
-
})),
|
|
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;
|
|
580
625
|
}
|
|
581
626
|
export {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
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,
|
|
644
|
+
Y as createModuleWorker,
|
|
645
|
+
ze as createReadPageTool,
|
|
598
646
|
we as done,
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
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
|
|
620
672
|
};
|