@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [8.40.2](https://github.com/memori-ai/memori-react/compare/v8.40.1...v8.40.2) (2026-06-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add unwrapDialogState function to handle nested currentState in NATS responses ([a6fcafc](https://github.com/memori-ai/memori-react/commit/a6fcafc7f000946baac6bb12e5f37972a956e828))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* reset clickedStart state in multiple scenarios within MemoriWidget ([a34ed85](https://github.com/memori-ai/memori-react/commit/a34ed853504a107b1096c8e82be64b97cdb30ede))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Changes
|
|
17
|
+
|
|
18
|
+
* improve error logging and clean up debug statements in MemoriWidget ([372b09a](https://github.com/memori-ai/memori-react/commit/372b09ac584aab552f5f1a7cde6258fef2a5493c))
|
|
19
|
+
|
|
3
20
|
## [8.40.1](https://github.com/memori-ai/memori-react/compare/v8.40.0...v8.40.1) (2026-06-17)
|
|
4
21
|
|
|
5
22
|
|
|
@@ -70,6 +70,9 @@ const NULL_PLACE_SPEC = {
|
|
|
70
70
|
uncertaintyKm: null,
|
|
71
71
|
};
|
|
72
72
|
const ENTER_TEXT_NATS_TIMEOUT_MS = 120000;
|
|
73
|
+
const logWidgetError = (context, detail) => {
|
|
74
|
+
console.error(`[MemoriWidget] ${context}`, detail !== null && detail !== void 0 ? detail : '');
|
|
75
|
+
};
|
|
73
76
|
function readCorrelationID(response) {
|
|
74
77
|
const value = response.correlationID;
|
|
75
78
|
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
@@ -451,12 +454,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
451
454
|
let gotError = false;
|
|
452
455
|
try {
|
|
453
456
|
const placeSpec = getPlaceSpecForEnterText(position);
|
|
454
|
-
console.debug('[EnterText] sendMessage: posting', {
|
|
455
|
-
sessionId: sessionID,
|
|
456
|
-
textLength: msg.length,
|
|
457
|
-
hasBatchQueued,
|
|
458
|
-
typingText,
|
|
459
|
-
});
|
|
460
457
|
const response = await postEnterTextAsync({
|
|
461
458
|
sessionId: sessionID,
|
|
462
459
|
text: msg,
|
|
@@ -465,11 +462,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
465
462
|
}),
|
|
466
463
|
...(placeSpec !== undefined && { place: placeSpec }),
|
|
467
464
|
});
|
|
468
|
-
console.debug('[EnterText] sendMessage: HTTP response', {
|
|
469
|
-
resultCode: response.resultCode,
|
|
470
|
-
correlationID: readCorrelationID(response),
|
|
471
|
-
resultMessage: response.resultMessage,
|
|
472
|
-
});
|
|
473
465
|
const correlationID = readCorrelationID(response);
|
|
474
466
|
if (response.resultCode === 0 && correlationID) {
|
|
475
467
|
registerPendingEnterText(correlationID, {
|
|
@@ -478,15 +470,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
478
470
|
useLoaderTextAsMsg,
|
|
479
471
|
hasBatchQueued,
|
|
480
472
|
});
|
|
481
|
-
console.info('[EnterText] sendMessage: accepted, showing typing indicator', {
|
|
482
|
-
correlationID: correlationID,
|
|
483
|
-
typingText,
|
|
484
|
-
});
|
|
485
473
|
setMemoriTyping(true);
|
|
486
474
|
setTypingText(typingText);
|
|
487
475
|
}
|
|
488
476
|
else if (response.resultCode === 0) {
|
|
489
|
-
|
|
477
|
+
logWidgetError('enter-text missing correlationID', response);
|
|
490
478
|
}
|
|
491
479
|
else if (response.resultCode === 404) {
|
|
492
480
|
setHistory(h => [...h.slice(0, h.length - 1)]);
|
|
@@ -496,7 +484,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
496
484
|
ROUTE: ((_d = (_c = window.location.pathname) === null || _c === void 0 ? void 0 : _c.split('/')) === null || _d === void 0 ? void 0 : _d.pop()) || '',
|
|
497
485
|
...(initialContextVars || {}),
|
|
498
486
|
}, initialQuestion, undefined, undefined, undefined, undefined, true).then(state => {
|
|
499
|
-
console.info('session timeout');
|
|
500
487
|
if (state === null || state === void 0 ? void 0 : state.sessionID) {
|
|
501
488
|
setTimeout(() => {
|
|
502
489
|
sendMessage(text, media, state === null || state === void 0 ? void 0 : state.sessionID);
|
|
@@ -518,13 +505,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
518
505
|
]);
|
|
519
506
|
}
|
|
520
507
|
else {
|
|
521
|
-
console.warn('[SEND_MESSAGE]', response);
|
|
522
508
|
return Promise.reject(response);
|
|
523
509
|
}
|
|
524
510
|
}
|
|
525
511
|
catch (error) {
|
|
526
|
-
console.error('[EnterText] sendMessage: request failed', error);
|
|
527
512
|
gotError = true;
|
|
513
|
+
logWidgetError('sendMessage failed', error);
|
|
528
514
|
setTypingText(undefined);
|
|
529
515
|
setMemoriTyping(false);
|
|
530
516
|
}
|
|
@@ -606,7 +592,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
606
592
|
}
|
|
607
593
|
}
|
|
608
594
|
catch (error) {
|
|
609
|
-
console.error('[TRANSLATE] Error during translation:', error);
|
|
610
595
|
translatedState = { ...state, emission };
|
|
611
596
|
translatedMsg = {
|
|
612
597
|
text: emission,
|
|
@@ -714,7 +699,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
714
699
|
try {
|
|
715
700
|
setTimeout(() => {
|
|
716
701
|
var _a;
|
|
717
|
-
console.log('snippet', s);
|
|
718
702
|
new Function((_a = s.content) !== null && _a !== void 0 ? _a : '')();
|
|
719
703
|
setTimeout(() => {
|
|
720
704
|
var _a, _b, _c;
|
|
@@ -723,8 +707,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
723
707
|
}, 400);
|
|
724
708
|
}, 1000);
|
|
725
709
|
}
|
|
726
|
-
catch (
|
|
727
|
-
console.warn(e);
|
|
710
|
+
catch (_a) {
|
|
728
711
|
}
|
|
729
712
|
});
|
|
730
713
|
};
|
|
@@ -760,8 +743,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
760
743
|
return window.location.href;
|
|
761
744
|
})();
|
|
762
745
|
}
|
|
763
|
-
catch (
|
|
764
|
-
console.debug(err);
|
|
746
|
+
catch (_m) {
|
|
765
747
|
}
|
|
766
748
|
const session = await initSession({
|
|
767
749
|
...params,
|
|
@@ -793,7 +775,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
793
775
|
};
|
|
794
776
|
}
|
|
795
777
|
else if (session === null || session === void 0 ? void 0 : session.resultMessage.startsWith('This Memori is aged restricted')) {
|
|
796
|
-
console.warn(session);
|
|
797
778
|
react_hot_toast_1.default.error(t('underageTwinSession', { age: minAge }));
|
|
798
779
|
}
|
|
799
780
|
else if ((session === null || session === void 0 ? void 0 : session.resultCode) === 403 && memori.privacyType !== 'PUBLIC') {
|
|
@@ -802,7 +783,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
802
783
|
return session;
|
|
803
784
|
}
|
|
804
785
|
else {
|
|
805
|
-
console.warn(session);
|
|
806
786
|
react_hot_toast_1.default.error(tst => ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("p", { children: t((0, error_1.getErrori18nKey)(session === null || session === void 0 ? void 0 : session.resultCode)) }), (0, jsx_runtime_1.jsx)(Button_1.default, { outlined: true, padded: false, onClick: () => react_hot_toast_1.default.dismiss(tst.id), icon: (0, jsx_runtime_1.jsx)(Close_1.default, {}), children: t('close') })] })), {
|
|
807
787
|
duration: Infinity,
|
|
808
788
|
});
|
|
@@ -810,7 +790,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
810
790
|
}
|
|
811
791
|
}
|
|
812
792
|
catch (err) {
|
|
813
|
-
|
|
793
|
+
logWidgetError('fetchSession failed', err);
|
|
814
794
|
}
|
|
815
795
|
};
|
|
816
796
|
const reopenSession = async (updateDialogState = false, password, recoveryTokens, tag, pin, initialContextVars, initialQuestion, birthDate, additionalInfoProp, continueFromChatLogID, continueFromSessionID, isSessionExpired) => {
|
|
@@ -842,8 +822,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
842
822
|
return window.location.href;
|
|
843
823
|
})();
|
|
844
824
|
}
|
|
845
|
-
catch (
|
|
846
|
-
console.debug('[REOPEN_SESSION] Error getting referral:', err);
|
|
825
|
+
catch (_o) {
|
|
847
826
|
}
|
|
848
827
|
const { sessionID, currentState, ...response } = await initSession({
|
|
849
828
|
memoriID: (_a = memori.engineMemoriID) !== null && _a !== void 0 ? _a : '',
|
|
@@ -870,12 +849,10 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
870
849
|
},
|
|
871
850
|
});
|
|
872
851
|
if (sessionID && currentState && response.resultCode === 0) {
|
|
873
|
-
console.log('[REOPEN_SESSION] Session initialized successfully:', sessionID);
|
|
874
852
|
setSessionId(sessionID);
|
|
875
853
|
if (updateDialogState) {
|
|
876
854
|
setCurrentDialogState(currentState);
|
|
877
855
|
if (currentState.emission) {
|
|
878
|
-
console.log('[REOPEN_SESSION] Processing emission:', currentState.emission);
|
|
879
856
|
const initialStatus = isSessionExpired && history.length > 1
|
|
880
857
|
? 'Session Expired, reopening session'
|
|
881
858
|
: history.length <= 1
|
|
@@ -927,22 +904,19 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
927
904
|
};
|
|
928
905
|
}
|
|
929
906
|
else if (response === null || response === void 0 ? void 0 : response.resultMessage.startsWith('This Memori is aged restricted')) {
|
|
930
|
-
console.error('[REOPEN_SESSION] Age restriction error:', response);
|
|
931
907
|
react_hot_toast_1.default.error(t('underageTwinSession', { age: minAge }));
|
|
932
908
|
}
|
|
933
909
|
else if ((response === null || response === void 0 ? void 0 : response.resultCode) === 403 &&
|
|
934
910
|
memori.privacyType !== 'PUBLIC') {
|
|
935
|
-
console.error('[REOPEN_SESSION] Authentication error');
|
|
936
911
|
setMemoriPwd(undefined);
|
|
937
912
|
setAuthModalState('password');
|
|
938
913
|
}
|
|
939
914
|
else {
|
|
940
|
-
console.error('[REOPEN_SESSION] Other error:', response);
|
|
941
915
|
react_hot_toast_1.default.error(t((0, error_1.getErrori18nKey)(response.resultCode)));
|
|
942
916
|
}
|
|
943
917
|
}
|
|
944
918
|
catch (err) {
|
|
945
|
-
|
|
919
|
+
logWidgetError('reopenSession failed', err);
|
|
946
920
|
}
|
|
947
921
|
setLoading(false);
|
|
948
922
|
return null;
|
|
@@ -950,7 +924,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
950
924
|
const changeTag = async (memoriId, sessionId, tag, pin) => {
|
|
951
925
|
var _a, _b, _c, _d, _f, _g, _h, _j, _k;
|
|
952
926
|
if (!memoriId || !sessionId) {
|
|
953
|
-
console.error('CHANGETAG/Session not found');
|
|
954
927
|
return Promise.reject('Session not found');
|
|
955
928
|
}
|
|
956
929
|
try {
|
|
@@ -982,7 +955,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
982
955
|
}
|
|
983
956
|
}
|
|
984
957
|
else if ([400, 401, 403, 404, 500].includes(resultCode)) {
|
|
985
|
-
console.warn('[APPCONTEXT/CHANGETAG]', resultCode);
|
|
986
958
|
let storageBirthDate = (0, configuration_1.getLocalConfig)('birthDate', undefined);
|
|
987
959
|
let referral;
|
|
988
960
|
try {
|
|
@@ -990,8 +962,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
990
962
|
return window.location.href;
|
|
991
963
|
})();
|
|
992
964
|
}
|
|
993
|
-
catch (
|
|
994
|
-
console.debug(err);
|
|
965
|
+
catch (_l) {
|
|
995
966
|
}
|
|
996
967
|
fetchSession({
|
|
997
968
|
memoriID: (_b = memori.engineMemoriID) !== null && _b !== void 0 ? _b : '',
|
|
@@ -1026,7 +997,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1026
997
|
}
|
|
1027
998
|
catch (_e) {
|
|
1028
999
|
let err = _e;
|
|
1029
|
-
console.warn('[APPCONTEXT/CHANGETAG]', err);
|
|
1030
1000
|
return Promise.reject(err);
|
|
1031
1001
|
}
|
|
1032
1002
|
return null;
|
|
@@ -1077,7 +1047,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1077
1047
|
}, autoStart, defaultEnableAudio, (_u = defaultSpeakerActive !== null && defaultSpeakerActive !== void 0 ? defaultSpeakerActive : integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.defaultSpeakerActive) !== null && _u !== void 0 ? _u : true);
|
|
1078
1048
|
const shouldPlayAudio = (text) => {
|
|
1079
1049
|
const currentSpeakerMuted = (0, configuration_1.getLocalConfig)('muteSpeaker', !defaultEnableAudio);
|
|
1080
|
-
console.log('[MemoriWidget] shouldPlayAudio', currentSpeakerMuted);
|
|
1081
1050
|
return (text &&
|
|
1082
1051
|
text.trim() &&
|
|
1083
1052
|
!preview &&
|
|
@@ -1090,15 +1059,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1090
1059
|
}
|
|
1091
1060
|
try {
|
|
1092
1061
|
const message = (0, utils_1.stripDuplicates)(text);
|
|
1093
|
-
console.debug('Processing speech message:', message);
|
|
1094
1062
|
if (message.length > 0) {
|
|
1095
1063
|
setUserMessage('');
|
|
1096
|
-
console.debug('Sending message:', message);
|
|
1097
1064
|
sendMessage(message);
|
|
1098
1065
|
}
|
|
1099
1066
|
}
|
|
1100
|
-
catch (
|
|
1101
|
-
console.error('Error in processSpeechAndSendMessage:', error);
|
|
1067
|
+
catch (_a) {
|
|
1102
1068
|
}
|
|
1103
1069
|
};
|
|
1104
1070
|
const { isListening, startRecording, stopRecording, } = (0, useSTT_1.useSTT)(sttConfig, processSpeechAndSendMessage, {
|
|
@@ -1132,8 +1098,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1132
1098
|
}
|
|
1133
1099
|
return translatedState;
|
|
1134
1100
|
}
|
|
1135
|
-
catch (
|
|
1136
|
-
console.error('Error in translateAndSpeak:', error);
|
|
1101
|
+
catch (_a) {
|
|
1137
1102
|
if (!hasUserActivatedSpeak) {
|
|
1138
1103
|
setHasUserActivatedSpeak(true);
|
|
1139
1104
|
}
|
|
@@ -1148,20 +1113,10 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1148
1113
|
]);
|
|
1149
1114
|
const processEnterTextDialogResponse = (0, react_1.useCallback)((event, pending) => {
|
|
1150
1115
|
var _a, _b;
|
|
1151
|
-
console.debug('[EnterText] processDialogResponse', {
|
|
1152
|
-
correlationID: event.correlationID,
|
|
1153
|
-
resultCode: event.resultCode,
|
|
1154
|
-
hasCurrentState: !!event.currentState,
|
|
1155
|
-
hasBatchQueued: pending.hasBatchQueued,
|
|
1156
|
-
});
|
|
1157
1116
|
const { msg, typingText: pendingTypingText, useLoaderTextAsMsg, } = pending;
|
|
1158
1117
|
const currentState = event.currentState;
|
|
1159
1118
|
if (event.resultCode !== 0 || !currentState) {
|
|
1160
1119
|
if (event.resultCode === 500 && event.resultMessage) {
|
|
1161
|
-
console.warn('[EnterText] processDialogResponse: server error', {
|
|
1162
|
-
correlationID: event.correlationID,
|
|
1163
|
-
resultMessage: event.resultMessage,
|
|
1164
|
-
});
|
|
1165
1120
|
setHistory(h => [
|
|
1166
1121
|
...h,
|
|
1167
1122
|
{
|
|
@@ -1174,24 +1129,15 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1174
1129
|
},
|
|
1175
1130
|
]);
|
|
1176
1131
|
}
|
|
1177
|
-
else if (event.resultCode !== 0) {
|
|
1178
|
-
console.warn('[SEND_MESSAGE/NATS]', event);
|
|
1179
|
-
}
|
|
1180
1132
|
return;
|
|
1181
1133
|
}
|
|
1182
1134
|
if (!msg) {
|
|
1183
|
-
console.debug('[EnterText] processDialogResponse: no msg in pending, skipping');
|
|
1184
1135
|
return;
|
|
1185
1136
|
}
|
|
1186
1137
|
setChatLogID(undefined);
|
|
1187
1138
|
const emission = useLoaderTextAsMsg && pendingTypingText
|
|
1188
1139
|
? pendingTypingText
|
|
1189
1140
|
: (_a = currentState.emission) !== null && _a !== void 0 ? _a : currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.emission;
|
|
1190
|
-
console.debug('[EnterText] processDialogResponse: rendering emission', {
|
|
1191
|
-
correlationID: event.correlationID,
|
|
1192
|
-
emissionPreview: emission === null || emission === void 0 ? void 0 : emission.slice(0, 80),
|
|
1193
|
-
state: currentState.state,
|
|
1194
|
-
});
|
|
1195
1141
|
if (userLang.toLowerCase() !== language.toLowerCase() &&
|
|
1196
1142
|
emission &&
|
|
1197
1143
|
isMultilanguageEnabled) {
|
|
@@ -1258,11 +1204,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1258
1204
|
: event.errorCode
|
|
1259
1205
|
? `Error: ${event.errorCode}`
|
|
1260
1206
|
: 'Error: An unexpected error occurred';
|
|
1261
|
-
console.error('[EnterText] NATS error event', {
|
|
1262
|
-
correlationID,
|
|
1263
|
-
errorCode: event.errorCode,
|
|
1264
|
-
errorMessage: event.errorMessage,
|
|
1265
|
-
});
|
|
1266
1207
|
pushMessage({
|
|
1267
1208
|
text: errorText,
|
|
1268
1209
|
emitter: 'system',
|
|
@@ -1284,24 +1225,11 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1284
1225
|
const deliverEnterTextNatsResponse = (0, react_1.useCallback)((correlationID, event) => {
|
|
1285
1226
|
const pending = pendingEnterTextRef.current.get(correlationID);
|
|
1286
1227
|
if (!pending) {
|
|
1287
|
-
const pendingCorrelationIDs = [...pendingEnterTextRef.current.keys()];
|
|
1288
|
-
console.warn('[EnterText] NATS response buffered (no matching pending)', {
|
|
1289
|
-
receivedCorrelationID: correlationID,
|
|
1290
|
-
resultCode: event.resultCode,
|
|
1291
|
-
pendingCorrelationIDs,
|
|
1292
|
-
hint: pendingCorrelationIDs.length > 0
|
|
1293
|
-
? 'Use one of pendingCorrelationIDs in your nats pub correlation_id'
|
|
1294
|
-
: 'Send a message in the widget first, then copy correlationID from HTTP response logs',
|
|
1295
|
-
});
|
|
1296
1228
|
bufferedNatsResponsesRef.current.set(correlationID, event);
|
|
1297
1229
|
return;
|
|
1298
1230
|
}
|
|
1299
1231
|
clearEnterTextPending(correlationID, pending);
|
|
1300
1232
|
if (pending.waitForResponse) {
|
|
1301
|
-
console.info('[EnterText] NATS response delivered to waiter', {
|
|
1302
|
-
correlationID,
|
|
1303
|
-
resultCode: event.resultCode,
|
|
1304
|
-
});
|
|
1305
1233
|
pending.waitForResponse.resolve(event);
|
|
1306
1234
|
setMemoriTyping(false);
|
|
1307
1235
|
setTypingText(undefined);
|
|
@@ -1309,23 +1237,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1309
1237
|
}
|
|
1310
1238
|
processEnterTextDialogResponse(event, pending);
|
|
1311
1239
|
if (!pending.hasBatchQueued) {
|
|
1312
|
-
console.info('[EnterText] typing indicator cleared', { correlationID });
|
|
1313
1240
|
setMemoriTyping(false);
|
|
1314
1241
|
setTypingText(undefined);
|
|
1315
1242
|
}
|
|
1316
|
-
else {
|
|
1317
|
-
console.debug('[EnterText] typing kept (batch queued)', {
|
|
1318
|
-
correlationID,
|
|
1319
|
-
});
|
|
1320
|
-
}
|
|
1321
1243
|
}, [processEnterTextDialogResponse, clearEnterTextPending]);
|
|
1322
1244
|
const registerPendingEnterText = (0, react_1.useCallback)((correlationID, pending) => {
|
|
1323
1245
|
const buffered = bufferedNatsResponsesRef.current.get(correlationID);
|
|
1324
1246
|
if (buffered) {
|
|
1325
|
-
console.info('[EnterText] replaying buffered NATS response', {
|
|
1326
|
-
correlationID,
|
|
1327
|
-
waitForResponse: !!pending.waitForResponse,
|
|
1328
|
-
});
|
|
1329
1247
|
bufferedNatsResponsesRef.current.delete(correlationID);
|
|
1330
1248
|
pendingEnterTextRef.current.set(correlationID, pending);
|
|
1331
1249
|
deliverEnterTextNatsResponse(correlationID, buffered);
|
|
@@ -1338,7 +1256,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1338
1256
|
if (!current)
|
|
1339
1257
|
return;
|
|
1340
1258
|
clearEnterTextPending(correlationID, current);
|
|
1341
|
-
|
|
1259
|
+
logWidgetError('NATS timeout', {
|
|
1342
1260
|
correlationID,
|
|
1343
1261
|
timeoutMs: ENTER_TEXT_NATS_TIMEOUT_MS,
|
|
1344
1262
|
});
|
|
@@ -1349,27 +1267,15 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1349
1267
|
(_a = current.waitForResponse) === null || _a === void 0 ? void 0 : _a.reject(new Error('NATS enter-text response timeout'));
|
|
1350
1268
|
}, ENTER_TEXT_NATS_TIMEOUT_MS);
|
|
1351
1269
|
}
|
|
1352
|
-
console.debug('[EnterText] pending registered', {
|
|
1353
|
-
correlationID,
|
|
1354
|
-
waitForResponse: !!pending.waitForResponse,
|
|
1355
|
-
hasBatchQueued: pending.hasBatchQueued,
|
|
1356
|
-
});
|
|
1357
1270
|
pendingEnterTextRef.current.set(correlationID, pending);
|
|
1358
1271
|
}, [deliverEnterTextNatsResponse, clearEnterTextPending]);
|
|
1359
1272
|
const waitForEnterTextNatsResponse = (0, react_1.useCallback)((correlationID, timeoutMs = 120000) => new Promise((resolve, reject) => {
|
|
1360
|
-
console.debug('[EnterText] waiting for NATS response', {
|
|
1361
|
-
correlationID,
|
|
1362
|
-
timeoutMs,
|
|
1363
|
-
});
|
|
1364
1273
|
const timeoutId = setTimeout(() => {
|
|
1365
1274
|
const current = pendingEnterTextRef.current.get(correlationID);
|
|
1366
1275
|
if (current) {
|
|
1367
1276
|
clearEnterTextPending(correlationID, current);
|
|
1368
1277
|
}
|
|
1369
|
-
|
|
1370
|
-
correlationID,
|
|
1371
|
-
timeoutMs,
|
|
1372
|
-
});
|
|
1278
|
+
logWidgetError('NATS timeout', { correlationID, timeoutMs });
|
|
1373
1279
|
reject(new Error('NATS enter-text response timeout'));
|
|
1374
1280
|
}, timeoutMs);
|
|
1375
1281
|
registerPendingEnterText(correlationID, {
|
|
@@ -1390,25 +1296,14 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1390
1296
|
baseUrl,
|
|
1391
1297
|
sessionId,
|
|
1392
1298
|
onProgress: (0, react_1.useCallback)((event) => {
|
|
1393
|
-
console.debug('[EnterText] NATS progress', {
|
|
1394
|
-
correlationID: event.correlationID,
|
|
1395
|
-
step: event.currentStep,
|
|
1396
|
-
finalStep: event.finalStep,
|
|
1397
|
-
message: event.message,
|
|
1398
|
-
});
|
|
1399
1299
|
if (event.message) {
|
|
1400
1300
|
setTypingText(event.message);
|
|
1401
1301
|
}
|
|
1402
1302
|
}, []),
|
|
1403
1303
|
onDialogResponse: (0, react_1.useCallback)((event) => {
|
|
1404
1304
|
const correlationID = event.correlationID;
|
|
1405
|
-
console.debug('[EnterText] NATS dialog.text_entered_response received', {
|
|
1406
|
-
correlationID,
|
|
1407
|
-
resultCode: event.resultCode,
|
|
1408
|
-
requestID: event.requestID,
|
|
1409
|
-
});
|
|
1410
1305
|
if (!correlationID) {
|
|
1411
|
-
|
|
1306
|
+
logWidgetError('NATS dialog response missing correlationID', event);
|
|
1412
1307
|
setMemoriTyping(false);
|
|
1413
1308
|
setTypingText(undefined);
|
|
1414
1309
|
return;
|
|
@@ -1438,7 +1333,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1438
1333
|
timeoutRef.current = undefined;
|
|
1439
1334
|
ttsStop();
|
|
1440
1335
|
}
|
|
1441
|
-
catch (
|
|
1336
|
+
catch (_a) {
|
|
1442
1337
|
}
|
|
1443
1338
|
};
|
|
1444
1339
|
(0, react_1.useEffect)(() => {
|
|
@@ -1715,8 +1610,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1715
1610
|
};
|
|
1716
1611
|
}));
|
|
1717
1612
|
}
|
|
1718
|
-
catch (
|
|
1719
|
-
console.error('[onClickStart] Error translating messages:', e);
|
|
1613
|
+
catch (_w) {
|
|
1720
1614
|
}
|
|
1721
1615
|
}
|
|
1722
1616
|
setHistory(translatedMessages);
|
|
@@ -1746,7 +1640,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1746
1640
|
if (response.resultCode !== 0 || !currentState) {
|
|
1747
1641
|
const { chatLogs } = await getSessionChatLogs(sessionID, sessionID);
|
|
1748
1642
|
setSessionId(undefined);
|
|
1749
|
-
setClickedStart(false);
|
|
1750
1643
|
await onClickStart(undefined, true, chatLogs === null || chatLogs === void 0 ? void 0 : chatLogs[0]);
|
|
1751
1644
|
return;
|
|
1752
1645
|
}
|
|
@@ -1758,13 +1651,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1758
1651
|
const session = await changeTag(memori.engineMemoriID, sessionID, personification.tag, personification.pin);
|
|
1759
1652
|
if (session && session.resultCode === 0) {
|
|
1760
1653
|
await translateAndSpeak(session.currentState, userLang);
|
|
1654
|
+
setClickedStart(false);
|
|
1761
1655
|
}
|
|
1762
1656
|
else {
|
|
1763
1657
|
throw new Error('No session');
|
|
1764
1658
|
}
|
|
1765
1659
|
}
|
|
1766
|
-
catch (
|
|
1767
|
-
console.error('[onClickStart] Error changing tag:', e);
|
|
1660
|
+
catch (_x) {
|
|
1768
1661
|
reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, personification.tag, personification.pin, {
|
|
1769
1662
|
LANG: userLang,
|
|
1770
1663
|
PATHNAME: (_l = window.location.pathname) === null || _l === void 0 ? void 0 : _l.toUpperCase(),
|
|
@@ -1786,6 +1679,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1786
1679
|
const session = await changeTag(memori.engineMemoriID, sessionID, constants_1.anonTag);
|
|
1787
1680
|
if (session && session.resultCode === 0) {
|
|
1788
1681
|
await translateAndSpeak(session.currentState, userLang);
|
|
1682
|
+
setClickedStart(false);
|
|
1789
1683
|
}
|
|
1790
1684
|
else {
|
|
1791
1685
|
throw new Error('No session');
|
|
@@ -1800,6 +1694,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1800
1694
|
...(initialContextVars || {}),
|
|
1801
1695
|
}, initialQuestion, birth).then(() => {
|
|
1802
1696
|
setHasUserActivatedSpeak(true);
|
|
1697
|
+
setClickedStart(false);
|
|
1803
1698
|
});
|
|
1804
1699
|
}
|
|
1805
1700
|
}
|
|
@@ -1831,28 +1726,23 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1831
1726
|
text: (await (0, translations_1.getTranslation)(m.text, userLang, language, baseUrl)).text,
|
|
1832
1727
|
})));
|
|
1833
1728
|
}
|
|
1834
|
-
catch (
|
|
1835
|
-
console.error('[onClickStart] Error translating messages:', e);
|
|
1729
|
+
catch (_y) {
|
|
1836
1730
|
}
|
|
1837
1731
|
}
|
|
1838
1732
|
setHistory(translatedMessages);
|
|
1839
1733
|
}
|
|
1840
|
-
catch (
|
|
1841
|
-
console.error('[onClickStart] Error retrieving chat logs:', e);
|
|
1734
|
+
catch (_z) {
|
|
1842
1735
|
}
|
|
1843
1736
|
if ((!!(translatedMessages === null || translatedMessages === void 0 ? void 0 : translatedMessages.length) && translatedMessages.length > 1) ||
|
|
1844
1737
|
!initialQuestion) {
|
|
1845
1738
|
setHasUserActivatedSpeak(true);
|
|
1739
|
+
setClickedStart(false);
|
|
1846
1740
|
await translateAndSpeak(currentState, userLang, undefined, !!(translatedMessages === null || translatedMessages === void 0 ? void 0 : translatedMessages.length));
|
|
1847
1741
|
}
|
|
1848
1742
|
else {
|
|
1849
|
-
console.log('[onClickStart] Starting with initial question');
|
|
1850
1743
|
translatedMessages = [];
|
|
1851
1744
|
setHistory([]);
|
|
1852
1745
|
const placeSpec = getPlaceSpecForEnterText(position);
|
|
1853
|
-
console.debug('[EnterText] onClickStart: posting initial question', {
|
|
1854
|
-
sessionId: sessionID,
|
|
1855
|
-
});
|
|
1856
1746
|
const response = await postEnterTextAsync({
|
|
1857
1747
|
sessionId: sessionID,
|
|
1858
1748
|
text: initialQuestion,
|
|
@@ -1861,10 +1751,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1861
1751
|
}),
|
|
1862
1752
|
...(placeSpec !== undefined && { place: placeSpec }),
|
|
1863
1753
|
});
|
|
1864
|
-
console.debug('[EnterText] onClickStart: HTTP response', {
|
|
1865
|
-
resultCode: response.resultCode,
|
|
1866
|
-
correlationID: readCorrelationID(response),
|
|
1867
|
-
});
|
|
1868
1754
|
if (response.resultCode === 500 && response.resultMessage) {
|
|
1869
1755
|
setHistory(h => [
|
|
1870
1756
|
...h,
|
|
@@ -1881,28 +1767,22 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1881
1767
|
}
|
|
1882
1768
|
const onClickStartCorrelationID = readCorrelationID(response);
|
|
1883
1769
|
if (response.resultCode === 0 && onClickStartCorrelationID) {
|
|
1884
|
-
console.info('[EnterText] onClickStart: accepted, showing typing indicator', {
|
|
1885
|
-
correlationID: onClickStartCorrelationID,
|
|
1886
|
-
});
|
|
1887
1770
|
setMemoriTyping(true);
|
|
1888
1771
|
try {
|
|
1889
1772
|
const natsEvent = await waitForEnterTextNatsResponse(onClickStartCorrelationID);
|
|
1890
|
-
console.info('[EnterText] onClickStart: NATS response received', {
|
|
1891
|
-
correlationID: onClickStartCorrelationID,
|
|
1892
|
-
resultCode: natsEvent.resultCode,
|
|
1893
|
-
});
|
|
1894
1773
|
if (natsEvent.resultCode === 0 && natsEvent.currentState) {
|
|
1895
1774
|
await translateAndSpeak(natsEvent.currentState, userLang, undefined, false);
|
|
1775
|
+
setClickedStart(false);
|
|
1896
1776
|
}
|
|
1897
1777
|
}
|
|
1898
|
-
catch (
|
|
1899
|
-
|
|
1778
|
+
catch (err) {
|
|
1779
|
+
logWidgetError('onClickStart NATS wait failed', err);
|
|
1900
1780
|
setMemoriTyping(false);
|
|
1901
1781
|
setTypingText(undefined);
|
|
1902
1782
|
}
|
|
1903
1783
|
}
|
|
1904
1784
|
else if (response.resultCode === 0) {
|
|
1905
|
-
|
|
1785
|
+
logWidgetError('onClickStart enter-text missing correlationID', response);
|
|
1906
1786
|
}
|
|
1907
1787
|
}
|
|
1908
1788
|
}
|
|
@@ -1910,11 +1790,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1910
1790
|
else {
|
|
1911
1791
|
setHistory([]);
|
|
1912
1792
|
await translateAndSpeak(dialogState, userLang);
|
|
1793
|
+
setClickedStart(false);
|
|
1913
1794
|
}
|
|
1914
1795
|
}, [memoriPwd, memori, memoriTokens, birthDate, sessionId, userLang, position]);
|
|
1915
1796
|
(0, react_1.useEffect)(() => {
|
|
1916
1797
|
if (!clickedStart &&
|
|
1917
1798
|
!sessionStartingRef.current &&
|
|
1799
|
+
!sessionId &&
|
|
1918
1800
|
autoStart &&
|
|
1919
1801
|
selectedLayout !== 'HIDDEN_CHAT') {
|
|
1920
1802
|
onClickStart();
|
|
@@ -1960,12 +1842,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1960
1842
|
if (resp.resultCode === 0) {
|
|
1961
1843
|
setExperts(experts);
|
|
1962
1844
|
}
|
|
1963
|
-
else {
|
|
1964
|
-
console.warn('Error fetching experts', resp);
|
|
1965
|
-
}
|
|
1966
1845
|
}
|
|
1967
|
-
catch (
|
|
1968
|
-
console.warn(err);
|
|
1846
|
+
catch (_a) {
|
|
1969
1847
|
}
|
|
1970
1848
|
}, [sessionId, memori === null || memori === void 0 ? void 0 : memori.enableBoardOfExperts]);
|
|
1971
1849
|
(0, react_1.useEffect)(() => {
|
|
@@ -1986,7 +1864,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1986
1864
|
if (!(tenant === null || tenant === void 0 ? void 0 : tenant.billingDelegation))
|
|
1987
1865
|
return true;
|
|
1988
1866
|
if (!ownerUserID && !ownerUserName) {
|
|
1989
|
-
console.warn('Cannot verify credits: missing owner identifier');
|
|
1990
1867
|
if (options === null || options === void 0 ? void 0 : options.notify) {
|
|
1991
1868
|
handleNotEnoughCredits();
|
|
1992
1869
|
}
|
|
@@ -2010,7 +1887,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2010
1887
|
return true;
|
|
2011
1888
|
}
|
|
2012
1889
|
else {
|
|
2013
|
-
console.warn('Not enough credits. Required:', resp.required);
|
|
2014
1890
|
if (options === null || options === void 0 ? void 0 : options.notify) {
|
|
2015
1891
|
handleNotEnoughCredits();
|
|
2016
1892
|
}
|
|
@@ -2020,9 +1896,8 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
2020
1896
|
return false;
|
|
2021
1897
|
}
|
|
2022
1898
|
}
|
|
2023
|
-
catch (
|
|
2024
|
-
|
|
2025
|
-
console.debug(err);
|
|
1899
|
+
catch (err) {
|
|
1900
|
+
logWidgetError('checkCredits failed', err);
|
|
2026
1901
|
return true;
|
|
2027
1902
|
}
|
|
2028
1903
|
}, [
|