@gengage/assistant-fe 0.6.21 → 0.6.23
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 +4 -2
- package/dist/agentic/adaptor/create-adaptor.d.ts +6 -3
- package/dist/agentic/adaptor/mount.d.ts +8 -2
- package/dist/agentic/{similarity.d.ts → algos/similarity.d.ts} +11 -2
- package/dist/agentic/algos/similarity.js +261 -0
- package/dist/agentic/context/chat-context.d.ts +4 -2
- package/dist/agentic/context/context-store.d.ts +11 -1
- package/dist/agentic/context/persistence.d.ts +1 -0
- package/dist/agentic/contracts/agentic-contracts.d.ts +133 -0
- package/dist/agentic/debug/activity-collector.d.ts +14 -0
- package/dist/agentic/debug/activity-instrumentation.d.ts +22 -0
- package/dist/agentic/debug/activity-overlay.d.ts +3 -0
- package/dist/agentic/debug/activity-state.d.ts +37 -0
- package/dist/agentic/debug/local-dev.d.ts +18 -0
- package/dist/agentic/events/product-normalize.d.ts +4 -1
- package/dist/agentic/events/ui-specs.d.ts +8 -4
- package/dist/agentic/index.d.ts +25 -2
- package/dist/agentic/index.js +2792 -441
- package/dist/agentic/types.d.ts +77 -4
- package/dist/agentic/util/common/declarative-cache.d.ts +21 -0
- package/dist/agentic/util/common/fallback-status.d.ts +10 -0
- package/dist/agentic/util/common/flow-steps.d.ts +8 -0
- package/dist/agentic/util/common/gss-tool-aliases.d.ts +66 -0
- package/dist/agentic/util/common/iframe-scraper.d.ts +22 -0
- package/dist/agentic/util/common/llm-routing.d.ts +50 -0
- package/dist/agentic/util/common/object.d.ts +1 -0
- package/dist/agentic/util/common/open-product-page.d.ts +30 -0
- package/dist/agentic/util/common/panel-context.d.ts +3 -0
- package/dist/agentic/util/common/privacy.d.ts +14 -0
- package/dist/agentic/util/common/product-resolver.d.ts +20 -0
- package/dist/agentic/util/common/product-surface.d.ts +24 -0
- package/dist/agentic/util/common/ref-store.d.ts +15 -0
- package/dist/agentic/util/common/retail-privacy.d.ts +4 -0
- package/dist/agentic/util/common/route-params.d.ts +3 -0
- package/dist/agentic/util/common/similarity-ranking.d.ts +2 -0
- package/dist/agentic/util/common/site-awareness.d.ts +130 -0
- package/dist/agentic/util/lazy-runtime-loader.d.ts +2 -1
- package/dist/agentic/worker/rpc.d.ts +26 -6
- package/dist/agentic/worker.d.ts +15 -2
- package/dist/agentic/worker.js +316 -119
- package/dist/agentic.iife.js +352 -6
- package/dist/{api-paths-DcKsQqb6.js → api-paths-BmN07ddR.js} +144 -154
- package/dist/chat/catalog.d.ts +8 -0
- package/dist/chat/types.d.ts +2 -1
- package/dist/{chat-rvSffJXw.js → chat-CIfQyuBl.js} +26 -21
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +44 -44
- package/dist/chat.js +2 -2
- package/dist/{common-MpBmMLVk.js → common-sx2gD-IP.js} +1 -1
- package/dist/common.js +5 -5
- package/dist/{connection-warning-ClrMLgmZ.js → connection-warning-D5T4gHSM.js} +1 -1
- package/dist/{fastIntent-Bl4xN0qL.js → fastIntent-BFAGybCb.js} +1 -1
- package/dist/index.js +10 -10
- package/dist/native.iife.js +17 -17
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +7 -7
- package/dist/qna.js +1 -1
- package/dist/route-params-5KSvTyeb.js +2454 -0
- package/dist/{runtime-CS4mg3ra.js → runtime-BD2fW-ed.js} +3 -3
- package/dist/{runtime-_koZbJK_.js → runtime-DM7DHhH9.js} +1816 -1778
- package/dist/{runtime-BlU1rKqc.js → runtime-DQ3ULuNF.js} +3 -3
- package/dist/{simbut-BtL7zYIJ.js → simbut-hkt_4H97.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/{simrel-ekf3kUb_.js → simrel-BbkK5Bwt.js} +1 -1
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.iife.js +6 -6
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-p1EKDuiI.js → widget-base-BPKfPh0N.js} +1 -1
- package/package.json +5 -1
- package/dist/account-config-D_EMuR0g.js +0 -1479
package/dist/agentic/index.js
CHANGED
|
@@ -1,139 +1,147 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { buildPhotoSimilarityProfile as lo, buildProductSimilarityProfile as uo, buildSimilarityQueries as fo, normalizeSimilarityText as po, rankSimilarProducts as mo, rankSimilarProductsAsync as go, scoreSimilarityCandidate as ho, tokenizeSimilarityText as bo } from "./algos/similarity.js";
|
|
2
|
+
import { $ as wo, A as vo, B as ut, C as xo, D as ko, E as So, F as _o, G as To, H as Eo, I as Co, J as Ao, K as Lo, L as Ro, M as Po, N as jo, O as Io, P as Uo, Q as qo, R as No, S as Mo, T as Fo, U as Oo, V as Bo, W as ue, X as $o, Y as Do, Z as zo, _ as Go, _t as Ho, a as Wo, at as dt, b as Vo, c as ft, d as Ko, dt as Jo, et as Yo, f as Zo, ft as Qo, g as Xo, gt as pt, h as ei, ht as mt, i as ti, it as ri, j as ni, k as oi, l as ii, lt as gt, m as ai, mt as Me, n as si, nt as ht, o as ci, ot as li, p as ui, q as di, r as fi, rt as pi, s as mi, st as Fe, t as gi, tt as hi, u as bi, ut as yi, v as wi, vt as vi, w as xi, x as ki, y as Si, z as bt } from "../route-params-5KSvTyeb.js";
|
|
3
|
+
var yt = 512, wt = 0.74;
|
|
4
|
+
function vt({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: i, defaultLocale: a, tools: s = {}, beacon: c, confirmation: d, memory: f = Me() }) {
|
|
5
|
+
let b = 1;
|
|
6
|
+
const m = /* @__PURE__ */ new Map();
|
|
7
|
+
return mt({
|
|
7
8
|
worker: t,
|
|
8
|
-
tools:
|
|
9
|
-
beacon: (l) =>
|
|
9
|
+
tools: s,
|
|
10
|
+
beacon: (l) => c?.({
|
|
10
11
|
...l,
|
|
11
12
|
accountId: l.accountId || e
|
|
12
13
|
}),
|
|
13
|
-
|
|
14
|
+
...d ? { confirmation: d } : {},
|
|
15
|
+
memory: f
|
|
14
16
|
}), t.addEventListener("message", (l) => {
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
if (
|
|
20
|
-
|
|
17
|
+
const p = l.data || {}, g = typeof p.id == "number" ? p.id : null;
|
|
18
|
+
if (g == null) return;
|
|
19
|
+
const u = m.get(g);
|
|
20
|
+
if (u) {
|
|
21
|
+
if (p.type === "event" && p.event) {
|
|
22
|
+
oe(u, p.event);
|
|
21
23
|
return;
|
|
22
24
|
}
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
+
if (p.type === "error") {
|
|
26
|
+
u.onError(new Error(p.message || "Agent worker failed")), m.delete(g);
|
|
25
27
|
return;
|
|
26
28
|
}
|
|
27
|
-
|
|
29
|
+
p.type === "end" && m.delete(g);
|
|
28
30
|
}
|
|
29
|
-
}), (l,
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
id:
|
|
31
|
+
}), (l, p, g, u) => {
|
|
32
|
+
const h = b++;
|
|
33
|
+
m.set(h, p);
|
|
34
|
+
const w = () => {
|
|
35
|
+
m.delete(h), t.postMessage({
|
|
36
|
+
id: h,
|
|
35
37
|
type: "abort"
|
|
36
38
|
});
|
|
37
|
-
},
|
|
38
|
-
if (
|
|
39
|
-
|
|
39
|
+
}, k = (v) => {
|
|
40
|
+
if (g.aborted) {
|
|
41
|
+
w();
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
42
44
|
t.postMessage({
|
|
43
|
-
id:
|
|
45
|
+
id: h,
|
|
44
46
|
type: "invoke",
|
|
45
47
|
accountId: e,
|
|
46
48
|
beUrl: r,
|
|
47
49
|
devJwtSecret: n,
|
|
48
50
|
tokenBrokerUrl: o,
|
|
49
|
-
tokenBrokerAudience:
|
|
50
|
-
defaultLocale:
|
|
51
|
-
request:
|
|
51
|
+
tokenBrokerAudience: i,
|
|
52
|
+
defaultLocale: a,
|
|
53
|
+
request: v,
|
|
52
54
|
parentUrl: window.location.href
|
|
53
55
|
});
|
|
54
56
|
};
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
+
if (g.aborted) {
|
|
58
|
+
w();
|
|
57
59
|
return;
|
|
58
60
|
}
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
if (g.addEventListener("abort", w, { once: !0 }), u) {
|
|
62
|
+
Oe(l, u).then(k).catch((v) => {
|
|
63
|
+
m.delete(h), p.onError(v instanceof Error ? v : /* @__PURE__ */ new Error("Failed to read image attachment"));
|
|
62
64
|
});
|
|
63
65
|
return;
|
|
64
66
|
}
|
|
65
|
-
|
|
67
|
+
k(l);
|
|
66
68
|
};
|
|
67
69
|
}
|
|
68
|
-
function
|
|
69
|
-
let
|
|
70
|
-
const
|
|
70
|
+
function xt({ accountId: e, accountModule: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: i, defaultLocale: a, tools: s = {}, beacon: c, confirmation: d, memory: f }) {
|
|
71
|
+
let b = null;
|
|
72
|
+
const m = kt({
|
|
71
73
|
accountId: e,
|
|
72
|
-
tools:
|
|
73
|
-
beacon:
|
|
74
|
-
|
|
74
|
+
tools: s,
|
|
75
|
+
beacon: c,
|
|
76
|
+
confirmation: d,
|
|
77
|
+
memory: f ?? Me()
|
|
78
|
+
}), l = bt(m), p = Fe({
|
|
75
79
|
accountId: e,
|
|
76
80
|
...n ? { devJwtSecret: n } : {},
|
|
77
81
|
...o ? { tokenBrokerUrl: o } : {},
|
|
78
|
-
...
|
|
82
|
+
...i ? { tokenBrokerAudience: i } : {}
|
|
79
83
|
});
|
|
80
|
-
return async (
|
|
81
|
-
const
|
|
82
|
-
|
|
84
|
+
return async (g, u, h, w) => {
|
|
85
|
+
const k = await Oe(g || {}, w);
|
|
86
|
+
b ||= new gt({
|
|
83
87
|
accountId: e,
|
|
84
|
-
locale:
|
|
88
|
+
locale: k?.locale || a,
|
|
85
89
|
parentUrl: window.location.href,
|
|
86
|
-
rpc:
|
|
90
|
+
rpc: m,
|
|
87
91
|
persistentPanelKeys: t.contextPersistence?.panelKeys,
|
|
88
|
-
panelKeyLimits: t.contextPersistence?.panelKeyLimits
|
|
92
|
+
panelKeyLimits: t.contextPersistence?.panelKeyLimits,
|
|
93
|
+
messageLimit: t.contextPersistence?.messageLimit,
|
|
94
|
+
maxThreads: t.contextPersistence?.maxThreads,
|
|
95
|
+
threadTtlMs: t.contextPersistence?.threadTtlMs
|
|
89
96
|
});
|
|
90
97
|
try {
|
|
91
|
-
await
|
|
92
|
-
request:
|
|
98
|
+
await ut({
|
|
99
|
+
request: k,
|
|
93
100
|
accountModule: {
|
|
94
101
|
...t,
|
|
95
102
|
accountId: e
|
|
96
103
|
},
|
|
97
|
-
contextStore:
|
|
98
|
-
beClient: { invoke({ op:
|
|
99
|
-
return
|
|
104
|
+
contextStore: b,
|
|
105
|
+
beClient: { invoke({ op: v, input: E, signal: x, cacheTtlS: C, cacheKey: O, browserCache: z }) {
|
|
106
|
+
return ht({
|
|
100
107
|
beUrl: r,
|
|
101
108
|
accountId: e,
|
|
102
|
-
jwtProvider:
|
|
109
|
+
jwtProvider: p,
|
|
103
110
|
parentUrl: window.location.href,
|
|
104
|
-
op:
|
|
105
|
-
input:
|
|
106
|
-
cacheTtlS:
|
|
107
|
-
cacheKey:
|
|
108
|
-
browserCache:
|
|
109
|
-
...
|
|
111
|
+
op: v,
|
|
112
|
+
input: E,
|
|
113
|
+
cacheTtlS: C,
|
|
114
|
+
cacheKey: O,
|
|
115
|
+
browserCache: z,
|
|
116
|
+
...x ? { signal: x } : {}
|
|
110
117
|
});
|
|
111
118
|
} },
|
|
112
119
|
toolBridge: l,
|
|
113
|
-
emit: (
|
|
114
|
-
rpc:
|
|
115
|
-
signal:
|
|
120
|
+
emit: (v) => oe(u, v),
|
|
121
|
+
rpc: m,
|
|
122
|
+
signal: h
|
|
116
123
|
});
|
|
117
|
-
} catch (
|
|
118
|
-
|
|
124
|
+
} catch (v) {
|
|
125
|
+
h?.aborted || (oe(u, dt(v)), u.onDone());
|
|
119
126
|
}
|
|
120
127
|
};
|
|
121
128
|
}
|
|
122
|
-
function
|
|
123
|
-
const
|
|
124
|
-
...
|
|
125
|
-
accountId:
|
|
129
|
+
function kt({ accountId: e, tools: t, beacon: r, confirmation: n, memory: o }) {
|
|
130
|
+
const i = (a) => r?.({
|
|
131
|
+
...a,
|
|
132
|
+
accountId: a.accountId || e
|
|
126
133
|
});
|
|
127
|
-
return ((
|
|
134
|
+
return ((a, s) => pt(a, s, {
|
|
128
135
|
tools: t,
|
|
129
|
-
beacon:
|
|
130
|
-
|
|
136
|
+
beacon: i,
|
|
137
|
+
confirmation: n,
|
|
138
|
+
memory: o
|
|
131
139
|
}));
|
|
132
140
|
}
|
|
133
|
-
async function
|
|
141
|
+
async function Oe(e, t) {
|
|
134
142
|
if (!t || !t.type?.startsWith("image/")) return e;
|
|
135
|
-
const r = await
|
|
136
|
-
...
|
|
143
|
+
const r = await Tt(t), n = {
|
|
144
|
+
...St(e.payload ?? e.action?.payload),
|
|
137
145
|
image_data_url: r.dataUrl,
|
|
138
146
|
image_mime: r.mime
|
|
139
147
|
};
|
|
@@ -146,33 +154,33 @@ async function L(e, t) {
|
|
|
146
154
|
} } : {}
|
|
147
155
|
};
|
|
148
156
|
}
|
|
149
|
-
function
|
|
150
|
-
return
|
|
157
|
+
function St(e) {
|
|
158
|
+
return _t(e) ? { ...e } : typeof e == "string" ? { text: e } : {};
|
|
151
159
|
}
|
|
152
|
-
function
|
|
160
|
+
function _t(e) {
|
|
153
161
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
154
162
|
}
|
|
155
|
-
async function
|
|
156
|
-
const t = await
|
|
163
|
+
async function Tt(e) {
|
|
164
|
+
const t = await Et(e);
|
|
157
165
|
return t || {
|
|
158
|
-
dataUrl: await
|
|
166
|
+
dataUrl: await Be(e),
|
|
159
167
|
mime: e.type
|
|
160
168
|
};
|
|
161
169
|
}
|
|
162
|
-
async function
|
|
170
|
+
async function Et(e) {
|
|
163
171
|
if (typeof createImageBitmap != "function" || typeof document > "u") return null;
|
|
164
172
|
let t = null;
|
|
165
173
|
try {
|
|
166
174
|
t = await createImageBitmap(e);
|
|
167
|
-
const r = Math.min(1,
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
if (!
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
return
|
|
174
|
-
dataUrl: await
|
|
175
|
-
mime:
|
|
175
|
+
const r = Math.min(1, yt / Math.max(t.width, t.height)), n = Math.max(1, Math.round(t.width * r)), o = Math.max(1, Math.round(t.height * r)), i = document.createElement("canvas");
|
|
176
|
+
i.width = n, i.height = o;
|
|
177
|
+
const a = i.getContext("2d");
|
|
178
|
+
if (!a) return null;
|
|
179
|
+
a.drawImage(t, 0, 0, n, o);
|
|
180
|
+
const s = await new Promise((c) => i.toBlob(c, "image/jpeg", wt));
|
|
181
|
+
return s ? {
|
|
182
|
+
dataUrl: await Be(s),
|
|
183
|
+
mime: s.type || "image/jpeg"
|
|
176
184
|
} : null;
|
|
177
185
|
} catch {
|
|
178
186
|
return null;
|
|
@@ -180,14 +188,14 @@ async function ie(e) {
|
|
|
180
188
|
t?.close();
|
|
181
189
|
}
|
|
182
190
|
}
|
|
183
|
-
async function
|
|
191
|
+
async function Be(e) {
|
|
184
192
|
const t = new Uint8Array(await e.arrayBuffer());
|
|
185
193
|
let r = "";
|
|
186
194
|
const n = 32768;
|
|
187
195
|
for (let o = 0; o < t.length; o += n) r += String.fromCharCode(...t.subarray(o, o + n));
|
|
188
196
|
return `data:${e.type};base64,${btoa(r)}`;
|
|
189
197
|
}
|
|
190
|
-
function
|
|
198
|
+
function oe(e, t) {
|
|
191
199
|
switch (t?.type) {
|
|
192
200
|
case "text_chunk": {
|
|
193
201
|
const r = t;
|
|
@@ -206,7 +214,7 @@ function E(e, t) {
|
|
|
206
214
|
e.onMetadata(t);
|
|
207
215
|
break;
|
|
208
216
|
case "error":
|
|
209
|
-
e.onError(
|
|
217
|
+
e.onError(Ct(t));
|
|
210
218
|
break;
|
|
211
219
|
case "done":
|
|
212
220
|
e.onDone();
|
|
@@ -215,64 +223,84 @@ function E(e, t) {
|
|
|
215
223
|
break;
|
|
216
224
|
}
|
|
217
225
|
}
|
|
218
|
-
function
|
|
226
|
+
function Ct(e) {
|
|
219
227
|
const t = new Error(e.message || e.code || "Agent error");
|
|
220
228
|
return e.code && (t.code = e.code), t;
|
|
221
229
|
}
|
|
222
|
-
var
|
|
230
|
+
var At = "entries", Lt = 1, Rt = {
|
|
223
231
|
volatile: "Hot per-page state and sensitive request context.",
|
|
224
232
|
session: "Current-visit tool context without raw tokens or PII-heavy payloads.",
|
|
225
233
|
local: "Small, non-sensitive capability facts or user preferences.",
|
|
226
234
|
indexedDb: "Larger product/search payload caches with short TTLs."
|
|
227
|
-
},
|
|
228
|
-
function
|
|
235
|
+
}, Se = /* @__PURE__ */ new Map();
|
|
236
|
+
function ie() {
|
|
229
237
|
return Date.now();
|
|
230
238
|
}
|
|
231
|
-
function
|
|
232
|
-
return e?.expiresAt != null && e.expiresAt <=
|
|
239
|
+
function U(e) {
|
|
240
|
+
return e?.expiresAt != null && e.expiresAt <= ie();
|
|
233
241
|
}
|
|
234
|
-
function
|
|
242
|
+
function de(e, t) {
|
|
235
243
|
return {
|
|
236
244
|
value: e,
|
|
237
|
-
createdAt:
|
|
238
|
-
expiresAt: t ?
|
|
245
|
+
createdAt: ie(),
|
|
246
|
+
expiresAt: t ? ie() + t : null
|
|
239
247
|
};
|
|
240
248
|
}
|
|
241
|
-
function
|
|
249
|
+
function Pt(e, t, r) {
|
|
242
250
|
try {
|
|
243
251
|
const n = e.getItem(`${t}${r}`);
|
|
244
252
|
if (!n) return null;
|
|
245
253
|
const o = JSON.parse(n);
|
|
246
|
-
return
|
|
254
|
+
return U(o) ? (e.removeItem(`${t}${r}`), null) : o.value;
|
|
247
255
|
} catch {
|
|
248
256
|
return null;
|
|
249
257
|
}
|
|
250
258
|
}
|
|
251
|
-
function
|
|
259
|
+
function jt(e, t, r, n, o) {
|
|
252
260
|
try {
|
|
253
|
-
return e.setItem(`${t}${r}`, JSON.stringify(
|
|
261
|
+
return e.setItem(`${t}${r}`, JSON.stringify(de(n, o))), !0;
|
|
254
262
|
} catch {
|
|
255
263
|
return !1;
|
|
256
264
|
}
|
|
257
265
|
}
|
|
258
|
-
function
|
|
266
|
+
function It(e, t, r) {
|
|
259
267
|
try {
|
|
260
268
|
e.removeItem(`${t}${r}`);
|
|
261
269
|
} catch {
|
|
262
270
|
}
|
|
263
271
|
}
|
|
264
|
-
function
|
|
272
|
+
function _e(e, t) {
|
|
273
|
+
if (!e) return 0;
|
|
274
|
+
let r = 0;
|
|
275
|
+
try {
|
|
276
|
+
const n = [];
|
|
277
|
+
for (let o = 0; o < e.length; o += 1) {
|
|
278
|
+
const i = e.key(o);
|
|
279
|
+
i?.startsWith(t) && n.push(i);
|
|
280
|
+
}
|
|
281
|
+
for (const o of n) try {
|
|
282
|
+
const i = JSON.parse(e.getItem(o) || "null");
|
|
283
|
+
(!i || U(i)) && (e.removeItem(o), r += 1);
|
|
284
|
+
} catch {
|
|
285
|
+
e.removeItem(o), r += 1;
|
|
286
|
+
}
|
|
287
|
+
} catch {
|
|
288
|
+
return r;
|
|
289
|
+
}
|
|
290
|
+
return r;
|
|
291
|
+
}
|
|
292
|
+
function Te(e) {
|
|
265
293
|
try {
|
|
266
294
|
return window[e];
|
|
267
295
|
} catch {
|
|
268
296
|
return null;
|
|
269
297
|
}
|
|
270
298
|
}
|
|
271
|
-
function
|
|
299
|
+
function Ee(e, t) {
|
|
272
300
|
return e ? {
|
|
273
|
-
get: (r) =>
|
|
274
|
-
set: (r, n, o = {}) =>
|
|
275
|
-
remove: (r) =>
|
|
301
|
+
get: (r) => Pt(e, t, r),
|
|
302
|
+
set: (r, n, o = {}) => jt(e, t, r, n, o.ttlMs),
|
|
303
|
+
remove: (r) => It(e, t, r)
|
|
276
304
|
} : {
|
|
277
305
|
get: () => null,
|
|
278
306
|
set: () => !1,
|
|
@@ -280,266 +308,302 @@ function _(e, t) {
|
|
|
280
308
|
}
|
|
281
309
|
};
|
|
282
310
|
}
|
|
283
|
-
function
|
|
284
|
-
const r = t.dbName || `gengage-${e}`, n = t.dbStore ||
|
|
285
|
-
let
|
|
286
|
-
const
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
},
|
|
291
|
-
}),
|
|
311
|
+
function Ut(e, t) {
|
|
312
|
+
const r = t.dbName || `gengage-${e}`, n = t.dbStore || At, o = t.dbVersion || Lt, i = /* @__PURE__ */ new Map();
|
|
313
|
+
let a = null;
|
|
314
|
+
const s = () => "indexedDB" in window ? a || (a = new Promise((m) => {
|
|
315
|
+
const l = indexedDB.open(r, o);
|
|
316
|
+
l.onupgradeneeded = () => {
|
|
317
|
+
l.result.createObjectStore(n, { keyPath: "key" });
|
|
318
|
+
}, l.onsuccess = () => m(l.result), l.onerror = () => m(null), l.onblocked = () => m(null);
|
|
319
|
+
}), a) : Promise.resolve(null);
|
|
292
320
|
return {
|
|
293
|
-
volatileEntries:
|
|
294
|
-
idbGet: async (
|
|
295
|
-
const
|
|
296
|
-
return
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
const
|
|
300
|
-
if (!
|
|
301
|
-
|
|
321
|
+
volatileEntries: i,
|
|
322
|
+
idbGet: async (m) => {
|
|
323
|
+
const l = await s();
|
|
324
|
+
return l ? new Promise((p) => {
|
|
325
|
+
const g = l.transaction(n, "readwrite").objectStore(n), u = g.get(m);
|
|
326
|
+
u.onsuccess = () => {
|
|
327
|
+
const h = u.result;
|
|
328
|
+
if (!h || U(h)) {
|
|
329
|
+
h && g.delete(m), p(null);
|
|
302
330
|
return;
|
|
303
331
|
}
|
|
304
|
-
|
|
305
|
-
},
|
|
332
|
+
p(h.value);
|
|
333
|
+
}, u.onerror = () => p(null);
|
|
306
334
|
}) : null;
|
|
307
335
|
},
|
|
308
|
-
idbSet: async (
|
|
309
|
-
const
|
|
310
|
-
return
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
key:
|
|
314
|
-
...
|
|
336
|
+
idbSet: async (m, l, p = {}) => {
|
|
337
|
+
const g = await s();
|
|
338
|
+
return g ? new Promise((u) => {
|
|
339
|
+
const h = g.transaction(n, "readwrite");
|
|
340
|
+
h.oncomplete = () => u(!0), h.onerror = () => u(!1), h.objectStore(n).put({
|
|
341
|
+
key: m,
|
|
342
|
+
...de(l, p.ttlMs)
|
|
315
343
|
});
|
|
316
344
|
}) : !1;
|
|
317
345
|
},
|
|
318
|
-
idbRemove: async (
|
|
319
|
-
const
|
|
320
|
-
|
|
346
|
+
idbRemove: async (m) => {
|
|
347
|
+
const l = await s();
|
|
348
|
+
l && l.transaction(n, "readwrite").objectStore(n).delete(m);
|
|
349
|
+
},
|
|
350
|
+
idbGc: async () => {
|
|
351
|
+
const m = await s();
|
|
352
|
+
return m ? new Promise((l) => {
|
|
353
|
+
let p = 0;
|
|
354
|
+
const g = m.transaction(n, "readwrite"), u = g.objectStore(n).openCursor();
|
|
355
|
+
u.onsuccess = () => {
|
|
356
|
+
const h = u.result;
|
|
357
|
+
if (!h) return;
|
|
358
|
+
const w = h.value;
|
|
359
|
+
(!w || U(w)) && (h.delete(), p += 1), h.continue();
|
|
360
|
+
}, g.oncomplete = () => l(p), g.onerror = () => l(p), u.onerror = () => l(p);
|
|
361
|
+
}) : 0;
|
|
321
362
|
}
|
|
322
363
|
};
|
|
323
364
|
}
|
|
324
|
-
function
|
|
325
|
-
const r = window, n = r.gengage || (r.gengage = {}), o = n.memory || (n.memory = {}),
|
|
326
|
-
if (
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
const
|
|
330
|
-
get: (
|
|
331
|
-
const
|
|
332
|
-
return
|
|
365
|
+
function $e(e, t = {}) {
|
|
366
|
+
const r = window, n = r.gengage || (r.gengage = {}), o = n.memory || (n.memory = {}), i = o[e];
|
|
367
|
+
if (i) return i;
|
|
368
|
+
const a = Se.get(e) || Ut(e, t);
|
|
369
|
+
Se.set(e, a);
|
|
370
|
+
const s = t.sessionPrefix || `gengage:${e}:session:`, c = t.localPrefix || `gengage:${e}:local:`, d = Te("sessionStorage"), f = Te("localStorage"), m = {
|
|
371
|
+
get: (u) => {
|
|
372
|
+
const h = a.volatileEntries.get(u);
|
|
373
|
+
return h ? U(h) ? (a.volatileEntries.delete(u), null) : h.value : null;
|
|
333
374
|
},
|
|
334
|
-
set: (
|
|
335
|
-
remove: (
|
|
336
|
-
|
|
375
|
+
set: (u, h, w = {}) => (a.volatileEntries.set(u, de(h, w.ttlMs)), !0),
|
|
376
|
+
remove: (u) => {
|
|
377
|
+
a.volatileEntries.delete(u);
|
|
337
378
|
},
|
|
338
|
-
clear: () =>
|
|
379
|
+
clear: () => a.volatileEntries.clear()
|
|
339
380
|
}, l = {
|
|
340
|
-
get:
|
|
341
|
-
set:
|
|
342
|
-
remove:
|
|
343
|
-
},
|
|
381
|
+
get: a.idbGet,
|
|
382
|
+
set: a.idbSet,
|
|
383
|
+
remove: a.idbRemove
|
|
384
|
+
}, p = async () => {
|
|
385
|
+
let u = 0;
|
|
386
|
+
for (const [v, E] of a.volatileEntries)
|
|
387
|
+
U(E) && (a.volatileEntries.delete(v), u += 1);
|
|
388
|
+
const h = _e(d, s), w = _e(f, c), k = await a.idbGc();
|
|
389
|
+
return {
|
|
390
|
+
volatile: u,
|
|
391
|
+
session: h,
|
|
392
|
+
local: w,
|
|
393
|
+
indexedDb: k
|
|
394
|
+
};
|
|
395
|
+
}, g = {
|
|
344
396
|
accountId: e,
|
|
345
|
-
volatile:
|
|
346
|
-
session:
|
|
347
|
-
local:
|
|
397
|
+
volatile: m,
|
|
398
|
+
session: Ee(d, s),
|
|
399
|
+
local: Ee(f, c),
|
|
348
400
|
indexedDb: l,
|
|
349
|
-
|
|
401
|
+
gc: p,
|
|
402
|
+
stableKey: ue,
|
|
350
403
|
policy: {
|
|
351
|
-
...
|
|
404
|
+
...Rt,
|
|
352
405
|
...t.policy || {}
|
|
353
406
|
}
|
|
354
407
|
};
|
|
355
|
-
o[e] =
|
|
356
|
-
for (const
|
|
357
|
-
return
|
|
408
|
+
o[e] = g;
|
|
409
|
+
for (const u of t.aliases || []) o[u] = g;
|
|
410
|
+
return qt(g), g;
|
|
411
|
+
}
|
|
412
|
+
function qt(e) {
|
|
413
|
+
const t = window, r = () => {
|
|
414
|
+
e.gc().catch(() => {
|
|
415
|
+
});
|
|
416
|
+
};
|
|
417
|
+
if (typeof t.requestIdleCallback == "function") {
|
|
418
|
+
t.requestIdleCallback(r);
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
setTimeout(r, 5e3);
|
|
358
422
|
}
|
|
359
|
-
var
|
|
360
|
-
function
|
|
423
|
+
var W = "__gengageAgentFetchBridge", Nt = 1e3 * 60 * 60 * 24 * 14;
|
|
424
|
+
function _i({ accountId: e, streamTransport: t, endpoints: r = {}, endpointCache: n }) {
|
|
361
425
|
if (!e) throw new Error("accountId is required.");
|
|
362
426
|
if (typeof t != "function") throw new Error("streamTransport is required.");
|
|
363
|
-
const o =
|
|
427
|
+
const o = Mt(), i = `https://gengage-injector.invalid/${encodeURIComponent(e)}`, a = /* @__PURE__ */ new Set(), s = n ? zt({
|
|
364
428
|
accountId: e,
|
|
365
429
|
endpointCache: n,
|
|
366
430
|
fetchImpl: o.originalFetch
|
|
367
|
-
}) : void 0,
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
const
|
|
431
|
+
}) : void 0, c = (d) => {
|
|
432
|
+
const f = `${i}/chat/${d}`;
|
|
433
|
+
a.add(f);
|
|
434
|
+
const b = r[d], m = {
|
|
371
435
|
streamTransport: t,
|
|
372
|
-
endpoint:
|
|
436
|
+
endpoint: d
|
|
373
437
|
};
|
|
374
|
-
|
|
438
|
+
b && (m.endpointHandler = b), s && (m.endpointCache = s), o.routes.set(f, m);
|
|
375
439
|
};
|
|
376
|
-
|
|
377
|
-
for (const
|
|
440
|
+
c("process_action");
|
|
441
|
+
for (const d of Object.keys(r)) d !== "process_action" && c(d);
|
|
378
442
|
return {
|
|
379
|
-
middlewareUrl:
|
|
443
|
+
middlewareUrl: i,
|
|
380
444
|
stop() {
|
|
381
|
-
for (const
|
|
382
|
-
|
|
445
|
+
for (const d of a) o.routes.delete(d);
|
|
446
|
+
Ft(o);
|
|
383
447
|
}
|
|
384
448
|
};
|
|
385
449
|
}
|
|
386
|
-
function
|
|
387
|
-
const e = window, t = e[
|
|
450
|
+
function Mt() {
|
|
451
|
+
const e = window, t = e[W];
|
|
388
452
|
if (t) return t;
|
|
389
453
|
const r = e.fetch.bind(e), n = {
|
|
390
454
|
routes: /* @__PURE__ */ new Map(),
|
|
391
455
|
originalFetch: r,
|
|
392
456
|
installedFetch: r
|
|
393
457
|
};
|
|
394
|
-
return n.installedFetch = (o,
|
|
395
|
-
const
|
|
396
|
-
return
|
|
397
|
-
}, e.fetch = n.installedFetch, e[
|
|
458
|
+
return n.installedFetch = (o, i) => {
|
|
459
|
+
const a = De(o), s = n.routes.get(a);
|
|
460
|
+
return s ? Bt(s, o, i) : r(o, i);
|
|
461
|
+
}, e.fetch = n.installedFetch, e[W] = n, n;
|
|
398
462
|
}
|
|
399
|
-
function
|
|
463
|
+
function Ft(e) {
|
|
400
464
|
if (e.routes.size > 0) return;
|
|
401
465
|
const t = window;
|
|
402
|
-
t.fetch === e.installedFetch && (t.fetch = e.originalFetch), t[
|
|
466
|
+
t.fetch === e.installedFetch && (t.fetch = e.originalFetch), t[W] === e && delete t[W];
|
|
403
467
|
}
|
|
404
|
-
function
|
|
468
|
+
function De(e) {
|
|
405
469
|
return typeof e == "string" ? e : e instanceof URL ? e.href : e?.url || "";
|
|
406
470
|
}
|
|
407
|
-
function
|
|
471
|
+
function Ce(e, t) {
|
|
408
472
|
if (t?.signal) return t.signal;
|
|
409
473
|
if (typeof Request < "u" && e instanceof Request) return e.signal;
|
|
410
474
|
}
|
|
411
|
-
function
|
|
475
|
+
function ze(e, t) {
|
|
412
476
|
return t?.body !== void 0 && t?.body !== null ? t.body : typeof Request < "u" && e instanceof Request ? e.clone().text() : null;
|
|
413
477
|
}
|
|
414
|
-
async function
|
|
415
|
-
const r =
|
|
478
|
+
async function Ot(e, t) {
|
|
479
|
+
const r = ze(e, t);
|
|
416
480
|
if (r instanceof FormData) {
|
|
417
|
-
const o = r.get("request"),
|
|
481
|
+
const o = r.get("request"), i = r.get("attachment");
|
|
418
482
|
return {
|
|
419
483
|
request: JSON.parse(String(o || "{}")),
|
|
420
|
-
...
|
|
484
|
+
...i instanceof File ? { attachment: i } : {}
|
|
421
485
|
};
|
|
422
486
|
}
|
|
423
487
|
const n = await Promise.resolve(r);
|
|
424
488
|
return typeof n == "string" ? { request: JSON.parse(n || "{}") } : { request: {} };
|
|
425
489
|
}
|
|
426
|
-
async function
|
|
490
|
+
async function Bt(e, t, r) {
|
|
427
491
|
if (e.endpoint && e.endpoint !== "process_action" && e.endpointHandler) {
|
|
428
|
-
const
|
|
429
|
-
let
|
|
430
|
-
if (
|
|
431
|
-
const
|
|
432
|
-
|
|
492
|
+
const d = new AbortController(), f = Ce(t, r);
|
|
493
|
+
let b = null;
|
|
494
|
+
if (f) {
|
|
495
|
+
const m = () => d.abort();
|
|
496
|
+
f.aborted && m(), f.addEventListener("abort", m, { once: !0 }), b = () => f.removeEventListener("abort", m);
|
|
433
497
|
}
|
|
434
498
|
try {
|
|
435
|
-
const
|
|
436
|
-
accountId:
|
|
499
|
+
const m = await $t(t, r), l = {
|
|
500
|
+
accountId: Dt(t),
|
|
437
501
|
endpoint: e.endpoint,
|
|
438
|
-
signal:
|
|
439
|
-
},
|
|
440
|
-
if (
|
|
441
|
-
const
|
|
442
|
-
if (
|
|
443
|
-
}
|
|
444
|
-
const
|
|
445
|
-
return
|
|
502
|
+
signal: d.signal
|
|
503
|
+
}, p = Gt(e.endpointCache, e.endpoint, m, l.accountId);
|
|
504
|
+
if (p) {
|
|
505
|
+
const u = await Ht(e.endpointCache, p, d.signal);
|
|
506
|
+
if (u) return Zt(u);
|
|
507
|
+
}
|
|
508
|
+
const g = await e.endpointHandler(m, l);
|
|
509
|
+
return p && g.ok && await Wt(e.endpointCache, p, g.clone(), d.signal), g;
|
|
446
510
|
} finally {
|
|
447
|
-
|
|
511
|
+
b?.();
|
|
448
512
|
}
|
|
449
513
|
}
|
|
450
|
-
const n = new TextEncoder(), o = new AbortController(),
|
|
451
|
-
let
|
|
452
|
-
const
|
|
453
|
-
async start(
|
|
454
|
-
const
|
|
455
|
-
|
|
514
|
+
const n = new TextEncoder(), o = new AbortController(), i = Ce(t, r);
|
|
515
|
+
let a = !1, s = null;
|
|
516
|
+
const c = new ReadableStream({
|
|
517
|
+
async start(d) {
|
|
518
|
+
const f = (l) => {
|
|
519
|
+
a || d.enqueue(n.encode(`${JSON.stringify(l)}
|
|
456
520
|
`));
|
|
457
|
-
},
|
|
458
|
-
|
|
459
|
-
},
|
|
460
|
-
|
|
521
|
+
}, b = () => {
|
|
522
|
+
a || (a = !0, s?.(), d.close());
|
|
523
|
+
}, m = (l) => {
|
|
524
|
+
f({
|
|
461
525
|
type: "error",
|
|
462
|
-
code:
|
|
463
|
-
message:
|
|
464
|
-
}),
|
|
526
|
+
code: l?.code || "agent_bridge_error",
|
|
527
|
+
message: l instanceof Error ? l.message : String(l)
|
|
528
|
+
}), f({ type: "done" }), b();
|
|
465
529
|
};
|
|
466
|
-
if (
|
|
467
|
-
const
|
|
468
|
-
o.abort(),
|
|
530
|
+
if (i) {
|
|
531
|
+
const l = () => {
|
|
532
|
+
o.abort(), a || (a = !0, s?.(), d.error(new DOMException("Aborted", "AbortError")));
|
|
469
533
|
};
|
|
470
|
-
if (
|
|
471
|
-
|
|
534
|
+
if (i.aborted) {
|
|
535
|
+
l();
|
|
472
536
|
return;
|
|
473
537
|
}
|
|
474
|
-
|
|
538
|
+
i.addEventListener("abort", l, { once: !0 }), s = () => i.removeEventListener("abort", l);
|
|
475
539
|
}
|
|
476
540
|
try {
|
|
477
|
-
const { request:
|
|
478
|
-
onTextChunk: (
|
|
541
|
+
const { request: l, attachment: p } = await Ot(t, r), g = e.streamTransport(l, {
|
|
542
|
+
onTextChunk: (u, h, w = {}) => f({
|
|
479
543
|
type: "text_chunk",
|
|
480
|
-
content:
|
|
544
|
+
content: u,
|
|
481
545
|
final: h === !0,
|
|
482
546
|
...w
|
|
483
547
|
}),
|
|
484
|
-
onUISpec: (
|
|
548
|
+
onUISpec: (u, h, w, k) => f({
|
|
485
549
|
type: "ui_spec",
|
|
486
|
-
spec:
|
|
550
|
+
spec: u,
|
|
487
551
|
widget: h,
|
|
488
552
|
...w ? { panelHint: w } : {},
|
|
489
|
-
...
|
|
553
|
+
...k ? { clearPanel: !0 } : {}
|
|
490
554
|
}),
|
|
491
|
-
onAction: (
|
|
492
|
-
u
|
|
555
|
+
onAction: (u) => {
|
|
556
|
+
f(u?.type === "action" ? u : {
|
|
493
557
|
type: "action",
|
|
494
|
-
action:
|
|
558
|
+
action: u
|
|
495
559
|
});
|
|
496
560
|
},
|
|
497
|
-
onMetadata: (
|
|
498
|
-
u
|
|
561
|
+
onMetadata: (u) => {
|
|
562
|
+
f(u?.type === "metadata" ? u : {
|
|
499
563
|
type: "metadata",
|
|
500
|
-
...
|
|
564
|
+
...u
|
|
501
565
|
});
|
|
502
566
|
},
|
|
503
|
-
onError:
|
|
567
|
+
onError: m,
|
|
504
568
|
onDone: () => {
|
|
505
|
-
|
|
569
|
+
f({ type: "done" }), b();
|
|
506
570
|
}
|
|
507
|
-
}, o.signal,
|
|
508
|
-
|
|
509
|
-
} catch (
|
|
510
|
-
o.signal.aborted ||
|
|
571
|
+
}, o.signal, p);
|
|
572
|
+
tr(g) && (await g, o.signal.aborted || (f({ type: "done" }), b()));
|
|
573
|
+
} catch (l) {
|
|
574
|
+
o.signal.aborted || m(l);
|
|
511
575
|
}
|
|
512
576
|
},
|
|
513
577
|
cancel() {
|
|
514
|
-
o.abort(),
|
|
578
|
+
o.abort(), s?.(), a = !0;
|
|
515
579
|
}
|
|
516
580
|
});
|
|
517
|
-
return new Response(
|
|
581
|
+
return new Response(c, {
|
|
518
582
|
status: 200,
|
|
519
583
|
headers: { "Content-Type": "application/x-ndjson" }
|
|
520
584
|
});
|
|
521
585
|
}
|
|
522
|
-
async function
|
|
523
|
-
const r = await Promise.resolve(
|
|
586
|
+
async function $t(e, t) {
|
|
587
|
+
const r = await Promise.resolve(ze(e, t));
|
|
524
588
|
return typeof r != "string" || r.trim() === "" ? {} : JSON.parse(r);
|
|
525
589
|
}
|
|
526
|
-
function
|
|
590
|
+
function Dt(e) {
|
|
527
591
|
try {
|
|
528
|
-
const [t] = new URL(
|
|
592
|
+
const [t] = new URL(De(e)).pathname.split("/").filter(Boolean);
|
|
529
593
|
return decodeURIComponent(t || "");
|
|
530
594
|
} catch {
|
|
531
595
|
return "";
|
|
532
596
|
}
|
|
533
597
|
}
|
|
534
|
-
function
|
|
598
|
+
function zt({ accountId: e, endpointCache: t, fetchImpl: r }) {
|
|
535
599
|
return {
|
|
536
600
|
accountId: e,
|
|
537
601
|
beUrl: t.beUrl,
|
|
538
602
|
...t.parentUrl ? { parentUrl: t.parentUrl } : {},
|
|
539
|
-
ttlMs: t.ttlMs ??
|
|
603
|
+
ttlMs: t.ttlMs ?? Nt,
|
|
540
604
|
policies: t.policies,
|
|
541
605
|
fetchImpl: r,
|
|
542
|
-
jwtProvider:
|
|
606
|
+
jwtProvider: Fe({
|
|
543
607
|
accountId: e,
|
|
544
608
|
...t.devJwtSecret ? { devJwtSecret: t.devJwtSecret } : {},
|
|
545
609
|
...t.tokenBrokerUrl ? { tokenBrokerUrl: t.tokenBrokerUrl } : {},
|
|
@@ -548,40 +612,40 @@ function Ae({ accountId: e, endpointCache: t, fetchImpl: r }) {
|
|
|
548
612
|
})
|
|
549
613
|
};
|
|
550
614
|
}
|
|
551
|
-
function
|
|
615
|
+
function Gt(e, t, r, n) {
|
|
552
616
|
if (!e) return null;
|
|
553
617
|
const o = e.policies[t];
|
|
554
618
|
if (!o) return null;
|
|
555
|
-
const
|
|
619
|
+
const i = o(r, {
|
|
556
620
|
accountId: n,
|
|
557
621
|
endpoint: t
|
|
558
622
|
});
|
|
559
|
-
return !
|
|
560
|
-
partition:
|
|
561
|
-
key:
|
|
562
|
-
ttlMs:
|
|
623
|
+
return !i?.partition || !i?.key ? null : {
|
|
624
|
+
partition: i.partition,
|
|
625
|
+
key: i.key,
|
|
626
|
+
ttlMs: i.ttlMs ?? e.ttlMs
|
|
563
627
|
};
|
|
564
628
|
}
|
|
565
|
-
async function
|
|
566
|
-
const n =
|
|
567
|
-
if (
|
|
568
|
-
const
|
|
569
|
-
return
|
|
629
|
+
async function Ht(e, t, r) {
|
|
630
|
+
const n = Ve(e.accountId, t), o = await Qt(e.accountId, n);
|
|
631
|
+
if (We(o)) return o;
|
|
632
|
+
const i = await Vt(e, t, r);
|
|
633
|
+
return i ? (await Ke(e.accountId, n, i, t.ttlMs), i) : null;
|
|
570
634
|
}
|
|
571
|
-
async function
|
|
635
|
+
async function Wt(e, t, r, n) {
|
|
572
636
|
try {
|
|
573
|
-
const o = await
|
|
574
|
-
if (
|
|
575
|
-
const
|
|
576
|
-
await
|
|
637
|
+
const o = await Yt(r);
|
|
638
|
+
if (er(o.body)) return;
|
|
639
|
+
const i = Ve(e.accountId, t);
|
|
640
|
+
await Ke(e.accountId, i, o, t.ttlMs), Kt(e, t, o, n);
|
|
577
641
|
} catch {
|
|
578
642
|
}
|
|
579
643
|
}
|
|
580
|
-
async function
|
|
644
|
+
async function Vt(e, t, r) {
|
|
581
645
|
try {
|
|
582
|
-
const n = await e.fetchImpl(
|
|
646
|
+
const n = await e.fetchImpl(He(e.beUrl), {
|
|
583
647
|
method: "POST",
|
|
584
|
-
headers: await
|
|
648
|
+
headers: await Ge(e, r),
|
|
585
649
|
body: JSON.stringify({
|
|
586
650
|
partition: t.partition,
|
|
587
651
|
key: t.key
|
|
@@ -590,16 +654,16 @@ async function xe(e, t, r) {
|
|
|
590
654
|
});
|
|
591
655
|
if (!n.ok) return null;
|
|
592
656
|
const o = await n.json();
|
|
593
|
-
return o.hit === !0 &&
|
|
657
|
+
return o.hit === !0 && We(o.payload) ? o.payload : null;
|
|
594
658
|
} catch {
|
|
595
659
|
return null;
|
|
596
660
|
}
|
|
597
661
|
}
|
|
598
|
-
async function
|
|
662
|
+
async function Kt(e, t, r, n) {
|
|
599
663
|
try {
|
|
600
|
-
await e.fetchImpl(
|
|
664
|
+
await e.fetchImpl(He(e.beUrl), {
|
|
601
665
|
method: "POST",
|
|
602
|
-
headers: await
|
|
666
|
+
headers: await Ge(e, n),
|
|
603
667
|
body: JSON.stringify({
|
|
604
668
|
partition: t.partition,
|
|
605
669
|
key: t.key,
|
|
@@ -611,130 +675,154 @@ async function Te(e, t, r, n) {
|
|
|
611
675
|
} catch {
|
|
612
676
|
}
|
|
613
677
|
}
|
|
614
|
-
async function
|
|
678
|
+
async function Ge(e, t) {
|
|
615
679
|
return {
|
|
616
680
|
authorization: `Bearer ${await e.jwtProvider({
|
|
617
681
|
signal: t,
|
|
618
|
-
parentUrl: e.parentUrl ||
|
|
682
|
+
parentUrl: e.parentUrl || Jt()
|
|
619
683
|
})}`,
|
|
620
684
|
"content-type": "application/json",
|
|
621
685
|
accept: "application/json"
|
|
622
686
|
};
|
|
623
687
|
}
|
|
624
|
-
function
|
|
688
|
+
function Jt() {
|
|
625
689
|
try {
|
|
626
690
|
return window.location?.href || "";
|
|
627
691
|
} catch {
|
|
628
692
|
return "";
|
|
629
693
|
}
|
|
630
694
|
}
|
|
631
|
-
function
|
|
695
|
+
function He(e) {
|
|
632
696
|
return `${String(e).replace(/\/+$/u, "")}/v1/cache`;
|
|
633
697
|
}
|
|
634
|
-
async function
|
|
698
|
+
async function Yt(e) {
|
|
635
699
|
return {
|
|
636
700
|
status: e.status,
|
|
637
701
|
statusText: e.statusText,
|
|
638
|
-
headers: [...e.headers.entries()].filter(([t]) =>
|
|
702
|
+
headers: [...e.headers.entries()].filter(([t]) => Xt(t)),
|
|
639
703
|
body: await e.text()
|
|
640
704
|
};
|
|
641
705
|
}
|
|
642
|
-
function
|
|
706
|
+
function Zt(e) {
|
|
643
707
|
return new Response(e.body, {
|
|
644
708
|
status: e.status,
|
|
645
709
|
statusText: e.statusText,
|
|
646
710
|
headers: new Headers(e.headers)
|
|
647
711
|
});
|
|
648
712
|
}
|
|
649
|
-
function
|
|
713
|
+
function We(e) {
|
|
650
714
|
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
651
715
|
const t = e;
|
|
652
716
|
return typeof t.status == "number" && typeof t.statusText == "string" && typeof t.body == "string" && Array.isArray(t.headers);
|
|
653
717
|
}
|
|
654
|
-
function
|
|
655
|
-
return `endpoint-response:${
|
|
718
|
+
function Ve(e, t) {
|
|
719
|
+
return `endpoint-response:${ue({
|
|
656
720
|
accountId: e,
|
|
657
721
|
partition: t.partition,
|
|
658
722
|
key: t.key
|
|
659
723
|
})}`;
|
|
660
724
|
}
|
|
661
|
-
async function
|
|
662
|
-
const r =
|
|
725
|
+
async function Qt(e, t) {
|
|
726
|
+
const r = $e(e);
|
|
663
727
|
return r.volatile.get(t) || await r.indexedDb.get(t) || r.local.get(t);
|
|
664
728
|
}
|
|
665
|
-
async function
|
|
666
|
-
const o =
|
|
729
|
+
async function Ke(e, t, r, n) {
|
|
730
|
+
const o = $e(e);
|
|
667
731
|
o.volatile.set(t, r, { ttlMs: n }), await o.indexedDb.set(t, r, { ttlMs: n }) || o.local.set(t, r, { ttlMs: n });
|
|
668
732
|
}
|
|
669
|
-
function
|
|
733
|
+
function Xt(e) {
|
|
670
734
|
return ["content-type", "cache-control"].includes(e.toLowerCase());
|
|
671
735
|
}
|
|
672
|
-
function
|
|
736
|
+
function er(e) {
|
|
673
737
|
return /"_error"\s*:/u.test(e) || /"type"\s*:\s*"error"/u.test(e);
|
|
674
738
|
}
|
|
675
|
-
function
|
|
739
|
+
function tr(e) {
|
|
676
740
|
return e !== null && (typeof e == "object" || typeof e == "function") && typeof e.then == "function";
|
|
677
741
|
}
|
|
678
|
-
function
|
|
742
|
+
function Ti({ accountId: e, beUrl: t, devJwtSecret: r, tokenBrokerUrl: n, tokenBrokerAudience: o, workerUrl: i, defaultLocale: a = "en-GB", accountModule: s, tools: c = {}, beacon: d, confirmation: f, memory: b, allowBlobWorker: m = !1, signal: l }) {
|
|
679
743
|
if (!e) throw new Error("accountId is required.");
|
|
680
744
|
if (!t) throw new Error("beUrl is required. The injector owns backend URLs; the SDK has no default.");
|
|
681
|
-
if (!
|
|
682
|
-
const
|
|
683
|
-
if (
|
|
684
|
-
const
|
|
685
|
-
|
|
745
|
+
if (!i) throw new Error("workerUrl is required.");
|
|
746
|
+
const p = window, g = p.GengageAssistantInjector || (p.GengageAssistantInjector = {}), u = g[e] || (g[e] = {});
|
|
747
|
+
if (u.agentController) return u.agentController;
|
|
748
|
+
const h = Je(i) || m ? rr(i, `gengage-${e}-agent`, { allowBlobWorker: m }) : null;
|
|
749
|
+
h || d?.({
|
|
686
750
|
type: "agentRuntime",
|
|
687
751
|
accountId: e,
|
|
688
752
|
transport: "main-thread",
|
|
689
753
|
reason: "cross-origin-worker-url",
|
|
690
|
-
workerUrl:
|
|
691
|
-
}),
|
|
754
|
+
workerUrl: i
|
|
755
|
+
}), u.streamTransport = h ? vt({
|
|
692
756
|
accountId: e,
|
|
693
|
-
worker:
|
|
757
|
+
worker: h.worker,
|
|
694
758
|
beUrl: t,
|
|
695
759
|
...r ? { devJwtSecret: r } : {},
|
|
696
760
|
...n ? { tokenBrokerUrl: n } : {},
|
|
697
761
|
...o ? { tokenBrokerAudience: o } : {},
|
|
698
|
-
defaultLocale:
|
|
699
|
-
tools:
|
|
700
|
-
...
|
|
701
|
-
|
|
762
|
+
defaultLocale: a,
|
|
763
|
+
tools: c,
|
|
764
|
+
...d ? { beacon: d } : {},
|
|
765
|
+
...f ? { confirmation: f } : {},
|
|
766
|
+
...b ? { memory: b } : {}
|
|
767
|
+
}) : xt({
|
|
702
768
|
accountId: e,
|
|
703
|
-
accountModule:
|
|
769
|
+
accountModule: s,
|
|
704
770
|
beUrl: t,
|
|
705
771
|
...r ? { devJwtSecret: r } : {},
|
|
706
772
|
...n ? { tokenBrokerUrl: n } : {},
|
|
707
773
|
...o ? { tokenBrokerAudience: o } : {},
|
|
708
|
-
defaultLocale:
|
|
709
|
-
tools:
|
|
710
|
-
...
|
|
774
|
+
defaultLocale: a,
|
|
775
|
+
tools: c,
|
|
776
|
+
...d ? { beacon: d } : {},
|
|
777
|
+
...f ? { confirmation: f } : {},
|
|
778
|
+
...b ? { memory: b } : {}
|
|
711
779
|
});
|
|
712
|
-
const
|
|
780
|
+
const w = new AbortController(), k = [], v = () => {
|
|
781
|
+
for (; k.length; ) {
|
|
782
|
+
const C = k.pop();
|
|
783
|
+
try {
|
|
784
|
+
C?.();
|
|
785
|
+
} catch {
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}, E = () => {
|
|
789
|
+
w.signal.aborted || (w.abort(), l?.removeEventListener("abort", E), delete u.streamTransport, h?.worker.terminate(), h?.cleanup(), v(), delete u.agentController);
|
|
790
|
+
};
|
|
791
|
+
l?.addEventListener("abort", E, { once: !0 });
|
|
792
|
+
const x = {
|
|
713
793
|
type: "agent",
|
|
714
|
-
|
|
715
|
-
|
|
794
|
+
signal: w.signal,
|
|
795
|
+
addCleanup(C) {
|
|
796
|
+
if (typeof C == "function") {
|
|
797
|
+
if (w.signal.aborted) {
|
|
798
|
+
C();
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
k.push(C);
|
|
802
|
+
}
|
|
716
803
|
},
|
|
804
|
+
stop: E,
|
|
717
805
|
diagnostics() {
|
|
718
806
|
return {
|
|
719
807
|
accountId: e,
|
|
720
808
|
beUrl: t,
|
|
721
|
-
workerUrl:
|
|
809
|
+
workerUrl: i,
|
|
722
810
|
mounted: !0,
|
|
723
|
-
transport:
|
|
724
|
-
transportReason:
|
|
725
|
-
flows: Object.keys(
|
|
811
|
+
transport: h ? "worker" : "main-thread",
|
|
812
|
+
transportReason: h ? "module-worker" : "cross-origin-worker-url",
|
|
813
|
+
flows: Object.keys(s?.flows || {})
|
|
726
814
|
};
|
|
727
815
|
}
|
|
728
816
|
};
|
|
729
|
-
return
|
|
817
|
+
return u.agentController = x, x;
|
|
730
818
|
}
|
|
731
|
-
function
|
|
819
|
+
function Je(e) {
|
|
732
820
|
const t = new URL(e, window.location.href);
|
|
733
821
|
return t.origin === window.location.origin || t.protocol === "blob:";
|
|
734
822
|
}
|
|
735
|
-
function
|
|
823
|
+
function rr(e, t, r = {}) {
|
|
736
824
|
const n = new URL(e, window.location.href);
|
|
737
|
-
if (
|
|
825
|
+
if (Je(e)) return {
|
|
738
826
|
worker: new Worker(n.href, {
|
|
739
827
|
type: "module",
|
|
740
828
|
name: t
|
|
@@ -744,31 +832,31 @@ function $e(e, t, r = {}) {
|
|
|
744
832
|
};
|
|
745
833
|
if (!r.allowBlobWorker) throw new Error("Cross-origin agent workers require allowBlobWorker=true or a same-origin workerUrl.");
|
|
746
834
|
const o = new Blob([`import ${JSON.stringify(n.href)};
|
|
747
|
-
`], { type: "text/javascript" }),
|
|
835
|
+
`], { type: "text/javascript" }), i = URL.createObjectURL(o);
|
|
748
836
|
try {
|
|
749
837
|
return {
|
|
750
|
-
worker: new Worker(
|
|
838
|
+
worker: new Worker(i, {
|
|
751
839
|
type: "module",
|
|
752
840
|
name: t
|
|
753
841
|
}),
|
|
754
842
|
cleanup() {
|
|
755
|
-
URL.revokeObjectURL(
|
|
843
|
+
URL.revokeObjectURL(i);
|
|
756
844
|
}
|
|
757
845
|
};
|
|
758
|
-
} catch (
|
|
759
|
-
throw URL.revokeObjectURL(
|
|
846
|
+
} catch (a) {
|
|
847
|
+
throw URL.revokeObjectURL(i), a;
|
|
760
848
|
}
|
|
761
849
|
}
|
|
762
|
-
function
|
|
763
|
-
return `endpoint:${r}:${
|
|
850
|
+
function nr(e, t, r = "v1") {
|
|
851
|
+
return `endpoint:${r}:${ue({
|
|
764
852
|
endpoint: e,
|
|
765
853
|
request: t
|
|
766
854
|
})}`;
|
|
767
855
|
}
|
|
768
|
-
function
|
|
856
|
+
function Ei(e) {
|
|
769
857
|
const t = e.version || "v1", r = (n) => (o) => ({
|
|
770
858
|
partition: `${e.partitionPrefix}/${n}`,
|
|
771
|
-
key:
|
|
859
|
+
key: nr(n, o, t),
|
|
772
860
|
...e.ttlMs ? { ttlMs: e.ttlMs } : {}
|
|
773
861
|
});
|
|
774
862
|
return {
|
|
@@ -777,10 +865,10 @@ function jt(e) {
|
|
|
777
865
|
product_groupings: r("product_groupings")
|
|
778
866
|
};
|
|
779
867
|
}
|
|
780
|
-
function
|
|
868
|
+
function Ci(e) {
|
|
781
869
|
return { ...e };
|
|
782
870
|
}
|
|
783
|
-
function
|
|
871
|
+
function Ai(e, t = {}) {
|
|
784
872
|
return new Response(e.map((r) => JSON.stringify(r)).join(`
|
|
785
873
|
`) + `
|
|
786
874
|
`, {
|
|
@@ -791,7 +879,7 @@ function Bt(e, t = {}) {
|
|
|
791
879
|
}
|
|
792
880
|
});
|
|
793
881
|
}
|
|
794
|
-
function
|
|
882
|
+
function Li(e, t = {}) {
|
|
795
883
|
return new Response(JSON.stringify(e), {
|
|
796
884
|
...t,
|
|
797
885
|
headers: {
|
|
@@ -800,23 +888,23 @@ function $t(e, t = {}) {
|
|
|
800
888
|
}
|
|
801
889
|
});
|
|
802
890
|
}
|
|
803
|
-
function
|
|
891
|
+
function or(e) {
|
|
804
892
|
const t = (e?.chat || e?._chat)?.root || e?._chat?.root;
|
|
805
893
|
return t ? t.getRootNode?.()?.host || t : Array.from(document.querySelectorAll("*")).find((r) => r.shadowRoot?.querySelector?.(".gengage-chat-root, .gengage-chat-launcher-container"));
|
|
806
894
|
}
|
|
807
|
-
function
|
|
808
|
-
const r =
|
|
895
|
+
function Ri(e, t) {
|
|
896
|
+
const r = or(e);
|
|
809
897
|
r?.style && (t ? r.style.removeProperty("display") : r.style.setProperty("display", "none", "important")), t || (e?.chat || e?._chat)?.close?.();
|
|
810
898
|
}
|
|
811
|
-
var
|
|
812
|
-
function
|
|
813
|
-
const r =
|
|
899
|
+
var ir = "nd_be_url";
|
|
900
|
+
function Pi(e, t) {
|
|
901
|
+
const r = ar() || e.beUrl || t;
|
|
814
902
|
if (!r) throw new Error("resolveBeUrl: backend URL is required. The injector must supply a fallback URL; the SDK has no default.");
|
|
815
903
|
return r;
|
|
816
904
|
}
|
|
817
|
-
function
|
|
905
|
+
function ar() {
|
|
818
906
|
try {
|
|
819
|
-
const e = new URLSearchParams(window.location.search).get(
|
|
907
|
+
const e = new URLSearchParams(window.location.search).get(ir)?.trim();
|
|
820
908
|
if (!e) return null;
|
|
821
909
|
const t = new URL(e);
|
|
822
910
|
return t.protocol !== "https:" && t.protocol !== "http:" ? null : t.toString().replace(/\/+$/u, "");
|
|
@@ -824,7 +912,7 @@ function Fe() {
|
|
|
824
912
|
return null;
|
|
825
913
|
}
|
|
826
914
|
}
|
|
827
|
-
var
|
|
915
|
+
var sr = [
|
|
828
916
|
"addToCart",
|
|
829
917
|
"search",
|
|
830
918
|
"searchKeyword",
|
|
@@ -832,17 +920,17 @@ var qe = [
|
|
|
832
920
|
"searchGiftOptions",
|
|
833
921
|
"similaritySearch"
|
|
834
922
|
];
|
|
835
|
-
function
|
|
836
|
-
const n = window, o = n.gengage || (n.gengage = {}),
|
|
837
|
-
|
|
838
|
-
for (const
|
|
839
|
-
if (r.exposeStandardAliases !== !1) for (const
|
|
840
|
-
const
|
|
841
|
-
typeof
|
|
923
|
+
function ji(e, t, r = {}) {
|
|
924
|
+
const n = window, o = n.gengage || (n.gengage = {}), i = o.tools || (o.tools = {});
|
|
925
|
+
i[e] = t;
|
|
926
|
+
for (const a of r.accountAliases || []) i[a] = t;
|
|
927
|
+
if (r.exposeStandardAliases !== !1) for (const a of r.standardAliases || sr) {
|
|
928
|
+
const s = t[a];
|
|
929
|
+
typeof s == "function" && (i[a] = i[a] || s);
|
|
842
930
|
}
|
|
843
931
|
return t;
|
|
844
932
|
}
|
|
845
|
-
function
|
|
933
|
+
function Ii({ getPageType: e, getProduct: t }) {
|
|
846
934
|
return () => ({
|
|
847
935
|
url: window.location.href,
|
|
848
936
|
title: document.title,
|
|
@@ -850,7 +938,7 @@ function Ft({ getPageType: e, getProduct: t }) {
|
|
|
850
938
|
product: t()
|
|
851
939
|
});
|
|
852
940
|
}
|
|
853
|
-
function
|
|
941
|
+
function Ui({ accountId: e, getPageType: t, getProduct: r, getToolNames: n, getSearchCapabilities: o, getMemory: i }) {
|
|
854
942
|
return async () => ({
|
|
855
943
|
accountId: e,
|
|
856
944
|
url: window.location.href,
|
|
@@ -858,98 +946,2361 @@ function qt({ accountId: e, getPageType: t, getProduct: r, getToolNames: n, getS
|
|
|
858
946
|
productSku: r()?.sku ?? null,
|
|
859
947
|
toolNames: n(),
|
|
860
948
|
...o ? { searchCapabilities: o() } : {},
|
|
861
|
-
...
|
|
949
|
+
...i ? { memoryPolicy: i().policy } : {},
|
|
862
950
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
863
951
|
});
|
|
864
952
|
}
|
|
865
|
-
function
|
|
953
|
+
function qi({ accountId: e, runtimeFile: t = "runtime.js", startExport: r = "start", globalBaseUrlKey: n, errorLabel: o, trustedRuntimeOrigins: i } = {}) {
|
|
866
954
|
if (!e) throw new Error("accountId is required.");
|
|
867
|
-
const a = o || e,
|
|
868
|
-
const l =
|
|
955
|
+
const a = o || e, s = window, c = () => {
|
|
956
|
+
const l = s.GengageInjectorConfig || {}, p = l[e] || {};
|
|
869
957
|
return {
|
|
870
958
|
...l,
|
|
871
|
-
...
|
|
959
|
+
...p
|
|
872
960
|
};
|
|
873
|
-
},
|
|
874
|
-
const l =
|
|
961
|
+
}, d = () => {
|
|
962
|
+
const l = c();
|
|
875
963
|
if (l.runtimeUrl) return l.runtimeUrl;
|
|
876
|
-
const
|
|
877
|
-
if (!
|
|
878
|
-
return new URL(t,
|
|
879
|
-
}, f =
|
|
880
|
-
|
|
964
|
+
const p = l.assetBaseUrl || l.baseUrl || document.currentScript?.getAttribute("src") || (n ? s[n] : null);
|
|
965
|
+
if (!p) throw new Error(`${a} runtime URL cannot be resolved.`);
|
|
966
|
+
return new URL(t, p).href;
|
|
967
|
+
}, f = (l) => {
|
|
968
|
+
if (i === !0) return l;
|
|
969
|
+
const p = new URL(l, window.location.href).origin, g = /* @__PURE__ */ new Set([window.location.origin]), u = c();
|
|
970
|
+
B(g, document.currentScript?.getAttribute("src")), B(g, u.assetBaseUrl), B(g, u.baseUrl), B(g, n ? s[n] : void 0);
|
|
971
|
+
for (const h of i || []) B(g, h);
|
|
972
|
+
if (!g.has(p)) throw new Error(`${a} runtime origin ${p} is not trusted.`);
|
|
973
|
+
return l;
|
|
974
|
+
}, b = s.GengageAssistantInjector || (s.GengageAssistantInjector = {}), m = b[e] || (b[e] = {});
|
|
975
|
+
return m.loaderPromise || (m.loaderPromise = import(
|
|
881
976
|
/* @vite-ignore */
|
|
882
|
-
|
|
977
|
+
f(d())
|
|
883
978
|
).then((l) => {
|
|
884
|
-
const
|
|
885
|
-
if (typeof
|
|
886
|
-
return
|
|
979
|
+
const p = l[r];
|
|
980
|
+
if (typeof p != "function") throw new Error(`${a} runtime export ${r} is unavailable.`);
|
|
981
|
+
return p();
|
|
887
982
|
}).catch((l) => {
|
|
888
|
-
throw delete
|
|
889
|
-
})),
|
|
983
|
+
throw delete m.loaderPromise, console.error(`[Gengage][${e}] runtime load failed`, l), l;
|
|
984
|
+
})), m.loaderPromise;
|
|
985
|
+
}
|
|
986
|
+
function B(e, t) {
|
|
987
|
+
if (t)
|
|
988
|
+
try {
|
|
989
|
+
const r = new URL(t, window.location.href);
|
|
990
|
+
e.add(r.origin);
|
|
991
|
+
} catch {
|
|
992
|
+
e.add(t);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
var cr = 500, Ae = "__GENGAGE_AGENTIC_ACTIVITY__";
|
|
996
|
+
function lr({ accountId: e, clock: t = () => Date.now() } = {}) {
|
|
997
|
+
const r = /* @__PURE__ */ new Set();
|
|
998
|
+
let n = 1;
|
|
999
|
+
const o = {
|
|
1000
|
+
accountId: e,
|
|
1001
|
+
entries: []
|
|
1002
|
+
};
|
|
1003
|
+
function i(a) {
|
|
1004
|
+
const s = dr({
|
|
1005
|
+
id: n++,
|
|
1006
|
+
at: t(),
|
|
1007
|
+
accountId: e,
|
|
1008
|
+
...a
|
|
1009
|
+
});
|
|
1010
|
+
o.entries.push(s), o.entries.length > cr && (o.entries = o.entries.slice(-500));
|
|
1011
|
+
for (const c of r) c(s, o.entries);
|
|
1012
|
+
return s;
|
|
1013
|
+
}
|
|
1014
|
+
return {
|
|
1015
|
+
accountId: e,
|
|
1016
|
+
get entries() {
|
|
1017
|
+
return o.entries.slice();
|
|
1018
|
+
},
|
|
1019
|
+
clear() {
|
|
1020
|
+
o.entries = [];
|
|
1021
|
+
for (const a of r) a(null, o.entries);
|
|
1022
|
+
},
|
|
1023
|
+
record: i,
|
|
1024
|
+
subscribe(a) {
|
|
1025
|
+
return typeof a != "function" ? () => {
|
|
1026
|
+
} : (r.add(a), a(null, o.entries), () => r.delete(a));
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
function ur(e) {
|
|
1031
|
+
const t = window[Ae];
|
|
1032
|
+
if (t?.accountId === e && typeof t.record == "function") return t;
|
|
1033
|
+
const r = lr({ accountId: e });
|
|
1034
|
+
return window[Ae] = r, r;
|
|
1035
|
+
}
|
|
1036
|
+
function dr(e) {
|
|
1037
|
+
const t = String(e.kind || e.type || "activity"), r = fr(t);
|
|
1038
|
+
return {
|
|
1039
|
+
...e,
|
|
1040
|
+
kind: t,
|
|
1041
|
+
section: r,
|
|
1042
|
+
severity: e.severity || pr({
|
|
1043
|
+
...e,
|
|
1044
|
+
kind: t
|
|
1045
|
+
}),
|
|
1046
|
+
group: e.group || mr({
|
|
1047
|
+
...e,
|
|
1048
|
+
kind: t,
|
|
1049
|
+
section: r
|
|
1050
|
+
})
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
function fr(e) {
|
|
1054
|
+
return e.startsWith("flow/") ? "Flow" : e.startsWith("intent/") ? "Intent" : e.startsWith("be/") ? "Backend" : e.startsWith("tool/") ? "Tools" : e === "beacon" ? "Telemetry" : "Runtime";
|
|
1055
|
+
}
|
|
1056
|
+
function pr(e) {
|
|
1057
|
+
const t = String(e?.kind || "");
|
|
1058
|
+
return /\/(?:error|rejected|thrown)$/u.test(t) || e?.error || t === "be/response" && Number(e?.status) >= 400 ? "error" : t === "flow/metadata" && /fallback|retry|missing|empty/iu.test(String(e?.event?.phase || e?.event?.type || "")) || t === "be/response" && Number(e?.status) >= 300 ? "warn" : "info";
|
|
1059
|
+
}
|
|
1060
|
+
function mr(e) {
|
|
1061
|
+
const t = String(e?.kind || "");
|
|
1062
|
+
if (t.startsWith("tool/")) return e?.tool ? `Tool: ${e.tool}` : "Tools";
|
|
1063
|
+
if (t.startsWith("be/")) return e?.op ? `BE: ${e.op}` : "Backend";
|
|
1064
|
+
if (t === "flow/request") {
|
|
1065
|
+
const r = e?.request?.type || e?.request?.action?.type;
|
|
1066
|
+
return r ? `Flow: ${r}` : "Flow request";
|
|
1067
|
+
}
|
|
1068
|
+
if (t === "flow/action") {
|
|
1069
|
+
const r = e?.event?.name || e?.event?.action || e?.event?.type;
|
|
1070
|
+
return r ? `Action: ${r}` : "Flow action";
|
|
1071
|
+
}
|
|
1072
|
+
return t === "flow/ui" ? e?.widget ? `UI: ${e.widget}` : "UI" : t.startsWith("flow/") ? "Flow lifecycle" : t.startsWith("intent/") ? e?.intent?.kind ? `Intent: ${e.intent.kind}` : "Intent" : t === "beacon" ? e?.payload?.type ? `Beacon: ${e.payload.type}` : "Beacon" : e?.section || "Runtime";
|
|
1073
|
+
}
|
|
1074
|
+
var gr = 8, fe = 120;
|
|
1075
|
+
function hr(e = []) {
|
|
1076
|
+
const t = Array.isArray(e) ? e : [], r = {
|
|
1077
|
+
status: "idle",
|
|
1078
|
+
sessionId: "",
|
|
1079
|
+
requestType: "",
|
|
1080
|
+
actionType: "",
|
|
1081
|
+
model: "",
|
|
1082
|
+
current: "Waiting for activity",
|
|
1083
|
+
errors: 0,
|
|
1084
|
+
warnings: 0,
|
|
1085
|
+
startedAt: null,
|
|
1086
|
+
lastAt: null,
|
|
1087
|
+
tools: [],
|
|
1088
|
+
beOps: [],
|
|
1089
|
+
uiSurfaces: [],
|
|
1090
|
+
timeline: []
|
|
1091
|
+
}, n = {
|
|
1092
|
+
intent: null,
|
|
1093
|
+
route: null,
|
|
1094
|
+
panel: null,
|
|
1095
|
+
threadExtensions: {},
|
|
1096
|
+
pageProduct: null,
|
|
1097
|
+
products: null,
|
|
1098
|
+
ui: null,
|
|
1099
|
+
lastText: ""
|
|
1100
|
+
};
|
|
1101
|
+
for (const o of t) br(r, n, o);
|
|
1102
|
+
return r.tools = te(r.tools).slice(-8), r.beOps = te(r.beOps).slice(-8), r.uiSurfaces = te(r.uiSurfaces).slice(-8), r.timeline = r.timeline.slice(-36), !r.lastAt && t.length && (r.lastAt = t.at(-1)?.at || null), {
|
|
1103
|
+
flow: r,
|
|
1104
|
+
context: n
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
function Y(e, t = "") {
|
|
1108
|
+
if (!e || typeof e != "object") return null;
|
|
1109
|
+
const r = T({
|
|
1110
|
+
source: t,
|
|
1111
|
+
panel: ae(e.panel || e.panel_state),
|
|
1112
|
+
threadExtensions: Tr(e.thread?.extensions || e.threadExtensions || e.extensions),
|
|
1113
|
+
pageProduct: Cr(e.product || e.page?.product),
|
|
1114
|
+
products: V(e.products || e.last_search_products || e.items),
|
|
1115
|
+
ui: Ye(e.spec),
|
|
1116
|
+
intent: pe(e.intent),
|
|
1117
|
+
route: Q({
|
|
1118
|
+
searchParams: e.searchParams || e.search_params,
|
|
1119
|
+
flowParams: e.flowParams || e.flow_params
|
|
1120
|
+
})
|
|
1121
|
+
});
|
|
1122
|
+
return Object.keys(r).some((n) => n !== "source") ? r : null;
|
|
1123
|
+
}
|
|
1124
|
+
function ae(e) {
|
|
1125
|
+
if (!e || typeof e != "object") return null;
|
|
1126
|
+
const t = V(e.last_search_products || e.current_panel_products), r = q(e.screen_sku_list || e.search_suggestions_skus);
|
|
1127
|
+
return T({
|
|
1128
|
+
source: e.list_source || e.source,
|
|
1129
|
+
screenType: y(e.screen_type || e.screen),
|
|
1130
|
+
screenSummary: y(e.screen_summary || e.ai_plist_summary),
|
|
1131
|
+
screenSkus: r,
|
|
1132
|
+
chatMentionedSkus: q(e.chat_mentioned_skus),
|
|
1133
|
+
lastSearch: Er(e.last_search),
|
|
1134
|
+
productCount: t?.count ?? me(e.current_panel_product_count),
|
|
1135
|
+
productSkus: t?.skus
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
function Ye(e, t = "", r = "") {
|
|
1139
|
+
if (!e || typeof e != "object") return null;
|
|
1140
|
+
const n = Ar(e);
|
|
1141
|
+
if (!n) return null;
|
|
1142
|
+
const o = n.props || {}, i = n.type === "ProductDetailsPanel" ? V([o.product || o.item].filter(Boolean)) : V(o.products || o.items || o.cards), a = Array.isArray(o.buttons) ? o.buttons : Array.isArray(o.actions) ? o.actions : [], s = Array.isArray(o.rows) ? o.rows.length : Array.isArray(o.comparison_table) ? o.comparison_table.length : void 0;
|
|
1143
|
+
return T({
|
|
1144
|
+
widget: t,
|
|
1145
|
+
panelHint: r,
|
|
1146
|
+
rootType: n.type,
|
|
1147
|
+
productCount: i?.count,
|
|
1148
|
+
productSkus: i?.skus,
|
|
1149
|
+
buttonCount: a.length || void 0,
|
|
1150
|
+
buttonLabels: a.length ? q(a.map((c) => c.label || c.title)) : void 0,
|
|
1151
|
+
comparisonRows: s
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
function br(e, t, r = {}) {
|
|
1155
|
+
if (!(!r || typeof r != "object"))
|
|
1156
|
+
switch (e.lastAt = r.at || e.lastAt, r.severity === "error" && (e.errors += 1), r.severity === "warn" && (e.warnings += 1), r.state && Z(t, r.state), r.kind) {
|
|
1157
|
+
case "flow/request":
|
|
1158
|
+
yr(e, t, r);
|
|
1159
|
+
break;
|
|
1160
|
+
case "flow/metadata":
|
|
1161
|
+
wr(e, t, r);
|
|
1162
|
+
break;
|
|
1163
|
+
case "flow/ui":
|
|
1164
|
+
vr(e, t, r);
|
|
1165
|
+
break;
|
|
1166
|
+
case "flow/text-final":
|
|
1167
|
+
t.lastText = y(r.content, fe), _(e, r, "Text", t.lastText, "done");
|
|
1168
|
+
break;
|
|
1169
|
+
case "flow/done":
|
|
1170
|
+
e.status = e.status === "error" ? "error" : "done", e.current = "Done", _(e, r, "Done", "Flow completed", "done");
|
|
1171
|
+
break;
|
|
1172
|
+
case "flow/error":
|
|
1173
|
+
case "flow/rejected":
|
|
1174
|
+
case "flow/thrown":
|
|
1175
|
+
e.status = "error", e.current = "Flow error", _(e, r, "Error", y(r.error || r.kind), "error");
|
|
1176
|
+
break;
|
|
1177
|
+
case "tool/start":
|
|
1178
|
+
e.status = e.status === "idle" ? "running" : e.status, e.current = `Tool: ${r.tool || "tool"}`, e.tools.push(r.tool || "tool"), _(e, r, "Tool", r.tool || "tool", "running");
|
|
1179
|
+
break;
|
|
1180
|
+
case "tool/done":
|
|
1181
|
+
e.tools.push(r.tool || "tool"), _(e, r, "Tool", r.tool || "tool", "done");
|
|
1182
|
+
break;
|
|
1183
|
+
case "tool/error":
|
|
1184
|
+
e.status = "error", e.current = `Tool error: ${r.tool || "tool"}`, e.tools.push(r.tool || "tool"), _(e, r, "Tool", r.tool || "tool", "error");
|
|
1185
|
+
break;
|
|
1186
|
+
case "be/request":
|
|
1187
|
+
e.status = e.status === "idle" ? "running" : e.status, e.current = `BE: ${r.op || "request"}`, e.beOps.push(r.op || "unknown"), xr(t, r), _(e, r, "BE", r.op || "request", "running");
|
|
1188
|
+
break;
|
|
1189
|
+
case "be/response":
|
|
1190
|
+
e.beOps.push(r.op || r.result?.op || "unknown"), kr(t, r.result), _(e, r, "BE", r.op || r.result?.intent?.kind || "response", r.severity || "done");
|
|
1191
|
+
break;
|
|
1192
|
+
case "intent/selected":
|
|
1193
|
+
t.intent = pe(r.intent), t.route = Q({
|
|
1194
|
+
searchParams: r.searchParams,
|
|
1195
|
+
flowParams: r.flowParams
|
|
1196
|
+
}), e.current = `Intent: ${t.intent?.kind || "selected"}`, _(e, r, "Intent", t.intent?.kind || "selected", "done");
|
|
1197
|
+
break;
|
|
1198
|
+
default:
|
|
1199
|
+
r.kind?.startsWith?.("runtime/") && _(e, r, "Runtime", r.title || r.kind, "done");
|
|
1200
|
+
break;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
function yr(e, t, r) {
|
|
1204
|
+
const n = r.request || {};
|
|
1205
|
+
e.status = "running", e.startedAt = r.at || e.startedAt, e.sessionId = y(n.session_id || n.sessionId || e.sessionId), e.requestType = y(n.type || e.requestType), e.actionType = y(n.action?.type || n.payload?.type || e.actionType), e.current = e.actionType || e.requestType || "Flow request", Z(t, Y(n.context || {}, "request.context")), _(e, r, "Request", [e.requestType, e.actionType].filter(Boolean).join(" / ") || "request", "running");
|
|
1206
|
+
}
|
|
1207
|
+
function wr(e, t, r) {
|
|
1208
|
+
const n = r.event || {};
|
|
1209
|
+
e.sessionId = y(n.sessionId || n.session_id || e.sessionId), e.model = y(n.model || e.model), n.panelLoading === !0 && (e.current = "Panel loading"), Z(t, Y(n, "flow.metadata")), _(e, r, "Metadata", y(n.name || n.phase || n.type || "metadata"), r.severity);
|
|
1210
|
+
}
|
|
1211
|
+
function vr(e, t, r) {
|
|
1212
|
+
const n = Ye(r.spec, r.widget, r.panelHint);
|
|
1213
|
+
n && (t.ui = n, t.products = n.productCount ? {
|
|
1214
|
+
count: n.productCount,
|
|
1215
|
+
skus: n.productSkus || []
|
|
1216
|
+
} : t.products, e.uiSurfaces.push(n.rootType), e.current = `UI: ${n.rootType}`, _(e, r, "UI", n.rootType || "ui", "done"));
|
|
1217
|
+
}
|
|
1218
|
+
function xr(e, t) {
|
|
1219
|
+
const r = t.params || {};
|
|
1220
|
+
Z(e, Y(r, "be.params")), r.panel_state && (e.panel = ae(r.panel_state)), r.structured_context && (e.panel = Ze(e.panel, ae(r.structured_context)));
|
|
1221
|
+
const n = Q({
|
|
1222
|
+
searchParams: r.search_params,
|
|
1223
|
+
flowParams: r.flow_params
|
|
1224
|
+
});
|
|
1225
|
+
n && (e.route = n);
|
|
1226
|
+
}
|
|
1227
|
+
function kr(e, t) {
|
|
1228
|
+
if (!t || typeof t != "object") return;
|
|
1229
|
+
t.intent && (e.intent = pe(t.intent));
|
|
1230
|
+
const r = Q({
|
|
1231
|
+
searchParams: t.search_params,
|
|
1232
|
+
flowParams: t.flow_params
|
|
1233
|
+
});
|
|
1234
|
+
r && (e.route = r);
|
|
1235
|
+
}
|
|
1236
|
+
function Z(e, t) {
|
|
1237
|
+
!t || typeof t != "object" || (t.panel && (e.panel = Ze(e.panel, t.panel)), t.threadExtensions && (e.threadExtensions = {
|
|
1238
|
+
...e.threadExtensions,
|
|
1239
|
+
...t.threadExtensions
|
|
1240
|
+
}), t.pageProduct && (e.pageProduct = t.pageProduct), t.products && (e.products = t.products), t.ui && (e.ui = t.ui), t.intent && (e.intent = t.intent), t.route && (e.route = t.route));
|
|
1241
|
+
}
|
|
1242
|
+
function Ze(e, t) {
|
|
1243
|
+
return e ? t ? T({
|
|
1244
|
+
...e,
|
|
1245
|
+
...t
|
|
1246
|
+
}) : e : t || null;
|
|
1247
|
+
}
|
|
1248
|
+
function _(e, t, r, n, o = "done") {
|
|
1249
|
+
e.timeline.push(T({
|
|
1250
|
+
id: t.id,
|
|
1251
|
+
at: t.at,
|
|
1252
|
+
label: r,
|
|
1253
|
+
detail: y(n, fe),
|
|
1254
|
+
status: o === "info" ? "done" : o,
|
|
1255
|
+
kind: t.kind
|
|
1256
|
+
}));
|
|
1257
|
+
}
|
|
1258
|
+
function pe(e) {
|
|
1259
|
+
return !e || typeof e != "object" ? null : T({
|
|
1260
|
+
kind: y(e.kind || e.intent || e.type),
|
|
1261
|
+
target: y(e.target),
|
|
1262
|
+
confidence: typeof e.confidence == "number" ? Math.round(e.confidence * 100) / 100 : void 0
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
function Q({ searchParams: e, flowParams: t } = {}) {
|
|
1266
|
+
const r = T({
|
|
1267
|
+
search: Sr(e),
|
|
1268
|
+
flow: _r(t)
|
|
1269
|
+
});
|
|
1270
|
+
return Object.keys(r).length ? r : null;
|
|
1271
|
+
}
|
|
1272
|
+
function Sr(e) {
|
|
1273
|
+
return !e || typeof e != "object" ? null : T({
|
|
1274
|
+
query: y(e.query || e.search_query),
|
|
1275
|
+
category: y(e.category || e.category_name || e.categoryName),
|
|
1276
|
+
categoryId: y(e.categoryId || e.category_id),
|
|
1277
|
+
limit: me(e.limit),
|
|
1278
|
+
facets: Array.isArray(e.facets) ? e.facets.length : void 0
|
|
1279
|
+
});
|
|
1280
|
+
}
|
|
1281
|
+
function _r(e) {
|
|
1282
|
+
return !e || typeof e != "object" ? null : T({
|
|
1283
|
+
target: y(e.target),
|
|
1284
|
+
sku: y(e.sku || e.product_sku),
|
|
1285
|
+
skus: q(e.skus || e.sku_list),
|
|
1286
|
+
action: y(e.action || e.action_type)
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
function Tr(e) {
|
|
1290
|
+
if (!e || typeof e != "object") return {};
|
|
1291
|
+
const t = {};
|
|
1292
|
+
for (const [r, n] of Object.entries(e))
|
|
1293
|
+
n != null && (t[r] = n && typeof n == "object" ? T({
|
|
1294
|
+
keys: Object.keys(n).slice(0, 8),
|
|
1295
|
+
summary: y(n.summary || n.occasion || n.target_date_iso || n.type)
|
|
1296
|
+
}) : y(n));
|
|
1297
|
+
return t;
|
|
1298
|
+
}
|
|
1299
|
+
function Er(e) {
|
|
1300
|
+
return !e || typeof e != "object" ? null : T({
|
|
1301
|
+
query: y(e.query),
|
|
1302
|
+
source: y(e.source),
|
|
1303
|
+
category: y(e.category || e.category_name),
|
|
1304
|
+
count: me(e.count)
|
|
1305
|
+
});
|
|
1306
|
+
}
|
|
1307
|
+
function V(e) {
|
|
1308
|
+
if (!Array.isArray(e)) return null;
|
|
1309
|
+
const t = e.filter(Boolean);
|
|
1310
|
+
return T({
|
|
1311
|
+
count: t.length,
|
|
1312
|
+
skus: q(t.map((r) => r?.sku || r?.code || r?.id)),
|
|
1313
|
+
names: q(t.map((r) => r?.name || r?.title), 4)
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
function Cr(e) {
|
|
1317
|
+
return !e || typeof e != "object" ? null : T({
|
|
1318
|
+
sku: y(e.sku || e.code || e.id),
|
|
1319
|
+
name: y(e.name || e.title),
|
|
1320
|
+
category: y(e.category),
|
|
1321
|
+
url: y(e.url)
|
|
1322
|
+
});
|
|
1323
|
+
}
|
|
1324
|
+
function Ar(e) {
|
|
1325
|
+
const t = e.elements || {};
|
|
1326
|
+
return t[e.root || "root"] || t.root || e.rootElement || null;
|
|
1327
|
+
}
|
|
1328
|
+
function q(e, t = gr) {
|
|
1329
|
+
if (!Array.isArray(e)) return;
|
|
1330
|
+
const r = e.map((n) => y(n)).filter(Boolean);
|
|
1331
|
+
return r.length ? r.slice(0, t) : void 0;
|
|
1332
|
+
}
|
|
1333
|
+
function te(e) {
|
|
1334
|
+
return [...new Set(e.map((t) => y(t)).filter(Boolean))];
|
|
1335
|
+
}
|
|
1336
|
+
function me(e) {
|
|
1337
|
+
return Number.isFinite(Number(e)) ? Number(e) : void 0;
|
|
1338
|
+
}
|
|
1339
|
+
function y(e, t = fe) {
|
|
1340
|
+
const r = String(e ?? "").replace(/\s+/gu, " ").trim();
|
|
1341
|
+
return r.length > t ? `${r.slice(0, t - 1)}...` : r;
|
|
1342
|
+
}
|
|
1343
|
+
function T(e) {
|
|
1344
|
+
return Object.fromEntries(Object.entries(e || {}).filter(([, t]) => t == null || t === "" ? !1 : Array.isArray(t) ? t.length > 0 : typeof t == "object" ? Object.keys(t).length > 0 : !0));
|
|
1345
|
+
}
|
|
1346
|
+
function Lr(e, t) {
|
|
1347
|
+
if (!e || typeof e != "object" || !t) return e;
|
|
1348
|
+
const r = { ...e };
|
|
1349
|
+
for (const [n, o] of Object.entries(e))
|
|
1350
|
+
typeof o != "function" || o.__gengageActivityWrapped || (r[n] = async function(a, ...s) {
|
|
1351
|
+
t.record({
|
|
1352
|
+
kind: "tool/start",
|
|
1353
|
+
tool: n,
|
|
1354
|
+
params: a
|
|
1355
|
+
});
|
|
1356
|
+
try {
|
|
1357
|
+
const c = await o.call(this, a, ...s);
|
|
1358
|
+
return t.record({
|
|
1359
|
+
kind: "tool/done",
|
|
1360
|
+
tool: n,
|
|
1361
|
+
params: a,
|
|
1362
|
+
result: zr(c),
|
|
1363
|
+
state: Y(c, `tool:${n}`)
|
|
1364
|
+
}), c;
|
|
1365
|
+
} catch (c) {
|
|
1366
|
+
throw t.record({
|
|
1367
|
+
kind: "tool/error",
|
|
1368
|
+
tool: n,
|
|
1369
|
+
params: a,
|
|
1370
|
+
error: N(c)
|
|
1371
|
+
}), c;
|
|
1372
|
+
}
|
|
1373
|
+
}, Object.defineProperty(r[n], "__gengageActivityWrapped", { value: !0 }));
|
|
1374
|
+
return r;
|
|
1375
|
+
}
|
|
1376
|
+
function Rr(e, t) {
|
|
1377
|
+
return t ? (r) => (t.record({
|
|
1378
|
+
kind: "beacon",
|
|
1379
|
+
payload: r
|
|
1380
|
+
}), e?.(r)) : e;
|
|
1381
|
+
}
|
|
1382
|
+
function Pr(e, t) {
|
|
1383
|
+
if (!t) return !1;
|
|
1384
|
+
const r = window.GengageAssistantInjector?.[e], n = r?.streamTransport;
|
|
1385
|
+
if (typeof n != "function" || n.__gengageActivityWrapped) return !1;
|
|
1386
|
+
const o = function(a, s, c, d) {
|
|
1387
|
+
t.record({
|
|
1388
|
+
kind: "flow/request",
|
|
1389
|
+
request: a
|
|
1390
|
+
});
|
|
1391
|
+
try {
|
|
1392
|
+
const f = n.call(this, a, Ir(s, t), c, d);
|
|
1393
|
+
return f && typeof f.then == "function" ? f.catch((b) => {
|
|
1394
|
+
throw t.record({
|
|
1395
|
+
kind: "flow/rejected",
|
|
1396
|
+
requestType: a?.type,
|
|
1397
|
+
error: N(b)
|
|
1398
|
+
}), b;
|
|
1399
|
+
}) : f;
|
|
1400
|
+
} catch (f) {
|
|
1401
|
+
throw t.record({
|
|
1402
|
+
kind: "flow/thrown",
|
|
1403
|
+
requestType: a?.type,
|
|
1404
|
+
error: N(f)
|
|
1405
|
+
}), f;
|
|
1406
|
+
}
|
|
1407
|
+
};
|
|
1408
|
+
return Object.defineProperty(o, "__gengageActivityWrapped", { value: !0 }), r.streamTransport = o, t.record({
|
|
1409
|
+
kind: "runtime/transport-wrapped",
|
|
1410
|
+
title: "streamTransport wrapped"
|
|
1411
|
+
}), !0;
|
|
1412
|
+
}
|
|
1413
|
+
function jr({ accountId: e, collector: t, promptBaseUrl: r } = {}) {
|
|
1414
|
+
if (!t || window.__GENGAGE_ACTIVITY_FETCH_PATCHED__) return;
|
|
1415
|
+
window.__GENGAGE_ACTIVITY_FETCH_PATCHED__ = !0;
|
|
1416
|
+
const n = window.fetch?.bind(window);
|
|
1417
|
+
typeof n == "function" && (window.fetch = async (o, i) => {
|
|
1418
|
+
const a = Or(o, i), s = $r(a.url);
|
|
1419
|
+
let c = "";
|
|
1420
|
+
s && (c = a.body?.op_name || a.body?.op || "unknown", t.record({
|
|
1421
|
+
kind: "be/request",
|
|
1422
|
+
source: "main-thread-fetch",
|
|
1423
|
+
url: a.url,
|
|
1424
|
+
op: c,
|
|
1425
|
+
opDomain: a.body?.op_domain || "",
|
|
1426
|
+
prompt: await qr({
|
|
1427
|
+
accountId: e,
|
|
1428
|
+
opName: c,
|
|
1429
|
+
promptBaseUrl: r
|
|
1430
|
+
}),
|
|
1431
|
+
params: a.body?.op_payload || {},
|
|
1432
|
+
rawBody: a.body
|
|
1433
|
+
}));
|
|
1434
|
+
const d = await n(o, i);
|
|
1435
|
+
return s && d.clone().text().then((f) => {
|
|
1436
|
+
const b = Dr(f);
|
|
1437
|
+
t.record({
|
|
1438
|
+
kind: "be/response",
|
|
1439
|
+
source: "main-thread-fetch",
|
|
1440
|
+
url: a.url,
|
|
1441
|
+
status: d.status,
|
|
1442
|
+
op: c,
|
|
1443
|
+
result: b,
|
|
1444
|
+
rawText: f
|
|
1445
|
+
}), Qe(t, b);
|
|
1446
|
+
}).catch((f) => {
|
|
1447
|
+
t.record({
|
|
1448
|
+
kind: "be/response",
|
|
1449
|
+
source: "main-thread-fetch",
|
|
1450
|
+
url: a.url,
|
|
1451
|
+
status: d.status,
|
|
1452
|
+
op: c,
|
|
1453
|
+
error: N(f)
|
|
1454
|
+
});
|
|
1455
|
+
}), d;
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1458
|
+
function Ir(e, t) {
|
|
1459
|
+
if (!e || e.__gengageActivityWrapped) return e;
|
|
1460
|
+
const r = { ...e };
|
|
1461
|
+
Object.defineProperty(r, "__gengageActivityWrapped", { value: !0 });
|
|
1462
|
+
for (const n of [
|
|
1463
|
+
"onAction",
|
|
1464
|
+
"onMetadata",
|
|
1465
|
+
"onUISpec",
|
|
1466
|
+
"onTextChunk",
|
|
1467
|
+
"onError",
|
|
1468
|
+
"onDone"
|
|
1469
|
+
])
|
|
1470
|
+
typeof e[n] == "function" && (r[n] = (...o) => (n === "onAction" ? t.record({
|
|
1471
|
+
kind: "flow/action",
|
|
1472
|
+
event: o[0]
|
|
1473
|
+
}) : n === "onMetadata" ? t.record({
|
|
1474
|
+
kind: "flow/metadata",
|
|
1475
|
+
event: o[0]
|
|
1476
|
+
}) : n === "onUISpec" ? t.record({
|
|
1477
|
+
kind: "flow/ui",
|
|
1478
|
+
widget: o[1],
|
|
1479
|
+
panelHint: o[2],
|
|
1480
|
+
clearPanel: o[3] === !0,
|
|
1481
|
+
spec: o[0]
|
|
1482
|
+
}) : n === "onTextChunk" && o[1] === !0 ? t.record({
|
|
1483
|
+
kind: "flow/text-final",
|
|
1484
|
+
content: o[0],
|
|
1485
|
+
extra: o[2]
|
|
1486
|
+
}) : n === "onError" ? t.record({
|
|
1487
|
+
kind: "flow/error",
|
|
1488
|
+
error: N(o[0])
|
|
1489
|
+
}) : n === "onDone" && t.record({ kind: "flow/done" }), e[n](...o)));
|
|
1490
|
+
return r;
|
|
1491
|
+
}
|
|
1492
|
+
function Ur(e, t) {
|
|
1493
|
+
!e || !t || (e.record(t), t.kind === "be/response" && Qe(e, t.result));
|
|
1494
|
+
}
|
|
1495
|
+
async function qr({ accountId: e, opName: t, promptBaseUrl: r }) {
|
|
1496
|
+
if (!e || !t) return null;
|
|
1497
|
+
const n = Nr({
|
|
1498
|
+
accountId: e,
|
|
1499
|
+
baseId: String(e).replace(/-agentic$/u, ""),
|
|
1500
|
+
promptBaseUrl: r
|
|
1501
|
+
});
|
|
1502
|
+
if (!n) return { error: "Configure agenticActivityPromptBaseUrl to inspect prompt source in this build." };
|
|
1503
|
+
try {
|
|
1504
|
+
const o = new URL(`${t}.yaml`, n).href, i = await fetch(o, { cache: "no-store" });
|
|
1505
|
+
return i.ok ? {
|
|
1506
|
+
url: o,
|
|
1507
|
+
yaml: await i.text()
|
|
1508
|
+
} : {
|
|
1509
|
+
url: o,
|
|
1510
|
+
error: `HTTP ${i.status}`
|
|
1511
|
+
};
|
|
1512
|
+
} catch (o) {
|
|
1513
|
+
return { error: N(o) };
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
function Nr({ accountId: e, baseId: t, promptBaseUrl: r }) {
|
|
1517
|
+
if (typeof r == "string" && r.trim()) return r;
|
|
1518
|
+
const n = Mr(e, t);
|
|
1519
|
+
return n || Fr(t);
|
|
1520
|
+
}
|
|
1521
|
+
function Mr(e, t) {
|
|
1522
|
+
const r = window.__GENGAGE_AGENTIC_PROMPT_BASE_URL__;
|
|
1523
|
+
if (typeof r == "string" && r.trim()) return r;
|
|
1524
|
+
if (r && typeof r == "object") {
|
|
1525
|
+
const o = r[e] || r[t];
|
|
1526
|
+
if (typeof o == "string" && o.trim()) return o;
|
|
1527
|
+
}
|
|
1528
|
+
const n = (window.GengageInjectorConfig?.[e] || window.GengageInjectorConfig?.[t])?.agenticActivityPromptBaseUrl;
|
|
1529
|
+
return typeof n == "string" && n.trim() ? n : null;
|
|
1530
|
+
}
|
|
1531
|
+
function Fr(e) {
|
|
1532
|
+
const t = Array.from(document.scripts || []);
|
|
1533
|
+
for (const r of t) {
|
|
1534
|
+
const n = r?.src || "";
|
|
1535
|
+
if (n.includes("/agentic/index.js")) return new URL(`../prompts/${e}/`, n).href;
|
|
1536
|
+
if (n.includes("/agentic.iife.js")) return new URL(`prompts/${e}/`, n).href;
|
|
1537
|
+
}
|
|
1538
|
+
return null;
|
|
1539
|
+
}
|
|
1540
|
+
function Qe(e, t) {
|
|
1541
|
+
const r = t?.intent;
|
|
1542
|
+
r && e.record({
|
|
1543
|
+
kind: "intent/selected",
|
|
1544
|
+
intent: r,
|
|
1545
|
+
searchParams: t?.search_params,
|
|
1546
|
+
flowParams: t?.flow_params
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
function Or(e, t) {
|
|
1550
|
+
const r = typeof e == "string" ? e : e?.url || "", n = t?.body || (typeof e != "string" ? e?.body : null);
|
|
1551
|
+
return {
|
|
1552
|
+
url: String(r || ""),
|
|
1553
|
+
body: Br(n)
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1556
|
+
function Br(e) {
|
|
1557
|
+
if (!e || typeof e != "string") return {};
|
|
1558
|
+
try {
|
|
1559
|
+
return JSON.parse(e);
|
|
1560
|
+
} catch {
|
|
1561
|
+
return { raw: e };
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
function $r(e) {
|
|
1565
|
+
try {
|
|
1566
|
+
const t = new URL(e, window.location.href);
|
|
1567
|
+
return t.pathname === "/v1/execute" && /agentic\.gengage\.ai$/u.test(t.hostname);
|
|
1568
|
+
} catch {
|
|
1569
|
+
return !1;
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
function Dr(e) {
|
|
1573
|
+
const t = {};
|
|
1574
|
+
for (const r of String(e || "").split(/\r?\n/u)) {
|
|
1575
|
+
const n = r.trim();
|
|
1576
|
+
if (n)
|
|
1577
|
+
try {
|
|
1578
|
+
Object.assign(t, JSON.parse(n));
|
|
1579
|
+
} catch {
|
|
1580
|
+
t._raw = [t._raw, n].filter(Boolean).join(`
|
|
1581
|
+
`);
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
return t;
|
|
1585
|
+
}
|
|
1586
|
+
function zr(e) {
|
|
1587
|
+
if (Array.isArray(e)) return {
|
|
1588
|
+
type: "array",
|
|
1589
|
+
length: e.length,
|
|
1590
|
+
preview: e.slice(0, 5)
|
|
1591
|
+
};
|
|
1592
|
+
if (!e || typeof e != "object") return e;
|
|
1593
|
+
const t = {};
|
|
1594
|
+
for (const [r, n] of Object.entries(e)) Array.isArray(n) ? t[r] = {
|
|
1595
|
+
type: "array",
|
|
1596
|
+
length: n.length,
|
|
1597
|
+
preview: n.slice(0, 5)
|
|
1598
|
+
} : n && typeof n == "object" ? t[r] = {
|
|
1599
|
+
type: "object",
|
|
1600
|
+
keys: Object.keys(n).slice(0, 20)
|
|
1601
|
+
} : t[r] = n;
|
|
1602
|
+
return t;
|
|
1603
|
+
}
|
|
1604
|
+
function N(e) {
|
|
1605
|
+
return e?.message || String(e);
|
|
1606
|
+
}
|
|
1607
|
+
var Le = "gengage-agentic-activity-overlay", D = "all", se = "all", Re = [
|
|
1608
|
+
"Flow",
|
|
1609
|
+
"Tools",
|
|
1610
|
+
"Backend",
|
|
1611
|
+
"Intent",
|
|
1612
|
+
"Telemetry",
|
|
1613
|
+
"Runtime"
|
|
1614
|
+
], Pe = [
|
|
1615
|
+
"info",
|
|
1616
|
+
"warn",
|
|
1617
|
+
"error"
|
|
1618
|
+
];
|
|
1619
|
+
function Gr(e) {
|
|
1620
|
+
if (!e || typeof e.subscribe != "function") return null;
|
|
1621
|
+
const t = document.getElementById(Le);
|
|
1622
|
+
if (t?.shadowRoot) return t;
|
|
1623
|
+
const r = document.createElement("div");
|
|
1624
|
+
r.id = Le, r.style.cssText = "position:fixed;left:10px;top:10px;z-index:2147483647;";
|
|
1625
|
+
const n = r.attachShadow({ mode: "open" });
|
|
1626
|
+
n.innerHTML = hn(e.accountId), document.documentElement.appendChild(r);
|
|
1627
|
+
const o = {
|
|
1628
|
+
entries: [],
|
|
1629
|
+
section: D,
|
|
1630
|
+
severity: se,
|
|
1631
|
+
search: "",
|
|
1632
|
+
grouped: !0,
|
|
1633
|
+
follow: !0,
|
|
1634
|
+
stateVisible: !0
|
|
1635
|
+
}, i = {
|
|
1636
|
+
stateView: n.querySelector('[data-role="state-view"]'),
|
|
1637
|
+
list: n.querySelector('[data-role="list"]'),
|
|
1638
|
+
count: n.querySelector('[data-role="count"]'),
|
|
1639
|
+
visibleCount: n.querySelector('[data-role="visible-count"]'),
|
|
1640
|
+
panel: n.querySelector('[data-role="panel"]'),
|
|
1641
|
+
search: n.querySelector('[data-role="search"]'),
|
|
1642
|
+
sections: n.querySelector('[data-role="section-filters"]'),
|
|
1643
|
+
severities: n.querySelector('[data-role="severity-filters"]'),
|
|
1644
|
+
groupToggle: n.querySelector('[data-action="group"]'),
|
|
1645
|
+
followToggle: n.querySelector('[data-action="follow"]'),
|
|
1646
|
+
stateToggle: n.querySelector('[data-action="state"]')
|
|
1647
|
+
};
|
|
1648
|
+
Hr(r, i.list);
|
|
1649
|
+
const a = () => Vr(i, o);
|
|
1650
|
+
return n.querySelector('[data-action="clear"]')?.addEventListener("click", () => e.clear()), n.querySelector('[data-action="toggle"]')?.addEventListener("click", (s) => {
|
|
1651
|
+
i.panel.classList.toggle("is-minimized"), s.currentTarget.textContent = i.panel.classList.contains("is-minimized") ? "Open" : "Min";
|
|
1652
|
+
}), i.search?.addEventListener("input", () => {
|
|
1653
|
+
o.search = i.search.value || "", a();
|
|
1654
|
+
}), i.sections?.addEventListener("click", (s) => {
|
|
1655
|
+
const c = s.target?.closest?.("[data-section-filter]")?.dataset?.sectionFilter;
|
|
1656
|
+
c && (o.section = c, a());
|
|
1657
|
+
}), i.severities?.addEventListener("click", (s) => {
|
|
1658
|
+
const c = s.target?.closest?.("[data-severity-filter]")?.dataset?.severityFilter;
|
|
1659
|
+
c && (o.severity = c, a());
|
|
1660
|
+
}), i.groupToggle?.addEventListener("click", () => {
|
|
1661
|
+
o.grouped = !o.grouped, i.groupToggle.setAttribute("aria-pressed", String(o.grouped)), i.groupToggle.textContent = o.grouped ? "Grouped" : "Flat", a();
|
|
1662
|
+
}), i.followToggle?.addEventListener("click", () => {
|
|
1663
|
+
o.follow = !o.follow, i.followToggle.setAttribute("aria-pressed", String(o.follow)), i.followToggle.textContent = o.follow ? "Follow" : "Paused";
|
|
1664
|
+
}), i.stateToggle?.addEventListener("click", () => {
|
|
1665
|
+
o.stateVisible = !o.stateVisible, i.stateToggle.setAttribute("aria-pressed", String(o.stateVisible)), i.stateToggle.textContent = o.stateVisible ? "State" : "State off", a();
|
|
1666
|
+
}), n.querySelector('[data-action="expand-all"]')?.addEventListener("click", () => {
|
|
1667
|
+
i.list?.querySelectorAll("details").forEach((s) => {
|
|
1668
|
+
s.open = !0;
|
|
1669
|
+
});
|
|
1670
|
+
}), n.querySelector('[data-action="collapse-all"]')?.addEventListener("click", () => {
|
|
1671
|
+
i.list?.querySelectorAll("details").forEach((s) => {
|
|
1672
|
+
s.open = !1;
|
|
1673
|
+
});
|
|
1674
|
+
}), i.list?.addEventListener("click", (s) => {
|
|
1675
|
+
const c = s.target?.closest?.('[data-action="copy-json"]');
|
|
1676
|
+
if (!c) return;
|
|
1677
|
+
const d = Number(c.dataset.entryId || 0);
|
|
1678
|
+
pn(o.entries.find((f) => f.id === d), c);
|
|
1679
|
+
}), e.subscribe((s, c) => {
|
|
1680
|
+
o.entries = c.slice(), a();
|
|
1681
|
+
}), r;
|
|
1682
|
+
}
|
|
1683
|
+
function Hr(e, t) {
|
|
1684
|
+
e.addEventListener("wheel", (r) => {
|
|
1685
|
+
const n = Wr(r.composedPath?.() || [], t);
|
|
1686
|
+
n && (n.scrollTop += r.deltaY, n.scrollLeft += r.deltaX, r.preventDefault(), r.stopPropagation());
|
|
1687
|
+
}, {
|
|
1688
|
+
passive: !1,
|
|
1689
|
+
capture: !0
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
function Wr(e, t) {
|
|
1693
|
+
for (const r of e)
|
|
1694
|
+
if (!(!r || r.nodeType !== 1) && je(r))
|
|
1695
|
+
return r;
|
|
1696
|
+
return je(t) ? t : null;
|
|
1697
|
+
}
|
|
1698
|
+
function je(e) {
|
|
1699
|
+
return !!(e && (e.scrollHeight > e.clientHeight + 1 || e.scrollWidth > e.clientWidth + 1) && getComputedStyle(e).overflow !== "hidden");
|
|
1700
|
+
}
|
|
1701
|
+
function Vr(e, t) {
|
|
1702
|
+
const r = Kr(t.entries, t), n = r.slice(-260);
|
|
1703
|
+
Ie(e.sections, t.entries, t.section, "section"), Ie(e.severities, t.entries, t.severity, "severity"), e.count && (e.count.textContent = String(t.entries.length)), e.visibleCount && (e.visibleCount.textContent = String(r.length)), Qr(e.stateView, hr(t.entries), t.stateVisible), Zr(e.list, n, t);
|
|
1704
|
+
}
|
|
1705
|
+
function Kr(e, t = {}) {
|
|
1706
|
+
const r = t.section || D, n = t.severity || se, o = tt(t.search);
|
|
1707
|
+
return (Array.isArray(e) ? e : []).filter((i) => r !== D && i.section !== r || n !== se && i.severity !== n ? !1 : o ? gn(i).includes(o) : !0);
|
|
1708
|
+
}
|
|
1709
|
+
function Ie(e, t, r, n) {
|
|
1710
|
+
if (!e) return;
|
|
1711
|
+
e.textContent = "";
|
|
1712
|
+
const o = n === "section" ? Jr(t) : Yr(t), i = document.createElement("button");
|
|
1713
|
+
i.type = "button", i.dataset[`${n}Filter`] = D, i.className = r === D ? "chip is-active" : "chip", i.textContent = `All ${t.length}`, e.appendChild(i);
|
|
1714
|
+
for (const a of o) {
|
|
1715
|
+
const s = t.filter((d) => d[n] === a).length, c = document.createElement("button");
|
|
1716
|
+
c.type = "button", c.dataset[`${n}Filter`] = a, c.className = r === a ? `chip is-active ${n}-${M(a)}` : `chip ${n}-${M(a)}`, c.textContent = `${ot(a)} ${s}`, e.appendChild(c);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
function Jr(e) {
|
|
1720
|
+
const t = new Set(e.map((r) => r.section).filter(Boolean));
|
|
1721
|
+
return Re.filter((r) => t.has(r)).concat([...t].filter((r) => !Re.includes(r)).sort());
|
|
1722
|
+
}
|
|
1723
|
+
function Yr(e) {
|
|
1724
|
+
const t = new Set(e.map((r) => r.severity).filter(Boolean));
|
|
1725
|
+
return Pe.filter((r) => t.has(r)).concat([...t].filter((r) => !Pe.includes(r)).sort());
|
|
1726
|
+
}
|
|
1727
|
+
function Zr(e, t, r) {
|
|
1728
|
+
if (!e) return;
|
|
1729
|
+
if (e.textContent = "", !t.length) {
|
|
1730
|
+
const o = document.createElement("div");
|
|
1731
|
+
o.className = "empty", o.textContent = r.entries.length ? "No activity matches the current filters." : "Waiting for agentic activity...", e.appendChild(o);
|
|
1732
|
+
return;
|
|
1733
|
+
}
|
|
1734
|
+
const n = document.createDocumentFragment();
|
|
1735
|
+
if (r.grouped) for (const o of un(t)) n.appendChild(dn(o));
|
|
1736
|
+
else for (const o of t) n.appendChild(et(o));
|
|
1737
|
+
e.appendChild(n), r.follow && requestAnimationFrame(() => e.scrollTop = e.scrollHeight);
|
|
1738
|
+
}
|
|
1739
|
+
function Qr(e, t, r) {
|
|
1740
|
+
if (!e || (e.textContent = "", e.classList.toggle("is-hidden", !r), !r)) return;
|
|
1741
|
+
const { flow: n, context: o } = t, i = document.createDocumentFragment();
|
|
1742
|
+
i.appendChild(Xr(n)), i.appendChild(en(o)), i.appendChild(tn(n.timeline)), e.appendChild(i);
|
|
1743
|
+
}
|
|
1744
|
+
function Xr(e) {
|
|
1745
|
+
const t = document.createElement("section");
|
|
1746
|
+
return t.className = `viz-card flow-card status-${M(e.status)}`, t.appendChild(ge("Flow State", e.status)), Xe(t, [
|
|
1747
|
+
["Current", e.current],
|
|
1748
|
+
["Session", e.sessionId],
|
|
1749
|
+
["Request", [e.requestType, e.actionType].filter(Boolean).join(" / ")],
|
|
1750
|
+
["Model", e.model],
|
|
1751
|
+
["Tools", e.tools?.join(", ")],
|
|
1752
|
+
["BE ops", e.beOps?.join(", ")],
|
|
1753
|
+
["UI", e.uiSurfaces?.join(", ")],
|
|
1754
|
+
["Health", rn(e)]
|
|
1755
|
+
]), t;
|
|
1756
|
+
}
|
|
1757
|
+
function en(e) {
|
|
1758
|
+
const t = document.createElement("section");
|
|
1759
|
+
return t.className = "viz-card context-card", t.appendChild(ge("Context State", e.panel?.screenType || e.ui?.rootType || "empty")), Xe(t, [
|
|
1760
|
+
["Intent", nn(e.intent)],
|
|
1761
|
+
["Route", on(e.route)],
|
|
1762
|
+
["Screen", an(e)],
|
|
1763
|
+
["Last search", sn(e.panel?.lastSearch)],
|
|
1764
|
+
["Products", cn(e.panel, e.products)],
|
|
1765
|
+
["Page product", ln(e.pageProduct)],
|
|
1766
|
+
["Extensions", Object.keys(e.threadExtensions || {}).join(", ")],
|
|
1767
|
+
["Last text", e.lastText]
|
|
1768
|
+
]), t;
|
|
1769
|
+
}
|
|
1770
|
+
function tn(e) {
|
|
1771
|
+
const t = document.createElement("section");
|
|
1772
|
+
t.className = "viz-card timeline-card", t.appendChild(ge("Flow Timeline", `${e.length} steps`));
|
|
1773
|
+
const r = document.createElement("ol");
|
|
1774
|
+
if (r.className = "timeline", e.length)
|
|
1775
|
+
for (const n of e) {
|
|
1776
|
+
const o = document.createElement("li");
|
|
1777
|
+
o.className = `timeline-step step-${M(n.status || "done")}`;
|
|
1778
|
+
const i = document.createElement("span");
|
|
1779
|
+
i.className = "timeline-time", i.textContent = nt(n.at);
|
|
1780
|
+
const a = document.createElement("span");
|
|
1781
|
+
a.className = "timeline-label", a.textContent = n.label || n.kind || "Step";
|
|
1782
|
+
const s = document.createElement("span");
|
|
1783
|
+
s.className = "timeline-detail", s.textContent = n.detail || n.kind || "", o.append(i, a, s), r.appendChild(o);
|
|
1784
|
+
}
|
|
1785
|
+
else {
|
|
1786
|
+
const n = document.createElement("li");
|
|
1787
|
+
n.className = "timeline-empty", n.textContent = "No flow events yet.", r.appendChild(n);
|
|
1788
|
+
}
|
|
1789
|
+
return t.appendChild(r), t;
|
|
1790
|
+
}
|
|
1791
|
+
function ge(e, t) {
|
|
1792
|
+
const r = document.createElement("div");
|
|
1793
|
+
r.className = "viz-title";
|
|
1794
|
+
const n = document.createElement("span");
|
|
1795
|
+
n.textContent = e;
|
|
1796
|
+
const o = document.createElement("span");
|
|
1797
|
+
return o.className = "viz-badge", o.textContent = t || "idle", r.append(n, o), r;
|
|
1798
|
+
}
|
|
1799
|
+
function Xe(e, t) {
|
|
1800
|
+
for (const [r, n] of t) {
|
|
1801
|
+
if (n == null || n === "") continue;
|
|
1802
|
+
const o = document.createElement("div");
|
|
1803
|
+
o.className = "viz-row";
|
|
1804
|
+
const i = document.createElement("span");
|
|
1805
|
+
i.className = "viz-key", i.textContent = r;
|
|
1806
|
+
const a = document.createElement("span");
|
|
1807
|
+
a.className = "viz-value", a.textContent = String(n), o.append(i, a), e.appendChild(o);
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
function rn(e) {
|
|
1811
|
+
return !e.errors && !e.warnings ? "clean" : `${e.errors || 0} errors, ${e.warnings || 0} warnings`;
|
|
1812
|
+
}
|
|
1813
|
+
function nn(e) {
|
|
1814
|
+
return e ? [
|
|
1815
|
+
e.kind,
|
|
1816
|
+
e.target,
|
|
1817
|
+
e.confidence != null ? `conf ${e.confidence}` : ""
|
|
1818
|
+
].filter(Boolean).join(" / ") : "";
|
|
1819
|
+
}
|
|
1820
|
+
function on(e) {
|
|
1821
|
+
return e ? [e.search ? [
|
|
1822
|
+
e.search.query,
|
|
1823
|
+
e.search.category,
|
|
1824
|
+
e.search.categoryId,
|
|
1825
|
+
e.search.facets ? `${e.search.facets} facets` : ""
|
|
1826
|
+
].filter(Boolean).join(" / ") : "", e.flow ? [
|
|
1827
|
+
e.flow.target,
|
|
1828
|
+
e.flow.sku,
|
|
1829
|
+
e.flow.skus?.join(", "),
|
|
1830
|
+
e.flow.action
|
|
1831
|
+
].filter(Boolean).join(" / ") : ""].filter(Boolean).join(" -> ") : "";
|
|
1832
|
+
}
|
|
1833
|
+
function an(e) {
|
|
1834
|
+
const t = e.panel || {}, r = e.ui || {};
|
|
1835
|
+
return [
|
|
1836
|
+
t.screenType,
|
|
1837
|
+
r.rootType,
|
|
1838
|
+
r.widget,
|
|
1839
|
+
r.panelHint
|
|
1840
|
+
].filter(Boolean).join(" / ");
|
|
1841
|
+
}
|
|
1842
|
+
function sn(e) {
|
|
1843
|
+
return e ? [
|
|
1844
|
+
e.query,
|
|
1845
|
+
e.source,
|
|
1846
|
+
e.category,
|
|
1847
|
+
e.count != null ? `${e.count} results` : ""
|
|
1848
|
+
].filter(Boolean).join(" / ") : "";
|
|
1849
|
+
}
|
|
1850
|
+
function cn(e, t) {
|
|
1851
|
+
const r = e?.productSkus || e?.screenSkus || t?.skus || [], n = e?.productCount ?? t?.count;
|
|
1852
|
+
return n == null && !r.length ? "" : [`${n ?? r.length} products`, r.join(", ")].filter(Boolean).join(" / ");
|
|
1853
|
+
}
|
|
1854
|
+
function ln(e) {
|
|
1855
|
+
return e ? [
|
|
1856
|
+
e.sku,
|
|
1857
|
+
e.name,
|
|
1858
|
+
e.category
|
|
1859
|
+
].filter(Boolean).join(" / ") : "";
|
|
1860
|
+
}
|
|
1861
|
+
function un(e) {
|
|
1862
|
+
const t = /* @__PURE__ */ new Map();
|
|
1863
|
+
for (const r of e) {
|
|
1864
|
+
const n = `${r.section || "Runtime"}:${r.group || r.kind}`, o = t.get(n) || {
|
|
1865
|
+
key: n,
|
|
1866
|
+
section: r.section || "Runtime",
|
|
1867
|
+
severity: r.severity || "info",
|
|
1868
|
+
title: r.group || r.kind,
|
|
1869
|
+
entries: []
|
|
1870
|
+
};
|
|
1871
|
+
o.entries.push(r), o.severity = mn(o.severity, r.severity), t.set(n, o);
|
|
1872
|
+
}
|
|
1873
|
+
return [...t.values()];
|
|
1874
|
+
}
|
|
1875
|
+
function dn(e) {
|
|
1876
|
+
const t = document.createElement("section");
|
|
1877
|
+
t.className = `group group-${M(e.severity)}`, t.dataset.section = e.section;
|
|
1878
|
+
const r = document.createElement("div");
|
|
1879
|
+
r.className = "group-head";
|
|
1880
|
+
const n = document.createElement("span");
|
|
1881
|
+
n.className = "section", n.textContent = e.section;
|
|
1882
|
+
const o = document.createElement("span");
|
|
1883
|
+
o.className = "group-title", o.textContent = e.title;
|
|
1884
|
+
const i = document.createElement("span");
|
|
1885
|
+
i.className = "group-count", i.textContent = String(e.entries.length), r.append(n, o, i), t.appendChild(r);
|
|
1886
|
+
for (const a of e.entries) t.appendChild(et(a));
|
|
1887
|
+
return t;
|
|
1888
|
+
}
|
|
1889
|
+
function et(e) {
|
|
1890
|
+
const t = document.createElement("details");
|
|
1891
|
+
t.dataset.entryId = String(e.id || ""), t.dataset.section = e.section || "Runtime", t.dataset.severity = e.severity || "info", t.className = `entry entry-${M(e.severity || "info")}`, t.open = e.severity === "error";
|
|
1892
|
+
const r = document.createElement("summary"), n = document.createElement("span");
|
|
1893
|
+
n.className = "time", n.textContent = nt(e.at);
|
|
1894
|
+
const o = document.createElement("span");
|
|
1895
|
+
o.className = "section", o.textContent = e.section || "Runtime";
|
|
1896
|
+
const i = document.createElement("span");
|
|
1897
|
+
i.className = "severity", i.textContent = ot(e.severity || "info");
|
|
1898
|
+
const a = document.createElement("span");
|
|
1899
|
+
a.className = "title", a.textContent = rt(e), r.append(n, o, i, a);
|
|
1900
|
+
const s = document.createElement("div");
|
|
1901
|
+
s.className = "entry-body";
|
|
1902
|
+
const c = document.createElement("div");
|
|
1903
|
+
c.className = "entry-toolbar";
|
|
1904
|
+
const d = document.createElement("span");
|
|
1905
|
+
d.className = "kind", d.textContent = e.kind;
|
|
1906
|
+
const f = document.createElement("span");
|
|
1907
|
+
f.className = "kind", f.textContent = e.group || "";
|
|
1908
|
+
const b = document.createElement("button");
|
|
1909
|
+
b.type = "button", b.dataset.action = "copy-json", b.dataset.entryId = String(e.id || ""), b.textContent = "Copy JSON", c.append(d, f, b);
|
|
1910
|
+
const m = document.createElement("pre"), l = document.createElement("code");
|
|
1911
|
+
return l.innerHTML = fn(e), m.appendChild(l), s.append(c, m), t.append(r, s), t;
|
|
1912
|
+
}
|
|
1913
|
+
function fn(e) {
|
|
1914
|
+
const t = he(e), r = /("(?:\\u[\da-fA-F]{4}|\\[^u]|[^\\"])*"(?:\s*:)?|\btrue\b|\bfalse\b|\bnull\b|-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)/gu;
|
|
1915
|
+
let n = "", o = 0;
|
|
1916
|
+
for (const i of t.matchAll(r)) {
|
|
1917
|
+
const a = i[0];
|
|
1918
|
+
n += G(t.slice(o, i.index));
|
|
1919
|
+
let s = "json-number";
|
|
1920
|
+
a.startsWith('"') ? s = a.endsWith(":") ? "json-key" : "json-string" : a === "true" || a === "false" ? s = "json-boolean" : a === "null" && (s = "json-null"), n += `<span class="${s}">${G(a)}</span>`, o = i.index + a.length;
|
|
1921
|
+
}
|
|
1922
|
+
return n + G(t.slice(o));
|
|
1923
|
+
}
|
|
1924
|
+
function pn(e, t) {
|
|
1925
|
+
if (!e) return;
|
|
1926
|
+
const r = he(e), n = () => {
|
|
1927
|
+
const o = t.textContent;
|
|
1928
|
+
t.textContent = "Copied", setTimeout(() => {
|
|
1929
|
+
t.textContent = o;
|
|
1930
|
+
}, 900);
|
|
1931
|
+
};
|
|
1932
|
+
if (navigator.clipboard?.writeText) {
|
|
1933
|
+
navigator.clipboard.writeText(r).then(n).catch(() => Ue(r, n));
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1936
|
+
Ue(r, n);
|
|
1937
|
+
}
|
|
1938
|
+
function Ue(e, t) {
|
|
1939
|
+
const r = document.createElement("textarea");
|
|
1940
|
+
r.value = e, r.style.cssText = "position:fixed;left:-9999px;top:-9999px;", document.body.appendChild(r), r.select();
|
|
1941
|
+
try {
|
|
1942
|
+
document.execCommand("copy"), t();
|
|
1943
|
+
} finally {
|
|
1944
|
+
r.remove();
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
function mn(e, t) {
|
|
1948
|
+
const r = {
|
|
1949
|
+
info: 0,
|
|
1950
|
+
warn: 1,
|
|
1951
|
+
error: 2
|
|
1952
|
+
};
|
|
1953
|
+
return (r[t] || 0) > (r[e] || 0) ? t : e;
|
|
1954
|
+
}
|
|
1955
|
+
function gn(e) {
|
|
1956
|
+
return tt([
|
|
1957
|
+
e.kind,
|
|
1958
|
+
e.section,
|
|
1959
|
+
e.severity,
|
|
1960
|
+
e.group,
|
|
1961
|
+
rt(e),
|
|
1962
|
+
e.tool,
|
|
1963
|
+
e.op,
|
|
1964
|
+
e.request?.type,
|
|
1965
|
+
e.request?.action?.type,
|
|
1966
|
+
e.event?.name,
|
|
1967
|
+
e.event?.action,
|
|
1968
|
+
e.event?.type,
|
|
1969
|
+
he(e)
|
|
1970
|
+
].join(" "));
|
|
1971
|
+
}
|
|
1972
|
+
function tt(e) {
|
|
1973
|
+
return String(e || "").toLocaleLowerCase("tr-TR").trim();
|
|
1974
|
+
}
|
|
1975
|
+
function rt(e) {
|
|
1976
|
+
if (e.kind === "flow/request") return e.request?.type || e.request?.action?.type || "request";
|
|
1977
|
+
if (e.kind === "flow/action") return e.event?.name || e.event?.action || e.event?.type || "action";
|
|
1978
|
+
if (e.kind === "flow/metadata") return e.event?.name || e.event?.phase || e.event?.type || "metadata";
|
|
1979
|
+
if (e.kind === "flow/ui") return e.widget || e.panelHint || "ui";
|
|
1980
|
+
if (e.kind === "flow/text-final") return bn(e.content || "final text", 90);
|
|
1981
|
+
if (e.kind === "be/request") return e.op || "BE request";
|
|
1982
|
+
if (e.kind === "be/response") {
|
|
1983
|
+
const t = e.result?.intent?.kind || e.result?.intent_kind || e.result?.kind;
|
|
1984
|
+
return t ? `intent selected: ${t}` : e.op || "BE response";
|
|
1985
|
+
}
|
|
1986
|
+
return e.kind === "intent/selected" ? e.intent?.kind || e.kind : e.kind.startsWith("tool/") ? e.tool || "tool" : e.kind === "beacon" ? e.payload?.type || "beacon" : e.title || e.kind;
|
|
1987
|
+
}
|
|
1988
|
+
function hn(e) {
|
|
1989
|
+
return `
|
|
1990
|
+
<style>
|
|
1991
|
+
:host { all: initial; }
|
|
1992
|
+
.panel {
|
|
1993
|
+
width: 560px;
|
|
1994
|
+
max-width: calc(100vw - 20px);
|
|
1995
|
+
max-height: min(82vh, 820px);
|
|
1996
|
+
display: flex;
|
|
1997
|
+
flex-direction: column;
|
|
1998
|
+
overflow: hidden;
|
|
1999
|
+
color: #1f2937;
|
|
2000
|
+
background: rgba(255, 255, 255, 0.98);
|
|
2001
|
+
border: 1px solid #b8c2d2;
|
|
2002
|
+
border-radius: 8px;
|
|
2003
|
+
box-shadow: 0 18px 48px rgba(17, 24, 39, 0.24);
|
|
2004
|
+
font: 12px/1.4 Inter, Arial, sans-serif;
|
|
2005
|
+
}
|
|
2006
|
+
.head {
|
|
2007
|
+
display: flex;
|
|
2008
|
+
align-items: center;
|
|
2009
|
+
justify-content: space-between;
|
|
2010
|
+
gap: 10px;
|
|
2011
|
+
padding: 9px 10px;
|
|
2012
|
+
background: #111827;
|
|
2013
|
+
color: #fff;
|
|
2014
|
+
font-weight: 700;
|
|
2015
|
+
}
|
|
2016
|
+
.meta { display: flex; gap: 7px; align-items: center; min-width: 0; }
|
|
2017
|
+
.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2018
|
+
.count { color: #d1d5db; font-weight: 600; white-space: nowrap; }
|
|
2019
|
+
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
|
|
2020
|
+
button {
|
|
2021
|
+
appearance: none;
|
|
2022
|
+
border: 1px solid rgba(255,255,255,0.34);
|
|
2023
|
+
border-radius: 5px;
|
|
2024
|
+
background: rgba(255,255,255,0.12);
|
|
2025
|
+
color: inherit;
|
|
2026
|
+
padding: 3px 7px;
|
|
2027
|
+
font: inherit;
|
|
2028
|
+
cursor: pointer;
|
|
2029
|
+
}
|
|
2030
|
+
button:hover { filter: brightness(1.08); }
|
|
2031
|
+
.controls {
|
|
2032
|
+
display: grid;
|
|
2033
|
+
gap: 7px;
|
|
2034
|
+
padding: 8px;
|
|
2035
|
+
background: #f8fafc;
|
|
2036
|
+
border-bottom: 1px solid #d9dee7;
|
|
2037
|
+
}
|
|
2038
|
+
.search {
|
|
2039
|
+
width: 100%;
|
|
2040
|
+
box-sizing: border-box;
|
|
2041
|
+
border: 1px solid #cbd5e1;
|
|
2042
|
+
border-radius: 6px;
|
|
2043
|
+
background: #fff;
|
|
2044
|
+
color: #111827;
|
|
2045
|
+
padding: 6px 8px;
|
|
2046
|
+
font: inherit;
|
|
2047
|
+
}
|
|
2048
|
+
.filters, .toggles {
|
|
2049
|
+
display: flex;
|
|
2050
|
+
flex-wrap: wrap;
|
|
2051
|
+
gap: 5px;
|
|
2052
|
+
align-items: center;
|
|
2053
|
+
}
|
|
2054
|
+
.chip, .toggles button {
|
|
2055
|
+
color: #334155;
|
|
2056
|
+
border-color: #cbd5e1;
|
|
2057
|
+
background: #fff;
|
|
2058
|
+
font-weight: 650;
|
|
2059
|
+
}
|
|
2060
|
+
.chip.is-active, .toggles button[aria-pressed="true"] {
|
|
2061
|
+
background: #111827;
|
|
2062
|
+
border-color: #111827;
|
|
2063
|
+
color: #fff;
|
|
2064
|
+
}
|
|
2065
|
+
.section-flow { border-color: #38bdf8; }
|
|
2066
|
+
.section-tools { border-color: #34d399; }
|
|
2067
|
+
.section-backend { border-color: #fb923c; }
|
|
2068
|
+
.section-intent { border-color: #a78bfa; }
|
|
2069
|
+
.section-telemetry { border-color: #2dd4bf; }
|
|
2070
|
+
.severity-warn { border-color: #f59e0b; }
|
|
2071
|
+
.severity-error { border-color: #ef4444; }
|
|
2072
|
+
.list {
|
|
2073
|
+
flex: 1 1 auto;
|
|
2074
|
+
min-height: 0;
|
|
2075
|
+
overflow: auto;
|
|
2076
|
+
overscroll-behavior: contain;
|
|
2077
|
+
touch-action: pan-x pan-y;
|
|
2078
|
+
padding: 8px;
|
|
2079
|
+
background: #f1f5f9;
|
|
2080
|
+
}
|
|
2081
|
+
.state-view {
|
|
2082
|
+
display: grid;
|
|
2083
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
2084
|
+
gap: 8px;
|
|
2085
|
+
padding: 8px;
|
|
2086
|
+
background: #eef4fb;
|
|
2087
|
+
border-bottom: 1px solid #d9dee7;
|
|
2088
|
+
max-height: 280px;
|
|
2089
|
+
overflow: auto;
|
|
2090
|
+
overscroll-behavior: contain;
|
|
2091
|
+
}
|
|
2092
|
+
.state-view.is-hidden { display: none; }
|
|
2093
|
+
.viz-card {
|
|
2094
|
+
min-width: 0;
|
|
2095
|
+
border: 1px solid #cbd5e1;
|
|
2096
|
+
border-radius: 7px;
|
|
2097
|
+
background: #fff;
|
|
2098
|
+
overflow: hidden;
|
|
2099
|
+
}
|
|
2100
|
+
.timeline-card { grid-column: 1 / -1; }
|
|
2101
|
+
.viz-title {
|
|
2102
|
+
display: flex;
|
|
2103
|
+
justify-content: space-between;
|
|
2104
|
+
gap: 8px;
|
|
2105
|
+
align-items: center;
|
|
2106
|
+
padding: 6px 8px;
|
|
2107
|
+
background: #e2e8f0;
|
|
2108
|
+
color: #172033;
|
|
2109
|
+
font-weight: 800;
|
|
2110
|
+
}
|
|
2111
|
+
.viz-badge {
|
|
2112
|
+
max-width: 48%;
|
|
2113
|
+
overflow: hidden;
|
|
2114
|
+
text-overflow: ellipsis;
|
|
2115
|
+
white-space: nowrap;
|
|
2116
|
+
padding: 1px 6px;
|
|
2117
|
+
border-radius: 999px;
|
|
2118
|
+
background: #fff;
|
|
2119
|
+
border: 1px solid #cbd5e1;
|
|
2120
|
+
color: #475569;
|
|
2121
|
+
font-weight: 750;
|
|
2122
|
+
}
|
|
2123
|
+
.status-running .viz-title { background: #dbeafe; }
|
|
2124
|
+
.status-done .viz-title { background: #dcfce7; }
|
|
2125
|
+
.status-error .viz-title { background: #fee2e2; }
|
|
2126
|
+
.viz-row {
|
|
2127
|
+
display: grid;
|
|
2128
|
+
grid-template-columns: 82px minmax(0, 1fr);
|
|
2129
|
+
gap: 6px;
|
|
2130
|
+
padding: 5px 8px;
|
|
2131
|
+
border-top: 1px solid #eef2f7;
|
|
2132
|
+
}
|
|
2133
|
+
.viz-key {
|
|
2134
|
+
color: #64748b;
|
|
2135
|
+
font-weight: 750;
|
|
2136
|
+
}
|
|
2137
|
+
.viz-value {
|
|
2138
|
+
color: #111827;
|
|
2139
|
+
overflow: hidden;
|
|
2140
|
+
text-overflow: ellipsis;
|
|
2141
|
+
white-space: nowrap;
|
|
2142
|
+
}
|
|
2143
|
+
.timeline {
|
|
2144
|
+
list-style: none;
|
|
2145
|
+
margin: 0;
|
|
2146
|
+
padding: 0;
|
|
2147
|
+
max-height: 122px;
|
|
2148
|
+
overflow: auto;
|
|
2149
|
+
}
|
|
2150
|
+
.timeline-step, .timeline-empty {
|
|
2151
|
+
display: grid;
|
|
2152
|
+
grid-template-columns: 70px 70px minmax(0, 1fr);
|
|
2153
|
+
gap: 7px;
|
|
2154
|
+
align-items: center;
|
|
2155
|
+
padding: 5px 8px;
|
|
2156
|
+
border-top: 1px solid #eef2f7;
|
|
2157
|
+
}
|
|
2158
|
+
.timeline-time {
|
|
2159
|
+
color: #64748b;
|
|
2160
|
+
font-variant-numeric: tabular-nums;
|
|
2161
|
+
}
|
|
2162
|
+
.timeline-label {
|
|
2163
|
+
width: fit-content;
|
|
2164
|
+
max-width: 70px;
|
|
2165
|
+
overflow: hidden;
|
|
2166
|
+
text-overflow: ellipsis;
|
|
2167
|
+
white-space: nowrap;
|
|
2168
|
+
border-radius: 999px;
|
|
2169
|
+
padding: 1px 6px;
|
|
2170
|
+
background: #e2e8f0;
|
|
2171
|
+
color: #334155;
|
|
2172
|
+
font-weight: 750;
|
|
2173
|
+
}
|
|
2174
|
+
.timeline-detail {
|
|
2175
|
+
min-width: 0;
|
|
2176
|
+
overflow: hidden;
|
|
2177
|
+
text-overflow: ellipsis;
|
|
2178
|
+
white-space: nowrap;
|
|
2179
|
+
}
|
|
2180
|
+
.step-running .timeline-label { background: #dbeafe; color: #1d4ed8; }
|
|
2181
|
+
.step-warn .timeline-label { background: #fef3c7; color: #92400e; }
|
|
2182
|
+
.step-error .timeline-label { background: #fee2e2; color: #991b1b; }
|
|
2183
|
+
.empty { color: #64748b; padding: 10px; }
|
|
2184
|
+
.group {
|
|
2185
|
+
border: 1px solid #d6dce6;
|
|
2186
|
+
border-radius: 7px;
|
|
2187
|
+
margin: 0 0 8px;
|
|
2188
|
+
background: #fff;
|
|
2189
|
+
overflow: hidden;
|
|
2190
|
+
}
|
|
2191
|
+
.group-head {
|
|
2192
|
+
display: grid;
|
|
2193
|
+
grid-template-columns: auto minmax(0, 1fr) auto;
|
|
2194
|
+
gap: 7px;
|
|
2195
|
+
align-items: center;
|
|
2196
|
+
padding: 6px 7px;
|
|
2197
|
+
background: #e9eef6;
|
|
2198
|
+
border-bottom: 1px solid #d6dce6;
|
|
2199
|
+
font-weight: 750;
|
|
2200
|
+
}
|
|
2201
|
+
.group-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2202
|
+
.group-count {
|
|
2203
|
+
min-width: 20px;
|
|
2204
|
+
text-align: center;
|
|
2205
|
+
color: #475569;
|
|
2206
|
+
background: #fff;
|
|
2207
|
+
border: 1px solid #cbd5e1;
|
|
2208
|
+
border-radius: 999px;
|
|
2209
|
+
padding: 1px 6px;
|
|
2210
|
+
}
|
|
2211
|
+
details.entry {
|
|
2212
|
+
border: 1px solid #d6dce6;
|
|
2213
|
+
border-left-width: 4px;
|
|
2214
|
+
border-radius: 6px;
|
|
2215
|
+
margin: 0 0 7px;
|
|
2216
|
+
background: #fff;
|
|
2217
|
+
overflow: hidden;
|
|
2218
|
+
}
|
|
2219
|
+
.group details.entry {
|
|
2220
|
+
border-left-width: 4px;
|
|
2221
|
+
border-right-width: 0;
|
|
2222
|
+
border-bottom-width: 0;
|
|
2223
|
+
border-radius: 0;
|
|
2224
|
+
margin: 0;
|
|
2225
|
+
}
|
|
2226
|
+
details[data-severity="info"] { border-left-color: #64748b; }
|
|
2227
|
+
details[data-severity="warn"] { border-left-color: #f59e0b; }
|
|
2228
|
+
details[data-severity="error"] { border-left-color: #ef4444; }
|
|
2229
|
+
summary {
|
|
2230
|
+
cursor: pointer;
|
|
2231
|
+
padding: 7px 8px;
|
|
2232
|
+
display: grid;
|
|
2233
|
+
grid-template-columns: 70px 86px 54px minmax(0, 1fr);
|
|
2234
|
+
gap: 7px;
|
|
2235
|
+
align-items: center;
|
|
2236
|
+
color: #1f2937;
|
|
2237
|
+
}
|
|
2238
|
+
.time { color: #64748b; font-variant-numeric: tabular-nums; }
|
|
2239
|
+
.section, .severity {
|
|
2240
|
+
width: fit-content;
|
|
2241
|
+
max-width: 86px;
|
|
2242
|
+
overflow: hidden;
|
|
2243
|
+
text-overflow: ellipsis;
|
|
2244
|
+
white-space: nowrap;
|
|
2245
|
+
padding: 2px 6px;
|
|
2246
|
+
border-radius: 999px;
|
|
2247
|
+
background: #eef2f7;
|
|
2248
|
+
color: #334155;
|
|
2249
|
+
font-weight: 750;
|
|
2250
|
+
}
|
|
2251
|
+
[data-section="Flow"] .section { background: #e0f2fe; color: #075985; }
|
|
2252
|
+
[data-section="Tools"] .section { background: #dcfce7; color: #166534; }
|
|
2253
|
+
[data-section="Backend"] .section { background: #ffedd5; color: #9a3412; }
|
|
2254
|
+
[data-section="Intent"] .section { background: #ede9fe; color: #5b21b6; }
|
|
2255
|
+
[data-section="Telemetry"] .section { background: #ccfbf1; color: #115e59; }
|
|
2256
|
+
[data-severity="info"] .severity { background: #e2e8f0; color: #334155; }
|
|
2257
|
+
[data-severity="warn"] .severity { background: #fef3c7; color: #92400e; }
|
|
2258
|
+
[data-severity="error"] .severity { background: #fee2e2; color: #991b1b; }
|
|
2259
|
+
.title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
2260
|
+
.entry-body { border-top: 1px solid #d6dce6; background: #0b1020; }
|
|
2261
|
+
.entry-toolbar {
|
|
2262
|
+
display: flex;
|
|
2263
|
+
gap: 6px;
|
|
2264
|
+
align-items: center;
|
|
2265
|
+
padding: 6px 8px;
|
|
2266
|
+
color: #dbeafe;
|
|
2267
|
+
border-bottom: 1px solid rgba(148, 163, 184, 0.32);
|
|
2268
|
+
}
|
|
2269
|
+
.kind {
|
|
2270
|
+
overflow: hidden;
|
|
2271
|
+
text-overflow: ellipsis;
|
|
2272
|
+
white-space: nowrap;
|
|
2273
|
+
border: 1px solid rgba(148, 163, 184, 0.38);
|
|
2274
|
+
border-radius: 999px;
|
|
2275
|
+
padding: 2px 6px;
|
|
2276
|
+
}
|
|
2277
|
+
.entry-toolbar button {
|
|
2278
|
+
margin-left: auto;
|
|
2279
|
+
color: #e5e7eb;
|
|
2280
|
+
border-color: rgba(148, 163, 184, 0.42);
|
|
2281
|
+
background: rgba(255,255,255,0.08);
|
|
2282
|
+
}
|
|
2283
|
+
pre {
|
|
2284
|
+
margin: 0;
|
|
2285
|
+
padding: 8px;
|
|
2286
|
+
max-height: 430px;
|
|
2287
|
+
overflow: auto;
|
|
2288
|
+
overscroll-behavior: contain;
|
|
2289
|
+
touch-action: pan-x pan-y;
|
|
2290
|
+
color: #dbeafe;
|
|
2291
|
+
font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
2292
|
+
white-space: pre-wrap;
|
|
2293
|
+
word-break: break-word;
|
|
2294
|
+
}
|
|
2295
|
+
.json-key { color: #93c5fd; }
|
|
2296
|
+
.json-string { color: #86efac; }
|
|
2297
|
+
.json-number { color: #fbbf24; }
|
|
2298
|
+
.json-boolean { color: #f0abfc; }
|
|
2299
|
+
.json-null { color: #cbd5e1; }
|
|
2300
|
+
.is-minimized .controls, .is-minimized .list { display: none; }
|
|
2301
|
+
.is-minimized .state-view { display: none; }
|
|
2302
|
+
@media (max-width: 620px) {
|
|
2303
|
+
.panel { width: calc(100vw - 20px); }
|
|
2304
|
+
.state-view { grid-template-columns: 1fr; max-height: 240px; }
|
|
2305
|
+
summary { grid-template-columns: 62px 76px 50px minmax(0, 1fr); }
|
|
2306
|
+
}
|
|
2307
|
+
</style>
|
|
2308
|
+
<div class="panel" data-role="panel">
|
|
2309
|
+
<div class="head">
|
|
2310
|
+
<div class="meta">
|
|
2311
|
+
<span class="name">Agentic Activity - ${G(e)}</span>
|
|
2312
|
+
<span class="count"><span data-role="visible-count">0</span>/<span data-role="count">0</span></span>
|
|
2313
|
+
</div>
|
|
2314
|
+
<div class="actions">
|
|
2315
|
+
<button type="button" data-action="clear">Clear</button>
|
|
2316
|
+
<button type="button" data-action="toggle">Min</button>
|
|
2317
|
+
</div>
|
|
2318
|
+
</div>
|
|
2319
|
+
<div class="controls">
|
|
2320
|
+
<input class="search" type="search" data-role="search" placeholder="Filter by tool, op, kind, title, or JSON value" />
|
|
2321
|
+
<div class="filters" data-role="section-filters"></div>
|
|
2322
|
+
<div class="filters" data-role="severity-filters"></div>
|
|
2323
|
+
<div class="toggles">
|
|
2324
|
+
<button type="button" data-action="state" aria-pressed="true">State</button>
|
|
2325
|
+
<button type="button" data-action="group" aria-pressed="true">Grouped</button>
|
|
2326
|
+
<button type="button" data-action="follow" aria-pressed="true">Follow</button>
|
|
2327
|
+
<button type="button" data-action="expand-all">Expand all</button>
|
|
2328
|
+
<button type="button" data-action="collapse-all">Collapse all</button>
|
|
2329
|
+
</div>
|
|
2330
|
+
</div>
|
|
2331
|
+
<div class="state-view" data-role="state-view"></div>
|
|
2332
|
+
<div class="list" data-role="list"></div>
|
|
2333
|
+
</div>
|
|
2334
|
+
`;
|
|
2335
|
+
}
|
|
2336
|
+
function he(e) {
|
|
2337
|
+
try {
|
|
2338
|
+
return JSON.stringify(e, null, 2);
|
|
2339
|
+
} catch {
|
|
2340
|
+
return String(e);
|
|
2341
|
+
}
|
|
2342
|
+
}
|
|
2343
|
+
function nt(e) {
|
|
2344
|
+
try {
|
|
2345
|
+
return new Date(e || Date.now()).toLocaleTimeString();
|
|
2346
|
+
} catch {
|
|
2347
|
+
return "";
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
function bn(e, t) {
|
|
2351
|
+
const r = String(e || "");
|
|
2352
|
+
return r.length > t ? `${r.slice(0, t - 1)}...` : r;
|
|
2353
|
+
}
|
|
2354
|
+
function ot(e) {
|
|
2355
|
+
const t = String(e || "");
|
|
2356
|
+
return t ? `${t.slice(0, 1).toLocaleUpperCase("en-US")}${t.slice(1)}` : "";
|
|
2357
|
+
}
|
|
2358
|
+
function M(e) {
|
|
2359
|
+
return String(e || "").toLocaleLowerCase("en-US").replace(/[^a-z0-9]+/gu, "-").replace(/^-|-$/gu, "");
|
|
2360
|
+
}
|
|
2361
|
+
function G(e) {
|
|
2362
|
+
return String(e).replace(/[&<>"']/gu, (t) => t === "&" ? "&" : t === "<" ? "<" : t === ">" ? ">" : t === '"' ? """ : "'");
|
|
2363
|
+
}
|
|
2364
|
+
function Ni({ accountId: e, config: t = {}, tools: r, beacon: n } = {}) {
|
|
2365
|
+
if (!yn(e, t)) return {
|
|
2366
|
+
enabled: !1,
|
|
2367
|
+
tools: r,
|
|
2368
|
+
beacon: n,
|
|
2369
|
+
record() {
|
|
2370
|
+
},
|
|
2371
|
+
wrapTransport() {
|
|
2372
|
+
}
|
|
2373
|
+
};
|
|
2374
|
+
const o = ur(e);
|
|
2375
|
+
return window.__GENGAGE_AGENTIC_DEBUG_RECORD_BE__ = (i) => Ur(o, i), Gr(o), jr({
|
|
2376
|
+
accountId: e,
|
|
2377
|
+
collector: o,
|
|
2378
|
+
promptBaseUrl: t.agenticActivityPromptBaseUrl
|
|
2379
|
+
}), o.record({
|
|
2380
|
+
kind: "runtime/debug-enabled",
|
|
2381
|
+
title: "Agentic activity debug enabled"
|
|
2382
|
+
}), {
|
|
2383
|
+
enabled: !0,
|
|
2384
|
+
collector: o,
|
|
2385
|
+
tools: Lr(r, o),
|
|
2386
|
+
beacon: Rr(n, o),
|
|
2387
|
+
record: (i) => o.record(i),
|
|
2388
|
+
wrapTransport: () => Pr(e, o)
|
|
2389
|
+
};
|
|
2390
|
+
}
|
|
2391
|
+
function yn(e, t = {}) {
|
|
2392
|
+
return t.agenticActivityDebug === !1 ? !1 : t.agenticActivityDebug === !0 || window.__GENGAGE_PWTEST_ACCOUNT__ === e || window.__GENGAGE_AGENTIC_ACTIVITY_DEBUG__ === !0 ? !0 : !!(t.debug === !0 && wn(e));
|
|
2393
|
+
}
|
|
2394
|
+
function wn(e) {
|
|
2395
|
+
return Array.from(document.scripts || []).some((t) => {
|
|
2396
|
+
const r = t?.src || "";
|
|
2397
|
+
return r.includes(`/${e}/glov.js`) && /[?&]pwtest=/u.test(r);
|
|
2398
|
+
});
|
|
2399
|
+
}
|
|
2400
|
+
var vn = [
|
|
2401
|
+
"sku",
|
|
2402
|
+
"group_id",
|
|
2403
|
+
"name",
|
|
2404
|
+
"brand",
|
|
2405
|
+
"rating",
|
|
2406
|
+
"review_count",
|
|
2407
|
+
"cart_code",
|
|
2408
|
+
"images",
|
|
2409
|
+
"price_currency",
|
|
2410
|
+
"price",
|
|
2411
|
+
"price_discounted",
|
|
2412
|
+
"discount_reason",
|
|
2413
|
+
"url",
|
|
2414
|
+
"category_ids",
|
|
2415
|
+
"category_names",
|
|
2416
|
+
"facet_hits",
|
|
2417
|
+
"in_stock",
|
|
2418
|
+
"promotions",
|
|
2419
|
+
"variants"
|
|
2420
|
+
], xn = [
|
|
2421
|
+
"description",
|
|
2422
|
+
"description_html",
|
|
2423
|
+
"features",
|
|
2424
|
+
"service",
|
|
2425
|
+
"sellers",
|
|
2426
|
+
"reviews",
|
|
2427
|
+
"qna",
|
|
2428
|
+
"documents",
|
|
2429
|
+
"delivery",
|
|
2430
|
+
"payment"
|
|
2431
|
+
], kn = [
|
|
2432
|
+
"accountId",
|
|
2433
|
+
"query",
|
|
2434
|
+
"products",
|
|
2435
|
+
"pendingProducts",
|
|
2436
|
+
"rankedSkus",
|
|
2437
|
+
"facets",
|
|
2438
|
+
"facetsUsed",
|
|
2439
|
+
"available_facets",
|
|
2440
|
+
"logs",
|
|
2441
|
+
"meta"
|
|
2442
|
+
], Sn = [
|
|
2443
|
+
"source",
|
|
2444
|
+
"sourceType",
|
|
2445
|
+
"sourceProfile",
|
|
2446
|
+
"products",
|
|
2447
|
+
"queries",
|
|
2448
|
+
"logs"
|
|
2449
|
+
], _n = [
|
|
2450
|
+
"items",
|
|
2451
|
+
"kind",
|
|
2452
|
+
"label",
|
|
2453
|
+
"href",
|
|
2454
|
+
"count",
|
|
2455
|
+
"privacy"
|
|
2456
|
+
];
|
|
2457
|
+
function Mi({ accountId: e, search: t, facetedSearch: r, similaritySearch: n, searchGiftOptions: o, filters: i = {}, resultContract: a = {}, limitations: s = [], extraTools: c = [] } = {}) {
|
|
2458
|
+
return {
|
|
2459
|
+
searchKeyword: async (f = {}, b = {}) => t(En(f, b)),
|
|
2460
|
+
facetedSearch: typeof r == "function" ? (f = {}, b = {}) => r(qe(f, b)) : async (f = {}, b = {}) => t(qe(f, b)),
|
|
2461
|
+
getSearchCapabilities: () => Tn({
|
|
2462
|
+
accountId: e,
|
|
2463
|
+
hasSimilarity: typeof n == "function",
|
|
2464
|
+
hasGiftSearch: typeof o == "function",
|
|
2465
|
+
filters: i,
|
|
2466
|
+
resultContract: a,
|
|
2467
|
+
limitations: s,
|
|
2468
|
+
extraTools: c
|
|
2469
|
+
})
|
|
2470
|
+
};
|
|
2471
|
+
}
|
|
2472
|
+
function Tn({ accountId: e, hasSimilarity: t = !0, hasGiftSearch: r = !1, filters: n = {}, resultContract: o = {}, limitations: i = [], extraTools: a = [] } = {}) {
|
|
2473
|
+
return {
|
|
2474
|
+
accountId: e,
|
|
2475
|
+
tools: Cn([
|
|
2476
|
+
"search",
|
|
2477
|
+
"searchKeyword",
|
|
2478
|
+
"facetedSearch",
|
|
2479
|
+
r ? "searchGiftOptions" : "",
|
|
2480
|
+
t ? "similaritySearch" : "",
|
|
2481
|
+
"scanSite",
|
|
2482
|
+
"siteGrep",
|
|
2483
|
+
"discoverSiteContent",
|
|
2484
|
+
"runSiteCommand",
|
|
2485
|
+
"describeVisualContext",
|
|
2486
|
+
"inspectProductSurface",
|
|
2487
|
+
"openProductPage",
|
|
2488
|
+
...a
|
|
2489
|
+
].filter(Boolean)),
|
|
2490
|
+
filters: {
|
|
2491
|
+
query: "LLM-selected merchant search phrase or empty string when structured metadata is enough.",
|
|
2492
|
+
categoryId: "Optional native merchant category id selected from account metadata or visible page state.",
|
|
2493
|
+
categoryName: "Optional shopper-facing category label selected by the LLM/router.",
|
|
2494
|
+
categoryHints: "Optional category hints supplied by the LLM/router.",
|
|
2495
|
+
brandHints: "Optional brand hints supplied by the LLM/router.",
|
|
2496
|
+
featureHints: "Optional feature, material, style, size, compatibility, or project hints supplied by the LLM/router.",
|
|
2497
|
+
facets: "Optional structured facet array of { key, value } selected from route payloads or merchant metadata.",
|
|
2498
|
+
facetParams: "Optional native account facet map selected from account metadata.",
|
|
2499
|
+
priceMin: "Optional numeric lower price bound.",
|
|
2500
|
+
priceMax: "Optional numeric upper price bound.",
|
|
2501
|
+
...n
|
|
2502
|
+
},
|
|
2503
|
+
resultContract: {
|
|
2504
|
+
productItemFields: vn,
|
|
2505
|
+
productDetailFields: xn,
|
|
2506
|
+
searchResultFields: kn,
|
|
2507
|
+
similarityResultFields: Sn,
|
|
2508
|
+
siteContentFields: _n,
|
|
2509
|
+
...o
|
|
2510
|
+
},
|
|
2511
|
+
privacy: [
|
|
2512
|
+
"Runs in the shopper browser with merchant-origin state.",
|
|
2513
|
+
"Does not expose raw HTML, cookies, storage, cart/session tokens, CSRF values, or form values.",
|
|
2514
|
+
"Returns compact product, content, and visible-page facts only.",
|
|
2515
|
+
"Free-text intent and search planning stay LLM-owned; runtime wrappers only forward structured inputs."
|
|
2516
|
+
],
|
|
2517
|
+
limitations: i
|
|
2518
|
+
};
|
|
2519
|
+
}
|
|
2520
|
+
function En(e, t) {
|
|
2521
|
+
return ce(typeof e == "string" ? {
|
|
2522
|
+
...t,
|
|
2523
|
+
query: e
|
|
2524
|
+
} : {
|
|
2525
|
+
...t,
|
|
2526
|
+
...e || {}
|
|
2527
|
+
});
|
|
2528
|
+
}
|
|
2529
|
+
function qe(e, t) {
|
|
2530
|
+
const r = typeof e == "string" ? { query: e } : e || {}, n = r.query ?? t.query ?? "", o = ce({
|
|
2531
|
+
...t,
|
|
2532
|
+
...r,
|
|
2533
|
+
query: n,
|
|
2534
|
+
categoryId: r.categoryId ?? r.category_id ?? t.categoryId ?? t.category_id,
|
|
2535
|
+
categoryName: r.categoryName ?? r.category_name ?? t.categoryName ?? t.category_name,
|
|
2536
|
+
facets: r.facets ?? t.facets,
|
|
2537
|
+
facetParams: r.facetParams ?? r.facet_params ?? t.facetParams ?? t.facet_params,
|
|
2538
|
+
priceMin: r.priceMin ?? r.price_min ?? r.budgetMin ?? r.min_budget ?? t.priceMin,
|
|
2539
|
+
priceMax: r.priceMax ?? r.price_max ?? r.budgetMax ?? r.max_budget ?? t.priceMax,
|
|
2540
|
+
limit: r.limit ?? r.pageSize ?? t.limit ?? t.pageSize
|
|
2541
|
+
});
|
|
2542
|
+
return n === "" && (o.query = ""), o;
|
|
2543
|
+
}
|
|
2544
|
+
function Cn(e) {
|
|
2545
|
+
const t = /* @__PURE__ */ new Set();
|
|
2546
|
+
return e.filter((r) => {
|
|
2547
|
+
const n = String(r || "");
|
|
2548
|
+
return !n || t.has(n) ? !1 : (t.add(n), !0);
|
|
2549
|
+
});
|
|
2550
|
+
}
|
|
2551
|
+
function ce(e) {
|
|
2552
|
+
return Object.fromEntries(Object.entries(e || {}).filter(([, t]) => t != null && t !== "" && (!Array.isArray(t) || t.length)));
|
|
2553
|
+
}
|
|
2554
|
+
var An = 15e3, Ln = "glov_agentic_iframe", Rn = "position:absolute;width:1px;height:1px;left:-9999px;top:-9999px;opacity:0;pointer-events:none;";
|
|
2555
|
+
function Fi({ markerParam: e = Ln, markerValue: t = "agentic-scraper", frameName: r = t, sandbox: n = "allow-same-origin", timeoutMs: o = An, hiddenStyle: i = Rn, messageType: a, parser: s, isBlockedDocument: c } = {}) {
|
|
2556
|
+
const d = a || `gengage:agentic-iframe-scraper:${t}`;
|
|
2557
|
+
function f(p, g = {}) {
|
|
2558
|
+
const u = new URL(String(p), re());
|
|
2559
|
+
for (const [h, w] of Object.entries(g || {})) w != null && w !== "" && u.searchParams.set(h, String(w));
|
|
2560
|
+
return u.searchParams.set(e, t), u.href;
|
|
2561
|
+
}
|
|
2562
|
+
function b(p = globalThis.window?.location, g = globalThis.window?.name || "") {
|
|
2563
|
+
if (g === r || g === t) return !0;
|
|
2564
|
+
try {
|
|
2565
|
+
return new URL(p?.href || String(p || ""), re()).searchParams.get(e) === t;
|
|
2566
|
+
} catch {
|
|
2567
|
+
return !1;
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
async function m(p, g = {}, u = {}) {
|
|
2571
|
+
const h = u.parser || s, w = u.isBlockedDocument || c, k = globalThis.document, v = globalThis.window;
|
|
2572
|
+
if (!k?.body || typeof k.createElement != "function" || typeof k.body.appendChild != "function") return {
|
|
2573
|
+
attempted: !1,
|
|
2574
|
+
doc: null,
|
|
2575
|
+
result: null,
|
|
2576
|
+
blocked: !1,
|
|
2577
|
+
timedOut: !1,
|
|
2578
|
+
via: "unavailable"
|
|
2579
|
+
};
|
|
2580
|
+
const E = f(p), x = k.createElement("iframe");
|
|
2581
|
+
x.name = r;
|
|
2582
|
+
try {
|
|
2583
|
+
x.sandbox = n;
|
|
2584
|
+
} catch {
|
|
2585
|
+
}
|
|
2586
|
+
return x.style && (x.style.cssText = i), new Promise((C) => {
|
|
2587
|
+
let O = !1;
|
|
2588
|
+
const z = typeof v?.addEventListener == "function" && typeof v?.removeEventListener == "function", ct = v.setTimeout(() => {
|
|
2589
|
+
ee({
|
|
2590
|
+
attempted: !0,
|
|
2591
|
+
doc: null,
|
|
2592
|
+
result: null,
|
|
2593
|
+
blocked: !1,
|
|
2594
|
+
timedOut: !0,
|
|
2595
|
+
via: "timeout"
|
|
2596
|
+
});
|
|
2597
|
+
}, o);
|
|
2598
|
+
function lt() {
|
|
2599
|
+
v.clearTimeout(ct), z && v.removeEventListener("message", ke), typeof x.remove == "function" && x.remove();
|
|
2600
|
+
}
|
|
2601
|
+
function ee(A) {
|
|
2602
|
+
O || (O = !0, lt(), C(A));
|
|
2603
|
+
}
|
|
2604
|
+
function ke(A) {
|
|
2605
|
+
if (A.source && x.contentWindow && A.source !== x.contentWindow) return;
|
|
2606
|
+
const P = A.data;
|
|
2607
|
+
!P || P.type !== d || P.marker !== t || ee({
|
|
2608
|
+
attempted: !0,
|
|
2609
|
+
doc: null,
|
|
2610
|
+
result: P.payload || null,
|
|
2611
|
+
blocked: !!P.blocked,
|
|
2612
|
+
timedOut: !1,
|
|
2613
|
+
via: "postMessage"
|
|
2614
|
+
});
|
|
2615
|
+
}
|
|
2616
|
+
x.addEventListener("load", () => {
|
|
2617
|
+
if (x.contentWindow?.location?.href !== "about:blank")
|
|
2618
|
+
try {
|
|
2619
|
+
const A = x.contentDocument || x.contentWindow?.document || null, P = !!w?.(A);
|
|
2620
|
+
ee({
|
|
2621
|
+
attempted: !0,
|
|
2622
|
+
doc: A,
|
|
2623
|
+
result: typeof h == "function" ? h(A, {
|
|
2624
|
+
url: E,
|
|
2625
|
+
input: g
|
|
2626
|
+
}) : null,
|
|
2627
|
+
blocked: P,
|
|
2628
|
+
timedOut: !1,
|
|
2629
|
+
via: "contentDocument"
|
|
2630
|
+
});
|
|
2631
|
+
} catch {
|
|
2632
|
+
}
|
|
2633
|
+
}), z && v.addEventListener("message", ke), k.body.appendChild(x), x.src = E;
|
|
2634
|
+
});
|
|
2635
|
+
}
|
|
2636
|
+
function l(p = s, { targetOrigin: g = re() } = {}) {
|
|
2637
|
+
const u = globalThis.window;
|
|
2638
|
+
if (!u?.parent || !b(u.location, u.name)) return !1;
|
|
2639
|
+
const h = typeof p == "function" ? p(globalThis.document, {
|
|
2640
|
+
url: u.location?.href || "",
|
|
2641
|
+
input: {}
|
|
2642
|
+
}) : p;
|
|
2643
|
+
return u.parent.postMessage({
|
|
2644
|
+
type: d,
|
|
2645
|
+
marker: t,
|
|
2646
|
+
payload: h
|
|
2647
|
+
}, g || "*"), !0;
|
|
2648
|
+
}
|
|
2649
|
+
return {
|
|
2650
|
+
markerParam: e,
|
|
2651
|
+
markerValue: t,
|
|
2652
|
+
frameName: r,
|
|
2653
|
+
messageType: d,
|
|
2654
|
+
decorateUrl: f,
|
|
2655
|
+
isScraperFrame: b,
|
|
2656
|
+
load: m,
|
|
2657
|
+
postCurrentDocument: l
|
|
2658
|
+
};
|
|
2659
|
+
}
|
|
2660
|
+
function Oi(e, { accountId: t, type: r = "agenticSearchFrame" } = {}) {
|
|
2661
|
+
return e?.isScraperFrame?.() ? (t && globalThis.window && (globalThis.window.GengageAssistantInjector ||= {}, globalThis.window.GengageAssistantInjector[t] ||= { type: r }), !0) : !1;
|
|
2662
|
+
}
|
|
2663
|
+
function re() {
|
|
2664
|
+
return globalThis.window?.location?.origin || globalThis.location?.origin || "https://example.invalid";
|
|
2665
|
+
}
|
|
2666
|
+
function Bi({ rootUrl: e, successMessage: t, alreadyCurrentPageMessage: r = t, missingUrlMessage: n = "Ürün sayfasını açmak için ürün bağlantısı gerekiyor." } = {}) {
|
|
2667
|
+
const o = new URL(e).origin;
|
|
2668
|
+
return async function(a = {}) {
|
|
2669
|
+
const s = a.product || {}, c = Pn(a.url || a.productUrl || s.url, e, o), d = a.sku || s.sku || null;
|
|
2670
|
+
return c ? In(c) ? {
|
|
2671
|
+
ok: !0,
|
|
2672
|
+
sku: d,
|
|
2673
|
+
url: c,
|
|
2674
|
+
method: "already-current-page",
|
|
2675
|
+
alreadyCurrentPage: !0,
|
|
2676
|
+
message: r || t
|
|
2677
|
+
} : (jn(c), {
|
|
2678
|
+
ok: !0,
|
|
2679
|
+
sku: d,
|
|
2680
|
+
url: c,
|
|
2681
|
+
method: "browser-navigation",
|
|
2682
|
+
message: t
|
|
2683
|
+
}) : {
|
|
2684
|
+
ok: !1,
|
|
2685
|
+
sku: d,
|
|
2686
|
+
reason: "missing-url",
|
|
2687
|
+
message: n
|
|
2688
|
+
};
|
|
2689
|
+
};
|
|
2690
|
+
}
|
|
2691
|
+
function Pn(e, t, r = new URL(t).origin) {
|
|
2692
|
+
if (!e) return "";
|
|
2693
|
+
try {
|
|
2694
|
+
const n = new URL(e, t);
|
|
2695
|
+
return n.protocol !== "https:" || n.origin !== r ? "" : (n.hash = "", n.href);
|
|
2696
|
+
} catch {
|
|
2697
|
+
return "";
|
|
2698
|
+
}
|
|
2699
|
+
}
|
|
2700
|
+
function jn(e) {
|
|
2701
|
+
if (typeof document > "u") {
|
|
2702
|
+
window.location.href = e;
|
|
2703
|
+
return;
|
|
2704
|
+
}
|
|
2705
|
+
const t = document.createElement("a");
|
|
2706
|
+
t.href = e, t.target = "_self", t.rel = "noreferrer", t.style.display = "none", document.body.appendChild(t), t.click(), t.remove(), setTimeout(() => {
|
|
2707
|
+
window.location.href !== e && window.location.assign(e);
|
|
2708
|
+
}, 0);
|
|
2709
|
+
}
|
|
2710
|
+
function In(e) {
|
|
2711
|
+
try {
|
|
2712
|
+
const t = new URL(globalThis.window?.location?.href || "", e), r = new URL(e, t.href);
|
|
2713
|
+
return t.hash = "", r.hash = "", t.href === r.href;
|
|
2714
|
+
} catch {
|
|
2715
|
+
return !1;
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
function Un({ accountId: e, supplied: t = [], pageProduct: r = null, listingProducts: n = [], skus: o = [], limit: i = 4, storedProducts: a = [], getStoredPanelProducts: s } = {}) {
|
|
2719
|
+
const c = it(o), d = Array.isArray(n) ? n : [], f = typeof s == "function" ? s({
|
|
2720
|
+
accountId: e,
|
|
2721
|
+
visibleProducts: d
|
|
2722
|
+
}) : a;
|
|
2723
|
+
return qn([
|
|
2724
|
+
...K(t),
|
|
2725
|
+
...K(f),
|
|
2726
|
+
r,
|
|
2727
|
+
...d
|
|
2728
|
+
], {
|
|
2729
|
+
skus: c,
|
|
2730
|
+
limit: i
|
|
2731
|
+
});
|
|
2732
|
+
}
|
|
2733
|
+
function $i({ accountId: e, rootUrl: t, getProduct: r, getProducts: n, getStoredPanelProducts: o, limit: i = 4 } = {}) {
|
|
2734
|
+
return async function(s = {}) {
|
|
2735
|
+
return {
|
|
2736
|
+
accountId: e,
|
|
2737
|
+
products: Un({
|
|
2738
|
+
accountId: e,
|
|
2739
|
+
supplied: Array.isArray(s.products) ? s.products : [],
|
|
2740
|
+
pageProduct: r?.(),
|
|
2741
|
+
listingProducts: n?.(),
|
|
2742
|
+
getStoredPanelProducts: o,
|
|
2743
|
+
skus: s.skus || s.sku_list || [],
|
|
2744
|
+
limit: i
|
|
2745
|
+
}),
|
|
2746
|
+
rootUrl: t
|
|
2747
|
+
};
|
|
2748
|
+
};
|
|
2749
|
+
}
|
|
2750
|
+
function qn(e, { skus: t = [], limit: r = 4 } = {}) {
|
|
2751
|
+
const n = new Set(it(t)), o = /* @__PURE__ */ new Set(), i = [];
|
|
2752
|
+
for (const a of K(e)) {
|
|
2753
|
+
if (!a) continue;
|
|
2754
|
+
const s = H(a?.sku);
|
|
2755
|
+
if (n.size && !n.has(s)) continue;
|
|
2756
|
+
const c = s || H(a?.url) || H(a?.name || a?.title);
|
|
2757
|
+
if (!(c && o.has(c)) && (c && o.add(c), i.push(a), i.length >= r))
|
|
2758
|
+
break;
|
|
2759
|
+
}
|
|
2760
|
+
return i;
|
|
2761
|
+
}
|
|
2762
|
+
function it(e) {
|
|
2763
|
+
return K(e).map(H).filter(Boolean);
|
|
2764
|
+
}
|
|
2765
|
+
function H(e) {
|
|
2766
|
+
return String(e || "").trim();
|
|
2767
|
+
}
|
|
2768
|
+
function K(e) {
|
|
2769
|
+
return Array.isArray(e) ? e.filter(Boolean) : e ? [e] : [];
|
|
2770
|
+
}
|
|
2771
|
+
var I = {
|
|
2772
|
+
headings: 8,
|
|
2773
|
+
products: 8,
|
|
2774
|
+
controls: 12,
|
|
2775
|
+
textMatches: 8,
|
|
2776
|
+
snippetChars: 180
|
|
2777
|
+
}, J = /\b(?:checkout|payment|pay now|place order|delete|remove|confirm|submit|ödeme|odeme|siparişi tamamla|siparisi tamamla|satın al|satin al|sil|kaldır|kaldir|onayla|gönder|gonder)\b/iu, Nn = /(?:token|session|sid|auth|code|csrf|secret|key|password|passwd|phone|email|address|postcode|zip|jwt|bearer)/iu, Mn = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}|\+?\d[\d\s().-]{8,}\d|[A-Z]{1,2}\d[A-Z\d]?\s*\d[A-Z]{2}|[A-Za-z0-9_-]{24,}/iu, Fn = {
|
|
2778
|
+
campaign: /\b(?:campaign|promotion|discount|deal|coupon|kampanya|indirim|firsat|fırsat|kupon)\b/iu,
|
|
2779
|
+
blog: /\b(?:blog|journal|guide|article|editorial|inspiration|rehber|makale|ilham|icerik|içerik)\b/iu,
|
|
2780
|
+
category: /\b(?:category|collection|department|kategori|koleksiyon|reyon)\b/iu
|
|
2781
|
+
};
|
|
2782
|
+
function Di({ accountId: e, getPageType: t, getProduct: r, getProducts: n, normalizeProduct: o = (i) => i }) {
|
|
2783
|
+
return {
|
|
2784
|
+
scanSite: (i = {}) => On({
|
|
2785
|
+
accountId: e,
|
|
2786
|
+
getPageType: t,
|
|
2787
|
+
getProduct: r,
|
|
2788
|
+
getProducts: n,
|
|
2789
|
+
normalizeProduct: o,
|
|
2790
|
+
input: i
|
|
2791
|
+
}),
|
|
2792
|
+
siteGrep: (i = {}) => Bn(i),
|
|
2793
|
+
discoverSiteContent: (i = {}) => at(i, e),
|
|
2794
|
+
runSiteCommand: (i = {}) => $n(i),
|
|
2795
|
+
describeVisualContext: (i = {}) => Dn(i, e),
|
|
2796
|
+
inspectProductSurface: ft({
|
|
2797
|
+
accountId: e,
|
|
2798
|
+
getPageType: t,
|
|
2799
|
+
getProduct: r,
|
|
2800
|
+
getProducts: n,
|
|
2801
|
+
normalizeProduct: o
|
|
2802
|
+
}),
|
|
2803
|
+
getSiteCapabilities: () => Hn(e)
|
|
2804
|
+
};
|
|
2805
|
+
}
|
|
2806
|
+
function On({ accountId: e, getPageType: t, getProduct: r, getProducts: n, normalizeProduct: o, input: i }) {
|
|
2807
|
+
const a = S(i.query || i.text || ""), s = ve(i), c = ne(r), d = ne(n) || [];
|
|
2808
|
+
return xe({
|
|
2809
|
+
accountId: e,
|
|
2810
|
+
url: io(),
|
|
2811
|
+
title: R(document.title || ""),
|
|
2812
|
+
pageType: ne(t) || "other",
|
|
2813
|
+
viewport: ao(),
|
|
2814
|
+
product: Ne(o(c)),
|
|
2815
|
+
products: d.map(o).map(Ne).filter(Boolean).slice(0, s.products),
|
|
2816
|
+
content: i.includeContent === !1 ? void 0 : at(i, e).items,
|
|
2817
|
+
headings: Wn(s.headings),
|
|
2818
|
+
controls: i.includeControls === !1 ? void 0 : Vn(s.controls),
|
|
2819
|
+
textMatches: a ? be(a, s) : [],
|
|
2820
|
+
privacy: {
|
|
2821
|
+
rawHtml: !1,
|
|
2822
|
+
formValues: !1,
|
|
2823
|
+
redacted: !0,
|
|
2824
|
+
browserLocal: !0
|
|
2825
|
+
}
|
|
2826
|
+
});
|
|
2827
|
+
}
|
|
2828
|
+
function at(e = {}, t = "") {
|
|
2829
|
+
const r = ve(e), n = new Set(Yn(e.kinds || e.kind)), o = Kn(r.controls).filter((i) => !n.size || n.has(i.kind)).slice(0, r.controls);
|
|
2830
|
+
return {
|
|
2831
|
+
accountId: t,
|
|
2832
|
+
items: o,
|
|
2833
|
+
count: o.length,
|
|
2834
|
+
privacy: L()
|
|
2835
|
+
};
|
|
2836
|
+
}
|
|
2837
|
+
function Bn(e = {}) {
|
|
2838
|
+
const t = S(e.query || e.text || e.pattern || "");
|
|
2839
|
+
if (!t) return {
|
|
2840
|
+
ok: !1,
|
|
2841
|
+
matches: [],
|
|
2842
|
+
message: "Provide a query to scan visible page text.",
|
|
2843
|
+
privacy: L()
|
|
2844
|
+
};
|
|
2845
|
+
const r = be(t, ve(e));
|
|
2846
|
+
return {
|
|
2847
|
+
ok: r.length > 0,
|
|
2848
|
+
query: t,
|
|
2849
|
+
matches: r,
|
|
2850
|
+
count: r.length,
|
|
2851
|
+
privacy: L()
|
|
2852
|
+
};
|
|
2853
|
+
}
|
|
2854
|
+
function $n(e = {}) {
|
|
2855
|
+
const t = S(e.command || e.action || "").toLowerCase();
|
|
2856
|
+
return t === "scroll_to_text" || t === "scrolltotext" ? zn(e) : t === "click_visible_text" || t === "clickvisibletext" ? Gn(e) : t === "scroll_top" || t === "scrolltotop" ? (window.scrollTo({
|
|
2857
|
+
top: 0,
|
|
2858
|
+
behavior: "smooth"
|
|
2859
|
+
}), {
|
|
2860
|
+
ok: !0,
|
|
2861
|
+
command: "scroll_top",
|
|
2862
|
+
message: "Scrolled to the top of the page.",
|
|
2863
|
+
privacy: L()
|
|
2864
|
+
}) : {
|
|
2865
|
+
ok: !1,
|
|
2866
|
+
command: t,
|
|
2867
|
+
message: "Supported commands are scroll_to_text, click_visible_text, and scroll_top.",
|
|
2868
|
+
privacy: L()
|
|
2869
|
+
};
|
|
2870
|
+
}
|
|
2871
|
+
function Dn(e = {}, t) {
|
|
2872
|
+
const r = e.visual_consent === !0 || e.visualConsent === !0 || e.consent === !0, n = r ? Qn(e.visual_observations || e.visualObservations) : [], o = Zn(Number(e.maxImages || 8));
|
|
2873
|
+
return {
|
|
2874
|
+
accountId: t,
|
|
2875
|
+
ok: r || o.length > 0,
|
|
2876
|
+
consentedObservations: n,
|
|
2877
|
+
visibleImages: o,
|
|
2878
|
+
message: Xn({
|
|
2879
|
+
consented: r,
|
|
2880
|
+
observations: n,
|
|
2881
|
+
visibleImages: o
|
|
2882
|
+
}),
|
|
2883
|
+
privacy: {
|
|
2884
|
+
rawHtml: !1,
|
|
2885
|
+
formValues: !1,
|
|
2886
|
+
screenshotPixels: !1,
|
|
2887
|
+
redacted: !0,
|
|
2888
|
+
browserLocal: !0,
|
|
2889
|
+
requiresConsentForExternalVisualFacts: !0
|
|
2890
|
+
}
|
|
2891
|
+
};
|
|
2892
|
+
}
|
|
2893
|
+
function zn(e) {
|
|
2894
|
+
const t = S(e.query || e.text || e.label || ""), r = t ? ro(t) : null;
|
|
2895
|
+
return r ? (r.scrollIntoView({
|
|
2896
|
+
block: "center",
|
|
2897
|
+
inline: "nearest",
|
|
2898
|
+
behavior: "smooth"
|
|
2899
|
+
}), {
|
|
2900
|
+
ok: !0,
|
|
2901
|
+
command: "scroll_to_text",
|
|
2902
|
+
label: F(r),
|
|
2903
|
+
message: "Scrolled to the matching page area.",
|
|
2904
|
+
privacy: L()
|
|
2905
|
+
}) : {
|
|
2906
|
+
ok: !1,
|
|
2907
|
+
command: "scroll_to_text",
|
|
2908
|
+
message: "No visible matching text found."
|
|
2909
|
+
};
|
|
2910
|
+
}
|
|
2911
|
+
function Gn(e) {
|
|
2912
|
+
const t = S(e.label || e.query || e.text || "");
|
|
2913
|
+
if (!t) return {
|
|
2914
|
+
ok: !1,
|
|
2915
|
+
command: "click_visible_text",
|
|
2916
|
+
message: "Provide a visible label to click."
|
|
2917
|
+
};
|
|
2918
|
+
if (J.test(t)) return {
|
|
2919
|
+
ok: !1,
|
|
2920
|
+
blocked: !0,
|
|
2921
|
+
command: "click_visible_text",
|
|
2922
|
+
message: "This looks like a checkout, payment, destructive, or final confirmation action, so it was not clicked.",
|
|
2923
|
+
privacy: L()
|
|
2924
|
+
};
|
|
2925
|
+
const r = to(t);
|
|
2926
|
+
if (!r) return {
|
|
2927
|
+
ok: !1,
|
|
2928
|
+
command: "click_visible_text",
|
|
2929
|
+
message: "No safe visible clickable control found."
|
|
2930
|
+
};
|
|
2931
|
+
const n = F(r);
|
|
2932
|
+
return J.test(n) ? {
|
|
2933
|
+
ok: !1,
|
|
2934
|
+
blocked: !0,
|
|
2935
|
+
command: "click_visible_text",
|
|
2936
|
+
label: n,
|
|
2937
|
+
message: "The matched control is blocked by the safe-click policy.",
|
|
2938
|
+
privacy: L()
|
|
2939
|
+
} : (r.click(), {
|
|
2940
|
+
ok: !0,
|
|
2941
|
+
command: "click_visible_text",
|
|
2942
|
+
label: n,
|
|
2943
|
+
message: "Clicked the safe visible control.",
|
|
2944
|
+
privacy: L()
|
|
2945
|
+
});
|
|
2946
|
+
}
|
|
2947
|
+
function Hn(e) {
|
|
2948
|
+
return {
|
|
2949
|
+
accountId: e,
|
|
2950
|
+
tools: [
|
|
2951
|
+
"scanSite",
|
|
2952
|
+
"siteGrep",
|
|
2953
|
+
"discoverSiteContent",
|
|
2954
|
+
"runSiteCommand",
|
|
2955
|
+
"describeVisualContext",
|
|
2956
|
+
"inspectProductSurface"
|
|
2957
|
+
],
|
|
2958
|
+
commands: {
|
|
2959
|
+
scanSite: "Returns a compact browser-local summary of page type, title, headings, products, controls, and matching visible text.",
|
|
2960
|
+
siteGrep: "Finds capped visible text snippets by plain query, like grep for the rendered page.",
|
|
2961
|
+
discoverSiteContent: "Returns visible campaign, blog/editorial, and category/content links as compact browser-local metadata.",
|
|
2962
|
+
runSiteCommand: "Runs guarded browser-local page commands: scroll_to_text, click_visible_text, scroll_top. Checkout, payment, destructive, and final-confirm controls are blocked.",
|
|
2963
|
+
describeVisualContext: "Summarizes visible image metadata and explicit shopper-consented redacted visual observations without capturing screenshots or pixels.",
|
|
2964
|
+
inspectProductSurface: "Returns compact GSS-style product detail evidence visible in the browser: description, specs, seller, QNA, reviews/ratings, installment/payment, shipping/stock, campaigns, variants, documents, and related visible products."
|
|
2965
|
+
},
|
|
2966
|
+
privacy: [
|
|
2967
|
+
"Runs in the shopper browser.",
|
|
2968
|
+
"Does not return raw HTML, cookies, storage, hidden text, or form values.",
|
|
2969
|
+
"Redacts emails, phone numbers, tokens, and address-like postal snippets before returning text.",
|
|
2970
|
+
"Returns compact capped snippets only.",
|
|
2971
|
+
"Does not send screenshots or pixels implicitly; external visual observations must be explicitly consented."
|
|
2972
|
+
]
|
|
2973
|
+
};
|
|
2974
|
+
}
|
|
2975
|
+
function Wn(e) {
|
|
2976
|
+
return [...document.querySelectorAll('h1,h2,h3,[role="heading"]')].filter(j).map((t) => R(S(t.textContent))).filter(Boolean).slice(0, e);
|
|
2977
|
+
}
|
|
2978
|
+
function Vn(e) {
|
|
2979
|
+
return [...document.querySelectorAll('button,a,[role="button"],summary,input[type="button"],input[type="submit"]')].filter(j).map((t) => ({
|
|
2980
|
+
label: F(t),
|
|
2981
|
+
tag: t.tagName?.toLowerCase(),
|
|
2982
|
+
role: t.getAttribute?.("role") || null,
|
|
2983
|
+
href: st(t),
|
|
2984
|
+
safeClick: !J.test(F(t))
|
|
2985
|
+
})).filter((t) => t.label).filter(X((t) => `${t.tag}:${t.label}:${t.href || ""}`)).slice(0, e);
|
|
2986
|
+
}
|
|
2987
|
+
function Kn(e) {
|
|
2988
|
+
return [...document.querySelectorAll('a[href],button,[role="button"],summary')].filter(j).map((t) => {
|
|
2989
|
+
const r = F(t), n = st(t), o = Jn([
|
|
2990
|
+
r,
|
|
2991
|
+
n,
|
|
2992
|
+
le(t)
|
|
2993
|
+
].join(" "));
|
|
2994
|
+
return o ? xe({
|
|
2995
|
+
kind: o,
|
|
2996
|
+
label: r,
|
|
2997
|
+
href: n,
|
|
2998
|
+
heading: le(t),
|
|
2999
|
+
safeClick: !J.test(r)
|
|
3000
|
+
}) : null;
|
|
3001
|
+
}).filter(Boolean).filter(X((t) => `${t.kind}:${t.label}:${t.href || ""}`)).slice(0, Math.max(1, Math.min(e, 30)));
|
|
3002
|
+
}
|
|
3003
|
+
function Jn(e) {
|
|
3004
|
+
for (const [t, r] of Object.entries(Fn)) if (r.test(e)) return t;
|
|
3005
|
+
return "";
|
|
3006
|
+
}
|
|
3007
|
+
function Yn(e) {
|
|
3008
|
+
return (Array.isArray(e) ? e : String(e || "").split(/[,|]/u)).map((t) => S(t).toLowerCase()).filter(Boolean);
|
|
3009
|
+
}
|
|
3010
|
+
function be(e, t) {
|
|
3011
|
+
const r = e.toLocaleLowerCase("tr-TR");
|
|
3012
|
+
return eo(document.body).map((n) => ({
|
|
3013
|
+
node: n,
|
|
3014
|
+
text: S(n.nodeValue || "")
|
|
3015
|
+
})).filter(({ text: n }) => n && n.toLocaleLowerCase("tr-TR").includes(r)).map(({ node: n, text: o }) => ({
|
|
3016
|
+
snippet: no(o, e, t.snippetChars),
|
|
3017
|
+
tag: n.parentElement?.tagName?.toLowerCase() || "",
|
|
3018
|
+
heading: le(n.parentElement)
|
|
3019
|
+
})).filter((n) => n.snippet).filter(X((n) => n.snippet)).slice(0, t.textMatches);
|
|
3020
|
+
}
|
|
3021
|
+
function Zn(e) {
|
|
3022
|
+
return [...document.querySelectorAll("img")].filter(j).map((t) => ({
|
|
3023
|
+
alt: R(S(t.getAttribute("alt") || t.getAttribute("aria-label") || "")),
|
|
3024
|
+
title: R(S(t.getAttribute("title") || "")),
|
|
3025
|
+
src: ye(t.currentSrc || t.getAttribute("src")),
|
|
3026
|
+
width: Math.round(t.getBoundingClientRect().width),
|
|
3027
|
+
height: Math.round(t.getBoundingClientRect().height)
|
|
3028
|
+
})).filter((t) => t.alt || t.title || t.src).filter(X((t) => `${t.alt}:${t.title}:${t.src}`)).slice(0, Math.max(1, Math.min(Number.isFinite(e) && e > 0 ? Math.floor(e) : 8, 20)));
|
|
3029
|
+
}
|
|
3030
|
+
function Qn(e) {
|
|
3031
|
+
return (Array.isArray(e) ? e : String(e || "").split(/\n|;|\|/u)).map((t) => R(t).slice(0, 180)).filter(Boolean).slice(0, 8);
|
|
3032
|
+
}
|
|
3033
|
+
function Xn({ consented: e, observations: t, visibleImages: r }) {
|
|
3034
|
+
const n = [];
|
|
3035
|
+
if (t.length && n.push(`Consented visual observations: ${t.slice(0, 3).join(" | ")}.`), r.length) {
|
|
3036
|
+
const o = r.map((i) => i.alt || i.title).filter(Boolean).slice(0, 3);
|
|
3037
|
+
n.push(o.length ? `Visible image labels: ${o.join(", ")}.` : `${r.length} visible images found.`);
|
|
3038
|
+
}
|
|
3039
|
+
return !n.length && !e && n.push("I can use visible image labels, but external visual observations need explicit shopper consent."), n.push("No screenshots or pixels were captured or sent."), n.join(" ");
|
|
3040
|
+
}
|
|
3041
|
+
function eo(e) {
|
|
3042
|
+
if (!e) return [];
|
|
3043
|
+
const t = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, { acceptNode(n) {
|
|
3044
|
+
const o = n.parentElement;
|
|
3045
|
+
return !o || !j(o) || /^(script|style|noscript|template|svg)$/iu.test(o.tagName || "") || oo(o) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT;
|
|
3046
|
+
} }), r = [];
|
|
3047
|
+
for (; r.length < 500; ) {
|
|
3048
|
+
const n = t.nextNode();
|
|
3049
|
+
if (!n) break;
|
|
3050
|
+
r.push(n);
|
|
3051
|
+
}
|
|
3052
|
+
return r;
|
|
3053
|
+
}
|
|
3054
|
+
function to(e) {
|
|
3055
|
+
return [...document.querySelectorAll('button,a,[role="button"],summary,input[type="button"],input[type="submit"]')].filter(j).find((t) => F(t).toLocaleLowerCase("tr-TR").includes(e.toLocaleLowerCase("tr-TR")));
|
|
3056
|
+
}
|
|
3057
|
+
function ro(e) {
|
|
3058
|
+
const t = be(e, {
|
|
3059
|
+
...I,
|
|
3060
|
+
textMatches: 1
|
|
3061
|
+
})[0];
|
|
3062
|
+
return t ? [...document.querySelectorAll("body *")].filter(j).find((r) => S(r.textContent).includes(t.snippet.slice(0, 24))) : null;
|
|
3063
|
+
}
|
|
3064
|
+
function F(e) {
|
|
3065
|
+
return e ? R(S(e.getAttribute?.("aria-label") || e.getAttribute?.("title") || e.getAttribute?.("alt") || e.value || e.textContent || "")).slice(0, 90) : "";
|
|
3066
|
+
}
|
|
3067
|
+
function le(e) {
|
|
3068
|
+
let t = e;
|
|
3069
|
+
for (let r = 0; t && r < 5; r += 1) {
|
|
3070
|
+
const n = S((t.matches?.('h1,h2,h3,[role="heading"]') ? t : t.querySelector?.('h1,h2,h3,[role="heading"]'))?.textContent || "");
|
|
3071
|
+
if (n) return R(n).slice(0, 90);
|
|
3072
|
+
t = t.parentElement;
|
|
3073
|
+
}
|
|
3074
|
+
return "";
|
|
3075
|
+
}
|
|
3076
|
+
function Ne(e) {
|
|
3077
|
+
return e ? xe({
|
|
3078
|
+
sku: S(e.sku || e.id || ""),
|
|
3079
|
+
name: S(e.name || e.title || ""),
|
|
3080
|
+
url: ye(e.url),
|
|
3081
|
+
price_text: S(e.price_text || e.priceText || ""),
|
|
3082
|
+
price: e.price,
|
|
3083
|
+
currency: e.price_currency || e.currency,
|
|
3084
|
+
in_stock: e.in_stock,
|
|
3085
|
+
category: S(e.category || "")
|
|
3086
|
+
}) : null;
|
|
3087
|
+
}
|
|
3088
|
+
function no(e, t, r) {
|
|
3089
|
+
const n = R(e), o = n.toLocaleLowerCase("tr-TR").indexOf(t.toLocaleLowerCase("tr-TR")), i = Math.max(0, o - Math.floor(r / 3));
|
|
3090
|
+
return n.slice(i, i + r).trim();
|
|
3091
|
+
}
|
|
3092
|
+
function j(e) {
|
|
3093
|
+
if (!e || !e.getBoundingClientRect) return !1;
|
|
3094
|
+
const t = e.getBoundingClientRect();
|
|
3095
|
+
if (t.width <= 0 || t.height <= 0) return !1;
|
|
3096
|
+
const r = window.getComputedStyle(e);
|
|
3097
|
+
return r.visibility !== "hidden" && r.display !== "none" && Number(r.opacity || 1) > 0;
|
|
3098
|
+
}
|
|
3099
|
+
function oo(e) {
|
|
3100
|
+
return !!e.closest?.('input,textarea,select,[contenteditable="true"]');
|
|
3101
|
+
}
|
|
3102
|
+
function st(e) {
|
|
3103
|
+
return e.tagName?.toLowerCase() !== "a" ? null : ye(e.getAttribute("href"));
|
|
3104
|
+
}
|
|
3105
|
+
function ye(e) {
|
|
3106
|
+
if (!e) return "";
|
|
3107
|
+
try {
|
|
3108
|
+
const t = new URL(e, window.location.href);
|
|
3109
|
+
return /^https?:$/u.test(t.protocol) ? (t.hash = "", we(t), t.href) : "";
|
|
3110
|
+
} catch {
|
|
3111
|
+
return "";
|
|
3112
|
+
}
|
|
3113
|
+
}
|
|
3114
|
+
function io() {
|
|
3115
|
+
const e = new URL(window.location.href);
|
|
3116
|
+
return we(e), `${e.origin}${e.pathname}${e.search}`;
|
|
3117
|
+
}
|
|
3118
|
+
function ao() {
|
|
3119
|
+
return {
|
|
3120
|
+
width: window.innerWidth,
|
|
3121
|
+
height: window.innerHeight,
|
|
3122
|
+
scrollY: Math.round(window.scrollY || 0),
|
|
3123
|
+
documentHeight: Math.round(document.documentElement?.scrollHeight || 0)
|
|
3124
|
+
};
|
|
3125
|
+
}
|
|
3126
|
+
function R(e) {
|
|
3127
|
+
return S(e).replace(/https?:\/\/[^\s?#]+(?:\?[^#\s]*)?/giu, so).replace(/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/giu, "<email>").replace(/\b(?:\+?\d[\d\s().-]{8,}\d)\b/gu, "<phone>").replace(/\b[A-Z]{1,2}\d[A-Z\d]?\s*\d[A-Z]{2}\b/giu, "<postcode>").replace(/\btoken\s*=\s*[\w.-]+/giu, "token=<redacted>").replace(/\b(?:api[_-]?key|session|csrf|secret)\s*[:=]\s*[\w.-]+/giu, "<secret>");
|
|
3128
|
+
}
|
|
3129
|
+
function so(e) {
|
|
3130
|
+
try {
|
|
3131
|
+
const t = new URL(e);
|
|
3132
|
+
return t.hash = "", we(t), t.href;
|
|
3133
|
+
} catch {
|
|
3134
|
+
return String(e || "").replace(/\?[^#\s]*/u, "?redacted");
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
function we(e) {
|
|
3138
|
+
for (const [t, r] of [...e.searchParams.entries()]) {
|
|
3139
|
+
const n = String(r || "");
|
|
3140
|
+
(Nn.test(t) || Mn.test(n)) && e.searchParams.set(t, "redacted");
|
|
3141
|
+
}
|
|
3142
|
+
return e;
|
|
3143
|
+
}
|
|
3144
|
+
function S(e) {
|
|
3145
|
+
return String(e || "").replace(/\s+/gu, " ").trim();
|
|
3146
|
+
}
|
|
3147
|
+
function ve(e) {
|
|
3148
|
+
return {
|
|
3149
|
+
headings: $(e.maxHeadings, I.headings, 20),
|
|
3150
|
+
products: $(e.maxProducts, I.products, 20),
|
|
3151
|
+
controls: $(e.maxControls, I.controls, 30),
|
|
3152
|
+
textMatches: $(e.maxMatches || e.limit, I.textMatches, 20),
|
|
3153
|
+
snippetChars: $(e.snippetChars, I.snippetChars, 320)
|
|
3154
|
+
};
|
|
3155
|
+
}
|
|
3156
|
+
function $(e, t, r) {
|
|
3157
|
+
const n = Number(e);
|
|
3158
|
+
return !Number.isFinite(n) || n <= 0 ? t : Math.min(Math.floor(n), r);
|
|
3159
|
+
}
|
|
3160
|
+
function L() {
|
|
3161
|
+
return {
|
|
3162
|
+
rawHtml: !1,
|
|
3163
|
+
formValues: !1,
|
|
3164
|
+
redacted: !0,
|
|
3165
|
+
browserLocal: !0
|
|
3166
|
+
};
|
|
3167
|
+
}
|
|
3168
|
+
function xe(e) {
|
|
3169
|
+
return Object.fromEntries(Object.entries(e).filter(([, t]) => t != null));
|
|
3170
|
+
}
|
|
3171
|
+
function ne(e) {
|
|
3172
|
+
try {
|
|
3173
|
+
return typeof e == "function" ? e() : null;
|
|
3174
|
+
} catch {
|
|
3175
|
+
return null;
|
|
3176
|
+
}
|
|
3177
|
+
}
|
|
3178
|
+
function X(e) {
|
|
3179
|
+
const t = /* @__PURE__ */ new Set();
|
|
3180
|
+
return (r) => {
|
|
3181
|
+
const n = e(r);
|
|
3182
|
+
return !n || t.has(n) ? !1 : (t.add(n), !0);
|
|
3183
|
+
};
|
|
890
3184
|
}
|
|
891
3185
|
export {
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
3186
|
+
pi as AgentError,
|
|
3187
|
+
gt as ContextStore,
|
|
3188
|
+
Go as FALLBACK_STATUS,
|
|
3189
|
+
$o as action,
|
|
3190
|
+
ni as actionButtonsUiSpec,
|
|
3191
|
+
_o as alignProductsToTable,
|
|
3192
|
+
Fo as anonymousRequestText,
|
|
3193
|
+
ri as beErrorToAgentError,
|
|
3194
|
+
hr as buildActivityVisualization,
|
|
3195
|
+
lo as buildPhotoSimilarityProfile,
|
|
3196
|
+
uo as buildProductSimilarityProfile,
|
|
3197
|
+
fo as buildSimilarityQueries,
|
|
3198
|
+
Je as canUseModuleWorker,
|
|
3199
|
+
dt as caughtToStreamError,
|
|
3200
|
+
xo as compactAccountConfig,
|
|
3201
|
+
No as compactContextProducts,
|
|
3202
|
+
ei as compactObject,
|
|
3203
|
+
mi as compactProductSurfaceForLlm,
|
|
3204
|
+
Co as comparisonResultForUi,
|
|
3205
|
+
Po as comparisonUiSpec,
|
|
3206
|
+
lr as createActivityCollector,
|
|
3207
|
+
$e as createBrowserMemory,
|
|
3208
|
+
Ui as createDiagnosticsTool,
|
|
3209
|
+
Ei as createEndpointCachePolicies,
|
|
3210
|
+
Ci as createEndpointHandlers,
|
|
3211
|
+
vo as createFlow,
|
|
3212
|
+
Mi as createGssToolAliases,
|
|
3213
|
+
Fi as createIframeScraper,
|
|
3214
|
+
vt as createInjectorAdapter,
|
|
3215
|
+
Ho as createLocalRefStore,
|
|
3216
|
+
xt as createMainThreadInjectorAdapter,
|
|
3217
|
+
rr as createModuleWorker,
|
|
3218
|
+
Bi as createOpenProductPageTool,
|
|
3219
|
+
Zo as createPrivacyHelpers,
|
|
3220
|
+
ft as createProductSurfaceInspector,
|
|
3221
|
+
Xo as createReadPageStep,
|
|
3222
|
+
Ii as createReadPageTool,
|
|
3223
|
+
$i as createResolveProductsTool,
|
|
3224
|
+
Di as createSiteAwarenessTools,
|
|
3225
|
+
Vo as declarativeBeOpCache,
|
|
3226
|
+
So as defaultPiiPatternPack,
|
|
3227
|
+
ko as defaultPiiPatterns,
|
|
3228
|
+
zo as done,
|
|
3229
|
+
Jo as elapsedMs,
|
|
3230
|
+
nr as endpointStableKey,
|
|
3231
|
+
qo as error,
|
|
3232
|
+
wi as fallbackStatus,
|
|
3233
|
+
Kr as filterActivityEntries,
|
|
3234
|
+
gi as firstArrayValue,
|
|
3235
|
+
fn as formatJsonHtml,
|
|
3236
|
+
ur as getOrCreateActivityCollector,
|
|
3237
|
+
mr as groupForEntry,
|
|
3238
|
+
Tn as gssSearchCapabilities,
|
|
3239
|
+
ai as homePanelReset,
|
|
3240
|
+
li as httpErrorToAgentError,
|
|
3241
|
+
ki as inputHashCachePolicy,
|
|
3242
|
+
ii as inspectProductSurface,
|
|
3243
|
+
jr as installActivityFetchPatch,
|
|
3244
|
+
ji as installBrowserTools,
|
|
3245
|
+
_i as installFetchTransportBridge,
|
|
3246
|
+
Oi as installIframeScraperBypass,
|
|
3247
|
+
Ni as installLocalAgenticActivityDebug,
|
|
3248
|
+
Si as isFallbackStatus,
|
|
3249
|
+
vi as isRef,
|
|
3250
|
+
Li as jsonResponse,
|
|
3251
|
+
Bo as llmCacheKey,
|
|
3252
|
+
bi as mergeProductSurfaceEvidence,
|
|
3253
|
+
wo as metadata,
|
|
3254
|
+
Ti as mountAccount,
|
|
3255
|
+
Gr as mountActivityOverlay,
|
|
3256
|
+
jn as navigateSameTab,
|
|
3257
|
+
Ai as ndjsonResponse,
|
|
3258
|
+
Ro as normalizeComparisonTable,
|
|
3259
|
+
dr as normalizeEntry,
|
|
3260
|
+
Lo as normalizeProduct,
|
|
3261
|
+
Pn as normalizeSameOriginUrl,
|
|
3262
|
+
po as normalizeSimilarityText,
|
|
3263
|
+
Qo as nowIso,
|
|
3264
|
+
ui as plainMessageContent,
|
|
3265
|
+
jo as productDetailsUiSpec,
|
|
3266
|
+
Eo as productFactsKey,
|
|
3267
|
+
Oo as productSkuKey,
|
|
3268
|
+
Ko as productSurfaceReviewText,
|
|
3269
|
+
Uo as productsUiSpec,
|
|
3270
|
+
mo as rankSimilarProducts,
|
|
3271
|
+
go as rankSimilarProductsAsync,
|
|
3272
|
+
Ur as recordBeDebugPayload,
|
|
3273
|
+
Io as redactPii,
|
|
3274
|
+
oi as requestText,
|
|
3275
|
+
Pi as resolveBeUrl,
|
|
3276
|
+
Do as resolveFlow,
|
|
3277
|
+
Un as resolveProductCandidates,
|
|
3278
|
+
ti as retailAnonymizeMessages,
|
|
3279
|
+
Wo as retailAnonymousRequestText,
|
|
3280
|
+
ci as retailRedactPii,
|
|
3281
|
+
si as routeFlowParams,
|
|
3282
|
+
fi as routeSkuList,
|
|
3283
|
+
ho as scoreSimilarityCandidate,
|
|
3284
|
+
fr as sectionForKind,
|
|
3285
|
+
Ri as setAssistantHostVisible,
|
|
3286
|
+
pr as severityForEntry,
|
|
3287
|
+
yn as shouldInstallActivityDebug,
|
|
3288
|
+
ue as stableKey,
|
|
3289
|
+
qi as startLazyRuntimeLoader,
|
|
3290
|
+
yi as stickyContextKey,
|
|
3291
|
+
Y as summarizeDebugState,
|
|
3292
|
+
ae as summarizePanelState,
|
|
3293
|
+
Ye as summarizeUiSpec,
|
|
3294
|
+
Yo as textChunk,
|
|
3295
|
+
To as textKey,
|
|
3296
|
+
bo as tokenizeSimilarityText,
|
|
3297
|
+
di as trimProductFactsCore,
|
|
3298
|
+
Ao as trimProductFactsListCore,
|
|
3299
|
+
hi as uiSpec,
|
|
3300
|
+
qn as uniqueProductsBySku,
|
|
3301
|
+
xi as withAccountConfig,
|
|
3302
|
+
Mo as withDeclarativeBeOpCache,
|
|
3303
|
+
Rr as wrapActivityBeacon,
|
|
3304
|
+
Lr as wrapActivityTools,
|
|
3305
|
+
Pr as wrapActivityTransport
|
|
955
3306
|
};
|