@bytexbyte/nxtlinq-ai-agent-sdk 1.2.4 → 1.2.5
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 +204 -55
- package/dist/components/context/ChatBotContext.d.ts.map +1 -1
- package/dist/components/context/ChatBotContext.js +17 -4
- package/dist/components/types/ChatBotTypes.d.ts +2 -2
- package/dist/components/types/ChatBotTypes.d.ts.map +1 -1
- package/dist/components/ui/ChatBotUI.d.ts.map +1 -1
- package/dist/components/ui/ChatBotUI.js +73 -8
- package/dist/components/ui/MessageInput.d.ts.map +1 -1
- package/dist/components/ui/MessageInput.js +7 -4
- package/dist/components/ui/MessageList.d.ts.map +1 -1
- package/dist/components/ui/MessageList.js +13 -7
- package/dist/components/ui/PermissionForm.d.ts.map +1 -1
- package/dist/components/ui/PermissionForm.js +60 -23
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
A powerful AI Agent SDK that supports multiple AI model switching, wallet connection, permission management, and more.
|
|
4
4
|
|
|
5
|
+
## 🚀 What's New in v1.2.4
|
|
6
|
+
|
|
7
|
+
- **🎯 AI Model Switching**: Real-time switching between multiple AI models during conversations
|
|
8
|
+
- **🤖 Multi-Model Support**: Support for Nova, Claude, ChatGPT, Llama, and Gemini
|
|
9
|
+
- **🎨 Enhanced UI**: Model selector dropdown and model badges for messages
|
|
10
|
+
- **💾 Persistent Preferences**: Model selection saved in localStorage
|
|
11
|
+
- **🔧 Improved API**: Enhanced API client with dynamic model endpoints
|
|
12
|
+
|
|
5
13
|
## Features
|
|
6
14
|
|
|
7
15
|
- 🤖 **Multiple AI Models Support**: Supports Nova, Claude, ChatGPT, Llama, Gemini, and other AI models
|
|
@@ -10,21 +18,39 @@ A powerful AI Agent SDK that supports multiple AI model switching, wallet connec
|
|
|
10
18
|
- 🔐 **Permission Management**: AIT (AI Identity Token) based permission control system
|
|
11
19
|
- 💬 **Real-time Chat**: Context-aware conversation functionality
|
|
12
20
|
- 🎨 **Customizable UI**: Complete UI components and style customization options
|
|
21
|
+
- 📱 **Responsive Design**: Works seamlessly across different screen sizes
|
|
22
|
+
- 🔒 **Type Safety**: Full TypeScript support with comprehensive type definitions
|
|
13
23
|
|
|
14
24
|
## Installation
|
|
15
25
|
|
|
16
26
|
```bash
|
|
17
|
-
npm install nxtlinq-ai-agent-sdk
|
|
27
|
+
npm install @bytexbyte/nxtlinq-ai-agent-sdk
|
|
18
28
|
# or
|
|
19
|
-
yarn add nxtlinq-ai-agent-sdk
|
|
29
|
+
yarn add @bytexbyte/nxtlinq-ai-agent-sdk
|
|
20
30
|
```
|
|
21
31
|
|
|
22
|
-
##
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### Basic Configuration
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { ChatBot } from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
38
|
+
|
|
39
|
+
function App() {
|
|
40
|
+
return (
|
|
41
|
+
<ChatBot
|
|
42
|
+
serviceId="your-service-id"
|
|
43
|
+
apiKey="your-api-key"
|
|
44
|
+
apiSecret="your-api-secret"
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
```
|
|
23
49
|
|
|
24
|
-
###
|
|
50
|
+
### AI Model Switching
|
|
25
51
|
|
|
26
52
|
```tsx
|
|
27
|
-
import { ChatBot } from 'nxtlinq-ai-agent-sdk';
|
|
53
|
+
import { ChatBot, DEFAULT_AI_MODELS } from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
28
54
|
|
|
29
55
|
function App() {
|
|
30
56
|
return (
|
|
@@ -32,15 +58,23 @@ function App() {
|
|
|
32
58
|
serviceId="your-service-id"
|
|
33
59
|
apiKey="your-api-key"
|
|
34
60
|
apiSecret="your-api-secret"
|
|
61
|
+
// Enable AI model switching
|
|
62
|
+
showModelSelector={true}
|
|
63
|
+
defaultModelIndex={0} // Start with Nova
|
|
64
|
+
onModelChange={(model) => {
|
|
65
|
+
console.log('Switched to:', model.label);
|
|
66
|
+
// Track model usage
|
|
67
|
+
analytics.track('model_changed', { model: model.value });
|
|
68
|
+
}}
|
|
35
69
|
/>
|
|
36
70
|
);
|
|
37
71
|
}
|
|
38
72
|
```
|
|
39
73
|
|
|
40
|
-
###
|
|
74
|
+
### Custom Model Configuration
|
|
41
75
|
|
|
42
76
|
```tsx
|
|
43
|
-
import { ChatBot
|
|
77
|
+
import { ChatBot } from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
44
78
|
|
|
45
79
|
function App() {
|
|
46
80
|
// Custom available AI models
|
|
@@ -48,7 +82,7 @@ function App() {
|
|
|
48
82
|
{ label: 'Nova', value: 'nova' },
|
|
49
83
|
{ label: 'Claude', value: 'claude' },
|
|
50
84
|
{ label: 'ChatGPT', value: 'open-ai' },
|
|
51
|
-
// Add more models
|
|
85
|
+
// Add more models as needed
|
|
52
86
|
];
|
|
53
87
|
|
|
54
88
|
return (
|
|
@@ -60,17 +94,17 @@ function App() {
|
|
|
60
94
|
defaultModelIndex={1} // Default to Claude
|
|
61
95
|
showModelSelector={true}
|
|
62
96
|
onModelChange={(model) => {
|
|
63
|
-
console.log('
|
|
97
|
+
console.log('Model changed to:', model.label);
|
|
64
98
|
}}
|
|
65
99
|
/>
|
|
66
100
|
);
|
|
67
101
|
}
|
|
68
102
|
```
|
|
69
103
|
|
|
70
|
-
###
|
|
104
|
+
### Advanced Configuration
|
|
71
105
|
|
|
72
106
|
```tsx
|
|
73
|
-
import { ChatBot } from 'nxtlinq-ai-agent-sdk';
|
|
107
|
+
import { ChatBot, DEFAULT_AI_MODELS } from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
74
108
|
|
|
75
109
|
function App() {
|
|
76
110
|
return (
|
|
@@ -84,18 +118,28 @@ function App() {
|
|
|
84
118
|
showModelSelector={true}
|
|
85
119
|
onModelChange={(model) => {
|
|
86
120
|
console.log('Model changed to:', model.label);
|
|
121
|
+
// Update user preferences
|
|
122
|
+
localStorage.setItem('preferred-model', model.value);
|
|
87
123
|
}}
|
|
88
124
|
// Preset messages
|
|
89
125
|
presetMessages={[
|
|
90
126
|
{ text: 'Hello, how can you help me?', autoSend: true },
|
|
91
|
-
{ text: 'I want to
|
|
127
|
+
{ text: 'I want to switch to a different AI model.', autoSend: false },
|
|
128
|
+
{ text: 'What are the differences between the available models?', autoSend: false }
|
|
92
129
|
]}
|
|
93
130
|
// Callback functions
|
|
94
131
|
onMessage={(message) => {
|
|
95
|
-
console.log('New message:',
|
|
132
|
+
console.log('New message:', {
|
|
133
|
+
content: message.content,
|
|
134
|
+
role: message.role,
|
|
135
|
+
model: message.metadata?.model,
|
|
136
|
+
timestamp: message.timestamp
|
|
137
|
+
});
|
|
96
138
|
}}
|
|
97
139
|
onError={(error) => {
|
|
98
|
-
console.error('
|
|
140
|
+
console.error('ChatBot error:', error);
|
|
141
|
+
// Add error reporting
|
|
142
|
+
errorReporting.captureException(error);
|
|
99
143
|
}}
|
|
100
144
|
onToolUse={async (toolUse) => {
|
|
101
145
|
console.log('Tool used:', toolUse);
|
|
@@ -128,32 +172,32 @@ function App() {
|
|
|
128
172
|
|
|
129
173
|
### ChatBot Props
|
|
130
174
|
|
|
131
|
-
| Property | Type | Default | Description |
|
|
132
|
-
|
|
133
|
-
| `serviceId` | `string` | - | Service ID
|
|
134
|
-
| `apiKey` | `string` | - | API Key
|
|
135
|
-
| `apiSecret` | `string` | - | API Secret
|
|
136
|
-
| `availableModels` | `AIModel[]` | `DEFAULT_AI_MODELS` | Available AI models list |
|
|
137
|
-
| `defaultModelIndex` | `number` | `0` | Default selected model index |
|
|
138
|
-
| `showModelSelector` | `boolean` | `true` | Whether to show model selector |
|
|
139
|
-
| `onModelChange` | `(model: AIModel) => void` | - | Model change callback |
|
|
140
|
-
| `presetMessages` | `PresetMessage[]` | `[]` | Preset messages list |
|
|
141
|
-
| `placeholder` | `string` | `'Type a message...'` | Input placeholder |
|
|
142
|
-
| `className` | `string` | `''` | Custom CSS class name |
|
|
143
|
-
| `maxRetries` | `number` | `3` | Maximum retry attempts |
|
|
144
|
-
| `retryDelay` | `number` | `1000` | Retry delay (milliseconds) |
|
|
145
|
-
| `onMessage` | `(message: Message) => void` | - | Message callback |
|
|
146
|
-
| `onError` | `(error: Error) => void` | - | Error callback |
|
|
147
|
-
| `onToolUse` | `(toolUse: ToolUse) => Promise<Message \| void>` | - | Tool use callback |
|
|
148
|
-
| `onVerifyWallet` | `() => Promise<{token: string} \| undefined>` | - | Wallet verification callback |
|
|
149
|
-
| `permissionGroup` | `string` | - | Permission group name |
|
|
175
|
+
| Property | Type | Default | Required | Description |
|
|
176
|
+
|----------|------|---------|----------|-------------|
|
|
177
|
+
| `serviceId` | `string` | - | ✅ | Service ID |
|
|
178
|
+
| `apiKey` | `string` | - | ✅ | API Key |
|
|
179
|
+
| `apiSecret` | `string` | - | ✅ | API Secret |
|
|
180
|
+
| `availableModels` | `AIModel[]` | `DEFAULT_AI_MODELS` | ❌ | Available AI models list |
|
|
181
|
+
| `defaultModelIndex` | `number` | `0` | ❌ | Default selected model index |
|
|
182
|
+
| `showModelSelector` | `boolean` | `true` | ❌ | Whether to show model selector |
|
|
183
|
+
| `onModelChange` | `(model: AIModel) => void` | - | ❌ | Model change callback |
|
|
184
|
+
| `presetMessages` | `PresetMessage[]` | `[]` | ❌ | Preset messages list |
|
|
185
|
+
| `placeholder` | `string` | `'Type a message...'` | ❌ | Input placeholder |
|
|
186
|
+
| `className` | `string` | `''` | ❌ | Custom CSS class name |
|
|
187
|
+
| `maxRetries` | `number` | `3` | ❌ | Maximum retry attempts |
|
|
188
|
+
| `retryDelay` | `number` | `1000` | ❌ | Retry delay (milliseconds) |
|
|
189
|
+
| `onMessage` | `(message: Message) => void` | - | ❌ | Message callback |
|
|
190
|
+
| `onError` | `(error: Error) => void` | - | ❌ | Error callback |
|
|
191
|
+
| `onToolUse` | `(toolUse: ToolUse) => Promise<Message \| void>` | - | ❌ | Tool use callback |
|
|
192
|
+
| `onVerifyWallet` | `() => Promise<{token: string} \| undefined>` | - | ❌ | Wallet verification callback |
|
|
193
|
+
| `permissionGroup` | `string` | - | ❌ | Permission group name |
|
|
150
194
|
|
|
151
195
|
### AIModel Type
|
|
152
196
|
|
|
153
197
|
```typescript
|
|
154
198
|
interface AIModel {
|
|
155
|
-
label: string; // Display name
|
|
156
|
-
value: string; // Model identifier
|
|
199
|
+
label: string; // Display name (e.g., "Nova", "Claude")
|
|
200
|
+
value: string; // Model identifier (e.g., "nova", "claude")
|
|
157
201
|
}
|
|
158
202
|
```
|
|
159
203
|
|
|
@@ -169,6 +213,26 @@ const DEFAULT_AI_MODELS = [
|
|
|
169
213
|
];
|
|
170
214
|
```
|
|
171
215
|
|
|
216
|
+
### Message Type with Model Metadata
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
interface Message {
|
|
220
|
+
id: string;
|
|
221
|
+
content: string;
|
|
222
|
+
role: 'user' | 'assistant';
|
|
223
|
+
timestamp: string;
|
|
224
|
+
metadata?: {
|
|
225
|
+
model?: string; // AI model used
|
|
226
|
+
permissions?: string[]; // User permissions
|
|
227
|
+
issuedBy?: string; // Wallet address
|
|
228
|
+
toolUse?: { // Tool call information
|
|
229
|
+
name: string;
|
|
230
|
+
input: Record<string, any>;
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
172
236
|
## Component Usage
|
|
173
237
|
|
|
174
238
|
### Using Components Individually
|
|
@@ -180,7 +244,7 @@ import {
|
|
|
180
244
|
ModelSelector,
|
|
181
245
|
MessageList,
|
|
182
246
|
MessageInput
|
|
183
|
-
} from 'nxtlinq-ai-agent-sdk';
|
|
247
|
+
} from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
184
248
|
|
|
185
249
|
function CustomChatBot() {
|
|
186
250
|
return (
|
|
@@ -197,7 +261,7 @@ function CustomChatBot() {
|
|
|
197
261
|
}
|
|
198
262
|
```
|
|
199
263
|
|
|
200
|
-
### Custom Layout
|
|
264
|
+
### Custom Layout with Model Selector
|
|
201
265
|
|
|
202
266
|
```tsx
|
|
203
267
|
import {
|
|
@@ -206,7 +270,7 @@ import {
|
|
|
206
270
|
ModelSelector,
|
|
207
271
|
MessageList,
|
|
208
272
|
MessageInput
|
|
209
|
-
} from 'nxtlinq-ai-agent-sdk';
|
|
273
|
+
} from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
210
274
|
|
|
211
275
|
function CustomLayout() {
|
|
212
276
|
const { isOpen, setIsOpen } = useChatBot();
|
|
@@ -214,7 +278,7 @@ function CustomLayout() {
|
|
|
214
278
|
if (!isOpen) {
|
|
215
279
|
return (
|
|
216
280
|
<button onClick={() => setIsOpen(true)}>
|
|
217
|
-
Open
|
|
281
|
+
Open AI Agent
|
|
218
282
|
</button>
|
|
219
283
|
);
|
|
220
284
|
}
|
|
@@ -274,6 +338,11 @@ function App() {
|
|
|
274
338
|
.nxtlinq-model-selector {
|
|
275
339
|
/* Custom styles */
|
|
276
340
|
}
|
|
341
|
+
|
|
342
|
+
/* Model badge */
|
|
343
|
+
.nxtlinq-model-badge {
|
|
344
|
+
/* Custom styles */
|
|
345
|
+
}
|
|
277
346
|
```
|
|
278
347
|
|
|
279
348
|
### Inline Style Override
|
|
@@ -287,7 +356,9 @@ function App() {
|
|
|
287
356
|
style={{
|
|
288
357
|
'--primary-color': '#007bff',
|
|
289
358
|
'--secondary-color': '#6c757d',
|
|
290
|
-
'--border-radius': '10px'
|
|
359
|
+
'--border-radius': '10px',
|
|
360
|
+
'--model-badge-bg': '#e3f2fd',
|
|
361
|
+
'--model-badge-color': '#1976d2'
|
|
291
362
|
}}
|
|
292
363
|
/>
|
|
293
364
|
```
|
|
@@ -303,16 +374,17 @@ function App() {
|
|
|
303
374
|
apiSecret="your-api-secret"
|
|
304
375
|
onModelChange={(model) => {
|
|
305
376
|
console.log('Model changed to:', model.label);
|
|
306
|
-
//
|
|
377
|
+
// Add analytics tracking
|
|
307
378
|
analytics.track('model_changed', {
|
|
308
379
|
model: model.value,
|
|
309
|
-
label: model.label
|
|
380
|
+
label: model.label,
|
|
381
|
+
timestamp: new Date().toISOString()
|
|
310
382
|
});
|
|
311
383
|
}}
|
|
312
384
|
/>
|
|
313
385
|
```
|
|
314
386
|
|
|
315
|
-
### Message Events
|
|
387
|
+
### Message Events with Model Information
|
|
316
388
|
|
|
317
389
|
```tsx
|
|
318
390
|
<ChatBot
|
|
@@ -321,11 +393,18 @@ function App() {
|
|
|
321
393
|
apiSecret="your-api-secret"
|
|
322
394
|
onMessage={(message) => {
|
|
323
395
|
console.log('New message:', message);
|
|
324
|
-
//
|
|
396
|
+
// Track message with model info
|
|
325
397
|
if (message.role === 'user') {
|
|
326
398
|
analytics.track('user_message', {
|
|
327
399
|
content: message.content,
|
|
328
|
-
model: message.metadata?.model
|
|
400
|
+
model: message.metadata?.model,
|
|
401
|
+
timestamp: message.timestamp
|
|
402
|
+
});
|
|
403
|
+
} else if (message.role === 'assistant') {
|
|
404
|
+
analytics.track('ai_response', {
|
|
405
|
+
model: message.metadata?.model,
|
|
406
|
+
hasToolUse: !!message.metadata?.toolUse,
|
|
407
|
+
timestamp: message.timestamp
|
|
329
408
|
});
|
|
330
409
|
}
|
|
331
410
|
}}
|
|
@@ -341,24 +420,94 @@ function App() {
|
|
|
341
420
|
apiSecret="your-api-secret"
|
|
342
421
|
onError={(error) => {
|
|
343
422
|
console.error('ChatBot error:', error);
|
|
344
|
-
//
|
|
423
|
+
// Add error reporting
|
|
345
424
|
errorReporting.captureException(error);
|
|
425
|
+
|
|
426
|
+
// Track error with context
|
|
427
|
+
analytics.track('chatbot_error', {
|
|
428
|
+
error: error.message,
|
|
429
|
+
stack: error.stack,
|
|
430
|
+
timestamp: new Date().toISOString()
|
|
431
|
+
});
|
|
346
432
|
}}
|
|
347
433
|
/>
|
|
348
434
|
```
|
|
349
435
|
|
|
350
436
|
## Best Practices
|
|
351
437
|
|
|
352
|
-
1.
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
438
|
+
### 1. Model Selection
|
|
439
|
+
- Choose appropriate AI models based on use cases
|
|
440
|
+
- Consider user preferences and requirements
|
|
441
|
+
- Monitor model performance and usage
|
|
442
|
+
|
|
443
|
+
### 2. Error Handling
|
|
444
|
+
- Always provide `onError` callback to handle errors
|
|
445
|
+
- Implement proper error reporting and monitoring
|
|
446
|
+
- Provide fallback mechanisms for failed requests
|
|
447
|
+
|
|
448
|
+
### 3. User Experience
|
|
449
|
+
- Use preset messages to guide users
|
|
450
|
+
- Provide clear model switching feedback
|
|
451
|
+
- Maintain conversation context across model switches
|
|
452
|
+
|
|
453
|
+
### 4. Performance Optimization
|
|
454
|
+
- Set reasonable retry counts and delays
|
|
455
|
+
- Implement proper loading states
|
|
456
|
+
- Optimize for different network conditions
|
|
457
|
+
|
|
458
|
+
### 5. Security
|
|
459
|
+
- Keep API keys secure and use environment variables
|
|
460
|
+
- Validate user permissions before tool calls
|
|
461
|
+
- Implement proper wallet verification
|
|
462
|
+
|
|
463
|
+
## Migration Guide
|
|
464
|
+
|
|
465
|
+
### From v1.2.3 to v1.2.4
|
|
466
|
+
|
|
467
|
+
1. **Update package version**:
|
|
468
|
+
```bash
|
|
469
|
+
npm install @bytexbyte/nxtlinq-ai-agent-sdk@1.2.4
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
2. **Add model switching props** (optional):
|
|
473
|
+
```tsx
|
|
474
|
+
<ChatBot
|
|
475
|
+
// ... existing props
|
|
476
|
+
showModelSelector={true}
|
|
477
|
+
onModelChange={(model) => console.log('Model:', model.label)}
|
|
478
|
+
/>
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
3. **Update message handling** (if needed):
|
|
482
|
+
```tsx
|
|
483
|
+
onMessage={(message) => {
|
|
484
|
+
// Now includes model information
|
|
485
|
+
console.log('Model used:', message.metadata?.model);
|
|
486
|
+
}}
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
## Changelog
|
|
490
|
+
|
|
491
|
+
### v1.2.4 (Latest)
|
|
492
|
+
- ✨ **NEW**: AI model switching functionality
|
|
493
|
+
- ✨ **NEW**: Support for 5 AI models (Nova, Claude, ChatGPT, Llama, Gemini)
|
|
494
|
+
- ✨ **NEW**: ModelSelector dropdown component
|
|
495
|
+
- ✨ **NEW**: Model badges in messages
|
|
496
|
+
- ✨ **NEW**: Persistent model preferences
|
|
497
|
+
- 🔧 **IMPROVED**: Enhanced API client with dynamic endpoints
|
|
498
|
+
- 🔧 **IMPROVED**: Better TypeScript types and interfaces
|
|
499
|
+
- 📚 **UPDATED**: Comprehensive documentation and examples
|
|
500
|
+
|
|
501
|
+
### v1.2.3
|
|
502
|
+
- Initial release with basic functionality
|
|
357
503
|
|
|
358
|
-
##
|
|
504
|
+
## Support
|
|
359
505
|
|
|
360
|
-
|
|
506
|
+
For questions, issues, or feature requests:
|
|
507
|
+
- 📧 Email: support@nxtlinq.ai
|
|
508
|
+
- 📖 Documentation: https://docs.nxtlinq.ai
|
|
509
|
+
- 🐛 Issues: https://github.com/bytexbyte/nxtlinq-ai-agent-sdk/issues
|
|
361
510
|
|
|
362
|
-
##
|
|
511
|
+
## License
|
|
363
512
|
|
|
364
|
-
|
|
513
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../../src/components/context/ChatBotContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EACL,kBAAkB,EAClB,YAAY,EAOb,MAAM,uBAAuB,CAAC;AAI/B,eAAO,MAAM,UAAU,0BAMtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"ChatBotContext.d.ts","sourceRoot":"","sources":["../../../src/components/context/ChatBotContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EACL,kBAAkB,EAClB,YAAY,EAOb,MAAM,uBAAuB,CAAC;AAI/B,eAAO,MAAM,UAAU,0BAMtB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAg7BlD,CAAC"}
|
|
@@ -322,6 +322,15 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
322
322
|
return false;
|
|
323
323
|
}
|
|
324
324
|
const availablePermissionLabels = availablePermissions.map(p => p.label);
|
|
325
|
+
if (availablePermissions.length === 0) {
|
|
326
|
+
setMessages(prev => [...prev, {
|
|
327
|
+
id: Date.now().toString(),
|
|
328
|
+
content: `No permissions available for your current identity provider. Please check your service configuration or contact support. Service ID: ${serviceId}, Permission Group: ${permissionGroup || 'None'}`,
|
|
329
|
+
role: 'assistant',
|
|
330
|
+
timestamp: new Date().toISOString()
|
|
331
|
+
}]);
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
325
334
|
if (!availablePermissionLabels.includes(toolName)) {
|
|
326
335
|
setMessages(prev => [...prev, {
|
|
327
336
|
id: Date.now().toString(),
|
|
@@ -391,6 +400,10 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
391
400
|
// Handle tool calls
|
|
392
401
|
const toolUse = response.toolCall.toolUse;
|
|
393
402
|
if (onToolUse) {
|
|
403
|
+
const isToolAllowed = await hasPermission(toolUse.name);
|
|
404
|
+
if (!isToolAllowed) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
394
407
|
const toolResult = await onToolUse(toolUse);
|
|
395
408
|
if (toolResult) {
|
|
396
409
|
// Ensure the tool result has model information
|
|
@@ -574,7 +587,7 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
574
587
|
}
|
|
575
588
|
};
|
|
576
589
|
// Generate and register AIT
|
|
577
|
-
const generateAndRegisterAIT = async () => {
|
|
590
|
+
const generateAndRegisterAIT = async (newPermissions) => {
|
|
578
591
|
if (!signer || !hitAddress) {
|
|
579
592
|
throw new Error('Missing signer or wallet address');
|
|
580
593
|
}
|
|
@@ -582,7 +595,7 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
582
595
|
const aitId = `did:polygon:ike-dashboard:${hitAddress}:${timestamp}`;
|
|
583
596
|
const metadata = {
|
|
584
597
|
model: 'gpt-4',
|
|
585
|
-
permissions,
|
|
598
|
+
permissions: newPermissions || permissions,
|
|
586
599
|
issuedBy: hitAddress,
|
|
587
600
|
};
|
|
588
601
|
const metadataStr = stringify(metadata);
|
|
@@ -613,10 +626,10 @@ availableModels = DEFAULT_AI_MODELS, defaultModelIndex = 0, showModelSelector =
|
|
|
613
626
|
setPermissions(permissions);
|
|
614
627
|
};
|
|
615
628
|
// Save permissions
|
|
616
|
-
const savePermissions = async () => {
|
|
629
|
+
const savePermissions = async (newPermissions) => {
|
|
617
630
|
setIsDisabled(true);
|
|
618
631
|
try {
|
|
619
|
-
await generateAndRegisterAIT();
|
|
632
|
+
await generateAndRegisterAIT(newPermissions);
|
|
620
633
|
showSuccess('AIT permissions saved successfully! You can now use the AI agent with your configured permissions.');
|
|
621
634
|
setShowPermissionForm(false);
|
|
622
635
|
setIsPermissionFormOpen(false);
|
|
@@ -93,7 +93,7 @@ export interface ChatBotContextType {
|
|
|
93
93
|
sendMessage: (content: string, retryCount?: number) => Promise<void>;
|
|
94
94
|
handleSubmit: (e: React.FormEvent) => Promise<void>;
|
|
95
95
|
handlePresetMessage: (message: PresetMessage) => void;
|
|
96
|
-
savePermissions: () => Promise<void>;
|
|
96
|
+
savePermissions: (newPermissions?: string[]) => Promise<void>;
|
|
97
97
|
handleVerifyWalletClick: () => Promise<void>;
|
|
98
98
|
showSuccess: (message: string) => void;
|
|
99
99
|
showError: (message: string) => void;
|
|
@@ -102,7 +102,7 @@ export interface ChatBotContextType {
|
|
|
102
102
|
refreshAIT: (forceUpdatePermissions?: boolean) => Promise<void>;
|
|
103
103
|
handleModelChange: (modelIndex: number) => void;
|
|
104
104
|
getCurrentModel: () => AIModel;
|
|
105
|
-
onSave: () => Promise<void>;
|
|
105
|
+
onSave: (newPermissions?: string[]) => Promise<void>;
|
|
106
106
|
onConnectWallet: () => Promise<string | undefined>;
|
|
107
107
|
onSignIn: () => Promise<void>;
|
|
108
108
|
isNeedSignInWithWallet: boolean;
|
|
@@ -1 +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;CAClB;AA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AE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhE,iBAAiB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,eAAe,EAAE,MAAM,OAAO,CAAC;IAG/B,MAAM,EAAE,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,eAAe,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatBotUI.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ChatBotUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatBotUI.d.ts","sourceRoot":"","sources":["../../../src/components/ui/ChatBotUI.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAqG/B,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAmP7B,CAAC"}
|
|
@@ -1,12 +1,81 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useChatBot } from '../context/ChatBotContext';
|
|
4
|
-
import { NotificationModal } from './NotificationModal';
|
|
5
4
|
import { PermissionForm } from './PermissionForm';
|
|
6
5
|
import { MessageList } from './MessageList';
|
|
7
6
|
import { MessageInput } from './MessageInput';
|
|
8
7
|
import { PresetMessages } from './PresetMessages';
|
|
9
8
|
import { ModelSelector } from './ModelSelector';
|
|
9
|
+
// Toast Notification Component
|
|
10
|
+
const ToastNotification = ({ type, message, onClose, isChatOpen = false }) => {
|
|
11
|
+
const getStyles = () => {
|
|
12
|
+
const baseStyles = {
|
|
13
|
+
position: 'fixed',
|
|
14
|
+
padding: '12px 24px',
|
|
15
|
+
borderRadius: 8,
|
|
16
|
+
zIndex: 2000,
|
|
17
|
+
fontWeight: 600,
|
|
18
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
|
|
19
|
+
transition: 'all 0.3s ease',
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center',
|
|
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
|
+
}
|
|
42
|
+
switch (type) {
|
|
43
|
+
case 'success':
|
|
44
|
+
return { ...baseStyles, background: '#4caf50', color: 'white' };
|
|
45
|
+
case 'error':
|
|
46
|
+
return { ...baseStyles, background: '#f44336', color: 'white' };
|
|
47
|
+
case 'warning':
|
|
48
|
+
return { ...baseStyles, background: '#ff9800', color: 'white' };
|
|
49
|
+
default:
|
|
50
|
+
return { ...baseStyles, background: '#2196f3', color: 'white' };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const getIcon = () => {
|
|
54
|
+
switch (type) {
|
|
55
|
+
case 'success':
|
|
56
|
+
return '✅';
|
|
57
|
+
case 'error':
|
|
58
|
+
return '❌';
|
|
59
|
+
case 'warning':
|
|
60
|
+
return '⚠️';
|
|
61
|
+
default:
|
|
62
|
+
return 'ℹ️';
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return (_jsxs("div", { style: getStyles(), children: [_jsx("span", { style: { fontSize: '18px' }, children: getIcon() }), _jsx("span", { style: { flex: 1 }, children: message }), _jsx("button", { onClick: onClose, style: {
|
|
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" })] }));
|
|
78
|
+
};
|
|
10
79
|
export const ChatBotUI = () => {
|
|
11
80
|
const { isOpen, setIsOpen, showPermissionForm, setShowPermissionForm, notification, setNotification, isAITLoading, props: { className = '' } } = useChatBot();
|
|
12
81
|
// Add CSS animation for loading spinner
|
|
@@ -58,9 +127,7 @@ export const ChatBotUI = () => {
|
|
|
58
127
|
}, onMouseOut: (e) => {
|
|
59
128
|
e.currentTarget.style.backgroundColor = '#007bff';
|
|
60
129
|
e.currentTarget.style.transform = 'translateY(0)';
|
|
61
|
-
}, title: "Open AI Agent Chat", children: "AI Agent" }), notification.show && (_jsx(
|
|
62
|
-
notification.type === 'error' ? 'Error' :
|
|
63
|
-
notification.type === 'warning' ? 'Warning' : 'Info', message: notification.message, onClose: handleCloseNotification }))] }));
|
|
130
|
+
}, title: "Open AI Agent Chat", children: "AI Agent" }), notification.show && (_jsx(ToastNotification, { type: notification.type, message: notification.message, onClose: handleCloseNotification, isChatOpen: isOpen }))] }));
|
|
64
131
|
}
|
|
65
132
|
return (_jsxs(_Fragment, { children: [_jsxs("div", { style: {
|
|
66
133
|
position: 'fixed',
|
|
@@ -141,7 +208,5 @@ export const ChatBotUI = () => {
|
|
|
141
208
|
alignItems: 'center',
|
|
142
209
|
justifyContent: 'center',
|
|
143
210
|
zIndex: 1002
|
|
144
|
-
}, children: _jsx(PermissionForm, { onClose: () => setShowPermissionForm(false), onOpen: () => setShowPermissionForm(true) }) })), notification.show && (_jsx(
|
|
145
|
-
notification.type === 'error' ? 'Error' :
|
|
146
|
-
notification.type === 'warning' ? 'Warning' : 'Info', message: notification.message, onClose: handleCloseNotification }))] }));
|
|
211
|
+
}, children: _jsx(PermissionForm, { onClose: () => setShowPermissionForm(false), onOpen: () => setShowPermissionForm(true) }) })), notification.show && (_jsx(ToastNotification, { type: notification.type, message: notification.message, onClose: handleCloseNotification, isChatOpen: isOpen }))] }));
|
|
147
212
|
};
|
|
@@ -1 +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,
|
|
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,EAsFhC,CAAC"}
|
|
@@ -3,7 +3,6 @@ import { useChatBot } from '../context/ChatBotContext';
|
|
|
3
3
|
export const MessageInput = () => {
|
|
4
4
|
const { inputValue, setInputValue, isLoading, isAITLoading, handleSubmit, props: { placeholder = 'Type a message...' } } = useChatBot();
|
|
5
5
|
const isDisabled = isLoading || isAITLoading;
|
|
6
|
-
const buttonText = isLoading ? 'Sending...' : isAITLoading ? 'Loading...' : 'Send';
|
|
7
6
|
const inputPlaceholder = isAITLoading ? 'Loading wallet configuration...' : placeholder;
|
|
8
7
|
const handleKeyPress = (e) => {
|
|
9
8
|
if (e.key === 'Enter' && !e.shiftKey) {
|
|
@@ -24,7 +23,7 @@ export const MessageInput = () => {
|
|
|
24
23
|
outline: 'none',
|
|
25
24
|
fontSize: '14px',
|
|
26
25
|
backgroundColor: isDisabled ? '#f8f9fa' : '#fff'
|
|
27
|
-
} }),
|
|
26
|
+
} }), _jsxs("button", { onClick: (e) => handleSubmit(e), disabled: isDisabled || !inputValue.trim(), style: {
|
|
28
27
|
backgroundColor: isDisabled || !inputValue.trim() ? '#e9ecef' : '#007bff',
|
|
29
28
|
color: isDisabled || !inputValue.trim() ? '#6c757d' : 'white',
|
|
30
29
|
border: 'none',
|
|
@@ -33,7 +32,11 @@ export const MessageInput = () => {
|
|
|
33
32
|
cursor: isDisabled || !inputValue.trim() ? 'not-allowed' : 'pointer',
|
|
34
33
|
fontSize: '14px',
|
|
35
34
|
fontWeight: '500',
|
|
36
|
-
transition: 'background-color 0.3s'
|
|
35
|
+
transition: 'background-color 0.3s',
|
|
36
|
+
position: 'relative',
|
|
37
|
+
display: 'flex',
|
|
38
|
+
alignItems: 'center',
|
|
39
|
+
justifyContent: 'center'
|
|
37
40
|
}, onMouseOver: (e) => {
|
|
38
41
|
if (!isDisabled && inputValue.trim()) {
|
|
39
42
|
e.currentTarget.style.backgroundColor = '#0056b3';
|
|
@@ -42,5 +45,5 @@ export const MessageInput = () => {
|
|
|
42
45
|
if (!isDisabled && inputValue.trim()) {
|
|
43
46
|
e.currentTarget.style.backgroundColor = '#007bff';
|
|
44
47
|
}
|
|
45
|
-
}, children:
|
|
48
|
+
}, children: ["Send", (isLoading || isAITLoading) && (_jsx("span", { style: { marginLeft: 8, display: 'flex', alignItems: 'center' }, 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" }) }) }) }))] })] }));
|
|
46
49
|
};
|
|
@@ -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;AAI/B,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,
|
|
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,EAiJ/B,CAAC"}
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { useChatBot } from '../context/ChatBotContext';
|
|
4
4
|
import { AI_MODEL_MAP } from '../types/ChatBotTypes';
|
|
5
5
|
export const MessageList = () => {
|
|
6
|
-
const { messages, isLoading, connectWallet, signInWallet, hitAddress, ait, setShowPermissionForm, isWalletLoading } = useChatBot();
|
|
6
|
+
const { messages, isLoading, connectWallet, signInWallet, hitAddress, ait, setShowPermissionForm, isWalletLoading, isNeedSignInWithWallet } = useChatBot();
|
|
7
7
|
const messagesEndRef = React.useRef(null);
|
|
8
8
|
const scrollToBottom = () => {
|
|
9
9
|
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
|
@@ -42,16 +42,22 @@ export const MessageList = () => {
|
|
|
42
42
|
borderRadius: '15px',
|
|
43
43
|
wordWrap: 'break-word',
|
|
44
44
|
position: 'relative'
|
|
45
|
-
}, children: [message.content, message.button && (_jsx("div", { style: { marginTop: '10px' }, children: _jsx("button", { onClick: () => handleButtonClick(message.button),
|
|
45
|
+
}, children: [message.content, message.button && (_jsx("div", { style: { marginTop: '10px' }, children: _jsx("button", { onClick: () => handleButtonClick(message.button), disabled: (message.button === 'connect' && Boolean(hitAddress)) ||
|
|
46
|
+
(message.button === 'signIn' && !isNeedSignInWithWallet), style: {
|
|
46
47
|
padding: '8px 16px',
|
|
47
|
-
backgroundColor: message.role === 'user' ? 'rgba(255, 255, 255, 0.2)' :
|
|
48
|
+
backgroundColor: message.role === 'user' ? 'rgba(255, 255, 255, 0.2)' :
|
|
49
|
+
(message.button === 'connect' && Boolean(hitAddress)) ? '#28a745' :
|
|
50
|
+
(message.button === 'signIn' && !isNeedSignInWithWallet) ? '#28a745' : '#007bff',
|
|
48
51
|
color: message.role === 'user' ? 'white' : 'white',
|
|
49
52
|
border: 'none',
|
|
50
53
|
borderRadius: '5px',
|
|
51
|
-
cursor: '
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
cursor: ((message.button === 'connect' && Boolean(hitAddress)) ||
|
|
55
|
+
(message.button === 'signIn' && !isNeedSignInWithWallet)) ? 'not-allowed' : 'pointer',
|
|
56
|
+
fontSize: '14px',
|
|
57
|
+
opacity: ((message.button === 'connect' && Boolean(hitAddress)) ||
|
|
58
|
+
(message.button === 'signIn' && !isNeedSignInWithWallet)) ? 0.8 : 1
|
|
59
|
+
}, children: message.button === 'connect' ? (Boolean(hitAddress) ? 'Connected' : 'Connect Wallet') :
|
|
60
|
+
message.button === 'signIn' ? (!isNeedSignInWithWallet ? 'Signed In' : 'Sign In') : message.button }) }))] }), message.role === 'assistant' && message.metadata?.model && (_jsx("div", { style: {
|
|
55
61
|
display: 'flex',
|
|
56
62
|
alignItems: 'center',
|
|
57
63
|
marginTop: '4px',
|
|
@@ -1 +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,
|
|
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,CAifxD,CAAC"}
|
|
@@ -5,6 +5,11 @@ export const PermissionForm = ({ onClose, onOpen }) => {
|
|
|
5
5
|
const { hitAddress, permissions, setPermissions, setIsDisabled, onSave, onConnectWallet, onSignIn, isNeedSignInWithWallet, walletInfo, onVerifyWallet, serviceId, nxtlinqApi, permissionGroup, isAITLoading, isWalletLoading = false } = useChatBot();
|
|
6
6
|
const [availablePermissions, setAvailablePermissions] = React.useState([]);
|
|
7
7
|
const [isSaving, setIsSaving] = React.useState(false);
|
|
8
|
+
const [tempPermissions, setTempPermissions] = React.useState(permissions);
|
|
9
|
+
// Update temp permissions when permissions change
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
setTempPermissions(permissions);
|
|
12
|
+
}, [permissions]);
|
|
8
13
|
const fetchAvailablePermissions = async () => {
|
|
9
14
|
if (!serviceId)
|
|
10
15
|
return;
|
|
@@ -30,12 +35,26 @@ export const PermissionForm = ({ onClose, onOpen }) => {
|
|
|
30
35
|
const handleSave = async () => {
|
|
31
36
|
setIsSaving(true);
|
|
32
37
|
try {
|
|
33
|
-
|
|
38
|
+
// Update the actual permissions with temp permissions
|
|
39
|
+
setPermissions(tempPermissions);
|
|
40
|
+
await onSave(tempPermissions);
|
|
34
41
|
}
|
|
35
42
|
finally {
|
|
36
43
|
setIsSaving(false);
|
|
37
44
|
}
|
|
38
45
|
};
|
|
46
|
+
const handleCancel = () => {
|
|
47
|
+
// Reset temp permissions to original permissions
|
|
48
|
+
setTempPermissions(permissions);
|
|
49
|
+
onClose();
|
|
50
|
+
};
|
|
51
|
+
// Check if permissions have changed
|
|
52
|
+
const hasPermissionChanges = () => {
|
|
53
|
+
if (tempPermissions.length !== permissions.length)
|
|
54
|
+
return true;
|
|
55
|
+
return tempPermissions.some(p => !permissions.includes(p)) ||
|
|
56
|
+
permissions.some(p => !tempPermissions.includes(p));
|
|
57
|
+
};
|
|
39
58
|
// Show loading state while checking wallet status
|
|
40
59
|
if (isWalletLoading) {
|
|
41
60
|
return (_jsxs("div", { style: {
|
|
@@ -132,17 +151,26 @@ export const PermissionForm = ({ onClose, onOpen }) => {
|
|
|
132
151
|
marginBottom: '24px',
|
|
133
152
|
fontSize: '16px',
|
|
134
153
|
color: '#666'
|
|
135
|
-
}, children: "Please connect your wallet first" }), _jsx("button", { onClick: onConnectWallet, style: {
|
|
154
|
+
}, children: "Please connect your wallet first" }), _jsx("button", { onClick: onConnectWallet, disabled: Boolean(hitAddress), style: {
|
|
136
155
|
padding: '12px 24px',
|
|
137
|
-
backgroundColor: '#007bff',
|
|
156
|
+
backgroundColor: Boolean(hitAddress) ? '#28a745' : '#007bff',
|
|
138
157
|
color: 'white',
|
|
139
158
|
border: 'none',
|
|
140
159
|
borderRadius: '8px',
|
|
141
|
-
cursor: 'pointer',
|
|
160
|
+
cursor: Boolean(hitAddress) ? 'not-allowed' : 'pointer',
|
|
142
161
|
fontSize: '16px',
|
|
143
162
|
fontWeight: '500',
|
|
144
|
-
transition: 'background-color 0.2s'
|
|
145
|
-
|
|
163
|
+
transition: 'background-color 0.2s',
|
|
164
|
+
opacity: Boolean(hitAddress) ? 0.8 : 1
|
|
165
|
+
}, onMouseOver: (e) => {
|
|
166
|
+
if (!Boolean(hitAddress)) {
|
|
167
|
+
e.currentTarget.style.backgroundColor = '#0056b3';
|
|
168
|
+
}
|
|
169
|
+
}, onMouseOut: (e) => {
|
|
170
|
+
if (!Boolean(hitAddress)) {
|
|
171
|
+
e.currentTarget.style.backgroundColor = '#007bff';
|
|
172
|
+
}
|
|
173
|
+
}, children: Boolean(hitAddress) ? 'Connected' : 'Connect Wallet' })] })) : isNeedSignInWithWallet ? (_jsxs("div", { style: { textAlign: 'center', padding: '32px 0' }, children: [_jsxs("div", { style: { marginBottom: '24px' }, children: [_jsx("h4", { style: {
|
|
146
174
|
marginBottom: '12px',
|
|
147
175
|
fontSize: '16px',
|
|
148
176
|
color: '#666'
|
|
@@ -158,17 +186,26 @@ export const PermissionForm = ({ onClose, onOpen }) => {
|
|
|
158
186
|
marginBottom: '24px',
|
|
159
187
|
fontSize: '16px',
|
|
160
188
|
color: '#666'
|
|
161
|
-
}, children: "Please sign in to continue" }), _jsx("button", { onClick: onSignIn, style: {
|
|
189
|
+
}, children: "Please sign in to continue" }), _jsx("button", { onClick: onSignIn, disabled: !isNeedSignInWithWallet, style: {
|
|
162
190
|
padding: '12px 24px',
|
|
163
|
-
backgroundColor: '#007bff',
|
|
191
|
+
backgroundColor: !isNeedSignInWithWallet ? '#28a745' : '#007bff',
|
|
164
192
|
color: 'white',
|
|
165
193
|
border: 'none',
|
|
166
194
|
borderRadius: '8px',
|
|
167
|
-
cursor: 'pointer',
|
|
195
|
+
cursor: !isNeedSignInWithWallet ? 'not-allowed' : 'pointer',
|
|
168
196
|
fontSize: '16px',
|
|
169
197
|
fontWeight: '500',
|
|
170
|
-
transition: 'background-color 0.2s'
|
|
171
|
-
|
|
198
|
+
transition: 'background-color 0.2s',
|
|
199
|
+
opacity: !isNeedSignInWithWallet ? 0.8 : 1
|
|
200
|
+
}, onMouseOver: (e) => {
|
|
201
|
+
if (isNeedSignInWithWallet) {
|
|
202
|
+
e.currentTarget.style.backgroundColor = '#0056b3';
|
|
203
|
+
}
|
|
204
|
+
}, onMouseOut: (e) => {
|
|
205
|
+
if (isNeedSignInWithWallet) {
|
|
206
|
+
e.currentTarget.style.backgroundColor = '#007bff';
|
|
207
|
+
}
|
|
208
|
+
}, children: !isNeedSignInWithWallet ? 'Signed In' : 'Sign In' })] })) : !isWalletVerified ? (_jsxs("div", { style: { textAlign: 'center', padding: '32px 0' }, children: [_jsxs("div", { style: { marginBottom: '24px' }, children: [_jsx("h4", { style: {
|
|
172
209
|
marginBottom: '12px',
|
|
173
210
|
fontSize: '16px',
|
|
174
211
|
color: '#666'
|
|
@@ -239,12 +276,12 @@ export const PermissionForm = ({ onClose, onOpen }) => {
|
|
|
239
276
|
if (!isAITLoading) {
|
|
240
277
|
e.currentTarget.style.backgroundColor = 'transparent';
|
|
241
278
|
}
|
|
242
|
-
}, children: [_jsx("input", { type: "checkbox", checked:
|
|
279
|
+
}, children: [_jsx("input", { type: "checkbox", checked: tempPermissions.includes(permission.label), onChange: () => {
|
|
243
280
|
if (!isAITLoading) {
|
|
244
|
-
const newPermissions =
|
|
245
|
-
?
|
|
246
|
-
: [...
|
|
247
|
-
|
|
281
|
+
const newPermissions = tempPermissions.includes(permission.label)
|
|
282
|
+
? tempPermissions.filter(p => p !== permission.label)
|
|
283
|
+
: [...tempPermissions, permission.label].sort();
|
|
284
|
+
setTempPermissions(newPermissions);
|
|
248
285
|
setIsDisabled(false);
|
|
249
286
|
}
|
|
250
287
|
}, disabled: isAITLoading, style: {
|
|
@@ -261,7 +298,7 @@ export const PermissionForm = ({ onClose, onOpen }) => {
|
|
|
261
298
|
gap: '12px',
|
|
262
299
|
borderTop: '1px solid #e9ecef',
|
|
263
300
|
paddingTop: '24px'
|
|
264
|
-
}, children: [_jsx("button", { onClick:
|
|
301
|
+
}, children: [_jsx("button", { onClick: handleCancel, style: {
|
|
265
302
|
padding: '10px 20px',
|
|
266
303
|
backgroundColor: '#f8f9fa',
|
|
267
304
|
color: '#666',
|
|
@@ -277,22 +314,22 @@ export const PermissionForm = ({ onClose, onOpen }) => {
|
|
|
277
314
|
}, onMouseOut: (e) => {
|
|
278
315
|
e.currentTarget.style.backgroundColor = '#f8f9fa';
|
|
279
316
|
e.currentTarget.style.borderColor = '#dee2e6';
|
|
280
|
-
}, children: "Cancel" }), _jsx("button", { onClick: handleSave, disabled:
|
|
317
|
+
}, children: "Cancel" }), _jsx("button", { onClick: handleSave, disabled: !hasPermissionChanges() || isSaving || isAITLoading, style: {
|
|
281
318
|
padding: '10px 20px',
|
|
282
|
-
backgroundColor:
|
|
283
|
-
color:
|
|
319
|
+
backgroundColor: !hasPermissionChanges() || isSaving || isAITLoading ? '#e9ecef' : '#007bff',
|
|
320
|
+
color: !hasPermissionChanges() || isSaving || isAITLoading ? '#6c757d' : 'white',
|
|
284
321
|
border: 'none',
|
|
285
322
|
borderRadius: '8px',
|
|
286
|
-
cursor:
|
|
323
|
+
cursor: !hasPermissionChanges() || isSaving || isAITLoading ? 'not-allowed' : 'pointer',
|
|
287
324
|
fontSize: '14px',
|
|
288
325
|
fontWeight: '500',
|
|
289
326
|
transition: 'background-color 0.2s'
|
|
290
327
|
}, onMouseOver: (e) => {
|
|
291
|
-
if (
|
|
328
|
+
if (hasPermissionChanges() && !isSaving && !isAITLoading) {
|
|
292
329
|
e.currentTarget.style.backgroundColor = '#0056b3';
|
|
293
330
|
}
|
|
294
331
|
}, onMouseOut: (e) => {
|
|
295
|
-
if (
|
|
332
|
+
if (hasPermissionChanges() && !isSaving && !isAITLoading) {
|
|
296
333
|
e.currentTarget.style.backgroundColor = '#007bff';
|
|
297
334
|
}
|
|
298
335
|
}, children: isSaving ? 'Saving...' : 'Save' })] })] }))] }));
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export { PresetMessages } from './components/ui/PresetMessages';
|
|
|
7
7
|
export { PermissionForm } from './components/ui/PermissionForm';
|
|
8
8
|
export { NotificationModal } from './components/ui/NotificationModal';
|
|
9
9
|
export { ModelSelector } from './components/ui/ModelSelector';
|
|
10
|
-
export type { ChatBotProps, ChatBotContextType, PresetMessage, ToolUse, ToolCall, NovaResponse, NovaError, AITMetadata, AIModel
|
|
10
|
+
export type { ChatBotProps, ChatBotContextType, PresetMessage, ToolUse, ToolCall, NovaResponse, NovaError, AITMetadata, AIModel } from './components/types/ChatBotTypes';
|
|
11
|
+
export { DEFAULT_AI_MODELS, AI_MODEL_MAP } from './components/types/ChatBotTypes';
|
|
11
12
|
export { connectWallet, disconnectWallet, validateToken } from './core/utils/walletUtils';
|
|
12
13
|
export { generateAITId, createAITMetadata, prepareAITCreation } from './core/utils/aitUtils';
|
|
13
14
|
export { createNotification, getNotificationIcon } from './core/utils/notificationUtils';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAG9D,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,WAAW,EAEX,OAAO,
|
|
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;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAG9D,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,WAAW,EAEX,OAAO,EACR,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,iBAAiB,EACjB,YAAY,EACb,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
|
@@ -10,6 +10,8 @@ export { PresetMessages } from './components/ui/PresetMessages';
|
|
|
10
10
|
export { PermissionForm } from './components/ui/PermissionForm';
|
|
11
11
|
export { NotificationModal } from './components/ui/NotificationModal';
|
|
12
12
|
export { ModelSelector } from './components/ui/ModelSelector';
|
|
13
|
+
// AI Model constants
|
|
14
|
+
export { DEFAULT_AI_MODELS, AI_MODEL_MAP } from './components/types/ChatBotTypes';
|
|
13
15
|
// Utility functions
|
|
14
16
|
export { connectWallet, disconnectWallet, validateToken } from './core/utils/walletUtils';
|
|
15
17
|
export { generateAITId, createAITMetadata, prepareAITCreation } from './core/utils/aitUtils';
|
package/package.json
CHANGED