@bytexbyte/nxtlinq-ai-agent-sdk v1.1.5
Nxtlinq AI Agent SDK
A powerful SDK for building intelligent conversation applications with Nxtlinq AI Agent.
Features
- 💬 Real-time chat interface with AI Agent
- 🎯 Preset messages for quick interactions
- 🛠️ Tool integration support
- 🔄 Automatic retry mechanism for failed requests
- 📱 Responsive and modern UI design
- 🎨 Customizable styling
- 🔌 Easy integration with React applications
- 🔒 Secure authentication and API key management
- 👛 MetaMask wallet integration
- 🔐 AIT (AI Token) management
- 🔑 Permission-based access control
Installation
npm install @bytexbyte/nxtlinq-ai-agent-sdk
# or
yarn add @bytexbyte/nxtlinq-ai-agent-sdkQuick Start
import { ChatBot } from '@bytexbyte/nxtlinq-ai-agent-sdk';
function App() {
const handleMessage = (message) => {
console.log('Received new message:', message);
};
const handleToolUse = async (toolUse) => {
console.log('Tool use:', toolUse);
return {
id: Date.now().toString(),
content: 'Tool execution response',
role: 'assistant',
timestamp: new Date().toISOString()
};
};
const presetMessages = [
{ text: 'Hello, how can you help me?' },
{ text: 'I want to add a new member' },
{ text: 'I want to view the analytics page' },
{ text: 'I want to change my name' }
];
return (
<ChatBot
serviceId="your-service-id"
apiKey="your-api-key"
apiSecret="your-api-secret"
onMessage={handleMessage}
onToolUse={handleToolUse}
presetMessages={presetMessages}
onVerifyWallet={async (address) => {
// Implement your wallet verification logic here
return { token: 'verification-token' };
}}
/>
);
}API Reference
NxtlinqAITSDK
| Method | Description |
|---|---|
connectWallet() | Connect to MetaMask wallet |
verifyWallet(token: string, method: string) | Verify wallet ownership |
signInWithWallet() | Sign in using wallet |
generateAndRegisterAIT(permissions: string[]) | Generate and register a new AIT |
getAIT() | Get AIT information |
getWalletInfo() | Get wallet information |
NxtlinqAIAgent
| Method | Description |
|---|---|
setAIT(ait: AIT, signer?: ethers.Signer) | Set AIT for the agent |
generateAIT(options: GenerateAITOptions) | Generate a new AIT |
getAITInfo(serviceId: string, controller: string, signer?: ethers.Signer) | Get AIT information |
sendMessage(message: string, toolName?: string) | Send a message to the agent |
API Endpoints
AIT API
getAITByServiceIdAndController: Get AIT by service ID and controllercreateAIT: Create a new AIT
Wallet API
verifyWallet: Verify wallet ownershipgetWallet: Get wallet information
Metadata API
createMetadata: Create metadata for AIT
Auth API
getNonce: Get nonce for wallet sign-insignIn: Sign in with wallet
Agent API
sendMessage: Send message to AI agent
ChatBot Component Props
| Prop | Type | Required | Description |
|---|---|---|---|
| serviceId | string | Yes | Your Nxtlinq service ID |
| apiKey | string | Yes | Your Nxtlinq API key |
| apiSecret | string | Yes | Your Nxtlinq API secret |
| onMessage | (message: Message) => void | No | Callback when a new message is received |
| onError | (error: Error) => void | No | Callback when an error occurs |
| onToolUse | (toolUse: ToolUse) => Promise<Message | void> | No | Callback for handling tool usage |
| onVerifyWallet | (address: string) => Promise<{ token: string }> | Yes | Callback for wallet verification |
| presetMessages | PresetMessage[] | No | Array of preset messages to display |
| placeholder | string | No | Input placeholder text (default: "Type a message...") |
| className | string | No | Additional CSS class name |
| maxRetries | number | No | Maximum number of retry attempts (default: 3) |
| retryDelay | number | No | Delay between retries in milliseconds (default: 1000) |
Types
Message
interface Message {
id: string;
content: string;
role: 'user' | 'assistant';
timestamp: string;
button?: boolean;
error?: string;
}PresetMessage
interface PresetMessage {
text: string;
autoSend?: boolean;
}ToolUse
interface ToolUse {
name: string;
input: Record<string, any>;
}AIT
interface AIT {
aitId: string;
controller: string;
metadata: AITMetadata;
metadataHash: string;
metadataCid: string;
signature: string;
}
interface AITMetadata {
model: string;
permissions: string[];
issuedBy: string;
serviceId?: string;
}
interface AITInfo {
aitId: string;
controller: string;
metadata: AITMetadata;
metadataHash: string;
metadataCid: string;
signature: string;
}
interface AITPermission {
hasPermission: boolean;
reason?: string;
permissions?: string[];
}
interface GenerateAITOptions {
hitAddress: string;
signer: ethers.Signer;
permissions: string[];
serviceId: string;
}
interface WalletInfo {
id: string;
address: string;
verified: boolean;
method?: string;
}
interface MessageContext {
aitId?: string;
walletAddress?: string | null;
}Features
Wallet Integration
- MetaMask wallet connection
- Wallet verification
- Wallet-based authentication
- AIT (AI Token) generation and management
Available Permissions
- Set User Name
- Navigate To Page
- Add Member
Authentication Flow
- Connect MetaMask wallet
- Verify wallet ownership
- Sign in with wallet
- Generate and register AIT with required permissions
- Use AIT for authenticated operations
Error Handling
The SDK includes built-in error handling with:
- Automatic retry mechanism for failed requests
- Error callback for custom error handling
- User-friendly error messages
- Wallet connection error handling
- Authentication error handling
Best Practices
- Implement proper wallet verification logic
- Handle AIT permissions appropriately
- Set appropriate timeout values
- Implement error retry mechanisms
- Use context management to maintain conversation coherence
- Handle wallet connection errors gracefully
- Implement proper error handling for authentication flow
License
Proprietary - All Rights Reserved
Copyright (c) 2025 ByteXByte. All rights reserved.
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.
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.
For licensing inquiries, please contact: Your Contact Information