@alxxsck/ai-assistant 1.8.0 → 2.2.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 (41) hide show
  1. package/README.md +121 -314
  2. package/dist/App.d.ts +0 -7
  3. package/dist/{Avatar-BAlmduYw.js → Avatar-DKGkEfXe.js} +2608 -2716
  4. package/dist/ChatWidgetContent-Coj_NDep.js +8570 -0
  5. package/dist/avatar/AnimationManager.d.ts +45 -15
  6. package/dist/avatar/Avatar.d.ts +15 -19
  7. package/dist/avatar/publicAnimations.d.ts +3 -0
  8. package/dist/bridge-ai-chat-widget.es.js +4 -14123
  9. package/dist/config/runtime-config.d.ts +4 -0
  10. package/dist/context/ChatWidgetContext.d.ts +6 -5
  11. package/dist/domain/command/CommandRuntime.d.ts +1 -0
  12. package/dist/domain/command/command.types.d.ts +15 -24
  13. package/dist/domain/message/cable/AnyCable.service.d.ts +2 -1
  14. package/dist/domain/message/cable/CableContext.d.ts +2 -1
  15. package/dist/domain/message/cable/CableContext.types.d.ts +2 -4
  16. package/dist/domain/speech/LipSyncCueSource.d.ts +25 -0
  17. package/dist/domain/speech/LipSyncRuntime.d.ts +54 -0
  18. package/dist/domain/speech/RealtimeLipSyncCueSource.d.ts +13 -0
  19. package/dist/domain/speech/SpeechPlayer.d.ts +10 -0
  20. package/dist/domain/ui/ui.service.d.ts +7 -1
  21. package/dist/domain/ui/widget-geometry.d.ts +23 -0
  22. package/dist/domain/voice/voice.store.d.ts +1 -0
  23. package/dist/index-Dt2DYOP-.js +9632 -0
  24. package/dist/index.d.ts +18 -21
  25. package/dist/index.types.d.ts +6 -43
  26. package/dist/lib/isAuthenticationError.d.ts +1 -0
  27. package/dist/lib/logger.d.ts +5 -2
  28. package/dist/lib/markdownRenderer.d.ts +4 -0
  29. package/dist/types/index.d.ts +4 -6
  30. package/dist/ui/chat-routes.d.ts +2 -0
  31. package/dist/ui/components/ChatAvatarStage.d.ts +1 -0
  32. package/dist/ui/components/ChatWidget.d.ts +0 -2
  33. package/dist/ui/components/ChatWidgetContent.d.ts +1 -0
  34. package/dist/ui/components/ChatWidgetFrame.d.ts +13 -0
  35. package/dist/ui/components/StreamingMessageText.d.ts +2 -1
  36. package/dist/ui/hooks/useSmoothStreamingText.d.ts +2 -1
  37. package/dist/ui/streaming/smooth-text.d.ts +5 -0
  38. package/package.json +7 -20
  39. package/dist/OrbitControls-BhEr8WlG.js +0 -458
  40. package/dist/lil-gui.esm-BicvE3D7.js +0 -1263
  41. package/dist/ui/components/ChatFooter.d.ts +0 -2
package/dist/index.d.ts CHANGED
@@ -1,49 +1,46 @@
1
- import type { ExternallyAvailableActions } from "./avatar/Avatar";
2
1
  import type { WidgetConfig } from "./index.types";
3
2
  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";
3
+ import type { CommandEventDetail } from "./domain/command/command.types";
4
+ export type { CustomerInteractionSession, CommandEventDetail, HighlightCommandContext, HostCommandHandlers, OpenModalContext, OpenPageContext, WidgetConfig, } from "./index.types";
5
+ export { EXTERNALLY_AVAILABLE_ACTIONS, isExternallyAvailableAction, } from "./avatar/publicAnimations";
6
+ export type { ExternallyAvailableActions } from "./avatar/publicAnimations";
7
+ type WidgetEventMap = {
8
+ renew_session: CustomEvent<void>;
9
+ command_received: CustomEvent<CommandEventDetail>;
10
+ command_succeeded: CustomEvent<CommandEventDetail>;
11
+ command_failed: CustomEvent<CommandEventDetail>;
12
+ command_expired: CustomEvent<CommandEventDetail>;
13
+ command_unsupported: CustomEvent<CommandEventDetail>;
14
+ };
7
15
  export declare class ChatWidgetInstance extends EventTarget {
8
16
  private root;
17
+ private hostElement;
9
18
  private shadowRoot;
10
19
  private config;
11
- private gui;
12
20
  private setOpenImpl;
13
21
  private pendingOpenState;
14
- private sendServiceMessageImpl;
15
22
  private playAnimationImpl;
16
23
  private avatarLoadError;
17
24
  private avatarLoadGeneration;
18
25
  private readonly pendingAvatarAnimations;
19
26
  private destroyed;
20
- private executeReactionImpl;
27
+ private disableDebugLogging;
21
28
  private resolveAssetPath;
22
- private setLocaleImpl;
23
29
  private setSessionImpl;
24
30
  private readonly commandRuntime;
31
+ private readonly onSessionExpired;
32
+ addEventListener<K extends keyof WidgetEventMap>(type: K, listener: (this: ChatWidgetInstance, event: WidgetEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
33
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void;
25
34
  constructor(config: WidgetConfig);
26
- private initGui;
27
35
  private init;
28
- private fetchAndMergeRemoteConfig;
29
36
  private onAvatarReady;
30
37
  private onAvatarLoadStarted;
31
38
  private onAvatarLoadFailed;
32
39
  private playAvatarAnimation;
33
- private onSessionExpired;
34
40
  private onCommandStatus;
35
41
  private injectStyles;
42
+ private validateCustomerInteractionSession;
36
43
  setOpen(open: boolean): void;
37
- playAnimation(name: ExternallyAvailableActions): void;
38
44
  setCustomerInteractionSession(session: CustomerInteractionSession): void;
39
- registerUiTarget(code: string, target: UiTarget): () => void;
40
- registerCommandHandler<K extends HostCommandHandlerName>(name: K, handler: NonNullable<NonNullable<WidgetConfig["commandHandlers"]>[K]>): () => void;
41
- executeReaction(params: {
42
- animation: string;
43
- voice: string;
44
- text: string;
45
- }): void;
46
- sendServiceMessage(message: string, animationName: ExternallyAvailableActions): void;
47
- setLocale(locale: string): void;
48
45
  destroy(): void;
49
46
  }
@@ -1,50 +1,13 @@
1
- import type { ExternallyAvailableActions } from "./avatar/Avatar";
2
1
  import type { CustomerInteractionSession } from "./types";
3
- import type { CommandEventDetail, HostCommandHandlerName, HostCommandHandlers, UiTarget } from "./domain/command/command.types";
2
+ import type { HostCommandHandlers } from "./domain/command/command.types";
4
3
  export type WidgetConfig = {
5
- mountElementId: string;
6
- configName?: string;
7
4
  customerInteractionSession: CustomerInteractionSession;
8
- agentId: string;
9
- customerId?: string;
10
- wsUrl: string;
11
- apiUrl: string;
12
- /** Optional xAI voice passed to Lola when creating a voice session. */
13
- voiceConfig?: {
14
- voice: string;
15
- };
16
- AIAvatar?: boolean;
5
+ /** Hides the built-in launcher while preserving programmatic `setOpen`. */
6
+ hideOpenButton?: boolean;
7
+ /** Enables verbose `[Lola-Widget]` diagnostics. Errors are always logged. */
17
8
  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. */
9
+ /** Optional product integrations for navigation, modals, and highlighting. */
30
10
  handlers?: HostCommandHandlers;
31
11
  };
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
12
  export type { CustomerInteractionSession };
50
- export type { CommandAck, CommandAckStatus, CommandEnvelope, CommandEventDetail, CommandType, CtaCommandContext, HighlightCommandContext, HostCommandContext, HostCommandHandler, HostCommandHandlerName, HostCommandHandlers, ModalCommandTarget, OpenModalContext, OpenPageContext, PageCommandTarget, SpeakTextCommandContext, StartVoiceConversationCommandContext, UiCommandActionSnapshot, UiCommandTarget, UiTarget, UiTargetKind, } from "./domain/command/command.types";
13
+ export type { CommandEventDetail, HighlightCommandContext, HostCommandHandlers, OpenModalContext, OpenPageContext, } from "./domain/command/command.types";
@@ -0,0 +1 @@
1
+ export declare const isAuthenticationError: (error: unknown) => boolean;
@@ -1,8 +1,11 @@
1
1
  type LogLevel = "debug" | "info" | "warn" | "error";
2
2
  declare class Logger {
3
- private level;
4
- private prefix;
3
+ private readonly level;
4
+ private readonly prefix;
5
+ private debugOwnerCount;
5
6
  constructor(prefix?: string, level?: LogLevel);
7
+ enableDebug(): () => void;
8
+ private isEnabled;
6
9
  debug(...args: unknown[]): void;
7
10
  info(...args: unknown[]): void;
8
11
  warn(...args: unknown[]): void;
@@ -0,0 +1,4 @@
1
+ export declare function getSafeHttpUrl(value: unknown): string | null;
2
+ export declare function renderMarkdown(markdown: string): string;
3
+ export declare function renderInlineMarkdown(markdown: string): string;
4
+ export declare function renderPlainText(text: string): string;
@@ -1,9 +1,7 @@
1
1
  import type { ExternallyAvailableActions } from "@/avatar/Avatar";
2
2
  export type CustomerInteractionSession = {
3
- accessToken: string;
4
- chatId: string;
5
- /** Lola Backend interaction session id. Defaults to chatId for compatibility transports. */
6
- sessionId?: string;
7
- expiresAt: string;
3
+ readonly accessToken: string;
4
+ readonly interactionSessionId: string;
5
+ readonly expiresAt: string;
8
6
  };
9
- export type OnAvatarReady = (playAnimation: (name: ExternallyAvailableActions) => void) => void;
7
+ export type OnAvatarReady = (playAnimation: (name: ExternallyAvailableActions) => void | Promise<void>) => void;
@@ -10,8 +10,10 @@ export declare const CHAT_PATHS: {
10
10
  export type ChatListNavigationState = {
11
11
  chatMode: ChatMode;
12
12
  };
13
+ export type ChatPageTransitionDirection = "forward" | "backward";
13
14
  export declare function getChatModeFromNavigationState(state: unknown): ChatMode | null;
14
15
  export declare function getChatModeFromPathname(pathname: string): ChatMode;
15
16
  export declare function isChatListPath(pathname: string): boolean;
17
+ export declare function getChatPageTransitionDirection(fromPathname: string, toPathname: string): ChatPageTransitionDirection | null;
16
18
  export declare function isVoiceChatPath(pathname: string): boolean;
17
19
  export declare function shouldOpenIncomingMessageInTextMode(pathname: string): boolean;
@@ -0,0 +1 @@
1
+ export declare function ChatAvatarStage(): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,2 @@
1
1
  export { CHAT_PATHS, ChatMode } from "@/ui/chat-routes";
2
- export declare const DEFAULT_WIDGET_WIDTH = 360;
3
- export declare const DEFAULT_WIDGET_HEIGHT = 680;
4
2
  export declare function ChatWidget(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export default function ChatWidgetContent(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import type { PropsWithChildren } from "react";
2
+ type ChatWidgetFrameProps = PropsWithChildren<{
3
+ open: boolean;
4
+ onOpenChange: (open: boolean) => void;
5
+ isMobile: boolean;
6
+ fullscreen: boolean;
7
+ hideOpenButton: boolean;
8
+ loadingProgress: number;
9
+ launcherImageSrc: string;
10
+ unreadIndicator?: React.ReactNode;
11
+ }>;
12
+ export declare function ChatWidgetFrame({ open, onOpenChange, isMobile, fullscreen, hideOpenButton, loadingProgress, launcherImageSrc, unreadIndicator, children, }: ChatWidgetFrameProps): import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -2,9 +2,10 @@ type StreamingMessageTextProps = {
2
2
  stableText: string;
3
3
  incomingText: string;
4
4
  sequence: number;
5
+ initialText?: string;
5
6
  targetText?: string;
6
7
  finished?: boolean;
7
8
  onSettled?: () => void;
8
9
  };
9
- export declare function StreamingMessageText({ stableText, incomingText, targetText, finished, onSettled, }: StreamingMessageTextProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function StreamingMessageText({ stableText, incomingText, initialText, targetText, finished, onSettled, }: StreamingMessageTextProps): import("react/jsx-runtime").JSX.Element;
10
11
  export {};
@@ -1,7 +1,8 @@
1
- export declare const useSmoothStreamingText: (targetText: string) => {
1
+ export declare const useSmoothStreamingText: (targetText: string, initialText: string) => {
2
2
  isSettled: boolean;
3
3
  displayedText: string;
4
4
  stableText: string;
5
5
  animatedText: string;
6
+ animatedFragments: import("@/ui/streaming/smooth-text").SmoothTextFragment[];
6
7
  revision: number;
7
8
  };
@@ -1,7 +1,12 @@
1
+ export type SmoothTextFragment = {
2
+ text: string;
3
+ revision: number;
4
+ };
1
5
  export type SmoothTextFrame = {
2
6
  displayedText: string;
3
7
  stableText: string;
4
8
  animatedText: string;
9
+ animatedFragments: SmoothTextFragment[];
5
10
  revision: number;
6
11
  };
7
12
  export type SmoothTextController = {
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@alxxsck/ai-assistant",
3
3
  "private": false,
4
- "version": "1.8.0",
5
- "description": "Embeddable chat widget for communication with Bridge AI agent",
4
+ "version": "2.2.0",
5
+ "description": "Embeddable Lola AI assistant library",
6
6
  "type": "module",
7
7
  "main": "dist/bridge-ai-chat-widget.es.js",
8
8
  "module": "dist/bridge-ai-chat-widget.es.js",
9
- "types": "dist/index.types.d.ts",
9
+ "types": "dist/index.d.ts",
10
10
  "exports": {
11
11
  ".": {
12
- "types": "./dist/index.types.d.ts",
12
+ "types": "./dist/index.d.ts",
13
13
  "import": "./dist/bridge-ai-chat-widget.es.js"
14
14
  }
15
15
  },
@@ -28,22 +28,14 @@
28
28
  "last 2 versions"
29
29
  ],
30
30
  "scripts": {
31
- "dev": "vite",
32
31
  "lint": "eslint .",
33
32
  "lint-fix": "eslint . --fix",
34
33
  "format": "prettier --write .",
35
34
  "format:check": "prettier --check .",
36
35
  "test": "vitest run",
37
- "deploy-g-spot-prod": "npm run build-dev && npm run clean-g-spot-prod-bucket && npm run upload-g-spot-prod-bucket",
38
- "deploy-bridge-demo": "npm run build-dev && npm run clean-bridge-demo-bucket && npm run upload-bridge-demo-bucket",
39
- "build-dev": "vite build",
36
+ "typecheck": "tsc -p tsconfig.typecheck.json --noEmit",
40
37
  "build-lib": "vite build --config vite.config.lib.ts && tsc -p tsconfig.build.json",
41
- "preview": "vite preview",
42
38
  "prepublishOnly": "npm run build-lib",
43
- "clean-g-spot-prod-bucket": "aws s3 rm s3://bridgeapp-ai-chat-widget-dev.com --recursive",
44
- "upload-g-spot-prod-bucket": "aws s3 cp dist-demo s3://bridgeapp-ai-chat-widget-dev.com/g-spot-prod --recursive",
45
- "clean-bridge-demo-bucket": "aws s3 rm s3://bridge-ai-assistant --recursive",
46
- "upload-bridge-demo-bucket": "aws s3 cp dist-demo s3://bridge-ai-assistant/bridge-demo --recursive",
47
39
  "push-assets-metamediastatic": "bash scripts/push-assets-to-metamediastatic.sh"
48
40
  },
49
41
  "dependencies": {
@@ -55,19 +47,15 @@
55
47
  "clsx": "^2.1.1",
56
48
  "gsap": "^3.14.2",
57
49
  "howler": "^2.2.4",
58
- "lil-gui": "^0.21.0",
59
50
  "lodash-es": "^4.17.23",
60
51
  "lucide-react": "^0.562.0",
52
+ "markdown-it": "^14.3.0",
61
53
  "react-error-boundary": "^6.1.1",
62
54
  "react-router-dom": "^7.13.1",
63
- "react-use": "^17.6.0",
64
55
  "socket.io-client": "^4.8.3",
65
56
  "tailwind-merge": "^3.4.0",
66
57
  "three": "^0.182.0",
67
- "vite-plugin-lib-inject-css": "^2.2.2",
68
- "vite-plugin-mkcert": "^2.0.0",
69
58
  "vite-plugin-svgr": "^4.5.0",
70
- "zukeeper": "^1.0.2",
71
59
  "zustand": "^5.0.10"
72
60
  },
73
61
  "devDependencies": {
@@ -75,6 +63,7 @@
75
63
  "@tailwindcss/postcss": "^4.1.18",
76
64
  "@tailwindcss/vite": "^4.1.18",
77
65
  "@types/howler": "^2.2.12",
66
+ "@types/markdown-it": "^14.1.2",
78
67
  "@types/node": "^24.10.4",
79
68
  "@types/react": "^19.2.5",
80
69
  "@types/react-dom": "^19.2.3",
@@ -91,13 +80,11 @@
91
80
  "prettier-plugin-tailwindcss": "^0.7.2",
92
81
  "react": "^19.2.5",
93
82
  "react-dom": "^19.2.5",
94
- "rollup-plugin-visualizer": "^7.0.1",
95
83
  "tailwindcss": "^4.1.18",
96
84
  "tw-animate-css": "^1.4.0",
97
85
  "typescript": "~5.9.3",
98
86
  "typescript-eslint": "^8.46.4",
99
87
  "vite": "^7.2.4",
100
- "vite-plugin-static-copy": "^3.2.0",
101
88
  "vitest": "^4.1.10"
102
89
  }
103
90
  }