@gengage/assistant-fe 0.6.19 → 0.6.22

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.
Files changed (76) hide show
  1. package/README.md +4 -2
  2. package/dist/agentic/adaptor/create-adaptor.d.ts +6 -3
  3. package/dist/agentic/adaptor/mount.d.ts +8 -2
  4. package/dist/agentic/{similarity.d.ts → algos/similarity.d.ts} +11 -2
  5. package/dist/agentic/algos/similarity.js +261 -0
  6. package/dist/agentic/context/chat-context.d.ts +4 -2
  7. package/dist/agentic/context/context-store.d.ts +11 -1
  8. package/dist/agentic/context/persistence.d.ts +1 -0
  9. package/dist/agentic/contracts/agentic-contracts.d.ts +133 -0
  10. package/dist/agentic/debug/activity-collector.d.ts +14 -0
  11. package/dist/agentic/debug/activity-instrumentation.d.ts +22 -0
  12. package/dist/agentic/debug/activity-overlay.d.ts +3 -0
  13. package/dist/agentic/debug/activity-state.d.ts +37 -0
  14. package/dist/agentic/debug/local-dev.d.ts +18 -0
  15. package/dist/agentic/events/product-normalize.d.ts +4 -1
  16. package/dist/agentic/events/ui-specs.d.ts +8 -4
  17. package/dist/agentic/index.d.ts +25 -2
  18. package/dist/agentic/index.js +2792 -441
  19. package/dist/agentic/types.d.ts +77 -4
  20. package/dist/agentic/util/common/declarative-cache.d.ts +21 -0
  21. package/dist/agentic/util/common/fallback-status.d.ts +10 -0
  22. package/dist/agentic/util/common/flow-steps.d.ts +8 -0
  23. package/dist/agentic/util/common/gss-tool-aliases.d.ts +66 -0
  24. package/dist/agentic/util/common/iframe-scraper.d.ts +22 -0
  25. package/dist/agentic/util/common/llm-routing.d.ts +50 -0
  26. package/dist/agentic/util/common/object.d.ts +1 -0
  27. package/dist/agentic/util/common/open-product-page.d.ts +30 -0
  28. package/dist/agentic/util/common/panel-context.d.ts +3 -0
  29. package/dist/agentic/util/common/privacy.d.ts +14 -0
  30. package/dist/agentic/util/common/product-resolver.d.ts +20 -0
  31. package/dist/agentic/util/common/product-surface.d.ts +24 -0
  32. package/dist/agentic/util/common/ref-store.d.ts +15 -0
  33. package/dist/agentic/util/common/retail-privacy.d.ts +4 -0
  34. package/dist/agentic/util/common/route-params.d.ts +3 -0
  35. package/dist/agentic/util/common/similarity-ranking.d.ts +2 -0
  36. package/dist/agentic/util/common/site-awareness.d.ts +130 -0
  37. package/dist/agentic/util/lazy-runtime-loader.d.ts +2 -1
  38. package/dist/agentic/worker/rpc.d.ts +26 -6
  39. package/dist/agentic/worker.d.ts +15 -2
  40. package/dist/agentic/worker.js +316 -119
  41. package/dist/agentic.iife.js +352 -6
  42. package/dist/{api-paths-lIioK7-S.js → api-paths-DE3_TyTw.js} +1 -1
  43. package/dist/chat/history-storage.d.ts +1 -0
  44. package/dist/chat/runtime.d.ts +1 -1
  45. package/dist/chat/types.d.ts +1 -0
  46. package/dist/chat-runtime.js +1 -1
  47. package/dist/chat.iife.js +10 -10
  48. package/dist/chat.js +1 -1
  49. package/dist/{common-8WOyaL9-.js → common-BWnFHbvv.js} +2 -2
  50. package/dist/common.js +8 -8
  51. package/dist/{connection-warning-CBR0CWsY.js → connection-warning-Tk4ZjgMi.js} +1 -1
  52. package/dist/{context-heG8hv5l.js → context-UTzCGyR9.js} +19 -8
  53. package/dist/{fastIntent-Dw79pmRK.js → fastIntent-DIhMlxVd.js} +2 -2
  54. package/dist/index.js +13 -13
  55. package/dist/{native-webview-NWc9LrJh.js → native-webview-BcwGKkDe.js} +1 -1
  56. package/dist/native.iife.js +6 -6
  57. package/dist/native.js +1 -1
  58. package/dist/{overlay-COzFFq0-.js → overlay-cF2SjxYU.js} +1 -1
  59. package/dist/overlay.js +2 -2
  60. package/dist/qna-runtime.js +1 -1
  61. package/dist/qna.iife.js +1 -1
  62. package/dist/qna.js +1 -1
  63. package/dist/route-params-5KSvTyeb.js +2454 -0
  64. package/dist/{runtime-BsnZ6gt2.js → runtime-CjJy8KKu.js} +4 -4
  65. package/dist/{runtime-w0f2VkzL.js → runtime-H5hNQQKm.js} +51 -48
  66. package/dist/{runtime-D5Sj-_tA.js → runtime-wEP7N2Hr.js} +4 -4
  67. package/dist/{simbut-BvdJtzCu.js → simbut-BlBLtgVy.js} +2 -2
  68. package/dist/simbut.iife.js +1 -1
  69. package/dist/simbut.js +1 -1
  70. package/dist/{simrel-DU6a27g9.js → simrel-S6-OsWJ9.js} +2 -2
  71. package/dist/simrel-runtime.js +1 -1
  72. package/dist/simrel.iife.js +2 -2
  73. package/dist/simrel.js +2 -2
  74. package/dist/{widget-base-BeWuIxD6.js → widget-base-e4JwEf2I.js} +2 -2
  75. package/package.json +5 -1
  76. package/dist/account-config-D_EMuR0g.js +0 -1479
@@ -1,12 +1,29 @@
1
- import type { AgentBeaconPayload, RpcFn, ToolMap } from '../types.js';
2
- interface MemoryLike {
1
+ import type { AgentBeaconPayload, ConfirmationCallback, AgentMemoryProvider, BrowserMemory, RpcFn, ToolMap } from '../types.js';
2
+ interface StorageMemoryLike {
3
3
  getItem: (key: string) => string | null;
4
4
  setItem: (key: string, value: string) => void;
5
+ removeItem?: (key: string) => void;
6
+ }
7
+ export type MainRpcMemory = StorageMemoryLike | BrowserMemory | AgentMemoryProvider;
8
+ interface MainRpcRefStore {
9
+ put: (value: unknown, options?: {
10
+ kind?: string;
11
+ ttlMs?: number;
12
+ }) => Promise<{
13
+ kind: string;
14
+ id: string;
15
+ }>;
16
+ get: (refOrId: unknown) => Promise<unknown>;
17
+ delete: (refOrId: unknown) => Promise<void>;
18
+ materialize: (value: unknown) => Promise<unknown>;
19
+ cleanup?: () => void;
5
20
  }
6
21
  interface MainRpcDeps {
7
22
  tools: ToolMap;
8
23
  beacon?: ((payload: AgentBeaconPayload) => void) | undefined;
9
- memory: MemoryLike;
24
+ confirmation?: ConfirmationCallback | undefined;
25
+ memory: MainRpcMemory;
26
+ refStore?: MainRpcRefStore | undefined;
10
27
  }
11
28
  interface RpcScope {
12
29
  addEventListener: (type: 'message', listener: (event: MessageEvent) => void) => void;
@@ -17,8 +34,11 @@ interface HandleMainRpcArgs {
17
34
  worker: Worker;
18
35
  tools?: ToolMap;
19
36
  beacon?: (payload: AgentBeaconPayload) => void;
20
- memory?: MemoryLike;
37
+ confirmation?: ConfirmationCallback;
38
+ memory?: MainRpcMemory;
39
+ refStore?: MainRpcRefStore;
21
40
  }
22
- export declare function handleMainRpc({ worker, tools, beacon, memory }: HandleMainRpcArgs): void;
23
- export declare function runMainRpc(method: string, payload: unknown, { tools, beacon, memory }: MainRpcDeps): Promise<unknown>;
41
+ export declare function handleMainRpc({ worker, tools, beacon, confirmation, memory, refStore, }: HandleMainRpcArgs): void;
42
+ export declare function defaultMainRpcMemory(): StorageMemoryLike;
43
+ export declare function runMainRpc(method: string, payload: unknown, { tools, beacon, confirmation, memory, refStore }: MainRpcDeps): Promise<unknown>;
24
44
  export {};
@@ -1,4 +1,5 @@
1
1
  export { ContextStore } from './context/context-store.js';
2
+ export { stickyContextKey } from './context/persistence.js';
2
3
  export { action, done, error, metadata, textChunk, uiSpec } from './events/builders.js';
3
4
  export { AgentError, beErrorToAgentError, caughtToStreamError, httpErrorToAgentError, } from './events/error-taxonomy.js';
4
5
  export { normalizeProduct, trimProductFactsCore, trimProductFactsListCore } from './events/product-normalize.js';
@@ -7,7 +8,7 @@ export { alignProductsToTable, comparisonResultForUi, normalizeComparisonTable }
7
8
  export { actionButtonsUiSpec, comparisonUiSpec, productDetailsUiSpec, productsUiSpec } from './events/ui-specs.js';
8
9
  export { createFlow } from './flow/create-flow.js';
9
10
  export { resolveFlow } from './flow/dispatch.js';
10
- export { buildPhotoSimilarityProfile, buildProductSimilarityProfile, buildSimilarityQueries, normalizeSimilarityText, rankSimilarProducts, scoreSimilarityCandidate, tokenizeSimilarityText, type PhotoSimilaritySignals, type ProductSimilarityProfile, type SimilarityProductLike, type SimilarityRankedProduct, type SimilarityRankingOptions, type SimilarityScore, type SimilarityWeights, } from './similarity.js';
11
+ export { buildPhotoSimilarityProfile, buildProductSimilarityProfile, buildSimilarityQueries, normalizeSimilarityText, rankSimilarProducts, rankSimilarProductsAsync, scoreSimilarityCandidate, tokenizeSimilarityText, type PhotoSimilaritySignals, type ProductSimilarityProfile, type SimilarityProductLike, type SimilarityAsyncRankingOptions, type SimilarityRankedProduct, type SimilarityRankingOptions, type SimilarityScore, type SimilarityWeights, } from './algos/similarity.js';
11
12
  export { requestText } from './util/request-text.js';
12
13
  export { anonymousRequestText, defaultPiiPatternPack, defaultPiiPatterns, redactPii } from './util/privacy.js';
13
14
  export { compactAccountConfig, withAccountConfig } from './util/account-config.js';
@@ -21,5 +22,17 @@ export { startWorker } from './worker/entry.js';
21
22
  export { runTurn } from './worker/flow-runner.js';
22
23
  export { createJwtProvider, mintDevJwt } from './worker/jwt-mint.js';
23
24
  export { createWorkerRpc, handleMainRpc, runMainRpc } from './worker/rpc.js';
25
+ export type { MainRpcMemory } from './worker/rpc.js';
24
26
  export { createToolBridge } from './worker/tool-bridge.js';
25
- export type { AccountModule, AdapterStep, AgentBeaconPayload, BeClient, BeOpStep, BranchStep, BrowserCachePolicy, ChatContext, CommitStep, EmitStep, Flow, FlowAdapterFn, FlowAdapterMap, FlowPatch, FlowStep, FlowStepCtx, FlowValue, ParallelStep, RefusalStep, ToolFn, ToolMap, ToolStep, } from './types.js';
27
+ export { declarativeBeOpCache, inputHashCachePolicy, withDeclarativeBeOpCache, } from './util/common/declarative-cache.js';
28
+ export { FALLBACK_STATUS, fallbackStatus, isFallbackStatus } from './util/common/fallback-status.js';
29
+ export { createReadPageStep } from './util/common/flow-steps.js';
30
+ export { explicitRoute, flowParamsFromRoute, llmIntentStep, routeKind, routeText, searchInputFromRoute, searchQueryFromRoute, } from './util/common/llm-routing.js';
31
+ export { compactObject } from './util/common/object.js';
32
+ export { homePanelReset } from './util/common/panel-context.js';
33
+ export { createPrivacyHelpers, plainMessageContent } from './util/common/privacy.js';
34
+ export { compactProductSurfaceForLlm, mergeProductSurfaceEvidence, productSurfaceReviewText, } from './util/common/product-surface.js';
35
+ export { anonymousRequestText as retailAnonymousRequestText, anonymizeMessages as retailAnonymizeMessages, redactPii as retailRedactPii, } from './util/common/retail-privacy.js';
36
+ export { firstArrayValue, routeFlowParams, routeSkuList } from './util/common/route-params.js';
37
+ export type { AccountModule, AgentConfirmationRequest, AgentConfirmationResult, AgentMemoryProvider, AgentTraceCallback, AgentTraceEvent, AdapterStep, AgentBeaconPayload, Awaitable, BeClient, BeOpStep, BranchStep, BrowserCachePolicy, ChatContext, CommitStep, EmitStep, Flow, FlowAdapterFn, FlowAdapterMap, FlowConfirmationGate, FlowConfirmationRequest, FlowConfirmationValue, FlowPatch, FlowStep, FlowStepCtx, FlowValue, MemoryTier, ParallelStep, RefusalStep, ToolFn, ToolMap, ToolStep, } from './types.js';
38
+ export type { BeOpInputBase, CompareInput, CompareOutput, GssInstallmentOption, GssProductDetails, GssProductFeature, GssProductQuestionAnswer, GssProductReview, GssProductSeller, GssShippingOption, IntentOpInput, IntentOpOutput, LocaleCode, MoneyValue, ProductAnswerInput, ProductAnswerOutput, RefPayload, UiSpec, UiSpecElement, UiSpecElementType, UiSpecEvent, } from './contracts/agentic-contracts.js';
@@ -1,145 +1,342 @@
1
- import { $ as E, A as J, B as g, C as F, D as L, E as R, F as j, G as q, H as z, I as m, J as x, K as B, L as M, M as C, N as I, O as D, P as W, Q as G, R as O, S as Q, T as H, U as N, V as T, W as K, X as V, Y as X, Z as h, _ as Y, a as Z, b as _, c as $, d as ee, f as te, g as re, h as oe, i as ae, j as ne, k as ie, l as ce, m as se, n as le, o as de, p as ue, q as pe, r as ke, s as ye, t as Pe, u as fe, v as Se, w as be, x as ve, y as Ue, z as we } from "../account-config-D_EMuR0g.js";
2
- function me(a) {
3
- const n = self, i = /* @__PURE__ */ new Map(), c = h(n), y = C(c);
4
- let t = null, u = null, s = null, p = "";
5
- n.addEventListener("message", (e) => {
6
- const r = e.data;
7
- if (r) {
8
- if (r.type === "abort") {
9
- typeof r.id == "number" && (i.get(r.id)?.abort(), i.delete(r.id));
1
+ import { buildPhotoSimilarityProfile as X, buildProductSimilarityProfile as Y, buildSimilarityQueries as Z, normalizeSimilarityText as tt, rankSimilarProducts as et, rankSimilarProductsAsync as rt, scoreSimilarityCandidate as at, tokenizeSimilarityText as ot } from "./algos/similarity.js";
2
+ import { $ as ct, A as st, B as b, C as it, D as I, E as ut, F as lt, G as U, H as dt, I as pt, J as yt, K as mt, L as ft, M as _t, N as Pt, O as C, P as gt, Q as kt, R as ht, S as St, T as R, U as xt, V as B, W as vt, X as wt, Y as At, Z as K, _ as Tt, a as bt, at as F, b as It, ct as Ut, d as Ct, dt as Rt, et as Bt, f as Kt, ft as Ft, g as Lt, gt as jt, h as zt, ht as Et, i as Ot, it as Mt, j as Jt, k as L, lt as j, m as Nt, n as qt, nt as z, o as Dt, ot as $t, p as Ht, pt as E, q as Qt, r as Vt, rt as Wt, s as Gt, st as O, t as Xt, tt as Yt, u as Zt, ut as te, v as ee, w as M, x as J, y as re, z as N } from "../route-params-5KSvTyeb.js";
3
+ function ae(t) {
4
+ const e = self, r = /* @__PURE__ */ new Map(), a = E(e), d = N(a);
5
+ let i = null, f = null, m = null, _ = "";
6
+ e.addEventListener("message", (o) => {
7
+ const u = o.data;
8
+ if (u) {
9
+ if (u.type === "abort") {
10
+ typeof u.id == "number" && (r.get(u.id)?.abort(), r.delete(u.id));
10
11
  return;
11
12
  }
12
- r.type === "invoke" && P(r);
13
+ u.type === "invoke" && k(u);
13
14
  }
14
15
  });
15
- async function P(e) {
16
- t = {
17
- accountId: String(e.accountId || a.accountId || ""),
18
- beUrl: e.beUrl || "",
19
- ...e.devJwtSecret ? { devJwtSecret: e.devJwtSecret } : {},
20
- ...e.tokenBrokerUrl ? { tokenBrokerUrl: e.tokenBrokerUrl } : {},
21
- ...e.tokenBrokerAudience ? { tokenBrokerAudience: e.tokenBrokerAudience } : {},
22
- locale: e.defaultLocale || a.defaultLocale || "en-GB",
23
- parentUrl: e.parentUrl || ""
16
+ async function k(o) {
17
+ i = {
18
+ accountId: String(o.accountId || t.accountId || ""),
19
+ beUrl: o.beUrl || "",
20
+ ...o.devJwtSecret ? { devJwtSecret: o.devJwtSecret } : {},
21
+ ...o.tokenBrokerUrl ? { tokenBrokerUrl: o.tokenBrokerUrl } : {},
22
+ ...o.tokenBrokerAudience ? { tokenBrokerAudience: o.tokenBrokerAudience } : {},
23
+ locale: o.defaultLocale || t.defaultLocale || "en-GB",
24
+ parentUrl: o.parentUrl || ""
24
25
  };
25
- const r = [
26
- t.accountId,
27
- t.devJwtSecret || "",
28
- t.tokenBrokerUrl || "",
29
- t.tokenBrokerAudience || ""
26
+ const u = [
27
+ i.accountId,
28
+ i.devJwtSecret || "",
29
+ i.tokenBrokerUrl || "",
30
+ i.tokenBrokerAudience || ""
30
31
  ].join(`
31
32
  `);
32
- (!s || p !== r) && (s = B(t), p = r), u ||= new x({
33
- accountId: t.accountId,
34
- locale: t.locale,
35
- parentUrl: t.parentUrl,
36
- rpc: c,
37
- persistentPanelKeys: a.contextPersistence?.panelKeys,
38
- panelKeyLimits: a.contextPersistence?.panelKeyLimits
33
+ (!m || _ !== u) && (m = O(i), _ = u), f ||= new j({
34
+ accountId: i.accountId,
35
+ locale: i.locale,
36
+ parentUrl: i.parentUrl,
37
+ rpc: a,
38
+ persistentPanelKeys: t.contextPersistence?.panelKeys,
39
+ panelKeyLimits: t.contextPersistence?.panelKeyLimits,
40
+ messageLimit: t.contextPersistence?.messageLimit,
41
+ maxThreads: t.contextPersistence?.maxThreads,
42
+ threadTtlMs: t.contextPersistence?.threadTtlMs
39
43
  });
40
- const l = new AbortController();
41
- i.set(e.id, l);
42
- const d = (o) => {
43
- n.postMessage({
44
- id: e.id,
44
+ const c = new AbortController();
45
+ r.set(o.id, c);
46
+ const s = (n) => {
47
+ e.postMessage({
48
+ id: o.id,
45
49
  type: "event",
46
- event: o
50
+ event: n
47
51
  });
48
52
  };
49
53
  try {
50
- const o = t, f = s;
51
- await I({
52
- request: e.request || {},
54
+ const n = i, l = m;
55
+ await b({
56
+ request: o.request || {},
53
57
  accountModule: {
54
- ...a,
55
- accountId: o.accountId
58
+ ...t,
59
+ accountId: n.accountId
56
60
  },
57
- contextStore: u,
58
- beClient: { invoke({ op: S, input: b, signal: k, cacheTtlS: v, cacheKey: U, browserCache: w }) {
59
- return T({
60
- beUrl: o.beUrl,
61
- accountId: o.accountId,
62
- jwtProvider: f,
63
- parentUrl: o.parentUrl,
64
- op: S,
65
- input: b,
66
- cacheTtlS: v,
67
- cacheKey: U,
68
- browserCache: w,
69
- ...k ? { signal: k } : {}
61
+ contextStore: f,
62
+ beClient: { invoke({ op: P, input: v, signal: S, cacheTtlS: w, cacheKey: A, browserCache: T }) {
63
+ return z({
64
+ beUrl: n.beUrl,
65
+ accountId: n.accountId,
66
+ jwtProvider: l,
67
+ parentUrl: n.parentUrl,
68
+ op: P,
69
+ input: v,
70
+ cacheTtlS: w,
71
+ cacheKey: A,
72
+ browserCache: T,
73
+ ...S ? { signal: S } : {}
70
74
  });
71
75
  } },
72
- toolBridge: y,
73
- emit: d,
74
- rpc: c,
75
- signal: l.signal
76
- }), n.postMessage({
77
- id: e.id,
76
+ toolBridge: d,
77
+ emit: s,
78
+ rpc: a,
79
+ signal: c.signal
80
+ }), e.postMessage({
81
+ id: o.id,
78
82
  type: "end"
79
83
  });
80
- } catch (o) {
81
- l.signal.aborted || (d(K(o)), d(m()), n.postMessage({
82
- id: e.id,
84
+ } catch (n) {
85
+ c.signal.aborted || (s(F(n)), s(K()), e.postMessage({
86
+ id: o.id,
83
87
  type: "end"
84
88
  }));
85
89
  } finally {
86
- i.delete(e.id);
90
+ r.delete(o.id);
87
91
  }
88
92
  }
89
93
  }
94
+ var h = { patterns: [
95
+ ...I,
96
+ {
97
+ pattern: /(?:adresim|adres|address)\s*[:=]?\s*[^.;\n]{0,160}/giu,
98
+ replacement: "[address]"
99
+ },
100
+ {
101
+ pattern: /[^\s,.;]{2,}\s+(?:mahallesi|mah\.|sokak|sk\.|cadde|cad\.)\s+[^.;\n]{0,120}/giu,
102
+ replacement: "[address]"
103
+ }
104
+ ] }, q = "llm-flow-routing-v1";
105
+ function D(t) {
106
+ return String(t?.payload?.text || t?.payload?.query || t?.action?.payload?.text || "");
107
+ }
108
+ function oe(t, e = {}) {
109
+ return e[t?.type || t?.action?.type] || "";
110
+ }
111
+ function ne({ accountId: t, cacheTtlS: e = 3600, browserCacheTtlMs: r, promptVersion: a = q, cacheable: d = !0, piiPatternPack: i = h, utterance: f, compactPageContext: m = H, compactStructuredContext: _ = Q, extraInput: k, cacheKeyParts: o, onError: u = [] } = {}) {
112
+ return {
113
+ kind: "be_op",
114
+ op: "intent",
115
+ input: (c) => {
116
+ const { request: s, context: n, bag: l, accountConfig: P } = c;
117
+ return M(y({
118
+ utterance: x(s, {
119
+ request: s,
120
+ context: n,
121
+ bag: l,
122
+ accountConfig: P
123
+ }, f, i),
124
+ page_context: p(m, l.page, c),
125
+ structured_context: p(_, n, c),
126
+ locale: n.meta.locale,
127
+ ...y(p(k, c))
128
+ }), P, "intent");
129
+ },
130
+ out: "route",
131
+ cache: (c) => p(d, c) ? J({
132
+ ttlS: e,
133
+ promptVersion: a
134
+ }) : void 0,
135
+ ...r ? { browserCache: { ttlMs: r } } : {},
136
+ cacheKey: ({ request: c, context: s, bag: n, accountConfig: l }) => {
137
+ if (p(d, {
138
+ request: c,
139
+ context: s,
140
+ bag: n,
141
+ accountConfig: l
142
+ }))
143
+ return B("intent", {
144
+ account: t,
145
+ prompt: a,
146
+ locale: s.meta.locale,
147
+ utterance: U(x(c, {
148
+ request: c,
149
+ context: s,
150
+ bag: n,
151
+ accountConfig: l
152
+ }, f, i), s.meta.locale),
153
+ page: p(m, n.page, {
154
+ request: c,
155
+ context: s,
156
+ bag: n,
157
+ accountConfig: l
158
+ }),
159
+ panel: p(_, s, {
160
+ request: c,
161
+ context: s,
162
+ bag: n,
163
+ accountConfig: l
164
+ }),
165
+ ...y(p(o, {
166
+ request: c,
167
+ context: s,
168
+ bag: n,
169
+ accountConfig: l
170
+ }))
171
+ });
172
+ },
173
+ onError: u
174
+ };
175
+ }
176
+ function ce(t, e = "product") {
177
+ const r = String(t?.intent?.kind || t?.kind || "").trim();
178
+ return {
179
+ product_search: "search",
180
+ add_to_cart: "cart",
181
+ question: "product",
182
+ open_product: "open_product",
183
+ beauty_consulting: "consulting",
184
+ fashion_consulting: "consulting",
185
+ style_consulting: "consulting",
186
+ account_expert: "consulting",
187
+ consulting: "consulting",
188
+ consulting_redirect: "consulting",
189
+ handoff_shopping: "consulting",
190
+ handOffShopping: "consulting"
191
+ }[r] || r || e;
192
+ }
193
+ function se(t, e) {
194
+ return $(t, e).query || "";
195
+ }
196
+ function $(t, e) {
197
+ const r = e.route?.search_params || e.route?.searchParams || {}, a = t?.payload || {}, d = r.query || a.query;
198
+ return y({
199
+ ...r,
200
+ query: d,
201
+ text: r.text || a.text,
202
+ facetParams: r.facetParams || r.facet_params || a.facetParams || a.facet_params,
203
+ facets: r.facets || a.facets,
204
+ categoryName: r.categoryName || r.category_name || a.categoryName || a.category_name,
205
+ categoryId: r.categoryId || r.category_id || a.categoryId || a.category_id,
206
+ size: r.size || a.size || a.beden || a.shoeSize || a.clothingSize,
207
+ budgetMax: r.budgetMax || r.budget_max || r.maxPrice || a.budgetMax || a.budget_max || a.maxPrice,
208
+ maxPrice: r.maxPrice || a.maxPrice
209
+ });
210
+ }
211
+ function ie(t) {
212
+ return (t.route?.flow_params && typeof t.route.flow_params == "object" ? t.route.flow_params : null) || (t.route?.flowParams && typeof t.route.flowParams == "object" ? t.route.flowParams : null) || {};
213
+ }
214
+ function H(t = {}) {
215
+ const e = t?.product && typeof t.product == "object" ? t.product : null;
216
+ return y({
217
+ pageType: t?.pageType || t?.type || "other",
218
+ sku: t?.sku || e?.sku,
219
+ product_name: e?.name || e?.title,
220
+ category_names: Array.isArray(e?.category_names) ? e.category_names.slice(0, 5) : void 0
221
+ });
222
+ }
223
+ function Q(t = {}) {
224
+ const e = t.panel || {};
225
+ return y({
226
+ screen_type: e.screen_type,
227
+ screen_sku_list: Array.isArray(e.screen_sku_list) ? e.screen_sku_list.slice(0, 24) : void 0,
228
+ chat_mentioned_skus: Array.isArray(e.chat_mentioned_skus) ? e.chat_mentioned_skus.slice(0, 12) : void 0,
229
+ last_search: V(e.last_search),
230
+ current_panel_product_count: Array.isArray(e.last_search_products) ? e.last_search_products.length : 0
231
+ });
232
+ }
233
+ function V(t) {
234
+ return !t || typeof t != "object" ? null : y({
235
+ query: g(t.query),
236
+ source: t.source,
237
+ count: t.count,
238
+ category: g(t.category),
239
+ goal: g(t.goal)
240
+ });
241
+ }
242
+ function W(t, e = h) {
243
+ return R(t, e) || g(L(t) || D(t), e);
244
+ }
245
+ function x(t, e, r, a) {
246
+ const d = p(r, t, e);
247
+ return d ? String(d) : W(t, a);
248
+ }
249
+ function g(t, e = h) {
250
+ return C(String(t || ""), e);
251
+ }
252
+ function p(t, e, r) {
253
+ return typeof t == "function" ? t(e, r) : t;
254
+ }
255
+ function y(t) {
256
+ return Object.fromEntries(Object.entries(t || {}).filter(([, e]) => e != null && e !== "" && (!Array.isArray(e) || e.length)));
257
+ }
90
258
  export {
91
- z as AgentError,
92
- x as ContextStore,
93
- j as action,
94
- re as actionButtonsUiSpec,
95
- _ as alignProductsToTable,
96
- ke as anonymousRequestText,
97
- N as beErrorToAgentError,
98
- $ as buildPhotoSimilarityProfile,
99
- ce as buildProductSimilarityProfile,
100
- fe as buildSimilarityQueries,
101
- K as caughtToStreamError,
102
- Pe as compactAccountConfig,
103
- F as compactContextProducts,
104
- ve as comparisonResultForUi,
105
- Y as comparisonUiSpec,
106
- oe as createFlow,
107
- B as createJwtProvider,
108
- C as createToolBridge,
109
- h as createWorkerRpc,
110
- ae as defaultPiiPatternPack,
111
- Z as defaultPiiPatterns,
112
- m as done,
113
- X as elapsedMs,
114
- M as error,
115
- G as handleMainRpc,
116
- q as httpErrorToAgentError,
117
- T as invokeBeOp,
118
- be as llmCacheKey,
119
- O as metadata,
120
- pe as mintDevJwt,
121
- Q as normalizeComparisonTable,
122
- ie as normalizeProduct,
123
- ee as normalizeSimilarityText,
124
- V as nowIso,
125
- Se as productDetailsUiSpec,
126
- H as productFactsKey,
127
- R as productSkuKey,
128
- Ue as productsUiSpec,
129
- te as rankSimilarProducts,
130
- de as redactPii,
131
- ye as requestText,
132
- W as resolveFlow,
133
- E as runMainRpc,
134
- I as runTurn,
135
- ue as scoreSimilarityCandidate,
136
- L as stableKey,
137
- me as startWorker,
138
- we as textChunk,
139
- D as textKey,
140
- se as tokenizeSimilarityText,
141
- J as trimProductFactsCore,
142
- ne as trimProductFactsListCore,
143
- g as uiSpec,
144
- le as withAccountConfig
259
+ Wt as AgentError,
260
+ j as ContextStore,
261
+ Tt as FALLBACK_STATUS,
262
+ wt as action,
263
+ Jt as actionButtonsUiSpec,
264
+ lt as alignProductsToTable,
265
+ R as anonymousRequestText,
266
+ Mt as beErrorToAgentError,
267
+ X as buildPhotoSimilarityProfile,
268
+ Y as buildProductSimilarityProfile,
269
+ Z as buildSimilarityQueries,
270
+ F as caughtToStreamError,
271
+ it as compactAccountConfig,
272
+ ht as compactContextProducts,
273
+ zt as compactObject,
274
+ Gt as compactProductSurfaceForLlm,
275
+ pt as comparisonResultForUi,
276
+ _t as comparisonUiSpec,
277
+ st as createFlow,
278
+ O as createJwtProvider,
279
+ Kt as createPrivacyHelpers,
280
+ Lt as createReadPageStep,
281
+ N as createToolBridge,
282
+ E as createWorkerRpc,
283
+ It as declarativeBeOpCache,
284
+ ut as defaultPiiPatternPack,
285
+ I as defaultPiiPatterns,
286
+ K as done,
287
+ Rt as elapsedMs,
288
+ kt as error,
289
+ oe as explicitRoute,
290
+ ee as fallbackStatus,
291
+ Xt as firstArrayValue,
292
+ ie as flowParamsFromRoute,
293
+ Et as handleMainRpc,
294
+ Nt as homePanelReset,
295
+ $t as httpErrorToAgentError,
296
+ J as inputHashCachePolicy,
297
+ z as invokeBeOp,
298
+ re as isFallbackStatus,
299
+ B as llmCacheKey,
300
+ ne as llmIntentStep,
301
+ Zt as mergeProductSurfaceEvidence,
302
+ ct as metadata,
303
+ Ut as mintDevJwt,
304
+ ft as normalizeComparisonTable,
305
+ mt as normalizeProduct,
306
+ tt as normalizeSimilarityText,
307
+ Ft as nowIso,
308
+ Ht as plainMessageContent,
309
+ Pt as productDetailsUiSpec,
310
+ dt as productFactsKey,
311
+ xt as productSkuKey,
312
+ Ct as productSurfaceReviewText,
313
+ gt as productsUiSpec,
314
+ et as rankSimilarProducts,
315
+ rt as rankSimilarProductsAsync,
316
+ C as redactPii,
317
+ L as requestText,
318
+ At as resolveFlow,
319
+ Ot as retailAnonymizeMessages,
320
+ bt as retailAnonymousRequestText,
321
+ Dt as retailRedactPii,
322
+ qt as routeFlowParams,
323
+ ce as routeKind,
324
+ Vt as routeSkuList,
325
+ D as routeText,
326
+ jt as runMainRpc,
327
+ b as runTurn,
328
+ at as scoreSimilarityCandidate,
329
+ $ as searchInputFromRoute,
330
+ se as searchQueryFromRoute,
331
+ vt as stableKey,
332
+ ae as startWorker,
333
+ te as stickyContextKey,
334
+ Bt as textChunk,
335
+ U as textKey,
336
+ ot as tokenizeSimilarityText,
337
+ Qt as trimProductFactsCore,
338
+ yt as trimProductFactsListCore,
339
+ Yt as uiSpec,
340
+ M as withAccountConfig,
341
+ St as withDeclarativeBeOpCache
145
342
  };