@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
|
@@ -67,6 +67,9 @@ const NULL_PLACE_SPEC = {
|
|
|
67
67
|
uncertaintyKm: null,
|
|
68
68
|
};
|
|
69
69
|
const ENTER_TEXT_NATS_TIMEOUT_MS = 120000;
|
|
70
|
+
const logWidgetError = (context, detail) => {
|
|
71
|
+
console.error(`[MemoriWidget] ${context}`, detail !== null && detail !== void 0 ? detail : '');
|
|
72
|
+
};
|
|
70
73
|
function readCorrelationID(response) {
|
|
71
74
|
const value = response.correlationID;
|
|
72
75
|
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
@@ -205,6 +208,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
205
208
|
}, [loginToken, user === null || user === void 0 ? void 0 : user.userID]);
|
|
206
209
|
const [showLoginDrawer, setShowLoginDrawer] = useState(false);
|
|
207
210
|
const [clickedStart, setClickedStart] = useState(false);
|
|
211
|
+
const sessionStartingRef = useRef(false);
|
|
208
212
|
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()) ||
|
|
209
213
|
((_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());
|
|
210
214
|
const integrationConfig = (integration === null || integration === void 0 ? void 0 : integration.customData)
|
|
@@ -447,12 +451,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
447
451
|
let gotError = false;
|
|
448
452
|
try {
|
|
449
453
|
const placeSpec = getPlaceSpecForEnterText(position);
|
|
450
|
-
console.debug('[EnterText] sendMessage: posting', {
|
|
451
|
-
sessionId: sessionID,
|
|
452
|
-
textLength: msg.length,
|
|
453
|
-
hasBatchQueued,
|
|
454
|
-
typingText,
|
|
455
|
-
});
|
|
456
454
|
const response = await postEnterTextAsync({
|
|
457
455
|
sessionId: sessionID,
|
|
458
456
|
text: msg,
|
|
@@ -461,11 +459,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
461
459
|
}),
|
|
462
460
|
...(placeSpec !== undefined && { place: placeSpec }),
|
|
463
461
|
});
|
|
464
|
-
console.debug('[EnterText] sendMessage: HTTP response', {
|
|
465
|
-
resultCode: response.resultCode,
|
|
466
|
-
correlationID: readCorrelationID(response),
|
|
467
|
-
resultMessage: response.resultMessage,
|
|
468
|
-
});
|
|
469
462
|
const correlationID = readCorrelationID(response);
|
|
470
463
|
if (response.resultCode === 0 && correlationID) {
|
|
471
464
|
registerPendingEnterText(correlationID, {
|
|
@@ -474,15 +467,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
474
467
|
useLoaderTextAsMsg,
|
|
475
468
|
hasBatchQueued,
|
|
476
469
|
});
|
|
477
|
-
console.info('[EnterText] sendMessage: accepted, showing typing indicator', {
|
|
478
|
-
correlationID: correlationID,
|
|
479
|
-
typingText,
|
|
480
|
-
});
|
|
481
470
|
setMemoriTyping(true);
|
|
482
471
|
setTypingText(typingText);
|
|
483
472
|
}
|
|
484
473
|
else if (response.resultCode === 0) {
|
|
485
|
-
|
|
474
|
+
logWidgetError('enter-text missing correlationID', response);
|
|
486
475
|
}
|
|
487
476
|
else if (response.resultCode === 404) {
|
|
488
477
|
setHistory(h => [...h.slice(0, h.length - 1)]);
|
|
@@ -492,7 +481,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
492
481
|
ROUTE: ((_d = (_c = window.location.pathname) === null || _c === void 0 ? void 0 : _c.split('/')) === null || _d === void 0 ? void 0 : _d.pop()) || '',
|
|
493
482
|
...(initialContextVars || {}),
|
|
494
483
|
}, initialQuestion, undefined, undefined, undefined, undefined, true).then(state => {
|
|
495
|
-
console.info('session timeout');
|
|
496
484
|
if (state === null || state === void 0 ? void 0 : state.sessionID) {
|
|
497
485
|
setTimeout(() => {
|
|
498
486
|
sendMessage(text, media, state === null || state === void 0 ? void 0 : state.sessionID);
|
|
@@ -514,13 +502,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
514
502
|
]);
|
|
515
503
|
}
|
|
516
504
|
else {
|
|
517
|
-
console.warn('[SEND_MESSAGE]', response);
|
|
518
505
|
return Promise.reject(response);
|
|
519
506
|
}
|
|
520
507
|
}
|
|
521
508
|
catch (error) {
|
|
522
|
-
console.error('[EnterText] sendMessage: request failed', error);
|
|
523
509
|
gotError = true;
|
|
510
|
+
logWidgetError('sendMessage failed', error);
|
|
524
511
|
setTypingText(undefined);
|
|
525
512
|
setMemoriTyping(false);
|
|
526
513
|
}
|
|
@@ -602,7 +589,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
602
589
|
}
|
|
603
590
|
}
|
|
604
591
|
catch (error) {
|
|
605
|
-
console.error('[TRANSLATE] Error during translation:', error);
|
|
606
592
|
translatedState = { ...state, emission };
|
|
607
593
|
translatedMsg = {
|
|
608
594
|
text: emission,
|
|
@@ -710,7 +696,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
710
696
|
try {
|
|
711
697
|
setTimeout(() => {
|
|
712
698
|
var _a;
|
|
713
|
-
console.log('snippet', s);
|
|
714
699
|
new Function((_a = s.content) !== null && _a !== void 0 ? _a : '')();
|
|
715
700
|
setTimeout(() => {
|
|
716
701
|
var _a, _b, _c;
|
|
@@ -719,8 +704,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
719
704
|
}, 400);
|
|
720
705
|
}, 1000);
|
|
721
706
|
}
|
|
722
|
-
catch (
|
|
723
|
-
console.warn(e);
|
|
707
|
+
catch (_a) {
|
|
724
708
|
}
|
|
725
709
|
});
|
|
726
710
|
};
|
|
@@ -756,8 +740,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
756
740
|
return window.location.href;
|
|
757
741
|
})();
|
|
758
742
|
}
|
|
759
|
-
catch (
|
|
760
|
-
console.debug(err);
|
|
743
|
+
catch (_m) {
|
|
761
744
|
}
|
|
762
745
|
const session = await initSession({
|
|
763
746
|
...params,
|
|
@@ -789,7 +772,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
789
772
|
};
|
|
790
773
|
}
|
|
791
774
|
else if (session === null || session === void 0 ? void 0 : session.resultMessage.startsWith('This Memori is aged restricted')) {
|
|
792
|
-
console.warn(session);
|
|
793
775
|
toast.error(t('underageTwinSession', { age: minAge }));
|
|
794
776
|
}
|
|
795
777
|
else if ((session === null || session === void 0 ? void 0 : session.resultCode) === 403 && memori.privacyType !== 'PUBLIC') {
|
|
@@ -798,7 +780,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
798
780
|
return session;
|
|
799
781
|
}
|
|
800
782
|
else {
|
|
801
|
-
console.warn(session);
|
|
802
783
|
toast.error(tst => (_jsxs("div", { children: [_jsx("p", { children: t(getErrori18nKey(session === null || session === void 0 ? void 0 : session.resultCode)) }), _jsx(Button, { outlined: true, padded: false, onClick: () => toast.dismiss(tst.id), icon: _jsx(CloseIcon, {}), children: t('close') })] })), {
|
|
803
784
|
duration: Infinity,
|
|
804
785
|
});
|
|
@@ -806,7 +787,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
806
787
|
}
|
|
807
788
|
}
|
|
808
789
|
catch (err) {
|
|
809
|
-
|
|
790
|
+
logWidgetError('fetchSession failed', err);
|
|
810
791
|
}
|
|
811
792
|
};
|
|
812
793
|
const reopenSession = async (updateDialogState = false, password, recoveryTokens, tag, pin, initialContextVars, initialQuestion, birthDate, additionalInfoProp, continueFromChatLogID, continueFromSessionID, isSessionExpired) => {
|
|
@@ -838,8 +819,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
838
819
|
return window.location.href;
|
|
839
820
|
})();
|
|
840
821
|
}
|
|
841
|
-
catch (
|
|
842
|
-
console.debug('[REOPEN_SESSION] Error getting referral:', err);
|
|
822
|
+
catch (_o) {
|
|
843
823
|
}
|
|
844
824
|
const { sessionID, currentState, ...response } = await initSession({
|
|
845
825
|
memoriID: (_a = memori.engineMemoriID) !== null && _a !== void 0 ? _a : '',
|
|
@@ -866,12 +846,10 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
866
846
|
},
|
|
867
847
|
});
|
|
868
848
|
if (sessionID && currentState && response.resultCode === 0) {
|
|
869
|
-
console.log('[REOPEN_SESSION] Session initialized successfully:', sessionID);
|
|
870
849
|
setSessionId(sessionID);
|
|
871
850
|
if (updateDialogState) {
|
|
872
851
|
setCurrentDialogState(currentState);
|
|
873
852
|
if (currentState.emission) {
|
|
874
|
-
console.log('[REOPEN_SESSION] Processing emission:', currentState.emission);
|
|
875
853
|
const initialStatus = isSessionExpired && history.length > 1
|
|
876
854
|
? 'Session Expired, reopening session'
|
|
877
855
|
: history.length <= 1
|
|
@@ -923,22 +901,19 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
923
901
|
};
|
|
924
902
|
}
|
|
925
903
|
else if (response === null || response === void 0 ? void 0 : response.resultMessage.startsWith('This Memori is aged restricted')) {
|
|
926
|
-
console.error('[REOPEN_SESSION] Age restriction error:', response);
|
|
927
904
|
toast.error(t('underageTwinSession', { age: minAge }));
|
|
928
905
|
}
|
|
929
906
|
else if ((response === null || response === void 0 ? void 0 : response.resultCode) === 403 &&
|
|
930
907
|
memori.privacyType !== 'PUBLIC') {
|
|
931
|
-
console.error('[REOPEN_SESSION] Authentication error');
|
|
932
908
|
setMemoriPwd(undefined);
|
|
933
909
|
setAuthModalState('password');
|
|
934
910
|
}
|
|
935
911
|
else {
|
|
936
|
-
console.error('[REOPEN_SESSION] Other error:', response);
|
|
937
912
|
toast.error(t(getErrori18nKey(response.resultCode)));
|
|
938
913
|
}
|
|
939
914
|
}
|
|
940
915
|
catch (err) {
|
|
941
|
-
|
|
916
|
+
logWidgetError('reopenSession failed', err);
|
|
942
917
|
}
|
|
943
918
|
setLoading(false);
|
|
944
919
|
return null;
|
|
@@ -946,7 +921,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
946
921
|
const changeTag = async (memoriId, sessionId, tag, pin) => {
|
|
947
922
|
var _a, _b, _c, _d, _f, _g, _h, _j, _k;
|
|
948
923
|
if (!memoriId || !sessionId) {
|
|
949
|
-
console.error('CHANGETAG/Session not found');
|
|
950
924
|
return Promise.reject('Session not found');
|
|
951
925
|
}
|
|
952
926
|
try {
|
|
@@ -978,7 +952,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
978
952
|
}
|
|
979
953
|
}
|
|
980
954
|
else if ([400, 401, 403, 404, 500].includes(resultCode)) {
|
|
981
|
-
console.warn('[APPCONTEXT/CHANGETAG]', resultCode);
|
|
982
955
|
let storageBirthDate = getLocalConfig('birthDate', undefined);
|
|
983
956
|
let referral;
|
|
984
957
|
try {
|
|
@@ -986,8 +959,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
986
959
|
return window.location.href;
|
|
987
960
|
})();
|
|
988
961
|
}
|
|
989
|
-
catch (
|
|
990
|
-
console.debug(err);
|
|
962
|
+
catch (_l) {
|
|
991
963
|
}
|
|
992
964
|
fetchSession({
|
|
993
965
|
memoriID: (_b = memori.engineMemoriID) !== null && _b !== void 0 ? _b : '',
|
|
@@ -1022,7 +994,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1022
994
|
}
|
|
1023
995
|
catch (_e) {
|
|
1024
996
|
let err = _e;
|
|
1025
|
-
console.warn('[APPCONTEXT/CHANGETAG]', err);
|
|
1026
997
|
return Promise.reject(err);
|
|
1027
998
|
}
|
|
1028
999
|
return null;
|
|
@@ -1043,6 +1014,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1043
1014
|
return () => {
|
|
1044
1015
|
setHasUserActivatedSpeak(false);
|
|
1045
1016
|
setClickedStart(false);
|
|
1017
|
+
sessionStartingRef.current = false;
|
|
1046
1018
|
clearInteractionTimeout();
|
|
1047
1019
|
timeoutRef.current = undefined;
|
|
1048
1020
|
};
|
|
@@ -1072,7 +1044,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1072
1044
|
}, autoStart, defaultEnableAudio, (_u = defaultSpeakerActive !== null && defaultSpeakerActive !== void 0 ? defaultSpeakerActive : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.defaultSpeakerActive) !== null && _u !== void 0 ? _u : true);
|
|
1073
1045
|
const shouldPlayAudio = (text) => {
|
|
1074
1046
|
const currentSpeakerMuted = getLocalConfig('muteSpeaker', !defaultEnableAudio);
|
|
1075
|
-
console.log('[MemoriWidget] shouldPlayAudio', currentSpeakerMuted);
|
|
1076
1047
|
return (text &&
|
|
1077
1048
|
text.trim() &&
|
|
1078
1049
|
!preview &&
|
|
@@ -1085,15 +1056,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1085
1056
|
}
|
|
1086
1057
|
try {
|
|
1087
1058
|
const message = stripDuplicates(text);
|
|
1088
|
-
console.debug('Processing speech message:', message);
|
|
1089
1059
|
if (message.length > 0) {
|
|
1090
1060
|
setUserMessage('');
|
|
1091
|
-
console.debug('Sending message:', message);
|
|
1092
1061
|
sendMessage(message);
|
|
1093
1062
|
}
|
|
1094
1063
|
}
|
|
1095
|
-
catch (
|
|
1096
|
-
console.error('Error in processSpeechAndSendMessage:', error);
|
|
1064
|
+
catch (_a) {
|
|
1097
1065
|
}
|
|
1098
1066
|
};
|
|
1099
1067
|
const { isListening, startRecording, stopRecording, } = useSTT(sttConfig, processSpeechAndSendMessage, {
|
|
@@ -1127,8 +1095,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1127
1095
|
}
|
|
1128
1096
|
return translatedState;
|
|
1129
1097
|
}
|
|
1130
|
-
catch (
|
|
1131
|
-
console.error('Error in translateAndSpeak:', error);
|
|
1098
|
+
catch (_a) {
|
|
1132
1099
|
if (!hasUserActivatedSpeak) {
|
|
1133
1100
|
setHasUserActivatedSpeak(true);
|
|
1134
1101
|
}
|
|
@@ -1143,20 +1110,10 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1143
1110
|
]);
|
|
1144
1111
|
const processEnterTextDialogResponse = useCallback((event, pending) => {
|
|
1145
1112
|
var _a, _b;
|
|
1146
|
-
console.debug('[EnterText] processDialogResponse', {
|
|
1147
|
-
correlationID: event.correlationID,
|
|
1148
|
-
resultCode: event.resultCode,
|
|
1149
|
-
hasCurrentState: !!event.currentState,
|
|
1150
|
-
hasBatchQueued: pending.hasBatchQueued,
|
|
1151
|
-
});
|
|
1152
1113
|
const { msg, typingText: pendingTypingText, useLoaderTextAsMsg, } = pending;
|
|
1153
1114
|
const currentState = event.currentState;
|
|
1154
1115
|
if (event.resultCode !== 0 || !currentState) {
|
|
1155
1116
|
if (event.resultCode === 500 && event.resultMessage) {
|
|
1156
|
-
console.warn('[EnterText] processDialogResponse: server error', {
|
|
1157
|
-
correlationID: event.correlationID,
|
|
1158
|
-
resultMessage: event.resultMessage,
|
|
1159
|
-
});
|
|
1160
1117
|
setHistory(h => [
|
|
1161
1118
|
...h,
|
|
1162
1119
|
{
|
|
@@ -1169,24 +1126,15 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1169
1126
|
},
|
|
1170
1127
|
]);
|
|
1171
1128
|
}
|
|
1172
|
-
else if (event.resultCode !== 0) {
|
|
1173
|
-
console.warn('[SEND_MESSAGE/NATS]', event);
|
|
1174
|
-
}
|
|
1175
1129
|
return;
|
|
1176
1130
|
}
|
|
1177
1131
|
if (!msg) {
|
|
1178
|
-
console.debug('[EnterText] processDialogResponse: no msg in pending, skipping');
|
|
1179
1132
|
return;
|
|
1180
1133
|
}
|
|
1181
1134
|
setChatLogID(undefined);
|
|
1182
1135
|
const emission = useLoaderTextAsMsg && pendingTypingText
|
|
1183
1136
|
? pendingTypingText
|
|
1184
1137
|
: (_a = currentState.emission) !== null && _a !== void 0 ? _a : currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.emission;
|
|
1185
|
-
console.debug('[EnterText] processDialogResponse: rendering emission', {
|
|
1186
|
-
correlationID: event.correlationID,
|
|
1187
|
-
emissionPreview: emission === null || emission === void 0 ? void 0 : emission.slice(0, 80),
|
|
1188
|
-
state: currentState.state,
|
|
1189
|
-
});
|
|
1190
1138
|
if (userLang.toLowerCase() !== language.toLowerCase() &&
|
|
1191
1139
|
emission &&
|
|
1192
1140
|
isMultilanguageEnabled) {
|
|
@@ -1253,11 +1201,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1253
1201
|
: event.errorCode
|
|
1254
1202
|
? `Error: ${event.errorCode}`
|
|
1255
1203
|
: 'Error: An unexpected error occurred';
|
|
1256
|
-
console.error('[EnterText] NATS error event', {
|
|
1257
|
-
correlationID,
|
|
1258
|
-
errorCode: event.errorCode,
|
|
1259
|
-
errorMessage: event.errorMessage,
|
|
1260
|
-
});
|
|
1261
1204
|
pushMessage({
|
|
1262
1205
|
text: errorText,
|
|
1263
1206
|
emitter: 'system',
|
|
@@ -1279,24 +1222,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1279
1222
|
const deliverEnterTextNatsResponse = useCallback((correlationID, event) => {
|
|
1280
1223
|
const pending = pendingEnterTextRef.current.get(correlationID);
|
|
1281
1224
|
if (!pending) {
|
|
1282
|
-
const pendingCorrelationIDs = [...pendingEnterTextRef.current.keys()];
|
|
1283
|
-
console.warn('[EnterText] NATS response buffered (no matching pending)', {
|
|
1284
|
-
receivedCorrelationID: correlationID,
|
|
1285
|
-
resultCode: event.resultCode,
|
|
1286
|
-
pendingCorrelationIDs,
|
|
1287
|
-
hint: pendingCorrelationIDs.length > 0
|
|
1288
|
-
? 'Use one of pendingCorrelationIDs in your nats pub correlation_id'
|
|
1289
|
-
: 'Send a message in the widget first, then copy correlationID from HTTP response logs',
|
|
1290
|
-
});
|
|
1291
1225
|
bufferedNatsResponsesRef.current.set(correlationID, event);
|
|
1292
1226
|
return;
|
|
1293
1227
|
}
|
|
1294
1228
|
clearEnterTextPending(correlationID, pending);
|
|
1295
1229
|
if (pending.waitForResponse) {
|
|
1296
|
-
console.info('[EnterText] NATS response delivered to waiter', {
|
|
1297
|
-
correlationID,
|
|
1298
|
-
resultCode: event.resultCode,
|
|
1299
|
-
});
|
|
1300
1230
|
pending.waitForResponse.resolve(event);
|
|
1301
1231
|
setMemoriTyping(false);
|
|
1302
1232
|
setTypingText(undefined);
|
|
@@ -1304,23 +1234,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1304
1234
|
}
|
|
1305
1235
|
processEnterTextDialogResponse(event, pending);
|
|
1306
1236
|
if (!pending.hasBatchQueued) {
|
|
1307
|
-
console.info('[EnterText] typing indicator cleared', { correlationID });
|
|
1308
1237
|
setMemoriTyping(false);
|
|
1309
1238
|
setTypingText(undefined);
|
|
1310
1239
|
}
|
|
1311
|
-
else {
|
|
1312
|
-
console.debug('[EnterText] typing kept (batch queued)', {
|
|
1313
|
-
correlationID,
|
|
1314
|
-
});
|
|
1315
|
-
}
|
|
1316
1240
|
}, [processEnterTextDialogResponse, clearEnterTextPending]);
|
|
1317
1241
|
const registerPendingEnterText = useCallback((correlationID, pending) => {
|
|
1318
1242
|
const buffered = bufferedNatsResponsesRef.current.get(correlationID);
|
|
1319
1243
|
if (buffered) {
|
|
1320
|
-
console.info('[EnterText] replaying buffered NATS response', {
|
|
1321
|
-
correlationID,
|
|
1322
|
-
waitForResponse: !!pending.waitForResponse,
|
|
1323
|
-
});
|
|
1324
1244
|
bufferedNatsResponsesRef.current.delete(correlationID);
|
|
1325
1245
|
pendingEnterTextRef.current.set(correlationID, pending);
|
|
1326
1246
|
deliverEnterTextNatsResponse(correlationID, buffered);
|
|
@@ -1333,7 +1253,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1333
1253
|
if (!current)
|
|
1334
1254
|
return;
|
|
1335
1255
|
clearEnterTextPending(correlationID, current);
|
|
1336
|
-
|
|
1256
|
+
logWidgetError('NATS timeout', {
|
|
1337
1257
|
correlationID,
|
|
1338
1258
|
timeoutMs: ENTER_TEXT_NATS_TIMEOUT_MS,
|
|
1339
1259
|
});
|
|
@@ -1344,27 +1264,15 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1344
1264
|
(_a = current.waitForResponse) === null || _a === void 0 ? void 0 : _a.reject(new Error('NATS enter-text response timeout'));
|
|
1345
1265
|
}, ENTER_TEXT_NATS_TIMEOUT_MS);
|
|
1346
1266
|
}
|
|
1347
|
-
console.debug('[EnterText] pending registered', {
|
|
1348
|
-
correlationID,
|
|
1349
|
-
waitForResponse: !!pending.waitForResponse,
|
|
1350
|
-
hasBatchQueued: pending.hasBatchQueued,
|
|
1351
|
-
});
|
|
1352
1267
|
pendingEnterTextRef.current.set(correlationID, pending);
|
|
1353
1268
|
}, [deliverEnterTextNatsResponse, clearEnterTextPending]);
|
|
1354
1269
|
const waitForEnterTextNatsResponse = useCallback((correlationID, timeoutMs = 120000) => new Promise((resolve, reject) => {
|
|
1355
|
-
console.debug('[EnterText] waiting for NATS response', {
|
|
1356
|
-
correlationID,
|
|
1357
|
-
timeoutMs,
|
|
1358
|
-
});
|
|
1359
1270
|
const timeoutId = setTimeout(() => {
|
|
1360
1271
|
const current = pendingEnterTextRef.current.get(correlationID);
|
|
1361
1272
|
if (current) {
|
|
1362
1273
|
clearEnterTextPending(correlationID, current);
|
|
1363
1274
|
}
|
|
1364
|
-
|
|
1365
|
-
correlationID,
|
|
1366
|
-
timeoutMs,
|
|
1367
|
-
});
|
|
1275
|
+
logWidgetError('NATS timeout', { correlationID, timeoutMs });
|
|
1368
1276
|
reject(new Error('NATS enter-text response timeout'));
|
|
1369
1277
|
}, timeoutMs);
|
|
1370
1278
|
registerPendingEnterText(correlationID, {
|
|
@@ -1385,25 +1293,14 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1385
1293
|
baseUrl,
|
|
1386
1294
|
sessionId,
|
|
1387
1295
|
onProgress: useCallback((event) => {
|
|
1388
|
-
console.debug('[EnterText] NATS progress', {
|
|
1389
|
-
correlationID: event.correlationID,
|
|
1390
|
-
step: event.currentStep,
|
|
1391
|
-
finalStep: event.finalStep,
|
|
1392
|
-
message: event.message,
|
|
1393
|
-
});
|
|
1394
1296
|
if (event.message) {
|
|
1395
1297
|
setTypingText(event.message);
|
|
1396
1298
|
}
|
|
1397
1299
|
}, []),
|
|
1398
1300
|
onDialogResponse: useCallback((event) => {
|
|
1399
1301
|
const correlationID = event.correlationID;
|
|
1400
|
-
console.debug('[EnterText] NATS dialog.text_entered_response received', {
|
|
1401
|
-
correlationID,
|
|
1402
|
-
resultCode: event.resultCode,
|
|
1403
|
-
requestID: event.requestID,
|
|
1404
|
-
});
|
|
1405
1302
|
if (!correlationID) {
|
|
1406
|
-
|
|
1303
|
+
logWidgetError('NATS dialog response missing correlationID', event);
|
|
1407
1304
|
setMemoriTyping(false);
|
|
1408
1305
|
setTypingText(undefined);
|
|
1409
1306
|
return;
|
|
@@ -1433,7 +1330,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1433
1330
|
timeoutRef.current = undefined;
|
|
1434
1331
|
ttsStop();
|
|
1435
1332
|
}
|
|
1436
|
-
catch (
|
|
1333
|
+
catch (_a) {
|
|
1437
1334
|
}
|
|
1438
1335
|
};
|
|
1439
1336
|
useEffect(() => {
|
|
@@ -1631,6 +1528,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1631
1528
|
if (!sessionID && !!minAge && !birth) {
|
|
1632
1529
|
setShowAgeVerification(true);
|
|
1633
1530
|
setClickedStart(false);
|
|
1531
|
+
return;
|
|
1634
1532
|
}
|
|
1635
1533
|
else if (!sessionID &&
|
|
1636
1534
|
memori.privacyType !== 'PUBLIC' &&
|
|
@@ -1642,82 +1540,94 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1642
1540
|
return;
|
|
1643
1541
|
}
|
|
1644
1542
|
else if (!sessionID || initialSessionExpired) {
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
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
|
-
initial: i === 0,
|
|
1689
|
-
});
|
|
1690
|
-
});
|
|
1691
|
-
translatedMessages = messages !== null && messages !== void 0 ? messages : [];
|
|
1692
|
-
if (language.toUpperCase() !== userLang.toUpperCase() &&
|
|
1693
|
-
isMultilanguageEnabled) {
|
|
1694
|
-
try {
|
|
1695
|
-
translatedMessages = await Promise.all(messages.map(async (m) => {
|
|
1696
|
-
if ('originalText' in m && m.originalText) {
|
|
1697
|
-
return m;
|
|
1698
|
-
}
|
|
1699
|
-
return {
|
|
1543
|
+
if (sessionStartingRef.current) {
|
|
1544
|
+
return;
|
|
1545
|
+
}
|
|
1546
|
+
sessionStartingRef.current = true;
|
|
1547
|
+
try {
|
|
1548
|
+
const session = await fetchSession({
|
|
1549
|
+
memoriID: memori.engineMemoriID,
|
|
1550
|
+
password: secret || memoriPwd || memori.secretToken,
|
|
1551
|
+
tag: personification === null || personification === void 0 ? void 0 : personification.tag,
|
|
1552
|
+
pin: personification === null || personification === void 0 ? void 0 : personification.pin,
|
|
1553
|
+
continueFromChatLogID: chatLog === null || chatLog === void 0 ? void 0 : chatLog.chatLogID,
|
|
1554
|
+
initialContextVars: {
|
|
1555
|
+
LANG: userLang,
|
|
1556
|
+
PATHNAME: (_a = window.location.pathname) === null || _a === void 0 ? void 0 : _a.toUpperCase(),
|
|
1557
|
+
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()) ||
|
|
1558
|
+
'',
|
|
1559
|
+
...((!chatLog
|
|
1560
|
+
? initialContextVars
|
|
1561
|
+
: chatLog.lines[chatLog.lines.length - 1].contextVars) || {}),
|
|
1562
|
+
},
|
|
1563
|
+
initialQuestion: chatLog ? undefined : initialQuestion,
|
|
1564
|
+
birthDate: birth,
|
|
1565
|
+
additionalInfo: {
|
|
1566
|
+
...(additionalInfo || {}),
|
|
1567
|
+
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,
|
|
1568
|
+
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(),
|
|
1569
|
+
timeZoneOffset: new Date().getTimezoneOffset().toString(),
|
|
1570
|
+
},
|
|
1571
|
+
});
|
|
1572
|
+
if (session === null || session === void 0 ? void 0 : session.dialogState) {
|
|
1573
|
+
if (!chatLog) {
|
|
1574
|
+
setHistory([]);
|
|
1575
|
+
await translateAndSpeak(session.dialogState, userLang);
|
|
1576
|
+
setHasUserActivatedSpeak(true);
|
|
1577
|
+
setClickedStart(false);
|
|
1578
|
+
}
|
|
1579
|
+
else {
|
|
1580
|
+
const messages = chatLog.lines.map((l, i) => {
|
|
1581
|
+
var _a, _b;
|
|
1582
|
+
return ({
|
|
1583
|
+
text: l.text,
|
|
1584
|
+
media: (_b = (_a = l.media) === null || _a === void 0 ? void 0 : _a.filter(m => allowedMediaTypes.includes(m.mimeType))) === null || _b === void 0 ? void 0 : _b.map(m => ({
|
|
1585
|
+
mediumID: `${i}-${m.mimeType}`,
|
|
1700
1586
|
...m,
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1587
|
+
})),
|
|
1588
|
+
fromUser: l.inbound,
|
|
1589
|
+
llmUsage: l.llmUsage,
|
|
1590
|
+
timestamp: l.timestamp,
|
|
1591
|
+
emitter: l.emitter,
|
|
1592
|
+
initial: i === 0,
|
|
1593
|
+
});
|
|
1594
|
+
});
|
|
1595
|
+
translatedMessages = messages !== null && messages !== void 0 ? messages : [];
|
|
1596
|
+
if (language.toUpperCase() !== userLang.toUpperCase() &&
|
|
1597
|
+
isMultilanguageEnabled) {
|
|
1598
|
+
try {
|
|
1599
|
+
translatedMessages = await Promise.all(messages.map(async (m) => {
|
|
1600
|
+
if ('originalText' in m && m.originalText) {
|
|
1601
|
+
return m;
|
|
1602
|
+
}
|
|
1603
|
+
return {
|
|
1604
|
+
...m,
|
|
1605
|
+
originalText: m.text,
|
|
1606
|
+
text: (await getTranslation(m.text, userLang, language, baseUrl)).text,
|
|
1607
|
+
};
|
|
1608
|
+
}));
|
|
1609
|
+
}
|
|
1610
|
+
catch (_w) {
|
|
1611
|
+
}
|
|
1708
1612
|
}
|
|
1613
|
+
setHistory(translatedMessages);
|
|
1614
|
+
translateDialogState(session.dialogState, userLang, undefined, true).finally(() => {
|
|
1615
|
+
setHasUserActivatedSpeak(true);
|
|
1616
|
+
setClickedStart(false);
|
|
1617
|
+
});
|
|
1709
1618
|
}
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1619
|
+
}
|
|
1620
|
+
else if ((session === null || session === void 0 ? void 0 : session.resultCode) === 0) {
|
|
1621
|
+
sessionStartingRef.current = false;
|
|
1622
|
+
await onClickStart(session || undefined);
|
|
1623
|
+
}
|
|
1624
|
+
else {
|
|
1625
|
+
setLoading(false);
|
|
1626
|
+
setClickedStart(false);
|
|
1714
1627
|
}
|
|
1715
1628
|
}
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
}
|
|
1719
|
-
else {
|
|
1720
|
-
setLoading(false);
|
|
1629
|
+
finally {
|
|
1630
|
+
sessionStartingRef.current = false;
|
|
1721
1631
|
}
|
|
1722
1632
|
return;
|
|
1723
1633
|
}
|
|
@@ -1727,7 +1637,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1727
1637
|
if (response.resultCode !== 0 || !currentState) {
|
|
1728
1638
|
const { chatLogs } = await getSessionChatLogs(sessionID, sessionID);
|
|
1729
1639
|
setSessionId(undefined);
|
|
1730
|
-
setClickedStart(false);
|
|
1731
1640
|
await onClickStart(undefined, true, chatLogs === null || chatLogs === void 0 ? void 0 : chatLogs[0]);
|
|
1732
1641
|
return;
|
|
1733
1642
|
}
|
|
@@ -1739,13 +1648,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1739
1648
|
const session = await changeTag(memori.engineMemoriID, sessionID, personification.tag, personification.pin);
|
|
1740
1649
|
if (session && session.resultCode === 0) {
|
|
1741
1650
|
await translateAndSpeak(session.currentState, userLang);
|
|
1651
|
+
setClickedStart(false);
|
|
1742
1652
|
}
|
|
1743
1653
|
else {
|
|
1744
1654
|
throw new Error('No session');
|
|
1745
1655
|
}
|
|
1746
1656
|
}
|
|
1747
|
-
catch (
|
|
1748
|
-
console.error('[onClickStart] Error changing tag:', e);
|
|
1657
|
+
catch (_x) {
|
|
1749
1658
|
reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, personification.tag, personification.pin, {
|
|
1750
1659
|
LANG: userLang,
|
|
1751
1660
|
PATHNAME: (_l = window.location.pathname) === null || _l === void 0 ? void 0 : _l.toUpperCase(),
|
|
@@ -1754,6 +1663,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1754
1663
|
...(initialContextVars || {}),
|
|
1755
1664
|
}, initialQuestion, birth).then(() => {
|
|
1756
1665
|
setHasUserActivatedSpeak(true);
|
|
1666
|
+
setClickedStart(false);
|
|
1757
1667
|
});
|
|
1758
1668
|
}
|
|
1759
1669
|
}
|
|
@@ -1766,6 +1676,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1766
1676
|
const session = await changeTag(memori.engineMemoriID, sessionID, anonTag);
|
|
1767
1677
|
if (session && session.resultCode === 0) {
|
|
1768
1678
|
await translateAndSpeak(session.currentState, userLang);
|
|
1679
|
+
setClickedStart(false);
|
|
1769
1680
|
}
|
|
1770
1681
|
else {
|
|
1771
1682
|
throw new Error('No session');
|
|
@@ -1780,6 +1691,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1780
1691
|
...(initialContextVars || {}),
|
|
1781
1692
|
}, initialQuestion, birth).then(() => {
|
|
1782
1693
|
setHasUserActivatedSpeak(true);
|
|
1694
|
+
setClickedStart(false);
|
|
1783
1695
|
});
|
|
1784
1696
|
}
|
|
1785
1697
|
}
|
|
@@ -1811,28 +1723,23 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1811
1723
|
text: (await getTranslation(m.text, userLang, language, baseUrl)).text,
|
|
1812
1724
|
})));
|
|
1813
1725
|
}
|
|
1814
|
-
catch (
|
|
1815
|
-
console.error('[onClickStart] Error translating messages:', e);
|
|
1726
|
+
catch (_y) {
|
|
1816
1727
|
}
|
|
1817
1728
|
}
|
|
1818
1729
|
setHistory(translatedMessages);
|
|
1819
1730
|
}
|
|
1820
|
-
catch (
|
|
1821
|
-
console.error('[onClickStart] Error retrieving chat logs:', e);
|
|
1731
|
+
catch (_z) {
|
|
1822
1732
|
}
|
|
1823
1733
|
if ((!!(translatedMessages === null || translatedMessages === void 0 ? void 0 : translatedMessages.length) && translatedMessages.length > 1) ||
|
|
1824
1734
|
!initialQuestion) {
|
|
1825
1735
|
setHasUserActivatedSpeak(true);
|
|
1736
|
+
setClickedStart(false);
|
|
1826
1737
|
await translateAndSpeak(currentState, userLang, undefined, !!(translatedMessages === null || translatedMessages === void 0 ? void 0 : translatedMessages.length));
|
|
1827
1738
|
}
|
|
1828
1739
|
else {
|
|
1829
|
-
console.log('[onClickStart] Starting with initial question');
|
|
1830
1740
|
translatedMessages = [];
|
|
1831
1741
|
setHistory([]);
|
|
1832
1742
|
const placeSpec = getPlaceSpecForEnterText(position);
|
|
1833
|
-
console.debug('[EnterText] onClickStart: posting initial question', {
|
|
1834
|
-
sessionId: sessionID,
|
|
1835
|
-
});
|
|
1836
1743
|
const response = await postEnterTextAsync({
|
|
1837
1744
|
sessionId: sessionID,
|
|
1838
1745
|
text: initialQuestion,
|
|
@@ -1841,10 +1748,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1841
1748
|
}),
|
|
1842
1749
|
...(placeSpec !== undefined && { place: placeSpec }),
|
|
1843
1750
|
});
|
|
1844
|
-
console.debug('[EnterText] onClickStart: HTTP response', {
|
|
1845
|
-
resultCode: response.resultCode,
|
|
1846
|
-
correlationID: readCorrelationID(response),
|
|
1847
|
-
});
|
|
1848
1751
|
if (response.resultCode === 500 && response.resultMessage) {
|
|
1849
1752
|
setHistory(h => [
|
|
1850
1753
|
...h,
|
|
@@ -1861,28 +1764,22 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1861
1764
|
}
|
|
1862
1765
|
const onClickStartCorrelationID = readCorrelationID(response);
|
|
1863
1766
|
if (response.resultCode === 0 && onClickStartCorrelationID) {
|
|
1864
|
-
console.info('[EnterText] onClickStart: accepted, showing typing indicator', {
|
|
1865
|
-
correlationID: onClickStartCorrelationID,
|
|
1866
|
-
});
|
|
1867
1767
|
setMemoriTyping(true);
|
|
1868
1768
|
try {
|
|
1869
1769
|
const natsEvent = await waitForEnterTextNatsResponse(onClickStartCorrelationID);
|
|
1870
|
-
console.info('[EnterText] onClickStart: NATS response received', {
|
|
1871
|
-
correlationID: onClickStartCorrelationID,
|
|
1872
|
-
resultCode: natsEvent.resultCode,
|
|
1873
|
-
});
|
|
1874
1770
|
if (natsEvent.resultCode === 0 && natsEvent.currentState) {
|
|
1875
1771
|
await translateAndSpeak(natsEvent.currentState, userLang, undefined, false);
|
|
1772
|
+
setClickedStart(false);
|
|
1876
1773
|
}
|
|
1877
1774
|
}
|
|
1878
|
-
catch (
|
|
1879
|
-
|
|
1775
|
+
catch (err) {
|
|
1776
|
+
logWidgetError('onClickStart NATS wait failed', err);
|
|
1880
1777
|
setMemoriTyping(false);
|
|
1881
1778
|
setTypingText(undefined);
|
|
1882
1779
|
}
|
|
1883
1780
|
}
|
|
1884
1781
|
else if (response.resultCode === 0) {
|
|
1885
|
-
|
|
1782
|
+
logWidgetError('onClickStart enter-text missing correlationID', response);
|
|
1886
1783
|
}
|
|
1887
1784
|
}
|
|
1888
1785
|
}
|
|
@@ -1890,13 +1787,18 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1890
1787
|
else {
|
|
1891
1788
|
setHistory([]);
|
|
1892
1789
|
await translateAndSpeak(dialogState, userLang);
|
|
1790
|
+
setClickedStart(false);
|
|
1893
1791
|
}
|
|
1894
1792
|
}, [memoriPwd, memori, memoriTokens, birthDate, sessionId, userLang, position]);
|
|
1895
1793
|
useEffect(() => {
|
|
1896
|
-
if (!clickedStart &&
|
|
1794
|
+
if (!clickedStart &&
|
|
1795
|
+
!sessionStartingRef.current &&
|
|
1796
|
+
!sessionId &&
|
|
1797
|
+
autoStart &&
|
|
1798
|
+
selectedLayout !== 'HIDDEN_CHAT') {
|
|
1897
1799
|
onClickStart();
|
|
1898
1800
|
}
|
|
1899
|
-
}, [clickedStart, autoStart, selectedLayout]);
|
|
1801
|
+
}, [clickedStart, autoStart, selectedLayout, sessionId]);
|
|
1900
1802
|
useEffect(() => {
|
|
1901
1803
|
const targetNode = document.querySelector(`memori-client[memoriname="${memori.name}"]`) ||
|
|
1902
1804
|
document.querySelector(`memori-client[memoriid="${memori.memoriID}"]`) ||
|
|
@@ -1937,12 +1839,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1937
1839
|
if (resp.resultCode === 0) {
|
|
1938
1840
|
setExperts(experts);
|
|
1939
1841
|
}
|
|
1940
|
-
else {
|
|
1941
|
-
console.warn('Error fetching experts', resp);
|
|
1942
|
-
}
|
|
1943
1842
|
}
|
|
1944
|
-
catch (
|
|
1945
|
-
console.warn(err);
|
|
1843
|
+
catch (_a) {
|
|
1946
1844
|
}
|
|
1947
1845
|
}, [sessionId, memori === null || memori === void 0 ? void 0 : memori.enableBoardOfExperts]);
|
|
1948
1846
|
useEffect(() => {
|
|
@@ -1963,7 +1861,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1963
1861
|
if (!(tenant === null || tenant === void 0 ? void 0 : tenant.billingDelegation))
|
|
1964
1862
|
return true;
|
|
1965
1863
|
if (!ownerUserID && !ownerUserName) {
|
|
1966
|
-
console.warn('Cannot verify credits: missing owner identifier');
|
|
1967
1864
|
if (options === null || options === void 0 ? void 0 : options.notify) {
|
|
1968
1865
|
handleNotEnoughCredits();
|
|
1969
1866
|
}
|
|
@@ -1987,7 +1884,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1987
1884
|
return true;
|
|
1988
1885
|
}
|
|
1989
1886
|
else {
|
|
1990
|
-
console.warn('Not enough credits. Required:', resp.required);
|
|
1991
1887
|
if (options === null || options === void 0 ? void 0 : options.notify) {
|
|
1992
1888
|
handleNotEnoughCredits();
|
|
1993
1889
|
}
|
|
@@ -1997,9 +1893,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1997
1893
|
return false;
|
|
1998
1894
|
}
|
|
1999
1895
|
}
|
|
2000
|
-
catch (
|
|
2001
|
-
|
|
2002
|
-
console.debug(err);
|
|
1896
|
+
catch (err) {
|
|
1897
|
+
logWidgetError('checkCredits failed', err);
|
|
2003
1898
|
return true;
|
|
2004
1899
|
}
|
|
2005
1900
|
}, [
|