@syncmem/sdk
v0.1.2
Published
The universal memory layer for AI agents — TypeScript/JavaScript SDK
Maintainers
Readme
@syncmem/sdk
The universal memory layer for AI agents — TypeScript/JavaScript SDK
Give your AI agents persistent, cross-platform memory in under 2 minutes. SyncMem stores facts extracted from conversations, retrieves them in sub-4ms, and probabilistically links the same user across multiple accounts and devices — without changing your LLM or your stack.
Installation
npm install @syncmem/sdk
# or
yarn add @syncmem/sdk
# or
pnpm add @syncmem/sdkQuickstart
import { SyncMem } from '@syncmem/sdk';
const client = new SyncMem({
llmProvider: 'openai',
llmApiKey: process.env.OPENAI_API_KEY!, // your existing key — no new credentials
baseUrl: 'https://api.syncmem.com',
});
// First message — facts are extracted and stored automatically
await client.chat({
accountId: '[email protected]',
message: "I'm a vegetarian living in Tokyo. I'm a backend engineer.",
});
// Later — memory is injected automatically
const response = await client.chat({
accountId: '[email protected]',
message: 'What restaurants would you recommend near my office?',
});
console.log(response.reply);
// → "For vegetarian options in Tokyo, I'd suggest Ain Soph Ripple in Shinjuku..."
console.log(`Injected ${response.factsInjected} memories`);Authentication
Keyless (recommended)
Your existing LLM API key is your SyncMem identity — zero sign-up, zero new credentials.
const client = new SyncMem({
llmProvider: 'openai', // openai | gemini | claude | groq | ollama | mistral
llmApiKey: 'sk-...',
});SyncMem API Key
For multiple isolated namespaces or production deployments, create a sm_live_... key from the dashboard.
const client = new SyncMem({
apiKey: 'sm_live_...',
});Core API
client.chat(options)
Send a message and get a memory-enriched reply. Facts are extracted and stored asynchronously.
const response = await client.chat({
accountId: '[email protected]', // any stable user identifier
message: 'What did we discuss about the Q4 roadmap?',
deviceId: 'device-uuid-123', // optional: improves cross-device linking
});
// response.reply — the LLM's response, enriched with memory
// response.factsInjected — number of memories injected into context
// response.accountId — normalized account identifierclient.getFacts(accountId)
Retrieve all stored facts for a user.
const { facts } = await client.getFacts('[email protected]');
facts.forEach(f => {
console.log(`[${f.category}] ${f.content} (importance: ${f.importance})`);
});client.addFact(accountId, content, options?)
Manually store a fact for a user.
await client.addFact('[email protected]', 'Prefers dark mode in all apps', {
category: 'preferences',
importance: 0.8,
});client.deleteFact(factId)
Delete a specific fact by ID.
await client.deleteFact('fact-uuid-123');client.searchFacts(accountId, query)
Full-text search across a user's facts.
const results = await client.searchFacts('[email protected]', 'dietary preferences');client.getIdentityLinks(accountId)
Get probabilistic identity links — other accounts that likely belong to the same person.
const { links } = await client.getIdentityLinks('[email protected]');
links.forEach(link => {
console.log(`Linked to ${link.accountId} with ${link.confidence * 100}% confidence`);
});Supported LLM Providers
| Provider | llmProvider value |
|----------|-------------------|
| OpenAI | openai |
| Google Gemini | gemini |
| Anthropic Claude | claude |
| Groq | groq |
| Mistral | mistral |
| Together AI | together |
| DeepSeek | deepseek |
| Ollama (local) | ollama |
| Custom / proxy | custom |
MCP Server
SyncMem ships a built-in MCP server for Claude Desktop, Cursor, Windsurf, and any other MCP-compatible agent:
{
"mcpServers": {
"syncmem": {
"command": "npx",
"args": ["-y", "@syncmem/mcp"],
"env": {
"SYNCMEM_API_KEY": "sm_live_...",
"LLM_PROVIDER": "openai",
"LLM_API_KEY": "sk-..."
}
}
}
}Self-hosting
SyncMem is fully open source. Run your own instance:
git clone https://github.com/syncmem/syncmem
cd syncmem/production
cp .env.example .env # fill in secrets
bash scripts/deploy.shLinks
License
MIT © SyncMem
