@bytexbyte/nxtlinq-ai-agent-sdk 1.5.9 → 1.6.1
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/dist/components/ChatBot.d.ts.map +1 -1
- package/dist/components/ChatBot.js +0 -1
- package/dist/components/context/ChatBotContext.d.ts.map +1 -1
- package/dist/components/context/ChatBotContext.js +42 -82
- package/dist/components/ui/BerifyMeModal.d.ts +1 -0
- package/dist/components/ui/BerifyMeModal.d.ts.map +1 -1
- package/dist/components/ui/BerifyMeModal.js +8 -10
- package/dist/components/ui/ChatBotUI.d.ts +1 -0
- package/dist/components/ui/ChatBotUI.d.ts.map +1 -1
- package/dist/components/ui/ChatBotUI.js +58 -222
- package/dist/components/ui/MessageInput.d.ts.map +1 -1
- package/dist/components/ui/MessageInput.js +41 -38
- package/dist/components/ui/MessageList.d.ts +1 -0
- package/dist/components/ui/MessageList.d.ts.map +1 -1
- package/dist/components/ui/MessageList.js +16 -79
- package/dist/components/ui/ModelSelector.d.ts +1 -0
- package/dist/components/ui/ModelSelector.d.ts.map +1 -1
- package/dist/components/ui/ModelSelector.js +51 -45
- package/dist/components/ui/NotificationModal.d.ts +1 -0
- package/dist/components/ui/NotificationModal.d.ts.map +1 -1
- package/dist/components/ui/NotificationModal.js +48 -74
- package/dist/components/ui/PermissionForm.d.ts +1 -1
- package/dist/components/ui/PermissionForm.d.ts.map +1 -1
- package/dist/components/ui/PermissionForm.js +302 -293
- package/dist/components/ui/PresetMessages.d.ts +1 -0
- package/dist/components/ui/PresetMessages.d.ts.map +1 -1
- package/dist/components/ui/PresetMessages.js +26 -27
- package/dist/components/ui/styles/isolatedStyles.d.ts +34 -0
- package/dist/components/ui/styles/isolatedStyles.d.ts.map +1 -0
- package/dist/components/ui/styles/isolatedStyles.js +449 -0
- package/dist/core/lib/useSpeechToTextFromMic/helper.d.ts.map +1 -1
- package/dist/core/lib/useSpeechToTextFromMic/helper.js +0 -4
- package/dist/core/lib/useSpeechToTextFromMic/index.js +1 -1
- package/dist/core/metakeepClient.d.ts.map +1 -1
- package/dist/core/metakeepClient.js +0 -1
- package/package.json +1 -1
- package/umd/nxtlinq-ai-agent.umd.js +882 -19
|
@@ -1,53 +1,36 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
2
3
|
import * as React from 'react';
|
|
4
|
+
import { css } from '@emotion/react';
|
|
3
5
|
import { useChatBot } from '../context/ChatBotContext';
|
|
4
6
|
import { PermissionForm } from './PermissionForm';
|
|
5
7
|
import { MessageList } from './MessageList';
|
|
6
8
|
import { MessageInput } from './MessageInput';
|
|
7
9
|
import { PresetMessages } from './PresetMessages';
|
|
8
10
|
import { ModelSelector } from './ModelSelector';
|
|
11
|
+
import { sdkContainer, floatingButton, chatWindow, chatHeader, headerTitle, headerButton, closeButton, modalOverlay, idvBanner, idvBannerTitle, idvBannerText, idvVerifyButton, idvDismissButton, loadingSpinner, successToast, errorToast, warningToast, infoToast, toastCloseButton } from './styles/isolatedStyles';
|
|
9
12
|
// Toast Notification Component
|
|
10
13
|
const ToastNotification = ({ type, message, onClose, isChatOpen = false }) => {
|
|
11
|
-
const
|
|
12
|
-
const baseStyles =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
gap: '12px',
|
|
23
|
-
minWidth: '300px',
|
|
24
|
-
maxWidth: '500px'
|
|
25
|
-
};
|
|
26
|
-
// Dynamically adjust position based on chat window state
|
|
27
|
-
if (isChatOpen) {
|
|
28
|
-
// When chat window is open, show notification above the chat window
|
|
29
|
-
Object.assign(baseStyles, {
|
|
30
|
-
top: 20,
|
|
31
|
-
right: 20, // Align with the right edge of chat window
|
|
32
|
-
maxWidth: '480px', // Slightly smaller than chat window width
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
// When chat window is closed, show notification in bottom right corner
|
|
37
|
-
Object.assign(baseStyles, {
|
|
38
|
-
bottom: 20,
|
|
39
|
-
right: 20,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
14
|
+
const getToastStyles = () => {
|
|
15
|
+
const baseStyles = css `
|
|
16
|
+
${isChatOpen ? css `
|
|
17
|
+
top: 20px !important;
|
|
18
|
+
right: 20px !important;
|
|
19
|
+
max-width: 480px !important;
|
|
20
|
+
` : css `
|
|
21
|
+
bottom: 20px !important;
|
|
22
|
+
right: 20px !important;
|
|
23
|
+
`}
|
|
24
|
+
`;
|
|
42
25
|
switch (type) {
|
|
43
26
|
case 'success':
|
|
44
|
-
return {
|
|
27
|
+
return css `${successToast} ${baseStyles}`;
|
|
45
28
|
case 'error':
|
|
46
|
-
return {
|
|
29
|
+
return css `${errorToast} ${baseStyles}`;
|
|
47
30
|
case 'warning':
|
|
48
|
-
return {
|
|
31
|
+
return css `${warningToast} ${baseStyles}`;
|
|
49
32
|
default:
|
|
50
|
-
return {
|
|
33
|
+
return css `${infoToast} ${baseStyles}`;
|
|
51
34
|
}
|
|
52
35
|
};
|
|
53
36
|
const getIcon = () => {
|
|
@@ -62,19 +45,7 @@ const ToastNotification = ({ type, message, onClose, isChatOpen = false }) => {
|
|
|
62
45
|
return 'ℹ️';
|
|
63
46
|
}
|
|
64
47
|
};
|
|
65
|
-
return (_jsxs("div", {
|
|
66
|
-
background: 'none',
|
|
67
|
-
border: 'none',
|
|
68
|
-
color: 'white',
|
|
69
|
-
fontSize: '18px',
|
|
70
|
-
cursor: 'pointer',
|
|
71
|
-
padding: '4px',
|
|
72
|
-
display: 'flex',
|
|
73
|
-
alignItems: 'center',
|
|
74
|
-
justifyContent: 'center',
|
|
75
|
-
borderRadius: '4px',
|
|
76
|
-
transition: 'background-color 0.2s'
|
|
77
|
-
}, onMouseOver: (e) => e.currentTarget.style.backgroundColor = 'rgba(255, 255, 255, 0.2)', onMouseOut: (e) => e.currentTarget.style.backgroundColor = 'transparent', children: "\u00D7" })] }));
|
|
48
|
+
return (_jsxs("div", { css: getToastStyles(), children: [_jsx("span", { css: css `font-size: 18px !important;`, children: getIcon() }), _jsx("span", { css: css `flex: 1 !important;`, children: message }), _jsx("button", { onClick: onClose, css: toastCloseButton, children: "\u00D7" })] }));
|
|
78
49
|
};
|
|
79
50
|
export const ChatBotUI = () => {
|
|
80
51
|
const { isOpen, setIsOpen, showPermissionForm, setShowPermissionForm, notification, setNotification, isAITLoading, hitAddress, walletInfo, onVerifyWallet, props } = useChatBot();
|
|
@@ -89,16 +60,13 @@ export const ChatBotUI = () => {
|
|
|
89
60
|
const isWalletVerifiedWithBerifyme = walletInfo?.id && walletInfo?.method === 'berifyme';
|
|
90
61
|
// Check if IDV suggestion should be shown
|
|
91
62
|
React.useEffect(() => {
|
|
92
|
-
// Add delay to prevent flashing when wallet info is still loading
|
|
93
63
|
// Only show suggestion when verification is not required and wallet is not verified with berifyme
|
|
94
64
|
const shouldShowBanner = hitAddress &&
|
|
95
65
|
!props.requireWalletIDVVerification &&
|
|
96
66
|
!hasBerifymeToken &&
|
|
97
67
|
!isWalletVerifiedWithBerifyme;
|
|
98
68
|
if (shouldShowBanner) {
|
|
99
|
-
// Wait 1 second to allow wallet info to fully load
|
|
100
69
|
const timer = setTimeout(() => {
|
|
101
|
-
// Re-check conditions after delay
|
|
102
70
|
const shouldShowBannerAfterDelay = hitAddress &&
|
|
103
71
|
!props.requireWalletIDVVerification &&
|
|
104
72
|
!hasBerifymeToken &&
|
|
@@ -110,10 +78,8 @@ export const ChatBotUI = () => {
|
|
|
110
78
|
const now = Date.now();
|
|
111
79
|
const timeLeft = dismissTime - now;
|
|
112
80
|
if (timeLeft > 0) {
|
|
113
|
-
// Still within 24 hours, don't show
|
|
114
81
|
setShowIDVSuggestion(false);
|
|
115
82
|
setDismissUntil(dismissTime);
|
|
116
|
-
// Start countdown timer
|
|
117
83
|
const countdownTimer = setInterval(() => {
|
|
118
84
|
const remaining = dismissTime - Date.now();
|
|
119
85
|
if (remaining > 0) {
|
|
@@ -122,7 +88,6 @@ export const ChatBotUI = () => {
|
|
|
122
88
|
setTimeRemaining(`${hours}h ${minutes}m`);
|
|
123
89
|
}
|
|
124
90
|
else {
|
|
125
|
-
// 24 hours passed, show again
|
|
126
91
|
setShowIDVSuggestion(true);
|
|
127
92
|
setDismissUntil(null);
|
|
128
93
|
setTimeRemaining('');
|
|
@@ -133,7 +98,6 @@ export const ChatBotUI = () => {
|
|
|
133
98
|
return () => clearInterval(countdownTimer);
|
|
134
99
|
}
|
|
135
100
|
else {
|
|
136
|
-
// 24 hours passed, show again
|
|
137
101
|
localStorage.removeItem('idv-suggestion-dismissed');
|
|
138
102
|
setShowIDVSuggestion(true);
|
|
139
103
|
setDismissUntil(null);
|
|
@@ -141,14 +105,12 @@ export const ChatBotUI = () => {
|
|
|
141
105
|
}
|
|
142
106
|
}
|
|
143
107
|
else {
|
|
144
|
-
// Never dismissed, show
|
|
145
108
|
setShowIDVSuggestion(true);
|
|
146
109
|
setDismissUntil(null);
|
|
147
110
|
setTimeRemaining('');
|
|
148
111
|
}
|
|
149
112
|
}
|
|
150
113
|
else {
|
|
151
|
-
console.log('❌ After delay: conditions no longer met, hiding suggestion');
|
|
152
114
|
setShowIDVSuggestion(false);
|
|
153
115
|
setDismissUntil(null);
|
|
154
116
|
setTimeRemaining('');
|
|
@@ -215,177 +177,51 @@ export const ChatBotUI = () => {
|
|
|
215
177
|
};
|
|
216
178
|
// Show floating button when chat is closed
|
|
217
179
|
if (!isOpen) {
|
|
218
|
-
return (_jsxs(
|
|
219
|
-
position: 'fixed',
|
|
220
|
-
bottom: '20px',
|
|
221
|
-
right: '20px',
|
|
222
|
-
backgroundColor: '#007bff',
|
|
223
|
-
color: 'white',
|
|
224
|
-
border: 'none',
|
|
225
|
-
padding: '10px 20px',
|
|
226
|
-
borderRadius: '20px',
|
|
227
|
-
cursor: 'pointer',
|
|
228
|
-
boxShadow: '0 2px 5px rgba(0,0,0,0.2)',
|
|
229
|
-
transition: 'all 0.3s ease',
|
|
230
|
-
zIndex: 1000,
|
|
231
|
-
fontSize: '14px',
|
|
232
|
-
fontWeight: '500'
|
|
233
|
-
}, onMouseOver: (e) => {
|
|
234
|
-
e.currentTarget.style.backgroundColor = '#0056b3';
|
|
235
|
-
e.currentTarget.style.transform = 'translateY(-2px)';
|
|
236
|
-
}, onMouseOut: (e) => {
|
|
237
|
-
e.currentTarget.style.backgroundColor = '#007bff';
|
|
238
|
-
e.currentTarget.style.transform = 'translateY(0)';
|
|
239
|
-
}, title: "Open AI Agent Chat", children: "AI Agent" }), notification.show && (_jsx(ToastNotification, { type: notification.type, message: notification.message, onClose: handleCloseNotification, isChatOpen: isOpen }))] }));
|
|
180
|
+
return (_jsxs("div", { css: sdkContainer, children: [_jsx("button", { onClick: handleOpen, css: floatingButton, title: "Open AI Agent Chat", children: "AI Agent" }), notification.show && (_jsx(ToastNotification, { type: notification.type, message: notification.message, onClose: handleCloseNotification, isChatOpen: isOpen }))] }));
|
|
240
181
|
}
|
|
241
|
-
return (_jsxs(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
fontSize: '16px',
|
|
269
|
-
fontWeight: '600'
|
|
270
|
-
}, children: "AI Agent" }), _jsx("div", { style: { position: 'relative' }, children: _jsx(ModelSelector, {}) }), isAITLoading && (_jsxs("div", { style: {
|
|
271
|
-
display: 'flex',
|
|
272
|
-
alignItems: 'center',
|
|
273
|
-
gap: '5px',
|
|
274
|
-
fontSize: '12px',
|
|
275
|
-
opacity: '0.8'
|
|
276
|
-
}, children: [_jsx("div", { style: {
|
|
277
|
-
width: '12px',
|
|
278
|
-
height: '12px',
|
|
279
|
-
border: '2px solid rgba(255, 255, 255, 0.3)',
|
|
280
|
-
borderTop: '2px solid white',
|
|
281
|
-
borderRadius: '50%',
|
|
282
|
-
animation: 'spin 1s linear infinite'
|
|
283
|
-
} }), "Loading..."] }))] }), _jsxs("div", { style: {
|
|
284
|
-
display: 'flex',
|
|
285
|
-
alignItems: 'center',
|
|
286
|
-
gap: '10px'
|
|
287
|
-
}, children: [_jsx("button", { onClick: handleSettingsClick, style: {
|
|
288
|
-
background: 'none',
|
|
289
|
-
border: 'none',
|
|
290
|
-
color: 'white',
|
|
291
|
-
fontSize: '16px',
|
|
292
|
-
cursor: 'pointer',
|
|
293
|
-
padding: '4px',
|
|
294
|
-
display: 'flex',
|
|
295
|
-
alignItems: 'center',
|
|
296
|
-
justifyContent: 'center',
|
|
297
|
-
borderRadius: '4px',
|
|
298
|
-
transition: 'background-color 0.2s'
|
|
299
|
-
}, onMouseOver: (e) => e.currentTarget.style.backgroundColor = 'rgba(255, 255, 255, 0.2)', onMouseOut: (e) => e.currentTarget.style.backgroundColor = 'transparent', title: "AIT Settings", children: "\u2699\uFE0F" }), _jsx("button", { onClick: handleClose, style: {
|
|
300
|
-
background: 'none',
|
|
301
|
-
border: 'none',
|
|
302
|
-
color: 'white',
|
|
303
|
-
fontSize: '24px',
|
|
304
|
-
cursor: 'pointer',
|
|
305
|
-
padding: '0',
|
|
306
|
-
display: 'flex',
|
|
307
|
-
alignItems: 'center',
|
|
308
|
-
justifyContent: 'center'
|
|
309
|
-
}, children: "\u00D7" })] })] }), showIDVSuggestion && hitAddress && !props.requireWalletIDVVerification && !hasBerifymeToken && !isWalletVerifiedWithBerifyme && (_jsxs("div", { "data-idv-banner": true, style: {
|
|
310
|
-
backgroundColor: '#fff3cd',
|
|
311
|
-
border: '1px solid #ffeaa7',
|
|
312
|
-
borderLeft: '4px solid #f39c12',
|
|
313
|
-
margin: '16px',
|
|
314
|
-
padding: '16px',
|
|
315
|
-
borderRadius: '8px',
|
|
316
|
-
display: 'flex',
|
|
317
|
-
alignItems: 'center',
|
|
318
|
-
gap: '12px'
|
|
319
|
-
}, children: [_jsx("div", { style: {
|
|
320
|
-
fontSize: '20px',
|
|
321
|
-
color: '#f39c12'
|
|
322
|
-
}, children: "\uD83D\uDCA1" }), _jsxs("div", { style: { flex: 1 }, children: [_jsx("h5", { style: {
|
|
323
|
-
margin: '0 0 8px 0',
|
|
324
|
-
fontSize: '14px',
|
|
325
|
-
fontWeight: '600',
|
|
326
|
-
color: '#856404'
|
|
327
|
-
}, children: "Recommended: Verify Your Wallet" }), _jsx("p", { style: {
|
|
328
|
-
margin: '0 0 12px 0',
|
|
329
|
-
fontSize: '13px',
|
|
330
|
-
color: '#856404',
|
|
331
|
-
lineHeight: '1.4'
|
|
332
|
-
}, children: "While not required, verifying your wallet with Berify.me provides additional security and trust for your AI agent interactions." }), _jsx("button", { onClick: () => onVerifyWallet('berifyme'), style: {
|
|
333
|
-
padding: '8px 16px',
|
|
334
|
-
backgroundColor: '#f39c12',
|
|
335
|
-
color: 'white',
|
|
336
|
-
border: 'none',
|
|
337
|
-
borderRadius: '6px',
|
|
338
|
-
cursor: 'pointer',
|
|
339
|
-
fontSize: '13px',
|
|
340
|
-
fontWeight: '500',
|
|
341
|
-
transition: 'background-color 0.2s'
|
|
342
|
-
}, onMouseOver: (e) => e.currentTarget.style.backgroundColor = '#e67e22', onMouseOut: (e) => e.currentTarget.style.backgroundColor = '#f39c12', children: "Verify Wallet" })] }), _jsx("button", { onClick: handleDismissIDV, style: {
|
|
343
|
-
background: 'none',
|
|
344
|
-
border: 'none',
|
|
345
|
-
color: '#856404',
|
|
346
|
-
fontSize: '18px',
|
|
347
|
-
cursor: 'pointer',
|
|
348
|
-
padding: '4px',
|
|
349
|
-
borderRadius: '4px',
|
|
350
|
-
transition: 'background-color 0.2s'
|
|
351
|
-
}, onMouseOver: (e) => e.currentTarget.style.backgroundColor = 'rgba(133, 100, 4, 0.1)', onMouseOut: (e) => e.currentTarget.style.backgroundColor = 'transparent', title: `Hide for ${Math.floor((props.idvBannerDismissSeconds || 86400) / 3600)} hours`, children: "\u00D7" })] })), !showIDVSuggestion && dismissUntil && timeRemaining && (_jsxs("div", { style: {
|
|
352
|
-
backgroundColor: '#f8f9fa',
|
|
353
|
-
border: '1px solid #e9ecef',
|
|
354
|
-
margin: '16px',
|
|
355
|
-
padding: '12px',
|
|
356
|
-
borderRadius: '8px',
|
|
357
|
-
textAlign: 'center',
|
|
358
|
-
fontSize: '13px',
|
|
359
|
-
color: '#6c757d'
|
|
360
|
-
}, children: [_jsxs("span", { children: ["\uD83D\uDCA1 IDV suggestion hidden. Will show again in ", timeRemaining] }), _jsx("button", { onClick: () => {
|
|
182
|
+
return (_jsxs("div", { css: sdkContainer, children: [_jsxs("div", { css: chatWindow, children: [_jsxs("div", { css: chatHeader, children: [_jsxs("div", { css: css `
|
|
183
|
+
display: flex !important;
|
|
184
|
+
align-items: center !important;
|
|
185
|
+
gap: 10px !important;
|
|
186
|
+
`, children: [_jsx("h3", { css: headerTitle, children: "AI Agent" }), _jsx("div", { css: css `position: relative !important;`, children: _jsx(ModelSelector, {}) }), isAITLoading && (_jsxs("div", { css: css `
|
|
187
|
+
display: flex !important;
|
|
188
|
+
align-items: center !important;
|
|
189
|
+
gap: 5px !important;
|
|
190
|
+
font-size: 12px !important;
|
|
191
|
+
opacity: 0.8 !important;
|
|
192
|
+
`, children: [_jsx("div", { css: loadingSpinner }), "Loading..."] }))] }), _jsxs("div", { css: css `
|
|
193
|
+
display: flex !important;
|
|
194
|
+
align-items: center !important;
|
|
195
|
+
gap: 10px !important;
|
|
196
|
+
`, children: [_jsx("button", { onClick: handleSettingsClick, css: headerButton, title: "AIT Settings", children: "\u2699\uFE0F" }), _jsx("button", { onClick: handleClose, css: closeButton, children: "\u00D7" })] })] }), showIDVSuggestion && hitAddress && !props.requireWalletIDVVerification && !hasBerifymeToken && !isWalletVerifiedWithBerifyme && (_jsxs("div", { "data-idv-banner": true, css: idvBanner, children: [_jsx("div", { css: css `
|
|
197
|
+
font-size: 20px !important;
|
|
198
|
+
color: #f39c12 !important;
|
|
199
|
+
`, children: "\uD83D\uDCA1" }), _jsxs("div", { css: css `flex: 1 !important;`, children: [_jsx("h5", { css: idvBannerTitle, children: "Recommended: Verify Your Wallet" }), _jsx("p", { css: idvBannerText, children: "While not required, verifying your wallet with Berify.me provides additional security and trust for your AI agent interactions." }), _jsx("button", { onClick: () => onVerifyWallet('berifyme'), css: idvVerifyButton, children: "Verify Wallet" })] }), _jsx("button", { onClick: handleDismissIDV, css: idvDismissButton, title: `Hide for ${Math.floor((props.idvBannerDismissSeconds || 86400) / 3600)} hours`, children: "\u00D7" })] })), !showIDVSuggestion && dismissUntil && timeRemaining && (_jsxs("div", { css: css `
|
|
200
|
+
background-color: #f8f9fa !important;
|
|
201
|
+
border: 1px solid #e9ecef !important;
|
|
202
|
+
margin: 16px !important;
|
|
203
|
+
padding: 12px !important;
|
|
204
|
+
border-radius: 8px !important;
|
|
205
|
+
text-align: center !important;
|
|
206
|
+
font-size: 13px !important;
|
|
207
|
+
color: #6c757d !important;
|
|
208
|
+
`, children: [_jsxs("span", { children: ["\uD83D\uDCA1 IDV suggestion hidden. Will show again in ", timeRemaining] }), _jsx("button", { onClick: () => {
|
|
361
209
|
localStorage.removeItem('idv-suggestion-dismissed');
|
|
362
210
|
setShowIDVSuggestion(true);
|
|
363
211
|
setDismissUntil(null);
|
|
364
212
|
setTimeRemaining('');
|
|
365
|
-
},
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
position: 'fixed',
|
|
375
|
-
top: 0,
|
|
376
|
-
left: 0,
|
|
377
|
-
right: 0,
|
|
378
|
-
bottom: 0,
|
|
379
|
-
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
380
|
-
display: 'flex',
|
|
381
|
-
alignItems: 'center',
|
|
382
|
-
justifyContent: 'center',
|
|
383
|
-
zIndex: 1002,
|
|
384
|
-
padding: '20px'
|
|
385
|
-
}, onClick: (e) => {
|
|
213
|
+
}, css: css `
|
|
214
|
+
background: none !important;
|
|
215
|
+
border: none !important;
|
|
216
|
+
color: #007bff !important;
|
|
217
|
+
font-size: 12px !important;
|
|
218
|
+
cursor: pointer !important;
|
|
219
|
+
margin-left: 8px !important;
|
|
220
|
+
text-decoration: underline !important;
|
|
221
|
+
`, title: "Show now", children: "Show now" })] })), _jsx(MessageList, {}), _jsx(PresetMessages, {}), _jsx(MessageInput, {})] }), showPermissionForm && (_jsx("div", { css: modalOverlay, onClick: (e) => {
|
|
386
222
|
// Close modal when clicking on background
|
|
387
223
|
if (e.target === e.currentTarget) {
|
|
388
224
|
setShowPermissionForm(false);
|
|
389
225
|
}
|
|
390
|
-
}, children: _jsx(PermissionForm, { onClose: () => setShowPermissionForm(false)
|
|
226
|
+
}, children: _jsx(PermissionForm, { onClose: () => setShowPermissionForm(false) }) })), notification.show && (_jsx(ToastNotification, { type: notification.type, message: notification.message, onClose: handleCloseNotification, isChatOpen: isOpen }))] }));
|
|
391
227
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageInput.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MessageInput.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageInput.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAiGhC,CAAC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
2
3
|
import MicIcon from '@mui/icons-material/Mic';
|
|
3
4
|
import MicOffIcon from '@mui/icons-material/MicOff';
|
|
4
5
|
import { IconButton, InputBase } from '@mui/material';
|
|
6
|
+
import { css } from '@emotion/react';
|
|
5
7
|
import { useChatBot } from '../context/ChatBotContext';
|
|
8
|
+
import { actionButton } from './styles/isolatedStyles';
|
|
6
9
|
export const MessageInput = () => {
|
|
7
10
|
const { inputValue, setInputValue, isLoading, isAITLoading, handleSubmit, isRecording, startRecording, stopRecording, textInputRef, props: { placeholder = 'Type a message...' } } = useChatBot();
|
|
8
11
|
const isDisabled = isLoading || isAITLoading;
|
|
@@ -13,42 +16,42 @@ export const MessageInput = () => {
|
|
|
13
16
|
handleSubmit(e);
|
|
14
17
|
}
|
|
15
18
|
};
|
|
16
|
-
return (_jsxs("div", {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
return (_jsxs("div", { css: css `
|
|
20
|
+
padding: 15px !important;
|
|
21
|
+
display: flex !important;
|
|
22
|
+
gap: 10px !important;
|
|
23
|
+
border-top: 1px solid #eee !important;
|
|
24
|
+
`, children: [_jsx(InputBase, { value: inputValue, onChange: (e) => setInputValue(e.target.value), onKeyPress: handleKeyPress, placeholder: inputPlaceholder, disabled: isDisabled, fullWidth: true, inputProps: {
|
|
22
25
|
ref: textInputRef
|
|
23
|
-
}, endAdornment: _jsx(IconButton, { onClick: () => isRecording ? stopRecording() : startRecording(), disabled: isDisabled, children: isRecording ? _jsx(MicIcon, {}) : _jsx(MicOffIcon, {}) }), onFocus: () => stopRecording(),
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
26
|
+
}, endAdornment: _jsx(IconButton, { onClick: () => isRecording ? stopRecording() : startRecording(), disabled: isDisabled, children: isRecording ? _jsx(MicIcon, {}) : _jsx(MicOffIcon, {}) }), onFocus: () => stopRecording(), css: css `
|
|
27
|
+
flex: 1 !important;
|
|
28
|
+
padding: 10px !important;
|
|
29
|
+
border: 1px solid #ddd !important;
|
|
30
|
+
border-radius: 20px !important;
|
|
31
|
+
outline: none !important;
|
|
32
|
+
font-size: 14px !important;
|
|
33
|
+
background-color: ${isDisabled ? '#f8f9fa' : '#fff'} !important;
|
|
34
|
+
` }), _jsxs("button", { onClick: (e) => handleSubmit(e), disabled: isDisabled || !inputValue.trim(), css: css `
|
|
35
|
+
${actionButton}
|
|
36
|
+
padding: 10px 20px !important;
|
|
37
|
+
border-radius: 20px !important;
|
|
38
|
+
position: relative !important;
|
|
39
|
+
display: flex !important;
|
|
40
|
+
align-items: center !important;
|
|
41
|
+
justify-content: center !important;
|
|
42
|
+
|
|
43
|
+
&:disabled {
|
|
44
|
+
background-color: #e9ecef !important;
|
|
45
|
+
color: #6c757d !important;
|
|
46
|
+
cursor: not-allowed !important;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&:hover:not(:disabled) {
|
|
50
|
+
background-color: #0056b3 !important;
|
|
51
|
+
}
|
|
52
|
+
`, children: ["Send", (isLoading || isAITLoading) && (_jsx("span", { css: css `
|
|
53
|
+
margin-left: 8px !important;
|
|
54
|
+
display: flex !important;
|
|
55
|
+
align-items: center !important;
|
|
56
|
+
`, children: _jsx("svg", { width: "16", height: "16", viewBox: "0 0 50 50", children: _jsx("circle", { cx: "25", cy: "25", r: "20", fill: "none", stroke: "#fff", strokeWidth: "4", strokeDasharray: "31.4 31.4", strokeLinecap: "round", children: _jsx("animateTransform", { attributeName: "transform", type: "rotate", from: "0 25 25", to: "360 25 25", dur: "1s", repeatCount: "indefinite" }) }) }) }))] })] }));
|
|
54
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageList.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAqB/B,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAiI/B,CAAC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
2
3
|
import * as React from 'react';
|
|
4
|
+
import { css } from '@emotion/react';
|
|
3
5
|
import { convertUrlsToLinks } from '../../core/utils/urlUtils';
|
|
4
6
|
import { useChatBot } from '../context/ChatBotContext';
|
|
5
7
|
import { AI_MODEL_MAP } from '../types/ChatBotTypes';
|
|
8
|
+
import { messageListContainer, messageBubble, userMessage, messageContent, userMessageContent, retryMessageContent, actionButton, connectedButton, loadingIndicator, modelIndicator, modelBadge, modelDot } from './styles/isolatedStyles';
|
|
6
9
|
export const MessageList = () => {
|
|
7
|
-
const { messages, isLoading, connectWallet, signInWallet, hitAddress,
|
|
10
|
+
const { messages, isLoading, connectWallet, signInWallet, hitAddress, isAutoConnecting, isNeedSignInWithWallet, enableAIT, isAITLoading, isAITEnabling, sendMessage, permissions } = useChatBot();
|
|
8
11
|
const messagesEndRef = React.useRef(null);
|
|
9
12
|
const scrollToBottom = () => {
|
|
10
13
|
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
|
@@ -46,28 +49,11 @@ export const MessageList = () => {
|
|
|
46
49
|
return '';
|
|
47
50
|
return AI_MODEL_MAP[modelValue] || modelValue;
|
|
48
51
|
};
|
|
49
|
-
return (_jsxs("div", {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
flexDirection: 'column',
|
|
55
|
-
gap: '10px'
|
|
56
|
-
}, children: [messages.map((message) => (_jsxs("div", { style: {
|
|
57
|
-
alignSelf: message.role === 'user' ? 'flex-end' : 'flex-start',
|
|
58
|
-
maxWidth: '80%',
|
|
59
|
-
marginBottom: '10px'
|
|
60
|
-
}, children: [_jsxs("div", { style: {
|
|
61
|
-
backgroundColor: message.role === 'user' ? '#007bff' :
|
|
62
|
-
message.metadata?.isRetry ? '#fff3cd' : '#f1f1f1',
|
|
63
|
-
color: message.role === 'user' ? 'white' :
|
|
64
|
-
message.metadata?.isRetry ? '#856404' : '#333',
|
|
65
|
-
padding: '10px 15px',
|
|
66
|
-
borderRadius: '15px',
|
|
67
|
-
wordWrap: 'break-word',
|
|
68
|
-
position: 'relative',
|
|
69
|
-
border: message.metadata?.isRetry ? '1px solid #ffeaa7' : 'none'
|
|
70
|
-
}, children: [message.metadata?.isRetry && (_jsx("span", { style: { marginRight: '8px', fontSize: '14px' }, children: "\uD83D\uDD04" })), message.role === 'assistant' ? convertUrlsToLinks(message.content) : message.content, message.button && (_jsx("div", { style: { marginTop: '10px' }, children: _jsx("button", { onClick: () => {
|
|
52
|
+
return (_jsxs("div", { css: messageListContainer, children: [messages.map((message) => (_jsxs("div", { css: message.role === 'user' ? userMessage : messageBubble, children: [_jsxs("div", { css: message.role === 'user'
|
|
53
|
+
? userMessageContent
|
|
54
|
+
: message.metadata?.isRetry
|
|
55
|
+
? retryMessageContent
|
|
56
|
+
: messageContent, children: [message.metadata?.isRetry && (_jsx("span", { css: css `margin-right: 8px !important; font-size: 14px !important;`, children: "\uD83D\uDD04" })), message.role === 'assistant' ? convertUrlsToLinks(message.content) : message.content, message.button && (_jsx("div", { css: css `margin-top: 10px !important;`, children: _jsx("button", { onClick: () => {
|
|
71
57
|
if (message.button && message.button.trim()) {
|
|
72
58
|
handleButtonClick(message.button, message);
|
|
73
59
|
}
|
|
@@ -75,65 +61,16 @@ export const MessageList = () => {
|
|
|
75
61
|
(message.button === 'connectWallet' && Boolean(hitAddress)) ||
|
|
76
62
|
(message.button === 'signIn' && !isNeedSignInWithWallet) ||
|
|
77
63
|
(message.button === 'enableAIT' && (isAITLoading || isAITEnabling ||
|
|
78
|
-
(message.metadata?.toolName && permissions.includes(message.metadata.toolName)))) || false,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
(message.button === 'signIn' && !isNeedSignInWithWallet) ? '#28a745' :
|
|
84
|
-
(message.button === 'continue') ? '#28a745' :
|
|
85
|
-
(message.button === 'enableAIT' && (isAITLoading || isAITEnabling ||
|
|
86
|
-
(message.metadata?.toolName && permissions.includes(message.metadata.toolName)))) ?
|
|
87
|
-
((message.metadata?.toolName && permissions.includes(message.metadata.toolName)) ? '#28a745' : '#6c757d') : '#007bff',
|
|
88
|
-
color: message.role === 'user' ? 'white' : 'white',
|
|
89
|
-
border: 'none',
|
|
90
|
-
borderRadius: '5px',
|
|
91
|
-
cursor: (message.button !== 'continue' && (isAutoConnecting ||
|
|
92
|
-
(message.button === 'connectWallet' && Boolean(hitAddress)) ||
|
|
93
|
-
(message.button === 'signIn' && !isNeedSignInWithWallet) ||
|
|
94
|
-
(message.button === 'enableAIT' && (isAITLoading || isAITEnabling ||
|
|
95
|
-
(message.metadata?.toolName && permissions.includes(message.metadata.toolName)))))) ? 'not-allowed' : 'pointer',
|
|
96
|
-
fontSize: '14px',
|
|
97
|
-
opacity: (isAutoConnecting ||
|
|
98
|
-
(message.button === 'connectWallet' && Boolean(hitAddress)) ||
|
|
99
|
-
(message.button === 'signIn' && !isNeedSignInWithWallet) ||
|
|
100
|
-
(message.button === 'enableAIT' && (isAITLoading || isAITEnabling ||
|
|
101
|
-
(message.metadata?.toolName && permissions.includes(message.metadata.toolName))))) ? 0.8 : 1
|
|
102
|
-
}, children: isAutoConnecting ? 'Connecting...' :
|
|
64
|
+
(message.metadata?.toolName && permissions.includes(message.metadata.toolName)))) || false, css: (message.button === 'connectWallet' && Boolean(hitAddress)) ? connectedButton :
|
|
65
|
+
(message.button === 'signIn' && !isNeedSignInWithWallet) ? connectedButton :
|
|
66
|
+
(message.button === 'continue') ? connectedButton :
|
|
67
|
+
(message.button === 'enableAIT' && (message.metadata?.toolName && permissions.includes(message.metadata.toolName))) ? connectedButton :
|
|
68
|
+
actionButton, children: isAutoConnecting ? 'Connecting...' :
|
|
103
69
|
message.button === 'connectWallet' ? (Boolean(hitAddress) ? 'Connected' : 'Connect Wallet') :
|
|
104
70
|
message.button === 'signIn' ? (!isNeedSignInWithWallet ? 'Signed In' : 'Sign In') :
|
|
105
71
|
message.button === 'continue' ? 'Continue' :
|
|
106
72
|
message.button === 'enableAIT' ?
|
|
107
73
|
((isAITLoading || isAITEnabling) ? 'Enabling...' :
|
|
108
74
|
(message.metadata?.toolName && permissions.includes(message.metadata.toolName)) ? 'AIT Enabled' : 'Enable AIT Permissions') :
|
|
109
|
-
message.button }) }))] }), message.role === 'assistant' && message.metadata?.model && (_jsx("div", {
|
|
110
|
-
display: 'flex',
|
|
111
|
-
alignItems: 'center',
|
|
112
|
-
marginTop: '4px',
|
|
113
|
-
marginLeft: '8px'
|
|
114
|
-
}, children: _jsxs("div", { style: {
|
|
115
|
-
backgroundColor: '#e3f2fd',
|
|
116
|
-
color: '#1976d2',
|
|
117
|
-
padding: '2px 8px',
|
|
118
|
-
borderRadius: '10px',
|
|
119
|
-
fontSize: '10px',
|
|
120
|
-
fontWeight: '500',
|
|
121
|
-
border: '1px solid #bbdefb',
|
|
122
|
-
display: 'flex',
|
|
123
|
-
alignItems: 'center',
|
|
124
|
-
gap: '4px'
|
|
125
|
-
}, children: [_jsx("span", { style: {
|
|
126
|
-
width: '6px',
|
|
127
|
-
height: '6px',
|
|
128
|
-
backgroundColor: '#1976d2',
|
|
129
|
-
borderRadius: '50%',
|
|
130
|
-
display: 'inline-block'
|
|
131
|
-
} }), getModelDisplayName(message.metadata.model)] }) }))] }, message.id))), isLoading && (_jsx("div", { style: {
|
|
132
|
-
alignSelf: 'flex-start',
|
|
133
|
-
backgroundColor: '#f1f1f1',
|
|
134
|
-
color: '#333',
|
|
135
|
-
padding: '10px 15px',
|
|
136
|
-
borderRadius: '15px',
|
|
137
|
-
maxWidth: '80%'
|
|
138
|
-
}, children: "Thinking..." })), _jsx("div", { ref: messagesEndRef })] }));
|
|
75
|
+
message.button }) }))] }), message.role === 'assistant' && message.metadata?.model && (_jsx("div", { css: modelIndicator, children: _jsxs("div", { css: modelBadge, children: [_jsx("span", { css: modelDot }), getModelDisplayName(message.metadata.model)] }) }))] }, message.id))), isLoading && (_jsx("div", { css: loadingIndicator, children: "Thinking..." })), _jsx("div", { ref: messagesEndRef })] }));
|
|
139
76
|
};
|