@gengage/assistant-fe 0.5.7 → 0.6.1

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 (191) hide show
  1. package/README.md +6 -22
  2. package/dist/agentic/adaptor/create-adaptor.d.ts +19 -0
  3. package/dist/agentic/adaptor/fetch-bridge.d.ts +11 -0
  4. package/dist/agentic/adaptor/mount.d.ts +38 -0
  5. package/dist/agentic/context/chat-context.d.ts +15 -0
  6. package/dist/agentic/context/context-store.d.ts +20 -0
  7. package/dist/agentic/context/persistence.d.ts +12 -0
  8. package/dist/agentic/events/builders.d.ts +10 -0
  9. package/dist/agentic/events/error-taxonomy.d.ts +27 -0
  10. package/dist/agentic/events/product-normalize.d.ts +47 -0
  11. package/dist/agentic/events/ui-specs.d.ts +37 -0
  12. package/dist/agentic/flow/beauty-consulting-turn.d.ts +1 -0
  13. package/dist/agentic/flow/create-flow.d.ts +2 -0
  14. package/dist/agentic/flow/dispatch.d.ts +3 -0
  15. package/dist/agentic/index.d.ts +18 -0
  16. package/dist/agentic/index.js +624 -0
  17. package/dist/agentic/types.d.ts +212 -0
  18. package/dist/agentic/util/assistant-host.d.ts +11 -0
  19. package/dist/agentic/util/be-url.d.ts +4 -0
  20. package/dist/agentic/util/browser-memory.d.ts +13 -0
  21. package/dist/agentic/util/browser-tools.d.ts +31 -0
  22. package/dist/agentic/util/lazy-runtime-loader.d.ts +9 -0
  23. package/dist/agentic/util/request-text.d.ts +3 -0
  24. package/dist/agentic/util/time.d.ts +2 -0
  25. package/dist/agentic/worker/be-client.d.ts +15 -0
  26. package/dist/agentic/worker/entry.d.ts +2 -0
  27. package/dist/agentic/worker/flow-runner.d.ts +24 -0
  28. package/dist/agentic/worker/jwt-mint.d.ts +21 -0
  29. package/dist/agentic/worker/rpc.d.ts +24 -0
  30. package/dist/agentic/worker/tool-bridge.d.ts +2 -0
  31. package/dist/agentic/worker.d.ts +16 -0
  32. package/dist/agentic/worker.js +119 -0
  33. package/dist/agentic.iife.js +5 -0
  34. package/dist/{api-paths-CwzwbgQZ.js → api-paths-C4WzXzyY.js} +1 -1
  35. package/dist/beauty-consulting-turn-BmPXbkQg.js +1019 -0
  36. package/dist/chat/api.d.ts +17 -0
  37. package/dist/chat/assistant-mode.d.ts +20 -0
  38. package/dist/chat/attachment-utils.d.ts +9 -0
  39. package/dist/chat/catalog.d.ts +455 -0
  40. package/dist/chat/chat-presentation-state.d.ts +53 -0
  41. package/dist/chat/components/AIGroupingCards.d.ts +15 -0
  42. package/dist/chat/components/AISuggestedSearchCards.d.ts +13 -0
  43. package/dist/chat/components/AITopPicks.d.ts +9 -0
  44. package/dist/chat/components/BeautyPhotoStep.d.ts +31 -0
  45. package/dist/chat/components/CategoriesContainer.d.ts +11 -0
  46. package/dist/chat/components/ChatDrawer.d.ts +362 -0
  47. package/dist/chat/components/ChoicePrompter.d.ts +21 -0
  48. package/dist/chat/components/ComparisonTable.d.ts +66 -0
  49. package/dist/chat/components/ConsultingStylePicker.d.ts +40 -0
  50. package/dist/chat/components/FloatingComparisonButton.d.ts +7 -0
  51. package/dist/chat/components/FloatingLauncher.d.ts +79 -0
  52. package/dist/chat/components/GroundingReviewCard.d.ts +11 -0
  53. package/dist/chat/components/HandoffNotice.d.ts +9 -0
  54. package/dist/chat/components/KvkkBanner.d.ts +6 -0
  55. package/dist/chat/components/Launcher.d.ts +28 -0
  56. package/dist/chat/components/PanelRestoreCard.d.ts +4 -0
  57. package/dist/chat/components/PanelTopBar.d.ts +32 -0
  58. package/dist/chat/components/PhotoAnalysisCard.d.ts +27 -0
  59. package/dist/chat/components/ProductSummaryCard.d.ts +12 -0
  60. package/dist/chat/components/ProsAndCons.d.ts +8 -0
  61. package/dist/chat/components/ReviewHighlights.d.ts +16 -0
  62. package/dist/chat/components/actionClassifier.d.ts +12 -0
  63. package/dist/chat/components/product-price-layout.d.ts +17 -0
  64. package/dist/chat/components/productMentionLinker.d.ts +26 -0
  65. package/dist/chat/components/renderUISpec.d.ts +15 -0
  66. package/dist/chat/components/typewriter.d.ts +24 -0
  67. package/dist/chat/extendedModeManager.d.ts +32 -0
  68. package/dist/chat/features/beauty-consulting/consulting-grid.d.ts +38 -0
  69. package/dist/chat/features/beauty-consulting/drawer-extensions.d.ts +22 -0
  70. package/dist/chat/features/beauty-consulting/mode-controller.d.ts +59 -0
  71. package/dist/chat/features/beauty-consulting/registry.d.ts +9 -0
  72. package/dist/chat/features/beauty-consulting/stream-handler.d.ts +45 -0
  73. package/dist/chat/history-storage.d.ts +85 -0
  74. package/dist/chat/index.d.ts +6 -0
  75. package/dist/chat/kvkk.d.ts +20 -0
  76. package/dist/chat/locales/en.d.ts +2 -0
  77. package/dist/chat/locales/index.d.ts +5 -0
  78. package/dist/chat/locales/tr.d.ts +2 -0
  79. package/dist/chat/panel-manager.d.ts +142 -0
  80. package/dist/chat/runtime.d.ts +417 -0
  81. package/dist/chat/session-persistence.d.ts +73 -0
  82. package/dist/chat/stream-error-display.d.ts +6 -0
  83. package/dist/chat/types.d.ts +547 -0
  84. package/dist/chat/utils/chat-presentation-debug.d.ts +18 -0
  85. package/dist/chat/utils/get-chat-scroll-element.d.ts +10 -0
  86. package/dist/chat/utils/ui.d.ts +10 -0
  87. package/dist/chat-runtime.js +1 -1
  88. package/dist/chat.iife.js +12 -12
  89. package/dist/chat.js +1 -1
  90. package/dist/common/action-router.d.ts +26 -0
  91. package/dist/common/api-paths.d.ts +23 -0
  92. package/dist/common/client.d.ts +27 -0
  93. package/dist/common/communication-bridge.d.ts +51 -0
  94. package/dist/common/config-constants.d.ts +1 -0
  95. package/dist/common/config-schema.d.ts +54 -0
  96. package/dist/common/connection-warning.d.ts +8 -0
  97. package/dist/common/consulting-sources.d.ts +8 -0
  98. package/dist/common/context.d.ts +64 -0
  99. package/dist/common/css-escape.d.ts +1 -0
  100. package/dist/common/customization-factories.d.ts +59 -0
  101. package/dist/common/debug.d.ts +13 -0
  102. package/dist/common/events.d.ts +55 -0
  103. package/dist/common/fastIntent.d.ts +1 -0
  104. package/dist/common/find-similar-payload.d.ts +3 -0
  105. package/dist/common/ga-datalayer.d.ts +80 -0
  106. package/dist/common/global-error-toast.d.ts +6 -0
  107. package/dist/common/index.d.ts +47 -0
  108. package/dist/common/indexed-db.d.ts +89 -0
  109. package/dist/common/locale.d.ts +1 -0
  110. package/dist/common/native-webview.d.ts +60 -0
  111. package/dist/common/navigation.d.ts +1 -0
  112. package/dist/common/overlay.d.ts +172 -0
  113. package/dist/common/page-detect.d.ts +36 -0
  114. package/dist/common/pill-launcher.d.ts +51 -0
  115. package/dist/common/preflight.d.ts +13 -0
  116. package/dist/common/price-formatter.d.ts +35 -0
  117. package/dist/common/product-utils.d.ts +35 -0
  118. package/dist/common/protocol-adapter.d.ts +108 -0
  119. package/dist/common/renderer/dom.d.ts +3 -0
  120. package/dist/common/renderer/index.d.ts +4 -0
  121. package/dist/common/renderer/overrides.d.ts +23 -0
  122. package/dist/common/renderer/registry.d.ts +2 -0
  123. package/dist/common/renderer/types.d.ts +19 -0
  124. package/dist/common/safe-html.d.ts +22 -0
  125. package/dist/common/sdk-version.d.ts +3 -0
  126. package/dist/common/streaming.d.ts +52 -0
  127. package/dist/common/suggested-search-keywords.d.ts +18 -0
  128. package/dist/common/theme-utils.d.ts +15 -0
  129. package/dist/common/transport.d.ts +75 -0
  130. package/dist/common/tts-player.d.ts +13 -0
  131. package/dist/common/types.d.ts +379 -0
  132. package/dist/common/ui-theme.d.ts +9 -0
  133. package/dist/common/uuidv7.d.ts +7 -0
  134. package/dist/common/voice-input.d.ts +74 -0
  135. package/dist/common/widget-base.d.ts +82 -0
  136. package/dist/{common-KpJP1YwP.js → common-DstAcheX.js} +90 -139
  137. package/dist/common.js +41 -41
  138. package/dist/{connection-warning-B5T_1oBn.js → connection-warning-Ddr91Y9x.js} +1 -1
  139. package/dist/{fastIntent--Ukm2nOh.js → fastIntent-XtUvISni.js} +199 -137
  140. package/dist/index.d.ts +25 -0
  141. package/dist/index.js +50 -50
  142. package/dist/native/index.d.ts +2 -0
  143. package/dist/{native-webview-qfjm4SHx.js → native-webview-JDC1vtde.js} +1 -1
  144. package/dist/native.iife.js +14 -14
  145. package/dist/native.js +1 -1
  146. package/dist/{overlay-CP5A0Hhf.js → overlay-BetAvpVZ.js} +19 -19
  147. package/dist/overlay.d.ts +4 -0
  148. package/dist/overlay.js +1 -1
  149. package/dist/qna/api.d.ts +23 -0
  150. package/dist/qna/catalog.d.ts +60 -0
  151. package/dist/qna/components/ButtonRow.d.ts +15 -0
  152. package/dist/qna/components/TextInput.d.ts +11 -0
  153. package/dist/qna/components/renderUISpec.d.ts +7 -0
  154. package/dist/qna/index.d.ts +3 -0
  155. package/dist/qna/locales/en.d.ts +2 -0
  156. package/dist/qna/locales/index.d.ts +4 -0
  157. package/dist/qna/locales/tr.d.ts +2 -0
  158. package/dist/qna/normalize-ui-specs.d.ts +15 -0
  159. package/dist/qna/runtime.d.ts +73 -0
  160. package/dist/qna/types.d.ts +98 -0
  161. package/dist/qna-runtime.js +1 -1
  162. package/dist/qna.iife.js +1 -1
  163. package/dist/qna.js +1 -1
  164. package/dist/{runtime-G3idwfkM.js → runtime-C66Wp6OR.js} +967 -923
  165. package/dist/{runtime-C3yOvNFK.js → runtime-CcA_r8pw.js} +3 -3
  166. package/dist/{runtime-BPyXOyyp.js → runtime-DJMUL882.js} +3 -3
  167. package/dist/simbut/index.d.ts +31 -0
  168. package/dist/simbut/locales.d.ts +3 -0
  169. package/dist/simbut/types.d.ts +43 -0
  170. package/dist/{simbut-CiknJI6-.js → simbut-B6L3fwI7.js} +1 -1
  171. package/dist/simbut.iife.js +1 -1
  172. package/dist/simbut.js +1 -1
  173. package/dist/simrel/api.d.ts +25 -0
  174. package/dist/simrel/catalog.d.ts +77 -0
  175. package/dist/simrel/components/GroupTabs.d.ts +24 -0
  176. package/dist/simrel/components/ProductCard.d.ts +19 -0
  177. package/dist/simrel/components/ProductGrid.d.ts +17 -0
  178. package/dist/simrel/components/renderUISpec.d.ts +7 -0
  179. package/dist/simrel/index.d.ts +5 -0
  180. package/dist/simrel/locales/en.d.ts +2 -0
  181. package/dist/simrel/locales/index.d.ts +4 -0
  182. package/dist/simrel/locales/tr.d.ts +2 -0
  183. package/dist/simrel/renderers/default.d.ts +41 -0
  184. package/dist/simrel/runtime.d.ts +68 -0
  185. package/dist/simrel/types.d.ts +145 -0
  186. package/dist/{simrel-C1YN71aW.js → simrel-BB4Jrr32.js} +1 -1
  187. package/dist/simrel-runtime.js +1 -1
  188. package/dist/simrel.iife.js +1 -1
  189. package/dist/simrel.js +2 -2
  190. package/dist/{widget-base-UmvgIqDk.js → widget-base-B3Oq8pjs.js} +1 -1
  191. package/package.json +21 -39
package/README.md CHANGED
@@ -97,7 +97,7 @@ The chat widget includes a built-in history entry point in the header. Past chat
97
97
 
98
98
  ## Customization
99
99
 
100
- **Theme tokens** — no fork required:
100
+ **Theme tokens** — configure visual defaults at the SDK boundary:
101
101
  ```ts
102
102
  chat.init({
103
103
  theme: { primaryColor: '#f27a1a', headerBg: '#1a1a2e' },
@@ -128,9 +128,9 @@ await initOverlayWidgets({
128
128
 
129
129
  **SimBut customization** — use theme tokens, `i18n.findSimilarLabel`, and `onFindSimilar` for the PDP image-overlay pill.
130
130
 
131
- **Full fork** — replace `src/chat/components/` entirely; keep `catalog.ts` + `index.ts`.
131
+ **Reusable component changes** — update SDK components and keep `catalog.ts`, public exports, tests, and catalog previews in sync.
132
132
 
133
- See [docs/customization.md](docs/customization.md) for the fork and merchant-customization playbook.
133
+ See [docs/customization.md](docs/customization.md) for the supported SDK customization surface.
134
134
 
135
135
  ---
136
136
 
@@ -138,30 +138,16 @@ See [docs/customization.md](docs/customization.md) for the fork and merchant-cus
138
138
 
139
139
  ```bash
140
140
  npm install
141
- npm run dev -- koctascomtr --sku=1000465056 # Local dev server with HMR
142
- npm run koctascomtr # Merchant shortcut with the seeded demo SKU
143
- npm run trendyolcom # Another merchant shortcut using its default PDP SKU
144
141
  npm run typecheck # TypeScript strict check
145
142
  npm run test # Unit tests
146
143
  npm run test:chat-history # Targeted history + restore regression suite
147
144
  npm run build # Build to dist/
148
- npm run catalog # Visual component catalog at :3002
145
+ npm run catalog # Visual component catalog at :3002, with fixed generic styling presets
149
146
  npm run docs:build # Build contributor docs with VitePress
150
147
  ```
151
148
 
152
- **Using a local backend:**
153
-
154
- ```bash
155
- npm run dev -- koctascomtr --sku=1000465056 --backend-url=http://localhost:7860
156
- ```
157
-
158
- The local demos use the shared `defaultDevBackend` value from `demos/shared/default-dev-backend.ts`. For account-specific testing, set `MIDDLEWARE_URL` to the backend service location provided for your Gengage account:
159
-
160
- ```bash
161
- MIDDLEWARE_URL=http://localhost:7860 npm run dev -- koctascomtr --sku=1000465056
162
- ```
163
-
164
- Merchant demo pages under `demos/` now seed a default PDP SKU for direct launch flows, and the affected PDP shells hydrate their breadcrumb, summary content, and gallery imagery from middleware `productDetails` when the backend is available.
149
+ This repo builds the SDK package only. Hosted account demos and exact client PDP/PLP clones live in
150
+ `gengage-assistant-injector` and are deployed from that repository to `configs.gengage.ai`.
165
151
 
166
152
  ---
167
153
 
@@ -180,7 +166,6 @@ Merchant demo pages under `demos/` now seed a default PDP SKU for direct launch
180
166
  | [Security](docs/security-production.md) | Production CSP, postMessage origins, sanitization |
181
167
  | [Analytics](docs/analytics-contract.md) | GTM/GA dataLayer event mapping |
182
168
  | [Mobile SDK](docs/native-mobile-sdk.md) | Android/iOS/React Native integration |
183
- | [New Account](docs/new-account-guide.md) | Adding a new merchant demo |
184
169
  | [AGENTS](AGENTS.md) | Coding-agent architecture and code-path index |
185
170
  | [Contributing](CONTRIBUTING.md) | Shared SDK contribution workflow |
186
171
 
@@ -196,7 +181,6 @@ src/
196
181
  simrel/ # Similar products widget (GengageSimRel class + components)
197
182
  simbut/ # PDP image overlay pill widget (GengageSimBut class)
198
183
  native/ # Native WebView bridge exports
199
- demos/ # Merchant-branded demo pages and framework integration examples
200
184
  catalog/ # Visual component catalog (mock data, no backend)
201
185
  docs/ # Architecture, wire protocol, customization, analytics
202
186
  tests/ # Vitest unit tests + Playwright E2E
@@ -0,0 +1,19 @@
1
+ import type { InjectorAdapter } from '../../common/transport.js';
2
+ import type { AccountModule, BeaconCallback, ToolMap } from '../types.js';
3
+ interface CreateInjectorAdapterArgs {
4
+ accountId: string;
5
+ worker: Worker;
6
+ beUrl: string;
7
+ devJwtSecret?: string | undefined;
8
+ tokenBrokerUrl?: string | undefined;
9
+ tokenBrokerAudience?: string | undefined;
10
+ defaultLocale?: string | undefined;
11
+ tools?: ToolMap | undefined;
12
+ beacon?: BeaconCallback | undefined;
13
+ }
14
+ export declare function createInjectorAdapter({ accountId, worker, beUrl, devJwtSecret, tokenBrokerUrl, tokenBrokerAudience, defaultLocale, tools, beacon, }: CreateInjectorAdapterArgs): InjectorAdapter;
15
+ interface CreateMainThreadInjectorAdapterArgs extends Omit<CreateInjectorAdapterArgs, 'worker'> {
16
+ accountModule: AccountModule;
17
+ }
18
+ export declare function createMainThreadInjectorAdapter({ accountId, accountModule, beUrl, devJwtSecret, tokenBrokerUrl, tokenBrokerAudience, defaultLocale, tools, beacon, }: CreateMainThreadInjectorAdapterArgs): InjectorAdapter;
19
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { InjectorAdapter } from '../../common/transport.js';
2
+ interface InstallFetchBridgeArgs {
3
+ accountId: string;
4
+ streamTransport: InjectorAdapter;
5
+ }
6
+ interface InstallFetchBridgeResult {
7
+ middlewareUrl: string;
8
+ stop: () => void;
9
+ }
10
+ export declare function installFetchTransportBridge({ accountId, streamTransport, }: InstallFetchBridgeArgs): InstallFetchBridgeResult;
11
+ export {};
@@ -0,0 +1,38 @@
1
+ import type { AccountModule, BeaconCallback, ToolMap } from '../types.js';
2
+ interface MountAccountArgs {
3
+ accountId: string;
4
+ beUrl: string;
5
+ devJwtSecret?: string;
6
+ tokenBrokerUrl?: string;
7
+ tokenBrokerAudience?: string;
8
+ workerUrl: string;
9
+ defaultLocale?: string;
10
+ accountModule: AccountModule;
11
+ tools?: ToolMap;
12
+ beacon?: BeaconCallback;
13
+ allowBlobWorker?: boolean;
14
+ }
15
+ interface AgentDiagnostics {
16
+ accountId: string;
17
+ beUrl: string;
18
+ workerUrl: string;
19
+ mounted: boolean;
20
+ transport: 'worker' | 'main-thread';
21
+ flows: string[];
22
+ }
23
+ export interface AgentController {
24
+ type: 'agent';
25
+ stop: () => void;
26
+ diagnostics: () => AgentDiagnostics;
27
+ }
28
+ interface ModuleWorkerHandle {
29
+ worker: Worker;
30
+ cleanup: () => void;
31
+ }
32
+ interface CreateModuleWorkerOptions {
33
+ allowBlobWorker?: boolean;
34
+ }
35
+ export declare function mountAccount({ accountId, beUrl, devJwtSecret, tokenBrokerUrl, tokenBrokerAudience, workerUrl, defaultLocale, accountModule, tools, beacon, allowBlobWorker, }: MountAccountArgs): AgentController;
36
+ export declare function canUseModuleWorker(workerUrl: string): boolean;
37
+ export declare function createModuleWorker(workerUrl: string, name: string, options?: CreateModuleWorkerOptions): ModuleWorkerHandle;
38
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { ChatContext } 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
+ }
9
+ interface IncomingMessageLike {
10
+ role?: unknown;
11
+ content?: unknown;
12
+ }
13
+ export declare function createChatContext(args: CreateChatContextArgs): ChatContext;
14
+ export declare function appendMessage(context: ChatContext, message: IncomingMessageLike): ChatContext;
15
+ export {};
@@ -0,0 +1,20 @@
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
+ }
9
+ type PatchInput = Partial<ChatContext> | null | undefined | ((current: ChatContext) => Partial<ChatContext> | null | undefined);
10
+ export declare class ContextStore {
11
+ #private;
12
+ constructor({ accountId, locale, parentUrl, rpc }: ContextStoreOptions);
13
+ load(request: (ProcessActionRequest & {
14
+ sessionId?: string;
15
+ }) | null | undefined): Promise<ChatContext>;
16
+ patch(threadId: string | null | undefined, patch: PatchInput): ChatContext | null;
17
+ appendUserMessage(threadId: string | null | undefined, text: string): ChatContext | null;
18
+ commit(threadId: string | null | undefined): Promise<ChatContext | null>;
19
+ }
20
+ export {};
@@ -0,0 +1,12 @@
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
+ }
10
+ export declare function loadStickyContext({ accountId, threadId, rpc }: LoadArgs): Promise<Record<string, unknown>>;
11
+ export declare function saveStickyContext({ accountId, threadId, extensions, rpc }: SaveArgs): Promise<void>;
12
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { StreamEventAction, StreamEventDone, StreamEventError, StreamEventMetadata, StreamEventTextChunk, StreamEventUISpec } from '../../common/types.js';
2
+ import type { UiSpecEnvelope } from '../types.js';
3
+ export declare function metadata(args?: Record<string, unknown>): StreamEventMetadata;
4
+ type TextChunkExtras = Omit<StreamEventTextChunk, 'type' | 'content' | 'final'>;
5
+ export declare function textChunk(content: string, final?: boolean, extras?: TextChunkExtras): StreamEventTextChunk;
6
+ export declare function uiSpec(args: UiSpecEnvelope): StreamEventUISpec;
7
+ export declare function action(payload: StreamEventAction['action']): StreamEventAction;
8
+ export declare function error(code: string, message: string): StreamEventError;
9
+ export declare function done(): StreamEventDone;
10
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { StreamEventError } from '../../common/types.js';
2
+ interface AgentErrorOptions {
3
+ source?: string;
4
+ sourceCode?: string;
5
+ detail?: unknown;
6
+ }
7
+ export declare class AgentError extends Error {
8
+ readonly code: string;
9
+ readonly source: string;
10
+ readonly sourceCode?: string;
11
+ readonly detail?: unknown;
12
+ constructor(code: string, message: string, options?: AgentErrorOptions);
13
+ }
14
+ interface BeErrorLike {
15
+ code?: unknown;
16
+ detail?: unknown;
17
+ }
18
+ export declare function beErrorToAgentError(beError: BeErrorLike | null | undefined): AgentError;
19
+ interface HttpErrorBody {
20
+ error?: {
21
+ code?: unknown;
22
+ detail?: unknown;
23
+ };
24
+ }
25
+ export declare function httpErrorToAgentError(status: number, body: HttpErrorBody | null | undefined): AgentError;
26
+ export declare function caughtToStreamError(caught: unknown): StreamEventError;
27
+ export {};
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Account-agnostic product normalization. Maps a wide variety of catalog
3
+ * shapes (Algolia hits, scraped JSON-LD, direct product feeds) into the
4
+ * minimal field set that FE's ProductCard / ProductDetailsPanel renderers
5
+ * consume. Used by the UI-spec builders.
6
+ */
7
+ export interface NormalizedProduct {
8
+ sku: string;
9
+ name: string;
10
+ url: string;
11
+ imageUrl?: string;
12
+ images?: string[];
13
+ price?: string;
14
+ originalPrice?: string;
15
+ brand?: string;
16
+ rating?: number;
17
+ reviewCount?: number;
18
+ cartCode?: string;
19
+ inStock?: boolean;
20
+ categoryNames?: string[];
21
+ }
22
+ export interface TrimmedProductFacts {
23
+ sku: unknown;
24
+ name?: unknown;
25
+ url?: unknown;
26
+ price?: unknown;
27
+ currency?: unknown;
28
+ category?: unknown;
29
+ category_names?: unknown;
30
+ image?: unknown;
31
+ in_stock?: unknown;
32
+ rating?: unknown;
33
+ review_count?: unknown;
34
+ }
35
+ export declare function normalizeProduct(product: unknown): NormalizedProduct | null;
36
+ /**
37
+ * Compact product facts for BE LLM-op evidence. Account-agnostic core —
38
+ * keeps fields aligned with BE's shared productSchema (sharedSchemas.ts)
39
+ * and drops merchant-internal noise (cart codes, group ids, full image
40
+ * arrays, internal flags). Account-specific trimmers can wrap this and
41
+ * add domain-specific facet fields (e.g. occasion, color) on top.
42
+ */
43
+ export declare function trimProductFactsCore(product: unknown): unknown;
44
+ export declare function trimProductFactsListCore(products: unknown): unknown[];
45
+ export declare function firstString(...values: unknown[]): string;
46
+ export declare function numberValue(value: unknown): number;
47
+ export declare function stringList(value: unknown): string[];
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Account-agnostic UI-spec builders for FE-facing StreamEvents.
3
+ *
4
+ * Account flows compose these to emit `ui_spec` events. They produce the
5
+ * generic `chat` widget envelope used across all merchants. Account-specific
6
+ * decoration (occasion-aware copy, brand-themed cards, etc.) belongs in
7
+ * the account folder, but the structural specs live here.
8
+ */
9
+ import type { UiSpecEnvelope } from '../types.js';
10
+ import { firstString, numberValue, stringList } from './product-normalize.js';
11
+ interface ActionRequest {
12
+ title?: string;
13
+ type?: string;
14
+ payload?: unknown;
15
+ }
16
+ interface ActionEntry {
17
+ label?: string;
18
+ title?: string;
19
+ shortName?: string;
20
+ action?: ActionRequest;
21
+ requestDetails?: ActionRequest;
22
+ request_details?: ActionRequest;
23
+ }
24
+ interface ComparisonInput {
25
+ multiple_product_details?: unknown[];
26
+ products?: unknown[];
27
+ recommended_choice_sku?: string;
28
+ recommended_choice?: string;
29
+ table?: Record<string, unknown>;
30
+ key_differences?: unknown;
31
+ special_considerations?: unknown;
32
+ }
33
+ export declare function productsUiSpec(products?: unknown[]): UiSpecEnvelope;
34
+ export declare function productDetailsUiSpec(product: unknown): UiSpecEnvelope;
35
+ export declare function comparisonUiSpec(comparison?: ComparisonInput): UiSpecEnvelope;
36
+ export declare function actionButtonsUiSpec(actions?: ActionEntry[]): UiSpecEnvelope;
37
+ export { firstString, numberValue, stringList };
@@ -0,0 +1 @@
1
+ export declare const beautyConsultingTurnFlow: import("../types.js").Flow;
@@ -0,0 +1,2 @@
1
+ import type { Flow, FlowStep } from '../types.js';
2
+ export declare function createFlow(steps: readonly FlowStep[]): Flow;
@@ -0,0 +1,3 @@
1
+ import type { ProcessActionRequest } from '../../common/transport.js';
2
+ import type { Flow } from '../types.js';
3
+ export declare function resolveFlow(dispatch: Record<string, Flow | undefined>, request: ProcessActionRequest | null | undefined): Flow | undefined;
@@ -0,0 +1,18 @@
1
+ export { createInjectorAdapter, createMainThreadInjectorAdapter } from './adaptor/create-adaptor.js';
2
+ export { installFetchTransportBridge } from './adaptor/fetch-bridge.js';
3
+ export { canUseModuleWorker, createModuleWorker, mountAccount } from './adaptor/mount.js';
4
+ export { ContextStore } from './context/context-store.js';
5
+ export { action, done, error, metadata, textChunk, uiSpec } from './events/builders.js';
6
+ export { AgentError, beErrorToAgentError, caughtToStreamError, httpErrorToAgentError, } from './events/error-taxonomy.js';
7
+ export { normalizeProduct, trimProductFactsCore, trimProductFactsListCore } from './events/product-normalize.js';
8
+ export { actionButtonsUiSpec, comparisonUiSpec, productDetailsUiSpec, productsUiSpec } from './events/ui-specs.js';
9
+ export { beautyConsultingTurnFlow } from './flow/beauty-consulting-turn.js';
10
+ export { createFlow } from './flow/create-flow.js';
11
+ export { resolveFlow } from './flow/dispatch.js';
12
+ export { setAssistantHostVisible } from './util/assistant-host.js';
13
+ export { resolveBeUrl } from './util/be-url.js';
14
+ export { createBrowserMemory, stableKey } from './util/browser-memory.js';
15
+ export { createDiagnosticsTool, createReadPageTool, installBrowserTools } from './util/browser-tools.js';
16
+ export { startLazyRuntimeLoader } from './util/lazy-runtime-loader.js';
17
+ export { requestText } from './util/request-text.js';
18
+ export { elapsedMs, nowIso } from './util/time.js';