Metadata-Version: 2.4
Name: cortex-memory-client
Version: 0.3.2
Summary: Self-organizing graph memory for AI agents — Python SDK
Project-URL: Homepage, https://github.com/MikeSquared-Agency/cortex
Project-URL: Documentation, https://github.com/MikeSquared-Agency/cortex/tree/main/docs
Project-URL: Repository, https://github.com/MikeSquared-Agency/cortex.git
Project-URL: Issues, https://github.com/MikeSquared-Agency/cortex/issues
Author-email: MikeSquared Agency <mike@darlington.dev>
License-Expression: MIT
License-File: LICENSE
Keywords: ai-agents,cortex,graph-memory,memory,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: grpcio-tools>=1.60
Requires-Dist: grpcio>=1.60
Requires-Dist: protobuf>=4.25
Provides-Extra: dev
Requires-Dist: pytest; extra == 'dev'
Requires-Dist: pytest-asyncio; extra == 'dev'
Description-Content-Type: text/markdown

# cortex-memory-client

Python client SDK for the [Cortex](https://github.com/MikeSquared-Agency/cortex) graph memory engine. The distribution is named `cortex-memory-client`; the import package remains `cortex_memory`.

## Installation

```bash
pip install cortex-memory-client
```

## Quick start

```python
from cortex_memory import Cortex

# Connect to a running server
with Cortex("localhost:9090") as cx:
    # Store knowledge
    node_id = cx.store(
        "decision",
        "Use FastAPI for the backend",
        body="Chose FastAPI over Flask for async support and type hints",
        tags=["backend", "python"],
        importance=0.8,
    )

    # Semantic search
    results = cx.search("backend technology choices", limit=5)
    for r in results:
        print(f"{r.score:.2f} — {r.title}")

    # Get a briefing
    briefing = cx.briefing("my-agent")
    print(briefing)  # Ready-to-inject markdown
```

## Library mode (embedded server)

```python
cx = Cortex.open("./memory.redb")
# Works identically — starts a local server subprocess
```

## Testing

```python
from cortex_memory.testing import mock_cortex

def test_my_agent():
    with mock_cortex() as cx:
        cx.store("fact", "test data")
        results = cx.search("test")
        assert len(results) == 1
        cx.assert_stored("fact", "test data")
```

### pytest fixture

```python
import pytest
from cortex_memory.testing import mock_cortex

@pytest.fixture
def cortex():
    with mock_cortex() as cx:
        yield cx

def test_store_and_search(cortex):
    cortex.store("decision", "Use FastAPI", body="Async support", importance=0.8)
    results = cortex.search("FastAPI")
    assert results[0].title == "Use FastAPI"
```

## Proto generation

The `cortex_pb2.py` and `cortex_pb2_grpc.py` stubs are pre-generated from
`crates/cortex-proto/proto/cortex.proto`. To regenerate after a proto change:

```bash
pip install grpcio-tools
./scripts/generate_protos.sh
```
