@memori.ai/memori-react 8.40.0 → 8.40.2
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/CHANGELOG.md +24 -0
- package/dist/components/MemoriWidget/MemoriWidget.js +125 -230
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/helpers/nats/useNatsSession.js +9 -1
- package/dist/helpers/nats/useNatsSession.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/esm/components/MemoriWidget/MemoriWidget.js +125 -230
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/helpers/nats/useNatsSession.js +9 -1
- package/esm/helpers/nats/useNatsSession.js.map +1 -1
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/package.json +1 -1
- package/src/components/MemoriWidget/MemoriWidget.tsx +106 -263
- package/src/components/layouts/layouts.stories.tsx +1 -1
- package/src/helpers/nats/useNatsSession.ts +21 -1
- package/src/version.ts +1 -1
|
@@ -70,6 +70,9 @@ const NULL_PLACE_SPEC = {
|
|
|
70
70
|
uncertaintyKm: null,
|
|
71
71
|
};
|
|
72
72
|
const ENTER_TEXT_NATS_TIMEOUT_MS = 120000;
|
|
73
|
+
const logWidgetError = (context, detail) => {
|
|
74
|
+
console.error(`[MemoriWidget] ${context}`, detail !== null && detail !== void 0 ? detail : '');
|
|
75
|
+
};
|
|
73
76
|
function readCorrelationID(response) {
|
|
74
77
|
const value = response.correlationID;
|
|
75
78
|
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
@@ -208,6 +211,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
208
211
|
}, [loginToken, user === null || user === void 0 ? void 0 : user.userID]);
|
|
209
212
|
const [showLoginDrawer, setShowLoginDrawer] = (0, react_1.useState)(false);
|
|
210
213
|
const [clickedStart, setClickedStart] = (0, react_1.useState)(false);
|
|
214
|
+
const sessionStartingRef = (0, react_1.useRef)(false);
|
|
211
215
|
const language = ((_d = (_c = (_b = memori.culture) === null || _b === void 0 ? void 0 : _b.split('-')) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.toUpperCase()) ||
|
|
212
216
|
((_j = (_h = (_g = (_f = memoriConfigs === null || memoriConfigs === void 0 ? void 0 : memoriConfigs.find(c => c.memoriConfigID === memori.memoriConfigurationID)) === null || _f === void 0 ? void 0 : _f.culture) === null || _g === void 0 ? void 0 : _g.split('-')) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.toUpperCase());
|
|
213
217
|
const integrationConfig = (integration === null || integration === void 0 ? void 0 : integration.customData)
|
|
@@ -450,12 +454,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
450
454
|
let gotError = false;
|
|
451
455
|
try {
|
|
452
456
|
const placeSpec = getPlaceSpecForEnterText(position);
|
|
453
|
-
console.debug('[EnterText] sendMessage: posting', {
|
|
454
|
-
sessionId: sessionID,
|
|
455
|
-
textLength: msg.length,
|
|
456
|
-
hasBatchQueued,
|
|
457
|
-
typingText,
|
|
458
|
-
});
|
|
459
457
|
const response = await postEnterTextAsync({
|
|
460
458
|
sessionId: sessionID,
|
|
461
459
|
text: msg,
|
|
@@ -464,11 +462,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
464
462
|
}),
|
|
465
463
|
...(placeSpec !== undefined && { place: placeSpec }),
|
|
466
464
|
});
|
|
467
|
-
console.debug('[EnterText] sendMessage: HTTP response', {
|
|
468
|
-
resultCode: response.resultCode,
|
|
469
|
-
correlationID: readCorrelationID(response),
|
|
470
|
-
resultMessage: response.resultMessage,
|
|
471
|
-
});
|
|
472
465
|
const correlationID = readCorrelationID(response);
|
|
473
466
|
if (response.resultCode === 0 && correlationID) {
|
|
474
467
|
registerPendingEnterText(correlationID, {
|
|
@@ -477,15 +470,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
477
470
|
useLoaderTextAsMsg,
|
|
478
471
|
hasBatchQueued,
|
|
479
472
|
});
|
|
480
|
-
console.info('[EnterText] sendMessage: accepted, showing typing indicator', {
|
|
481
|
-
correlationID: correlationID,
|
|
482
|
-
typingText,
|
|
483
|
-
});
|
|
484
473
|
setMemoriTyping(true);
|
|
485
474
|
setTypingText(typingText);
|
|
486
475
|
}
|
|
487
476
|
else if (response.resultCode === 0) {
|
|
488
|
-
|
|
477
|
+
logWidgetError('enter-text missing correlationID', response);
|
|
489
478
|
}
|
|
490
479
|
else if (response.resultCode === 404) {
|
|
491
480
|
setHistory(h => [...h.slice(0, h.length - 1)]);
|
|
@@ -495,7 +484,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
495
484
|
ROUTE: ((_d = (_c = window.location.pathname) === null || _c === void 0 ? void 0 : _c.split('/')) === null || _d === void 0 ? void 0 : _d.pop()) || '',
|
|
496
485
|
...(initialContextVars || {}),
|
|
497
486
|
}, initialQuestion, undefined, undefined, undefined, undefined, true).then(state => {
|
|
498
|
-
console.info('session timeout');
|
|
499
487
|
if (state === null || state === void 0 ? void 0 : state.sessionID) {
|
|
500
488
|
setTimeout(() => {
|
|
501
489
|
sendMessage(text, media, state === null || state === void 0 ? void 0 : state.sessionID);
|
|
@@ -517,13 +505,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
517
505
|
]);
|
|
518
506
|
}
|
|
519
507
|
else {
|
|
520
|
-
console.warn('[SEND_MESSAGE]', response);
|
|
521
508
|
return Promise.reject(response);
|
|
522
509
|
}
|
|
523
510
|
}
|
|
524
511
|
catch (error) {
|
|
525
|
-
console.error('[EnterText] sendMessage: request failed', error);
|
|
526
512
|
gotError = true;
|
|
513
|
+
logWidgetError('sendMessage failed', error);
|
|
527
514
|
setTypingText(undefined);
|
|
528
515
|
setMemoriTyping(false);
|
|
529
516
|
}
|
|
@@ -605,7 +592,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
605
592
|
}
|
|
606
593
|
}
|
|
607
594
|
catch (error) {
|
|
608
|
-
console.error('[TRANSLATE] Error during translation:', error);
|
|
609
595
|
translatedState = { ...state, emission };
|
|
610
596
|
translatedMsg = {
|
|
611
597
|
text: emission,
|
|
@@ -713,7 +699,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
713
699
|
try {
|
|
714
700
|
setTimeout(() => {
|
|
715
701
|
var _a;
|
|
716
|
-
console.log('snippet', s);
|
|
717
702
|
new Function((_a = s.content) !== null && _a !== void 0 ? _a : '')();
|
|
718
703
|
setTimeout(() => {
|
|
719
704
|
var _a, _b, _c;
|
|
@@ -722,8 +707,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
722
707
|
}, 400);
|
|
723
708
|
}, 1000);
|
|
724
709
|
}
|
|
725
|
-
catch (
|
|
726
|
-
console.warn(e);
|
|
710
|
+
catch (_a) {
|
|
727
711
|
}
|
|
728
712
|
});
|
|
729
713
|
};
|
|
@@ -759,8 +743,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
759
743
|
return window.location.href;
|
|
760
744
|
})();
|
|
761
745
|
}
|
|
762
|
-
catch (
|
|
763
|
-
console.debug(err);
|
|
746
|
+
catch (_m) {
|
|
764
747
|
}
|
|
765
748
|
const session = await initSession({
|
|
766
749
|
...params,
|
|
@@ -792,7 +775,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
792
775
|
};
|
|
793
776
|
}
|
|
794
777
|
else if (session === null || session === void 0 ? void 0 : session.resultMessage.startsWith('This Memori is aged restricted')) {
|
|
795
|
-
console.warn(session);
|
|
796
778
|
react_hot_toast_1.default.error(t('underageTwinSession', { age: minAge }));
|
|
797
779
|
}
|
|
798
780
|
else if ((session === null || session === void 0 ? void 0 : session.resultCode) === 403 && memori.privacyType !== 'PUBLIC') {
|
|
@@ -801,7 +783,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
801
783
|
return session;
|
|
802
784
|
}
|
|
803
785
|
else {
|
|
804
|
-
console.warn(session);
|
|
805
786
|
react_hot_toast_1.default.error(tst => ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("p", { children: t((0, error_1.getErrori18nKey)(session === null || session === void 0 ? void 0 : session.resultCode)) }), (0, jsx_runtime_1.jsx)(Button_1.default, { outlined: true, padded: false, onClick: () => react_hot_toast_1.default.dismiss(tst.id), icon: (0, jsx_runtime_1.jsx)(Close_1.default, {}), children: t('close') })] })), {
|
|
806
787
|
duration: Infinity,
|
|
807
788
|
});
|
|
@@ -809,7 +790,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
809
790
|
}
|
|
810
791
|
}
|
|
811
792
|
catch (err) {
|
|
812
|
-
|
|
793
|
+
logWidgetError('fetchSession failed', err);
|
|
813
794
|
}
|
|
814
795
|
};
|
|
815
796
|
const reopenSession = async (updateDialogState = false, password, recoveryTokens, tag, pin, initialContextVars, initialQuestion, birthDate, additionalInfoProp, continueFromChatLogID, continueFromSessionID, isSessionExpired) => {
|
|
@@ -841,8 +822,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
841
822
|
return window.location.href;
|
|
842
823
|
})();
|
|
843
824
|
}
|
|
844
|
-
catch (
|
|
845
|
-
console.debug('[REOPEN_SESSION] Error getting referral:', err);
|
|
825
|
+
catch (_o) {
|
|
846
826
|
}
|
|
847
827
|
const { sessionID, currentState, ...response } = await initSession({
|
|
848
828
|
memoriID: (_a = memori.engineMemoriID) !== null && _a !== void 0 ? _a : '',
|
|
@@ -869,12 +849,10 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
869
849
|
},
|
|
870
850
|
});
|
|
871
851
|
if (sessionID && currentState && response.resultCode === 0) {
|
|
872
|
-
console.log('[REOPEN_SESSION] Session initialized successfully:', sessionID);
|
|
873
852
|
setSessionId(sessionID);
|
|
874
853
|
if (updateDialogState) {
|
|
875
854
|
setCurrentDialogState(currentState);
|
|
876
855
|
if (currentState.emission) {
|
|
877
|
-
console.log('[REOPEN_SESSION] Processing emission:', currentState.emission);
|
|
878
856
|
const initialStatus = isSessionExpired && history.length > 1
|
|
879
857
|
? 'Session Expired, reopening session'
|
|
880
858
|
: history.length <= 1
|
|
@@ -926,22 +904,19 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
926
904
|
};
|
|
927
905
|
}
|
|
928
906
|
else if (response === null || response === void 0 ? void 0 : response.resultMessage.startsWith('This Memori is aged restricted')) {
|
|
929
|
-
console.error('[REOPEN_SESSION] Age restriction error:', response);
|
|
930
907
|
react_hot_toast_1.default.error(t('underageTwinSession', { age: minAge }));
|
|
931
908
|
}
|
|
932
909
|
else if ((response === null || response === void 0 ? void 0 : response.resultCode) === 403 &&
|
|
933
910
|
memori.privacyType !== 'PUBLIC') {
|
|
934
|
-
console.error('[REOPEN_SESSION] Authentication error');
|
|
935
911
|
setMemoriPwd(undefined);
|
|
936
912
|
setAuthModalState('password');
|
|
937
913
|
}
|
|
938
914
|
else {
|
|
939
|
-
console.error('[REOPEN_SESSION] Other error:', response);
|
|
940
915
|
react_hot_toast_1.default.error(t((0, error_1.getErrori18nKey)(response.resultCode)));
|
|
941
916
|
}
|
|
942
917
|
}
|
|
943
918
|
catch (err) {
|
|
944
|
-
|
|
919
|
+
logWidgetError('reopenSession failed', err);
|
|
945
920
|
}
|
|
946
921
|
setLoading(false);
|
|
947
922
|
return null;
|
|
@@ -949,7 +924,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
949
924
|
const changeTag = async (memoriId, sessionId, tag, pin) => {
|
|
950
925
|
var _a, _b, _c, _d, _f, _g, _h, _j, _k;
|
|
951
926
|
if (!memoriId || !sessionId) {
|
|
952
|
-
console.error('CHANGETAG/Session not found');
|
|
953
927
|
return Promise.reject('Session not found');
|
|
954
928
|
}
|
|
955
929
|
try {
|
|
@@ -981,7 +955,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
981
955
|
}
|
|
982
956
|
}
|
|
983
957
|
else if ([400, 401, 403, 404, 500].includes(resultCode)) {
|
|
984
|
-
console.warn('[APPCONTEXT/CHANGETAG]', resultCode);
|
|
985
958
|
let storageBirthDate = (0, configuration_1.getLocalConfig)('birthDate', undefined);
|
|
986
959
|
let referral;
|
|
987
960
|
try {
|
|
@@ -989,8 +962,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
989
962
|
return window.location.href;
|
|
990
963
|
})();
|
|
991
964
|
}
|
|
992
|
-
catch (
|
|
993
|
-
console.debug(err);
|
|
965
|
+
catch (_l) {
|
|
994
966
|
}
|
|
995
967
|
fetchSession({
|
|
996
968
|
memoriID: (_b = memori.engineMemoriID) !== null && _b !== void 0 ? _b : '',
|
|
@@ -1025,7 +997,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1025
997
|
}
|
|
1026
998
|
catch (_e) {
|
|
1027
999
|
let err = _e;
|
|
1028
|
-
console.warn('[APPCONTEXT/CHANGETAG]', err);
|
|
1029
1000
|
return Promise.reject(err);
|
|
1030
1001
|
}
|
|
1031
1002
|
return null;
|
|
@@ -1046,6 +1017,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1046
1017
|
return () => {
|
|
1047
1018
|
setHasUserActivatedSpeak(false);
|
|
1048
1019
|
setClickedStart(false);
|
|
1020
|
+
sessionStartingRef.current = false;
|
|
1049
1021
|
clearInteractionTimeout();
|
|
1050
1022
|
timeoutRef.current = undefined;
|
|
1051
1023
|
};
|
|
@@ -1075,7 +1047,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1075
1047
|
}, autoStart, defaultEnableAudio, (_u = defaultSpeakerActive !== null && defaultSpeakerActive !== void 0 ? defaultSpeakerActive : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.defaultSpeakerActive) !== null && _u !== void 0 ? _u : true);
|
|
1076
1048
|
const shouldPlayAudio = (text) => {
|
|
1077
1049
|
const currentSpeakerMuted = (0, configuration_1.getLocalConfig)('muteSpeaker', !defaultEnableAudio);
|
|
1078
|
-
console.log('[MemoriWidget] shouldPlayAudio', currentSpeakerMuted);
|
|
1079
1050
|
return (text &&
|
|
1080
1051
|
text.trim() &&
|
|
1081
1052
|
!preview &&
|
|
@@ -1088,15 +1059,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1088
1059
|
}
|
|
1089
1060
|
try {
|
|
1090
1061
|
const message = (0, utils_1.stripDuplicates)(text);
|
|
1091
|
-
console.debug('Processing speech message:', message);
|
|
1092
1062
|
if (message.length > 0) {
|
|
1093
1063
|
setUserMessage('');
|
|
1094
|
-
console.debug('Sending message:', message);
|
|
1095
1064
|
sendMessage(message);
|
|
1096
1065
|
}
|
|
1097
1066
|
}
|
|
1098
|
-
catch (
|
|
1099
|
-
console.error('Error in processSpeechAndSendMessage:', error);
|
|
1067
|
+
catch (_a) {
|
|
1100
1068
|
}
|
|
1101
1069
|
};
|
|
1102
1070
|
const { isListening, startRecording, stopRecording, } = (0, useSTT_1.useSTT)(sttConfig, processSpeechAndSendMessage, {
|
|
@@ -1130,8 +1098,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1130
1098
|
}
|
|
1131
1099
|
return translatedState;
|
|
1132
1100
|
}
|
|
1133
|
-
catch (
|
|
1134
|
-
console.error('Error in translateAndSpeak:', error);
|
|
1101
|
+
catch (_a) {
|
|
1135
1102
|
if (!hasUserActivatedSpeak) {
|
|
1136
1103
|
setHasUserActivatedSpeak(true);
|
|
1137
1104
|
}
|
|
@@ -1146,20 +1113,10 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1146
1113
|
]);
|
|
1147
1114
|
const processEnterTextDialogResponse = (0, react_1.useCallback)((event, pending) => {
|
|
1148
1115
|
var _a, _b;
|
|
1149
|
-
console.debug('[EnterText] processDialogResponse', {
|
|
1150
|
-
correlationID: event.correlationID,
|
|
1151
|
-
resultCode: event.resultCode,
|
|
1152
|
-
hasCurrentState: !!event.currentState,
|
|
1153
|
-
hasBatchQueued: pending.hasBatchQueued,
|
|
1154
|
-
});
|
|
1155
1116
|
const { msg, typingText: pendingTypingText, useLoaderTextAsMsg, } = pending;
|
|
1156
1117
|
const currentState = event.currentState;
|
|
1157
1118
|
if (event.resultCode !== 0 || !currentState) {
|
|
1158
1119
|
if (event.resultCode === 500 && event.resultMessage) {
|
|
1159
|
-
console.warn('[EnterText] processDialogResponse: server error', {
|
|
1160
|
-
correlationID: event.correlationID,
|
|
1161
|
-
resultMessage: event.resultMessage,
|
|
1162
|
-
});
|
|
1163
1120
|
setHistory(h => [
|
|
1164
1121
|
...h,
|
|
1165
1122
|
{
|
|
@@ -1172,24 +1129,15 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1172
1129
|
},
|
|
1173
1130
|
]);
|
|
1174
1131
|
}
|
|
1175
|
-
else if (event.resultCode !== 0) {
|
|
1176
|
-
console.warn('[SEND_MESSAGE/NATS]', event);
|
|
1177
|
-
}
|
|
1178
1132
|
return;
|
|
1179
1133
|
}
|
|
1180
1134
|
if (!msg) {
|
|
1181
|
-
console.debug('[EnterText] processDialogResponse: no msg in pending, skipping');
|
|
1182
1135
|
return;
|
|
1183
1136
|
}
|
|
1184
1137
|
setChatLogID(undefined);
|
|
1185
1138
|
const emission = useLoaderTextAsMsg && pendingTypingText
|
|
1186
1139
|
? pendingTypingText
|
|
1187
1140
|
: (_a = currentState.emission) !== null && _a !== void 0 ? _a : currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.emission;
|
|
1188
|
-
console.debug('[EnterText] processDialogResponse: rendering emission', {
|
|
1189
|
-
correlationID: event.correlationID,
|
|
1190
|
-
emissionPreview: emission === null || emission === void 0 ? void 0 : emission.slice(0, 80),
|
|
1191
|
-
state: currentState.state,
|
|
1192
|
-
});
|
|
1193
1141
|
if (userLang.toLowerCase() !== language.toLowerCase() &&
|
|
1194
1142
|
emission &&
|
|
1195
1143
|
isMultilanguageEnabled) {
|
|
@@ -1256,11 +1204,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1256
1204
|
: event.errorCode
|
|
1257
1205
|
? `Error: ${event.errorCode}`
|
|
1258
1206
|
: 'Error: An unexpected error occurred';
|
|
1259
|
-
console.error('[EnterText] NATS error event', {
|
|
1260
|
-
correlationID,
|
|
1261
|
-
errorCode: event.errorCode,
|
|
1262
|
-
errorMessage: event.errorMessage,
|
|
1263
|
-
});
|
|
1264
1207
|
pushMessage({
|
|
1265
1208
|
text: errorText,
|
|
1266
1209
|
emitter: 'system',
|
|
@@ -1282,24 +1225,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1282
1225
|
const deliverEnterTextNatsResponse = (0, react_1.useCallback)((correlationID, event) => {
|
|
1283
1226
|
const pending = pendingEnterTextRef.current.get(correlationID);
|
|
1284
1227
|
if (!pending) {
|
|
1285
|
-
const pendingCorrelationIDs = [...pendingEnterTextRef.current.keys()];
|
|
1286
|
-
console.warn('[EnterText] NATS response buffered (no matching pending)', {
|
|
1287
|
-
receivedCorrelationID: correlationID,
|
|
1288
|
-
resultCode: event.resultCode,
|
|
1289
|
-
pendingCorrelationIDs,
|
|
1290
|
-
hint: pendingCorrelationIDs.length > 0
|
|
1291
|
-
? 'Use one of pendingCorrelationIDs in your nats pub correlation_id'
|
|
1292
|
-
: 'Send a message in the widget first, then copy correlationID from HTTP response logs',
|
|
1293
|
-
});
|
|
1294
1228
|
bufferedNatsResponsesRef.current.set(correlationID, event);
|
|
1295
1229
|
return;
|
|
1296
1230
|
}
|
|
1297
1231
|
clearEnterTextPending(correlationID, pending);
|
|
1298
1232
|
if (pending.waitForResponse) {
|
|
1299
|
-
console.info('[EnterText] NATS response delivered to waiter', {
|
|
1300
|
-
correlationID,
|
|
1301
|
-
resultCode: event.resultCode,
|
|
1302
|
-
});
|
|
1303
1233
|
pending.waitForResponse.resolve(event);
|
|
1304
1234
|
setMemoriTyping(false);
|
|
1305
1235
|
setTypingText(undefined);
|
|
@@ -1307,23 +1237,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1307
1237
|
}
|
|
1308
1238
|
processEnterTextDialogResponse(event, pending);
|
|
1309
1239
|
if (!pending.hasBatchQueued) {
|
|
1310
|
-
console.info('[EnterText] typing indicator cleared', { correlationID });
|
|
1311
1240
|
setMemoriTyping(false);
|
|
1312
1241
|
setTypingText(undefined);
|
|
1313
1242
|
}
|
|
1314
|
-
else {
|
|
1315
|
-
console.debug('[EnterText] typing kept (batch queued)', {
|
|
1316
|
-
correlationID,
|
|
1317
|
-
});
|
|
1318
|
-
}
|
|
1319
1243
|
}, [processEnterTextDialogResponse, clearEnterTextPending]);
|
|
1320
1244
|
const registerPendingEnterText = (0, react_1.useCallback)((correlationID, pending) => {
|
|
1321
1245
|
const buffered = bufferedNatsResponsesRef.current.get(correlationID);
|
|
1322
1246
|
if (buffered) {
|
|
1323
|
-
console.info('[EnterText] replaying buffered NATS response', {
|
|
1324
|
-
correlationID,
|
|
1325
|
-
waitForResponse: !!pending.waitForResponse,
|
|
1326
|
-
});
|
|
1327
1247
|
bufferedNatsResponsesRef.current.delete(correlationID);
|
|
1328
1248
|
pendingEnterTextRef.current.set(correlationID, pending);
|
|
1329
1249
|
deliverEnterTextNatsResponse(correlationID, buffered);
|
|
@@ -1336,7 +1256,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1336
1256
|
if (!current)
|
|
1337
1257
|
return;
|
|
1338
1258
|
clearEnterTextPending(correlationID, current);
|
|
1339
|
-
|
|
1259
|
+
logWidgetError('NATS timeout', {
|
|
1340
1260
|
correlationID,
|
|
1341
1261
|
timeoutMs: ENTER_TEXT_NATS_TIMEOUT_MS,
|
|
1342
1262
|
});
|
|
@@ -1347,27 +1267,15 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1347
1267
|
(_a = current.waitForResponse) === null || _a === void 0 ? void 0 : _a.reject(new Error('NATS enter-text response timeout'));
|
|
1348
1268
|
}, ENTER_TEXT_NATS_TIMEOUT_MS);
|
|
1349
1269
|
}
|
|
1350
|
-
console.debug('[EnterText] pending registered', {
|
|
1351
|
-
correlationID,
|
|
1352
|
-
waitForResponse: !!pending.waitForResponse,
|
|
1353
|
-
hasBatchQueued: pending.hasBatchQueued,
|
|
1354
|
-
});
|
|
1355
1270
|
pendingEnterTextRef.current.set(correlationID, pending);
|
|
1356
1271
|
}, [deliverEnterTextNatsResponse, clearEnterTextPending]);
|
|
1357
1272
|
const waitForEnterTextNatsResponse = (0, react_1.useCallback)((correlationID, timeoutMs = 120000) => new Promise((resolve, reject) => {
|
|
1358
|
-
console.debug('[EnterText] waiting for NATS response', {
|
|
1359
|
-
correlationID,
|
|
1360
|
-
timeoutMs,
|
|
1361
|
-
});
|
|
1362
1273
|
const timeoutId = setTimeout(() => {
|
|
1363
1274
|
const current = pendingEnterTextRef.current.get(correlationID);
|
|
1364
1275
|
if (current) {
|
|
1365
1276
|
clearEnterTextPending(correlationID, current);
|
|
1366
1277
|
}
|
|
1367
|
-
|
|
1368
|
-
correlationID,
|
|
1369
|
-
timeoutMs,
|
|
1370
|
-
});
|
|
1278
|
+
logWidgetError('NATS timeout', { correlationID, timeoutMs });
|
|
1371
1279
|
reject(new Error('NATS enter-text response timeout'));
|
|
1372
1280
|
}, timeoutMs);
|
|
1373
1281
|
registerPendingEnterText(correlationID, {
|
|
@@ -1388,25 +1296,14 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1388
1296
|
baseUrl,
|
|
1389
1297
|
sessionId,
|
|
1390
1298
|
onProgress: (0, react_1.useCallback)((event) => {
|
|
1391
|
-
console.debug('[EnterText] NATS progress', {
|
|
1392
|
-
correlationID: event.correlationID,
|
|
1393
|
-
step: event.currentStep,
|
|
1394
|
-
finalStep: event.finalStep,
|
|
1395
|
-
message: event.message,
|
|
1396
|
-
});
|
|
1397
1299
|
if (event.message) {
|
|
1398
1300
|
setTypingText(event.message);
|
|
1399
1301
|
}
|
|
1400
1302
|
}, []),
|
|
1401
1303
|
onDialogResponse: (0, react_1.useCallback)((event) => {
|
|
1402
1304
|
const correlationID = event.correlationID;
|
|
1403
|
-
console.debug('[EnterText] NATS dialog.text_entered_response received', {
|
|
1404
|
-
correlationID,
|
|
1405
|
-
resultCode: event.resultCode,
|
|
1406
|
-
requestID: event.requestID,
|
|
1407
|
-
});
|
|
1408
1305
|
if (!correlationID) {
|
|
1409
|
-
|
|
1306
|
+
logWidgetError('NATS dialog response missing correlationID', event);
|
|
1410
1307
|
setMemoriTyping(false);
|
|
1411
1308
|
setTypingText(undefined);
|
|
1412
1309
|
return;
|
|
@@ -1436,7 +1333,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1436
1333
|
timeoutRef.current = undefined;
|
|
1437
1334
|
ttsStop();
|
|
1438
1335
|
}
|
|
1439
|
-
catch (
|
|
1336
|
+
catch (_a) {
|
|
1440
1337
|
}
|
|
1441
1338
|
};
|
|
1442
1339
|
(0, react_1.useEffect)(() => {
|
|
@@ -1634,6 +1531,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1634
1531
|
if (!sessionID && !!minAge && !birth) {
|
|
1635
1532
|
setShowAgeVerification(true);
|
|
1636
1533
|
setClickedStart(false);
|
|
1534
|
+
return;
|
|
1637
1535
|
}
|
|
1638
1536
|
else if (!sessionID &&
|
|
1639
1537
|
memori.privacyType !== 'PUBLIC' &&
|
|
@@ -1645,82 +1543,94 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1645
1543
|
return;
|
|
1646
1544
|
}
|
|
1647
1545
|
else if (!sessionID || initialSessionExpired) {
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
:
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
initial: i === 0,
|
|
1692
|
-
});
|
|
1693
|
-
});
|
|
1694
|
-
translatedMessages = messages !== null && messages !== void 0 ? messages : [];
|
|
1695
|
-
if (language.toUpperCase() !== userLang.toUpperCase() &&
|
|
1696
|
-
isMultilanguageEnabled) {
|
|
1697
|
-
try {
|
|
1698
|
-
translatedMessages = await Promise.all(messages.map(async (m) => {
|
|
1699
|
-
if ('originalText' in m && m.originalText) {
|
|
1700
|
-
return m;
|
|
1701
|
-
}
|
|
1702
|
-
return {
|
|
1546
|
+
if (sessionStartingRef.current) {
|
|
1547
|
+
return;
|
|
1548
|
+
}
|
|
1549
|
+
sessionStartingRef.current = true;
|
|
1550
|
+
try {
|
|
1551
|
+
const session = await fetchSession({
|
|
1552
|
+
memoriID: memori.engineMemoriID,
|
|
1553
|
+
password: secret || memoriPwd || memori.secretToken,
|
|
1554
|
+
tag: personification === null || personification === void 0 ? void 0 : personification.tag,
|
|
1555
|
+
pin: personification === null || personification === void 0 ? void 0 : personification.pin,
|
|
1556
|
+
continueFromChatLogID: chatLog === null || chatLog === void 0 ? void 0 : chatLog.chatLogID,
|
|
1557
|
+
initialContextVars: {
|
|
1558
|
+
LANG: userLang,
|
|
1559
|
+
PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
|
|
1560
|
+
ROUTE: ((_d = (_c = (_b = window.location.pathname) === null || _b === void 0 ? void 0 : _b.split('/')) === null || _c === void 0 ? void 0 : _c.pop()) === null || _d === void 0 ? void 0 : _d.toUpperCase()) ||
|
|
1561
|
+
'',
|
|
1562
|
+
...((!chatLog
|
|
1563
|
+
? initialContextVars
|
|
1564
|
+
: chatLog.lines[chatLog.lines.length - 1].contextVars) || {}),
|
|
1565
|
+
},
|
|
1566
|
+
initialQuestion: chatLog ? undefined : initialQuestion,
|
|
1567
|
+
birthDate: birth,
|
|
1568
|
+
additionalInfo: {
|
|
1569
|
+
...(additionalInfo || {}),
|
|
1570
|
+
loginToken: (_g = (_f = userToken !== null && userToken !== void 0 ? userToken : loginToken) !== null && _f !== void 0 ? _f : additionalInfo === null || additionalInfo === void 0 ? void 0 : additionalInfo.loginToken) !== null && _g !== void 0 ? _g : authToken,
|
|
1571
|
+
language: ((_k = userLang !== null && userLang !== void 0 ? userLang : (_j = (_h = memori.culture) === null || _h === void 0 ? void 0 : _h.split('-')) === null || _j === void 0 ? void 0 : _j[0]) !== null && _k !== void 0 ? _k : 'IT').toLowerCase(),
|
|
1572
|
+
timeZoneOffset: new Date().getTimezoneOffset().toString(),
|
|
1573
|
+
},
|
|
1574
|
+
});
|
|
1575
|
+
if (session === null || session === void 0 ? void 0 : session.dialogState) {
|
|
1576
|
+
if (!chatLog) {
|
|
1577
|
+
setHistory([]);
|
|
1578
|
+
await translateAndSpeak(session.dialogState, userLang);
|
|
1579
|
+
setHasUserActivatedSpeak(true);
|
|
1580
|
+
setClickedStart(false);
|
|
1581
|
+
}
|
|
1582
|
+
else {
|
|
1583
|
+
const messages = chatLog.lines.map((l, i) => {
|
|
1584
|
+
var _a, _b;
|
|
1585
|
+
return ({
|
|
1586
|
+
text: l.text,
|
|
1587
|
+
media: (_b = (_a = l.media) === null || _a === void 0 ? void 0 : _a.filter(m => constants_1.allowedMediaTypes.includes(m.mimeType))) === null || _b === void 0 ? void 0 : _b.map(m => ({
|
|
1588
|
+
mediumID: `${i}-${m.mimeType}`,
|
|
1703
1589
|
...m,
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1590
|
+
})),
|
|
1591
|
+
fromUser: l.inbound,
|
|
1592
|
+
llmUsage: l.llmUsage,
|
|
1593
|
+
timestamp: l.timestamp,
|
|
1594
|
+
emitter: l.emitter,
|
|
1595
|
+
initial: i === 0,
|
|
1596
|
+
});
|
|
1597
|
+
});
|
|
1598
|
+
translatedMessages = messages !== null && messages !== void 0 ? messages : [];
|
|
1599
|
+
if (language.toUpperCase() !== userLang.toUpperCase() &&
|
|
1600
|
+
isMultilanguageEnabled) {
|
|
1601
|
+
try {
|
|
1602
|
+
translatedMessages = await Promise.all(messages.map(async (m) => {
|
|
1603
|
+
if ('originalText' in m && m.originalText) {
|
|
1604
|
+
return m;
|
|
1605
|
+
}
|
|
1606
|
+
return {
|
|
1607
|
+
...m,
|
|
1608
|
+
originalText: m.text,
|
|
1609
|
+
text: (await (0, translations_1.getTranslation)(m.text, userLang, language, baseUrl)).text,
|
|
1610
|
+
};
|
|
1611
|
+
}));
|
|
1612
|
+
}
|
|
1613
|
+
catch (_w) {
|
|
1614
|
+
}
|
|
1711
1615
|
}
|
|
1616
|
+
setHistory(translatedMessages);
|
|
1617
|
+
translateDialogState(session.dialogState, userLang, undefined, true).finally(() => {
|
|
1618
|
+
setHasUserActivatedSpeak(true);
|
|
1619
|
+
setClickedStart(false);
|
|
1620
|
+
});
|
|
1712
1621
|
}
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1622
|
+
}
|
|
1623
|
+
else if ((session === null || session === void 0 ? void 0 : session.resultCode) === 0) {
|
|
1624
|
+
sessionStartingRef.current = false;
|
|
1625
|
+
await onClickStart(session || undefined);
|
|
1626
|
+
}
|
|
1627
|
+
else {
|
|
1628
|
+
setLoading(false);
|
|
1629
|
+
setClickedStart(false);
|
|
1717
1630
|
}
|
|
1718
1631
|
}
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
}
|
|
1722
|
-
else {
|
|
1723
|
-
setLoading(false);
|
|
1632
|
+
finally {
|
|
1633
|
+
sessionStartingRef.current = false;
|
|
1724
1634
|
}
|
|
1725
1635
|
return;
|
|
1726
1636
|
}
|
|
@@ -1730,7 +1640,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1730
1640
|
if (response.resultCode !== 0 || !currentState) {
|
|
1731
1641
|
const { chatLogs } = await getSessionChatLogs(sessionID, sessionID);
|
|
1732
1642
|
setSessionId(undefined);
|
|
1733
|
-
setClickedStart(false);
|
|
1734
1643
|
await onClickStart(undefined, true, chatLogs === null || chatLogs === void 0 ? void 0 : chatLogs[0]);
|
|
1735
1644
|
return;
|
|
1736
1645
|
}
|
|
@@ -1742,13 +1651,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1742
1651
|
const session = await changeTag(memori.engineMemoriID, sessionID, personification.tag, personification.pin);
|
|
1743
1652
|
if (session && session.resultCode === 0) {
|
|
1744
1653
|
await translateAndSpeak(session.currentState, userLang);
|
|
1654
|
+
setClickedStart(false);
|
|
1745
1655
|
}
|
|
1746
1656
|
else {
|
|
1747
1657
|
throw new Error('No session');
|
|
1748
1658
|
}
|
|
1749
1659
|
}
|
|
1750
|
-
catch (
|
|
1751
|
-
console.error('[onClickStart] Error changing tag:', e);
|
|
1660
|
+
catch (_x) {
|
|
1752
1661
|
reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, personification.tag, personification.pin, {
|
|
1753
1662
|
LANG: userLang,
|
|
1754
1663
|
PATHNAME: (_l = window.location.pathname) === null || _l === void 0 ? void 0 : _l.toUpperCase(),
|
|
@@ -1757,6 +1666,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1757
1666
|
...(initialContextVars || {}),
|
|
1758
1667
|
}, initialQuestion, birth).then(() => {
|
|
1759
1668
|
setHasUserActivatedSpeak(true);
|
|
1669
|
+
setClickedStart(false);
|
|
1760
1670
|
});
|
|
1761
1671
|
}
|
|
1762
1672
|
}
|
|
@@ -1769,6 +1679,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1769
1679
|
const session = await changeTag(memori.engineMemoriID, sessionID, constants_1.anonTag);
|
|
1770
1680
|
if (session && session.resultCode === 0) {
|
|
1771
1681
|
await translateAndSpeak(session.currentState, userLang);
|
|
1682
|
+
setClickedStart(false);
|
|
1772
1683
|
}
|
|
1773
1684
|
else {
|
|
1774
1685
|
throw new Error('No session');
|
|
@@ -1783,6 +1694,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1783
1694
|
...(initialContextVars || {}),
|
|
1784
1695
|
}, initialQuestion, birth).then(() => {
|
|
1785
1696
|
setHasUserActivatedSpeak(true);
|
|
1697
|
+
setClickedStart(false);
|
|
1786
1698
|
});
|
|
1787
1699
|
}
|
|
1788
1700
|
}
|
|
@@ -1814,28 +1726,23 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1814
1726
|
text: (await (0, translations_1.getTranslation)(m.text, userLang, language, baseUrl)).text,
|
|
1815
1727
|
})));
|
|
1816
1728
|
}
|
|
1817
|
-
catch (
|
|
1818
|
-
console.error('[onClickStart] Error translating messages:', e);
|
|
1729
|
+
catch (_y) {
|
|
1819
1730
|
}
|
|
1820
1731
|
}
|
|
1821
1732
|
setHistory(translatedMessages);
|
|
1822
1733
|
}
|
|
1823
|
-
catch (
|
|
1824
|
-
console.error('[onClickStart] Error retrieving chat logs:', e);
|
|
1734
|
+
catch (_z) {
|
|
1825
1735
|
}
|
|
1826
1736
|
if ((!!(translatedMessages === null || translatedMessages === void 0 ? void 0 : translatedMessages.length) && translatedMessages.length > 1) ||
|
|
1827
1737
|
!initialQuestion) {
|
|
1828
1738
|
setHasUserActivatedSpeak(true);
|
|
1739
|
+
setClickedStart(false);
|
|
1829
1740
|
await translateAndSpeak(currentState, userLang, undefined, !!(translatedMessages === null || translatedMessages === void 0 ? void 0 : translatedMessages.length));
|
|
1830
1741
|
}
|
|
1831
1742
|
else {
|
|
1832
|
-
console.log('[onClickStart] Starting with initial question');
|
|
1833
1743
|
translatedMessages = [];
|
|
1834
1744
|
setHistory([]);
|
|
1835
1745
|
const placeSpec = getPlaceSpecForEnterText(position);
|
|
1836
|
-
console.debug('[EnterText] onClickStart: posting initial question', {
|
|
1837
|
-
sessionId: sessionID,
|
|
1838
|
-
});
|
|
1839
1746
|
const response = await postEnterTextAsync({
|
|
1840
1747
|
sessionId: sessionID,
|
|
1841
1748
|
text: initialQuestion,
|
|
@@ -1844,10 +1751,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1844
1751
|
}),
|
|
1845
1752
|
...(placeSpec !== undefined && { place: placeSpec }),
|
|
1846
1753
|
});
|
|
1847
|
-
console.debug('[EnterText] onClickStart: HTTP response', {
|
|
1848
|
-
resultCode: response.resultCode,
|
|
1849
|
-
correlationID: readCorrelationID(response),
|
|
1850
|
-
});
|
|
1851
1754
|
if (response.resultCode === 500 && response.resultMessage) {
|
|
1852
1755
|
setHistory(h => [
|
|
1853
1756
|
...h,
|
|
@@ -1864,28 +1767,22 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1864
1767
|
}
|
|
1865
1768
|
const onClickStartCorrelationID = readCorrelationID(response);
|
|
1866
1769
|
if (response.resultCode === 0 && onClickStartCorrelationID) {
|
|
1867
|
-
console.info('[EnterText] onClickStart: accepted, showing typing indicator', {
|
|
1868
|
-
correlationID: onClickStartCorrelationID,
|
|
1869
|
-
});
|
|
1870
1770
|
setMemoriTyping(true);
|
|
1871
1771
|
try {
|
|
1872
1772
|
const natsEvent = await waitForEnterTextNatsResponse(onClickStartCorrelationID);
|
|
1873
|
-
console.info('[EnterText] onClickStart: NATS response received', {
|
|
1874
|
-
correlationID: onClickStartCorrelationID,
|
|
1875
|
-
resultCode: natsEvent.resultCode,
|
|
1876
|
-
});
|
|
1877
1773
|
if (natsEvent.resultCode === 0 && natsEvent.currentState) {
|
|
1878
1774
|
await translateAndSpeak(natsEvent.currentState, userLang, undefined, false);
|
|
1775
|
+
setClickedStart(false);
|
|
1879
1776
|
}
|
|
1880
1777
|
}
|
|
1881
|
-
catch (
|
|
1882
|
-
|
|
1778
|
+
catch (err) {
|
|
1779
|
+
logWidgetError('onClickStart NATS wait failed', err);
|
|
1883
1780
|
setMemoriTyping(false);
|
|
1884
1781
|
setTypingText(undefined);
|
|
1885
1782
|
}
|
|
1886
1783
|
}
|
|
1887
1784
|
else if (response.resultCode === 0) {
|
|
1888
|
-
|
|
1785
|
+
logWidgetError('onClickStart enter-text missing correlationID', response);
|
|
1889
1786
|
}
|
|
1890
1787
|
}
|
|
1891
1788
|
}
|
|
@@ -1893,13 +1790,18 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1893
1790
|
else {
|
|
1894
1791
|
setHistory([]);
|
|
1895
1792
|
await translateAndSpeak(dialogState, userLang);
|
|
1793
|
+
setClickedStart(false);
|
|
1896
1794
|
}
|
|
1897
1795
|
}, [memoriPwd, memori, memoriTokens, birthDate, sessionId, userLang, position]);
|
|
1898
1796
|
(0, react_1.useEffect)(() => {
|
|
1899
|
-
if (!clickedStart &&
|
|
1797
|
+
if (!clickedStart &&
|
|
1798
|
+
!sessionStartingRef.current &&
|
|
1799
|
+
!sessionId &&
|
|
1800
|
+
autoStart &&
|
|
1801
|
+
selectedLayout !== 'HIDDEN_CHAT') {
|
|
1900
1802
|
onClickStart();
|
|
1901
1803
|
}
|
|
1902
|
-
}, [clickedStart, autoStart, selectedLayout]);
|
|
1804
|
+
}, [clickedStart, autoStart, selectedLayout, sessionId]);
|
|
1903
1805
|
(0, react_1.useEffect)(() => {
|
|
1904
1806
|
const targetNode = document.querySelector(`memori-client[memoriname="${memori.name}"]`) ||
|
|
1905
1807
|
document.querySelector(`memori-client[memoriid="${memori.memoriID}"]`) ||
|
|
@@ -1940,12 +1842,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1940
1842
|
if (resp.resultCode === 0) {
|
|
1941
1843
|
setExperts(experts);
|
|
1942
1844
|
}
|
|
1943
|
-
else {
|
|
1944
|
-
console.warn('Error fetching experts', resp);
|
|
1945
|
-
}
|
|
1946
1845
|
}
|
|
1947
|
-
catch (
|
|
1948
|
-
console.warn(err);
|
|
1846
|
+
catch (_a) {
|
|
1949
1847
|
}
|
|
1950
1848
|
}, [sessionId, memori === null || memori === void 0 ? void 0 : memori.enableBoardOfExperts]);
|
|
1951
1849
|
(0, react_1.useEffect)(() => {
|
|
@@ -1966,7 +1864,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1966
1864
|
if (!(tenant === null || tenant === void 0 ? void 0 : tenant.billingDelegation))
|
|
1967
1865
|
return true;
|
|
1968
1866
|
if (!ownerUserID && !ownerUserName) {
|
|
1969
|
-
console.warn('Cannot verify credits: missing owner identifier');
|
|
1970
1867
|
if (options === null || options === void 0 ? void 0 : options.notify) {
|
|
1971
1868
|
handleNotEnoughCredits();
|
|
1972
1869
|
}
|
|
@@ -1990,7 +1887,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1990
1887
|
return true;
|
|
1991
1888
|
}
|
|
1992
1889
|
else {
|
|
1993
|
-
console.warn('Not enough credits. Required:', resp.required);
|
|
1994
1890
|
if (options === null || options === void 0 ? void 0 : options.notify) {
|
|
1995
1891
|
handleNotEnoughCredits();
|
|
1996
1892
|
}
|
|
@@ -2000,9 +1896,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2000
1896
|
return false;
|
|
2001
1897
|
}
|
|
2002
1898
|
}
|
|
2003
|
-
catch (
|
|
2004
|
-
|
|
2005
|
-
console.debug(err);
|
|
1899
|
+
catch (err) {
|
|
1900
|
+
logWidgetError('checkCredits failed', err);
|
|
2006
1901
|
return true;
|
|
2007
1902
|
}
|
|
2008
1903
|
}, [
|