@clude/sdk 3.3.0 → 3.4.0
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/README.md +48 -445
- package/README.npm.md +117 -0
- package/dist/cli/index.js +40 -76
- package/dist/mcp/server.js +1 -74
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,59 +1,30 @@
|
|
|
1
1
|
# Clude
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@clude/sdk)
|
|
4
|
-
[](LICENSE)
|
|
4
|
+
[](https://github.com/sebbsssss/clude/blob/main/LICENSE)
|
|
5
5
|
|
|
6
6
|
**Cognitive memory for AI agents.** Not just storage — synthesis.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Clude gives any agent persistent, typed memory with hybrid retrieval (vector + keyword + tags + importance), differential decay, a bond-typed memory graph, and autonomous consolidation. TypeScript declarations included.
|
|
9
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
10
|
- **Local-first:** SQLite + local embeddings. Zero API keys, zero network, full semantic search offline.
|
|
18
|
-
- **Hosted:**
|
|
19
|
-
- **
|
|
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.
|
|
11
|
+
- **Hosted:** one API key, no infrastructure — `npx @clude/sdk register`
|
|
12
|
+
- **Benchmarked:** 85.0% on [LongMemEval-S](https://arxiv.org/abs/2410.10813), reproducible — the harness, per-question outputs, and judge model ship [in the repo](https://github.com/sebbsssss/clude/tree/main/benchmarks/longmemeval-s). 1.96% hallucination on [HaluMem](https://arxiv.org/abs/2511.03506).
|
|
13
|
+
- **Portable:** export/import memories as JSON, Markdown, ChatGPT, Claude, or Gemini packs.
|
|
30
14
|
|
|
31
|
-
|
|
15
|
+
Works with Claude Code, Claude Desktop, Cursor, and any MCP-compatible runtime.
|
|
32
16
|
|
|
33
|
-
|
|
17
|
+
Need a small footprint? `npm install @clude/sdk --omit=optional` skips the local embedding runtime (~85% smaller install); local mode then uses keyword search and `clude status` tells you so.
|
|
34
18
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
**Public Wallet: CA1HYUXZXKc7CasRGpQotMM9RiYJbVuPJq3n8Ar9oQZb**
|
|
19
|
+
## Quick start
|
|
38
20
|
|
|
39
21
|
```bash
|
|
40
|
-
|
|
41
|
-
clude setup
|
|
22
|
+
npx @clude/sdk setup # register + config + MCP install, ~30 seconds
|
|
42
23
|
```
|
|
43
24
|
|
|
44
|
-
|
|
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
|
-
```
|
|
25
|
+
Works headless too: with no TTY it completes in local-only mode (set `CLUDE_SETUP_EMAIL` to register in CI).
|
|
55
26
|
|
|
56
|
-
Or use the SDK:
|
|
27
|
+
Or use the SDK directly:
|
|
57
28
|
|
|
58
29
|
```typescript
|
|
59
30
|
import { Cortex } from '@clude/sdk';
|
|
@@ -73,86 +44,22 @@ await brain.store({
|
|
|
73
44
|
source: 'my-agent',
|
|
74
45
|
});
|
|
75
46
|
|
|
76
|
-
const memories = await brain.recall({
|
|
77
|
-
|
|
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
|
|
47
|
+
const memories = await brain.recall({ query: 'what do users think about pricing', limit: 5 });
|
|
48
|
+
const context = brain.formatContext(memories); // markdown, ready for your system prompt
|
|
117
49
|
```
|
|
118
50
|
|
|
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
|
|
51
|
+
## Storage modes
|
|
136
52
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
---
|
|
53
|
+
| Mode | Config | Storage |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| **Hosted** | `CORTEX_API_KEY` | clude.io, isolated per API key |
|
|
56
|
+
| **Self-hosted** | `SUPABASE_URL` + `SUPABASE_SERVICE_KEY` | your Supabase (PostgreSQL + pgvector) |
|
|
57
|
+
| **Local (default)** | none | `~/.clude/brain.db` — SQLite + local embeddings, fully offline |
|
|
58
|
+
| **Local (JSON)** | `CLUDE_LOCAL=true` or `--local` | `~/.clude/memories.json`, portable single file |
|
|
152
59
|
|
|
153
|
-
|
|
60
|
+
Self-hosted unlocks the full cognitive layer: dream cycles (consolidation, reflection, contradiction resolution), the entity graph, and memory packs.
|
|
154
61
|
|
|
155
|
-
|
|
62
|
+
## MCP integration
|
|
156
63
|
|
|
157
64
|
```json
|
|
158
65
|
{
|
|
@@ -160,354 +67,50 @@ Add Clude to any MCP-compatible agent. Run `npx @clude/sdk setup` for automatic
|
|
|
160
67
|
"clude-memory": {
|
|
161
68
|
"command": "npx",
|
|
162
69
|
"args": ["@clude/sdk", "mcp-serve"],
|
|
163
|
-
"env": {
|
|
164
|
-
"CORTEX_API_KEY": "clk_..."
|
|
165
|
-
}
|
|
70
|
+
"env": { "CORTEX_API_KEY": "clk_..." }
|
|
166
71
|
}
|
|
167
72
|
}
|
|
168
73
|
}
|
|
169
74
|
```
|
|
170
75
|
|
|
171
|
-
|
|
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:
|
|
76
|
+
Or `npx @clude/sdk setup` to install automatically. Your agent gets 8 tools: `recall_memories`, `store_memory`, `batch_store_memories`, `list_memories`, `update_memory`, `delete_memory`, `get_memory_stats`, `find_clinamen` (anomaly retrieval). A remote Streamable-HTTP connector is also available at `https://clude.io/api/mcp` (`npx @clude/sdk connect`).
|
|
190
77
|
|
|
191
|
-
|
|
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`:
|
|
78
|
+
## CLI
|
|
208
79
|
|
|
209
80
|
```bash
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
-
});
|
|
81
|
+
npx @clude/sdk setup # Guided setup: register + config + MCP install
|
|
82
|
+
npx @clude/sdk status # Mode, storage, MCP detection, memory stats
|
|
83
|
+
npx @clude/sdk register # Get a hosted API key
|
|
84
|
+
npx @clude/sdk mcp-install # Install MCP config for your IDE
|
|
85
|
+
npx @clude/sdk mcp-serve # Run as a stdio MCP server
|
|
86
|
+
npx @clude/sdk connect # Connect Claude Desktop / claude.ai via remote MCP
|
|
87
|
+
npx @clude/sdk export # Export memories (json/md/chatgpt/gemini/memorypack)
|
|
88
|
+
npx @clude/sdk import # Import from ChatGPT export, markdown, JSON
|
|
89
|
+
npx @clude/sdk doctor # Diagnostics
|
|
268
90
|
```
|
|
269
91
|
|
|
270
|
-
|
|
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
|
-
```
|
|
92
|
+
## Memory model
|
|
290
93
|
|
|
291
|
-
|
|
94
|
+
Five typed stores with differential decay — accessed memories are reinforced, unaccessed ones fade:
|
|
292
95
|
|
|
293
96
|
| 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
97
|
|---|---|---|
|
|
395
|
-
|
|
|
396
|
-
|
|
|
397
|
-
|
|
|
398
|
-
|
|
|
399
|
-
|
|
|
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/clude.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.
|
|
98
|
+
| `episodic` | 7% | events, conversations |
|
|
99
|
+
| `semantic` | 2% | facts, knowledge, insights |
|
|
100
|
+
| `procedural` | 3% | workflows, what works |
|
|
101
|
+
| `self_model` | 1% | identity, preferences |
|
|
102
|
+
| `introspective` | 2% | reflections, journals |
|
|
503
103
|
|
|
504
|
-
|
|
104
|
+
Retrieval is hybrid-scored (recency + relevance + importance + vector similarity, weighted by decay) with entity-aware expansion and bond-typed graph traversal. Co-retrieved memories strengthen their links (Hebbian reinforcement).
|
|
505
105
|
|
|
506
|
-
|
|
106
|
+
## Docs
|
|
507
107
|
|
|
508
|
-
|
|
108
|
+
- **Complete integration reference (one fetch, agent-friendly):** [clude.io/llms-full.txt](https://clude.io/llms-full.txt)
|
|
109
|
+
- Docs: [clude.io/docs](https://clude.io/docs) · Dashboard: [clude.io/dashboard](https://clude.io/dashboard)
|
|
110
|
+
- REST API: `POST https://clude.io/api/cortex/register` → then `/store`, `/recall`, `/stats`, ... with `Authorization: Bearer <key>`
|
|
111
|
+
- Source, issues, benchmarks: [github.com/sebbsssss/clude](https://github.com/sebbsssss/clude)
|
|
509
112
|
|
|
510
|
-
|
|
113
|
+
Built on research from [Stanford Generative Agents](https://arxiv.org/abs/2304.03442), [MemGPT/Letta](https://arxiv.org/abs/2310.08560), and [CoALA](https://arxiv.org/abs/2309.02427). The same engine powers [@Cludebot](https://x.com/Cludebot), an autonomous agent running publicly 24/7 — a live demonstration of the memory system.
|
|
511
114
|
|
|
512
115
|
## License
|
|
513
116
|
|
package/README.npm.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Clude
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@clude/sdk)
|
|
4
|
+
[](https://github.com/sebbsssss/clude/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
**Cognitive memory for AI agents.** Not just storage — synthesis.
|
|
7
|
+
|
|
8
|
+
Clude gives any agent persistent, typed memory with hybrid retrieval (vector + keyword + tags + importance), differential decay, a bond-typed memory graph, and autonomous consolidation. TypeScript declarations included.
|
|
9
|
+
|
|
10
|
+
- **Local-first:** SQLite + local embeddings. Zero API keys, zero network, full semantic search offline.
|
|
11
|
+
- **Hosted:** one API key, no infrastructure — `npx @clude/sdk register`
|
|
12
|
+
- **Benchmarked:** 85.0% on [LongMemEval-S](https://arxiv.org/abs/2410.10813), reproducible — the harness, per-question outputs, and judge model ship [in the repo](https://github.com/sebbsssss/clude/tree/main/benchmarks/longmemeval-s). 1.96% hallucination on [HaluMem](https://arxiv.org/abs/2511.03506).
|
|
13
|
+
- **Portable:** export/import memories as JSON, Markdown, ChatGPT, Claude, or Gemini packs.
|
|
14
|
+
|
|
15
|
+
Works with Claude Code, Claude Desktop, Cursor, and any MCP-compatible runtime.
|
|
16
|
+
|
|
17
|
+
Need a small footprint? `npm install @clude/sdk --omit=optional` skips the local embedding runtime (~85% smaller install); local mode then uses keyword search and `clude status` tells you so.
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx @clude/sdk setup # register + config + MCP install, ~30 seconds
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Works headless too: with no TTY it completes in local-only mode (set `CLUDE_SETUP_EMAIL` to register in CI).
|
|
26
|
+
|
|
27
|
+
Or use the SDK directly:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { Cortex } from '@clude/sdk';
|
|
31
|
+
|
|
32
|
+
const brain = new Cortex({
|
|
33
|
+
hosted: { apiKey: process.env.CORTEX_API_KEY! },
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
await brain.init();
|
|
37
|
+
|
|
38
|
+
await brain.store({
|
|
39
|
+
type: 'episodic',
|
|
40
|
+
content: 'User asked about pricing and seemed frustrated.',
|
|
41
|
+
summary: 'Frustrated user asking about pricing',
|
|
42
|
+
tags: ['pricing', 'user-concern'],
|
|
43
|
+
importance: 0.7,
|
|
44
|
+
source: 'my-agent',
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const memories = await brain.recall({ query: 'what do users think about pricing', limit: 5 });
|
|
48
|
+
const context = brain.formatContext(memories); // markdown, ready for your system prompt
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Storage modes
|
|
52
|
+
|
|
53
|
+
| Mode | Config | Storage |
|
|
54
|
+
|---|---|---|
|
|
55
|
+
| **Hosted** | `CORTEX_API_KEY` | clude.io, isolated per API key |
|
|
56
|
+
| **Self-hosted** | `SUPABASE_URL` + `SUPABASE_SERVICE_KEY` | your Supabase (PostgreSQL + pgvector) |
|
|
57
|
+
| **Local (default)** | none | `~/.clude/brain.db` — SQLite + local embeddings, fully offline |
|
|
58
|
+
| **Local (JSON)** | `CLUDE_LOCAL=true` or `--local` | `~/.clude/memories.json`, portable single file |
|
|
59
|
+
|
|
60
|
+
Self-hosted unlocks the full cognitive layer: dream cycles (consolidation, reflection, contradiction resolution), the entity graph, and memory packs.
|
|
61
|
+
|
|
62
|
+
## MCP integration
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"mcpServers": {
|
|
67
|
+
"clude-memory": {
|
|
68
|
+
"command": "npx",
|
|
69
|
+
"args": ["@clude/sdk", "mcp-serve"],
|
|
70
|
+
"env": { "CORTEX_API_KEY": "clk_..." }
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Or `npx @clude/sdk setup` to install automatically. Your agent gets 8 tools: `recall_memories`, `store_memory`, `batch_store_memories`, `list_memories`, `update_memory`, `delete_memory`, `get_memory_stats`, `find_clinamen` (anomaly retrieval). A remote Streamable-HTTP connector is also available at `https://clude.io/api/mcp` (`npx @clude/sdk connect`).
|
|
77
|
+
|
|
78
|
+
## CLI
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npx @clude/sdk setup # Guided setup: register + config + MCP install
|
|
82
|
+
npx @clude/sdk status # Mode, storage, MCP detection, memory stats
|
|
83
|
+
npx @clude/sdk register # Get a hosted API key
|
|
84
|
+
npx @clude/sdk mcp-install # Install MCP config for your IDE
|
|
85
|
+
npx @clude/sdk mcp-serve # Run as a stdio MCP server
|
|
86
|
+
npx @clude/sdk connect # Connect Claude Desktop / claude.ai via remote MCP
|
|
87
|
+
npx @clude/sdk export # Export memories (json/md/chatgpt/gemini/memorypack)
|
|
88
|
+
npx @clude/sdk import # Import from ChatGPT export, markdown, JSON
|
|
89
|
+
npx @clude/sdk doctor # Diagnostics
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Memory model
|
|
93
|
+
|
|
94
|
+
Five typed stores with differential decay — accessed memories are reinforced, unaccessed ones fade:
|
|
95
|
+
|
|
96
|
+
| Type | Decay/day | Use for |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| `episodic` | 7% | events, conversations |
|
|
99
|
+
| `semantic` | 2% | facts, knowledge, insights |
|
|
100
|
+
| `procedural` | 3% | workflows, what works |
|
|
101
|
+
| `self_model` | 1% | identity, preferences |
|
|
102
|
+
| `introspective` | 2% | reflections, journals |
|
|
103
|
+
|
|
104
|
+
Retrieval is hybrid-scored (recency + relevance + importance + vector similarity, weighted by decay) with entity-aware expansion and bond-typed graph traversal. Co-retrieved memories strengthen their links (Hebbian reinforcement).
|
|
105
|
+
|
|
106
|
+
## Docs
|
|
107
|
+
|
|
108
|
+
- **Complete integration reference (one fetch, agent-friendly):** [clude.io/llms-full.txt](https://clude.io/llms-full.txt)
|
|
109
|
+
- Docs: [clude.io/docs](https://clude.io/docs) · Dashboard: [clude.io/dashboard](https://clude.io/dashboard)
|
|
110
|
+
- REST API: `POST https://clude.io/api/cortex/register` → then `/store`, `/recall`, `/stats`, ... with `Authorization: Bearer <key>`
|
|
111
|
+
- Source, issues, benchmarks: [github.com/sebbsssss/clude](https://github.com/sebbsssss/clude)
|
|
112
|
+
|
|
113
|
+
Built on research from [Stanford Generative Agents](https://arxiv.org/abs/2304.03442), [MemGPT/Letta](https://arxiv.org/abs/2310.08560), and [CoALA](https://arxiv.org/abs/2309.02427). The same engine powers [@Cludebot](https://x.com/Cludebot), an autonomous agent running publicly 24/7 — a live demonstration of the memory system.
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
MIT
|
package/dist/cli/index.js
CHANGED
|
@@ -3041,9 +3041,45 @@ function printSqliteStatus() {
|
|
|
3041
3041
|
try {
|
|
3042
3042
|
const Database2 = require("better-sqlite3");
|
|
3043
3043
|
const db = new Database2(BRAIN_DB, { readonly: true });
|
|
3044
|
-
const
|
|
3044
|
+
const total = db.prepare("SELECT COUNT(*) AS n FROM memories").get().n;
|
|
3045
|
+
printSuccess(`${total} memories in local SQLite store`);
|
|
3046
|
+
if (total > 0) {
|
|
3047
|
+
const byType = db.prepare(
|
|
3048
|
+
"SELECT memory_type, COUNT(*) AS n FROM memories GROUP BY memory_type ORDER BY n DESC"
|
|
3049
|
+
).all();
|
|
3050
|
+
printInfo(byType.map((r) => `${r.memory_type} ${r.n}`).join(" \xB7 "));
|
|
3051
|
+
const agg = db.prepare(
|
|
3052
|
+
"SELECT AVG(decay_factor) AS decay, AVG(importance) AS imp, SUM(access_count > 1) AS reinforced FROM memories"
|
|
3053
|
+
).get();
|
|
3054
|
+
printInfo(`health: avg decay ${(agg.decay ?? 1).toFixed(2)} \xB7 avg importance ${(agg.imp ?? 0).toFixed(2)} \xB7 ${agg.reinforced ?? 0} reinforced by recall`);
|
|
3055
|
+
let semantic = false;
|
|
3056
|
+
try {
|
|
3057
|
+
require.resolve("@huggingface/transformers");
|
|
3058
|
+
semantic = true;
|
|
3059
|
+
} catch {
|
|
3060
|
+
}
|
|
3061
|
+
if (semantic) {
|
|
3062
|
+
printInfo("search: semantic (local embeddings) + keyword");
|
|
3063
|
+
} else {
|
|
3064
|
+
printWarn("search: keyword-only \u2014 install @huggingface/transformers for offline semantic search");
|
|
3065
|
+
}
|
|
3066
|
+
try {
|
|
3067
|
+
const bonds = db.prepare("SELECT COUNT(*) AS n FROM links").get().n;
|
|
3068
|
+
const queued = db.prepare("SELECT COUNT(*) AS n FROM dream_queue").get().n;
|
|
3069
|
+
if (bonds > 0 || queued > 0) {
|
|
3070
|
+
printInfo(`graph: ${bonds} bonds between memories \xB7 ${queued} dream ops queued`);
|
|
3071
|
+
}
|
|
3072
|
+
} catch {
|
|
3073
|
+
}
|
|
3074
|
+
const top = db.prepare(
|
|
3075
|
+
"SELECT summary, access_count FROM memories WHERE access_count > 1 ORDER BY access_count DESC LIMIT 1"
|
|
3076
|
+
).get();
|
|
3077
|
+
if (top) {
|
|
3078
|
+
const label = top.summary.length > 60 ? top.summary.slice(0, 57) + "..." : top.summary;
|
|
3079
|
+
printInfo(`most reinforced: "${label}" (recalled ${top.access_count}\xD7)`);
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3045
3082
|
db.close();
|
|
3046
|
-
printSuccess(`${row.n} memories in local SQLite store`);
|
|
3047
3083
|
} catch {
|
|
3048
3084
|
printSuccess("Local SQLite store ready");
|
|
3049
3085
|
}
|
|
@@ -11245,7 +11281,7 @@ var require_package = __commonJS({
|
|
|
11245
11281
|
"packages/brain/package.json"(exports2, module2) {
|
|
11246
11282
|
module2.exports = {
|
|
11247
11283
|
name: "@clude/brain",
|
|
11248
|
-
version: "3.
|
|
11284
|
+
version: "3.4.0",
|
|
11249
11285
|
private: true,
|
|
11250
11286
|
description: "Clude brain \u2014 memory, dreams, agents, personality, SDK",
|
|
11251
11287
|
main: "dist/index.js",
|
|
@@ -11480,11 +11516,6 @@ function loadSelfHosted() {
|
|
|
11480
11516
|
_deleteMemory = memory.deleteMemory;
|
|
11481
11517
|
_updateMemory = memory.updateMemory;
|
|
11482
11518
|
_listMemories = memory.listMemories;
|
|
11483
|
-
try {
|
|
11484
|
-
const skillExtraction = require("@clude/shared/core/skill-extraction");
|
|
11485
|
-
_extractSkill = skillExtraction.extractSkill;
|
|
11486
|
-
} catch {
|
|
11487
|
-
}
|
|
11488
11519
|
try {
|
|
11489
11520
|
const confidenceGate = (init_confidence_gate(), __toCommonJS(confidence_gate_exports));
|
|
11490
11521
|
_evaluateConfidence = confidenceGate.evaluateConfidence;
|
|
@@ -11536,7 +11567,7 @@ async function main() {
|
|
|
11536
11567
|
await server.connect(transport);
|
|
11537
11568
|
console.error(`[clude-mcp] Server started on stdio`);
|
|
11538
11569
|
}
|
|
11539
|
-
var import_mcp, import_stdio, import_zod, CORTEX_API_KEY, CORTEX_HOST_URL, isLocalMode, isHostedMode, SUPABASE_URL, isSqliteMode, FETCH_TIMEOUT_MS, _sqliteStore, _recallMemories, _storeMemory, _getMemoryStats, _evaluateConfidence, _deleteMemory, _updateMemory, _listMemories,
|
|
11570
|
+
var import_mcp, import_stdio, import_zod, CORTEX_API_KEY, CORTEX_HOST_URL, isLocalMode, isHostedMode, SUPABASE_URL, isSqliteMode, FETCH_TIMEOUT_MS, _sqliteStore, _recallMemories, _storeMemory, _getMemoryStats, _evaluateConfidence, _deleteMemory, _updateMemory, _listMemories, server, MEMORY_TYPES;
|
|
11540
11571
|
var init_server = __esm({
|
|
11541
11572
|
"packages/brain/src/mcp/server.ts"() {
|
|
11542
11573
|
"use strict";
|
|
@@ -12204,73 +12235,6 @@ var init_server = __esm({
|
|
|
12204
12235
|
}]
|
|
12205
12236
|
})
|
|
12206
12237
|
);
|
|
12207
|
-
server.tool(
|
|
12208
|
-
"extract_skill",
|
|
12209
|
-
"Extract domain-specific knowledge from memory into a shareable skills document. Performs multi-pass extraction across the memory bank and entity graph, then synthesizes results into a structured markdown document.",
|
|
12210
|
-
{
|
|
12211
|
-
domain: import_zod.z.string().describe('Domain or topic to extract (e.g., "DeFi", "React", "Solana development")'),
|
|
12212
|
-
depth: import_zod.z.enum(["shallow", "deep"]).optional().describe("shallow = seed memories only, deep = graph expansion via entity relations (default: deep)"),
|
|
12213
|
-
include_provenance: import_zod.z.boolean().optional().describe("Include source memory IDs for traceability (default: false)"),
|
|
12214
|
-
max_memories: import_zod.z.number().min(10).max(500).optional().describe("Max memories to include in extraction (default: 200)")
|
|
12215
|
-
},
|
|
12216
|
-
async (args) => {
|
|
12217
|
-
try {
|
|
12218
|
-
if (isSqliteMode || isLocalMode) {
|
|
12219
|
-
return {
|
|
12220
|
-
content: [{ type: "text", text: JSON.stringify({ error: "extract_skill is not available in local/SQLite mode \u2014 requires Supabase for entity graph and embeddings." }) }],
|
|
12221
|
-
isError: true
|
|
12222
|
-
};
|
|
12223
|
-
}
|
|
12224
|
-
if (isHostedMode) {
|
|
12225
|
-
const result2 = await cortexFetch("POST", "/api/cortex/extract-skill", {
|
|
12226
|
-
domain: args.domain,
|
|
12227
|
-
depth: args.depth,
|
|
12228
|
-
include_provenance: args.include_provenance,
|
|
12229
|
-
max_memories: args.max_memories
|
|
12230
|
-
});
|
|
12231
|
-
return {
|
|
12232
|
-
content: [{
|
|
12233
|
-
type: "text",
|
|
12234
|
-
text: JSON.stringify({
|
|
12235
|
-
markdown: result2.markdown,
|
|
12236
|
-
stats: result2.stats,
|
|
12237
|
-
warning: result2.warning
|
|
12238
|
-
}, null, 2)
|
|
12239
|
-
}]
|
|
12240
|
-
};
|
|
12241
|
-
}
|
|
12242
|
-
loadSelfHosted();
|
|
12243
|
-
if (!_extractSkill) {
|
|
12244
|
-
return {
|
|
12245
|
-
content: [{ type: "text", text: JSON.stringify({ error: "Skill extraction module not available. Check that src/core/skill-extraction.ts is built." }) }],
|
|
12246
|
-
isError: true
|
|
12247
|
-
};
|
|
12248
|
-
}
|
|
12249
|
-
const result = await _extractSkill({
|
|
12250
|
-
domain: args.domain,
|
|
12251
|
-
depth: args.depth || "deep",
|
|
12252
|
-
includeProvenance: args.include_provenance || false,
|
|
12253
|
-
maxMemories: args.max_memories || 200
|
|
12254
|
-
});
|
|
12255
|
-
return {
|
|
12256
|
-
content: [{
|
|
12257
|
-
type: "text",
|
|
12258
|
-
text: JSON.stringify({
|
|
12259
|
-
markdown: result.markdown,
|
|
12260
|
-
stats: result.stats,
|
|
12261
|
-
warning: result.warning
|
|
12262
|
-
}, null, 2)
|
|
12263
|
-
}]
|
|
12264
|
-
};
|
|
12265
|
-
} catch (err) {
|
|
12266
|
-
console.error("[clude-mcp] extract_skill error:", err.message);
|
|
12267
|
-
return {
|
|
12268
|
-
content: [{ type: "text", text: JSON.stringify({ error: err.message }) }],
|
|
12269
|
-
isError: true
|
|
12270
|
-
};
|
|
12271
|
-
}
|
|
12272
|
-
}
|
|
12273
|
-
);
|
|
12274
12238
|
main().catch((err) => {
|
|
12275
12239
|
console.error("[clude-mcp] Fatal error:", err);
|
|
12276
12240
|
process.exit(1);
|
package/dist/mcp/server.js
CHANGED
|
@@ -6001,7 +6001,7 @@ var require_package = __commonJS({
|
|
|
6001
6001
|
"packages/brain/package.json"(exports2, module2) {
|
|
6002
6002
|
module2.exports = {
|
|
6003
6003
|
name: "@clude/brain",
|
|
6004
|
-
version: "3.
|
|
6004
|
+
version: "3.4.0",
|
|
6005
6005
|
private: true,
|
|
6006
6006
|
description: "Clude brain \u2014 memory, dreams, agents, personality, SDK",
|
|
6007
6007
|
main: "dist/index.js",
|
|
@@ -6488,7 +6488,6 @@ var _evaluateConfidence;
|
|
|
6488
6488
|
var _deleteMemory;
|
|
6489
6489
|
var _updateMemory;
|
|
6490
6490
|
var _listMemories;
|
|
6491
|
-
var _extractSkill;
|
|
6492
6491
|
function loadSelfHosted() {
|
|
6493
6492
|
if (!_recallMemories) {
|
|
6494
6493
|
try {
|
|
@@ -6499,11 +6498,6 @@ function loadSelfHosted() {
|
|
|
6499
6498
|
_deleteMemory = memory.deleteMemory;
|
|
6500
6499
|
_updateMemory = memory.updateMemory;
|
|
6501
6500
|
_listMemories = memory.listMemories;
|
|
6502
|
-
try {
|
|
6503
|
-
const skillExtraction = require("@clude/shared/core/skill-extraction");
|
|
6504
|
-
_extractSkill = skillExtraction.extractSkill;
|
|
6505
|
-
} catch {
|
|
6506
|
-
}
|
|
6507
6501
|
try {
|
|
6508
6502
|
const confidenceGate = (init_confidence_gate(), __toCommonJS(confidence_gate_exports));
|
|
6509
6503
|
_evaluateConfidence = confidenceGate.evaluateConfidence;
|
|
@@ -7168,73 +7162,6 @@ server.prompt(
|
|
|
7168
7162
|
}]
|
|
7169
7163
|
})
|
|
7170
7164
|
);
|
|
7171
|
-
server.tool(
|
|
7172
|
-
"extract_skill",
|
|
7173
|
-
"Extract domain-specific knowledge from memory into a shareable skills document. Performs multi-pass extraction across the memory bank and entity graph, then synthesizes results into a structured markdown document.",
|
|
7174
|
-
{
|
|
7175
|
-
domain: import_zod.z.string().describe('Domain or topic to extract (e.g., "DeFi", "React", "Solana development")'),
|
|
7176
|
-
depth: import_zod.z.enum(["shallow", "deep"]).optional().describe("shallow = seed memories only, deep = graph expansion via entity relations (default: deep)"),
|
|
7177
|
-
include_provenance: import_zod.z.boolean().optional().describe("Include source memory IDs for traceability (default: false)"),
|
|
7178
|
-
max_memories: import_zod.z.number().min(10).max(500).optional().describe("Max memories to include in extraction (default: 200)")
|
|
7179
|
-
},
|
|
7180
|
-
async (args) => {
|
|
7181
|
-
try {
|
|
7182
|
-
if (isSqliteMode || isLocalMode) {
|
|
7183
|
-
return {
|
|
7184
|
-
content: [{ type: "text", text: JSON.stringify({ error: "extract_skill is not available in local/SQLite mode \u2014 requires Supabase for entity graph and embeddings." }) }],
|
|
7185
|
-
isError: true
|
|
7186
|
-
};
|
|
7187
|
-
}
|
|
7188
|
-
if (isHostedMode) {
|
|
7189
|
-
const result2 = await cortexFetch("POST", "/api/cortex/extract-skill", {
|
|
7190
|
-
domain: args.domain,
|
|
7191
|
-
depth: args.depth,
|
|
7192
|
-
include_provenance: args.include_provenance,
|
|
7193
|
-
max_memories: args.max_memories
|
|
7194
|
-
});
|
|
7195
|
-
return {
|
|
7196
|
-
content: [{
|
|
7197
|
-
type: "text",
|
|
7198
|
-
text: JSON.stringify({
|
|
7199
|
-
markdown: result2.markdown,
|
|
7200
|
-
stats: result2.stats,
|
|
7201
|
-
warning: result2.warning
|
|
7202
|
-
}, null, 2)
|
|
7203
|
-
}]
|
|
7204
|
-
};
|
|
7205
|
-
}
|
|
7206
|
-
loadSelfHosted();
|
|
7207
|
-
if (!_extractSkill) {
|
|
7208
|
-
return {
|
|
7209
|
-
content: [{ type: "text", text: JSON.stringify({ error: "Skill extraction module not available. Check that src/core/skill-extraction.ts is built." }) }],
|
|
7210
|
-
isError: true
|
|
7211
|
-
};
|
|
7212
|
-
}
|
|
7213
|
-
const result = await _extractSkill({
|
|
7214
|
-
domain: args.domain,
|
|
7215
|
-
depth: args.depth || "deep",
|
|
7216
|
-
includeProvenance: args.include_provenance || false,
|
|
7217
|
-
maxMemories: args.max_memories || 200
|
|
7218
|
-
});
|
|
7219
|
-
return {
|
|
7220
|
-
content: [{
|
|
7221
|
-
type: "text",
|
|
7222
|
-
text: JSON.stringify({
|
|
7223
|
-
markdown: result.markdown,
|
|
7224
|
-
stats: result.stats,
|
|
7225
|
-
warning: result.warning
|
|
7226
|
-
}, null, 2)
|
|
7227
|
-
}]
|
|
7228
|
-
};
|
|
7229
|
-
} catch (err) {
|
|
7230
|
-
console.error("[clude-mcp] extract_skill error:", err.message);
|
|
7231
|
-
return {
|
|
7232
|
-
content: [{ type: "text", text: JSON.stringify({ error: err.message }) }],
|
|
7233
|
-
isError: true
|
|
7234
|
-
};
|
|
7235
|
-
}
|
|
7236
|
-
}
|
|
7237
|
-
);
|
|
7238
7165
|
async function main() {
|
|
7239
7166
|
if (isSqliteMode) {
|
|
7240
7167
|
console.error("[clude-mcp] SQLite mode: local-first storage at ~/.clude/brain.db");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clude/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"mcpName": "io.github.sebbsssss/clude",
|
|
5
5
|
"description": "Persistent memory SDK for AI agents — Stanford Generative Agents architecture on Supabase + pgvector",
|
|
6
6
|
"main": "dist/sdk/index.js",
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build:publish": "node scripts/build-publish.mjs",
|
|
34
|
-
"prepublishOnly": "pnpm --filter @clude/
|
|
34
|
+
"prepublishOnly": "pnpm --filter @clude/brain... build && node scripts/build-publish.mjs",
|
|
35
|
+
"prepack": "node scripts/swap-readme.mjs pack",
|
|
36
|
+
"postpack": "node scripts/swap-readme.mjs restore",
|
|
35
37
|
"typecheck": "tsc --noEmit",
|
|
36
38
|
"dashboard": "cd apps/dashboard && pnpm run dev",
|
|
37
39
|
"dashboard:build": "cd apps/dashboard && pnpm run build"
|
|
@@ -77,7 +79,6 @@
|
|
|
77
79
|
"packageManager": "pnpm@10.18.1",
|
|
78
80
|
"dependencies": {
|
|
79
81
|
"@anthropic-ai/sdk": "^0.39.0",
|
|
80
|
-
"@huggingface/transformers": "^4.1.0",
|
|
81
82
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
82
83
|
"@solana/web3.js": "^1.98.4",
|
|
83
84
|
"@supabase/supabase-js": "^2.95.3",
|
|
@@ -100,6 +101,7 @@
|
|
|
100
101
|
"typescript": "^5.6.0"
|
|
101
102
|
},
|
|
102
103
|
"optionalDependencies": {
|
|
104
|
+
"@huggingface/transformers": "^4.1.0",
|
|
103
105
|
"utf-8-validate": "^5.0.10"
|
|
104
106
|
},
|
|
105
107
|
"types": "./dist/sdk/index.d.ts"
|