@gengage/assistant-fe 0.6.12 → 0.6.14

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 (50) hide show
  1. package/dist/agentic/adaptor/mount.d.ts +1 -0
  2. package/dist/agentic/context/context-store.d.ts +2 -1
  3. package/dist/agentic/context/persistence.d.ts +2 -1
  4. package/dist/agentic/index.d.ts +3 -2
  5. package/dist/agentic/index.js +244 -240
  6. package/dist/agentic/types.d.ts +28 -20
  7. package/dist/agentic/util/browser-memory.d.ts +2 -2
  8. package/dist/agentic/util/cache-key.d.ts +15 -0
  9. package/dist/agentic/worker/be-client.d.ts +3 -1
  10. package/dist/agentic/worker.d.ts +3 -2
  11. package/dist/agentic/worker.js +92 -86
  12. package/dist/agentic.iife.js +5 -5
  13. package/dist/{api-paths-Cth1szY1.js → api-paths-kwROurUu.js} +1 -1
  14. package/dist/{chat-CrEa2W-e.js → chat-BP-yXukW.js} +1 -1
  15. package/dist/chat-runtime.js +1 -1
  16. package/dist/chat.iife.js +17 -17
  17. package/dist/chat.js +2 -2
  18. package/dist/common/request-response-cache.d.ts +9 -0
  19. package/dist/{common-CmPjQ9RK.js → common-DZuPNgWh.js} +3 -3
  20. package/dist/common.js +7 -7
  21. package/dist/{connection-warning-Bx1TJaU9.js → connection-warning-Bg4gn-cq.js} +1 -1
  22. package/dist/{fastIntent-nZXiT9DG.js → fastIntent-BSgLJDlW.js} +1 -1
  23. package/dist/index.js +12 -12
  24. package/dist/{native-webview-BlHM7cLs.js → native-webview-DbKq9lN8.js} +1 -1
  25. package/dist/native.iife.js +14 -14
  26. package/dist/native.js +1 -1
  27. package/dist/overlay.js +1 -1
  28. package/dist/{qna-BNvttR6s.js → qna-B3lMzHvS.js} +1 -1
  29. package/dist/qna-runtime.js +1 -1
  30. package/dist/qna.iife.js +13 -13
  31. package/dist/qna.js +2 -2
  32. package/dist/request-response-cache-zsgz3Awp.js +154 -0
  33. package/dist/request-text-su3Vlhrs.js +1318 -0
  34. package/dist/{runtime-B0v76aJ5.js → runtime-CAJp9Ehc.js} +366 -365
  35. package/dist/{runtime-xlTFF9HS.js → runtime-DwQSV54I.js} +38 -37
  36. package/dist/{runtime-Dt6FUotQ.js → runtime-KV5wCTc-.js} +69 -68
  37. package/dist/{simbut-pTonQlCT.js → simbut-Bm96zEAo.js} +1 -1
  38. package/dist/simbut.iife.js +1 -1
  39. package/dist/simbut.js +1 -1
  40. package/dist/{simrel-C3ZJHVIW.js → simrel-C9sM9CCV.js} +3 -3
  41. package/dist/simrel-runtime.js +1 -1
  42. package/dist/simrel.iife.js +12 -12
  43. package/dist/simrel.js +2 -2
  44. package/dist/{widget-base-C6H3cDSW.js → widget-base-TZjXRr3u.js} +1 -1
  45. package/package.json +1 -1
  46. package/dist/agentic/flow/beauty-consulting-turn.d.ts +0 -1
  47. package/dist/similarity-qMH5-do-.js +0 -1262
  48. /package/dist/{overlay-fgrzmFTR.js → overlay-CyoB1K0w.js} +0 -0
  49. /package/dist/{price-formatter-xI3g9Cd4.js → price-formatter-CFsWT0lP.js} +0 -0
  50. /package/dist/{schemas-CLo8wCjs.js → schemas-Cq2blsO_.js} +0 -0
@@ -33,6 +33,7 @@ export interface BeClient {
33
33
  signal?: AbortSignal;
34
34
  cacheTtlS?: number;
35
35
  cacheKey?: string;
36
+ browserCache?: BrowserCachePolicy;
36
37
  }): Promise<unknown>;
37
38
  }
38
39
  export interface FlowStepCtx {
@@ -43,6 +44,9 @@ export interface FlowStepCtx {
43
44
  }
44
45
  export type FlowValue<T> = T | ((ctx: FlowStepCtx) => T);
45
46
  export type FlowPatch = (ctx: ChatContext, result: unknown, snapshot: FlowStepCtx) => Partial<ChatContext> | null | undefined;
47
+ export type BrowserCachePolicy = boolean | {
48
+ ttlMs?: number;
49
+ };
46
50
  export type FlowAdapterFn = (input: unknown, ctx: FlowStepCtx) => unknown | Promise<unknown>;
47
51
  export type FlowAdapterMap = Record<string, FlowAdapterFn>;
48
52
  export interface BeOpStep {
@@ -51,7 +55,10 @@ export interface BeOpStep {
51
55
  input: FlowValue<unknown>;
52
56
  cacheTtlS?: FlowValue<number | undefined>;
53
57
  cacheKey?: FlowValue<string | undefined>;
58
+ browserCache?: FlowValue<BrowserCachePolicy | undefined>;
54
59
  out?: string;
60
+ errorOut?: string;
61
+ onError?: readonly FlowStep[];
55
62
  patch?: FlowPatch;
56
63
  }
57
64
  export interface ToolStep {
@@ -59,6 +66,8 @@ export interface ToolStep {
59
66
  name: string;
60
67
  input: FlowValue<unknown>;
61
68
  out?: string;
69
+ errorOut?: string;
70
+ onError?: readonly FlowStep[];
62
71
  patch?: FlowPatch;
63
72
  }
64
73
  export interface AdapterStep {
@@ -80,6 +89,11 @@ export interface BranchStep {
80
89
  export interface ParallelStep {
81
90
  kind: 'parallel';
82
91
  steps: readonly (readonly FlowStep[])[];
92
+ merge?: {
93
+ bag?: readonly string[];
94
+ panel?: readonly string[];
95
+ threadExtensions?: readonly string[];
96
+ };
83
97
  }
84
98
  export interface RefusalStep {
85
99
  kind: 'refusal';
@@ -99,6 +113,9 @@ export interface AccountModule {
99
113
  tools?: ToolMap;
100
114
  adapters?: FlowAdapterMap;
101
115
  accountConfig?: Record<string, unknown>;
116
+ contextPersistence?: {
117
+ panelKeys?: readonly string[];
118
+ };
102
119
  }
103
120
  export interface AgentOpBeacon {
104
121
  type: 'agentOp';
@@ -110,6 +127,16 @@ export interface AgentOpBeacon {
110
127
  latencyMs: number;
111
128
  errorCode?: string | undefined;
112
129
  }
130
+ export interface AgentToolBeacon {
131
+ type: 'agentTool';
132
+ threadId: string;
133
+ sessionId: string;
134
+ accountId: string;
135
+ tool: string;
136
+ status: 'ok' | 'error';
137
+ latencyMs: number;
138
+ errorCode?: string | undefined;
139
+ }
113
140
  export interface TurnSummaryBeacon {
114
141
  type: 'turnSummary';
115
142
  threadId: string;
@@ -124,7 +151,7 @@ export interface GenericBeacon {
124
151
  accountId?: string;
125
152
  [key: string]: unknown;
126
153
  }
127
- export type AgentBeaconPayload = AgentOpBeacon | TurnSummaryBeacon | GenericBeacon;
154
+ export type AgentBeaconPayload = AgentOpBeacon | AgentToolBeacon | TurnSummaryBeacon | GenericBeacon;
128
155
  export type BeaconCallback = (payload: AgentBeaconPayload) => void;
129
156
  export interface UiSpecEnvelope {
130
157
  widget: 'chat' | 'qna' | 'simrel';
@@ -205,22 +232,3 @@ export interface RpcResultMessage {
205
232
  message?: string;
206
233
  } | string;
207
234
  }
208
- export interface BeautyConsultingResult {
209
- consultation_state?: {
210
- stage?: string;
211
- captured_profile?: Record<string, unknown>;
212
- };
213
- refusal?: {
214
- message?: string;
215
- };
216
- plain_text?: string;
217
- answer_html?: string;
218
- product_mentions?: Array<{
219
- sku: string;
220
- short_name?: string;
221
- }>;
222
- search_params?: {
223
- query?: string;
224
- facets?: Record<string, unknown>;
225
- };
226
- }
@@ -1,4 +1,6 @@
1
1
  import type { BrowserMemory } from '../types.js';
2
+ import { stableKey } from './cache-key.js';
3
+ export { stableKey };
2
4
  interface BrowserMemoryOptions {
3
5
  dbName?: string;
4
6
  dbStore?: string;
@@ -8,6 +10,4 @@ interface BrowserMemoryOptions {
8
10
  policy?: Record<string, string>;
9
11
  aliases?: string[];
10
12
  }
11
- export declare function stableKey(value: unknown): string;
12
13
  export declare function createBrowserMemory(accountId: string, options?: BrowserMemoryOptions): BrowserMemory;
13
- export {};
@@ -0,0 +1,15 @@
1
+ export interface LlmCacheKeyOptions {
2
+ version?: string;
3
+ }
4
+ export interface ProductKeyOptions {
5
+ limit?: number;
6
+ locale?: string;
7
+ }
8
+ export interface ProductFactsKeyOptions extends ProductKeyOptions {
9
+ mapProduct?: (product: Record<string, unknown>) => Record<string, unknown> | null | undefined;
10
+ }
11
+ export declare function llmCacheKey(op: string, parts: unknown, options?: LlmCacheKeyOptions): string;
12
+ export declare function productSkuKey(products: unknown, options?: ProductKeyOptions): string;
13
+ export declare function productFactsKey(products: unknown, options?: ProductFactsKeyOptions): string;
14
+ export declare function textKey(value: unknown, locale?: string): string;
15
+ export declare function stableKey(value: unknown): string;
@@ -1,4 +1,5 @@
1
1
  import { type JwtProvider } from './jwt-mint.js';
2
+ import type { BrowserCachePolicy } from '../types.js';
2
3
  interface InvokeBeOpArgs {
3
4
  beUrl: string;
4
5
  accountId: string;
@@ -11,7 +12,8 @@ interface InvokeBeOpArgs {
11
12
  input?: unknown;
12
13
  cacheTtlS?: number | undefined;
13
14
  cacheKey?: string | undefined;
15
+ browserCache?: BrowserCachePolicy | undefined;
14
16
  signal?: AbortSignal | undefined;
15
17
  }
16
- export declare function invokeBeOp({ beUrl, accountId, devJwtSecret, tokenBrokerUrl, tokenBrokerAudience, jwtProvider, parentUrl, op, input, cacheTtlS, cacheKey, signal, }: InvokeBeOpArgs): Promise<Record<string, unknown>>;
18
+ export declare function invokeBeOp({ beUrl, accountId, devJwtSecret, tokenBrokerUrl, tokenBrokerAudience, jwtProvider, parentUrl, op, input, cacheTtlS, cacheKey, browserCache, signal, }: InvokeBeOpArgs): Promise<Record<string, unknown>>;
17
19
  export {};
@@ -3,11 +3,12 @@ export { action, done, error, metadata, textChunk, uiSpec } from './events/build
3
3
  export { AgentError, beErrorToAgentError, caughtToStreamError, httpErrorToAgentError, } from './events/error-taxonomy.js';
4
4
  export { normalizeProduct, trimProductFactsCore, trimProductFactsListCore } from './events/product-normalize.js';
5
5
  export { actionButtonsUiSpec, comparisonUiSpec, productDetailsUiSpec, productsUiSpec } from './events/ui-specs.js';
6
- export { beautyConsultingTurnFlow } from './flow/beauty-consulting-turn.js';
7
6
  export { createFlow } from './flow/create-flow.js';
8
7
  export { resolveFlow } from './flow/dispatch.js';
9
8
  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';
10
9
  export { requestText } from './util/request-text.js';
10
+ export { llmCacheKey, productFactsKey, productSkuKey, stableKey, textKey } from './util/cache-key.js';
11
+ export type { LlmCacheKeyOptions, ProductFactsKeyOptions, ProductKeyOptions } from './util/cache-key.js';
11
12
  export { elapsedMs, nowIso } from './util/time.js';
12
13
  export { invokeBeOp } from './worker/be-client.js';
13
14
  export { startWorker } from './worker/entry.js';
@@ -15,4 +16,4 @@ export { runTurn } from './worker/flow-runner.js';
15
16
  export { createJwtProvider, mintDevJwt } from './worker/jwt-mint.js';
16
17
  export { createWorkerRpc, handleMainRpc, runMainRpc } from './worker/rpc.js';
17
18
  export { createToolBridge } from './worker/tool-bridge.js';
18
- export type { AdapterStep, FlowAdapterFn, FlowAdapterMap } from './types.js';
19
+ 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';
@@ -1,128 +1,134 @@
1
- import { A as P, C as m, D as B, E as J, F as M, I as F, L as I, M as C, N as g, O as j, P as T, R as L, S as h, T as z, _ as R, a as q, b as D, c as K, d as O, f as W, g as G, h as N, i as Q, j as _, k as H, l as V, m as X, n as Y, o as Z, p as $, r as tt, s as et, t as rt, u as ot, v as x, w as at, x as nt, y as A, z as it } from "../similarity-qMH5-do-.js";
2
- function ct(i) {
3
- const a = self, n = /* @__PURE__ */ new Map(), c = I(a), S = x(c);
4
- let e = null, u = null, l = null, p = "";
5
- a.addEventListener("message", (t) => {
6
- const r = t.data;
1
+ import { A as E, B as J, C as B, D as F, E as I, F as M, H as j, I as x, L, M as g, N as z, O as R, P as h, R as C, S as A, T as q, U as D, V as K, _ as O, a as W, b as G, c as H, d as N, f as Q, g as V, h as _, i as X, j as T, k as Y, l as Z, m as $, n as ee, o as te, p as re, r as oe, s as ae, t as ne, u as ie, v as ce, w as le, x as se, y as de, z as ue } from "../request-text-su3Vlhrs.js";
2
+ function pe(n) {
3
+ const a = self, i = /* @__PURE__ */ new Map(), c = K(a), y = A(c);
4
+ let t = null, u = null, l = null, p = "";
5
+ a.addEventListener("message", (e) => {
6
+ const r = e.data;
7
7
  if (r) {
8
8
  if (r.type === "abort") {
9
- typeof r.id == "number" && (n.get(r.id)?.abort(), n.delete(r.id));
9
+ typeof r.id == "number" && (i.get(r.id)?.abort(), i.delete(r.id));
10
10
  return;
11
11
  }
12
- r.type === "invoke" && v(r);
12
+ r.type === "invoke" && S(r);
13
13
  }
14
14
  });
15
- async function v(t) {
16
- e = {
17
- accountId: String(t.accountId || i.accountId || ""),
18
- beUrl: t.beUrl || "",
19
- ...t.devJwtSecret ? { devJwtSecret: t.devJwtSecret } : {},
20
- ...t.tokenBrokerUrl ? { tokenBrokerUrl: t.tokenBrokerUrl } : {},
21
- ...t.tokenBrokerAudience ? { tokenBrokerAudience: t.tokenBrokerAudience } : {},
22
- locale: t.defaultLocale || i.defaultLocale || "en-GB",
23
- parentUrl: t.parentUrl || ""
15
+ async function S(e) {
16
+ t = {
17
+ accountId: String(e.accountId || n.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 || n.defaultLocale || "en-GB",
23
+ parentUrl: e.parentUrl || ""
24
24
  };
25
25
  const r = [
26
- e.accountId,
27
- e.devJwtSecret || "",
28
- e.tokenBrokerUrl || "",
29
- e.tokenBrokerAudience || ""
26
+ t.accountId,
27
+ t.devJwtSecret || "",
28
+ t.tokenBrokerUrl || "",
29
+ t.tokenBrokerAudience || ""
30
30
  ].join(`
31
31
  `);
32
- (!l || p !== r) && (l = C(e), p = r), u ||= new T({
33
- accountId: e.accountId,
34
- locale: e.locale,
35
- parentUrl: e.parentUrl,
36
- rpc: c
32
+ (!l || p !== r) && (l = x(t), p = r), u ||= new C({
33
+ accountId: t.accountId,
34
+ locale: t.locale,
35
+ parentUrl: t.parentUrl,
36
+ rpc: c,
37
+ persistentPanelKeys: n.contextPersistence?.panelKeys
37
38
  });
38
- const d = new AbortController();
39
- n.set(t.id, d);
40
- const s = (o) => {
39
+ const s = new AbortController();
40
+ i.set(e.id, s);
41
+ const d = (o) => {
41
42
  a.postMessage({
42
- id: t.id,
43
+ id: e.id,
43
44
  type: "event",
44
45
  event: o
45
46
  });
46
47
  };
47
48
  try {
48
- const o = e, f = l;
49
- await A({
50
- request: t.request || {},
49
+ const o = t, v = l;
50
+ await B({
51
+ request: e.request || {},
51
52
  accountModule: {
52
- ...i,
53
+ ...n,
53
54
  accountId: o.accountId
54
55
  },
55
56
  contextStore: u,
56
- beClient: { invoke({ op: w, input: y, signal: k, cacheTtlS: b, cacheKey: U }) {
57
- return B({
57
+ beClient: { invoke({ op: f, input: U, signal: k, cacheTtlS: b, cacheKey: w, browserCache: P }) {
58
+ return T({
58
59
  beUrl: o.beUrl,
59
60
  accountId: o.accountId,
60
- jwtProvider: f,
61
+ jwtProvider: v,
61
62
  parentUrl: o.parentUrl,
62
- op: w,
63
- input: y,
63
+ op: f,
64
+ input: U,
64
65
  cacheTtlS: b,
65
- cacheKey: U,
66
+ cacheKey: w,
67
+ browserCache: P,
66
68
  ...k ? { signal: k } : {}
67
69
  });
68
70
  } },
69
- toolBridge: S,
70
- emit: s,
71
+ toolBridge: y,
72
+ emit: d,
71
73
  rpc: c,
72
- signal: d.signal
74
+ signal: s.signal
73
75
  }), a.postMessage({
74
- id: t.id,
76
+ id: e.id,
75
77
  type: "end"
76
78
  });
77
79
  } catch (o) {
78
- d.signal.aborted || (s(P(o)), s(h()), a.postMessage({
79
- id: t.id,
80
+ s.signal.aborted || (d(h(o)), d(I()), a.postMessage({
81
+ id: e.id,
80
82
  type: "end"
81
83
  }));
82
84
  } finally {
83
- n.delete(t.id);
85
+ i.delete(e.id);
84
86
  }
85
87
  }
86
88
  }
87
89
  export {
88
- j as AgentError,
89
- T as ContextStore,
90
- nt as action,
91
- O as actionButtonsUiSpec,
92
- H as beErrorToAgentError,
93
- K as beautyConsultingTurnFlow,
94
- rt as buildPhotoSimilarityProfile,
95
- Y as buildProductSimilarityProfile,
96
- tt as buildSimilarityQueries,
97
- P as caughtToStreamError,
98
- W as comparisonUiSpec,
99
- V as createFlow,
100
- C as createJwtProvider,
101
- x as createToolBridge,
102
- I as createWorkerRpc,
103
- h as done,
104
- M as elapsedMs,
105
- m as error,
106
- L as handleMainRpc,
107
- _ as httpErrorToAgentError,
108
- B as invokeBeOp,
109
- at as metadata,
110
- g as mintDevJwt,
111
- N as normalizeProduct,
112
- Q as normalizeSimilarityText,
113
- F as nowIso,
114
- $ as productDetailsUiSpec,
115
- X as productsUiSpec,
116
- q as rankSimilarProducts,
117
- ot as requestText,
118
- D as resolveFlow,
119
- it as runMainRpc,
120
- A as runTurn,
121
- Z as scoreSimilarityCandidate,
122
- ct as startWorker,
123
- z as textChunk,
124
- et as tokenizeSimilarityText,
90
+ g as AgentError,
91
+ C as ContextStore,
92
+ q as action,
93
+ _ as actionButtonsUiSpec,
94
+ z as beErrorToAgentError,
95
+ ae as buildPhotoSimilarityProfile,
96
+ H as buildProductSimilarityProfile,
97
+ Z as buildSimilarityQueries,
98
+ h as caughtToStreamError,
99
+ V as comparisonUiSpec,
100
+ $ as createFlow,
101
+ x as createJwtProvider,
102
+ A as createToolBridge,
103
+ K as createWorkerRpc,
104
+ I as done,
105
+ ue as elapsedMs,
106
+ F as error,
107
+ j as handleMainRpc,
108
+ M as httpErrorToAgentError,
109
+ T as invokeBeOp,
110
+ ee as llmCacheKey,
111
+ R as metadata,
112
+ L as mintDevJwt,
113
+ de as normalizeProduct,
114
+ ie as normalizeSimilarityText,
115
+ J as nowIso,
116
+ O as productDetailsUiSpec,
117
+ oe as productFactsKey,
118
+ X as productSkuKey,
119
+ ce as productsUiSpec,
120
+ N as rankSimilarProducts,
121
+ ne as requestText,
122
+ le as resolveFlow,
123
+ D as runMainRpc,
124
+ B as runTurn,
125
+ Q as scoreSimilarityCandidate,
126
+ W as stableKey,
127
+ pe as startWorker,
128
+ Y as textChunk,
129
+ te as textKey,
130
+ re as tokenizeSimilarityText,
125
131
  G as trimProductFactsCore,
126
- R as trimProductFactsListCore,
127
- J as uiSpec
132
+ se as trimProductFactsListCore,
133
+ E as uiSpec
128
134
  };