@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
|
@@ -6,64 +6,72 @@
|
|
|
6
6
|
* error constructor.
|
|
7
7
|
*/
|
|
8
8
|
export declare class LanceDBError extends Error {
|
|
9
|
-
code:
|
|
10
|
-
details:
|
|
11
|
-
timestamp:
|
|
9
|
+
code: any;
|
|
10
|
+
details: any;
|
|
11
|
+
timestamp: any;
|
|
12
12
|
/**
|
|
13
13
|
* Create a new LanceDBError
|
|
14
14
|
* @param {string} message - Human-readable error message
|
|
15
15
|
* @param {string} code - Machine-readable error code (e.g., 'EMBEDDING_ERROR')
|
|
16
16
|
* @param {Object} details - Additional error context and metadata
|
|
17
17
|
*/
|
|
18
|
-
constructor(message:
|
|
18
|
+
constructor(message: any, code: any, details?: {});
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Error raised when embedding generation or comparison fails
|
|
22
22
|
*/
|
|
23
23
|
export declare class EmbeddingError extends LanceDBError {
|
|
24
|
-
constructor(message:
|
|
24
|
+
constructor(message: any, details: any);
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Error raised when storage operations (read/write/delete) fail
|
|
28
28
|
*/
|
|
29
29
|
export declare class StorageError extends LanceDBError {
|
|
30
|
-
constructor(message:
|
|
30
|
+
constructor(message: any, details: any);
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Error raised when database queries fail or return invalid results
|
|
34
34
|
*/
|
|
35
35
|
export declare class QueryError extends LanceDBError {
|
|
36
|
-
constructor(message:
|
|
36
|
+
constructor(message: any, details: any);
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Error raised when configuration is missing or invalid
|
|
40
40
|
*/
|
|
41
41
|
export declare class ConfigurationError extends LanceDBError {
|
|
42
|
-
constructor(message:
|
|
42
|
+
constructor(message: any, details: any);
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Sanitize error messages by redacting sensitive information
|
|
46
46
|
* @param {string} message - Error message to sanitize
|
|
47
47
|
* @returns {string} Sanitized error message
|
|
48
48
|
*/
|
|
49
|
-
export declare function sanitizeErrorMessage(message:
|
|
50
|
-
export interface ErrorResponse {
|
|
51
|
-
success: boolean;
|
|
52
|
-
error: {
|
|
53
|
-
code: string;
|
|
54
|
-
message: string;
|
|
55
|
-
details?: Record<string, any>;
|
|
56
|
-
context?: Record<string, any>;
|
|
57
|
-
stack?: string;
|
|
58
|
-
};
|
|
59
|
-
}
|
|
49
|
+
export declare function sanitizeErrorMessage(message: any): string;
|
|
60
50
|
/**
|
|
61
51
|
* Normalize errors into a consistent response format
|
|
62
52
|
* @param {Error} error - The error to handle
|
|
63
53
|
* @param {Object} context - Additional context about where/when the error occurred
|
|
64
54
|
* @returns {Object} Formatted error response with success: false
|
|
65
55
|
*/
|
|
66
|
-
export declare function handleError(error:
|
|
56
|
+
export declare function handleError(error: any, context?: {}): {
|
|
57
|
+
success: boolean;
|
|
58
|
+
error: {
|
|
59
|
+
code: any;
|
|
60
|
+
message: string;
|
|
61
|
+
details: any;
|
|
62
|
+
context: {};
|
|
63
|
+
stack?: undefined;
|
|
64
|
+
};
|
|
65
|
+
} | {
|
|
66
|
+
success: boolean;
|
|
67
|
+
error: {
|
|
68
|
+
code: string;
|
|
69
|
+
message: string;
|
|
70
|
+
stack: string;
|
|
71
|
+
context: {};
|
|
72
|
+
details?: undefined;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
67
75
|
declare const _default: {
|
|
68
76
|
LanceDBError: typeof LanceDBError;
|
|
69
77
|
EmbeddingError: typeof EmbeddingError;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
/**
|
|
2
3
|
* Custom error classes for LanceDB operations
|
|
3
4
|
*
|
|
@@ -6,161 +7,123 @@
|
|
|
6
7
|
* error constructor.
|
|
7
8
|
*/
|
|
8
9
|
export class LanceDBError extends Error {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// Capture stack trace for proper debugging (Node.js best practice)
|
|
31
|
-
// This ensures stack traces point to where the error was thrown,
|
|
32
|
-
// not to the error constructor itself
|
|
33
|
-
Error.captureStackTrace(this, this.constructor);
|
|
34
|
-
}
|
|
10
|
+
code;
|
|
11
|
+
details;
|
|
12
|
+
timestamp;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new LanceDBError
|
|
15
|
+
* @param {string} message - Human-readable error message
|
|
16
|
+
* @param {string} code - Machine-readable error code (e.g., 'EMBEDDING_ERROR')
|
|
17
|
+
* @param {Object} details - Additional error context and metadata
|
|
18
|
+
*/
|
|
19
|
+
constructor(message, code, details = {}) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = "LanceDBError";
|
|
22
|
+
this.code = code;
|
|
23
|
+
this.details = details;
|
|
24
|
+
this.timestamp = new Date().toISOString();
|
|
25
|
+
// Capture stack trace for proper debugging (Node.js best practice)
|
|
26
|
+
// This ensures stack traces point to where the error was thrown,
|
|
27
|
+
// not to the error constructor itself
|
|
28
|
+
Error.captureStackTrace(this, this.constructor);
|
|
29
|
+
}
|
|
35
30
|
}
|
|
36
|
-
|
|
37
31
|
/**
|
|
38
32
|
* Error raised when embedding generation or comparison fails
|
|
39
33
|
*/
|
|
40
34
|
export class EmbeddingError extends LanceDBError {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
constructor(message, details) {
|
|
36
|
+
super(message, "EMBEDDING_ERROR", details);
|
|
37
|
+
this.name = "EmbeddingError";
|
|
38
|
+
}
|
|
45
39
|
}
|
|
46
|
-
|
|
47
40
|
/**
|
|
48
41
|
* Error raised when storage operations (read/write/delete) fail
|
|
49
42
|
*/
|
|
50
43
|
export class StorageError extends LanceDBError {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
constructor(message, details) {
|
|
45
|
+
super(message, "STORAGE_ERROR", details);
|
|
46
|
+
this.name = "StorageError";
|
|
47
|
+
}
|
|
55
48
|
}
|
|
56
|
-
|
|
57
49
|
/**
|
|
58
50
|
* Error raised when database queries fail or return invalid results
|
|
59
51
|
*/
|
|
60
52
|
export class QueryError extends LanceDBError {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
constructor(message, details) {
|
|
54
|
+
super(message, "QUERY_ERROR", details);
|
|
55
|
+
this.name = "QueryError";
|
|
56
|
+
}
|
|
65
57
|
}
|
|
66
|
-
|
|
67
58
|
/**
|
|
68
59
|
* Error raised when configuration is missing or invalid
|
|
69
60
|
*/
|
|
70
61
|
export class ConfigurationError extends LanceDBError {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
constructor(message, details) {
|
|
63
|
+
super(message, "CONFIGURATION_ERROR", details);
|
|
64
|
+
this.name = "ConfigurationError";
|
|
65
|
+
}
|
|
75
66
|
}
|
|
76
|
-
|
|
77
67
|
/**
|
|
78
68
|
* Sanitize error messages by redacting sensitive information
|
|
79
69
|
* @param {string} message - Error message to sanitize
|
|
80
70
|
* @returns {string} Sanitized error message
|
|
81
71
|
*/
|
|
82
|
-
export function sanitizeErrorMessage(message
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
"
|
|
100
|
-
)
|
|
101
|
-
// Redact Authorization headers
|
|
102
|
-
.replace(/Authorization:\s*[^"\r\n]+/gi, "Authorization: [REDACTED]")
|
|
103
|
-
// Redact potential JWT tokens
|
|
104
|
-
.replace(
|
|
105
|
-
/eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*/g,
|
|
106
|
-
"[JWT_REDACTED]",
|
|
107
|
-
)
|
|
108
|
-
);
|
|
72
|
+
export function sanitizeErrorMessage(message) {
|
|
73
|
+
if (typeof message !== "string") {
|
|
74
|
+
return "[Non-string error message]";
|
|
75
|
+
}
|
|
76
|
+
// Redact common sensitive patterns
|
|
77
|
+
return (message
|
|
78
|
+
// Redact Bearer tokens
|
|
79
|
+
.replace(/Bearer\s+[A-Za-z0-9\-._~+/]+=*/gi, "Bearer [REDACTED]")
|
|
80
|
+
// Redact OpenAI API keys (sk- followed by 32+ chars)
|
|
81
|
+
.replace(/sk-[A-Za-z0-9]{32,}/g, "sk-[REDACTED]")
|
|
82
|
+
// Redact generic API keys (20+ alphanumeric chars after api_key)
|
|
83
|
+
.replace(/api_key["\s:]+[A-Za-z0-9]{20,}/gi, "api_key: [REDACTED]")
|
|
84
|
+
// Redact environment variable patterns that might contain secrets
|
|
85
|
+
.replace(/(OPENAI_API_KEY|ANTHROPIC_API_KEY|GOOGLE_API_KEY)["='\s]+[A-Za-z0-9\-_]+/gi, "$1=[REDACTED]")
|
|
86
|
+
// Redact Authorization headers
|
|
87
|
+
.replace(/Authorization:\s*[^"\r\n]+/gi, "Authorization: [REDACTED]")
|
|
88
|
+
// Redact potential JWT tokens
|
|
89
|
+
.replace(/eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*/g, "[JWT_REDACTED]"));
|
|
109
90
|
}
|
|
110
|
-
|
|
111
|
-
export interface ErrorResponse {
|
|
112
|
-
success: boolean;
|
|
113
|
-
error: {
|
|
114
|
-
code: string;
|
|
115
|
-
message: string;
|
|
116
|
-
details?: Record<string, any>;
|
|
117
|
-
context?: Record<string, any>;
|
|
118
|
-
stack?: string;
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
91
|
/**
|
|
123
92
|
* Normalize errors into a consistent response format
|
|
124
93
|
* @param {Error} error - The error to handle
|
|
125
94
|
* @param {Object} context - Additional context about where/when the error occurred
|
|
126
95
|
* @returns {Object} Formatted error response with success: false
|
|
127
96
|
*/
|
|
128
|
-
export function handleError(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
97
|
+
export function handleError(error, context = {}) {
|
|
98
|
+
if (error instanceof LanceDBError) {
|
|
99
|
+
return {
|
|
100
|
+
success: false,
|
|
101
|
+
error: {
|
|
102
|
+
code: error.code,
|
|
103
|
+
message: sanitizeErrorMessage(error.message),
|
|
104
|
+
details: error.details,
|
|
105
|
+
context,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
110
|
+
// Wrap unknown errors
|
|
133
111
|
return {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
112
|
+
success: false,
|
|
113
|
+
error: {
|
|
114
|
+
code: "UNKNOWN_ERROR",
|
|
115
|
+
message: sanitizeErrorMessage(err.message),
|
|
116
|
+
stack: process.env.NODE_ENV === "development" ? err.stack : undefined,
|
|
117
|
+
context,
|
|
118
|
+
},
|
|
141
119
|
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const err = error instanceof Error ? error : new Error(String(error));
|
|
145
|
-
|
|
146
|
-
// Wrap unknown errors
|
|
147
|
-
return {
|
|
148
|
-
success: false,
|
|
149
|
-
error: {
|
|
150
|
-
code: "UNKNOWN_ERROR",
|
|
151
|
-
message: sanitizeErrorMessage(err.message),
|
|
152
|
-
stack: process.env.NODE_ENV === "development" ? err.stack : undefined,
|
|
153
|
-
context,
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
120
|
}
|
|
157
|
-
|
|
158
121
|
export default {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
122
|
+
LanceDBError,
|
|
123
|
+
EmbeddingError,
|
|
124
|
+
StorageError,
|
|
125
|
+
QueryError,
|
|
126
|
+
ConfigurationError,
|
|
127
|
+
handleError,
|
|
128
|
+
sanitizeErrorMessage,
|
|
166
129
|
};
|
|
@@ -1,21 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MemoryContextManager - High-level memory management for YAMO
|
|
3
|
-
*/
|
|
4
|
-
import { MemoryMesh } from "./memory-mesh.js";
|
|
5
|
-
export interface MemoryContextConfig {
|
|
6
|
-
mesh?: MemoryMesh;
|
|
7
|
-
autoInit?: boolean;
|
|
8
|
-
enableCache?: boolean;
|
|
9
|
-
recallLimit?: number;
|
|
10
|
-
minImportance?: number;
|
|
11
|
-
silent?: boolean;
|
|
12
|
-
}
|
|
13
1
|
export declare class MemoryContextManager {
|
|
14
2
|
#private;
|
|
15
3
|
/**
|
|
16
4
|
* Create a new MemoryContextManager
|
|
17
5
|
*/
|
|
18
|
-
constructor(config?:
|
|
6
|
+
constructor(config?: {});
|
|
19
7
|
/**
|
|
20
8
|
* Initialize the memory context manager
|
|
21
9
|
*/
|
|
@@ -23,18 +11,27 @@ export declare class MemoryContextManager {
|
|
|
23
11
|
/**
|
|
24
12
|
* Capture an interaction as memory
|
|
25
13
|
*/
|
|
26
|
-
captureInteraction(prompt:
|
|
14
|
+
captureInteraction(prompt: any, response: any, context?: {}): Promise<any>;
|
|
27
15
|
/**
|
|
28
16
|
* Recall relevant memories for a query
|
|
29
17
|
*/
|
|
30
|
-
recallMemories(query:
|
|
18
|
+
recallMemories(query: any, options?: {}): Promise<any>;
|
|
31
19
|
/**
|
|
32
20
|
* Format memories for inclusion in prompt
|
|
33
21
|
*/
|
|
34
|
-
formatMemoriesForPrompt(memories: any
|
|
22
|
+
formatMemoriesForPrompt(memories: any, options?: {}): string;
|
|
35
23
|
clearCache(): void;
|
|
36
|
-
getCacheStats():
|
|
37
|
-
|
|
24
|
+
getCacheStats(): {
|
|
25
|
+
size: number;
|
|
26
|
+
maxSize: number;
|
|
27
|
+
ttlMs: number;
|
|
28
|
+
};
|
|
29
|
+
healthCheck(): Promise<{
|
|
30
|
+
status: string;
|
|
31
|
+
timestamp: string;
|
|
32
|
+
initialized: boolean;
|
|
33
|
+
checks: {};
|
|
34
|
+
}>;
|
|
38
35
|
/**
|
|
39
36
|
* Dispose of resources (cleanup timer and cache)
|
|
40
37
|
* Call this when the MemoryContextManager is no longer needed
|