@convai/web-sdk 1.1.0 → 1.2.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 (39) hide show
  1. package/README.md +19 -11
  2. package/dist/core/ConvaiClient.d.ts +4 -0
  3. package/dist/core/ConvaiClient.d.ts.map +1 -1
  4. package/dist/core/ConvaiClient.js +75 -18
  5. package/dist/core/ConvaiClient.js.map +1 -1
  6. package/dist/core/MessageHandler.d.ts +14 -0
  7. package/dist/core/MessageHandler.d.ts.map +1 -1
  8. package/dist/core/MessageHandler.js +82 -20
  9. package/dist/core/MessageHandler.js.map +1 -1
  10. package/dist/core/types.d.ts +37 -4
  11. package/dist/core/types.d.ts.map +1 -1
  12. package/dist/react/components/ConvaiWidget.d.ts.map +1 -1
  13. package/dist/react/components/ConvaiWidget.js +46 -4
  14. package/dist/react/components/ConvaiWidget.js.map +1 -1
  15. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js +1 -1
  16. package/dist/react/components/rtc-widget/components/conviComponents/ConviFooter.js.map +1 -1
  17. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts +3 -1
  18. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts.map +1 -1
  19. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js +3 -3
  20. package/dist/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.js.map +1 -1
  21. package/dist/react/hooks/useConvaiClient.d.ts.map +1 -1
  22. package/dist/react/hooks/useConvaiClient.js +6 -1
  23. package/dist/react/hooks/useConvaiClient.js.map +1 -1
  24. package/dist/types/index.d.ts +35 -4
  25. package/dist/types/index.d.ts.map +1 -1
  26. package/dist/utils/logger.d.ts +12 -12
  27. package/dist/utils/logger.d.ts.map +1 -1
  28. package/dist/utils/logger.js +31 -21
  29. package/dist/utils/logger.js.map +1 -1
  30. package/dist/vanilla/ConvaiWidget.d.ts.map +1 -1
  31. package/dist/vanilla/ConvaiWidget.js +74 -5
  32. package/dist/vanilla/ConvaiWidget.js.map +1 -1
  33. package/dist/vanilla/types.d.ts +2 -0
  34. package/dist/vanilla/types.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/utils/speakerManagement.d.ts +0 -22
  37. package/dist/utils/speakerManagement.d.ts.map +0 -1
  38. package/dist/utils/speakerManagement.js +0 -64
  39. package/dist/utils/speakerManagement.js.map +0 -1
@@ -49,8 +49,15 @@ export interface ConvaiConfig {
49
49
  * Use a unique UUID or device ID for persistent user experiences.
50
50
  */
51
51
  endUserId?: string;
52
+ /** Optional metadata object for the end user (sent as end_user_metadata to the API) */
53
+ endUserMetadata?: Record<string, unknown>;
52
54
  /** Custom Convai API URL (optional, defaults to production endpoint) */
53
55
  url?: string;
56
+ /**
57
+ * Character session ID (optional). Pass to resume an existing session;
58
+ * otherwise populated from the connect API response after first connection.
59
+ */
60
+ characterSessionId?: string;
54
61
  /**
55
62
  * Enable video capability (default: false).
56
63
  * If true, connection_type will be "video" (supports audio, video, and screenshare).
@@ -76,6 +83,8 @@ export interface ConvaiConfig {
76
83
  * When false, sets blendshape_provider to "none" (no facial animation data).
77
84
  */
78
85
  enableLipsync?: boolean;
86
+ /** Enable emotion detection and bot-emotion updates (default: true) */
87
+ enableEmotion?: boolean;
79
88
  /** Blendshape configuration for facial animation format */
80
89
  blendshapeConfig?: {
81
90
  /** Format of blendshapes: "arkit" or "mha" (Meta Human Animation, default: "mha") */
@@ -88,6 +97,17 @@ export interface ConvaiConfig {
88
97
  */
89
98
  frames_buffer_duration?: number;
90
99
  };
100
+ /** Emotion configuration for character emotional state (sent to server on connect) */
101
+ emotionConfig?: {
102
+ /** Emotion provider (default: "llm") */
103
+ provider?: "llm";
104
+ /** Minimum word threshold for emotion detection */
105
+ min_word_threshold?: number;
106
+ /** Low intensity threshold (0–1) */
107
+ low_intensity_threshold?: number;
108
+ /** High intensity threshold (0–1) */
109
+ high_intensity_threshold?: number;
110
+ };
91
111
  /** Configuration for character actions and environmental context */
92
112
  actionConfig?: {
93
113
  /** List of action names the character can perform */
@@ -134,8 +154,8 @@ export interface ChatMessage {
134
154
  content: string;
135
155
  /** ISO timestamp string of when the message was created */
136
156
  timestamp: string;
137
- /** Whether this is the final version of the message (for streaming) */
138
- isFinal?: boolean;
157
+ /** Whether this message is still streaming (mutable); false when finalized */
158
+ isStreaming?: boolean;
139
159
  }
140
160
  /**
141
161
  * Represents the current state of the Convai client connection and activity.
@@ -162,7 +182,7 @@ export interface ConvaiClientState {
162
182
  isConnected: boolean;
163
183
  /** Whether a connection attempt is in progress */
164
184
  isConnecting: boolean;
165
- /** Whether the system is actively listening to user input */
185
+ /** True from user-started-speaking until user-stopped-speaking (user is speaking, bot is listening). Priority below isSpeaking. */
166
186
  isListening: boolean;
167
187
  /** Whether the character is processing/thinking about a response */
168
188
  isThinking: boolean;
@@ -170,9 +190,14 @@ export interface ConvaiClientState {
170
190
  isSpeaking: boolean;
171
191
  /**
172
192
  * Combined state indicator for the character's current activity.
173
- * Use this as a single source of truth for UI state.
193
+ * Priority: speaking > listening (user speaking) > thinking > connected.
174
194
  */
175
195
  agentState: 'disconnected' | 'connected' | 'listening' | 'thinking' | 'speaking';
196
+ /** Current bot emotion (name and optional scale). Updated when bot-emotion messages are received. */
197
+ emotion: {
198
+ emotion: string;
199
+ scale?: number;
200
+ } | null;
176
201
  }
177
202
  import type { AudioControls, VideoControls, ScreenShareControls } from "../core/types";
178
203
  /**
@@ -275,5 +300,11 @@ export interface ConvaiClient {
275
300
  * When disabled, character responses won't be spoken aloud.
276
301
  */
277
302
  toggleTts: (enabled: boolean) => void;
303
+ /**
304
+ * Toggle speech-to-text on or off.
305
+ * When enabled, user speech is transcribed to text (e.g. for dictation).
306
+ * When disabled, STT is off.
307
+ */
308
+ toggleStt: (enabled: boolean) => void;
278
309
  }
279
310
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["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kF;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;IAEtC;;;;OAIG;IACH,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC"}
@@ -1,23 +1,23 @@
1
1
  /**
2
- * Logger utility that only logs in development mode.
3
- * Completely silent in production builds and npm packages.
2
+ * Logger utility that only logs in development mode (or when debug is enabled at runtime).
3
+ * Completely silent in production builds unless explicitly enabled.
4
4
  *
5
- * This logger is designed to be tree-shakeable and completely removed
6
- * from production builds when not used.
5
+ * To see logs after a production build, enable at runtime in the browser console:
6
+ * window.__CONVAI_DEBUG__ = true
7
+ * Then refresh the page. Logs will appear with the [Convai] prefix.
7
8
  *
8
9
  * To test logger behavior:
9
10
  * - Development: Set NODE_ENV=development or run on localhost
10
11
  * - Production: Set NODE_ENV=production or deploy to production
11
- *
12
- * In npm packages, this logger will be completely silent by default.
12
+ * - Production + debug: Set window.__CONVAI_DEBUG__ = true before/during use
13
13
  */
14
14
  export declare const logger: {
15
- log: (...args: any[]) => void;
16
- warn: (...args: any[]) => void;
17
- error: (...args: any[]) => void;
18
- info: (...args: any[]) => void;
19
- debug: (...args: any[]) => void;
20
- trace: (...args: any[]) => void;
15
+ log: (...args: unknown[]) => void;
16
+ warn: (...args: unknown[]) => void;
17
+ error: (...args: unknown[]) => void;
18
+ info: (...args: unknown[]) => void;
19
+ debug: (...args: unknown[]) => void;
20
+ trace: (...args: unknown[]) => void;
21
21
  };
22
22
  export declare const loggerConfig: {
23
23
  environment: string;
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAuFH,eAAO,MAAM,MAAM;mBAnBF,GAAG,EAAE;oBACJ,GAAG,EAAE;qBACJ,GAAG,EAAE;oBACN,GAAG,EAAE;qBACJ,GAAG,EAAE;qBACL,GAAG,EAAE;CAcoC,CAAC;AAG7D,eAAO,MAAM,YAAY;;;;CAIxB,CAAC"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAwFH,eAAO,MAAM,MAAM;mBACF,OAAO,EAAE;oBACR,OAAO,EAAE;qBACR,OAAO,EAAE;oBACV,OAAO,EAAE;qBACR,OAAO,EAAE;qBACT,OAAO,EAAE;CAC3B,CAAC;AAGF,eAAO,MAAM,YAAY;;;;CAIxB,CAAC"}
@@ -1,15 +1,15 @@
1
1
  /**
2
- * Logger utility that only logs in development mode.
3
- * Completely silent in production builds and npm packages.
2
+ * Logger utility that only logs in development mode (or when debug is enabled at runtime).
3
+ * Completely silent in production builds unless explicitly enabled.
4
4
  *
5
- * This logger is designed to be tree-shakeable and completely removed
6
- * from production builds when not used.
5
+ * To see logs after a production build, enable at runtime in the browser console:
6
+ * window.__CONVAI_DEBUG__ = true
7
+ * Then refresh the page. Logs will appear with the [Convai] prefix.
7
8
  *
8
9
  * To test logger behavior:
9
10
  * - Development: Set NODE_ENV=development or run on localhost
10
11
  * - Production: Set NODE_ENV=production or deploy to production
11
- *
12
- * In npm packages, this logger will be completely silent by default.
12
+ * - Production + debug: Set window.__CONVAI_DEBUG__ = true before/during use
13
13
  */
14
14
  // Environment detection with multiple fallbacks
15
15
  const detectEnvironment = () => {
@@ -63,11 +63,21 @@ const detectEnvironment = () => {
63
63
  };
64
64
  const environment = detectEnvironment();
65
65
  const isDevelopment = environment === 'development';
66
- // No-op function that gets completely removed by tree shaking
67
- const noop = () => {
68
- // This function is intentionally empty and will be removed in production
69
- };
70
- // Development logger functions
66
+ /** At runtime, enable logging in built/production apps via window.__CONVAI_DEBUG__ = true */
67
+ function shouldLog() {
68
+ if (isDevelopment)
69
+ return true;
70
+ try {
71
+ if (typeof window !== 'undefined' && window.__CONVAI_DEBUG__) {
72
+ return true;
73
+ }
74
+ }
75
+ catch {
76
+ // no window
77
+ }
78
+ return false;
79
+ }
80
+ // Development logger functions (used when shouldLog() is true)
71
81
  const devLogger = {
72
82
  log: (...args) => console.log('[Convai]', ...args),
73
83
  warn: (...args) => console.warn('[Convai]', ...args),
@@ -76,17 +86,17 @@ const devLogger = {
76
86
  debug: (...args) => console.debug('[Convai]', ...args),
77
87
  trace: (...args) => console.trace('[Convai]', ...args),
78
88
  };
79
- // Production logger functions (all no-ops)
80
- const prodLogger = {
81
- log: noop,
82
- warn: noop,
83
- error: noop,
84
- info: noop,
85
- debug: noop,
86
- trace: noop,
89
+ // No-op when logging is disabled
90
+ const noop = () => { };
91
+ // Logger that checks shouldLog() at call time so production builds can enable logs via window.__CONVAI_DEBUG__
92
+ export const logger = {
93
+ log: (...args) => (shouldLog() ? devLogger.log(...args) : noop()),
94
+ warn: (...args) => (shouldLog() ? devLogger.warn(...args) : noop()),
95
+ error: (...args) => (shouldLog() ? devLogger.error(...args) : noop()),
96
+ info: (...args) => (shouldLog() ? devLogger.info(...args) : noop()),
97
+ debug: (...args) => (shouldLog() ? devLogger.debug(...args) : noop()),
98
+ trace: (...args) => (shouldLog() ? devLogger.trace(...args) : noop()),
87
99
  };
88
- // Export the appropriate logger based on environment
89
- export const logger = isDevelopment ? devLogger : prodLogger;
90
100
  // Export environment info for debugging
91
101
  export const loggerConfig = {
92
102
  environment,
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,gDAAgD;AAChD,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,0CAA0C;IAC1C,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;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IAAI,CAE/D"}
1
+ {"version":3,"file":"ConvaiWidget.d.ts","sourceRoot":"","sources":["../../src/vanilla/ConvaiWidget.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EAGd,MAAM,SAAS,CAAC;AAWjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,WAAW,EACtB,OAAO,EAAE,oBAAoB,GAC5B,aAAa,CAsjEf;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAE/D"}
@@ -54,6 +54,7 @@ export function createConvaiWidget(container, options) {
54
54
  enableVideo: options.enableVideo ?? false,
55
55
  startWithVideoOn: options.startWithVideoOn ?? false,
56
56
  enableLipsync: options.enableLipsync ?? false,
57
+ enableEmotion: options.enableEmotion,
57
58
  blendshapeConfig: options.blendshapeConfig,
58
59
  });
59
60
  })();
@@ -71,6 +72,8 @@ export function createConvaiWidget(container, options) {
71
72
  let characterImage = "";
72
73
  let audioRenderer = null;
73
74
  let hasEnteredDefaultVoiceMode = false;
75
+ /** True after we have connected at least once; used to call reconnect() instead of connect() when opening after disconnect */
76
+ let hasConnectedBefore = false;
74
77
  // DOM elements (will be created below)
75
78
  let rootElement;
76
79
  let morphingContainer;
@@ -285,7 +288,7 @@ export function createConvaiWidget(container, options) {
285
288
  return;
286
289
  const bars = voiceModeOverlay.querySelectorAll(".voice-bar");
287
290
  const isTalking = client.state.isSpeaking;
288
- const isListening = !client.audioControls.isAudioMuted;
291
+ const isListening = client.state.isListening; // User is speaking (from user-started-speaking)
289
292
  const isAnimating = isListening || isTalking;
290
293
  // Update colors based on state
291
294
  bars.forEach((bar) => {
@@ -311,8 +314,8 @@ export function createConvaiWidget(container, options) {
311
314
  ? "Audio active"
312
315
  : "Press and hold the microphone to talk";
313
316
  }
314
- // Animation Logic - Matches React version
315
- if (isListening && analyzer && dataArray) {
317
+ // Animation Logic - Matches React version (animate when user or bot is active)
318
+ if ((isListening || !client.audioControls.isAudioMuted) && analyzer && dataArray) {
316
319
  // Use time domain data (waveform) instead of frequency
317
320
  // @ts-ignore - TypeScript strict mode issue with Uint8Array type
318
321
  analyzer.getByteTimeDomainData(dataArray);
@@ -555,6 +558,62 @@ export function createConvaiWidget(container, options) {
555
558
  `;
556
559
  titleSection.appendChild(voiceBadge);
557
560
  }
561
+ // Speaking tag (top bar, same style as React)
562
+ if (client.state.isSpeaking) {
563
+ const speakingTag = document.createElement("span");
564
+ speakingTag.textContent = "SPEAKING";
565
+ speakingTag.style.cssText = `
566
+ font-size: 10px;
567
+ color: #10b981;
568
+ font-weight: 600;
569
+ margin-left: 8px;
570
+ padding: 3px 8px;
571
+ border-radius: 6px;
572
+ background-color: #10b98120;
573
+ border: 1px solid #10b98140;
574
+ display: inline-flex;
575
+ align-items: center;
576
+ gap: 4px;
577
+ `;
578
+ const dot = document.createElement("span");
579
+ dot.style.cssText = `
580
+ width: 6px;
581
+ height: 6px;
582
+ border-radius: 50%;
583
+ background-color: #10b981;
584
+ display: inline-block;
585
+ `;
586
+ speakingTag.insertBefore(dot, speakingTag.firstChild);
587
+ titleSection.appendChild(speakingTag);
588
+ }
589
+ // Listening tag (top bar, when user is speaking)
590
+ if (client.state.isListening && !client.state.isSpeaking) {
591
+ const listeningTag = document.createElement("span");
592
+ listeningTag.textContent = "LISTENING";
593
+ listeningTag.style.cssText = `
594
+ font-size: 10px;
595
+ color: #3b82f6;
596
+ font-weight: 600;
597
+ margin-left: 8px;
598
+ padding: 3px 8px;
599
+ border-radius: 6px;
600
+ background-color: #3b82f620;
601
+ border: 1px solid #3b82f640;
602
+ display: inline-flex;
603
+ align-items: center;
604
+ gap: 4px;
605
+ `;
606
+ const dot = document.createElement("span");
607
+ dot.style.cssText = `
608
+ width: 6px;
609
+ height: 6px;
610
+ border-radius: 50%;
611
+ background-color: #3b82f6;
612
+ display: inline-block;
613
+ `;
614
+ listeningTag.insertBefore(dot, listeningTag.firstChild);
615
+ titleSection.appendChild(listeningTag);
616
+ }
558
617
  };
559
618
  // Create message list
560
619
  const createMessageList = () => {
@@ -627,7 +686,7 @@ export function createConvaiWidget(container, options) {
627
686
  inputElement.placeholder = "Conversation";
628
687
  inputElement.style.cssText = `
629
688
  width: 100%;
630
- padding: 0.75rem 3rem 0.75rem 1rem;
689
+ padding: 0.75rem 2.75rem 0.75rem 1rem;
631
690
  border-radius: ${aeroTheme.borderRadius.full};
632
691
  border: 1px solid ${aeroTheme.colors.neutral[300]};
633
692
  background: ${aeroTheme.colors.glass.medium};
@@ -1104,7 +1163,13 @@ export function createConvaiWidget(container, options) {
1104
1163
  // Connect on first click if not already connected/connecting
1105
1164
  if (!client.state.isConnected && !client.state.isConnecting) {
1106
1165
  try {
1107
- await client.connect();
1166
+ // Use reconnect when opening again after a disconnect (reuses stored config)
1167
+ if (hasConnectedBefore && typeof client.reconnect === "function") {
1168
+ await client.reconnect();
1169
+ }
1170
+ else {
1171
+ await client.connect();
1172
+ }
1108
1173
  setIsOpen(true);
1109
1174
  }
1110
1175
  catch (error) {
@@ -1602,6 +1667,9 @@ export function createConvaiWidget(container, options) {
1602
1667
  if (client.state.isConnecting || !client.isBotReady) {
1603
1668
  return { color: "#f59e0b", label: "Connecting" };
1604
1669
  }
1670
+ if (client.state.isListening) {
1671
+ return { color: "#3b82f6", label: "Listening" };
1672
+ }
1605
1673
  return { color: "#10b981", label: "Connected" };
1606
1674
  };
1607
1675
  const formatMessages = () => {
@@ -1748,6 +1816,7 @@ export function createConvaiWidget(container, options) {
1748
1816
  updateHeader(); // Update header to show green status
1749
1817
  });
1750
1818
  client.on("connect", () => {
1819
+ hasConnectedBefore = true;
1751
1820
  // Initialize audio renderer on connection
1752
1821
  if (client.room && !audioRenderer) {
1753
1822
  audioRenderer = new AudioRenderer(client.room);