@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.
- package/dist/agentic/adaptor/fetch-bridge.d.ts +3 -2
- package/dist/agentic/index.d.ts +1 -0
- package/dist/agentic/index.js +324 -276
- package/dist/agentic/similarity.d.ts +77 -0
- package/dist/agentic/types.d.ts +2 -0
- 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-C4WzXzyY.js → api-paths-B1sFG4Tn.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/transport.d.ts +7 -0
- package/dist/{common-DstAcheX.js → common-BML75wCP.js} +1 -1
- package/dist/common.js +5 -5
- package/dist/{connection-warning-Ddr91Y9x.js → connection-warning-Qy4APv0U.js} +1 -1
- package/dist/{fastIntent-XtUvISni.js → fastIntent-CXqUDc50.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-C66Wp6OR.js → runtime-C5FjeLrv.js} +3 -3
- package/dist/{runtime-CcA_r8pw.js → runtime-DmZ325aj.js} +3 -3
- package/dist/{runtime-DJMUL882.js → runtime-U8DOh3fb.js} +3 -3
- package/dist/{simbut-B6L3fwI7.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-BB4Jrr32.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-B3Oq8pjs.js → widget-base-d-dDGkr7.js} +1 -1
- package/package.json +1 -1
package/dist/agentic/index.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
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,
|
|
@@ -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:
|
|
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:
|
|
60
|
-
beacon:
|
|
61
|
-
}),
|
|
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 (
|
|
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:
|
|
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:
|
|
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, 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
|
|
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,46 +140,56 @@ 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
176
|
return e.fetch = (o, i) => {
|
|
166
|
-
const c =
|
|
167
|
-
return
|
|
168
|
-
}, e[
|
|
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
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
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
|
|
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
|
-
},
|
|
201
|
-
c || (c = !0,
|
|
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
238
|
if (i) {
|
|
210
|
-
const
|
|
211
|
-
o.abort(), c || (c = !0,
|
|
239
|
+
const a = () => {
|
|
240
|
+
o.abort(), c || (c = !0, d?.(), p.error(new DOMException("Aborted", "AbortError")));
|
|
212
241
|
};
|
|
213
242
|
if (i.aborted) {
|
|
214
|
-
|
|
243
|
+
a();
|
|
215
244
|
return;
|
|
216
245
|
}
|
|
217
|
-
i.addEventListener("abort",
|
|
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
|
-
V(
|
|
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
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
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
|
|
273
|
-
if (
|
|
274
|
-
const
|
|
275
|
-
|
|
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:
|
|
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:
|
|
284
|
-
...
|
|
285
|
-
}) :
|
|
324
|
+
tools: w,
|
|
325
|
+
...p ? { beacon: p } : {}
|
|
326
|
+
}) : G({
|
|
286
327
|
accountId: e,
|
|
287
|
-
accountModule:
|
|
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:
|
|
294
|
-
...
|
|
334
|
+
tools: w,
|
|
335
|
+
...p ? { beacon: p } : {}
|
|
295
336
|
});
|
|
296
|
-
const
|
|
337
|
+
const m = {
|
|
297
338
|
type: "agent",
|
|
298
339
|
stop() {
|
|
299
|
-
delete
|
|
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:
|
|
308
|
-
flows: Object.keys(
|
|
348
|
+
transport: f ? "worker" : "main-thread",
|
|
349
|
+
flows: Object.keys(d?.flows || {})
|
|
309
350
|
};
|
|
310
351
|
}
|
|
311
352
|
};
|
|
312
|
-
return
|
|
353
|
+
return a.agentController = m, m;
|
|
313
354
|
}
|
|
314
|
-
function
|
|
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 (
|
|
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
|
|
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
|
|
350
|
-
const r =
|
|
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
|
|
354
|
-
function
|
|
355
|
-
const r =
|
|
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
|
|
400
|
+
function ee() {
|
|
360
401
|
try {
|
|
361
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
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
|
|
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
|
|
416
|
+
function E() {
|
|
376
417
|
return Date.now();
|
|
377
418
|
}
|
|
378
419
|
function R(e) {
|
|
379
|
-
return e?.expiresAt != null && e.expiresAt <=
|
|
420
|
+
return e?.expiresAt != null && e.expiresAt <= E();
|
|
380
421
|
}
|
|
381
|
-
function
|
|
422
|
+
function v(e, t) {
|
|
382
423
|
return {
|
|
383
424
|
value: e,
|
|
384
|
-
createdAt:
|
|
385
|
-
expiresAt: t ?
|
|
425
|
+
createdAt: E(),
|
|
426
|
+
expiresAt: t ? E() + t : null
|
|
386
427
|
};
|
|
387
428
|
}
|
|
388
|
-
function
|
|
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
|
|
439
|
+
function se(e, t, r, n, o) {
|
|
399
440
|
try {
|
|
400
|
-
return e.setItem(`${t}${r}`, JSON.stringify(
|
|
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
|
|
446
|
+
function ae(e, t, r) {
|
|
406
447
|
try {
|
|
407
448
|
e.removeItem(`${t}${r}`);
|
|
408
449
|
} catch {
|
|
409
450
|
}
|
|
410
451
|
}
|
|
411
|
-
function
|
|
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
|
|
459
|
+
function L(e, t) {
|
|
419
460
|
return e ? {
|
|
420
|
-
get: (r) =>
|
|
421
|
-
set: (r, n, o = {}) =>
|
|
422
|
-
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)
|
|
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
|
|
431
|
-
if (Array.isArray(e)) return `[${e.map(
|
|
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)}:${
|
|
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
|
|
479
|
+
function ie(e) {
|
|
439
480
|
let t = 2166136261;
|
|
440
|
-
const r =
|
|
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
|
|
446
|
-
const r = t.dbName || `gengage-${e}`, n = t.dbStore ||
|
|
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
|
|
449
|
-
const
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
},
|
|
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 (
|
|
457
|
-
const
|
|
458
|
-
return
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
const
|
|
462
|
-
if (!
|
|
463
|
-
|
|
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
|
-
|
|
467
|
-
},
|
|
507
|
+
a(g.value);
|
|
508
|
+
}, m.onerror = () => a(null);
|
|
468
509
|
}) : null;
|
|
469
510
|
},
|
|
470
|
-
idbSet: async (
|
|
471
|
-
const
|
|
472
|
-
return
|
|
473
|
-
const
|
|
474
|
-
|
|
475
|
-
key:
|
|
476
|
-
...
|
|
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 (
|
|
481
|
-
const
|
|
482
|
-
|
|
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
|
|
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) ||
|
|
530
|
+
const c = T.get(e) || ce(e, t);
|
|
490
531
|
T.set(e, c);
|
|
491
|
-
const
|
|
492
|
-
get: (
|
|
493
|
-
const
|
|
494
|
-
return
|
|
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: (
|
|
497
|
-
remove: (
|
|
498
|
-
c.volatileEntries.delete(
|
|
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
|
-
},
|
|
542
|
+
}, l = {
|
|
502
543
|
get: c.idbGet,
|
|
503
544
|
set: c.idbSet,
|
|
504
545
|
remove: c.idbRemove
|
|
505
|
-
},
|
|
546
|
+
}, s = {
|
|
506
547
|
accountId: e,
|
|
507
|
-
volatile:
|
|
508
|
-
session: x(
|
|
509
|
-
local: x(
|
|
510
|
-
indexedDb:
|
|
511
|
-
stableKey:
|
|
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
|
-
...
|
|
554
|
+
...ne,
|
|
514
555
|
...t.policy || {}
|
|
515
556
|
}
|
|
516
557
|
};
|
|
517
|
-
o[e] =
|
|
518
|
-
for (const
|
|
519
|
-
return
|
|
558
|
+
o[e] = s;
|
|
559
|
+
for (const a of t.aliases || []) o[a] = s;
|
|
560
|
+
return s;
|
|
520
561
|
}
|
|
521
|
-
var
|
|
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
|
|
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 ||
|
|
534
|
-
const
|
|
535
|
-
typeof
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
562
|
-
const
|
|
602
|
+
const i = o || e, c = window, d = () => {
|
|
603
|
+
const l = c.GengageInjectorConfig || {}, s = l[e] || {};
|
|
563
604
|
return {
|
|
564
|
-
...
|
|
565
|
-
...
|
|
605
|
+
...l,
|
|
606
|
+
...s
|
|
566
607
|
};
|
|
567
|
-
},
|
|
568
|
-
const
|
|
569
|
-
if (
|
|
570
|
-
const
|
|
571
|
-
if (!
|
|
572
|
-
return new URL(t,
|
|
573
|
-
},
|
|
574
|
-
return
|
|
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
|
-
|
|
577
|
-
).then((
|
|
578
|
-
const
|
|
579
|
-
if (typeof
|
|
580
|
-
return
|
|
581
|
-
}).catch((
|
|
582
|
-
throw console.error(`[Gengage][${e}] runtime load failed`,
|
|
583
|
-
})),
|
|
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
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
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
|
-
|
|
645
|
+
ze as createReadPageTool,
|
|
602
646
|
we as done,
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
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
|
};
|