reactbridge-sdk 0.1.17 → 0.1.19
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.
package/dist/index.js
CHANGED
|
@@ -79,7 +79,7 @@ class ReactBridgeAPI {
|
|
|
79
79
|
if (request.userRecentActivity)
|
|
80
80
|
formData.append('userRecentActivity', request.userRecentActivity);
|
|
81
81
|
if (request.interfaceState)
|
|
82
|
-
formData.append(
|
|
82
|
+
formData.append("InterfaceStateJson", JSON.stringify(request.interfaceState));
|
|
83
83
|
if (request.sessionId)
|
|
84
84
|
formData.append('sessionId', request.sessionId);
|
|
85
85
|
if (request.modalityHint)
|
|
@@ -98,14 +98,14 @@ class ReactBridgeAPI {
|
|
|
98
98
|
headers['Content-Type'] = 'application/json';
|
|
99
99
|
body = JSON.stringify(request);
|
|
100
100
|
}
|
|
101
|
-
console.log('Sending request to ReactBridge API:', { url, headers, body, timeoutMs });
|
|
101
|
+
// console.log('Sending request to ReactBridge API:', { url, headers, body, timeoutMs });
|
|
102
102
|
const response = yield fetch(url, {
|
|
103
103
|
method: 'POST',
|
|
104
104
|
headers,
|
|
105
105
|
body,
|
|
106
106
|
signal,
|
|
107
107
|
});
|
|
108
|
-
console.log('Received response from ReactBridge API:', response);
|
|
108
|
+
// console.log('Received response from ReactBridge API:', response);
|
|
109
109
|
// Clear any manual timeout timer if set
|
|
110
110
|
if (timeoutId) {
|
|
111
111
|
clearTimeout(timeoutId);
|
|
@@ -343,7 +343,7 @@ function useReactBridge({ onIntentDetected, currentContext, onError, onSpeechSta
|
|
|
343
343
|
previousContextRef.current = currentContext;
|
|
344
344
|
}
|
|
345
345
|
}, [currentContext]);
|
|
346
|
-
const sendChatQuery = React.useCallback((
|
|
346
|
+
const sendChatQuery = React.useCallback((queryOrOptions_1, ...args_1) => __awaiter(this, [queryOrOptions_1, ...args_1], void 0, function* (queryOrOptions, fromVoiceInput = false) {
|
|
347
347
|
const isMultimodal = typeof queryOrOptions === 'object';
|
|
348
348
|
const query = isMultimodal ? (queryOrOptions.query || '') : queryOrOptions;
|
|
349
349
|
const image = isMultimodal ? queryOrOptions.image : undefined;
|
|
@@ -401,8 +401,10 @@ function useReactBridge({ onIntentDetected, currentContext, onError, onSpeechSta
|
|
|
401
401
|
toolCall: response.toolCall,
|
|
402
402
|
};
|
|
403
403
|
setMessages(prev => [...prev, assistantMessage]);
|
|
404
|
-
// Trigger TTS and callback
|
|
405
|
-
|
|
404
|
+
// Trigger TTS and callback only if input came from voice
|
|
405
|
+
if (fromVoiceInput) {
|
|
406
|
+
ttsProvider.speak(response.message);
|
|
407
|
+
}
|
|
406
408
|
if (onAgentResponse) {
|
|
407
409
|
onAgentResponse(response.message);
|
|
408
410
|
}
|
|
@@ -421,8 +423,10 @@ function useReactBridge({ onIntentDetected, currentContext, onError, onSpeechSta
|
|
|
421
423
|
timestamp: new Date(),
|
|
422
424
|
};
|
|
423
425
|
setMessages(prev => [...prev, finalMessage]);
|
|
424
|
-
// Trigger TTS for final response
|
|
425
|
-
|
|
426
|
+
// Trigger TTS for final response only if input came from voice
|
|
427
|
+
if (fromVoiceInput) {
|
|
428
|
+
ttsProvider.speak(resultResponse.message);
|
|
429
|
+
}
|
|
426
430
|
if (onAgentResponse) {
|
|
427
431
|
onAgentResponse(resultResponse.message);
|
|
428
432
|
}
|
|
@@ -477,7 +481,7 @@ function useReactBridge({ onIntentDetected, currentContext, onError, onSpeechSta
|
|
|
477
481
|
if (onTranscript) {
|
|
478
482
|
onTranscript(text);
|
|
479
483
|
}
|
|
480
|
-
sendChatQuery(text);
|
|
484
|
+
sendChatQuery(text, true); // Pass true to indicate voice input
|
|
481
485
|
setIsListening(false);
|
|
482
486
|
if (onSpeechEnd) {
|
|
483
487
|
onSpeechEnd();
|
|
@@ -779,6 +783,7 @@ toggleButtonClass = defaultToggleButtonClass, toggleButtonTitle = "Open chat ass
|
|
|
779
783
|
} }),
|
|
780
784
|
React.createElement("button", { type: "button", onClick: () => setIsUploadMenuOpen(!isUploadMenuOpen), disabled: isLoading, title: "Attach file", style: {
|
|
781
785
|
padding: theme.spacing.sm,
|
|
786
|
+
paddingRight: 0,
|
|
782
787
|
backgroundColor: theme.colors.secondary,
|
|
783
788
|
color: "#ffffff",
|
|
784
789
|
border: "none",
|
|
@@ -833,6 +838,7 @@ toggleButtonClass = defaultToggleButtonClass, toggleButtonTitle = "Open chat ass
|
|
|
833
838
|
"Upload Document"))),
|
|
834
839
|
React.createElement("button", { type: "button", onClick: isListening ? stopVoiceInput : startVoiceInput, disabled: isLoading, title: isListening ? "Stop recording" : "Start voice input", style: {
|
|
835
840
|
padding: theme.spacing.sm,
|
|
841
|
+
paddingLeft: 0,
|
|
836
842
|
backgroundColor: isListening
|
|
837
843
|
? theme.colors.error
|
|
838
844
|
: theme.colors.secondary,
|