@gengage/assistant-fe 0.5.7 → 0.6.0

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 (190) hide show
  1. package/dist/agentic/adaptor/create-adaptor.d.ts +19 -0
  2. package/dist/agentic/adaptor/fetch-bridge.d.ts +11 -0
  3. package/dist/agentic/adaptor/mount.d.ts +38 -0
  4. package/dist/agentic/context/chat-context.d.ts +15 -0
  5. package/dist/agentic/context/context-store.d.ts +20 -0
  6. package/dist/agentic/context/persistence.d.ts +12 -0
  7. package/dist/agentic/events/builders.d.ts +10 -0
  8. package/dist/agentic/events/error-taxonomy.d.ts +27 -0
  9. package/dist/agentic/events/product-normalize.d.ts +47 -0
  10. package/dist/agentic/events/ui-specs.d.ts +37 -0
  11. package/dist/agentic/flow/beauty-consulting-turn.d.ts +1 -0
  12. package/dist/agentic/flow/create-flow.d.ts +2 -0
  13. package/dist/agentic/flow/dispatch.d.ts +3 -0
  14. package/dist/agentic/index.d.ts +18 -0
  15. package/dist/agentic/index.js +620 -0
  16. package/dist/agentic/types.d.ts +212 -0
  17. package/dist/agentic/util/assistant-host.d.ts +11 -0
  18. package/dist/agentic/util/be-url.d.ts +4 -0
  19. package/dist/agentic/util/browser-memory.d.ts +13 -0
  20. package/dist/agentic/util/browser-tools.d.ts +31 -0
  21. package/dist/agentic/util/lazy-runtime-loader.d.ts +9 -0
  22. package/dist/agentic/util/request-text.d.ts +3 -0
  23. package/dist/agentic/util/time.d.ts +2 -0
  24. package/dist/agentic/worker/be-client.d.ts +15 -0
  25. package/dist/agentic/worker/entry.d.ts +2 -0
  26. package/dist/agentic/worker/flow-runner.d.ts +24 -0
  27. package/dist/agentic/worker/jwt-mint.d.ts +21 -0
  28. package/dist/agentic/worker/rpc.d.ts +24 -0
  29. package/dist/agentic/worker/tool-bridge.d.ts +2 -0
  30. package/dist/agentic/worker.d.ts +16 -0
  31. package/dist/agentic/worker.js +119 -0
  32. package/dist/agentic.iife.js +5 -0
  33. package/dist/{api-paths-CwzwbgQZ.js → api-paths-DJFF9RuZ.js} +1 -1
  34. package/dist/beauty-consulting-turn-BmPXbkQg.js +1019 -0
  35. package/dist/chat/api.d.ts +17 -0
  36. package/dist/chat/assistant-mode.d.ts +20 -0
  37. package/dist/chat/attachment-utils.d.ts +9 -0
  38. package/dist/chat/catalog.d.ts +455 -0
  39. package/dist/chat/chat-presentation-state.d.ts +53 -0
  40. package/dist/chat/components/AIGroupingCards.d.ts +15 -0
  41. package/dist/chat/components/AISuggestedSearchCards.d.ts +13 -0
  42. package/dist/chat/components/AITopPicks.d.ts +9 -0
  43. package/dist/chat/components/BeautyPhotoStep.d.ts +31 -0
  44. package/dist/chat/components/CategoriesContainer.d.ts +11 -0
  45. package/dist/chat/components/ChatDrawer.d.ts +362 -0
  46. package/dist/chat/components/ChoicePrompter.d.ts +21 -0
  47. package/dist/chat/components/ComparisonTable.d.ts +66 -0
  48. package/dist/chat/components/ConsultingStylePicker.d.ts +40 -0
  49. package/dist/chat/components/FloatingComparisonButton.d.ts +7 -0
  50. package/dist/chat/components/FloatingLauncher.d.ts +79 -0
  51. package/dist/chat/components/GroundingReviewCard.d.ts +11 -0
  52. package/dist/chat/components/HandoffNotice.d.ts +9 -0
  53. package/dist/chat/components/KvkkBanner.d.ts +6 -0
  54. package/dist/chat/components/Launcher.d.ts +28 -0
  55. package/dist/chat/components/PanelRestoreCard.d.ts +4 -0
  56. package/dist/chat/components/PanelTopBar.d.ts +32 -0
  57. package/dist/chat/components/PhotoAnalysisCard.d.ts +27 -0
  58. package/dist/chat/components/ProductSummaryCard.d.ts +12 -0
  59. package/dist/chat/components/ProsAndCons.d.ts +8 -0
  60. package/dist/chat/components/ReviewHighlights.d.ts +16 -0
  61. package/dist/chat/components/actionClassifier.d.ts +12 -0
  62. package/dist/chat/components/product-price-layout.d.ts +17 -0
  63. package/dist/chat/components/productMentionLinker.d.ts +26 -0
  64. package/dist/chat/components/renderUISpec.d.ts +15 -0
  65. package/dist/chat/components/typewriter.d.ts +24 -0
  66. package/dist/chat/extendedModeManager.d.ts +32 -0
  67. package/dist/chat/features/beauty-consulting/consulting-grid.d.ts +38 -0
  68. package/dist/chat/features/beauty-consulting/drawer-extensions.d.ts +22 -0
  69. package/dist/chat/features/beauty-consulting/mode-controller.d.ts +59 -0
  70. package/dist/chat/features/beauty-consulting/registry.d.ts +9 -0
  71. package/dist/chat/features/beauty-consulting/stream-handler.d.ts +45 -0
  72. package/dist/chat/history-storage.d.ts +85 -0
  73. package/dist/chat/index.d.ts +6 -0
  74. package/dist/chat/kvkk.d.ts +20 -0
  75. package/dist/chat/locales/en.d.ts +2 -0
  76. package/dist/chat/locales/index.d.ts +5 -0
  77. package/dist/chat/locales/tr.d.ts +2 -0
  78. package/dist/chat/panel-manager.d.ts +142 -0
  79. package/dist/chat/runtime.d.ts +416 -0
  80. package/dist/chat/session-persistence.d.ts +73 -0
  81. package/dist/chat/stream-error-display.d.ts +6 -0
  82. package/dist/chat/types.d.ts +547 -0
  83. package/dist/chat/utils/chat-presentation-debug.d.ts +18 -0
  84. package/dist/chat/utils/get-chat-scroll-element.d.ts +10 -0
  85. package/dist/chat/utils/ui.d.ts +10 -0
  86. package/dist/chat-runtime.js +1 -1
  87. package/dist/chat.iife.js +12 -12
  88. package/dist/chat.js +1 -1
  89. package/dist/common/action-router.d.ts +26 -0
  90. package/dist/common/api-paths.d.ts +23 -0
  91. package/dist/common/client.d.ts +27 -0
  92. package/dist/common/communication-bridge.d.ts +51 -0
  93. package/dist/common/config-constants.d.ts +1 -0
  94. package/dist/common/config-schema.d.ts +54 -0
  95. package/dist/common/connection-warning.d.ts +8 -0
  96. package/dist/common/consulting-sources.d.ts +8 -0
  97. package/dist/common/context.d.ts +64 -0
  98. package/dist/common/css-escape.d.ts +1 -0
  99. package/dist/common/customization-factories.d.ts +59 -0
  100. package/dist/common/debug.d.ts +13 -0
  101. package/dist/common/events.d.ts +55 -0
  102. package/dist/common/fastIntent.d.ts +1 -0
  103. package/dist/common/find-similar-payload.d.ts +3 -0
  104. package/dist/common/ga-datalayer.d.ts +80 -0
  105. package/dist/common/global-error-toast.d.ts +6 -0
  106. package/dist/common/index.d.ts +47 -0
  107. package/dist/common/indexed-db.d.ts +89 -0
  108. package/dist/common/locale.d.ts +1 -0
  109. package/dist/common/native-webview.d.ts +60 -0
  110. package/dist/common/navigation.d.ts +1 -0
  111. package/dist/common/overlay.d.ts +172 -0
  112. package/dist/common/page-detect.d.ts +36 -0
  113. package/dist/common/pill-launcher.d.ts +51 -0
  114. package/dist/common/preflight.d.ts +13 -0
  115. package/dist/common/price-formatter.d.ts +35 -0
  116. package/dist/common/product-utils.d.ts +35 -0
  117. package/dist/common/protocol-adapter.d.ts +108 -0
  118. package/dist/common/renderer/dom.d.ts +3 -0
  119. package/dist/common/renderer/index.d.ts +4 -0
  120. package/dist/common/renderer/overrides.d.ts +23 -0
  121. package/dist/common/renderer/registry.d.ts +2 -0
  122. package/dist/common/renderer/types.d.ts +19 -0
  123. package/dist/common/safe-html.d.ts +22 -0
  124. package/dist/common/sdk-version.d.ts +3 -0
  125. package/dist/common/streaming.d.ts +52 -0
  126. package/dist/common/suggested-search-keywords.d.ts +18 -0
  127. package/dist/common/theme-utils.d.ts +15 -0
  128. package/dist/common/transport.d.ts +75 -0
  129. package/dist/common/tts-player.d.ts +13 -0
  130. package/dist/common/types.d.ts +379 -0
  131. package/dist/common/ui-theme.d.ts +9 -0
  132. package/dist/common/uuidv7.d.ts +7 -0
  133. package/dist/common/voice-input.d.ts +74 -0
  134. package/dist/common/widget-base.d.ts +82 -0
  135. package/dist/{common-KpJP1YwP.js → common-BydCGBNn.js} +90 -139
  136. package/dist/common.js +41 -41
  137. package/dist/{connection-warning-B5T_1oBn.js → connection-warning-Pbvk3J8k.js} +1 -1
  138. package/dist/{fastIntent--Ukm2nOh.js → fastIntent-CkYN2UOl.js} +199 -137
  139. package/dist/index.d.ts +25 -0
  140. package/dist/index.js +50 -50
  141. package/dist/native/index.d.ts +2 -0
  142. package/dist/{native-webview-qfjm4SHx.js → native-webview-JDC1vtde.js} +1 -1
  143. package/dist/native.iife.js +14 -14
  144. package/dist/native.js +1 -1
  145. package/dist/{overlay-CP5A0Hhf.js → overlay-BetAvpVZ.js} +19 -19
  146. package/dist/overlay.d.ts +4 -0
  147. package/dist/overlay.js +1 -1
  148. package/dist/qna/api.d.ts +23 -0
  149. package/dist/qna/catalog.d.ts +60 -0
  150. package/dist/qna/components/ButtonRow.d.ts +15 -0
  151. package/dist/qna/components/TextInput.d.ts +11 -0
  152. package/dist/qna/components/renderUISpec.d.ts +7 -0
  153. package/dist/qna/index.d.ts +3 -0
  154. package/dist/qna/locales/en.d.ts +2 -0
  155. package/dist/qna/locales/index.d.ts +4 -0
  156. package/dist/qna/locales/tr.d.ts +2 -0
  157. package/dist/qna/normalize-ui-specs.d.ts +15 -0
  158. package/dist/qna/runtime.d.ts +73 -0
  159. package/dist/qna/types.d.ts +98 -0
  160. package/dist/qna-runtime.js +1 -1
  161. package/dist/qna.iife.js +1 -1
  162. package/dist/qna.js +1 -1
  163. package/dist/{runtime-BPyXOyyp.js → runtime-DbZO1qG5.js} +3 -3
  164. package/dist/{runtime-G3idwfkM.js → runtime-OpNoB3cu.js} +894 -853
  165. package/dist/{runtime-C3yOvNFK.js → runtime-iCLkUjI3.js} +3 -3
  166. package/dist/simbut/index.d.ts +31 -0
  167. package/dist/simbut/locales.d.ts +3 -0
  168. package/dist/simbut/types.d.ts +43 -0
  169. package/dist/{simbut-CiknJI6-.js → simbut-FyXolmZY.js} +1 -1
  170. package/dist/simbut.iife.js +1 -1
  171. package/dist/simbut.js +1 -1
  172. package/dist/simrel/api.d.ts +25 -0
  173. package/dist/simrel/catalog.d.ts +77 -0
  174. package/dist/simrel/components/GroupTabs.d.ts +24 -0
  175. package/dist/simrel/components/ProductCard.d.ts +19 -0
  176. package/dist/simrel/components/ProductGrid.d.ts +17 -0
  177. package/dist/simrel/components/renderUISpec.d.ts +7 -0
  178. package/dist/simrel/index.d.ts +5 -0
  179. package/dist/simrel/locales/en.d.ts +2 -0
  180. package/dist/simrel/locales/index.d.ts +4 -0
  181. package/dist/simrel/locales/tr.d.ts +2 -0
  182. package/dist/simrel/renderers/default.d.ts +41 -0
  183. package/dist/simrel/runtime.d.ts +68 -0
  184. package/dist/simrel/types.d.ts +145 -0
  185. package/dist/{simrel-C1YN71aW.js → simrel-CbLe5OAr.js} +1 -1
  186. package/dist/simrel-runtime.js +1 -1
  187. package/dist/simrel.iife.js +1 -1
  188. package/dist/simrel.js +2 -2
  189. package/dist/{widget-base-UmvgIqDk.js → widget-base-COP8QwU3.js} +1 -1
  190. package/package.json +20 -6
@@ -0,0 +1,60 @@
1
+ import type { OverlayWidgetsController, OverlayWidgetsOptions } from './overlay.js';
2
+ export declare const DEFAULT_NATIVE_TRACKED_EVENTS: readonly ["gengage:chat:open", "gengage:chat:close", "gengage:chat:ready", "gengage:chat:add-to-cart", "gengage:qna:action", "gengage:qna:open-chat", "gengage:similar:product-click", "gengage:similar:grouping-click", "gengage:similar:products-impression", "gengage:similar:add-to-cart", "gengage:global:error", "gengage:context:update"];
3
+ export type NativeTrackedEvent = (typeof DEFAULT_NATIVE_TRACKED_EVENTS)[number];
4
+ export type NativeInboundMessage = 'openChat' | 'closeChat' | 'updateContext' | 'updatePageContext' | 'setPageContext' | 'updateSku' | 'setSession' | 'destroy';
5
+ export type NativeBridgeEnvironment = 'ios' | 'android' | 'react-native' | 'browser';
6
+ export interface NativeSessionPayload {
7
+ sessionId?: string;
8
+ userId?: string;
9
+ }
10
+ export interface NativeBridgeMessage {
11
+ type: string;
12
+ payload?: unknown;
13
+ }
14
+ export interface NativeWebViewBridgeOptions {
15
+ iosHandlerName?: string;
16
+ androidInterfaceName?: string;
17
+ reactNativeInterfaceName?: string;
18
+ trackedEvents?: NativeTrackedEvent[] | string[];
19
+ /** Log unhandled inbound message types to console in addition to forwarding to postMessage. */
20
+ logUnhandled?: boolean;
21
+ /** Injected for tests; defaults to global window. */
22
+ win?: Window;
23
+ }
24
+ export interface NativeWebViewBridge {
25
+ readonly env: NativeBridgeEnvironment;
26
+ sendToNative(type: string, payload?: unknown): void;
27
+ receive(message: NativeBridgeMessage | string): void;
28
+ setController(controller: OverlayWidgetsController | null): void;
29
+ destroy(): void;
30
+ }
31
+ export interface NativeOverlayInitOptions extends OverlayWidgetsOptions {
32
+ nativeBridge?: Omit<NativeWebViewBridgeOptions, 'win'>;
33
+ emitReadyEvent?: boolean;
34
+ }
35
+ export interface NativeOverlayInitResult {
36
+ controller: OverlayWidgetsController;
37
+ bridge: NativeWebViewBridge;
38
+ destroy(): void;
39
+ }
40
+ export declare function detectNativeEnvironment(options?: Pick<NativeWebViewBridgeOptions, 'iosHandlerName' | 'androidInterfaceName' | 'reactNativeInterfaceName' | 'win'>): NativeBridgeEnvironment;
41
+ /**
42
+ * Applies native-provided session identity so widgets can share correlation IDs
43
+ * with the host app. Safe to call before or after widget initialization.
44
+ */
45
+ export declare function applyNativeSession(payload: NativeSessionPayload, options?: Pick<NativeWebViewBridgeOptions, 'win'>): void;
46
+ /**
47
+ * Installs a native WebView bridge compatible with:
48
+ * - iOS WKWebView (`webkit.messageHandlers`)
49
+ * - Android JavascriptInterface (`window.GengageNative`)
50
+ * - React Native WebView (`window.ReactNativeWebView`)
51
+ * and exposes it on `window.gengageNative`.
52
+ */
53
+ export declare function createNativeWebViewBridge(options?: NativeWebViewBridgeOptions): NativeWebViewBridge;
54
+ /**
55
+ * Convenience helper for mobile WebViews:
56
+ * 1) installs native bridge
57
+ * 2) initializes overlay widgets
58
+ * 3) sends a `ready` message to native
59
+ */
60
+ export declare function initNativeOverlayWidgets(options: NativeOverlayInitOptions): Promise<NativeOverlayInitResult>;
@@ -0,0 +1 @@
1
+ export declare function navigateToUrl(url: string, newTab?: boolean): boolean;
@@ -0,0 +1,172 @@
1
+ import type { GengageChat } from '../chat/runtime.js';
2
+ import type { ChatI18n, ChatWidgetConfig } from '../chat/types.js';
3
+ import type { GengageQNA } from '../qna/runtime.js';
4
+ import type { QNAWidgetConfig } from '../qna/types.js';
5
+ import type { GengageSimRel } from '../simrel/runtime.js';
6
+ import type { SimRelWidgetConfig } from '../simrel/types.js';
7
+ import type { GengageSimBut } from '../simbut/index.js';
8
+ import type { SimButWidgetConfig } from '../simbut/types.js';
9
+ import type { AddToCartHandlerResult, AddToCartParams, PageContext, SessionContext, WidgetTheme } from './types.js';
10
+ import type { InjectorAdapter } from './transport.js';
11
+ export interface OverlayChatOptions {
12
+ enabled?: boolean;
13
+ /** AGENTIC_ADAPTER_SEAM: optional chat transport override from the injector. */
14
+ injectorAdapter?: InjectorAdapter;
15
+ variant?: ChatWidgetConfig['variant'];
16
+ mountTarget?: HTMLElement | string;
17
+ launcherSvg?: string;
18
+ launcherImageUrl?: string;
19
+ mobileLauncherImageUrl?: string;
20
+ headerTitle?: string;
21
+ headerAvatarUrl?: string;
22
+ headerBadge?: string;
23
+ headerCartUrl?: string;
24
+ headerFavoritesToggle?: boolean;
25
+ /** Opens merchant favorites page (passed to chat `onFavoritesClick`). */
26
+ onFavoritesClick?: () => void;
27
+ hideMobileLauncher?: boolean;
28
+ mobileBreakpoint?: number;
29
+ mobileInitialState?: 'half' | 'full';
30
+ i18n?: Partial<ChatI18n>;
31
+ actionHandling?: ChatWidgetConfig['actionHandling'];
32
+ /** UISpec renderer overrides for chat components. */
33
+ renderer?: ChatWidgetConfig['renderer'];
34
+ /** When true, allow full product details in the assistant side panel; default is chat summary only. */
35
+ productDetailsExtended?: boolean;
36
+ /** Hides percent discount badges on chat product cards / details when true. */
37
+ hideProductDiscountBadge?: ChatWidgetConfig['hideProductDiscountBadge'];
38
+ /** When true, hides user reviews (ReviewHighlights, review chip, AITopPicks reviewHighlight). */
39
+ hideUserReviews?: ChatWidgetConfig['hideUserReviews'];
40
+ /** When true, hides in-stock / out-of-stock labels on product cards. */
41
+ hideStockStatus?: ChatWidgetConfig['hideStockStatus'];
42
+ isDemoWebsite?: ChatWidgetConfig['isDemoWebsite'];
43
+ /** Pill launcher — forwarded to `chat.pillLauncher` (applied inside GengageChat). */
44
+ pillLauncher?: ChatWidgetConfig['pillLauncher'];
45
+ /** Search-bar style floating launcher — forwarded to `chat.floatingLauncher`. */
46
+ floatingLauncher?: ChatWidgetConfig['floatingLauncher'];
47
+ /** Dynamic launcher positioning relative to page elements. */
48
+ launcherAnchor?: ChatWidgetConfig['launcherAnchor'];
49
+ /** Called when the chat panel opens. */
50
+ onOpen?: () => void;
51
+ /** Called when the chat panel closes. */
52
+ onClose?: () => void;
53
+ productPriceUi?: ChatWidgetConfig['productPriceUi'];
54
+ }
55
+ export interface OverlayQNAOptions {
56
+ enabled?: boolean;
57
+ mountTarget?: HTMLElement | string;
58
+ chrome?: QNAWidgetConfig['chrome'];
59
+ ctaText?: string;
60
+ hideButtonRowCta?: boolean;
61
+ inputPlaceholder?: QNAWidgetConfig['inputPlaceholder'];
62
+ inputAfterPills?: QNAWidgetConfig['inputAfterPills'];
63
+ i18n?: QNAWidgetConfig['i18n'];
64
+ /** UISpec renderer overrides for QNA components. */
65
+ renderer?: QNAWidgetConfig['renderer'];
66
+ /**
67
+ * Q&A panel heading (e.g. "Koçtaş'a Sor"). Independent from `chat.headerTitle`.
68
+ * If omitted, falls back to the deprecated `headingTitle` field.
69
+ * Set this explicitly — it does not inherit from `chat.headerTitle`.
70
+ */
71
+ headerTitle?: string;
72
+ /** @deprecated Use `headerTitle` */
73
+ headingTitle?: string;
74
+ }
75
+ export interface OverlaySimRelOptions {
76
+ enabled?: boolean;
77
+ mountTarget?: HTMLElement | string;
78
+ discountType?: SimRelWidgetConfig['discountType'];
79
+ gridColumns?: SimRelWidgetConfig['gridColumns'];
80
+ enableProductGroupings?: SimRelWidgetConfig['enableProductGroupings'];
81
+ /** Custom card element renderer for the direct rendering path (GroupTabs/ProductGrid). */
82
+ renderCardElement?: SimRelWidgetConfig['renderCardElement'];
83
+ /** UISpec renderer overrides for simrel components. */
84
+ renderer?: SimRelWidgetConfig['renderer'];
85
+ }
86
+ export interface OverlaySimButOptions {
87
+ enabled?: boolean;
88
+ mountTarget?: HTMLElement | string;
89
+ layout?: SimButWidgetConfig['layout'];
90
+ inlineCard?: SimButWidgetConfig['inlineCard'];
91
+ /** Optional product image URL for custom `onFindSimilar`; chat actions use SKU when available. */
92
+ imageUrl?: string;
93
+ i18n?: SimButWidgetConfig['i18n'];
94
+ /** Custom click behavior, used instead of `chat` when provided. */
95
+ onFindSimilar?: SimButWidgetConfig['onFindSimilar'];
96
+ }
97
+ export interface OverlayWidgetsOptions {
98
+ accountId: string;
99
+ middlewareUrl: string;
100
+ /** AGENTIC_ADAPTER_SEAM: top-level adapter forwarded into chat only. */
101
+ injectorAdapter?: InjectorAdapter;
102
+ locale?: string;
103
+ session?: Partial<SessionContext>;
104
+ pageContext?: Partial<PageContext>;
105
+ sku?: string;
106
+ theme?: WidgetTheme;
107
+ /** Backward-compatible alias for `chat.isDemoWebsite`. */
108
+ isDemoWebsite?: ChatWidgetConfig['isDemoWebsite'];
109
+ /** Backward-compatible alias for `chat.productDetailsExtended`. */
110
+ productDetailsExtended?: ChatWidgetConfig['productDetailsExtended'];
111
+ /** Price formatting options. Defaults to Turkish locale. */
112
+ pricing?: import('./price-formatter.js').PriceFormatConfig;
113
+ idempotencyKey?: string;
114
+ wireQnaToChat?: boolean;
115
+ chat?: OverlayChatOptions;
116
+ qna?: OverlayQNAOptions;
117
+ simrel?: OverlaySimRelOptions;
118
+ simbut?: OverlaySimButOptions;
119
+ onAddToCart?: (params: AddToCartParams) => AddToCartHandlerResult;
120
+ onProductNavigate?: SimRelWidgetConfig['onProductNavigate'];
121
+ onScriptCall?: ChatWidgetConfig['onScriptCall'];
122
+ }
123
+ export interface OverlayWidgetsController {
124
+ readonly idempotencyKey: string;
125
+ readonly session: SessionContext;
126
+ readonly chat: GengageChat | null;
127
+ readonly qna: GengageQNA | null;
128
+ readonly simrel: GengageSimRel | null;
129
+ readonly simbut: GengageSimBut | null;
130
+ openChat(options?: {
131
+ state?: 'half' | 'full';
132
+ }): void;
133
+ closeChat(): void;
134
+ /**
135
+ * Merges partial page context (SKU, page type, category, …) into the active
136
+ * widgets. Use after SPA navigation so chat and PDP stay aligned.
137
+ */
138
+ updateContext(patch: Partial<PageContext>): Promise<void>;
139
+ /** @see {@link updateContext} */
140
+ updatePageContext(patch: Partial<PageContext>): Promise<void>;
141
+ /**
142
+ * Merge-only page context update. This is an alias of {@link updateContext},
143
+ * not a full replacement of the existing PageContext.
144
+ */
145
+ setPageContext(patch: Partial<PageContext>): Promise<void>;
146
+ updateSku(sku: string, pageType?: PageContext['pageType']): Promise<void>;
147
+ destroy(): void;
148
+ }
149
+ /**
150
+ * Initialize chat, QNA, SimRel, and optional SimBut (PDP image “find similar” pill) in one call.
151
+ * Idempotent — safe to call multiple times from GTM; deduplicates by account + SKU key.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * import { initOverlayWidgets } from '@gengage/assistant-fe/overlay';
156
+ *
157
+ * const controller = await initOverlayWidgets({
158
+ * accountId: 'mystore',
159
+ * middlewareUrl: '<backend service location provided for your Gengage account>',
160
+ * sku: window.productSku,
161
+ * pageContext: { pageType: 'pdp' },
162
+ * chat: { variant: 'floating' },
163
+ * qna: { mountTarget: '#qna-section' },
164
+ * simrel: { mountTarget: '#similar-products' },
165
+ * simbut: { mountTarget: '#pdp-image-wrap' },
166
+ * });
167
+ * ```
168
+ */
169
+ export declare function initOverlayWidgets(options: OverlayWidgetsOptions): Promise<OverlayWidgetsController>;
170
+ export declare function getOverlayWidgets(idempotencyKey: string): OverlayWidgetsController | null;
171
+ export declare function destroyOverlayWidgets(idempotencyKey: string): void;
172
+ export declare function buildOverlayIdempotencyKey(accountId: string): string;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * URL-based page type detection.
3
+ *
4
+ * Provides auto-detection of page type from URL patterns and DOM signals.
5
+ * Falls back to 'other' when no rule matches.
6
+ */
7
+ import type { PageContext } from './types.js';
8
+ export type DetectablePageType = PageContext['pageType'];
9
+ export interface PageDetectionRule {
10
+ /** Page type to assign when this rule matches. */
11
+ pageType: DetectablePageType;
12
+ /** URL pathname patterns (tested with `new RegExp(pattern)`). */
13
+ urlPatterns?: string[];
14
+ /** If present, page type is detected only when this query param exists. */
15
+ queryParam?: string;
16
+ /** DOM selector — if an element matching this exists, rule matches. */
17
+ selector?: string;
18
+ }
19
+ /**
20
+ * Detects page type from the current URL and optional DOM signals.
21
+ *
22
+ * @param rules - Custom rules (defaults to common Turkish e-commerce patterns).
23
+ * @param url - URL to analyze (defaults to window.location).
24
+ * @returns Detected page type, or 'other' if no rule matches.
25
+ */
26
+ export declare function detectPageType(rules?: PageDetectionRule[], url?: URL): DetectablePageType;
27
+ /**
28
+ * Attempts to extract a product SKU from the URL path.
29
+ * Looks for common patterns like `/p/SKU`, `/urun/SKU`, `/-p-SKU`.
30
+ */
31
+ export declare function extractSkuFromUrl(url?: URL): string | undefined;
32
+ /**
33
+ * Auto-detects page context from URL and DOM signals.
34
+ * Use as a fallback when the host page doesn't set pageContext explicitly.
35
+ */
36
+ export declare function autoDetectPageContext(rules?: PageDetectionRule[]): Partial<PageContext>;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * makePillLauncher — creates a pill-shaped chat launcher that combines an
3
+ * avatar image with a text label, replacing the default circular FAB.
4
+ *
5
+
6
+ * });
7
+ *
8
+ * Or call `makePillLauncher` + `apply()` manually when you need custom control.
9
+ */
10
+ export interface PillLauncherOptions {
11
+ /** Text label shown beside the avatar inside the pill */
12
+ label: string;
13
+ /** Avatar image URL — also used as `launcherImageUrl` to activate image-mode */
14
+ avatarUrl: string;
15
+ /** Brand primary color — used for border and hover effects */
16
+ primaryColor: string;
17
+ /** Dark text / shadow color for the label and drop shadow (default: '#111827') */
18
+ secondaryColor?: string;
19
+ /** CSS font-family string for the label text */
20
+ fontFamily?: string;
21
+ /** CSS class name injected on the label span (default: 'gengage-pill-launcher-label') */
22
+ labelClassName?: string;
23
+ /** id for the <style> tag injected into the shadow root (default: 'gengage-pill-launcher-style') */
24
+ styleId?: string;
25
+ /** Mobile breakpoint in px (default: 768) */
26
+ mobileBreakpoint?: number;
27
+ /** Desktop pill width (default: '188px') */
28
+ desktopWidth?: string;
29
+ /** Desktop pill height (default: '60px') */
30
+ desktopHeight?: string;
31
+ /** Avatar icon diameter (default: '46px') */
32
+ iconSize?: string;
33
+ }
34
+ export interface PillLauncherKit {
35
+ /**
36
+ * Pass as `chat.launcherImageUrl` to `initOverlayWidgets`.
37
+ * Equals `avatarUrl` — activates image-mode on the launcher button.
38
+ */
39
+ launcherImageUrl: string;
40
+ /**
41
+ * Call after `initOverlayWidgets` resolves.
42
+ * Injects pill CSS into the widget shadow root, fixes the header avatar
43
+ * class, and appends the text label span to the launcher button.
44
+ * Retries via requestAnimationFrame for up to ~1.5 s.
45
+ *
46
+ * Pass the widget's shadow root when it is available to avoid a global DOM
47
+ * scan — required when multiple GengageChat instances share the same page.
48
+ */
49
+ apply(targetShadow?: ShadowRoot): Promise<void>;
50
+ }
51
+ export declare function makePillLauncher(options: PillLauncherOptions): PillLauncherKit;
@@ -0,0 +1,13 @@
1
+ import type { AccountRuntimeConfig } from './config-schema.js';
2
+ export interface PreflightWarning {
3
+ code: string;
4
+ message: string;
5
+ severity: 'warn' | 'error';
6
+ }
7
+ export interface PreflightResult {
8
+ ok: boolean;
9
+ warnings: PreflightWarning[];
10
+ }
11
+ export declare function preflightDiagnostics(config: AccountRuntimeConfig, options?: {
12
+ skipCspCheck?: boolean;
13
+ }): PreflightResult;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Configurable price formatting.
3
+ *
4
+ * Defaults to Turkish locale (dot thousands, comma decimal, TL suffix),
5
+ * but renders whole TL amounts without kurus for a cleaner retail UI.
6
+ * Configure via widget config `pricing` field for any locale/currency.
7
+ */
8
+ export interface PriceFormatConfig {
9
+ /** ISO 4217 currency code (e.g. 'TRY', 'USD'). Not consumed by formatPrice(). */
10
+ currencyCode?: string;
11
+ /** Currency symbol. Default: 'TL' */
12
+ currencySymbol?: string;
13
+ /** Where to place the symbol. Default: 'suffix' */
14
+ currencyPosition?: 'prefix' | 'suffix';
15
+ /** Separator between thousands. Default: '.' (Turkish) */
16
+ thousandsSeparator?: string;
17
+ /** Decimal point character. Default: ',' (Turkish) */
18
+ decimalSeparator?: string;
19
+ /** Whether to show decimal part for whole numbers. Default: false */
20
+ alwaysShowDecimals?: boolean;
21
+ }
22
+ /**
23
+ * Formats a raw numeric price string into the configured locale format.
24
+ *
25
+ * Examples (default Turkish):
26
+ * "17990" → "17.990 TL"
27
+ * "17990.5" → "17.990,50 TL"
28
+ *
29
+ * Examples (GBP prefix):
30
+ * "17990" with { currencySymbol: '£', currencyPosition: 'prefix', thousandsSeparator: ',', decimalSeparator: '.' }
31
+ * → "£17,990"
32
+ *
33
+ * Returns the input as-is if it's not a valid number.
34
+ */
35
+ export declare function formatPrice(raw: string, config?: PriceFormatConfig): string;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Shared product rendering utilities.
3
+ *
4
+ * Extracted from chat/renderUISpec and simrel/ProductCard to eliminate
5
+ * duplication and provide consistent behavior across all widgets.
6
+ */
7
+ /** Clamp a rating value to the 0–5 range. Returns 0 for NaN/non-finite. */
8
+ export declare function clampRating(value: number): number;
9
+ /** Clamp a discount percentage to the 0–100 range, rounded to integer. Returns 0 for NaN/non-finite. */
10
+ export declare function clampDiscount(value: number): number;
11
+ /**
12
+ * Render a star rating string with full, half, and empty stars.
13
+ *
14
+ * @param rating - A numeric rating (will be clamped to 0–5).
15
+ * @param halfStars - Whether to render half-star characters. Defaults to true.
16
+ * @returns A string like "★★★½☆" or "★★★☆☆" (without half-stars).
17
+ */
18
+ export declare function renderStarRating(rating: number, halfStars?: boolean): string;
19
+ /**
20
+ * Create a star rating DOM element with proper half-filled star rendering.
21
+ *
22
+ * Uses a CSS-clipped full star overlaid on an empty star for the half-star,
23
+ * giving a visually accurate half-filled appearance instead of the "½" character.
24
+ *
25
+ * @param rating - A numeric rating (will be clamped to 0–5).
26
+ * @returns An HTMLSpanElement containing the star icons.
27
+ */
28
+ export declare function createStarRatingElement(rating: number): HTMLSpanElement;
29
+ /**
30
+ * Attach a one-time error handler that hides the image on load failure.
31
+ *
32
+ * Works with any HTMLImageElement. Hides the element by setting
33
+ * `display: none` so layout doesn't break from broken images.
34
+ */
35
+ export declare function addImageErrorHandler(img: HTMLImageElement): void;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Wire protocol adapter.
3
+ *
4
+ * Backend emits NDJSON events with `type` values like
5
+ * `outputText`, `suggestedActions`, `productList`, etc.
6
+ *
7
+ * This module translates those backend events into the SDK's normalized
8
+ * `StreamEvent` model.
9
+ *
10
+ * Also handles JSON-mode responses from `similar_products` and
11
+ * `product_groupings` endpoints.
12
+ */
13
+ import type { StreamEvent } from './types.js';
14
+ export interface V1Product {
15
+ sku: string;
16
+ name: string;
17
+ brand?: string;
18
+ images?: string[];
19
+ price?: number;
20
+ price_discounted?: number;
21
+ price_discount_rate?: number;
22
+ price_currency?: string;
23
+ discount_reason?: string;
24
+ url?: string;
25
+ rating?: number;
26
+ review_count?: number;
27
+ cart_code?: string;
28
+ in_stock?: boolean;
29
+ description?: string;
30
+ description_html?: string;
31
+ features?: Array<{
32
+ name?: string;
33
+ key?: string;
34
+ value?: string | number | boolean;
35
+ [key: string]: unknown;
36
+ }>;
37
+ specifications?: Record<string, string> | Array<{
38
+ key: string;
39
+ value: string;
40
+ }>;
41
+ short_name?: string;
42
+ category_ids?: string[];
43
+ category_names?: string[];
44
+ variants?: Array<Record<string, unknown>>;
45
+ facet_hits?: Record<string, unknown> | null;
46
+ promotions?: string[];
47
+ }
48
+ export declare function adaptBackendEvent(raw: Record<string, unknown>): StreamEvent | null;
49
+ export interface NormalizedProduct {
50
+ sku: string;
51
+ name: string;
52
+ imageUrl?: string;
53
+ images?: string[];
54
+ price?: string;
55
+ originalPrice?: string;
56
+ discountPercent?: number;
57
+ url: string;
58
+ brand?: string;
59
+ rating?: number;
60
+ reviewCount?: number;
61
+ cartCode?: string;
62
+ inStock?: boolean;
63
+ variants?: Array<Record<string, unknown>>;
64
+ discountReason?: string;
65
+ promotions?: string[];
66
+ description?: string;
67
+ descriptionHtml?: string;
68
+ features?: Array<{
69
+ name?: string;
70
+ key?: string;
71
+ value?: string | number | boolean;
72
+ [key: string]: unknown;
73
+ }>;
74
+ specifications?: Record<string, string> | Array<{
75
+ key: string;
76
+ value: string;
77
+ }>;
78
+ facetHits?: Record<string, unknown>;
79
+ categoryNames?: string[];
80
+ shortName?: string;
81
+ /** Pass-through bag for backend fields not consumed by the SDK. */
82
+ extras?: Record<string, unknown>;
83
+ }
84
+ export declare function productToNormalized(p: V1Product): NormalizedProduct;
85
+ export interface SimilarProductsJsonResponse {
86
+ results: V1Product[];
87
+ count: number;
88
+ source_sku?: string;
89
+ }
90
+ export interface ProductGroupingsJsonResponse {
91
+ intro_message?: string;
92
+ product_groupings: Array<{
93
+ name: string;
94
+ description?: string;
95
+ highlight?: string;
96
+ repr_sku?: string;
97
+ repr_image?: string;
98
+ group_skus?: string[];
99
+ group_products?: V1Product[];
100
+ }>;
101
+ count: number;
102
+ }
103
+ export declare function normalizeSimilarProductsResponse(json: SimilarProductsJsonResponse): NormalizedProduct[];
104
+ export declare function normalizeProductGroupingsResponse(json: ProductGroupingsJsonResponse): Array<{
105
+ name: string;
106
+ highlight?: string;
107
+ products: NormalizedProduct[];
108
+ }>;
@@ -0,0 +1,3 @@
1
+ import type { UISpecDomUnknownRenderer, RenderUISpecWithRegistryOptions } from './types.js';
2
+ export declare const defaultUnknownUISpecRenderer: UISpecDomUnknownRenderer<unknown>;
3
+ export declare function renderUISpecWithRegistry<TContext>(options: RenderUISpecWithRegistryOptions<TContext>): HTMLElement;
@@ -0,0 +1,4 @@
1
+ export { renderUISpecWithRegistry, defaultUnknownUISpecRenderer } from './dom.js';
2
+ export { mergeUISpecRegistry } from './registry.js';
3
+ export type { UISpecRenderHelpers, UISpecRendererOverrides } from './overrides.js';
4
+ export type { UISpecDomComponentRenderParams, UISpecDomComponentRenderer, UISpecDomRegistry, UISpecDomUnknownRendererParams, UISpecDomUnknownRenderer, RenderUISpecWithRegistryOptions, } from './types.js';
@@ -0,0 +1,23 @@
1
+ import type { UISpec } from '../types.js';
2
+ import type { UISpecDomRegistry, UISpecDomUnknownRenderer } from './types.js';
3
+ export interface UISpecRenderHelpers<TContext> {
4
+ registry: UISpecDomRegistry<TContext>;
5
+ unknownRenderer?: UISpecDomUnknownRenderer<TContext>;
6
+ defaultRender: (spec: UISpec, context: TContext) => HTMLElement;
7
+ }
8
+ export interface UISpecRendererOverrides<TContext> {
9
+ /**
10
+ * Component-level overrides. Merged on top of the widget's default registry.
11
+ */
12
+ registry?: Partial<UISpecDomRegistry<TContext>>;
13
+ /**
14
+ * Optional fallback for unknown component types.
15
+ * Defaults to the widget's built-in unknown renderer.
16
+ */
17
+ unknownRenderer?: UISpecDomUnknownRenderer<TContext>;
18
+ /**
19
+ * Full UISpec rendering override.
20
+ * Use this to replace the default rendering methodology entirely.
21
+ */
22
+ renderUISpec?: (spec: UISpec, context: TContext, helpers: UISpecRenderHelpers<TContext>) => HTMLElement;
23
+ }
@@ -0,0 +1,2 @@
1
+ import type { UISpecDomRegistry } from './types.js';
2
+ export declare function mergeUISpecRegistry<TContext>(base: UISpecDomRegistry<TContext>, overrides?: Partial<UISpecDomRegistry<TContext>>): UISpecDomRegistry<TContext>;
@@ -0,0 +1,19 @@
1
+ import type { UISpec, UIElement } from '../types.js';
2
+ export interface UISpecDomComponentRenderParams<TContext> {
3
+ elementId: string;
4
+ element: UIElement;
5
+ spec: UISpec;
6
+ context: TContext;
7
+ renderElement: (elementId: string) => HTMLElement | null;
8
+ }
9
+ export type UISpecDomComponentRenderer<TContext> = (params: UISpecDomComponentRenderParams<TContext>) => HTMLElement | null;
10
+ export type UISpecDomRegistry<TContext> = Record<string, UISpecDomComponentRenderer<TContext>>;
11
+ export type UISpecDomUnknownRendererParams<TContext> = UISpecDomComponentRenderParams<TContext>;
12
+ export type UISpecDomUnknownRenderer<TContext> = (params: UISpecDomUnknownRendererParams<TContext>) => HTMLElement | null;
13
+ export interface RenderUISpecWithRegistryOptions<TContext> {
14
+ spec: UISpec;
15
+ context: TContext;
16
+ registry: UISpecDomRegistry<TContext>;
17
+ containerClassName: string;
18
+ unknownRenderer?: UISpecDomUnknownRenderer<TContext>;
19
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * DOMParser-based HTML sanitizer.
3
+ *
4
+ * Backend sends HTML in assistant messages (e.g. KVKK notice).
5
+ * This module strips dangerous elements/attributes while preserving
6
+ * safe formatting tags.
7
+ *
8
+ * WARNING: Any new injection point that uses innerHTML must call this function first.
9
+ */
10
+ /** Check if an image URL uses a safe protocol or same-origin absolute path. */
11
+ export declare function isSafeImageUrl(url: string): boolean;
12
+ /**
13
+ * Check if a URL is safe for use in href/src attributes.
14
+ * Allows http:, https:, and relative paths (starting with `/`).
15
+ */
16
+ export declare function isSafeUrl(url: string): boolean;
17
+ /**
18
+ * Safely set an attribute on an element.
19
+ * For `href` and `src` attributes, validates the URL against safe protocols.
20
+ */
21
+ export declare function safeSetAttribute(el: HTMLElement, attr: string, value: string): void;
22
+ export declare function sanitizeHtml(raw: string): string;
@@ -0,0 +1,3 @@
1
+ export declare const GENGAGE_VERSION: string;
2
+ export declare const GENGAGE_BUILD_FLAVOR: string;
3
+ export declare function logSdkRuntimeInfoOnce(): void;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Wire protocol streaming utilities.
3
+ *
4
+ * The Gengage backend streams responses as Newline-Delimited JSON (NDJSON)
5
+ * over a single HTTP response. This module provides utilities to consume
6
+ * that stream and parse events in real time.
7
+ *
8
+ * Protocol shape:
9
+ * {"type":"metadata","sessionId":"...","model":"..."}
10
+ * {"type":"text_chunk","content":"Hello "}
11
+ * {"type":"text_chunk","content":"there!","final":true}
12
+ * {"type":"ui_spec","widget":"chat","spec":{...}}
13
+ * {"type":"action","action":{"kind":"navigate","url":"..."}}
14
+ * {"type":"done"}
15
+ */
16
+ import type { StreamEvent } from './types.js';
17
+ export type StreamEventHandler = (event: StreamEvent) => void;
18
+ export interface StreamOptions {
19
+ /** Called for each parsed StreamEvent. */
20
+ onEvent: StreamEventHandler;
21
+ /** Called once when the stream closes normally. */
22
+ onDone?: () => void;
23
+ /** Called if the stream errors or the response is non-2xx. */
24
+ onError?: (err: Error) => void;
25
+ /** AbortController signal to cancel mid-stream. */
26
+ signal?: AbortSignal;
27
+ /**
28
+ * Max milliseconds to wait between chunks before treating the stream as dead.
29
+ * Prevents the UI from hanging indefinitely when the backend stops sending
30
+ * data without closing the connection. Default: 60_000 (60 s).
31
+ */
32
+ idleTimeoutMs?: number;
33
+ }
34
+ /**
35
+ * Consume an NDJSON streaming response and call onEvent for each line.
36
+ *
37
+ * Usage:
38
+ * const controller = new AbortController();
39
+ * await consumeStream(response, {
40
+ * onEvent: (event) => { ... },
41
+ * signal: controller.signal,
42
+ * });
43
+ */
44
+ export declare function consumeStream(response: Response, options: StreamOptions): Promise<void>;
45
+ /**
46
+ * Convenience: POST to a streaming endpoint and consume the response.
47
+ *
48
+ * @returns an AbortController that cancels the stream when aborted.
49
+ */
50
+ export declare function streamPost(url: string, body: unknown, options: StreamOptions & {
51
+ headers?: Record<string, string>;
52
+ }): AbortController;