@memori.ai/memori-react 8.40.1 → 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 +17 -0
- package/dist/components/MemoriWidget/MemoriWidget.js +34 -159
- 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 -158
- 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 +38 -222
- 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;
|
|
@@ -448,12 +451,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
448
451
|
let gotError = false;
|
|
449
452
|
try {
|
|
450
453
|
const placeSpec = getPlaceSpecForEnterText(position);
|
|
451
|
-
console.debug('[EnterText] sendMessage: posting', {
|
|
452
|
-
sessionId: sessionID,
|
|
453
|
-
textLength: msg.length,
|
|
454
|
-
hasBatchQueued,
|
|
455
|
-
typingText,
|
|
456
|
-
});
|
|
457
454
|
const response = await postEnterTextAsync({
|
|
458
455
|
sessionId: sessionID,
|
|
459
456
|
text: msg,
|
|
@@ -462,11 +459,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
462
459
|
}),
|
|
463
460
|
...(placeSpec !== undefined && { place: placeSpec }),
|
|
464
461
|
});
|
|
465
|
-
console.debug('[EnterText] sendMessage: HTTP response', {
|
|
466
|
-
resultCode: response.resultCode,
|
|
467
|
-
correlationID: readCorrelationID(response),
|
|
468
|
-
resultMessage: response.resultMessage,
|
|
469
|
-
});
|
|
470
462
|
const correlationID = readCorrelationID(response);
|
|
471
463
|
if (response.resultCode === 0 && correlationID) {
|
|
472
464
|
registerPendingEnterText(correlationID, {
|
|
@@ -475,15 +467,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
475
467
|
useLoaderTextAsMsg,
|
|
476
468
|
hasBatchQueued,
|
|
477
469
|
});
|
|
478
|
-
console.info('[EnterText] sendMessage: accepted, showing typing indicator', {
|
|
479
|
-
correlationID: correlationID,
|
|
480
|
-
typingText,
|
|
481
|
-
});
|
|
482
470
|
setMemoriTyping(true);
|
|
483
471
|
setTypingText(typingText);
|
|
484
472
|
}
|
|
485
473
|
else if (response.resultCode === 0) {
|
|
486
|
-
|
|
474
|
+
logWidgetError('enter-text missing correlationID', response);
|
|
487
475
|
}
|
|
488
476
|
else if (response.resultCode === 404) {
|
|
489
477
|
setHistory(h => [...h.slice(0, h.length - 1)]);
|
|
@@ -493,7 +481,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
493
481
|
ROUTE: ((_d = (_c = window.location.pathname) === null || _c === void 0 ? void 0 : _c.split('/')) === null || _d === void 0 ? void 0 : _d.pop()) || '',
|
|
494
482
|
...(initialContextVars || {}),
|
|
495
483
|
}, initialQuestion, undefined, undefined, undefined, undefined, true).then(state => {
|
|
496
|
-
console.info('session timeout');
|
|
497
484
|
if (state === null || state === void 0 ? void 0 : state.sessionID) {
|
|
498
485
|
setTimeout(() => {
|
|
499
486
|
sendMessage(text, media, state === null || state === void 0 ? void 0 : state.sessionID);
|
|
@@ -515,13 +502,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
515
502
|
]);
|
|
516
503
|
}
|
|
517
504
|
else {
|
|
518
|
-
console.warn('[SEND_MESSAGE]', response);
|
|
519
505
|
return Promise.reject(response);
|
|
520
506
|
}
|
|
521
507
|
}
|
|
522
508
|
catch (error) {
|
|
523
|
-
console.error('[EnterText] sendMessage: request failed', error);
|
|
524
509
|
gotError = true;
|
|
510
|
+
logWidgetError('sendMessage failed', error);
|
|
525
511
|
setTypingText(undefined);
|
|
526
512
|
setMemoriTyping(false);
|
|
527
513
|
}
|
|
@@ -603,7 +589,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
603
589
|
}
|
|
604
590
|
}
|
|
605
591
|
catch (error) {
|
|
606
|
-
console.error('[TRANSLATE] Error during translation:', error);
|
|
607
592
|
translatedState = { ...state, emission };
|
|
608
593
|
translatedMsg = {
|
|
609
594
|
text: emission,
|
|
@@ -711,7 +696,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
711
696
|
try {
|
|
712
697
|
setTimeout(() => {
|
|
713
698
|
var _a;
|
|
714
|
-
console.log('snippet', s);
|
|
715
699
|
new Function((_a = s.content) !== null && _a !== void 0 ? _a : '')();
|
|
716
700
|
setTimeout(() => {
|
|
717
701
|
var _a, _b, _c;
|
|
@@ -720,8 +704,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
720
704
|
}, 400);
|
|
721
705
|
}, 1000);
|
|
722
706
|
}
|
|
723
|
-
catch (
|
|
724
|
-
console.warn(e);
|
|
707
|
+
catch (_a) {
|
|
725
708
|
}
|
|
726
709
|
});
|
|
727
710
|
};
|
|
@@ -757,8 +740,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
757
740
|
return window.location.href;
|
|
758
741
|
})();
|
|
759
742
|
}
|
|
760
|
-
catch (
|
|
761
|
-
console.debug(err);
|
|
743
|
+
catch (_m) {
|
|
762
744
|
}
|
|
763
745
|
const session = await initSession({
|
|
764
746
|
...params,
|
|
@@ -790,7 +772,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
790
772
|
};
|
|
791
773
|
}
|
|
792
774
|
else if (session === null || session === void 0 ? void 0 : session.resultMessage.startsWith('This Memori is aged restricted')) {
|
|
793
|
-
console.warn(session);
|
|
794
775
|
toast.error(t('underageTwinSession', { age: minAge }));
|
|
795
776
|
}
|
|
796
777
|
else if ((session === null || session === void 0 ? void 0 : session.resultCode) === 403 && memori.privacyType !== 'PUBLIC') {
|
|
@@ -799,7 +780,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
799
780
|
return session;
|
|
800
781
|
}
|
|
801
782
|
else {
|
|
802
|
-
console.warn(session);
|
|
803
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') })] })), {
|
|
804
784
|
duration: Infinity,
|
|
805
785
|
});
|
|
@@ -807,7 +787,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
807
787
|
}
|
|
808
788
|
}
|
|
809
789
|
catch (err) {
|
|
810
|
-
|
|
790
|
+
logWidgetError('fetchSession failed', err);
|
|
811
791
|
}
|
|
812
792
|
};
|
|
813
793
|
const reopenSession = async (updateDialogState = false, password, recoveryTokens, tag, pin, initialContextVars, initialQuestion, birthDate, additionalInfoProp, continueFromChatLogID, continueFromSessionID, isSessionExpired) => {
|
|
@@ -839,8 +819,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
839
819
|
return window.location.href;
|
|
840
820
|
})();
|
|
841
821
|
}
|
|
842
|
-
catch (
|
|
843
|
-
console.debug('[REOPEN_SESSION] Error getting referral:', err);
|
|
822
|
+
catch (_o) {
|
|
844
823
|
}
|
|
845
824
|
const { sessionID, currentState, ...response } = await initSession({
|
|
846
825
|
memoriID: (_a = memori.engineMemoriID) !== null && _a !== void 0 ? _a : '',
|
|
@@ -867,12 +846,10 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
867
846
|
},
|
|
868
847
|
});
|
|
869
848
|
if (sessionID && currentState && response.resultCode === 0) {
|
|
870
|
-
console.log('[REOPEN_SESSION] Session initialized successfully:', sessionID);
|
|
871
849
|
setSessionId(sessionID);
|
|
872
850
|
if (updateDialogState) {
|
|
873
851
|
setCurrentDialogState(currentState);
|
|
874
852
|
if (currentState.emission) {
|
|
875
|
-
console.log('[REOPEN_SESSION] Processing emission:', currentState.emission);
|
|
876
853
|
const initialStatus = isSessionExpired && history.length > 1
|
|
877
854
|
? 'Session Expired, reopening session'
|
|
878
855
|
: history.length <= 1
|
|
@@ -924,22 +901,19 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
924
901
|
};
|
|
925
902
|
}
|
|
926
903
|
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
904
|
toast.error(t('underageTwinSession', { age: minAge }));
|
|
929
905
|
}
|
|
930
906
|
else if ((response === null || response === void 0 ? void 0 : response.resultCode) === 403 &&
|
|
931
907
|
memori.privacyType !== 'PUBLIC') {
|
|
932
|
-
console.error('[REOPEN_SESSION] Authentication error');
|
|
933
908
|
setMemoriPwd(undefined);
|
|
934
909
|
setAuthModalState('password');
|
|
935
910
|
}
|
|
936
911
|
else {
|
|
937
|
-
console.error('[REOPEN_SESSION] Other error:', response);
|
|
938
912
|
toast.error(t(getErrori18nKey(response.resultCode)));
|
|
939
913
|
}
|
|
940
914
|
}
|
|
941
915
|
catch (err) {
|
|
942
|
-
|
|
916
|
+
logWidgetError('reopenSession failed', err);
|
|
943
917
|
}
|
|
944
918
|
setLoading(false);
|
|
945
919
|
return null;
|
|
@@ -947,7 +921,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
947
921
|
const changeTag = async (memoriId, sessionId, tag, pin) => {
|
|
948
922
|
var _a, _b, _c, _d, _f, _g, _h, _j, _k;
|
|
949
923
|
if (!memoriId || !sessionId) {
|
|
950
|
-
console.error('CHANGETAG/Session not found');
|
|
951
924
|
return Promise.reject('Session not found');
|
|
952
925
|
}
|
|
953
926
|
try {
|
|
@@ -979,7 +952,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
979
952
|
}
|
|
980
953
|
}
|
|
981
954
|
else if ([400, 401, 403, 404, 500].includes(resultCode)) {
|
|
982
|
-
console.warn('[APPCONTEXT/CHANGETAG]', resultCode);
|
|
983
955
|
let storageBirthDate = getLocalConfig('birthDate', undefined);
|
|
984
956
|
let referral;
|
|
985
957
|
try {
|
|
@@ -987,8 +959,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
987
959
|
return window.location.href;
|
|
988
960
|
})();
|
|
989
961
|
}
|
|
990
|
-
catch (
|
|
991
|
-
console.debug(err);
|
|
962
|
+
catch (_l) {
|
|
992
963
|
}
|
|
993
964
|
fetchSession({
|
|
994
965
|
memoriID: (_b = memori.engineMemoriID) !== null && _b !== void 0 ? _b : '',
|
|
@@ -1023,7 +994,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1023
994
|
}
|
|
1024
995
|
catch (_e) {
|
|
1025
996
|
let err = _e;
|
|
1026
|
-
console.warn('[APPCONTEXT/CHANGETAG]', err);
|
|
1027
997
|
return Promise.reject(err);
|
|
1028
998
|
}
|
|
1029
999
|
return null;
|
|
@@ -1074,7 +1044,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1074
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);
|
|
1075
1045
|
const shouldPlayAudio = (text) => {
|
|
1076
1046
|
const currentSpeakerMuted = getLocalConfig('muteSpeaker', !defaultEnableAudio);
|
|
1077
|
-
console.log('[MemoriWidget] shouldPlayAudio', currentSpeakerMuted);
|
|
1078
1047
|
return (text &&
|
|
1079
1048
|
text.trim() &&
|
|
1080
1049
|
!preview &&
|
|
@@ -1087,15 +1056,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1087
1056
|
}
|
|
1088
1057
|
try {
|
|
1089
1058
|
const message = stripDuplicates(text);
|
|
1090
|
-
console.debug('Processing speech message:', message);
|
|
1091
1059
|
if (message.length > 0) {
|
|
1092
1060
|
setUserMessage('');
|
|
1093
|
-
console.debug('Sending message:', message);
|
|
1094
1061
|
sendMessage(message);
|
|
1095
1062
|
}
|
|
1096
1063
|
}
|
|
1097
|
-
catch (
|
|
1098
|
-
console.error('Error in processSpeechAndSendMessage:', error);
|
|
1064
|
+
catch (_a) {
|
|
1099
1065
|
}
|
|
1100
1066
|
};
|
|
1101
1067
|
const { isListening, startRecording, stopRecording, } = useSTT(sttConfig, processSpeechAndSendMessage, {
|
|
@@ -1129,8 +1095,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1129
1095
|
}
|
|
1130
1096
|
return translatedState;
|
|
1131
1097
|
}
|
|
1132
|
-
catch (
|
|
1133
|
-
console.error('Error in translateAndSpeak:', error);
|
|
1098
|
+
catch (_a) {
|
|
1134
1099
|
if (!hasUserActivatedSpeak) {
|
|
1135
1100
|
setHasUserActivatedSpeak(true);
|
|
1136
1101
|
}
|
|
@@ -1145,20 +1110,10 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1145
1110
|
]);
|
|
1146
1111
|
const processEnterTextDialogResponse = useCallback((event, pending) => {
|
|
1147
1112
|
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
1113
|
const { msg, typingText: pendingTypingText, useLoaderTextAsMsg, } = pending;
|
|
1155
1114
|
const currentState = event.currentState;
|
|
1156
1115
|
if (event.resultCode !== 0 || !currentState) {
|
|
1157
1116
|
if (event.resultCode === 500 && event.resultMessage) {
|
|
1158
|
-
console.warn('[EnterText] processDialogResponse: server error', {
|
|
1159
|
-
correlationID: event.correlationID,
|
|
1160
|
-
resultMessage: event.resultMessage,
|
|
1161
|
-
});
|
|
1162
1117
|
setHistory(h => [
|
|
1163
1118
|
...h,
|
|
1164
1119
|
{
|
|
@@ -1171,24 +1126,15 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1171
1126
|
},
|
|
1172
1127
|
]);
|
|
1173
1128
|
}
|
|
1174
|
-
else if (event.resultCode !== 0) {
|
|
1175
|
-
console.warn('[SEND_MESSAGE/NATS]', event);
|
|
1176
|
-
}
|
|
1177
1129
|
return;
|
|
1178
1130
|
}
|
|
1179
1131
|
if (!msg) {
|
|
1180
|
-
console.debug('[EnterText] processDialogResponse: no msg in pending, skipping');
|
|
1181
1132
|
return;
|
|
1182
1133
|
}
|
|
1183
1134
|
setChatLogID(undefined);
|
|
1184
1135
|
const emission = useLoaderTextAsMsg && pendingTypingText
|
|
1185
1136
|
? pendingTypingText
|
|
1186
1137
|
: (_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
1138
|
if (userLang.toLowerCase() !== language.toLowerCase() &&
|
|
1193
1139
|
emission &&
|
|
1194
1140
|
isMultilanguageEnabled) {
|
|
@@ -1255,11 +1201,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1255
1201
|
: event.errorCode
|
|
1256
1202
|
? `Error: ${event.errorCode}`
|
|
1257
1203
|
: 'Error: An unexpected error occurred';
|
|
1258
|
-
console.error('[EnterText] NATS error event', {
|
|
1259
|
-
correlationID,
|
|
1260
|
-
errorCode: event.errorCode,
|
|
1261
|
-
errorMessage: event.errorMessage,
|
|
1262
|
-
});
|
|
1263
1204
|
pushMessage({
|
|
1264
1205
|
text: errorText,
|
|
1265
1206
|
emitter: 'system',
|
|
@@ -1281,24 +1222,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1281
1222
|
const deliverEnterTextNatsResponse = useCallback((correlationID, event) => {
|
|
1282
1223
|
const pending = pendingEnterTextRef.current.get(correlationID);
|
|
1283
1224
|
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
1225
|
bufferedNatsResponsesRef.current.set(correlationID, event);
|
|
1294
1226
|
return;
|
|
1295
1227
|
}
|
|
1296
1228
|
clearEnterTextPending(correlationID, pending);
|
|
1297
1229
|
if (pending.waitForResponse) {
|
|
1298
|
-
console.info('[EnterText] NATS response delivered to waiter', {
|
|
1299
|
-
correlationID,
|
|
1300
|
-
resultCode: event.resultCode,
|
|
1301
|
-
});
|
|
1302
1230
|
pending.waitForResponse.resolve(event);
|
|
1303
1231
|
setMemoriTyping(false);
|
|
1304
1232
|
setTypingText(undefined);
|
|
@@ -1306,23 +1234,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1306
1234
|
}
|
|
1307
1235
|
processEnterTextDialogResponse(event, pending);
|
|
1308
1236
|
if (!pending.hasBatchQueued) {
|
|
1309
|
-
console.info('[EnterText] typing indicator cleared', { correlationID });
|
|
1310
1237
|
setMemoriTyping(false);
|
|
1311
1238
|
setTypingText(undefined);
|
|
1312
1239
|
}
|
|
1313
|
-
else {
|
|
1314
|
-
console.debug('[EnterText] typing kept (batch queued)', {
|
|
1315
|
-
correlationID,
|
|
1316
|
-
});
|
|
1317
|
-
}
|
|
1318
1240
|
}, [processEnterTextDialogResponse, clearEnterTextPending]);
|
|
1319
1241
|
const registerPendingEnterText = useCallback((correlationID, pending) => {
|
|
1320
1242
|
const buffered = bufferedNatsResponsesRef.current.get(correlationID);
|
|
1321
1243
|
if (buffered) {
|
|
1322
|
-
console.info('[EnterText] replaying buffered NATS response', {
|
|
1323
|
-
correlationID,
|
|
1324
|
-
waitForResponse: !!pending.waitForResponse,
|
|
1325
|
-
});
|
|
1326
1244
|
bufferedNatsResponsesRef.current.delete(correlationID);
|
|
1327
1245
|
pendingEnterTextRef.current.set(correlationID, pending);
|
|
1328
1246
|
deliverEnterTextNatsResponse(correlationID, buffered);
|
|
@@ -1335,7 +1253,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1335
1253
|
if (!current)
|
|
1336
1254
|
return;
|
|
1337
1255
|
clearEnterTextPending(correlationID, current);
|
|
1338
|
-
|
|
1256
|
+
logWidgetError('NATS timeout', {
|
|
1339
1257
|
correlationID,
|
|
1340
1258
|
timeoutMs: ENTER_TEXT_NATS_TIMEOUT_MS,
|
|
1341
1259
|
});
|
|
@@ -1346,27 +1264,15 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1346
1264
|
(_a = current.waitForResponse) === null || _a === void 0 ? void 0 : _a.reject(new Error('NATS enter-text response timeout'));
|
|
1347
1265
|
}, ENTER_TEXT_NATS_TIMEOUT_MS);
|
|
1348
1266
|
}
|
|
1349
|
-
console.debug('[EnterText] pending registered', {
|
|
1350
|
-
correlationID,
|
|
1351
|
-
waitForResponse: !!pending.waitForResponse,
|
|
1352
|
-
hasBatchQueued: pending.hasBatchQueued,
|
|
1353
|
-
});
|
|
1354
1267
|
pendingEnterTextRef.current.set(correlationID, pending);
|
|
1355
1268
|
}, [deliverEnterTextNatsResponse, clearEnterTextPending]);
|
|
1356
1269
|
const waitForEnterTextNatsResponse = useCallback((correlationID, timeoutMs = 120000) => new Promise((resolve, reject) => {
|
|
1357
|
-
console.debug('[EnterText] waiting for NATS response', {
|
|
1358
|
-
correlationID,
|
|
1359
|
-
timeoutMs,
|
|
1360
|
-
});
|
|
1361
1270
|
const timeoutId = setTimeout(() => {
|
|
1362
1271
|
const current = pendingEnterTextRef.current.get(correlationID);
|
|
1363
1272
|
if (current) {
|
|
1364
1273
|
clearEnterTextPending(correlationID, current);
|
|
1365
1274
|
}
|
|
1366
|
-
|
|
1367
|
-
correlationID,
|
|
1368
|
-
timeoutMs,
|
|
1369
|
-
});
|
|
1275
|
+
logWidgetError('NATS timeout', { correlationID, timeoutMs });
|
|
1370
1276
|
reject(new Error('NATS enter-text response timeout'));
|
|
1371
1277
|
}, timeoutMs);
|
|
1372
1278
|
registerPendingEnterText(correlationID, {
|
|
@@ -1387,25 +1293,14 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1387
1293
|
baseUrl,
|
|
1388
1294
|
sessionId,
|
|
1389
1295
|
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
1296
|
if (event.message) {
|
|
1397
1297
|
setTypingText(event.message);
|
|
1398
1298
|
}
|
|
1399
1299
|
}, []),
|
|
1400
1300
|
onDialogResponse: useCallback((event) => {
|
|
1401
1301
|
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
1302
|
if (!correlationID) {
|
|
1408
|
-
|
|
1303
|
+
logWidgetError('NATS dialog response missing correlationID', event);
|
|
1409
1304
|
setMemoriTyping(false);
|
|
1410
1305
|
setTypingText(undefined);
|
|
1411
1306
|
return;
|
|
@@ -1435,7 +1330,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1435
1330
|
timeoutRef.current = undefined;
|
|
1436
1331
|
ttsStop();
|
|
1437
1332
|
}
|
|
1438
|
-
catch (
|
|
1333
|
+
catch (_a) {
|
|
1439
1334
|
}
|
|
1440
1335
|
};
|
|
1441
1336
|
useEffect(() => {
|
|
@@ -1712,8 +1607,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1712
1607
|
};
|
|
1713
1608
|
}));
|
|
1714
1609
|
}
|
|
1715
|
-
catch (
|
|
1716
|
-
console.error('[onClickStart] Error translating messages:', e);
|
|
1610
|
+
catch (_w) {
|
|
1717
1611
|
}
|
|
1718
1612
|
}
|
|
1719
1613
|
setHistory(translatedMessages);
|
|
@@ -1754,13 +1648,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1754
1648
|
const session = await changeTag(memori.engineMemoriID, sessionID, personification.tag, personification.pin);
|
|
1755
1649
|
if (session && session.resultCode === 0) {
|
|
1756
1650
|
await translateAndSpeak(session.currentState, userLang);
|
|
1651
|
+
setClickedStart(false);
|
|
1757
1652
|
}
|
|
1758
1653
|
else {
|
|
1759
1654
|
throw new Error('No session');
|
|
1760
1655
|
}
|
|
1761
1656
|
}
|
|
1762
|
-
catch (
|
|
1763
|
-
console.error('[onClickStart] Error changing tag:', e);
|
|
1657
|
+
catch (_x) {
|
|
1764
1658
|
reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, personification.tag, personification.pin, {
|
|
1765
1659
|
LANG: userLang,
|
|
1766
1660
|
PATHNAME: (_l = window.location.pathname) === null || _l === void 0 ? void 0 : _l.toUpperCase(),
|
|
@@ -1782,6 +1676,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1782
1676
|
const session = await changeTag(memori.engineMemoriID, sessionID, anonTag);
|
|
1783
1677
|
if (session && session.resultCode === 0) {
|
|
1784
1678
|
await translateAndSpeak(session.currentState, userLang);
|
|
1679
|
+
setClickedStart(false);
|
|
1785
1680
|
}
|
|
1786
1681
|
else {
|
|
1787
1682
|
throw new Error('No session');
|
|
@@ -1828,14 +1723,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1828
1723
|
text: (await getTranslation(m.text, userLang, language, baseUrl)).text,
|
|
1829
1724
|
})));
|
|
1830
1725
|
}
|
|
1831
|
-
catch (
|
|
1832
|
-
console.error('[onClickStart] Error translating messages:', e);
|
|
1726
|
+
catch (_y) {
|
|
1833
1727
|
}
|
|
1834
1728
|
}
|
|
1835
1729
|
setHistory(translatedMessages);
|
|
1836
1730
|
}
|
|
1837
|
-
catch (
|
|
1838
|
-
console.error('[onClickStart] Error retrieving chat logs:', e);
|
|
1731
|
+
catch (_z) {
|
|
1839
1732
|
}
|
|
1840
1733
|
if ((!!(translatedMessages === null || translatedMessages === void 0 ? void 0 : translatedMessages.length) && translatedMessages.length > 1) ||
|
|
1841
1734
|
!initialQuestion) {
|
|
@@ -1844,13 +1737,9 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1844
1737
|
await translateAndSpeak(currentState, userLang, undefined, !!(translatedMessages === null || translatedMessages === void 0 ? void 0 : translatedMessages.length));
|
|
1845
1738
|
}
|
|
1846
1739
|
else {
|
|
1847
|
-
console.log('[onClickStart] Starting with initial question');
|
|
1848
1740
|
translatedMessages = [];
|
|
1849
1741
|
setHistory([]);
|
|
1850
1742
|
const placeSpec = getPlaceSpecForEnterText(position);
|
|
1851
|
-
console.debug('[EnterText] onClickStart: posting initial question', {
|
|
1852
|
-
sessionId: sessionID,
|
|
1853
|
-
});
|
|
1854
1743
|
const response = await postEnterTextAsync({
|
|
1855
1744
|
sessionId: sessionID,
|
|
1856
1745
|
text: initialQuestion,
|
|
@@ -1859,10 +1748,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1859
1748
|
}),
|
|
1860
1749
|
...(placeSpec !== undefined && { place: placeSpec }),
|
|
1861
1750
|
});
|
|
1862
|
-
console.debug('[EnterText] onClickStart: HTTP response', {
|
|
1863
|
-
resultCode: response.resultCode,
|
|
1864
|
-
correlationID: readCorrelationID(response),
|
|
1865
|
-
});
|
|
1866
1751
|
if (response.resultCode === 500 && response.resultMessage) {
|
|
1867
1752
|
setHistory(h => [
|
|
1868
1753
|
...h,
|
|
@@ -1879,28 +1764,22 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1879
1764
|
}
|
|
1880
1765
|
const onClickStartCorrelationID = readCorrelationID(response);
|
|
1881
1766
|
if (response.resultCode === 0 && onClickStartCorrelationID) {
|
|
1882
|
-
console.info('[EnterText] onClickStart: accepted, showing typing indicator', {
|
|
1883
|
-
correlationID: onClickStartCorrelationID,
|
|
1884
|
-
});
|
|
1885
1767
|
setMemoriTyping(true);
|
|
1886
1768
|
try {
|
|
1887
1769
|
const natsEvent = await waitForEnterTextNatsResponse(onClickStartCorrelationID);
|
|
1888
|
-
console.info('[EnterText] onClickStart: NATS response received', {
|
|
1889
|
-
correlationID: onClickStartCorrelationID,
|
|
1890
|
-
resultCode: natsEvent.resultCode,
|
|
1891
|
-
});
|
|
1892
1770
|
if (natsEvent.resultCode === 0 && natsEvent.currentState) {
|
|
1893
1771
|
await translateAndSpeak(natsEvent.currentState, userLang, undefined, false);
|
|
1772
|
+
setClickedStart(false);
|
|
1894
1773
|
}
|
|
1895
1774
|
}
|
|
1896
|
-
catch (
|
|
1897
|
-
|
|
1775
|
+
catch (err) {
|
|
1776
|
+
logWidgetError('onClickStart NATS wait failed', err);
|
|
1898
1777
|
setMemoriTyping(false);
|
|
1899
1778
|
setTypingText(undefined);
|
|
1900
1779
|
}
|
|
1901
1780
|
}
|
|
1902
1781
|
else if (response.resultCode === 0) {
|
|
1903
|
-
|
|
1782
|
+
logWidgetError('onClickStart enter-text missing correlationID', response);
|
|
1904
1783
|
}
|
|
1905
1784
|
}
|
|
1906
1785
|
}
|
|
@@ -1908,6 +1787,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1908
1787
|
else {
|
|
1909
1788
|
setHistory([]);
|
|
1910
1789
|
await translateAndSpeak(dialogState, userLang);
|
|
1790
|
+
setClickedStart(false);
|
|
1911
1791
|
}
|
|
1912
1792
|
}, [memoriPwd, memori, memoriTokens, birthDate, sessionId, userLang, position]);
|
|
1913
1793
|
useEffect(() => {
|
|
@@ -1959,12 +1839,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1959
1839
|
if (resp.resultCode === 0) {
|
|
1960
1840
|
setExperts(experts);
|
|
1961
1841
|
}
|
|
1962
|
-
else {
|
|
1963
|
-
console.warn('Error fetching experts', resp);
|
|
1964
|
-
}
|
|
1965
1842
|
}
|
|
1966
|
-
catch (
|
|
1967
|
-
console.warn(err);
|
|
1843
|
+
catch (_a) {
|
|
1968
1844
|
}
|
|
1969
1845
|
}, [sessionId, memori === null || memori === void 0 ? void 0 : memori.enableBoardOfExperts]);
|
|
1970
1846
|
useEffect(() => {
|
|
@@ -1985,7 +1861,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1985
1861
|
if (!(tenant === null || tenant === void 0 ? void 0 : tenant.billingDelegation))
|
|
1986
1862
|
return true;
|
|
1987
1863
|
if (!ownerUserID && !ownerUserName) {
|
|
1988
|
-
console.warn('Cannot verify credits: missing owner identifier');
|
|
1989
1864
|
if (options === null || options === void 0 ? void 0 : options.notify) {
|
|
1990
1865
|
handleNotEnoughCredits();
|
|
1991
1866
|
}
|
|
@@ -2009,7 +1884,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2009
1884
|
return true;
|
|
2010
1885
|
}
|
|
2011
1886
|
else {
|
|
2012
|
-
console.warn('Not enough credits. Required:', resp.required);
|
|
2013
1887
|
if (options === null || options === void 0 ? void 0 : options.notify) {
|
|
2014
1888
|
handleNotEnoughCredits();
|
|
2015
1889
|
}
|
|
@@ -2019,9 +1893,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2019
1893
|
return false;
|
|
2020
1894
|
}
|
|
2021
1895
|
}
|
|
2022
|
-
catch (
|
|
2023
|
-
|
|
2024
|
-
console.debug(err);
|
|
1896
|
+
catch (err) {
|
|
1897
|
+
logWidgetError('checkCredits failed', err);
|
|
2025
1898
|
return true;
|
|
2026
1899
|
}
|
|
2027
1900
|
}, [
|