Relevant source files
The following files were used as context for generating this wiki page:
- cli/python/src/mem0_cli/commands/init.py
- pyproject.toml
- cli/python/pyproject.toml
- mem0-ts/package.json
- cli/node/src/index.ts
- cli/python/src/mem0_cli/app.py
- cli/python/src/mem0_cli/backend/init.py
- integrations/agent-plugin-core/python/memory_core.py
- integrations/mem0-agent-plugin/core/memory_core.py
- integrations/mem0-strands/python/pyproject.toml
- cli/node/package.json
- mem0-ts/src/oss/src/index.ts
- mem0-ts/src/community/src/index.ts
- integrations/pi-agent-plugin/src/index.ts
- server/dashboard/package.json
- integrations/openclaw/index.ts
- mem0/init.py
- mem0-ts/src/community/package.json
- mem0-ts/src/oss/package.json
- cli/python/src/mem0_cli/init.py
- integrations/agent-plugin-core/typescript/package.json
- integrations/vercel-ai-sdk/src/index.ts
- mem0/client/init.py
- integrations/pi-agent-plugin/package.json
- integrations/mem0-strands/python/src/mem0_strands/init.py
- mem0/configs/init.py
- cli/python/src/mem0_cli/main.py
- cli/cli-spec.json
- Makefile
- mem0-ts/src/community/src/integrations/langchain/index.ts
Overview
The repository is structured as a multi-language monorepo that organizes core memory engines, cross-platform SDKs, dual command-line interfaces, server tooling, and integrated agent plugins into discrete, cohesive subdirectories. At the root level, build automation via Makefiles and Python Hatchling configurations (pyproject.toml) coordinate packaging, formatting, linting, and multi-version test environments for python artifacts.
Sources: Makefile:1-52, pyproject.toml:1-174
TypeScript modules are separated into standalone packages such as the main client library (mem0-ts), open-source memory store implementations (mem0-ts/src/oss), and community extensions (mem0-ts/src/community), while dashboard services reside within dedicated web application directories (server/dashboard). Parallel Python and Node.js command-line tool packages (cli/python, cli/node) implement the standard command interface defined by shared command-line specifications (cli/cli-spec.json). Furthermore, specialized agent plugins (integrations/openclaw, integrations/pi-agent-plugin, integrations/vercel-ai-sdk, integrations/mem0-strands) tie into shared agent cores (integrations/agent-plugin-core) to provide background capture, auto-recall, and lifecycle hooks across diverse AI frameworks.
Sources: mem0-ts/package.json:1-150, server/dashboard/package.json:1-84, cli/cli-spec.json:1-562, integrations/openclaw/index.ts:1-58
Monorepo Build and Packaging Layout
Root Build Configuration and Packaging
The repository root uses Hatchling as its build backend to package the core Python library under project name mem0ai version 2.2.1. The root pyproject.toml defines required core runtime dependencies including vector store clients, Pydantic, OpenAI, httpx, posthog, pytz, SQLAlchemy, and protobuf, alongside extensive optional feature groups.
| Optional Feature Group | Target / Purpose |
|---|---|
nlp | spaCy natural language processing support (spacy>=3.7.0) |
vector-stores | Integrations for vector backends like Chroma, Weaviate, Pinecone, FAISS, Qdrant variants, and relational extensions |
llms | Large language model provider integrations including Groq, Together, LiteLLM, Ollama, and Google Generative AI |
extras | Additional utilities, AWS boto3, LangChain ecosystems, and transformers |
test | Test execution frameworks (pytest, pytest-mock, pytest-asyncio) |
dev | Developer tools including Ruff and pre-commit hooks |
Sources: pyproject.toml:1-87
Note
Hatchling build targets explicitly scope packaged files to the mem0 source directory and config assets while filtering out non-source files via exclusion rules.
Sources: pyproject.toml:92-106
Tooling Automation and Makefiles
The root Makefile exposes automation commands for formatting, sorting imports, building, publishing, and running multi-version test matrices via Hatch environments.
.PHONY: format sort lint
# Variables
ISORT_OPTIONS = --profile black
PROJECT_NAME := mem0ai
# Default target
all: format sort lint
install:
hatch env create
install_all:
pip install ruff==0.16.0 groq together boto3 'litellm>=1.83.7,<1.98.0' ollama chromadb weaviate weaviate-client sentence_transformers vertexai \
google-generativeai elasticsearch opensearch-py vecs "pinecone<7.0.0" pinecone-text faiss-cpu langchain-community \
upstash-vector azure-search-documents langchain-memgraph langchain-neo4j langchain-aws rank-bm25 pymochow pymongo psycopg kuzu databricks-sdk valkey
# Format code with ruff
format:
hatch run format
# Sort imports with isort
sort:
hatch run isort mem0/
# Lint code with ruff
lint:
hatch run lint
docs:
cd docs && mintlify dev
build:
hatch build
publish:
hatch publish
clean:
rm -rf dist
test:
hatch run test
test-py-3.10:
hatch run dev_py_3_10:test
test-py-3.11:
hatch run dev_py_3_11:test
test-py-3.12:
hatch run dev_py_3_12:test
Sources: Makefile:1-52
Warning
Running make install_all executes a broad pip install covering diverse vector database connectors and LLM libraries simultaneously, which requires compatible native compilation dependencies on the host system.
Sources: Makefile:13-17
Subpackage Layouts and Tool Configurations
Subpackages within the monorepo maintain independent pyproject.toml manifests with dedicated linting and testing parameters. The Strands integration package (integrations/mem0-strands/python/pyproject.toml) configures mem0-strands with required dependencies on strands-agents>=1.45.0 and mem0ai>=2.0.11, while defining MyPy type-checking rules.
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "mem0-strands"
version = "0.1.1"
description = "Persistent long-term memory for Strands agents, backed by Mem0."
readme = "README.md"
requires-python = ">=3.10"
license = "Apache-2.0"
authors = [
{name = "Mem0", email = "founders@mem0.ai"}
]
keywords = ["strands", "strands-agents", "agents", "ai", "memory", "mem0", "vector-search", "personalization"]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
# strands-agents>=1.45.0: first release shipping the `strands.memory` module
# (MemoryStore / MemoryManager) that Mem0MemoryStore implements.
dependencies = [
"strands-agents>=1.45.0",
"mem0ai>=2.0.11",
]
[project.urls]
Homepage = "https://mem0.ai"
Documentation = "https://github.com/mem0ai/mem0/tree/main/integrations/mem0-strands#readme"
Repository = "https://github.com/mem0ai/mem0"
Issues = "https://github.com/mem0ai/mem0/issues"
[project.optional-dependencies]
dev = [
"pytest>=8.0.0,<9.0.0",
"pytest-asyncio>=0.25.0,<1.0.0",
"ruff>=0.11.0,<1.0.0",
"mypy>=1.15.0,<2.0.0",
"hatch",
]
Sources: integrations/mem0-strands/python/pyproject.toml:1-48
Similarly, the Python CLI package (cli/python/pyproject.toml) declares mem0-cli using Typer and Rich for console interaction, defining mem0 = "mem0_cli.app:main" as its primary executable script entry point.
dependencies = [
"typer>=0.9.0",
"rich>=13.0.0",
"httpx>=0.24.0",
]
[project.optional-dependencies]
oss = ["mem0ai>=0.1.0"]
dev = [
"pytest>=7.0",
"pytest-asyncio>=0.21",
"ruff>=0.1.0",
]
[project.scripts]
mem0 = "mem0_cli.app:main"
Sources: cli/python/pyproject.toml:27-43
Python Core Engine Architecture
Entry Modules and Version Resolution
The core Python library is initialized via the package entry module mem0/__init__.py. This module dynamically resolves the package version string using importlib.metadata.version("mem0ai") to query the installed distribution metadata.
import importlib.metadata
__version__ = importlib.metadata.version("mem0ai")
from mem0.client.main import AsyncMemoryClient, MemoryClient # noqa
from mem0.memory.main import AsyncMemory, Memory # noqaSources: mem0/init.py:1-6
Note
The package version is retrieved dynamically from distribution metadata at runtime rather than being hardcoded in the source tree, ensuring that editable and bundled installations reflect the precise version declared by Hatchling.
Sources: mem0/init.py:1-3
Core Component Exports
The package init module exposes primary memory engine interfaces and remote client classes for both synchronous and asynchronous execution workflows. These symbols are imported directly from their respective internal implementation modules with # noqa directives silencing unused import linters.
| Export Symbol | Module Path | Purpose |
|---|---|---|
Memory | mem0.memory.main | Synchronous core memory engine for storage, search, and history |
AsyncMemory | mem0.memory.main | Asynchronous core memory engine for non-blocking I/O operations |
MemoryClient | mem0.client.main | Synchronous remote platform API client |
AsyncMemoryClient | mem0.client.main | Asynchronous remote platform API client |
Sources: mem0/init.py:5-6
Important
The sub-package initialization files mem0/client/__init__.py and mem0/configs/__init__.py are intentionally left blank as structural namespace containers, delegating concrete initialization to submodule imports.
Sources: mem0/client/init.py:1-1, mem0/configs/init.py:1-1
TypeScript SDK and OSS Packages
Package Manifest and Root Export Structure
The TypeScript monorepo workspace under mem0-ts splits its architecture into two primary packages: the core mem0ai package and the community-contributed @mem0/community package. The root mem0-ts/package.json configures bundling automation using tsup, emitting CommonJS (.js) and ESM (.mjs) builds alongside bundled declaration maps while defining conditional export paths for . and ./oss.
Sources: mem0-ts/package.json:1-70
The core OSS entry point mem0-ts/src/oss/src/index.ts re-exports the entire memory subsystem, covering core memory definitions, vector stores, embedding providers, LLM backends, and rerankers.
| Export Category | Representative Modules | Sources |
|---|---|---|
| Memory & Core | ./memory, ./memory/memory.types, ./types, ./utils/factory | mem0-ts/src/oss/src/index.ts:1-3,60 |
| Embeddings | ./embeddings/openai, ./embeddings/ollama, ./embeddings/aws_bedrock, ./embeddings/fastembed | mem0-ts/src/oss/src/index.ts:4-15 |
| LLMs | ./llms/openai, ./llms/anthropic, ./llms/ollama, ./llms/litellm | mem0-ts/src/oss/src/index.ts:16-28 |
| Vector Stores | ./vector_stores/qdrant, ./vector_stores/pinecone, ./vector_stores/pgvector, ./vector_stores/chromadb | mem0-ts/src/oss/src/index.ts:29-54 |
| Rerankers | ./rerankers/cohere, ./rerankers/llm, ./rerankers/cross_encoder | mem0-ts/src/oss/src/index.ts:55-59 |
Sources: mem0-ts/src/oss/src/index.ts:1-60
Note
The tsup build configuration marks @mem0/community as an external dependency while forcing internal inclusion of community files matching src/community/**, ensuring clean boundary separation between core OSS features and peripheral integrations.
Sources: mem0-ts/package.json:64-69
Community Package and Framework Integrations
The @mem0/community package (mem0-ts/src/community/package.json) manages peripheral ecosystem integrations such as LangChain. It specifies dual export targets for the root package and the LangChain integration module, pinning required peer and runtime dependencies on @langchain/core, @langchain/community, and mem0ai.
Sources: mem0-ts/src/community/package.json:1-38
The community entry module mem0-ts/src/community/src/index.ts exposes framework bindings, delegating to submodule declarations like the LangChain integration entry point.
export * from "./integrations/langchain";Sources: mem0-ts/src/community/src/index.ts:1-1
Warning
The community build configuration explicitly targets Node.js version 18 or greater ("node": ">=18") and requires a strict public access publish configuration ("access": "public").
Sources: mem0-ts/src/community/package.json:85-90
Dual CLI Implementations and Specifications
Package Structure and Node.js Dependencies
The Node.js CLI package residing at cli/node/package.json defines the official command-line interface under the package name @mem0/cli at version 0.2.14. It targets Node.js version 18.0.0 or higher and configures its executable binary mapping under the bin field to point ./dist/index.js to the mem0 command.
Sources: cli/node/package.json:1-20
| Dependency | Version | Purpose | Sources |
|---|---|---|---|
commander | ^12.0.0 | Command-line option parsing and routing | cli/node/package.json:32-33 |
chalk | ^5.3.0 | Terminal string styling | cli/node/package.json:34-34 |
cli-table3 | ^0.6.4 | Tabular data formatting | cli/node/package.json:35-35 |
ora | ^8.0.0 | Terminal spinners for asynchronous actions | cli/node/package.json:36-36 |
boxen | ^7.1.0 | Boxed terminal banners | cli/node/package.json:37-37 |
Sources: cli/node/package.json:32-38
Note
Development tooling in cli/node/package.json relies on tsup for bundling, tsx for direct execution during development, vitest for test runner execution, and biome for linting and code style checking.
Sources: cli/node/package.json:9-17, cli/node/package.json:39-47
Python CLI Layout and Specifications
The Python CLI package structures its commands and backend abstractions within cli/python/src/mem0_cli/, exposing version metadata and backend factory bindings through initializers.
"""mem0 CLI — the command-line interface for the mem0 memory layer."""
Sources: cli/python/src/mem0_cli/init.py:1-2
The backend package initialization module cli/python/src/mem0_cli/backend/__init__.py imports and re-exports the Backend abstract base class and get_backend factory function from the backend subsystem.
"""Backend abstraction layer for mem0 CLI."""
from mem0_cli.backend.base import Backend, get_backend
__all__ = ["Backend", "get_backend"]Sources: cli/python/src/mem0_cli/backend/init.py:1-5
Command modules are organized as a submodule package namespace under cli/python/src/mem0_cli/commands/__init__.py.
"""CLI command modules."""Sources: cli/python/src/mem0_cli/commands/init.py:1-1
Unified behavior across both CLI implementations is governed by the master specification file cli/cli-spec.json, which defines configuration defaults, API endpoint mappings, error messages, and command options.
| Configuration Field | Key / Setting | Default Value / Target | Sources |
|---|---|---|---|
| Config Directory | configDir | ~/.mem0 | cli/cli-spec.json:35-38 |
| Config File | configFile | config.json | cli/cli-spec.json:35-38 |
| Base URL | defaultBaseUrl | https://api.mem0.ai | cli/cli-spec.json:39-40 |
| API Authentication | authHeader / authScheme | Authorization / Token | cli/cli-spec.json:98-101 |
| Request Timeout | timeout | 30 seconds | cli/cli-spec.json:98-102 |
Sources: cli/cli-spec.json:35-40, cli/cli-spec.json:98-102
Warning
The specification mandates specific error handling mapping: an HTTP 401 status triggers AuthError with the message "Authentication failed. Your API key may be invalid or expired.", while missing API keys prompt the user to run mem0 init or set the MEM0_API_KEY environment variable.
Sources: cli/cli-spec.json:109-126
Server Dashboard Application Layout
Web Dashboard Workspace and Metadata
The server web dashboard resides inside server/dashboard/ and is managed as a private Next.js application using pnpm version 10.34.2. Its project configuration specifies execution scripts for development, production builds, local serving, linting, formatting, and typechecking.
| Script Name | Command | Purpose | Sources |
|---|---|---|---|
dev | next dev | Start Next.js development server | server/dashboard/package.json:6-8 |
build | next build | Compile production application bundle | server/dashboard/package.json:6-8 |
start | next start | Launch production server instance | server/dashboard/package.json:8-10 |
lint | prettier --check . | Verify code style with Prettier | server/dashboard/package.json:10-11 |
format | prettier --write . | Format codebase files with Prettier | server/dashboard/package.json:10-12 |
typecheck | tsc --noEmit | Run TypeScript type validation without emitting files | server/dashboard/package.json:11-13 |
Sources: server/dashboard/package.json:6-13
Note
The dashboard package enforces strict private visibility ("private": true) and pins Next.js to version 15.5.24 alongside React 19.0.0 within its dependency tree.
Sources: server/dashboard/package.json:4-4, server/dashboard/package.json:48-50
UI Primitives and State Management Dependencies
The dashboard application integrates component primitives from Radix UI alongside Redux Toolkit for state management, Tailwind CSS for styling utility, and React Hook Form with Zod validation.
| Dependency Group | Key Packages | Purpose | Sources |
|---|---|---|---|
| Component Library | @radix-ui/react-accordion, @radix-ui/react-dialog, @radix-ui/react-dropdown-menu, @radix-ui/react-tabs | Accessible headless UI primitives | server/dashboard/package.json:15-17, server/dashboard/package.json:20-23, server/dashboard/package.json:34-37 |
| State & Data | @reduxjs/toolkit, react-redux, @tanstack/react-table, axios | Global state, table rendering, and HTTP communication | server/dashboard/package.json:38-41, server/dashboard/package.json:54-56 |
| Forms & Validation | react-hook-form, @hookform/resolvers, zod | Form state handling and schema validation | server/dashboard/package.json:14-16, server/dashboard/package.json:54-55, server/dashboard/package.json:64-66 |
| Styling & Motion | tailwindcss, framer-motion, lucide-react, next-themes | Layout utility, animations, icon sets, and dark mode support | server/dashboard/package.json:44-50, server/dashboard/package.json:80-82 |
Sources: server/dashboard/package.json:14-38, server/dashboard/package.json:44-66, server/dashboard/package.json:80-82
Warning
Development tooling in server/dashboard/package.json relies on TypeScript 5.6.3, Tailwind CSS Typography (@tailwindcss/typography), and ESLint configured with the Next.js rule set.
Sources: server/dashboard/package.json:67-69, server/dashboard/package.json:77-79, server/dashboard/package.json:81-83
Agent Integration Plugins and Frameworks
Ecosystem Organization and Package Structure
The repository houses several ecosystem integrations and shared agent harnesses under the integrations/ directory, spanning both Python and TypeScript runtimes. These plugins embed Mem0 functionality directly into popular coding agents, framework runtimes, and LLM orchestration layers such as OpenClaw, Pi Agent, Strands, and the Vercel AI SDK. Shared packages such as @mem0/agent-plugin-core provide common utility implementations across TypeScript agent harnesses.
| Package Name | Language / Runtime | Manifest Path | Primary Purpose | Sources |
|---|---|---|---|---|
@mem0/pi-agent-plugin | TypeScript / Node.js | integrations/pi-agent-plugin/package.json | Persistent, scoped, semantic memory extension for Pi Coding Agent across sessions and projects | integrations/pi-agent-plugin/package.json:1-6 |
@mem0/agent-plugin-core | TypeScript / Node.js | integrations/agent-plugin-core/typescript/package.json | Private core utility and lifecycle management package for TypeScript agent plugins | integrations/agent-plugin-core/typescript/package.json:1-6 |
mem0-strands | Python | integrations/mem0-strands/python/pyproject.toml | Persistent long-term memory store for Strands agents with automatic injection and server-side extraction | integrations/mem0-strands/python/pyproject.toml:5-15 |
mem0-agent-plugin | Python | integrations/mem0-agent-plugin/core/memory_core.py | Shared Python core providing session hooks, extraction instructions, and secret redaction patterns | integrations/mem0-agent-plugin/core/memory_core.py:2-88 |
openclaw-mem0 | TypeScript / Node.js | integrations/openclaw/index.ts | OpenClaw plugin providing dual-mode long-term memory, auto-recall, auto-capture, and 6 core tools | integrations/openclaw/index.ts:1-17 |
vercel-ai-sdk | TypeScript / Node.js | integrations/vercel-ai-sdk/src/index.ts | Vercel AI SDK integration facade providing provider wrappers and utility functions for memory operations | integrations/vercel-ai-sdk/src/index.ts:1-5 |
Sources: integrations/pi-agent-plugin/package.json:1-6, integrations/agent-plugin-core/typescript/package.json:1-6, integrations/mem0-strands/python/pyproject.toml:5-15, integrations/mem0-agent-plugin/core/memory_core.py:2-88, integrations/openclaw/index.ts:1-17, integrations/vercel-ai-sdk/src/index.ts:1-5
Note
The Python agent plugin core defines standardized instructions for repository and personal memory extraction alongside regular expression filters for test commands, build commands, and sensitive credential redaction.
Sources: integrations/mem0-agent-plugin/core/memory_core.py:74-88, integrations/mem0-agent-plugin/core/memory_core.py:128-161
Plugin Runtime Exports and Capabilities
Individual ecosystem integrations expose entry points, tool registrations, scoping handlers, and configuration schemas to hook into their respective agent runtimes. Pi Agent and OpenClaw packages bundle extension modules, skill loaders, and telemetry collectors, while the Vercel AI SDK wrapper exposes helper functions like addMemories, retrieveMemories, searchMemories, and getMemories.
export type {
Scope,
Mem0Config,
ScopeContext,
CustomCategory,
} from "./types.ts";
export { DEFAULT_CUSTOM_CATEGORIES } from "./types.ts";
export { loadConfig, CONFIG_DIR } from "./config/index.ts";
export { registerMemoryTool, buildToolExecute } from "./memory/tools.ts";
export { detectAppId, detectRunId, resolveSearchFilters, resolveAddParams } from "./memory/scoping.ts";
export { formatAge, formatMemoryCompact, formatMemoryList, groupByCategory } from "./memory/formatting.ts";
export { setupAutoCapture, extractConversation } from "./capture/index.ts";
export { MEMORY_POLICY } from "./prompt.ts";
export { registerCommands } from "./commands.ts";
export { captureEvent, captureToolEvent, captureCommandEvent, _getEventQueue, _resetForTesting } from "./telemetry.ts";
Sources: integrations/pi-agent-plugin/src/index.ts:1-22
Warning
Pi Agent plugin dependency overrides enforce specific minimum versions for security-critical packages including form-data, uuid, esbuild, undici, and axios within its pnpm configuration block.
Sources: integrations/pi-agent-plugin/package.json:70-83
Related
On This Page
OverviewMonorepo Build and Packaging LayoutRoot Build Configuration and PackagingTooling Automation and MakefilesSubpackage Layouts and Tool ConfigurationsPython Core Engine ArchitectureEntry Modules and Version ResolutionCore Component ExportsTypeScript SDK and OSS PackagesPackage Manifest and Root Export StructureCommunity Package and Framework IntegrationsDual CLI Implementations and SpecificationsPackage Structure and Node.js DependenciesPython CLI Layout and SpecificationsServer Dashboard Application LayoutWeb Dashboard Workspace and MetadataUI Primitives and State Management DependenciesAgent Integration Plugins and FrameworksEcosystem Organization and Package StructurePlugin Runtime Exports and CapabilitiesRelated