Skip to content

TypeScript SDK

The MemoryLayer TypeScript SDK (@scitrera/memorylayer-sdk) provides a fully typed client for the MemoryLayer server from TypeScript and JavaScript applications. It is an Apache-2.0 licensed ESM package with no runtime dependencies, and it requires Node.js 18+ or another runtime with fetch.

Installation

Terminal window
npm install @scitrera/memorylayer-sdk

Features

  • Full TypeScript Support — Complete type definitions included, no @types packages needed
  • Memory Operations — Remember, recall (including temporal filters and token budgets), reflect, forget, decay, browse
  • Relationship Graph — Create, update, delete, and traverse typed relationships
  • Entity Registry — Resolve and merge canonical entities
  • Sessions — Working memory with TTL and commit, plus checkpoints, context packs, and context deltas
  • Chat Threads — Conversation history with decomposition into memories
  • Skills, MCP Servers, Knowledgebase, RPG — client.skills, client.mcpServers, client.kb, client.rpg
  • On-Behalf-Of — Per-call or scoped authority headers
  • Retries and Custom Transport — Automatic backoff for idempotent requests, and a pluggable fetch
  • Error Handling — Typed exception hierarchy

Quick Start

import { MemoryLayerClient, MemoryType } from "@scitrera/memorylayer-sdk";
const client = new MemoryLayerClient({
baseUrl: "http://localhost:61001",
workspaceId: "my-workspace",
});
// Store a memory
const memory = await client.remember("User prefers dark mode", {
type: MemoryType.SEMANTIC,
importance: 0.8,
tags: ["preference", "ui"],
});
// Recall memories
const result = await client.recall("What are the user's UI preferences?", {
limit: 5,
minRelevance: 0.7,
});
console.log(result.memories);

Configuration

const client = new MemoryLayerClient({
baseUrl: "http://localhost:61001", // Default
apiKey: process.env.MEMORYLAYER_API_KEY, // Optional for local dev
workspaceId: "my-workspace",
sessionId: "optional-session-id", // Auto-include in requests
timeout: 30000, // Request timeout in ms
maxRetries: 3, // Retries for idempotent requests
});

Next Steps

Other SDKs

  • Python SDK — memorylayer-client (async and sync)
  • Go SDK — github.com/scitrera/memorylayer/memorylayer-sdk-go