@clude/sdk 3.3.0 → 3.3.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/README.md +47 -446
- package/README.npm.md +115 -0
- package/dist/cli/index.js +2 -74
- package/dist/mcp/server.js +1 -74
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,59 +1,28 @@
|
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
**Public Wallet: CA1HYUXZXKc7CasRGpQotMM9RiYJbVuPJq3n8Ar9oQZb**
|
|
17
|
+
## Quick start
|
|
38
18
|
|
|
39
19
|
```bash
|
|
40
|
-
|
|
41
|
-
clude setup
|
|
20
|
+
npx @clude/sdk setup # register + config + MCP install, ~30 seconds
|
|
42
21
|
```
|
|
43
22
|
|
|
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)
|
|
23
|
+
Works headless too: with no TTY it completes in local-only mode (set `CLUDE_SETUP_EMAIL` to register in CI).
|
|
51
24
|
|
|
52
|
-
|
|
53
|
-
npx @clude/sdk setup # Creates agent, installs MCP, done
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Or use the SDK:
|
|
25
|
+
Or use the SDK directly:
|
|
57
26
|
|
|
58
27
|
```typescript
|
|
59
28
|
import { Cortex } from '@clude/sdk';
|
|
@@ -73,86 +42,22 @@ await brain.store({
|
|
|
73
42
|
source: 'my-agent',
|
|
74
43
|
});
|
|
75
44
|
|
|
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
|
|
45
|
+
const memories = await brain.recall({ query: 'what do users think about pricing', limit: 5 });
|
|
46
|
+
const context = brain.formatContext(memories); // markdown, ready for your system prompt
|
|
117
47
|
```
|
|
118
48
|
|
|
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
|
-
```
|
|
49
|
+
## Storage modes
|
|
150
50
|
|
|
151
|
-
|
|
51
|
+
| Mode | Config | Storage |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| **Hosted** | `CORTEX_API_KEY` | clude.io, isolated per API key |
|
|
54
|
+
| **Self-hosted** | `SUPABASE_URL` + `SUPABASE_SERVICE_KEY` | your Supabase (PostgreSQL + pgvector) |
|
|
55
|
+
| **Local (default)** | none | `~/.clude/brain.db` — SQLite + local embeddings, fully offline |
|
|
56
|
+
| **Local (JSON)** | `CLUDE_LOCAL=true` or `--local` | `~/.clude/memories.json`, portable single file |
|
|
152
57
|
|
|
153
|
-
|
|
58
|
+
Self-hosted unlocks the full cognitive layer: dream cycles (consolidation, reflection, contradiction resolution), the entity graph, and memory packs.
|
|
154
59
|
|
|
155
|
-
|
|
60
|
+
## MCP integration
|
|
156
61
|
|
|
157
62
|
```json
|
|
158
63
|
{
|
|
@@ -160,354 +65,50 @@ Add Clude to any MCP-compatible agent. Run `npx @clude/sdk setup` for automatic
|
|
|
160
65
|
"clude-memory": {
|
|
161
66
|
"command": "npx",
|
|
162
67
|
"args": ["@clude/sdk", "mcp-serve"],
|
|
163
|
-
"env": {
|
|
164
|
-
"CORTEX_API_KEY": "clk_..."
|
|
165
|
-
}
|
|
68
|
+
"env": { "CORTEX_API_KEY": "clk_..." }
|
|
166
69
|
}
|
|
167
70
|
}
|
|
168
71
|
}
|
|
169
72
|
```
|
|
170
73
|
|
|
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
|
|
74
|
+
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`).
|
|
188
75
|
|
|
189
|
-
|
|
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`:
|
|
76
|
+
## CLI
|
|
208
77
|
|
|
209
78
|
```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
|
-
});
|
|
79
|
+
npx @clude/sdk setup # Guided setup: register + config + MCP install
|
|
80
|
+
npx @clude/sdk status # Mode, storage, MCP detection, memory stats
|
|
81
|
+
npx @clude/sdk register # Get a hosted API key
|
|
82
|
+
npx @clude/sdk mcp-install # Install MCP config for your IDE
|
|
83
|
+
npx @clude/sdk mcp-serve # Run as a stdio MCP server
|
|
84
|
+
npx @clude/sdk connect # Connect Claude Desktop / claude.ai via remote MCP
|
|
85
|
+
npx @clude/sdk export # Export memories (json/md/chatgpt/gemini/memorypack)
|
|
86
|
+
npx @clude/sdk import # Import from ChatGPT export, markdown, JSON
|
|
87
|
+
npx @clude/sdk doctor # Diagnostics
|
|
268
88
|
```
|
|
269
89
|
|
|
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
|
-
```
|
|
90
|
+
## Memory model
|
|
290
91
|
|
|
291
|
-
|
|
92
|
+
Five typed stores with differential decay — accessed memories are reinforced, unaccessed ones fade:
|
|
292
93
|
|
|
293
94
|
| 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
95
|
|---|---|---|
|
|
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.
|
|
96
|
+
| `episodic` | 7% | events, conversations |
|
|
97
|
+
| `semantic` | 2% | facts, knowledge, insights |
|
|
98
|
+
| `procedural` | 3% | workflows, what works |
|
|
99
|
+
| `self_model` | 1% | identity, preferences |
|
|
100
|
+
| `introspective` | 2% | reflections, journals |
|
|
503
101
|
|
|
504
|
-
|
|
102
|
+
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
103
|
|
|
506
|
-
|
|
104
|
+
## Docs
|
|
507
105
|
|
|
508
|
-
|
|
106
|
+
- **Complete integration reference (one fetch, agent-friendly):** [clude.io/llms-full.txt](https://clude.io/llms-full.txt)
|
|
107
|
+
- Docs: [clude.io/docs](https://clude.io/docs) · Dashboard: [clude.io/dashboard](https://clude.io/dashboard)
|
|
108
|
+
- REST API: `POST https://clude.io/api/cortex/register` → then `/store`, `/recall`, `/stats`, ... with `Authorization: Bearer <key>`
|
|
109
|
+
- Source, issues, benchmarks: [github.com/sebbsssss/clude](https://github.com/sebbsssss/clude)
|
|
509
110
|
|
|
510
|
-
|
|
111
|
+
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
112
|
|
|
512
113
|
## License
|
|
513
114
|
|
package/README.npm.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx @clude/sdk setup # register + config + MCP install, ~30 seconds
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Works headless too: with no TTY it completes in local-only mode (set `CLUDE_SETUP_EMAIL` to register in CI).
|
|
24
|
+
|
|
25
|
+
Or use the SDK directly:
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { Cortex } from '@clude/sdk';
|
|
29
|
+
|
|
30
|
+
const brain = new Cortex({
|
|
31
|
+
hosted: { apiKey: process.env.CORTEX_API_KEY! },
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
await brain.init();
|
|
35
|
+
|
|
36
|
+
await brain.store({
|
|
37
|
+
type: 'episodic',
|
|
38
|
+
content: 'User asked about pricing and seemed frustrated.',
|
|
39
|
+
summary: 'Frustrated user asking about pricing',
|
|
40
|
+
tags: ['pricing', 'user-concern'],
|
|
41
|
+
importance: 0.7,
|
|
42
|
+
source: 'my-agent',
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const memories = await brain.recall({ query: 'what do users think about pricing', limit: 5 });
|
|
46
|
+
const context = brain.formatContext(memories); // markdown, ready for your system prompt
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Storage modes
|
|
50
|
+
|
|
51
|
+
| Mode | Config | Storage |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| **Hosted** | `CORTEX_API_KEY` | clude.io, isolated per API key |
|
|
54
|
+
| **Self-hosted** | `SUPABASE_URL` + `SUPABASE_SERVICE_KEY` | your Supabase (PostgreSQL + pgvector) |
|
|
55
|
+
| **Local (default)** | none | `~/.clude/brain.db` — SQLite + local embeddings, fully offline |
|
|
56
|
+
| **Local (JSON)** | `CLUDE_LOCAL=true` or `--local` | `~/.clude/memories.json`, portable single file |
|
|
57
|
+
|
|
58
|
+
Self-hosted unlocks the full cognitive layer: dream cycles (consolidation, reflection, contradiction resolution), the entity graph, and memory packs.
|
|
59
|
+
|
|
60
|
+
## MCP integration
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"mcpServers": {
|
|
65
|
+
"clude-memory": {
|
|
66
|
+
"command": "npx",
|
|
67
|
+
"args": ["@clude/sdk", "mcp-serve"],
|
|
68
|
+
"env": { "CORTEX_API_KEY": "clk_..." }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
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`).
|
|
75
|
+
|
|
76
|
+
## CLI
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npx @clude/sdk setup # Guided setup: register + config + MCP install
|
|
80
|
+
npx @clude/sdk status # Mode, storage, MCP detection, memory stats
|
|
81
|
+
npx @clude/sdk register # Get a hosted API key
|
|
82
|
+
npx @clude/sdk mcp-install # Install MCP config for your IDE
|
|
83
|
+
npx @clude/sdk mcp-serve # Run as a stdio MCP server
|
|
84
|
+
npx @clude/sdk connect # Connect Claude Desktop / claude.ai via remote MCP
|
|
85
|
+
npx @clude/sdk export # Export memories (json/md/chatgpt/gemini/memorypack)
|
|
86
|
+
npx @clude/sdk import # Import from ChatGPT export, markdown, JSON
|
|
87
|
+
npx @clude/sdk doctor # Diagnostics
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Memory model
|
|
91
|
+
|
|
92
|
+
Five typed stores with differential decay — accessed memories are reinforced, unaccessed ones fade:
|
|
93
|
+
|
|
94
|
+
| Type | Decay/day | Use for |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| `episodic` | 7% | events, conversations |
|
|
97
|
+
| `semantic` | 2% | facts, knowledge, insights |
|
|
98
|
+
| `procedural` | 3% | workflows, what works |
|
|
99
|
+
| `self_model` | 1% | identity, preferences |
|
|
100
|
+
| `introspective` | 2% | reflections, journals |
|
|
101
|
+
|
|
102
|
+
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).
|
|
103
|
+
|
|
104
|
+
## Docs
|
|
105
|
+
|
|
106
|
+
- **Complete integration reference (one fetch, agent-friendly):** [clude.io/llms-full.txt](https://clude.io/llms-full.txt)
|
|
107
|
+
- Docs: [clude.io/docs](https://clude.io/docs) · Dashboard: [clude.io/dashboard](https://clude.io/dashboard)
|
|
108
|
+
- REST API: `POST https://clude.io/api/cortex/register` → then `/store`, `/recall`, `/stats`, ... with `Authorization: Bearer <key>`
|
|
109
|
+
- Source, issues, benchmarks: [github.com/sebbsssss/clude](https://github.com/sebbsssss/clude)
|
|
110
|
+
|
|
111
|
+
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.
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
MIT
|
package/dist/cli/index.js
CHANGED
|
@@ -11245,7 +11245,7 @@ var require_package = __commonJS({
|
|
|
11245
11245
|
"packages/brain/package.json"(exports2, module2) {
|
|
11246
11246
|
module2.exports = {
|
|
11247
11247
|
name: "@clude/brain",
|
|
11248
|
-
version: "3.3.
|
|
11248
|
+
version: "3.3.1",
|
|
11249
11249
|
private: true,
|
|
11250
11250
|
description: "Clude brain \u2014 memory, dreams, agents, personality, SDK",
|
|
11251
11251
|
main: "dist/index.js",
|
|
@@ -11480,11 +11480,6 @@ function loadSelfHosted() {
|
|
|
11480
11480
|
_deleteMemory = memory.deleteMemory;
|
|
11481
11481
|
_updateMemory = memory.updateMemory;
|
|
11482
11482
|
_listMemories = memory.listMemories;
|
|
11483
|
-
try {
|
|
11484
|
-
const skillExtraction = require("@clude/shared/core/skill-extraction");
|
|
11485
|
-
_extractSkill = skillExtraction.extractSkill;
|
|
11486
|
-
} catch {
|
|
11487
|
-
}
|
|
11488
11483
|
try {
|
|
11489
11484
|
const confidenceGate = (init_confidence_gate(), __toCommonJS(confidence_gate_exports));
|
|
11490
11485
|
_evaluateConfidence = confidenceGate.evaluateConfidence;
|
|
@@ -11536,7 +11531,7 @@ async function main() {
|
|
|
11536
11531
|
await server.connect(transport);
|
|
11537
11532
|
console.error(`[clude-mcp] Server started on stdio`);
|
|
11538
11533
|
}
|
|
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,
|
|
11534
|
+
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
11535
|
var init_server = __esm({
|
|
11541
11536
|
"packages/brain/src/mcp/server.ts"() {
|
|
11542
11537
|
"use strict";
|
|
@@ -12204,73 +12199,6 @@ var init_server = __esm({
|
|
|
12204
12199
|
}]
|
|
12205
12200
|
})
|
|
12206
12201
|
);
|
|
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
12202
|
main().catch((err) => {
|
|
12275
12203
|
console.error("[clude-mcp] Fatal error:", err);
|
|
12276
12204
|
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.3.
|
|
6004
|
+
version: "3.3.1",
|
|
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.
|
|
3
|
+
"version": "3.3.1",
|
|
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"
|