@alxxsck/ai-assistant 1.0.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 (56) hide show
  1. package/README.md +345 -0
  2. package/dist/App.d.ts +26 -0
  3. package/dist/Avatar-XISRbl7X.js +29627 -0
  4. package/dist/OrbitControls-XelJ40xM.js +458 -0
  5. package/dist/api/messages.api.d.ts +20 -0
  6. package/dist/api/messages.api.types.d.ts +88 -0
  7. package/dist/api/messages.api.utils.d.ts +2 -0
  8. package/dist/api/voice.api.d.ts +65 -0
  9. package/dist/api/voice.api.types.d.ts +37 -0
  10. package/dist/avatar/AnimationManager.d.ts +39 -0
  11. package/dist/avatar/Avatar.d.ts +69 -0
  12. package/dist/avatar/BlendShapeScenario.d.ts +19 -0
  13. package/dist/bridge-ai-chat-widget.es.js +10194 -0
  14. package/dist/constants.d.ts +2 -0
  15. package/dist/context/ChatWidgetContext.d.ts +32 -0
  16. package/dist/domain/command/CommandRuntime.d.ts +50 -0
  17. package/dist/domain/command/command.types.d.ts +70 -0
  18. package/dist/domain/message/cable/AnyCable.service.d.ts +34 -0
  19. package/dist/domain/message/cable/CableContext.d.ts +17 -0
  20. package/dist/domain/message/cable/CableContext.types.d.ts +19 -0
  21. package/dist/domain/message/cable/WidgetChat.channel.d.ts +4 -0
  22. package/dist/domain/message/cable/widget-message.d.ts +3 -0
  23. package/dist/domain/message/message.store.d.ts +51 -0
  24. package/dist/domain/scenario/scenario-choice.d.ts +17 -0
  25. package/dist/domain/ui/ui.service.d.ts +7 -0
  26. package/dist/domain/voice/voice.store.d.ts +69 -0
  27. package/dist/hooks/useDeviceManager.d.ts +25 -0
  28. package/dist/hooks/useSessionExpiryChecks.d.ts +3 -0
  29. package/dist/index.d.ts +41 -0
  30. package/dist/index.types.d.ts +50 -0
  31. package/dist/lib/isSessionExpired.d.ts +2 -0
  32. package/dist/lib/logger.d.ts +12 -0
  33. package/dist/lib/retrieveContent.d.ts +6 -0
  34. package/dist/lib/utils.d.ts +2 -0
  35. package/dist/lib//321/201ontentRenderer.d.ts +6 -0
  36. package/dist/lil-gui.esm-BicvE3D7.js +1263 -0
  37. package/dist/react/mount.d.ts +3 -0
  38. package/dist/types/index.d.ts +9 -0
  39. package/dist/ui/chat-routes.d.ts +11 -0
  40. package/dist/ui/components/ChatFooter.d.ts +2 -0
  41. package/dist/ui/components/ChatListItem.d.ts +10 -0
  42. package/dist/ui/components/ChatListPage.d.ts +1 -0
  43. package/dist/ui/components/ChatMessage.d.ts +8 -0
  44. package/dist/ui/components/ChatTextMode.d.ts +1 -0
  45. package/dist/ui/components/ChatTopControls.d.ts +1 -0
  46. package/dist/ui/components/ChatTypingIndicator.d.ts +4 -0
  47. package/dist/ui/components/ChatUnreadIndicator.d.ts +1 -0
  48. package/dist/ui/components/ChatVoiceMode.d.ts +1 -0
  49. package/dist/ui/components/ChatWidget.d.ts +4 -0
  50. package/dist/ui/components/ErrorMessage.d.ts +7 -0
  51. package/dist/ui/components/VoiceModeMessage.d.ts +12 -0
  52. package/dist/ui/components/overlays/ChatBlurOverlayBottom.d.ts +1 -0
  53. package/dist/ui/components/overlays/ChatBlurOverlayTop.d.ts +1 -0
  54. package/dist/ui/components/overlays/ChatDarkOverlay.d.ts +1 -0
  55. package/dist/ui/error-messages.d.ts +7 -0
  56. package/package.json +102 -0
@@ -0,0 +1,2 @@
1
+ export declare const SM_BREAKPOINT = 640;
2
+ export declare const SHOW_REACTION_MESSAGE_DURATION = 5000;
@@ -0,0 +1,32 @@
1
+ import type { AppApi } from "@/App";
2
+ import type { Avatar } from "@/avatar/Avatar";
3
+ import type { WidgetConfig } from "@/index.types";
4
+ import type { CtaCommandContext } from "@/domain/command/command.types";
5
+ type ChatWidgetContextValue = {
6
+ open: boolean;
7
+ setOpen: (v: boolean) => void;
8
+ /** False when `manualOpen` is false and the widget was dismissed; chrome stays mounted but is hidden and non-interactive until `setOpen(true)`. */
9
+ isChromeVisible: boolean;
10
+ widgetHeight: number;
11
+ setWidgetHeight: (h: number) => void;
12
+ widgetWidth: number;
13
+ setWidgetWidth: (w: number) => void;
14
+ reactionMessage: string | null;
15
+ setReactionMessage: (message: string | null) => void;
16
+ isMobile: boolean;
17
+ config: WidgetConfig;
18
+ api: AppApi;
19
+ loadingProgress: number;
20
+ setLoadingProgress: (p: number) => void;
21
+ assistantRef: React.RefObject<Avatar | null>;
22
+ cta: CtaCommandContext | null;
23
+ executeCta: () => Promise<void>;
24
+ dismissCta: () => void;
25
+ };
26
+ export declare const ChatWidgetContextProvider: ({ children, config, api, }: {
27
+ children: React.ReactNode;
28
+ config: WidgetConfig;
29
+ api: AppApi;
30
+ }) => import("react/jsx-runtime").JSX.Element;
31
+ export declare function useChatWidget(): ChatWidgetContextValue;
32
+ export {};
@@ -0,0 +1,50 @@
1
+ import type { CustomerInteractionSession } from "@/types";
2
+ import { type CommandAck, type CommandEnvelope, type CommandEventDetail, type CtaCommandContext, type HostCommandHandlerName, type HostCommandHandlers, type UiTarget } from "./command.types";
3
+ type AckSender = (ack: CommandAck) => Promise<unknown>;
4
+ type InternalHandlers = {
5
+ setAssistantVisible?: (visible: boolean) => void;
6
+ setChatOpen?: (open: boolean) => void;
7
+ playAnimation?: (animation: string) => void;
8
+ showCta?: (context: CtaCommandContext) => void;
9
+ };
10
+ export declare class CommandRuntime {
11
+ private readonly onStatus?;
12
+ private readonly targets;
13
+ private readonly hostHandlers;
14
+ private readonly internalHandlers;
15
+ private readonly internalHandlersReady;
16
+ private resolveInternalHandlers;
17
+ private readonly completed;
18
+ private readonly inFlight;
19
+ private readonly highlights;
20
+ constructor(targets?: Record<string, UiTarget>, handlers?: HostCommandHandlers, onStatus?: ((detail: CommandEventDetail) => void) | undefined);
21
+ registerTarget(code: string, target: UiTarget): () => void;
22
+ registerHostHandler<K extends HostCommandHandlerName>(name: K, handler: NonNullable<HostCommandHandlers[K]>): () => void;
23
+ setInternalHandlers(handlers: InternalHandlers): () => void;
24
+ execute(envelope: CommandEnvelope, session: CustomerInteractionSession, sendAck: AckSender): Promise<void>;
25
+ executeCtaAction(context: CtaCommandContext): Promise<void>;
26
+ destroy(): void;
27
+ private executeOnce;
28
+ private dispatch;
29
+ private executeTargetCommand;
30
+ private executeHighlight;
31
+ private executeShowCta;
32
+ private canOpenPage;
33
+ private canOpenModal;
34
+ private requireTarget;
35
+ private findTargetElement;
36
+ private applyDefaultHighlight;
37
+ private removeDefaultHighlight;
38
+ private requireInternal;
39
+ private requireString;
40
+ private firstDefined;
41
+ private applyUrlFallback;
42
+ private targetUrl;
43
+ private assertTargetCode;
44
+ private finish;
45
+ private storageKey;
46
+ private loadCompleted;
47
+ private saveCompleted;
48
+ private toAck;
49
+ }
50
+ export {};
@@ -0,0 +1,70 @@
1
+ export declare const COMMAND_TYPES: readonly ["show_assistant", "hide_assistant", "open_chat", "close_chat", "play_animation", "highlight_element", "remove_highlight", "show_cta", "open_page", "open_modal"];
2
+ export type CommandType = (typeof COMMAND_TYPES)[number];
3
+ export type CommandAckStatus = "received" | "succeeded" | "failed" | "expired" | "unsupported";
4
+ export type CommandAck = {
5
+ commandId: string;
6
+ status: CommandAckStatus;
7
+ errorCode?: string;
8
+ details?: Record<string, unknown>;
9
+ };
10
+ export type CommandEnvelope = {
11
+ type: "command.created";
12
+ eventId: string;
13
+ sequence: number;
14
+ occurredAt: string;
15
+ data: {
16
+ commandId: string;
17
+ scenarioRunId: string;
18
+ interactionSessionId: string;
19
+ commandType: string;
20
+ target?: {
21
+ id?: string;
22
+ code?: string;
23
+ };
24
+ payload: Record<string, unknown>;
25
+ expiresAt: string | null;
26
+ };
27
+ };
28
+ export type UiTargetKind = "button" | "element" | "modal" | "page";
29
+ export type UiTarget = {
30
+ kind: UiTargetKind;
31
+ /** Trusted selector supplied by the host application. */
32
+ selector?: string;
33
+ /** Trusted route used by the built-in openPage fallback. */
34
+ route?: string;
35
+ /** Explicit URL fallback. It may include query parameters such as lola_modal. */
36
+ url?: string;
37
+ /** Query parameters merged into url, route, or the current location. Null removes a key. */
38
+ query?: Record<string, string | null>;
39
+ };
40
+ export type HostCommandContext = {
41
+ commandId: string;
42
+ commandType: CommandType;
43
+ target: string;
44
+ targetDefinition?: UiTarget;
45
+ payload: Readonly<Record<string, unknown>>;
46
+ url?: string;
47
+ route?: string;
48
+ modalId?: string;
49
+ modalCode?: string;
50
+ };
51
+ export type HighlightCommandContext = HostCommandContext & {
52
+ active: boolean;
53
+ element?: Element;
54
+ };
55
+ export type CtaCommandContext = Omit<HostCommandContext, "target"> & {
56
+ label: string;
57
+ action: "none" | "open_modal" | "open_page";
58
+ target?: string;
59
+ };
60
+ export type HostCommandHandlers = {
61
+ openPage?: (context: HostCommandContext) => void | Promise<void>;
62
+ openModal?: (context: HostCommandContext) => void | Promise<void>;
63
+ highlight?: (context: HighlightCommandContext) => void | Promise<void>;
64
+ showCta?: (context: CtaCommandContext) => void | Promise<void>;
65
+ };
66
+ export type HostCommandHandlerName = keyof HostCommandHandlers;
67
+ export type HostCommandHandler = NonNullable<HostCommandHandlers[HostCommandHandlerName]>;
68
+ export type CommandEventDetail = CommandAck & {
69
+ commandType?: string;
70
+ };
@@ -0,0 +1,34 @@
1
+ import type { Channel } from "@anycable/web";
2
+ import { WidgetChatChannel } from "./WidgetChat.channel";
3
+ import type { CommandAck } from "@/domain/command/command.types";
4
+ import type { ScenarioChoiceInput } from "@/domain/scenario/scenario-choice";
5
+ /**
6
+ * AnyCableService is responsible for managing the WebSocket connection and
7
+ * subscribing to channels.
8
+ */
9
+ export declare class AnyCableService {
10
+ private url;
11
+ private cable?;
12
+ channels: {
13
+ chat: WidgetChatChannel;
14
+ };
15
+ constructor(url: string, onMessage?: (message: unknown) => void);
16
+ /**
17
+ * Subscribes to a channel
18
+ *
19
+ * @param channel - The channel to subscribe to
20
+ */
21
+ subscribe(channel: Channel): this;
22
+ /**
23
+ * Unsubscribes from a channel
24
+ *
25
+ * @param channel - The channel to unsubscribe from
26
+ */
27
+ unsubscribe(channel: Channel): this;
28
+ acknowledgeCommand(ack: CommandAck): Promise<unknown>;
29
+ submitScenarioChoice(input: ScenarioChoiceInput): Promise<unknown>;
30
+ /** Registers the cable and subscribes to the bridge channel */
31
+ private register;
32
+ /** Unregisters the cable and disconnects from the WebSocket server */
33
+ unregister(): void;
34
+ }
@@ -0,0 +1,17 @@
1
+ import { type ReactNode } from "react";
2
+ import { AnyCableService } from "./AnyCable.service";
3
+ import { NetworkStatus } from "./CableContext.types";
4
+ import type { WidgetConfig } from "@/index.types";
5
+ import type { CommandRuntime } from "@/domain/command/CommandRuntime";
6
+ interface CableContextType {
7
+ anycableService: AnyCableService | null;
8
+ networkStatus: NetworkStatus;
9
+ }
10
+ interface CableProviderProps {
11
+ children: ReactNode;
12
+ config: WidgetConfig;
13
+ commandRuntime: CommandRuntime;
14
+ }
15
+ export declare const CableProvider: ({ children, config, commandRuntime, }: CableProviderProps) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const useCable: () => CableContextType;
17
+ export {};
@@ -0,0 +1,19 @@
1
+ export declare enum NetworkStatus {
2
+ /** When we are trying to establish WS connection */
3
+ Pending = "pending",
4
+ /**
5
+ * When the user is online (has access to the internet) and WS connection is
6
+ * established
7
+ */
8
+ Available = "available",
9
+ /**
10
+ * When the user is offline (no internet access) but WS connection is
11
+ * established
12
+ */
13
+ Offline = "offline",
14
+ /**
15
+ * When the user is offline (no internet access) and WS connection is not
16
+ * established
17
+ */
18
+ Unavailable = "unavailable"
19
+ }
@@ -0,0 +1,4 @@
1
+ import { Channel } from "@anycable/web";
2
+ export declare class WidgetChatChannel extends Channel {
3
+ static identifier: string;
4
+ }
@@ -0,0 +1,3 @@
1
+ import type { AgenticStepsAppendedData, MessageData } from "@/api/messages.api.types";
2
+ export declare const getMessageFromFrame: (frame: unknown) => MessageData | null;
3
+ export declare const getAgenticStepsFromFrame: (frame: unknown) => AgenticStepsAppendedData | null;
@@ -0,0 +1,51 @@
1
+ import { type AgenticStepsAppendedData, type ConversationData, type MessageData } from "@/api/messages.api.types";
2
+ import type { AppApi } from "@/App";
3
+ import type { WidgetConfig } from "@/index.types";
4
+ export interface ThreadSummary {
5
+ threadId: string;
6
+ lastMessage: MessageData;
7
+ }
8
+ export type MessageStore = {
9
+ currentThreadId: string | undefined;
10
+ currentThreadMessages: MessageData[];
11
+ messages: MessageData[];
12
+ conversations: ConversationData[];
13
+ threadIds: string[];
14
+ threads: Map<string, MessageData[]>;
15
+ threadsPreviews: ThreadSummary[];
16
+ sendError: string | null;
17
+ config: WidgetConfig | null;
18
+ api: AppApi | null;
19
+ latestReadMessageDate: string | null;
20
+ latestMessageDate: string | null;
21
+ actions: MessageStoreActions;
22
+ };
23
+ type MessageStoreActions = {
24
+ initMessageStore: (config: WidgetConfig, api: AppApi) => Promise<void>;
25
+ setCurrentThread: (conversationId: string) => Promise<void>;
26
+ createNewConversation: () => Promise<string>;
27
+ handleMessage: (message: MessageData) => void;
28
+ sendMessage: (message: string) => Promise<void>;
29
+ clearSendError: () => void;
30
+ getThreadsSummaryData: () => ThreadSummary[];
31
+ setLatestReadMessageDate: (readMessageDate: string) => void;
32
+ addMessage: (message: MessageData) => void;
33
+ updateMessage: (message: MessageData, index: number) => void;
34
+ handleMessagesAgenticSteps: (message: AgenticStepsAppendedData) => void;
35
+ updateThreads: () => void;
36
+ fetchThreadMessages: (conversationId: string) => Promise<void>;
37
+ setCurrentThreadMessages: (conversationId: string) => void;
38
+ sendServiceMessage: (message: string) => Promise<void>;
39
+ updateConfig: (config: WidgetConfig, api: AppApi) => void;
40
+ recoverMessages: () => Promise<void>;
41
+ };
42
+ export declare const useMessageStore: import("zustand").UseBoundStore<import("zustand").StoreApi<MessageStore>>;
43
+ export declare const useSelectCurrentThreadId: () => string | undefined;
44
+ export declare const useSelectCurrentThreadMessages: () => MessageData[];
45
+ export declare const useSelectThreadsPreviews: () => ThreadSummary[];
46
+ export declare const useCurrentThreadId: () => string | undefined;
47
+ export declare const useLatestReadMessageDate: () => string | null;
48
+ export declare const useLatestMessageDate: () => string | null;
49
+ export declare const useSendError: () => string | null;
50
+ export declare const useMessageStoreActions: () => MessageStoreActions;
51
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { MessageData } from "@/api/messages.api.types";
2
+ export type ScenarioChoiceOption = {
3
+ id: string;
4
+ label: string;
5
+ };
6
+ export type ScenarioChoiceCommand = {
7
+ type: "ask_choice";
8
+ inputRequestId: string;
9
+ options: ScenarioChoiceOption[];
10
+ };
11
+ export type ScenarioChoiceInput = {
12
+ inputRequestId: string;
13
+ optionId: string;
14
+ clientEventId: string;
15
+ };
16
+ export declare const getScenarioChoice: (message: MessageData) => ScenarioChoiceCommand | null;
17
+ export declare const getLatestScenarioChoice: (messages: MessageData[]) => ScenarioChoiceCommand | null;
@@ -0,0 +1,7 @@
1
+ type WidgetUIData = {
2
+ width: number;
3
+ height: number;
4
+ };
5
+ export declare function loadWidgetUIData(): WidgetUIData | null;
6
+ export declare function saveWidgetUIData(data: WidgetUIData): void;
7
+ export {};
@@ -0,0 +1,69 @@
1
+ import type { AppApi } from "@/App";
2
+ import type { VoiceSessionData } from "@/api/voice.api.types";
3
+ import type { WidgetConfig } from "@/index.types";
4
+ /** Arguments for creating a local media stream */
5
+ export interface GetLocalStreamArgs {
6
+ /** Optional audio input device ID */
7
+ inputAudioDeviceId?: string;
8
+ }
9
+ type VoiceStatus = "idle" | "connecting" | "live" | "ending" | "error";
10
+ type VoiceStore = {
11
+ activeVoiceSessionData: VoiceSessionData | null;
12
+ config: WidgetConfig | null;
13
+ api: AppApi | null;
14
+ status: VoiceStatus;
15
+ errorMessage: string | null;
16
+ isVoiceBootstrapped: boolean;
17
+ connection: RTCPeerConnection | null;
18
+ connectionId: string | null;
19
+ connectionGeneration: number | null;
20
+ iceCandidates: RTCIceCandidateInit[];
21
+ voiceEventsChannel: RTCDataChannel | null;
22
+ voiceInputChannel: RTCDataChannel | null;
23
+ downstream: MediaStream | null;
24
+ localStream: MediaStream | null;
25
+ remoteAudioElement: HTMLAudioElement | null;
26
+ customerMessageTranscript: string;
27
+ customerMessageTranscriptVisible: boolean;
28
+ assistantMessageTranscript: string;
29
+ assistantMessageTranscriptVisible: boolean;
30
+ assistantResponseInProgress: boolean;
31
+ microphoneEnabled: boolean;
32
+ inputAudioDevice: MediaDeviceInfo | null;
33
+ audioInputDevices: MediaDeviceInfo[];
34
+ actions: VoiceStoreActions;
35
+ };
36
+ type VoiceStoreActions = {
37
+ onVoiceEventsEvent: (event: MessageEvent<string>) => void;
38
+ onVoiceInputEvent: (event: MessageEvent<string>) => void;
39
+ initVoiceStore: (config: WidgetConfig, api: AppApi) => Promise<void>;
40
+ createConnection: () => RTCPeerConnection;
41
+ sendCandidates: () => Promise<void>;
42
+ playRemoteAudio: (stream: MediaStream) => void;
43
+ endVoiceSession: (reason?: string) => Promise<void>;
44
+ setMicrophoneEnabled: (enabled: boolean) => void;
45
+ sendOffer: (offer: RTCSessionDescriptionInit) => Promise<void>;
46
+ getLocalStream: (deviceId?: string) => Promise<MediaStream | null>;
47
+ setNewLocalStream: () => Promise<void>;
48
+ createAudioTrack: () => Promise<MediaStreamTrack | null>;
49
+ attachAudioTrack: (newTrack: MediaStreamTrack, { replaceExisting }: {
50
+ replaceExisting: boolean;
51
+ }) => Promise<MediaStreamTrack>;
52
+ ensureAudioTrack: () => Promise<boolean>;
53
+ recreateAudioTrack: () => Promise<boolean>;
54
+ enableMicrophone: () => Promise<void>;
55
+ disableMicrophone: () => void;
56
+ switchAudio: () => Promise<void>;
57
+ refreshAudioProcessing: () => Promise<void>;
58
+ switchInputAudioDevice: (newDevice: MediaDeviceInfo) => Promise<void>;
59
+ };
60
+ export declare const useVoiceStore: import("zustand").UseBoundStore<import("zustand").StoreApi<VoiceStore>>;
61
+ export declare const useVoiceStoreActions: () => VoiceStoreActions;
62
+ export declare const useMicrophoneEnabled: () => boolean;
63
+ export declare const useInputAudioDevice: () => MediaDeviceInfo | null;
64
+ export declare const useLocalStream: () => MediaStream | null;
65
+ export declare const useConnection: () => RTCPeerConnection | null;
66
+ export declare const useConnectionId: () => string | null;
67
+ export declare const useDownstream: () => MediaStream | null;
68
+ export declare const useCustomerMessageTranscript: () => string;
69
+ export {};
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Hook for managing media devices (audio input, audio output, video input) in
3
+ * video calls.
4
+ *
5
+ * This hook provides:
6
+ *
7
+ * - Automatic device enumeration and updates
8
+ * - Device change event listening
9
+ * - Automatic fallback to available devices when current device is disconnected
10
+ * - Permission handling for device access
11
+ *
12
+ * The hook automatically:
13
+ *
14
+ * - Enumerates available devices on mount
15
+ * - Listens for device changes (connect/disconnect)
16
+ * - Switches to the first available device if the current device becomes
17
+ * unavailable
18
+ * - Requests microphone permission if needed to get device labels
19
+ *
20
+ * @returns Void - This hook doesn't return any values, it manages device state
21
+ * internally
22
+ */
23
+ export declare const useDeviceManager: () => {
24
+ updateDevices: (e?: Event) => Promise<void>;
25
+ };
@@ -0,0 +1,3 @@
1
+ import type { AppApi } from "@/App";
2
+ import type { WidgetConfig } from "@/index.types";
3
+ export declare function useSessionExpiryChecks(config: WidgetConfig, api: AppApi, open: boolean): void;
@@ -0,0 +1,41 @@
1
+ import type { ExternallyAvailableActions } from "./avatar/Avatar";
2
+ import type { WidgetConfig } from "./index.types";
3
+ import type { CustomerInteractionSession } from "./types";
4
+ import type { HostCommandHandlerName, UiTarget } from "./domain/command/command.types";
5
+ export type { WidgetConfig } from "./index.types";
6
+ export declare const ASSETS_URL = "https://metamediastatic.com";
7
+ export declare class ChatWidgetInstance extends EventTarget {
8
+ private root;
9
+ private shadowRoot;
10
+ private config;
11
+ private gui;
12
+ private setOpenImpl;
13
+ private sendServiceMessageImpl;
14
+ private playAnimationImpl;
15
+ private executeReactionImpl;
16
+ private resolveAssetPath;
17
+ private setLocaleImpl;
18
+ private setSessionImpl;
19
+ private readonly commandRuntime;
20
+ constructor(config: WidgetConfig);
21
+ private initGui;
22
+ private init;
23
+ private fetchAndMergeRemoteConfig;
24
+ private onAvatarReady;
25
+ private onSessionExpired;
26
+ private onCommandStatus;
27
+ private injectStyles;
28
+ setOpen(open: boolean): void;
29
+ playAnimation(name: ExternallyAvailableActions): void;
30
+ setCustomerInteractionSession(session: CustomerInteractionSession): void;
31
+ registerUiTarget(code: string, target: UiTarget): () => void;
32
+ registerCommandHandler<K extends HostCommandHandlerName>(name: K, handler: NonNullable<NonNullable<WidgetConfig["commandHandlers"]>[K]>): () => void;
33
+ executeReaction(params: {
34
+ animation: string;
35
+ voice: string;
36
+ text: string;
37
+ }): void;
38
+ sendServiceMessage(message: string, animationName: ExternallyAvailableActions): void;
39
+ setLocale(locale: string): void;
40
+ destroy(): void;
41
+ }
@@ -0,0 +1,50 @@
1
+ import type { ExternallyAvailableActions } from "./avatar/Avatar";
2
+ import type { CustomerInteractionSession } from "./types";
3
+ import type { CommandEventDetail, HostCommandHandlerName, HostCommandHandlers, UiTarget } from "./domain/command/command.types";
4
+ export type WidgetConfig = {
5
+ mountElementId: string;
6
+ configName?: string;
7
+ customerInteractionSession: CustomerInteractionSession;
8
+ agentId: string;
9
+ customerId?: string;
10
+ wsUrl: string;
11
+ apiUrl: string;
12
+ voiceModelId?: string;
13
+ voiceConfig?: {
14
+ voice: string;
15
+ };
16
+ AIAvatar?: boolean;
17
+ debug?: boolean;
18
+ avatarDebug?: boolean;
19
+ background?: boolean;
20
+ voiceEnabled?: boolean;
21
+ footer?: boolean;
22
+ /** When true, launcher + open/close behave as today. When false, closing hides the widget entirely until `setOpen(true)`. */
23
+ manualOpen?: boolean;
24
+ locale?: string;
25
+ /** Host-owned UI targets that commands are allowed to address. */
26
+ uiTargets?: Record<string, UiTarget>;
27
+ /** Optional host integrations. Built-in fallbacks cover CTA and data-lola highlights. */
28
+ commandHandlers?: HostCommandHandlers;
29
+ /** Lola SDK-compatible alias for commandHandlers. */
30
+ handlers?: HostCommandHandlers;
31
+ };
32
+ export declare class ChatWidgetInstance extends EventTarget {
33
+ constructor(config: WidgetConfig);
34
+ destroy(): void;
35
+ playAnimation(name: ExternallyAvailableActions): void;
36
+ setCustomerInteractionSession(session: CustomerInteractionSession): void;
37
+ setOpen(open: boolean): void;
38
+ setLocale(locale: string): void;
39
+ executeReaction(params: {
40
+ animation: string;
41
+ voice: string;
42
+ text: string;
43
+ }): void;
44
+ registerUiTarget(code: string, target: UiTarget): () => void;
45
+ registerCommandHandler<K extends HostCommandHandlerName>(name: K, handler: NonNullable<HostCommandHandlers[K]>): () => void;
46
+ addEventListener(type: "command_received" | "command_succeeded" | "command_failed" | "command_expired" | "command_unsupported", listener: (event: CustomEvent<CommandEventDetail>) => void, options?: boolean | AddEventListenerOptions): void;
47
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
48
+ }
49
+ export type { CustomerInteractionSession };
50
+ export type { CommandAck, CommandAckStatus, CommandEnvelope, CommandEventDetail, CommandType, CtaCommandContext, HighlightCommandContext, HostCommandContext, HostCommandHandler, HostCommandHandlerName, HostCommandHandlers, UiTarget, UiTargetKind, } from "./domain/command/command.types";
@@ -0,0 +1,2 @@
1
+ import type { CustomerInteractionSession } from "@/types";
2
+ export declare function isSessionExpireInNextHour(session: CustomerInteractionSession): boolean;
@@ -0,0 +1,12 @@
1
+ type LogLevel = "debug" | "info" | "warn" | "error";
2
+ declare class Logger {
3
+ private level;
4
+ private prefix;
5
+ constructor(prefix?: string, level?: LogLevel);
6
+ debug(...args: unknown[]): void;
7
+ info(...args: unknown[]): void;
8
+ warn(...args: unknown[]): void;
9
+ error(...args: unknown[]): void;
10
+ }
11
+ export declare const logger: Logger;
12
+ export {};
@@ -0,0 +1,6 @@
1
+ import { type MessageData } from "@/api/messages.api.types";
2
+ /**
3
+ * Plain-text preview from HTML for list items etc. Truncation works with CSS (e.g. truncate).
4
+ */
5
+ export declare function htmlToPlainPreview(html: string, maxLength?: number): string;
6
+ export declare function retrieveContent(m: MessageData): string;
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from "clsx";
2
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -0,0 +1,6 @@
1
+ import type { JSONContent } from "@/api/messages.api.types";
2
+ /**
3
+ * Renders agent message content (TipTap JSON) to an HTML string.
4
+ * Uses the ProseMirror-free static JSON renderer.
5
+ */
6
+ export declare function сontentToHtml(content: JSONContent | null | undefined): string;