vektor-slipstream 1.4.4 → 2.0.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.
Files changed (56) hide show
  1. package/README.md +67 -306
  2. package/package.json +14 -146
  3. package/CHANGELOG.md +0 -139
  4. package/LICENSE +0 -33
  5. package/TENETS.md +0 -189
  6. package/audn-log.js +0 -143
  7. package/axon.js +0 -389
  8. package/boot-patch.js +0 -33
  9. package/boot-screen.html +0 -210
  10. package/briefing.js +0 -150
  11. package/cerebellum.js +0 -439
  12. package/cloak-behaviour.js +0 -596
  13. package/cloak-captcha.js +0 -541
  14. package/cloak-core.js +0 -499
  15. package/cloak-identity.js +0 -484
  16. package/cloak-index.js +0 -261
  17. package/cloak-llms.js +0 -163
  18. package/cloak-pattern-store.js +0 -471
  19. package/cloak-recorder-auto.js +0 -297
  20. package/cloak-recorder-snippet.js +0 -119
  21. package/cloak-turbo-quant.js +0 -357
  22. package/cloak-warmup.js +0 -240
  23. package/cortex.js +0 -221
  24. package/detect-hardware.js +0 -181
  25. package/entity-resolver.js +0 -298
  26. package/errors.js +0 -66
  27. package/examples/example-claude-mcp.js +0 -220
  28. package/examples/example-langchain-researcher.js +0 -82
  29. package/examples/example-openai-assistant.js +0 -84
  30. package/examples/examples-README.md +0 -161
  31. package/export-import.js +0 -221
  32. package/forget.js +0 -148
  33. package/inspect.js +0 -199
  34. package/mistral/README-mistral.md +0 -123
  35. package/mistral/mistral-bridge.js +0 -218
  36. package/mistral/mistral-setup.js +0 -220
  37. package/mistral/vektor-tool-manifest.json +0 -41
  38. package/models/model_quantized.onnx +0 -0
  39. package/models/vocab.json +0 -1
  40. package/namespace.js +0 -186
  41. package/pin.js +0 -91
  42. package/slipstream-core-extended.js +0 -134
  43. package/slipstream-core.js +0 -1
  44. package/slipstream-db.js +0 -140
  45. package/slipstream-embedder.js +0 -338
  46. package/sovereign.js +0 -142
  47. package/token.js +0 -322
  48. package/types/index.d.ts +0 -269
  49. package/vektor-banner-loader.js +0 -109
  50. package/vektor-cli.js +0 -259
  51. package/vektor-licence-prompt.js +0 -128
  52. package/vektor-licence.js +0 -192
  53. package/vektor-setup.js +0 -270
  54. package/vektor-slipstream.dxt +0 -0
  55. package/vektor-tui.js +0 -373
  56. package/visualize.js +0 -235
package/errors.js DELETED
@@ -1,66 +0,0 @@
1
- /**
2
- * VEKTOR structured error codes — v1.3.7
3
- * Replace all string throws with VektorError instances.
4
- * Consumers can switch/case on error.code reliably.
5
- */
6
-
7
- export class VektorError extends Error {
8
- constructor(code, message, detail = null) {
9
- super(message);
10
- this.name = 'VektorError';
11
- this.code = code;
12
- this.detail = detail;
13
- if (Error.captureStackTrace) Error.captureStackTrace(this, VektorError);
14
- }
15
- }
16
-
17
- export const ERR = {
18
- // Licence
19
- LICENCE_MISSING: 'ERR_LICENCE_MISSING',
20
- LICENCE_INVALID: 'ERR_LICENCE_INVALID',
21
- LICENCE_EXPIRED: 'ERR_LICENCE_EXPIRED',
22
-
23
- // Memory operations
24
- MEMORY_NOT_FOUND: 'ERR_MEMORY_NOT_FOUND',
25
- MEMORY_WRITE_FAILED: 'ERR_MEMORY_WRITE_FAILED',
26
- MEMORY_READ_FAILED: 'ERR_MEMORY_READ_FAILED',
27
- MEMORY_DELETE_FAILED: 'ERR_MEMORY_DELETE_FAILED',
28
-
29
- // Graph
30
- GRAPH_NODE_NOT_FOUND: 'ERR_GRAPH_NODE_NOT_FOUND',
31
- GRAPH_CORRUPTED: 'ERR_GRAPH_CORRUPTED',
32
-
33
- // Provider / embedding
34
- PROVIDER_NOT_SUPPORTED: 'ERR_PROVIDER_NOT_SUPPORTED',
35
- EMBED_FAILED: 'ERR_EMBED_FAILED',
36
- PROVIDER_RATE_LIMIT: 'ERR_PROVIDER_RATE_LIMIT',
37
- PROVIDER_AUTH: 'ERR_PROVIDER_AUTH',
38
-
39
- // Config
40
- AGENT_ID_MISSING: 'ERR_AGENT_ID_MISSING',
41
- DB_INIT_FAILED: 'ERR_DB_INIT_FAILED',
42
-
43
- // Import / export
44
- EXPORT_FAILED: 'ERR_EXPORT_FAILED',
45
- IMPORT_FAILED: 'ERR_IMPORT_FAILED',
46
- IMPORT_SCHEMA_MISMATCH: 'ERR_IMPORT_SCHEMA_MISMATCH',
47
-
48
- // Namespace
49
- NAMESPACE_INVALID: 'ERR_NAMESPACE_INVALID',
50
- };
51
-
52
- /**
53
- * Usage:
54
- * throw new VektorError(ERR.LICENCE_INVALID, 'Licence key rejected', { key: '...' });
55
- *
56
- * Consumer:
57
- * try { await memory.remember(...) }
58
- * catch (e) {
59
- * if (e instanceof VektorError) {
60
- * switch (e.code) {
61
- * case ERR.LICENCE_INVALID: // handle
62
- * case ERR.EMBED_FAILED: // retry
63
- * }
64
- * }
65
- * }
66
- */
@@ -1,220 +0,0 @@
1
- 'use strict';
2
- /**
3
- * example-claude-mcp.js — VEKTOR Slipstream + Claude
4
- * ─────────────────────────────────────────────────────────────────────────────
5
- * Auto-memory: every conversation turn is stored in the MAGMA graph.
6
- * Claude recalls relevant context before every response.
7
- * No setup required — memory just works.
8
- *
9
- * Usage (MCP server for Claude Desktop):
10
- * node example-claude-mcp.js --mcp
11
- *
12
- * Usage (direct chat):
13
- * ANTHROPIC_API_KEY=sk-ant-... VEKTOR_LICENCE_KEY=... node example-claude-mcp.js
14
- */
15
-
16
- const { createMemory } = require('vektor-slipstream');
17
- const readline = require('readline');
18
-
19
- // ── Memory init ───────────────────────────────────────────────────────────────
20
- let _memory = null;
21
- async function getMemory() {
22
- if (_memory) return _memory;
23
- _memory = await createMemory({
24
- agentId: process.env.SLIPSTREAM_AGENT_ID || 'claude-vektor',
25
- licenceKey: process.env.VEKTOR_LICENCE_KEY,
26
- dbPath: process.env.VEKTOR_DB_PATH,
27
- silent: true,
28
- });
29
- return _memory;
30
- }
31
-
32
- // ── Auto-store: extract memorable facts from a conversation turn ──────────────
33
- async function autoStore(memory, userMsg, assistantResponse) {
34
- // Store the user message if it contains memorable content
35
- const memorable = isMemorableContent(userMsg);
36
- if (memorable) {
37
- await memory.remember(userMsg, { importance: memorable.importance }).catch(() => {});
38
- }
39
-
40
- // Store a condensed version of the exchange
41
- const exchange = `User: ${userMsg.slice(0, 200)} | Assistant: ${assistantResponse.slice(0, 300)}`;
42
- await memory.remember(exchange, { importance: 2 }).catch(() => {});
43
- }
44
-
45
- // ── Heuristic: is this content worth storing? ─────────────────────────────────
46
- function isMemorableContent(text) {
47
- const t = text.toLowerCase();
48
-
49
- // High importance — preferences, decisions, critical facts
50
- if (/prefer|always|never|hate|love|my name|i am|i'm a|i work|my project|deadline|important|remember/.test(t)) {
51
- return { importance: 4 };
52
- }
53
- // Medium importance — project details, tech choices, context
54
- if (/project|build|using|stack|version|deploy|api|database|language|framework|decided|going with/.test(t)) {
55
- return { importance: 3 };
56
- }
57
- // Low importance — general context worth keeping
58
- if (text.length > 80) {
59
- return { importance: 2 };
60
- }
61
- return null;
62
- }
63
-
64
- // ── MCP Server mode ───────────────────────────────────────────────────────────
65
- if (process.argv.includes('--mcp')) {
66
- const TOOLS = [
67
- {
68
- name: 'vektor_recall',
69
- description: 'Search persistent memory for relevant context. Call before answering anything that might have prior context.',
70
- inputSchema: { type: 'object', properties: { query: { type: 'string' }, top_k: { type: 'integer', default: 5 } }, required: ['query'] },
71
- },
72
- {
73
- name: 'vektor_store',
74
- description: 'Store a fact, preference, decision, or context in persistent memory.',
75
- inputSchema: { type: 'object', properties: { content: { type: 'string' }, importance: { type: 'integer', default: 3 } }, required: ['content'] },
76
- },
77
- {
78
- name: 'vektor_graph',
79
- description: 'Traverse the associative memory graph to find connected memories.',
80
- inputSchema: { type: 'object', properties: { topic: { type: 'string' }, depth: { type: 'integer', default: 2 } }, required: ['topic'] },
81
- },
82
- {
83
- name: 'vektor_delta',
84
- description: 'See what changed in memory on a topic recently.',
85
- inputSchema: { type: 'object', properties: { topic: { type: 'string' }, days: { type: 'integer', default: 7 } }, required: ['topic'] },
86
- },
87
- {
88
- name: 'vektor_briefing',
89
- description: 'Generate a briefing summary from recent memories.',
90
- inputSchema: { type: 'object', properties: {} },
91
- },
92
- ];
93
-
94
- async function runTool(name, input) {
95
- const mem = await getMemory();
96
- switch (name) {
97
- case 'vektor_recall': {
98
- const results = await mem.recall(input.query, input.top_k || 5);
99
- return { results: (results || []).map(r => ({ id: r.id, content: r.content, score: r.score })) };
100
- }
101
- case 'vektor_store': {
102
- const { id } = await mem.remember(input.content, { importance: input.importance || 3 });
103
- return { id, stored: true };
104
- }
105
- case 'vektor_graph': return await mem.graph(input.topic, input.depth || 2);
106
- case 'vektor_delta': return await mem.delta(input.topic, input.days || 7);
107
- case 'vektor_briefing': return { briefing: await mem.briefing() };
108
- default: throw new Error(`Unknown tool: ${name}`);
109
- }
110
- }
111
-
112
- process.stdin.setEncoding('utf8');
113
- let buffer = '';
114
- const send = obj => process.stdout.write(JSON.stringify(obj) + '\n');
115
-
116
- process.stdin.on('data', async chunk => {
117
- buffer += chunk;
118
- const lines = buffer.split('\n');
119
- buffer = lines.pop();
120
- for (const line of lines) {
121
- if (!line.trim()) continue;
122
- let req;
123
- try { req = JSON.parse(line); } catch {
124
- send({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } });
125
- continue;
126
- }
127
- if (req.method?.startsWith('notifications/')) continue;
128
- try {
129
- switch (req.method) {
130
- case 'initialize':
131
- send({ jsonrpc: '2.0', id: req.id, result: {
132
- protocolVersion: '2024-11-05',
133
- serverInfo: { name: 'vektor-slipstream', version: '1.3.9' },
134
- capabilities: { tools: { listChanged: false } },
135
- }});
136
- break;
137
- case 'tools/list':
138
- send({ jsonrpc: '2.0', id: req.id, result: { tools: TOOLS } });
139
- break;
140
- case 'tools/call': {
141
- const { name, arguments: args } = req.params;
142
- const result = await runTool(name, args || {});
143
- send({ jsonrpc: '2.0', id: req.id, result: {
144
- content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
145
- isError: false,
146
- }});
147
- break;
148
- }
149
- default:
150
- send({ jsonrpc: '2.0', id: req.id, error: { code: -32601, message: `Method not found: ${req.method}` }});
151
- }
152
- } catch(e) {
153
- send({ jsonrpc: '2.0', id: req.id, error: { code: -32603, message: e.message }});
154
- }
155
- }
156
- });
157
- process.stdin.on('end', () => process.exit(0));
158
- process.on('uncaughtException', e => process.stderr.write('[vektor-mcp] ' + e.message + '\n'));
159
-
160
- } else {
161
- // ── Direct chat mode with auto-memory ───────────────────────────────────────
162
- const Anthropic = require('@anthropic-ai/sdk');
163
-
164
- async function main() {
165
- const memory = await getMemory();
166
- const client = new Anthropic();
167
- const messages = [];
168
-
169
- // Morning briefing
170
- const brief = await memory.briefing().catch(() => '');
171
-
172
- const systemPrompt = [
173
- 'You are a helpful assistant with persistent memory via VEKTOR Slipstream.',
174
- 'Your memory persists across all sessions — you remember everything.',
175
- brief ? `\nMEMORY BRIEFING (last 24h):\n${brief}` : '',
176
- '\nWhen the user shares preferences, decisions, or important facts — they are automatically remembered.',
177
- 'Recall relevant context before answering. Store important new facts as they arise.',
178
- ].filter(Boolean).join('\n');
179
-
180
- console.log('\n🧠 VEKTOR Memory active — all conversations stored in MAGMA graph');
181
- console.log('Type your message (Ctrl+C to exit)\n');
182
-
183
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
184
-
185
- const ask = () => rl.question('You: ', async userInput => {
186
- if (!userInput.trim()) return ask();
187
-
188
- // Auto-recall before responding
189
- const recalled = await memory.recall(userInput, 5).catch(() => []);
190
- const context = recalled.length
191
- ? '\n\nRELEVANT MEMORY:\n' + recalled.map(r => `- ${r.content} (score: ${r.score?.toFixed(2)})`).join('\n')
192
- : '';
193
-
194
- messages.push({ role: 'user', content: userInput + context });
195
-
196
- try {
197
- const res = await client.messages.create({
198
- model: 'claude-opus-4-5',
199
- max_tokens: 1024,
200
- system: systemPrompt,
201
- messages,
202
- });
203
-
204
- const reply = res.content[0].text;
205
- console.log(`\nClaude: ${reply}\n`);
206
- messages.push({ role: 'assistant', content: reply });
207
-
208
- // Auto-store the exchange into MAGMA graph
209
- await autoStore(memory, userInput, reply);
210
-
211
- } catch (err) {
212
- console.error('API error:', err.message);
213
- }
214
-
215
- ask();
216
- });
217
- }
218
-
219
- main().catch(console.error);
220
- }
@@ -1,82 +0,0 @@
1
- 'use strict';
2
- /**
3
- * example-langchain-researcher.js — VEKTOR Slipstream + LangChain
4
- * ─────────────────────────────────────────────────────────────────────────────
5
- * Auto-memory: agent context, research results, and decisions flow
6
- * into the MAGMA graph automatically after every run.
7
- *
8
- * Usage:
9
- * OPENAI_API_KEY=sk-... VEKTOR_LICENCE_KEY=... node example-langchain-researcher.js
10
- */
11
-
12
- const { createMemory } = require('vektor-slipstream');
13
- const { ChatOpenAI } = require('@langchain/openai');
14
- const { AgentExecutor, createOpenAIFunctionsAgent } = require('langchain/agents');
15
- const { TavilySearchResults } = require('@langchain/community/tools/tavily_search');
16
- const { ChatPromptTemplate, MessagesPlaceholder } = require('@langchain/core/prompts');
17
- const readline = require('readline');
18
-
19
- async function main() {
20
- // ── Init VEKTOR memory ──────────────────────────────────────────────────────
21
- const memory = await createMemory({
22
- agentId: process.env.SLIPSTREAM_AGENT_ID || 'langchain-vektor',
23
- licenceKey: process.env.VEKTOR_LICENCE_KEY,
24
- dbPath: process.env.VEKTOR_DB_PATH,
25
- silent: true,
26
- });
27
-
28
- const brief = await memory.briefing().catch(() => '');
29
- console.log('\n🧠 VEKTOR Memory active — research stored in MAGMA graph');
30
- if (brief) console.log(`\nBriefing: ${brief}\n`);
31
-
32
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
33
-
34
- const ask = () => rl.question('\nResearch topic (Ctrl+C to exit): ', async topic => {
35
- if (!topic.trim()) return ask();
36
-
37
- // ── Recall prior research on this topic ─────────────────────────────────
38
- const prior = await memory.recall(topic, 5).catch(() => []);
39
- const priorText = prior.length
40
- ? 'PRIOR RESEARCH:\n' + prior.map(r => `- ${r.content}`).join('\n')
41
- : 'No prior research found on this topic.';
42
-
43
- // ── Build agent ──────────────────────────────────────────────────────────
44
- const llm = new ChatOpenAI({ modelName: 'gpt-4o-mini', temperature: 0.1 });
45
- const tools = [new TavilySearchResults({ maxResults: 5 })];
46
-
47
- const prompt = ChatPromptTemplate.fromMessages([
48
- ['system', `You are a research agent with persistent memory.\n\n${priorText}\n\nBuild on prior research. Identify new findings. Be concise.`],
49
- ['human', '{input}'],
50
- new MessagesPlaceholder('agent_scratchpad'),
51
- ]);
52
-
53
- const agent = await createOpenAIFunctionsAgent({ llm, tools, prompt });
54
- const executor = new AgentExecutor({ agent, tools, verbose: false });
55
-
56
- try {
57
- console.log(`\nResearching: ${topic}...`);
58
- const result = await executor.invoke({ input: topic });
59
-
60
- console.log(`\nFindings:\n${result.output}\n`);
61
-
62
- // ── Auto-store findings into MAGMA graph ─────────────────────────────
63
- await memory.remember(`Research topic: ${topic}`, { importance: 3 }).catch(() => {});
64
- await memory.remember(`Research findings: ${result.output.slice(0, 500)}`, { importance: 4 }).catch(() => {});
65
-
66
- // Store key sentences as individual memories for better graph connectivity
67
- const sentences = result.output.split(/[.!?]+/).filter(s => s.trim().length > 40);
68
- for (const sentence of sentences.slice(0, 5)) {
69
- await memory.remember(sentence.trim(), { importance: 2 }).catch(() => {});
70
- }
71
-
72
- console.log(`✓ ${sentences.slice(0, 5).length + 2} memories stored in MAGMA graph`);
73
-
74
- } catch (err) {
75
- console.error('Agent error:', err.message);
76
- }
77
-
78
- ask();
79
- });
80
- }
81
-
82
- main().catch(console.error);
@@ -1,84 +0,0 @@
1
- 'use strict';
2
- /**
3
- * example-openai-assistant.js — VEKTOR Slipstream + OpenAI
4
- * ─────────────────────────────────────────────────────────────────────────────
5
- * Auto-memory: every conversation turn flows into the MAGMA graph.
6
- * No setup required — memory just works from the first message.
7
- *
8
- * Usage:
9
- * OPENAI_API_KEY=sk-... VEKTOR_LICENCE_KEY=... node example-openai-assistant.js
10
- */
11
-
12
- const { createMemory } = require('vektor-slipstream');
13
- const OpenAI = require('openai');
14
- const readline = require('readline');
15
-
16
- // ── Heuristic: importance scoring ────────────────────────────────────────────
17
- function scoreImportance(text) {
18
- const t = text.toLowerCase();
19
- if (/prefer|always|never|my name|i am|i'm a|i work|my project|deadline|critical|remember/.test(t)) return 4;
20
- if (/project|build|using|stack|deploy|api|database|decided|going with|language|framework/.test(t)) return 3;
21
- if (text.length > 80) return 2;
22
- return null;
23
- }
24
-
25
- async function main() {
26
- const memory = await createMemory({
27
- agentId: process.env.SLIPSTREAM_AGENT_ID || 'openai-vektor',
28
- licenceKey: process.env.VEKTOR_LICENCE_KEY,
29
- dbPath: process.env.VEKTOR_DB_PATH,
30
- silent: true,
31
- });
32
-
33
- const client = new OpenAI();
34
- const messages = [];
35
-
36
- // Boot briefing — inject yesterday's context
37
- const brief = await memory.briefing().catch(() => '');
38
- const system = [
39
- 'You are a helpful assistant with persistent memory. You remember everything across sessions.',
40
- brief ? `\nMEMORY BRIEFING:\n${brief}` : '',
41
- ].filter(Boolean).join('\n');
42
-
43
- console.log('\n🧠 VEKTOR Memory active — conversations stored in MAGMA graph');
44
- console.log('Type your message (Ctrl+C to exit)\n');
45
-
46
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
47
-
48
- const ask = () => rl.question('You: ', async userInput => {
49
- if (!userInput.trim()) return ask();
50
-
51
- // Auto-recall relevant context
52
- const recalled = await memory.recall(userInput, 5).catch(() => []);
53
- const context = recalled.length
54
- ? '\n\n[MEMORY CONTEXT]\n' + recalled.map(r => `- ${r.content}`).join('\n') + '\n[/MEMORY CONTEXT]'
55
- : '';
56
-
57
- messages.push({ role: 'user', content: userInput + context });
58
-
59
- try {
60
- const res = await client.chat.completions.create({ model: 'gpt-4o-mini', messages: [{ role: 'system', content: system }, ...messages] });
61
- const reply = res.choices[0].message.content;
62
-
63
- console.log(`\nAssistant: ${reply}\n`);
64
- messages.push({ role: 'assistant', content: reply });
65
-
66
- // Auto-store user input if memorable
67
- const imp = scoreImportance(userInput);
68
- if (imp) await memory.remember(userInput, { importance: imp }).catch(() => {});
69
-
70
- // Always store the exchange summary
71
- await memory.remember(
72
- `Exchange — User: ${userInput.slice(0, 150)} | Assistant: ${reply.slice(0, 200)}`,
73
- { importance: 2 }
74
- ).catch(() => {});
75
-
76
- } catch (err) {
77
- console.error('API error:', err.message);
78
- }
79
-
80
- ask();
81
- });
82
- }
83
-
84
- main().catch(console.error);
@@ -1,161 +0,0 @@
1
- # VEKTOR Slipstream — Production Agent Examples
2
-
3
- Three complete, copyable agents built on the Slipstream memory API.
4
- Each works out of the box — adapt the agent logic, keep the memory layer.
5
-
6
- ---
7
-
8
- ## Quick Start
9
-
10
- ```bash
11
- npm install vektor-slipstream
12
- ```
13
-
14
- All three examples use the same two-line memory setup:
15
-
16
- ```js
17
- const { createMemory } = require('vektor-slipstream');
18
- const memory = await createMemory({ agentId: 'my-agent' });
19
- ```
20
-
21
- ---
22
-
23
- ## Example 1 — LangChain Researcher
24
-
25
- `example-langchain-researcher.js`
26
-
27
- A research agent that searches the web, summarises findings, and builds
28
- a persistent knowledge base that grows smarter with every run.
29
-
30
- **What it does:**
31
- - Recalls prior research before starting a new search
32
- - Runs a LangChain agent with Tavily web search
33
- - Stores the full summary and each key finding separately
34
- - Prints a memory briefing showing everything learned today
35
-
36
- **Install:**
37
- ```bash
38
- npm install vektor-slipstream langchain @langchain/openai @langchain/community
39
- ```
40
-
41
- **Run:**
42
- ```bash
43
- OPENAI_API_KEY=sk-... TAVILY_API_KEY=tvly-... \
44
- node example-langchain-researcher.js "quantum computing breakthroughs 2025"
45
- ```
46
-
47
- **Run again tomorrow** — the agent picks up where it left off.
48
-
49
- ---
50
-
51
- ## Example 2 — OpenAI Assistant Loop
52
-
53
- `example-openai-assistant.js`
54
-
55
- An interactive personal assistant that genuinely remembers you across sessions.
56
- Uses the OpenAI Agents SDK with three memory tools wired in.
57
-
58
- **What it does:**
59
- - Injects a memory briefing into every session
60
- - Gives the assistant `remember`, `recall`, and `memory_graph` tools
61
- - Stores important facts automatically as you chat
62
- - Traverses the memory graph for full context on any topic
63
-
64
- **Install:**
65
- ```bash
66
- npm install vektor-slipstream openai
67
- ```
68
-
69
- **Run:**
70
- ```bash
71
- OPENAI_API_KEY=sk-... node example-openai-assistant.js
72
- ```
73
-
74
- **Commands:**
75
- - Type naturally — the assistant manages memory automatically
76
- - Type `briefing` to see everything stored in the last 24h
77
- - Type `exit` to end the session
78
-
79
- ---
80
-
81
- ## Example 3 — Claude MCP Agent
82
-
83
- `example-claude-mcp.js`
84
-
85
- Connects Claude to Slipstream via the Model Context Protocol.
86
- Runs in two modes: as an MCP server for Claude Desktop, or as a
87
- standalone interactive chat.
88
-
89
- **What it does:**
90
- - Implements `vektor_recall`, `vektor_store`, `vektor_graph`, `vektor_delta` as MCP tools
91
- - Full stdio MCP server (JSON-RPC 2.0) for Claude Desktop integration
92
- - Direct chat mode for testing without Claude Desktop
93
-
94
- **Install:**
95
- ```bash
96
- npm install vektor-slipstream @anthropic-ai/sdk
97
- ```
98
-
99
- **Direct chat mode:**
100
- ```bash
101
- ANTHROPIC_API_KEY=sk-ant-... node example-claude-mcp.js
102
- ```
103
-
104
- **Claude Desktop MCP mode** — add to `claude_desktop_config.json`:
105
- ```json
106
- {
107
- "mcpServers": {
108
- "slipstream": {
109
- "command": "node",
110
- "args": ["/absolute/path/to/example-claude-mcp.js", "--mcp"],
111
- "env": {
112
- "SLIPSTREAM_AGENT_ID": "claude-desktop"
113
- }
114
- }
115
- }
116
- }
117
- ```
118
-
119
- Restart Claude Desktop — Slipstream memory tools appear automatically.
120
-
121
- ---
122
-
123
- ## The Memory API
124
-
125
- All three examples use the same four methods:
126
-
127
- ```js
128
- // Store a memory
129
- await memory.remember('User prefers TypeScript over JavaScript', { importance: 3 });
130
-
131
- // Recall by semantic similarity
132
- const results = await memory.recall('coding preferences', 5);
133
- // → [{ content, score, id, importance }]
134
-
135
- // Traverse the graph
136
- const { nodes, edges } = await memory.graph('TypeScript', { hops: 2 });
137
-
138
- // See what changed recently
139
- const changes = await memory.delta('project status', 7); // last 7 days
140
-
141
- // Morning briefing
142
- const brief = await memory.briefing(); // inject into system prompt
143
- ```
144
-
145
- ---
146
-
147
- ## Each agent gets its own DB
148
-
149
- ```js
150
- // Separate memory per agent — no cross-contamination
151
- const researchMemory = await createMemory({ agentId: 'researcher', dbPath: './research.db' });
152
- const assistantMemory = await createMemory({ agentId: 'assistant', dbPath: './assistant.db' });
153
- ```
154
-
155
- Or share memory across agents:
156
-
157
- ```js
158
- // Same DB, different agent IDs — memories are scoped per agent
159
- const scout = await createMemory({ agentId: 'scout', dbPath: './shared.db' });
160
- const forge = await createMemory({ agentId: 'forge', dbPath: './shared.db' });
161
- ```