claude-flow 2.7.1 → 2.7.3
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 +272 -33
- 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-cli.js +0 -104
- package/dist/src/cli/simple-cli.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/cli/validation-helper.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/utils/metrics-reader.js +29 -41
- 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 +347 -35
- 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,mBAAmB,EAAEF,YAAY;YAG5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,EAAEvD,QAAQM,QAAQ,CAAC,EAAE,CAAC;QAC5CuE,MAAMtB,IAAI,CAAC;QACXsB,MAAMtB,IAAI,CAAC;QACXsB,MAAMtB,IAAI,CAAC,CAAC,YAAY,EAAEvD,QAAQE,QAAQ,EAAE;QAC5C2E,MAAMtB,IAAI,CAAC,CAAC,UAAU,EAAEvD,QAAQG,MAAM,EAAE;QACxC0E,MAAMtB,IAAI,CAAC,CAAC,WAAW,EAAEvD,QAAQI,OAAO,EAAE;QAE1C,IAAIJ,QAAQK,UAAU,EAAE;YACtBwE,MAAMtB,IAAI,CAAC;YACXsB,MAAMtB,IAAI,CAAC,CAAC,iBAAiB,EAAEvD,QAAQK,UAAU,EAAE;QACrD;QAEA,IAAIL,QAAQ2B,KAAK,EAAE;YACjBkD,MAAMtB,IAAI,CAAC;YACXsB,MAAMtB,IAAI,CAAC,CAAC,OAAO,EAAEvD,QAAQ2B,KAAK,EAAE;QACtC;QAEAkD,MAAMtB,IAAI,CAAC,IAAIuB,MAAM,CAAC;QAEtB,OAAOD,MAAMxF,IAAI,CAAC;IACpB;AACF;AAEA,eAAeC,iBAAiB"}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import path from 'path';
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
import * as path from 'path';
|
|
3
3
|
import { exec } from 'child_process';
|
|
4
4
|
import { promisify } from 'util';
|
|
5
5
|
const execAsync = promisify(exec);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.sessionsDir = '.claude-flow/sessions';
|
|
10
|
-
}
|
|
6
|
+
export class MetricsReader {
|
|
7
|
+
metricsDir = '.claude-flow/metrics';
|
|
8
|
+
sessionsDir = '.claude-flow/sessions';
|
|
11
9
|
async getSystemMetrics() {
|
|
12
10
|
try {
|
|
13
11
|
const filePath = path.join(this.metricsDir, 'system-metrics.json');
|
|
@@ -18,15 +16,6 @@ let MetricsReader = class MetricsReader {
|
|
|
18
16
|
return null;
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
|
-
async getTaskQueue() {
|
|
22
|
-
try {
|
|
23
|
-
const queueFile = '.claude-flow/tasks/queue.json';
|
|
24
|
-
const content = await fs.readFile(queueFile, 'utf8');
|
|
25
|
-
return JSON.parse(content);
|
|
26
|
-
} catch (error) {
|
|
27
|
-
return [];
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
19
|
async getTaskMetrics() {
|
|
31
20
|
try {
|
|
32
21
|
const filePath = path.join(this.metricsDir, 'task-metrics.json');
|
|
@@ -47,30 +36,30 @@ let MetricsReader = class MetricsReader {
|
|
|
47
36
|
}
|
|
48
37
|
async getActiveAgents() {
|
|
49
38
|
try {
|
|
39
|
+
const perfMetrics = await this.getPerformanceMetrics();
|
|
40
|
+
const sessionFiles = await this.getSessionFiles();
|
|
50
41
|
const agents = [];
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
const content = await fs.readFile(path.join(agentsDir, file), 'utf8');
|
|
58
|
-
const agent = JSON.parse(content);
|
|
59
|
-
agents.push(agent);
|
|
60
|
-
} catch {}
|
|
42
|
+
for (const file of sessionFiles){
|
|
43
|
+
try {
|
|
44
|
+
const content = await fs.readFile(path.join(this.sessionsDir, 'pair', file), 'utf8');
|
|
45
|
+
const sessionData = JSON.parse(content);
|
|
46
|
+
if (sessionData.agents && Array.isArray(sessionData.agents)) {
|
|
47
|
+
agents.push(...sessionData.agents);
|
|
61
48
|
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (agents.length === 0) {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
49
|
+
} catch {}
|
|
50
|
+
}
|
|
51
|
+
if (agents.length === 0 && perfMetrics) {
|
|
52
|
+
const activeCount = perfMetrics.activeAgents || 0;
|
|
53
|
+
const totalCount = perfMetrics.totalAgents || 0;
|
|
54
|
+
for(let i = 0; i < totalCount; i++){
|
|
55
|
+
agents.push({
|
|
56
|
+
id: `agent-${i + 1}`,
|
|
57
|
+
name: `Agent ${i + 1}`,
|
|
58
|
+
type: i === 0 ? 'orchestrator' : 'worker',
|
|
59
|
+
status: i < activeCount ? 'active' : 'idle',
|
|
60
|
+
activeTasks: i < activeCount ? 1 : 0,
|
|
61
|
+
lastActivity: Date.now() - i * 1000
|
|
62
|
+
});
|
|
74
63
|
}
|
|
75
64
|
}
|
|
76
65
|
return agents;
|
|
@@ -146,7 +135,7 @@ let MetricsReader = class MetricsReader {
|
|
|
146
135
|
}
|
|
147
136
|
async getMCPServerStatus() {
|
|
148
137
|
try {
|
|
149
|
-
const { stdout } = await execAsync('ps aux | grep -E "mcp" | grep -v grep | wc -l');
|
|
138
|
+
const { stdout } = await execAsync('ps aux | grep -E "mcp-server\\.js|claude-flow mcp start" | grep -v grep | wc -l');
|
|
150
139
|
const processCount = parseInt(stdout.trim(), 10);
|
|
151
140
|
const { stdout: orchestratorOut } = await execAsync('ps aux | grep -E "claude-flow start" | grep -v grep | wc -l');
|
|
152
141
|
const orchestratorRunning = parseInt(orchestratorOut.trim(), 10) > 0;
|
|
@@ -175,7 +164,6 @@ let MetricsReader = class MetricsReader {
|
|
|
175
164
|
};
|
|
176
165
|
}
|
|
177
166
|
}
|
|
178
|
-
}
|
|
179
|
-
export { MetricsReader };
|
|
167
|
+
}
|
|
180
168
|
|
|
181
169
|
//# sourceMappingURL=metrics-reader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/metrics-reader.js"],"sourcesContent":["import { promises as fs } from 'fs';\nimport path from 'path';\nimport { exec } from 'child_process';\nimport { promisify } from 'util';\n\nconst execAsync = promisify(exec);\n\nclass MetricsReader {\n constructor() {\n this.metricsDir = '.claude-flow/metrics';\n this.sessionsDir = '.claude-flow/sessions';\n }\n\n async getSystemMetrics() {\n try {\n const filePath = path.join(this.metricsDir, 'system-metrics.json');\n const content = await fs.readFile(filePath, 'utf8');\n const metrics = JSON.parse(content);\n \n // Return the most recent metric\n return metrics.length > 0 ? metrics[metrics.length - 1] : null;\n } catch (error) {\n return null;\n }\n }\n\n async getTaskQueue() {\n try {\n const queueFile = '.claude-flow/tasks/queue.json';\n const content = await fs.readFile(queueFile, 'utf8');\n return JSON.parse(content);\n } catch (error) {\n return [];\n }\n }\n\n async getTaskMetrics() {\n try {\n const filePath = path.join(this.metricsDir, 'task-metrics.json');\n const content = await fs.readFile(filePath, 'utf8');\n return JSON.parse(content);\n } catch (error) {\n return [];\n }\n }\n\n async getPerformanceMetrics() {\n try {\n const filePath = path.join(this.metricsDir, 'performance.json');\n const content = await fs.readFile(filePath, 'utf8');\n return JSON.parse(content);\n } catch (error) {\n return null;\n }\n }\n\n async getActiveAgents() {\n try {\n const agents = [];\n \n // Check for agents in the .claude-flow/agents directory\n const agentsDir = '.claude-flow/agents';\n try {\n const agentFiles = await fs.readdir(agentsDir);\n for (const file of agentFiles) {\n if (file.endsWith('.json')) {\n try {\n const content = await fs.readFile(path.join(agentsDir, file), 'utf8');\n const agent = JSON.parse(content);\n agents.push(agent);\n } catch {\n // Skip invalid agent files\n }\n }\n }\n } catch {\n // Agents directory doesn't exist yet\n }\n \n // If no agents found in directory, check session files\n if (agents.length === 0) {\n const sessionFiles = await this.getSessionFiles();\n for (const file of sessionFiles) {\n try {\n const content = await fs.readFile(path.join(this.sessionsDir, 'pair', file), 'utf8');\n const sessionData = JSON.parse(content);\n \n if (sessionData.agents && Array.isArray(sessionData.agents)) {\n agents.push(...sessionData.agents);\n }\n } catch {\n // Skip invalid session files\n }\n }\n }\n \n return agents;\n } catch (error) {\n return [];\n }\n }\n\n async getSessionStatus() {\n try {\n const sessionFiles = await this.getSessionFiles();\n \n if (sessionFiles.length === 0) {\n return null;\n }\n \n // Get the most recent session\n const mostRecentFile = sessionFiles[sessionFiles.length - 1];\n const content = await fs.readFile(path.join(this.sessionsDir, 'pair', mostRecentFile), 'utf8');\n return JSON.parse(content);\n } catch (error) {\n return null;\n }\n }\n\n async getRecentTasks(limit = 10) {\n try {\n const taskMetrics = await this.getTaskMetrics();\n \n // Sort by timestamp descending and take the limit\n return taskMetrics\n .sort((a, b) => b.timestamp - a.timestamp)\n .slice(0, limit)\n .map(task => ({\n id: task.id,\n type: task.type,\n status: task.success ? 'completed' : 'failed',\n startTime: task.timestamp - task.duration,\n endTime: task.timestamp,\n duration: task.duration\n }));\n } catch (error) {\n return [];\n }\n }\n\n async getOverallHealth() {\n try {\n const systemMetrics = await this.getSystemMetrics();\n const perfMetrics = await this.getPerformanceMetrics();\n \n if (!systemMetrics && !perfMetrics) {\n return 'error';\n }\n \n // Check memory usage\n if (systemMetrics && systemMetrics.memoryUsagePercent > 90) {\n return 'error';\n }\n \n if (systemMetrics && systemMetrics.memoryUsagePercent > 75) {\n return 'warning';\n }\n \n // Check CPU load\n if (systemMetrics && systemMetrics.cpuLoad > 0.8) {\n return 'warning';\n }\n \n // Check task failure rate\n if (perfMetrics && perfMetrics.totalTasks > 0) {\n const failureRate = perfMetrics.failedTasks / perfMetrics.totalTasks;\n if (failureRate > 0.5) {\n return 'error';\n }\n if (failureRate > 0.2) {\n return 'warning';\n }\n }\n \n return 'healthy';\n } catch (error) {\n return 'error';\n }\n }\n\n async getSessionFiles() {\n try {\n const files = await fs.readdir(path.join(this.sessionsDir, 'pair'));\n return files.filter(f => f.endsWith('.json')).sort();\n } catch (error) {\n return [];\n }\n }\n\n async getMCPServerStatus() {\n try {\n // Check if MCP server process is running (including flow-nexus and other MCP variants)\n const { stdout } = await execAsync('ps aux | grep -E \"mcp\" | grep -v grep | wc -l');\n const processCount = parseInt(stdout.trim(), 10);\n \n // Check for orchestrator running\n const { stdout: orchestratorOut } = await execAsync('ps aux | grep -E \"claude-flow start\" | grep -v grep | wc -l');\n const orchestratorRunning = parseInt(orchestratorOut.trim(), 10) > 0;\n \n // Determine status\n const isRunning = processCount > 0;\n \n // Try to get port from process (default is 3000)\n let port = 3000;\n try {\n const { stdout: portOut } = await execAsync('lsof -i :3000 2>/dev/null | grep LISTEN | wc -l');\n if (parseInt(portOut.trim(), 10) === 0) {\n // If port 3000 not listening, check other common ports\n port = null;\n }\n } catch {\n // lsof might not be available or port not in use\n }\n \n return {\n running: isRunning,\n processCount,\n orchestratorRunning,\n port,\n connections: processCount > 0 ? Math.max(1, processCount - 1) : 0 // Estimate connections\n };\n } catch (error) {\n // Fallback if commands fail\n return {\n running: false,\n processCount: 0,\n orchestratorRunning: false,\n port: null,\n connections: 0\n };\n }\n }\n}\n\nexport { MetricsReader };"],"names":["promises","fs","path","exec","promisify","execAsync","MetricsReader","metricsDir","sessionsDir","getSystemMetrics","filePath","join","content","readFile","metrics","JSON","parse","length","error","getTaskQueue","queueFile","getTaskMetrics","getPerformanceMetrics","getActiveAgents","agents","agentsDir","agentFiles","readdir","file","endsWith","agent","push","sessionFiles","getSessionFiles","sessionData","Array","isArray","getSessionStatus","mostRecentFile","getRecentTasks","limit","taskMetrics","sort","a","b","timestamp","slice","map","task","id","type","status","success","startTime","duration","endTime","getOverallHealth","systemMetrics","perfMetrics","memoryUsagePercent","cpuLoad","totalTasks","failureRate","failedTasks","files","filter","f","getMCPServerStatus","stdout","processCount","parseInt","trim","orchestratorOut","orchestratorRunning","isRunning","port","portOut","running","connections","Math","max"],"mappings":"AAAA,SAASA,YAAYC,EAAE,QAAQ,KAAK;AACpC,OAAOC,UAAU,OAAO;AACxB,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,SAAS,QAAQ,OAAO;AAEjC,MAAMC,YAAYD,UAAUD;AAE5B,IAAA,AAAMG,gBAAN,MAAMA;IACJ,aAAc;QACZ,IAAI,CAACC,UAAU,GAAG;QAClB,IAAI,CAACC,WAAW,GAAG;IACrB;IAEA,MAAMC,mBAAmB;QACvB,IAAI;YACF,MAAMC,WAAWR,KAAKS,IAAI,CAAC,IAAI,C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AO;YACd,OAAO,EAAE;QACX;IACF;IAEA,MAAMsD,qBAA+C;QACnD,IAAI;YAEF,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMpE,UAAU;YACnC,MAAMqE,eAAeC,SAASF,OAAOG,IAAI,IAAI;YAG7C,MAAM,EAAEH,QAAQI,eAAe,EAAE,GAAG,MAAMxE,UAAU;YACpD,MAAMyE,sBAAsBH,SAASE,gBAAgBD,IAAI,IAAI,MAAM;YAGnE,MAAMG,YAAYL,eAAe;YAGjC,IAAIM,OAAsB;YAC1B,IAAI;gBACF,MAAM,EAAEP,QAAQQ,OAAO,EAAE,GAAG,MAAM5E,UAAU;gBAC5C,IAAIsE,SAASM,QAAQL,IAAI,IAAI,QAAQ,GAAG;oBAEtCI,OAAO;gBACT;YACF,EAAE,OAAM,CAER;YAEA,OAAO;gBACLE,SAASH;gBACTL;gBACAI;gBACAE;gBACAG,aAAaT,eAAe,IAAIU,KAAKC,GAAG,CAAC,GAAGX,eAAe,KAAK;YAClE;QACF,EAAE,OAAOxD,OAAO;YAEd,OAAO;gBACLgE,SAAS;gBACTR,cAAc;gBACdI,qBAAqB;gBACrBE,MAAM;gBACNG,aAAa;YACf;QACF;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/metrics-reader.ts"],"sourcesContent":["import * as fs from 'fs/promises';\nimport * as path from 'path';\nimport { exec } from 'child_process';\nimport { promisify } from 'util';\n\nconst execAsync = promisify(exec);\n\ninterface SystemMetrics {\n timestamp: number;\n memoryTotal: number;\n memoryUsed: number;\n memoryFree: number;\n memoryUsagePercent: number;\n memoryEfficiency: number;\n cpuCount: number;\n cpuLoad: number;\n platform: string;\n uptime: number;\n}\n\ninterface TaskMetric {\n id: string;\n type: string;\n success: boolean;\n duration: number;\n timestamp: number;\n metadata: Record<string, any>;\n}\n\ninterface PerformanceMetrics {\n startTime: number;\n totalTasks: number;\n successfulTasks: number;\n failedTasks: number;\n totalAgents: number;\n activeAgents: number;\n neuralEvents: number;\n}\n\ninterface Agent {\n id: string;\n name: string;\n type: string;\n status: 'active' | 'idle' | 'busy';\n activeTasks: number;\n lastActivity?: number;\n}\n\ninterface SessionData {\n id: string;\n startTime: number;\n endTime?: number;\n agents: Agent[];\n tasks: any[];\n status: 'active' | 'completed' | 'paused';\n}\n\ninterface MCPServerStatus {\n running: boolean;\n processCount: number;\n orchestratorRunning: boolean;\n port: number | null;\n connections: number;\n}\n\nexport class MetricsReader {\n private metricsDir = '.claude-flow/metrics';\n private sessionsDir = '.claude-flow/sessions';\n\n async getSystemMetrics(): Promise<SystemMetrics | null> {\n try {\n const filePath = path.join(this.metricsDir, 'system-metrics.json');\n const content = await fs.readFile(filePath, 'utf8');\n const metrics: SystemMetrics[] = JSON.parse(content);\n \n // Return the most recent metric\n return metrics.length > 0 ? metrics[metrics.length - 1] : null;\n } catch (error) {\n return null;\n }\n }\n\n async getTaskMetrics(): Promise<TaskMetric[]> {\n try {\n const filePath = path.join(this.metricsDir, 'task-metrics.json');\n const content = await fs.readFile(filePath, 'utf8');\n return JSON.parse(content);\n } catch (error) {\n return [];\n }\n }\n\n async getPerformanceMetrics(): Promise<PerformanceMetrics | null> {\n try {\n const filePath = path.join(this.metricsDir, 'performance.json');\n const content = await fs.readFile(filePath, 'utf8');\n return JSON.parse(content);\n } catch (error) {\n return null;\n }\n }\n\n async getActiveAgents(): Promise<Agent[]> {\n try {\n // First check performance metrics for agent count\n const perfMetrics = await this.getPerformanceMetrics();\n \n // Also check session files for more detailed agent info\n const sessionFiles = await this.getSessionFiles();\n const agents: Agent[] = [];\n \n for (const file of sessionFiles) {\n try {\n const content = await fs.readFile(path.join(this.sessionsDir, 'pair', file), 'utf8');\n const sessionData = JSON.parse(content);\n \n if (sessionData.agents && Array.isArray(sessionData.agents)) {\n agents.push(...sessionData.agents);\n }\n } catch {\n // Skip invalid session files\n }\n }\n \n // If no agents found in sessions, create mock agents based on performance metrics\n if (agents.length === 0 && perfMetrics) {\n const activeCount = perfMetrics.activeAgents || 0;\n const totalCount = perfMetrics.totalAgents || 0;\n \n for (let i = 0; i < totalCount; i++) {\n agents.push({\n id: `agent-${i + 1}`,\n name: `Agent ${i + 1}`,\n type: i === 0 ? 'orchestrator' : 'worker',\n status: i < activeCount ? 'active' : 'idle',\n activeTasks: i < activeCount ? 1 : 0,\n lastActivity: Date.now() - (i * 1000)\n });\n }\n }\n \n return agents;\n } catch (error) {\n return [];\n }\n }\n\n async getSessionStatus(): Promise<SessionData | null> {\n try {\n const sessionFiles = await this.getSessionFiles();\n \n if (sessionFiles.length === 0) {\n return null;\n }\n \n // Get the most recent session\n const mostRecentFile = sessionFiles[sessionFiles.length - 1];\n const content = await fs.readFile(path.join(this.sessionsDir, 'pair', mostRecentFile), 'utf8');\n return JSON.parse(content);\n } catch (error) {\n return null;\n }\n }\n\n async getRecentTasks(limit: number = 10): Promise<any[]> {\n try {\n const taskMetrics = await this.getTaskMetrics();\n \n // Sort by timestamp descending and take the limit\n return taskMetrics\n .sort((a, b) => b.timestamp - a.timestamp)\n .slice(0, limit)\n .map(task => ({\n id: task.id,\n type: task.type,\n status: task.success ? 'completed' : 'failed',\n startTime: task.timestamp - task.duration,\n endTime: task.timestamp,\n duration: task.duration\n }));\n } catch (error) {\n return [];\n }\n }\n\n async getOverallHealth(): Promise<'healthy' | 'warning' | 'error'> {\n try {\n const systemMetrics = await this.getSystemMetrics();\n const perfMetrics = await this.getPerformanceMetrics();\n \n if (!systemMetrics && !perfMetrics) {\n return 'error';\n }\n \n // Check memory usage\n if (systemMetrics && systemMetrics.memoryUsagePercent > 90) {\n return 'error';\n }\n \n if (systemMetrics && systemMetrics.memoryUsagePercent > 75) {\n return 'warning';\n }\n \n // Check CPU load\n if (systemMetrics && systemMetrics.cpuLoad > 0.8) {\n return 'warning';\n }\n \n // Check task failure rate\n if (perfMetrics && perfMetrics.totalTasks > 0) {\n const failureRate = perfMetrics.failedTasks / perfMetrics.totalTasks;\n if (failureRate > 0.5) {\n return 'error';\n }\n if (failureRate > 0.2) {\n return 'warning';\n }\n }\n \n return 'healthy';\n } catch (error) {\n return 'error';\n }\n }\n\n private async getSessionFiles(): Promise<string[]> {\n try {\n const files = await fs.readdir(path.join(this.sessionsDir, 'pair'));\n return files.filter(f => f.endsWith('.json')).sort();\n } catch (error) {\n return [];\n }\n }\n\n async getMCPServerStatus(): Promise<MCPServerStatus> {\n try {\n // Check if MCP server process is running\n const { stdout } = await execAsync('ps aux | grep -E \"mcp-server\\\\.js|claude-flow mcp start\" | grep -v grep | wc -l');\n const processCount = parseInt(stdout.trim(), 10);\n \n // Check for orchestrator running\n const { stdout: orchestratorOut } = await execAsync('ps aux | grep -E \"claude-flow start\" | grep -v grep | wc -l');\n const orchestratorRunning = parseInt(orchestratorOut.trim(), 10) > 0;\n \n // Determine status\n const isRunning = processCount > 0;\n \n // Try to get port from process (default is 3000)\n let port: number | null = 3000;\n try {\n const { stdout: portOut } = await execAsync('lsof -i :3000 2>/dev/null | grep LISTEN | wc -l');\n if (parseInt(portOut.trim(), 10) === 0) {\n // If port 3000 not listening, check other common ports\n port = null;\n }\n } catch {\n // lsof might not be available or port not in use\n }\n \n return {\n running: isRunning,\n processCount,\n orchestratorRunning,\n port,\n connections: processCount > 0 ? Math.max(1, processCount - 1) : 0 // Estimate connections\n };\n } catch (error) {\n // Fallback if commands fail\n return {\n running: false,\n processCount: 0,\n orchestratorRunning: false,\n port: null,\n connections: 0\n };\n }\n }\n}"],"names":["fs","path","exec","promisify","execAsync","MetricsReader","metricsDir","sessionsDir","getSystemMetrics","filePath","join","content","readFile","metrics","JSON","parse","length","error","getTaskMetrics","getPerformanceMetrics","getActiveAgents","perfMetrics","sessionFiles","getSessionFiles","agents","file","sessionData","Array","isArray","push","activeCount","activeAgents","totalCount","totalAgents","i","id","name","type","status","activeTasks","lastActivity","Date","now","getSessionStatus","mostRecentFile","getRecentTasks","limit","taskMetrics","sort","a","b","timestamp","slice","map","task","success","startTime","duration","endTime","getOverallHealth","systemMetrics","memoryUsagePercent","cpuLoad","totalTasks","failureRate","failedTasks","files","readdir","filter","f","endsWith","getMCPServerStatus","stdout","processCount","parseInt","trim","orchestratorOut","orchestratorRunning","isRunning","port","portOut","running","connections","Math","max"],"mappings":"AAAA,YAAYA,QAAQ,cAAc;AAClC,YAAYC,UAAU,OAAO;AAC7B,SAASC,IAAI,QAAQ,gBAAgB;AACrC,SAASC,SAAS,QAAQ,OAAO;AAEjC,MAAMC,YAAYD,UAAUD;AA4D5B,OAAO,MAAMG;IACHC,aAAa,uBAAuB;IACpCC,cAAc,wBAAwB;IAE9C,MAAMC,mBAAkD;QACtD,IAAI;YACF,MAAMC,WAAWR,KAAKS,IAAI,CAAC,IAAI,CAACJ,UAAU,EAAE;YAC5C,MAAMK,UAAU,MAAMX,GAAGY,QAAQ,CAACH,UAAU;YAC5C,MAAMI,UAA2BC,KAAKC,KAAK,CAACJ;YAG5C,OAAOE,QAAQG,MAAM,GAAG,IAAIH,OAAO,CAACA,QAAQG,MAAM,GAAG,EAAE,GAAG;QAC5D,EAAE,OAAOC,OAAO;YACd,OAAO;QACT;IACF;IAEA,MAAMC,iBAAwC;QAC5C,IAAI;YACF,MAAMT,WAAWR,KAAKS,IAAI,CAAC,IAAI,CAACJ,UAAU,EAAE;YAC5C,MAAMK,UAAU,MAAMX,GAAGY,QAAQ,CAACH,UAAU;YAC5C,OAAOK,KAAKC,KAAK,CAACJ;QACpB,EAAE,OAAOM,OAAO;YACd,OAAO,EAAE;QACX;IACF;IAEA,MAAME,wBAA4D;QAChE,IAAI;YACF,MAAMV,WAAWR,KAAKS,IAAI,CAAC,IAAI,CAACJ,UAAU,EAAE;YAC5C,MAAMK,UAAU,MAAMX,GAAGY,QAAQ,CAACH,UAAU;YAC5C,OAAOK,KAAKC,KAAK,CAACJ;QACpB,EAAE,OAAOM,OAAO;YACd,OAAO;QACT;IACF;IAEA,MAAMG,kBAAoC;QACxC,IAAI;YAEF,MAAMC,cAAc,MAAM,IAAI,CAACF,qBAAqB;YAGpD,MAAMG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;QACT,EAAE,OAAO/C,OAAO;YACd,OAAO;QACT;IACF;IAEA,MAAcM,kBAAqC;QACjD,IAAI;YACF,MAAM2C,QAAQ,MAAMlE,GAAGmE,OAAO,CAAClE,KAAKS,IAAI,CAAC,IAAI,CAACH,WAAW,EAAE;YAC3D,OAAO2D,MAAME,MAAM,CAACC,CAAAA,IAAKA,EAAEC,QAAQ,CAAC,UAAUtB,IAAI;QACpD,EAAE,OAAO/B,OAAO;YACd,OAAO,EAAE;QACX;IACF;IAEA,MAAMsD,qBAA+C;QACnD,IAAI;YAEF,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMpE,UAAU;YACnC,MAAMqE,eAAeC,SAASF,OAAOG,IAAI,IAAI;YAG7C,MAAM,EAAEH,QAAQI,eAAe,EAAE,GAAG,MAAMxE,UAAU;YACpD,MAAMyE,sBAAsBH,SAASE,gBAAgBD,IAAI,IAAI,MAAM;YAGnE,MAAMG,YAAYL,eAAe;YAGjC,IAAIM,OAAsB;YAC1B,IAAI;gBACF,MAAM,EAAEP,QAAQQ,OAAO,EAAE,GAAG,MAAM5E,UAAU;gBAC5C,IAAIsE,SAASM,QAAQL,IAAI,IAAI,QAAQ,GAAG;oBAEtCI,OAAO;gBACT;YACF,EAAE,OAAM,CAER;YAEA,OAAO;gBACLE,SAASH;gBACTL;gBACAI;gBACAE;gBACAG,aAAaT,eAAe,IAAIU,KAAKC,GAAG,CAAC,GAAGX,eAAe,KAAK;YAClE;QACF,EAAE,OAAOxD,OAAO;YAEd,OAAO;gBACLgE,SAAS;gBACTR,cAAc;gBACdI,qBAAqB;gBACrBE,MAAM;gBACNG,aAAa;YACf;QACF;IACF;AACF"}
|
|
@@ -1,9 +1,87 @@
|
|
|
1
1
|
{
|
|
2
|
-
"startTime":
|
|
2
|
+
"startTime": 1761229787011,
|
|
3
|
+
"sessionId": "session-1761229787011",
|
|
4
|
+
"lastActivity": 1761229787011,
|
|
5
|
+
"sessionDuration": 0,
|
|
3
6
|
"totalTasks": 1,
|
|
4
7
|
"successfulTasks": 1,
|
|
5
8
|
"failedTasks": 0,
|
|
6
9
|
"totalAgents": 0,
|
|
7
10
|
"activeAgents": 0,
|
|
8
|
-
"neuralEvents": 0
|
|
11
|
+
"neuralEvents": 0,
|
|
12
|
+
"memoryMode": {
|
|
13
|
+
"reasoningbankOperations": 0,
|
|
14
|
+
"basicOperations": 0,
|
|
15
|
+
"autoModeSelections": 0,
|
|
16
|
+
"modeOverrides": 0,
|
|
17
|
+
"currentMode": "auto"
|
|
18
|
+
},
|
|
19
|
+
"operations": {
|
|
20
|
+
"store": {
|
|
21
|
+
"count": 0,
|
|
22
|
+
"totalDuration": 0,
|
|
23
|
+
"errors": 0
|
|
24
|
+
},
|
|
25
|
+
"retrieve": {
|
|
26
|
+
"count": 0,
|
|
27
|
+
"totalDuration": 0,
|
|
28
|
+
"errors": 0
|
|
29
|
+
},
|
|
30
|
+
"query": {
|
|
31
|
+
"count": 0,
|
|
32
|
+
"totalDuration": 0,
|
|
33
|
+
"errors": 0
|
|
34
|
+
},
|
|
35
|
+
"list": {
|
|
36
|
+
"count": 0,
|
|
37
|
+
"totalDuration": 0,
|
|
38
|
+
"errors": 0
|
|
39
|
+
},
|
|
40
|
+
"delete": {
|
|
41
|
+
"count": 0,
|
|
42
|
+
"totalDuration": 0,
|
|
43
|
+
"errors": 0
|
|
44
|
+
},
|
|
45
|
+
"search": {
|
|
46
|
+
"count": 0,
|
|
47
|
+
"totalDuration": 0,
|
|
48
|
+
"errors": 0
|
|
49
|
+
},
|
|
50
|
+
"init": {
|
|
51
|
+
"count": 0,
|
|
52
|
+
"totalDuration": 0,
|
|
53
|
+
"errors": 0
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"performance": {
|
|
57
|
+
"avgOperationDuration": 0,
|
|
58
|
+
"minOperationDuration": null,
|
|
59
|
+
"maxOperationDuration": null,
|
|
60
|
+
"slowOperations": 0,
|
|
61
|
+
"fastOperations": 0,
|
|
62
|
+
"totalOperationTime": 0
|
|
63
|
+
},
|
|
64
|
+
"storage": {
|
|
65
|
+
"totalEntries": 0,
|
|
66
|
+
"reasoningbankEntries": 0,
|
|
67
|
+
"basicEntries": 0,
|
|
68
|
+
"databaseSize": 0,
|
|
69
|
+
"lastBackup": null,
|
|
70
|
+
"growthRate": 0
|
|
71
|
+
},
|
|
72
|
+
"errors": {
|
|
73
|
+
"total": 0,
|
|
74
|
+
"byType": {},
|
|
75
|
+
"byOperation": {},
|
|
76
|
+
"recent": []
|
|
77
|
+
},
|
|
78
|
+
"reasoningbank": {
|
|
79
|
+
"semanticSearches": 0,
|
|
80
|
+
"sqlFallbacks": 0,
|
|
81
|
+
"embeddingGenerated": 0,
|
|
82
|
+
"consolidations": 0,
|
|
83
|
+
"avgQueryTime": 0,
|
|
84
|
+
"cacheHits": 0,
|
|
85
|
+
"cacheMisses": 0
|
|
86
|
+
}
|
|
9
87
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"id": "cmd-hooks-
|
|
3
|
+
"id": "cmd-hooks-1761229787109",
|
|
4
4
|
"type": "hooks",
|
|
5
5
|
"success": true,
|
|
6
|
-
"duration": 7.
|
|
7
|
-
"timestamp":
|
|
6
|
+
"duration": 7.501108999999985,
|
|
7
|
+
"timestamp": 1761229787117,
|
|
8
8
|
"metadata": {}
|
|
9
9
|
}
|
|
10
10
|
]
|
package/docs/INDEX.md
CHANGED
|
@@ -256,27 +256,52 @@ npx claude-flow@alpha --agents 3 swarm "task description"
|
|
|
256
256
|
docs/
|
|
257
257
|
├── 📄 README.md & INDEX.md # Core entry points
|
|
258
258
|
│
|
|
259
|
+
├── 🚀 releases/ # Release Notes & Changelogs
|
|
260
|
+
│ ├── RELEASE_v2.7.1.md # v2.7.1 release notes
|
|
261
|
+
│ ├── RELEASE_SUMMARY_v2.7.1.md # v2.7.1 summary
|
|
262
|
+
│ ├── RELEASE-NOTES-v2.7.0-alpha.10.md # Alpha 10 release notes
|
|
263
|
+
│ ├── RELEASE-NOTES-v2.7.0-alpha.9.md # Alpha 9 release notes
|
|
264
|
+
│ └── ALPHA_TAG_UPDATE.md # Alpha versioning guide
|
|
265
|
+
│
|
|
266
|
+
├── 🧠 agentdb/ # AgentDB v1.3.9 Integration
|
|
267
|
+
│ ├── SWARM_IMPLEMENTATION_COMPLETE.md # 3-agent swarm (180 tests)
|
|
268
|
+
│ ├── AGENTDB_INTEGRATION_PLAN.md # Integration planning
|
|
269
|
+
│ ├── BACKWARD_COMPATIBILITY_GUARANTEE.md # 100% compatibility
|
|
270
|
+
│ ├── PUBLISHING_CHECKLIST.md # Pre-release verification
|
|
271
|
+
│ ├── agentdb-integration-summary.md # Quick overview
|
|
272
|
+
│ ├── PRODUCTION_READINESS.md # Deployment guide
|
|
273
|
+
│ └── OPTIMIZATION_REPORT.md # Performance analysis
|
|
274
|
+
│
|
|
275
|
+
├── ⚡ performance/ # Performance Optimization
|
|
276
|
+
│ ├── PERFORMANCE-JSON-IMPROVEMENTS.md # JSON optimization
|
|
277
|
+
│ └── PERFORMANCE-METRICS-GUIDE.md # Metrics tracking
|
|
278
|
+
│
|
|
279
|
+
├── 🔧 fixes/ # Bug Fixes & Patches
|
|
280
|
+
│ ├── PATTERN_PERSISTENCE_FIX.md # v2.7.1 critical fix
|
|
281
|
+
│ ├── PATTERN_FIX_CONFIRMATION.md # Verification results
|
|
282
|
+
│ └── CLI-MEMORY-COMMANDS-WORKING.md # Memory command fixes
|
|
283
|
+
│
|
|
284
|
+
├── 🛠️ development/ # Development Reports
|
|
285
|
+
│ ├── AGENT1_COMPLETION_REPORT.md # AgentDB integration agent
|
|
286
|
+
│ ├── FINAL_INIT_STRUCTURE.md # Initialization architecture
|
|
287
|
+
│ └── COMMANDS_TO_SKILLS_MIGRATION.md # Migration guide
|
|
288
|
+
│
|
|
289
|
+
├── ✅ validation/ # Testing & Validation
|
|
290
|
+
│ └── DOCKER_VERIFICATION_REPORT.md # Docker testing results
|
|
291
|
+
│
|
|
292
|
+
├── 📚 guides/ # User Guides & Tutorials
|
|
293
|
+
│ └── skills-tutorial.md # 25 Claude Flow skills
|
|
294
|
+
│
|
|
259
295
|
├── 🔌 integrations/ # Platform Integrations
|
|
260
296
|
│ ├── reasoningbank/ # ReasoningBank AI integration (16 docs)
|
|
261
297
|
│ ├── agentic-flow/ # Agentic Flow system (5 docs)
|
|
262
298
|
│ ├── agent-booster/ # Agent performance optimization
|
|
263
299
|
│ └── epic-sdk/ # Epic SDK integration
|
|
264
300
|
│
|
|
265
|
-
├── 📊 reports/ # Analysis & Reports
|
|
266
|
-
│ ├── validation/ # Validation & testing reports (7 docs)
|
|
267
|
-
│ ├── releases/ # Release notes & summaries (4 docs)
|
|
268
|
-
│ └── analysis/ # Deep analysis & reviews (2 docs)
|
|
269
|
-
│
|
|
270
|
-
├── 🔧 technical/ # Technical Details
|
|
271
|
-
│ ├── fixes/ # Technical fix summaries (2 docs)
|
|
272
|
-
│ └── performance/ # Performance reports & metrics
|
|
273
|
-
│
|
|
274
301
|
├── 🏗️ architecture/ # Architecture documentation
|
|
275
|
-
├── 📚 guides/ # User guides & tutorials
|
|
276
302
|
├── 🔬 experimental/ # Experimental features
|
|
277
303
|
├── 📘 reference/ # API & command reference
|
|
278
|
-
├── ⚙️ setup/ # Setup & configuration
|
|
279
|
-
├── ✅ validation/ # Validation frameworks
|
|
304
|
+
├── ⚙️ setup/ # Setup & configuration
|
|
280
305
|
├── 🔄 ci-cd/ # CI/CD workflows
|
|
281
306
|
├── 📦 sdk/ # SDK documentation
|
|
282
307
|
└── 📖 wiki/ # Additional wiki content
|