@yamo/memory-mesh 2.3.2 → 3.0.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.
Files changed (124) hide show
  1. package/README.md +8 -2
  2. package/bin/memory_mesh.js +1 -1
  3. package/lib/llm/client.d.ts +86 -0
  4. package/lib/llm/client.js +300 -357
  5. package/lib/llm/client.ts +334 -0
  6. package/lib/llm/index.d.ts +17 -0
  7. package/lib/llm/index.js +16 -8
  8. package/lib/llm/index.ts +18 -0
  9. package/lib/memory/adapters/client.d.ts +120 -0
  10. package/lib/memory/adapters/client.js +519 -0
  11. package/lib/memory/adapters/client.ts +519 -0
  12. package/lib/memory/adapters/config.d.ts +130 -0
  13. package/lib/memory/adapters/config.js +190 -0
  14. package/lib/memory/adapters/config.ts +190 -0
  15. package/lib/memory/adapters/errors.d.ts +84 -0
  16. package/lib/memory/adapters/errors.js +129 -0
  17. package/lib/memory/adapters/errors.ts +129 -0
  18. package/lib/memory/context-manager.d.ts +41 -0
  19. package/lib/memory/context-manager.js +345 -0
  20. package/lib/memory/context-manager.ts +345 -0
  21. package/lib/memory/embeddings/factory.d.ts +57 -0
  22. package/lib/memory/embeddings/factory.js +149 -0
  23. package/lib/memory/embeddings/factory.ts +149 -0
  24. package/lib/memory/embeddings/index.d.ts +2 -0
  25. package/lib/memory/embeddings/index.js +3 -0
  26. package/lib/memory/embeddings/index.ts +3 -0
  27. package/lib/memory/embeddings/service.d.ts +134 -0
  28. package/lib/memory/embeddings/service.js +516 -0
  29. package/lib/memory/embeddings/service.ts +516 -0
  30. package/lib/memory/index.d.ts +9 -0
  31. package/lib/memory/index.js +10 -1
  32. package/lib/memory/index.ts +10 -0
  33. package/lib/memory/memory-mesh.d.ts +332 -0
  34. package/lib/memory/memory-mesh.js +1470 -678
  35. package/lib/memory/memory-mesh.ts +1517 -0
  36. package/lib/memory/memory-translator.d.ts +14 -0
  37. package/lib/memory/memory-translator.js +126 -0
  38. package/lib/memory/memory-translator.ts +126 -0
  39. package/lib/memory/schema.d.ts +130 -0
  40. package/lib/memory/schema.js +184 -0
  41. package/lib/memory/schema.ts +184 -0
  42. package/lib/memory/scorer.d.ts +25 -0
  43. package/lib/memory/scorer.js +78 -0
  44. package/lib/memory/scorer.ts +78 -0
  45. package/lib/memory/search/index.d.ts +1 -0
  46. package/lib/memory/search/index.js +2 -0
  47. package/lib/memory/search/index.ts +2 -0
  48. package/lib/memory/search/keyword-search.d.ts +46 -0
  49. package/lib/memory/search/keyword-search.js +136 -0
  50. package/lib/memory/search/keyword-search.ts +136 -0
  51. package/lib/scrubber/config/defaults.d.ts +46 -0
  52. package/lib/scrubber/config/defaults.js +50 -57
  53. package/lib/scrubber/config/defaults.ts +55 -0
  54. package/lib/scrubber/errors/scrubber-error.d.ts +22 -0
  55. package/lib/scrubber/errors/scrubber-error.js +28 -32
  56. package/lib/scrubber/errors/scrubber-error.ts +44 -0
  57. package/lib/scrubber/index.d.ts +5 -0
  58. package/lib/scrubber/index.js +4 -23
  59. package/lib/scrubber/index.ts +6 -0
  60. package/lib/scrubber/scrubber.d.ts +44 -0
  61. package/lib/scrubber/scrubber.js +100 -121
  62. package/lib/scrubber/scrubber.ts +109 -0
  63. package/lib/scrubber/stages/chunker.d.ts +25 -0
  64. package/lib/scrubber/stages/chunker.js +74 -91
  65. package/lib/scrubber/stages/chunker.ts +104 -0
  66. package/lib/scrubber/stages/metadata-annotator.d.ts +17 -0
  67. package/lib/scrubber/stages/metadata-annotator.js +55 -65
  68. package/lib/scrubber/stages/metadata-annotator.ts +75 -0
  69. package/lib/scrubber/stages/normalizer.d.ts +16 -0
  70. package/lib/scrubber/stages/normalizer.js +42 -50
  71. package/lib/scrubber/stages/normalizer.ts +60 -0
  72. package/lib/scrubber/stages/semantic-filter.d.ts +16 -0
  73. package/lib/scrubber/stages/semantic-filter.js +42 -52
  74. package/lib/scrubber/stages/semantic-filter.ts +62 -0
  75. package/lib/scrubber/stages/structural-cleaner.d.ts +18 -0
  76. package/lib/scrubber/stages/structural-cleaner.js +66 -75
  77. package/lib/scrubber/stages/structural-cleaner.ts +83 -0
  78. package/lib/scrubber/stages/validator.d.ts +17 -0
  79. package/lib/scrubber/stages/validator.js +46 -56
  80. package/lib/scrubber/stages/validator.ts +67 -0
  81. package/lib/scrubber/telemetry.d.ts +29 -0
  82. package/lib/scrubber/telemetry.js +54 -58
  83. package/lib/scrubber/telemetry.ts +62 -0
  84. package/lib/scrubber/utils/hash.d.ts +14 -0
  85. package/lib/scrubber/utils/hash.js +30 -32
  86. package/lib/scrubber/utils/hash.ts +40 -0
  87. package/lib/scrubber/utils/html-parser.d.ts +14 -0
  88. package/lib/scrubber/utils/html-parser.js +32 -39
  89. package/lib/scrubber/utils/html-parser.ts +46 -0
  90. package/lib/scrubber/utils/pattern-matcher.d.ts +12 -0
  91. package/lib/scrubber/utils/pattern-matcher.js +48 -57
  92. package/lib/scrubber/utils/pattern-matcher.ts +64 -0
  93. package/lib/scrubber/utils/token-counter.d.ts +18 -0
  94. package/lib/scrubber/utils/token-counter.js +24 -25
  95. package/lib/scrubber/utils/token-counter.ts +32 -0
  96. package/lib/utils/logger.d.ts +19 -0
  97. package/lib/utils/logger.js +65 -0
  98. package/lib/utils/logger.ts +65 -0
  99. package/lib/utils/skill-metadata.d.ts +24 -0
  100. package/lib/utils/skill-metadata.js +133 -0
  101. package/lib/utils/skill-metadata.ts +133 -0
  102. package/lib/yamo/emitter.d.ts +46 -0
  103. package/lib/yamo/emitter.js +79 -143
  104. package/lib/yamo/emitter.ts +171 -0
  105. package/lib/yamo/index.d.ts +14 -0
  106. package/lib/yamo/index.js +6 -7
  107. package/lib/yamo/index.ts +16 -0
  108. package/lib/yamo/schema.d.ts +56 -0
  109. package/lib/yamo/schema.js +82 -108
  110. package/lib/yamo/schema.ts +133 -0
  111. package/package.json +13 -8
  112. package/index.d.ts +0 -111
  113. package/lib/embeddings/factory.js +0 -151
  114. package/lib/embeddings/index.js +0 -2
  115. package/lib/embeddings/service.js +0 -586
  116. package/lib/index.js +0 -6
  117. package/lib/lancedb/client.js +0 -633
  118. package/lib/lancedb/config.js +0 -215
  119. package/lib/lancedb/errors.js +0 -144
  120. package/lib/lancedb/index.js +0 -4
  121. package/lib/lancedb/schema.js +0 -217
  122. package/lib/search/index.js +0 -1
  123. package/lib/search/keyword-search.js +0 -144
  124. package/lib/utils/index.js +0 -1
@@ -0,0 +1,56 @@
1
+ /**
2
+ * YAMO Block Schema Definitions for yamo-memory-mesh
3
+ * Uses Apache Arrow Schema format for LanceDB JavaScript SDK
4
+ *
5
+ * Provides schema and table creation for YAMO block persistence.
6
+ * YAMO blocks provide audit trail for all memory operations.
7
+ */
8
+ import * as arrow from "apache-arrow";
9
+ /**
10
+ * Create YAMO blocks table schema
11
+ * Defines the structure for storing YAMO protocol blocks
12
+ * @returns {arrow.Schema} Arrow schema for YAMO blocks
13
+ */
14
+ export declare function createYamoSchema(): arrow.Schema<any>;
15
+ /**
16
+ * Create YAMO blocks table in LanceDB
17
+ * Creates the table if it doesn't exist, opens it if it does
18
+ *
19
+ * @param {lancedb.Connection} db - LanceDB connection
20
+ * @param {string} [tableName='yamo_blocks'] - Name of the table
21
+ * @returns {Promise<lancedb.Table>} The created or opened table
22
+ * @throws {Error} If table creation fails
23
+ */
24
+ export declare function createYamoTable(db: any, tableName?: string): Promise<any>;
25
+ /**
26
+ * Validate a YAMO block record before insertion
27
+ * Checks for required fields and valid values
28
+ */
29
+ export declare function validateYamoRecord(record: any): {
30
+ valid: boolean;
31
+ errors: any[];
32
+ };
33
+ /**
34
+ * Generate a YAMO block ID
35
+ * Creates a unique ID for a YAMO block
36
+ *
37
+ * @param {string} operationType - Type of operation
38
+ * @returns {string} Generated YAMO block ID
39
+ */
40
+ export declare function generateYamoId(operationType: any): string;
41
+ /**
42
+ * Check if a table uses YAMO schema
43
+ * Detects if a table has the YAMO block schema structure
44
+ *
45
+ * @param {arrow.Schema} schema - Table schema to check
46
+ * @returns {boolean} True if YAMO schema detected
47
+ */
48
+ export declare function isYamoSchema(schema: any): any;
49
+ declare const _default: {
50
+ createYamoSchema: typeof createYamoSchema;
51
+ createYamoTable: typeof createYamoTable;
52
+ validateYamoRecord: typeof validateYamoRecord;
53
+ generateYamoId: typeof generateYamoId;
54
+ isYamoSchema: typeof isYamoSchema;
55
+ };
56
+ export default _default;
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  /**
2
3
  * YAMO Block Schema Definitions for yamo-memory-mesh
3
4
  * Uses Apache Arrow Schema format for LanceDB JavaScript SDK
@@ -5,121 +6,99 @@
5
6
  * Provides schema and table creation for YAMO block persistence.
6
7
  * YAMO blocks provide audit trail for all memory operations.
7
8
  */
8
-
9
9
  import * as arrow from "apache-arrow";
10
-
11
10
  /**
12
11
  * Create YAMO blocks table schema
13
12
  * Defines the structure for storing YAMO protocol blocks
14
- *
15
- * Schema includes:
16
- * - Core identifiers (id, agent_id)
17
- * - Operation tracking (operation_type, yamo_text)
18
- * - Temporal data (timestamp)
19
- * - Blockchain fields (block_hash, prev_hash) - nullable for future use
20
- * - Metadata (JSON string for flexibility)
21
- *
22
- * @returns {import('apache-arrow').Schema} Arrow schema for YAMO blocks
13
+ * @returns {arrow.Schema} Arrow schema for YAMO blocks
23
14
  */
24
15
  export function createYamoSchema() {
25
- return new arrow.Schema([
26
- // Core identifiers
27
- new arrow.Field('id', new arrow.Utf8(), false),
28
- new arrow.Field('agent_id', new arrow.Utf8(), true),
29
-
30
- // Operation tracking
31
- new arrow.Field('operation_type', new arrow.Utf8(), false), // 'retain', 'recall', 'reflect'
32
- new arrow.Field('yamo_text', new arrow.Utf8(), false), // Full YAMO block content
33
-
34
- // Temporal
35
- new arrow.Field('timestamp', new arrow.Timestamp(arrow.TimeUnit.MILLISECOND), false),
36
-
37
- // Blockchain fields (optional, nullable) - for future anchoring
38
- new arrow.Field('block_hash', new arrow.Utf8(), true), // Hash of this block
39
- new arrow.Field('prev_hash', new arrow.Utf8(), true), // Hash of previous block (for chain)
40
-
41
- // Metadata (JSON string for flexibility)
42
- new arrow.Field('metadata', new arrow.Utf8(), true), // Additional metadata as JSON
43
- ]);
16
+ return new arrow.Schema([
17
+ // Core identifiers
18
+ new arrow.Field("id", new arrow.Utf8(), false),
19
+ new arrow.Field("agent_id", new arrow.Utf8(), true),
20
+ // Operation tracking
21
+ new arrow.Field("operation_type", new arrow.Utf8(), false), // 'retain', 'recall', 'reflect'
22
+ new arrow.Field("yamo_text", new arrow.Utf8(), false), // Full YAMO block content
23
+ // Temporal
24
+ new arrow.Field("timestamp", new arrow.Timestamp(arrow.TimeUnit.MILLISECOND), false),
25
+ // Blockchain fields (optional, nullable) - for future anchoring
26
+ new arrow.Field("block_hash", new arrow.Utf8(), true), // Hash of this block
27
+ new arrow.Field("prev_hash", new arrow.Utf8(), true), // Hash of previous block (for chain)
28
+ // Metadata (JSON string for flexibility)
29
+ new arrow.Field("metadata", new arrow.Utf8(), true), // Additional metadata as JSON
30
+ ]);
44
31
  }
45
-
46
32
  /**
47
33
  * Create YAMO blocks table in LanceDB
48
34
  * Creates the table if it doesn't exist, opens it if it does
49
35
  *
50
- * @param {import('@lancedb/lancedb').Connection} db - LanceDB connection
36
+ * @param {lancedb.Connection} db - LanceDB connection
51
37
  * @param {string} [tableName='yamo_blocks'] - Name of the table
52
- * @returns {Promise<import('@lancedb/lancedb').Table>} The created or opened table
38
+ * @returns {Promise<lancedb.Table>} The created or opened table
53
39
  * @throws {Error} If table creation fails
54
40
  */
55
- export async function createYamoTable(db, tableName = 'yamo_blocks') {
56
- try {
57
- // Check if table already exists
58
- const existingTables = await db.tableNames();
59
-
60
- if (existingTables.includes(tableName)) {
61
- // Table exists, open it
62
- return await db.openTable(tableName);
41
+ export async function createYamoTable(db, tableName = "yamo_blocks") {
42
+ try {
43
+ // Check if table already exists
44
+ const existingTables = await db.tableNames();
45
+ if (existingTables.includes(tableName)) {
46
+ // Table exists, open it
47
+ return await db.openTable(tableName);
48
+ }
49
+ // Create new table with YAMO schema
50
+ const schema = createYamoSchema();
51
+ const table = await db.createTable(tableName, [], { schema });
52
+ return table;
53
+ }
54
+ catch (error) {
55
+ const message = error instanceof Error ? error.message : String(error);
56
+ throw new Error(`Failed to create YAMO table '${tableName}': ${message}`);
63
57
  }
64
-
65
- // Create new table with YAMO schema
66
- const schema = createYamoSchema();
67
- const table = await db.createTable(tableName, [], { schema });
68
-
69
- return table;
70
-
71
- } catch (error) {
72
- const message = error instanceof Error ? error.message : String(error);
73
- throw new Error(`Failed to create YAMO table '${tableName}': ${message}`);
74
- }
75
58
  }
76
-
77
59
  /**
78
60
  * Validate a YAMO block record before insertion
79
61
  * Checks for required fields and valid values
80
- *
81
- * @param {Object} record - Record to validate
82
- * @param {string} record.id - Block ID
83
- * @param {string} record.operation_type - Operation type
84
- * @param {string} record.yamo_text - YAMO block text
85
- * @returns {Object} Validation result { valid, errors }
86
62
  */
87
63
  export function validateYamoRecord(record) {
88
- const errors = [];
89
-
90
- // Check required fields
91
- if (!record.id) {
92
- errors.push('Missing required field: id');
93
- }
94
-
95
- if (!record.operation_type) {
96
- errors.push('Missing required field: operation_type');
97
- } else {
98
- // Validate operation_type is one of the allowed values
99
- const validTypes = ['retain', 'recall', 'reflect'];
100
- if (!validTypes.includes(record.operation_type)) {
101
- errors.push(`Invalid operation_type: ${record.operation_type}. Must be one of: ${validTypes.join(', ')}`);
64
+ const errors = [];
65
+ // Check required fields
66
+ if (!record.id) {
67
+ errors.push("Missing required field: id");
68
+ }
69
+ if (!record.operation_type) {
70
+ errors.push("Missing required field: operation_type");
71
+ }
72
+ else {
73
+ // Validate operation_type is one of the allowed values
74
+ const validTypes = ["retain", "recall", "reflect"];
75
+ if (!validTypes.includes(record.operation_type)) {
76
+ errors.push(`Invalid operation_type: ${record.operation_type}. Must be one of: ${validTypes.join(", ")}`);
77
+ }
78
+ }
79
+ if (!record.yamo_text) {
80
+ errors.push("Missing required field: yamo_text");
102
81
  }
103
- }
104
-
105
- if (!record.yamo_text) {
106
- errors.push('Missing required field: yamo_text');
107
- } else {
108
- // Validate YAMO block format
109
- const requiredSections = ['agent:', 'intent:', 'context:', 'output:', 'log:'];
110
- for (const section of requiredSections) {
111
- if (!record.yamo_text.includes(section)) {
112
- errors.push(`YAMO block missing required section: ${section}`);
113
- }
82
+ else {
83
+ // Validate YAMO block format
84
+ const requiredSections = [
85
+ "agent:",
86
+ "intent:",
87
+ "context:",
88
+ "output:",
89
+ "log:",
90
+ ];
91
+ for (const section of requiredSections) {
92
+ if (!record.yamo_text.includes(section)) {
93
+ errors.push(`YAMO block missing required section: ${section}`);
94
+ }
95
+ }
114
96
  }
115
- }
116
-
117
- return {
118
- valid: errors.length === 0,
119
- errors
120
- };
97
+ return {
98
+ valid: errors.length === 0,
99
+ errors,
100
+ };
121
101
  }
122
-
123
102
  /**
124
103
  * Generate a YAMO block ID
125
104
  * Creates a unique ID for a YAMO block
@@ -128,32 +107,27 @@ export function validateYamoRecord(record) {
128
107
  * @returns {string} Generated YAMO block ID
129
108
  */
130
109
  export function generateYamoId(operationType) {
131
- const timestamp = Date.now();
132
- const random = Math.random().toString(36).substring(2, 10);
133
- return `yamo_${operationType}_${timestamp}_${random}`;
110
+ const timestamp = Date.now();
111
+ const random = Math.random().toString(36).substring(2, 10);
112
+ return `yamo_${operationType}_${timestamp}_${random}`;
134
113
  }
135
-
136
114
  /**
137
115
  * Check if a table uses YAMO schema
138
116
  * Detects if a table has the YAMO block schema structure
139
117
  *
140
- * @param {import('apache-arrow').Schema} schema - Table schema to check
118
+ * @param {arrow.Schema} schema - Table schema to check
141
119
  * @returns {boolean} True if YAMO schema detected
142
120
  */
143
121
  export function isYamoSchema(schema) {
144
- // Check for unique YAMO fields
145
- const hasYamoFields = schema.fields.some(f =>
146
- f.name === 'operation_type' || f.name === 'yamo_text'
147
- );
148
-
149
- return hasYamoFields;
122
+ // Check for unique YAMO fields
123
+ const hasYamoFields = schema.fields.some((f) => f.name === "operation_type" || f.name === "yamo_text");
124
+ return hasYamoFields;
150
125
  }
151
-
152
126
  // Export schema function as default for consistency with lancedb/schema.js
153
127
  export default {
154
- createYamoSchema,
155
- createYamoTable,
156
- validateYamoRecord,
157
- generateYamoId,
158
- isYamoSchema
128
+ createYamoSchema,
129
+ createYamoTable,
130
+ validateYamoRecord,
131
+ generateYamoId,
132
+ isYamoSchema,
159
133
  };
@@ -0,0 +1,133 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * YAMO Block Schema Definitions for yamo-memory-mesh
4
+ * Uses Apache Arrow Schema format for LanceDB JavaScript SDK
5
+ *
6
+ * Provides schema and table creation for YAMO block persistence.
7
+ * YAMO blocks provide audit trail for all memory operations.
8
+ */
9
+ import * as arrow from "apache-arrow";
10
+ /**
11
+ * Create YAMO blocks table schema
12
+ * Defines the structure for storing YAMO protocol blocks
13
+ * @returns {arrow.Schema} Arrow schema for YAMO blocks
14
+ */
15
+ export function createYamoSchema() {
16
+ return new arrow.Schema([
17
+ // Core identifiers
18
+ new arrow.Field("id", new arrow.Utf8(), false),
19
+ new arrow.Field("agent_id", new arrow.Utf8(), true),
20
+ // Operation tracking
21
+ new arrow.Field("operation_type", new arrow.Utf8(), false), // 'retain', 'recall', 'reflect'
22
+ new arrow.Field("yamo_text", new arrow.Utf8(), false), // Full YAMO block content
23
+ // Temporal
24
+ new arrow.Field("timestamp", new arrow.Timestamp(arrow.TimeUnit.MILLISECOND), false),
25
+ // Blockchain fields (optional, nullable) - for future anchoring
26
+ new arrow.Field("block_hash", new arrow.Utf8(), true), // Hash of this block
27
+ new arrow.Field("prev_hash", new arrow.Utf8(), true), // Hash of previous block (for chain)
28
+ // Metadata (JSON string for flexibility)
29
+ new arrow.Field("metadata", new arrow.Utf8(), true), // Additional metadata as JSON
30
+ ]);
31
+ }
32
+ /**
33
+ * Create YAMO blocks table in LanceDB
34
+ * Creates the table if it doesn't exist, opens it if it does
35
+ *
36
+ * @param {lancedb.Connection} db - LanceDB connection
37
+ * @param {string} [tableName='yamo_blocks'] - Name of the table
38
+ * @returns {Promise<lancedb.Table>} The created or opened table
39
+ * @throws {Error} If table creation fails
40
+ */
41
+ export async function createYamoTable(db, tableName = "yamo_blocks") {
42
+ try {
43
+ // Check if table already exists
44
+ const existingTables = await db.tableNames();
45
+ if (existingTables.includes(tableName)) {
46
+ // Table exists, open it
47
+ return await db.openTable(tableName);
48
+ }
49
+ // Create new table with YAMO schema
50
+ const schema = createYamoSchema();
51
+ const table = await db.createTable(tableName, [], { schema });
52
+ return table;
53
+ }
54
+ catch (error) {
55
+ const message = error instanceof Error ? error.message : String(error);
56
+ throw new Error(`Failed to create YAMO table '${tableName}': ${message}`);
57
+ }
58
+ }
59
+ /**
60
+ * Validate a YAMO block record before insertion
61
+ * Checks for required fields and valid values
62
+ */
63
+ export function validateYamoRecord(record) {
64
+ const errors = [];
65
+ // Check required fields
66
+ if (!record.id) {
67
+ errors.push("Missing required field: id");
68
+ }
69
+ if (!record.operation_type) {
70
+ errors.push("Missing required field: operation_type");
71
+ }
72
+ else {
73
+ // Validate operation_type is one of the allowed values
74
+ const validTypes = ["retain", "recall", "reflect"];
75
+ if (!validTypes.includes(record.operation_type)) {
76
+ errors.push(`Invalid operation_type: ${record.operation_type}. Must be one of: ${validTypes.join(", ")}`);
77
+ }
78
+ }
79
+ if (!record.yamo_text) {
80
+ errors.push("Missing required field: yamo_text");
81
+ }
82
+ else {
83
+ // Validate YAMO block format
84
+ const requiredSections = [
85
+ "agent:",
86
+ "intent:",
87
+ "context:",
88
+ "output:",
89
+ "log:",
90
+ ];
91
+ for (const section of requiredSections) {
92
+ if (!record.yamo_text.includes(section)) {
93
+ errors.push(`YAMO block missing required section: ${section}`);
94
+ }
95
+ }
96
+ }
97
+ return {
98
+ valid: errors.length === 0,
99
+ errors,
100
+ };
101
+ }
102
+ /**
103
+ * Generate a YAMO block ID
104
+ * Creates a unique ID for a YAMO block
105
+ *
106
+ * @param {string} operationType - Type of operation
107
+ * @returns {string} Generated YAMO block ID
108
+ */
109
+ export function generateYamoId(operationType) {
110
+ const timestamp = Date.now();
111
+ const random = Math.random().toString(36).substring(2, 10);
112
+ return `yamo_${operationType}_${timestamp}_${random}`;
113
+ }
114
+ /**
115
+ * Check if a table uses YAMO schema
116
+ * Detects if a table has the YAMO block schema structure
117
+ *
118
+ * @param {arrow.Schema} schema - Table schema to check
119
+ * @returns {boolean} True if YAMO schema detected
120
+ */
121
+ export function isYamoSchema(schema) {
122
+ // Check for unique YAMO fields
123
+ const hasYamoFields = schema.fields.some((f) => f.name === "operation_type" || f.name === "yamo_text");
124
+ return hasYamoFields;
125
+ }
126
+ // Export schema function as default for consistency with lancedb/schema.js
127
+ export default {
128
+ createYamoSchema,
129
+ createYamoTable,
130
+ validateYamoRecord,
131
+ generateYamoId,
132
+ isYamoSchema,
133
+ };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@yamo/memory-mesh",
3
- "version": "2.3.2",
4
- "description": "Portable semantic memory system with Layer 0 Scrubber for YAMO agents",
3
+ "version": "3.0.1",
4
+ "description": "Portable semantic memory system with Layer 0 Scrubber for YAMO agents (v3 Singularity Edition)",
5
5
  "type": "module",
6
6
  "main": "lib/memory/index.js",
7
- "types": "index.d.ts",
7
+ "types": "lib/memory/index.d.ts",
8
8
  "bin": {
9
9
  "memory-mesh": "./bin/memory_mesh.js",
10
10
  "memory-mesh-setup": "./bin/setup.js"
@@ -12,18 +12,23 @@
12
12
  "files": [
13
13
  "lib/",
14
14
  "bin/",
15
- "skills/",
16
- "index.d.ts"
15
+ "skills/"
17
16
  ],
18
17
  "scripts": {
19
- "test": "npm run type-check && node --test test/*.test.js",
20
- "type-check": "tsc --noEmit"
18
+ "build": "tsc",
19
+ "test": "npm run build && npx tsx --test test/**/*.test.ts",
20
+ "test:unit": "npx tsx --test test/unit/*.test.ts",
21
+ "test:e2e": "npm run build && npx tsx --test test/e2e/*.test.ts",
22
+ "type-check": "tsc --noEmit",
23
+ "prepublishOnly": "npm run build"
21
24
  },
22
25
  "dependencies": {
23
26
  "@lancedb/lancedb": "^0.23.0",
24
27
  "@xenova/transformers": "^2.17.0",
25
28
  "apache-arrow": "^17.0.0",
26
- "onnxruntime-node": "^1.18.0"
29
+ "onnxruntime-node": "^1.18.0",
30
+ "pino": "^10.3.1",
31
+ "pino-pretty": "^13.1.3"
27
32
  },
28
33
  "author": "Soverane Labs",
29
34
  "license": "MIT",
package/index.d.ts DELETED
@@ -1,111 +0,0 @@
1
- export declare class MemoryMesh {
2
- constructor();
3
- init(): Promise<void>;
4
- add(content: string, metadata?: Record<string, any>): Promise<{
5
- id: string;
6
- content: string;
7
- metadata: Record<string, any>;
8
- created_at: string;
9
- }>;
10
- addBatch(entries: Array<{
11
- content: string;
12
- metadata?: Record<string, any>;
13
- }>): Promise<{
14
- count: number;
15
- success: boolean;
16
- ids: string[];
17
- }>;
18
- search(query: string, options?: {
19
- limit?: number;
20
- filter?: string;
21
- useCache?: boolean;
22
- }): Promise<Array<{
23
- id: string;
24
- content: string;
25
- metadata: Record<string, any>;
26
- score: number;
27
- created_at: string;
28
- }>>;
29
- get(id: string): Promise<{
30
- id: string;
31
- content: string;
32
- metadata: Record<string, any>;
33
- created_at: string;
34
- updated_at: string;
35
- } | null>;
36
- getAll(options?: {
37
- limit?: number;
38
- }): Promise<Array<any>>;
39
- update(id: string, content: string, metadata?: Record<string, any>): Promise<{
40
- id: string;
41
- content: string;
42
- success: boolean;
43
- }>;
44
- delete(id: string): Promise<{
45
- deleted: string;
46
- success: boolean;
47
- }>;
48
- stats(): Promise<{
49
- count: number;
50
- tableName: string;
51
- uri: string;
52
- isConnected: boolean;
53
- embedding: any;
54
- }>;
55
- healthCheck(): Promise<{
56
- status: string;
57
- timestamp: string;
58
- checks: Record<string, any>;
59
- }>;
60
- }
61
-
62
- export declare class Scrubber {
63
- constructor(config?: ScrubberConfig);
64
- process(document: {
65
- content: string;
66
- source: string;
67
- type: 'html' | 'md' | 'txt';
68
- }): Promise<ScrubberResult>;
69
- }
70
-
71
- export interface ScrubberConfig {
72
- enabled?: boolean;
73
- structural?: {
74
- stripHTML?: boolean;
75
- normalizeMarkdown?: boolean;
76
- collapseWhitespace?: boolean;
77
- removeScripts?: boolean;
78
- removeStyles?: boolean;
79
- };
80
- semantic?: {
81
- removeDuplicates?: boolean;
82
- removeBoilerplate?: boolean;
83
- minSignalRatio?: number;
84
- };
85
- chunking?: {
86
- maxTokens?: number;
87
- minTokens?: number;
88
- splitOnHeadings?: boolean;
89
- };
90
- validation?: {
91
- enforceMinLength?: boolean;
92
- };
93
- }
94
-
95
- export interface ScrubberResult {
96
- chunks: Array<{
97
- text: string;
98
- metadata: Record<string, any>;
99
- }>;
100
- metadata: {
101
- source: string;
102
- type: string;
103
- processingTimestamp: string;
104
- };
105
- telemetry: {
106
- totalDuration: number;
107
- stages: Record<string, any>;
108
- };
109
- success: boolean;
110
- error?: string;
111
- }