@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.
Files changed (108) hide show
  1. package/README.md +9 -3
  2. package/bin/memory_mesh.js +95 -8
  3. package/lib/llm/client.d.ts +23 -48
  4. package/lib/llm/client.js +1 -0
  5. package/lib/llm/client.ts +298 -377
  6. package/lib/llm/index.js +1 -0
  7. package/lib/llm/index.ts +1 -2
  8. package/lib/memory/adapters/client.d.ts +22 -85
  9. package/lib/memory/adapters/client.js +1 -0
  10. package/lib/memory/adapters/client.ts +474 -633
  11. package/lib/memory/adapters/config.d.ts +82 -89
  12. package/lib/memory/adapters/config.js +1 -0
  13. package/lib/memory/adapters/config.ts +156 -225
  14. package/lib/memory/adapters/errors.d.ts +28 -20
  15. package/lib/memory/adapters/errors.js +1 -0
  16. package/lib/memory/adapters/errors.ts +83 -120
  17. package/lib/memory/context-manager.d.ts +15 -18
  18. package/lib/memory/context-manager.js +1 -0
  19. package/lib/memory/context-manager.ts +314 -401
  20. package/lib/memory/embeddings/factory.d.ts +18 -20
  21. package/lib/memory/embeddings/factory.js +1 -0
  22. package/lib/memory/embeddings/factory.ts +130 -173
  23. package/lib/memory/embeddings/index.js +1 -0
  24. package/lib/memory/embeddings/index.ts +1 -0
  25. package/lib/memory/embeddings/service.d.ts +36 -66
  26. package/lib/memory/embeddings/service.js +1 -0
  27. package/lib/memory/embeddings/service.ts +479 -616
  28. package/lib/memory/index.d.ts +2 -2
  29. package/lib/memory/index.js +1 -0
  30. package/lib/memory/index.ts +3 -13
  31. package/lib/memory/memory-mesh.d.ts +151 -93
  32. package/lib/memory/memory-mesh.js +1 -0
  33. package/lib/memory/memory-mesh.ts +1406 -1692
  34. package/lib/memory/memory-translator.d.ts +1 -6
  35. package/lib/memory/memory-translator.js +1 -0
  36. package/lib/memory/memory-translator.ts +96 -128
  37. package/lib/memory/schema.d.ts +29 -10
  38. package/lib/memory/schema.js +1 -0
  39. package/lib/memory/schema.ts +102 -185
  40. package/lib/memory/scorer.d.ts +3 -4
  41. package/lib/memory/scorer.js +1 -0
  42. package/lib/memory/scorer.ts +69 -86
  43. package/lib/memory/search/index.js +1 -0
  44. package/lib/memory/search/index.ts +1 -0
  45. package/lib/memory/search/keyword-search.d.ts +10 -26
  46. package/lib/memory/search/keyword-search.js +1 -0
  47. package/lib/memory/search/keyword-search.ts +123 -161
  48. package/lib/scrubber/config/defaults.d.ts +39 -46
  49. package/lib/scrubber/config/defaults.js +1 -0
  50. package/lib/scrubber/config/defaults.ts +50 -112
  51. package/lib/scrubber/errors/scrubber-error.d.ts +22 -0
  52. package/lib/scrubber/errors/scrubber-error.js +39 -0
  53. package/lib/scrubber/errors/scrubber-error.ts +44 -0
  54. package/lib/scrubber/index.d.ts +0 -1
  55. package/lib/scrubber/index.js +1 -0
  56. package/lib/scrubber/index.ts +1 -2
  57. package/lib/scrubber/scrubber.d.ts +14 -31
  58. package/lib/scrubber/scrubber.js +1 -0
  59. package/lib/scrubber/scrubber.ts +93 -152
  60. package/lib/scrubber/stages/chunker.d.ts +22 -10
  61. package/lib/scrubber/stages/chunker.js +86 -0
  62. package/lib/scrubber/stages/chunker.ts +104 -0
  63. package/lib/scrubber/stages/metadata-annotator.d.ts +14 -15
  64. package/lib/scrubber/stages/metadata-annotator.js +64 -0
  65. package/lib/scrubber/stages/metadata-annotator.ts +75 -0
  66. package/lib/scrubber/stages/normalizer.d.ts +13 -10
  67. package/lib/scrubber/stages/normalizer.js +51 -0
  68. package/lib/scrubber/stages/normalizer.ts +60 -0
  69. package/lib/scrubber/stages/semantic-filter.d.ts +13 -10
  70. package/lib/scrubber/stages/semantic-filter.js +51 -0
  71. package/lib/scrubber/stages/semantic-filter.ts +62 -0
  72. package/lib/scrubber/stages/structural-cleaner.d.ts +15 -10
  73. package/lib/scrubber/stages/structural-cleaner.js +73 -0
  74. package/lib/scrubber/stages/structural-cleaner.ts +83 -0
  75. package/lib/scrubber/stages/validator.d.ts +14 -15
  76. package/lib/scrubber/stages/validator.js +56 -0
  77. package/lib/scrubber/stages/validator.ts +67 -0
  78. package/lib/scrubber/telemetry.d.ts +20 -27
  79. package/lib/scrubber/telemetry.js +1 -0
  80. package/lib/scrubber/telemetry.ts +53 -90
  81. package/lib/scrubber/utils/hash.d.ts +14 -0
  82. package/lib/scrubber/utils/hash.js +37 -0
  83. package/lib/scrubber/utils/hash.ts +40 -0
  84. package/lib/scrubber/utils/html-parser.d.ts +14 -0
  85. package/lib/scrubber/utils/html-parser.js +38 -0
  86. package/lib/scrubber/utils/html-parser.ts +46 -0
  87. package/lib/scrubber/utils/pattern-matcher.d.ts +12 -0
  88. package/lib/scrubber/utils/pattern-matcher.js +54 -0
  89. package/lib/scrubber/utils/pattern-matcher.ts +64 -0
  90. package/lib/scrubber/utils/token-counter.d.ts +18 -0
  91. package/lib/scrubber/utils/token-counter.js +30 -0
  92. package/lib/scrubber/utils/token-counter.ts +32 -0
  93. package/lib/utils/logger.d.ts +1 -11
  94. package/lib/utils/logger.js +1 -0
  95. package/lib/utils/logger.ts +43 -63
  96. package/lib/utils/skill-metadata.d.ts +6 -14
  97. package/lib/utils/skill-metadata.js +1 -0
  98. package/lib/utils/skill-metadata.ts +89 -103
  99. package/lib/yamo/emitter.d.ts +8 -35
  100. package/lib/yamo/emitter.js +1 -0
  101. package/lib/yamo/emitter.ts +77 -155
  102. package/lib/yamo/index.d.ts +14 -0
  103. package/lib/yamo/index.js +14 -0
  104. package/lib/yamo/index.ts +16 -0
  105. package/lib/yamo/schema.d.ts +8 -10
  106. package/lib/yamo/schema.js +1 -0
  107. package/lib/yamo/schema.ts +82 -114
  108. 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', 'openai', 'cohere', 'ollama'
221
- EMBEDDING_MODEL_NAME=Xenova/all-MiniLM-L6-v2
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=Xenova/all-MiniLM-L6-v2
248
+ EMBEDDING_MODEL_NAME=hf_ggml-org_embeddinggemma-300m-qat-Q8_0.gguf
243
249
  ```
244
250
 
245
251
 
@@ -1,14 +1,101 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * MemoryMesh CLI Entry Point
5
- * Delegates to the core CLI handler in lib/memory/memory-mesh.js
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 { run } from '@yamo/memory-mesh';
10
+ import { Command } from 'commander';
11
+ import { MemoryMesh } from '../lib/memory/index.js';
12
+ import { createLogger } from '../lib/utils/logger.js';
9
13
 
10
- // Execute the main CLI handler
11
- run().catch(err => {
12
- console.error(`❌ Fatal Error: ${err.message}`);
13
- process.exit(1);
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();
@@ -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: string;
35
- apiKey: string;
36
- model: string;
37
- baseUrl: string;
38
- timeout: number;
39
- maxRetries: number;
40
- maxTokens: number;
41
- stats: LLMStats;
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?: LLMConfig);
17
+ constructor(config?: {});
46
18
  /**
47
19
  * Get default model for provider
48
20
  * @private
49
21
  */
50
- _getDefaultModel(): string;
22
+ _getDefaultModel(): any;
51
23
  /**
52
24
  * Get default base URL for provider
53
25
  * @private
54
26
  */
55
- _getDefaultBaseUrl(): string;
27
+ _getDefaultBaseUrl(): any;
56
28
  /**
57
29
  * Generate reflection from memories
58
30
  * Main entry point for reflection generation
59
31
  */
60
- reflect(prompt: string, memories: any[]): Promise<ReflectionResult>;
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: string, memories: any[]): string;
37
+ _formatMemoriesForLLM(prompt: any, memories: any): string;
66
38
  /**
67
39
  * Call LLM with retry logic
68
40
  * @private
69
41
  */
70
- _callWithRetry(systemPrompt: string, userContent: string): Promise<string>;
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: string, userContent: string): Promise<string>;
47
+ _callLLM(systemPrompt: any, userContent: any): Promise<any>;
76
48
  /**
77
49
  * Call OpenAI API
78
50
  * @private
79
51
  */
80
- _callOpenAI(systemPrompt: string, userContent: string): Promise<string>;
52
+ _callOpenAI(systemPrompt: any, userContent: any): Promise<any>;
81
53
  /**
82
54
  * Call Anthropic (Claude) API
83
55
  * @private
84
56
  */
85
- _callAnthropic(systemPrompt: string, userContent: string): Promise<string>;
57
+ _callAnthropic(systemPrompt: any, userContent: any): Promise<any>;
86
58
  /**
87
59
  * Call Ollama (local) API
88
60
  * @private
89
61
  */
90
- _callOllama(systemPrompt: string, userContent: string): Promise<string>;
62
+ _callOllama(systemPrompt: any, userContent: any): Promise<any>;
91
63
  /**
92
64
  * Fallback when LLM fails
93
65
  * @private
94
66
  */
95
- _fallback(reason: string, memories?: any[]): ReflectionResult;
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: number): Promise<void>;
75
+ _sleep(ms: any): Promise<unknown>;
101
76
  /**
102
77
  * Get client statistics
103
78
  * @returns {Object} Statistics
package/lib/llm/client.js CHANGED
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  /**
2
3
  * LLM Client - Multi-provider LLM API client for reflection generation
3
4
  *