Skip to main content

🧩 SDK Overview

The Memory SDK is a set of published @lighthouse-ai/* npm packages that gives agents three primitives - remember / recall / forget - over swappable engines, storages, and embedders. No cloning - install what you need:

npm install @lighthouse-ai/core @lighthouse-ai/engine-batched @lighthouse-ai/store-local-fs @lighthouse-ai/embed-keyword
# add more as needed: @lighthouse-ai/store-lighthouse @lighthouse-ai/store-s3 @lighthouse-ai/embed-local @lighthouse-ai/engine-memwal @lighthouse-ai/cloud-sync

Packages

PackageRoleImport
@lighthouse-ai/coreInterfaces, factory, registry, CID, scoring. Zero network deps.import { createStorage, createEmbedder } from '@lighthouse-ai/core'
@lighthouse-ai/engine-batchedDIY engine: you embed locally, memories buffer and flush as one blob per flushEveryimport { BatchedEngine } from '@lighthouse-ai/engine-batched'
@lighthouse-ai/engine-memwalRelayer engine: embed + SEAL-encrypt + search in the Walrus relayerimport { MemwalMemory } from '@lighthouse-ai/engine-memwal'
@lighthouse-ai/store-local-fsLocal folder adapterimport '@lighthouse-ai/store-local-fs'
@lighthouse-ai/store-lighthouseLighthouse Walrus / Filecoin adapterimport '@lighthouse-ai/store-lighthouse'
@lighthouse-ai/store-s3S3 / R2 / MinIO adapterimport '@lighthouse-ai/store-s3'
@lighthouse-ai/embed-localOn-device MiniLM vectorsimport '@lighthouse-ai/embed-local'
@lighthouse-ai/embed-keywordKeyword-only, zero depsimport '@lighthouse-ai/embed-keyword'
@lighthouse-ai/cloud-syncPointer-service client (backupIndex / restoreIndex)import { backupIndex, restoreIndex } from '@lighthouse-ai/cloud-sync'

core never imports the others. Adding a layer is one registerStorage / registerEmbedder call (see Core & Factory).

Composition pattern

Side-effect imports self-register each package so the factory can find it. You can also pass an instance directly.

import '@lighthouse-ai/store-lighthouse'
import '@lighthouse-ai/embed-local'
import { createStorage, createEmbedder } from '@lighthouse-ai/core'
import { BatchedEngine } from '@lighthouse-ai/engine-batched'

// Factory + registry path
const storage = await createStorage('lh-ipfs-filecoin', { apiKey: process.env.LIGHTHOUSE_API_KEY })
const embedder = await createEmbedder('local')
const memory = new BatchedEngine(storage, { namespace: 'demo', embedder })

// Direct-instance path (same result, no registry lookup)
import { LocalFsStorage } from '@lighthouse-ai/store-local-fs'
const memory2 = new BatchedEngine(new LocalFsStorage({ dir: './blobs' }), { namespace: 'demo', embedder: null })

Engines at a glance

EngineWho embeds / searches / encryptsBatchingNeeds
batchedYou supply the embedder; engine batches into one blob per flushEvery (default 10, min 1) on any storageYes - flush() / auto-flushstorage + embedder (defaults: lh-ipfs-filecoin + local)
memwalRelayer embeds, SEAL-encrypts, and searches; you keep tags/CIDs locallyNo - every remember goes straight to the relayerMEMWAL_PRIVATE_KEY + MEMWAL_ACCOUNT_ID
import { MemwalMemory } from '@lighthouse-ai/engine-memwal'
const memwal = await MemwalMemory.fromEnv() // MEMWAL_* + optional LIGHTHOUSE_API_KEY

Common engine interface (MemoryEngine)

Both engines implement:

remember(content, opts?) // { tags?, metadata? } -> RememberResult
recall(query, opts?) // { tags?, limit? } (+ memwal: { maxDistance? })
list(opts?) // { limit? } (+ memwal: { tags? })
get(idOrCid) // full record
forget(idOrCid) // { removed, blobDeleted?, note }
status() // engine, namespace, counts, index state
flush?() // batched only
rebuild?() // batched: from blobs
snapshotIndex?() // both: one CID for the whole local index
rebuildLocal?(cid) // both: merge a snapshot CID

Memwal adds analyze(), verify(), blobIds(), restore(), and repinPending() - see Memwal Engine.

Local state

Everything saved lives in .memory-sdk/ in the folder you run from (git-ignored):

.memory-sdk/
<namespace>.index.json # batched search index: entries + pending queue
blobs/ # local-fs blobs (batch JSON + CID pointers)
memwal/ # memwal local index (<network>.<namespace>.index.json)

Writes are atomic (tmp file + rename); a missing index just starts empty. Relocate with MEMORY_DIR (batched) or MEMWAL_MEMORY_DIR (memwal). To back the batched index with something else (e.g. Dynamo in the hosted API), pass indexStore to BatchedEngine - it satisfies the IndexStore interface (path, load(), save()).

The cloud-sync auth token is a credential and lives separately at ~/.memory-sdk-cloud/token (mode 0600).

Where to go next

  • Core & Factory - createStorage, createEmbedder, registry, MemoryRecord / RecallMatch types
  • Batched Engine - every method, return shape, and batching rules
  • Memwal Engine - relayer methods, pinning, verification
  • Storages - local-fs, s3, lh-ipfs-* options and capabilities
  • Embedders - local vs keyword vs remote, scoring formula
  • Cloud Sync - backupIndex / restoreIndex pointer client
  • Configuration - full env-var table