TypeScript SDK Quick Start
This guide walks you through connecting to a HEBBS server, storing memories, and recalling them — all in under 30 lines of TypeScript.
Prerequisites
Section titled “Prerequisites”- HEBBS TypeScript SDK installed (
npm install @hebbs/sdk) - A running HEBBS server (default:
localhost:6380) - Your API key exported:
export HEBBS_API_KEY="hb_..."
Full Example
Section titled “Full Example”import { HebbsClient, MemoryKind } from '@hebbs/sdk';
const client = new HebbsClient('localhost:6380', { apiKey: process.env.HEBBS_API_KEY,});await client.connect();
// Check server healthconst health = await client.health();console.log(`Server status: ${health.serving ? 'serving' : 'not serving'}`);
// Store some memoriesconst m1 = await client.remember({ content: 'Customer mentioned they are expanding to Europe next quarter', entityId: 'acme-corp', kind: MemoryKind.EPISODIC,});console.log(`Stored memory: ${m1.id.toString('hex')}`);
const m2 = await client.remember({ content: 'GDPR compliance is their top concern for the expansion', entityId: 'acme-corp', kind: MemoryKind.EPISODIC,});console.log(`Stored memory: ${m2.id.toString('hex')}`);
const m3 = await client.remember({ content: 'European expansion requires GDPR compliance as a prerequisite', entityId: 'acme-corp', kind: MemoryKind.SEMANTIC,});console.log(`Stored memory: ${m3.id.toString('hex')}`);
// Recall by similarityconst results = await client.recall({ cue: 'What are the customer plans for Europe?', entityId: 'acme-corp', strategies: ['similarity'], topK: 5,});
console.log(`\nRecall returned ${results.results.length} memories:`);for (const r of results.results) { console.log(` [${r.score.toFixed(3)}] ${r.memory.content}`);}
// Recall by temporal proximityconst temporal = await client.recall({ cue: 'What happened recently with this customer?', entityId: 'acme-corp', strategies: ['temporal'], topK: 5,});
console.log(`\nTemporal recall returned ${temporal.results.length} memories:`);for (const r of temporal.results) { console.log(` [${r.memory.createdAt}] ${r.memory.content}`);}
await client.close();What Just Happened
Section titled “What Just Happened”- Connect —
new HebbsClient()creates the client, andconnect()establishes the gRPC channel. Callclose()when done. - Remember — each
remember()call stores a memory in the engine. HEBBS automatically embeds the content, indexes it across vector, temporal, and graph indexes, and returns the stored memory with its assigned ID. - Recall —
recall()queries the engine using one of four strategies:similarity,temporal,causal, oranalogical. Results include relevance scores and metadata.
Next Steps
Section titled “Next Steps”- Client Reference — explore all available methods
- Types Reference — understand the data model
- Error Handling — handle failures gracefully
- Multi-Strategy Recall — compare all four recall strategies