@yamo/memory-mesh 3.0.0 → 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 (107) hide show
  1. package/README.md +8 -2
  2. package/lib/llm/client.d.ts +23 -48
  3. package/lib/llm/client.js +1 -0
  4. package/lib/llm/client.ts +298 -377
  5. package/lib/llm/index.js +1 -0
  6. package/lib/llm/index.ts +1 -2
  7. package/lib/memory/adapters/client.d.ts +22 -85
  8. package/lib/memory/adapters/client.js +1 -0
  9. package/lib/memory/adapters/client.ts +474 -633
  10. package/lib/memory/adapters/config.d.ts +82 -89
  11. package/lib/memory/adapters/config.js +1 -0
  12. package/lib/memory/adapters/config.ts +156 -225
  13. package/lib/memory/adapters/errors.d.ts +28 -20
  14. package/lib/memory/adapters/errors.js +1 -0
  15. package/lib/memory/adapters/errors.ts +83 -120
  16. package/lib/memory/context-manager.d.ts +15 -18
  17. package/lib/memory/context-manager.js +1 -0
  18. package/lib/memory/context-manager.ts +314 -401
  19. package/lib/memory/embeddings/factory.d.ts +18 -20
  20. package/lib/memory/embeddings/factory.js +1 -0
  21. package/lib/memory/embeddings/factory.ts +130 -173
  22. package/lib/memory/embeddings/index.js +1 -0
  23. package/lib/memory/embeddings/index.ts +1 -0
  24. package/lib/memory/embeddings/service.d.ts +36 -66
  25. package/lib/memory/embeddings/service.js +1 -0
  26. package/lib/memory/embeddings/service.ts +479 -616
  27. package/lib/memory/index.d.ts +2 -2
  28. package/lib/memory/index.js +1 -0
  29. package/lib/memory/index.ts +3 -13
  30. package/lib/memory/memory-mesh.d.ts +151 -93
  31. package/lib/memory/memory-mesh.js +1 -0
  32. package/lib/memory/memory-mesh.ts +1406 -1692
  33. package/lib/memory/memory-translator.d.ts +1 -6
  34. package/lib/memory/memory-translator.js +1 -0
  35. package/lib/memory/memory-translator.ts +96 -128
  36. package/lib/memory/schema.d.ts +29 -10
  37. package/lib/memory/schema.js +1 -0
  38. package/lib/memory/schema.ts +102 -185
  39. package/lib/memory/scorer.d.ts +3 -4
  40. package/lib/memory/scorer.js +1 -0
  41. package/lib/memory/scorer.ts +69 -86
  42. package/lib/memory/search/index.js +1 -0
  43. package/lib/memory/search/index.ts +1 -0
  44. package/lib/memory/search/keyword-search.d.ts +10 -26
  45. package/lib/memory/search/keyword-search.js +1 -0
  46. package/lib/memory/search/keyword-search.ts +123 -161
  47. package/lib/scrubber/config/defaults.d.ts +39 -46
  48. package/lib/scrubber/config/defaults.js +1 -0
  49. package/lib/scrubber/config/defaults.ts +50 -112
  50. package/lib/scrubber/errors/scrubber-error.d.ts +22 -0
  51. package/lib/scrubber/errors/scrubber-error.js +39 -0
  52. package/lib/scrubber/errors/scrubber-error.ts +44 -0
  53. package/lib/scrubber/index.d.ts +0 -1
  54. package/lib/scrubber/index.js +1 -0
  55. package/lib/scrubber/index.ts +1 -2
  56. package/lib/scrubber/scrubber.d.ts +14 -31
  57. package/lib/scrubber/scrubber.js +1 -0
  58. package/lib/scrubber/scrubber.ts +93 -152
  59. package/lib/scrubber/stages/chunker.d.ts +22 -10
  60. package/lib/scrubber/stages/chunker.js +86 -0
  61. package/lib/scrubber/stages/chunker.ts +104 -0
  62. package/lib/scrubber/stages/metadata-annotator.d.ts +14 -15
  63. package/lib/scrubber/stages/metadata-annotator.js +64 -0
  64. package/lib/scrubber/stages/metadata-annotator.ts +75 -0
  65. package/lib/scrubber/stages/normalizer.d.ts +13 -10
  66. package/lib/scrubber/stages/normalizer.js +51 -0
  67. package/lib/scrubber/stages/normalizer.ts +60 -0
  68. package/lib/scrubber/stages/semantic-filter.d.ts +13 -10
  69. package/lib/scrubber/stages/semantic-filter.js +51 -0
  70. package/lib/scrubber/stages/semantic-filter.ts +62 -0
  71. package/lib/scrubber/stages/structural-cleaner.d.ts +15 -10
  72. package/lib/scrubber/stages/structural-cleaner.js +73 -0
  73. package/lib/scrubber/stages/structural-cleaner.ts +83 -0
  74. package/lib/scrubber/stages/validator.d.ts +14 -15
  75. package/lib/scrubber/stages/validator.js +56 -0
  76. package/lib/scrubber/stages/validator.ts +67 -0
  77. package/lib/scrubber/telemetry.d.ts +20 -27
  78. package/lib/scrubber/telemetry.js +1 -0
  79. package/lib/scrubber/telemetry.ts +53 -90
  80. package/lib/scrubber/utils/hash.d.ts +14 -0
  81. package/lib/scrubber/utils/hash.js +37 -0
  82. package/lib/scrubber/utils/hash.ts +40 -0
  83. package/lib/scrubber/utils/html-parser.d.ts +14 -0
  84. package/lib/scrubber/utils/html-parser.js +38 -0
  85. package/lib/scrubber/utils/html-parser.ts +46 -0
  86. package/lib/scrubber/utils/pattern-matcher.d.ts +12 -0
  87. package/lib/scrubber/utils/pattern-matcher.js +54 -0
  88. package/lib/scrubber/utils/pattern-matcher.ts +64 -0
  89. package/lib/scrubber/utils/token-counter.d.ts +18 -0
  90. package/lib/scrubber/utils/token-counter.js +30 -0
  91. package/lib/scrubber/utils/token-counter.ts +32 -0
  92. package/lib/utils/logger.d.ts +1 -11
  93. package/lib/utils/logger.js +1 -0
  94. package/lib/utils/logger.ts +43 -63
  95. package/lib/utils/skill-metadata.d.ts +6 -14
  96. package/lib/utils/skill-metadata.js +1 -0
  97. package/lib/utils/skill-metadata.ts +89 -103
  98. package/lib/yamo/emitter.d.ts +8 -35
  99. package/lib/yamo/emitter.js +1 -0
  100. package/lib/yamo/emitter.ts +77 -155
  101. package/lib/yamo/index.d.ts +14 -0
  102. package/lib/yamo/index.js +14 -0
  103. package/lib/yamo/index.ts +16 -0
  104. package/lib/yamo/schema.d.ts +8 -10
  105. package/lib/yamo/schema.js +1 -0
  106. package/lib/yamo/schema.ts +82 -114
  107. package/package.json +4 -2
@@ -6,64 +6,72 @@
6
6
  * error constructor.
7
7
  */
8
8
  export declare class LanceDBError extends Error {
9
- code: string;
10
- details: Record<string, any>;
11
- timestamp: string;
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: string, code: string, details?: Record<string, any>);
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: string, details?: Record<string, any>);
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: string, details?: Record<string, any>);
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: string, details?: Record<string, any>);
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: string, details?: Record<string, any>);
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: unknown): string;
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: unknown, context?: Record<string, any>): ErrorResponse;
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
  *
@@ -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
- code: string;
10
- details: Record<string, any>;
11
- timestamp: string;
12
-
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(
20
- message: string,
21
- code: string,
22
- details: Record<string, any> = {},
23
- ) {
24
- super(message);
25
- this.name = "LanceDBError";
26
- this.code = code;
27
- this.details = details;
28
- this.timestamp = new Date().toISOString();
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
- constructor(message: string, details?: Record<string, any>) {
42
- super(message, "EMBEDDING_ERROR", details);
43
- this.name = "EmbeddingError";
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
- constructor(message: string, details?: Record<string, any>) {
52
- super(message, "STORAGE_ERROR", details);
53
- this.name = "StorageError";
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
- constructor(message: string, details?: Record<string, any>) {
62
- super(message, "QUERY_ERROR", details);
63
- this.name = "QueryError";
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
- constructor(message: string, details?: Record<string, any>) {
72
- super(message, "CONFIGURATION_ERROR", details);
73
- this.name = "ConfigurationError";
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: unknown): string {
83
- if (typeof message !== "string") {
84
- return "[Non-string error message]";
85
- }
86
-
87
- // Redact common sensitive patterns
88
- return (
89
- message
90
- // Redact Bearer tokens
91
- .replace(/Bearer\s+[A-Za-z0-9\-._~+/]+=*/gi, "Bearer [REDACTED]")
92
- // Redact OpenAI API keys (sk- followed by 32+ chars)
93
- .replace(/sk-[A-Za-z0-9]{32,}/g, "sk-[REDACTED]")
94
- // Redact generic API keys (20+ alphanumeric chars after api_key)
95
- .replace(/api_key["\s:]+[A-Za-z0-9]{20,}/gi, "api_key: [REDACTED]")
96
- // Redact environment variable patterns that might contain secrets
97
- .replace(
98
- /(OPENAI_API_KEY|ANTHROPIC_API_KEY|GOOGLE_API_KEY)["='\s]+[A-Za-z0-9\-_]+/gi,
99
- "$1=[REDACTED]",
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
- error: unknown,
130
- context: Record<string, any> = {},
131
- ): ErrorResponse {
132
- if (error instanceof LanceDBError) {
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
- success: false,
135
- error: {
136
- code: error.code,
137
- message: sanitizeErrorMessage(error.message),
138
- details: error.details,
139
- context,
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
- LanceDBError,
160
- EmbeddingError,
161
- StorageError,
162
- QueryError,
163
- ConfigurationError,
164
- handleError,
165
- sanitizeErrorMessage,
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?: MemoryContextConfig);
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: string, response: string, context?: any): Promise<any>;
14
+ captureInteraction(prompt: any, response: any, context?: {}): Promise<any>;
27
15
  /**
28
16
  * Recall relevant memories for a query
29
17
  */
30
- recallMemories(query: string, options?: any): Promise<any[]>;
18
+ recallMemories(query: any, options?: {}): Promise<any>;
31
19
  /**
32
20
  * Format memories for inclusion in prompt
33
21
  */
34
- formatMemoriesForPrompt(memories: any[], options?: any): string;
22
+ formatMemoriesForPrompt(memories: any, options?: {}): string;
35
23
  clearCache(): void;
36
- getCacheStats(): any;
37
- healthCheck(): Promise<any>;
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
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  /**
2
3
  * MemoryContextManager - High-level memory management for YAMO
3
4
  */