claude-flow 2.7.0-alpha.7 → 2.7.0-alpha.8
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/bin/claude-flow +1 -1
- package/dist/src/cli/help-formatter.js +5 -0
- package/dist/src/cli/simple-commands/memory.js +22 -15
- package/dist/src/cli/simple-commands/memory.js.map +1 -1
- package/dist/src/cli/simple-commands/performance-metrics.js +231 -1
- package/dist/src/cli/simple-commands/performance-metrics.js.map +1 -1
- package/dist/src/cli/validation-helper.js.map +1 -1
- package/dist/src/core/version.js.map +1 -1
- package/dist/src/memory/swarm-memory.js +340 -421
- 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 +37 -39
- package/dist/src/utils/metrics-reader.js.map +1 -1
- package/docs/.claude-flow/metrics/performance.json +1 -1
- package/docs/.claude-flow/metrics/task-metrics.json +3 -3
- package/docs/PERFORMANCE-JSON-IMPROVEMENTS.md +277 -0
- package/docs/PERFORMANCE-METRICS-GUIDE.md +259 -0
- package/docs/integrations/agentic-flow/AGENTIC_FLOW_SECURITY_TEST_REPORT.md +7 -7
- package/docs/integrations/reasoningbank/MIGRATION-v1.5.13.md +189 -0
- package/docs/reports/REASONINGBANK_STATUS_UPDATE_v2_7_0_alpha_7.md +366 -0
- package/docs/reports/validation/DOCKER_SQL_FALLBACK_VALIDATION.md +398 -0
- package/docs/reports/validation/MEMORY_REDACTION_TEST_REPORT.md +7 -7
- package/docs/reports/validation/SQL_FALLBACK_VALIDATION_REPORT.md +405 -0
- package/docs/setup/MCP-SETUP-GUIDE.md +154 -0
- package/package.json +5 -6
- package/src/cli/simple-commands/memory.js +27 -17
- package/src/cli/simple-commands/performance-metrics.js +268 -2
- package/src/reasoningbank/reasoningbank-adapter.js +183 -132
|
@@ -21,13 +21,78 @@ let metricsCache = {
|
|
|
21
21
|
agents: {},
|
|
22
22
|
system: [],
|
|
23
23
|
performance: {
|
|
24
|
+
// Session information
|
|
24
25
|
startTime: Date.now(),
|
|
26
|
+
sessionId: `session-${Date.now()}`,
|
|
27
|
+
lastActivity: Date.now(),
|
|
28
|
+
sessionDuration: 0,
|
|
29
|
+
|
|
30
|
+
// General task metrics
|
|
25
31
|
totalTasks: 0,
|
|
26
32
|
successfulTasks: 0,
|
|
27
33
|
failedTasks: 0,
|
|
28
34
|
totalAgents: 0,
|
|
29
35
|
activeAgents: 0,
|
|
30
|
-
neuralEvents: 0
|
|
36
|
+
neuralEvents: 0,
|
|
37
|
+
|
|
38
|
+
// Memory mode tracking
|
|
39
|
+
memoryMode: {
|
|
40
|
+
reasoningbankOperations: 0,
|
|
41
|
+
basicOperations: 0,
|
|
42
|
+
autoModeSelections: 0,
|
|
43
|
+
modeOverrides: 0,
|
|
44
|
+
currentMode: 'auto'
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
// Operation type breakdown
|
|
48
|
+
operations: {
|
|
49
|
+
store: { count: 0, totalDuration: 0, errors: 0 },
|
|
50
|
+
retrieve: { count: 0, totalDuration: 0, errors: 0 },
|
|
51
|
+
query: { count: 0, totalDuration: 0, errors: 0 },
|
|
52
|
+
list: { count: 0, totalDuration: 0, errors: 0 },
|
|
53
|
+
delete: { count: 0, totalDuration: 0, errors: 0 },
|
|
54
|
+
search: { count: 0, totalDuration: 0, errors: 0 },
|
|
55
|
+
init: { count: 0, totalDuration: 0, errors: 0 }
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
// Performance statistics
|
|
59
|
+
performance: {
|
|
60
|
+
avgOperationDuration: 0,
|
|
61
|
+
minOperationDuration: null,
|
|
62
|
+
maxOperationDuration: null,
|
|
63
|
+
slowOperations: 0, // Count of operations > 5s
|
|
64
|
+
fastOperations: 0, // Count of operations < 100ms
|
|
65
|
+
totalOperationTime: 0
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
// Memory storage statistics
|
|
69
|
+
storage: {
|
|
70
|
+
totalEntries: 0,
|
|
71
|
+
reasoningbankEntries: 0,
|
|
72
|
+
basicEntries: 0,
|
|
73
|
+
databaseSize: 0,
|
|
74
|
+
lastBackup: null,
|
|
75
|
+
growthRate: 0
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// Error tracking
|
|
79
|
+
errors: {
|
|
80
|
+
total: 0,
|
|
81
|
+
byType: {},
|
|
82
|
+
byOperation: {},
|
|
83
|
+
recent: []
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
// ReasoningBank specific metrics
|
|
87
|
+
reasoningbank: {
|
|
88
|
+
semanticSearches: 0,
|
|
89
|
+
sqlFallbacks: 0,
|
|
90
|
+
embeddingGenerated: 0,
|
|
91
|
+
consolidations: 0,
|
|
92
|
+
avgQueryTime: 0,
|
|
93
|
+
cacheHits: 0,
|
|
94
|
+
cacheMisses: 0
|
|
95
|
+
}
|
|
31
96
|
}
|
|
32
97
|
};
|
|
33
98
|
|
|
@@ -162,10 +227,211 @@ export async function trackAgentActivity(agentId, agentType, action, duration, s
|
|
|
162
227
|
// Track neural events
|
|
163
228
|
export async function trackNeuralEvent(eventType, metadata = {}) {
|
|
164
229
|
metricsCache.performance.neuralEvents++;
|
|
165
|
-
|
|
230
|
+
|
|
166
231
|
await saveMetricsToDisk();
|
|
167
232
|
}
|
|
168
233
|
|
|
234
|
+
// Track memory operations
|
|
235
|
+
export async function trackMemoryOperation(operationType, mode, duration, success = true, errorType = null) {
|
|
236
|
+
// Update session activity
|
|
237
|
+
metricsCache.performance.lastActivity = Date.now();
|
|
238
|
+
metricsCache.performance.sessionDuration = Date.now() - metricsCache.performance.startTime;
|
|
239
|
+
|
|
240
|
+
// Track mode usage
|
|
241
|
+
if (mode === 'reasoningbank') {
|
|
242
|
+
metricsCache.performance.memoryMode.reasoningbankOperations++;
|
|
243
|
+
} else if (mode === 'basic') {
|
|
244
|
+
metricsCache.performance.memoryMode.basicOperations++;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Track operation type
|
|
248
|
+
if (metricsCache.performance.operations[operationType]) {
|
|
249
|
+
const op = metricsCache.performance.operations[operationType];
|
|
250
|
+
op.count++;
|
|
251
|
+
op.totalDuration += duration;
|
|
252
|
+
|
|
253
|
+
if (!success) {
|
|
254
|
+
op.errors++;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Update performance statistics
|
|
259
|
+
const perf = metricsCache.performance.performance;
|
|
260
|
+
perf.totalOperationTime += duration;
|
|
261
|
+
|
|
262
|
+
const totalOps = Object.values(metricsCache.performance.operations)
|
|
263
|
+
.reduce((sum, op) => sum + op.count, 0);
|
|
264
|
+
|
|
265
|
+
if (totalOps > 0) {
|
|
266
|
+
perf.avgOperationDuration = perf.totalOperationTime / totalOps;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (perf.minOperationDuration === null || duration < perf.minOperationDuration) {
|
|
270
|
+
perf.minOperationDuration = duration;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (perf.maxOperationDuration === null || duration > perf.maxOperationDuration) {
|
|
274
|
+
perf.maxOperationDuration = duration;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (duration > 5000) {
|
|
278
|
+
perf.slowOperations++;
|
|
279
|
+
} else if (duration < 100) {
|
|
280
|
+
perf.fastOperations++;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// Track errors
|
|
284
|
+
if (!success && errorType) {
|
|
285
|
+
metricsCache.performance.errors.total++;
|
|
286
|
+
|
|
287
|
+
// Track by type
|
|
288
|
+
if (!metricsCache.performance.errors.byType[errorType]) {
|
|
289
|
+
metricsCache.performance.errors.byType[errorType] = 0;
|
|
290
|
+
}
|
|
291
|
+
metricsCache.performance.errors.byType[errorType]++;
|
|
292
|
+
|
|
293
|
+
// Track by operation
|
|
294
|
+
if (!metricsCache.performance.errors.byOperation[operationType]) {
|
|
295
|
+
metricsCache.performance.errors.byOperation[operationType] = 0;
|
|
296
|
+
}
|
|
297
|
+
metricsCache.performance.errors.byOperation[operationType]++;
|
|
298
|
+
|
|
299
|
+
// Add to recent errors (keep last 20)
|
|
300
|
+
metricsCache.performance.errors.recent.push({
|
|
301
|
+
operation: operationType,
|
|
302
|
+
type: errorType,
|
|
303
|
+
timestamp: Date.now(),
|
|
304
|
+
mode
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
if (metricsCache.performance.errors.recent.length > 20) {
|
|
308
|
+
metricsCache.performance.errors.recent = metricsCache.performance.errors.recent.slice(-20);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
await saveMetricsToDisk();
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Track mode selection (auto, override)
|
|
316
|
+
export async function trackModeSelection(selectedMode, wasAutomatic = true) {
|
|
317
|
+
metricsCache.performance.memoryMode.currentMode = selectedMode;
|
|
318
|
+
|
|
319
|
+
if (wasAutomatic) {
|
|
320
|
+
metricsCache.performance.memoryMode.autoModeSelections++;
|
|
321
|
+
} else {
|
|
322
|
+
metricsCache.performance.memoryMode.modeOverrides++;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
await saveMetricsToDisk();
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// Track ReasoningBank specific operations
|
|
329
|
+
export async function trackReasoningBankOperation(operationType, duration, metadata = {}) {
|
|
330
|
+
const rb = metricsCache.performance.reasoningbank;
|
|
331
|
+
|
|
332
|
+
switch (operationType) {
|
|
333
|
+
case 'semantic_search':
|
|
334
|
+
rb.semanticSearches++;
|
|
335
|
+
break;
|
|
336
|
+
case 'sql_fallback':
|
|
337
|
+
rb.sqlFallbacks++;
|
|
338
|
+
break;
|
|
339
|
+
case 'embedding_generated':
|
|
340
|
+
rb.embeddingGenerated++;
|
|
341
|
+
break;
|
|
342
|
+
case 'consolidation':
|
|
343
|
+
rb.consolidations++;
|
|
344
|
+
break;
|
|
345
|
+
case 'cache_hit':
|
|
346
|
+
rb.cacheHits++;
|
|
347
|
+
break;
|
|
348
|
+
case 'cache_miss':
|
|
349
|
+
rb.cacheMisses++;
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// Update average query time
|
|
354
|
+
const totalQueries = rb.semanticSearches + rb.sqlFallbacks;
|
|
355
|
+
if (totalQueries > 0) {
|
|
356
|
+
rb.avgQueryTime = ((rb.avgQueryTime * (totalQueries - 1)) + duration) / totalQueries;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
await saveMetricsToDisk();
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// Update storage statistics
|
|
363
|
+
export async function updateStorageStats(totalEntries, reasoningbankEntries, basicEntries, databaseSize = 0) {
|
|
364
|
+
const storage = metricsCache.performance.storage;
|
|
365
|
+
|
|
366
|
+
const previousTotal = storage.totalEntries;
|
|
367
|
+
storage.totalEntries = totalEntries;
|
|
368
|
+
storage.reasoningbankEntries = reasoningbankEntries;
|
|
369
|
+
storage.basicEntries = basicEntries;
|
|
370
|
+
storage.databaseSize = databaseSize;
|
|
371
|
+
|
|
372
|
+
// Calculate growth rate (entries per hour)
|
|
373
|
+
if (previousTotal > 0) {
|
|
374
|
+
const sessionHours = metricsCache.performance.sessionDuration / (1000 * 60 * 60);
|
|
375
|
+
if (sessionHours > 0) {
|
|
376
|
+
storage.growthRate = (totalEntries - previousTotal) / sessionHours;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
await saveMetricsToDisk();
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// Get memory performance summary
|
|
384
|
+
export async function getMemoryPerformanceSummary() {
|
|
385
|
+
const perf = metricsCache.performance;
|
|
386
|
+
const totalOps = Object.values(perf.operations).reduce((sum, op) => sum + op.count, 0);
|
|
387
|
+
const totalErrors = Object.values(perf.operations).reduce((sum, op) => sum + op.errors, 0);
|
|
388
|
+
|
|
389
|
+
return {
|
|
390
|
+
session: {
|
|
391
|
+
sessionId: perf.sessionId,
|
|
392
|
+
duration: perf.sessionDuration,
|
|
393
|
+
startTime: new Date(perf.startTime).toISOString(),
|
|
394
|
+
lastActivity: new Date(perf.lastActivity).toISOString()
|
|
395
|
+
},
|
|
396
|
+
mode: {
|
|
397
|
+
current: perf.memoryMode.currentMode,
|
|
398
|
+
reasoningbankUsage: perf.memoryMode.reasoningbankOperations,
|
|
399
|
+
basicUsage: perf.memoryMode.basicOperations,
|
|
400
|
+
autoSelections: perf.memoryMode.autoModeSelections,
|
|
401
|
+
manualOverrides: perf.memoryMode.modeOverrides
|
|
402
|
+
},
|
|
403
|
+
operations: {
|
|
404
|
+
total: totalOps,
|
|
405
|
+
breakdown: perf.operations,
|
|
406
|
+
errors: totalErrors,
|
|
407
|
+
errorRate: totalOps > 0 ? (totalErrors / totalOps) * 100 : 0
|
|
408
|
+
},
|
|
409
|
+
performance: {
|
|
410
|
+
avgDuration: perf.performance.avgOperationDuration,
|
|
411
|
+
minDuration: perf.performance.minOperationDuration,
|
|
412
|
+
maxDuration: perf.performance.maxOperationDuration,
|
|
413
|
+
slowOps: perf.performance.slowOperations,
|
|
414
|
+
fastOps: perf.performance.fastOperations
|
|
415
|
+
},
|
|
416
|
+
storage: perf.storage,
|
|
417
|
+
reasoningbank: {
|
|
418
|
+
...perf.reasoningbank,
|
|
419
|
+
fallbackRate: perf.reasoningbank.semanticSearches > 0
|
|
420
|
+
? (perf.reasoningbank.sqlFallbacks / perf.reasoningbank.semanticSearches) * 100
|
|
421
|
+
: 0,
|
|
422
|
+
cacheHitRate: (perf.reasoningbank.cacheHits + perf.reasoningbank.cacheMisses) > 0
|
|
423
|
+
? (perf.reasoningbank.cacheHits / (perf.reasoningbank.cacheHits + perf.reasoningbank.cacheMisses)) * 100
|
|
424
|
+
: 0
|
|
425
|
+
},
|
|
426
|
+
errors: {
|
|
427
|
+
total: perf.errors.total,
|
|
428
|
+
byType: perf.errors.byType,
|
|
429
|
+
byOperation: perf.errors.byOperation,
|
|
430
|
+
recent: perf.errors.recent.slice(-5)
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
|
|
169
435
|
// Get performance report data
|
|
170
436
|
export async function getPerformanceReport(timeframe = '24h') {
|
|
171
437
|
const now = Date.now();
|