Introduction
The AI Memory Layer for Effect Applications
Cortex is a logic-first vector database built for the Effect ecosystem. It provides a type-safe, pluggable memory layer for AI agents and LLM applications, keeping you in full control of your data without the infrastructure overhead.
Why Cortex?
Most vector databases are black boxes that require complex infrastructure or network calls. Cortex sits right in your process, giving you:
- Local-First Persistence: In-process storage with WAL (Write-Ahead Logging) via ZVec.
- Effect Native: Built on
effect. Fully typed, zero exceptions, and pure dependency injection. - Logic/Infrastructure Separation: Define your AI memory logic today, choose your storage adapter (ZVec, InMemory, etc.) at runtime.
- Automatic TTL: Native support for expiring memories (
expires_at), perfect for ephemeral session context.
Quick Look
How easy is it to teach an AI something new?
import { Effect } from "effect";
import { VectorDB, DocumentId, Vector } from "@thaletto/cortex";
const teachAI = (id: string, fact: string) =>
Effect.gen(function* () {
const db = yield* VectorDB;
yield* db.upsert({
id: DocumentId.make(id),
content: fact,
category: "memory",
tags: "user-profile",
metadata_json: "{}",
vector: Vector.make([...]), // Your embedding here
expires_at: new Date("2030-01-01")
});
});
// Later, search it back Semantically
const remember = (queryVector: Vector) =>
Effect.gen(function* () {
const db = yield* VectorDB;
return yield* db.search(queryVector, 5);
});Features at a Glance
| Feature | Description |
|---|---|
| Pluggable | Swap between ZVec (persistent) and InMemory (tests) seamlessly. |
| Type-Safe | Powered by Effect Schema. No more "any" in your metadata. |
| Zero-Infra | No Docker, no external API keys, just your data in .cortex/. |
| Pruning | Built-in pruneExpired to keep your context window lean. |