npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@memoryrelay/sdk

v0.1.0

Published

Official Node.js SDK for MemoryRelay - semantic memory storage for AI agents

Readme

MemoryRelay Node.js SDK

Official Node.js/TypeScript SDK for MemoryRelay - semantic memory storage for AI agents

npm version License: MIT

Features

  • 🎯 Full TypeScript support with complete type definitions
  • 🔄 Automatic retries with exponential backoff
  • 🚀 Batch operations for efficient bulk inserts
  • 🔍 Semantic search powered by vector embeddings
  • Promise-based API (async/await)
  • 🛡️ Comprehensive error handling
  • 📝 100% test coverage

Installation

npm install @memoryrelay/sdk

or with yarn:

yarn add @memoryrelay/sdk

Quick Start

import { MemoryRelay } from '@memoryrelay/sdk';

// Initialize client
const client = new MemoryRelay({
  apiKey: 'mem_your_api_key_here',
});

// Create a memory
const memory = await client.memories.create({
  content: 'User prefers dark mode',
  agent_id: 'my-agent',
  metadata: { source: 'settings' },
});

// Search memories
const results = await client.memories.search({
  query: 'user preferences',
  limit: 5,
});

console.log(results);

Configuration

const client = new MemoryRelay({
  apiKey: 'mem_your_api_key_here',
  baseURL: 'https://api.memoryrelay.net', // optional
  timeout: 30000,                          // optional (ms)
  maxRetries: 3,                           // optional
});

API Reference

Memories

Create Memory

const memory = await client.memories.create({
  content: 'Memory content',
  agent_id: 'agent-id',
  metadata: { key: 'value' },  // optional
  user_id: 'user-123',          // optional
});

Get Memory

const memory = await client.memories.get('memory-id');

Update Memory

const memory = await client.memories.update('memory-id', {
  content: 'Updated content',
  metadata: { updated: true },
});

Delete Memory

await client.memories.delete('memory-id');

Search Memories

const results = await client.memories.search({
  query: 'search query',
  agent_id: 'agent-id',  // optional
  limit: 10,              // optional
  threshold: 0.7,         // optional
});

List Memories

const memories = await client.memories.list({
  agent_id: 'agent-id',  // optional
  limit: 20,              // optional
  offset: 0,              // optional
});

Batch Create

const response = await client.memories.createBatch([
  { content: 'Memory 1', agent_id: 'agent-1' },
  { content: 'Memory 2', agent_id: 'agent-1' },
  { content: 'Memory 3', agent_id: 'agent-2' },
]);

console.log(`Created ${response.succeeded}/${response.total} memories`);
console.log(`Total time: ${response.timing.total_ms}ms`);

Entities

// Create entity
const entity = await client.entities.create({
  name: 'John Doe',
  type: 'person',
  metadata: { role: 'user' },
});

// Get entity
const entity = await client.entities.get('entity-id');

// List entities
const entities = await client.entities.list({ limit: 10 });

Agents

// Create agent
const agent = await client.agents.create({
  id: 'my-agent',
  name: 'My Agent',
  description: 'Agent description',
});

// Get agent
const agent = await client.agents.get('agent-id');

// List agents
const agents = await client.agents.list();

// Get agent stats
const stats = await client.agents.stats('agent-id');
console.log(`Memories: ${stats.memory_count}`);

Health Check

const health = await client.health();
console.log(health.status); // "healthy"

Error Handling

import {
  ValidationError,
  AuthenticationError,
  NotFoundError,
  RateLimitError,
  NetworkError,
  APIError,
} from '@memoryrelay/sdk';

try {
  const memory = await client.memories.create({
    content: 'Test',
    agent_id: 'agent-1',
  });
} catch (error) {
  if (error instanceof ValidationError) {
    console.error('Invalid input:', error.message);
  } else if (error instanceof AuthenticationError) {
    console.error('Invalid API key');
  } else if (error instanceof NotFoundError) {
    console.error('Resource not found');
  } else if (error instanceof RateLimitError) {
    console.error('Rate limited, retry after:', error.retryAfter);
  } else if (error instanceof NetworkError) {
    console.error('Network error:', error.message);
  } else if (error instanceof APIError) {
    console.error('API error:', error.statusCode, error.message);
  }
}

TypeScript Support

The SDK is written in TypeScript and provides complete type definitions:

import type {
  Memory,
  MemorySearchResult,
  BatchMemoryResponse,
  Entity,
  Agent,
  HealthStatus,
} from '@memoryrelay/sdk';

const memory: Memory = await client.memories.create({
  content: 'Test',
  agent_id: 'agent-1',
});

Examples

Basic Usage

import { MemoryRelay } from '@memoryrelay/sdk';

const client = new MemoryRelay({ apiKey: process.env.MEMORYRELAY_API_KEY! });

// Store user preference
await client.memories.create({
  content: 'User prefers emails in the morning',
  agent_id: 'email-assistant',
  metadata: { category: 'preference', priority: 'high' },
});

// Retrieve relevant context
const context = await client.memories.search({
  query: 'when should I send emails',
  agent_id: 'email-assistant',
  limit: 3,
});

context.forEach((memory) => {
  console.log(`${memory.content} (score: ${memory.score})`);
});

Batch Processing

const newMemories = [
  { content: 'User clicked on product A', agent_id: 'analytics' },
  { content: 'User added item to cart', agent_id: 'analytics' },
  { content: 'User completed purchase', agent_id: 'analytics' },
];

const result = await client.memories.createBatch(newMemories);

console.log(`
  Success: ${result.succeeded}
  Failed: ${result.failed}
  Time: ${result.timing.total_ms}ms
  Avg: ${result.timing.avg_per_item_ms}ms/item
`);

Error Handling with Retries

The SDK automatically retries failed requests with exponential backoff:

const client = new MemoryRelay({
  apiKey: process.env.MEMORYRELAY_API_KEY!,
  maxRetries: 5,  // Retry up to 5 times
  timeout: 60000, // 60 second timeout
});

try {
  const memory = await client.memories.create({
    content: 'Important memory',
    agent_id: 'critical-agent',
  });
} catch (error) {
  // Only throws after all retries exhausted
  console.error('Failed after retries:', error);
}

Development

# Install dependencies
npm install

# Build
npm run build

# Test
npm test

# Test with coverage
npm run test:coverage

# Lint
npm run lint

# Format
npm run format

Requirements

  • Node.js >= 16.0.0
  • TypeScript >= 5.0.0 (for TypeScript users)

Links

  • Documentation: https://docs.memoryrelay.ai
  • API Reference: https://api.memoryrelay.net/docs
  • GitHub: https://github.com/memoryrelay/node-sdk
  • npm: https://www.npmjs.com/package/@memoryrelay/sdk
  • Website: https://memoryrelay.ai

License

MIT License - see LICENSE file for details

Support

  • 📧 Email: [email protected]
  • 💬 Discord: https://discord.gg/memoryrelay
  • 🐛 Issues: https://github.com/memoryrelay/node-sdk/issues

Made with ❤️ by the MemoryRelay team