{"library":"mentedb","title":"MenteDB: AI Agent Memory Database","description":"MenteDB is a purpose-built database engine designed for AI agent memory, providing capabilities like vector similarity search, a typed knowledge graph, token budget-aware context assembly, contradiction detection, and trajectory tracking. It delivers its full Rust-based engine as a native Node.js addon via `napi-rs`, offering zero runtime dependencies for prebuilt binaries. The package is currently at version 0.3.1, indicating an early development stage with potentially rapid API evolution. It releases frequently, with minor versions and bug fixes appearing regularly across its main package and internal sub-packages like `mentedb-storage` and `mentedb-query`. Its key differentiators include its focus on agent-specific cognitive features and its performance benefits from the Rust-native implementation.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install mentedb"],"cli":null},"imports":["import { MenteDB } from 'mentedb';","import { MemoryType } from 'mentedb';","import { CognitionStream } from 'mentedb';","import { EdgeType } from 'mentedb';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { MenteDB, MemoryType, EdgeType, CognitionStream, TrajectoryTracker } from 'mentedb';\n\n// Initialize your embedding model (example placeholder)\nconst embeddingFromYourModel = Array(1536).fill(0.123);\nconst queryEmbedding = Array(1536).fill(0.456);\n\nasync function runMenteDB() {\n  // Open or create a database\n  const db = new MenteDB('./my-agent-memory-data');\n  console.log('MenteDB initialized.');\n\n  // Store a memory\n  const id = db.store({\n    content: 'The deploy key rotates every 90 days',\n    memoryType: MemoryType.Semantic,\n    embedding: embeddingFromYourModel,\n    tags: ['infra', 'security'],\n  });\n  console.log(`Stored memory with ID: ${id}`);\n\n  // Vector similarity search\n  const hits = db.search(queryEmbedding, 2);\n  console.log('Search hits:', hits);\n\n  // MQL recall with token budget\n  const ctx = db.recall('RECALL similar(\"deploy key rotation\") LIMIT 10');\n  console.log('Recall context:', ctx.text, `(${ctx.totalTokens} tokens)`);\n\n  // Relate memories (assuming 'otherId' exists, e.g., from another store call)\n  // const otherId = db.store({ content: 'Another related fact', memoryType: MemoryType.Semantic, embedding: embeddingFromYourModel });\n  // db.relate(id, otherId, EdgeType.Supersedes);\n  // console.log(`Related ${id} to ${otherId}`);\n\n  // Simulate an LLM token stream for cognition\n  const stream = new CognitionStream();\n  const llmTokens = ['Hello', ' ', 'world', '!'];\n  for (const token of llmTokens) {\n    stream.feedToken(token);\n  }\n  console.log('Drained CognitionStream buffer:', stream.drainBuffer());\n\n  // Track reasoning trajectory\n  const tracker = new TrajectoryTracker();\n  tracker.recordTurn('Discuss JWT auth', 'investigating', ['Which algorithm?', 'Token lifetime?']);\n  tracker.recordTurn('Token lifetime', 'decided:15 minutes');\n  console.log('Resume context:', tracker.getResumeContext());\n  console.log('Predicted next topics:', tracker.predictNextTopics());\n\n  // Forget a memory\n  db.forget(id);\n  console.log(`Forgot memory with ID: ${id}`);\n\n  // Close the database\n  db.close();\n  console.log('MenteDB closed.');\n}\n\nrunMenteDB().catch(console.error);","lang":"typescript","description":"This quickstart demonstrates how to initialize MenteDB, store and search memories with embeddings, perform MQL recalls, and utilize its cognitive features like CognitionStream and TrajectoryTracker.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}