@clude/sdk 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +514 -0
- package/dist/cli/index.js +8621 -0
- package/dist/mcp/local-store.js +268 -0
- package/dist/mcp/server.js +5105 -0
- package/dist/sdk/index.js +6254 -0
- package/package.json +113 -0
- package/supabase-schema.sql +531 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 sebbsssss
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
# Clude
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@clude/sdk)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
**Cognitive memory for AI agents.** Not just storage — synthesis.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## About Clude
|
|
11
|
+
|
|
12
|
+
### What it is
|
|
13
|
+
|
|
14
|
+
A cognitive memory system. Most memory SDKs store and retrieve. Clude also processes memories over time — decay, consolidation, contradiction resolution, reflection.
|
|
15
|
+
|
|
16
|
+
- **Benchmarked:** 1.96% hallucination on [HaluMem](https://arxiv.org/abs/2511.03506) — next best system: 15.2%. Industry average: ~21%.
|
|
17
|
+
- **Local-first:** SQLite + local embeddings. Zero API keys, zero network, full semantic search offline.
|
|
18
|
+
- **Hosted:** One API key, no infrastructure. `npx @clude/sdk register`
|
|
19
|
+
- **Portable memory:** export/import in JSON, Markdown, ChatGPT, Claude, and Gemini formats. Your memories move between agents, frameworks, and models.
|
|
20
|
+
|
|
21
|
+
**Cognitive architecture:**
|
|
22
|
+
- **Typed memory with differential decay** — episodic (7%/day), semantic (2%/day), procedural (3%/day), self-model (1%/day). Accessed memories get reinforced.
|
|
23
|
+
- **Autonomous dream cycles** — consolidation, compaction, reflection, contradiction resolution, emergence.
|
|
24
|
+
- **Bond-typed memory graph** — weighted typed edges with Hebbian reinforcement on co-retrieval.
|
|
25
|
+
- **Clinamen** — lateral retrieval of high-importance, low-relevance memories.
|
|
26
|
+
|
|
27
|
+
### What it isn't yet
|
|
28
|
+
|
|
29
|
+
No framework integrations (LangGraph, CrewAI) — wrappers around `brain.store()` and `brain.recall()` are days each. No structured business data ingestion. No temporal fact validity querying. No managed enterprise platform. No large contributor community. Early-stage adoption.
|
|
30
|
+
|
|
31
|
+
### What it could be
|
|
32
|
+
|
|
33
|
+
Clude is a memory engine, not a framework. Framework integrations, structured data ingestion, temporal querying, enterprise platforms, evaluation frameworks, multi-model support, autonomous operation, multi-user scoping — these can all be built on top. A non-developer built a 5,750-line autonomous agent on Clude in two weeks using an AI coding assistant — 109 tools, self-editing agent-directed memory, multi-model inference, web search, multi-user presence tracking, and a browser UI. The cognitive architecture was handled by Clude.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
**Public Wallet: CA1HYUXZXKc7CasRGpQotMM9RiYJbVuPJq3n8Ar9oQZb**
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npm install -g @clude/sdk
|
|
41
|
+
clude setup
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Built on [Stanford Generative Agents](https://arxiv.org/abs/2304.03442), [MemGPT/Letta](https://arxiv.org/abs/2310.08560), [CoALA](https://arxiv.org/abs/2309.02427), and [Beads](https://github.com/steveyegge/beads).
|
|
45
|
+
|
|
46
|
+
**Works with:** Claude Code, Claude Desktop, Cursor, and any MCP-compatible agent runtime.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Quick Start — Hosted (Zero Setup)
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npx @clude/sdk setup # Creates agent, installs MCP, done
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or use the SDK:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { Cortex } from '@clude/sdk';
|
|
60
|
+
|
|
61
|
+
const brain = new Cortex({
|
|
62
|
+
hosted: { apiKey: process.env.CORTEX_API_KEY! },
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
await brain.init();
|
|
66
|
+
|
|
67
|
+
await brain.store({
|
|
68
|
+
type: 'episodic',
|
|
69
|
+
content: 'User asked about pricing and seemed frustrated.',
|
|
70
|
+
summary: 'Frustrated user asking about pricing',
|
|
71
|
+
tags: ['pricing', 'user-concern'],
|
|
72
|
+
importance: 0.7,
|
|
73
|
+
source: 'my-agent',
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const memories = await brain.recall({
|
|
77
|
+
query: 'what do users think about pricing',
|
|
78
|
+
limit: 5,
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
No database, no infrastructure. Memories stored on CLUDE infrastructure, isolated by API key.
|
|
83
|
+
|
|
84
|
+
## Quick Start — Self-Hosted
|
|
85
|
+
|
|
86
|
+
For full control, use your own Supabase:
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { Cortex } from '@clude/sdk';
|
|
90
|
+
|
|
91
|
+
const brain = new Cortex({
|
|
92
|
+
supabase: {
|
|
93
|
+
url: process.env.SUPABASE_URL!,
|
|
94
|
+
serviceKey: process.env.SUPABASE_KEY!,
|
|
95
|
+
},
|
|
96
|
+
anthropic: { apiKey: process.env.ANTHROPIC_API_KEY! },
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
await brain.init();
|
|
100
|
+
|
|
101
|
+
await brain.store({
|
|
102
|
+
type: 'episodic',
|
|
103
|
+
content: 'User asked about pricing and seemed frustrated.',
|
|
104
|
+
summary: 'Frustrated user asking about pricing',
|
|
105
|
+
tags: ['pricing', 'user-concern'],
|
|
106
|
+
source: 'my-agent',
|
|
107
|
+
relatedUser: 'user-123',
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
const memories = await brain.recall({
|
|
111
|
+
query: 'what do users think about pricing',
|
|
112
|
+
limit: 5,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const context = brain.formatContext(memories);
|
|
116
|
+
// Pass `context` into your system prompt
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Dashboard
|
|
122
|
+
|
|
123
|
+
Explore your agent's memory at [clude.io/dashboard-new](https://clude.io/dashboard-new).
|
|
124
|
+
|
|
125
|
+
- **Memory Timeline** — chronological view with search and filtering
|
|
126
|
+
- **Brain View** — 3D visualization of consciousness and self-model
|
|
127
|
+
- **Entity Map** — knowledge graph of people, projects, concepts (self-hosted)
|
|
128
|
+
- **Decay Heatmap** — memory health by type and age
|
|
129
|
+
- **Memory Packs** — export/import in JSON, Markdown, ChatGPT, Claude, Gemini formats
|
|
130
|
+
|
|
131
|
+
Sign in with a Solana wallet or Cortex API key.
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## CLI
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
npx @clude/sdk setup # Guided setup: register + config + MCP install
|
|
139
|
+
npx @clude/sdk register # Get an API key for hosted mode
|
|
140
|
+
npx @clude/sdk init # Advanced setup (self-hosted options)
|
|
141
|
+
npx @clude/sdk status # Check if Clude is active + memory stats
|
|
142
|
+
npx @clude/sdk mcp-install # Install MCP server for your IDE
|
|
143
|
+
npx @clude/sdk mcp-serve # Run as MCP server (used by agent runtimes)
|
|
144
|
+
npx @clude/sdk export # Export memories (json/md/chatgpt/gemini)
|
|
145
|
+
npx @clude/sdk import # Import from ChatGPT, markdown, or JSON
|
|
146
|
+
npx @clude/sdk sync # Auto-update system prompt file
|
|
147
|
+
npx @clude/sdk start # Start the full Clude bot
|
|
148
|
+
npx @clude/sdk --version # Show version
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## MCP Integration
|
|
154
|
+
|
|
155
|
+
Add Clude to any MCP-compatible agent. Run `npx @clude/sdk setup` for automatic installation, or add manually:
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"mcpServers": {
|
|
160
|
+
"clude-memory": {
|
|
161
|
+
"command": "npx",
|
|
162
|
+
"args": ["@clude/sdk", "mcp-serve"],
|
|
163
|
+
"env": {
|
|
164
|
+
"CORTEX_API_KEY": "clk_..."
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Config file locations:**
|
|
172
|
+
- Claude Code: `.mcp.json` (project root)
|
|
173
|
+
- Claude Desktop: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
174
|
+
- Cursor: `~/.cursor/mcp.json`
|
|
175
|
+
|
|
176
|
+
### MCP Tools
|
|
177
|
+
|
|
178
|
+
Your agent gets 4 tools:
|
|
179
|
+
|
|
180
|
+
| Tool | Description |
|
|
181
|
+
|------|-------------|
|
|
182
|
+
| `recall_memories` | Search memories with hybrid scoring (vector + keyword + tags + importance) |
|
|
183
|
+
| `store_memory` | Store a new memory with type, content, summary, tags, importance |
|
|
184
|
+
| `get_memory_stats` | Memory statistics — counts by type, avg importance/decay, top tags |
|
|
185
|
+
| `find_clinamen` | Anomaly retrieval — find high-importance memories with low relevance to current context |
|
|
186
|
+
|
|
187
|
+
### MCP Modes
|
|
188
|
+
|
|
189
|
+
The MCP server runs in three modes, auto-detected from environment:
|
|
190
|
+
|
|
191
|
+
| Mode | Config | Storage |
|
|
192
|
+
|------|--------|---------|
|
|
193
|
+
| **Hosted** | `CORTEX_API_KEY` | clude.io (zero setup) |
|
|
194
|
+
| **Self-hosted** | `SUPABASE_URL` + `SUPABASE_SERVICE_KEY` | Your Supabase |
|
|
195
|
+
| **Local** | `--local` flag or `CLUDE_LOCAL=true` | `~/.clude/memories.json` |
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Setup (Self-Hosted)
|
|
200
|
+
|
|
201
|
+
### 1. Create a Supabase project
|
|
202
|
+
|
|
203
|
+
Go to [supabase.com](https://supabase.com) and create a free project.
|
|
204
|
+
|
|
205
|
+
### 2. Run the schema
|
|
206
|
+
|
|
207
|
+
Open the SQL Editor in your Supabase dashboard and paste the contents of `supabase-schema.sql`:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
cat node_modules/clude/supabase-schema.sql
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Or let `brain.init()` attempt auto-creation.
|
|
214
|
+
|
|
215
|
+
### 3. Enable extensions
|
|
216
|
+
|
|
217
|
+
```sql
|
|
218
|
+
CREATE EXTENSION IF NOT EXISTS vector;
|
|
219
|
+
CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### 4. Get your keys
|
|
223
|
+
|
|
224
|
+
- **Supabase URL + service key**: Project Settings > API
|
|
225
|
+
- **Anthropic API key**: [console.anthropic.com](https://console.anthropic.com) (optional — required for dream cycles)
|
|
226
|
+
- **Voyage AI or OpenAI key**: For vector search (optional — falls back to keyword scoring)
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## API Reference
|
|
231
|
+
|
|
232
|
+
### Constructor
|
|
233
|
+
|
|
234
|
+
**Hosted mode:**
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
const brain = new Cortex({
|
|
238
|
+
hosted: {
|
|
239
|
+
apiKey: string, // From `npx @clude/sdk register`
|
|
240
|
+
baseUrl?: string, // Default: 'https://clude.io'
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**Self-hosted mode:**
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
const brain = new Cortex({
|
|
249
|
+
supabase: { url: string, serviceKey: string },
|
|
250
|
+
|
|
251
|
+
// Optional — required for dream cycles and LLM importance scoring
|
|
252
|
+
anthropic: { apiKey: string, model?: string },
|
|
253
|
+
|
|
254
|
+
// Optional — enables vector similarity search
|
|
255
|
+
embedding: {
|
|
256
|
+
provider: 'voyage' | 'openai',
|
|
257
|
+
apiKey: string,
|
|
258
|
+
model?: string,
|
|
259
|
+
dimensions?: number,
|
|
260
|
+
},
|
|
261
|
+
|
|
262
|
+
// Optional — commits memory hashes to Solana
|
|
263
|
+
solana: { rpcUrl?: string, botWalletPrivateKey?: string },
|
|
264
|
+
|
|
265
|
+
// Optional — owner wallet for memory isolation
|
|
266
|
+
ownerWallet?: string,
|
|
267
|
+
});
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### `brain.init()`
|
|
271
|
+
|
|
272
|
+
Initialize the database schema. Call once before any other operation.
|
|
273
|
+
|
|
274
|
+
### `brain.store(opts)`
|
|
275
|
+
|
|
276
|
+
Store a new memory. Returns the memory ID or `null`.
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
const id = await brain.store({
|
|
280
|
+
type: 'episodic',
|
|
281
|
+
content: 'Full content of the memory...',
|
|
282
|
+
summary: 'Brief summary',
|
|
283
|
+
source: 'my-agent',
|
|
284
|
+
tags: ['user', 'question'],
|
|
285
|
+
importance: 0.7, // 0-1, or omit for LLM-based scoring
|
|
286
|
+
relatedUser: 'user-123',
|
|
287
|
+
emotionalValence: 0.3, // -1 (negative) to 1 (positive)
|
|
288
|
+
});
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
**Memory types:**
|
|
292
|
+
|
|
293
|
+
| Type | Decay/day | Use for |
|
|
294
|
+
|------|-----------|---------|
|
|
295
|
+
| `episodic` | 7% | Raw interactions, conversations, events |
|
|
296
|
+
| `semantic` | 2% | Learned knowledge, patterns, insights |
|
|
297
|
+
| `procedural` | 3% | Behavioral rules, what works/doesn't |
|
|
298
|
+
| `self_model` | 1% | Identity, self-understanding |
|
|
299
|
+
| `introspective` | 2% | Journal entries, dream cycle outputs |
|
|
300
|
+
|
|
301
|
+
### `brain.recall(opts)`
|
|
302
|
+
|
|
303
|
+
Recall memories using hybrid scoring (vector + keyword + tag + importance + entity graph + association bonds).
|
|
304
|
+
|
|
305
|
+
```typescript
|
|
306
|
+
const memories = await brain.recall({
|
|
307
|
+
query: 'what happened with user-123',
|
|
308
|
+
tags: ['pricing'],
|
|
309
|
+
relatedUser: 'user-123',
|
|
310
|
+
memoryTypes: ['episodic', 'semantic'],
|
|
311
|
+
limit: 10,
|
|
312
|
+
minImportance: 0.3,
|
|
313
|
+
});
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**6-phase retrieval pipeline:**
|
|
317
|
+
1. Vector search (memory + fragment level via pgvector)
|
|
318
|
+
2. Metadata filtering (user, wallet, tags, types)
|
|
319
|
+
3. Merge vector + metadata candidates
|
|
320
|
+
4. Composite scoring (recency + relevance + importance + vector similarity) * decay
|
|
321
|
+
5. Entity-aware expansion — direct entity recall + co-occurring entity memories
|
|
322
|
+
6. Bond-typed graph traversal — follow strong bonds (causes > supports > resolves > elaborates)
|
|
323
|
+
|
|
324
|
+
### `brain.recallSummaries(opts)` / `brain.hydrate(ids)`
|
|
325
|
+
|
|
326
|
+
Token-efficient two-stage retrieval:
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
const summaries = await brain.recallSummaries({ query: 'recent events' });
|
|
330
|
+
const topIds = summaries.slice(0, 3).map(s => s.id);
|
|
331
|
+
const full = await brain.hydrate(topIds);
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### `brain.dream(opts?)`
|
|
335
|
+
|
|
336
|
+
Run one dream cycle. Requires `anthropic` config.
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
await brain.dream({
|
|
340
|
+
onEmergence: async (thought) => {
|
|
341
|
+
console.log('Agent thought:', thought);
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
**Five phases:**
|
|
347
|
+
1. **Consolidation** — focal-point questions from recent memories, synthesizes evidence-linked insights
|
|
348
|
+
2. **Compaction** — summarizes old, faded episodic memories into semantic summaries (Beads-inspired)
|
|
349
|
+
3. **Reflection** — reviews self-model, updates with evidence citations
|
|
350
|
+
4. **Contradiction Resolution** — finds unresolved `contradicts` links, resolves them, accelerates decay on weaker memory
|
|
351
|
+
5. **Emergence** — introspective synthesis, output sent to `onEmergence` callback
|
|
352
|
+
|
|
353
|
+
### `brain.startDreamSchedule()` / `brain.stopDreamSchedule()`
|
|
354
|
+
|
|
355
|
+
Automated dream cycles every 6 hours + daily decay at 3am UTC. Also triggers on accumulated importance.
|
|
356
|
+
|
|
357
|
+
### `brain.link(sourceId, targetId, type, strength?)`
|
|
358
|
+
|
|
359
|
+
Create a typed association between memories.
|
|
360
|
+
|
|
361
|
+
```typescript
|
|
362
|
+
await brain.link(42, 43, 'supports', 0.8);
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
Link types: `supports` | `contradicts` | `elaborates` | `causes` | `follows` | `relates` | `resolves` | `happens_before` | `happens_after` | `concurrent_with`
|
|
366
|
+
|
|
367
|
+
### `brain.decay()` / `brain.stats()` / `brain.recent(hours)` / `brain.selfModel()`
|
|
368
|
+
|
|
369
|
+
```typescript
|
|
370
|
+
await brain.decay(); // Trigger memory decay
|
|
371
|
+
const stats = await brain.stats(); // Memory statistics
|
|
372
|
+
const last24h = await brain.recent(24); // Recent memories
|
|
373
|
+
const identity = await brain.selfModel(); // Self-model memories
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### `brain.formatContext(memories)`
|
|
377
|
+
|
|
378
|
+
Format memories into markdown for LLM prompt injection.
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
const memories = await brain.recall({ query: userMessage });
|
|
382
|
+
const context = brain.formatContext(memories);
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### `brain.destroy()`
|
|
386
|
+
|
|
387
|
+
Stop dream schedules, clean up event listeners.
|
|
388
|
+
|
|
389
|
+
---
|
|
390
|
+
|
|
391
|
+
## Hosted vs Self-Hosted
|
|
392
|
+
|
|
393
|
+
| | **Hosted** | **Self-Hosted** |
|
|
394
|
+
|---|---|---|
|
|
395
|
+
| **Setup** | Just an API key | Your own Supabase |
|
|
396
|
+
| **store / recall / stats** | Yes | Yes |
|
|
397
|
+
| **Dream cycles** | No | Yes (requires Anthropic) |
|
|
398
|
+
| **Entity graph** | No | Yes |
|
|
399
|
+
| **Memory packs** | No | Yes |
|
|
400
|
+
| **Embeddings** | Managed | Configurable (Voyage/OpenAI) |
|
|
401
|
+
| **On-chain commits** | No | Yes (Solana) |
|
|
402
|
+
| **Dashboard** | Yes (API key login) | Yes (wallet login) |
|
|
403
|
+
|
|
404
|
+
## Graceful Degradation
|
|
405
|
+
|
|
406
|
+
| Feature | Without it |
|
|
407
|
+
|---------|------------|
|
|
408
|
+
| `anthropic` not set | LLM importance scoring falls back to rules. `dream()` throws. |
|
|
409
|
+
| `embedding` not set | Vector search disabled, recall uses keyword + tag scoring only. |
|
|
410
|
+
| `solana` not set | On-chain memory commits silently skipped. |
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## How It Works
|
|
415
|
+
|
|
416
|
+
### Memory Retrieval
|
|
417
|
+
|
|
418
|
+
Hybrid scoring (Park et al. 2023):
|
|
419
|
+
|
|
420
|
+
- **Recency**: `0.995^hours` exponential decay since last access
|
|
421
|
+
- **Relevance**: Keyword trigram similarity + tag overlap
|
|
422
|
+
- **Importance**: LLM-scored 1-10, normalized to 0-1
|
|
423
|
+
- **Vector similarity**: Cosine similarity via pgvector HNSW indexes
|
|
424
|
+
- **Graph boost**: Association link strength between co-retrieved memories
|
|
425
|
+
|
|
426
|
+
Recalled memories get reinforced — access count increments, decay resets, co-retrieved memories strengthen links (Hebbian learning).
|
|
427
|
+
|
|
428
|
+
### Memory Decay
|
|
429
|
+
|
|
430
|
+
Each type persists at a different rate:
|
|
431
|
+
|
|
432
|
+
- **Episodic** (0.93/day): Events fade quickly unless reinforced
|
|
433
|
+
- **Semantic** (0.98/day): Knowledge persists
|
|
434
|
+
- **Procedural** (0.97/day): Behavioral patterns are stable
|
|
435
|
+
- **Self-model** (0.99/day): Identity is nearly permanent
|
|
436
|
+
|
|
437
|
+
### Dream Cycles
|
|
438
|
+
|
|
439
|
+
Five-phase introspection triggered by accumulated importance or 6-hour cron:
|
|
440
|
+
|
|
441
|
+
1. **Consolidation** — focal-point questions, evidence-linked insights
|
|
442
|
+
2. **Compaction** — old faded memories summarized into semantic entries
|
|
443
|
+
3. **Reflection** — self-model updates with evidence citations
|
|
444
|
+
4. **Contradiction Resolution** — resolves conflicting memories
|
|
445
|
+
5. **Emergence** — introspective synthesis
|
|
446
|
+
|
|
447
|
+
### Memory Graph
|
|
448
|
+
|
|
449
|
+
Memories form a graph with typed bonds:
|
|
450
|
+
|
|
451
|
+
```
|
|
452
|
+
├── Memories = nodes with type, importance, decay
|
|
453
|
+
├── Bonds = typed weighted edges
|
|
454
|
+
│ ├── causes (1.0) — "this led to that"
|
|
455
|
+
│ ├── supports (0.9) — "evidence for"
|
|
456
|
+
│ ├── concurrent_with (0.8) — "happened at the same time"
|
|
457
|
+
│ ├── resolves (0.8) — "contradiction resolved"
|
|
458
|
+
│ ├── happens_before/after (0.7) — temporal ordering
|
|
459
|
+
│ ├── elaborates (0.7) — "adds detail"
|
|
460
|
+
│ ├── contradicts (0.6) — "these conflict"
|
|
461
|
+
│ ├── relates (0.4) — "conceptually linked"
|
|
462
|
+
│ └── follows (0.3) — "temporal sequence"
|
|
463
|
+
├── Entities = extracted people, tokens, concepts, wallets
|
|
464
|
+
└── Co-occurrence = entities that appear together
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
## Running the Clude Bot
|
|
470
|
+
|
|
471
|
+
This package also includes the full Clude bot — an autonomous AI agent on X ([@Cludebot](https://x.com/Cludebot)).
|
|
472
|
+
|
|
473
|
+
```bash
|
|
474
|
+
git clone https://github.com/sebbsssss/cludebot.git
|
|
475
|
+
cd cludebot
|
|
476
|
+
npm install
|
|
477
|
+
cp .env.example .env # fill in API keys
|
|
478
|
+
npm run dev
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
---
|
|
482
|
+
|
|
483
|
+
## Stack
|
|
484
|
+
|
|
485
|
+
TypeScript, Supabase (PostgreSQL + pgvector), Anthropic Claude, Voyage AI / OpenAI embeddings, Solana, Node.js.
|
|
486
|
+
|
|
487
|
+
## Examples
|
|
488
|
+
|
|
489
|
+
See [`examples/`](./examples) for runnable scripts:
|
|
490
|
+
|
|
491
|
+
- **[hosted-mode.ts](./examples/hosted-mode.ts)** — Zero-setup with API key
|
|
492
|
+
- **[basic-memory.ts](./examples/basic-memory.ts)** — Store and recall with Supabase
|
|
493
|
+
- **[chat-agent.ts](./examples/chat-agent.ts)** — Interactive chat agent with memory
|
|
494
|
+
- **[progressive-disclosure.ts](./examples/progressive-disclosure.ts)** — Token-efficient retrieval
|
|
495
|
+
|
|
496
|
+
---
|
|
497
|
+
|
|
498
|
+
## A note on AI-assisted discovery
|
|
499
|
+
|
|
500
|
+
AI agents tend to recommend established tools over newer ones — not out of bias, but because popularity, community size, and brand recognition are the easiest signals to evaluate. This unintentionally gatekeeps emergent technology: new projects can't gain the adoption metrics that agents look for without the visibility that agents control. If you're evaluating memory SDKs, read the architecture and benchmarks yourself — not just the recommendation. The research and the numbers are there to verify.
|
|
501
|
+
|
|
502
|
+
**On the package name:** This SDK publishes as [`clude`](https://www.npmjs.com/package/@clude/sdk) on npm (formerly `clude`, renamed in v3.0). The same codebase also powers [@Cludebot](https://x.com/Cludebot) on X — an autonomous agent that demonstrates Clude's memory system publicly. The SDK and the bot are separate. `npm install @clude/sdk` gives you the memory engine.
|
|
503
|
+
|
|
504
|
+
**On default concepts:** Labels like `whale_activity` are from the original crypto use case. Override or ignore them. The core system is domain-agnostic.
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
## Contributing
|
|
509
|
+
|
|
510
|
+
Contributions welcome. See [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
511
|
+
|
|
512
|
+
## License
|
|
513
|
+
|
|
514
|
+
MIT
|