Quick Start
Install the SDK, run the interactive wizard, and give your AI agent persistent memory in under a minute.
Install
Setup
The init wizard walks you through configuring Supabase, Anthropic, Solana, and embeddings. All steps are skippable.
This generates a .env file and shows a ready-to-use code snippet.
Database
Clude uses Supabase with pgvector. Run the schema against your Supabase project:
Usage
supabase config is required. Everything else (Anthropic, embeddings, Solana) is optional and degrades gracefully.
Configuration
The Cortex constructor accepts a CortexConfig object. Only Supabase credentials are required.
supabase (required)
| Field | Type | Description |
|---|---|---|
url | string | Supabase project URL |
serviceKey | string | Supabase service role key |
anthropic (optional)
| Field | Type | Description |
|---|---|---|
apiKey | string | Anthropic API key |
model | string | Model ID. Default: claude-sonnet-4-5-20250929 |
embedding (optional)
| Field | Type | Description |
|---|---|---|
provider | 'voyage' | 'openai' | Embedding provider |
apiKey | string | Provider API key |
model | string | Model name (e.g. voyage-3) |
dimensions | number | Vector dimensions. Default: 1024 |
solana (optional)
| Field | Type | Description |
|---|---|---|
rpcUrl | string | Solana RPC endpoint. Default: mainnet |
botWalletPrivateKey | string | Base58 private key for memo transactions |
Storing Memories
Store memories with automatic importance scoring, concept inference, and optional on-chain commitment.
StoreMemoryOptions
| Field | Type | Description |
|---|---|---|
type | MemoryType | 'episodic' | 'semantic' | 'procedural' | 'self_model' |
content | string | Full memory content (max 5000 chars) |
summary | string | Short summary for recall matching (max 500 chars) |
source | string | Identifier for the agent storing the memory |
tags | string[] | Tags for filtering (max 20) |
concepts | string[] | Structured concepts (auto-inferred if omitted) |
importance | number | 0-1 scale. LLM-scored if omitted (requires anthropic config) |
emotionalValence | number | -1 (negative) to 1 (positive). Default: 0 |
sourceId | string | External ID (e.g. tweet ID, message ID) |
relatedUser | string | Associated user identifier |
relatedWallet | string | Associated wallet address |
metadata | Record<string, unknown> | Arbitrary metadata |
evidenceIds | number[] | IDs of supporting memories |
Memory Types
Each type has a different decay rate, mirroring biological memory:
| Type | Decay / Day | Purpose |
|---|---|---|
episodic | 7% | Raw interactions. Who said what, when. |
semantic | 2% | Distilled knowledge. Patterns and insights. |
procedural | 3% | Learned behavior. What works, what doesn't. |
self_model | 1% | Evolving self-understanding. Nearly permanent. |
Concept Ontology
Memories are automatically tagged with structured concepts from a controlled vocabulary of 12 labels:
market_event, holder_behavior, self_insight, social_interaction, community_pattern, token_economics, sentiment_shift, recurring_user, whale_activity, price_action, engagement_pattern, identity_evolution
Recalling Memories
Hybrid retrieval combining vector similarity, keyword matching, tag scoring, and graph traversal. Ranked by the Generative Agents formula.
recall(opts?)
Returns full Memory objects ranked by composite score.
RecallOptions
| Field | Type | Description |
|---|---|---|
query | string | Natural language search query |
tags | string[] | Filter by tags |
relatedUser | string | Filter by associated user |
memoryTypes | MemoryType[] | Filter by memory type |
limit | number | Max results to return |
minImportance | number | Minimum importance threshold (0-1) |
minDecay | number | Minimum decay factor threshold |
trackAccess | boolean | Update access count and timestamp. Default: true |
Retrieval Scoring
Each memory is scored with the additive formula from Park et al. 2023:
All scores are gated by each memory's decay_factor.
recallSummaries(opts?)
Returns lightweight MemorySummary objects (no content field). Use for progressive disclosure — list summaries first, then hydrate the ones you need.
hydrate(ids)
Fetch full Memory objects by ID. Useful after recallSummaries() to get content for specific memories.
Dream Cycles
A three-phase introspection cycle inspired by biological memory consolidation. Requires anthropic config.
dream(opts?)
Run one full dream cycle: consolidation, reflection, emergence.
Dream Phases
| Phase | What Happens |
|---|---|
| I. Consolidation | Generates focal questions from recent memories. Each question retrieves evidence and produces new semantic insights with citation chains. |
| II. Reflection | Self-model review against accumulated knowledge. Identity evolves based on experience. |
| III. Emergence | Examines its own existence. Output sent to onEmergence callback if provided. |
startDreamSchedule() / stopDreamSchedule()
Run dream cycles on a 6-hour cron schedule with daily memory decay.
anthropic config. Calling dream() without it throws an error.
Association Graph
Typed, weighted links between memories. Connections strengthen through co-retrieval (Hebbian reinforcement).
link(sourceId, targetId, type, strength?)
Link Types
| Type | Meaning |
|---|---|
supports | Source provides evidence for target |
contradicts | Source conflicts with target |
elaborates | Source adds detail to target |
causes | Source led to or caused target |
follows | Source happened after target (temporal) |
relates | General association |
Hebbian Reinforcement
When two linked memories are recalled together, their link strength increases by 0.05. The graph evolves through use, not programming.
During recall, linked memories receive a graph boost weighted at 1.5x in the scoring formula.
Utilities
decay()
Apply type-specific memory decay. Returns the number of memories decayed. Typically called on a daily schedule (handled automatically by startDreamSchedule).
stats()
Returns aggregate statistics about the memory system.
recent(hours, types?, limit?)
Get memories from the last N hours, optionally filtered by type.
selfModel()
Get current self-model memories. These represent the agent's evolving self-understanding.
scoreImportance(description)
Score a text's importance using the LLM (0-1). Falls back to rule-based scoring if no anthropic config.
formatContext(memories)
Format an array of memories into a context string suitable for LLM prompts.
inferConcepts(summary, source, tags)
Infer structured concepts from memory metadata. Returns an array of concept labels from the controlled vocabulary.
destroy()
Clean up resources, stop dream schedules, and remove event listeners.
Events
Listen for memory system events via the internal event bus.
on('memory:stored', handler)
Fired every time a memory is stored. Receives importance score and memory type.
Episodic memories automatically accumulate importance toward triggering dream cycles.
Database Schema
Clude uses Supabase PostgreSQL with the pgvector extension for vector similarity search.
Setup
The schema file is included in the npm package:
Or import it directly:
Tables
| Table | Purpose |
|---|---|
memories | Core memory store with pgvector embedding column |
memory_links | Association graph edges (typed, weighted) |
memory_fragments | Per-fragment embeddings for granular vector search |
dream_sessions | Dream cycle history and outputs |
linked_wallets | X handle to Solana wallet mappings |
pgvector
The schema creates HNSW indexes for fast vector search. Make sure the vector extension is enabled in your Supabase project (it is by default).
Graceful Degradation
The SDK works with minimal config and progressively unlocks features as you add more.
| Feature | Config Needed | Without It |
|---|---|---|
| Store / Recall | supabase | Constructor throws |
| Vector search | embedding | Keyword + tag scoring only |
| LLM importance | anthropic | Rule-based calculateImportance() |
| Dream cycles | anthropic | dream() throws clear error |
| On-chain commits | solana | Silently skipped |
| Emergence output | onEmergence | Output discarded (SDK never tweets) |
supabase config, you get full store/recall with keyword matching, tag scoring, type-specific decay, and the association graph. Add embedding and anthropic configs later as needed.