@bytexbyte/nxtlinq-ai-agent-sdk 1.2.2 → 1.2.4

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.
Files changed (48) hide show
  1. package/README.md +282 -200
  2. package/dist/api/nxtlinq-api.d.ts.map +1 -1
  3. package/dist/api/nxtlinq-api.js +127 -142
  4. package/dist/components/ChatBot.d.ts +2 -44
  5. package/dist/components/ChatBot.d.ts.map +1 -1
  6. package/dist/components/ChatBot.js +5 -1241
  7. package/dist/components/context/ChatBotContext.d.ts +5 -0
  8. package/dist/components/context/ChatBotContext.d.ts.map +1 -0
  9. package/dist/components/context/ChatBotContext.js +865 -0
  10. package/dist/components/types/ChatBotTypes.d.ts +115 -0
  11. package/dist/components/types/ChatBotTypes.d.ts.map +1 -0
  12. package/dist/components/types/ChatBotTypes.js +14 -0
  13. package/dist/components/ui/ChatBotUI.d.ts +3 -0
  14. package/dist/components/ui/ChatBotUI.d.ts.map +1 -0
  15. package/dist/components/ui/ChatBotUI.js +147 -0
  16. package/dist/components/ui/MessageInput.d.ts +3 -0
  17. package/dist/components/ui/MessageInput.d.ts.map +1 -0
  18. package/dist/components/ui/MessageInput.js +46 -0
  19. package/dist/components/ui/MessageList.d.ts +3 -0
  20. package/dist/components/ui/MessageList.d.ts.map +1 -0
  21. package/dist/components/ui/MessageList.js +84 -0
  22. package/dist/components/ui/ModelSelector.d.ts +3 -0
  23. package/dist/components/ui/ModelSelector.d.ts.map +1 -0
  24. package/dist/components/ui/ModelSelector.js +65 -0
  25. package/dist/components/ui/NotificationModal.d.ts +14 -0
  26. package/dist/components/ui/NotificationModal.d.ts.map +1 -0
  27. package/dist/components/ui/NotificationModal.js +79 -0
  28. package/dist/components/ui/PermissionForm.d.ts +8 -0
  29. package/dist/components/ui/PermissionForm.d.ts.map +1 -0
  30. package/dist/components/ui/PermissionForm.js +299 -0
  31. package/dist/components/ui/PresetMessages.d.ts +3 -0
  32. package/dist/components/ui/PresetMessages.d.ts.map +1 -0
  33. package/dist/components/ui/PresetMessages.js +35 -0
  34. package/dist/core/utils/aitUtils.d.ts +28 -0
  35. package/dist/core/utils/aitUtils.d.ts.map +1 -0
  36. package/dist/core/utils/aitUtils.js +34 -0
  37. package/dist/core/utils/notificationUtils.d.ts +29 -0
  38. package/dist/core/utils/notificationUtils.d.ts.map +1 -0
  39. package/dist/core/utils/notificationUtils.js +47 -0
  40. package/dist/core/utils/walletUtils.d.ts +10 -0
  41. package/dist/core/utils/walletUtils.d.ts.map +1 -0
  42. package/dist/core/utils/walletUtils.js +38 -0
  43. package/dist/index.d.ts +14 -1
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +18 -0
  46. package/dist/types/ait-api.d.ts +32 -1
  47. package/dist/types/ait-api.d.ts.map +1 -1
  48. package/package.json +1 -1
@@ -0,0 +1,115 @@
1
+ import { Message, AIT, ServicePermission, AITApi } from '../../types/ait-api';
2
+ export interface PresetMessage {
3
+ text: string;
4
+ autoSend?: boolean;
5
+ }
6
+ export interface ToolUse {
7
+ name: string;
8
+ input: Record<string, any>;
9
+ }
10
+ export interface ToolCall {
11
+ toolUse: ToolUse;
12
+ }
13
+ export interface NovaResponse {
14
+ result: string;
15
+ reply: Array<{
16
+ text: string;
17
+ }>;
18
+ toolCall?: ToolCall;
19
+ }
20
+ export interface NovaError {
21
+ error: string;
22
+ }
23
+ export interface AITMetadata {
24
+ model: string;
25
+ permissions: string[];
26
+ issuedBy: string;
27
+ }
28
+ export interface AIModel {
29
+ label: string;
30
+ value: string;
31
+ }
32
+ export declare const DEFAULT_AI_MODELS: AIModel[];
33
+ export declare const AI_MODEL_MAP: Record<string, string>;
34
+ export interface ChatBotProps {
35
+ onMessage?: (message: Message) => void;
36
+ onError?: (error: Error) => void;
37
+ onToolUse?: (toolUse: ToolUse) => Promise<Message | void>;
38
+ presetMessages?: PresetMessage[];
39
+ placeholder?: string;
40
+ className?: string;
41
+ maxRetries?: number;
42
+ retryDelay?: number;
43
+ serviceId: string;
44
+ apiKey: string;
45
+ apiSecret: string;
46
+ onVerifyWallet?: () => Promise<{
47
+ token: string;
48
+ } | undefined>;
49
+ permissionGroup?: string;
50
+ children?: React.ReactNode;
51
+ availableModels?: AIModel[];
52
+ defaultModelIndex?: number;
53
+ showModelSelector?: boolean;
54
+ onModelChange?: (model: AIModel) => void;
55
+ }
56
+ export interface ChatBotContextType {
57
+ messages: Message[];
58
+ inputValue: string;
59
+ isLoading: boolean;
60
+ isOpen: boolean;
61
+ hitAddress: string | null;
62
+ ait: AIT | null;
63
+ permissions: string[];
64
+ availablePermissions: ServicePermission[];
65
+ showPermissionForm: boolean;
66
+ isPermissionFormOpen: boolean;
67
+ isAITLoading: boolean;
68
+ isDisabled: boolean;
69
+ walletInfo: any;
70
+ isWalletLoading: boolean;
71
+ notification: {
72
+ show: boolean;
73
+ type: 'success' | 'error' | 'warning' | 'info';
74
+ message: string;
75
+ autoHide?: boolean;
76
+ duration?: number;
77
+ };
78
+ availableModels: AIModel[];
79
+ selectedModelIndex: number;
80
+ showModelSelector: boolean;
81
+ setInputValue: (value: string) => void;
82
+ setIsOpen: (open: boolean) => void;
83
+ setShowPermissionForm: (show: boolean) => void;
84
+ setIsPermissionFormOpen: (open: boolean) => void;
85
+ setPermissions: (permissions: string[]) => void;
86
+ setIsDisabled: (disabled: boolean) => void;
87
+ setIsWalletLoading: (loading: boolean) => void;
88
+ setNotification: (notification: any) => void;
89
+ setSelectedModelIndex: (index: number) => void;
90
+ setShowModelSelector: (show: boolean) => void;
91
+ connectWallet: (autoShowSignInMessage?: boolean) => Promise<string | undefined>;
92
+ signInWallet: (autoShowSuccessMessage?: boolean) => Promise<void>;
93
+ sendMessage: (content: string, retryCount?: number) => Promise<void>;
94
+ handleSubmit: (e: React.FormEvent) => Promise<void>;
95
+ handlePresetMessage: (message: PresetMessage) => void;
96
+ savePermissions: () => Promise<void>;
97
+ handleVerifyWalletClick: () => Promise<void>;
98
+ showSuccess: (message: string) => void;
99
+ showError: (message: string) => void;
100
+ showWarning: (message: string) => void;
101
+ showInfo: (message: string) => void;
102
+ refreshAIT: (forceUpdatePermissions?: boolean) => Promise<void>;
103
+ handleModelChange: (modelIndex: number) => void;
104
+ getCurrentModel: () => AIModel;
105
+ onSave: () => Promise<void>;
106
+ onConnectWallet: () => Promise<string | undefined>;
107
+ onSignIn: () => Promise<void>;
108
+ isNeedSignInWithWallet: boolean;
109
+ onVerifyWallet: () => Promise<void>;
110
+ serviceId: string;
111
+ permissionGroup?: string;
112
+ props: ChatBotProps;
113
+ nxtlinqApi: AITApi;
114
+ }
115
+ //# sourceMappingURL=ChatBotTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatBotTypes.d.ts","sourceRoot":"","sources":["../../../src/components/types/ChatBotTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE9E,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;C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,CAAC,CAAC;IACnD,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,sBAAsB,EAAE,OAAO,CAAC;IAChC,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,KAAK,EAAE,YAAY,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB"}
@@ -0,0 +1,14 @@
1
+ export const DEFAULT_AI_MODELS = [
2
+ { label: 'Nova', value: 'nova' },
3
+ { label: 'Claude', value: 'claude' },
4
+ { label: 'ChatGPT', value: 'open-ai' },
5
+ { label: 'Llama', value: 'llama' },
6
+ { label: 'Gemini', value: 'gemini' },
7
+ ];
8
+ export const AI_MODEL_MAP = {
9
+ nova: 'Nova',
10
+ claude: 'Claude',
11
+ 'open-ai': 'ChatGPT',
12
+ llama: 'Llama',
13
+ gemini: 'Gemini',
14
+ };
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ export declare const ChatBotUI: React.FC;
3
+ //# sourceMappingURL=ChatBotUI.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatBotUI.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ChatBotUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAsP7B,CAAC"}
@@ -0,0 +1,147 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import { useChatBot } from '../context/ChatBotContext';
4
+ import { NotificationModal } from './NotificationModal';
5
+ import { PermissionForm } from './PermissionForm';
6
+ import { MessageList } from './MessageList';
7
+ import { MessageInput } from './MessageInput';
8
+ import { PresetMessages } from './PresetMessages';
9
+ import { ModelSelector } from './ModelSelector';
10
+ export const ChatBotUI = () => {
11
+ const { isOpen, setIsOpen, showPermissionForm, setShowPermissionForm, notification, setNotification, isAITLoading, props: { className = '' } } = useChatBot();
12
+ // Add CSS animation for loading spinner
13
+ React.useEffect(() => {
14
+ const style = document.createElement('style');
15
+ style.textContent = `
16
+ @keyframes spin {
17
+ 0% { transform: rotate(0deg); }
18
+ 100% { transform: rotate(360deg); }
19
+ }
20
+ `;
21
+ document.head.appendChild(style);
22
+ return () => {
23
+ document.head.removeChild(style);
24
+ };
25
+ }, []);
26
+ const handleClose = () => {
27
+ setIsOpen(false);
28
+ };
29
+ const handleOpen = () => {
30
+ setIsOpen(true);
31
+ };
32
+ const handleCloseNotification = () => {
33
+ setNotification((prev) => ({ ...prev, show: false }));
34
+ };
35
+ const handleSettingsClick = () => {
36
+ setShowPermissionForm(true);
37
+ };
38
+ // Show floating button when chat is closed
39
+ if (!isOpen) {
40
+ return (_jsxs(_Fragment, { children: [_jsx("button", { onClick: handleOpen, style: {
41
+ position: 'fixed',
42
+ bottom: '20px',
43
+ right: '20px',
44
+ backgroundColor: '#007bff',
45
+ color: 'white',
46
+ border: 'none',
47
+ padding: '10px 20px',
48
+ borderRadius: '20px',
49
+ cursor: 'pointer',
50
+ boxShadow: '0 2px 5px rgba(0,0,0,0.2)',
51
+ transition: 'all 0.3s ease',
52
+ zIndex: 1000,
53
+ fontSize: '14px',
54
+ fontWeight: '500'
55
+ }, onMouseOver: (e) => {
56
+ e.currentTarget.style.backgroundColor = '#0056b3';
57
+ e.currentTarget.style.transform = 'translateY(-2px)';
58
+ }, onMouseOut: (e) => {
59
+ e.currentTarget.style.backgroundColor = '#007bff';
60
+ e.currentTarget.style.transform = 'translateY(0)';
61
+ }, title: "Open AI Agent Chat", children: "AI Agent" }), notification.show && (_jsx(NotificationModal, { type: notification.type, title: notification.type === 'success' ? 'Success' :
62
+ notification.type === 'error' ? 'Error' :
63
+ notification.type === 'warning' ? 'Warning' : 'Info', message: notification.message, onClose: handleCloseNotification }))] }));
64
+ }
65
+ return (_jsxs(_Fragment, { children: [_jsxs("div", { style: {
66
+ position: 'fixed',
67
+ bottom: '20px',
68
+ right: '20px',
69
+ width: '500px',
70
+ height: '600px',
71
+ backgroundColor: 'white',
72
+ borderRadius: '10px',
73
+ boxShadow: '0 5px 15px rgba(0,0,0,0.2)',
74
+ display: 'flex',
75
+ flexDirection: 'column',
76
+ zIndex: 1001,
77
+ overflow: 'hidden'
78
+ }, className: className, children: [_jsxs("div", { style: {
79
+ padding: '15px',
80
+ backgroundColor: '#007bff',
81
+ color: 'white',
82
+ borderRadius: '10px 10px 0 0',
83
+ display: 'flex',
84
+ justifyContent: 'space-between',
85
+ alignItems: 'center'
86
+ }, children: [_jsxs("div", { style: {
87
+ display: 'flex',
88
+ alignItems: 'center',
89
+ gap: '10px'
90
+ }, children: [_jsx("h3", { style: {
91
+ margin: 0,
92
+ fontSize: '16px',
93
+ fontWeight: '600'
94
+ }, children: "AI Agent" }), _jsx("div", { style: { position: 'relative' }, children: _jsx(ModelSelector, {}) }), isAITLoading && (_jsxs("div", { style: {
95
+ display: 'flex',
96
+ alignItems: 'center',
97
+ gap: '5px',
98
+ fontSize: '12px',
99
+ opacity: '0.8'
100
+ }, children: [_jsx("div", { style: {
101
+ width: '12px',
102
+ height: '12px',
103
+ border: '2px solid rgba(255, 255, 255, 0.3)',
104
+ borderTop: '2px solid white',
105
+ borderRadius: '50%',
106
+ animation: 'spin 1s linear infinite'
107
+ } }), "Loading..."] }))] }), _jsxs("div", { style: {
108
+ display: 'flex',
109
+ alignItems: 'center',
110
+ gap: '10px'
111
+ }, children: [_jsx("button", { onClick: handleSettingsClick, style: {
112
+ background: 'none',
113
+ border: 'none',
114
+ color: 'white',
115
+ fontSize: '16px',
116
+ cursor: 'pointer',
117
+ padding: '4px',
118
+ display: 'flex',
119
+ alignItems: 'center',
120
+ justifyContent: 'center',
121
+ borderRadius: '4px',
122
+ transition: 'background-color 0.2s'
123
+ }, 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: {
124
+ background: 'none',
125
+ border: 'none',
126
+ color: 'white',
127
+ fontSize: '24px',
128
+ cursor: 'pointer',
129
+ padding: '0',
130
+ display: 'flex',
131
+ alignItems: 'center',
132
+ justifyContent: 'center'
133
+ }, children: "\u00D7" })] })] }), _jsx(MessageList, {}), _jsx(PresetMessages, {}), _jsx(MessageInput, {})] }), showPermissionForm && (_jsx("div", { style: {
134
+ position: 'fixed',
135
+ top: 0,
136
+ left: 0,
137
+ right: 0,
138
+ bottom: 0,
139
+ backgroundColor: 'rgba(0, 0, 0, 0.5)',
140
+ display: 'flex',
141
+ alignItems: 'center',
142
+ justifyContent: 'center',
143
+ zIndex: 1002
144
+ }, children: _jsx(PermissionForm, { onClose: () => setShowPermissionForm(false), onOpen: () => setShowPermissionForm(true) }) })), notification.show && (_jsx(NotificationModal, { type: notification.type, title: notification.type === 'success' ? 'Success' :
145
+ notification.type === 'error' ? 'Error' :
146
+ notification.type === 'warning' ? 'Warning' : 'Info', message: notification.message, onClose: handleCloseNotification }))] }));
147
+ };
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ export declare const MessageInput: React.FC;
3
+ //# sourceMappingURL=MessageInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessageInput.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EA0EhC,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useChatBot } from '../context/ChatBotContext';
3
+ export const MessageInput = () => {
4
+ const { inputValue, setInputValue, isLoading, isAITLoading, handleSubmit, props: { placeholder = 'Type a message...' } } = useChatBot();
5
+ const isDisabled = isLoading || isAITLoading;
6
+ const buttonText = isLoading ? 'Sending...' : isAITLoading ? 'Loading...' : 'Send';
7
+ const inputPlaceholder = isAITLoading ? 'Loading wallet configuration...' : placeholder;
8
+ const handleKeyPress = (e) => {
9
+ if (e.key === 'Enter' && !e.shiftKey) {
10
+ e.preventDefault();
11
+ handleSubmit(e);
12
+ }
13
+ };
14
+ return (_jsxs("div", { style: {
15
+ padding: '15px',
16
+ display: 'flex',
17
+ gap: '10px',
18
+ borderTop: '1px solid #eee'
19
+ }, children: [_jsx("input", { type: "text", value: inputValue, onChange: (e) => setInputValue(e.target.value), onKeyPress: handleKeyPress, placeholder: inputPlaceholder, disabled: isDisabled, style: {
20
+ flex: 1,
21
+ padding: '10px',
22
+ border: '1px solid #ddd',
23
+ borderRadius: '20px',
24
+ outline: 'none',
25
+ fontSize: '14px',
26
+ backgroundColor: isDisabled ? '#f8f9fa' : '#fff'
27
+ } }), _jsx("button", { onClick: (e) => handleSubmit(e), disabled: isDisabled || !inputValue.trim(), style: {
28
+ backgroundColor: isDisabled || !inputValue.trim() ? '#e9ecef' : '#007bff',
29
+ color: isDisabled || !inputValue.trim() ? '#6c757d' : 'white',
30
+ border: 'none',
31
+ padding: '10px 20px',
32
+ borderRadius: '20px',
33
+ cursor: isDisabled || !inputValue.trim() ? 'not-allowed' : 'pointer',
34
+ fontSize: '14px',
35
+ fontWeight: '500',
36
+ transition: 'background-color 0.3s'
37
+ }, onMouseOver: (e) => {
38
+ if (!isDisabled && inputValue.trim()) {
39
+ e.currentTarget.style.backgroundColor = '#0056b3';
40
+ }
41
+ }, onMouseOut: (e) => {
42
+ if (!isDisabled && inputValue.trim()) {
43
+ e.currentTarget.style.backgroundColor = '#007bff';
44
+ }
45
+ }, children: buttonText })] }));
46
+ };
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ export declare const MessageList: React.FC;
3
+ //# sourceMappingURL=MessageList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../src/components/ui/MessageList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAyI/B,CAAC"}
@@ -0,0 +1,84 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import { useChatBot } from '../context/ChatBotContext';
4
+ import { AI_MODEL_MAP } from '../types/ChatBotTypes';
5
+ export const MessageList = () => {
6
+ const { messages, isLoading, connectWallet, signInWallet, hitAddress, ait, setShowPermissionForm, isWalletLoading } = useChatBot();
7
+ const messagesEndRef = React.useRef(null);
8
+ const scrollToBottom = () => {
9
+ messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
10
+ };
11
+ React.useEffect(() => {
12
+ scrollToBottom();
13
+ }, [messages]);
14
+ const handleButtonClick = (buttonType) => {
15
+ if (buttonType === 'connect') {
16
+ connectWallet(true);
17
+ }
18
+ else if (buttonType === 'signIn') {
19
+ signInWallet(true);
20
+ }
21
+ };
22
+ const getModelDisplayName = (modelValue) => {
23
+ if (!modelValue)
24
+ return '';
25
+ return AI_MODEL_MAP[modelValue] || modelValue;
26
+ };
27
+ return (_jsxs("div", { style: {
28
+ flex: 1,
29
+ padding: '15px',
30
+ overflowY: 'auto',
31
+ display: 'flex',
32
+ flexDirection: 'column',
33
+ gap: '10px'
34
+ }, children: [messages.map((message) => (_jsxs("div", { style: {
35
+ alignSelf: message.role === 'user' ? 'flex-end' : 'flex-start',
36
+ maxWidth: '80%',
37
+ marginBottom: '10px'
38
+ }, children: [_jsxs("div", { style: {
39
+ backgroundColor: message.role === 'user' ? '#007bff' : '#f1f1f1',
40
+ color: message.role === 'user' ? 'white' : '#333',
41
+ padding: '10px 15px',
42
+ borderRadius: '15px',
43
+ wordWrap: 'break-word',
44
+ position: 'relative'
45
+ }, children: [message.content, message.button && (_jsx("div", { style: { marginTop: '10px' }, children: _jsx("button", { onClick: () => handleButtonClick(message.button), style: {
46
+ padding: '8px 16px',
47
+ backgroundColor: message.role === 'user' ? 'rgba(255, 255, 255, 0.2)' : '#007bff',
48
+ color: message.role === 'user' ? 'white' : 'white',
49
+ border: 'none',
50
+ borderRadius: '5px',
51
+ cursor: 'pointer',
52
+ fontSize: '14px'
53
+ }, children: message.button === 'connect' ? 'Connect Wallet' :
54
+ message.button === 'signIn' ? 'Sign In' : message.button }) }))] }), message.role === 'assistant' && message.metadata?.model && (_jsx("div", { style: {
55
+ display: 'flex',
56
+ alignItems: 'center',
57
+ marginTop: '4px',
58
+ marginLeft: '8px'
59
+ }, children: _jsxs("div", { style: {
60
+ backgroundColor: '#e3f2fd',
61
+ color: '#1976d2',
62
+ padding: '2px 8px',
63
+ borderRadius: '10px',
64
+ fontSize: '10px',
65
+ fontWeight: '500',
66
+ border: '1px solid #bbdefb',
67
+ display: 'flex',
68
+ alignItems: 'center',
69
+ gap: '4px'
70
+ }, children: [_jsx("span", { style: {
71
+ width: '6px',
72
+ height: '6px',
73
+ backgroundColor: '#1976d2',
74
+ borderRadius: '50%',
75
+ display: 'inline-block'
76
+ } }), getModelDisplayName(message.metadata.model)] }) }))] }, message.id))), isLoading && (_jsx("div", { style: {
77
+ alignSelf: 'flex-start',
78
+ backgroundColor: '#f1f1f1',
79
+ color: '#333',
80
+ padding: '10px 15px',
81
+ borderRadius: '15px',
82
+ maxWidth: '80%'
83
+ }, children: "Thinking..." })), _jsx("div", { ref: messagesEndRef })] }));
84
+ };
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ export declare const ModelSelector: React.FC;
3
+ //# sourceMappingURL=ModelSelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModelSelector.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ModelSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAkHjC,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from 'react';
3
+ import { useChatBot } from '../context/ChatBotContext';
4
+ export const ModelSelector = () => {
5
+ const { availableModels, selectedModelIndex, showModelSelector, handleModelChange } = useChatBot();
6
+ const [anchorEl, setAnchorEl] = React.useState(null);
7
+ const open = Boolean(anchorEl);
8
+ const handleClick = (event) => {
9
+ setAnchorEl(event.currentTarget);
10
+ };
11
+ const handleMenuItemClick = (event, index) => {
12
+ handleModelChange(index);
13
+ setAnchorEl(null);
14
+ };
15
+ const handleClose = () => {
16
+ setAnchorEl(null);
17
+ };
18
+ if (!showModelSelector) {
19
+ return null;
20
+ }
21
+ return (_jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsxs("div", { style: {
22
+ display: 'flex',
23
+ alignItems: 'center',
24
+ cursor: 'pointer',
25
+ padding: '4px 8px',
26
+ borderRadius: '4px',
27
+ backgroundColor: 'rgba(255, 255, 255, 0.1)',
28
+ transition: 'background-color 0.2s',
29
+ fontSize: '12px',
30
+ fontWeight: '500'
31
+ }, onClick: handleClick, onMouseOver: (e) => e.currentTarget.style.backgroundColor = 'rgba(255, 255, 255, 0.2)', onMouseOut: (e) => e.currentTarget.style.backgroundColor = 'rgba(255, 255, 255, 0.1)', title: "Change AI Model", children: [_jsx("span", { style: { marginRight: '4px' }, children: availableModels[selectedModelIndex]?.label || 'Nova' }), _jsx("span", { style: { fontSize: '10px' }, children: "\u25BC" })] }), open && (_jsx("div", { style: {
32
+ position: 'absolute',
33
+ top: '100%',
34
+ left: '0',
35
+ backgroundColor: 'white',
36
+ border: '1px solid #ddd',
37
+ borderRadius: '4px',
38
+ boxShadow: '0 2px 8px rgba(0,0,0,0.1)',
39
+ zIndex: 1000,
40
+ minWidth: '120px',
41
+ marginTop: '4px'
42
+ }, children: availableModels.map((model, index) => (_jsx("div", { style: {
43
+ padding: '8px 12px',
44
+ cursor: 'pointer',
45
+ backgroundColor: index === selectedModelIndex ? '#f0f0f0' : 'transparent',
46
+ color: index === selectedModelIndex ? '#007bff' : '#333',
47
+ fontSize: '12px',
48
+ borderBottom: index < availableModels.length - 1 ? '1px solid #eee' : 'none'
49
+ }, onClick: (event) => handleMenuItemClick(event, index), onMouseOver: (e) => {
50
+ if (index !== selectedModelIndex) {
51
+ e.currentTarget.style.backgroundColor = '#f8f9fa';
52
+ }
53
+ }, onMouseOut: (e) => {
54
+ if (index !== selectedModelIndex) {
55
+ e.currentTarget.style.backgroundColor = 'transparent';
56
+ }
57
+ }, children: model.label }, model.value))) })), open && (_jsx("div", { style: {
58
+ position: 'fixed',
59
+ top: 0,
60
+ left: 0,
61
+ right: 0,
62
+ bottom: 0,
63
+ zIndex: 999
64
+ }, onClick: handleClose }))] }));
65
+ };
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+ interface NotificationModalProps {
3
+ type: 'success' | 'error' | 'info' | 'warning';
4
+ title: string;
5
+ message: string;
6
+ onClose: () => void;
7
+ onConfirm?: () => void;
8
+ showConfirm?: boolean;
9
+ confirmText?: string;
10
+ cancelText?: string;
11
+ }
12
+ export declare const NotificationModal: React.FC<NotificationModalProps>;
13
+ export {};
14
+ //# sourceMappingURL=NotificationModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationModal.d.ts","sourceRoot":"","sources":["../../../src/components/ui/NotificationModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,UAAU,sBAAsB;IAC9B,IAAI,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA0H9D,CAAC"}
@@ -0,0 +1,79 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createNotification, getNotificationIcon } from '../../core/utils/notificationUtils';
3
+ export const NotificationModal = ({ type, title, message, onClose, onConfirm, showConfirm = false, confirmText = 'Confirm', cancelText = 'Cancel' }) => {
4
+ const icon = getNotificationIcon(type);
5
+ const notification = createNotification(type, message);
6
+ return (_jsx("div", { style: {
7
+ position: 'fixed',
8
+ top: 0,
9
+ left: 0,
10
+ right: 0,
11
+ bottom: 0,
12
+ backgroundColor: 'rgba(0, 0, 0, 0.5)',
13
+ display: 'flex',
14
+ alignItems: 'center',
15
+ justifyContent: 'center',
16
+ zIndex: 1000
17
+ }, children: _jsxs("div", { style: {
18
+ backgroundColor: 'white',
19
+ padding: '24px',
20
+ borderRadius: '12px',
21
+ width: '400px',
22
+ maxWidth: '90%',
23
+ boxShadow: '0 4px 12px rgba(0, 0, 0, 0.1)',
24
+ textAlign: 'center'
25
+ }, children: [_jsx("div", { style: {
26
+ fontSize: '48px',
27
+ marginBottom: '16px'
28
+ }, children: icon }), _jsx("h3", { style: {
29
+ margin: '0 0 12px 0',
30
+ fontSize: '20px',
31
+ fontWeight: '600',
32
+ color: '#1a1a1a'
33
+ }, children: title }), _jsx("p", { style: {
34
+ margin: '0 0 24px 0',
35
+ fontSize: '16px',
36
+ color: '#666',
37
+ lineHeight: '1.5'
38
+ }, children: message }), _jsxs("div", { style: {
39
+ display: 'flex',
40
+ justifyContent: 'center',
41
+ gap: '12px'
42
+ }, children: [showConfirm && onConfirm && (_jsx("button", { onClick: onConfirm, style: {
43
+ padding: '10px 20px',
44
+ backgroundColor: type === 'error' ? '#dc3545' : '#007bff',
45
+ color: 'white',
46
+ border: 'none',
47
+ borderRadius: '8px',
48
+ cursor: 'pointer',
49
+ fontSize: '14px',
50
+ fontWeight: '500',
51
+ transition: 'background-color 0.2s'
52
+ }, onMouseOver: (e) => e.currentTarget.style.backgroundColor = type === 'error' ? '#c82333' : '#0056b3', onMouseOut: (e) => e.currentTarget.style.backgroundColor = type === 'error' ? '#dc3545' : '#007bff', children: confirmText })), _jsx("button", { onClick: onClose, style: {
53
+ padding: '10px 20px',
54
+ backgroundColor: showConfirm ? '#f8f9fa' : '#007bff',
55
+ color: showConfirm ? '#666' : 'white',
56
+ border: showConfirm ? '1px solid #dee2e6' : 'none',
57
+ borderRadius: '8px',
58
+ cursor: 'pointer',
59
+ fontSize: '14px',
60
+ fontWeight: '500',
61
+ transition: 'all 0.2s'
62
+ }, onMouseOver: (e) => {
63
+ if (showConfirm) {
64
+ e.currentTarget.style.backgroundColor = '#e9ecef';
65
+ e.currentTarget.style.borderColor = '#ced4da';
66
+ }
67
+ else {
68
+ e.currentTarget.style.backgroundColor = '#0056b3';
69
+ }
70
+ }, onMouseOut: (e) => {
71
+ if (showConfirm) {
72
+ e.currentTarget.style.backgroundColor = '#f8f9fa';
73
+ e.currentTarget.style.borderColor = '#dee2e6';
74
+ }
75
+ else {
76
+ e.currentTarget.style.backgroundColor = '#007bff';
77
+ }
78
+ }, children: cancelText })] })] }) }));
79
+ };
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ interface PermissionFormProps {
3
+ onClose: () => void;
4
+ onOpen: () => void;
5
+ }
6
+ export declare const PermissionForm: React.FC<PermissionFormProps>;
7
+ export {};
8
+ //# sourceMappingURL=PermissionForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PermissionForm.d.ts","sourceRoot":"","sources":["../../../src/components/ui/PermissionForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,UAAU,mBAAmB;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAwcxD,CAAC"}