Metadata-Version: 2.4
Name: memblock
Version: 0.4.2
Summary: Typed block tree + knowledge graph memory SDK for AI agents
Author-email: iexcalibur <shubhamkannojia10@gmail.com>
License: Proprietary
Project-URL: Homepage, https://memblock.xyz
Project-URL: Documentation, https://memblock.xyz
Project-URL: Repository, https://github.com/iexcalibur/memblock
Project-URL: Bug Tracker, https://github.com/iexcalibur/memblock/issues
Keywords: ai,memory,knowledge-graph,llm,agent
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography>=41.0
Provides-Extra: postgres
Requires-Dist: psycopg[binary]>=3.1; extra == "postgres"
Provides-Extra: tokens
Requires-Dist: tiktoken>=0.5; extra == "tokens"
Provides-Extra: llm
Requires-Dist: openai>=1.0; extra == "llm"
Requires-Dist: anthropic>=0.20; extra == "llm"
Requires-Dist: google-genai>=1.0; extra == "llm"
Provides-Extra: embeddings
Requires-Dist: fastembed>=0.3; extra == "embeddings"
Provides-Extra: embeddings-openai
Requires-Dist: httpx>=0.24; extra == "embeddings-openai"
Provides-Extra: embeddings-gemini
Requires-Dist: httpx>=0.24; extra == "embeddings-gemini"
Provides-Extra: llm-gemini
Requires-Dist: google-genai>=1.0; extra == "llm-gemini"
Provides-Extra: reranker-cohere
Requires-Dist: httpx>=0.24; extra == "reranker-cohere"
Provides-Extra: reranker-cross-encoder
Requires-Dist: sentence-transformers>=2.0; extra == "reranker-cross-encoder"
Provides-Extra: all
Requires-Dist: memblock[postgres]; extra == "all"
Requires-Dist: memblock[tokens]; extra == "all"
Requires-Dist: memblock[llm]; extra == "all"
Requires-Dist: memblock[embeddings]; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: psycopg[binary]>=3.1; extra == "dev"
Dynamic: license-file

<p align="center">
  <h1 align="center">MemBlock</h1>
  <p align="center"><strong>Structured memory SDK for AI agents.</strong></p>
  <p align="center">Typed blocks · Knowledge graph · Hybrid search · Encryption · Decay engine — all local, all yours.</p>
</p>

---

## Install

```bash
pip install memblock
```

## Quick Start

```python
from memblock import MemBlock, BlockType

mem = MemBlock(storage="sqlite:///memory.db")

# Store structured memories
mem.store("User prefers Python", type=BlockType.PREFERENCE)
mem.store("User works at Acme Corp", type=BlockType.FACT, confidence=0.95)

# Query with hybrid search
results = mem.query(text_search="programming", type=BlockType.PREFERENCE)

# Build LLM-ready context
context = mem.build_context(query="user preferences", token_budget=4000)

# Knowledge graph
mem.link(results[0].id, other.id, relation="related_to")

# Tamper detection
mem.verify()
```

## What's Included

- **5 typed memory blocks** — FACT, PREFERENCE, EVENT, ENTITY, RELATION
- **Knowledge graph** — 8 relation types, traversal, no external DB
- **Hybrid search** — FTS5 + vector similarity with Reciprocal Rank Fusion
- **Memory decay** — Exponential decay with access reinforcement
- **AES-256 encryption** — Field-level, your keys, no enterprise tier
- **Tamper detection** — SHA-256 hash chain on every operation
- **LLM extraction** — Auto-extract memories from conversations (OpenAI, Anthropic, Gemini)
- **Conflict resolution** — LLM-powered ADD/UPDATE/DELETE decisions
- **Context builder** — Token-budgeted, 3 strategies
- **Async API** — Full async support via AsyncMemBlock
- **Event hooks** — on_add, on_update, on_delete, on_query
- **Hierarchical scoping** — org → project → user → agent → session
- **Rerankers** — BM25, Cohere, CrossEncoder
- **Storage** — SQLite (local) or PostgreSQL (production)
- **CLI** — init, query, stats, prune, export, reindex

## Optional Extras

```bash
pip install "memblock[postgres]"            # PostgreSQL backend
pip install "memblock[embeddings]"          # Local vector embeddings (FastEmbed)
pip install "memblock[llm]"                 # LLM extraction (OpenAI, Anthropic, Gemini)
pip install "memblock[reranker-cohere]"     # Cohere reranker
pip install "memblock[reranker-cross-encoder]"  # HuggingFace reranker
pip install "memblock[all]"                 # Everything
```

## Documentation

Full docs, API reference, and examples: **[memblock.xyz](https://memblock.xyz)**

## License

Proprietary. Copyright (c) 2025-2026 iexcalibur. All Rights Reserved.
