@bytexbyte/nxtlinq-ai-agent-sdk 1.2.1 → 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.
Files changed (43) hide show
  1. package/README.md +175 -207
  2. package/dist/api/nxtlinq-api.d.ts.map +1 -1
  3. package/dist/api/nxtlinq-api.js +121 -142
  4. package/dist/components/ChatBot.d.ts +2 -44
  5. package/dist/components/ChatBot.d.ts.map +1 -1
  6. package/dist/components/ChatBot.js +5 -1143
  7. package/dist/components/context/ChatBotContext.d.ts +5 -0
  8. package/dist/components/context/ChatBotContext.d.ts.map +1 -0
  9. package/dist/components/context/ChatBotContext.js +737 -0
  10. package/dist/components/types/ChatBotTypes.d.ts +98 -0
  11. package/dist/components/types/ChatBotTypes.d.ts.map +1 -0
  12. package/dist/components/types/ChatBotTypes.js +1 -0
  13. package/dist/components/ui/ChatBotUI.d.ts +3 -0
  14. package/dist/components/ui/ChatBotUI.d.ts.map +1 -0
  15. package/dist/components/ui/ChatBotUI.js +146 -0
  16. package/dist/components/ui/MessageInput.d.ts +3 -0
  17. package/dist/components/ui/MessageInput.d.ts.map +1 -0
  18. package/dist/components/ui/MessageInput.js +46 -0
  19. package/dist/components/ui/MessageList.d.ts +3 -0
  20. package/dist/components/ui/MessageList.d.ts.map +1 -0
  21. package/dist/components/ui/MessageList.js +54 -0
  22. package/dist/components/ui/NotificationModal.d.ts +14 -0
  23. package/dist/components/ui/NotificationModal.d.ts.map +1 -0
  24. package/dist/components/ui/NotificationModal.js +79 -0
  25. package/dist/components/ui/PermissionForm.d.ts +8 -0
  26. package/dist/components/ui/PermissionForm.d.ts.map +1 -0
  27. package/dist/components/ui/PermissionForm.js +299 -0
  28. package/dist/components/ui/PresetMessages.d.ts +3 -0
  29. package/dist/components/ui/PresetMessages.d.ts.map +1 -0
  30. package/dist/components/ui/PresetMessages.js +35 -0
  31. package/dist/core/utils/aitUtils.d.ts +28 -0
  32. package/dist/core/utils/aitUtils.d.ts.map +1 -0
  33. package/dist/core/utils/aitUtils.js +34 -0
  34. package/dist/core/utils/notificationUtils.d.ts +29 -0
  35. package/dist/core/utils/notificationUtils.d.ts.map +1 -0
  36. package/dist/core/utils/notificationUtils.js +47 -0
  37. package/dist/core/utils/walletUtils.d.ts +10 -0
  38. package/dist/core/utils/walletUtils.d.ts.map +1 -0
  39. package/dist/core/utils/walletUtils.js +38 -0
  40. package/dist/index.d.ts +13 -1
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +17 -0
  43. package/package.json +1 -1
package/README.md CHANGED
@@ -1,268 +1,236 @@
1
1
  # Nxtlinq AI Agent SDK
2
2
 
3
- A powerful SDK for building intelligent conversation applications with Nxtlinq AI Agent.
4
-
5
- ## Features
6
-
7
- - 💬 Real-time chat interface with AI Agent
8
- - 🎯 Preset messages for quick interactions
9
- - 🛠️ Tool integration support
10
- - 🔄 Automatic retry mechanism for failed requests
11
- - 📱 Responsive and modern UI design
12
- - 🎨 Customizable styling
13
- - 🔌 Easy integration with React applications
14
- - 🔒 Secure authentication and API key management
15
- - 👛 MetaMask wallet integration
16
- - 🔐 AIT (AI Identity Token) management
17
- - 🔑 Permission-based access control
18
- - 🔍 Enhanced error handling and debugging
19
- - ⚡ Improved async operation handling
20
-
21
- ## Installation
3
+ A React SDK designed for Nxtlinq AI Agent, providing complete wallet connection, AIT management, and AI conversation functionality.
4
+
5
+ ## 🚀 Features
6
+
7
+ - **Modular Design**: Clear code structure, easy to maintain and extend
8
+ - **Wallet Integration**: Support for MetaKeep wallet connection and verification
9
+ - **AIT Management**: Complete AIT (AI Identity Token) creation and management
10
+ - **Permission Control**: Fine-grained permission management and validation
11
+ - **Real-time Chat**: Real-time conversation functionality with AI Agent
12
+ - **Type Safety**: Complete TypeScript type definitions
13
+ - **Responsive UI**: Modern user interface design
14
+
15
+ ## 📦 Installation
22
16
 
23
17
  ```bash
24
- npm install @bytexbyte/nxtlinq-ai-agent-sdk@1.1.9
25
- # or
26
- yarn add @bytexbyte/nxtlinq-ai-agent-sdk@1.1.9
18
+ npm install @bytexbyte/nxtlinq-ai-agent-sdk
27
19
  ```
28
20
 
29
- ## Quick Start
21
+ ## 🎯 Quick Start
22
+
23
+ ### Basic Usage
30
24
 
31
25
  ```tsx
32
26
  import { ChatBot } from '@bytexbyte/nxtlinq-ai-agent-sdk';
33
27
 
34
28
  function App() {
35
- const handleMessage = (message) => {
36
- console.log('Received new message:', message);
37
- };
38
-
39
- const handleToolUse = async (toolUse) => {
40
- console.log('Tool use:', toolUse);
41
- return {
42
- id: Date.now().toString(),
43
- content: 'Tool execution response',
44
- role: 'assistant',
45
- timestamp: new Date().toISOString()
46
- };
47
- };
48
-
49
- const presetMessages = [
50
- { text: 'Hello, how can you help me?' },
51
- { text: 'I want to add a new member' },
52
- { text: 'I want to view the analytics page' },
53
- { text: 'I want to change my name' }
54
- ];
55
-
56
29
  return (
57
30
  <ChatBot
58
31
  serviceId="your-service-id"
59
32
  apiKey="your-api-key"
60
33
  apiSecret="your-api-secret"
61
- onMessage={handleMessage}
62
- onToolUse={handleToolUse}
63
- presetMessages={presetMessages}
64
- onVerifyWallet={async () => {
65
- // Implement Berify.me verification
66
- return { token: 'verification-token' };
34
+ onMessage={(message) => console.log('New message:', message)}
35
+ onError={(error) => console.error('Error:', error)}
36
+ onToolUse={async (toolUse) => {
37
+ // Handle tool calls
38
+ console.log('Tool use:', toolUse);
67
39
  }}
68
40
  />
69
41
  );
70
42
  }
71
43
  ```
72
44
 
73
- ## Berify.me Integration
74
-
75
- The SDK supports Berify.me wallet verification for enhanced security:
45
+ ### Advanced Configuration
76
46
 
77
47
  ```tsx
78
48
  import { ChatBot } from '@bytexbyte/nxtlinq-ai-agent-sdk';
79
49
 
80
50
  function App() {
81
- const handleVerifyWallet = async () => {
82
- // Open Berify.me verification modal
83
- const modal = window.open(
84
- 'https://berify.me/verify',
85
- 'BerifyMeModal',
86
- 'width=500,height=600'
87
- );
88
-
89
- return new Promise((resolve) => {
90
- const handleMessage = (event) => {
91
- if (event.origin === 'https://berify.me' && event.data.type === 'VERIFICATION_SUCCESS') {
92
- window.removeEventListener('message', handleMessage);
93
- modal?.close();
94
- resolve({ token: event.data.token });
95
- }
96
- };
97
-
98
- window.addEventListener('message', handleMessage);
99
- });
100
- };
101
-
102
51
  return (
103
52
  <ChatBot
104
53
  serviceId="your-service-id"
105
54
  apiKey="your-api-key"
106
55
  apiSecret="your-api-secret"
107
- onVerifyWallet={handleVerifyWallet}
56
+ permissionGroup="default"
57
+ maxRetries={3}
58
+ retryDelay={1000}
59
+ placeholder="Type your message..."
60
+ presetMessages={[
61
+ { text: "Hello", autoSend: false },
62
+ { text: "Help", autoSend: true }
63
+ ]}
64
+ onVerifyWallet={async () => {
65
+ // Custom wallet verification logic
66
+ return { token: "verification-token" };
67
+ }}
108
68
  />
109
69
  );
110
70
  }
111
71
  ```
112
72
 
113
- ## API Reference
114
-
115
- ### ChatBot Component Props
116
-
117
- | Prop | Type | Required | Description |
118
- |------|------|----------|-------------|
119
- | serviceId | string | Yes | Your Nxtlinq service ID |
120
- | apiKey | string | Yes | Your Nxtlinq API key |
121
- | apiSecret | string | Yes | Your Nxtlinq API secret |
122
- | onMessage | (message: Message) => void | No | Callback when a new message is received |
123
- | onError | (error: Error) => void | No | Callback when an error occurs |
124
- | onToolUse | (toolUse: ToolUse) => Promise<Message \| void> | No | Callback for handling tool usage |
125
- | onVerifyWallet | () => Promise<{ token: string } \| undefined> | Yes | Callback for wallet verification |
126
- | presetMessages | PresetMessage[] | No | Array of preset messages to display |
127
- | placeholder | string | No | Input placeholder text (default: "Type a message...") |
128
- | className | string | No | Additional CSS class name |
129
- | maxRetries | number | No | Maximum number of retry attempts (default: 3) |
130
- | retryDelay | number | No | Delay between retries in milliseconds (default: 1000) |
131
- | permissionGroup | string | No | Permission group name for filtering permissions |
132
-
133
- ## Types
134
-
135
- ### Message
136
- ```typescript
137
- interface Message {
138
- id: string;
139
- content: string;
140
- role: 'user' | 'assistant';
141
- timestamp: string;
142
- button?: string;
143
- error?: string;
144
- }
73
+ ## 🏗️ Project Structure
74
+
75
+ ```
76
+ src/
77
+ ├── components/ # React Components
78
+ │ ├── ChatBot.tsx # Main component entry
79
+ │ ├── context/ # Context and state management
80
+ │ │ └── ChatBotContext.tsx
81
+ │ ├── types/ # Type definitions
82
+ │ │ └── ChatBotTypes.ts
83
+ │ └── ui/ # UI Components
84
+ │ ├── ChatBotUI.tsx
85
+ │ ├── MessageList.tsx
86
+ │ ├── MessageInput.tsx
87
+ │ ├── PresetMessages.tsx
88
+ │ ├── PermissionForm.tsx
89
+ │ └── NotificationModal.tsx
90
+ ├── api/ # API Layer
91
+ │ └── nxtlinq-api.ts # API Client
92
+ ├── core/ # Core functionality
93
+ │ ├── metakeepClient.ts
94
+ │ ├── lib/ # Utility libraries
95
+ │ │ └── useLocalStorage.ts
96
+ │ └── utils/ # Utility functions
97
+ │ ├── walletUtils.ts
98
+ │ ├── aitUtils.ts
99
+ │ └── notificationUtils.ts
100
+ ├── types/ # Global type definitions
101
+ │ ├── ait-api.ts
102
+ │ └── window.d.ts
103
+ └── index.ts # Main entry file
145
104
  ```
146
105
 
147
- ### PresetMessage
148
- ```typescript
149
- interface PresetMessage {
150
- text: string;
151
- autoSend?: boolean;
152
- }
106
+ ## 🔧 API Reference
107
+
108
+ ### ChatBot Props
109
+
110
+ | Property | Type | Required | Description |
111
+ |----------|------|----------|-------------|
112
+ | `serviceId` | `string` | ✅ | Service ID |
113
+ | `apiKey` | `string` | ✅ | API Key |
114
+ | `apiSecret` | `string` | ✅ | API Secret |
115
+ | `onMessage` | `(message: Message) => void` | ❌ | Message callback |
116
+ | `onError` | `(error: Error) => void` | ❌ | Error callback |
117
+ | `onToolUse` | `(toolUse: ToolUse) => Promise<Message \| void>` | ❌ | Tool use callback |
118
+ | `presetMessages` | `PresetMessage[]` | ❌ | Preset messages |
119
+ | `placeholder` | `string` | ❌ | Input placeholder |
120
+ | `className` | `string` | ❌ | Custom CSS class |
121
+ | `maxRetries` | `number` | ❌ | Maximum retry attempts |
122
+ | `retryDelay` | `number` | ❌ | Retry delay |
123
+ | `onVerifyWallet` | `() => Promise<{token: string} \| undefined>` | ❌ | Wallet verification callback |
124
+ | `permissionGroup` | `string` | ❌ | Permission group |
125
+
126
+ ### Utility Functions
127
+
128
+ #### Wallet Utilities
129
+
130
+ ```tsx
131
+ import { connectWallet, disconnectWallet, validateToken } from '@bytexbyte/nxtlinq-ai-agent-sdk';
132
+
133
+ // Connect wallet
134
+ const { address, signer } = await connectWallet();
135
+
136
+ // Disconnect wallet
137
+ disconnectWallet();
138
+
139
+ // Validate token
140
+ const isValid = validateToken(token, address);
153
141
  ```
154
142
 
155
- ### ToolUse
156
- ```typescript
157
- interface ToolUse {
158
- name: string;
159
- input: Record<string, any>;
160
- }
143
+ #### AIT Utilities
144
+
145
+ ```tsx
146
+ import { generateAITId, createAITMetadata, prepareAITCreation } from '@bytexbyte/nxtlinq-ai-agent-sdk';
147
+
148
+ // Generate AIT ID
149
+ const aitId = generateAITId(address);
150
+
151
+ // Create AIT metadata
152
+ const metadata = createAITMetadata(permissions, address);
153
+
154
+ // Prepare AIT creation parameters
155
+ const { aitId, metadata, metadataHash, createAITParams } = prepareAITCreation(
156
+ address,
157
+ permissions,
158
+ serviceId
159
+ );
161
160
  ```
162
161
 
163
- ### AIT
164
- ```typescript
165
- interface AIT {
166
- aitId: string;
167
- controller: string;
168
- metadata: AITMetadata;
169
- metadataHash: string;
170
- metadataCid: string;
171
- }
162
+ #### Notification Utilities
172
163
 
173
- interface AITMetadata {
174
- model: string;
175
- permissions: string[];
176
- issuedBy: string;
177
- serviceId?: string;
178
- }
164
+ ```tsx
165
+ import { createNotification, getNotificationIcon } from '@bytexbyte/nxtlinq-ai-agent-sdk';
166
+
167
+ // Create notification
168
+ const notification = createNotification('success', 'Operation successful');
169
+
170
+ // Get notification icon
171
+ const icon = getNotificationIcon('success'); // '✅'
179
172
  ```
180
173
 
181
- ### ServicePermission
182
- ```typescript
183
- interface ServicePermission {
184
- id: string;
185
- label: string;
186
- description: string;
187
- groups: string[];
174
+ ## 🔒 Permission Management
175
+
176
+ The SDK supports fine-grained permission management:
177
+
178
+ 1. **Connect Wallet**: Users first need to connect their MetaKeep wallet
179
+ 2. **Signature Verification**: Users need to sign to verify their identity
180
+ 3. **AIT Configuration**: Users can select required permissions
181
+ 4. **Permission Validation**: Each tool call validates permissions
182
+
183
+ ## 🎨 Custom Styling
184
+
185
+ You can add custom styles through the `className` property:
186
+
187
+ ```css
188
+ .nxtlinq-chatbot {
189
+ /* Custom styles */
190
+ border-radius: 15px;
191
+ box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
188
192
  }
189
193
  ```
190
194
 
191
- ## Features
192
-
193
- ### Wallet Integration
194
- - MetaMask wallet connection
195
- - Berify.me wallet verification
196
- - Wallet-based authentication
197
- - AIT (AI Identity Token) generation and management
198
-
199
- ### Authentication Flow
200
- 1. Connect MetaMask wallet
201
- 2. Verify wallet ownership (optional, via Berify.me)
202
- 3. Sign in with wallet
203
- 4. Generate and register AIT with required permissions
204
- 5. Use AIT for authenticated operations
205
-
206
- ### Enhanced Error Handling
207
- - Improved async operation handling
208
- - Better state management
209
- - Detailed error messages
210
- - Comprehensive debugging logs
211
-
212
- ## Error Handling
213
-
214
- The SDK includes enhanced error handling with:
215
- - Automatic retry mechanism for failed requests
216
- - Error callback for custom error handling
217
- - User-friendly error messages
218
- - Wallet connection error handling
219
- - Authentication error handling
220
- - Detailed console logging for debugging
221
-
222
- ## Best Practices
223
-
224
- 1. Implement proper wallet verification logic
225
- 2. Handle AIT permissions appropriately
226
- 3. Set appropriate timeout values
227
- 4. Implement error retry mechanisms
228
- 5. Use context management to maintain conversation coherence
229
- 6. Handle wallet connection errors gracefully
230
- 7. Implement proper error handling for authentication flow
231
- 8. Monitor console logs for debugging
232
-
233
- ## Troubleshooting
234
-
235
- Having issues? Check our [Troubleshooting Guide](./TROUBLESHOOTING.md) which includes:
236
-
237
- - Common problems and solutions
238
- - Authentication debugging steps
239
- - Permission issue resolution
240
- - Best practice recommendations
195
+ ## 🐛 Troubleshooting
241
196
 
242
197
  ### Common Issues
243
198
 
244
- **Q: Still need to sign in after connecting wallet?**
245
- A: This is usually due to expired authentication tokens or address mismatches. Check browser console logs and refer to the [Troubleshooting Guide](./TROUBLESHOOTING.md) for detailed solutions.
199
+ 1. **Wallet Connection Failed**
200
+ - Ensure MetaKeep extension is installed
201
+ - Check network connection
202
+
203
+ 2. **Permission Validation Failed**
204
+ - Ensure AIT permissions are correctly configured
205
+ - Check service ID and API keys
206
+
207
+ 3. **Message Sending Failed**
208
+ - Check network connection
209
+ - Verify API key and secret
246
210
 
247
- **Q: Cannot use specific AI tool features?**
248
- A: Check AIT permission settings to ensure required tool permissions are included. See [Troubleshooting Guide](./TROUBLESHOOTING.md) for details.
211
+ ### Debug Mode
249
212
 
250
- ## Changelog
213
+ Enable debug mode to get more information:
251
214
 
252
- ### v1.1.9
253
- - 🔧 Fixed async operation timing issues in wallet connection
254
- - 🐛 Improved state management for AIT validation
255
- - 📝 Enhanced error messages and debugging logs
256
- - Better handling of authentication flow
215
+ ```tsx
216
+ <ChatBot
217
+ // ... other props
218
+ onError={(error) => {
219
+ console.error('ChatBot Error:', error);
220
+ }}
221
+ />
222
+ ```
257
223
 
258
- ## License
224
+ ## 📄 License
259
225
 
260
- Proprietary - All Rights Reserved
226
+ MIT License
261
227
 
262
- Copyright (c) 2025 ByteXByte. All rights reserved.
228
+ ## 🤝 Contributing
263
229
 
264
- This software and associated documentation files (the "Software") are proprietary and confidential. The Software is protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties.
230
+ Issues and Pull Requests are welcome!
265
231
 
266
- Unauthorized copying, distribution, modification, public display, or public performance of the Software is strictly prohibited. The Software may only be used in accordance with the terms of a valid license agreement with ByteXByte.
232
+ ## 📞 Support
267
233
 
268
- For licensing inquiries, please contact: [Your Contact Information]
234
+ For questions, please contact:
235
+ - Email: support@nxtlinq.ai
236
+ - Documentation: https://docs.nxtlinq.ai
@@ -1 +1 @@
1
- {"version":3,"file":"nxtlinq-api.d.ts","sourceRoot":"","sources":["../../src/api/nxtlinq-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAK1C,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,WAAW,MAAM,KAAG,MAwJpE,CAAC"}
1
+ {"version":3,"file":"nxtlinq-api.d.ts","sourceRoot":"","sources":["../../src/api/nxtlinq-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAiL1C,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,EAAE,WAAW,MAAM,KAAG,MASpE,CAAC"}