@bytexbyte/nxtlinq-ai-agent-sdk 1.4.7 → 1.5.0
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 +74 -531
- package/dist/components/ChatBot.d.ts.map +1 -1
- package/dist/components/ChatBot.js +29 -2
- package/dist/components/context/ChatBotContext.d.ts.map +1 -1
- package/dist/components/context/ChatBotContext.js +16 -3
- package/dist/components/types/ChatBotTypes.d.ts +1 -0
- package/dist/components/types/ChatBotTypes.d.ts.map +1 -1
- package/dist/components/ui/BerifyMeModal.d.ts +20 -0
- package/dist/components/ui/BerifyMeModal.d.ts.map +1 -0
- package/dist/components/ui/BerifyMeModal.js +107 -0
- package/dist/components/ui/ChatBotUI.d.ts.map +1 -1
- package/dist/components/ui/ChatBotUI.js +157 -3
- package/dist/components/ui/PermissionForm.d.ts.map +1 -1
- package/dist/components/ui/PermissionForm.js +5 -2
- package/dist/core/utils/__tests__/urlUtils.test.d.ts +5 -0
- package/dist/core/utils/__tests__/urlUtils.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/urlUtils.test.js +57 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/setupTests.d.ts +2 -0
- package/dist/setupTests.d.ts.map +1 -0
- package/dist/setupTests.js +16 -0
- package/dist/types/ait-api.d.ts +1 -0
- package/dist/types/ait-api.d.ts.map +1 -1
- package/package.json +2 -2
- package/umd/nxtlinq-ai-agent.umd.js +19 -19
package/README.md
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# nxtlinq AI Agent SDK
|
|
2
2
|
|
|
3
|
-
A
|
|
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
|
|
3
|
+
A comprehensive SDK for integrating AI agents with wallet verification capabilities.
|
|
12
4
|
|
|
13
5
|
## Features
|
|
14
6
|
|
|
15
|
-
- 🤖
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
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
|
|
7
|
+
- 🤖 AI-powered chat interface
|
|
8
|
+
- 🔐 Built-in BerifyMe wallet verification
|
|
9
|
+
- 🎨 Customizable UI components
|
|
10
|
+
- 🔧 Tool integration support
|
|
11
|
+
- 📱 Responsive design
|
|
23
12
|
|
|
24
13
|
## Installation
|
|
25
14
|
|
|
@@ -31,6 +20,8 @@ yarn add @bytexbyte/nxtlinq-ai-agent-sdk
|
|
|
31
20
|
|
|
32
21
|
## Quick Start
|
|
33
22
|
|
|
23
|
+
### Basic Usage
|
|
24
|
+
|
|
34
25
|
```tsx
|
|
35
26
|
import { ChatBot } from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
36
27
|
|
|
@@ -40,163 +31,36 @@ function App() {
|
|
|
40
31
|
serviceId="your-service-id"
|
|
41
32
|
apiKey="your-api-key"
|
|
42
33
|
apiSecret="your-api-secret"
|
|
43
|
-
// Enable AI model switching
|
|
44
|
-
showModelSelector={true}
|
|
45
|
-
defaultModelIndex={0} // Start with Claude (default)
|
|
46
|
-
onModelChange={(model) => {
|
|
47
|
-
console.log('Switched to:', model.label);
|
|
48
|
-
// Track model usage
|
|
49
|
-
analytics.track('model_changed', { model: model.value });
|
|
50
|
-
}}
|
|
51
34
|
/>
|
|
52
35
|
);
|
|
53
36
|
}
|
|
54
37
|
```
|
|
55
38
|
|
|
56
|
-
###
|
|
57
|
-
|
|
58
|
-
The SDK provides two ways to control which AI models are available:
|
|
59
|
-
|
|
60
|
-
#### 1. Default Models (4 models)
|
|
61
|
-
|
|
62
|
-
By default, the SDK shows these 4 AI models:
|
|
63
|
-
- Claude
|
|
64
|
-
- ChatGPT
|
|
65
|
-
- Llama
|
|
66
|
-
- Gemini
|
|
67
|
-
|
|
68
|
-
```tsx
|
|
69
|
-
<ChatBot
|
|
70
|
-
serviceId="your-service-id"
|
|
71
|
-
apiKey="your-api-key"
|
|
72
|
-
apiSecret="your-api-secret"
|
|
73
|
-
showModelSelector={true}
|
|
74
|
-
/>
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
#### 2. Custom Models
|
|
78
|
-
|
|
79
|
-
To specify exactly which models to show:
|
|
80
|
-
|
|
81
|
-
```tsx
|
|
82
|
-
<ChatBot
|
|
83
|
-
serviceId="your-service-id"
|
|
84
|
-
apiKey="your-api-key"
|
|
85
|
-
apiSecret="your-api-secret"
|
|
86
|
-
availableModels={[
|
|
87
|
-
{ label: 'Claude', value: 'claude' },
|
|
88
|
-
{ label: 'ChatGPT', value: 'open-ai' },
|
|
89
|
-
{ label: 'Nova', value: 'nova' },
|
|
90
|
-
// Only show the models you want
|
|
91
|
-
]}
|
|
92
|
-
showModelSelector={true}
|
|
93
|
-
/>
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Real-world Usage Examples
|
|
39
|
+
### With Built-in BerifyMe Support
|
|
97
40
|
|
|
98
|
-
|
|
99
|
-
```tsx
|
|
100
|
-
<ChatBot
|
|
101
|
-
serviceId="your-service-id"
|
|
102
|
-
apiKey="your-api-key"
|
|
103
|
-
apiSecret="your-api-secret"
|
|
104
|
-
// Default shows only 4 basic models
|
|
105
|
-
showModelSelector={true}
|
|
106
|
-
/>
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
#### For Premium Users (all models)
|
|
110
|
-
```tsx
|
|
111
|
-
import { ChatBot, ALL_AVAILABLE_MODELS } from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
112
|
-
|
|
113
|
-
<ChatBot
|
|
114
|
-
serviceId="your-service-id"
|
|
115
|
-
apiKey="your-api-key"
|
|
116
|
-
apiSecret="your-api-secret"
|
|
117
|
-
// Show all available models
|
|
118
|
-
availableModels={ALL_AVAILABLE_MODELS}
|
|
119
|
-
showModelSelector={true}
|
|
120
|
-
/>
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
#### For Enterprise Users (custom selection)
|
|
124
|
-
```tsx
|
|
125
|
-
<ChatBot
|
|
126
|
-
serviceId="your-service-id"
|
|
127
|
-
apiKey="your-api-key"
|
|
128
|
-
apiSecret="your-api-secret"
|
|
129
|
-
// Enterprise users only show Claude and Nova
|
|
130
|
-
availableModels={[
|
|
131
|
-
{ label: 'Claude', value: 'claude' },
|
|
132
|
-
{ label: 'Nova', value: 'nova' },
|
|
133
|
-
]}
|
|
134
|
-
showModelSelector={true}
|
|
135
|
-
/>
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### Custom Model Configuration
|
|
41
|
+
The SDK now includes built-in BerifyMe wallet verification, making integration extremely simple:
|
|
139
42
|
|
|
140
43
|
```tsx
|
|
141
44
|
import { ChatBot } from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
142
45
|
|
|
143
46
|
function App() {
|
|
144
|
-
// Custom available AI models
|
|
145
|
-
const customModels = [
|
|
146
|
-
{ label: 'Nova', value: 'nova' },
|
|
147
|
-
{ label: 'Claude', value: 'claude' },
|
|
148
|
-
{ label: 'ChatGPT', value: 'open-ai' },
|
|
149
|
-
// Add more models as needed
|
|
150
|
-
];
|
|
151
|
-
|
|
152
47
|
return (
|
|
153
48
|
<ChatBot
|
|
154
49
|
serviceId="your-service-id"
|
|
155
50
|
apiKey="your-api-key"
|
|
156
51
|
apiSecret="your-api-secret"
|
|
157
|
-
|
|
158
|
-
defaultModelIndex={1} // Default to Claude
|
|
159
|
-
showModelSelector={true}
|
|
160
|
-
onModelChange={(model) => {
|
|
161
|
-
console.log('Model changed to:', model.label);
|
|
162
|
-
}}
|
|
52
|
+
// requireWalletIDVVerification defaults to true - wallet verification is required
|
|
163
53
|
/>
|
|
164
54
|
);
|
|
165
55
|
}
|
|
166
56
|
```
|
|
167
57
|
|
|
168
|
-
###
|
|
58
|
+
### Built-in Wallet Verification (Recommended)
|
|
169
59
|
|
|
170
|
-
|
|
171
|
-
import { ChatBot } from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
172
|
-
|
|
173
|
-
function App() {
|
|
174
|
-
return (
|
|
175
|
-
<ChatBot
|
|
176
|
-
serviceId="your-service-id"
|
|
177
|
-
apiKey="your-api-key"
|
|
178
|
-
apiSecret="your-api-secret"
|
|
179
|
-
// Show all models including Nova
|
|
180
|
-
availableModels={[
|
|
181
|
-
{ label: 'Claude', value: 'claude' },
|
|
182
|
-
{ label: 'ChatGPT', value: 'open-ai' },
|
|
183
|
-
{ label: 'Llama', value: 'llama' },
|
|
184
|
-
{ label: 'Gemini', value: 'gemini' },
|
|
185
|
-
{ label: 'Nova', value: 'nova' },
|
|
186
|
-
]}
|
|
187
|
-
defaultModelIndex={0}
|
|
188
|
-
showModelSelector={true}
|
|
189
|
-
onModelChange={(model) => {
|
|
190
|
-
console.log('Model changed to:', model.label);
|
|
191
|
-
// Update user preferences
|
|
192
|
-
localStorage.setItem('preferred-model', model.value);
|
|
193
|
-
}}
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
### Advanced Configuration
|
|
60
|
+
The SDK automatically handles wallet verification. No need to implement `onVerifyWallet` manually:
|
|
197
61
|
|
|
198
62
|
```tsx
|
|
199
|
-
import { ChatBot
|
|
63
|
+
import { ChatBot } from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
200
64
|
|
|
201
65
|
function App() {
|
|
202
66
|
return (
|
|
@@ -204,434 +68,113 @@ function App() {
|
|
|
204
68
|
serviceId="your-service-id"
|
|
205
69
|
apiKey="your-api-key"
|
|
206
70
|
apiSecret="your-api-secret"
|
|
207
|
-
//
|
|
208
|
-
availableModels={DEFAULT_AI_MODELS}
|
|
209
|
-
defaultModelIndex={0}
|
|
210
|
-
showModelSelector={true}
|
|
211
|
-
onModelChange={(model) => {
|
|
212
|
-
console.log('Model changed to:', model.label);
|
|
213
|
-
// Update user preferences
|
|
214
|
-
localStorage.setItem('preferred-model', model.value);
|
|
215
|
-
}}
|
|
216
|
-
// Preset messages
|
|
217
|
-
presetMessages={[
|
|
218
|
-
{ text: 'Hello, how can you help me?', autoSend: true },
|
|
219
|
-
{ text: 'I want to switch to a different AI model.', autoSend: false },
|
|
220
|
-
{ text: 'What are the differences between the available models?', autoSend: false }
|
|
221
|
-
]}
|
|
222
|
-
// Callback functions
|
|
223
|
-
onMessage={(message) => {
|
|
224
|
-
console.log('New message:', {
|
|
225
|
-
content: message.content,
|
|
226
|
-
role: message.role,
|
|
227
|
-
model: message.metadata?.model,
|
|
228
|
-
timestamp: message.timestamp
|
|
229
|
-
});
|
|
230
|
-
}}
|
|
231
|
-
onError={(error) => {
|
|
232
|
-
console.error('ChatBot error:', error);
|
|
233
|
-
// Add error reporting
|
|
234
|
-
errorReporting.captureException(error);
|
|
235
|
-
}}
|
|
236
|
-
onToolUse={async (toolUse) => {
|
|
237
|
-
console.log('Tool used:', toolUse);
|
|
238
|
-
// Handle tool calls
|
|
239
|
-
return {
|
|
240
|
-
id: Date.now().toString(),
|
|
241
|
-
content: 'Tool executed successfully',
|
|
242
|
-
role: 'assistant',
|
|
243
|
-
timestamp: new Date().toISOString()
|
|
244
|
-
};
|
|
245
|
-
}}
|
|
246
|
-
// Wallet verification
|
|
247
|
-
onVerifyWallet={async () => {
|
|
248
|
-
// Custom wallet verification logic
|
|
249
|
-
return { token: 'your-token' };
|
|
250
|
-
}}
|
|
251
|
-
// Permission group
|
|
252
|
-
permissionGroup="default"
|
|
253
|
-
// UI configuration
|
|
254
|
-
placeholder="Type your message..."
|
|
255
|
-
className="custom-chatbot"
|
|
256
|
-
maxRetries={3}
|
|
257
|
-
retryDelay={1000}
|
|
71
|
+
// Built-in wallet verification - no onVerifyWallet needed!
|
|
258
72
|
/>
|
|
259
73
|
);
|
|
260
74
|
}
|
|
261
75
|
```
|
|
262
76
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
| `serviceId` | `string` | - | ✅ | Service ID |
|
|
270
|
-
| `apiKey` | `string` | - | ✅ | API Key |
|
|
271
|
-
| `apiSecret` | `string` | - | ✅ | API Secret |
|
|
272
|
-
| `availableModels` | `AIModel[]` | - | ❌ | Custom AI models list (highest priority) |
|
|
273
|
-
| `defaultModelIndex` | `number` | `0` | ❌ | Default selected model index |
|
|
274
|
-
| `showModelSelector` | `boolean` | `true` | ❌ | Whether to show model selector |
|
|
275
|
-
| `onModelChange` | `(model: AIModel) => void` | - | ❌ | Model change callback |
|
|
276
|
-
| `presetMessages` | `PresetMessage[]` | `[]` | ❌ | Preset messages list |
|
|
277
|
-
| `placeholder` | `string` | `'Type a message...'` | ❌ | Input placeholder |
|
|
278
|
-
| `className` | `string` | `''` | ❌ | Custom CSS class name |
|
|
279
|
-
| `maxRetries` | `number` | `3` | ❌ | Maximum retry attempts |
|
|
280
|
-
| `retryDelay` | `number` | `1000` | ❌ | Retry delay (milliseconds) |
|
|
281
|
-
| `onMessage` | `(message: Message) => void` | - | ❌ | Message callback |
|
|
282
|
-
| `onError` | `(error: Error) => void` | - | ❌ | Error callback |
|
|
283
|
-
| `onToolUse` | `(toolUse: ToolUse) => Promise<Message \| void>` | - | ❌ | Tool use callback |
|
|
284
|
-
| `onVerifyWallet` | `() => Promise<{token: string} \| undefined>` | - | ❌ | Wallet verification callback |
|
|
285
|
-
| `permissionGroup` | `string` | - | ❌ | Permission group name |
|
|
286
|
-
|
|
287
|
-
### AIModel Type
|
|
288
|
-
|
|
289
|
-
```typescript
|
|
290
|
-
interface AIModel {
|
|
291
|
-
label: string; // Display name (e.g., "Nova", "Claude")
|
|
292
|
-
value: string; // Model identifier (e.g., "nova", "claude")
|
|
293
|
-
}
|
|
294
|
-
```
|
|
295
|
-
|
|
296
|
-
### Model Configuration Priority
|
|
297
|
-
|
|
298
|
-
The SDK uses the following priority order to determine which models to show:
|
|
77
|
+
**What happens automatically:**
|
|
78
|
+
1. ✅ Check for existing token in URL parameters
|
|
79
|
+
2. ✅ Open BerifyMe modal when verification is needed
|
|
80
|
+
3. ✅ Handle verification completion and token extraction
|
|
81
|
+
4. ✅ Clean up modal and state management
|
|
82
|
+
5. ✅ Return token to the system for wallet verification
|
|
299
83
|
|
|
300
|
-
|
|
301
|
-
2. **Default** - Shows only the 4 basic models
|
|
84
|
+
### Skip Wallet Verification Check
|
|
302
85
|
|
|
303
|
-
|
|
86
|
+
If you want to allow users to set AIT permissions without wallet verification, you can disable the verification check:
|
|
304
87
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
//
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
// Or select specific models from the list
|
|
314
|
-
availableModels={[
|
|
315
|
-
ALL_AVAILABLE_MODELS[0], // Claude
|
|
316
|
-
ALL_AVAILABLE_MODELS[4], // Nova
|
|
317
|
-
]}
|
|
88
|
+
```tsx
|
|
89
|
+
<ChatBot
|
|
90
|
+
serviceId="your-service-id"
|
|
91
|
+
apiKey="your-api-key"
|
|
92
|
+
apiSecret="your-api-secret"
|
|
93
|
+
requireWalletIDVVerification={false} // Skip wallet IDV verification check
|
|
94
|
+
/>
|
|
318
95
|
```
|
|
319
96
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
```typescript
|
|
323
|
-
const DEFAULT_AI_MODELS = [
|
|
324
|
-
{ label: 'Claude', value: 'claude' },
|
|
325
|
-
{ label: 'ChatGPT', value: 'open-ai' },
|
|
326
|
-
{ label: 'Llama', value: 'llama' },
|
|
327
|
-
{ label: 'Gemini', value: 'gemini' },
|
|
328
|
-
];
|
|
329
|
-
|
|
330
|
-
// All available models for reference
|
|
331
|
-
const ALL_AVAILABLE_MODELS = [
|
|
332
|
-
{ label: 'Claude', value: 'claude' },
|
|
333
|
-
{ label: 'ChatGPT', value: 'open-ai' },
|
|
334
|
-
{ label: 'Llama', value: 'llama' },
|
|
335
|
-
{ label: 'Gemini', value: 'gemini' },
|
|
336
|
-
{ label: 'Nova', value: 'nova' },
|
|
337
|
-
];
|
|
338
|
-
```
|
|
97
|
+
**Note**: When `requireWalletIDVVerification: false`, users can connect and sign in with their wallet, then directly set AIT permissions without going through the wallet IDV verification process.
|
|
339
98
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
```typescript
|
|
343
|
-
interface Message {
|
|
344
|
-
id: string;
|
|
345
|
-
content: string;
|
|
346
|
-
role: 'user' | 'assistant';
|
|
347
|
-
timestamp: string;
|
|
348
|
-
metadata?: {
|
|
349
|
-
model?: string; // AI model used
|
|
350
|
-
permissions?: string[]; // User permissions
|
|
351
|
-
issuedBy?: string; // Wallet address
|
|
352
|
-
toolUse?: { // Tool call information
|
|
353
|
-
name: string;
|
|
354
|
-
input: Record<string, any>;
|
|
355
|
-
};
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
```
|
|
99
|
+
**Default Behavior**: `requireWalletIDVVerification` defaults to `true`, meaning wallet verification is required by default for security.
|
|
359
100
|
|
|
360
|
-
##
|
|
101
|
+
## Benefits of Built-in BerifyMe Support
|
|
361
102
|
|
|
362
|
-
|
|
103
|
+
✅ **Always Available**: Built-in BerifyMe support is always enabled - no configuration needed!
|
|
363
104
|
|
|
364
|
-
|
|
365
|
-
import {
|
|
366
|
-
ChatBotProvider,
|
|
367
|
-
ChatBotUI,
|
|
368
|
-
ModelSelector,
|
|
369
|
-
MessageList,
|
|
370
|
-
MessageInput
|
|
371
|
-
} from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
372
|
-
|
|
373
|
-
function CustomChatBot() {
|
|
374
|
-
return (
|
|
375
|
-
<ChatBotProvider
|
|
376
|
-
serviceId="your-service-id"
|
|
377
|
-
apiKey="your-api-key"
|
|
378
|
-
apiSecret="your-api-secret"
|
|
379
|
-
>
|
|
380
|
-
<div className="custom-chatbot-container">
|
|
381
|
-
<ChatBotUI />
|
|
382
|
-
</div>
|
|
383
|
-
</ChatBotProvider>
|
|
384
|
-
);
|
|
385
|
-
}
|
|
386
|
-
```
|
|
105
|
+
✅ **No onVerifyWallet Needed**: SDK automatically handles wallet verification - no callback implementation required
|
|
387
106
|
|
|
388
|
-
|
|
107
|
+
✅ **Simplified Integration**: No need to manually handle DOM manipulation, React roots, or modal lifecycle
|
|
389
108
|
|
|
390
|
-
|
|
391
|
-
import {
|
|
392
|
-
ChatBotProvider,
|
|
393
|
-
useChatBot,
|
|
394
|
-
ModelSelector,
|
|
395
|
-
MessageList,
|
|
396
|
-
MessageInput
|
|
397
|
-
} from '@bytexbyte/nxtlinq-ai-agent-sdk';
|
|
398
|
-
|
|
399
|
-
function CustomLayout() {
|
|
400
|
-
const { isOpen, setIsOpen } = useChatBot();
|
|
401
|
-
|
|
402
|
-
if (!isOpen) {
|
|
403
|
-
return (
|
|
404
|
-
<button onClick={() => setIsOpen(true)}>
|
|
405
|
-
Open AI Agent
|
|
406
|
-
</button>
|
|
407
|
-
);
|
|
408
|
-
}
|
|
109
|
+
✅ **Automatic SDK Loading**: SDK automatically loads BerifyMe dependencies when needed
|
|
409
110
|
|
|
410
|
-
|
|
411
|
-
<div className="custom-layout">
|
|
412
|
-
<header>
|
|
413
|
-
<h3>AI Assistant</h3>
|
|
414
|
-
<ModelSelector />
|
|
415
|
-
<button onClick={() => setIsOpen(false)}>Close</button>
|
|
416
|
-
</header>
|
|
417
|
-
<MessageList />
|
|
418
|
-
<MessageInput />
|
|
419
|
-
</div>
|
|
420
|
-
);
|
|
421
|
-
}
|
|
111
|
+
✅ **Built-in Error Handling**: Comprehensive error handling and fallback mechanisms
|
|
422
112
|
|
|
423
|
-
|
|
424
|
-
return (
|
|
425
|
-
<ChatBotProvider
|
|
426
|
-
serviceId="your-service-id"
|
|
427
|
-
apiKey="your-api-key"
|
|
428
|
-
apiSecret="your-api-secret"
|
|
429
|
-
>
|
|
430
|
-
<CustomLayout />
|
|
431
|
-
</ChatBotProvider>
|
|
432
|
-
);
|
|
433
|
-
}
|
|
434
|
-
```
|
|
113
|
+
✅ **Consistent UI**: Unified modal experience across all implementations
|
|
435
114
|
|
|
436
|
-
|
|
115
|
+
✅ **Easy Configuration**: Simple configuration object with sensible defaults
|
|
437
116
|
|
|
438
|
-
|
|
117
|
+
✅ **Automatic Cleanup**: Modal cleanup and memory management handled automatically
|
|
439
118
|
|
|
440
|
-
|
|
441
|
-
/* Main container */
|
|
442
|
-
.nxtlinq-chatbot-container {
|
|
443
|
-
/* Custom styles */
|
|
444
|
-
}
|
|
119
|
+
✅ **Flexible IDV Verification**: Control whether to require wallet IDV verification before AIT operations
|
|
445
120
|
|
|
446
|
-
|
|
447
|
-
.nxtlinq-message-list {
|
|
448
|
-
/* Custom styles */
|
|
449
|
-
}
|
|
121
|
+
✅ **Smart Suggestion Banner**: When verification is optional, shows helpful suggestion banner with 1-second delay to prevent flashing
|
|
450
122
|
|
|
451
|
-
|
|
452
|
-
.nxtlinq-user-message {
|
|
453
|
-
/* Custom styles */
|
|
454
|
-
}
|
|
123
|
+
## Configuration Options
|
|
455
124
|
|
|
456
|
-
|
|
457
|
-
.nxtlinq-ai-message {
|
|
458
|
-
/* Custom styles */
|
|
459
|
-
}
|
|
125
|
+
### Built-in BerifyMe Support
|
|
460
126
|
|
|
461
|
-
|
|
462
|
-
.nxtlinq-model-selector {
|
|
463
|
-
/* Custom styles */
|
|
464
|
-
}
|
|
127
|
+
The built-in BerifyMe support requires no configuration - it automatically redirects to the current page after verification.
|
|
465
128
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
```
|
|
129
|
+
**Wallet Verification Options:**
|
|
130
|
+
| Property | Type | Default | Description |
|
|
131
|
+
|----------|------|---------|-------------|
|
|
132
|
+
| `requireWalletIDVVerification` | `boolean` | `true` | Whether to check wallet IDV verification status before AIT operations |
|
|
471
133
|
|
|
472
|
-
###
|
|
134
|
+
### Configuration Examples
|
|
473
135
|
|
|
136
|
+
#### Require Wallet Verification (Default)
|
|
474
137
|
```tsx
|
|
475
138
|
<ChatBot
|
|
476
139
|
serviceId="your-service-id"
|
|
477
140
|
apiKey="your-api-key"
|
|
478
141
|
apiSecret="your-api-secret"
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
'--primary-color': '#007bff',
|
|
482
|
-
'--secondary-color': '#6c757d',
|
|
483
|
-
'--border-radius': '10px',
|
|
484
|
-
'--model-badge-bg': '#e3f2fd',
|
|
485
|
-
'--model-badge-color': '#1976d2'
|
|
486
|
-
}}
|
|
142
|
+
// requireWalletIDVVerification defaults to true
|
|
143
|
+
// Users must complete wallet verification before using AIT
|
|
487
144
|
/>
|
|
488
145
|
```
|
|
489
146
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
### Model Change Events
|
|
493
|
-
|
|
147
|
+
#### Make Wallet Verification Optional
|
|
494
148
|
```tsx
|
|
495
149
|
<ChatBot
|
|
496
150
|
serviceId="your-service-id"
|
|
497
151
|
apiKey="your-api-key"
|
|
498
152
|
apiSecret="your-api-secret"
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
analytics.track('model_changed', {
|
|
503
|
-
model: model.value,
|
|
504
|
-
label: model.label,
|
|
505
|
-
timestamp: new Date().toISOString()
|
|
506
|
-
});
|
|
507
|
-
}}
|
|
153
|
+
requireWalletIDVVerification={false}
|
|
154
|
+
// Users can use AIT without wallet verification
|
|
155
|
+
// Helpful suggestion banner will appear for unverified wallets
|
|
508
156
|
/>
|
|
509
157
|
```
|
|
510
158
|
|
|
511
|
-
|
|
159
|
+
## Advanced Features
|
|
512
160
|
|
|
513
|
-
|
|
514
|
-
<ChatBot
|
|
515
|
-
serviceId="your-service-id"
|
|
516
|
-
apiKey="your-api-key"
|
|
517
|
-
apiSecret="your-api-secret"
|
|
518
|
-
onMessage={(message) => {
|
|
519
|
-
console.log('New message:', message);
|
|
520
|
-
// Track message with model info
|
|
521
|
-
if (message.role === 'user') {
|
|
522
|
-
analytics.track('user_message', {
|
|
523
|
-
content: message.content,
|
|
524
|
-
model: message.metadata?.model,
|
|
525
|
-
timestamp: message.timestamp
|
|
526
|
-
});
|
|
527
|
-
} else if (message.role === 'assistant') {
|
|
528
|
-
analytics.track('ai_response', {
|
|
529
|
-
model: message.metadata?.model,
|
|
530
|
-
hasToolUse: !!message.metadata?.toolUse,
|
|
531
|
-
timestamp: message.timestamp
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
}}
|
|
535
|
-
/>
|
|
536
|
-
```
|
|
161
|
+
### IDV Suggestion Banner
|
|
537
162
|
|
|
538
|
-
|
|
163
|
+
When `requireWalletIDVVerification: false`, the SDK shows a helpful suggestion banner for unverified wallets:
|
|
539
164
|
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
apiSecret="your-api-secret"
|
|
545
|
-
onError={(error) => {
|
|
546
|
-
console.error('ChatBot error:', error);
|
|
547
|
-
// Add error reporting
|
|
548
|
-
errorReporting.captureException(error);
|
|
549
|
-
|
|
550
|
-
// Track error with context
|
|
551
|
-
analytics.track('chatbot_error', {
|
|
552
|
-
error: error.message,
|
|
553
|
-
stack: error.stack,
|
|
554
|
-
timestamp: new Date().toISOString()
|
|
555
|
-
});
|
|
556
|
-
}}
|
|
557
|
-
/>
|
|
558
|
-
```
|
|
165
|
+
- **Smart Timing**: 1-second delay prevents flashing during wallet connection
|
|
166
|
+
- **24-Hour Dismissal**: Users can dismiss the banner for 24 hours
|
|
167
|
+
- **Persistent State**: Dismissal preference is saved in localStorage
|
|
168
|
+
- **Responsive Design**: Banner adapts to different screen sizes
|
|
559
169
|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
### 1. Model Selection
|
|
563
|
-
- Choose appropriate AI models based on use cases
|
|
564
|
-
- Consider user preferences and requirements
|
|
565
|
-
- Monitor model performance and usage
|
|
566
|
-
|
|
567
|
-
### 2. Error Handling
|
|
568
|
-
- Always provide `onError` callback to handle errors
|
|
569
|
-
- Implement proper error reporting and monitoring
|
|
570
|
-
- Provide fallback mechanisms for failed requests
|
|
571
|
-
|
|
572
|
-
### 3. User Experience
|
|
573
|
-
- Use preset messages to guide users
|
|
574
|
-
- Provide clear model switching feedback
|
|
575
|
-
- Maintain conversation context across model switches
|
|
576
|
-
|
|
577
|
-
### 4. Performance Optimization
|
|
578
|
-
- Set reasonable retry counts and delays
|
|
579
|
-
- Implement proper loading states
|
|
580
|
-
- Optimize for different network conditions
|
|
581
|
-
|
|
582
|
-
### 5. Security
|
|
583
|
-
- Keep API keys secure and use environment variables
|
|
584
|
-
- Validate user permissions before tool calls
|
|
585
|
-
- Implement proper wallet verification
|
|
586
|
-
|
|
587
|
-
## Migration Guide
|
|
588
|
-
|
|
589
|
-
### From v1.2.3 to v1.2.4
|
|
590
|
-
|
|
591
|
-
1. **Update package version**:
|
|
592
|
-
```bash
|
|
593
|
-
npm install @bytexbyte/nxtlinq-ai-agent-sdk@1.2.4
|
|
594
|
-
```
|
|
595
|
-
|
|
596
|
-
2. **Add model switching props** (optional):
|
|
597
|
-
```tsx
|
|
598
|
-
<ChatBot
|
|
599
|
-
// ... existing props
|
|
600
|
-
showModelSelector={true}
|
|
601
|
-
onModelChange={(model) => console.log('Model:', model.label)}
|
|
602
|
-
/>
|
|
603
|
-
```
|
|
604
|
-
|
|
605
|
-
3. **Update message handling** (if needed):
|
|
606
|
-
```tsx
|
|
607
|
-
onMessage={(message) => {
|
|
608
|
-
// Now includes model information
|
|
609
|
-
console.log('Model used:', message.metadata?.model);
|
|
610
|
-
}}
|
|
611
|
-
```
|
|
612
|
-
|
|
613
|
-
## Changelog
|
|
614
|
-
|
|
615
|
-
### v1.2.4 (Latest)
|
|
616
|
-
- ✨ **NEW**: AI model switching functionality
|
|
617
|
-
- ✨ **NEW**: Support for 5 AI models (Nova, Claude, ChatGPT, Llama, Gemini)
|
|
618
|
-
- ✨ **NEW**: ModelSelector dropdown component
|
|
619
|
-
- ✨ **NEW**: Model badges in messages
|
|
620
|
-
- ✨ **NEW**: Persistent model preferences
|
|
621
|
-
- 🔧 **IMPROVED**: Enhanced API client with dynamic endpoints
|
|
622
|
-
- 🔧 **IMPROVED**: Better TypeScript types and interfaces
|
|
623
|
-
- 📚 **UPDATED**: Comprehensive documentation and examples
|
|
624
|
-
|
|
625
|
-
### v1.2.3
|
|
626
|
-
- Initial release with basic functionality
|
|
170
|
+
### Wallet Connection Flow
|
|
627
171
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
- 🐛 Issues: https://github.com/bytexbyte/nxtlinq-ai-agent-sdk/issues
|
|
172
|
+
1. **Connect Wallet**: User connects their wallet
|
|
173
|
+
2. **Sign In**: User signs in with wallet (if required)
|
|
174
|
+
3. **Verification Check**: SDK checks if wallet is verified
|
|
175
|
+
4. **Conditional Banner**: If verification is optional and wallet is unverified, show suggestion banner
|
|
176
|
+
5. **User Choice**: User can verify wallet or continue without verification
|
|
634
177
|
|
|
635
|
-
##
|
|
178
|
+
## Support
|
|
636
179
|
|
|
637
|
-
|
|
180
|
+
For questions and support, please refer to the SDK documentation or contact the development team.
|