@memori.ai/memori-react 8.40.1 → 8.40.3
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 +34 -181
- 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 +31 -180
- 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 +37 -246
- package/src/helpers/nats/useNatsSession.ts +21 -1
- package/src/version.ts +1 -1
|
@@ -66,7 +66,9 @@ const NULL_PLACE_SPEC = {
|
|
|
66
66
|
longitude: null,
|
|
67
67
|
uncertaintyKm: null,
|
|
68
68
|
};
|
|
69
|
-
const
|
|
69
|
+
const logWidgetError = (context, detail) => {
|
|
70
|
+
console.error(`[MemoriWidget] ${context}`, detail !== null && detail !== void 0 ? detail : '');
|
|
71
|
+
};
|
|
70
72
|
function readCorrelationID(response) {
|
|
71
73
|
const value = response.correlationID;
|
|
72
74
|
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
@@ -448,12 +450,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
448
450
|
let gotError = false;
|
|
449
451
|
try {
|
|
450
452
|
const placeSpec = getPlaceSpecForEnterText(position);
|
|
451
|
-
console.debug('[EnterText] sendMessage: posting', {
|
|
452
|
-
sessionId: sessionID,
|
|
453
|
-
textLength: msg.length,
|
|
454
|
-
hasBatchQueued,
|
|
455
|
-
typingText,
|
|
456
|
-
});
|
|
457
453
|
const response = await postEnterTextAsync({
|
|
458
454
|
sessionId: sessionID,
|
|
459
455
|
text: msg,
|
|
@@ -462,11 +458,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
462
458
|
}),
|
|
463
459
|
...(placeSpec !== undefined && { place: placeSpec }),
|
|
464
460
|
});
|
|
465
|
-
console.debug('[EnterText] sendMessage: HTTP response', {
|
|
466
|
-
resultCode: response.resultCode,
|
|
467
|
-
correlationID: readCorrelationID(response),
|
|
468
|
-
resultMessage: response.resultMessage,
|
|
469
|
-
});
|
|
470
461
|
const correlationID = readCorrelationID(response);
|
|
471
462
|
if (response.resultCode === 0 && correlationID) {
|
|
472
463
|
registerPendingEnterText(correlationID, {
|
|
@@ -475,15 +466,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
475
466
|
useLoaderTextAsMsg,
|
|
476
467
|
hasBatchQueued,
|
|
477
468
|
});
|
|
478
|
-
console.info('[EnterText] sendMessage: accepted, showing typing indicator', {
|
|
479
|
-
correlationID: correlationID,
|
|
480
|
-
typingText,
|
|
481
|
-
});
|
|
482
469
|
setMemoriTyping(true);
|
|
483
470
|
setTypingText(typingText);
|
|
484
471
|
}
|
|
485
472
|
else if (response.resultCode === 0) {
|
|
486
|
-
|
|
473
|
+
logWidgetError('enter-text missing correlationID', response);
|
|
487
474
|
}
|
|
488
475
|
else if (response.resultCode === 404) {
|
|
489
476
|
setHistory(h => [...h.slice(0, h.length - 1)]);
|
|
@@ -493,7 +480,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
493
480
|
ROUTE: ((_d = (_c = window.location.pathname) === null || _c === void 0 ? void 0 : _c.split('/')) === null || _d === void 0 ? void 0 : _d.pop()) || '',
|
|
494
481
|
...(initialContextVars || {}),
|
|
495
482
|
}, initialQuestion, undefined, undefined, undefined, undefined, true).then(state => {
|
|
496
|
-
console.info('session timeout');
|
|
497
483
|
if (state === null || state === void 0 ? void 0 : state.sessionID) {
|
|
498
484
|
setTimeout(() => {
|
|
499
485
|
sendMessage(text, media, state === null || state === void 0 ? void 0 : state.sessionID);
|
|
@@ -515,13 +501,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
515
501
|
]);
|
|
516
502
|
}
|
|
517
503
|
else {
|
|
518
|
-
console.warn('[SEND_MESSAGE]', response);
|
|
519
504
|
return Promise.reject(response);
|
|
520
505
|
}
|
|
521
506
|
}
|
|
522
507
|
catch (error) {
|
|
523
|
-
console.error('[EnterText] sendMessage: request failed', error);
|
|
524
508
|
gotError = true;
|
|
509
|
+
logWidgetError('sendMessage failed', error);
|
|
525
510
|
setTypingText(undefined);
|
|
526
511
|
setMemoriTyping(false);
|
|
527
512
|
}
|
|
@@ -603,7 +588,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
603
588
|
}
|
|
604
589
|
}
|
|
605
590
|
catch (error) {
|
|
606
|
-
console.error('[TRANSLATE] Error during translation:', error);
|
|
607
591
|
translatedState = { ...state, emission };
|
|
608
592
|
translatedMsg = {
|
|
609
593
|
text: emission,
|
|
@@ -711,7 +695,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
711
695
|
try {
|
|
712
696
|
setTimeout(() => {
|
|
713
697
|
var _a;
|
|
714
|
-
console.log('snippet', s);
|
|
715
698
|
new Function((_a = s.content) !== null && _a !== void 0 ? _a : '')();
|
|
716
699
|
setTimeout(() => {
|
|
717
700
|
var _a, _b, _c;
|
|
@@ -720,8 +703,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
720
703
|
}, 400);
|
|
721
704
|
}, 1000);
|
|
722
705
|
}
|
|
723
|
-
catch (
|
|
724
|
-
console.warn(e);
|
|
706
|
+
catch (_a) {
|
|
725
707
|
}
|
|
726
708
|
});
|
|
727
709
|
};
|
|
@@ -757,8 +739,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
757
739
|
return window.location.href;
|
|
758
740
|
})();
|
|
759
741
|
}
|
|
760
|
-
catch (
|
|
761
|
-
console.debug(err);
|
|
742
|
+
catch (_m) {
|
|
762
743
|
}
|
|
763
744
|
const session = await initSession({
|
|
764
745
|
...params,
|
|
@@ -790,7 +771,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
790
771
|
};
|
|
791
772
|
}
|
|
792
773
|
else if (session === null || session === void 0 ? void 0 : session.resultMessage.startsWith('This Memori is aged restricted')) {
|
|
793
|
-
console.warn(session);
|
|
794
774
|
toast.error(t('underageTwinSession', { age: minAge }));
|
|
795
775
|
}
|
|
796
776
|
else if ((session === null || session === void 0 ? void 0 : session.resultCode) === 403 && memori.privacyType !== 'PUBLIC') {
|
|
@@ -799,7 +779,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
799
779
|
return session;
|
|
800
780
|
}
|
|
801
781
|
else {
|
|
802
|
-
console.warn(session);
|
|
803
782
|
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') })] })), {
|
|
804
783
|
duration: Infinity,
|
|
805
784
|
});
|
|
@@ -807,7 +786,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
807
786
|
}
|
|
808
787
|
}
|
|
809
788
|
catch (err) {
|
|
810
|
-
|
|
789
|
+
logWidgetError('fetchSession failed', err);
|
|
811
790
|
}
|
|
812
791
|
};
|
|
813
792
|
const reopenSession = async (updateDialogState = false, password, recoveryTokens, tag, pin, initialContextVars, initialQuestion, birthDate, additionalInfoProp, continueFromChatLogID, continueFromSessionID, isSessionExpired) => {
|
|
@@ -839,8 +818,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
839
818
|
return window.location.href;
|
|
840
819
|
})();
|
|
841
820
|
}
|
|
842
|
-
catch (
|
|
843
|
-
console.debug('[REOPEN_SESSION] Error getting referral:', err);
|
|
821
|
+
catch (_o) {
|
|
844
822
|
}
|
|
845
823
|
const { sessionID, currentState, ...response } = await initSession({
|
|
846
824
|
memoriID: (_a = memori.engineMemoriID) !== null && _a !== void 0 ? _a : '',
|
|
@@ -867,12 +845,10 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
867
845
|
},
|
|
868
846
|
});
|
|
869
847
|
if (sessionID && currentState && response.resultCode === 0) {
|
|
870
|
-
console.log('[REOPEN_SESSION] Session initialized successfully:', sessionID);
|
|
871
848
|
setSessionId(sessionID);
|
|
872
849
|
if (updateDialogState) {
|
|
873
850
|
setCurrentDialogState(currentState);
|
|
874
851
|
if (currentState.emission) {
|
|
875
|
-
console.log('[REOPEN_SESSION] Processing emission:', currentState.emission);
|
|
876
852
|
const initialStatus = isSessionExpired && history.length > 1
|
|
877
853
|
? 'Session Expired, reopening session'
|
|
878
854
|
: history.length <= 1
|
|
@@ -924,22 +900,19 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
924
900
|
};
|
|
925
901
|
}
|
|
926
902
|
else if (response === null || response === void 0 ? void 0 : response.resultMessage.startsWith('This Memori is aged restricted')) {
|
|
927
|
-
console.error('[REOPEN_SESSION] Age restriction error:', response);
|
|
928
903
|
toast.error(t('underageTwinSession', { age: minAge }));
|
|
929
904
|
}
|
|
930
905
|
else if ((response === null || response === void 0 ? void 0 : response.resultCode) === 403 &&
|
|
931
906
|
memori.privacyType !== 'PUBLIC') {
|
|
932
|
-
console.error('[REOPEN_SESSION] Authentication error');
|
|
933
907
|
setMemoriPwd(undefined);
|
|
934
908
|
setAuthModalState('password');
|
|
935
909
|
}
|
|
936
910
|
else {
|
|
937
|
-
console.error('[REOPEN_SESSION] Other error:', response);
|
|
938
911
|
toast.error(t(getErrori18nKey(response.resultCode)));
|
|
939
912
|
}
|
|
940
913
|
}
|
|
941
914
|
catch (err) {
|
|
942
|
-
|
|
915
|
+
logWidgetError('reopenSession failed', err);
|
|
943
916
|
}
|
|
944
917
|
setLoading(false);
|
|
945
918
|
return null;
|
|
@@ -947,7 +920,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
947
920
|
const changeTag = async (memoriId, sessionId, tag, pin) => {
|
|
948
921
|
var _a, _b, _c, _d, _f, _g, _h, _j, _k;
|
|
949
922
|
if (!memoriId || !sessionId) {
|
|
950
|
-
console.error('CHANGETAG/Session not found');
|
|
951
923
|
return Promise.reject('Session not found');
|
|
952
924
|
}
|
|
953
925
|
try {
|
|
@@ -979,7 +951,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
979
951
|
}
|
|
980
952
|
}
|
|
981
953
|
else if ([400, 401, 403, 404, 500].includes(resultCode)) {
|
|
982
|
-
console.warn('[APPCONTEXT/CHANGETAG]', resultCode);
|
|
983
954
|
let storageBirthDate = getLocalConfig('birthDate', undefined);
|
|
984
955
|
let referral;
|
|
985
956
|
try {
|
|
@@ -987,8 +958,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
987
958
|
return window.location.href;
|
|
988
959
|
})();
|
|
989
960
|
}
|
|
990
|
-
catch (
|
|
991
|
-
console.debug(err);
|
|
961
|
+
catch (_l) {
|
|
992
962
|
}
|
|
993
963
|
fetchSession({
|
|
994
964
|
memoriID: (_b = memori.engineMemoriID) !== null && _b !== void 0 ? _b : '',
|
|
@@ -1023,7 +993,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1023
993
|
}
|
|
1024
994
|
catch (_e) {
|
|
1025
995
|
let err = _e;
|
|
1026
|
-
console.warn('[APPCONTEXT/CHANGETAG]', err);
|
|
1027
996
|
return Promise.reject(err);
|
|
1028
997
|
}
|
|
1029
998
|
return null;
|
|
@@ -1074,7 +1043,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1074
1043
|
}, autoStart, defaultEnableAudio, (_u = defaultSpeakerActive !== null && defaultSpeakerActive !== void 0 ? defaultSpeakerActive : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.defaultSpeakerActive) !== null && _u !== void 0 ? _u : true);
|
|
1075
1044
|
const shouldPlayAudio = (text) => {
|
|
1076
1045
|
const currentSpeakerMuted = getLocalConfig('muteSpeaker', !defaultEnableAudio);
|
|
1077
|
-
console.log('[MemoriWidget] shouldPlayAudio', currentSpeakerMuted);
|
|
1078
1046
|
return (text &&
|
|
1079
1047
|
text.trim() &&
|
|
1080
1048
|
!preview &&
|
|
@@ -1087,15 +1055,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1087
1055
|
}
|
|
1088
1056
|
try {
|
|
1089
1057
|
const message = stripDuplicates(text);
|
|
1090
|
-
console.debug('Processing speech message:', message);
|
|
1091
1058
|
if (message.length > 0) {
|
|
1092
1059
|
setUserMessage('');
|
|
1093
|
-
console.debug('Sending message:', message);
|
|
1094
1060
|
sendMessage(message);
|
|
1095
1061
|
}
|
|
1096
1062
|
}
|
|
1097
|
-
catch (
|
|
1098
|
-
console.error('Error in processSpeechAndSendMessage:', error);
|
|
1063
|
+
catch (_a) {
|
|
1099
1064
|
}
|
|
1100
1065
|
};
|
|
1101
1066
|
const { isListening, startRecording, stopRecording, } = useSTT(sttConfig, processSpeechAndSendMessage, {
|
|
@@ -1129,8 +1094,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1129
1094
|
}
|
|
1130
1095
|
return translatedState;
|
|
1131
1096
|
}
|
|
1132
|
-
catch (
|
|
1133
|
-
console.error('Error in translateAndSpeak:', error);
|
|
1097
|
+
catch (_a) {
|
|
1134
1098
|
if (!hasUserActivatedSpeak) {
|
|
1135
1099
|
setHasUserActivatedSpeak(true);
|
|
1136
1100
|
}
|
|
@@ -1145,20 +1109,10 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1145
1109
|
]);
|
|
1146
1110
|
const processEnterTextDialogResponse = useCallback((event, pending) => {
|
|
1147
1111
|
var _a, _b;
|
|
1148
|
-
console.debug('[EnterText] processDialogResponse', {
|
|
1149
|
-
correlationID: event.correlationID,
|
|
1150
|
-
resultCode: event.resultCode,
|
|
1151
|
-
hasCurrentState: !!event.currentState,
|
|
1152
|
-
hasBatchQueued: pending.hasBatchQueued,
|
|
1153
|
-
});
|
|
1154
1112
|
const { msg, typingText: pendingTypingText, useLoaderTextAsMsg, } = pending;
|
|
1155
1113
|
const currentState = event.currentState;
|
|
1156
1114
|
if (event.resultCode !== 0 || !currentState) {
|
|
1157
1115
|
if (event.resultCode === 500 && event.resultMessage) {
|
|
1158
|
-
console.warn('[EnterText] processDialogResponse: server error', {
|
|
1159
|
-
correlationID: event.correlationID,
|
|
1160
|
-
resultMessage: event.resultMessage,
|
|
1161
|
-
});
|
|
1162
1116
|
setHistory(h => [
|
|
1163
1117
|
...h,
|
|
1164
1118
|
{
|
|
@@ -1171,24 +1125,15 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1171
1125
|
},
|
|
1172
1126
|
]);
|
|
1173
1127
|
}
|
|
1174
|
-
else if (event.resultCode !== 0) {
|
|
1175
|
-
console.warn('[SEND_MESSAGE/NATS]', event);
|
|
1176
|
-
}
|
|
1177
1128
|
return;
|
|
1178
1129
|
}
|
|
1179
1130
|
if (!msg) {
|
|
1180
|
-
console.debug('[EnterText] processDialogResponse: no msg in pending, skipping');
|
|
1181
1131
|
return;
|
|
1182
1132
|
}
|
|
1183
1133
|
setChatLogID(undefined);
|
|
1184
1134
|
const emission = useLoaderTextAsMsg && pendingTypingText
|
|
1185
1135
|
? pendingTypingText
|
|
1186
1136
|
: (_a = currentState.emission) !== null && _a !== void 0 ? _a : currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.emission;
|
|
1187
|
-
console.debug('[EnterText] processDialogResponse: rendering emission', {
|
|
1188
|
-
correlationID: event.correlationID,
|
|
1189
|
-
emissionPreview: emission === null || emission === void 0 ? void 0 : emission.slice(0, 80),
|
|
1190
|
-
state: currentState.state,
|
|
1191
|
-
});
|
|
1192
1137
|
if (userLang.toLowerCase() !== language.toLowerCase() &&
|
|
1193
1138
|
emission &&
|
|
1194
1139
|
isMultilanguageEnabled) {
|
|
@@ -1239,9 +1184,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1239
1184
|
]);
|
|
1240
1185
|
const clearEnterTextPending = useCallback((correlationID, pending) => {
|
|
1241
1186
|
var _a;
|
|
1242
|
-
if (pending.natsTimeoutId) {
|
|
1243
|
-
clearTimeout(pending.natsTimeoutId);
|
|
1244
|
-
}
|
|
1245
1187
|
if ((_a = pending.waitForResponse) === null || _a === void 0 ? void 0 : _a.timeoutId) {
|
|
1246
1188
|
clearTimeout(pending.waitForResponse.timeoutId);
|
|
1247
1189
|
}
|
|
@@ -1255,11 +1197,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1255
1197
|
: event.errorCode
|
|
1256
1198
|
? `Error: ${event.errorCode}`
|
|
1257
1199
|
: 'Error: An unexpected error occurred';
|
|
1258
|
-
console.error('[EnterText] NATS error event', {
|
|
1259
|
-
correlationID,
|
|
1260
|
-
errorCode: event.errorCode,
|
|
1261
|
-
errorMessage: event.errorMessage,
|
|
1262
|
-
});
|
|
1263
1200
|
pushMessage({
|
|
1264
1201
|
text: errorText,
|
|
1265
1202
|
emitter: 'system',
|
|
@@ -1281,24 +1218,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1281
1218
|
const deliverEnterTextNatsResponse = useCallback((correlationID, event) => {
|
|
1282
1219
|
const pending = pendingEnterTextRef.current.get(correlationID);
|
|
1283
1220
|
if (!pending) {
|
|
1284
|
-
const pendingCorrelationIDs = [...pendingEnterTextRef.current.keys()];
|
|
1285
|
-
console.warn('[EnterText] NATS response buffered (no matching pending)', {
|
|
1286
|
-
receivedCorrelationID: correlationID,
|
|
1287
|
-
resultCode: event.resultCode,
|
|
1288
|
-
pendingCorrelationIDs,
|
|
1289
|
-
hint: pendingCorrelationIDs.length > 0
|
|
1290
|
-
? 'Use one of pendingCorrelationIDs in your nats pub correlation_id'
|
|
1291
|
-
: 'Send a message in the widget first, then copy correlationID from HTTP response logs',
|
|
1292
|
-
});
|
|
1293
1221
|
bufferedNatsResponsesRef.current.set(correlationID, event);
|
|
1294
1222
|
return;
|
|
1295
1223
|
}
|
|
1296
1224
|
clearEnterTextPending(correlationID, pending);
|
|
1297
1225
|
if (pending.waitForResponse) {
|
|
1298
|
-
console.info('[EnterText] NATS response delivered to waiter', {
|
|
1299
|
-
correlationID,
|
|
1300
|
-
resultCode: event.resultCode,
|
|
1301
|
-
});
|
|
1302
1226
|
pending.waitForResponse.resolve(event);
|
|
1303
1227
|
setMemoriTyping(false);
|
|
1304
1228
|
setTypingText(undefined);
|
|
@@ -1306,67 +1230,27 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1306
1230
|
}
|
|
1307
1231
|
processEnterTextDialogResponse(event, pending);
|
|
1308
1232
|
if (!pending.hasBatchQueued) {
|
|
1309
|
-
console.info('[EnterText] typing indicator cleared', { correlationID });
|
|
1310
1233
|
setMemoriTyping(false);
|
|
1311
1234
|
setTypingText(undefined);
|
|
1312
1235
|
}
|
|
1313
|
-
else {
|
|
1314
|
-
console.debug('[EnterText] typing kept (batch queued)', {
|
|
1315
|
-
correlationID,
|
|
1316
|
-
});
|
|
1317
|
-
}
|
|
1318
1236
|
}, [processEnterTextDialogResponse, clearEnterTextPending]);
|
|
1319
1237
|
const registerPendingEnterText = useCallback((correlationID, pending) => {
|
|
1320
1238
|
const buffered = bufferedNatsResponsesRef.current.get(correlationID);
|
|
1321
1239
|
if (buffered) {
|
|
1322
|
-
console.info('[EnterText] replaying buffered NATS response', {
|
|
1323
|
-
correlationID,
|
|
1324
|
-
waitForResponse: !!pending.waitForResponse,
|
|
1325
|
-
});
|
|
1326
1240
|
bufferedNatsResponsesRef.current.delete(correlationID);
|
|
1327
1241
|
pendingEnterTextRef.current.set(correlationID, pending);
|
|
1328
1242
|
deliverEnterTextNatsResponse(correlationID, buffered);
|
|
1329
1243
|
return;
|
|
1330
1244
|
}
|
|
1331
|
-
if (!pending.waitForResponse && !pending.natsTimeoutId) {
|
|
1332
|
-
pending.natsTimeoutId = setTimeout(() => {
|
|
1333
|
-
var _a;
|
|
1334
|
-
const current = pendingEnterTextRef.current.get(correlationID);
|
|
1335
|
-
if (!current)
|
|
1336
|
-
return;
|
|
1337
|
-
clearEnterTextPending(correlationID, current);
|
|
1338
|
-
console.error('[EnterText] NATS response timeout', {
|
|
1339
|
-
correlationID,
|
|
1340
|
-
timeoutMs: ENTER_TEXT_NATS_TIMEOUT_MS,
|
|
1341
|
-
});
|
|
1342
|
-
if (!current.hasBatchQueued) {
|
|
1343
|
-
setMemoriTyping(false);
|
|
1344
|
-
setTypingText(undefined);
|
|
1345
|
-
}
|
|
1346
|
-
(_a = current.waitForResponse) === null || _a === void 0 ? void 0 : _a.reject(new Error('NATS enter-text response timeout'));
|
|
1347
|
-
}, ENTER_TEXT_NATS_TIMEOUT_MS);
|
|
1348
|
-
}
|
|
1349
|
-
console.debug('[EnterText] pending registered', {
|
|
1350
|
-
correlationID,
|
|
1351
|
-
waitForResponse: !!pending.waitForResponse,
|
|
1352
|
-
hasBatchQueued: pending.hasBatchQueued,
|
|
1353
|
-
});
|
|
1354
1245
|
pendingEnterTextRef.current.set(correlationID, pending);
|
|
1355
|
-
}, [deliverEnterTextNatsResponse
|
|
1246
|
+
}, [deliverEnterTextNatsResponse]);
|
|
1356
1247
|
const waitForEnterTextNatsResponse = useCallback((correlationID, timeoutMs = 120000) => new Promise((resolve, reject) => {
|
|
1357
|
-
console.debug('[EnterText] waiting for NATS response', {
|
|
1358
|
-
correlationID,
|
|
1359
|
-
timeoutMs,
|
|
1360
|
-
});
|
|
1361
1248
|
const timeoutId = setTimeout(() => {
|
|
1362
1249
|
const current = pendingEnterTextRef.current.get(correlationID);
|
|
1363
1250
|
if (current) {
|
|
1364
1251
|
clearEnterTextPending(correlationID, current);
|
|
1365
1252
|
}
|
|
1366
|
-
|
|
1367
|
-
correlationID,
|
|
1368
|
-
timeoutMs,
|
|
1369
|
-
});
|
|
1253
|
+
logWidgetError('NATS timeout', { correlationID, timeoutMs });
|
|
1370
1254
|
reject(new Error('NATS enter-text response timeout'));
|
|
1371
1255
|
}, timeoutMs);
|
|
1372
1256
|
registerPendingEnterText(correlationID, {
|
|
@@ -1387,25 +1271,14 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1387
1271
|
baseUrl,
|
|
1388
1272
|
sessionId,
|
|
1389
1273
|
onProgress: useCallback((event) => {
|
|
1390
|
-
console.debug('[EnterText] NATS progress', {
|
|
1391
|
-
correlationID: event.correlationID,
|
|
1392
|
-
step: event.currentStep,
|
|
1393
|
-
finalStep: event.finalStep,
|
|
1394
|
-
message: event.message,
|
|
1395
|
-
});
|
|
1396
1274
|
if (event.message) {
|
|
1397
1275
|
setTypingText(event.message);
|
|
1398
1276
|
}
|
|
1399
1277
|
}, []),
|
|
1400
1278
|
onDialogResponse: useCallback((event) => {
|
|
1401
1279
|
const correlationID = event.correlationID;
|
|
1402
|
-
console.debug('[EnterText] NATS dialog.text_entered_response received', {
|
|
1403
|
-
correlationID,
|
|
1404
|
-
resultCode: event.resultCode,
|
|
1405
|
-
requestID: event.requestID,
|
|
1406
|
-
});
|
|
1407
1280
|
if (!correlationID) {
|
|
1408
|
-
|
|
1281
|
+
logWidgetError('NATS dialog response missing correlationID', event);
|
|
1409
1282
|
setMemoriTyping(false);
|
|
1410
1283
|
setTypingText(undefined);
|
|
1411
1284
|
return;
|
|
@@ -1435,7 +1308,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1435
1308
|
timeoutRef.current = undefined;
|
|
1436
1309
|
ttsStop();
|
|
1437
1310
|
}
|
|
1438
|
-
catch (
|
|
1311
|
+
catch (_a) {
|
|
1439
1312
|
}
|
|
1440
1313
|
};
|
|
1441
1314
|
useEffect(() => {
|
|
@@ -1712,8 +1585,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1712
1585
|
};
|
|
1713
1586
|
}));
|
|
1714
1587
|
}
|
|
1715
|
-
catch (
|
|
1716
|
-
console.error('[onClickStart] Error translating messages:', e);
|
|
1588
|
+
catch (_w) {
|
|
1717
1589
|
}
|
|
1718
1590
|
}
|
|
1719
1591
|
setHistory(translatedMessages);
|
|
@@ -1754,13 +1626,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1754
1626
|
const session = await changeTag(memori.engineMemoriID, sessionID, personification.tag, personification.pin);
|
|
1755
1627
|
if (session && session.resultCode === 0) {
|
|
1756
1628
|
await translateAndSpeak(session.currentState, userLang);
|
|
1629
|
+
setClickedStart(false);
|
|
1757
1630
|
}
|
|
1758
1631
|
else {
|
|
1759
1632
|
throw new Error('No session');
|
|
1760
1633
|
}
|
|
1761
1634
|
}
|
|
1762
|
-
catch (
|
|
1763
|
-
console.error('[onClickStart] Error changing tag:', e);
|
|
1635
|
+
catch (_x) {
|
|
1764
1636
|
reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, personification.tag, personification.pin, {
|
|
1765
1637
|
LANG: userLang,
|
|
1766
1638
|
PATHNAME: (_l = window.location.pathname) === null || _l === void 0 ? void 0 : _l.toUpperCase(),
|
|
@@ -1782,6 +1654,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1782
1654
|
const session = await changeTag(memori.engineMemoriID, sessionID, anonTag);
|
|
1783
1655
|
if (session && session.resultCode === 0) {
|
|
1784
1656
|
await translateAndSpeak(session.currentState, userLang);
|
|
1657
|
+
setClickedStart(false);
|
|
1785
1658
|
}
|
|
1786
1659
|
else {
|
|
1787
1660
|
throw new Error('No session');
|
|
@@ -1828,14 +1701,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1828
1701
|
text: (await getTranslation(m.text, userLang, language, baseUrl)).text,
|
|
1829
1702
|
})));
|
|
1830
1703
|
}
|
|
1831
|
-
catch (
|
|
1832
|
-
console.error('[onClickStart] Error translating messages:', e);
|
|
1704
|
+
catch (_y) {
|
|
1833
1705
|
}
|
|
1834
1706
|
}
|
|
1835
1707
|
setHistory(translatedMessages);
|
|
1836
1708
|
}
|
|
1837
|
-
catch (
|
|
1838
|
-
console.error('[onClickStart] Error retrieving chat logs:', e);
|
|
1709
|
+
catch (_z) {
|
|
1839
1710
|
}
|
|
1840
1711
|
if ((!!(translatedMessages === null || translatedMessages === void 0 ? void 0 : translatedMessages.length) && translatedMessages.length > 1) ||
|
|
1841
1712
|
!initialQuestion) {
|
|
@@ -1844,13 +1715,9 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1844
1715
|
await translateAndSpeak(currentState, userLang, undefined, !!(translatedMessages === null || translatedMessages === void 0 ? void 0 : translatedMessages.length));
|
|
1845
1716
|
}
|
|
1846
1717
|
else {
|
|
1847
|
-
console.log('[onClickStart] Starting with initial question');
|
|
1848
1718
|
translatedMessages = [];
|
|
1849
1719
|
setHistory([]);
|
|
1850
1720
|
const placeSpec = getPlaceSpecForEnterText(position);
|
|
1851
|
-
console.debug('[EnterText] onClickStart: posting initial question', {
|
|
1852
|
-
sessionId: sessionID,
|
|
1853
|
-
});
|
|
1854
1721
|
const response = await postEnterTextAsync({
|
|
1855
1722
|
sessionId: sessionID,
|
|
1856
1723
|
text: initialQuestion,
|
|
@@ -1859,10 +1726,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1859
1726
|
}),
|
|
1860
1727
|
...(placeSpec !== undefined && { place: placeSpec }),
|
|
1861
1728
|
});
|
|
1862
|
-
console.debug('[EnterText] onClickStart: HTTP response', {
|
|
1863
|
-
resultCode: response.resultCode,
|
|
1864
|
-
correlationID: readCorrelationID(response),
|
|
1865
|
-
});
|
|
1866
1729
|
if (response.resultCode === 500 && response.resultMessage) {
|
|
1867
1730
|
setHistory(h => [
|
|
1868
1731
|
...h,
|
|
@@ -1879,28 +1742,22 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1879
1742
|
}
|
|
1880
1743
|
const onClickStartCorrelationID = readCorrelationID(response);
|
|
1881
1744
|
if (response.resultCode === 0 && onClickStartCorrelationID) {
|
|
1882
|
-
console.info('[EnterText] onClickStart: accepted, showing typing indicator', {
|
|
1883
|
-
correlationID: onClickStartCorrelationID,
|
|
1884
|
-
});
|
|
1885
1745
|
setMemoriTyping(true);
|
|
1886
1746
|
try {
|
|
1887
1747
|
const natsEvent = await waitForEnterTextNatsResponse(onClickStartCorrelationID);
|
|
1888
|
-
console.info('[EnterText] onClickStart: NATS response received', {
|
|
1889
|
-
correlationID: onClickStartCorrelationID,
|
|
1890
|
-
resultCode: natsEvent.resultCode,
|
|
1891
|
-
});
|
|
1892
1748
|
if (natsEvent.resultCode === 0 && natsEvent.currentState) {
|
|
1893
1749
|
await translateAndSpeak(natsEvent.currentState, userLang, undefined, false);
|
|
1750
|
+
setClickedStart(false);
|
|
1894
1751
|
}
|
|
1895
1752
|
}
|
|
1896
|
-
catch (
|
|
1897
|
-
|
|
1753
|
+
catch (err) {
|
|
1754
|
+
logWidgetError('onClickStart NATS wait failed', err);
|
|
1898
1755
|
setMemoriTyping(false);
|
|
1899
1756
|
setTypingText(undefined);
|
|
1900
1757
|
}
|
|
1901
1758
|
}
|
|
1902
1759
|
else if (response.resultCode === 0) {
|
|
1903
|
-
|
|
1760
|
+
logWidgetError('onClickStart enter-text missing correlationID', response);
|
|
1904
1761
|
}
|
|
1905
1762
|
}
|
|
1906
1763
|
}
|
|
@@ -1908,6 +1765,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1908
1765
|
else {
|
|
1909
1766
|
setHistory([]);
|
|
1910
1767
|
await translateAndSpeak(dialogState, userLang);
|
|
1768
|
+
setClickedStart(false);
|
|
1911
1769
|
}
|
|
1912
1770
|
}, [memoriPwd, memori, memoriTokens, birthDate, sessionId, userLang, position]);
|
|
1913
1771
|
useEffect(() => {
|
|
@@ -1959,12 +1817,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1959
1817
|
if (resp.resultCode === 0) {
|
|
1960
1818
|
setExperts(experts);
|
|
1961
1819
|
}
|
|
1962
|
-
else {
|
|
1963
|
-
console.warn('Error fetching experts', resp);
|
|
1964
|
-
}
|
|
1965
1820
|
}
|
|
1966
|
-
catch (
|
|
1967
|
-
console.warn(err);
|
|
1821
|
+
catch (_a) {
|
|
1968
1822
|
}
|
|
1969
1823
|
}, [sessionId, memori === null || memori === void 0 ? void 0 : memori.enableBoardOfExperts]);
|
|
1970
1824
|
useEffect(() => {
|
|
@@ -1985,7 +1839,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1985
1839
|
if (!(tenant === null || tenant === void 0 ? void 0 : tenant.billingDelegation))
|
|
1986
1840
|
return true;
|
|
1987
1841
|
if (!ownerUserID && !ownerUserName) {
|
|
1988
|
-
console.warn('Cannot verify credits: missing owner identifier');
|
|
1989
1842
|
if (options === null || options === void 0 ? void 0 : options.notify) {
|
|
1990
1843
|
handleNotEnoughCredits();
|
|
1991
1844
|
}
|
|
@@ -2009,7 +1862,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2009
1862
|
return true;
|
|
2010
1863
|
}
|
|
2011
1864
|
else {
|
|
2012
|
-
console.warn('Not enough credits. Required:', resp.required);
|
|
2013
1865
|
if (options === null || options === void 0 ? void 0 : options.notify) {
|
|
2014
1866
|
handleNotEnoughCredits();
|
|
2015
1867
|
}
|
|
@@ -2019,9 +1871,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2019
1871
|
return false;
|
|
2020
1872
|
}
|
|
2021
1873
|
}
|
|
2022
|
-
catch (
|
|
2023
|
-
|
|
2024
|
-
console.debug(err);
|
|
1874
|
+
catch (err) {
|
|
1875
|
+
logWidgetError('checkCredits failed', err);
|
|
2025
1876
|
return true;
|
|
2026
1877
|
}
|
|
2027
1878
|
}, [
|