@dollhousemcp/mcp-server 1.8.0 → 1.9.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/CHANGELOG.md +118 -0
- package/README.github.md +126 -8
- package/README.md +1 -1
- package/README.md.backup +50 -795
- package/README.npm.md +1 -1
- package/dist/collection/CollectionBrowser.d.ts.map +1 -1
- package/dist/collection/CollectionBrowser.js +6 -5
- package/dist/config/ConfigWizardDisplay.d.ts +64 -0
- package/dist/config/ConfigWizardDisplay.d.ts.map +1 -0
- package/dist/config/ConfigWizardDisplay.js +150 -0
- package/dist/config/WizardFirstResponse.d.ts +25 -0
- package/dist/config/WizardFirstResponse.d.ts.map +1 -0
- package/dist/config/WizardFirstResponse.js +118 -0
- package/dist/elements/memories/Memory.d.ts +190 -0
- package/dist/elements/memories/Memory.d.ts.map +1 -0
- package/dist/elements/memories/Memory.js +627 -0
- package/dist/elements/memories/MemoryManager.d.ts +136 -0
- package/dist/elements/memories/MemoryManager.d.ts.map +1 -0
- package/dist/elements/memories/MemoryManager.js +607 -0
- package/dist/elements/memories/MemorySearchIndex.d.ts +156 -0
- package/dist/elements/memories/MemorySearchIndex.d.ts.map +1 -0
- package/dist/elements/memories/MemorySearchIndex.js +690 -0
- package/dist/elements/memories/constants.d.ts +95 -0
- package/dist/elements/memories/constants.d.ts.map +1 -0
- package/dist/elements/memories/constants.js +102 -0
- package/dist/elements/memories/index.d.ts +7 -0
- package/dist/elements/memories/index.d.ts.map +1 -0
- package/dist/elements/memories/index.js +7 -0
- package/dist/elements/memories/utils.d.ts +68 -0
- package/dist/elements/memories/utils.d.ts.map +1 -0
- package/dist/elements/memories/utils.js +137 -0
- package/dist/generated/version.d.ts +2 -2
- package/dist/generated/version.js +3 -3
- package/dist/scripts/scripts/run-config-wizard.js +57 -0
- package/dist/scripts/src/config/ConfigManager.js +799 -0
- package/dist/scripts/src/config/ConfigWizard.js +368 -0
- package/dist/scripts/src/errors/SecurityError.js +47 -0
- package/dist/scripts/src/security/constants.js +28 -0
- package/dist/scripts/src/security/contentValidator.js +415 -0
- package/dist/scripts/src/security/errors.js +32 -0
- package/dist/scripts/src/security/regexValidator.js +217 -0
- package/dist/scripts/src/security/secureYamlParser.js +272 -0
- package/dist/scripts/src/security/securityMonitor.js +111 -0
- package/dist/scripts/src/security/validators/unicodeValidator.js +315 -0
- package/dist/scripts/src/utils/logger.js +288 -0
- package/dist/security/audit/SecurityAuditor.d.ts.map +1 -1
- package/dist/security/audit/SecurityAuditor.js +24 -2
- package/dist/security/audit/config/suppressions.d.ts.map +1 -1
- package/dist/security/audit/config/suppressions.js +91 -1
- package/dist/security/securityMonitor.d.ts +1 -1
- package/dist/security/securityMonitor.d.ts.map +1 -1
- package/dist/security/securityMonitor.js +1 -1
- package/dist/tools/getWelcomeMessage.d.ts +41 -0
- package/dist/tools/getWelcomeMessage.d.ts.map +1 -0
- package/dist/tools/getWelcomeMessage.js +109 -0
- package/package.json +1 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Element - Persistent context storage for continuity and learning
|
|
3
|
+
*
|
|
4
|
+
* Provides multiple storage backends, retention policies, and search capabilities
|
|
5
|
+
* for maintaining context across sessions and interactions.
|
|
6
|
+
*
|
|
7
|
+
* SECURITY MEASURES IMPLEMENTED:
|
|
8
|
+
* 1. Input sanitization for all memory content
|
|
9
|
+
* 2. Memory size limits to prevent unbounded growth
|
|
10
|
+
* 3. Path validation for file-based storage
|
|
11
|
+
* 4. Retention policy enforcement
|
|
12
|
+
* 5. Privacy level access control
|
|
13
|
+
* 6. Audit logging for all operations
|
|
14
|
+
*/
|
|
15
|
+
import { BaseElement } from '../BaseElement.js';
|
|
16
|
+
import { IElement, ElementValidationResult } from '../../types/elements/index.js';
|
|
17
|
+
import { IElementMetadata } from '../../types/elements/IElement.js';
|
|
18
|
+
import { PrivacyLevel, StorageBackend } from './constants.js';
|
|
19
|
+
export interface MemoryMetadata extends IElementMetadata {
|
|
20
|
+
storageBackend?: StorageBackend;
|
|
21
|
+
retentionDays?: number;
|
|
22
|
+
privacyLevel?: PrivacyLevel;
|
|
23
|
+
searchable?: boolean;
|
|
24
|
+
maxEntries?: number;
|
|
25
|
+
encryptionEnabled?: boolean;
|
|
26
|
+
indexThreshold?: number;
|
|
27
|
+
enableContentIndex?: boolean;
|
|
28
|
+
maxTermsPerEntry?: number;
|
|
29
|
+
minTermLength?: number;
|
|
30
|
+
}
|
|
31
|
+
export interface MemoryEntry {
|
|
32
|
+
id: string;
|
|
33
|
+
timestamp: Date;
|
|
34
|
+
content: string;
|
|
35
|
+
tags?: string[];
|
|
36
|
+
metadata?: Record<string, any>;
|
|
37
|
+
expiresAt?: Date;
|
|
38
|
+
privacyLevel?: PrivacyLevel;
|
|
39
|
+
}
|
|
40
|
+
export interface MemorySearchOptions {
|
|
41
|
+
query?: string;
|
|
42
|
+
tags?: string[];
|
|
43
|
+
startDate?: Date;
|
|
44
|
+
endDate?: Date;
|
|
45
|
+
limit?: number;
|
|
46
|
+
privacyLevel?: PrivacyLevel;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Memory Element Implementation
|
|
50
|
+
*
|
|
51
|
+
* TODO: Memory Sharding Strategy (Issue #981)
|
|
52
|
+
* ---------------------------------------------
|
|
53
|
+
* Current: Single Map<id, entry> for all memories
|
|
54
|
+
* Problem: Large memory sets (>10K entries) cause performance degradation
|
|
55
|
+
*
|
|
56
|
+
* Planned Sharding Architecture:
|
|
57
|
+
* 1. Shard memories across multiple files based on hash(memoryId) % shardCount
|
|
58
|
+
* 2. Each shard file <256KB for optimal YAML parsing
|
|
59
|
+
* 3. Memory references stored separately from content (like git objects)
|
|
60
|
+
* 4. Large binary content (PDFs, images) stored as external references
|
|
61
|
+
*
|
|
62
|
+
* Benefits:
|
|
63
|
+
* - Parallel loading of memory shards
|
|
64
|
+
* - Reduced memory footprint (load only needed shards)
|
|
65
|
+
* - Better corruption resistance (one shard failure doesn't affect others)
|
|
66
|
+
* - Efficient incremental updates
|
|
67
|
+
*
|
|
68
|
+
* TODO: Content Integrity Verification (Issue #982)
|
|
69
|
+
* --------------------------------------------------
|
|
70
|
+
* Add SHA-256 hashes to detect:
|
|
71
|
+
* - Accidental corruption from disk errors
|
|
72
|
+
* - Intentional tampering with memory files
|
|
73
|
+
* - Version conflicts during concurrent access
|
|
74
|
+
*
|
|
75
|
+
* Implementation:
|
|
76
|
+
* - Store hash in memory metadata
|
|
77
|
+
* - Verify on load, warn on mismatch
|
|
78
|
+
* - Option to auto-restore from backup on corruption
|
|
79
|
+
*
|
|
80
|
+
* TODO: Memory Capacity Management (Issue #983)
|
|
81
|
+
* ---------------------------------------------
|
|
82
|
+
* Current: Synchronous retention enforcement on each add
|
|
83
|
+
* Better: Background cleanup with smart triggers:
|
|
84
|
+
* - Cleanup when 90% capacity reached
|
|
85
|
+
* - Batch deletions for efficiency
|
|
86
|
+
* - LRU eviction with access tracking
|
|
87
|
+
* - Preserve "pinned" memories regardless of age
|
|
88
|
+
*/
|
|
89
|
+
export declare class Memory extends BaseElement implements IElement {
|
|
90
|
+
private entries;
|
|
91
|
+
private storageBackend;
|
|
92
|
+
private retentionDays;
|
|
93
|
+
private privacyLevel;
|
|
94
|
+
private searchable;
|
|
95
|
+
private maxEntries;
|
|
96
|
+
private searchIndex;
|
|
97
|
+
private sanitizationCache;
|
|
98
|
+
constructor(metadata?: Partial<MemoryMetadata>);
|
|
99
|
+
/**
|
|
100
|
+
* Add a new memory entry
|
|
101
|
+
* SECURITY: Validates and sanitizes all input, enforces size limits
|
|
102
|
+
*/
|
|
103
|
+
addEntry(content: string, tags?: string[], metadata?: Record<string, any>): Promise<MemoryEntry>;
|
|
104
|
+
/**
|
|
105
|
+
* Search memory entries
|
|
106
|
+
* SECURITY: Respects privacy levels and sanitizes search queries
|
|
107
|
+
*
|
|
108
|
+
* IMPLEMENTED: Basic indexed search for O(log n) performance (Issue #984)
|
|
109
|
+
* - Tag index: Map<tag, Set<entryId>> for instant tag lookups ✓
|
|
110
|
+
* - Content index: Inverted index for term search ✓
|
|
111
|
+
* - Date index: Binary tree for efficient range queries ✓
|
|
112
|
+
* - Privacy index: Pre-sorted entries by privacy level ✓
|
|
113
|
+
*
|
|
114
|
+
* TODO: Advanced indexing features (Future enhancements):
|
|
115
|
+
* - Composite indices: Combined indices for common query patterns
|
|
116
|
+
* - Index-of-indexes pattern:
|
|
117
|
+
* - Master index file (meta.yaml) with pointers to shard indices
|
|
118
|
+
* - Each shard maintains its own local index
|
|
119
|
+
* - Periodic index compaction and optimization
|
|
120
|
+
* - Persistent index storage to disk
|
|
121
|
+
* - Incremental index updates for large datasets
|
|
122
|
+
*
|
|
123
|
+
* Performance improvement achieved:
|
|
124
|
+
* - Previous: ~100ms for 10,000 entries (linear scan)
|
|
125
|
+
* - Current: <5ms for same dataset (indexed search)
|
|
126
|
+
*/
|
|
127
|
+
search(options?: MemorySearchOptions): Promise<MemoryEntry[]>;
|
|
128
|
+
/**
|
|
129
|
+
* Get a specific memory entry by ID
|
|
130
|
+
*/
|
|
131
|
+
getEntry(id: string): Promise<MemoryEntry | undefined>;
|
|
132
|
+
/**
|
|
133
|
+
* Delete a memory entry
|
|
134
|
+
* SECURITY: Validates permissions and logs deletion
|
|
135
|
+
*/
|
|
136
|
+
deleteEntry(id: string): Promise<boolean>;
|
|
137
|
+
/**
|
|
138
|
+
* Enforce retention policy by removing expired entries
|
|
139
|
+
* SECURITY: Ensures memory doesn't grow unbounded
|
|
140
|
+
*/
|
|
141
|
+
enforceRetentionPolicy(): Promise<number>;
|
|
142
|
+
/**
|
|
143
|
+
* Clear all memory entries
|
|
144
|
+
* SECURITY: Requires confirmation and logs the action
|
|
145
|
+
*/
|
|
146
|
+
clearAll(confirm?: boolean): Promise<void>;
|
|
147
|
+
/**
|
|
148
|
+
* Get memory statistics
|
|
149
|
+
*/
|
|
150
|
+
getStats(): {
|
|
151
|
+
totalEntries: number;
|
|
152
|
+
totalSize: number;
|
|
153
|
+
oldestEntry?: Date;
|
|
154
|
+
newestEntry?: Date;
|
|
155
|
+
tagFrequency: Map<string, number>;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Validate the memory element
|
|
159
|
+
*/
|
|
160
|
+
validate(): ElementValidationResult;
|
|
161
|
+
/**
|
|
162
|
+
* Serialize memory to string
|
|
163
|
+
*/
|
|
164
|
+
serialize(): string;
|
|
165
|
+
/**
|
|
166
|
+
* Deserialize memory from string
|
|
167
|
+
* SECURITY: Validates all loaded data
|
|
168
|
+
*/
|
|
169
|
+
deserialize(data: string): void;
|
|
170
|
+
private calculateExpiryDate;
|
|
171
|
+
private sanitizeTags;
|
|
172
|
+
private sanitizeMetadata;
|
|
173
|
+
private canAccessPrivacyLevel;
|
|
174
|
+
private isValidEntry;
|
|
175
|
+
/**
|
|
176
|
+
* Optimized sanitization with checksum caching
|
|
177
|
+
* Avoids re-sanitizing content that hasn't changed
|
|
178
|
+
* @param content Content to sanitize
|
|
179
|
+
* @param maxLength Maximum allowed length
|
|
180
|
+
* @returns Sanitized content
|
|
181
|
+
*/
|
|
182
|
+
private sanitizeWithCache;
|
|
183
|
+
/**
|
|
184
|
+
* Build search index with retry logic
|
|
185
|
+
* Attempts to build the index up to 3 times with exponential backoff
|
|
186
|
+
* This ensures search functionality even if there are transient failures
|
|
187
|
+
*/
|
|
188
|
+
private buildSearchIndexWithRetry;
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=Memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Memory.d.ts","sourceRoot":"","sources":["../../../src/elements/memories/Memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,uBAAuB,EAAmB,MAAM,+BAA+B,CAAC;AAEnG,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AA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