Metadata-Version: 2.4
Name: memorylaier
Version: 0.1.0
Summary: Python SDK for MemoryLayer — persistent memory infrastructure for AI agents
Project-URL: Homepage, https://memorylaier.com
Project-URL: Repository, https://github.com/Memorylaier/memorylaier
Project-URL: Documentation, https://memorylaier.com/v1/docs
License-Expression: Apache-2.0
Requires-Python: >=3.10
Requires-Dist: httpx>=0.25
Description-Content-Type: text/markdown

# MemoryLayer Python SDK

[![PyPI version](https://img.shields.io/pypi/v/memorylaier)](https://pypi.org/project/memorylaier/)

Python client for [MemorylAIer](https://memorylaier.com) — persistent memory infrastructure for AI agents. Knowledge graph, semantic dedup, decay, and behavioral lessons at **$0.001/call**. No subscription.

## Install

```bash
pip install memorylaier
```

## Quick Start

```python
from memorylaier import MemoryLayerClient

client = MemoryLayerClient(api_key="your-api-key")

# Store facts (auto-dedup, entity extraction, relationship graph)
client.store_facts([
    {"text": "John Smith works at Acme Corp as a senior engineer"},
    {"text": "Acme Corp is based in New York"},
])

# Semantic search with time-decay scoring
results = client.query("Where does John work?")
for m in results["memories"]:
    print(f"{m['fact']} (score: {m['score']})")

# Hybrid search (vector + full-text) — best for entity names and exact terms
results = client.query("john@acme.com", hybrid=True)

# Knowledge graph traversal
graph = client.graph_traverse("John Smith", max_depth=2)
for edge in graph["edges"]:
    print(f"{edge['source']} --{edge['predicate']}--> {edge['target']}")

# Temporal query: what did we know last month?
past = client.query("John Smith", as_of="2026-02-01T00:00:00Z")

# Extract facts from conversation
client.extract_conversation([
    {"role": "user", "content": "My name is Alice and I work at Google"},
    {"role": "assistant", "content": "Nice to meet you Alice!"},
])

# Behavioral lessons
client.add_lesson("Always confirm before making changes")

# Temporal triggers
client.set_trigger(
    trigger_at="2026-03-10T09:00:00Z",
    label="Follow up with John about the project",
)

client.close()
```

## Features

- **Semantic search** with time-decay and access-count boosting
- **Knowledge graph** with auto-extracted relationships and multi-hop traversal
- **Write gate** quality scoring on every write
- **Auto-dedup** with supersession tracking
- **Temporal queries** — "what did we know at date X?"
- **Conversation extraction** — auto-extract facts from chat messages
- **Behavioral lessons** — self-improvement primitives
- **Temporal triggers** — scheduled memory surfacing
- **Memory health** monitoring

## Authentication

Two auth paths — use whichever fits your setup:

- **API key**: `MemoryLayerClient(api_key="sk_...")` — persistent integrations
- **x402 micropayments**: USDC on Base, zero-signup — see [docs](https://memorylaier.com/docs)

## Pricing

| Operation | Price (USDC) |
|-----------|-------------|
| Write | $0.001 |
| Read | $0.0005 |
| Search | $0.001 |

## Links

- [Interactive API Docs](https://memorylaier.com/docs)
- [OpenAPI Spec](https://memorylaier.com/v1/docs)
- [MCP Server](https://www.npmjs.com/package/memorylaier) — `npx memorylaier-mcp`
- [GitHub](https://github.com/Memorylaier/memorylaier)

## License

Apache-2.0
