@bytexbyte/nxtlinq-ai-agent-sdk 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +175 -221
- package/dist/api/nxtlinq-api.d.ts.map +1 -1
- package/dist/api/nxtlinq-api.js +121 -142
- package/dist/components/ChatBot.d.ts +2 -44
- package/dist/components/ChatBot.d.ts.map +1 -1
- package/dist/components/ChatBot.js +5 -1241
- package/dist/components/context/ChatBotContext.d.ts +5 -0
- package/dist/components/context/ChatBotContext.d.ts.map +1 -0
- package/dist/components/context/ChatBotContext.js +737 -0
- package/dist/components/types/ChatBotTypes.d.ts +98 -0
- package/dist/components/types/ChatBotTypes.d.ts.map +1 -0
- package/dist/components/types/ChatBotTypes.js +1 -0
- package/dist/components/ui/ChatBotUI.d.ts +3 -0
- package/dist/components/ui/ChatBotUI.d.ts.map +1 -0
- package/dist/components/ui/ChatBotUI.js +146 -0
- package/dist/components/ui/MessageInput.d.ts +3 -0
- package/dist/components/ui/MessageInput.d.ts.map +1 -0
- package/dist/components/ui/MessageInput.js +46 -0
- package/dist/components/ui/MessageList.d.ts +3 -0
- package/dist/components/ui/MessageList.d.ts.map +1 -0
- package/dist/components/ui/MessageList.js +54 -0
- package/dist/components/ui/NotificationModal.d.ts +14 -0
- package/dist/components/ui/NotificationModal.d.ts.map +1 -0
- package/dist/components/ui/NotificationModal.js +79 -0
- package/dist/components/ui/PermissionForm.d.ts +8 -0
- package/dist/components/ui/PermissionForm.d.ts.map +1 -0
- package/dist/components/ui/PermissionForm.js +299 -0
- package/dist/components/ui/PresetMessages.d.ts +3 -0
- package/dist/components/ui/PresetMessages.d.ts.map +1 -0
- package/dist/components/ui/PresetMessages.js +35 -0
- package/dist/core/utils/aitUtils.d.ts +28 -0
- package/dist/core/utils/aitUtils.d.ts.map +1 -0
- package/dist/core/utils/aitUtils.js +34 -0
- package/dist/core/utils/notificationUtils.d.ts +29 -0
- package/dist/core/utils/notificationUtils.d.ts.map +1 -0
- package/dist/core/utils/notificationUtils.js +47 -0
- package/dist/core/utils/walletUtils.d.ts +10 -0
- package/dist/core/utils/walletUtils.d.ts.map +1 -0
- package/dist/core/utils/walletUtils.js +38 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -0
- package/package.json +1 -1
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useChatBot } from '../context/ChatBotContext';
|
|
4
|
+
export const PermissionForm = ({ onClose, onOpen }) => {
|
|
5
|
+
const { hitAddress, permissions, setPermissions, setIsDisabled, onSave, onConnectWallet, onSignIn, isNeedSignInWithWallet, walletInfo, onVerifyWallet, serviceId, nxtlinqApi, permissionGroup, isAITLoading, isWalletLoading = false } = useChatBot();
|
|
6
|
+
const [availablePermissions, setAvailablePermissions] = React.useState([]);
|
|
7
|
+
const [isSaving, setIsSaving] = React.useState(false);
|
|
8
|
+
const fetchAvailablePermissions = async () => {
|
|
9
|
+
if (!serviceId)
|
|
10
|
+
return;
|
|
11
|
+
try {
|
|
12
|
+
const result = await nxtlinqApi.permissions.getServicePermissions({
|
|
13
|
+
serviceId,
|
|
14
|
+
...(permissionGroup && { groupName: permissionGroup })
|
|
15
|
+
});
|
|
16
|
+
if ('error' in result) {
|
|
17
|
+
console.error('Failed to fetch permissions:', result.error);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
setAvailablePermissions(result.permissions);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.error('Error fetching permissions:', error);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
React.useEffect(() => {
|
|
27
|
+
fetchAvailablePermissions();
|
|
28
|
+
}, [serviceId, nxtlinqApi, permissionGroup]);
|
|
29
|
+
const isWalletVerified = Boolean(walletInfo?.id);
|
|
30
|
+
const handleSave = async () => {
|
|
31
|
+
setIsSaving(true);
|
|
32
|
+
try {
|
|
33
|
+
await onSave();
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
setIsSaving(false);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
// Show loading state while checking wallet status
|
|
40
|
+
if (isWalletLoading) {
|
|
41
|
+
return (_jsxs("div", { style: {
|
|
42
|
+
backgroundColor: 'white',
|
|
43
|
+
padding: '24px',
|
|
44
|
+
borderRadius: '12px',
|
|
45
|
+
width: '480px',
|
|
46
|
+
maxWidth: '90%',
|
|
47
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.1)'
|
|
48
|
+
}, children: [_jsxs("div", { style: {
|
|
49
|
+
display: 'flex',
|
|
50
|
+
justifyContent: 'space-between',
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
marginBottom: '24px'
|
|
53
|
+
}, children: [_jsx("h3", { style: {
|
|
54
|
+
margin: 0,
|
|
55
|
+
fontSize: '20px',
|
|
56
|
+
fontWeight: '600',
|
|
57
|
+
color: '#1a1a1a'
|
|
58
|
+
}, children: "AIT Settings" }), _jsx("button", { onClick: onClose, style: {
|
|
59
|
+
background: 'none',
|
|
60
|
+
border: 'none',
|
|
61
|
+
fontSize: '24px',
|
|
62
|
+
cursor: 'pointer',
|
|
63
|
+
color: '#666',
|
|
64
|
+
padding: '4px',
|
|
65
|
+
display: 'flex',
|
|
66
|
+
alignItems: 'center',
|
|
67
|
+
justifyContent: 'center'
|
|
68
|
+
}, children: "\u00D7" })] }), _jsxs("div", { style: { textAlign: 'center', padding: '32px 0' }, children: [_jsx("div", { style: {
|
|
69
|
+
width: '64px',
|
|
70
|
+
height: '64px',
|
|
71
|
+
margin: '0 auto 16px',
|
|
72
|
+
backgroundColor: '#f5f5f5',
|
|
73
|
+
borderRadius: '50%',
|
|
74
|
+
display: 'flex',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
justifyContent: 'center'
|
|
77
|
+
}, children: _jsx("div", { style: {
|
|
78
|
+
width: '32px',
|
|
79
|
+
height: '32px',
|
|
80
|
+
border: '3px solid #e3e3e3',
|
|
81
|
+
borderTop: '3px solid #007bff',
|
|
82
|
+
borderRadius: '50%',
|
|
83
|
+
animation: 'spin 1s linear infinite'
|
|
84
|
+
} }) }), _jsx("p", { style: {
|
|
85
|
+
marginBottom: '24px',
|
|
86
|
+
fontSize: '16px',
|
|
87
|
+
color: '#666'
|
|
88
|
+
}, children: "Checking wallet status..." })] }), _jsx("style", { children: `
|
|
89
|
+
@keyframes spin {
|
|
90
|
+
0% { transform: rotate(0deg); }
|
|
91
|
+
100% { transform: rotate(360deg); }
|
|
92
|
+
}
|
|
93
|
+
` })] }));
|
|
94
|
+
}
|
|
95
|
+
return (_jsxs("div", { style: {
|
|
96
|
+
backgroundColor: 'white',
|
|
97
|
+
padding: '24px',
|
|
98
|
+
borderRadius: '12px',
|
|
99
|
+
width: '480px',
|
|
100
|
+
maxWidth: '90%',
|
|
101
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.1)'
|
|
102
|
+
}, children: [_jsxs("div", { style: {
|
|
103
|
+
display: 'flex',
|
|
104
|
+
justifyContent: 'space-between',
|
|
105
|
+
alignItems: 'center',
|
|
106
|
+
marginBottom: '24px'
|
|
107
|
+
}, children: [_jsx("h3", { style: {
|
|
108
|
+
margin: 0,
|
|
109
|
+
fontSize: '20px',
|
|
110
|
+
fontWeight: '600',
|
|
111
|
+
color: '#1a1a1a'
|
|
112
|
+
}, children: "AIT Settings" }), _jsx("button", { onClick: onClose, style: {
|
|
113
|
+
background: 'none',
|
|
114
|
+
border: 'none',
|
|
115
|
+
fontSize: '24px',
|
|
116
|
+
cursor: 'pointer',
|
|
117
|
+
color: '#666',
|
|
118
|
+
padding: '4px',
|
|
119
|
+
display: 'flex',
|
|
120
|
+
alignItems: 'center',
|
|
121
|
+
justifyContent: 'center'
|
|
122
|
+
}, children: "\u00D7" })] }), !hitAddress ? (_jsxs("div", { style: { textAlign: 'center', padding: '32px 0' }, children: [_jsx("div", { style: {
|
|
123
|
+
width: '64px',
|
|
124
|
+
height: '64px',
|
|
125
|
+
margin: '0 auto 16px',
|
|
126
|
+
backgroundColor: '#f5f5f5',
|
|
127
|
+
borderRadius: '50%',
|
|
128
|
+
display: 'flex',
|
|
129
|
+
alignItems: 'center',
|
|
130
|
+
justifyContent: 'center'
|
|
131
|
+
}, children: _jsx("span", { style: { fontSize: '32px' }, children: "\uD83D\uDC5B" }) }), _jsx("p", { style: {
|
|
132
|
+
marginBottom: '24px',
|
|
133
|
+
fontSize: '16px',
|
|
134
|
+
color: '#666'
|
|
135
|
+
}, children: "Please connect your wallet first" }), _jsx("button", { onClick: onConnectWallet, style: {
|
|
136
|
+
padding: '12px 24px',
|
|
137
|
+
backgroundColor: '#007bff',
|
|
138
|
+
color: 'white',
|
|
139
|
+
border: 'none',
|
|
140
|
+
borderRadius: '8px',
|
|
141
|
+
cursor: 'pointer',
|
|
142
|
+
fontSize: '16px',
|
|
143
|
+
fontWeight: '500',
|
|
144
|
+
transition: 'background-color 0.2s'
|
|
145
|
+
}, onMouseOver: (e) => e.currentTarget.style.backgroundColor = '#0056b3', onMouseOut: (e) => e.currentTarget.style.backgroundColor = '#007bff', children: "Connect Wallet" })] })) : isNeedSignInWithWallet ? (_jsxs("div", { style: { textAlign: 'center', padding: '32px 0' }, children: [_jsxs("div", { style: { marginBottom: '24px' }, children: [_jsx("h4", { style: {
|
|
146
|
+
marginBottom: '12px',
|
|
147
|
+
fontSize: '16px',
|
|
148
|
+
color: '#666'
|
|
149
|
+
}, children: "Connected Wallet" }), _jsx("p", { style: {
|
|
150
|
+
wordBreak: 'break-all',
|
|
151
|
+
backgroundColor: '#f8f9fa',
|
|
152
|
+
padding: '12px',
|
|
153
|
+
borderRadius: '8px',
|
|
154
|
+
fontSize: '14px',
|
|
155
|
+
color: '#333',
|
|
156
|
+
border: '1px solid #e9ecef'
|
|
157
|
+
}, children: hitAddress })] }), _jsx("p", { style: {
|
|
158
|
+
marginBottom: '24px',
|
|
159
|
+
fontSize: '16px',
|
|
160
|
+
color: '#666'
|
|
161
|
+
}, children: "Please sign in to continue" }), _jsx("button", { onClick: onSignIn, style: {
|
|
162
|
+
padding: '12px 24px',
|
|
163
|
+
backgroundColor: '#007bff',
|
|
164
|
+
color: 'white',
|
|
165
|
+
border: 'none',
|
|
166
|
+
borderRadius: '8px',
|
|
167
|
+
cursor: 'pointer',
|
|
168
|
+
fontSize: '16px',
|
|
169
|
+
fontWeight: '500',
|
|
170
|
+
transition: 'background-color 0.2s'
|
|
171
|
+
}, onMouseOver: (e) => e.currentTarget.style.backgroundColor = '#0056b3', onMouseOut: (e) => e.currentTarget.style.backgroundColor = '#007bff', children: "Sign In" })] })) : !isWalletVerified ? (_jsxs("div", { style: { textAlign: 'center', padding: '32px 0' }, children: [_jsxs("div", { style: { marginBottom: '24px' }, children: [_jsx("h4", { style: {
|
|
172
|
+
marginBottom: '12px',
|
|
173
|
+
fontSize: '16px',
|
|
174
|
+
color: '#666'
|
|
175
|
+
}, children: "Connected Wallet" }), _jsx("p", { style: {
|
|
176
|
+
wordBreak: 'break-all',
|
|
177
|
+
backgroundColor: '#f8f9fa',
|
|
178
|
+
padding: '12px',
|
|
179
|
+
borderRadius: '8px',
|
|
180
|
+
fontSize: '14px',
|
|
181
|
+
color: '#333',
|
|
182
|
+
border: '1px solid #e9ecef'
|
|
183
|
+
}, children: hitAddress })] }), _jsx("p", { style: {
|
|
184
|
+
marginBottom: '24px',
|
|
185
|
+
fontSize: '16px',
|
|
186
|
+
color: '#666'
|
|
187
|
+
}, children: "Please verify your wallet to continue" }), _jsx("button", { onClick: onVerifyWallet, style: {
|
|
188
|
+
padding: '12px 24px',
|
|
189
|
+
backgroundColor: '#007bff',
|
|
190
|
+
color: 'white',
|
|
191
|
+
border: 'none',
|
|
192
|
+
borderRadius: '8px',
|
|
193
|
+
cursor: 'pointer',
|
|
194
|
+
fontSize: '16px',
|
|
195
|
+
fontWeight: '500',
|
|
196
|
+
transition: 'background-color 0.2s'
|
|
197
|
+
}, onMouseOver: (e) => e.currentTarget.style.backgroundColor = '#0056b3', onMouseOut: (e) => e.currentTarget.style.backgroundColor = '#007bff', children: "Verify your wallet" })] })) : (_jsxs(_Fragment, { children: [_jsxs("div", { style: { marginBottom: '24px' }, children: [_jsx("h4", { style: {
|
|
198
|
+
marginBottom: '12px',
|
|
199
|
+
fontSize: '16px',
|
|
200
|
+
color: '#666'
|
|
201
|
+
}, children: "Connected Wallet" }), _jsx("p", { style: {
|
|
202
|
+
wordBreak: 'break-all',
|
|
203
|
+
backgroundColor: '#f8f9fa',
|
|
204
|
+
padding: '12px',
|
|
205
|
+
borderRadius: '8px',
|
|
206
|
+
fontSize: '14px',
|
|
207
|
+
color: '#333',
|
|
208
|
+
border: '1px solid #e9ecef'
|
|
209
|
+
}, children: hitAddress })] }), _jsxs("div", { style: { marginBottom: '24px' }, children: [_jsx("h4", { style: {
|
|
210
|
+
marginBottom: '12px',
|
|
211
|
+
fontSize: '16px',
|
|
212
|
+
color: '#666'
|
|
213
|
+
}, children: "Permissions" }), isAITLoading ? (_jsx("div", { style: {
|
|
214
|
+
backgroundColor: '#f8f9fa',
|
|
215
|
+
padding: '16px',
|
|
216
|
+
borderRadius: '8px',
|
|
217
|
+
border: '1px solid #e9ecef',
|
|
218
|
+
textAlign: 'center',
|
|
219
|
+
color: '#666'
|
|
220
|
+
}, children: "Loading permissions..." })) : (_jsx("div", { style: {
|
|
221
|
+
backgroundColor: '#f8f9fa',
|
|
222
|
+
padding: '16px',
|
|
223
|
+
borderRadius: '8px',
|
|
224
|
+
border: '1px solid #e9ecef'
|
|
225
|
+
}, children: availablePermissions.map((permission) => (_jsx("div", { style: { marginBottom: '12px' }, children: _jsxs("label", { style: {
|
|
226
|
+
display: 'flex',
|
|
227
|
+
alignItems: 'center',
|
|
228
|
+
gap: '12px',
|
|
229
|
+
cursor: isAITLoading ? 'not-allowed' : 'pointer',
|
|
230
|
+
padding: '8px',
|
|
231
|
+
borderRadius: '6px',
|
|
232
|
+
transition: 'background-color 0.2s',
|
|
233
|
+
opacity: isAITLoading ? 0.6 : 1
|
|
234
|
+
}, onMouseOver: (e) => {
|
|
235
|
+
if (!isAITLoading) {
|
|
236
|
+
e.currentTarget.style.backgroundColor = '#e9ecef';
|
|
237
|
+
}
|
|
238
|
+
}, onMouseOut: (e) => {
|
|
239
|
+
if (!isAITLoading) {
|
|
240
|
+
e.currentTarget.style.backgroundColor = 'transparent';
|
|
241
|
+
}
|
|
242
|
+
}, children: [_jsx("input", { type: "checkbox", checked: permissions.includes(permission.label), onChange: () => {
|
|
243
|
+
if (!isAITLoading) {
|
|
244
|
+
const newPermissions = permissions.includes(permission.label)
|
|
245
|
+
? permissions.filter(p => p !== permission.label)
|
|
246
|
+
: [...permissions, permission.label].sort();
|
|
247
|
+
setPermissions(newPermissions);
|
|
248
|
+
setIsDisabled(false);
|
|
249
|
+
}
|
|
250
|
+
}, disabled: isAITLoading, style: {
|
|
251
|
+
margin: 0,
|
|
252
|
+
width: '18px',
|
|
253
|
+
height: '18px',
|
|
254
|
+
cursor: isAITLoading ? 'not-allowed' : 'pointer'
|
|
255
|
+
} }), _jsx("span", { style: {
|
|
256
|
+
fontSize: '14px',
|
|
257
|
+
color: '#333'
|
|
258
|
+
}, children: permission.label })] }) }, permission.id))) }))] }), _jsxs("div", { style: {
|
|
259
|
+
display: 'flex',
|
|
260
|
+
justifyContent: 'flex-end',
|
|
261
|
+
gap: '12px',
|
|
262
|
+
borderTop: '1px solid #e9ecef',
|
|
263
|
+
paddingTop: '24px'
|
|
264
|
+
}, children: [_jsx("button", { onClick: onClose, style: {
|
|
265
|
+
padding: '10px 20px',
|
|
266
|
+
backgroundColor: '#f8f9fa',
|
|
267
|
+
color: '#666',
|
|
268
|
+
border: '1px solid #dee2e6',
|
|
269
|
+
borderRadius: '8px',
|
|
270
|
+
cursor: 'pointer',
|
|
271
|
+
fontSize: '14px',
|
|
272
|
+
fontWeight: '500',
|
|
273
|
+
transition: 'all 0.2s'
|
|
274
|
+
}, onMouseOver: (e) => {
|
|
275
|
+
e.currentTarget.style.backgroundColor = '#e9ecef';
|
|
276
|
+
e.currentTarget.style.borderColor = '#ced4da';
|
|
277
|
+
}, onMouseOut: (e) => {
|
|
278
|
+
e.currentTarget.style.backgroundColor = '#f8f9fa';
|
|
279
|
+
e.currentTarget.style.borderColor = '#dee2e6';
|
|
280
|
+
}, children: "Cancel" }), _jsx("button", { onClick: handleSave, disabled: permissions.length === 0 || isSaving || isAITLoading, style: {
|
|
281
|
+
padding: '10px 20px',
|
|
282
|
+
backgroundColor: permissions.length === 0 || isSaving || isAITLoading ? '#e9ecef' : '#007bff',
|
|
283
|
+
color: permissions.length === 0 || isSaving || isAITLoading ? '#6c757d' : 'white',
|
|
284
|
+
border: 'none',
|
|
285
|
+
borderRadius: '8px',
|
|
286
|
+
cursor: permissions.length === 0 || isSaving || isAITLoading ? 'not-allowed' : 'pointer',
|
|
287
|
+
fontSize: '14px',
|
|
288
|
+
fontWeight: '500',
|
|
289
|
+
transition: 'background-color 0.2s'
|
|
290
|
+
}, onMouseOver: (e) => {
|
|
291
|
+
if (permissions.length > 0 && !isSaving && !isAITLoading) {
|
|
292
|
+
e.currentTarget.style.backgroundColor = '#0056b3';
|
|
293
|
+
}
|
|
294
|
+
}, onMouseOut: (e) => {
|
|
295
|
+
if (permissions.length > 0 && !isSaving && !isAITLoading) {
|
|
296
|
+
e.currentTarget.style.backgroundColor = '#007bff';
|
|
297
|
+
}
|
|
298
|
+
}, children: isSaving ? 'Saving...' : 'Save' })] })] }))] }));
|
|
299
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PresetMessages.d.ts","sourceRoot":"","sources":["../../../src/components/ui/PresetMessages.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAiDlC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useChatBot } from '../context/ChatBotContext';
|
|
3
|
+
export const PresetMessages = () => {
|
|
4
|
+
const { props, handlePresetMessage } = useChatBot();
|
|
5
|
+
const { presetMessages = [] } = props;
|
|
6
|
+
if (!presetMessages || presetMessages.length === 0) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return (_jsx("div", { style: {
|
|
10
|
+
padding: '10px 15px',
|
|
11
|
+
borderTop: '1px solid #eee',
|
|
12
|
+
overflowX: 'auto',
|
|
13
|
+
whiteSpace: 'nowrap',
|
|
14
|
+
display: 'flex',
|
|
15
|
+
gap: '10px',
|
|
16
|
+
alignItems: 'center'
|
|
17
|
+
}, children: presetMessages.map((preset, index) => (_jsx("button", { onClick: () => handlePresetMessage(preset), style: {
|
|
18
|
+
backgroundColor: '#007bff',
|
|
19
|
+
color: 'white',
|
|
20
|
+
border: 'none',
|
|
21
|
+
borderRadius: '5px',
|
|
22
|
+
padding: '5px 10px',
|
|
23
|
+
fontSize: '12px',
|
|
24
|
+
cursor: 'pointer',
|
|
25
|
+
transition: 'background-color 0.3s',
|
|
26
|
+
whiteSpace: 'nowrap',
|
|
27
|
+
flexShrink: 0
|
|
28
|
+
}, onMouseOver: (e) => {
|
|
29
|
+
e.currentTarget.style.backgroundColor = '#0056b3';
|
|
30
|
+
}, onMouseOut: (e) => {
|
|
31
|
+
e.currentTarget.style.backgroundColor = '#007bff';
|
|
32
|
+
}, onMouseDown: (e) => {
|
|
33
|
+
e.currentTarget.style.backgroundColor = '#004085';
|
|
34
|
+
}, children: preset.text }, index))) }));
|
|
35
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface AITMetadata {
|
|
2
|
+
model: string;
|
|
3
|
+
permissions: string[];
|
|
4
|
+
issuedBy: string;
|
|
5
|
+
}
|
|
6
|
+
export interface CreateAITParams {
|
|
7
|
+
aitId: string;
|
|
8
|
+
controller: string;
|
|
9
|
+
serviceId: string;
|
|
10
|
+
metadataHash: string;
|
|
11
|
+
metadataCid: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const generateAITId: (address: string) => string;
|
|
14
|
+
export declare const createAITMetadata: (permissions: string[], issuedBy: string) => AITMetadata;
|
|
15
|
+
export declare const generateMetadataHash: (metadata: AITMetadata) => string;
|
|
16
|
+
export declare const prepareAITCreation: (address: string, permissions: string[], serviceId: string) => {
|
|
17
|
+
aitId: string;
|
|
18
|
+
metadata: AITMetadata;
|
|
19
|
+
metadataHash: string;
|
|
20
|
+
createAITParams: {
|
|
21
|
+
aitId: string;
|
|
22
|
+
controller: string;
|
|
23
|
+
serviceId: string;
|
|
24
|
+
metadataHash: string;
|
|
25
|
+
metadataCid: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=aitUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aitUtils.d.ts","sourceRoot":"","sources":["../../../src/core/utils/aitUtils.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,GAAI,SAAS,MAAM,KAAG,MAG/C,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,aAAa,MAAM,EAAE,EAAE,UAAU,MAAM,KAAG,WAM3E,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,UAAU,WAAW,KAAG,MAG5D,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,EAAE,aAAa,MAAM,EAAE,EAAE,WAAW,MAAM;;;;;;;;;;;CAiB3F,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import stringify from 'fast-json-stable-stringify';
|
|
3
|
+
export const generateAITId = (address) => {
|
|
4
|
+
const timestamp = Math.floor(Date.now() / 1000);
|
|
5
|
+
return `did:polygon:ike-dashboard:${address}:${timestamp}`;
|
|
6
|
+
};
|
|
7
|
+
export const createAITMetadata = (permissions, issuedBy) => {
|
|
8
|
+
return {
|
|
9
|
+
model: 'gpt-4',
|
|
10
|
+
permissions,
|
|
11
|
+
issuedBy,
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export const generateMetadataHash = (metadata) => {
|
|
15
|
+
const metadataStr = stringify(metadata);
|
|
16
|
+
return ethers.utils.keccak256(ethers.utils.toUtf8Bytes(metadataStr));
|
|
17
|
+
};
|
|
18
|
+
export const prepareAITCreation = (address, permissions, serviceId) => {
|
|
19
|
+
const aitId = generateAITId(address);
|
|
20
|
+
const metadata = createAITMetadata(permissions, address);
|
|
21
|
+
const metadataHash = generateMetadataHash(metadata);
|
|
22
|
+
return {
|
|
23
|
+
aitId,
|
|
24
|
+
metadata,
|
|
25
|
+
metadataHash,
|
|
26
|
+
createAITParams: {
|
|
27
|
+
aitId,
|
|
28
|
+
controller: address,
|
|
29
|
+
serviceId,
|
|
30
|
+
metadataHash,
|
|
31
|
+
metadataCid: '', // Will be set after metadata upload
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type NotificationType = 'success' | 'error' | 'warning' | 'info';
|
|
2
|
+
export interface Notification {
|
|
3
|
+
show: boolean;
|
|
4
|
+
type: NotificationType;
|
|
5
|
+
message: string;
|
|
6
|
+
autoHide?: boolean;
|
|
7
|
+
duration?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const createNotification: (type: NotificationType, message: string, duration?: number) => Notification;
|
|
10
|
+
export declare const getNotificationIcon: (type: NotificationType) => string;
|
|
11
|
+
export declare const getNotificationStyles: (type: NotificationType) => {
|
|
12
|
+
background: string;
|
|
13
|
+
color: string;
|
|
14
|
+
position: "fixed";
|
|
15
|
+
bottom: number;
|
|
16
|
+
right: number;
|
|
17
|
+
padding: string;
|
|
18
|
+
borderRadius: number;
|
|
19
|
+
zIndex: number;
|
|
20
|
+
fontWeight: number;
|
|
21
|
+
boxShadow: string;
|
|
22
|
+
transition: string;
|
|
23
|
+
display: string;
|
|
24
|
+
alignItems: string;
|
|
25
|
+
gap: string;
|
|
26
|
+
minWidth: string;
|
|
27
|
+
maxWidth: string;
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=notificationUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notificationUtils.d.ts","sourceRoot":"","sources":["../../../src/core/utils/notificationUtils.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAExE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,kBAAkB,GAC7B,MAAM,gBAAgB,EACtB,SAAS,MAAM,EACf,iBAAe,KACd,YAMD,CAAC;AAEH,eAAO,MAAM,mBAAmB,GAAI,MAAM,gBAAgB,KAAG,MAW5D,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,MAAM,gBAAgB;;;;;;;;;;;;;;;;;CA4B3D,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const createNotification = (type, message, duration = 5000) => ({
|
|
2
|
+
show: true,
|
|
3
|
+
type,
|
|
4
|
+
message,
|
|
5
|
+
autoHide: true,
|
|
6
|
+
duration
|
|
7
|
+
});
|
|
8
|
+
export const getNotificationIcon = (type) => {
|
|
9
|
+
switch (type) {
|
|
10
|
+
case 'success':
|
|
11
|
+
return '✅';
|
|
12
|
+
case 'error':
|
|
13
|
+
return '❌';
|
|
14
|
+
case 'warning':
|
|
15
|
+
return '⚠️';
|
|
16
|
+
default:
|
|
17
|
+
return 'ℹ️';
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export const getNotificationStyles = (type) => {
|
|
21
|
+
const baseStyles = {
|
|
22
|
+
position: 'fixed',
|
|
23
|
+
bottom: 20,
|
|
24
|
+
right: 20,
|
|
25
|
+
padding: '12px 24px',
|
|
26
|
+
borderRadius: 8,
|
|
27
|
+
zIndex: 2000,
|
|
28
|
+
fontWeight: 600,
|
|
29
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
|
|
30
|
+
transition: 'all 0.3s ease',
|
|
31
|
+
display: 'flex',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
gap: '12px',
|
|
34
|
+
minWidth: '300px',
|
|
35
|
+
maxWidth: '500px'
|
|
36
|
+
};
|
|
37
|
+
switch (type) {
|
|
38
|
+
case 'success':
|
|
39
|
+
return { ...baseStyles, background: '#4caf50', color: 'white' };
|
|
40
|
+
case 'error':
|
|
41
|
+
return { ...baseStyles, background: '#f44336', color: 'white' };
|
|
42
|
+
case 'warning':
|
|
43
|
+
return { ...baseStyles, background: '#ff9800', color: 'white' };
|
|
44
|
+
default:
|
|
45
|
+
return { ...baseStyles, background: '#2196f3', color: 'white' };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
export interface WalletConnectionResult {
|
|
3
|
+
address: string;
|
|
4
|
+
signer: ethers.Signer;
|
|
5
|
+
}
|
|
6
|
+
export declare const connectWallet: () => Promise<WalletConnectionResult>;
|
|
7
|
+
export declare const disconnectWallet: () => void;
|
|
8
|
+
export declare const getStoredWalletAddress: () => string | null;
|
|
9
|
+
export declare const validateToken: (token: string, expectedAddress: string) => boolean;
|
|
10
|
+
//# sourceMappingURL=walletUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walletUtils.d.ts","sourceRoot":"","sources":["../../../src/core/utils/walletUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,QAAa,OAAO,CAAC,sBAAsB,CAkBpE,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAO,IAEnC,CAAC;AAEF,eAAO,MAAM,sBAAsB,QAAO,MAAM,GAAG,IAElD,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,iBAAiB,MAAM,KAAG,OActE,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import metakeepClient from '../metakeepClient';
|
|
3
|
+
export const connectWallet = async () => {
|
|
4
|
+
if (typeof window === 'undefined') {
|
|
5
|
+
throw new Error('Web3 is not available in server-side rendering');
|
|
6
|
+
}
|
|
7
|
+
const web3Provider = await metakeepClient.ethereum;
|
|
8
|
+
if (!web3Provider) {
|
|
9
|
+
throw new Error('Web3 provider not available');
|
|
10
|
+
}
|
|
11
|
+
await web3Provider.enable();
|
|
12
|
+
const ethersProvider = new ethers.providers.Web3Provider(web3Provider);
|
|
13
|
+
const signer = await ethersProvider.getSigner();
|
|
14
|
+
const address = await signer.getAddress();
|
|
15
|
+
localStorage.setItem('walletAddress', address);
|
|
16
|
+
return { address, signer };
|
|
17
|
+
};
|
|
18
|
+
export const disconnectWallet = () => {
|
|
19
|
+
localStorage.removeItem('walletAddress');
|
|
20
|
+
};
|
|
21
|
+
export const getStoredWalletAddress = () => {
|
|
22
|
+
return localStorage.getItem('walletAddress');
|
|
23
|
+
};
|
|
24
|
+
export const validateToken = (token, expectedAddress) => {
|
|
25
|
+
try {
|
|
26
|
+
const payload = JSON.parse(atob(token.split('.')[1]));
|
|
27
|
+
const exp = payload.exp * 1000;
|
|
28
|
+
const now = Date.now();
|
|
29
|
+
if (exp < now)
|
|
30
|
+
return false;
|
|
31
|
+
const address = payload.address;
|
|
32
|
+
return address === expectedAddress;
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
console.error('Error parsing token:', error);
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
export type { PresetMessage, ToolUse, ChatBotProps } from './components/ChatBot';
|
|
2
1
|
export { ChatBot } from './components/ChatBot';
|
|
2
|
+
export { ChatBotProvider, useChatBot } from './components/context/ChatBotContext';
|
|
3
|
+
export { ChatBotUI } from './components/ui/ChatBotUI';
|
|
4
|
+
export { MessageList } from './components/ui/MessageList';
|
|
5
|
+
export { MessageInput } from './components/ui/MessageInput';
|
|
6
|
+
export { PresetMessages } from './components/ui/PresetMessages';
|
|
7
|
+
export { PermissionForm } from './components/ui/PermissionForm';
|
|
8
|
+
export { NotificationModal } from './components/ui/NotificationModal';
|
|
9
|
+
export type { ChatBotProps, ChatBotContextType, PresetMessage, ToolUse, ToolCall, NovaResponse, NovaError, AITMetadata } from './components/types/ChatBotTypes';
|
|
10
|
+
export { connectWallet, disconnectWallet, validateToken } from './core/utils/walletUtils';
|
|
11
|
+
export { generateAITId, createAITMetadata, prepareAITCreation } from './core/utils/aitUtils';
|
|
12
|
+
export { createNotification, getNotificationIcon } from './core/utils/notificationUtils';
|
|
13
|
+
export { createNxtlinqApi } from './api/nxtlinq-api';
|
|
3
14
|
export type { Message, AIT, ServicePermission, AITApi } from './types/ait-api';
|
|
15
|
+
export { default as useLocalStorage } from './core/lib/useLocalStorage';
|
|
4
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AAGlF,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAGtE,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,WAAW,EACZ,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,aAAa,EACd,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAGrD,YAAY,EACV,OAAO,EACP,GAAG,EACH,iBAAiB,EACjB,MAAM,EACP,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
+
// Main ChatBot component
|
|
1
2
|
export { ChatBot } from './components/ChatBot';
|
|
3
|
+
// Context and hooks
|
|
4
|
+
export { ChatBotProvider, useChatBot } from './components/context/ChatBotContext';
|
|
5
|
+
// UI Components
|
|
6
|
+
export { ChatBotUI } from './components/ui/ChatBotUI';
|
|
7
|
+
export { MessageList } from './components/ui/MessageList';
|
|
8
|
+
export { MessageInput } from './components/ui/MessageInput';
|
|
9
|
+
export { PresetMessages } from './components/ui/PresetMessages';
|
|
10
|
+
export { PermissionForm } from './components/ui/PermissionForm';
|
|
11
|
+
export { NotificationModal } from './components/ui/NotificationModal';
|
|
12
|
+
// Utility functions
|
|
13
|
+
export { connectWallet, disconnectWallet, validateToken } from './core/utils/walletUtils';
|
|
14
|
+
export { generateAITId, createAITMetadata, prepareAITCreation } from './core/utils/aitUtils';
|
|
15
|
+
export { createNotification, getNotificationIcon } from './core/utils/notificationUtils';
|
|
16
|
+
// API client
|
|
17
|
+
export { createNxtlinqApi } from './api/nxtlinq-api';
|
|
18
|
+
export { default as useLocalStorage } from './core/lib/useLocalStorage';
|
package/package.json
CHANGED