TypeScript SDK
v0.11.54 · Node 20+ · TypeScript 5.0+npm install dakera
# yarn add dakera | pnpm add dakera | bun add dakera
Client setup
import { DakeraClient } from 'dakera';
// Recommended: set via env vars
// DAKERA_URL=http://<YOUR_SERVER_IP>:3300
// DAKERA_API_KEY=your-api-key
const client = new DakeraClient({
baseUrl: process.env.DAKERA_URL ?? 'http://localhost:3300',
apiKey: process.env.DAKERA_API_KEY,
});
Memory operations
await client.memories.store({ agentId: 'my-agent', content: 'User is learning Rust', importance: 0.8, tags: ['learning'] });
const memories = await client.memories.recall({ agentId: 'my-agent', query: 'programming languages', topK: 10 });
const filtered = await client.memories.batchRecall({ agentId: 'my-agent', tags: ['learning'], minImportance: 0.6 });
await client.memories.forget({ memoryId: 'mem-abc123' });
Sessions
const session = await client.sessions.start({ agentId: 'my-agent', metadata: { task: 'review' } });
await client.memories.store({ agentId: 'my-agent', content: 'Found issues', sessionId: session.id });
await client.sessions.end({ sessionId: session.id, summary: 'Review complete' });
const sessions = await client.sessions.list({ agentId: 'my-agent' });
TypeScript types
import type {
MemoryRecord, // { id, agentId, content, importance, tags, createdAt, sessionId? }
RecallResult, // extends MemoryRecord with score: number
StoreMemoryRequest, // { agentId, content, importance?, tags?, sessionId? }
RecallRequest, // { agentId, query, topK? }
Session, // { id, agentId, startedAt, endedAt?, memoryCount, summary? }
DakeraClient,
} from 'dakera';
Vector operations
// Auto-embed and upsert text
await client.vectors.upsertText('docs', [
{ id: 'doc-001', text: 'Quarterly revenue report', metadata: { source: 'finance' } }
]);
// Query by text
const results = await client.vectors.queryText('docs', 'revenue trends', { topK: 5 });
// Hybrid search (vector + BM25)
const hybrid = await client.vectors.hybridSearch('docs', { text: 'revenue', vectorWeight: 0.7 });
Knowledge graph
// Build graph from seed memory
const graph = await client.knowledge.graph('my-agent', 'mem-abc', { depth: 2 });
// Cross-agent network
const network = await client.knowledge.crossAgentNetwork(['agent-a', 'agent-b']);
// Deduplicate (preview)
const dupes = await client.knowledge.deduplicate('my-agent', { dryRun: true });
Namespace management
await client.namespaces.create('production', { dimension: 384, distance: 'cosine' });
const key = await client.namespaces.createKey('production', { name: 'reader', scope: 'read' });
await client.namespaces.setMemoryPolicy('production', { episodicTtlSeconds: 604800 });
Entity extraction & feedback
// Extract entities
const entities = await client.extractEntities('Alice met Bob at Google HQ');
// Feedback loop
await client.memories.feedback('mem-abc', 'upvote');
const summary = await client.agents.feedbackSummary('my-agent');
Import & export
const data = await client.exportMemories('my-agent', 'jsonl');
await client.importMemories('my-agent', mem0Data, 'mem0');
Error handling
import { DakeraError, NotFoundError, RateLimitError } from 'dakera';
try {
const mem = await client.memories.get('mem-abc');
} catch (e) {
if (e instanceof NotFoundError) console.log('Not found');
else if (e instanceof RateLimitError) console.log(`Retry after ${e.retryAfter}s`);
else if (e instanceof DakeraError) console.log(`${e.errorCode}: ${e.message}`);
}
Error types: DakeraError, ConnectionError, NotFoundError, ValidationError, RateLimitError, ServerError, AuthenticationError, AuthorizationError, TimeoutError. Branded types: VectorId, AgentId, MemoryId, SessionId for compile-time safety.