claude-flow 2.7.1 → 2.7.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 +83 -22
- package/bin/claude-flow +1 -1
- package/dist/src/cli/commands/memory.js +64 -1
- package/dist/src/cli/commands/memory.js.map +1 -1
- package/dist/src/cli/help-formatter.js +3 -5
- package/dist/src/cli/help-formatter.js.map +1 -1
- package/dist/src/cli/simple-commands/config.js +257 -115
- package/dist/src/cli/simple-commands/config.js.map +1 -1
- package/dist/src/core/version.js +1 -1
- package/dist/src/core/version.js.map +1 -1
- package/dist/src/memory/agentdb-adapter.js +214 -0
- package/dist/src/memory/agentdb-adapter.js.map +1 -0
- package/dist/src/memory/backends/agentdb.js +234 -0
- package/dist/src/memory/backends/agentdb.js.map +1 -0
- package/dist/src/memory/index.js +11 -2
- package/dist/src/memory/index.js.map +1 -1
- package/dist/src/memory/migration/legacy-bridge.js +222 -0
- package/dist/src/memory/migration/legacy-bridge.js.map +1 -0
- package/dist/src/memory/swarm-memory.js +421 -340
- package/dist/src/memory/swarm-memory.js.map +1 -1
- package/dist/src/utils/key-redactor.js.map +1 -1
- package/dist/src/utils/metrics-reader.js.map +1 -1
- package/docs/.claude-flow/metrics/performance.json +80 -2
- package/docs/.claude-flow/metrics/task-metrics.json +3 -3
- package/docs/INDEX.md +37 -12
- package/docs/README.md +92 -4
- package/docs/agentdb/AGENT3_FINAL_REPORT.md +643 -0
- package/docs/agentdb/AGENT3_SUMMARY.md +354 -0
- package/docs/agentdb/AGENTDB_INTEGRATION_PLAN.md +1258 -0
- package/docs/agentdb/BACKWARD_COMPATIBILITY_GUARANTEE.md +421 -0
- package/docs/agentdb/OPTIMIZATION_REPORT.md +360 -0
- package/docs/agentdb/PRODUCTION_READINESS.md +499 -0
- package/docs/agentdb/PUBLISHING_CHECKLIST.md +364 -0
- package/docs/agentdb/README.md +58 -0
- package/docs/agentdb/SWARM_COORDINATION.md +393 -0
- package/docs/agentdb/SWARM_IMPLEMENTATION_COMPLETE.md +538 -0
- package/docs/agentdb/agentdb-integration-summary.md +331 -0
- package/docs/agentdb/benchmarks/baseline-report.json +75 -0
- package/docs/development/AGENT1_COMPLETION_REPORT.md +466 -0
- package/docs/development/README.md +22 -0
- package/docs/fixes/PATTERN_FIX_CONFIRMATION.md +513 -0
- package/docs/fixes/README.md +33 -0
- package/docs/guides/README.md +29 -0
- package/docs/integrations/agentic-flow/INTEGRATION-TEST-v1.7.1.md +419 -0
- package/docs/integrations/agentic-flow/MIGRATION_v1.7.0.md +381 -0
- package/docs/integrations/agentic-flow/README.md +229 -0
- package/docs/integrations/agentic-flow/RELEASE-v1.7.0.md +348 -0
- package/docs/integrations/agentic-flow/RELEASE-v1.7.1.md +547 -0
- package/docs/integrations/agentic-flow/VERIFICATION-v1.7.4.md +556 -0
- package/docs/performance/README.md +31 -0
- package/docs/releases/ALPHA_TAG_UPDATE.md +150 -0
- package/docs/releases/README.md +25 -0
- package/docs/{RELEASE-NOTES-v2.7.0-alpha.10.md → releases/v2.7.0-alpha.10/RELEASE-NOTES-v2.7.0-alpha.10.md} +1 -1
- package/docs/releases/v2.7.1/RELEASE_SUMMARY_v2.7.1.md +340 -0
- package/docs/validation/DOCKER_VERIFICATION_REPORT.md +371 -0
- package/docs/validation/README.md +25 -0
- package/docs/validation/REGRESSION_ANALYSIS_v2.7.1.md +357 -0
- package/package.json +4 -3
- package/scripts/fix-agentdb-imports.sh +18 -0
- package/scripts/run-docker-regression.sh +101 -0
- package/scripts/verify-agentdb-integration.sh +220 -0
- package/src/cli/commands/memory.ts +95 -1
- package/src/memory/README-AGENTDB.md +366 -0
- package/src/memory/agentdb-adapter.js +373 -0
- package/src/memory/backends/agentdb.js +360 -0
- package/src/memory/index.js +32 -3
- package/src/memory/migration/legacy-bridge.js +330 -0
- /package/docs/{COMMANDS_TO_SKILLS_MIGRATION.md → development/COMMANDS_TO_SKILLS_MIGRATION.md} +0 -0
- /package/docs/{FINAL_INIT_STRUCTURE.md → development/FINAL_INIT_STRUCTURE.md} +0 -0
- /package/docs/{CLI-MEMORY-COMMANDS-WORKING.md → fixes/CLI-MEMORY-COMMANDS-WORKING.md} +0 -0
- /package/docs/{PATTERN_PERSISTENCE_FIX.md → fixes/PATTERN_PERSISTENCE_FIX.md} +0 -0
- /package/docs/{skills-tutorial.md → guides/skills-tutorial.md} +0 -0
- /package/docs/{PERFORMANCE-JSON-IMPROVEMENTS.md → performance/PERFORMANCE-JSON-IMPROVEMENTS.md} +0 -0
- /package/docs/{PERFORMANCE-METRICS-GUIDE.md → performance/PERFORMANCE-METRICS-GUIDE.md} +0 -0
- /package/docs/{RELEASE-NOTES-v2.7.0-alpha.9.md → releases/v2.7.0-alpha.9/RELEASE-NOTES-v2.7.0-alpha.9.md} +0 -0
- /package/docs/{RELEASE_v2.7.1.md → releases/v2.7.1/RELEASE_v2.7.1.md} +0 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { writeFileSync, readFileSync, existsSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
export class LegacyDataBridge {
|
|
4
|
+
constructor(options = {}){
|
|
5
|
+
this.backupDir = options.backupDir || '.agentdb/backups';
|
|
6
|
+
this.verbose = options.verbose || false;
|
|
7
|
+
}
|
|
8
|
+
async migrateToAgentDB(sourceStore, targetAdapter, options = {}) {
|
|
9
|
+
const startTime = Date.now();
|
|
10
|
+
const results = {
|
|
11
|
+
success: false,
|
|
12
|
+
migrated: 0,
|
|
13
|
+
errors: 0,
|
|
14
|
+
skipped: 0,
|
|
15
|
+
backupPath: null,
|
|
16
|
+
duration: 0
|
|
17
|
+
};
|
|
18
|
+
try {
|
|
19
|
+
this._log('Creating backup of legacy data...');
|
|
20
|
+
const backupPath = await this.createBackup(sourceStore);
|
|
21
|
+
results.backupPath = backupPath;
|
|
22
|
+
this._log(`Backup created at: ${backupPath}`);
|
|
23
|
+
this._log('Exporting legacy data...');
|
|
24
|
+
const legacyData = await sourceStore.exportData();
|
|
25
|
+
for (const [namespace, items] of Object.entries(legacyData)){
|
|
26
|
+
this._log(`Migrating namespace: ${namespace} (${items.length} items)`);
|
|
27
|
+
for (const item of items){
|
|
28
|
+
try {
|
|
29
|
+
const shouldEmbed = this._shouldEmbed(item, namespace, options);
|
|
30
|
+
if (shouldEmbed && options.generateEmbedding) {
|
|
31
|
+
const embedding = await options.generateEmbedding(item.value);
|
|
32
|
+
await targetAdapter.storeWithEmbedding(item.key, item.value, {
|
|
33
|
+
embedding,
|
|
34
|
+
metadata: item.metadata,
|
|
35
|
+
namespace,
|
|
36
|
+
ttl: item.ttl
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
await targetAdapter.store(item.key, item.value, {
|
|
40
|
+
metadata: item.metadata,
|
|
41
|
+
namespace,
|
|
42
|
+
ttl: item.ttl
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
results.migrated++;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
results.errors++;
|
|
48
|
+
this._log(`Error migrating ${item.key}: ${error.message}`, 'error');
|
|
49
|
+
if (options.stopOnError) {
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
this._log('Validating migration...');
|
|
56
|
+
const validation = await this.validateMigration(sourceStore, targetAdapter);
|
|
57
|
+
if (!validation.isValid && options.strictValidation) {
|
|
58
|
+
throw new Error(`Migration validation failed: ${validation.errors.join(', ')}`);
|
|
59
|
+
}
|
|
60
|
+
results.success = true;
|
|
61
|
+
results.duration = Date.now() - startTime;
|
|
62
|
+
this._log(`Migration completed in ${results.duration}ms`);
|
|
63
|
+
this._log(`Migrated: ${results.migrated}, Errors: ${results.errors}, Skipped: ${results.skipped}`);
|
|
64
|
+
return results;
|
|
65
|
+
} catch (error) {
|
|
66
|
+
results.success = false;
|
|
67
|
+
results.duration = Date.now() - startTime;
|
|
68
|
+
results.error = error.message;
|
|
69
|
+
this._log(`Migration failed: ${error.message}`, 'error');
|
|
70
|
+
return results;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async validateMigration(sourceStore, targetAdapter) {
|
|
74
|
+
const validation = {
|
|
75
|
+
isValid: true,
|
|
76
|
+
errors: [],
|
|
77
|
+
warnings: [],
|
|
78
|
+
stats: {
|
|
79
|
+
sourceCount: 0,
|
|
80
|
+
targetCount: 0,
|
|
81
|
+
matched: 0,
|
|
82
|
+
mismatched: 0
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
try {
|
|
86
|
+
const sourceData = await sourceStore.exportData();
|
|
87
|
+
const targetData = await targetAdapter.exportData();
|
|
88
|
+
for (const items of Object.values(sourceData)){
|
|
89
|
+
validation.stats.sourceCount += items.length;
|
|
90
|
+
}
|
|
91
|
+
for (const items of Object.values(targetData)){
|
|
92
|
+
validation.stats.targetCount += items.length;
|
|
93
|
+
}
|
|
94
|
+
for (const [namespace, sourceItems] of Object.entries(sourceData)){
|
|
95
|
+
const targetItems = targetData[namespace] || [];
|
|
96
|
+
const targetKeys = new Set(targetItems.map((item)=>item.key));
|
|
97
|
+
for (const sourceItem of sourceItems){
|
|
98
|
+
if (targetKeys.has(sourceItem.key)) {
|
|
99
|
+
const targetItem = targetItems.find((item)=>item.key === sourceItem.key);
|
|
100
|
+
if (JSON.stringify(sourceItem.value) === JSON.stringify(targetItem.value)) {
|
|
101
|
+
validation.stats.matched++;
|
|
102
|
+
} else {
|
|
103
|
+
validation.stats.mismatched++;
|
|
104
|
+
validation.warnings.push(`Value mismatch for key: ${sourceItem.key} in namespace: ${namespace}`);
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
validation.errors.push(`Missing key in target: ${sourceItem.key} in namespace: ${namespace}`);
|
|
108
|
+
validation.isValid = false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (validation.stats.sourceCount !== validation.stats.targetCount) {
|
|
113
|
+
validation.warnings.push(`Count mismatch: source=${validation.stats.sourceCount}, target=${validation.stats.targetCount}`);
|
|
114
|
+
}
|
|
115
|
+
return validation;
|
|
116
|
+
} catch (error) {
|
|
117
|
+
validation.isValid = false;
|
|
118
|
+
validation.errors.push(`Validation error: ${error.message}`);
|
|
119
|
+
return validation;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async rollback(backupPath, targetStore) {
|
|
123
|
+
const startTime = Date.now();
|
|
124
|
+
const results = {
|
|
125
|
+
success: false,
|
|
126
|
+
restored: 0,
|
|
127
|
+
errors: 0,
|
|
128
|
+
duration: 0
|
|
129
|
+
};
|
|
130
|
+
try {
|
|
131
|
+
if (!existsSync(backupPath)) {
|
|
132
|
+
throw new Error(`Backup file not found: ${backupPath}`);
|
|
133
|
+
}
|
|
134
|
+
this._log(`Reading backup from: ${backupPath}`);
|
|
135
|
+
const backupData = JSON.parse(readFileSync(backupPath, 'utf-8'));
|
|
136
|
+
this._log('Restoring data from backup...');
|
|
137
|
+
await targetStore.importData(backupData);
|
|
138
|
+
results.success = true;
|
|
139
|
+
results.duration = Date.now() - startTime;
|
|
140
|
+
this._log(`Rollback completed in ${results.duration}ms`);
|
|
141
|
+
return results;
|
|
142
|
+
} catch (error) {
|
|
143
|
+
results.success = false;
|
|
144
|
+
results.duration = Date.now() - startTime;
|
|
145
|
+
results.error = error.message;
|
|
146
|
+
this._log(`Rollback failed: ${error.message}`, 'error');
|
|
147
|
+
return results;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async createBackup(sourceStore) {
|
|
151
|
+
try {
|
|
152
|
+
const fs = await import('fs');
|
|
153
|
+
if (!fs.existsSync(this.backupDir)) {
|
|
154
|
+
fs.mkdirSync(this.backupDir, {
|
|
155
|
+
recursive: true
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
const data = await sourceStore.exportData();
|
|
159
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
160
|
+
const backupPath = join(this.backupDir, `backup-${timestamp}.json`);
|
|
161
|
+
writeFileSync(backupPath, JSON.stringify(data, null, 2), 'utf-8');
|
|
162
|
+
return backupPath;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
throw new Error(`Backup creation failed: ${error.message}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
_shouldEmbed(item, namespace, options) {
|
|
168
|
+
const skipNamespaces = options.skipEmbedding || [
|
|
169
|
+
'metrics',
|
|
170
|
+
'performance',
|
|
171
|
+
'coordination'
|
|
172
|
+
];
|
|
173
|
+
if (skipNamespaces.includes(namespace)) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
if (typeof item.value !== 'object' && typeof item.value !== 'string') {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
const embedNamespaces = options.embedNamespaces || [
|
|
180
|
+
'knowledge',
|
|
181
|
+
'learning',
|
|
182
|
+
'sessions',
|
|
183
|
+
'workflows'
|
|
184
|
+
];
|
|
185
|
+
return embedNamespaces.includes(namespace);
|
|
186
|
+
}
|
|
187
|
+
_log(message, level = 'info') {
|
|
188
|
+
if (!this.verbose && level !== 'error') {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const timestamp = new Date().toISOString();
|
|
192
|
+
const prefix = level === 'error' ? 'ERROR' : 'INFO';
|
|
193
|
+
console.error(`[${timestamp}] ${prefix} [legacy-bridge] ${message}`);
|
|
194
|
+
}
|
|
195
|
+
generateReport(results) {
|
|
196
|
+
const lines = [];
|
|
197
|
+
lines.push('='.repeat(60));
|
|
198
|
+
lines.push('AgentDB Migration Report');
|
|
199
|
+
lines.push('='.repeat(60));
|
|
200
|
+
lines.push('');
|
|
201
|
+
lines.push(`Status: ${results.success ? 'SUCCESS' : 'FAILED'}`);
|
|
202
|
+
lines.push(`Duration: ${results.duration}ms`);
|
|
203
|
+
lines.push('');
|
|
204
|
+
lines.push('Statistics:');
|
|
205
|
+
lines.push(` Migrated: ${results.migrated}`);
|
|
206
|
+
lines.push(` Errors: ${results.errors}`);
|
|
207
|
+
lines.push(` Skipped: ${results.skipped}`);
|
|
208
|
+
if (results.backupPath) {
|
|
209
|
+
lines.push('');
|
|
210
|
+
lines.push(`Backup Location: ${results.backupPath}`);
|
|
211
|
+
}
|
|
212
|
+
if (results.error) {
|
|
213
|
+
lines.push('');
|
|
214
|
+
lines.push(`Error: ${results.error}`);
|
|
215
|
+
}
|
|
216
|
+
lines.push('='.repeat(60));
|
|
217
|
+
return lines.join('\n');
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
export default LegacyDataBridge;
|
|
221
|
+
|
|
222
|
+
//# sourceMappingURL=legacy-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/memory/migration/legacy-bridge.js"],"sourcesContent":["/**\n * Legacy Data Bridge - Migration utilities for AgentDB integration\n * Provides safe migration from legacy memory stores to AgentDB\n */\n\nimport { writeFileSync, readFileSync, existsSync } from 'fs';\nimport { join } from 'path';\n\nexport class LegacyDataBridge {\n constructor(options = {}) {\n this.backupDir = options.backupDir || '.agentdb/backups';\n this.verbose = options.verbose || false;\n }\n\n /**\n * Migrate all data from legacy store to AgentDB\n * @param {Object} sourceStore - Legacy memory store (EnhancedMemory)\n * @param {Object} targetAdapter - AgentDB adapter\n * @param {Object} options - Migration options\n * @returns {Promise<Object>} Migration results\n */\n async migrateToAgentDB(sourceStore, targetAdapter, options = {}) {\n const startTime = Date.now();\n const results = {\n success: false,\n migrated: 0,\n errors: 0,\n skipped: 0,\n backupPath: null,\n duration: 0,\n };\n\n try {\n // Step 1: Create backup\n this._log('Creating backup of legacy data...');\n const backupPath = await this.createBackup(sourceStore);\n results.backupPath = backupPath;\n this._log(`Backup created at: ${backupPath}`);\n\n // Step 2: Export all legacy data\n this._log('Exporting legacy data...');\n const legacyData = await sourceStore.exportData();\n\n // Step 3: Migrate each namespace\n for (const [namespace, items] of Object.entries(legacyData)) {\n this._log(`Migrating namespace: ${namespace} (${items.length} items)`);\n\n for (const item of items) {\n try {\n // Check if item should be migrated with embedding\n const shouldEmbed = this._shouldEmbed(item, namespace, options);\n\n if (shouldEmbed && options.generateEmbedding) {\n // Generate embedding and store with vector\n const embedding = await options.generateEmbedding(item.value);\n\n await targetAdapter.storeWithEmbedding(item.key, item.value, {\n embedding,\n metadata: item.metadata,\n namespace,\n ttl: item.ttl,\n });\n } else {\n // Store without embedding (legacy compatibility)\n await targetAdapter.store(item.key, item.value, {\n metadata: item.metadata,\n namespace,\n ttl: item.ttl,\n });\n }\n\n results.migrated++;\n } catch (error) {\n results.errors++;\n this._log(`Error migrating ${item.key}: ${error.message}`, 'error');\n\n if (options.stopOnError) {\n throw error;\n }\n }\n }\n }\n\n // Step 4: Validate migration\n this._log('Validating migration...');\n const validation = await this.validateMigration(sourceStore, targetAdapter);\n\n if (!validation.isValid && options.strictValidation) {\n throw new Error(`Migration validation failed: ${validation.errors.join(', ')}`);\n }\n\n results.success = true;\n results.duration = Date.now() - startTime;\n\n this._log(`Migration completed in ${results.duration}ms`);\n this._log(`Migrated: ${results.migrated}, Errors: ${results.errors}, Skipped: ${results.skipped}`);\n\n return results;\n } catch (error) {\n results.success = false;\n results.duration = Date.now() - startTime;\n results.error = error.message;\n\n this._log(`Migration failed: ${error.message}`, 'error');\n return results;\n }\n }\n\n /**\n * Validate migration integrity\n * @param {Object} sourceStore - Source legacy store\n * @param {Object} targetAdapter - Target AgentDB adapter\n * @returns {Promise<Object>} Validation results\n */\n async validateMigration(sourceStore, targetAdapter) {\n const validation = {\n isValid: true,\n errors: [],\n warnings: [],\n stats: {\n sourceCount: 0,\n targetCount: 0,\n matched: 0,\n mismatched: 0,\n },\n };\n\n try {\n // Export both stores\n const sourceData = await sourceStore.exportData();\n const targetData = await targetAdapter.exportData();\n\n // Count total items\n for (const items of Object.values(sourceData)) {\n validation.stats.sourceCount += items.length;\n }\n\n for (const items of Object.values(targetData)) {\n validation.stats.targetCount += items.length;\n }\n\n // Validate each namespace\n for (const [namespace, sourceItems] of Object.entries(sourceData)) {\n const targetItems = targetData[namespace] || [];\n const targetKeys = new Set(targetItems.map(item => item.key));\n\n for (const sourceItem of sourceItems) {\n if (targetKeys.has(sourceItem.key)) {\n // Find matching item\n const targetItem = targetItems.find(item => item.key === sourceItem.key);\n\n // Deep compare values\n if (JSON.stringify(sourceItem.value) === JSON.stringify(targetItem.value)) {\n validation.stats.matched++;\n } else {\n validation.stats.mismatched++;\n validation.warnings.push(\n `Value mismatch for key: ${sourceItem.key} in namespace: ${namespace}`,\n );\n }\n } else {\n validation.errors.push(`Missing key in target: ${sourceItem.key} in namespace: ${namespace}`);\n validation.isValid = false;\n }\n }\n }\n\n // Check for count discrepancies\n if (validation.stats.sourceCount !== validation.stats.targetCount) {\n validation.warnings.push(\n `Count mismatch: source=${validation.stats.sourceCount}, target=${validation.stats.targetCount}`,\n );\n }\n\n return validation;\n } catch (error) {\n validation.isValid = false;\n validation.errors.push(`Validation error: ${error.message}`);\n return validation;\n }\n }\n\n /**\n * Rollback migration from backup\n * @param {string} backupPath - Path to backup file\n * @param {Object} targetStore - Store to restore to\n * @returns {Promise<Object>} Rollback results\n */\n async rollback(backupPath, targetStore) {\n const startTime = Date.now();\n const results = {\n success: false,\n restored: 0,\n errors: 0,\n duration: 0,\n };\n\n try {\n // Check if backup exists\n if (!existsSync(backupPath)) {\n throw new Error(`Backup file not found: ${backupPath}`);\n }\n\n // Read backup\n this._log(`Reading backup from: ${backupPath}`);\n const backupData = JSON.parse(readFileSync(backupPath, 'utf-8'));\n\n // Restore data\n this._log('Restoring data from backup...');\n await targetStore.importData(backupData);\n\n results.success = true;\n results.duration = Date.now() - startTime;\n\n this._log(`Rollback completed in ${results.duration}ms`);\n return results;\n } catch (error) {\n results.success = false;\n results.duration = Date.now() - startTime;\n results.error = error.message;\n\n this._log(`Rollback failed: ${error.message}`, 'error');\n return results;\n }\n }\n\n /**\n * Create backup of current data\n * @param {Object} sourceStore - Store to backup\n * @returns {Promise<string>} Backup file path\n */\n async createBackup(sourceStore) {\n try {\n // Ensure backup directory exists\n const fs = await import('fs');\n if (!fs.existsSync(this.backupDir)) {\n fs.mkdirSync(this.backupDir, { recursive: true });\n }\n\n // Export data\n const data = await sourceStore.exportData();\n\n // Create backup file with timestamp\n const timestamp = new Date().toISOString().replace(/[:.]/g, '-');\n const backupPath = join(this.backupDir, `backup-${timestamp}.json`);\n\n // Write backup\n writeFileSync(backupPath, JSON.stringify(data, null, 2), 'utf-8');\n\n return backupPath;\n } catch (error) {\n throw new Error(`Backup creation failed: ${error.message}`);\n }\n }\n\n /**\n * Determine if item should have embedding\n * @private\n */\n _shouldEmbed(item, namespace, options) {\n // Skip embedding for certain namespaces\n const skipNamespaces = options.skipEmbedding || ['metrics', 'performance', 'coordination'];\n\n if (skipNamespaces.includes(namespace)) {\n return false;\n }\n\n // Skip if value is not suitable for embedding\n if (typeof item.value !== 'object' && typeof item.value !== 'string') {\n return false;\n }\n\n // Embed knowledge, learning, and sessions by default\n const embedNamespaces = options.embedNamespaces || ['knowledge', 'learning', 'sessions', 'workflows'];\n\n return embedNamespaces.includes(namespace);\n }\n\n /**\n * Log message\n * @private\n */\n _log(message, level = 'info') {\n if (!this.verbose && level !== 'error') {\n return;\n }\n\n const timestamp = new Date().toISOString();\n const prefix = level === 'error' ? 'ERROR' : 'INFO';\n\n console.error(`[${timestamp}] ${prefix} [legacy-bridge] ${message}`);\n }\n\n /**\n * Generate migration report\n * @param {Object} results - Migration results\n * @returns {string} Formatted report\n */\n generateReport(results) {\n const lines = [];\n\n lines.push('='.repeat(60));\n lines.push('AgentDB Migration Report');\n lines.push('='.repeat(60));\n lines.push('');\n lines.push(`Status: ${results.success ? 'SUCCESS' : 'FAILED'}`);\n lines.push(`Duration: ${results.duration}ms`);\n lines.push('');\n lines.push('Statistics:');\n lines.push(` Migrated: ${results.migrated}`);\n lines.push(` Errors: ${results.errors}`);\n lines.push(` Skipped: ${results.skipped}`);\n\n if (results.backupPath) {\n lines.push('');\n lines.push(`Backup Location: ${results.backupPath}`);\n }\n\n if (results.error) {\n lines.push('');\n lines.push(`Error: ${results.error}`);\n }\n\n lines.push('='.repeat(60));\n\n return lines.join('\\n');\n }\n}\n\nexport default LegacyDataBridge;\n"],"names":["writeFileSync","readFileSync","existsSync","join","LegacyDataBridge","options","backupDir","verbose","migrateToAgentDB","sourceStore","targetAdapter","startTime","Date","now","results","success","migrated","errors","skipped","backupPath","duration","_log","createBackup","legacyData","exportData","namespace","items","Object","entries","length","item","shouldEmbed","_shouldEmbed","generateEmbedding","embedding","value","storeWithEmbedding","key","metadata","ttl","store","error","message","stopOnError","validation","validateMigration","isValid","strictValidation","Error","warnings","stats","sourceCount","targetCount","matched","mismatched","sourceData","targetData","values","sourceItems","targetItems","targetKeys","Set","map","sourceItem","has","targetItem","find","JSON","stringify","push","rollback","targetStore","restored","backupData","parse","importData","fs","mkdirSync","recursive","data","timestamp","toISOString","replace","skipNamespaces","skipEmbedding","includes","embedNamespaces","level","prefix","console","generateReport","lines","repeat"],"mappings":"AAKA,SAASA,aAAa,EAAEC,YAAY,EAAEC,UAAU,QAAQ,KAAK;AAC7D,SAASC,IAAI,QAAQ,OAAO;AAE5B,OAAO,MAAMC;IACX,YAAYC,UAAU,CAAC,CAAC,CAAE;QACxB,IAAI,CAACC,SAAS,GAAGD,QAAQC,SAAS,IAAI;QACtC,IAAI,CAACC,OAAO,GAAGF,QAAQE,OAAO,IAAI;IACpC;IASA,MAAMC,iBAAiBC,WAAW,EAAEC,aAAa,EAAEL,UAAU,CAAC,CAAC,EAAE;QAC/D,MAAMM,YAAYC,KAAKC,GAAG;QAC1B,MAAMC,UAAU;YACdC,SAAS;YACTC,UAAU;YACVC,QAAQ;YACRC,SAAS;YACTC,YAAY;YACZC,UAAU;QACZ;QAEA,IAAI;YAEF,IAAI,CAACC,IAAI,CAAC;YACV,MAAMF,aAAa,MAAM,IAAI,CAACG,YAAY,CAACb;YAC3CK,QAAQK,UAAU,GAAGA;YACrB,IAAI,CAACE,IAAI,CAAC,CAAC,mBAAm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