@yamo/memory-mesh 2.3.2 → 3.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.
- package/bin/memory_mesh.js +1 -1
- package/lib/llm/client.d.ts +111 -0
- package/lib/llm/client.js +299 -357
- package/lib/llm/client.ts +413 -0
- package/lib/llm/index.d.ts +17 -0
- package/lib/llm/index.js +15 -8
- package/lib/llm/index.ts +19 -0
- package/lib/memory/adapters/client.d.ts +183 -0
- package/lib/memory/adapters/client.js +518 -0
- package/lib/memory/adapters/client.ts +678 -0
- package/lib/memory/adapters/config.d.ts +137 -0
- package/lib/memory/adapters/config.js +189 -0
- package/lib/memory/adapters/config.ts +259 -0
- package/lib/memory/adapters/errors.d.ts +76 -0
- package/lib/memory/adapters/errors.js +128 -0
- package/lib/memory/adapters/errors.ts +166 -0
- package/lib/memory/context-manager.d.ts +44 -0
- package/lib/memory/context-manager.js +344 -0
- package/lib/memory/context-manager.ts +432 -0
- package/lib/memory/embeddings/factory.d.ts +59 -0
- package/lib/memory/embeddings/factory.js +148 -0
- package/lib/{embeddings/factory.js → memory/embeddings/factory.ts} +69 -28
- package/lib/memory/embeddings/index.d.ts +2 -0
- package/lib/memory/embeddings/index.js +2 -0
- package/lib/memory/embeddings/index.ts +2 -0
- package/lib/memory/embeddings/service.d.ts +164 -0
- package/lib/memory/embeddings/service.js +515 -0
- package/lib/{embeddings/service.js → memory/embeddings/service.ts} +223 -156
- package/lib/memory/index.d.ts +9 -0
- package/lib/memory/index.js +9 -1
- package/lib/memory/index.ts +20 -0
- package/lib/memory/memory-mesh.d.ts +274 -0
- package/lib/memory/memory-mesh.js +1469 -678
- package/lib/memory/memory-mesh.ts +1803 -0
- package/lib/memory/memory-translator.d.ts +19 -0
- package/lib/memory/memory-translator.js +125 -0
- package/lib/memory/memory-translator.ts +158 -0
- package/lib/memory/schema.d.ts +111 -0
- package/lib/memory/schema.js +183 -0
- package/lib/memory/schema.ts +267 -0
- package/lib/memory/scorer.d.ts +26 -0
- package/lib/memory/scorer.js +77 -0
- package/lib/memory/scorer.ts +95 -0
- package/lib/memory/search/index.d.ts +1 -0
- package/lib/memory/search/index.js +1 -0
- package/lib/memory/search/index.ts +1 -0
- package/lib/memory/search/keyword-search.d.ts +62 -0
- package/lib/memory/search/keyword-search.js +135 -0
- package/lib/{search/keyword-search.js → memory/search/keyword-search.ts} +66 -36
- package/lib/scrubber/config/defaults.d.ts +53 -0
- package/lib/scrubber/config/defaults.js +49 -57
- package/lib/scrubber/config/defaults.ts +117 -0
- package/lib/scrubber/index.d.ts +6 -0
- package/lib/scrubber/index.js +3 -23
- package/lib/scrubber/index.ts +7 -0
- package/lib/scrubber/scrubber.d.ts +61 -0
- package/lib/scrubber/scrubber.js +99 -121
- package/lib/scrubber/scrubber.ts +168 -0
- package/lib/scrubber/stages/chunker.d.ts +13 -0
- package/lib/scrubber/stages/metadata-annotator.d.ts +18 -0
- package/lib/scrubber/stages/normalizer.d.ts +13 -0
- package/lib/scrubber/stages/semantic-filter.d.ts +13 -0
- package/lib/scrubber/stages/structural-cleaner.d.ts +13 -0
- package/lib/scrubber/stages/validator.d.ts +18 -0
- package/lib/scrubber/telemetry.d.ts +36 -0
- package/lib/scrubber/telemetry.js +53 -58
- package/lib/scrubber/telemetry.ts +99 -0
- package/lib/utils/logger.d.ts +29 -0
- package/lib/utils/logger.js +64 -0
- package/lib/utils/logger.ts +85 -0
- package/lib/utils/skill-metadata.d.ts +32 -0
- package/lib/utils/skill-metadata.js +132 -0
- package/lib/utils/skill-metadata.ts +147 -0
- package/lib/yamo/emitter.d.ts +73 -0
- package/lib/yamo/emitter.js +78 -143
- package/lib/yamo/emitter.ts +249 -0
- package/lib/yamo/schema.d.ts +58 -0
- package/lib/yamo/schema.js +81 -108
- package/lib/yamo/schema.ts +165 -0
- package/package.json +11 -8
- package/index.d.ts +0 -111
- package/lib/embeddings/index.js +0 -2
- package/lib/index.js +0 -6
- package/lib/lancedb/client.js +0 -633
- package/lib/lancedb/config.js +0 -215
- package/lib/lancedb/errors.js +0 -144
- package/lib/lancedb/index.js +0 -4
- package/lib/lancedb/schema.js +0 -217
- package/lib/scrubber/errors/scrubber-error.js +0 -43
- package/lib/scrubber/stages/chunker.js +0 -103
- package/lib/scrubber/stages/metadata-annotator.js +0 -74
- package/lib/scrubber/stages/normalizer.js +0 -59
- package/lib/scrubber/stages/semantic-filter.js +0 -61
- package/lib/scrubber/stages/structural-cleaner.js +0 -82
- package/lib/scrubber/stages/validator.js +0 -66
- package/lib/scrubber/utils/hash.js +0 -39
- package/lib/scrubber/utils/html-parser.js +0 -45
- package/lib/scrubber/utils/pattern-matcher.js +0 -63
- package/lib/scrubber/utils/token-counter.js +0 -31
- package/lib/search/index.js +0 -1
- package/lib/utils/index.js +0 -1
- package/lib/yamo/index.js +0 -15
package/lib/yamo/schema.js
CHANGED
|
@@ -5,121 +5,99 @@
|
|
|
5
5
|
* Provides schema and table creation for YAMO block persistence.
|
|
6
6
|
* YAMO blocks provide audit trail for all memory operations.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
8
|
import * as arrow from "apache-arrow";
|
|
10
|
-
|
|
11
9
|
/**
|
|
12
10
|
* Create YAMO blocks table schema
|
|
13
11
|
* 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
|
|
12
|
+
* @returns {arrow.Schema} Arrow schema for YAMO blocks
|
|
23
13
|
*/
|
|
24
14
|
export function createYamoSchema() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// Metadata (JSON string for flexibility)
|
|
42
|
-
new arrow.Field('metadata', new arrow.Utf8(), true), // Additional metadata as JSON
|
|
43
|
-
]);
|
|
15
|
+
return new arrow.Schema([
|
|
16
|
+
// Core identifiers
|
|
17
|
+
new arrow.Field("id", new arrow.Utf8(), false),
|
|
18
|
+
new arrow.Field("agent_id", new arrow.Utf8(), true),
|
|
19
|
+
// Operation tracking
|
|
20
|
+
new arrow.Field("operation_type", new arrow.Utf8(), false), // 'retain', 'recall', 'reflect'
|
|
21
|
+
new arrow.Field("yamo_text", new arrow.Utf8(), false), // Full YAMO block content
|
|
22
|
+
// Temporal
|
|
23
|
+
new arrow.Field("timestamp", new arrow.Timestamp(arrow.TimeUnit.MILLISECOND), false),
|
|
24
|
+
// Blockchain fields (optional, nullable) - for future anchoring
|
|
25
|
+
new arrow.Field("block_hash", new arrow.Utf8(), true), // Hash of this block
|
|
26
|
+
new arrow.Field("prev_hash", new arrow.Utf8(), true), // Hash of previous block (for chain)
|
|
27
|
+
// Metadata (JSON string for flexibility)
|
|
28
|
+
new arrow.Field("metadata", new arrow.Utf8(), true), // Additional metadata as JSON
|
|
29
|
+
]);
|
|
44
30
|
}
|
|
45
|
-
|
|
46
31
|
/**
|
|
47
32
|
* Create YAMO blocks table in LanceDB
|
|
48
33
|
* Creates the table if it doesn't exist, opens it if it does
|
|
49
34
|
*
|
|
50
|
-
* @param {
|
|
35
|
+
* @param {lancedb.Connection} db - LanceDB connection
|
|
51
36
|
* @param {string} [tableName='yamo_blocks'] - Name of the table
|
|
52
|
-
* @returns {Promise<
|
|
37
|
+
* @returns {Promise<lancedb.Table>} The created or opened table
|
|
53
38
|
* @throws {Error} If table creation fails
|
|
54
39
|
*/
|
|
55
|
-
export async function createYamoTable(db, tableName =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
40
|
+
export async function createYamoTable(db, tableName = "yamo_blocks") {
|
|
41
|
+
try {
|
|
42
|
+
// Check if table already exists
|
|
43
|
+
const existingTables = await db.tableNames();
|
|
44
|
+
if (existingTables.includes(tableName)) {
|
|
45
|
+
// Table exists, open it
|
|
46
|
+
return await db.openTable(tableName);
|
|
47
|
+
}
|
|
48
|
+
// Create new table with YAMO schema
|
|
49
|
+
const schema = createYamoSchema();
|
|
50
|
+
const table = await db.createTable(tableName, [], { schema });
|
|
51
|
+
return table;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
55
|
+
throw new Error(`Failed to create YAMO table '${tableName}': ${message}`);
|
|
63
56
|
}
|
|
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
57
|
}
|
|
76
|
-
|
|
77
58
|
/**
|
|
78
59
|
* Validate a YAMO block record before insertion
|
|
79
60
|
* 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
61
|
*/
|
|
87
62
|
export function validateYamoRecord(record) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
63
|
+
const errors = [];
|
|
64
|
+
// Check required fields
|
|
65
|
+
if (!record.id) {
|
|
66
|
+
errors.push("Missing required field: id");
|
|
67
|
+
}
|
|
68
|
+
if (!record.operation_type) {
|
|
69
|
+
errors.push("Missing required field: operation_type");
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// Validate operation_type is one of the allowed values
|
|
73
|
+
const validTypes = ["retain", "recall", "reflect"];
|
|
74
|
+
if (!validTypes.includes(record.operation_type)) {
|
|
75
|
+
errors.push(`Invalid operation_type: ${record.operation_type}. Must be one of: ${validTypes.join(", ")}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (!record.yamo_text) {
|
|
79
|
+
errors.push("Missing required field: yamo_text");
|
|
102
80
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
81
|
+
else {
|
|
82
|
+
// Validate YAMO block format
|
|
83
|
+
const requiredSections = [
|
|
84
|
+
"agent:",
|
|
85
|
+
"intent:",
|
|
86
|
+
"context:",
|
|
87
|
+
"output:",
|
|
88
|
+
"log:",
|
|
89
|
+
];
|
|
90
|
+
for (const section of requiredSections) {
|
|
91
|
+
if (!record.yamo_text.includes(section)) {
|
|
92
|
+
errors.push(`YAMO block missing required section: ${section}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
114
95
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
errors
|
|
120
|
-
};
|
|
96
|
+
return {
|
|
97
|
+
valid: errors.length === 0,
|
|
98
|
+
errors,
|
|
99
|
+
};
|
|
121
100
|
}
|
|
122
|
-
|
|
123
101
|
/**
|
|
124
102
|
* Generate a YAMO block ID
|
|
125
103
|
* Creates a unique ID for a YAMO block
|
|
@@ -128,32 +106,27 @@ export function validateYamoRecord(record) {
|
|
|
128
106
|
* @returns {string} Generated YAMO block ID
|
|
129
107
|
*/
|
|
130
108
|
export function generateYamoId(operationType) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
109
|
+
const timestamp = Date.now();
|
|
110
|
+
const random = Math.random().toString(36).substring(2, 10);
|
|
111
|
+
return `yamo_${operationType}_${timestamp}_${random}`;
|
|
134
112
|
}
|
|
135
|
-
|
|
136
113
|
/**
|
|
137
114
|
* Check if a table uses YAMO schema
|
|
138
115
|
* Detects if a table has the YAMO block schema structure
|
|
139
116
|
*
|
|
140
|
-
* @param {
|
|
117
|
+
* @param {arrow.Schema} schema - Table schema to check
|
|
141
118
|
* @returns {boolean} True if YAMO schema detected
|
|
142
119
|
*/
|
|
143
120
|
export function isYamoSchema(schema) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
return hasYamoFields;
|
|
121
|
+
// Check for unique YAMO fields
|
|
122
|
+
const hasYamoFields = schema.fields.some((f) => f.name === "operation_type" || f.name === "yamo_text");
|
|
123
|
+
return hasYamoFields;
|
|
150
124
|
}
|
|
151
|
-
|
|
152
125
|
// Export schema function as default for consistency with lancedb/schema.js
|
|
153
126
|
export default {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
127
|
+
createYamoSchema,
|
|
128
|
+
createYamoTable,
|
|
129
|
+
validateYamoRecord,
|
|
130
|
+
generateYamoId,
|
|
131
|
+
isYamoSchema,
|
|
159
132
|
};
|
|
@@ -0,0 +1,165 @@
|
|
|
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
|
+
|
|
9
|
+
import * as arrow from "apache-arrow";
|
|
10
|
+
import * as lancedb from "@lancedb/lancedb";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Create YAMO blocks table schema
|
|
14
|
+
* Defines the structure for storing YAMO protocol blocks
|
|
15
|
+
* @returns {arrow.Schema} Arrow schema for YAMO blocks
|
|
16
|
+
*/
|
|
17
|
+
export function createYamoSchema(): arrow.Schema {
|
|
18
|
+
return new arrow.Schema([
|
|
19
|
+
// Core identifiers
|
|
20
|
+
new arrow.Field("id", new arrow.Utf8(), false),
|
|
21
|
+
new arrow.Field("agent_id", new arrow.Utf8(), true),
|
|
22
|
+
|
|
23
|
+
// Operation tracking
|
|
24
|
+
new arrow.Field("operation_type", new arrow.Utf8(), false), // 'retain', 'recall', 'reflect'
|
|
25
|
+
new arrow.Field("yamo_text", new arrow.Utf8(), false), // Full YAMO block content
|
|
26
|
+
|
|
27
|
+
// Temporal
|
|
28
|
+
new arrow.Field(
|
|
29
|
+
"timestamp",
|
|
30
|
+
new arrow.Timestamp(arrow.TimeUnit.MILLISECOND),
|
|
31
|
+
false,
|
|
32
|
+
),
|
|
33
|
+
|
|
34
|
+
// Blockchain fields (optional, nullable) - for future anchoring
|
|
35
|
+
new arrow.Field("block_hash", new arrow.Utf8(), true), // Hash of this block
|
|
36
|
+
new arrow.Field("prev_hash", new arrow.Utf8(), true), // Hash of previous block (for chain)
|
|
37
|
+
|
|
38
|
+
// Metadata (JSON string for flexibility)
|
|
39
|
+
new arrow.Field("metadata", new arrow.Utf8(), true), // Additional metadata as JSON
|
|
40
|
+
]);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Create YAMO blocks table in LanceDB
|
|
45
|
+
* Creates the table if it doesn't exist, opens it if it does
|
|
46
|
+
*
|
|
47
|
+
* @param {lancedb.Connection} db - LanceDB connection
|
|
48
|
+
* @param {string} [tableName='yamo_blocks'] - Name of the table
|
|
49
|
+
* @returns {Promise<lancedb.Table>} The created or opened table
|
|
50
|
+
* @throws {Error} If table creation fails
|
|
51
|
+
*/
|
|
52
|
+
export async function createYamoTable(
|
|
53
|
+
db: lancedb.Connection,
|
|
54
|
+
tableName: string = "yamo_blocks",
|
|
55
|
+
): Promise<lancedb.Table> {
|
|
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);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Create new table with YAMO schema
|
|
66
|
+
const schema = createYamoSchema();
|
|
67
|
+
const table = await db.createTable(tableName, [], { schema } as any);
|
|
68
|
+
|
|
69
|
+
return table;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
72
|
+
throw new Error(`Failed to create YAMO table '${tableName}': ${message}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface YamoRecordValidationResult {
|
|
77
|
+
valid: boolean;
|
|
78
|
+
errors: string[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Validate a YAMO block record before insertion
|
|
83
|
+
* Checks for required fields and valid values
|
|
84
|
+
*/
|
|
85
|
+
export function validateYamoRecord(record: any): YamoRecordValidationResult {
|
|
86
|
+
const errors: string[] = [];
|
|
87
|
+
|
|
88
|
+
// Check required fields
|
|
89
|
+
if (!record.id) {
|
|
90
|
+
errors.push("Missing required field: id");
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (!record.operation_type) {
|
|
94
|
+
errors.push("Missing required field: operation_type");
|
|
95
|
+
} else {
|
|
96
|
+
// Validate operation_type is one of the allowed values
|
|
97
|
+
const validTypes = ["retain", "recall", "reflect"];
|
|
98
|
+
if (!validTypes.includes(record.operation_type)) {
|
|
99
|
+
errors.push(
|
|
100
|
+
`Invalid operation_type: ${record.operation_type}. Must be one of: ${validTypes.join(", ")}`,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
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 = [
|
|
110
|
+
"agent:",
|
|
111
|
+
"intent:",
|
|
112
|
+
"context:",
|
|
113
|
+
"output:",
|
|
114
|
+
"log:",
|
|
115
|
+
];
|
|
116
|
+
for (const section of requiredSections) {
|
|
117
|
+
if (!record.yamo_text.includes(section)) {
|
|
118
|
+
errors.push(`YAMO block missing required section: ${section}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
valid: errors.length === 0,
|
|
125
|
+
errors,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Generate a YAMO block ID
|
|
131
|
+
* Creates a unique ID for a YAMO block
|
|
132
|
+
*
|
|
133
|
+
* @param {string} operationType - Type of operation
|
|
134
|
+
* @returns {string} Generated YAMO block ID
|
|
135
|
+
*/
|
|
136
|
+
export function generateYamoId(operationType: string): string {
|
|
137
|
+
const timestamp = Date.now();
|
|
138
|
+
const random = Math.random().toString(36).substring(2, 10);
|
|
139
|
+
return `yamo_${operationType}_${timestamp}_${random}`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Check if a table uses YAMO schema
|
|
144
|
+
* Detects if a table has the YAMO block schema structure
|
|
145
|
+
*
|
|
146
|
+
* @param {arrow.Schema} schema - Table schema to check
|
|
147
|
+
* @returns {boolean} True if YAMO schema detected
|
|
148
|
+
*/
|
|
149
|
+
export function isYamoSchema(schema: arrow.Schema): boolean {
|
|
150
|
+
// Check for unique YAMO fields
|
|
151
|
+
const hasYamoFields = schema.fields.some(
|
|
152
|
+
(f) => f.name === "operation_type" || f.name === "yamo_text",
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
return hasYamoFields;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Export schema function as default for consistency with lancedb/schema.js
|
|
159
|
+
export default {
|
|
160
|
+
createYamoSchema,
|
|
161
|
+
createYamoTable,
|
|
162
|
+
validateYamoRecord,
|
|
163
|
+
generateYamoId,
|
|
164
|
+
isYamoSchema,
|
|
165
|
+
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yamo/memory-mesh",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Portable semantic memory system with Layer 0 Scrubber for YAMO agents",
|
|
3
|
+
"version": "3.0.0",
|
|
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,21 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
"lib/",
|
|
14
14
|
"bin/",
|
|
15
|
-
"skills/"
|
|
16
|
-
"index.d.ts"
|
|
15
|
+
"skills/"
|
|
17
16
|
],
|
|
18
17
|
"scripts": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"test": "npm run build && node --test test/*.test.js",
|
|
20
|
+
"type-check": "tsc --noEmit",
|
|
21
|
+
"prepublishOnly": "npm run build"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
24
|
"@lancedb/lancedb": "^0.23.0",
|
|
24
25
|
"@xenova/transformers": "^2.17.0",
|
|
25
26
|
"apache-arrow": "^17.0.0",
|
|
26
|
-
"onnxruntime-node": "^1.18.0"
|
|
27
|
+
"onnxruntime-node": "^1.18.0",
|
|
28
|
+
"pino": "^10.3.1",
|
|
29
|
+
"pino-pretty": "^13.1.3"
|
|
27
30
|
},
|
|
28
31
|
"author": "Soverane Labs",
|
|
29
32
|
"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
|
-
}
|
package/lib/embeddings/index.js
DELETED