Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
211 changes: 25 additions & 186 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
# ============================================
# OpenMemory - Environment Configuration
# ============================================
# OpenMemory JS server environment

# --------------------------------------------
# Backend Server Settings
# --------------------------------------------
OM_PORT=8080

# API Authentication (IMPORTANT: Set a strong API key for production!)
# Generate a secure key: openssl rand -base64 32
# Leave empty to disable authentication (development only)
OM_API_KEY=your-secret-api-key-here

# Rate Limiting
# Enable rate limiting to prevent abuse
OM_RATE_LIMIT_ENABLED=true
# Time window in milliseconds (default: 60000 = 1 minute)
OM_RATE_LIMIT_WINDOW_MS=60000
# Maximum requests per window (default: 100 requests per minute)
OM_RATE_LIMIT_MAX_REQUESTS=100

# Optional: Log all authenticated requests (set to 'true' for debugging)
OM_API_KEY=
OM_LOG_AUTH=false

# Telemetry (true by default, set to false to opt out of anonymous ping)
OM_TELEMETRY=true

# Server Mode
Expand All @@ -44,198 +23,58 @@ OM_PG_USER=postgres
OM_PG_PASSWORD=postgres
OM_PG_SCHEMA=public
OM_PG_TABLE=openmemory_memories
OM_PG_SSL=disable # disable | require
OM_PG_SSL=disable

# --------------------------------------------
# Vector Store Backend
# --------------------------------------------
# Vector storage follows OM_METADATA_BACKEND (sqlite/postgres) unless set to 'valkey'
# Options: valkey (Redis-compatible), or leave unset to follow OM_METADATA_BACKEND
# Note: When using postgres metadata backend, vectors are stored in the same database
OM_VECTOR_BACKEND=sqlite
# Table name for vectors (configurable, will be created if it doesn't exist)
OM_VECTOR_TABLE=vectors
OM_WEAVIATE_URL=
OM_WEAVIATE_API_KEY=
OM_WEAVIATE_CLASS=OpenMemory
# Vector storage
OM_VECTOR_BACKEND=postgres
OM_VECTOR_TABLE=openmemory_vectors

# --------------------------------------------
# Embeddings Configuration
# --------------------------------------------
# Available providers: openai, gemini, aws, ollama, local, synthetic
# Embedding models per sector can be configured in models.yaml
#
# NOTE: Your selected TIER (fast/smart/deep) affects how embeddings work:
# β€’ FAST tier: Uses synthetic embeddings regardless of OM_EMBEDDINGS setting
# β€’ SMART tier: Combines synthetic + compressed semantic from your chosen provider
# β€’ DEEP tier: Uses full embeddings from your chosen provider
#
# For SMART/DEEP tiers, set your preferred provider:
# Embeddings
OM_EMBEDDINGS=openai

# Fallback chain: comma-separated list of providers to try if primary fails
# Each provider exhausts its own retry logic before moving to the next
# Example: OM_EMBEDDING_FALLBACK=ollama,synthetic
# Default: synthetic (always works as final fallback)
OM_EMBEDDING_FALLBACK=synthetic

# Vector dimension (auto-adjusted by tier, but can be overridden)
# β€’ FAST: 256-dim β€’ SMART: 384-dim β€’ DEEP: 1536-dim
# OM_VEC_DIM=1536

# Embedding Mode
# simple = 1 unified batch call for all sectors (faster, rate-limit safe, recommended)
# advanced = 5 separate calls, one per sector (higher precision, more API calls)
OM_EMBED_MODE=simple

# Advanced Mode Options (only used when OM_EMBED_MODE=advanced)
# Enable parallel embedding (not recommended for Gemini due to rate limits)
OM_ADV_EMBED_PARALLEL=false
# Delay between embeddings in milliseconds
OM_EMBED_DELAY_MS=200
OM_VEC_DIM=1536

# OpenAI-compatible Embeddings Provider
# OM_OPENAI_BASE_URL=https://api.openai.com/v1
# Model override for all sector embeddings (leave empty to use defaults)
# OM_OPENAI_MODEL=text-embedding-qwen3-embedding-4b

# API Configuration
# Max request body size in bytes (default: 1MB)
OM_MAX_PAYLOAD_SIZE=1000000

# --------------------------------------------
# Embedding Provider API Keys
# --------------------------------------------
# OpenAI Embeddings
OPENAI_API_KEY=your-openai-api-key-here

# Google Gemini Embeddings
GEMINI_API_KEY=your-gemini-api-key-here

# AWS Titan Text Embeddings V2
AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY
AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY
OPENAI_API_KEY=
GEMINI_API_KEY=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=us-east-1

# Ollama Local Embeddings
OLLAMA_URL=http://localhost:11434
LOCAL_MODEL_PATH=

# Local Model Path (for custom embedding models)
LOCAL_MODEL_PATH=/path/to/your/local/model

# --------------------------------------------
# Memory System Settings
# --------------------------------------------

# ============================================
# PERFORMANCE TIER (Manual Configuration Required)
# ============================================
# OpenMemory requires you to manually set the performance tier.
# Set OM_TIER to one of: hybrid, fast, smart, or deep
#
# Available Tiers:
#
# HYBRID - Keyword + Synthetic embeddings (256-dim) with BM25 ranking
# β€’ Recall: ~100% (exact keyword matching) β€’ QPS: 800-1000 β€’ RAM: 0.5GB/10k memories
# β€’ Best for: Exact searches, documentation, code search, personal knowledge
# β€’ Features: Exact phrase matching, BM25 scoring, n-gram matching, 100% accuracy
# β€’ Use when: You need guaranteed exact matches and keyword-based retrieval
#
# FAST - Synthetic embeddings only (256-dim)
# β€’ Recall: ~70-75% β€’ QPS: 700-850 β€’ RAM: 0.6GB/10k memories
# β€’ Best for: Local apps, VS Code extensions, low-end hardware
# β€’ Use when: < 4 CPU cores or < 8GB RAM
#
# SMART - Hybrid embeddings (256-dim synthetic + 128-dim compressed semantic = 384-dim)
# β€’ Recall: ~85% β€’ QPS: 500-600 β€’ RAM: 0.9GB/10k memories
# β€’ Best for: Production servers, AI copilots, mid-range hardware
# β€’ Use when: 4-7 CPU cores and 8-15GB RAM
#
# DEEP - Full AI embeddings (1536-dim OpenAI/Gemini)
# β€’ Recall: ~95-100% β€’ QPS: 350-400 β€’ RAM: 1.6GB/10k memories
# β€’ Best for: Cloud deployments, high-accuracy systems, semantic research
# β€’ Use when: 8+ CPU cores and 16+ GB RAM
#
# REQUIRED: Set your tier (no auto-detection):
OM_TIER=hybrid

# Keyword Matching Settings (HYBRID tier only)
# Boost multiplier for keyword matches (default: 2.5)
OM_KEYWORD_BOOST=2.5
# Minimum keyword length for matching (default: 3)
OM_KEYWORD_MIN_LENGTH=3
# Server limits
OM_MAX_PAYLOAD_SIZE=1000000
OM_RATE_LIMIT_ENABLED=false
OM_RATE_LIMIT_WINDOW_MS=60000
OM_RATE_LIMIT_MAX_REQUESTS=100

# Memory settings
OM_MIN_SCORE=0.3

# ============================================
# Smart Decay Settings (Time-Based Algorithm)
# ============================================
# Decay interval in minutes - how often the decay cycle runs
# The new algorithm uses time-based decay with daily lambda rates (hot=0.005/day, warm=0.02/day, cold=0.05/day)
# Unlike batch-based systems, running more frequently doesn't increase decay speed
# Decay is calculated from: decay_factor = exp(-lambda * days_since_access / (salience + 0.1))
#
# Recommended intervals:
# β€’ Testing: 30 minutes (for rapid validation)
# β€’ Development: 60-120 minutes (balanced testing)
# β€’ Production: 120-180 minutes (optimal - captures meaningful decay deltas while minimizing overhead)
#
# At 2-3 hours: hot tier decays ~0.04-0.06%, warm ~0.16-0.24%, cold ~0.4-0.6% per cycle
OM_DECAY_INTERVAL_MINUTES=120

# Number of parallel decay worker threads (default: 3)
OM_DECAY_THREADS=3
# Cold tier threshold - memories below this salience get fingerprinted (default: 0.25)
OM_DECAY_COLD_THRESHOLD=0.25
# Reinforce memory salience when queried (default: true)
OM_DECAY_REINFORCE_ON_QUERY=true
# Enable regeneration of cold memories on query hits (default: true)
OM_REGENERATION_ENABLED=true
# Maximum vector dimensions (default: 1536)
OM_MAX_VECTOR_DIM=1536
# Minimum vector dimensions for compression (default: 64)
OM_MIN_VECTOR_DIM=64
# Number of summary compression layers 1-3 (default: 3)
OM_SUMMARY_LAYERS=3

# Full Semantic Graph MVP Settings
# Use summary-only storage (≀300 chars, intelligent extraction)
OM_USE_SUMMARY_ONLY=true
# Maximum summary length - smart extraction preserves dates, names, numbers, actions
OM_SUMMARY_MAX_LENGTH=300
# Memories per segment (10k recommended for optimal cache performance)
OM_SEG_SIZE=10000
OM_KEYWORD_BOOST=2.5
OM_KEYWORD_MIN_LENGTH=3

# Cache segments (auto-tuned by tier, but can be overridden)
# β€’ FAST: 2 segments β€’ SMART: 3 segments β€’ DEEP: 5 segments
# OM_CACHE_SEGMENTS=3

# Max active queries (auto-tuned by tier, but can be overridden)
# β€’ FAST: 32 queries β€’ SMART: 64 queries β€’ DEEP: 128 queries
# OM_MAX_ACTIVE=64

# Brain Sector Configuration (auto-classified, but you can override)
# Sectors: episodic, semantic, procedural, emotional, reflective

# Auto-Reflection System
# Automatically creates reflective memories by clustering similar memories
# Optional background jobs
OM_AUTO_REFLECT=false
# Reflection interval in minutes (default: 10)
OM_REFLECT_INTERVAL=10
# Minimum memories required before reflection runs (default: 20)
OM_REFLECT_MIN_MEMORIES=20
OM_USER_SUMMARY_INTERVAL=30

# Compression
# Enable automatic content compression for large memories
OM_COMPRESSION_ENABLED=false
# Minimum content length (characters) to trigger compression (default: 100)
OM_COMPRESSION_MIN_LENGTH=100
# Compression algorithm: semantic, syntactic, aggressive, auto (default: auto)
OM_COMPRESSION_ALGORITHM=auto

# --------------------------------------------
# LangGraph Integration Mode (LGM)
# --------------------------------------------
# Optional LangGraph mode
OM_LG_NAMESPACE=default
OM_LG_MAX_CONTEXT=50
OM_LG_REFLECTIVE=true

36 changes: 20 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
workflow_dispatch:

jobs:
<<<<<<< Updated upstream
test-python:
name: Test Python SDK
runs-on: ubuntu-latest
Expand Down Expand Up @@ -35,25 +36,28 @@ jobs:

test-node:
name: Test Node.js SDK
=======
test-js:
name: Test JavaScript package
>>>>>>> Stashed changes
runs-on: ubuntu-latest
env:
OM_DB_URL: "sqlite:///:memory:"
OM_TIER: "fast"
OM_TIER: fast
OM_VEC_DIM: "1536"
OM_EMBEDDINGS: synthetic
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4

- uses: actions/setup-node@v4
with:
node-version: '22'
- name: Install Dependencies
run: |
cd packages/openmemory-js
npm ci
- name: Run Verification Test
run: |
cd packages/openmemory-js
npx tsx tests/test_omnibus.ts
node-version: "22"

- name: Install dependencies
run: cd packages/openmemory-js && npm ci

- name: Build
run: cd packages/openmemory-js && npm run build

- name: Run verification test
run: cd packages/openmemory-js && npx tsx tests/test_omnibus.ts

59 changes: 8 additions & 51 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,27 @@ name: Docker Build Test

on:
push:
branches:
- main
- develop
branches: [main, develop]
pull_request:
branches:
- main
- develop
branches: [main, develop]
workflow_dispatch:

jobs:
docker-build-test:
runs-on: ubuntu-latest
name: Test Docker Build

steps:
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: docker/setup-buildx-action@v3

- name: Build Backend Docker Image
- name: Build OpenMemory Docker image
uses: docker/build-push-action@v5
with:
context: ./packages/openmemory-js
file: ./packages/openmemory-js/Dockerfile
push: false
tags: openmemory-backend:test
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Test Docker Compose Build
run: |
docker compose build
docker compose config

- name: Start Services
run: |
docker compose up -d
sleep 10

- name: Check Health Endpoint
run: |
max_attempts=30
attempt=0
until curl -f http://localhost:8080/health || [ $attempt -eq $max_attempts ]; do
echo "Waiting for service to be healthy... (attempt $((attempt+1))/$max_attempts)"
sleep 2
attempt=$((attempt+1))
done

if [ $attempt -eq $max_attempts ]; then
echo "Service failed to become healthy"
docker compose logs
exit 1
fi

echo "βœ… Service is healthy!"
curl -v http://localhost:8080/health
tags: openmemory-js:test

- name: Show Container Logs
if: failure()
run: docker compose logs
- name: Validate compose config
run: docker compose config

- name: Cleanup
if: always()
run: docker compose down -v
Loading