@gengage/assistant-fe 0.6.30 → 0.6.31

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.
@@ -1,5 +1,5 @@
1
1
  import { buildPhotoSimilarityProfile as yo, buildProductSimilarityProfile as wo, buildSimilarityQueries as vo, normalizeSimilarityText as xo, rankSimilarProducts as ko, rankSimilarProductsAsync as _o, scoreSimilarityCandidate as So, tokenizeSimilarityText as Eo } from "./algos/similarity.js";
2
- import { $ as ft, A as Co, At as pt, B as Ao, C as Ro, Ct as mt, D as Po, E as Lo, Et as jo, F as No, G as Io, H as Uo, I as qo, J as Bo, K as Oo, L as Fo, M as $o, Mt as Mo, N as Do, O as Go, Ot as Oe, P as zo, Q as gt, R as Ho, S as Wo, T as Vo, Tt as Ko, U as Jo, V as Yo, W as Zo, X as Qo, Y as Xo, Z as ei, _ as ti, _t as ri, a as ni, at as oi, b as ii, bt as ai, c as si, ct as ci, d as li, dt as ui, et as di, f as fi, ft as pi, g as mi, gt as ht, h as gi, ht as hi, i as bi, it as ue, j as yi, jt as wi, k as vi, kt as bt, l as xi, lt as ki, m as _i, mt as Si, n as Ei, nt as Ti, o as Ci, ot as Ai, p as Ri, pt as Pi, q as Li, r as ji, rt as Ni, s as Ii, st as Ui, t as qi, tt as Bi, u as Oi, ut as Fi, v as $i, vt as Mi, w as Di, wt as Gi, x as yt, xt as Fe, y as zi, yt as wt, z as Hi } from "../agent-ui-steps-WKbTVOS4.js";
2
+ import { $ as ft, A as Co, At as pt, B as Ao, C as Ro, Ct as mt, D as Po, E as Lo, Et as jo, F as No, G as Io, H as Uo, I as qo, J as Bo, K as Oo, L as Fo, M as $o, Mt as Mo, N as Do, O as Go, Ot as Oe, P as zo, Q as gt, R as Ho, S as Wo, T as Vo, Tt as Ko, U as Jo, V as Yo, W as Zo, X as Qo, Y as Xo, Z as ei, _ as ti, _t as ri, a as ni, at as oi, b as ii, bt as ai, c as si, ct as ci, d as li, dt as ui, et as di, f as fi, ft as pi, g as mi, gt as ht, h as gi, ht as hi, i as bi, it as ue, j as yi, jt as wi, k as vi, kt as bt, l as xi, lt as ki, m as _i, mt as Si, n as Ei, nt as Ti, o as Ci, ot as Ai, p as Ri, pt as Pi, q as Li, r as ji, rt as Ni, s as Ii, st as Ui, t as qi, tt as Bi, u as Oi, ut as Fi, v as $i, vt as Mi, w as Di, wt as Gi, x as yt, xt as Fe, y as zi, yt as wt, z as Hi } from "../agent-ui-steps-DIWmTMuV.js";
3
3
  var vt = 512, xt = 0.74;
4
4
  function kt({ accountId: e, worker: t, beUrl: r, devJwtSecret: n, tokenBrokerUrl: o, tokenBrokerAudience: i, defaultLocale: a, tools: s = {}, beacon: c, confirmation: d, memory: f = Oe() }) {
5
5
  let b = 1;
@@ -38,6 +38,7 @@ export interface BeClient {
38
38
  signal?: AbortSignal;
39
39
  cacheTtlS?: number;
40
40
  cacheKey?: string;
41
+ cacheFreshness?: string;
41
42
  browserCache?: BrowserCachePolicy;
42
43
  }): Promise<unknown>;
43
44
  }
@@ -80,6 +81,7 @@ export interface BeOpStep {
80
81
  cache?: FlowValue<BeOpCachePolicy | false | null | undefined>;
81
82
  cacheTtlS?: FlowValue<number | undefined>;
82
83
  cacheKey?: FlowValue<string | undefined>;
84
+ cacheFreshness?: FlowValue<string | undefined>;
83
85
  browserCache?: FlowValue<BrowserCachePolicy | undefined>;
84
86
  timeoutMs?: FlowValue<number | undefined>;
85
87
  confirm?: FlowConfirmationGate;
@@ -24,6 +24,7 @@ export interface InvokeBeOpArgs {
24
24
  input?: unknown;
25
25
  cacheTtlS?: number | undefined;
26
26
  cacheKey?: string | undefined;
27
+ cacheFreshness?: string | undefined;
27
28
  browserCache?: BrowserCachePolicy | undefined;
28
29
  signal?: AbortSignal | undefined;
29
30
  interceptors?: BeClientInterceptors | undefined;
@@ -1,53 +1,53 @@
1
1
  import { buildPhotoSimilarityProfile as G, buildProductSimilarityProfile as X, buildSimilarityQueries as Y, normalizeSimilarityText as Z, rankSimilarProducts as tt, rankSimilarProductsAsync as et, scoreSimilarityCandidate as rt, tokenizeSimilarityText as at } from "./algos/similarity.js";
2
- import { $ as A, A as nt, At as st, B as b, C as ct, Ct as T, D as it, Dt as C, E as lt, Et as ut, F as dt, G as pt, H as U, I as yt, J as mt, K as ft, L as I, M as _t, N as gt, O as ht, P as R, Q as B, R as F, St as Pt, T as kt, Tt as wt, U as vt, V as M, W as St, X as xt, Y as At, Z as bt, _ as Tt, _t as Ct, a as Ut, at as K, b as It, bt as Rt, c as Bt, ct as Ft, d as Mt, dt as S, et as Kt, f as Lt, ft as L, g as jt, gt as j, h as Et, ht as zt, i as Ot, it as qt, j as Jt, k as Nt, kt as $t, l as Dt, lt as Ht, m as Wt, mt as Qt, n as Vt, nt as Gt, o as Xt, ot as Yt, p as Zt, pt as te, q as ee, r as re, rt as ae, s as oe, st as ne, t as se, tt as E, u as ce, ut as ie, v as le, vt as ue, w as de, wt as pe, xt as z, y as ye, yt as O, z as me } from "../agent-ui-steps-WKbTVOS4.js";
2
+ import { $ as A, A as nt, At as st, B as b, C as ct, Ct as T, D as it, Dt as C, E as lt, Et as ut, F as dt, G as pt, H as U, I as yt, J as mt, K as ft, L as I, M as _t, N as gt, O as Pt, P as R, Q as B, R as F, St as ht, T as kt, Tt as wt, U as vt, V as M, W as St, X as xt, Y as At, Z as bt, _ as Tt, _t as Ct, a as Ut, at as K, b as It, bt as Rt, c as Bt, ct as Ft, d as Mt, dt as S, et as Kt, f as Lt, ft as L, g as jt, gt as j, h as Et, ht as zt, i as Ot, it as qt, j as Jt, k as Nt, kt as $t, l as Dt, lt as Ht, m as Wt, mt as Qt, n as Vt, nt as Gt, o as Xt, ot as Yt, p as Zt, pt as te, q as ee, r as re, rt as ae, s as oe, st as ne, t as se, tt as E, u as ce, ut as ie, v as le, vt as ue, w as de, wt as pe, xt as z, y as ye, yt as O, z as me } from "../agent-ui-steps-DIWmTMuV.js";
3
3
  function fe(t) {
4
4
  const e = self, r = /* @__PURE__ */ new Map(), a = C(e), u = B(a);
5
- let s = null, y = null, p = null, g = "", f = "idle";
6
- e.addEventListener("message", (n) => {
7
- const o = n.data;
8
- if (o) {
9
- if (o.type === "abort") {
10
- typeof o.id == "number" && (r.get(o.id)?.abort(), r.delete(o.id));
5
+ let c = null, y = null, p = null, m = "", _ = "idle";
6
+ e.addEventListener("message", (o) => {
7
+ const n = o.data;
8
+ if (n) {
9
+ if (n.type === "abort") {
10
+ typeof n.id == "number" && (r.get(n.id)?.abort(), r.delete(n.id));
11
11
  return;
12
12
  }
13
- o.type === "invoke" && _(o);
13
+ n.type === "invoke" && P(n);
14
14
  }
15
15
  });
16
- async function _(n) {
17
- if (f !== "idle") {
16
+ async function P(o) {
17
+ if (_ !== "idle") {
18
18
  const l = (k) => {
19
19
  e.postMessage({
20
- id: n.id,
20
+ id: o.id,
21
21
  type: "event",
22
22
  event: k
23
23
  });
24
24
  };
25
25
  l(L("agent_busy", "Another shopper turn is already in flight; please try again in a moment.")), l(S()), e.postMessage({
26
- id: n.id,
26
+ id: o.id,
27
27
  type: "end"
28
28
  });
29
29
  return;
30
30
  }
31
- f = "in_turn", s = {
32
- accountId: String(n.accountId || t.accountId || ""),
33
- beUrl: n.beUrl || "",
34
- ...n.devJwtSecret ? { devJwtSecret: n.devJwtSecret } : {},
35
- ...n.tokenBrokerUrl ? { tokenBrokerUrl: n.tokenBrokerUrl } : {},
36
- ...n.tokenBrokerAudience ? { tokenBrokerAudience: n.tokenBrokerAudience } : {},
37
- locale: n.defaultLocale || t.defaultLocale || "en-GB",
38
- parentUrl: n.parentUrl || ""
31
+ _ = "in_turn", c = {
32
+ accountId: String(o.accountId || t.accountId || ""),
33
+ beUrl: o.beUrl || "",
34
+ ...o.devJwtSecret ? { devJwtSecret: o.devJwtSecret } : {},
35
+ ...o.tokenBrokerUrl ? { tokenBrokerUrl: o.tokenBrokerUrl } : {},
36
+ ...o.tokenBrokerAudience ? { tokenBrokerAudience: o.tokenBrokerAudience } : {},
37
+ locale: o.defaultLocale || t.defaultLocale || "en-GB",
38
+ parentUrl: o.parentUrl || ""
39
39
  };
40
- const o = [
41
- s.accountId,
42
- s.devJwtSecret || "",
43
- s.tokenBrokerUrl || "",
44
- s.tokenBrokerAudience || ""
40
+ const n = [
41
+ c.accountId,
42
+ c.devJwtSecret || "",
43
+ c.tokenBrokerUrl || "",
44
+ c.tokenBrokerAudience || ""
45
45
  ].join(`
46
46
  `);
47
- (!p || g !== o) && (p = z(s), g = o), y ||= new T({
48
- accountId: s.accountId,
49
- locale: s.locale,
50
- parentUrl: s.parentUrl,
47
+ (!p || m !== n) && (p = z(c), m = n), y ||= new T({
48
+ accountId: c.accountId,
49
+ locale: c.locale,
50
+ parentUrl: c.parentUrl,
51
51
  rpc: a,
52
52
  persistentPanelKeys: t.contextPersistence?.panelKeys,
53
53
  panelKeyLimits: t.contextPersistence?.panelKeyLimits,
@@ -55,25 +55,25 @@ function fe(t) {
55
55
  maxThreads: t.contextPersistence?.maxThreads,
56
56
  threadTtlMs: t.contextPersistence?.threadTtlMs
57
57
  });
58
- const c = new AbortController();
59
- r.set(n.id, c);
58
+ const s = new AbortController();
59
+ r.set(o.id, s);
60
60
  const i = (l) => {
61
61
  e.postMessage({
62
- id: n.id,
62
+ id: o.id,
63
63
  type: "event",
64
64
  event: l
65
65
  });
66
66
  }, d = (l) => {
67
- n.debugActivity === !0 && e.postMessage({
68
- id: n.id,
67
+ o.debugActivity === !0 && e.postMessage({
68
+ id: o.id,
69
69
  type: "activity",
70
70
  entry: l
71
71
  });
72
72
  };
73
73
  try {
74
- const l = s, k = p;
74
+ const l = c, k = p;
75
75
  await A({
76
- request: n.request || {},
76
+ request: o.request || {},
77
77
  accountModule: {
78
78
  ...t,
79
79
  accountId: l.accountId,
@@ -93,41 +93,42 @@ function fe(t) {
93
93
  toolBridge: u,
94
94
  emit: i,
95
95
  rpc: a,
96
- signal: c.signal
96
+ signal: s.signal
97
97
  }), e.postMessage({
98
- id: n.id,
98
+ id: o.id,
99
99
  type: "end"
100
100
  });
101
101
  } catch (l) {
102
- c.signal.aborted || (i(O(l)), i(S()), e.postMessage({
103
- id: n.id,
102
+ s.signal.aborted || (i(O(l)), i(S()), e.postMessage({
103
+ id: o.id,
104
104
  type: "end"
105
105
  }));
106
106
  } finally {
107
- r.delete(n.id), f = "idle";
107
+ r.delete(o.id), _ = "idle";
108
108
  }
109
109
  }
110
110
  }
111
111
  function q({ config: t, jwtProvider: e, postActivity: r }) {
112
- return { async invoke({ op: a, input: u, signal: s, cacheTtlS: y, cacheKey: p, browserCache: g }) {
113
- const f = performance.now(), _ = t.accountId.replace(/-agentic$/u, ""), n = `${String(t.beUrl).replace(/\/+$/u, "")}/v1/execute`;
112
+ return { async invoke({ op: a, input: u, signal: c, cacheTtlS: y, cacheKey: p, cacheFreshness: m, browserCache: _ }) {
113
+ const P = performance.now(), o = t.accountId.replace(/-agentic$/u, ""), n = `${String(t.beUrl).replace(/\/+$/u, "")}/v1/execute`;
114
114
  r({
115
115
  kind: "be/request",
116
116
  source: "worker-fetch",
117
117
  url: n,
118
118
  op: a,
119
- opDomain: _,
119
+ opDomain: o,
120
120
  params: u || {},
121
121
  rawBody: {
122
- op_domain: _,
122
+ op_domain: o,
123
123
  op_name: a,
124
124
  op_payload: u,
125
125
  ...y !== void 0 ? { cache_ttl_s: y } : {},
126
- ...p !== void 0 ? { cache_key: p } : {}
126
+ ...p !== void 0 ? { cache_key: p } : {},
127
+ ...m !== void 0 ? { cache_freshness: m } : {}
127
128
  }
128
129
  });
129
130
  try {
130
- const o = await j({
131
+ const s = await j({
131
132
  beUrl: t.beUrl,
132
133
  accountId: t.accountId,
133
134
  jwtProvider: e,
@@ -136,8 +137,9 @@ function q({ config: t, jwtProvider: e, postActivity: r }) {
136
137
  input: u,
137
138
  cacheTtlS: y,
138
139
  cacheKey: p,
139
- browserCache: g,
140
- ...s ? { signal: s } : {}
140
+ cacheFreshness: m,
141
+ browserCache: _,
142
+ ...c ? { signal: c } : {}
141
143
  });
142
144
  return r({
143
145
  kind: "be/response",
@@ -145,20 +147,20 @@ function q({ config: t, jwtProvider: e, postActivity: r }) {
145
147
  url: n,
146
148
  status: 200,
147
149
  op: a,
148
- opDomain: _,
149
- latencyMs: Math.max(0, Math.round(performance.now() - f)),
150
- result: o
151
- }), o;
152
- } catch (o) {
150
+ opDomain: o,
151
+ latencyMs: Math.max(0, Math.round(performance.now() - P)),
152
+ result: s
153
+ }), s;
154
+ } catch (s) {
153
155
  throw r({
154
156
  kind: "be/response",
155
157
  source: "worker-fetch",
156
158
  url: n,
157
159
  op: a,
158
- opDomain: _,
159
- latencyMs: Math.max(0, Math.round(performance.now() - f)),
160
- error: o instanceof Error ? o.message : String(o)
161
- }), o;
160
+ opDomain: o,
161
+ latencyMs: Math.max(0, Math.round(performance.now() - P)),
162
+ error: s instanceof Error ? s.message : String(s)
163
+ }), s;
162
164
  }
163
165
  } };
164
166
  }
@@ -179,72 +181,72 @@ function N(t) {
179
181
  function _e(t, e = {}) {
180
182
  return e[t?.type || t?.action?.type] || "";
181
183
  }
182
- function ge({ accountId: t, cacheTtlS: e = 3600, browserCacheTtlMs: r, promptVersion: a = J, cacheable: u = !0, piiPatternPack: s = w, utterance: y, compactPageContext: p = D, compactStructuredContext: g = H, extraInput: f, cacheKeyParts: _, onError: n = [] } = {}) {
184
+ function ge({ accountId: t, cacheTtlS: e = 3600, browserCacheTtlMs: r, promptVersion: a = J, cacheable: u = !0, piiPatternPack: c = w, utterance: y, compactPageContext: p = D, compactStructuredContext: m = H, extraInput: _, cacheKeyParts: P, onError: o = [] } = {}) {
183
185
  return {
184
186
  kind: "be_op",
185
187
  op: "intent",
186
- input: (o) => {
187
- const { request: c, context: i, bag: d, accountConfig: l } = o;
188
- return I(h({
189
- utterance: x(c, {
190
- request: c,
188
+ input: (n) => {
189
+ const { request: s, context: i, bag: d, accountConfig: l } = n;
190
+ return I(g({
191
+ utterance: x(s, {
192
+ request: s,
191
193
  context: i,
192
194
  bag: d,
193
195
  accountConfig: l
194
- }, y, s),
195
- page_context: m(p, d.page, o),
196
- structured_context: m(g, i, o),
196
+ }, y, c),
197
+ page_context: f(p, d.page, n),
198
+ structured_context: f(m, i, n),
197
199
  locale: i.meta.locale,
198
- ...h(m(f, o))
200
+ ...g(f(_, n))
199
201
  }), l, "intent");
200
202
  },
201
203
  out: "route",
202
- cache: (o) => m(u, o) ? R({
204
+ cache: (n) => f(u, n) ? R({
203
205
  ttlS: e,
204
206
  promptVersion: a
205
207
  }) : void 0,
206
208
  ...r ? { browserCache: { ttlMs: r } } : {},
207
- cacheKey: ({ request: o, context: c, bag: i, accountConfig: d }) => {
208
- if (m(u, {
209
- request: o,
210
- context: c,
209
+ cacheKey: ({ request: n, context: s, bag: i, accountConfig: d }) => {
210
+ if (f(u, {
211
+ request: n,
212
+ context: s,
211
213
  bag: i,
212
214
  accountConfig: d
213
215
  }))
214
216
  return E("intent", {
215
217
  account: t,
216
218
  prompt: a,
217
- locale: c.meta.locale,
218
- utterance: K(x(o, {
219
- request: o,
220
- context: c,
219
+ locale: s.meta.locale,
220
+ utterance: K(x(n, {
221
+ request: n,
222
+ context: s,
221
223
  bag: i,
222
224
  accountConfig: d
223
- }, y, s), c.meta.locale),
224
- page: m(p, i.page, {
225
- request: o,
226
- context: c,
225
+ }, y, c), s.meta.locale),
226
+ page: f(p, i.page, {
227
+ request: n,
228
+ context: s,
227
229
  bag: i,
228
230
  accountConfig: d
229
231
  }),
230
- panel: m(g, c, {
231
- request: o,
232
- context: c,
232
+ panel: f(m, s, {
233
+ request: n,
234
+ context: s,
233
235
  bag: i,
234
236
  accountConfig: d
235
237
  }),
236
- ...h(m(_, {
237
- request: o,
238
- context: c,
238
+ ...g(f(P, {
239
+ request: n,
240
+ context: s,
239
241
  bag: i,
240
242
  accountConfig: d
241
243
  }))
242
244
  });
243
245
  },
244
- onError: n
246
+ onError: o
245
247
  };
246
248
  }
247
- function he(t, e = "product") {
249
+ function Pe(t, e = "product") {
248
250
  const r = String(t?.intent?.kind || t?.kind || "").trim();
249
251
  return {
250
252
  product_search: "search",
@@ -261,12 +263,12 @@ function he(t, e = "product") {
261
263
  handOffShopping: "consulting"
262
264
  }[r] || r || e;
263
265
  }
264
- function Pe(t, e) {
266
+ function he(t, e) {
265
267
  return $(t, e).query || "";
266
268
  }
267
269
  function $(t, e) {
268
270
  const r = e.route?.search_params || e.route?.searchParams || {}, a = t?.payload || {}, u = r.query || a.query;
269
- return h({
271
+ return g({
270
272
  ...r,
271
273
  query: u,
272
274
  text: r.text || a.text,
@@ -284,7 +286,7 @@ function ke(t) {
284
286
  }
285
287
  function D(t = {}) {
286
288
  const e = t?.product && typeof t.product == "object" ? t.product : null;
287
- return h({
289
+ return g({
288
290
  pageType: t?.pageType || t?.type || "other",
289
291
  sku: t?.sku || e?.sku,
290
292
  product_name: e?.name || e?.title,
@@ -293,7 +295,7 @@ function D(t = {}) {
293
295
  }
294
296
  function H(t = {}) {
295
297
  const e = t.panel || {};
296
- return h({
298
+ return g({
297
299
  screen_type: e.screen_type,
298
300
  screen_sku_list: Array.isArray(e.screen_sku_list) ? e.screen_sku_list.slice(0, 24) : void 0,
299
301
  chat_mentioned_skus: Array.isArray(e.chat_mentioned_skus) ? e.chat_mentioned_skus.slice(0, 12) : void 0,
@@ -302,28 +304,28 @@ function H(t = {}) {
302
304
  });
303
305
  }
304
306
  function W(t) {
305
- return !t || typeof t != "object" ? null : h({
306
- query: P(t.query),
307
+ return !t || typeof t != "object" ? null : g({
308
+ query: h(t.query),
307
309
  source: t.source,
308
310
  count: t.count,
309
- category: P(t.category),
310
- goal: P(t.goal)
311
+ category: h(t.category),
312
+ goal: h(t.goal)
311
313
  });
312
314
  }
313
315
  function Q(t, e = w) {
314
- return F(t, e) || P(U(t) || N(t), e);
316
+ return F(t, e) || h(U(t) || N(t), e);
315
317
  }
316
318
  function x(t, e, r, a) {
317
- const u = m(r, t, e);
319
+ const u = f(r, t, e);
318
320
  return u ? String(u) : Q(t, a);
319
321
  }
320
- function P(t, e = w) {
322
+ function h(t, e = w) {
321
323
  return M(String(t || ""), e);
322
324
  }
323
- function m(t, e, r) {
325
+ function f(t, e, r) {
324
326
  return typeof t == "function" ? t(e, r) : t;
325
327
  }
326
- function h(t) {
328
+ function g(t) {
327
329
  return Object.fromEntries(Object.entries(t || {}).filter(([, e]) => e != null && e !== "" && (!Array.isArray(e) || e.length)));
328
330
  }
329
331
  export {
@@ -348,7 +350,7 @@ export {
348
350
  Lt as coalesceAddToCart,
349
351
  yt as compactAccountConfig,
350
352
  bt as compactContextProducts,
351
- ht as compactObject,
353
+ Pt as compactObject,
352
354
  It as compactProductSurfaceForLlm,
353
355
  At as comparisonResultForUi,
354
356
  pt as comparisonUiSpec,
@@ -379,7 +381,7 @@ export {
379
381
  ct as mergeProductSurfaceEvidence,
380
382
  Xt as mergeRoundProducts,
381
383
  te as metadata,
382
- Pt as mintDevJwt,
384
+ ht as mintDevJwt,
383
385
  xt as normalizeComparisonTable,
384
386
  Yt as normalizeProduct,
385
387
  Z as normalizeSimilarityText,
@@ -399,7 +401,7 @@ export {
399
401
  le as retailAnonymousRequestText,
400
402
  ye as retailRedactPii,
401
403
  Et as routeFlowParams,
402
- he as routeKind,
404
+ Pe as routeKind,
403
405
  jt as routeSkuList,
404
406
  N as routeText,
405
407
  st as runMainRpc,
@@ -407,7 +409,7 @@ export {
407
409
  rt as scoreSimilarityCandidate,
408
410
  oe as searchFollowUpPills,
409
411
  $ as searchInputFromRoute,
410
- Pe as searchQueryFromRoute,
412
+ he as searchQueryFromRoute,
411
413
  Ut as shouldCompact,
412
414
  Zt as singleFlight,
413
415
  qt as stableKey,