π€
Using a coding agent? Run this to install the Hindsight docs skill:
npx skills add https://github.com/vectorize-io/hindsight --skill hindsight-docsTypeScript / JavaScript Client
Official TypeScript/JavaScript client for the Hindsight API. Supports Node.js and Deno.
Installationβ
Node.jsβ
npminstall @vectorize-io/hindsight-client
Denoβ
No installation needed β import directly via the npm: specifier:
import{ HindsightClient }from"npm:@vectorize-io/hindsight-client";
Quick Startβ
import{ HindsightClient }from'@vectorize-io/hindsight-client';
const client =newHindsightClient({ baseUrl:'http://localhost:8888'});
// Retain a memory
await client.retain('my-bank','Alice works at Google');
// Recall memories
const response =await client.recall('my-bank','What does Alice do?');
for(const r of response.results){
console.log(r.text);
}
// Reflect - generate response with disposition
const answer =await client.reflect('my-bank','Tell me about Alice');
console.log(answer.text);
Client Initializationβ
import{ HindsightClient }from'@vectorize-io/hindsight-client';
const client =newHindsightClient({
baseUrl:'http://localhost:8888',
});
Core Operationsβ
Version and Feature Checksβ
const version =await client.getVersion();
console.log(version.api_version);
if(!version.features.mcp){
thrownewError('This server does not expose the MCP endpoint');
}
Retain (Store Memory)β
// Simple
await client.retain('my-bank','Alice works at Google');
// With options
await client.retain('my-bank','Alice got promoted',{
timestamp:newDate('2024εΉ΄01ζ15ζ₯'),
context:'career update',
metadata:{ source:'slack'},
async:false,// Set true for background processing
});
Retain Batchβ
await client.retainBatch('my-bank',[
{ content:'Alice works at Google', context:'career'},
{ content:'Bob is a data scientist', context:'career'},
],{
async:false,
});
Recall (Search)β
// Simple - returns RecallResponse
const response =await client.recall('my-bank','What does Alice do?');
for(const r of response.results){
console.log(`${r.text} (type: ${r.type})`);
}
// With options
const response =await client.recall('my-bank','What does Alice do?',{
types:['world','observation'],// Filter by fact type
maxTokens:4096,
budget:'high',// 'low', 'mid', or 'high'
});
Reflect (Generate Response)β
const answer =await client.reflect('my-bank','What should I know about Alice?',{
budget:'low',// 'low', 'mid', or 'high'
context:'preparing for a meeting',
});
console.log(answer.text);// Generated response
Bank Managementβ
Create Bankβ
await client.createBank('my-bank',{
name:'Assistant',
mission:"You're a helpful AI assistant - keep track of user preferences and conversation history.",
disposition:{
skepticism:3,// 1-5: trusting to skeptical
literalism:3,// 1-5: flexible to literal
empathy:3,// 1-5: detached to empathetic
},
});
List Memoriesβ
const response =await client.listMemories('my-bank',{
type:'world',// Optional filter
q:'Alice',// Optional text search
limit:100,
offset:0,
});
console.log(response)
Document Managementβ
Get Documentβ
const doc =await client.getDocument('my-bank','conversation_001');
if(doc){
console.log(doc);// null when document not found
}
List Documentsβ
const response =await client.listDocuments('my-bank',{
limit:50,
offset:0,
});
console.log(response);
Update Documentβ
await client.updateDocument('my-bank','conversation_001',{
tags:['important','meeting-notes'],
});
Delete Documentβ
await client.deleteDocument('my-bank','conversation_001');