@gengage/assistant-fe 0.6.33 → 0.6.35

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 (97) hide show
  1. package/dist/chat-runtime.js +1 -1
  2. package/dist/chat.iife.js +1 -1
  3. package/dist/chat.js +1 -1
  4. package/dist/common/index.d.ts +2 -1
  5. package/dist/{common-Bhl-diYQ.js → common-C-lXfS-s.js} +1 -1
  6. package/dist/common.js +68 -67
  7. package/dist/{connection-warning-CuJ66qqt.js → connection-warning-DrXU9qN9.js} +1 -1
  8. package/dist/{fastIntent-CjgT7XpX.js → fastIntent-Diz6Vo0W.js} +1 -1
  9. package/dist/index.js +21 -21
  10. package/dist/native.iife.js +1 -1
  11. package/dist/qna-runtime.js +1 -1
  12. package/dist/qna.iife.js +1 -1
  13. package/dist/qna.js +1 -1
  14. package/dist/request-response-cache-DmnzO4Hu.js +1426 -0
  15. package/dist/{runtime-8WgpotSV.js → runtime-CiO-HX8B.js} +198 -199
  16. package/dist/{runtime-4QEfxNRC.js → runtime-D0v-KyzN.js} +36 -37
  17. package/dist/{runtime-bXec5UVj.js → runtime-hci1VRsa.js} +8 -9
  18. package/dist/{simbut-3z-Ed-TM.js → simbut-D-IPkTT8.js} +1 -1
  19. package/dist/simbut.iife.js +1 -1
  20. package/dist/simbut.js +1 -1
  21. package/dist/{simrel-Bz7xAdSc.js → simrel-BjMCvCdo.js} +1 -1
  22. package/dist/simrel-runtime.js +1 -1
  23. package/dist/simrel.iife.js +1 -1
  24. package/dist/simrel.js +2 -2
  25. package/dist/{widget-base-DhkuNWft.js → widget-base-_HBDf5VH.js} +1 -1
  26. package/package.json +3 -19
  27. package/dist/agent-ui-steps-DIWmTMuV.js +0 -3199
  28. package/dist/agentic/adaptor/create-adaptor.d.ts +0 -22
  29. package/dist/agentic/adaptor/fetch-bridge.d.ts +0 -31
  30. package/dist/agentic/adaptor/mount.d.ts +0 -45
  31. package/dist/agentic/algos/similarity.d.ts +0 -86
  32. package/dist/agentic/algos/similarity.js +0 -261
  33. package/dist/agentic/context/chat-context.d.ts +0 -17
  34. package/dist/agentic/context/context-store.d.ts +0 -57
  35. package/dist/agentic/context/persistence.d.ts +0 -14
  36. package/dist/agentic/contracts/agentic-contracts.d.ts +0 -133
  37. package/dist/agentic/debug/activity-collector.d.ts +0 -15
  38. package/dist/agentic/debug/activity-instrumentation.d.ts +0 -22
  39. package/dist/agentic/debug/activity-overlay.d.ts +0 -3
  40. package/dist/agentic/debug/activity-state.d.ts +0 -37
  41. package/dist/agentic/debug/local-dev.d.ts +0 -18
  42. package/dist/agentic/events/builders.d.ts +0 -10
  43. package/dist/agentic/events/comparison.d.ts +0 -6
  44. package/dist/agentic/events/context-products.d.ts +0 -6
  45. package/dist/agentic/events/error-taxonomy.d.ts +0 -27
  46. package/dist/agentic/events/product-normalize.d.ts +0 -50
  47. package/dist/agentic/events/ui-specs.d.ts +0 -41
  48. package/dist/agentic/flow/create-flow.d.ts +0 -2
  49. package/dist/agentic/flow/dispatch.d.ts +0 -3
  50. package/dist/agentic/index.d.ts +0 -65
  51. package/dist/agentic/index.js +0 -3493
  52. package/dist/agentic/types.d.ts +0 -360
  53. package/dist/agentic/util/account-config.d.ts +0 -8
  54. package/dist/agentic/util/assistant-host.d.ts +0 -11
  55. package/dist/agentic/util/be-url.d.ts +0 -4
  56. package/dist/agentic/util/browser-memory.d.ts +0 -13
  57. package/dist/agentic/util/browser-tools.d.ts +0 -31
  58. package/dist/agentic/util/cache-key.d.ts +0 -15
  59. package/dist/agentic/util/common/declarative-cache.d.ts +0 -21
  60. package/dist/agentic/util/common/fallback-status.d.ts +0 -10
  61. package/dist/agentic/util/common/flow-steps.d.ts +0 -8
  62. package/dist/agentic/util/common/gss-tool-aliases.d.ts +0 -66
  63. package/dist/agentic/util/common/iframe-scraper.d.ts +0 -22
  64. package/dist/agentic/util/common/llm-routing.d.ts +0 -50
  65. package/dist/agentic/util/common/object.d.ts +0 -1
  66. package/dist/agentic/util/common/open-product-page.d.ts +0 -30
  67. package/dist/agentic/util/common/panel-context.d.ts +0 -3
  68. package/dist/agentic/util/common/privacy.d.ts +0 -14
  69. package/dist/agentic/util/common/product-resolver.d.ts +0 -20
  70. package/dist/agentic/util/common/product-surface.d.ts +0 -24
  71. package/dist/agentic/util/common/ref-store.d.ts +0 -15
  72. package/dist/agentic/util/common/retail-privacy.d.ts +0 -4
  73. package/dist/agentic/util/common/route-params.d.ts +0 -3
  74. package/dist/agentic/util/common/similarity-ranking.d.ts +0 -2
  75. package/dist/agentic/util/common/site-awareness.d.ts +0 -130
  76. package/dist/agentic/util/lazy-runtime-loader.d.ts +0 -10
  77. package/dist/agentic/util/privacy.d.ts +0 -12
  78. package/dist/agentic/util/request-text.d.ts +0 -3
  79. package/dist/agentic/util/time.d.ts +0 -2
  80. package/dist/agentic/widgets/endpoints.d.ts +0 -12
  81. package/dist/agentic/worker/agent-ui-steps.d.ts +0 -43
  82. package/dist/agentic/worker/agent-ui.d.ts +0 -44
  83. package/dist/agentic/worker/be-client.d.ts +0 -32
  84. package/dist/agentic/worker/coalesce.d.ts +0 -25
  85. package/dist/agentic/worker/compaction.d.ts +0 -12
  86. package/dist/agentic/worker/entry.d.ts +0 -2
  87. package/dist/agentic/worker/flow-runner.d.ts +0 -24
  88. package/dist/agentic/worker/jwt-mint.d.ts +0 -21
  89. package/dist/agentic/worker/pdp-hydrate.d.ts +0 -30
  90. package/dist/agentic/worker/rpc.d.ts +0 -47
  91. package/dist/agentic/worker/tool-bridge.d.ts +0 -2
  92. package/dist/agentic/worker/tool-schema.d.ts +0 -19
  93. package/dist/agentic/worker.d.ts +0 -52
  94. package/dist/agentic/worker.js +0 -429
  95. package/dist/agentic.iife.js +0 -445
  96. package/dist/api-paths-BTHgM_Tz.js +0 -1274
  97. package/dist/request-response-cache-BxRsKGJ0.js +0 -154
@@ -1,22 +0,0 @@
1
- import { type MainRpcMemory } from '../worker/rpc.js';
2
- import type { InjectorAdapter } from '../../common/transport.js';
3
- import type { AccountModule, BeaconCallback, ConfirmationCallback, ToolMap } from '../types.js';
4
- interface CreateInjectorAdapterArgs {
5
- accountId: string;
6
- worker: Worker;
7
- beUrl: string;
8
- devJwtSecret?: string | undefined;
9
- tokenBrokerUrl?: string | undefined;
10
- tokenBrokerAudience?: string | undefined;
11
- defaultLocale?: string | undefined;
12
- tools?: ToolMap | undefined;
13
- beacon?: BeaconCallback | undefined;
14
- confirmation?: ConfirmationCallback | undefined;
15
- memory?: MainRpcMemory | undefined;
16
- }
17
- export declare function createInjectorAdapter({ accountId, worker, beUrl, devJwtSecret, tokenBrokerUrl, tokenBrokerAudience, defaultLocale, tools, beacon, confirmation, memory, }: CreateInjectorAdapterArgs): InjectorAdapter;
18
- interface CreateMainThreadInjectorAdapterArgs extends Omit<CreateInjectorAdapterArgs, 'worker'> {
19
- accountModule: AccountModule;
20
- }
21
- export declare function createMainThreadInjectorAdapter({ accountId, accountModule, beUrl, devJwtSecret, tokenBrokerUrl, tokenBrokerAudience, defaultLocale, tools, beacon, confirmation, memory, }: CreateMainThreadInjectorAdapterArgs): InjectorAdapter;
22
- export {};
@@ -1,31 +0,0 @@
1
- import type { InjectorAdapter, InjectorBridgeEndpoint, InjectorEndpointHandler } from '../../common/transport.js';
2
- interface InstallFetchBridgeArgs {
3
- accountId: string;
4
- streamTransport: InjectorAdapter;
5
- endpoints?: Partial<Record<InjectorBridgeEndpoint, InjectorEndpointHandler>>;
6
- endpointCache?: EndpointCacheOptions;
7
- }
8
- interface InstallFetchBridgeResult {
9
- middlewareUrl: string;
10
- stop: () => void;
11
- }
12
- export interface EndpointCachePolicy {
13
- partition: string;
14
- key: string;
15
- ttlMs?: number;
16
- }
17
- export type EndpointCachePolicyResolver = (request: unknown, context: {
18
- accountId: string;
19
- endpoint: InjectorBridgeEndpoint;
20
- }) => EndpointCachePolicy | null | undefined;
21
- export interface EndpointCacheOptions {
22
- beUrl: string;
23
- devJwtSecret?: string | undefined;
24
- tokenBrokerUrl?: string | undefined;
25
- tokenBrokerAudience?: string | undefined;
26
- parentUrl?: string | undefined;
27
- ttlMs?: number | undefined;
28
- policies: Partial<Record<InjectorBridgeEndpoint, EndpointCachePolicyResolver>>;
29
- }
30
- export declare function installFetchTransportBridge({ accountId, streamTransport, endpoints, endpointCache, }: InstallFetchBridgeArgs): InstallFetchBridgeResult;
31
- export {};
@@ -1,45 +0,0 @@
1
- import type { AccountModule, BeaconCallback, ConfirmationCallback, ToolMap } from '../types.js';
2
- import type { MainRpcMemory } from '../worker/rpc.js';
3
- interface MountAccountArgs {
4
- accountId: string;
5
- beUrl: string;
6
- devJwtSecret?: string;
7
- tokenBrokerUrl?: string;
8
- tokenBrokerAudience?: string;
9
- workerUrl: string;
10
- defaultLocale?: string;
11
- accountModule: AccountModule;
12
- tools?: ToolMap;
13
- beacon?: BeaconCallback;
14
- confirmation?: ConfirmationCallback;
15
- memory?: MainRpcMemory;
16
- allowBlobWorker?: boolean;
17
- signal?: AbortSignal;
18
- }
19
- interface AgentDiagnostics {
20
- accountId: string;
21
- beUrl: string;
22
- workerUrl: string;
23
- mounted: boolean;
24
- transport: 'worker' | 'main-thread';
25
- transportReason?: 'module-worker' | 'cross-origin-worker-url';
26
- flows: string[];
27
- }
28
- export interface AgentController {
29
- type: 'agent';
30
- signal: AbortSignal;
31
- addCleanup: (cleanup: () => void) => void;
32
- stop: () => void;
33
- diagnostics: () => AgentDiagnostics;
34
- }
35
- interface ModuleWorkerHandle {
36
- worker: Worker;
37
- cleanup: () => void;
38
- }
39
- interface CreateModuleWorkerOptions {
40
- allowBlobWorker?: boolean;
41
- }
42
- export declare function mountAccount({ accountId, beUrl, devJwtSecret, tokenBrokerUrl, tokenBrokerAudience, workerUrl, defaultLocale, accountModule, tools, beacon, confirmation, memory, allowBlobWorker, signal, }: MountAccountArgs): AgentController;
43
- export declare function canUseModuleWorker(workerUrl: string): boolean;
44
- export declare function createModuleWorker(workerUrl: string, name: string, options?: CreateModuleWorkerOptions): ModuleWorkerHandle;
45
- export {};
@@ -1,86 +0,0 @@
1
- export interface SimilarityProductLike {
2
- sku?: unknown;
3
- name?: unknown;
4
- title?: unknown;
5
- brand?: unknown;
6
- price?: unknown;
7
- price_discounted?: unknown;
8
- category?: unknown;
9
- category_names?: unknown;
10
- category_ids?: unknown;
11
- facet_hits?: unknown;
12
- promotions?: unknown;
13
- description?: unknown;
14
- }
15
- export interface ProductSimilarityProfile {
16
- sku: string;
17
- title: string;
18
- brand: string;
19
- productType: string;
20
- categoryNames: string[];
21
- categoryIds: string[];
22
- facets: Record<string, string>;
23
- keywords: string[];
24
- tokens: string[];
25
- colors: string[];
26
- attributes: string[];
27
- price: number;
28
- }
29
- export interface PhotoSimilaritySignals {
30
- title?: string;
31
- product_type?: string;
32
- productType?: string;
33
- keywords?: string[];
34
- colors?: string[];
35
- materials?: string[];
36
- styles?: string[];
37
- attributes?: string[];
38
- search_queries?: string[];
39
- searchQueries?: string[];
40
- }
41
- export interface SimilarityRankingOptions {
42
- limit?: number;
43
- maxCandidates?: number;
44
- queryLimit?: number;
45
- locale?: string;
46
- similarityMapper?: ((raw: Record<string, unknown>) => ProductSimilarityProfile | null) | undefined;
47
- ignoreSkus?: string[];
48
- stopWords?: Iterable<string>;
49
- facetKeys?: string[];
50
- sourceProductType?: string;
51
- sourceKeywords?: string[];
52
- sourceQueries?: string[];
53
- hitCounts?: ReadonlyMap<string, number> | Record<string, number>;
54
- weights?: Partial<SimilarityWeights>;
55
- }
56
- export interface SimilarityAsyncRankingOptions extends SimilarityRankingOptions {
57
- batchSize?: number;
58
- signal?: AbortSignal;
59
- yield?: () => Promise<void>;
60
- }
61
- export interface SimilarityWeights {
62
- token: number;
63
- keyword: number;
64
- category: number;
65
- facet: number;
66
- color: number;
67
- attribute: number;
68
- price: number;
69
- retrieval: number;
70
- }
71
- export interface SimilarityScore {
72
- score: number;
73
- reasons: string[];
74
- }
75
- export type SimilarityRankedProduct<T> = T & {
76
- similarity_score: number;
77
- similarity_reasons: string[];
78
- };
79
- export declare function normalizeSimilarityText(value: unknown, locale?: string): string;
80
- export declare function tokenizeSimilarityText(value: unknown, stopWords?: Iterable<string>, locale?: string): string[];
81
- export declare function buildProductSimilarityProfile(product: SimilarityProductLike | ProductSimilarityProfile, options?: SimilarityRankingOptions): ProductSimilarityProfile;
82
- export declare function buildPhotoSimilarityProfile(signals: PhotoSimilaritySignals, options?: SimilarityRankingOptions): ProductSimilarityProfile;
83
- export declare function buildSimilarityQueries(source: SimilarityProductLike | ProductSimilarityProfile, options?: SimilarityRankingOptions): string[];
84
- export declare function scoreSimilarityCandidate(source: ProductSimilarityProfile, candidate: SimilarityProductLike, options?: SimilarityRankingOptions): SimilarityScore;
85
- export declare function rankSimilarProducts<T extends SimilarityProductLike>(source: SimilarityProductLike | ProductSimilarityProfile, candidates: T[], options?: SimilarityRankingOptions): Array<SimilarityRankedProduct<T>>;
86
- export declare function rankSimilarProductsAsync<T extends SimilarityProductLike>(source: SimilarityProductLike | ProductSimilarityProfile, candidates: T[], options?: SimilarityAsyncRankingOptions): Promise<Array<SimilarityRankedProduct<T>>>;
@@ -1,261 +0,0 @@
1
- var w = /* @__PURE__ */ new Set([
2
- "and",
3
- "are",
4
- "for",
5
- "from",
6
- "the",
7
- "with"
8
- ]), z = {
9
- token: 0.26,
10
- keyword: 0.22,
11
- category: 0.18,
12
- facet: 0.16,
13
- color: 0.08,
14
- attribute: 0.06,
15
- price: 0.08,
16
- retrieval: 0.08
17
- }, F = [
18
- "amber",
19
- "beige",
20
- "black",
21
- "blue",
22
- "blush",
23
- "bronze",
24
- "brown",
25
- "cream",
26
- "gold",
27
- "green",
28
- "grey",
29
- "ivory",
30
- "lilac",
31
- "mixed",
32
- "orange",
33
- "pastel",
34
- "pink",
35
- "purple",
36
- "red",
37
- "silver",
38
- "white",
39
- "yellow"
40
- ];
41
- function h(e, t) {
42
- return String(e ?? "").toLocaleLowerCase(t || void 0).normalize("NFKD").replace(new RegExp("\\p{Diacritic}", "gu"), "").replace(/[^\p{L}\p{N}]+/gu, " ").replace(/\s+/gu, " ").trim();
43
- }
44
- function y(e, t = w, r) {
45
- const i = t instanceof Set ? t : /* @__PURE__ */ new Set([...w, ...t]), n = /* @__PURE__ */ new Set(), o = [];
46
- for (const c of h(e, r).split(/\s+/u))
47
- c.length < 3 || i.has(c) || n.has(c) || (n.add(c), o.push(c));
48
- return o;
49
- }
50
- function g(e, t = {}) {
51
- if (B(e)) return e;
52
- const r = t.similarityMapper?.(e);
53
- if (r) return r;
54
- const i = t.facetKeys, n = l(e.category_names ?? e.category), o = l(e.category_ids), c = E(e.facet_hits), m = Object.entries(c).filter(([s]) => !i || i.some((O) => h(O, t.locale) === h(s, t.locale))).map(([, s]) => s), a = f(e.name, e.title), u = f(e.brand), p = t.sourceKeywords ?? [], T = [
55
- a,
56
- u,
57
- ...n,
58
- ...m,
59
- ...l(e.promotions),
60
- f(e.description),
61
- ...p
62
- ].join(" "), b = y(T, t.stopWords, t.locale), x = f(t.sourceProductType, K(n, a, b, t.locale), b[0]), S = d([...D(T, F, t.locale), ...Object.entries(c).filter(([s]) => /colou?r/iu.test(s)).flatMap(([, s]) => y(s, t.stopWords, t.locale))], t.locale), _ = d([...m.flatMap((s) => y(s, t.stopWords, t.locale)), ...l(e.promotions).flatMap((s) => y(s, t.stopWords, t.locale))], t.locale).slice(0, 24);
63
- return {
64
- sku: f(e.sku),
65
- title: a,
66
- brand: u,
67
- productType: x,
68
- categoryNames: n,
69
- categoryIds: o,
70
- facets: c,
71
- keywords: d([...p.flatMap((s) => y(s, t.stopWords, t.locale)), ...b], t.locale).slice(0, 12),
72
- tokens: b,
73
- colors: S,
74
- attributes: _,
75
- price: C(e)
76
- };
77
- }
78
- function v(e, t = {}) {
79
- const r = f(e.product_type, e.productType), i = f(e.title, r, l(e.keywords).join(" ")), n = d([
80
- ...l(e.keywords),
81
- ...l(e.colors),
82
- ...l(e.materials),
83
- ...l(e.styles),
84
- ...l(e.attributes)
85
- ]);
86
- return g({
87
- sku: "__photo__",
88
- name: i,
89
- category_names: r ? [r] : [],
90
- facet_hits: {
91
- colors: l(e.colors).join(", "),
92
- materials: l(e.materials).join(", "),
93
- styles: l(e.styles).join(", "),
94
- attributes: l(e.attributes).join(", ")
95
- },
96
- promotions: n
97
- }, {
98
- ...t,
99
- sourceProductType: r,
100
- sourceKeywords: n
101
- });
102
- }
103
- function U(e, t = {}) {
104
- const r = g(e, t);
105
- return d([
106
- ...t.sourceQueries ?? [],
107
- M([
108
- r.productType,
109
- ...r.colors.slice(0, 1),
110
- ...r.attributes.slice(0, 2)
111
- ]),
112
- M([r.productType, ...r.keywords.slice(0, 3)]),
113
- M([r.categoryNames[r.categoryNames.length - 1], ...r.keywords.slice(0, 2)]),
114
- M(r.title.split(/\s+/u).slice(0, 6)),
115
- r.productType
116
- ].map((i) => i.trim()).filter(Boolean)).slice(0, t.queryLimit ?? 6);
117
- }
118
- function j(e, t, r = {}) {
119
- const i = {
120
- ...z,
121
- ...r.weights
122
- }, n = g(t, r), o = [], c = k(e.tokens, n.tokens, r.locale), m = k(e.keywords, n.tokens, r.locale), a = R(e.categoryNames, n.categoryNames, r.locale) || k(P(e.categoryNames, r.locale), P(n.categoryNames, r.locale), r.locale), u = k(e.attributes, n.attributes, r.locale), p = k(e.colors, n.colors, r.locale), T = k(e.attributes, n.tokens, r.locale), b = W(e.price, n.price), x = I(n.sku, r.hitCounts) > 0 ? 1 : 0, S = Q(e, n), _ = c * i.token + m * i.keyword + a * i.category + u * i.facet + p * i.color + T * i.attribute + b * i.price + x * i.retrieval, s = q(S ? _ : _ * 0.35);
123
- return S && e.productType && e.productType === n.productType && o.push("same product type"), a > 0.4 && o.push("similar category"), u > 0.2 && o.push("matching product attributes"), p > 0 && o.push("matching colour"), b > 0.8 && o.push("similar price"), S || o.push("weaker product-type match"), {
124
- score: Number(s.toFixed(4)),
125
- reasons: o
126
- };
127
- }
128
- function $(e, t, r = {}) {
129
- const i = g(e, r), n = new Set([i.sku, ...r.ignoreSkus ?? []].filter(Boolean));
130
- return A(t.filter((o) => {
131
- const c = f(o.sku);
132
- return c && !n.has(c);
133
- }), r.maxCandidates).map((o) => {
134
- const c = j(i, o, r);
135
- return {
136
- ...o,
137
- similarity_score: c.score,
138
- similarity_reasons: c.reasons
139
- };
140
- }).sort((o, c) => c.similarity_score - o.similarity_score).slice(0, Math.max(1, Math.min(r.limit ?? 12, 100)));
141
- }
142
- async function G(e, t, r = {}) {
143
- const i = g(e, r), n = new Set([i.sku, ...r.ignoreSkus ?? []].filter(Boolean)), o = A(t.filter((a) => {
144
- const u = f(a.sku);
145
- return u && !n.has(u);
146
- }), r.maxCandidates), c = Math.max(1, Math.floor(r.batchSize ?? 50)), m = [];
147
- for (let a = 0; a < o.length; a += 1) {
148
- N(r.signal);
149
- const u = o[a], p = j(i, u, r);
150
- m.push({
151
- ...u,
152
- similarity_score: p.score,
153
- similarity_reasons: p.reasons
154
- }), (a + 1) % c === 0 && await L(r.yield);
155
- }
156
- return N(r.signal), m.sort((a, u) => u.similarity_score - a.similarity_score).slice(0, Math.max(1, Math.min(r.limit ?? 12, 100)));
157
- }
158
- function A(e, t) {
159
- if (t === void 0) return e;
160
- const r = Math.floor(Number(t));
161
- return Number.isFinite(r) && r > 0 ? e.slice(0, r) : e;
162
- }
163
- async function L(e) {
164
- if (e) {
165
- await e();
166
- return;
167
- }
168
- await new Promise((t) => {
169
- const r = globalThis;
170
- if (typeof r.scheduler?.yield == "function") {
171
- r.scheduler.yield().then(t, t);
172
- return;
173
- }
174
- if (typeof setTimeout == "function") {
175
- setTimeout(t, 0);
176
- return;
177
- }
178
- t();
179
- });
180
- }
181
- function N(e) {
182
- if (e?.aborted)
183
- throw new DOMException("Similarity ranking aborted.", "AbortError");
184
- }
185
- function B(e) {
186
- return !!(e && typeof e == "object" && Array.isArray(e.tokens));
187
- }
188
- function f(...e) {
189
- for (const t of e) if (typeof t == "string" && t.trim()) return t.trim();
190
- return "";
191
- }
192
- function l(e) {
193
- return Array.isArray(e) ? e.map((t) => f(t)).filter(Boolean) : typeof e == "string" && e.trim() ? e.split(/[,;/|]+/u).map((t) => t.trim()).filter(Boolean) : [];
194
- }
195
- function E(e) {
196
- return !e || typeof e != "object" || Array.isArray(e) ? {} : Object.fromEntries(Object.entries(e).map(([t, r]) => [t, f(r)]).filter(([, t]) => t));
197
- }
198
- function C(e) {
199
- const t = Number(e.price_discounted);
200
- if (Number.isFinite(t) && t > 0) return t;
201
- const r = Number(e.price);
202
- return Number.isFinite(r) && r > 0 ? r : 0;
203
- }
204
- function d(e, t) {
205
- const r = /* @__PURE__ */ new Set(), i = [];
206
- for (const n of e) {
207
- const o = h(n, t);
208
- !o || r.has(o) || (r.add(o), i.push(o));
209
- }
210
- return i;
211
- }
212
- function D(e, t, r) {
213
- const i = ` ${h(e, r)} `;
214
- return t.filter((n) => i.includes(` ${h(n, r)} `));
215
- }
216
- function K(e, t, r, i) {
217
- const n = h(e[e.length - 1] ?? e[0] ?? "", i);
218
- if (n) {
219
- const o = y(n, w, i), c = new Set(y(t, w, i));
220
- return o.find((m) => c.has(m)) ?? o[0] ?? n;
221
- }
222
- return r[0] ?? "";
223
- }
224
- function M(e) {
225
- return e.map((t) => h(t)).filter(Boolean).join(" ").replace(/\s+/gu, " ").trim().slice(0, 120);
226
- }
227
- function P(e, t) {
228
- return e.flatMap((r) => y(r, w, t));
229
- }
230
- function k(e, t, r) {
231
- const i = d(e, r), n = new Set(d(t, r));
232
- return i.length === 0 || n.size === 0 ? 0 : i.filter((o) => n.has(o)).length / i.length;
233
- }
234
- function R(e, t, r) {
235
- const i = d(e, r), n = new Set(d(t, r));
236
- return i.length === 0 || n.size === 0 ? 0 : i.filter((o) => n.has(o)).length / i.length;
237
- }
238
- function W(e, t) {
239
- return e <= 0 || t <= 0 ? 0 : Math.min(e, t) / Math.max(e, t);
240
- }
241
- function I(e, t) {
242
- return !e || !t ? 0 : typeof t.get == "function" ? t.get(e) ?? 0 : t[e] ?? 0;
243
- }
244
- function Q(e, t) {
245
- if (!e.productType || !t.productType || e.productType === t.productType) return !0;
246
- const r = new Set(y(e.productType)), i = /* @__PURE__ */ new Set([...y(t.productType), ...t.tokens]);
247
- return [...r].some((n) => i.has(n));
248
- }
249
- function q(e) {
250
- return Math.max(0, Math.min(1, e));
251
- }
252
- export {
253
- v as buildPhotoSimilarityProfile,
254
- g as buildProductSimilarityProfile,
255
- U as buildSimilarityQueries,
256
- h as normalizeSimilarityText,
257
- $ as rankSimilarProducts,
258
- G as rankSimilarProductsAsync,
259
- j as scoreSimilarityCandidate,
260
- y as tokenizeSimilarityText
261
- };
@@ -1,17 +0,0 @@
1
- import type { ChatContext, ChatMessage } from '../types.js';
2
- interface CreateChatContextArgs {
3
- accountId: string;
4
- locale?: string | undefined;
5
- parentUrl?: string | undefined;
6
- threadId?: string | undefined;
7
- incomingContext?: unknown;
8
- messageLimit?: number | undefined;
9
- }
10
- interface IncomingMessageLike {
11
- role?: unknown;
12
- content?: unknown;
13
- }
14
- export declare function createChatContext(args: CreateChatContextArgs): ChatContext;
15
- export declare function appendMessage(context: ChatContext, message: IncomingMessageLike, messageLimit?: number): ChatContext;
16
- export declare function limitMessages(messages: ChatMessage[], messageLimit?: number): ChatMessage[];
17
- export {};
@@ -1,57 +0,0 @@
1
- import type { ProcessActionRequest } from '../../common/transport.js';
2
- import type { ChatContext, RpcFn } from '../types.js';
3
- interface ContextStoreOptions {
4
- accountId: string;
5
- locale?: string | undefined;
6
- parentUrl?: string | undefined;
7
- rpc: RpcFn;
8
- persistentPanelKeys?: readonly string[] | undefined;
9
- panelKeyLimits?: Record<string, number> | undefined;
10
- messageLimit?: number | undefined;
11
- maxThreads?: number | undefined;
12
- threadTtlMs?: number | undefined;
13
- }
14
- type PatchInput = Partial<ChatContext> | null | undefined | ((current: ChatContext) => Partial<ChatContext> | null | undefined);
15
- export type PendingMessageKind = 'steer' | 'follow_up';
16
- export type QueueMode = 'all' | 'one-at-a-time';
17
- export interface PendingMessage {
18
- kind: PendingMessageKind;
19
- text: string;
20
- enqueuedAt: number;
21
- }
22
- export interface SavePointEntry<TPayload = unknown> {
23
- threadId: string;
24
- turnIndex: number;
25
- payload: TPayload;
26
- createdAt: number;
27
- }
28
- export declare class ContextStore {
29
- #private;
30
- constructor({ accountId, locale, parentUrl, rpc, persistentPanelKeys, panelKeyLimits, messageLimit, maxThreads, threadTtlMs, }: ContextStoreOptions);
31
- get size(): number;
32
- get(threadId?: string | null | undefined): ChatContext | null;
33
- getPanel(threadId?: string | null | undefined): ChatContext['panel'] | null;
34
- getRecentProducts(threadId?: string | null | undefined, key?: string): readonly unknown[];
35
- load(request: (ProcessActionRequest & {
36
- sessionId?: string;
37
- }) | null | undefined): Promise<ChatContext>;
38
- patch(threadId: string | null | undefined, patch: PatchInput): ChatContext | null;
39
- appendUserMessage(threadId: string | null | undefined, text: string): ChatContext | null;
40
- appendToolResult(threadId: string | null | undefined, entry: {
41
- name: string;
42
- content?: string;
43
- details?: unknown;
44
- }): ChatContext | null;
45
- commit(threadId: string | null | undefined): Promise<ChatContext | null>;
46
- delete(threadId: string | null | undefined): boolean;
47
- clear(): void;
48
- enqueueSteer(threadId: string | null | undefined, text: string, mode?: QueueMode): void;
49
- enqueueFollowUp(threadId: string | null | undefined, text: string, mode?: QueueMode): void;
50
- drainPending(threadId: string | null | undefined, kind: PendingMessageKind): PendingMessage | null;
51
- peekPending(threadId?: string | null | undefined): readonly PendingMessage[];
52
- savepoint<T>(threadId: string, turnIndex: number, payload: T): Promise<void>;
53
- restoreSavepoint<T>(threadId: string, turnIndex?: number): Promise<SavePointEntry<T> | null>;
54
- clearSavepoint(threadId: string, turnIndex?: number): Promise<void>;
55
- pruneExpired(now?: number): number;
56
- }
57
- export {};
@@ -1,14 +0,0 @@
1
- import type { RpcFn } from '../types.js';
2
- interface LoadArgs {
3
- accountId: string;
4
- threadId: string;
5
- rpc: RpcFn;
6
- }
7
- interface SaveArgs extends LoadArgs {
8
- extensions: Record<string, unknown>;
9
- panel?: Record<string, unknown> | undefined;
10
- }
11
- export declare function loadStickyContext({ accountId, threadId, rpc }: LoadArgs): Promise<Record<string, unknown>>;
12
- export declare function saveStickyContext({ accountId, threadId, extensions, panel, rpc }: SaveArgs): Promise<void>;
13
- export declare function stickyContextKey(accountId: string, threadId: string): string;
14
- export {};
@@ -1,133 +0,0 @@
1
- export type LocaleCode = string;
2
- export type MoneyValue = number | string;
3
- export interface GssProductFeature {
4
- key: string;
5
- value: string | number | boolean;
6
- group?: string;
7
- unit?: string;
8
- source?: string;
9
- }
10
- export interface GssProductSeller {
11
- id?: string;
12
- name: string;
13
- rating?: number;
14
- url?: string;
15
- }
16
- export interface GssProductReview {
17
- id?: string;
18
- author?: string;
19
- rating?: number;
20
- title?: string;
21
- text?: string;
22
- date?: string;
23
- }
24
- export interface GssProductQuestionAnswer {
25
- question: string;
26
- answer?: string;
27
- date?: string;
28
- }
29
- export interface GssShippingOption {
30
- label: string;
31
- price?: MoneyValue;
32
- currency?: string;
33
- eta?: string;
34
- }
35
- export interface GssInstallmentOption {
36
- count: number;
37
- monthlyAmount?: MoneyValue;
38
- totalAmount?: MoneyValue;
39
- bank?: string;
40
- currency?: string;
41
- }
42
- export interface GssProductDetails {
43
- sku?: string;
44
- id?: string;
45
- name?: string;
46
- title?: string;
47
- brand?: string;
48
- url?: string;
49
- image?: string;
50
- imageUrl?: string;
51
- images?: string[];
52
- category?: string;
53
- category_names?: string[];
54
- price?: MoneyValue;
55
- price_discounted?: MoneyValue;
56
- price_currency?: string;
57
- description?: string;
58
- features?: GssProductFeature[];
59
- specs?: Record<string, unknown>;
60
- seller?: GssProductSeller;
61
- qna?: GssProductQuestionAnswer[];
62
- reviews?: GssProductReview[];
63
- rating?: number;
64
- review_count?: number;
65
- in_stock?: boolean;
66
- availability?: 'in_stock' | 'out_of_stock' | 'preorder' | 'unknown' | string;
67
- shipping?: GssShippingOption[];
68
- installment?: GssInstallmentOption[];
69
- facets?: Record<string, string | string[] | number | boolean>;
70
- }
71
- export interface BeOpInputBase {
72
- locale?: LocaleCode;
73
- account_config?: Record<string, unknown>;
74
- }
75
- export interface IntentOpInput extends BeOpInputBase {
76
- utterance: string;
77
- page_context?: Record<string, unknown>;
78
- structured_context?: Record<string, unknown>;
79
- }
80
- export interface IntentOpOutput {
81
- intent?: {
82
- kind?: string;
83
- confidence?: number;
84
- rationale?: string;
85
- };
86
- search_params?: Record<string, unknown>;
87
- flow_params?: Record<string, unknown>;
88
- }
89
- export interface ProductAnswerInput extends BeOpInputBase {
90
- question: string;
91
- products: GssProductDetails[];
92
- page_context?: Record<string, unknown>;
93
- }
94
- export interface ProductAnswerOutput {
95
- answer?: string;
96
- citations?: Array<{
97
- sku?: string;
98
- key?: string;
99
- value?: string;
100
- }>;
101
- status?: string;
102
- }
103
- export interface CompareInput extends BeOpInputBase {
104
- products: GssProductDetails[];
105
- criteria?: string[];
106
- }
107
- export interface CompareOutput {
108
- summary?: string;
109
- table?: Record<string, Array<string | number | boolean | null>>;
110
- recommended_choice_sku?: string;
111
- key_differences?: string[];
112
- special_considerations?: string[];
113
- status?: string;
114
- }
115
- export type UiSpecElementType = 'ActionButtons' | 'ComparisonTable' | 'ProductCard' | 'ProductGrid' | 'ReviewSummary' | 'TextBlock' | string;
116
- export interface UiSpecElement<Props extends Record<string, unknown> = Record<string, unknown>> {
117
- type: UiSpecElementType;
118
- props?: Props;
119
- children?: string[];
120
- }
121
- export interface UiSpec {
122
- elements: Record<string, UiSpecElement>;
123
- root?: string;
124
- }
125
- export interface UiSpecEvent {
126
- type: 'ui_spec';
127
- widget?: 'chat' | 'qna' | 'simrel' | 'similarity' | string;
128
- spec: UiSpec;
129
- }
130
- export interface RefPayload {
131
- kind: string;
132
- id: string;
133
- }
@@ -1,15 +0,0 @@
1
- export declare function createActivityCollector({ accountId, clock }?: {
2
- clock?: (() => number) | undefined;
3
- }): {
4
- accountId: any;
5
- readonly entries: never[];
6
- clear(): void;
7
- record: (entry: any) => any;
8
- subscribe(listener: any): () => void;
9
- };
10
- export declare function getOrCreateActivityCollector(accountId: any): any;
11
- export declare function normalizeEntry(entry: any): any;
12
- export declare function isNoiseEntry(entry: any): boolean;
13
- export declare function sectionForKind(kind: any): "Flow" | "Intent" | "Backend" | "Tools" | "Telemetry" | "Runtime";
14
- export declare function severityForEntry(entry: any): "error" | "warn" | "info";
15
- export declare function groupForEntry(entry: any): any;