sobra-sdk
v1.0.0
Published
Official TypeScript SDK for the Sobra Protocol - Solana memory storage and verification
Maintainers
Readme

Installation
npm install sobra-sdk
# or
yarn add sobra-sdkQuick Start
import { SobraClient } from 'sobra-sdk';
import { Keypair } from '@solana/web3.js';
// Initialize the client with your wallet
const wallet = Keypair.generate(); // Replace with your actual wallet
const client = new SobraClient(wallet);
// Create a new memory
const memory = await client.createMemory(
'User wants to analyze token XYZ',
'intent',
'agent-123'
);
console.log(`Memory created: ${memory.data.id}`);🔧 Core Features
- Wallet-Keyed Memories: Secure, wallet-based memory storage
- Structured Memory Types: Intent, Alert, and Belief memory types
- Agent Integration: Seamless integration with AI agents
- Signature Verification: Cryptographic verification of memory contents
- Query Capabilities: Flexible memory retrieval and filtering
📊 Memory Management Example
import { SobraClient } from 'sobra-sdk';
import { Keypair } from '@solana/web3.js';
async function manageMemories() {
const wallet = Keypair.generate(); // Replace with your actual wallet
const client = new SobraClient(wallet);
// Create a new memory
const memory = await client.createMemory(
'Analyze market trends for SOL',
'intent',
'market-agent'
);
// Retrieve memories
const memories = await client.getMemories('intent', 'market-agent', 10);
console.log(`
Memory Management Results:
-------------------------
Total Memories: ${memories.data.length}
Latest Memory: ${memories.data[0]?.content}
`);
}API Endpoints
Memory Management
POST /memoryCreates a new memory entry with:
- Content
- Memory type (intent, alert, belief)
- Agent identifier
- Wallet signature
- Timestamp
Response type:
interface MemoryEntry {
id: string;
wallet: string;
content: string;
type: 'intent' | 'alert' | 'belief';
agent: string;
timestamp: number;
signature: string;
}Memory Retrieval
GET /memoryRetrieves memories with optional filtering:
- Memory type
- Agent identifier
- Result limit
Memory Verification
GET /verifyVerifies the signature of a memory entry:
- Content verification
- Timestamp validation
- Signature validation
Response type:
interface VerificationResponse {
isValid: boolean;
}Error Handling
All endpoints return standardized error responses:
interface ErrorResponse {
error: string; // Error type
message: string; // Detailed message
statusCode: number; // HTTP status code
timestamp: string; // Error timestamp
}🔍 Advanced Usage
Memory Management Class
import { SobraClient } from 'sobra-sdk';
import { Keypair } from '@solana/web3.js';
class MemoryManager {
private client: SobraClient;
private agentId: string;
constructor(wallet: Keypair, agentId: string) {
this.client = new SobraClient(wallet);
this.agentId = agentId;
}
async storeIntent(content: string) {
return this.client.createMemory(content, 'intent', this.agentId);
}
async getRecentMemories(limit: number = 10) {
return this.client.getMemories(undefined, this.agentId, limit);
}
async verifyMemory(content: string) {
return this.client.verifySignature(content);
}
}Error Handling Patterns
import { SobraClient } from 'sobra-sdk';
import { Keypair } from '@solana/web3.js';
async function robustMemoryCreation(content: string, agentId: string) {
const wallet = Keypair.generate(); // Replace with your actual wallet
const client = new SobraClient(wallet);
try {
const memory = await client.createMemory(content, 'intent', agentId);
return memory;
} catch (error: any) {
console.error('Memory Creation Error:', error.message);
throw error;
}
}Roadmap
- [ ] WebSocket support for real-time memory updates
- [ ] Advanced memory querying capabilities
- [ ] Memory encryption support
- [ ] Cross-chain memory compatibility
- [ ] Memory compression and optimization
- [ ] Multiple storage backends:
- [ ] IPFS integration for decentralized storage
- [ ] Local server storage option
- [ ] Arweave integration for permanent storage
- [ ] Custom blockchain storage adapters
License
MIT © Sobra Team
