@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.
- package/README.md +6 -22
- package/dist/agentic/adaptor/create-adaptor.d.ts +19 -0
- package/dist/agentic/adaptor/fetch-bridge.d.ts +11 -0
- package/dist/agentic/adaptor/mount.d.ts +38 -0
- package/dist/agentic/context/chat-context.d.ts +15 -0
- package/dist/agentic/context/context-store.d.ts +20 -0
- package/dist/agentic/context/persistence.d.ts +12 -0
- package/dist/agentic/events/builders.d.ts +10 -0
- package/dist/agentic/events/error-taxonomy.d.ts +27 -0
- package/dist/agentic/events/product-normalize.d.ts +47 -0
- package/dist/agentic/events/ui-specs.d.ts +37 -0
- package/dist/agentic/flow/beauty-consulting-turn.d.ts +1 -0
- package/dist/agentic/flow/create-flow.d.ts +2 -0
- package/dist/agentic/flow/dispatch.d.ts +3 -0
- package/dist/agentic/index.d.ts +18 -0
- package/dist/agentic/index.js +624 -0
- package/dist/agentic/types.d.ts +212 -0
- package/dist/agentic/util/assistant-host.d.ts +11 -0
- package/dist/agentic/util/be-url.d.ts +4 -0
- package/dist/agentic/util/browser-memory.d.ts +13 -0
- package/dist/agentic/util/browser-tools.d.ts +31 -0
- package/dist/agentic/util/lazy-runtime-loader.d.ts +9 -0
- package/dist/agentic/util/request-text.d.ts +3 -0
- package/dist/agentic/util/time.d.ts +2 -0
- package/dist/agentic/worker/be-client.d.ts +15 -0
- package/dist/agentic/worker/entry.d.ts +2 -0
- package/dist/agentic/worker/flow-runner.d.ts +24 -0
- package/dist/agentic/worker/jwt-mint.d.ts +21 -0
- package/dist/agentic/worker/rpc.d.ts +24 -0
- package/dist/agentic/worker/tool-bridge.d.ts +2 -0
- package/dist/agentic/worker.d.ts +16 -0
- package/dist/agentic/worker.js +119 -0
- package/dist/agentic.iife.js +5 -0
- package/dist/{api-paths-CwzwbgQZ.js → api-paths-C4WzXzyY.js} +1 -1
- package/dist/beauty-consulting-turn-BmPXbkQg.js +1019 -0
- package/dist/chat/api.d.ts +17 -0
- package/dist/chat/assistant-mode.d.ts +20 -0
- package/dist/chat/attachment-utils.d.ts +9 -0
- package/dist/chat/catalog.d.ts +455 -0
- package/dist/chat/chat-presentation-state.d.ts +53 -0
- package/dist/chat/components/AIGroupingCards.d.ts +15 -0
- package/dist/chat/components/AISuggestedSearchCards.d.ts +13 -0
- package/dist/chat/components/AITopPicks.d.ts +9 -0
- package/dist/chat/components/BeautyPhotoStep.d.ts +31 -0
- package/dist/chat/components/CategoriesContainer.d.ts +11 -0
- package/dist/chat/components/ChatDrawer.d.ts +362 -0
- package/dist/chat/components/ChoicePrompter.d.ts +21 -0
- package/dist/chat/components/ComparisonTable.d.ts +66 -0
- package/dist/chat/components/ConsultingStylePicker.d.ts +40 -0
- package/dist/chat/components/FloatingComparisonButton.d.ts +7 -0
- package/dist/chat/components/FloatingLauncher.d.ts +79 -0
- package/dist/chat/components/GroundingReviewCard.d.ts +11 -0
- package/dist/chat/components/HandoffNotice.d.ts +9 -0
- package/dist/chat/components/KvkkBanner.d.ts +6 -0
- package/dist/chat/components/Launcher.d.ts +28 -0
- package/dist/chat/components/PanelRestoreCard.d.ts +4 -0
- package/dist/chat/components/PanelTopBar.d.ts +32 -0
- package/dist/chat/components/PhotoAnalysisCard.d.ts +27 -0
- package/dist/chat/components/ProductSummaryCard.d.ts +12 -0
- package/dist/chat/components/ProsAndCons.d.ts +8 -0
- package/dist/chat/components/ReviewHighlights.d.ts +16 -0
- package/dist/chat/components/actionClassifier.d.ts +12 -0
- package/dist/chat/components/product-price-layout.d.ts +17 -0
- package/dist/chat/components/productMentionLinker.d.ts +26 -0
- package/dist/chat/components/renderUISpec.d.ts +15 -0
- package/dist/chat/components/typewriter.d.ts +24 -0
- package/dist/chat/extendedModeManager.d.ts +32 -0
- package/dist/chat/features/beauty-consulting/consulting-grid.d.ts +38 -0
- package/dist/chat/features/beauty-consulting/drawer-extensions.d.ts +22 -0
- package/dist/chat/features/beauty-consulting/mode-controller.d.ts +59 -0
- package/dist/chat/features/beauty-consulting/registry.d.ts +9 -0
- package/dist/chat/features/beauty-consulting/stream-handler.d.ts +45 -0
- package/dist/chat/history-storage.d.ts +85 -0
- package/dist/chat/index.d.ts +6 -0
- package/dist/chat/kvkk.d.ts +20 -0
- package/dist/chat/locales/en.d.ts +2 -0
- package/dist/chat/locales/index.d.ts +5 -0
- package/dist/chat/locales/tr.d.ts +2 -0
- package/dist/chat/panel-manager.d.ts +142 -0
- package/dist/chat/runtime.d.ts +417 -0
- package/dist/chat/session-persistence.d.ts +73 -0
- package/dist/chat/stream-error-display.d.ts +6 -0
- package/dist/chat/types.d.ts +547 -0
- package/dist/chat/utils/chat-presentation-debug.d.ts +18 -0
- package/dist/chat/utils/get-chat-scroll-element.d.ts +10 -0
- package/dist/chat/utils/ui.d.ts +10 -0
- package/dist/chat-runtime.js +1 -1
- package/dist/chat.iife.js +12 -12
- package/dist/chat.js +1 -1
- package/dist/common/action-router.d.ts +26 -0
- package/dist/common/api-paths.d.ts +23 -0
- package/dist/common/client.d.ts +27 -0
- package/dist/common/communication-bridge.d.ts +51 -0
- package/dist/common/config-constants.d.ts +1 -0
- package/dist/common/config-schema.d.ts +54 -0
- package/dist/common/connection-warning.d.ts +8 -0
- package/dist/common/consulting-sources.d.ts +8 -0
- package/dist/common/context.d.ts +64 -0
- package/dist/common/css-escape.d.ts +1 -0
- package/dist/common/customization-factories.d.ts +59 -0
- package/dist/common/debug.d.ts +13 -0
- package/dist/common/events.d.ts +55 -0
- package/dist/common/fastIntent.d.ts +1 -0
- package/dist/common/find-similar-payload.d.ts +3 -0
- package/dist/common/ga-datalayer.d.ts +80 -0
- package/dist/common/global-error-toast.d.ts +6 -0
- package/dist/common/index.d.ts +47 -0
- package/dist/common/indexed-db.d.ts +89 -0
- package/dist/common/locale.d.ts +1 -0
- package/dist/common/native-webview.d.ts +60 -0
- package/dist/common/navigation.d.ts +1 -0
- package/dist/common/overlay.d.ts +172 -0
- package/dist/common/page-detect.d.ts +36 -0
- package/dist/common/pill-launcher.d.ts +51 -0
- package/dist/common/preflight.d.ts +13 -0
- package/dist/common/price-formatter.d.ts +35 -0
- package/dist/common/product-utils.d.ts +35 -0
- package/dist/common/protocol-adapter.d.ts +108 -0
- package/dist/common/renderer/dom.d.ts +3 -0
- package/dist/common/renderer/index.d.ts +4 -0
- package/dist/common/renderer/overrides.d.ts +23 -0
- package/dist/common/renderer/registry.d.ts +2 -0
- package/dist/common/renderer/types.d.ts +19 -0
- package/dist/common/safe-html.d.ts +22 -0
- package/dist/common/sdk-version.d.ts +3 -0
- package/dist/common/streaming.d.ts +52 -0
- package/dist/common/suggested-search-keywords.d.ts +18 -0
- package/dist/common/theme-utils.d.ts +15 -0
- package/dist/common/transport.d.ts +75 -0
- package/dist/common/tts-player.d.ts +13 -0
- package/dist/common/types.d.ts +379 -0
- package/dist/common/ui-theme.d.ts +9 -0
- package/dist/common/uuidv7.d.ts +7 -0
- package/dist/common/voice-input.d.ts +74 -0
- package/dist/common/widget-base.d.ts +82 -0
- package/dist/{common-KpJP1YwP.js → common-DstAcheX.js} +90 -139
- package/dist/common.js +41 -41
- package/dist/{connection-warning-B5T_1oBn.js → connection-warning-Ddr91Y9x.js} +1 -1
- package/dist/{fastIntent--Ukm2nOh.js → fastIntent-XtUvISni.js} +199 -137
- package/dist/index.d.ts +25 -0
- package/dist/index.js +50 -50
- package/dist/native/index.d.ts +2 -0
- package/dist/{native-webview-qfjm4SHx.js → native-webview-JDC1vtde.js} +1 -1
- package/dist/native.iife.js +14 -14
- package/dist/native.js +1 -1
- package/dist/{overlay-CP5A0Hhf.js → overlay-BetAvpVZ.js} +19 -19
- package/dist/overlay.d.ts +4 -0
- package/dist/overlay.js +1 -1
- package/dist/qna/api.d.ts +23 -0
- package/dist/qna/catalog.d.ts +60 -0
- package/dist/qna/components/ButtonRow.d.ts +15 -0
- package/dist/qna/components/TextInput.d.ts +11 -0
- package/dist/qna/components/renderUISpec.d.ts +7 -0
- package/dist/qna/index.d.ts +3 -0
- package/dist/qna/locales/en.d.ts +2 -0
- package/dist/qna/locales/index.d.ts +4 -0
- package/dist/qna/locales/tr.d.ts +2 -0
- package/dist/qna/normalize-ui-specs.d.ts +15 -0
- package/dist/qna/runtime.d.ts +73 -0
- package/dist/qna/types.d.ts +98 -0
- package/dist/qna-runtime.js +1 -1
- package/dist/qna.iife.js +1 -1
- package/dist/qna.js +1 -1
- package/dist/{runtime-G3idwfkM.js → runtime-C66Wp6OR.js} +967 -923
- package/dist/{runtime-C3yOvNFK.js → runtime-CcA_r8pw.js} +3 -3
- package/dist/{runtime-BPyXOyyp.js → runtime-DJMUL882.js} +3 -3
- package/dist/simbut/index.d.ts +31 -0
- package/dist/simbut/locales.d.ts +3 -0
- package/dist/simbut/types.d.ts +43 -0
- package/dist/{simbut-CiknJI6-.js → simbut-B6L3fwI7.js} +1 -1
- package/dist/simbut.iife.js +1 -1
- package/dist/simbut.js +1 -1
- package/dist/simrel/api.d.ts +25 -0
- package/dist/simrel/catalog.d.ts +77 -0
- package/dist/simrel/components/GroupTabs.d.ts +24 -0
- package/dist/simrel/components/ProductCard.d.ts +19 -0
- package/dist/simrel/components/ProductGrid.d.ts +17 -0
- package/dist/simrel/components/renderUISpec.d.ts +7 -0
- package/dist/simrel/index.d.ts +5 -0
- package/dist/simrel/locales/en.d.ts +2 -0
- package/dist/simrel/locales/index.d.ts +4 -0
- package/dist/simrel/locales/tr.d.ts +2 -0
- package/dist/simrel/renderers/default.d.ts +41 -0
- package/dist/simrel/runtime.d.ts +68 -0
- package/dist/simrel/types.d.ts +145 -0
- package/dist/{simrel-C1YN71aW.js → simrel-BB4Jrr32.js} +1 -1
- package/dist/simrel-runtime.js +1 -1
- package/dist/simrel.iife.js +1 -1
- package/dist/simrel.js +2 -2
- package/dist/{widget-base-UmvgIqDk.js → widget-base-B3Oq8pjs.js} +1 -1
- package/package.json +21 -39
package/dist/chat.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e, c as t, d as r, i as s, l as n, n as i, o as c, r as l, s as o, t as C, u as h } from "./runtime-
|
|
1
|
+
import { a as e, c as t, d as r, i as s, l as n, n as i, o as c, r as l, s as o, t as C, u as h } from "./runtime-C66Wp6OR.js";
|
|
2
2
|
import { t as p } from "./chat-CrEa2W-e.js";
|
|
3
3
|
export {
|
|
4
4
|
n as CHAT_SCROLL_ELEMENT_ID,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { UnknownActionPolicy } from './config-schema.js';
|
|
2
|
+
import type { ActionPayload, AddToCartParams, StreamEventAction } from './types.js';
|
|
3
|
+
export interface HostActionHandlers {
|
|
4
|
+
openChat?: (payload?: ActionPayload | unknown) => void;
|
|
5
|
+
navigate?: (params: {
|
|
6
|
+
url: string;
|
|
7
|
+
newTab?: boolean;
|
|
8
|
+
}) => void;
|
|
9
|
+
saveSession?: (params: {
|
|
10
|
+
sessionId: string;
|
|
11
|
+
sku: string;
|
|
12
|
+
}) => void;
|
|
13
|
+
addToCart?: (params: AddToCartParams) => void;
|
|
14
|
+
scriptCall?: (params: {
|
|
15
|
+
name: string;
|
|
16
|
+
payload?: Record<string, unknown>;
|
|
17
|
+
}) => void;
|
|
18
|
+
unknown?: (action: StreamEventAction['action']) => void;
|
|
19
|
+
}
|
|
20
|
+
export interface ActionRouterOptions {
|
|
21
|
+
allowScriptCall?: boolean;
|
|
22
|
+
unknownActionPolicy?: UnknownActionPolicy;
|
|
23
|
+
logger?: Pick<Console, 'warn' | 'error' | 'debug'>;
|
|
24
|
+
defaultNavigate?: (url: string, newTab?: boolean) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function routeStreamAction(event: StreamEventAction, handlers: HostActionHandlers, options?: ActionRouterOptions): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Endpoint path helpers.
|
|
3
|
+
*
|
|
4
|
+
* All endpoints use `/chat/*` prefix. API versioning is handled via
|
|
5
|
+
* request-level compatibility params or feature-toggle params.
|
|
6
|
+
*/
|
|
7
|
+
import type { InjectorAdapter } from './transport.js';
|
|
8
|
+
export type ChatEndpointName = 'process_action' | 'launcher_action' | 'similar_products' | 'product_groupings';
|
|
9
|
+
export interface ChatTransportConfig {
|
|
10
|
+
middlewareUrl: string;
|
|
11
|
+
attachment?: File;
|
|
12
|
+
/** Account ID (used in URL path when needed). */
|
|
13
|
+
accountId?: string;
|
|
14
|
+
/**
|
|
15
|
+
* AGENTIC_ADAPTER_SEAM.
|
|
16
|
+
*
|
|
17
|
+
* Optional in-browser adaptor mounted by gengage-assistant-injector.
|
|
18
|
+
* When present, chat delegates turns to this function instead of `middlewareUrl`.
|
|
19
|
+
*/
|
|
20
|
+
injectorAdapter?: InjectorAdapter;
|
|
21
|
+
}
|
|
22
|
+
export declare function normalizeMiddlewareUrl(input?: string): string;
|
|
23
|
+
export declare function buildChatEndpointUrl(endpoint: ChatEndpointName, config: ChatTransportConfig): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AccountRuntimeConfig } from './config-schema.js';
|
|
2
|
+
import type { OverlayWidgetsController, OverlayWidgetsOptions } from './overlay.js';
|
|
3
|
+
import type { AddToCartHandlerResult, AddToCartParams, PageContext } from './types.js';
|
|
4
|
+
export interface HostActions {
|
|
5
|
+
onAddToCart?: (params: AddToCartParams) => AddToCartHandlerResult;
|
|
6
|
+
onProductNavigate?: (url: string, sku: string, sessionId: string | null) => void;
|
|
7
|
+
onFindSimilar?: (detail: {
|
|
8
|
+
sku: string;
|
|
9
|
+
imageUrl?: string;
|
|
10
|
+
}) => void;
|
|
11
|
+
onScriptCall?: (params: {
|
|
12
|
+
name: string;
|
|
13
|
+
payload?: Record<string, unknown>;
|
|
14
|
+
}) => void;
|
|
15
|
+
}
|
|
16
|
+
export interface GengageClientOptions {
|
|
17
|
+
runtimeConfig: AccountRuntimeConfig | unknown;
|
|
18
|
+
contextResolver?: () => Partial<PageContext>;
|
|
19
|
+
hostActions?: HostActions;
|
|
20
|
+
preflight?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Maps validated account runtime config to overlay widget options.
|
|
24
|
+
* Exported for unit tests.
|
|
25
|
+
*/
|
|
26
|
+
export declare function mapAccountRuntimeConfigToOverlayOptions(config: AccountRuntimeConfig, hostActions?: HostActions, initialContext?: Partial<PageContext>): OverlayWidgetsOptions;
|
|
27
|
+
export declare function initGengageClient(options: GengageClientOptions): Promise<OverlayWidgetsController>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two-way communication bridge between the host page and embedded widgets.
|
|
3
|
+
*
|
|
4
|
+
* Host -> Widget: The host sends `window.postMessage({ gengage, type, payload })`.
|
|
5
|
+
* The bridge validates the origin, checks the namespace, and routes to handlers.
|
|
6
|
+
*
|
|
7
|
+
* Widget -> Host: The bridge dispatches a `CustomEvent('gengage:bridge:message')`
|
|
8
|
+
* on window so the host can listen without tight coupling.
|
|
9
|
+
*
|
|
10
|
+
* Built-in message types:
|
|
11
|
+
* - 'addToCart' -- host confirms cart addition
|
|
12
|
+
* - 'productFavorite' -- widget → host: product card heart toggled (payload: sku, product, favorited, sessionId)
|
|
13
|
+
* - 'navigate' -- host navigates to URL
|
|
14
|
+
* - 'openChat' -- programmatic open
|
|
15
|
+
* - 'closeChat' -- programmatic close
|
|
16
|
+
* - 'getContext' -- host requests current context
|
|
17
|
+
*/
|
|
18
|
+
export interface BridgeMessage {
|
|
19
|
+
type: string;
|
|
20
|
+
payload?: unknown;
|
|
21
|
+
}
|
|
22
|
+
export interface CommunicationBridgeOptions {
|
|
23
|
+
/** Widget namespace for message identification (e.g. 'chat', 'qna'). */
|
|
24
|
+
namespace: string;
|
|
25
|
+
/** Allowed origins for postMessage security (default: ['*']). */
|
|
26
|
+
allowedOrigins?: string[];
|
|
27
|
+
/** Callback when a message is received from the host. */
|
|
28
|
+
onMessage?: (msg: BridgeMessage) => void;
|
|
29
|
+
}
|
|
30
|
+
type BridgeHandler = (payload: unknown) => void;
|
|
31
|
+
export declare class CommunicationBridge {
|
|
32
|
+
private readonly _namespace;
|
|
33
|
+
private readonly _allowedOrigins;
|
|
34
|
+
private readonly _onMessage;
|
|
35
|
+
private readonly _handlers;
|
|
36
|
+
private readonly _messageListener;
|
|
37
|
+
private _destroyed;
|
|
38
|
+
constructor(options: CommunicationBridgeOptions);
|
|
39
|
+
/** Send a message to the host page via CustomEvent on window. */
|
|
40
|
+
send(type: string, payload?: unknown): void;
|
|
41
|
+
/**
|
|
42
|
+
* Register a handler for a specific message type.
|
|
43
|
+
* Returns an unsubscribe function.
|
|
44
|
+
*/
|
|
45
|
+
on(type: string, handler: BridgeHandler): () => void;
|
|
46
|
+
/** Clean up all event listeners and handlers. */
|
|
47
|
+
destroy(): void;
|
|
48
|
+
private _handlePostMessage;
|
|
49
|
+
private _isOriginAllowed;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_IDEMPOTENCY_KEY = "__gengageWidgetsInit";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const UnknownActionPolicySchema: z.ZodEnum<{
|
|
3
|
+
"log-and-ignore": "log-and-ignore";
|
|
4
|
+
throw: "throw";
|
|
5
|
+
delegate: "delegate";
|
|
6
|
+
}>;
|
|
7
|
+
export declare const AccountRuntimeConfigSchema: z.ZodObject<{
|
|
8
|
+
version: z.ZodLiteral<"1">;
|
|
9
|
+
accountId: z.ZodString;
|
|
10
|
+
middlewareUrl: z.ZodString;
|
|
11
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
12
|
+
widgets: z.ZodObject<{
|
|
13
|
+
chat: z.ZodDefault<z.ZodObject<{
|
|
14
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
}, z.core.$strip>>;
|
|
16
|
+
qna: z.ZodDefault<z.ZodObject<{
|
|
17
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
18
|
+
}, z.core.$strip>>;
|
|
19
|
+
simrel: z.ZodOptional<z.ZodObject<{
|
|
20
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
simbut: z.ZodDefault<z.ZodObject<{
|
|
23
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
24
|
+
}, z.core.$strip>>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
mounts: z.ZodDefault<z.ZodObject<{
|
|
27
|
+
chat: z.ZodOptional<z.ZodString>;
|
|
28
|
+
qna: z.ZodOptional<z.ZodString>;
|
|
29
|
+
simrel: z.ZodOptional<z.ZodString>;
|
|
30
|
+
simbut: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>>;
|
|
32
|
+
transport: z.ZodDefault<z.ZodObject<{}, z.core.$strip>>;
|
|
33
|
+
gtm: z.ZodDefault<z.ZodObject<{
|
|
34
|
+
idempotencyKey: z.ZodDefault<z.ZodString>;
|
|
35
|
+
requireDomReady: z.ZodDefault<z.ZodBoolean>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
actionHandling: z.ZodDefault<z.ZodObject<{
|
|
38
|
+
unknownActionPolicy: z.ZodDefault<z.ZodEnum<{
|
|
39
|
+
"log-and-ignore": "log-and-ignore";
|
|
40
|
+
throw: "throw";
|
|
41
|
+
delegate: "delegate";
|
|
42
|
+
}>>;
|
|
43
|
+
allowScriptCall: z.ZodDefault<z.ZodBoolean>;
|
|
44
|
+
}, z.core.$strip>>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
export type AccountRuntimeConfig = z.infer<typeof AccountRuntimeConfigSchema>;
|
|
47
|
+
export type UnknownActionPolicy = z.infer<typeof UnknownActionPolicySchema>;
|
|
48
|
+
export declare function parseAccountRuntimeConfig(input: unknown): AccountRuntimeConfig;
|
|
49
|
+
export declare function safeParseAccountRuntimeConfig(input: unknown): ReturnType<typeof AccountRuntimeConfigSchema.safeParse>;
|
|
50
|
+
export declare function createDefaultAccountRuntimeConfig(params: {
|
|
51
|
+
accountId: string;
|
|
52
|
+
middlewareUrl: string;
|
|
53
|
+
locale?: string;
|
|
54
|
+
}): AccountRuntimeConfig;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function configureConnectionWarning(options: {
|
|
2
|
+
probeUrl?: string;
|
|
3
|
+
}): void;
|
|
4
|
+
export interface ConnectionWarningRequestOptions {
|
|
5
|
+
source: 'chat' | 'qna' | 'simrel';
|
|
6
|
+
locale?: string | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare function trackConnectionWarningRequest(options: ConnectionWarningRequestOptions): () => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire-protocol source strings that indicate consulting-style product grids.
|
|
3
|
+
*
|
|
4
|
+
* Kept in `common/` because both the protocol adapter and chat-specific
|
|
5
|
+
* renderers need to agree on which sources activate style-variation grids.
|
|
6
|
+
*/
|
|
7
|
+
/** Whether a wire-protocol source string is a consulting source. */
|
|
8
|
+
export declare function isConsultingSource(source: string | undefined): boolean;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page context management.
|
|
3
|
+
*
|
|
4
|
+
* Best practice for passing page context to widgets:
|
|
5
|
+
*
|
|
6
|
+
* ## SSR / Static pages
|
|
7
|
+
* Set window.gengage.pageContext before widget scripts load:
|
|
8
|
+
*
|
|
9
|
+
* <script>
|
|
10
|
+
* window.gengage = {
|
|
11
|
+
* pageContext: {
|
|
12
|
+
* pageType: 'pdp',
|
|
13
|
+
* sku: '{{ product.sku }}',
|
|
14
|
+
* price: '{{ product.price }}',
|
|
15
|
+
* categoryTree: {{ product.categories | json }},
|
|
16
|
+
* }
|
|
17
|
+
* };
|
|
18
|
+
* </script>
|
|
19
|
+
* <script src="https://cdn.gengage.ai/widgets/latest/chat.iife.js"></script>
|
|
20
|
+
*
|
|
21
|
+
* ## CSR / SPA (React, Vue, Next.js, etc.)
|
|
22
|
+
* Call widget.update() after each navigation:
|
|
23
|
+
*
|
|
24
|
+
* router.afterEach((to) => {
|
|
25
|
+
* chatWidget.update({
|
|
26
|
+
* pageType: to.meta.pageType,
|
|
27
|
+
* sku: to.params.sku,
|
|
28
|
+
* });
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* ## Event-based (loosest coupling)
|
|
32
|
+
* Dispatch 'gengage:context:update' from anywhere:
|
|
33
|
+
*
|
|
34
|
+
* window.dispatchEvent(new CustomEvent('gengage:context:update', {
|
|
35
|
+
* detail: { pageType: 'pdp', sku: '12345' }
|
|
36
|
+
* }));
|
|
37
|
+
*/
|
|
38
|
+
import type { PageContext, SessionContext } from './types.js';
|
|
39
|
+
/**
|
|
40
|
+
* Returns the shared session ID for this browser tab session.
|
|
41
|
+
* Creates and persists it on first call.
|
|
42
|
+
*
|
|
43
|
+
* Call this once at page load and share the result with all widget configs:
|
|
44
|
+
*
|
|
45
|
+
* const sessionId = bootstrapSession();
|
|
46
|
+
* chatWidget.init({ ..., session: { sessionId } });
|
|
47
|
+
* qnaWidget.init({ ..., session: { sessionId } });
|
|
48
|
+
*/
|
|
49
|
+
export declare function bootstrapSession(): string;
|
|
50
|
+
/**
|
|
51
|
+
* Reads the current page context from window.gengage.pageContext.
|
|
52
|
+
* Returns null if not set.
|
|
53
|
+
*/
|
|
54
|
+
export declare function getWindowPageContext(): PageContext | null;
|
|
55
|
+
/**
|
|
56
|
+
* Merges a partial context update into the current window.gengage.pageContext.
|
|
57
|
+
* Dispatches 'gengage:context:update' so all listening widgets update.
|
|
58
|
+
*/
|
|
59
|
+
export declare function updatePageContext(patch: Partial<PageContext>): void;
|
|
60
|
+
/**
|
|
61
|
+
* Resolves the session context, bootstrapping if necessary.
|
|
62
|
+
* Merges provided overrides with auto-generated session ID.
|
|
63
|
+
*/
|
|
64
|
+
export declare function resolveSession(overrides?: Partial<SessionContext>): SessionContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function escapeCssIdentifier(value: string): string;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ChatWidgetConfig } from '../chat/types.js';
|
|
2
|
+
import type { InjectorAdapter } from './transport.js';
|
|
3
|
+
import type { QNAWidgetConfig } from '../qna/types.js';
|
|
4
|
+
import type { SimRelWidgetConfig } from '../simrel/types.js';
|
|
5
|
+
import type { WidgetTheme } from './types.js';
|
|
6
|
+
export declare const DEFAULT_CUSTOMIZATION_LOCALE = "tr";
|
|
7
|
+
export interface AccountIdentityConfig {
|
|
8
|
+
accountId: string;
|
|
9
|
+
middlewareUrl: string;
|
|
10
|
+
locale?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AccountIdentity {
|
|
13
|
+
ACCOUNT_ID: string;
|
|
14
|
+
MIDDLEWARE_URL: string;
|
|
15
|
+
LOCALE: string;
|
|
16
|
+
}
|
|
17
|
+
interface BaseAccountWidgetConfigInput {
|
|
18
|
+
accountId: string;
|
|
19
|
+
middlewareUrl: string;
|
|
20
|
+
sessionId: string;
|
|
21
|
+
theme?: WidgetTheme;
|
|
22
|
+
injectorAdapter?: InjectorAdapter;
|
|
23
|
+
}
|
|
24
|
+
export interface FloatingChatConfigInput extends BaseAccountWidgetConfigInput {
|
|
25
|
+
locale?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface PdpQnaConfigInput extends BaseAccountWidgetConfigInput {
|
|
28
|
+
sku: string;
|
|
29
|
+
mountTarget: QNAWidgetConfig['mountTarget'];
|
|
30
|
+
}
|
|
31
|
+
export interface PdpSimRelConfigInput extends BaseAccountWidgetConfigInput {
|
|
32
|
+
sku: string;
|
|
33
|
+
mountTarget: SimRelWidgetConfig['mountTarget'];
|
|
34
|
+
}
|
|
35
|
+
type FloatingChatConfigOverrides = Omit<Partial<ChatWidgetConfig>, 'accountId' | 'middlewareUrl' | 'session' | 'variant' | 'theme' | 'locale'>;
|
|
36
|
+
type PdpQnaConfigOverrides = Omit<Partial<QNAWidgetConfig>, 'accountId' | 'middlewareUrl' | 'session' | 'pageContext' | 'mountTarget' | 'theme'>;
|
|
37
|
+
type SimRelAccountConfig = Omit<SimRelWidgetConfig, 'onAddToCart' | 'onProductNavigate'>;
|
|
38
|
+
type PdpSimRelConfigOverrides = Omit<Partial<SimRelAccountConfig>, 'accountId' | 'middlewareUrl' | 'session' | 'sku' | 'mountTarget' | 'theme'>;
|
|
39
|
+
export declare function discoverInjectorAdapter(accountId?: string): InjectorAdapter | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Shared account identity factory used by all customization folders.
|
|
42
|
+
* Keeps middleware URL + locale defaults centralized in the SDK layer.
|
|
43
|
+
*/
|
|
44
|
+
export declare function createAccountIdentity(config: AccountIdentityConfig): AccountIdentity;
|
|
45
|
+
/**
|
|
46
|
+
* Shared floating-chat baseline used by account customizations.
|
|
47
|
+
* Account files only pass differences via `overrides`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createFloatingChatConfig(input: FloatingChatConfigInput, overrides?: FloatingChatConfigOverrides): ChatWidgetConfig;
|
|
50
|
+
/**
|
|
51
|
+
* Shared PDP QNA baseline used by account customizations.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createPdpQnaConfig(input: PdpQnaConfigInput, overrides?: PdpQnaConfigOverrides): QNAWidgetConfig;
|
|
54
|
+
/**
|
|
55
|
+
* Shared PDP SimRel baseline used by account customizations.
|
|
56
|
+
* Host-level commerce callbacks stay in account init wrappers.
|
|
57
|
+
*/
|
|
58
|
+
export declare function createPdpSimRelConfig(input: PdpSimRelConfigInput, overrides?: PdpSimRelConfigOverrides): SimRelAccountConfig;
|
|
59
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug logging for integrators.
|
|
3
|
+
*
|
|
4
|
+
* Enable with: `localStorage.setItem('gengage:debug', '1')`
|
|
5
|
+
* Disable with: `localStorage.removeItem('gengage:debug')`
|
|
6
|
+
*
|
|
7
|
+
* When disabled, all debug calls are no-ops with zero overhead
|
|
8
|
+
* (the check is a single localStorage read cached per page load).
|
|
9
|
+
*/
|
|
10
|
+
/** Log a debug message (only when gengage:debug is enabled). */
|
|
11
|
+
export declare function debugLog(category: string, message: string, data?: unknown): void;
|
|
12
|
+
/** Reset the cached enabled state (for testing). */
|
|
13
|
+
export declare function _resetDebugCache(): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-widget event bus utilities.
|
|
3
|
+
*
|
|
4
|
+
* All Gengage widgets communicate through window CustomEvents following
|
|
5
|
+
* the naming convention: gengage:<widget>:<action>
|
|
6
|
+
*
|
|
7
|
+
* This creates a loosely-coupled event bus — widgets don't import each other,
|
|
8
|
+
* host pages can intercept any event, and third-party analytics can hook in.
|
|
9
|
+
*/
|
|
10
|
+
import type { GengageEventDetailMap, GengageEventName } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Dispatch a typed Gengage event on window.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* dispatch('gengage:qna:action', { title: 'About shipping', type: 'query', payload: 'shipping' });
|
|
16
|
+
*/
|
|
17
|
+
export declare function dispatch<K extends GengageEventName>(name: K, detail: GengageEventDetailMap[K]): void;
|
|
18
|
+
/**
|
|
19
|
+
* Listen for a typed Gengage event on window.
|
|
20
|
+
* Returns an unsubscribe function.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const off = listen('gengage:qna:action', (detail) => {
|
|
24
|
+
* window.gengage?.chat?.openWithAction(detail);
|
|
25
|
+
* });
|
|
26
|
+
* // Later:
|
|
27
|
+
* off();
|
|
28
|
+
*/
|
|
29
|
+
export declare function listen<K extends GengageEventName>(name: K, handler: (detail: GengageEventDetailMap[K]) => void): () => void;
|
|
30
|
+
export interface WireQNAToChatOptions {
|
|
31
|
+
onChatUnavailable?: () => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Convenience: wire QNA → Chat automatically.
|
|
35
|
+
* Call this once after both widgets are initialised.
|
|
36
|
+
*
|
|
37
|
+
* Listens for 'gengage:qna:action' and forwards to window.gengage.chat.openWithAction().
|
|
38
|
+
* Listens for 'gengage:qna:open-chat' and forwards to window.gengage.chat.open().
|
|
39
|
+
*
|
|
40
|
+
* If chat is not available at dispatch time, emits a one-time console.warn and
|
|
41
|
+
* calls options.onChatUnavailable (every time) if provided.
|
|
42
|
+
*
|
|
43
|
+
* @returns unsubscribe function that removes both listeners.
|
|
44
|
+
*/
|
|
45
|
+
export declare function wireQNAToChat(options?: WireQNAToChatOptions): () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Convenience: wire Similar Products → Chat for cross-page session continuity.
|
|
48
|
+
* Call this once after both widgets are initialised.
|
|
49
|
+
*
|
|
50
|
+
* When the user navigates to a product page, the chat widget can restore
|
|
51
|
+
* the conversation where it left off using saveSession().
|
|
52
|
+
*
|
|
53
|
+
* @returns unsubscribe function.
|
|
54
|
+
*/
|
|
55
|
+
export declare function wireSimilarToChat(): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function detectFastIntent(text: string): string | null;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function firstNonEmptyStringValue(...values: unknown[]): string | undefined;
|
|
2
|
+
export declare function nonEmptyStringList(value: unknown): string[];
|
|
3
|
+
export declare function normalizeFindSimilarPayload(payload: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Google Analytics dataLayer integration.
|
|
3
|
+
*
|
|
4
|
+
* Pushes chat activity events to `window.dataLayer` when GA is available.
|
|
5
|
+
* Silently skips pushes when GA is not detected.
|
|
6
|
+
*
|
|
7
|
+
* Event naming follows the GA4 recommended event pattern:
|
|
8
|
+
* - All lowercase, hyphen-separated
|
|
9
|
+
* - Prefixed with `gengage-` for easy filtering in GA dashboards
|
|
10
|
+
*
|
|
11
|
+
* Clients can build custom chat funnels in GA using these events.
|
|
12
|
+
*/
|
|
13
|
+
interface DataLayerEvent {
|
|
14
|
+
event: string;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
declare global {
|
|
18
|
+
interface Window {
|
|
19
|
+
dataLayer?: DataLayerEvent[];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** Widget icon/avatar displayed on page. */
|
|
23
|
+
export declare function trackInit(widget: string): void;
|
|
24
|
+
/** Widget opened / shown to user. */
|
|
25
|
+
export declare function trackShow(widget: string): void;
|
|
26
|
+
/** Widget closed / hidden. */
|
|
27
|
+
export declare function trackHide(widget: string): void;
|
|
28
|
+
/** User clicked a suggested question / action button. */
|
|
29
|
+
export declare function trackSuggestedQuestion(title: string, type: string): void;
|
|
30
|
+
/** User clicked "Find Similar" for a product. */
|
|
31
|
+
export declare function trackFindSimilars(sku: string): void;
|
|
32
|
+
/** User pre-selected a product for comparison. */
|
|
33
|
+
export declare function trackComparePreselection(sku: string): void;
|
|
34
|
+
/** User submitted the comparison (clicked "Compare Selected"). */
|
|
35
|
+
export declare function trackCompareSelected(skus: string[]): void;
|
|
36
|
+
/** User cleared the comparison selection. */
|
|
37
|
+
export declare function trackCompareClear(): void;
|
|
38
|
+
/** Comparison results received and rendered. */
|
|
39
|
+
export declare function trackCompareReceived(productCount: number): void;
|
|
40
|
+
/** User liked / favorited a product. */
|
|
41
|
+
export declare function trackLikeProduct(sku: string): void;
|
|
42
|
+
/** User clicked the favorites/likes list button. */
|
|
43
|
+
export declare function trackLikeList(): void;
|
|
44
|
+
/** Product list / search results displayed. */
|
|
45
|
+
export declare function trackSearch(query?: string, resultCount?: number): void;
|
|
46
|
+
/** User clicked on a product to view details. */
|
|
47
|
+
export declare function trackProductDetail(sku: string, name?: string): void;
|
|
48
|
+
/** SimRel (or chat-routed similar) product card click — distinct from generic PDP detail views. */
|
|
49
|
+
export declare function trackSimilarProductClick(sku: string, extras?: {
|
|
50
|
+
url?: string;
|
|
51
|
+
name?: string;
|
|
52
|
+
session_id?: string | null;
|
|
53
|
+
}): void;
|
|
54
|
+
/** User clicked the floating comparison dock primary action (popup bar). */
|
|
55
|
+
export declare function trackCompareProduct(skus: string[]): void;
|
|
56
|
+
/** Chat MainPane (assistant left panel) expanded into split view. */
|
|
57
|
+
export declare function trackChatbotMaximized(): void;
|
|
58
|
+
/**
|
|
59
|
+
* SDK / bridge could not become ready after bounded retries (e.g. chat not initialized).
|
|
60
|
+
* Also used when overlay bootstrap fails fatally.
|
|
61
|
+
*/
|
|
62
|
+
export declare function trackInterfaceNotReady(params?: {
|
|
63
|
+
reason?: string;
|
|
64
|
+
attempts?: number;
|
|
65
|
+
message?: string;
|
|
66
|
+
}): void;
|
|
67
|
+
/** User added a product to cart from the widget. */
|
|
68
|
+
export declare function trackCartAdd(sku: string, quantity: number): void;
|
|
69
|
+
/** User sent a chat message. */
|
|
70
|
+
export declare function trackMessageSent(): void;
|
|
71
|
+
/** Assistant responded with text. */
|
|
72
|
+
export declare function trackMessageReceived(): void;
|
|
73
|
+
/** User started a new conversation. */
|
|
74
|
+
export declare function trackConversationStart(): void;
|
|
75
|
+
/** User used voice input. */
|
|
76
|
+
export declare function trackVoiceInput(): void;
|
|
77
|
+
/** Widget or stream error occurred. */
|
|
78
|
+
export declare function trackError(widget: string, error: string): void;
|
|
79
|
+
export declare function wireGADataLayer(): () => void;
|
|
80
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GengageEventDetailMap } from './types.js';
|
|
2
|
+
export declare function isLikelyConnectivityIssue(error?: unknown): boolean;
|
|
3
|
+
export declare function getGlobalErrorMessage(locale?: string, error?: unknown): string;
|
|
4
|
+
export declare function registerGlobalErrorToastListener(): void;
|
|
5
|
+
export declare function showGlobalErrorToast(detail: GengageEventDetailMap['gengage:global:error']): void;
|
|
6
|
+
export declare function dismissGlobalErrorToast(): void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export type { PageContext, SessionContext, BaseWidgetConfig, WidgetTheme, GengageWidget, StreamEvent, StreamEventMetadata, StreamEventTextChunk, StreamEventUISpec, StreamEventAction, StreamEventError, StreamEventDone, UISpec, UIElement, ActionPayload, GengageEventName, GengageEventDetailMap, } from './types.js';
|
|
2
|
+
export { BaseWidget } from './widget-base.js';
|
|
3
|
+
export type { ChatPublicAPI } from './widget-base.js';
|
|
4
|
+
export { GENGAGE_VERSION, GENGAGE_BUILD_FLAVOR } from './sdk-version.js';
|
|
5
|
+
export { consumeStream, streamPost } from './streaming.js';
|
|
6
|
+
export type { StreamOptions, StreamEventHandler } from './streaming.js';
|
|
7
|
+
export { dispatch, listen, wireQNAToChat, wireSimilarToChat } from './events.js';
|
|
8
|
+
export type { WireQNAToChatOptions } from './events.js';
|
|
9
|
+
export { bootstrapSession, getWindowPageContext, updatePageContext, resolveSession } from './context.js';
|
|
10
|
+
export { initOverlayWidgets, getOverlayWidgets, destroyOverlayWidgets, buildOverlayIdempotencyKey } from './overlay.js';
|
|
11
|
+
export type { OverlayWidgetsController, OverlayWidgetsOptions, OverlayChatOptions, OverlayQNAOptions, OverlaySimRelOptions, OverlaySimButOptions, } from './overlay.js';
|
|
12
|
+
export { detectNativeEnvironment, applyNativeSession, createNativeWebViewBridge, initNativeOverlayWidgets, } from './native-webview.js';
|
|
13
|
+
export type { NativeBridgeEnvironment, NativeSessionPayload, NativeBridgeMessage, NativeWebViewBridgeOptions, NativeWebViewBridge, NativeOverlayInitOptions, NativeOverlayInitResult, } from './native-webview.js';
|
|
14
|
+
export { buildChatEndpointUrl, normalizeMiddlewareUrl } from './api-paths.js';
|
|
15
|
+
export type { ChatTransportConfig, ChatEndpointName } from './api-paths.js';
|
|
16
|
+
export type { ActionEnrichmentContext, BackendRequestMeta, InjectorAdapter, ProcessActionRequest, StreamCallbacks, } from './transport.js';
|
|
17
|
+
export { AccountRuntimeConfigSchema, UnknownActionPolicySchema, parseAccountRuntimeConfig, safeParseAccountRuntimeConfig, createDefaultAccountRuntimeConfig, } from './config-schema.js';
|
|
18
|
+
export type { AccountRuntimeConfig, UnknownActionPolicy } from './config-schema.js';
|
|
19
|
+
export { routeStreamAction } from './action-router.js';
|
|
20
|
+
export type { HostActionHandlers, ActionRouterOptions } from './action-router.js';
|
|
21
|
+
export { sanitizeHtml } from './safe-html.js';
|
|
22
|
+
export { renderUISpecWithRegistry, defaultUnknownUISpecRenderer } from './renderer/index.js';
|
|
23
|
+
export { mergeUISpecRegistry } from './renderer/index.js';
|
|
24
|
+
export type { UISpecRenderHelpers, UISpecRendererOverrides, UISpecDomComponentRenderParams, UISpecDomComponentRenderer, UISpecDomRegistry, UISpecDomUnknownRendererParams, UISpecDomUnknownRenderer, RenderUISpecWithRegistryOptions, } from './renderer/index.js';
|
|
25
|
+
export { BASE_WIDGET_THEME, withBaseTheme } from './theme-utils.js';
|
|
26
|
+
export { DEFAULT_WIDGET_THEME_TOKENS, withDefaultWidgetTheme } from './ui-theme.js';
|
|
27
|
+
export { registerGlobalErrorToastListener, showGlobalErrorToast, dismissGlobalErrorToast, getGlobalErrorMessage, } from './global-error-toast.js';
|
|
28
|
+
export { trackConnectionWarningRequest, configureConnectionWarning } from './connection-warning.js';
|
|
29
|
+
export type { ConnectionWarningRequestOptions } from './connection-warning.js';
|
|
30
|
+
export { DEFAULT_CUSTOMIZATION_LOCALE, createAccountIdentity, createFloatingChatConfig, createPdpQnaConfig, createPdpSimRelConfig, } from './customization-factories.js';
|
|
31
|
+
export type { AccountIdentityConfig, AccountIdentity } from './customization-factories.js';
|
|
32
|
+
export { initGengageClient } from './client.js';
|
|
33
|
+
export type { GengageClientOptions, HostActions } from './client.js';
|
|
34
|
+
export { preflightDiagnostics } from './preflight.js';
|
|
35
|
+
export type { PreflightResult, PreflightWarning } from './preflight.js';
|
|
36
|
+
export { adaptBackendEvent, productToNormalized, normalizeSimilarProductsResponse, normalizeProductGroupingsResponse, } from './protocol-adapter.js';
|
|
37
|
+
export { wireGADataLayer } from './ga-datalayer.js';
|
|
38
|
+
export { isVoiceInputSupported, VoiceInput } from './voice-input.js';
|
|
39
|
+
export type { VoiceInputState, VoiceInputErrorCode, VoiceInputCallbacks, VoiceInputOptions } from './voice-input.js';
|
|
40
|
+
export { detectPageType, extractSkuFromUrl, autoDetectPageContext } from './page-detect.js';
|
|
41
|
+
export type { DetectablePageType, PageDetectionRule } from './page-detect.js';
|
|
42
|
+
export type { NormalizedProduct, SimilarProductsJsonResponse, ProductGroupingsJsonResponse, } from './protocol-adapter.js';
|
|
43
|
+
export { getSuggestedSearchKeywords, getSuggestedSearchKeywordsText } from './suggested-search-keywords.js';
|
|
44
|
+
export type { SuggestedSearchKeywordSource } from './suggested-search-keywords.js';
|
|
45
|
+
export { detectFastIntent } from './fastIntent.js';
|
|
46
|
+
export { makePillLauncher } from './pill-launcher.js';
|
|
47
|
+
export type { PillLauncherOptions, PillLauncherKit } from './pill-launcher.js';
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IndexedDB persistence for chat sessions, backend context, and message payloads.
|
|
3
|
+
*
|
|
4
|
+
* Three stores:
|
|
5
|
+
* - `sessions` — full session state (messages, thread cursors, timestamps)
|
|
6
|
+
* - `context` — per-thread backend context snapshots (compound key)
|
|
7
|
+
* - `payload` — message UISpec payloads (lean message pattern)
|
|
8
|
+
*
|
|
9
|
+
* All operations are best-effort: IndexedDB unavailability is non-fatal.
|
|
10
|
+
*/
|
|
11
|
+
import type { SerializableChatMessage } from '../chat/types.js';
|
|
12
|
+
import type { UISpec } from './types.js';
|
|
13
|
+
export interface SessionData {
|
|
14
|
+
userId: string;
|
|
15
|
+
appId: string;
|
|
16
|
+
sessionId: string;
|
|
17
|
+
messages: SerializableChatMessage[];
|
|
18
|
+
currentThreadId: string | null;
|
|
19
|
+
lastThreadId: string | null;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
/** Thread IDs that produced panel content, in creation order. */
|
|
22
|
+
panelThreads?: string[] | undefined;
|
|
23
|
+
/** Legacy thumbnail-strip data kept optional for backward compatibility with older sessions. */
|
|
24
|
+
thumbnailEntries?: Array<{
|
|
25
|
+
sku: string;
|
|
26
|
+
imageUrl: string;
|
|
27
|
+
threadId: string;
|
|
28
|
+
}> | undefined;
|
|
29
|
+
/** Serialized panel HTML keyed by bot message ID (for panel snapshot restore). */
|
|
30
|
+
panelSnapshotHtml?: Record<string, string> | undefined;
|
|
31
|
+
/** Panel component type keyed by snapshot message ID. */
|
|
32
|
+
panelSnapshotTypes?: Record<string, string> | undefined;
|
|
33
|
+
/** Latest panel AI-zone UISpec keyed by thread ID. */
|
|
34
|
+
panelAiSpecByThread?: Record<string, UISpec> | undefined;
|
|
35
|
+
/** SKU active when session was saved — prevents cross-SKU restore. */
|
|
36
|
+
sku?: string | undefined;
|
|
37
|
+
}
|
|
38
|
+
export interface ContextData {
|
|
39
|
+
sessionId: string;
|
|
40
|
+
threadId: string;
|
|
41
|
+
context: import('./types.js').BackendContext;
|
|
42
|
+
}
|
|
43
|
+
export interface PayloadData {
|
|
44
|
+
threadId: string;
|
|
45
|
+
messageId: string;
|
|
46
|
+
uiSpec: UISpec;
|
|
47
|
+
}
|
|
48
|
+
export interface FavoriteData {
|
|
49
|
+
userId: string;
|
|
50
|
+
appId: string;
|
|
51
|
+
sku: string;
|
|
52
|
+
name?: string | undefined;
|
|
53
|
+
imageUrl?: string | undefined;
|
|
54
|
+
price?: string | undefined;
|
|
55
|
+
savedAt: string;
|
|
56
|
+
}
|
|
57
|
+
export declare class GengageIndexedDB {
|
|
58
|
+
private _db;
|
|
59
|
+
private _dbName;
|
|
60
|
+
private _version;
|
|
61
|
+
constructor(dbName?: string, version?: number);
|
|
62
|
+
open(): Promise<IDBDatabase>;
|
|
63
|
+
close(): void;
|
|
64
|
+
saveSession(data: SessionData): Promise<void>;
|
|
65
|
+
loadSession(userId: string, appId: string, sessionId: string): Promise<SessionData | null>;
|
|
66
|
+
saveContext(data: ContextData): Promise<void>;
|
|
67
|
+
loadContext(sessionId: string, threadId: string): Promise<ContextData | null>;
|
|
68
|
+
/**
|
|
69
|
+
* Delete all context entries for a session whose threadId is lexicographically
|
|
70
|
+
* greater than the given threadId. Used during rollback to prune future branches.
|
|
71
|
+
*
|
|
72
|
+
* Thread IDs are UUIDv7 (lexicographically sortable by time), so string
|
|
73
|
+
* comparison is sufficient.
|
|
74
|
+
*/
|
|
75
|
+
deleteContextsAfterThread(sessionId: string, threadId: string): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Load the most recent context for a session (latest threadId).
|
|
78
|
+
* Uses lexicographic ordering of UUIDv7 threadIds for chronological sort.
|
|
79
|
+
*/
|
|
80
|
+
loadLatestContext(sessionId: string): Promise<ContextData | null>;
|
|
81
|
+
savePayload(data: PayloadData): Promise<void>;
|
|
82
|
+
loadPayload(threadId: string, messageId: string): Promise<PayloadData | null>;
|
|
83
|
+
loadPayloadsByThread(threadId: string): Promise<PayloadData[]>;
|
|
84
|
+
saveFavorite(data: FavoriteData): Promise<void>;
|
|
85
|
+
removeFavorite(userId: string, appId: string, sku: string): Promise<void>;
|
|
86
|
+
loadFavorites(userId: string, appId: string): Promise<FavoriteData[]>;
|
|
87
|
+
isFavorite(userId: string, appId: string, sku: string): Promise<boolean>;
|
|
88
|
+
private _requireDb;
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveLocaleTag(locale: string | null | undefined): string;
|