@convai/web-sdk 1.8.0-beta.3 → 1.8.0-beta.5

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 (102) hide show
  1. package/README.md +37 -1
  2. package/dist/core/AudioManager.d.ts +3 -3
  3. package/dist/core/AudioManager.js +1 -1
  4. package/dist/core/CharacterVersionManager.d.ts +100 -0
  5. package/dist/core/CharacterVersionManager.d.ts.map +1 -0
  6. package/dist/core/CharacterVersionManager.js +227 -0
  7. package/dist/core/CharacterVersionManager.js.map +1 -0
  8. package/dist/core/ConnectionStateHandler.d.ts +1 -1
  9. package/dist/core/ConvaiClient.d.ts +19 -4
  10. package/dist/core/ConvaiClient.d.ts.map +1 -1
  11. package/dist/core/ConvaiClient.js +74 -17
  12. package/dist/core/ConvaiClient.js.map +1 -1
  13. package/dist/core/MemoryManager.d.ts +1 -1
  14. package/dist/core/MessageHandler.d.ts +3 -3
  15. package/dist/core/MessageHandler.js +2 -2
  16. package/dist/core/SSESession.d.ts +1 -1
  17. package/dist/core/SSESession.js +1 -1
  18. package/dist/core/ScreenShareManager.d.ts +2 -2
  19. package/dist/core/ScreenShareManager.js +2 -2
  20. package/dist/core/VideoManager.d.ts +2 -2
  21. package/dist/core/VideoManager.js +3 -3
  22. package/dist/core/characterReference.d.ts +40 -0
  23. package/dist/core/characterReference.d.ts.map +1 -0
  24. package/dist/core/characterReference.js +72 -0
  25. package/dist/core/characterReference.js.map +1 -0
  26. package/dist/core/connectRequest.d.ts +1 -1
  27. package/dist/core/contextUpdateRequest.d.ts +1 -1
  28. package/dist/core/index.d.ts +14 -12
  29. package/dist/core/index.d.ts.map +1 -1
  30. package/dist/core/index.js +13 -10
  31. package/dist/core/index.js.map +1 -1
  32. package/dist/core/types.d.ts +257 -4
  33. package/dist/core/types.d.ts.map +1 -1
  34. package/dist/core/types.js.map +1 -1
  35. package/dist/core/videoSourceState.d.ts +1 -1
  36. package/dist/core/visionRequest.d.ts +1 -1
  37. package/dist/index.d.ts +2 -2
  38. package/dist/index.js +2 -2
  39. package/dist/lipsync-helpers/createBlendshapeQueue.d.ts +2 -2
  40. package/dist/lipsync-helpers/createBlendshapeQueue.js +2 -2
  41. package/dist/lipsync-helpers/declarativeMapping.d.ts +1 -1
  42. package/dist/lipsync-helpers/declarativeMapping.js +2 -2
  43. package/dist/lipsync-helpers/index.d.ts +12 -12
  44. package/dist/lipsync-helpers/index.js +9 -9
  45. package/dist/lipsync-helpers/mhaLimitDrivers.js +2 -2
  46. package/dist/lipsync-helpers/naturalness/processor.d.ts +1 -1
  47. package/dist/lipsync-helpers/naturalness/processor.js +1 -1
  48. package/dist/lipsync-helpers/naturalness/profiles/mha.d.ts +1 -1
  49. package/dist/lipsync-helpers/naturalness/profiles/mha.js +1 -1
  50. package/dist/lipsync-helpers/presetMappers.d.ts +1 -1
  51. package/dist/react/components/ConvaiWidget.d.ts +1 -1
  52. package/dist/react/components/ConvaiWidget.js +4 -4
  53. package/dist/react/components/index.d.ts +1 -1
  54. package/dist/react/components/index.js +1 -1
  55. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts +1 -1
  56. package/dist/react/components/rtc-widget/components/ConviMessage.js +3 -3
  57. package/dist/react/components/rtc-widget/components/FloatingVideo.js +3 -3
  58. package/dist/react/components/rtc-widget/components/MessageBubble.js +1 -1
  59. package/dist/react/components/rtc-widget/components/MessageList.d.ts +1 -1
  60. package/dist/react/components/rtc-widget/components/MessageList.js +4 -4
  61. package/dist/react/components/rtc-widget/components/UserMessage.js +3 -3
  62. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js +4 -4
  63. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js +3 -3
  64. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js +4 -4
  65. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js +3 -3
  66. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js +3 -3
  67. package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts +5 -5
  68. package/dist/react/components/rtc-widget/components/conviComponents/index.js +5 -5
  69. package/dist/react/components/rtc-widget/components/index.d.ts +8 -8
  70. package/dist/react/components/rtc-widget/components/index.js +9 -9
  71. package/dist/react/components/rtc-widget/index.d.ts +5 -5
  72. package/dist/react/components/rtc-widget/index.js +3 -3
  73. package/dist/react/components/rtc-widget/styles/icons.d.ts +1 -1
  74. package/dist/react/components/rtc-widget/styles/icons.js +1 -1
  75. package/dist/react/components/rtc-widget/styles/index.d.ts +5 -5
  76. package/dist/react/components/rtc-widget/styles/index.js +4 -4
  77. package/dist/react/components/rtc-widget/styles/styledComponents.js +1 -1
  78. package/dist/react/hooks/index.d.ts +3 -3
  79. package/dist/react/hooks/index.js +3 -3
  80. package/dist/react/hooks/useCharacterInfo.js +1 -1
  81. package/dist/react/hooks/useConvaiClient.d.ts +1 -1
  82. package/dist/react/hooks/useConvaiClient.d.ts.map +1 -1
  83. package/dist/react/hooks/useConvaiClient.js +8 -3
  84. package/dist/react/hooks/useConvaiClient.js.map +1 -1
  85. package/dist/react/index.d.ts +6 -6
  86. package/dist/react/index.js +6 -6
  87. package/dist/vanilla/AudioRenderer.js +1 -1
  88. package/dist/vanilla/ConvaiWidget.d.ts +1 -1
  89. package/dist/vanilla/ConvaiWidget.js +4 -4
  90. package/dist/vanilla/WebSocketSession.d.ts +1 -1
  91. package/dist/vanilla/WebSocketSession.js +1 -1
  92. package/dist/vanilla/index.d.ts +6 -5
  93. package/dist/vanilla/index.d.ts.map +1 -1
  94. package/dist/vanilla/index.js +5 -4
  95. package/dist/vanilla/index.js.map +1 -1
  96. package/dist/vanilla/types.d.ts +1 -1
  97. package/dist/vanilla/websocket.d.ts +1 -1
  98. package/dist/vanilla/websocket.js +2 -2
  99. package/dist/version.d.ts +1 -1
  100. package/dist/version.js +1 -1
  101. package/dist/version.js.map +1 -1
  102. package/package.json +5 -4
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { ConvaiLogo } from "../../styles/icons";
3
- import { aeroTheme } from "../../styles/theme";
4
- import { iosTransitions } from "../../styles/framerConfig";
5
- import { ButtonContent, Logo } from "../../styles/styledComponents";
2
+ import { ConvaiLogo } from "../../styles/icons.js";
3
+ import { aeroTheme } from "../../styles/theme.js";
4
+ import { iosTransitions } from "../../styles/framerConfig.js";
5
+ import { ButtonContent, Logo } from "../../styles/styledComponents.js";
6
6
  export const ConviButton = ({ isOpen }) => {
7
7
  return (_jsx(ButtonContent, { animate: {
8
8
  opacity: isOpen ? 0 : 1,
@@ -2,9 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { AnimatePresence, motion } from "framer-motion";
3
3
  import { FiSend, FiMic } from "react-icons/fi";
4
4
  import { PiWaveform } from "react-icons/pi";
5
- import { aeroTheme } from "../../styles/theme";
6
- import { iosTransitions } from "../../styles/framerConfig";
7
- import { Footer, InputContainer, Input, ActionButton, } from "../../styles/styledComponents";
5
+ import { aeroTheme } from "../../styles/theme.js";
6
+ import { iosTransitions } from "../../styles/framerConfig.js";
7
+ import { Footer, InputContainer, Input, ActionButton, } from "../../styles/styledComponents.js";
8
8
  export const ConviFooter = ({ inputMode, inputValue, liveUserText, chatbotMic, localIsTyping, convaiIsTyping, isCreatingSpeaker, isPressingMic, isSettingsOpen, isVoiceMode, onInputChange, onKeyPress, onSend, onMicPress, onMicRelease, setIsPressingMic, onToggleVoiceMode, verbosityChanged = false, onContinue, }) => {
9
9
  // Show Continue button in verbosity mode
10
10
  if (inputMode === "verbosity") {
@@ -2,10 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { motion } from "framer-motion";
3
3
  import { FiMoreVertical } from "react-icons/fi";
4
4
  import { IoVolumeMute, IoVolumeHigh } from "react-icons/io5";
5
- import { ChevronDown } from "../../styles/icons";
6
- import { aeroTheme } from "../../styles/theme";
7
- import { iosTransitions } from "../../styles/framerConfig";
8
- import { Header, Title, CloseButton, SettingsButton, } from "../../styles/styledComponents";
5
+ import { ChevronDown } from "../../styles/icons.js";
6
+ import { aeroTheme } from "../../styles/theme.js";
7
+ import { iosTransitions } from "../../styles/framerConfig.js";
8
+ import { Header, Title, CloseButton, SettingsButton, } from "../../styles/styledComponents.js";
9
9
  export const ConviHeader = ({ isOpen, isSpeakerEditMode, isVoiceMode, isVerbosityMode, isMuted, characterImage, characterName = "Character", onClose, onSettingsToggle, onToggleMute, settingsButtonRef, }) => {
10
10
  return (_jsxs(Header, { initial: { opacity: 0, y: -20 }, animate: {
11
11
  opacity: isOpen ? 1 : 0,
@@ -3,9 +3,9 @@ import { AnimatePresence } from "framer-motion";
3
3
  import { LiaRedoAltSolid } from "react-icons/lia";
4
4
  import { IoVideocam, IoVideocamOff } from "react-icons/io5";
5
5
  import { MdScreenShare, MdStopScreenShare } from "react-icons/md";
6
- import { aeroTheme } from "../../styles/theme";
7
- import { iosTransitions } from "../../styles/framerConfig";
8
- import { SettingsTray as StyledSettingsTray, SettingsOption, } from "../../styles/styledComponents";
6
+ import { aeroTheme } from "../../styles/theme.js";
7
+ import { iosTransitions } from "../../styles/framerConfig.js";
8
+ import { SettingsTray as StyledSettingsTray, SettingsOption, } from "../../styles/styledComponents.js";
9
9
  export const SettingsTray = ({ isOpen, isVideoVisible, isScreenShareActive, onReset, onDisconnect, onToggleVideo, onToggleScreenShare, }) => {
10
10
  if (!isOpen)
11
11
  return null;
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useRef, useState } from "react";
3
3
  import { motion, AnimatePresence } from "framer-motion";
4
- import { aeroTheme } from "../../styles/theme";
5
- import { iosTransitions } from "../../styles/framerConfig";
6
- import { AudioVisualizer } from "../AudioVisualizer";
4
+ import { aeroTheme } from "../../styles/theme.js";
5
+ import { iosTransitions } from "../../styles/framerConfig.js";
6
+ import { AudioVisualizer } from "../AudioVisualizer.js";
7
7
  export const VoiceModeOverlay = ({ isActive, isTalking, isListening = false, convaiClient, characterImage, characterName = "Character", room, }) => {
8
8
  const barsCount = 40; // Number of bars for user microphone waveform
9
9
  // PERF: the waveform is driven OUTSIDE React. A setState per animation
@@ -1,6 +1,6 @@
1
- export { ConviButton } from "./ConviButton";
2
- export { ConviHeader } from "./ConviHeader";
3
- export { ConviFooter } from "./ConviFooter";
4
- export { SettingsTray } from "./SettingsTray";
5
- export { VoiceModeOverlay } from "./VoiceModeOverlay";
1
+ export { ConviButton } from "./ConviButton.js";
2
+ export { ConviHeader } from "./ConviHeader.js";
3
+ export { ConviFooter } from "./ConviFooter.js";
4
+ export { SettingsTray } from "./SettingsTray.js";
5
+ export { VoiceModeOverlay } from "./VoiceModeOverlay.js";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
- export { ConviButton } from "./ConviButton";
2
- export { ConviHeader } from "./ConviHeader";
3
- export { ConviFooter } from "./ConviFooter";
4
- export { SettingsTray } from "./SettingsTray";
5
- export { VoiceModeOverlay } from "./VoiceModeOverlay";
1
+ export { ConviButton } from "./ConviButton.js";
2
+ export { ConviHeader } from "./ConviHeader.js";
3
+ export { ConviFooter } from "./ConviFooter.js";
4
+ export { SettingsTray } from "./SettingsTray.js";
5
+ export { VoiceModeOverlay } from "./VoiceModeOverlay.js";
6
6
  //# sourceMappingURL=index.js.map
@@ -1,9 +1,9 @@
1
- export { MessageBubble } from "./MessageBubble";
2
- export { MessageList } from "./MessageList";
3
- export { UserMessage } from "./UserMessage";
4
- export { ConviMessage } from "./ConviMessage";
5
- export { MarkdownRenderer } from "./MarkdownRenderer";
6
- export { FloatingVideo } from "./FloatingVideo";
7
- export { AudioVisualizer } from "./AudioVisualizer";
8
- export { ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./conviComponents";
1
+ export { MessageBubble } from "./MessageBubble.js";
2
+ export { MessageList } from "./MessageList.js";
3
+ export { UserMessage } from "./UserMessage.js";
4
+ export { ConviMessage } from "./ConviMessage.js";
5
+ export { MarkdownRenderer } from "./MarkdownRenderer.js";
6
+ export { FloatingVideo } from "./FloatingVideo.js";
7
+ export { AudioVisualizer } from "./AudioVisualizer.js";
8
+ export { ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./conviComponents/index.js";
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1,15 +1,15 @@
1
1
  // Export message components
2
- export { MessageBubble } from "./MessageBubble";
3
- export { MessageList } from "./MessageList";
4
- export { UserMessage } from "./UserMessage";
5
- export { ConviMessage } from "./ConviMessage";
6
- export { MarkdownRenderer } from "./MarkdownRenderer";
2
+ export { MessageBubble } from "./MessageBubble.js";
3
+ export { MessageList } from "./MessageList.js";
4
+ export { UserMessage } from "./UserMessage.js";
5
+ export { ConviMessage } from "./ConviMessage.js";
6
+ export { MarkdownRenderer } from "./MarkdownRenderer.js";
7
7
  // Export floating video component
8
- export { FloatingVideo } from "./FloatingVideo";
8
+ export { FloatingVideo } from "./FloatingVideo.js";
9
9
  // Export audio visualizer
10
- export { AudioVisualizer } from "./AudioVisualizer";
10
+ export { AudioVisualizer } from "./AudioVisualizer.js";
11
11
  // Note: AudioSettingsPanel is internal only - audio settings are fixed
12
- // export { AudioSettingsPanel } from "./AudioSettingsPanel";
12
+ // export { AudioSettingsPanel } from "./AudioSettingsPanel.js";
13
13
  // Export convi sub-components
14
- export { ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./conviComponents";
14
+ export { ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./conviComponents/index.js";
15
15
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
- export { MessageBubble, MessageList, UserMessage, ConviMessage, FloatingVideo, ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./components";
2
- export { aeroTheme, glassStyles, iconSizes, variants, iosTransitions, animationVariants, ConvaiLogo, ChevronDown, } from "./styles";
3
- export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, Content, Footer, InputContainer, Input, ActionButton, } from "./styles";
4
- export type { RTCChatMessage, CharacterVerbosityConfig, ConviUIProps, } from "./types";
5
- export type { LogoState } from "./styles";
1
+ export { MessageBubble, MessageList, UserMessage, ConviMessage, FloatingVideo, ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./components/index.js";
2
+ export { aeroTheme, glassStyles, iconSizes, variants, iosTransitions, animationVariants, ConvaiLogo, ChevronDown, } from "./styles/index.js";
3
+ export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, Content, Footer, InputContainer, Input, ActionButton, } from "./styles/index.js";
4
+ export type { RTCChatMessage, CharacterVerbosityConfig, ConviUIProps, } from "./types/index.js";
5
+ export type { LogoState } from "./styles/index.js";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,9 +1,9 @@
1
1
  // Export all components
2
2
  export { MessageBubble, MessageList, UserMessage, ConviMessage, FloatingVideo,
3
3
  // AudioSettingsPanel, // Internal only - audio settings are fixed
4
- ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./components";
4
+ ConviButton, ConviHeader, ConviFooter, SettingsTray, VoiceModeOverlay, } from "./components/index.js";
5
5
  // Export styles and theme
6
- export { aeroTheme, glassStyles, iconSizes, variants, iosTransitions, animationVariants, ConvaiLogo, ChevronDown, } from "./styles";
6
+ export { aeroTheme, glassStyles, iconSizes, variants, iosTransitions, animationVariants, ConvaiLogo, ChevronDown, } from "./styles/index.js";
7
7
  // Export styled components for custom layouts
8
- export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, Content, Footer, InputContainer, Input, ActionButton, } from "./styles";
8
+ export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, Content, Footer, InputContainer, Input, ActionButton, } from "./styles/index.js";
9
9
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { iconSizes } from "./theme";
1
+ import { iconSizes } from "./theme.js";
2
2
  export type LogoState = "idle" | "connecting" | "connected" | "disconnected" | "typing" | "listening" | "processing";
3
3
  export declare const AeroIcons: {
4
4
  ChevronDown: ({ size, color, }: {
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from "react";
3
3
  import { motion } from "framer-motion";
4
4
  import styled from "styled-components";
5
- import { aeroTheme, iconSizes } from "./theme";
5
+ import { aeroTheme, iconSizes } from "./theme.js";
6
6
  const LogoSVG = styled(motion.svg) `
7
7
  width: ${(props) => props.$size || "100%"};
8
8
  height: ${(props) => props.$size || "100%"};
@@ -1,6 +1,6 @@
1
- export { aeroTheme, glassStyles, iconSizes, variants } from "./theme";
2
- export { iosTransitions, animationVariants } from "./framerConfig";
3
- export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, SettingsTray, SettingsOption, Content, Footer, InputContainer, Input, ActionButton, MessageList, Message, MessageBubble, MessageTime, ButtonContainer, ButtonLogo, ConviBubble, ConviMessageContainer, MessageHeader, ConviLabel, LogoWrapper, UserBubble, UserMessageContainer, UserLabel, BubbleContainer, Bubble, Timestamp, MessageListContainer, MessageWrapper, EmptyState, } from "./styledComponents";
4
- export { ConvaiLogo, ChevronDown, AeroIcons, IconButton } from "./icons";
5
- export type { LogoState } from "./icons";
1
+ export { aeroTheme, glassStyles, iconSizes, variants } from "./theme.js";
2
+ export { iosTransitions, animationVariants } from "./framerConfig.js";
3
+ export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, SettingsTray, SettingsOption, Content, Footer, InputContainer, Input, ActionButton, MessageList, Message, MessageBubble, MessageTime, ButtonContainer, ButtonLogo, ConviBubble, ConviMessageContainer, MessageHeader, ConviLabel, LogoWrapper, UserBubble, UserMessageContainer, UserLabel, BubbleContainer, Bubble, Timestamp, MessageListContainer, MessageWrapper, EmptyState, } from "./styledComponents.js";
4
+ export { ConvaiLogo, ChevronDown, AeroIcons, IconButton } from "./icons.js";
5
+ export type { LogoState } from "./icons.js";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,9 +1,9 @@
1
1
  // Export theme
2
- export { aeroTheme, glassStyles, iconSizes, variants } from "./theme";
2
+ export { aeroTheme, glassStyles, iconSizes, variants } from "./theme.js";
3
3
  // Export framer configs
4
- export { iosTransitions, animationVariants } from "./framerConfig";
4
+ export { iosTransitions, animationVariants } from "./framerConfig.js";
5
5
  // Export styled components
6
- export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, SettingsTray, SettingsOption, Content, Footer, InputContainer, Input, ActionButton, MessageList, Message, MessageBubble, MessageTime, ButtonContainer, ButtonLogo, ConviBubble, ConviMessageContainer, MessageHeader, ConviLabel, LogoWrapper, UserBubble, UserMessageContainer, UserLabel, BubbleContainer, Bubble, Timestamp, MessageListContainer, MessageWrapper, EmptyState, } from "./styledComponents";
6
+ export { ConvaiContainer, MorphingContainer, ButtonContent, Logo, ChatContent, Header, Title, HeaderLogo, CloseButton, SettingsButton, SettingsTray, SettingsOption, Content, Footer, InputContainer, Input, ActionButton, MessageList, Message, MessageBubble, MessageTime, ButtonContainer, ButtonLogo, ConviBubble, ConviMessageContainer, MessageHeader, ConviLabel, LogoWrapper, UserBubble, UserMessageContainer, UserLabel, BubbleContainer, Bubble, Timestamp, MessageListContainer, MessageWrapper, EmptyState, } from "./styledComponents.js";
7
7
  // Export icons
8
- export { ConvaiLogo, ChevronDown, AeroIcons, IconButton } from "./icons";
8
+ export { ConvaiLogo, ChevronDown, AeroIcons, IconButton } from "./icons.js";
9
9
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  import styled from "styled-components";
2
2
  import { motion } from "framer-motion";
3
- import { aeroTheme } from "./theme";
3
+ import { aeroTheme } from "./theme.js";
4
4
  // Styled Components matching the original webChat exactly
5
5
  export const ConvaiContainer = styled(motion.div) `
6
6
  position: fixed !important;
@@ -1,4 +1,4 @@
1
- export { useConvaiClient } from './useConvaiClient';
2
- export { useCharacterInfo } from './useCharacterInfo';
3
- export { useLocalCameraTrack } from './useLocalCameraTrack';
1
+ export { useConvaiClient } from './useConvaiClient.js';
2
+ export { useCharacterInfo } from './useCharacterInfo.js';
3
+ export { useLocalCameraTrack } from './useLocalCameraTrack.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
1
  // Main hook
2
- export { useConvaiClient } from './useConvaiClient';
2
+ export { useConvaiClient } from './useConvaiClient.js';
3
3
  // Additional hooks
4
- export { useCharacterInfo } from './useCharacterInfo';
5
- export { useLocalCameraTrack } from './useLocalCameraTrack';
4
+ export { useCharacterInfo } from './useCharacterInfo.js';
5
+ export { useLocalCameraTrack } from './useLocalCameraTrack.js';
6
6
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
1
  import { useState, useEffect } from "react";
2
- import { logger } from "../../utils/logger";
2
+ import { logger } from "../../utils/logger.js";
3
3
  /**
4
4
  * Hook to fetch character information from Convai API
5
5
  *
@@ -1,4 +1,4 @@
1
- import type { ConvaiConfig, IConvaiClient, ChatMessage } from "../../core/types";
1
+ import type { ConvaiConfig, IConvaiClient, ChatMessage } from "../../core/types.js";
2
2
  /**
3
3
  * React hook wrapper for ConvaiClient
4
4
  * Main hook for managing Convai client connection and functionality.
@@ -1 +1 @@
1
- {"version":3,"file":"useConvaiClient.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useConvaiClient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,YAAY,KACpB,aAAa,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,mBAAmB,EAAE,OAAO,CAAC;CA2N9B,CAAC"}
1
+ {"version":3,"file":"useConvaiClient.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useConvaiClient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,eAAe,GAC1B,SAAS,YAAY,KACpB,aAAa,GAAG;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,mBAAmB,EAAE,OAAO,CAAC;CAgO9B,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { useState, useEffect, useCallback } from "react";
2
- import { ConvaiClient as CoreConvaiClient } from "../../core";
2
+ import { ConvaiClient as CoreConvaiClient } from "../../core/index.js";
3
3
  /**
4
4
  * React hook wrapper for ConvaiClient
5
5
  * Main hook for managing Convai client connection and functionality.
@@ -27,8 +27,10 @@ import { ConvaiClient as CoreConvaiClient } from "../../core";
27
27
  * ```
28
28
  */
29
29
  export const useConvaiClient = (config) => {
30
- // Create client instance once
31
- const [client] = useState(() => new CoreConvaiClient());
30
+ // Create client instance once. The config is handed to the client as well
31
+ // as kept in the hook, so config-derived surfaces such as
32
+ // `characterVersions` are usable before the first connect().
33
+ const [client] = useState(() => new CoreConvaiClient(config));
32
34
  // React state for UI updates
33
35
  const [state, setState] = useState(client.state);
34
36
  const [activity, setActivity] = useState("Idle");
@@ -166,6 +168,8 @@ export const useConvaiClient = (config) => {
166
168
  ...(client.apiKey && { apiKey: client.apiKey }),
167
169
  ...(client.authToken && { authToken: client.authToken }),
168
170
  characterId: client.characterId,
171
+ characterVersion: client.characterVersion,
172
+ characterReference: client.characterReference,
169
173
  connect,
170
174
  connectWithConnectionData: client.connectWithConnectionData.bind(client),
171
175
  disconnect: client.disconnect.bind(client),
@@ -195,6 +199,7 @@ export const useConvaiClient = (config) => {
195
199
  blendshapeQueue: client.blendshapeQueue,
196
200
  conversationSessionId: client.conversationSessionId,
197
201
  memoryManager: client.memoryManager,
202
+ characterVersions: client.characterVersions,
198
203
  toggleTts: client.toggleTts.bind(client),
199
204
  toggleStt: client.toggleStt.bind(client),
200
205
  uploadFile: client.uploadFile.bind(client),
@@ -1 +1 @@
1
- {"version":3,"file":"useConvaiClient.js","sourceRoot":"","sources":["../../../src/react/hooks/useConvaiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAO9D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,MAAqB,EAOrB,EAAE;IACF,8BAA8B;IAC9B,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,gBAAgB,EAAE,CAAC,CAAC;IAExD,6BAA6B;IAC7B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAS,MAAM,CAAC,CAAC;IACzD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAC9C,MAAM,CAAC,YAAY,CACpB,CAAC;IACF,MAAM,CA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C,IAAI,CAAC,MAAM,CAAC;QAChD,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;QAC9C,aAAa,EAAE,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;QAChD,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC;QACxD,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC;QAC5D,QAAQ;QACR,YAAY;QACZ,iBAAiB;QACjB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;QAC7C,UAAU;QACV,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;QAC/C,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;QACnD,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;QACxC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;QACxC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;QAC1C,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;QAC1B,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;QAC5B,0BAA0B;QAC1B,YAAY;QACZ,cAAc;QACd,mBAAmB;KACpB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useState, useEffect, useCallback } from \"react\";\nimport { ConvaiClient as CoreConvaiClient } from \"../../core\";\nimport type {\n ConvaiConfig,\n IConvaiClient,\n ChatMessage,\n} from \"../../core/types\";\n\n/**\n * React hook wrapper for ConvaiClient\n * Main hook for managing Convai client connection and functionality.\n *\n * Provides a complete interface for connecting to Convai's AI-powered voice assistants,\n * managing real-time audio/video conversations, and handling various message types.\n *\n * @param config - Optional configuration to store for later connection\n * @returns {ConvaiClient & { activity: string; chatMessages: ChatMessage[] }} Complete client interface with connection state, methods, and message history\n *\n * @example\n * ```tsx\n * function App() {\n * const convaiClient = useConvaiClient({\n * apiKey: 'your-api-key',\n * characterId: 'your-character-id',\n * endUserId: 'user-uuid', // Optional: enables memory & analytics\n * enableVideo: true,\n * });\n *\n * return (\n * <ConvaiWidget convaiClient={convaiClient} />\n * );\n * }\n * ```\n */\nexport const useConvaiClient = (\n config?: ConvaiConfig,\n): IConvaiClient & {\n activity: string;\n chatMessages: ChatMessage[];\n isAudioMuted: boolean;\n isVideoEnabled: boolean;\n isScreenShareActive: boolean;\n} => {\n // Create client instance once\n const [client] = useState(() => new CoreConvaiClient());\n\n // React state for UI updates\n const [state, setState] = useState(client.state);\n const [activity, setActivity] = useState<string>(\"Idle\");\n const [chatMessages, setChatMessages] = useState<ChatMessage[]>(\n client.chatMessages,\n );\n const [userTranscription, setUserTranscription] = useState<string>(\n client.userTranscription,\n );\n const [isSpeaking, setIsSpeaking] = useState<boolean>(false);\n const [isBotReady, setIsBotReady] = useState<boolean>(client.isBotReady);\n \n // Reactive states for control managers\n const [isAudioMuted, setIsAudioMuted] = useState<boolean>(\n client.audioControls.isAudioMuted\n );\n const [isVideoEnabled, setIsVideoEnabled] = useState<boolean>(\n client.videoControls.isVideoEnabled\n );\n const [isScreenShareActive, setIsScreenShareActive] = useState<boolean>(\n client.screenShareControls.isScreenShareActive\n );\n\n // Store config if provided\n const [storedConfig] = useState<ConvaiConfig | undefined>(config);\n\n // Setup event listeners\n useEffect(() => {\n // State change listener\n const unsubStateChange = client.on(\"stateChange\", (newState) => {\n setState(newState);\n\n // Update activity based on state (priority: speaking > listening > thinking > connected)\n if (!newState.isConnected) {\n setActivity(\"Disconnected\");\n } else if (newState.isConnecting) {\n setActivity(\"Connecting...\");\n } else if (newState.isSpeaking) {\n setActivity(\"Speaking\");\n } else if (newState.isListening) {\n setActivity(\"Listening\");\n } else if (newState.isThinking) {\n setActivity(\"Thinking\");\n } else {\n setActivity(\"Connected\");\n }\n });\n\n // Messages change listener\n const unsubMessagesChange = client.on(\"messagesChange\", (messages) => {\n setChatMessages([...messages]);\n });\n\n // User transcription change listener\n const unsubUserTranscription = client.on(\n \"userTranscriptionChange\",\n (transcription) => {\n setUserTranscription(transcription);\n },\n );\n\n // Speaking change listener\n const unsubSpeaking = client.on(\"speakingChange\", (speaking) => {\n setIsSpeaking(speaking);\n });\n\n // Bot ready listener\n const unsubBotReady = client.on(\"botReady\", () => {\n setIsBotReady(true);\n setActivity(\"Connected\");\n });\n\n // Connect listener\n const unsubConnect = client.on(\"connect\", () => {\n setState(client.state);\n });\n\n // Disconnect listener\n const unsubDisconnect = client.on(\"disconnect\", () => {\n setIsBotReady(false);\n setState(client.state);\n setActivity(\"Disconnected\");\n setChatMessages([]);\n // Reset control states on disconnect\n setIsAudioMuted(true);\n setIsVideoEnabled(false);\n setIsScreenShareActive(false);\n });\n\n // WebSocket transport: play bot audio track via a hidden <audio> element\n const wsAudioEl = document.createElement(\"audio\");\n wsAudioEl.autoplay = true;\n wsAudioEl.dataset.convaiWs = \"true\";\n document.body.appendChild(wsAudioEl);\n\n const unsubBotAudioTrack = client.on(\n \"botAudioTrack\",\n (track: MediaStreamTrack) => {\n wsAudioEl.srcObject = new MediaStream([track]);\n },\n );\n\n // Disconnect listener also clears WS audio\n const unsubDisconnectWsAudio = client.on(\"disconnect\", () => {\n wsAudioEl.srcObject = null;\n });\n\n // Audio controls state change listener\n const unsubAudioState = client.audioControls.on(\"audioStateChange\", (audioState: any) => {\n if (audioState.isAudioMuted !== undefined) {\n setIsAudioMuted(audioState.isAudioMuted);\n }\n });\n\n // Video controls state change listener\n const unsubVideoState = client.videoControls.on(\"videoStateChange\", (videoState: any) => {\n if (videoState.isVideoEnabled !== undefined) {\n setIsVideoEnabled(videoState.isVideoEnabled);\n }\n });\n\n // Screen share controls state change listener\n const unsubScreenShareState = client.screenShareControls.on(\"screenShareStateChange\", (screenShareState: any) => {\n if (screenShareState.isScreenShareActive !== undefined) {\n setIsScreenShareActive(screenShareState.isScreenShareActive);\n }\n });\n\n // Cleanup listeners on unmount\n return () => {\n unsubStateChange();\n unsubMessagesChange();\n unsubUserTranscription();\n unsubSpeaking();\n unsubBotReady();\n unsubConnect();\n unsubDisconnect();\n unsubBotAudioTrack();\n unsubDisconnectWsAudio();\n unsubAudioState();\n unsubVideoState();\n unsubScreenShareState();\n wsAudioEl.srcObject = null;\n wsAudioEl.remove();\n };\n }, [client]);\n\n // Create enhanced connect function that can use stored config\n const connect = useCallback(\n async (configOverride?: ConvaiConfig) => {\n const finalConfig = configOverride || storedConfig;\n\n if (!finalConfig) {\n throw new Error(\n \"No configuration provided. Pass config to useConvaiClient() or to connect()\",\n );\n }\n\n await client.connect(finalConfig);\n },\n [client, storedConfig],\n );\n\n // Create reconnect function wrapper\n const reconnect = useCallback(async () => {\n await client.reconnect();\n }, [client]);\n\n // Return client interface with React-friendly additions\n return {\n state,\n connectionType: client.connectionType,\n ...(client.apiKey && { apiKey: client.apiKey }),\n ...(client.authToken && { authToken: client.authToken }),\n characterId: client.characterId,\n connect,\n connectWithConnectionData: client.connectWithConnectionData.bind(client),\n disconnect: client.disconnect.bind(client),\n reconnect,\n resetSession: client.resetSession.bind(client),\n room: client.room,\n sendUserTextMessage: client.sendUserTextMessage.bind(client),\n sendTriggerMessage: client.sendTriggerMessage.bind(client),\n sendInterruptMessage: client.sendInterruptMessage.bind(client),\n resetIdleTimer: client.resetIdleTimer.bind(client),\n updateTemplateKeys: client.updateTemplateKeys.bind(client),\n updateDynamicInfo: client.updateDynamicInfo.bind(client),\n updateContext: client.updateContext.bind(client),\n updateEmotion: client.updateEmotion.bind(client),\n visionStatus: client.visionStatus.bind(client),\n visionTrigger: client.visionTrigger.bind(client),\n respondModeUpdate: client.respondModeUpdate.bind(client),\n updateSceneMetadata: client.updateSceneMetadata.bind(client),\n activity,\n chatMessages,\n userTranscription,\n characterSessionId: client.characterSessionId,\n isBotReady,\n audioControls: client.audioControls,\n videoControls: client.videoControls,\n screenShareControls: client.screenShareControls,\n blendshapeQueue: client.blendshapeQueue,\n conversationSessionId: client.conversationSessionId,\n memoryManager: client.memoryManager,\n toggleTts: client.toggleTts.bind(client),\n toggleStt: client.toggleStt.bind(client),\n uploadFile: client.uploadFile.bind(client),\n on: client.on.bind(client),\n off: client.off.bind(client),\n // Reactive control states\n isAudioMuted,\n isVideoEnabled,\n isScreenShareActive,\n };\n};\n"]}
1
+ {"version":3,"file":"useConvaiClient.js","sourceRoot":"","sources":["../../../src/react/hooks/useConvaiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACzD,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAO9D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,MAAqB,EAOrB,EAAE;IACF,0EAA0E;IAC1E,0DAA0D;IAC1D,6DAA6D;IAC7D,MAAM,CAAC,MAAM,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IAE9D,6BAA6B;IAC7B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAS,MAAM,CAAC,CAAC;IACzD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAC9C,MAAM,CAAC,YAAY,CACpB,CAAC;IACF,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,QAAQ,CACxD,MAAM,CAAC,iBAAiB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C,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;QAChD,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;QAC9C,aAAa,EAAE,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC;QAChD,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC;QACxD,mBAAmB,EAAE,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC;QAC5D,QAAQ;QACR,YAAY;QACZ,iBAAiB;QACjB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;QAC7C,UAAU;QACV,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;QAC/C,eAAe,EAAE,MAAM,CAAC,eAAe;QACvC,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;QACnD,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;QAC3C,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;QACxC,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;QACxC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;QAC1C,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;QAC1B,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;QAC5B,0BAA0B;QAC1B,YAAY;QACZ,cAAc;QACd,mBAAmB;KACpB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useState, useEffect, useCallback } from \"react\";\nimport { ConvaiClient as CoreConvaiClient } from \"../../core\";\nimport type {\n ConvaiConfig,\n IConvaiClient,\n ChatMessage,\n} from \"../../core/types\";\n\n/**\n * React hook wrapper for ConvaiClient\n * Main hook for managing Convai client connection and functionality.\n *\n * Provides a complete interface for connecting to Convai's AI-powered voice assistants,\n * managing real-time audio/video conversations, and handling various message types.\n *\n * @param config - Optional configuration to store for later connection\n * @returns {ConvaiClient & { activity: string; chatMessages: ChatMessage[] }} Complete client interface with connection state, methods, and message history\n *\n * @example\n * ```tsx\n * function App() {\n * const convaiClient = useConvaiClient({\n * apiKey: 'your-api-key',\n * characterId: 'your-character-id',\n * endUserId: 'user-uuid', // Optional: enables memory & analytics\n * enableVideo: true,\n * });\n *\n * return (\n * <ConvaiWidget convaiClient={convaiClient} />\n * );\n * }\n * ```\n */\nexport const useConvaiClient = (\n config?: ConvaiConfig,\n): IConvaiClient & {\n activity: string;\n chatMessages: ChatMessage[];\n isAudioMuted: boolean;\n isVideoEnabled: boolean;\n isScreenShareActive: boolean;\n} => {\n // Create client instance once. The config is handed to the client as well\n // as kept in the hook, so config-derived surfaces such as\n // `characterVersions` are usable before the first connect().\n const [client] = useState(() => new CoreConvaiClient(config));\n\n // React state for UI updates\n const [state, setState] = useState(client.state);\n const [activity, setActivity] = useState<string>(\"Idle\");\n const [chatMessages, setChatMessages] = useState<ChatMessage[]>(\n client.chatMessages,\n );\n const [userTranscription, setUserTranscription] = useState<string>(\n client.userTranscription,\n );\n const [isSpeaking, setIsSpeaking] = useState<boolean>(false);\n const [isBotReady, setIsBotReady] = useState<boolean>(client.isBotReady);\n \n // Reactive states for control managers\n const [isAudioMuted, setIsAudioMuted] = useState<boolean>(\n client.audioControls.isAudioMuted\n );\n const [isVideoEnabled, setIsVideoEnabled] = useState<boolean>(\n client.videoControls.isVideoEnabled\n );\n const [isScreenShareActive, setIsScreenShareActive] = useState<boolean>(\n client.screenShareControls.isScreenShareActive\n );\n\n // Store config if provided\n const [storedConfig] = useState<ConvaiConfig | undefined>(config);\n\n // Setup event listeners\n useEffect(() => {\n // State change listener\n const unsubStateChange = client.on(\"stateChange\", (newState) => {\n setState(newState);\n\n // Update activity based on state (priority: speaking > listening > thinking > connected)\n if (!newState.isConnected) {\n setActivity(\"Disconnected\");\n } else if (newState.isConnecting) {\n setActivity(\"Connecting...\");\n } else if (newState.isSpeaking) {\n setActivity(\"Speaking\");\n } else if (newState.isListening) {\n setActivity(\"Listening\");\n } else if (newState.isThinking) {\n setActivity(\"Thinking\");\n } else {\n setActivity(\"Connected\");\n }\n });\n\n // Messages change listener\n const unsubMessagesChange = client.on(\"messagesChange\", (messages) => {\n setChatMessages([...messages]);\n });\n\n // User transcription change listener\n const unsubUserTranscription = client.on(\n \"userTranscriptionChange\",\n (transcription) => {\n setUserTranscription(transcription);\n },\n );\n\n // Speaking change listener\n const unsubSpeaking = client.on(\"speakingChange\", (speaking) => {\n setIsSpeaking(speaking);\n });\n\n // Bot ready listener\n const unsubBotReady = client.on(\"botReady\", () => {\n setIsBotReady(true);\n setActivity(\"Connected\");\n });\n\n // Connect listener\n const unsubConnect = client.on(\"connect\", () => {\n setState(client.state);\n });\n\n // Disconnect listener\n const unsubDisconnect = client.on(\"disconnect\", () => {\n setIsBotReady(false);\n setState(client.state);\n setActivity(\"Disconnected\");\n setChatMessages([]);\n // Reset control states on disconnect\n setIsAudioMuted(true);\n setIsVideoEnabled(false);\n setIsScreenShareActive(false);\n });\n\n // WebSocket transport: play bot audio track via a hidden <audio> element\n const wsAudioEl = document.createElement(\"audio\");\n wsAudioEl.autoplay = true;\n wsAudioEl.dataset.convaiWs = \"true\";\n document.body.appendChild(wsAudioEl);\n\n const unsubBotAudioTrack = client.on(\n \"botAudioTrack\",\n (track: MediaStreamTrack) => {\n wsAudioEl.srcObject = new MediaStream([track]);\n },\n );\n\n // Disconnect listener also clears WS audio\n const unsubDisconnectWsAudio = client.on(\"disconnect\", () => {\n wsAudioEl.srcObject = null;\n });\n\n // Audio controls state change listener\n const unsubAudioState = client.audioControls.on(\"audioStateChange\", (audioState: any) => {\n if (audioState.isAudioMuted !== undefined) {\n setIsAudioMuted(audioState.isAudioMuted);\n }\n });\n\n // Video controls state change listener\n const unsubVideoState = client.videoControls.on(\"videoStateChange\", (videoState: any) => {\n if (videoState.isVideoEnabled !== undefined) {\n setIsVideoEnabled(videoState.isVideoEnabled);\n }\n });\n\n // Screen share controls state change listener\n const unsubScreenShareState = client.screenShareControls.on(\"screenShareStateChange\", (screenShareState: any) => {\n if (screenShareState.isScreenShareActive !== undefined) {\n setIsScreenShareActive(screenShareState.isScreenShareActive);\n }\n });\n\n // Cleanup listeners on unmount\n return () => {\n unsubStateChange();\n unsubMessagesChange();\n unsubUserTranscription();\n unsubSpeaking();\n unsubBotReady();\n unsubConnect();\n unsubDisconnect();\n unsubBotAudioTrack();\n unsubDisconnectWsAudio();\n unsubAudioState();\n unsubVideoState();\n unsubScreenShareState();\n wsAudioEl.srcObject = null;\n wsAudioEl.remove();\n };\n }, [client]);\n\n // Create enhanced connect function that can use stored config\n const connect = useCallback(\n async (configOverride?: ConvaiConfig) => {\n const finalConfig = configOverride || storedConfig;\n\n if (!finalConfig) {\n throw new Error(\n \"No configuration provided. Pass config to useConvaiClient() or to connect()\",\n );\n }\n\n await client.connect(finalConfig);\n },\n [client, storedConfig],\n );\n\n // Create reconnect function wrapper\n const reconnect = useCallback(async () => {\n await client.reconnect();\n }, [client]);\n\n // Return client interface with React-friendly additions\n return {\n state,\n connectionType: client.connectionType,\n ...(client.apiKey && { apiKey: client.apiKey }),\n ...(client.authToken && { authToken: client.authToken }),\n characterId: client.characterId,\n characterVersion: client.characterVersion,\n characterReference: client.characterReference,\n connect,\n connectWithConnectionData: client.connectWithConnectionData.bind(client),\n disconnect: client.disconnect.bind(client),\n reconnect,\n resetSession: client.resetSession.bind(client),\n room: client.room,\n sendUserTextMessage: client.sendUserTextMessage.bind(client),\n sendTriggerMessage: client.sendTriggerMessage.bind(client),\n sendInterruptMessage: client.sendInterruptMessage.bind(client),\n resetIdleTimer: client.resetIdleTimer.bind(client),\n updateTemplateKeys: client.updateTemplateKeys.bind(client),\n updateDynamicInfo: client.updateDynamicInfo.bind(client),\n updateContext: client.updateContext.bind(client),\n updateEmotion: client.updateEmotion.bind(client),\n visionStatus: client.visionStatus.bind(client),\n visionTrigger: client.visionTrigger.bind(client),\n respondModeUpdate: client.respondModeUpdate.bind(client),\n updateSceneMetadata: client.updateSceneMetadata.bind(client),\n activity,\n chatMessages,\n userTranscription,\n characterSessionId: client.characterSessionId,\n isBotReady,\n audioControls: client.audioControls,\n videoControls: client.videoControls,\n screenShareControls: client.screenShareControls,\n blendshapeQueue: client.blendshapeQueue,\n conversationSessionId: client.conversationSessionId,\n memoryManager: client.memoryManager,\n characterVersions: client.characterVersions,\n toggleTts: client.toggleTts.bind(client),\n toggleStt: client.toggleStt.bind(client),\n uploadFile: client.uploadFile.bind(client),\n on: client.on.bind(client),\n off: client.off.bind(client),\n // Reactive control states\n isAudioMuted,\n isVideoEnabled,\n isScreenShareActive,\n };\n};\n"]}
@@ -1,8 +1,8 @@
1
- export { useConvaiClient } from './hooks/useConvaiClient';
2
- export { ConvaiWidget } from './components/ConvaiWidget';
3
- export * from './hooks';
4
- export * from '../core/types';
5
- export { getDisconnectReasonMessage } from '../core/types';
6
- export { ConvaiClient } from '../core';
1
+ export { useConvaiClient } from './hooks/useConvaiClient.js';
2
+ export { ConvaiWidget } from './components/ConvaiWidget.js';
3
+ export * from './hooks/index.js';
4
+ export * from '../core/types.js';
5
+ export { getDisconnectReasonMessage } from '../core/types.js';
6
+ export { ConvaiClient } from '../core/index.js';
7
7
  export { RoomAudioRenderer as AudioRenderer, RoomContext as AudioContext } from '@livekit/components-react';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1,15 +1,15 @@
1
1
  // Main hook (backward compatible)
2
- export { useConvaiClient } from './hooks/useConvaiClient';
2
+ export { useConvaiClient } from './hooks/useConvaiClient.js';
3
3
  // Components
4
- export { ConvaiWidget } from './components/ConvaiWidget';
4
+ export { ConvaiWidget } from './components/ConvaiWidget.js';
5
5
  // Additional hooks (for advanced usage)
6
- export * from './hooks';
6
+ export * from './hooks/index.js';
7
7
  // Re-export core types for convenience
8
- export * from '../core/types';
8
+ export * from '../core/types.js';
9
9
  // Re-export helper functions explicitly
10
- export { getDisconnectReasonMessage } from '../core/types';
10
+ export { getDisconnectReasonMessage } from '../core/types.js';
11
11
  // Re-export core client for advanced usage
12
- export { ConvaiClient } from '../core';
12
+ export { ConvaiClient } from '../core/index.js';
13
13
  // Re-export LiveKit components for convenience (backward compatible)
14
14
  export { RoomAudioRenderer as AudioRenderer, RoomContext as AudioContext } from '@livekit/components-react';
15
15
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
1
  import { RoomEvent } from 'livekit-client';
2
- import { logger } from '../utils/logger';
2
+ import { logger } from '../utils/logger.js';
3
3
  /**
4
4
  * AudioRenderer - Manages audio playback for remote participants
5
5
  * Automatically creates and attaches audio elements for remote audio tracks
@@ -2,7 +2,7 @@
2
2
  * Vanilla ConvaiWidget - Complete UI widget for Convai conversations
3
3
  * Ports the React ConvaiWidget to vanilla TypeScript with DOM manipulation
4
4
  */
5
- import type { VanillaWidgetOptions, VanillaWidget } from "./types";
5
+ import type { VanillaWidgetOptions, VanillaWidget } from "./types.js";
6
6
  /**
7
7
  * Create a Convai chat widget in the specified container
8
8
  *
@@ -2,10 +2,10 @@
2
2
  * Vanilla ConvaiWidget - Complete UI widget for Convai conversations
3
3
  * Ports the React ConvaiWidget to vanilla TypeScript with DOM manipulation
4
4
  */
5
- import { AudioRenderer } from "./AudioRenderer";
6
- import { aeroTheme, injectGlobalStyles, injectKeyframes, } from "./styles";
7
- import { Icons } from "./icons";
8
- import { ConvaiClient } from "../core/ConvaiClient";
5
+ import { AudioRenderer } from "./AudioRenderer.js";
6
+ import { aeroTheme, injectGlobalStyles, injectKeyframes, } from "./styles.js";
7
+ import { Icons } from "./icons.js";
8
+ import { ConvaiClient } from "../core/ConvaiClient.js";
9
9
  /**
10
10
  * Positioning declarations for the widget root, keyed by `placement`. The
11
11
  * `bottom-right` entry must stay byte-identical to the literals it replaces --
@@ -1,4 +1,4 @@
1
- import { EventEmitter } from "../core/EventEmitter";
1
+ import { EventEmitter } from "../core/EventEmitter.js";
2
2
  /**
3
3
  * Adapter that wraps PipecatClient + WebSocketTransport for use in ConvaiClient.
4
4
  *
@@ -1,6 +1,6 @@
1
1
  import { PipecatClient, RTVIEvent } from "@pipecat-ai/client-js";
2
2
  import { WebSocketTransport } from "@pipecat-ai/websocket-transport";
3
- import { EventEmitter } from "../core/EventEmitter";
3
+ import { EventEmitter } from "../core/EventEmitter.js";
4
4
  /**
5
5
  * Adapter that wraps PipecatClient + WebSocketTransport for use in ConvaiClient.
6
6
  *
@@ -28,9 +28,10 @@
28
28
  * // - client.audioControls, videoControls, etc.
29
29
  * ```
30
30
  */
31
- export { ConvaiClient } from '../core/ConvaiClient';
32
- export { AudioRenderer } from './AudioRenderer';
33
- export { createConvaiWidget, destroyConvaiWidget } from './ConvaiWidget';
34
- export * from '../core/types';
35
- export type { VanillaWidget, VanillaWidgetOptions, WidgetPlacement, } from './types';
31
+ export { ConvaiClient } from '../core/ConvaiClient.js';
32
+ export { CharacterVersionManager, CharacterApiError } from '../core/CharacterVersionManager.js';
33
+ export { AudioRenderer } from './AudioRenderer.js';
34
+ export { createConvaiWidget, destroyConvaiWidget } from './ConvaiWidget.js';
35
+ export * from '../core/types.js';
36
+ export type { VanillaWidget, VanillaWidgetOptions, WidgetPlacement, } from './types.js';
36
37
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vanilla/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGzE,cAAc,eAAe,CAAC;AAG9B,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,eAAe,GAChB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vanilla/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAG7F,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGzE,cAAc,eAAe,CAAC;AAG9B,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,eAAe,GAChB,MAAM,SAAS,CAAC"}
@@ -29,11 +29,12 @@
29
29
  * ```
30
30
  */
31
31
  // Main client for managing connections
32
- export { ConvaiClient } from '../core/ConvaiClient';
32
+ export { ConvaiClient } from '../core/ConvaiClient.js';
33
+ export { CharacterVersionManager, CharacterApiError } from '../core/CharacterVersionManager.js';
33
34
  // AudioRenderer for custom UI builders (handles audio playback)
34
- export { AudioRenderer } from './AudioRenderer';
35
+ export { AudioRenderer } from './AudioRenderer.js';
35
36
  // Vanilla widget - complete UI solution
36
- export { createConvaiWidget, destroyConvaiWidget } from './ConvaiWidget';
37
+ export { createConvaiWidget, destroyConvaiWidget } from './ConvaiWidget.js';
37
38
  // Re-export ALL core types for complete parity with React
38
- export * from '../core/types';
39
+ export * from '../core/types.js';
39
40
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vanilla/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,gEAAgE;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,wCAAwC;AACxC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,0DAA0D;AAC1D,cAAc,eAAe,CAAC","sourcesContent":["/**\n * Convai Web SDK - Vanilla JavaScript/TypeScript Export\n * \n * This module provides vanilla JS/TS exports for the Convai SDK.\n * Use this for non-React applications.\n * \n * @example\n * ```typescript\n * import { ConvaiClient, createConvaiWidget } from '@convai/web-sdk/vanilla';\n * \n * // Pass config to constructor (same pattern as React's useConvaiClient)\n * const client = new ConvaiClient({\n * apiKey: 'your-api-key',\n * characterId: 'your-character-id',\n * enableVideo: true,\n * });\n * \n * // Create widget - auto-connects on first click\n * const widget = createConvaiWidget(document.body, {\n * convaiClient: client\n * });\n * \n * // Client has all functions for advanced usage:\n * // - client.connect() - manual connection\n * // - client.disconnect() - disconnect\n * // - client.reconnect() - reconnect\n * // - client.sendUserTextMessage() - send messages\n * // - client.audioControls, videoControls, etc.\n * ```\n */\n\n// Main client for managing connections\nexport { ConvaiClient } from '../core/ConvaiClient';\n\n// AudioRenderer for custom UI builders (handles audio playback)\nexport { AudioRenderer } from './AudioRenderer';\n\n// Vanilla widget - complete UI solution\nexport { createConvaiWidget, destroyConvaiWidget } from './ConvaiWidget';\n\n// Re-export ALL core types for complete parity with React\nexport * from '../core/types';\n\n// Widget-specific types\nexport type {\n VanillaWidget,\n VanillaWidgetOptions,\n WidgetPlacement,\n} from './types';\n\n\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vanilla/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAE7F,gEAAgE;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,wCAAwC;AACxC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,0DAA0D;AAC1D,cAAc,eAAe,CAAC","sourcesContent":["/**\n * Convai Web SDK - Vanilla JavaScript/TypeScript Export\n * \n * This module provides vanilla JS/TS exports for the Convai SDK.\n * Use this for non-React applications.\n * \n * @example\n * ```typescript\n * import { ConvaiClient, createConvaiWidget } from '@convai/web-sdk/vanilla';\n * \n * // Pass config to constructor (same pattern as React's useConvaiClient)\n * const client = new ConvaiClient({\n * apiKey: 'your-api-key',\n * characterId: 'your-character-id',\n * enableVideo: true,\n * });\n * \n * // Create widget - auto-connects on first click\n * const widget = createConvaiWidget(document.body, {\n * convaiClient: client\n * });\n * \n * // Client has all functions for advanced usage:\n * // - client.connect() - manual connection\n * // - client.disconnect() - disconnect\n * // - client.reconnect() - reconnect\n * // - client.sendUserTextMessage() - send messages\n * // - client.audioControls, videoControls, etc.\n * ```\n */\n\n// Main client for managing connections\nexport { ConvaiClient } from '../core/ConvaiClient';\nexport { CharacterVersionManager, CharacterApiError } from '../core/CharacterVersionManager';\n\n// AudioRenderer for custom UI builders (handles audio playback)\nexport { AudioRenderer } from './AudioRenderer';\n\n// Vanilla widget - complete UI solution\nexport { createConvaiWidget, destroyConvaiWidget } from './ConvaiWidget';\n\n// Re-export ALL core types for complete parity with React\nexport * from '../core/types';\n\n// Widget-specific types\nexport type {\n VanillaWidget,\n VanillaWidgetOptions,\n WidgetPlacement,\n} from './types';\n\n\n"]}
@@ -1,4 +1,4 @@
1
- import type { IConvaiClient, ChatMessage } from '../core/types';
1
+ import type { IConvaiClient, ChatMessage } from '../core/types.js';
2
2
  /** Where the widget anchors itself. `inline` renders it in normal document flow. */
3
3
  export type WidgetPlacement = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'inline';
4
4
  /**
@@ -1,3 +1,3 @@
1
- import { WebSocketSession } from "./WebSocketSession";
1
+ import { WebSocketSession } from "./WebSocketSession.js";
2
2
  export { WebSocketSession };
3
3
  //# sourceMappingURL=websocket.d.ts.map
@@ -14,8 +14,8 @@
14
14
  * const client = new ConvaiClient({ transport: 'websocket', ... });
15
15
  * ```
16
16
  */
17
- import { ConvaiClient } from "../core/ConvaiClient";
18
- import { WebSocketSession } from "./WebSocketSession";
17
+ import { ConvaiClient } from "../core/ConvaiClient.js";
18
+ import { WebSocketSession } from "./WebSocketSession.js";
19
19
  // Side-effect: register the Pipecat-backed factory with ConvaiClient.
20
20
  // After this runs, any ConvaiClient instance can use transport: "websocket".
21
21
  ConvaiClient.registerWebSocketTransport((onMessage, enableMic) => new WebSocketSession(onMessage, enableMic));
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "1.8.0-beta.3";
1
+ export declare const SDK_VERSION = "1.8.0-beta.5";
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // GENERATED by scripts/sync-version.mjs — do not edit by hand.
2
2
  // Regenerated from package.json on every build.
3
- export const SDK_VERSION = "1.8.0-beta.3";
3
+ export const SDK_VERSION = "1.8.0-beta.5";
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,gDAAgD;AAChD,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC","sourcesContent":["// GENERATED by scripts/sync-version.mjs — do not edit by hand.\n// Regenerated from package.json on every build.\nexport const SDK_VERSION = \"1.8.0-beta.3\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,gDAAgD;AAChD,MAAM,CAAC,MAAM,WAAW,GAAG,cAAc,CAAC","sourcesContent":["// GENERATED by scripts/sync-version.mjs — do not edit by hand.\n// Regenerated from package.json on every build.\nexport const SDK_VERSION = \"1.8.0-beta.5\";\n"]}