@yamo/memory-mesh 3.0.0 → 3.0.2
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 +9 -3
- package/bin/memory_mesh.js +95 -8
- package/lib/llm/client.d.ts +23 -48
- package/lib/llm/client.js +1 -0
- package/lib/llm/client.ts +298 -377
- package/lib/llm/index.js +1 -0
- package/lib/llm/index.ts +1 -2
- package/lib/memory/adapters/client.d.ts +22 -85
- package/lib/memory/adapters/client.js +1 -0
- package/lib/memory/adapters/client.ts +474 -633
- package/lib/memory/adapters/config.d.ts +82 -89
- package/lib/memory/adapters/config.js +1 -0
- package/lib/memory/adapters/config.ts +156 -225
- package/lib/memory/adapters/errors.d.ts +28 -20
- package/lib/memory/adapters/errors.js +1 -0
- package/lib/memory/adapters/errors.ts +83 -120
- package/lib/memory/context-manager.d.ts +15 -18
- package/lib/memory/context-manager.js +1 -0
- package/lib/memory/context-manager.ts +314 -401
- package/lib/memory/embeddings/factory.d.ts +18 -20
- package/lib/memory/embeddings/factory.js +1 -0
- package/lib/memory/embeddings/factory.ts +130 -173
- package/lib/memory/embeddings/index.js +1 -0
- package/lib/memory/embeddings/index.ts +1 -0
- package/lib/memory/embeddings/service.d.ts +36 -66
- package/lib/memory/embeddings/service.js +1 -0
- package/lib/memory/embeddings/service.ts +479 -616
- package/lib/memory/index.d.ts +2 -2
- package/lib/memory/index.js +1 -0
- package/lib/memory/index.ts +3 -13
- package/lib/memory/memory-mesh.d.ts +151 -93
- package/lib/memory/memory-mesh.js +1 -0
- package/lib/memory/memory-mesh.ts +1406 -1692
- package/lib/memory/memory-translator.d.ts +1 -6
- package/lib/memory/memory-translator.js +1 -0
- package/lib/memory/memory-translator.ts +96 -128
- package/lib/memory/schema.d.ts +29 -10
- package/lib/memory/schema.js +1 -0
- package/lib/memory/schema.ts +102 -185
- package/lib/memory/scorer.d.ts +3 -4
- package/lib/memory/scorer.js +1 -0
- package/lib/memory/scorer.ts +69 -86
- package/lib/memory/search/index.js +1 -0
- package/lib/memory/search/index.ts +1 -0
- package/lib/memory/search/keyword-search.d.ts +10 -26
- package/lib/memory/search/keyword-search.js +1 -0
- package/lib/memory/search/keyword-search.ts +123 -161
- package/lib/scrubber/config/defaults.d.ts +39 -46
- package/lib/scrubber/config/defaults.js +1 -0
- package/lib/scrubber/config/defaults.ts +50 -112
- package/lib/scrubber/errors/scrubber-error.d.ts +22 -0
- package/lib/scrubber/errors/scrubber-error.js +39 -0
- package/lib/scrubber/errors/scrubber-error.ts +44 -0
- package/lib/scrubber/index.d.ts +0 -1
- package/lib/scrubber/index.js +1 -0
- package/lib/scrubber/index.ts +1 -2
- package/lib/scrubber/scrubber.d.ts +14 -31
- package/lib/scrubber/scrubber.js +1 -0
- package/lib/scrubber/scrubber.ts +93 -152
- package/lib/scrubber/stages/chunker.d.ts +22 -10
- package/lib/scrubber/stages/chunker.js +86 -0
- package/lib/scrubber/stages/chunker.ts +104 -0
- package/lib/scrubber/stages/metadata-annotator.d.ts +14 -15
- package/lib/scrubber/stages/metadata-annotator.js +64 -0
- package/lib/scrubber/stages/metadata-annotator.ts +75 -0
- package/lib/scrubber/stages/normalizer.d.ts +13 -10
- package/lib/scrubber/stages/normalizer.js +51 -0
- package/lib/scrubber/stages/normalizer.ts +60 -0
- package/lib/scrubber/stages/semantic-filter.d.ts +13 -10
- package/lib/scrubber/stages/semantic-filter.js +51 -0
- package/lib/scrubber/stages/semantic-filter.ts +62 -0
- package/lib/scrubber/stages/structural-cleaner.d.ts +15 -10
- package/lib/scrubber/stages/structural-cleaner.js +73 -0
- package/lib/scrubber/stages/structural-cleaner.ts +83 -0
- package/lib/scrubber/stages/validator.d.ts +14 -15
- package/lib/scrubber/stages/validator.js +56 -0
- package/lib/scrubber/stages/validator.ts +67 -0
- package/lib/scrubber/telemetry.d.ts +20 -27
- package/lib/scrubber/telemetry.js +1 -0
- package/lib/scrubber/telemetry.ts +53 -90
- package/lib/scrubber/utils/hash.d.ts +14 -0
- package/lib/scrubber/utils/hash.js +37 -0
- package/lib/scrubber/utils/hash.ts +40 -0
- package/lib/scrubber/utils/html-parser.d.ts +14 -0
- package/lib/scrubber/utils/html-parser.js +38 -0
- package/lib/scrubber/utils/html-parser.ts +46 -0
- package/lib/scrubber/utils/pattern-matcher.d.ts +12 -0
- package/lib/scrubber/utils/pattern-matcher.js +54 -0
- package/lib/scrubber/utils/pattern-matcher.ts +64 -0
- package/lib/scrubber/utils/token-counter.d.ts +18 -0
- package/lib/scrubber/utils/token-counter.js +30 -0
- package/lib/scrubber/utils/token-counter.ts +32 -0
- package/lib/utils/logger.d.ts +1 -11
- package/lib/utils/logger.js +1 -0
- package/lib/utils/logger.ts +43 -63
- package/lib/utils/skill-metadata.d.ts +6 -14
- package/lib/utils/skill-metadata.js +1 -0
- package/lib/utils/skill-metadata.ts +89 -103
- package/lib/yamo/emitter.d.ts +8 -35
- package/lib/yamo/emitter.js +1 -0
- package/lib/yamo/emitter.ts +77 -155
- package/lib/yamo/index.d.ts +14 -0
- package/lib/yamo/index.js +14 -0
- package/lib/yamo/index.ts +16 -0
- package/lib/yamo/schema.d.ts +8 -10
- package/lib/yamo/schema.js +1 -0
- package/lib/yamo/schema.ts +82 -114
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -217,9 +217,15 @@ LANCEDB_MEMORY_TABLE=memory_entries
|
|
|
217
217
|
|
|
218
218
|
```bash
|
|
219
219
|
# Embedding model settings
|
|
220
|
-
EMBEDDING_MODEL_TYPE=local # 'local', '
|
|
221
|
-
|
|
220
|
+
EMBEDDING_MODEL_TYPE=local # 'local', 'ollama', 'openai', 'cohere'
|
|
221
|
+
|
|
222
|
+
# Recommended: Gemma-300m for v3.0 Singularity Fidelity (matches OpenClaw)
|
|
223
|
+
EMBEDDING_MODEL_NAME=hf_ggml-org_embeddinggemma-300m-qat-Q8_0.gguf
|
|
222
224
|
EMBEDDING_DIMENSION=384
|
|
225
|
+
|
|
226
|
+
# Lightweight Default (fallback)
|
|
227
|
+
# EMBEDDING_MODEL_NAME=Xenova/all-MiniLM-L6-v2
|
|
228
|
+
# EMBEDDING_DIMENSION=384
|
|
223
229
|
```
|
|
224
230
|
|
|
225
231
|
### Example .env File
|
|
@@ -239,7 +245,7 @@ LANCEDB_URI=./data/lancedb
|
|
|
239
245
|
|
|
240
246
|
# Embeddings (local default)
|
|
241
247
|
EMBEDDING_MODEL_TYPE=local
|
|
242
|
-
EMBEDDING_MODEL_NAME=
|
|
248
|
+
EMBEDDING_MODEL_NAME=hf_ggml-org_embeddinggemma-300m-qat-Q8_0.gguf
|
|
243
249
|
```
|
|
244
250
|
|
|
245
251
|
|
package/bin/memory_mesh.js
CHANGED
|
@@ -1,14 +1,101 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* MemoryMesh CLI
|
|
5
|
-
*
|
|
4
|
+
* YAMO MemoryMesh CLI - Protocol-Native Edition (v3.1.0)
|
|
5
|
+
*
|
|
6
|
+
* Enforces the "Zero JSON" mandate by using standard CLI flags.
|
|
7
|
+
* Machines don't parse YAMO; they execute commands.
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
|
-
import {
|
|
10
|
+
import { Command } from 'commander';
|
|
11
|
+
import { MemoryMesh } from '../lib/memory/index.js';
|
|
12
|
+
import { createLogger } from '../lib/utils/logger.js';
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
const logger = createLogger('memory-mesh-cli');
|
|
15
|
+
const program = new Command();
|
|
16
|
+
|
|
17
|
+
program
|
|
18
|
+
.name('memory-mesh')
|
|
19
|
+
.description('Portable semantic memory subconscious for YAMO agents')
|
|
20
|
+
.version('3.1.0');
|
|
21
|
+
|
|
22
|
+
// 1. Store/Ingest Command
|
|
23
|
+
program
|
|
24
|
+
.command('store')
|
|
25
|
+
.alias('ingest')
|
|
26
|
+
.description('Persist a semantic memory')
|
|
27
|
+
.requiredOption('-c, --content <text>', 'The memory content')
|
|
28
|
+
.option('-t, --type <type>', 'Memory type (e.g., insight, decision, error)', 'event')
|
|
29
|
+
.option('-r, --rationale <text>', 'The constitutional rationale for this memory')
|
|
30
|
+
.option('-h, --hypothesis <text>', 'The associated hypothesis')
|
|
31
|
+
.option('--metadata <json>', 'Additional metadata (as flat flags or optional JSON)', '{}')
|
|
32
|
+
.action(async (options) => {
|
|
33
|
+
const mesh = new MemoryMesh();
|
|
34
|
+
try {
|
|
35
|
+
let metadata = {};
|
|
36
|
+
try {
|
|
37
|
+
metadata = JSON.parse(options.metadata);
|
|
38
|
+
} catch (_e) {
|
|
39
|
+
// Fallback to empty if invalid JSON
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (options.type) metadata.type = options.type;
|
|
43
|
+
if (options.rationale) metadata.rationale = options.rationale;
|
|
44
|
+
if (options.hypothesis) metadata.hypothesis = options.hypothesis;
|
|
45
|
+
|
|
46
|
+
const record = await mesh.add(options.content, metadata);
|
|
47
|
+
process.stdout.write(`[MemoryMesh] Ingested record ${record.id}\n`);
|
|
48
|
+
} catch (err) {
|
|
49
|
+
console.error(`❌ Error: ${err.message}`);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
} finally {
|
|
52
|
+
await mesh.close();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// 2. Search Command
|
|
57
|
+
program
|
|
58
|
+
.command('search')
|
|
59
|
+
.description('Perform semantic recall')
|
|
60
|
+
.argument('<query>', 'The semantic search query')
|
|
61
|
+
.option('-l, --limit <number>', 'Number of results', '10')
|
|
62
|
+
.option('-f, --filter <string>', 'LanceDB SQL-style filter')
|
|
63
|
+
.action(async (query, options) => {
|
|
64
|
+
const mesh = new MemoryMesh();
|
|
65
|
+
try {
|
|
66
|
+
const results = await mesh.search(query, {
|
|
67
|
+
limit: parseInt(options.limit),
|
|
68
|
+
filter: options.filter || null
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
process.stdout.write(`[MemoryMesh] Found ${results.length} matches.\n`);
|
|
72
|
+
process.stdout.write(mesh.formatResults(results));
|
|
73
|
+
process.stdout.write('\n');
|
|
74
|
+
} catch (err) {
|
|
75
|
+
console.error(`❌ Error: ${err.message}`);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
} finally {
|
|
78
|
+
await mesh.close();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// 3. Stats Command
|
|
83
|
+
program
|
|
84
|
+
.command('stats')
|
|
85
|
+
.description('Get database health and statistics')
|
|
86
|
+
.action(async () => {
|
|
87
|
+
const mesh = new MemoryMesh();
|
|
88
|
+
try {
|
|
89
|
+
const stats = await mesh.stats();
|
|
90
|
+
process.stdout.write(`[MemoryMesh] Total Memories: ${stats.count}\n`);
|
|
91
|
+
process.stdout.write(`[MemoryMesh] DB Path: ${stats.uri}\n`);
|
|
92
|
+
process.stdout.write(`[MemoryMesh] Status: ${stats.isConnected ? 'Connected' : 'Disconnected'}\n`);
|
|
93
|
+
} catch (err) {
|
|
94
|
+
console.error(`❌ Error: ${err.message}`);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
} finally {
|
|
97
|
+
await mesh.close();
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
program.parse();
|
package/lib/llm/client.d.ts
CHANGED
|
@@ -1,103 +1,78 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LLM Client - Multi-provider LLM API client for reflection generation
|
|
3
|
-
*
|
|
4
|
-
* Supports:
|
|
5
|
-
* - OpenAI (GPT-4, GPT-4o-mini, etc.)
|
|
6
|
-
* - Anthropic (Claude)
|
|
7
|
-
* - Ollama (local models)
|
|
8
|
-
* - Graceful fallback when LLM unavailable
|
|
9
|
-
*/
|
|
10
|
-
export interface LLMConfig {
|
|
11
|
-
provider?: string;
|
|
12
|
-
apiKey?: string;
|
|
13
|
-
model?: string;
|
|
14
|
-
baseUrl?: string;
|
|
15
|
-
timeout?: number;
|
|
16
|
-
maxRetries?: number;
|
|
17
|
-
maxTokens?: number;
|
|
18
|
-
}
|
|
19
|
-
export interface ReflectionResult {
|
|
20
|
-
reflection: string;
|
|
21
|
-
confidence: number;
|
|
22
|
-
}
|
|
23
|
-
export interface LLMStats {
|
|
24
|
-
totalRequests: number;
|
|
25
|
-
successfulRequests: number;
|
|
26
|
-
failedRequests: number;
|
|
27
|
-
fallbackCount: number;
|
|
28
|
-
}
|
|
29
1
|
/**
|
|
30
2
|
* LLMClient provides unified interface for calling various LLM providers
|
|
31
3
|
* to generate reflections from memory contexts.
|
|
32
4
|
*/
|
|
33
5
|
export declare class LLMClient {
|
|
34
|
-
provider:
|
|
35
|
-
apiKey:
|
|
36
|
-
model:
|
|
37
|
-
baseUrl:
|
|
38
|
-
timeout:
|
|
39
|
-
maxRetries:
|
|
40
|
-
maxTokens:
|
|
41
|
-
stats:
|
|
6
|
+
provider: any;
|
|
7
|
+
apiKey: any;
|
|
8
|
+
model: any;
|
|
9
|
+
baseUrl: any;
|
|
10
|
+
timeout: any;
|
|
11
|
+
maxRetries: any;
|
|
12
|
+
maxTokens: any;
|
|
13
|
+
stats: any;
|
|
42
14
|
/**
|
|
43
15
|
* Create a new LLMClient instance
|
|
44
16
|
*/
|
|
45
|
-
constructor(config?:
|
|
17
|
+
constructor(config?: {});
|
|
46
18
|
/**
|
|
47
19
|
* Get default model for provider
|
|
48
20
|
* @private
|
|
49
21
|
*/
|
|
50
|
-
_getDefaultModel():
|
|
22
|
+
_getDefaultModel(): any;
|
|
51
23
|
/**
|
|
52
24
|
* Get default base URL for provider
|
|
53
25
|
* @private
|
|
54
26
|
*/
|
|
55
|
-
_getDefaultBaseUrl():
|
|
27
|
+
_getDefaultBaseUrl(): any;
|
|
56
28
|
/**
|
|
57
29
|
* Generate reflection from memories
|
|
58
30
|
* Main entry point for reflection generation
|
|
59
31
|
*/
|
|
60
|
-
reflect(prompt:
|
|
32
|
+
reflect(prompt: any, memories: any): Promise<any>;
|
|
61
33
|
/**
|
|
62
34
|
* Format memories for LLM consumption
|
|
63
35
|
* @private
|
|
64
36
|
*/
|
|
65
|
-
_formatMemoriesForLLM(prompt:
|
|
37
|
+
_formatMemoriesForLLM(prompt: any, memories: any): string;
|
|
66
38
|
/**
|
|
67
39
|
* Call LLM with retry logic
|
|
68
40
|
* @private
|
|
69
41
|
*/
|
|
70
|
-
_callWithRetry(systemPrompt:
|
|
42
|
+
_callWithRetry(systemPrompt: any, userContent: any): Promise<any>;
|
|
71
43
|
/**
|
|
72
44
|
* Call LLM based on provider
|
|
73
45
|
* @private
|
|
74
46
|
*/
|
|
75
|
-
_callLLM(systemPrompt:
|
|
47
|
+
_callLLM(systemPrompt: any, userContent: any): Promise<any>;
|
|
76
48
|
/**
|
|
77
49
|
* Call OpenAI API
|
|
78
50
|
* @private
|
|
79
51
|
*/
|
|
80
|
-
_callOpenAI(systemPrompt:
|
|
52
|
+
_callOpenAI(systemPrompt: any, userContent: any): Promise<any>;
|
|
81
53
|
/**
|
|
82
54
|
* Call Anthropic (Claude) API
|
|
83
55
|
* @private
|
|
84
56
|
*/
|
|
85
|
-
_callAnthropic(systemPrompt:
|
|
57
|
+
_callAnthropic(systemPrompt: any, userContent: any): Promise<any>;
|
|
86
58
|
/**
|
|
87
59
|
* Call Ollama (local) API
|
|
88
60
|
* @private
|
|
89
61
|
*/
|
|
90
|
-
_callOllama(systemPrompt:
|
|
62
|
+
_callOllama(systemPrompt: any, userContent: any): Promise<any>;
|
|
91
63
|
/**
|
|
92
64
|
* Fallback when LLM fails
|
|
93
65
|
* @private
|
|
94
66
|
*/
|
|
95
|
-
_fallback(reason:
|
|
67
|
+
_fallback(reason: any, memories?: any[]): {
|
|
68
|
+
reflection: string;
|
|
69
|
+
confidence: number;
|
|
70
|
+
};
|
|
96
71
|
/**
|
|
97
72
|
* Sleep utility
|
|
98
73
|
* @private
|
|
99
74
|
*/
|
|
100
|
-
_sleep(ms:
|
|
75
|
+
_sleep(ms: any): Promise<unknown>;
|
|
101
76
|
/**
|
|
102
77
|
* Get client statistics
|
|
103
78
|
* @returns {Object} Statistics
|
package/lib/llm/client.js
CHANGED