@convai/web-sdk 1.9.0-beta.7 → 1.9.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 (344) hide show
  1. package/README.md +44 -13
  2. package/dist/core/AudioManager.d.ts +0 -1
  3. package/dist/core/AudioManager.js +0 -1
  4. package/dist/core/BlendshapeQueue.d.ts +0 -1
  5. package/dist/core/BlendshapeQueue.js +20 -6
  6. package/dist/core/CharacterRoster.d.ts +0 -1
  7. package/dist/core/CharacterRoster.js +0 -1
  8. package/dist/core/CharacterVersionManager.d.ts +0 -1
  9. package/dist/core/CharacterVersionManager.js +0 -1
  10. package/dist/core/ConnectionStateHandler.d.ts +0 -1
  11. package/dist/core/ConnectionStateHandler.js +5 -2
  12. package/dist/core/ConvaiClient.d.ts +31 -3
  13. package/dist/core/ConvaiClient.js +136 -14
  14. package/dist/core/ConvaiRoomError.d.ts +0 -1
  15. package/dist/core/ConvaiRoomError.js +20 -2
  16. package/dist/core/EventEmitter.d.ts +0 -1
  17. package/dist/core/EventEmitter.js +0 -1
  18. package/dist/core/MemoryManager.d.ts +0 -1
  19. package/dist/core/MemoryManager.js +0 -1
  20. package/dist/core/MessageHandler.d.ts +0 -1
  21. package/dist/core/MessageHandler.js +41 -10
  22. package/dist/core/SSESession.d.ts +0 -1
  23. package/dist/core/SSESession.js +0 -1
  24. package/dist/core/ScreenShareManager.d.ts +0 -1
  25. package/dist/core/ScreenShareManager.js +0 -1
  26. package/dist/core/VideoManager.d.ts +0 -1
  27. package/dist/core/VideoManager.js +0 -1
  28. package/dist/core/characterInfo.d.ts +45 -0
  29. package/dist/core/characterInfo.js +55 -0
  30. package/dist/core/characterReference.d.ts +0 -1
  31. package/dist/core/characterReference.js +0 -1
  32. package/dist/core/connectRequest.d.ts +0 -1
  33. package/dist/core/connectRequest.js +0 -1
  34. package/dist/core/contextUpdateRequest.d.ts +0 -1
  35. package/dist/core/contextUpdateRequest.js +0 -1
  36. package/dist/core/index.d.ts +4 -3
  37. package/dist/core/index.js +20 -3
  38. package/dist/core/logicalTurn.d.ts +0 -1
  39. package/dist/core/logicalTurn.js +0 -1
  40. package/dist/core/modelOutput.d.ts +0 -1
  41. package/dist/core/modelOutput.js +0 -1
  42. package/dist/core/publishedChat.d.ts +0 -1
  43. package/dist/core/publishedChat.js +0 -1
  44. package/dist/core/rosterRequest.d.ts +0 -1
  45. package/dist/core/rosterRequest.js +0 -1
  46. package/dist/core/rtviEnvelope.d.ts +0 -1
  47. package/dist/core/rtviEnvelope.js +0 -1
  48. package/dist/core/types.d.ts +112 -10
  49. package/dist/core/types.js +0 -1
  50. package/dist/core/videoSourceState.d.ts +0 -1
  51. package/dist/core/videoSourceState.js +0 -1
  52. package/dist/core/visionRequest.d.ts +0 -1
  53. package/dist/core/visionRequest.js +0 -1
  54. package/dist/embed/index.d.ts +11 -1
  55. package/dist/embed/index.js +11 -1
  56. package/dist/embed/publicationApi.d.ts +0 -1
  57. package/dist/embed/publicationApi.js +0 -1
  58. package/dist/index.d.ts +0 -1
  59. package/dist/index.js +0 -1
  60. package/dist/lipsync-helpers/arkitOrder61.d.ts +0 -1
  61. package/dist/lipsync-helpers/arkitOrder61.js +5 -3
  62. package/dist/lipsync-helpers/createBlendshapeQueue.d.ts +0 -1
  63. package/dist/lipsync-helpers/createBlendshapeQueue.js +7 -1
  64. package/dist/lipsync-helpers/declarativeMapping.d.ts +2 -1
  65. package/dist/lipsync-helpers/declarativeMapping.js +72 -146
  66. package/dist/lipsync-helpers/index.d.ts +0 -1
  67. package/dist/lipsync-helpers/index.js +0 -1
  68. package/dist/lipsync-helpers/mappingTypes.d.ts +6 -5
  69. package/dist/lipsync-helpers/mappingTypes.js +0 -1
  70. package/dist/lipsync-helpers/metahumanOrder251.d.ts +0 -1
  71. package/dist/lipsync-helpers/metahumanOrder251.js +8 -9
  72. package/dist/lipsync-helpers/mhaLimitDrivers.d.ts +0 -1
  73. package/dist/lipsync-helpers/mhaLimitDrivers.js +0 -1
  74. package/dist/lipsync-helpers/naturalness/processor.d.ts +0 -1
  75. package/dist/lipsync-helpers/naturalness/processor.js +6 -4
  76. package/dist/lipsync-helpers/naturalness/profiles/mha.d.ts +0 -1
  77. package/dist/lipsync-helpers/naturalness/profiles/mha.js +0 -1
  78. package/dist/lipsync-helpers/naturalness/types.d.ts +0 -1
  79. package/dist/lipsync-helpers/naturalness/types.js +0 -1
  80. package/dist/lipsync-helpers/presetMappers.d.ts +0 -1
  81. package/dist/lipsync-helpers/presetMappers.js +0 -1
  82. package/dist/react/components/ConvaiWidget.d.ts +0 -1
  83. package/dist/react/components/ConvaiWidget.js +16 -8
  84. package/dist/react/components/index.d.ts +0 -1
  85. package/dist/react/components/index.js +0 -1
  86. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts +0 -1
  87. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.js +0 -1
  88. package/dist/react/components/rtc-widget/components/AudioVisualizer.d.ts +0 -1
  89. package/dist/react/components/rtc-widget/components/AudioVisualizer.js +0 -1
  90. package/dist/react/components/rtc-widget/components/ConviMessage.d.ts +0 -1
  91. package/dist/react/components/rtc-widget/components/ConviMessage.js +0 -1
  92. package/dist/react/components/rtc-widget/components/FloatingVideo.d.ts +0 -1
  93. package/dist/react/components/rtc-widget/components/FloatingVideo.js +0 -1
  94. package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts +0 -1
  95. package/dist/react/components/rtc-widget/components/MarkdownRenderer.js +0 -1
  96. package/dist/react/components/rtc-widget/components/MessageBubble.d.ts +0 -1
  97. package/dist/react/components/rtc-widget/components/MessageBubble.js +0 -1
  98. package/dist/react/components/rtc-widget/components/MessageList.d.ts +0 -1
  99. package/dist/react/components/rtc-widget/components/MessageList.js +0 -1
  100. package/dist/react/components/rtc-widget/components/SiteCard.d.ts +0 -1
  101. package/dist/react/components/rtc-widget/components/SiteCard.js +0 -1
  102. package/dist/react/components/rtc-widget/components/UserMessage.d.ts +0 -1
  103. package/dist/react/components/rtc-widget/components/UserMessage.js +0 -1
  104. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts +0 -1
  105. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js +0 -1
  106. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts +0 -1
  107. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js +0 -1
  108. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts +0 -1
  109. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js +0 -1
  110. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts +0 -1
  111. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js +0 -1
  112. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts +0 -1
  113. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js +0 -1
  114. package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts +0 -1
  115. package/dist/react/components/rtc-widget/components/conviComponents/index.js +0 -1
  116. package/dist/react/components/rtc-widget/components/index.d.ts +0 -1
  117. package/dist/react/components/rtc-widget/components/index.js +0 -1
  118. package/dist/react/components/rtc-widget/index.d.ts +0 -1
  119. package/dist/react/components/rtc-widget/index.js +0 -1
  120. package/dist/react/components/rtc-widget/styles/framerConfig.d.ts +0 -1
  121. package/dist/react/components/rtc-widget/styles/framerConfig.js +0 -1
  122. package/dist/react/components/rtc-widget/styles/icons.d.ts +0 -1
  123. package/dist/react/components/rtc-widget/styles/icons.js +0 -1
  124. package/dist/react/components/rtc-widget/styles/index.d.ts +0 -1
  125. package/dist/react/components/rtc-widget/styles/index.js +0 -1
  126. package/dist/react/components/rtc-widget/styles/styledComponents.d.ts +0 -1
  127. package/dist/react/components/rtc-widget/styles/styledComponents.js +0 -1
  128. package/dist/react/components/rtc-widget/styles/theme.d.ts +0 -1
  129. package/dist/react/components/rtc-widget/styles/theme.js +0 -1
  130. package/dist/react/components/rtc-widget/types/index.d.ts +0 -1
  131. package/dist/react/components/rtc-widget/types/index.js +0 -1
  132. package/dist/react/hooks/index.d.ts +0 -1
  133. package/dist/react/hooks/index.js +0 -1
  134. package/dist/react/hooks/useCharacterInfo.d.ts +12 -11
  135. package/dist/react/hooks/useCharacterInfo.js +49 -50
  136. package/dist/react/hooks/useConvaiClient.d.ts +0 -1
  137. package/dist/react/hooks/useConvaiClient.js +6 -5
  138. package/dist/react/hooks/useLocalCameraTrack.d.ts +0 -1
  139. package/dist/react/hooks/useLocalCameraTrack.js +0 -1
  140. package/dist/react/icons.d.ts +0 -1
  141. package/dist/react/icons.js +0 -1
  142. package/dist/react/index.d.ts +0 -1
  143. package/dist/react/index.js +0 -1
  144. package/dist/utils/inlineMarkdown.d.ts +0 -1
  145. package/dist/utils/inlineMarkdown.js +0 -1
  146. package/dist/utils/lightbox.d.ts +0 -1
  147. package/dist/utils/lightbox.js +0 -1
  148. package/dist/utils/linkPresentation.d.ts +0 -1
  149. package/dist/utils/linkPresentation.js +0 -1
  150. package/dist/utils/linkPreview.d.ts +0 -1
  151. package/dist/utils/linkPreview.js +0 -1
  152. package/dist/utils/logger.d.ts +0 -1
  153. package/dist/utils/logger.js +0 -1
  154. package/dist/vanilla/AudioRenderer.d.ts +0 -1
  155. package/dist/vanilla/AudioRenderer.js +0 -1
  156. package/dist/vanilla/ConvaiWidget.d.ts +0 -1
  157. package/dist/vanilla/ConvaiWidget.js +18 -30
  158. package/dist/vanilla/WebSocketSession.d.ts +0 -1
  159. package/dist/vanilla/WebSocketSession.js +0 -1
  160. package/dist/vanilla/WidgetEventSubscriptions.d.ts +0 -1
  161. package/dist/vanilla/WidgetEventSubscriptions.js +0 -1
  162. package/dist/vanilla/icons.d.ts +0 -1
  163. package/dist/vanilla/icons.js +0 -1
  164. package/dist/vanilla/index.d.ts +0 -1
  165. package/dist/vanilla/index.js +0 -1
  166. package/dist/vanilla/styles.d.ts +0 -1
  167. package/dist/vanilla/styles.js +0 -1
  168. package/dist/vanilla/types.d.ts +0 -1
  169. package/dist/vanilla/types.js +0 -1
  170. package/dist/vanilla/websocket.d.ts +0 -1
  171. package/dist/vanilla/websocket.js +0 -1
  172. package/dist/version.d.ts +1 -2
  173. package/dist/version.js +1 -2
  174. package/package.json +3 -3
  175. package/dist/core/AudioManager.d.ts.map +0 -1
  176. package/dist/core/AudioManager.js.map +0 -1
  177. package/dist/core/BlendshapeQueue.d.ts.map +0 -1
  178. package/dist/core/BlendshapeQueue.js.map +0 -1
  179. package/dist/core/CharacterRoster.d.ts.map +0 -1
  180. package/dist/core/CharacterRoster.js.map +0 -1
  181. package/dist/core/CharacterVersionManager.d.ts.map +0 -1
  182. package/dist/core/CharacterVersionManager.js.map +0 -1
  183. package/dist/core/ConnectionStateHandler.d.ts.map +0 -1
  184. package/dist/core/ConnectionStateHandler.js.map +0 -1
  185. package/dist/core/ConvaiClient.d.ts.map +0 -1
  186. package/dist/core/ConvaiClient.js.map +0 -1
  187. package/dist/core/ConvaiRoomError.d.ts.map +0 -1
  188. package/dist/core/ConvaiRoomError.js.map +0 -1
  189. package/dist/core/EventEmitter.d.ts.map +0 -1
  190. package/dist/core/EventEmitter.js.map +0 -1
  191. package/dist/core/MemoryManager.d.ts.map +0 -1
  192. package/dist/core/MemoryManager.js.map +0 -1
  193. package/dist/core/MessageHandler.d.ts.map +0 -1
  194. package/dist/core/MessageHandler.js.map +0 -1
  195. package/dist/core/SSESession.d.ts.map +0 -1
  196. package/dist/core/SSESession.js.map +0 -1
  197. package/dist/core/ScreenShareManager.d.ts.map +0 -1
  198. package/dist/core/ScreenShareManager.js.map +0 -1
  199. package/dist/core/VideoManager.d.ts.map +0 -1
  200. package/dist/core/VideoManager.js.map +0 -1
  201. package/dist/core/characterReference.d.ts.map +0 -1
  202. package/dist/core/characterReference.js.map +0 -1
  203. package/dist/core/connectRequest.d.ts.map +0 -1
  204. package/dist/core/connectRequest.js.map +0 -1
  205. package/dist/core/contextUpdateRequest.d.ts.map +0 -1
  206. package/dist/core/contextUpdateRequest.js.map +0 -1
  207. package/dist/core/index.d.ts.map +0 -1
  208. package/dist/core/index.js.map +0 -1
  209. package/dist/core/logicalTurn.d.ts.map +0 -1
  210. package/dist/core/logicalTurn.js.map +0 -1
  211. package/dist/core/modelOutput.d.ts.map +0 -1
  212. package/dist/core/modelOutput.js.map +0 -1
  213. package/dist/core/publishedChat.d.ts.map +0 -1
  214. package/dist/core/publishedChat.js.map +0 -1
  215. package/dist/core/rosterRequest.d.ts.map +0 -1
  216. package/dist/core/rosterRequest.js.map +0 -1
  217. package/dist/core/rtviEnvelope.d.ts.map +0 -1
  218. package/dist/core/rtviEnvelope.js.map +0 -1
  219. package/dist/core/types.d.ts.map +0 -1
  220. package/dist/core/types.js.map +0 -1
  221. package/dist/core/videoSourceState.d.ts.map +0 -1
  222. package/dist/core/videoSourceState.js.map +0 -1
  223. package/dist/core/visionRequest.d.ts.map +0 -1
  224. package/dist/core/visionRequest.js.map +0 -1
  225. package/dist/embed/index.d.ts.map +0 -1
  226. package/dist/embed/index.js.map +0 -1
  227. package/dist/embed/publicationApi.d.ts.map +0 -1
  228. package/dist/embed/publicationApi.js.map +0 -1
  229. package/dist/index.d.ts.map +0 -1
  230. package/dist/index.js.map +0 -1
  231. package/dist/lipsync-helpers/arkitOrder61.d.ts.map +0 -1
  232. package/dist/lipsync-helpers/arkitOrder61.js.map +0 -1
  233. package/dist/lipsync-helpers/createBlendshapeQueue.d.ts.map +0 -1
  234. package/dist/lipsync-helpers/createBlendshapeQueue.js.map +0 -1
  235. package/dist/lipsync-helpers/declarativeMapping.d.ts.map +0 -1
  236. package/dist/lipsync-helpers/declarativeMapping.js.map +0 -1
  237. package/dist/lipsync-helpers/index.d.ts.map +0 -1
  238. package/dist/lipsync-helpers/index.js.map +0 -1
  239. package/dist/lipsync-helpers/mappingTypes.d.ts.map +0 -1
  240. package/dist/lipsync-helpers/mappingTypes.js.map +0 -1
  241. package/dist/lipsync-helpers/metahumanOrder251.d.ts.map +0 -1
  242. package/dist/lipsync-helpers/metahumanOrder251.js.map +0 -1
  243. package/dist/lipsync-helpers/mhaLimitDrivers.d.ts.map +0 -1
  244. package/dist/lipsync-helpers/mhaLimitDrivers.js.map +0 -1
  245. package/dist/lipsync-helpers/naturalness/processor.d.ts.map +0 -1
  246. package/dist/lipsync-helpers/naturalness/processor.js.map +0 -1
  247. package/dist/lipsync-helpers/naturalness/profiles/mha.d.ts.map +0 -1
  248. package/dist/lipsync-helpers/naturalness/profiles/mha.js.map +0 -1
  249. package/dist/lipsync-helpers/naturalness/types.d.ts.map +0 -1
  250. package/dist/lipsync-helpers/naturalness/types.js.map +0 -1
  251. package/dist/lipsync-helpers/presetMappers.d.ts.map +0 -1
  252. package/dist/lipsync-helpers/presetMappers.js.map +0 -1
  253. package/dist/react/components/ConvaiWidget.d.ts.map +0 -1
  254. package/dist/react/components/ConvaiWidget.js.map +0 -1
  255. package/dist/react/components/index.d.ts.map +0 -1
  256. package/dist/react/components/index.js.map +0 -1
  257. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.d.ts.map +0 -1
  258. package/dist/react/components/rtc-widget/components/AudioSettingsPanel.js.map +0 -1
  259. package/dist/react/components/rtc-widget/components/AudioVisualizer.d.ts.map +0 -1
  260. package/dist/react/components/rtc-widget/components/AudioVisualizer.js.map +0 -1
  261. package/dist/react/components/rtc-widget/components/ConviMessage.d.ts.map +0 -1
  262. package/dist/react/components/rtc-widget/components/ConviMessage.js.map +0 -1
  263. package/dist/react/components/rtc-widget/components/FloatingVideo.d.ts.map +0 -1
  264. package/dist/react/components/rtc-widget/components/FloatingVideo.js.map +0 -1
  265. package/dist/react/components/rtc-widget/components/MarkdownRenderer.d.ts.map +0 -1
  266. package/dist/react/components/rtc-widget/components/MarkdownRenderer.js.map +0 -1
  267. package/dist/react/components/rtc-widget/components/MessageBubble.d.ts.map +0 -1
  268. package/dist/react/components/rtc-widget/components/MessageBubble.js.map +0 -1
  269. package/dist/react/components/rtc-widget/components/MessageList.d.ts.map +0 -1
  270. package/dist/react/components/rtc-widget/components/MessageList.js.map +0 -1
  271. package/dist/react/components/rtc-widget/components/SiteCard.d.ts.map +0 -1
  272. package/dist/react/components/rtc-widget/components/SiteCard.js.map +0 -1
  273. package/dist/react/components/rtc-widget/components/UserMessage.d.ts.map +0 -1
  274. package/dist/react/components/rtc-widget/components/UserMessage.js.map +0 -1
  275. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts.map +0 -1
  276. package/dist/react/components/rtc-widget/components/conviComponents/ConviButton.js.map +0 -1
  277. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts.map +0 -1
  278. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js.map +0 -1
  279. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts.map +0 -1
  280. package/dist/react/components/rtc-widget/components/conviComponents/ConviHeader.js.map +0 -1
  281. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts.map +0 -1
  282. package/dist/react/components/rtc-widget/components/conviComponents/SettingsTray.js.map +0 -1
  283. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts.map +0 -1
  284. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js.map +0 -1
  285. package/dist/react/components/rtc-widget/components/conviComponents/index.d.ts.map +0 -1
  286. package/dist/react/components/rtc-widget/components/conviComponents/index.js.map +0 -1
  287. package/dist/react/components/rtc-widget/components/index.d.ts.map +0 -1
  288. package/dist/react/components/rtc-widget/components/index.js.map +0 -1
  289. package/dist/react/components/rtc-widget/index.d.ts.map +0 -1
  290. package/dist/react/components/rtc-widget/index.js.map +0 -1
  291. package/dist/react/components/rtc-widget/styles/framerConfig.d.ts.map +0 -1
  292. package/dist/react/components/rtc-widget/styles/framerConfig.js.map +0 -1
  293. package/dist/react/components/rtc-widget/styles/icons.d.ts.map +0 -1
  294. package/dist/react/components/rtc-widget/styles/icons.js.map +0 -1
  295. package/dist/react/components/rtc-widget/styles/index.d.ts.map +0 -1
  296. package/dist/react/components/rtc-widget/styles/index.js.map +0 -1
  297. package/dist/react/components/rtc-widget/styles/styledComponents.d.ts.map +0 -1
  298. package/dist/react/components/rtc-widget/styles/styledComponents.js.map +0 -1
  299. package/dist/react/components/rtc-widget/styles/theme.d.ts.map +0 -1
  300. package/dist/react/components/rtc-widget/styles/theme.js.map +0 -1
  301. package/dist/react/components/rtc-widget/types/index.d.ts.map +0 -1
  302. package/dist/react/components/rtc-widget/types/index.js.map +0 -1
  303. package/dist/react/hooks/index.d.ts.map +0 -1
  304. package/dist/react/hooks/index.js.map +0 -1
  305. package/dist/react/hooks/useCharacterInfo.d.ts.map +0 -1
  306. package/dist/react/hooks/useCharacterInfo.js.map +0 -1
  307. package/dist/react/hooks/useConvaiClient.d.ts.map +0 -1
  308. package/dist/react/hooks/useConvaiClient.js.map +0 -1
  309. package/dist/react/hooks/useLocalCameraTrack.d.ts.map +0 -1
  310. package/dist/react/hooks/useLocalCameraTrack.js.map +0 -1
  311. package/dist/react/icons.d.ts.map +0 -1
  312. package/dist/react/icons.js.map +0 -1
  313. package/dist/react/index.d.ts.map +0 -1
  314. package/dist/react/index.js.map +0 -1
  315. package/dist/utils/inlineMarkdown.d.ts.map +0 -1
  316. package/dist/utils/inlineMarkdown.js.map +0 -1
  317. package/dist/utils/lightbox.d.ts.map +0 -1
  318. package/dist/utils/lightbox.js.map +0 -1
  319. package/dist/utils/linkPresentation.d.ts.map +0 -1
  320. package/dist/utils/linkPresentation.js.map +0 -1
  321. package/dist/utils/linkPreview.d.ts.map +0 -1
  322. package/dist/utils/linkPreview.js.map +0 -1
  323. package/dist/utils/logger.d.ts.map +0 -1
  324. package/dist/utils/logger.js.map +0 -1
  325. package/dist/vanilla/AudioRenderer.d.ts.map +0 -1
  326. package/dist/vanilla/AudioRenderer.js.map +0 -1
  327. package/dist/vanilla/ConvaiWidget.d.ts.map +0 -1
  328. package/dist/vanilla/ConvaiWidget.js.map +0 -1
  329. package/dist/vanilla/WebSocketSession.d.ts.map +0 -1
  330. package/dist/vanilla/WebSocketSession.js.map +0 -1
  331. package/dist/vanilla/WidgetEventSubscriptions.d.ts.map +0 -1
  332. package/dist/vanilla/WidgetEventSubscriptions.js.map +0 -1
  333. package/dist/vanilla/icons.d.ts.map +0 -1
  334. package/dist/vanilla/icons.js.map +0 -1
  335. package/dist/vanilla/index.d.ts.map +0 -1
  336. package/dist/vanilla/index.js.map +0 -1
  337. package/dist/vanilla/styles.d.ts.map +0 -1
  338. package/dist/vanilla/styles.js.map +0 -1
  339. package/dist/vanilla/types.d.ts.map +0 -1
  340. package/dist/vanilla/types.js.map +0 -1
  341. package/dist/vanilla/websocket.d.ts.map +0 -1
  342. package/dist/vanilla/websocket.js.map +0 -1
  343. package/dist/version.d.ts.map +0 -1
  344. package/dist/version.js.map +0 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Real-time conversational AI characters for the web.**
4
4
 
5
- [![npm](https://img.shields.io/badge/npm-1.8.0--beta.7-blue)](https://www.npmjs.com/package/@convai/web-sdk)
5
+ [![npm](https://img.shields.io/npm/v/@convai/web-sdk/latest?label=npm&color=blue)](https://www.npmjs.com/package/@convai/web-sdk)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-first-3178C6)](https://www.typescriptlang.org/)
7
7
  [![License](https://img.shields.io/badge/license-Apache--2.0-green)](./LICENSE)
8
8
 
@@ -10,19 +10,44 @@ TypeScript-first SDK for embedding Convai AI characters into React and vanilla J
10
10
 
11
11
  ---
12
12
 
13
- ## What's new in 1.8.0 (beta)
13
+ ## What's new in 1.9.0
14
14
 
15
- Install the beta with `npm install @convai/web-sdk@beta`.
15
+ > **Breaking for 1.8.0 users:** the `<convai-chat>` custom element and the `./embed/browser` entry point (`dist/embed/chat-embed-v1.js`) are removed. The copy/paste published-chat embed is now `<convai-widget>` from [`@convai/web-widget`](https://www.npmjs.com/package/@convai/web-widget); the [CHANGELOG](./CHANGELOG.md) has the before/after snippet.
16
16
 
17
17
  - **Multi-character rooms** — connect a roster of characters with the `characters` config option (two copies of one character are two independent members), switch who answers with `setInteractionTarget()`, add or remove members live with `updateCharacterRoster()`, and let other participants join the same room with `joinRoom()`. Every transcript line, audio track and readiness event is attributed to a `membershipId`. [Usage below.](#multi-character-rooms-beta)
18
- - **Agentic actions and canonical model output (v2)** — opt in with `capabilities`, declare client-executed tools in `actionConfig.tools`, consume typed `modelOutput` envelopes, return results with `sendActionResultAndWait()` for a correlated server acknowledgement, and read the raw provider stream through `botLlmTextRaw`. `visionPromptMode: "disabled"` keeps scene context without advertising visual perception. [Usage below.](#agentic-actions-and-canonical-model-output-v2)
19
- - **Published text chat** — a credential-free, text-only connection for public chat pages: `connectWithPublicationGrant()` and `connectionType: "text"`. For a copy/paste embed, pair it with [`@convai/web-widget`](https://www.npmjs.com/package/@convai/web-widget). [Usage below.](#published-text-chat)
20
18
  - **Typed events** — `client.on(event, callback)` infers each callback's payload from the exported `ConvaiEventMap`, so `botReady`, `modelOutput`, `characterStatus` and the rest are checked at compile time. See the [events reference](docs/convai_events.md).
21
- - **Local transcript lines and usage updates** — `appendMessage()` inserts a line into the transcript without sending anything, and `toggleUsageUpdates(true)` opts into per-turn `usageUpdate` cost breakdowns.
19
+ - **Local transcript lines and usage updates** — `appendMessage()` inserts a line into the transcript without sending anything, and `toggleUsageUpdates(true)` opts into per-turn `usageUpdate` cost breakdowns (on a session connected with `debug: true`; otherwise the server has no usage stream).
22
20
  - **Character versioning** — connect to a character's editable draft, its promoted latest release, or an immutable tag with the `characterVersion` config option, and list, compare, release, promote, fork and discard versions through `client.characterVersions`. [Usage below.](#character-versioning-beta)
23
- - **SSE interaction transport** — text-only streamed interactions through the interaction API, selected by `interactionApiUrl`; the one transport that runs under Node. [Usage below.](#sse-interaction-transport-beta)
21
+ - **SSE interaction transport** — chat over the interaction API, selected by `interactionApiUrl`: text in, the reply streamed as text and, with `ttsEnabled`, as speech (`audioData`); the one transport that runs under Node. We recommend SSE for chat and realtime for voice — see [Choosing a Transport](docs/convai_choosing_transport.md). [Usage below.](#sse-interaction-transport-beta)
24
22
  - **Embeddable vanilla widget** — the vanilla widget runs inside a shadow root, with a character header and a connecting overlay, so it can be dropped into any page.
25
23
  - **Node-importable dist** — `@convai/web-sdk/core`, `/vanilla`, `/vanilla/websocket` and `/lipsync-helpers` load in plain Node, SSR and Next.js server components.
24
+ - **Character voice mute** — `setCharacterMuted()` / `isCharacterMuted()` silence the character's voice for the listener; `audioControls` stays the microphone.
25
+ - **Raw transport frames** — the typed `rawMessage` event exposes incoming LiveKit, WebSocket and SSE frames.
26
+ - **Smaller install** — 220 MB → 36 MB of dependencies, and no shipped source maps (681.9 kB → 290.5 kB packed).
27
+
28
+ ### Previously in 1.8.0
29
+
30
+ - **Protocol capabilities, opted into one at a time** — `capabilities`
31
+ selects v2 correlated client tool calls, the canonical Core-validated
32
+ `modelOutput` envelope, and raw `bot-llm-text` streaming, each independent
33
+ of the others. Core must confirm a v2 capability or the SDK refuses the
34
+ connection, so a half-upgraded backend fails at connect rather than
35
+ mid-conversation. Omit the block entirely and nothing changes: existing
36
+ connections and one-argument text messages stay on the v1 wire contract.
37
+ [Options table.](./docs/convai_configuration.md#protocol-capabilities)
38
+ - **Correlated action results and logical turns** — action results carry the
39
+ call they answer, and turn correlation holds across multi-envelope and
40
+ voice turns, so a response can be tied to its cause without guessing from
41
+ arrival order.
42
+ - **Extension renderer registry** — render custom model-output extensions
43
+ without the SDK knowing your UI framework.
44
+ - **Published chat without a credential** — a text-only connection method for
45
+ published-chat launch grants, plus a native custom-element browser bundle
46
+ at `dist/embed/chat-embed-v1.js` for iframe-free embeds. The embed never
47
+ receives a publisher API key. [Usage below.](#published-text-chat)
48
+ - **Loads in Node without a bundler** — emitted ESM carries explicit relative
49
+ extensions, so the published package and the Chat Publish client resolve
50
+ under plain Node resolution.
26
51
 
27
52
  ### Previously in 1.7.0
28
53
 
@@ -31,7 +56,7 @@ Install the beta with `npm install @convai/web-sdk@beta`.
31
56
  - **Lipsync naturalness pipeline** — modular naturalness processing with a tuned MetaHuman profile.
32
57
  - **Adaptive glass widget styling** — `ConvaiWidget` adapts to light and dark backgrounds.
33
58
 
34
- ### 1.6.0
59
+ ### Previously in 1.6.0
35
60
 
36
61
  - **Narrative Design template keys** — personalize one narrative graph per session: seed values at connect with the `narrativeTemplateKeys` config option, replace them mid-session with `updateTemplateKeys()`. [Usage below.](#narrative-design-template-keys)
37
62
  - **Typed parameterized actions** — `actionResponse` is now typed via the exported `ConvaiAction` / `ActionResponseEvent`, including the `target` of parameterized actions. [Usage below.](#actions)
@@ -236,7 +261,8 @@ Full documentation is at **<a href="https://docs.convai.com/api-docs/plugins-and
236
261
  | <a href="https://docs.convai.com/api-docs/plugins-and-integrations/web-plugins/convai-web-sdk/error-handling" target="_blank" rel="noopener noreferrer">Error Handling</a> | `error`, `disconnect`, `serverResponse`, retry patterns |
237
262
  | <a href="https://docs.convai.com/api-docs/plugins-and-integrations/web-plugins/convai-web-sdk/auth-tokens" target="_blank" rel="noopener noreferrer">Auth Tokens</a> | Server-side token exchange for production |
238
263
  | <a href="https://docs.convai.com/api-docs/plugins-and-integrations/web-plugins/convai-web-sdk/websocket-transport-layer" target="_blank" rel="noopener noreferrer">WebSocket Transport</a> | Alternative transport for WebRTC-constrained environments |
239
- | <a href="https://docs.convai.com/api-docs/plugins-and-integrations/web-plugins/convai-web-sdk" target="_blank" rel="noopener noreferrer">SSE Transport</a> | Text-only interaction transport; the one that runs under Node |
264
+ | <a href="https://docs.convai.com/api-docs/plugins-and-integrations/web-plugins/convai-web-sdk" target="_blank" rel="noopener noreferrer">SSE Transport</a> | Chat transport: text in, text or audio out; the one that runs under Node |
265
+ | [Choosing a Transport](docs/convai_choosing_transport.md) | SSE vs realtime vs WebSocket, the recommended SSE-chat-plus-voice-mode setup, and why |
240
266
  | [Character Versioning](docs/convai_character_versioning.md) | Connect to a draft, latest, or tagged version; list, compare, release and promote versions |
241
267
  | [Multi-Character Rooms](docs/convai_multi_character.md) | Rosters, `joinRoom`, interaction targets, live roster updates, per-member attribution |
242
268
  | [Published Text Chat](docs/convai_published_chat.md) | Grant-based text-only sessions, the copy/paste embed, lifecycle and API reference |
@@ -297,7 +323,7 @@ See the <a href="https://docs.convai.com/api-docs/plugins-and-integrations/web-p
297
323
 
298
324
  ## SSE interaction transport (beta)
299
325
 
300
- Use the interaction API for text-only integrations that need a streamed response:
326
+ Use the interaction API for chat — typed input, with the reply streamed as text and, optionally, speech:
301
327
 
302
328
  ```ts
303
329
  const client = new ConvaiClient({
@@ -311,10 +337,15 @@ client.sendUserTextMessage("Hello!");
311
337
  ```
312
338
 
313
339
  This sends each message as an SSE `POST` with `Authorization: Bearer ...`. Set `transport: "sse"`
314
- explicitly if preferred. SSE carries text only — no voice, video, or lipsync — and it never calls
340
+ explicitly if preferred. With `ttsEnabled: true` the reply's speech streams as `audioData`
341
+ events on the same response; there is no microphone, video, or lipsync. It never calls
315
342
  `/connect`, so `connect()` makes no network request and the session id arrives on the first
316
343
  interaction via the `characterSessionId` event.
317
344
 
345
+ We recommend SSE for chat and realtime for voice: start on SSE and move the same conversation to
346
+ realtime when the user wants to talk. See [Choosing a Transport](docs/convai_choosing_transport.md)
347
+ for why, and for building on one transport only.
348
+
318
349
  Because it needs neither WebRTC nor a DOM, this is the only transport that runs outside a browser.
319
350
  Import `@convai/web-sdk/core` from Node, SSR, or a serverless function — not the root or `/react`
320
351
  entry points, which pull in browser-only dependencies.
@@ -473,7 +504,7 @@ const triggerId = client.visionTrigger({
473
504
  await client.videoControls.unpublishVisionSource(handle);
474
505
  ```
475
506
 
476
- `visionStatus()` and `visionTrigger()` return an update id. Match it against `serverResponse` events for outcomes such as `frames_available`, `buffer_empty`, `attached`, or `no_active_video`.
507
+ `visionStatus()` and `visionTrigger()` return an update id. Match it against `serverResponse` events for outcomes such as `frames_available`, `buffer_empty`, `attached`, `no_active_video` or `vision_not_enabled`. Vision needs more than `enableVideo: true`: the account's unified vision context feature and a vision-capable, non-realtime model. Without them frames publish fine but are never seen, and the SDK warns once per session.
477
508
 
478
509
  ---
479
510
 
@@ -641,7 +672,7 @@ client.updateEmotion("joy");
641
672
  client.updateEmotion(null); // clear — "neutral" and "" clear it too
642
673
  ```
643
674
 
644
- Values are trimmed and lowercased. The runtime value carries into the next connect, including a reconnect; an explicit `stateOfMind` in the connect config takes precedence.
675
+ The server applies Plutchik's eight primary emotions — `joy`, `trust`, `fear`, `surprise`, `sadness`, `disgust`, `anger`, `anticipation` — and ignores anything else (the SDK warns). Values are trimmed and lowercased. The runtime value carries into the next connect, including a reconnect; an explicit `stateOfMind` in the connect config takes precedence.
645
676
 
646
677
  Requires backend support — live on production as of 2026-08-20. On a backend without it, the server replies with an `Unknown message type` error on `serverResponse`. Because `/connect` silently ignores unknown fields, a successful connect alone does not prove `state_of_mind` was applied, so watch the ack:
647
678
 
@@ -84,4 +84,3 @@ export declare class AudioManager extends EventEmitter implements AudioControls
84
84
  */
85
85
  reset(): void;
86
86
  }
87
- //# sourceMappingURL=AudioManager.d.ts.map
@@ -285,4 +285,3 @@ export class AudioManager extends EventEmitter {
285
285
  });
286
286
  }
287
287
  }
288
- //# sourceMappingURL=AudioManager.js.map
@@ -270,4 +270,3 @@ export declare class BlendshapeQueue {
270
270
  playbackFps: number;
271
271
  };
272
272
  }
273
- //# sourceMappingURL=BlendshapeQueue.d.ts.map
@@ -20,6 +20,25 @@
20
20
  * - Mapper is applied when frames are added to the queue
21
21
  * - Common use cases: ARKit 61 → ARKit 52, MetaHuman 251 → Custom format
22
22
  */
23
+ /**
24
+ * A frame scaled by alpha. Mapper output keeps its shape: the
25
+ * lipsync-helpers name mappers hang target names on the array
26
+ * (`__blendshapeNames`) or return `{ names, values, ... }`, and a fade that
27
+ * dropped either made getBlendshapeObject() return {} on faded frames.
28
+ */
29
+ function scaleFrame(frame, alpha) {
30
+ const optimized = frame;
31
+ if (!(frame instanceof Float32Array) && optimized.values instanceof Float32Array) {
32
+ return { ...optimized, values: optimized.values.map((v) => v * alpha) };
33
+ }
34
+ const faded = new Float32Array(frame.length);
35
+ for (let i = 0; i < frame.length; i++)
36
+ faded[i] = frame[i] * alpha;
37
+ const names = frame.__blendshapeNames;
38
+ if (names)
39
+ Object.defineProperty(faded, "__blendshapeNames", { value: names, enumerable: false });
40
+ return faded;
41
+ }
23
42
  export class BlendshapeQueue {
24
43
  /**
25
44
  * Create a new BlendshapeQueue
@@ -425,11 +444,7 @@ export class BlendshapeQueue {
425
444
  }
426
445
  // Apply alpha to all morph values
427
446
  if (alpha < 1.0) {
428
- const fadedFrame = new Float32Array(frame.length);
429
- for (let i = 0; i < frame.length; i++) {
430
- fadedFrame[i] = frame[i] * alpha;
431
- }
432
- return fadedFrame;
447
+ return scaleFrame(frame, alpha);
433
448
  }
434
449
  return frame;
435
450
  }
@@ -770,4 +785,3 @@ export class BlendshapeQueue {
770
785
  BlendshapeQueue.TARGET_FPS = 60;
771
786
  BlendshapeQueue.MAX_RETIRED_TIMELINE_ALIASES = 48;
772
787
  BlendshapeQueue.MISSING_INDEXED_FRAME_GRACE_MS = (24 / BlendshapeQueue.TARGET_FPS) * 1000;
773
- //# sourceMappingURL=BlendshapeQueue.js.map
@@ -81,4 +81,3 @@ export declare class CharacterRoster {
81
81
  */
82
82
  applyConnectResponse(data: Record<string, unknown>): boolean;
83
83
  }
84
- //# sourceMappingURL=CharacterRoster.d.ts.map
@@ -345,4 +345,3 @@ function asString(value) {
345
345
  function asNumber(value) {
346
346
  return typeof value === "number" && Number.isFinite(value) ? value : null;
347
347
  }
348
- //# sourceMappingURL=CharacterRoster.js.map
@@ -97,4 +97,3 @@ export declare class CharacterVersionManager {
97
97
  private assertTag;
98
98
  private request;
99
99
  }
100
- //# sourceMappingURL=CharacterVersionManager.d.ts.map
@@ -224,4 +224,3 @@ function describeFailure(status, data) {
224
224
  return `HTTP ${status}: ${data}`;
225
225
  return `HTTP ${status}`;
226
226
  }
227
- //# sourceMappingURL=CharacterVersionManager.js.map
@@ -26,4 +26,3 @@ export declare class ConnectionStateHandler {
26
26
  */
27
27
  resetConnectionState(): void;
28
28
  }
29
- //# sourceMappingURL=ConnectionStateHandler.d.ts.map
@@ -51,7 +51,11 @@ export class ConnectionStateHandler {
51
51
  isConnected: true,
52
52
  isConnecting: false,
53
53
  });
54
- this.onBotReadyChange(false); // Wait for bot-ready message
54
+ // Do not reset bot-ready here. Connecting (and Disconnected) already
55
+ // did, so a fresh connect still waits for it — but the first bot-ready
56
+ // data frame can arrive before this event (measured: 3ms early, 1
57
+ // connect in 5). Resetting then dropped it: botReady fired twice, and
58
+ // isBotReady stayed false until the server happened to send another.
55
59
  }
56
60
  else if (state === ConnectionState.Connecting) {
57
61
  this.onStateUpdate({
@@ -81,4 +85,3 @@ export class ConnectionStateHandler {
81
85
  this.onMessageHandlerReset();
82
86
  }
83
87
  }
84
- //# sourceMappingURL=ConnectionStateHandler.js.map
@@ -1,5 +1,5 @@
1
1
  import { Room } from "livekit-client";
2
- import { ConvaiConfig, ConvaiClientState, ChatMessage, IConvaiClient, PublishedChatConnectOptions, AudioControls, CharacterMuteOptions, VideoControls, ScreenShareControls, DynamicInfo, ContextUpdateOptions, UploadFileOptions, ServerResponse, WebSocketSessionFactory, RespondModeUpdateOptions, UpdateSceneMetadataOptions, VisionStatusOptions, VisionTriggerOptions, ConnectionData, SendUserTextMessageOptions, ConvaiCharacterInstance, ConvaiRoomSession, JoinRoomOptions, ActiveCharacterChange, CharacterRosterChange, UpdateCharacterRosterOptions, AppendMessageOptions, ConvaiEventMap, ActionResult, ActionResultAck, ActionResultAckFailureReason, ActionResultAckOptions } from "./types.js";
2
+ import { ConvaiConfig, ConvaiClientState, ChatMessage, IConvaiClient, PublishedChatConnectOptions, AudioControls, CharacterMuteOptions, VideoControls, ScreenShareControls, DynamicInfo, ContextUpdateOptions, UploadFileOptions, ServerResponse, WebSocketSessionFactory, RespondModeUpdateOptions, UpdateSceneMetadataOptions, VisionStatusOptions, VisionTriggerOptions, ConnectionData, SendUserTextMessageOptions, StateOfMindInput, ConvaiCharacterInstance, ConvaiRoomSession, JoinRoomOptions, ActiveCharacterChange, CharacterRosterChange, UpdateCharacterRosterOptions, AppendMessageOptions, ConvaiEventMap, ActionResult, ActionResultAck, ActionResultAckFailureReason, ActionResultAckOptions } from "./types.js";
3
3
  import { EventEmitter } from "./EventEmitter.js";
4
4
  import { BlendshapeQueue } from "./BlendshapeQueue.js";
5
5
  import { MemoryManager } from "./MemoryManager.js";
@@ -91,6 +91,12 @@ export declare class ConvaiClient extends EventEmitter implements IConvaiClient
91
91
  private _rosterCommandSeq;
92
92
  private _requestTraceId;
93
93
  private _isBotReady;
94
+ /** turnEnd held back until speaking stays stopped (see speakingChange). */
95
+ private _pendingTurnEnd;
96
+ /** How long speaking must stay stopped before a turn is reported ended. */
97
+ private static readonly TURN_END_SETTLE_MS;
98
+ /** Warn once per connect when Core reports vision off for the session. */
99
+ private _warnedVisionNotEnabled;
94
100
  private _participantSid;
95
101
  private _audioSettings;
96
102
  private _storedConfig;
@@ -99,6 +105,17 @@ export declare class ConvaiClient extends EventEmitter implements IConvaiClient
99
105
  * so updateEmotion() called before any config is stored is not lost.
100
106
  */
101
107
  private _stateOfMind;
108
+ /** States of mind published and not yet acked, oldest first; acks arrive in send order. */
109
+ private _pendingStateOfMindAcks;
110
+ /**
111
+ * Match an update-emotion ack to a value this client sent. The ack carries
112
+ * no request id, its state_of_mind is the state still in effect rather than
113
+ * the value it judged, and acks can arrive out of order (measured: "happy"'s
114
+ * rejection before "joy"'s success). So an applied ack settles the value it
115
+ * names, and a rejected one settles the oldest pending value that is not an
116
+ * accepted state of mind. Returns the rejected value, when it can be named.
117
+ */
118
+ private _settleStateOfMindAck;
102
119
  private _endUserId;
103
120
  private _endUserMetadata;
104
121
  private _wsSession;
@@ -180,6 +197,11 @@ export declare class ConvaiClient extends EventEmitter implements IConvaiClient
180
197
  get requestTraceId(): string | null;
181
198
  get isBotReady(): boolean;
182
199
  get audioControls(): AudioControls;
200
+ /**
201
+ * Configured origin for the widget's character name/avatar lookup, or null
202
+ * when unset. See {@link ConvaiConfig.characterInfoUrl}.
203
+ */
204
+ get characterInfoUrl(): string | null;
183
205
  /**
184
206
  * Silence the character's voice, or bring it back. See
185
207
  * {@link IConvaiClient.setCharacterMuted}.
@@ -456,7 +478,7 @@ export declare class ConvaiClient extends EventEmitter implements IConvaiClient
456
478
  * Set or clear the character's temporary state of mind.
457
479
  * This is silent: it affects the next response and does not trigger one.
458
480
  */
459
- updateEmotion(stateOfMind: string | null): void;
481
+ updateEmotion(stateOfMind: StateOfMindInput): void;
460
482
  /**
461
483
  * Send descriptive scene updates. Use when environment description changes
462
484
  * and the bot should know what is visible or nearby. Does not modify action_config.
@@ -465,6 +487,13 @@ export declare class ConvaiClient extends EventEmitter implements IConvaiClient
465
487
  name: string;
466
488
  description: string;
467
489
  }>, options?: UpdateSceneMetadataOptions): void;
490
+ /**
491
+ * Mirror a runtime respond-mode change into the stored config, so
492
+ * reconnect() — which replays _storedConfig — does not revert it. text and
493
+ * audio are typed `"must_respond"` only in the config, so other values for
494
+ * them stay runtime-only rather than widening that type.
495
+ */
496
+ private rememberRespondMode;
468
497
  private createUpdateId;
469
498
  private serializeRespondModes;
470
499
  /**
@@ -489,4 +518,3 @@ export declare class ConvaiClient extends EventEmitter implements IConvaiClient
489
518
  */
490
519
  resetIdleTimer(): void;
491
520
  }
492
- //# sourceMappingURL=ConvaiClient.d.ts.map
@@ -22,6 +22,10 @@ import { isJsonValue } from "./modelOutput.js";
22
22
  import { isValidLogicalTurnId } from "./logicalTurn.js";
23
23
  // Module-level registry — populated by importing @convai/web-sdk/vanilla/websocket
24
24
  let _wsFactory = null;
25
+ /** The states of mind Core applies (see StateOfMind); used only to name a rejection. */
26
+ const ACCEPTED_STATES_OF_MIND = new Set([
27
+ "joy", "trust", "fear", "surprise", "sadness", "disgust", "anger", "anticipation",
28
+ ]);
25
29
  function normalizeStateOfMind(value) {
26
30
  if (value == null)
27
31
  return value;
@@ -100,6 +104,29 @@ class NoReconnectPolicy extends DefaultReconnectPolicy {
100
104
  * ```
101
105
  */
102
106
  export class ConvaiClient extends EventEmitter {
107
+ /**
108
+ * Match an update-emotion ack to a value this client sent. The ack carries
109
+ * no request id, its state_of_mind is the state still in effect rather than
110
+ * the value it judged, and acks can arrive out of order (measured: "happy"'s
111
+ * rejection before "joy"'s success). So an applied ack settles the value it
112
+ * names, and a rejected one settles the oldest pending value that is not an
113
+ * accepted state of mind. Returns the rejected value, when it can be named.
114
+ */
115
+ _settleStateOfMindAck(response) {
116
+ const pending = this._pendingStateOfMindAcks;
117
+ if (response.extras?.applied === true) {
118
+ // The ack may name a later value already in effect, so fall back to
119
+ // the oldest accepted one — or the list grows for the whole session.
120
+ let i = pending.indexOf(response.extras.state_of_mind ?? null);
121
+ if (i === -1)
122
+ i = pending.findIndex((v) => v === null || ACCEPTED_STATES_OF_MIND.has(v));
123
+ if (i !== -1)
124
+ pending.splice(i, 1);
125
+ return undefined;
126
+ }
127
+ const i = pending.findIndex((v) => v !== null && !ACCEPTED_STATES_OF_MIND.has(v));
128
+ return i === -1 ? undefined : pending.splice(i, 1)[0];
129
+ }
103
130
  /**
104
131
  * Register the WebSocket transport factory. Called automatically as a side-effect
105
132
  * when you import `@convai/web-sdk/vanilla/websocket` (or the react equivalent).
@@ -139,6 +166,10 @@ export class ConvaiClient extends EventEmitter {
139
166
  this._rosterCommandSeq = 0;
140
167
  this._requestTraceId = null;
141
168
  this._isBotReady = false;
169
+ /** turnEnd held back until speaking stays stopped (see speakingChange). */
170
+ this._pendingTurnEnd = null;
171
+ /** Warn once per connect when Core reports vision off for the session. */
172
+ this._warnedVisionNotEnabled = false;
142
173
  this._participantSid = "";
143
174
  this._storedConfig = null;
144
175
  /**
@@ -146,6 +177,8 @@ export class ConvaiClient extends EventEmitter {
146
177
  * so updateEmotion() called before any config is stored is not lost.
147
178
  */
148
179
  this._stateOfMind = null;
180
+ /** States of mind published and not yet acked, oldest first; acks arrive in send order. */
181
+ this._pendingStateOfMindAcks = [];
149
182
  this._endUserId = null;
150
183
  this._endUserMetadata = null;
151
184
  this._wsSession = null;
@@ -326,6 +359,12 @@ export class ConvaiClient extends EventEmitter {
326
359
  toggleUsageUpdates(enabled) {
327
360
  if (!this.isTransportReady())
328
361
  return;
362
+ if (enabled && !this._storedConfig?.debug) {
363
+ // The server registers the usage stream only for debug sessions. Its
364
+ // refusal arrives as a serverResponse error nobody is listening for.
365
+ console.warn("[ConvaiClient] toggleUsageUpdates(true) needs a session connected with `debug: true`; " +
366
+ "without it the server sends no usageUpdate events.");
367
+ }
329
368
  this.publishMessage("usage-toggle", { enabled });
330
369
  }
331
370
  /** Insert a transcript line locally. Nothing is sent; nothing is billed. */
@@ -345,6 +384,13 @@ export class ConvaiClient extends EventEmitter {
345
384
  get audioControls() {
346
385
  return this._audioManager;
347
386
  }
387
+ /**
388
+ * Configured origin for the widget's character name/avatar lookup, or null
389
+ * when unset. See {@link ConvaiConfig.characterInfoUrl}.
390
+ */
391
+ get characterInfoUrl() {
392
+ return this._storedConfig?.characterInfoUrl ?? null;
393
+ }
348
394
  /**
349
395
  * Silence the character's voice, or bring it back. See
350
396
  * {@link IConvaiClient.setCharacterMuted}.
@@ -520,15 +566,28 @@ export class ConvaiClient extends EventEmitter {
520
566
  this._messageHandler.on("speakingChange", (isSpeaking) => {
521
567
  this.updateState({ isSpeaking });
522
568
  this.emit("speakingChange", isSpeaking);
523
- if (!isSpeaking && this._conversationSessionId > 0) {
524
- // Bot stopped speaking - turn end signal (same semantics as BlendshapeQueue.hasReceivedEndSignal())
525
- const duration = ((Date.now() - this._conversationStartTime) /
526
- 1000).toFixed(2);
527
- this.emit("turnEnd", {
528
- sessionId: this._conversationSessionId,
529
- duration: parseFloat(duration),
530
- timestamp: Date.now(),
531
- });
569
+ if (isSpeaking) {
570
+ // Speaking resumed: the stop was a gap between segments of one reply.
571
+ if (this._pendingTurnEnd)
572
+ clearTimeout(this._pendingTurnEnd);
573
+ this._pendingTurnEnd = null;
574
+ return;
575
+ }
576
+ if (this._conversationSessionId > 0) {
577
+ // A reply can be spoken in segments: live-sh-aws sent
578
+ // bot-stopped-speaking and bot-started-speaking in the same millisecond
579
+ // between two sentences, and each stop fired turnEnd. Report the end
580
+ // only if speaking does not resume within a beat; the duration and
581
+ // timestamp are still those of the stop.
582
+ const stoppedAt = Date.now();
583
+ const sessionId = this._conversationSessionId;
584
+ const duration = parseFloat(((stoppedAt - this._conversationStartTime) / 1000).toFixed(2));
585
+ if (this._pendingTurnEnd)
586
+ clearTimeout(this._pendingTurnEnd);
587
+ this._pendingTurnEnd = setTimeout(() => {
588
+ this._pendingTurnEnd = null;
589
+ this.emit("turnEnd", { sessionId, duration, timestamp: stoppedAt });
590
+ }, ConvaiClient.TURN_END_SETTLE_MS);
532
591
  }
533
592
  });
534
593
  this._messageHandler.on("botRespondingChange", (isResponding) => {
@@ -653,6 +712,24 @@ export class ConvaiClient extends EventEmitter {
653
712
  });
654
713
  this._messageHandler.on("serverResponse", (response, request) => {
655
714
  this._handleRosterServerResponse(response);
715
+ // The server acks an unknown state of mind as a *success* with
716
+ // applied: false, so without this nothing tells the caller it did nothing.
717
+ const sent = response.event_type === "update-emotion" ? this._settleStateOfMindAck(response) : undefined;
718
+ if (response.event_type === "update-emotion" && response.extras?.applied === false) {
719
+ console.warn(`[ConvaiClient] the server ignored ${sent !== undefined ? `state of mind ${JSON.stringify(sent)}` : "a state of mind"}. ` +
720
+ "Use one of: joy, trust, fear, surprise, sadness, disgust, anger, anticipation.");
721
+ }
722
+ // Vision needs an account feature and a vision-capable model as well as
723
+ // enableVideo; without them Core acks vision calls as successes that
724
+ // attach nothing. Say so once per session.
725
+ if (!this._warnedVisionNotEnabled &&
726
+ (response.extras?.downgrade_reason === "vision_not_enabled" ||
727
+ response.extras?.vision_buffer?.status === "vision_not_enabled")) {
728
+ this._warnedVisionNotEnabled = true;
729
+ console.warn("[ConvaiClient] vision is not enabled for this session, so published frames are not seen. " +
730
+ "It needs enableVideo: true, the unified vision context feature on the account, and a " +
731
+ "vision-capable non-realtime model on the character.");
732
+ }
656
733
  if (request)
657
734
  this.emit("serverResponse", response, request);
658
735
  else
@@ -759,6 +836,8 @@ export class ConvaiClient extends EventEmitter {
759
836
  * Connect to a Convai character
760
837
  */
761
838
  async connect(config) {
839
+ this._warnedVisionNotEnabled = false;
840
+ this._pendingStateOfMindAcks = [];
762
841
  // Use provided config or stored config
763
842
  const finalConfig = config || this._storedConfig;
764
843
  if (!finalConfig) {
@@ -1990,6 +2069,13 @@ export class ConvaiClient extends EventEmitter {
1990
2069
  throw new Error("resetSession() is not supported in a multi-character room; character sessions are server-owned");
1991
2070
  }
1992
2071
  this._characterSessionId = "-1";
2072
+ // connect() prefers config.characterSessionId over the live id, so a
2073
+ // resumed session in the stored config would make reconnect() resume it
2074
+ // again and quietly undo this reset.
2075
+ if (this._storedConfig?.characterSessionId !== undefined) {
2076
+ const { characterSessionId: _dropped, ...rest } = this._storedConfig;
2077
+ this._storedConfig = rest;
2078
+ }
1993
2079
  this.emit("characterSessionId", "-1");
1994
2080
  this._messageHandler.reset();
1995
2081
  // Clear metrics and disconnect reason when resetting session
@@ -2056,6 +2142,7 @@ export class ConvaiClient extends EventEmitter {
2056
2142
  }
2057
2143
  else {
2058
2144
  if (stateOfMind) {
2145
+ this._pendingStateOfMindAcks.push(stateOfMind);
2059
2146
  this.publishMessage("update-emotion", {
2060
2147
  state_of_mind: stateOfMind,
2061
2148
  participant_sid: this._participantSid || this._room.localParticipant?.sid,
@@ -2317,7 +2404,14 @@ export class ConvaiClient extends EventEmitter {
2317
2404
  * not a merge. Requires Narrative Design enabled on the character.
2318
2405
  */
2319
2406
  updateTemplateKeys(templateKeys) {
2320
- if (!this.isTransportReady() || Object.keys(templateKeys).length === 0)
2407
+ if (Object.keys(templateKeys).length === 0)
2408
+ return;
2409
+ // reconnect() replays _storedConfig; without this it re-sends the keys
2410
+ // from the original config over the ones set here.
2411
+ if (this._storedConfig) {
2412
+ this._storedConfig = { ...this._storedConfig, narrativeTemplateKeys: { ...templateKeys } };
2413
+ }
2414
+ if (!this.isTransportReady())
2321
2415
  return;
2322
2416
  this.publishMessage("update-template-keys", {
2323
2417
  template_keys: templateKeys,
@@ -2443,6 +2537,7 @@ export class ConvaiClient extends EventEmitter {
2443
2537
  respondModeUpdate(options) {
2444
2538
  if (!this.isTransportReady())
2445
2539
  return null;
2540
+ this.rememberRespondMode(options.modality, options.mode);
2446
2541
  const updateId = options.updateId ?? this.createUpdateId("respond-mode");
2447
2542
  this.publishMessage("respond-mode-update", {
2448
2543
  update_id: updateId,
@@ -2466,6 +2561,7 @@ export class ConvaiClient extends EventEmitter {
2466
2561
  return;
2467
2562
  if (this._activeTransport === "sse")
2468
2563
  return;
2564
+ this._pendingStateOfMindAcks.push(normalized);
2469
2565
  this.publishMessage("update-emotion", {
2470
2566
  state_of_mind: normalized,
2471
2567
  participant_sid: this._participantSid || this._room.localParticipant?.sid,
@@ -2486,6 +2582,30 @@ export class ConvaiClient extends EventEmitter {
2486
2582
  ...(options.respondMode && { respond_mode: options.respondMode }),
2487
2583
  });
2488
2584
  }
2585
+ /**
2586
+ * Mirror a runtime respond-mode change into the stored config, so
2587
+ * reconnect() — which replays _storedConfig — does not revert it. text and
2588
+ * audio are typed `"must_respond"` only in the config, so other values for
2589
+ * them stay runtime-only rather than widening that type.
2590
+ */
2591
+ rememberRespondMode(modality, mode) {
2592
+ if (!this._storedConfig)
2593
+ return;
2594
+ const key = {
2595
+ text: "text",
2596
+ audio: "audio",
2597
+ vision: "vision",
2598
+ context_update: "contextUpdate",
2599
+ trigger: "trigger",
2600
+ scene_metadata: "sceneMetadata",
2601
+ }[modality];
2602
+ if ((key === "text" || key === "audio") && mode !== "must_respond")
2603
+ return;
2604
+ this._storedConfig = {
2605
+ ...this._storedConfig,
2606
+ respondModes: { ...this._storedConfig.respondModes, [key]: mode },
2607
+ };
2608
+ }
2489
2609
  createUpdateId(prefix) {
2490
2610
  if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
2491
2611
  return `${prefix}:${crypto.randomUUID()}`;
@@ -2531,11 +2651,12 @@ export class ConvaiClient extends EventEmitter {
2531
2651
  toggleTts(enabled) {
2532
2652
  if (!this.isTransportReady())
2533
2653
  return;
2654
+ // Every transport, not only SSE: reconnect() replays _storedConfig.
2655
+ if (this._storedConfig) {
2656
+ this._storedConfig = { ...this._storedConfig, ttsEnabled: enabled };
2657
+ }
2534
2658
  if (this._activeTransport === "sse" && this._sseSession) {
2535
2659
  this._sseSession.setTtsEnabled(enabled);
2536
- if (this._storedConfig) {
2537
- this._storedConfig = { ...this._storedConfig, ttsEnabled: enabled };
2538
- }
2539
2660
  return;
2540
2661
  }
2541
2662
  this.publishMessage("tts-toggle", { enabled });
@@ -2565,6 +2686,8 @@ export class ConvaiClient extends EventEmitter {
2565
2686
  });
2566
2687
  }
2567
2688
  }
2689
+ /** How long speaking must stay stopped before a turn is reported ended. */
2690
+ ConvaiClient.TURN_END_SETTLE_MS = 150;
2568
2691
  ConvaiClient.CLIENT_READY_RETRY_MS = 500;
2569
2692
  ConvaiClient.CLIENT_READY_TIMEOUT_MS = 45000;
2570
2693
  ConvaiClient.ACTION_RESULT_ACK_TIMEOUT_MS = 10000;
@@ -2581,4 +2704,3 @@ ConvaiClient.ROSTER_COMMAND_TIMEOUT_MS = 10000;
2581
2704
  /** Default bounded retry while a roster room is still provisioning. */
2582
2705
  ConvaiClient.ROSTER_RETRY_ATTEMPTS = 4;
2583
2706
  ConvaiClient.ROSTER_RETRY_INITIAL_MS = 500;
2584
- //# sourceMappingURL=ConvaiClient.js.map
@@ -45,4 +45,3 @@ export declare function extractRequestTraceId(body: unknown): string | null;
45
45
  export declare function extractRoomErrorMessage(body: unknown, status: number): string;
46
46
  /** Build a `ConvaiRoomError` from a response status and its parsed body. */
47
47
  export declare function roomErrorFromResponse(status: number, body: unknown): ConvaiRoomError;
48
- //# sourceMappingURL=ConvaiRoomError.d.ts.map
@@ -104,8 +104,26 @@ export function extractRoomErrorMessage(body, status) {
104
104
  }
105
105
  return `Room request failed with HTTP ${status}`;
106
106
  }
107
+ /** `character_ids` from a body or its `detail`, when the server names them. */
108
+ function extractCharacterIds(body) {
109
+ if (typeof body !== "object" || body === null)
110
+ return [];
111
+ const record = body;
112
+ const ids = record.character_ids;
113
+ if (Array.isArray(ids))
114
+ return ids.filter((id) => typeof id === "string");
115
+ return extractCharacterIds(record.detail);
116
+ }
107
117
  /** Build a `ConvaiRoomError` from a response status and its parsed body. */
108
118
  export function roomErrorFromResponse(status, body) {
109
- return new ConvaiRoomError(extractRoomErrorMessage(body, status), status, extractRoomErrorCode(body), extractRequestTraceId(body), body);
119
+ const code = extractRoomErrorCode(body);
120
+ let message = extractRoomErrorMessage(body, status);
121
+ // A body with only a code ({"detail":{"code":"CHARACTER_NOT_FOUND_OR_INACCESSIBLE",
122
+ // "character_ids":[...]}}) has no prose, and the generic fallback dropped both
123
+ // the reason and which character from the message people actually log.
124
+ if (code && message === `Room request failed with HTTP ${status}`) {
125
+ const ids = extractCharacterIds(body);
126
+ message = `${code} (HTTP ${status})${ids.length ? `: ${ids.join(", ")}` : ""}`;
127
+ }
128
+ return new ConvaiRoomError(message, status, code, extractRequestTraceId(body), body);
110
129
  }
111
- //# sourceMappingURL=ConvaiRoomError.js.map
@@ -35,4 +35,3 @@ export declare class EventEmitter {
35
35
  */
36
36
  listenerCount(event: string): number;
37
37
  }
38
- //# sourceMappingURL=EventEmitter.d.ts.map
@@ -65,4 +65,3 @@ export class EventEmitter {
65
65
  return this.events.get(event)?.size ?? 0;
66
66
  }
67
67
  }
68
- //# sourceMappingURL=EventEmitter.js.map
@@ -176,4 +176,3 @@ export declare class MemoryManager {
176
176
  */
177
177
  getCharacterId(): string;
178
178
  }
179
- //# sourceMappingURL=MemoryManager.d.ts.map