@convai/web-sdk 0.0.4-beta.1 → 0.1.1-beta.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 (174) hide show
  1. package/README.md +277 -185
  2. package/dist/components/ConvaiWidget.d.ts.map +1 -1
  3. package/dist/components/ConvaiWidget.js +13 -0
  4. package/dist/components/ConvaiWidget.js.map +1 -1
  5. package/dist/components/rtc-widget/components/AudioSettingsPanel.js +1 -1
  6. package/dist/components/rtc-widget/components/AudioSettingsPanel.js.map +1 -1
  7. package/dist/components/rtc-widget/styles/styledComponents.d.ts.map +1 -1
  8. package/dist/components/rtc-widget/styles/styledComponents.js +72 -51
  9. package/dist/components/rtc-widget/styles/styledComponents.js.map +1 -1
  10. package/dist/core/AudioManager.d.ts +75 -0
  11. package/dist/core/AudioManager.d.ts.map +1 -0
  12. package/dist/core/AudioManager.js +219 -0
  13. package/dist/core/AudioManager.js.map +1 -0
  14. package/dist/core/ConvaiClient.d.ts +122 -0
  15. package/dist/core/ConvaiClient.d.ts.map +1 -0
  16. package/dist/core/ConvaiClient.js +509 -0
  17. package/dist/core/ConvaiClient.js.map +1 -0
  18. package/dist/core/EventEmitter.d.ts +38 -0
  19. package/dist/core/EventEmitter.d.ts.map +1 -0
  20. package/dist/core/EventEmitter.js +68 -0
  21. package/dist/core/EventEmitter.js.map +1 -0
  22. package/dist/core/MessageHandler.d.ts +52 -0
  23. package/dist/core/MessageHandler.d.ts.map +1 -0
  24. package/dist/core/MessageHandler.js +281 -0
  25. package/dist/core/MessageHandler.js.map +1 -0
  26. package/dist/core/ScreenShareManager.d.ts +57 -0
  27. package/dist/core/ScreenShareManager.d.ts.map +1 -0
  28. package/dist/core/ScreenShareManager.js +206 -0
  29. package/dist/core/ScreenShareManager.js.map +1 -0
  30. package/dist/core/VideoManager.d.ts +69 -0
  31. package/dist/core/VideoManager.d.ts.map +1 -0
  32. package/dist/core/VideoManager.js +207 -0
  33. package/dist/core/VideoManager.js.map +1 -0
  34. package/dist/core/index.d.ts +9 -0
  35. package/dist/core/index.d.ts.map +1 -0
  36. package/dist/core/index.js +12 -0
  37. package/dist/core/index.js.map +1 -0
  38. package/dist/core/types.d.ts +311 -0
  39. package/dist/core/types.d.ts.map +1 -0
  40. package/dist/core/types.js +2 -0
  41. package/dist/core/types.js.map +1 -0
  42. package/dist/hooks/useConvaiClient.d.ts.map +1 -1
  43. package/dist/hooks/useConvaiClient.js +16 -0
  44. package/dist/hooks/useConvaiClient.js.map +1 -1
  45. package/dist/hooks/useMessageHandler.d.ts.map +1 -1
  46. package/dist/hooks/useMessageHandler.js +39 -14
  47. package/dist/hooks/useMessageHandler.js.map +1 -1
  48. package/dist/index.d.ts +1 -5
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +3 -10
  51. package/dist/index.js.map +1 -1
  52. package/dist/react/components/ConvaiWidget.d.ts +59 -0
  53. package/dist/react/components/ConvaiWidget.d.ts.map +1 -0
  54. package/dist/react/components/ConvaiWidget.js +421 -0
  55. package/dist/react/components/ConvaiWidget.js.map +1 -0
  56. package/dist/react/components/index.d.ts +3 -0
  57. package/dist/react/components/index.d.ts.map +1 -0
  58. package/dist/react/components/index.js +5 -0
  59. package/dist/react/components/index.js.map +1 -0
  60. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts +10 -0
  61. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts.map +1 -0
  62. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.js +316 -0
  63. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.js.map +1 -0
  64. package/dist/react/components/rtc-widget/components/ConviMessage.d.ts +10 -0
  65. package/dist/react/components/rtc-widget/components/ConviMessage.d.ts.map +1 -0
  66. package/dist/react/components/rtc-widget/components/ConviMessage.js +14 -0
  67. package/dist/react/components/rtc-widget/components/ConviMessage.js.map +1 -0
  68. package/dist/react/components/rtc-widget/components/FloatingVideo.d.ts +9 -0
  69. package/dist/react/components/rtc-widget/components/FloatingVideo.d.ts.map +1 -0
  70. package/dist/react/components/rtc-widget/components/FloatingVideo.js +122 -0
  71. package/dist/react/components/rtc-widget/components/FloatingVideo.js.map +1 -0
  72. package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts +7 -0
  73. package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts.map +1 -0
  74. package/dist/react/components/rtc-widget/components/MarkdownRenderer.js +68 -0
  75. package/dist/react/components/rtc-widget/components/MarkdownRenderer.js.map +1 -0
  76. package/dist/react/components/rtc-widget/components/MessageBubble.d.ts +10 -0
  77. package/dist/react/components/rtc-widget/components/MessageBubble.d.ts.map +1 -0
  78. package/dist/react/components/rtc-widget/components/MessageBubble.js +23 -0
  79. package/dist/react/components/rtc-widget/components/MessageBubble.js.map +1 -0
  80. package/dist/react/components/rtc-widget/components/MessageList.d.ts +11 -0
  81. package/dist/react/components/rtc-widget/components/MessageList.d.ts.map +1 -0
  82. package/dist/react/components/rtc-widget/components/MessageList.js +89 -0
  83. package/dist/react/components/rtc-widget/components/MessageList.js.map +1 -0
  84. package/dist/react/components/rtc-widget/components/UserMessage.d.ts +9 -0
  85. package/dist/react/components/rtc-widget/components/UserMessage.d.ts.map +1 -0
  86. package/dist/react/components/rtc-widget/components/UserMessage.js +15 -0
  87. package/dist/react/components/rtc-widget/components/UserMessage.js.map +1 -0
  88. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts +6 -0
  89. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts.map +1 -0
  90. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js +15 -0
  91. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js.map +1 -0
  92. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts +25 -0
  93. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts.map +1 -0
  94. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js +172 -0
  95. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js.map +1 -0
  96. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts +17 -0
  97. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts.map +1 -0
  98. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js +66 -0
  99. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js.map +1 -0
  100. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts +12 -0
  101. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts.map +1 -0
  102. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js +68 -0
  103. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js.map +1 -0
  104. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts +8 -0
  105. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts.map +1 -0
  106. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js +199 -0
  107. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js.map +1 -0
  108. package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts +6 -0
  109. package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts.map +1 -0
  110. package/dist/react/components/rtc-widget/components/conviComponents/index.js +6 -0
  111. package/dist/react/components/rtc-widget/components/conviComponents/index.js.map +1 -0
  112. package/dist/react/components/rtc-widget/components/index.d.ts +8 -0
  113. package/dist/react/components/rtc-widget/components/index.d.ts.map +1 -0
  114. package/dist/react/components/rtc-widget/components/index.js +13 -0
  115. package/dist/react/components/rtc-widget/components/index.js.map +1 -0
  116. package/dist/react/components/rtc-widget/index.d.ts +6 -0
  117. package/dist/react/components/rtc-widget/index.d.ts.map +1 -0
  118. package/dist/react/components/rtc-widget/index.js +9 -0
  119. package/dist/react/components/rtc-widget/index.js.map +1 -0
  120. package/dist/react/components/rtc-widget/styles/framerConfig.d.ts +116 -0
  121. package/dist/react/components/rtc-widget/styles/framerConfig.d.ts.map +1 -0
  122. package/dist/react/components/rtc-widget/styles/framerConfig.js +73 -0
  123. package/dist/react/components/rtc-widget/styles/framerConfig.js.map +1 -0
  124. package/dist/react/components/rtc-widget/styles/icons.d.ts +28 -0
  125. package/dist/react/components/rtc-widget/styles/icons.d.ts.map +1 -0
  126. package/dist/react/components/rtc-widget/styles/icons.js +257 -0
  127. package/dist/react/components/rtc-widget/styles/icons.js.map +1 -0
  128. package/dist/react/components/rtc-widget/styles/index.d.ts +6 -0
  129. package/dist/react/components/rtc-widget/styles/index.d.ts.map +1 -0
  130. package/dist/react/components/rtc-widget/styles/index.js +9 -0
  131. package/dist/react/components/rtc-widget/styles/index.js.map +1 -0
  132. package/dist/react/components/rtc-widget/styles/styledComponents.d.ts +90 -0
  133. package/dist/react/components/rtc-widget/styles/styledComponents.d.ts.map +1 -0
  134. package/dist/react/components/rtc-widget/styles/styledComponents.js +661 -0
  135. package/dist/react/components/rtc-widget/styles/styledComponents.js.map +1 -0
  136. package/dist/react/components/rtc-widget/styles/theme.d.ts +188 -0
  137. package/dist/react/components/rtc-widget/styles/theme.d.ts.map +1 -0
  138. package/dist/react/components/rtc-widget/styles/theme.js +290 -0
  139. package/dist/react/components/rtc-widget/styles/theme.js.map +1 -0
  140. package/dist/react/components/rtc-widget/types/index.d.ts +60 -0
  141. package/dist/react/components/rtc-widget/types/index.d.ts.map +1 -0
  142. package/dist/react/components/rtc-widget/types/index.js +2 -0
  143. package/dist/react/components/rtc-widget/types/index.js.map +1 -0
  144. package/dist/react/hooks/index.d.ts +4 -0
  145. package/dist/react/hooks/index.d.ts.map +1 -0
  146. package/dist/react/hooks/index.js +6 -0
  147. package/dist/react/hooks/index.js.map +1 -0
  148. package/dist/react/hooks/useCharacterInfo.d.ts +17 -0
  149. package/dist/react/hooks/useCharacterInfo.d.ts.map +1 -0
  150. package/dist/react/hooks/useCharacterInfo.js +60 -0
  151. package/dist/react/hooks/useCharacterInfo.js.map +1 -0
  152. package/dist/react/hooks/useConvaiClient.d.ts +32 -0
  153. package/dist/react/hooks/useConvaiClient.d.ts.map +1 -0
  154. package/dist/react/hooks/useConvaiClient.js +140 -0
  155. package/dist/react/hooks/useConvaiClient.js.map +1 -0
  156. package/dist/react/hooks/useLocalCameraTrack.d.ts +22 -0
  157. package/dist/react/hooks/useLocalCameraTrack.d.ts.map +1 -0
  158. package/dist/react/hooks/useLocalCameraTrack.js +34 -0
  159. package/dist/react/hooks/useLocalCameraTrack.js.map +1 -0
  160. package/dist/react/index.d.ts +8 -0
  161. package/dist/react/index.d.ts.map +1 -0
  162. package/dist/react/index.js +15 -0
  163. package/dist/react/index.js.map +1 -0
  164. package/dist/types/index.d.ts +20 -0
  165. package/dist/types/index.d.ts.map +1 -1
  166. package/dist/utils/speakerManagement.d.ts +22 -0
  167. package/dist/utils/speakerManagement.d.ts.map +1 -0
  168. package/dist/utils/speakerManagement.js +71 -0
  169. package/dist/utils/speakerManagement.js.map +1 -0
  170. package/dist/vanilla/index.d.ts +3 -0
  171. package/dist/vanilla/index.d.ts.map +1 -0
  172. package/dist/vanilla/index.js +5 -0
  173. package/dist/vanilla/index.js.map +1 -0
  174. package/package.json +25 -8
@@ -0,0 +1,32 @@
1
+ import type { ConvaiConfig, IConvaiClient, ChatMessage } from "../../core/types";
2
+ /**
3
+ * React hook wrapper for ConvaiClient
4
+ * Main hook for managing Convai client connection and functionality.
5
+ *
6
+ * Provides a complete interface for connecting to Convai's AI-powered voice assistants,
7
+ * managing real-time audio/video conversations, and handling various message types.
8
+ *
9
+ * @param config - Optional configuration to store for later connection
10
+ * @returns {ConvaiClient & { activity: string; chatMessages: ChatMessage[] }} Complete client interface with connection state, methods, and message history
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * function App() {
15
+ * const convaiClient = useConvaiClient({
16
+ * apiKey: 'your-api-key',
17
+ * characterId: 'your-character-id',
18
+ * endUserId: 'user-uuid', // Optional: enables memory & analytics
19
+ * enableVideo: true,
20
+ * });
21
+ *
22
+ * return (
23
+ * <ConvaiWidget convaiClient={convaiClient} />
24
+ * );
25
+ * }
26
+ * ```
27
+ */
28
+ export declare const useConvaiClient: (config?: ConvaiConfig) => IConvaiClient & {
29
+ activity: string;
30
+ chatMessages: ChatMessage[];
31
+ };
32
+ //# sourceMappingURL=useConvaiClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConvaiClient.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useConvaiClient.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEjF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,eAAe,GAAI,SAAS,YAAY,KAAG,aAAa,GAAG;IACtE,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,WAAW,EAAE,CAAC;CA6H7B,CAAC"}
@@ -0,0 +1,140 @@
1
+ import { useState, useEffect, useCallback } from "react";
2
+ import { ConvaiClient as CoreConvaiClient } from "../../core";
3
+ /**
4
+ * React hook wrapper for ConvaiClient
5
+ * Main hook for managing Convai client connection and functionality.
6
+ *
7
+ * Provides a complete interface for connecting to Convai's AI-powered voice assistants,
8
+ * managing real-time audio/video conversations, and handling various message types.
9
+ *
10
+ * @param config - Optional configuration to store for later connection
11
+ * @returns {ConvaiClient & { activity: string; chatMessages: ChatMessage[] }} Complete client interface with connection state, methods, and message history
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * function App() {
16
+ * const convaiClient = useConvaiClient({
17
+ * apiKey: 'your-api-key',
18
+ * characterId: 'your-character-id',
19
+ * endUserId: 'user-uuid', // Optional: enables memory & analytics
20
+ * enableVideo: true,
21
+ * });
22
+ *
23
+ * return (
24
+ * <ConvaiWidget convaiClient={convaiClient} />
25
+ * );
26
+ * }
27
+ * ```
28
+ */
29
+ export const useConvaiClient = (config) => {
30
+ // Create client instance once
31
+ const [client] = useState(() => new CoreConvaiClient());
32
+ // React state for UI updates
33
+ const [state, setState] = useState(client.state);
34
+ const [activity, setActivity] = useState("Idle");
35
+ const [chatMessages, setChatMessages] = useState(client.chatMessages);
36
+ const [userTranscription, setUserTranscription] = useState(client.userTranscription);
37
+ const [isSpeaking, setIsSpeaking] = useState(false);
38
+ // Store config if provided
39
+ const [storedConfig] = useState(config);
40
+ // Setup event listeners
41
+ useEffect(() => {
42
+ // State change listener
43
+ const unsubStateChange = client.on('stateChange', (newState) => {
44
+ setState(newState);
45
+ // Update activity based on state
46
+ if (!newState.isConnected) {
47
+ setActivity("Disconnected");
48
+ }
49
+ else if (newState.isConnecting) {
50
+ setActivity("Connecting...");
51
+ }
52
+ else if (newState.isSpeaking) {
53
+ setActivity("Speaking");
54
+ }
55
+ else if (newState.isThinking) {
56
+ setActivity("Thinking");
57
+ }
58
+ else {
59
+ setActivity("Connected");
60
+ }
61
+ });
62
+ // Messages change listener
63
+ const unsubMessagesChange = client.on('messagesChange', (messages) => {
64
+ setChatMessages([...messages]);
65
+ });
66
+ // User transcription change listener
67
+ const unsubUserTranscription = client.on('userTranscriptionChange', (transcription) => {
68
+ setUserTranscription(transcription);
69
+ });
70
+ // Speaking change listener
71
+ const unsubSpeaking = client.on('speakingChange', (speaking) => {
72
+ setIsSpeaking(speaking);
73
+ });
74
+ // Bot ready listener
75
+ const unsubBotReady = client.on('botReady', () => {
76
+ setActivity("Connected");
77
+ });
78
+ // Connect listener
79
+ const unsubConnect = client.on('connect', () => {
80
+ setState(client.state);
81
+ });
82
+ // Disconnect listener
83
+ const unsubDisconnect = client.on('disconnect', () => {
84
+ setState(client.state);
85
+ setActivity("Disconnected");
86
+ setChatMessages([]);
87
+ });
88
+ // Cleanup listeners on unmount
89
+ return () => {
90
+ unsubStateChange();
91
+ unsubMessagesChange();
92
+ unsubUserTranscription();
93
+ unsubSpeaking();
94
+ unsubBotReady();
95
+ unsubConnect();
96
+ unsubDisconnect();
97
+ };
98
+ }, [client]);
99
+ // Create enhanced connect function that can use stored config
100
+ const connect = useCallback(async (configOverride) => {
101
+ const finalConfig = configOverride || storedConfig;
102
+ if (!finalConfig) {
103
+ throw new Error("No configuration provided. Pass config to useConvaiClient() or to connect()");
104
+ }
105
+ await client.connect(finalConfig);
106
+ }, [client, storedConfig]);
107
+ // Create reconnect function wrapper
108
+ const reconnect = useCallback(async () => {
109
+ await client.reconnect();
110
+ }, [client]);
111
+ // Return client interface with React-friendly additions
112
+ return {
113
+ state,
114
+ connectionType: client.connectionType,
115
+ apiKey: client.apiKey,
116
+ characterId: client.characterId,
117
+ speakerId: client.speakerId,
118
+ connect,
119
+ disconnect: client.disconnect.bind(client),
120
+ reconnect,
121
+ resetSession: client.resetSession.bind(client),
122
+ room: client.room,
123
+ sendUserTextMessage: client.sendUserTextMessage.bind(client),
124
+ sendTriggerMessage: client.sendTriggerMessage.bind(client),
125
+ updateTemplateKeys: client.updateTemplateKeys.bind(client),
126
+ updateDynamicInfo: client.updateDynamicInfo.bind(client),
127
+ activity,
128
+ chatMessages,
129
+ userTranscription,
130
+ characterSessionId: client.characterSessionId,
131
+ isBotReady: client.isBotReady,
132
+ audioControls: client.audioControls,
133
+ videoControls: client.videoControls,
134
+ screenShareControls: client.screenShareControls,
135
+ toggleTts: client.toggleTts.bind(client),
136
+ on: client.on.bind(client),
137
+ off: client.off.bind(client),
138
+ };
139
+ };
140
+ //# sourceMappingURL=useConvaiClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConvaiClient.js","sourceRoot":"","sources":["../../../src/react/hooks/useConvaiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAW,WAAW,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAqB,EAGnD,EAAE;IACF,8BAA8B;IAC9B,MAAM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MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC;QAC1D,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC;QACxD,QAAQ;QACR,YAAY;QACZ,iBAAiB;QACjB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;QAC7C,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;QAC/C,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;QACxC,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC;QAC1B,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;KAC7B,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { TrackReferenceOrPlaceholder } from "@livekit/components-react";
2
+ /**
3
+ * Hook to get the local camera track reference from LiveKit.
4
+ *
5
+ * Returns a track reference that can be used with LiveKit components
6
+ * to display the local participant's camera feed.
7
+ *
8
+ * @returns {TrackReferenceOrPlaceholder} Track reference for the local camera
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * function VideoComponent() {
13
+ * const cameraTrackRef = useLocalCameraTrack();
14
+ *
15
+ * return (
16
+ * <VideoTrack trackRef={cameraTrackRef} />
17
+ * );
18
+ * }
19
+ * ```
20
+ */
21
+ export declare const useLocalCameraTrack: () => TrackReferenceOrPlaceholder;
22
+ //# sourceMappingURL=useLocalCameraTrack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocalCameraTrack.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useLocalCameraTrack.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAE5B,MAAM,2BAA2B,CAAC;AAInC;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,mBAAmB,mCAY/B,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { useLocalParticipant, } from "@livekit/components-react";
2
+ import { Track } from "livekit-client";
3
+ import { useMemo } from "react";
4
+ /**
5
+ * Hook to get the local camera track reference from LiveKit.
6
+ *
7
+ * Returns a track reference that can be used with LiveKit components
8
+ * to display the local participant's camera feed.
9
+ *
10
+ * @returns {TrackReferenceOrPlaceholder} Track reference for the local camera
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * function VideoComponent() {
15
+ * const cameraTrackRef = useLocalCameraTrack();
16
+ *
17
+ * return (
18
+ * <VideoTrack trackRef={cameraTrackRef} />
19
+ * );
20
+ * }
21
+ * ```
22
+ */
23
+ export const useLocalCameraTrack = () => {
24
+ const { cameraTrack, localParticipant } = useLocalParticipant();
25
+ const cameraTrackRef = useMemo(() => {
26
+ return {
27
+ participant: localParticipant,
28
+ source: Track.Source.Camera,
29
+ publication: cameraTrack,
30
+ };
31
+ }, [localParticipant, cameraTrack]);
32
+ return cameraTrackRef;
33
+ };
34
+ //# sourceMappingURL=useLocalCameraTrack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocalCameraTrack.js","sourceRoot":"","sources":["../../../src/react/hooks/useLocalCameraTrack.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAEhE,MAAM,cAAc,GAAgC,OAAO,CAAC,GAAG,EAAE;QAC/D,OAAO;YACL,WAAW,EAAE,gBAAgB;YAC7B,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM;YAC3B,WAAW,EAAE,WAAW;SACzB,CAAC;IACJ,CAAC,EAAE,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC,CAAC;IAEpC,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export { useConvaiClient } from './hooks/useConvaiClient';
2
+ export { ConvaiWidget } from './components/ConvaiWidget';
3
+ export * from './hooks';
4
+ export * from './components/rtc-widget';
5
+ export * from '../core/types';
6
+ export { ConvaiClient } from '../core';
7
+ export { RoomAudioRenderer as AudioRenderer, RoomContext as AudioContext } from '@livekit/components-react';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,cAAc,SAAS,CAAC;AAGxB,cAAc,yBAAyB,CAAC;AAGxC,cAAc,eAAe,CAAC;AAG9B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,EAAE,iBAAiB,IAAI,aAAa,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Main hook (backward compatible)
2
+ export { useConvaiClient } from './hooks/useConvaiClient';
3
+ // Components
4
+ export { ConvaiWidget } from './components/ConvaiWidget';
5
+ // Additional hooks (for advanced usage)
6
+ export * from './hooks';
7
+ // RTC widget components (for advanced usage)
8
+ export * from './components/rtc-widget';
9
+ // Re-export core types for convenience
10
+ export * from '../core/types';
11
+ // Re-export core client for advanced usage
12
+ export { ConvaiClient } from '../core';
13
+ // Re-export LiveKit components for convenience (backward compatible)
14
+ export { RoomAudioRenderer as AudioRenderer, RoomContext as AudioContext } from '@livekit/components-react';
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,aAAa;AACb,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,wCAAwC;AACxC,cAAc,SAAS,CAAC;AAExB,6CAA6C;AAC7C,cAAc,yBAAyB,CAAC;AAExC,uCAAuC;AACvC,cAAc,eAAe,CAAC;AAE9B,2CAA2C;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,qEAAqE;AACrE,OAAO,EAAE,iBAAiB,IAAI,aAAa,EAAE,WAAW,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC"}
@@ -25,6 +25,7 @@ export type { AudioSettings };
25
25
  * const config: ConvaiConfig = {
26
26
  * apiKey: 'your-api-key',
27
27
  * characterId: 'your-character-id',
28
+ * endUserId: 'user-uuid', // Optional: enables long-term memory and analytics
28
29
  * enableVideo: false, // If false, connection_type will be "audio"
29
30
  * };
30
31
  * ```
@@ -34,6 +35,20 @@ export interface ConvaiConfig {
34
35
  apiKey: string;
35
36
  /** The Character ID to connect to (required) */
36
37
  characterId: string;
38
+ /**
39
+ * End user identifier for speaker management (optional).
40
+ *
41
+ * When provided:
42
+ * - Enables long-term memory: Character remembers context from previous conversations with this user
43
+ * - Enables analytics: Track user engagement and behavior
44
+ *
45
+ * When not provided:
46
+ * - Anonymous mode: No persistent memory or user tracking
47
+ * - Each session is independent with no conversation history
48
+ *
49
+ * Use a unique UUID or device ID for persistent user experiences.
50
+ */
51
+ endUserId?: string;
37
52
  /** Custom Convai API URL (optional, defaults to production endpoint) */
38
53
  url?: string;
39
54
  /**
@@ -175,6 +190,11 @@ export interface ConvaiClient {
175
190
  apiKey: string | null;
176
191
  /** Character ID used for the current connection (null if not connected) */
177
192
  characterId: string | null;
193
+ /**
194
+ * Speaker ID for the current user (null if not connected).
195
+ * Used for long-term memory and user analytics.
196
+ */
197
+ speakerId: string | null;
178
198
  /**
179
199
  * Connect to a Convai character.
180
200
  * Uses stored config from useConvaiClient() or accepts override config.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC;;;;GAIG;AACH,UAAU,aAAa;IACrB,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,0EAA0E;IAC1E,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAGD,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,YAAY;IAC3B,+DAA+D;IAC/D,MAAM,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,6DAA6D;IAC7D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oEAAoE;IACpE,YAAY,CAAC,EAAE;QACb,qDAAqD;QACrD,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,4DAA4D;QAC5D,UAAU,EAAE,KAAK,CAAC;YAChB,qBAAqB;YACrB,IAAI,EAAE,MAAM,CAAC;YACb,yCAAyC;YACzC,GAAG,EAAE,MAAM,CAAC;SACb,CAAC,CAAC;QACH,oDAAoD;QACpD,OAAO,EAAE,KAAK,CAAC;Y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AE,WAAW,EAAE,CAAC;IAE5B,qDAAqD;IACrD,iBAAiB,EAAE,MAAM,CAAC;IAE1B,+DAA+D;IAC/D,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAElC,kFAAkF;IAClF,UAAU,EAAE,OAAO,CAAC;IAEpB,gEAAgE;IAChE,aAAa,EAAE,aAAa,CAAC;IAE7B,0DAA0D;IAC1D,aAAa,EAAE,aAAa,CAAC;IAE7B,qCAAqC;IACrC,mBAAmB,EAAE,mBAAmB,CAAC;IAEzC;;;OAGG;IACH,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Resolves the speaker ID based on the end user ID.
3
+ *
4
+ * - If endUserId is not provided (anonymous mode), returns the API key as the speaker ID (no persistent memory)
5
+ * - If endUserId is provided, calls Convai API to get or create a speaker ID for the user
6
+ *
7
+ * @param endUserId - The end user identifier (optional). If not provided, anonymous mode is used.
8
+ * @param apiKey - Convai API key for authentication
9
+ * @returns Promise resolving to the speaker ID
10
+ */
11
+ export declare function resolveSpeakerId(endUserId: string | undefined, apiKey: string): Promise<string>;
12
+ /**
13
+ * Gets or creates a speaker ID from Convai's speaker management API.
14
+ * If the same endUserId is used multiple times, the same speaker ID is returned (idempotent).
15
+ *
16
+ * @param endUserId - The device or user identifier
17
+ * @param apiKey - Convai API key for authentication
18
+ * @returns Promise resolving to the speaker ID
19
+ * @throws Error if API request fails
20
+ */
21
+ export declare function getOrCreateSpeakerId(endUserId: string, apiKey: string): Promise<string>;
22
+ //# sourceMappingURL=speakerManagement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"speakerManagement.d.ts","sourceRoot":"","sources":["../../src/utils/speakerManagement.ts"],"names":[],"mappings":"AASA;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,CAqCjB"}
@@ -0,0 +1,71 @@
1
+ import { logger } from './logger';
2
+ /**
3
+ * Resolves the speaker ID based on the end user ID.
4
+ *
5
+ * - If endUserId is not provided (anonymous mode), returns the API key as the speaker ID (no persistent memory)
6
+ * - If endUserId is provided, calls Convai API to get or create a speaker ID for the user
7
+ *
8
+ * @param endUserId - The end user identifier (optional). If not provided, anonymous mode is used.
9
+ * @param apiKey - Convai API key for authentication
10
+ * @returns Promise resolving to the speaker ID
11
+ */
12
+ export async function resolveSpeakerId(endUserId, apiKey) {
13
+ // Anonymous mode: Use API key as speaker ID (no persistent memory or analytics)
14
+ if (!endUserId) {
15
+ logger.info('Anonymous mode: No persistent speaker ID or user tracking');
16
+ return apiKey;
17
+ }
18
+ // User tracking mode: Get or create speaker ID via Convai API (enables memory and analytics)
19
+ try {
20
+ const speakerId = await getOrCreateSpeakerId(endUserId, apiKey);
21
+ logger.info(`Resolved speaker ID: ${speakerId.substring(0, 8)}...`);
22
+ return speakerId;
23
+ }
24
+ catch (error) {
25
+ logger.error('Failed to resolve speaker ID:', error);
26
+ // Fallback to API key if speaker ID resolution fails
27
+ logger.warn('Falling back to API key as speaker ID');
28
+ return apiKey;
29
+ }
30
+ }
31
+ /**
32
+ * Gets or creates a speaker ID from Convai's speaker management API.
33
+ * If the same endUserId is used multiple times, the same speaker ID is returned (idempotent).
34
+ *
35
+ * @param endUserId - The device or user identifier
36
+ * @param apiKey - Convai API key for authentication
37
+ * @returns Promise resolving to the speaker ID
38
+ * @throws Error if API request fails
39
+ */
40
+ export async function getOrCreateSpeakerId(endUserId, apiKey) {
41
+ const url = 'https://api.convai.com/user/speaker/new';
42
+ logger.info(`Requesting speaker ID for endUserId: ${endUserId.substring(0, 8)}...`);
43
+ try {
44
+ const response = await fetch(url, {
45
+ method: 'POST',
46
+ headers: {
47
+ 'Content-Type': 'application/json',
48
+ 'CONVAI-API-KEY': apiKey,
49
+ },
50
+ body: JSON.stringify({
51
+ deviceId: endUserId,
52
+ }),
53
+ });
54
+ if (!response.ok) {
55
+ const errorText = await response.text();
56
+ throw new Error(`Speaker API request failed: ${response.status} ${response.statusText} - ${errorText}`);
57
+ }
58
+ const data = await response.json();
59
+ if (!data.speakerId) {
60
+ throw new Error('Speaker API did not return a speaker ID');
61
+ }
62
+ return data.speakerId;
63
+ }
64
+ catch (error) {
65
+ if (error instanceof Error) {
66
+ throw new Error(`Failed to get speaker ID: ${error.message}`);
67
+ }
68
+ throw new Error('Failed to get speaker ID: Unknown error');
69
+ }
70
+ }
71
+ //# sourceMappingURL=speakerManagement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"speakerManagement.js","sourceRoot":"","sources":["../../src/utils/speakerManagement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AASlC;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,SAA6B,EAC7B,MAAc;IAEd,gFAAgF;IAChF,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;QACzE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,6FAA6F;IAC7F,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,oBAAoB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAChE,MAAM,CAAC,IAAI,CAAC,wBAAwB,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QACpE,OAAO,SAAS,CAAC;IACnB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAC;QACrD,qDAAqD;QACrD,MAAM,CAAC,IAAI,CAAC,u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D,CAAC;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { ConvaiClient } from '../core';
2
+ export * from '../core/types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vanilla/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,5 @@
1
+ // Core client (re-exported from core)
2
+ export { ConvaiClient } from '../core';
3
+ // Re-export types for convenience
4
+ export * from '../core/types';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vanilla/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,kCAAkC;AAClC,cAAc,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@convai/web-sdk",
3
- "version": "0.0.4-beta.1",
3
+ "version": "0.1.1-beta.0",
4
4
  "description": "The convai/web-sdk helps power characters in websites (brain) and the communication UI with Convai characters. This SDK facilitates the capture of user audio streams and provides appropriate responses in the form of audio, actions, and facial expressions.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -12,9 +12,21 @@
12
12
  "import": "./dist/index.js",
13
13
  "types": "./dist/index.d.ts"
14
14
  },
15
+ "./core": {
16
+ "import": "./dist/core/index.js",
17
+ "types": "./dist/core/index.d.ts"
18
+ },
19
+ "./react": {
20
+ "import": "./dist/react/index.js",
21
+ "types": "./dist/react/index.d.ts"
22
+ },
23
+ "./vanilla": {
24
+ "import": "./dist/vanilla/index.js",
25
+ "types": "./dist/vanilla/index.d.ts"
26
+ },
15
27
  "./rtc-widget": {
16
- "import": "./dist/components/rtc-widget/index.js",
17
- "types": "./dist/components/rtc-widget/index.d.ts"
28
+ "import": "./dist/react/components/rtc-widget/index.js",
29
+ "types": "./dist/react/components/rtc-widget/index.d.ts"
18
30
  }
19
31
  },
20
32
  "sideEffects": false,
@@ -37,16 +49,19 @@
37
49
  "publish:beta": "npm run build:prod && changeset publish --tag beta",
38
50
  "example:react": "cd examples/react && pnpm dev",
39
51
  "example:react:build": "cd examples/react && pnpm build",
52
+ "example:vanilla-ts": "cd examples/vanilla-ts && pnpm dev",
40
53
  "examples:dev": "pnpm example:react",
41
54
  "examples:build": "pnpm example:react:build",
42
- "examples:install": "pnpm install && cd examples/react && pnpm install",
55
+ "examples:install": "pnpm install && cd examples/react && pnpm install && cd ../vanilla-ts && pnpm install",
43
56
  "examples:clean": "pnpm clean && cd examples/react && pnpm clean"
44
57
  },
45
58
  "keywords": [
46
59
  "convai",
47
60
  "livekit",
48
61
  "react",
62
+ "vanilla",
49
63
  "typescript",
64
+ "javascript",
50
65
  "ai",
51
66
  "voice-assistant",
52
67
  "video-chat",
@@ -61,18 +76,20 @@
61
76
  "text-to-speech",
62
77
  "rtc",
63
78
  "character-ai",
64
- "interactive-characters"
79
+ "interactive-characters",
80
+ "tree-shaking",
81
+ "multi-platform"
65
82
  ],
66
83
  "author": "Convai <support@convai.com>",
67
84
  "license": "MIT",
68
85
  "repository": {
69
86
  "type": "git",
70
- "url": "https://github.com/convai/web-handsfree.git"
87
+ "url": "https://github.com/convai/web-sdk.git"
71
88
  },
72
89
  "bugs": {
73
- "url": "https://github.com/convai/web-handsfree/issues"
90
+ "url": "https://github.com/convai/web-sdk/issues"
74
91
  },
75
- "homepage": "https://github.com/convai/web-handsfree#readme",
92
+ "homepage": "https://github.com/convai/web-sdk#readme",
76
93
  "dependencies": {
77
94
  "@livekit/components-react": "^2.9.3",
78
95
  "@livekit/components-styles": "^1.1.4",