claude-flow-novice 2.0.3 → 2.0.4
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/dist/src/cli/commands/guidance.js +487 -668
- package/dist/src/cli/commands/index-validate.js +18 -29
- package/dist/src/cli/commands/mcp-troubleshoot.js +230 -282
- package/dist/src/cli/commands/neural-goal-init.js +92 -125
- package/dist/src/cli/commands/swarm-exec.js +317 -393
- package/dist/src/cli/commands/swarm.js +1 -1
- package/dist/src/cli/commands/validate-framework.js +983 -1100
- package/dist/src/cli/commands/validate.js +144 -223
- package/dist/src/cli/simple-commands/__tests__/agent.test.js +265 -277
- package/dist/src/cli/simple-commands/__tests__/memory.test.js +6 -7
- package/dist/src/cli/simple-commands/__tests__/swarm.test.js +373 -356
- package/dist/src/cli/simple-commands/__tests__/task.test.js +6 -7
- package/dist/src/cli/simple-commands/agent.js +157 -193
- package/dist/src/cli/simple-commands/analysis.js +336 -446
- package/dist/src/cli/simple-commands/automation-executor.js +1095 -1339
- package/dist/src/cli/simple-commands/automation.js +481 -469
- package/dist/src/cli/simple-commands/batch-manager.js +261 -313
- package/dist/src/cli/simple-commands/claude-telemetry.js +241 -267
- package/dist/src/cli/simple-commands/claude-track.js +68 -90
- package/dist/src/cli/simple-commands/concurrent-display.js +266 -320
- package/dist/src/cli/simple-commands/config.js +245 -290
- package/dist/src/cli/simple-commands/coordination.js +182 -234
- package/dist/src/cli/simple-commands/enhanced-ui-views.js +812 -615
- package/dist/src/cli/simple-commands/enhanced-webui-complete.js +922 -981
- package/dist/src/cli/simple-commands/fix-hook-variables.js +274 -294
- package/dist/src/cli/simple-commands/github/gh-coordinator.js +378 -457
- package/dist/src/cli/simple-commands/github/github-api.js +535 -574
- package/dist/src/cli/simple-commands/github/init.js +276 -303
- package/dist/src/cli/simple-commands/github.js +222 -247
- package/dist/src/cli/simple-commands/goal.js +51 -63
- package/dist/src/cli/simple-commands/hive-mind/auto-save-middleware.js +208 -278
- package/dist/src/cli/simple-commands/hive-mind/communication.js +601 -696
- package/dist/src/cli/simple-commands/hive-mind/core.js +907 -979
- package/dist/src/cli/simple-commands/hive-mind/db-optimizer.js +406 -655
- package/dist/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1125 -1245
- package/dist/src/cli/simple-commands/hive-mind/memory.js +854 -1090
- package/dist/src/cli/simple-commands/hive-mind/performance-optimizer.js +459 -574
- package/dist/src/cli/simple-commands/hive-mind/performance-test.js +263 -347
- package/dist/src/cli/simple-commands/hive-mind/queen.js +727 -768
- package/dist/src/cli/simple-commands/hive-mind/session-manager.js +745 -1049
- package/dist/src/cli/simple-commands/hive-mind-optimize.js +227 -283
- package/dist/src/cli/simple-commands/hive-mind-wizard.js +174 -217
- package/dist/src/cli/simple-commands/hive-mind.js +1842 -2283
- package/dist/src/cli/simple-commands/hive.js +90 -79
- package/dist/src/cli/simple-commands/hook-safety.js +431 -521
- package/dist/src/cli/simple-commands/hooks/session-start-soul.js +203 -254
- package/dist/src/cli/simple-commands/hooks.js +1064 -1204
- package/dist/src/cli/simple-commands/init/agent-copier.js +294 -319
- package/dist/src/cli/simple-commands/init/batch-init.js +496 -562
- package/dist/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +13 -19
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +13 -19
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +61 -88
- package/dist/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +125 -150
- package/dist/src/cli/simple-commands/init/claude-commands/slash-commands.js +42 -49
- package/dist/src/cli/simple-commands/init/claude-commands/sparc-commands.js +43 -61
- package/dist/src/cli/simple-commands/init/copy-revised-templates.js +141 -147
- package/dist/src/cli/simple-commands/init/executable-wrapper.js +31 -44
- package/dist/src/cli/simple-commands/init/gitignore-updater.js +64 -90
- package/dist/src/cli/simple-commands/init/help.js +104 -107
- package/dist/src/cli/simple-commands/init/hive-mind-init.js +509 -528
- package/dist/src/cli/simple-commands/init/index.js +1510 -1759
- package/dist/src/cli/simple-commands/init/performance-monitor.js +234 -317
- package/dist/src/cli/simple-commands/init/rollback/backup-manager.js +441 -504
- package/dist/src/cli/simple-commands/init/rollback/index.js +289 -364
- package/dist/src/cli/simple-commands/init/rollback/recovery-manager.js +652 -728
- package/dist/src/cli/simple-commands/init/rollback/rollback-executor.js +416 -481
- package/dist/src/cli/simple-commands/init/rollback/state-tracker.js +369 -448
- package/dist/src/cli/simple-commands/init/sparc/roo-readme.js +1 -2
- package/dist/src/cli/simple-commands/init/sparc/roomodes-config.js +122 -99
- package/dist/src/cli/simple-commands/init/sparc/workflows.js +32 -37
- package/dist/src/cli/simple-commands/init/sparc-structure.js +55 -62
- package/dist/src/cli/simple-commands/init/template-copier.js +421 -533
- package/dist/src/cli/simple-commands/init/templates/coordination-md.js +3 -6
- package/dist/src/cli/simple-commands/init/templates/enhanced-templates.js +344 -318
- package/dist/src/cli/simple-commands/init/templates/github-safe-enhanced.js +173 -218
- package/dist/src/cli/simple-commands/init/templates/github-safe.js +65 -75
- package/dist/src/cli/simple-commands/init/templates/memory-bank-md.js +3 -6
- package/dist/src/cli/simple-commands/init/templates/readme-files.js +2 -4
- package/dist/src/cli/simple-commands/init/templates/safe-hook-patterns.js +187 -230
- package/dist/src/cli/simple-commands/init/templates/sparc-modes.js +53 -80
- package/dist/src/cli/simple-commands/init/templates/verification-claude-md.js +101 -85
- package/dist/src/cli/simple-commands/init/validation/config-validator.js +283 -330
- package/dist/src/cli/simple-commands/init/validation/health-checker.js +495 -561
- package/dist/src/cli/simple-commands/init/validation/index.js +302 -358
- package/dist/src/cli/simple-commands/init/validation/mode-validator.js +308 -359
- package/dist/src/cli/simple-commands/init/validation/post-init-validator.js +389 -366
- package/dist/src/cli/simple-commands/init/validation/pre-init-validator.js +270 -268
- package/dist/src/cli/simple-commands/init/validation/test-runner.js +427 -447
- package/dist/src/cli/simple-commands/init.js +1 -2
- package/dist/src/cli/simple-commands/mcp-health.js +131 -158
- package/dist/src/cli/simple-commands/mcp-integration-layer.js +533 -634
- package/dist/src/cli/simple-commands/mcp.js +345 -400
- package/dist/src/cli/simple-commands/memory-consolidation.js +426 -537
- package/dist/src/cli/simple-commands/memory.js +247 -311
- package/dist/src/cli/simple-commands/migrate-hooks.js +39 -46
- package/dist/src/cli/simple-commands/monitor.js +294 -363
- package/dist/src/cli/simple-commands/neural.js +51 -65
- package/dist/src/cli/simple-commands/pair-autofix-only.js +538 -662
- package/dist/src/cli/simple-commands/pair-basic.js +528 -656
- package/dist/src/cli/simple-commands/pair-old.js +430 -543
- package/dist/src/cli/simple-commands/pair-working.js +615 -751
- package/dist/src/cli/simple-commands/pair.js +615 -751
- package/dist/src/cli/simple-commands/performance-hooks.js +83 -111
- package/dist/src/cli/simple-commands/performance-metrics.js +348 -433
- package/dist/src/cli/simple-commands/process-ui-enhanced.js +708 -787
- package/dist/src/cli/simple-commands/process-ui.js +230 -254
- package/dist/src/cli/simple-commands/realtime-update-system.js +525 -611
- package/dist/src/cli/simple-commands/sparc/architecture.js +1704 -1530
- package/dist/src/cli/simple-commands/sparc/commands.js +438 -516
- package/dist/src/cli/simple-commands/sparc/completion.js +1224 -1481
- package/dist/src/cli/simple-commands/sparc/coordinator.js +913 -978
- package/dist/src/cli/simple-commands/sparc/index.js +241 -298
- package/dist/src/cli/simple-commands/sparc/phase-base.js +314 -390
- package/dist/src/cli/simple-commands/sparc/pseudocode.js +965 -869
- package/dist/src/cli/simple-commands/sparc/refinement.js +980 -1273
- package/dist/src/cli/simple-commands/sparc/specification.js +559 -645
- package/dist/src/cli/simple-commands/sparc-modes/architect.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/ask.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/code.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/debug.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/devops.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/docs-writer.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/generic.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/index.js +47 -55
- package/dist/src/cli/simple-commands/sparc-modes/integration.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/mcp.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/monitoring.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/optimization.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/security-review.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/supabase-admin.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/swarm.js +101 -87
- package/dist/src/cli/simple-commands/sparc-modes/tdd.js +1 -1
- package/dist/src/cli/simple-commands/sparc-modes/tutorial.js +1 -1
- package/dist/src/cli/simple-commands/sparc.js +465 -493
- package/dist/src/cli/simple-commands/start-ui.js +108 -132
- package/dist/src/cli/simple-commands/start-wrapper.js +240 -268
- package/dist/src/cli/simple-commands/start.js +1 -1
- package/dist/src/cli/simple-commands/status.js +254 -275
- package/dist/src/cli/simple-commands/stream-chain-clean.js +128 -171
- package/dist/src/cli/simple-commands/stream-chain-fixed.js +61 -82
- package/dist/src/cli/simple-commands/stream-chain-real.js +267 -331
- package/dist/src/cli/simple-commands/stream-chain-working.js +211 -263
- package/dist/src/cli/simple-commands/stream-chain.js +260 -318
- package/dist/src/cli/simple-commands/stream-processor.js +290 -315
- package/dist/src/cli/simple-commands/swarm-executor.js +189 -222
- package/dist/src/cli/simple-commands/swarm-metrics-integration.js +208 -300
- package/dist/src/cli/simple-commands/swarm-ui.js +623 -703
- package/dist/src/cli/simple-commands/swarm-webui-integration.js +258 -286
- package/dist/src/cli/simple-commands/swarm.js +887 -1082
- package/dist/src/cli/simple-commands/task.js +161 -206
- package/dist/src/cli/simple-commands/timestamp-fix.js +59 -89
- package/dist/src/cli/simple-commands/token-tracker.js +258 -316
- package/dist/src/cli/simple-commands/tool-execution-framework.js +433 -519
- package/dist/src/cli/simple-commands/train-and-stream.js +275 -331
- package/dist/src/cli/simple-commands/training-pipeline.js +619 -725
- package/dist/src/cli/simple-commands/training.js +170 -227
- package/dist/src/cli/simple-commands/verification-hooks.js +261 -284
- package/dist/src/cli/simple-commands/verification-integration.js +389 -417
- package/dist/src/cli/simple-commands/verification-training-integration.js +486 -606
- package/dist/src/cli/simple-commands/verification.js +493 -513
- package/dist/src/cli/simple-commands/web-server.js +766 -836
- package/dist/src/cli/simple-commands/webui-validator.js +106 -124
- package/dist/src/coordination/event-bus/demo-wasm-integration.js +212 -251
- package/dist/src/coordination/event-bus/qe-event-bus.js +608 -748
- package/dist/src/coordination/event-bus/qe-event-bus.test.js +379 -454
- package/dist/src/coordination/iteration-tracker.js +363 -454
- package/dist/src/enterprise/analytics-manager.js +1135 -0
- package/dist/src/enterprise/audit-manager.js +1115 -0
- package/dist/src/enterprise/cloud-manager.js +891 -0
- package/dist/src/enterprise/deployment-manager.js +966 -0
- package/dist/src/enterprise/index.js +6 -0
- package/dist/src/enterprise/project-manager.js +584 -0
- package/dist/src/enterprise/security-manager.js +991 -0
- package/dist/src/index.js +1 -1
- package/dist/src/mcp/DEPRECATED.js +46 -60
- package/dist/src/mcp/fixes/mcp-error-fixes.js +115 -134
- package/dist/src/mcp/implementations/agent-tracker.js +114 -128
- package/dist/src/mcp/implementations/daa-tools.js +292 -350
- package/dist/src/mcp/implementations/workflow-tools.js +329 -361
- package/dist/src/mcp/mcp-config-manager.js +1183 -1331
- package/dist/src/mcp/mcp-server-novice-simplified.js +11 -17
- package/dist/src/mcp/mcp-server-novice.js +11 -17
- package/dist/src/mcp/mcp-server-sdk.js +11 -17
- package/dist/src/mcp/mcp-server.js +1620 -1484
- package/dist/src/mcp/ruv-swarm-wrapper.js +209 -239
- package/dist/src/memory/advanced-serializer.js +609 -589
- package/dist/src/memory/enhanced-examples.js +220 -305
- package/dist/src/memory/enhanced-memory.js +295 -336
- package/dist/src/memory/enhanced-session-serializer.js +408 -492
- package/dist/src/memory/fallback-memory-system.js +900 -1021
- package/dist/src/memory/fallback-store.js +93 -131
- package/dist/src/memory/high-performance-serialization.js +592 -730
- package/dist/src/memory/in-memory-store.js +161 -213
- package/dist/src/memory/index.js +123 -157
- package/dist/src/memory/lock-free-structures.js +578 -764
- package/dist/src/memory/memory-mapped-persistence.js +585 -766
- package/dist/src/memory/memory-pressure-manager.js +569 -707
- package/dist/src/memory/migration.js +358 -445
- package/dist/src/memory/shared-memory.js +641 -768
- package/dist/src/memory/sqlite-store.js +245 -325
- package/dist/src/memory/sqlite-wrapper.js +122 -151
- package/dist/src/memory/swarm-memory.js +470 -603
- package/dist/src/memory/test-example.js +126 -134
- package/dist/src/memory/ultra-fast-memory-store.js +622 -821
- package/dist/src/memory/unified-memory-manager.js +356 -437
- package/dist/src/migration/index.js +92 -0
- package/dist/src/migration/logger.js +121 -0
- package/dist/src/migration/migration-analyzer.js +268 -0
- package/dist/src/migration/migration-runner.js +522 -0
- package/dist/src/migration/migration-validator.js +285 -0
- package/dist/src/migration/progress-reporter.js +150 -0
- package/dist/src/migration/rollback-manager.js +321 -0
- package/dist/src/migration/tests/migration-system.test.js +7 -0
- package/dist/src/migration/types.js +3 -0
- package/dist/src/swarm/CodeRefactoringSwarm.js +777 -952
- package/dist/src/swarm/__tests__/integration.test.js +227 -0
- package/dist/src/swarm/__tests__/prompt-copier.test.js +344 -0
- package/dist/src/swarm/advanced-orchestrator.js +1095 -0
- package/dist/src/swarm/claude-code-interface.js +961 -0
- package/dist/src/swarm/claude-flow-executor.js +229 -0
- package/dist/src/swarm/consensus-coordinator.js +475 -0
- package/dist/src/swarm/coordinator.js +2993 -0
- package/dist/src/swarm/direct-executor.js +1180 -0
- package/dist/src/swarm/error-recovery/advanced-error-detection.js +691 -0
- package/dist/src/swarm/error-recovery/automated-recovery-workflows.js +998 -0
- package/dist/src/swarm/error-recovery/error-recovery-coordinator.js +1197 -0
- package/dist/src/swarm/error-recovery/recovery-monitoring.js +772 -0
- package/dist/src/swarm/error-recovery/resilience-architecture.js +714 -0
- package/dist/src/swarm/error-recovery/self-healing-mechanisms.js +1319 -0
- package/dist/src/swarm/error-recovery/test-error-recovery-effectiveness.js +808 -0
- package/dist/src/swarm/executor-v2.js +322 -0
- package/dist/src/swarm/executor.js +815 -0
- package/dist/src/swarm/hive-mind-integration.js +703 -0
- package/dist/src/swarm/index.js +41 -0
- package/dist/src/swarm/json-output-aggregator.js +267 -0
- package/dist/src/swarm/large-scale-coordinator.js +542 -0
- package/dist/src/swarm/mcp-integration-wrapper.js +628 -0
- package/dist/src/swarm/memory.js +1117 -0
- package/dist/src/swarm/optimizations/__tests__/optimization.test.js +348 -0
- package/dist/src/swarm/optimizations/async-file-manager.js +285 -0
- package/dist/src/swarm/optimizations/circular-buffer.js +162 -0
- package/dist/src/swarm/optimizations/connection-pool.js +244 -0
- package/dist/src/swarm/optimizations/index.js +28 -0
- package/dist/src/swarm/optimizations/optimized-executor.js +320 -0
- package/dist/src/swarm/optimizations/ttl-map.js +234 -0
- package/dist/src/swarm/prompt-cli.js +200 -0
- package/dist/src/swarm/prompt-copier-enhanced.js +202 -0
- package/dist/src/swarm/prompt-copier.js +381 -0
- package/dist/src/swarm/prompt-manager.js +295 -0
- package/dist/src/swarm/prompt-utils.js +310 -0
- package/dist/src/swarm/result-aggregator.js +718 -0
- package/dist/src/swarm/sparc-executor.js +1568 -0
- package/dist/src/swarm/strategies/auto.js +758 -0
- package/dist/src/swarm/strategies/base.js +128 -0
- package/dist/src/swarm/strategies/research.js +914 -0
- package/dist/src/swarm/strategies/strategy-metrics-patch.js +2 -0
- package/dist/src/swarm/types.js +52 -0
- package/dist/src/swarm/workers/copy-worker.js +56 -0
- package/dist/src/utils/__tests__/github-cli-safety-wrapper.test.js +332 -400
- package/dist/src/utils/github-cli-safe.js +56 -64
- package/dist/src/utils/github-cli-safety-wrapper.js +451 -546
- package/dist/src/utils/npx-isolated-cache.js +104 -119
- package/dist/src/utils/preference-manager.js +622 -652
- package/dist/src/utils/timezone-utils.js +86 -105
- package/dist/src/validators/epic-config-schema.js +214 -0
- package/dist/src/validators/index.js +10 -0
- package/dist/src/validators/swarm-init-validator.js +259 -0
- package/dist/src/validators/todowrite-batching-validator.js +215 -0
- package/dist/src/validators/todowrite-integration.js +187 -0
- package/package.json +2 -2
|
@@ -2,658 +2,572 @@
|
|
|
2
2
|
* Real-time Update System for Claude-Flow Web UI
|
|
3
3
|
* Provides event-driven architecture for live data updates
|
|
4
4
|
* Supports WebSocket-like functionality and progressive loading
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export class RealtimeUpdateSystem {
|
|
8
|
-
constructor(ui) {
|
|
9
|
-
this.ui = ui;
|
|
10
|
-
this.subscribers = new Map(); // Event type -> Set of callbacks
|
|
11
|
-
this.updateQueues = new Map(); // View -> Queue of pending updates
|
|
12
|
-
this.updateTimers = new Map(); // View -> Timer for batched updates
|
|
13
|
-
this.batchDelay = 100; // ms to batch updates
|
|
14
|
-
this.eventHistory = []; // Keep last 100 events
|
|
15
|
-
this.maxHistorySize = 100;
|
|
16
|
-
|
|
17
|
-
// Performance monitoring
|
|
18
|
-
this.updateMetrics = {
|
|
19
|
-
totalUpdates: 0,
|
|
20
|
-
updateLatency: [],
|
|
21
|
-
batchedUpdates: 0,
|
|
22
|
-
droppedUpdates: 0,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
this.initializeSystem();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
5
|
+
*/ export class RealtimeUpdateSystem {
|
|
6
|
+
/**
|
|
29
7
|
* Initialize the real-time update system
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.ui.addLog('success', 'Real-time update system initialized');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
8
|
+
*/ initializeSystem() {
|
|
9
|
+
// Setup system event listeners
|
|
10
|
+
this.setupSystemEvents();
|
|
11
|
+
// Initialize update queues for all views
|
|
12
|
+
this.initializeUpdateQueues();
|
|
13
|
+
// Start performance monitoring
|
|
14
|
+
this.startPerformanceMonitoring();
|
|
15
|
+
this.ui.addLog('success', 'Real-time update system initialized');
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
45
18
|
* Setup system-level event listeners
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
operation: data.operation,
|
|
97
|
-
timestamp: Date.now(),
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
19
|
+
*/ setupSystemEvents() {
|
|
20
|
+
// Listen for tool execution events
|
|
21
|
+
this.subscribe('tool_start', (data)=>{
|
|
22
|
+
this.broadcastUpdate('tools', {
|
|
23
|
+
type: 'execution_start',
|
|
24
|
+
toolName: data.toolName,
|
|
25
|
+
executionId: data.executionId,
|
|
26
|
+
timestamp: Date.now()
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
this.subscribe('tool_complete', (data)=>{
|
|
30
|
+
this.broadcastUpdate('tools', {
|
|
31
|
+
type: 'execution_complete',
|
|
32
|
+
toolName: data.toolName,
|
|
33
|
+
executionId: data.executionId,
|
|
34
|
+
result: data.result,
|
|
35
|
+
timestamp: Date.now()
|
|
36
|
+
});
|
|
37
|
+
// Update relevant views based on tool type
|
|
38
|
+
this.updateRelatedViews(data.toolName, data.result);
|
|
39
|
+
});
|
|
40
|
+
this.subscribe('tool_error', (data)=>{
|
|
41
|
+
this.broadcastUpdate('tools', {
|
|
42
|
+
type: 'execution_error',
|
|
43
|
+
toolName: data.toolName,
|
|
44
|
+
executionId: data.executionId,
|
|
45
|
+
error: data.error,
|
|
46
|
+
timestamp: Date.now()
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
// Listen for swarm events
|
|
50
|
+
this.subscribe('swarm_status_change', (data)=>{
|
|
51
|
+
this.broadcastUpdate('orchestration', {
|
|
52
|
+
type: 'swarm_update',
|
|
53
|
+
swarmId: data.swarmId,
|
|
54
|
+
status: data.status,
|
|
55
|
+
timestamp: Date.now()
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
// Listen for memory events
|
|
59
|
+
this.subscribe('memory_change', (data)=>{
|
|
60
|
+
this.broadcastUpdate('memory', {
|
|
61
|
+
type: 'memory_update',
|
|
62
|
+
namespace: data.namespace,
|
|
63
|
+
operation: data.operation,
|
|
64
|
+
timestamp: Date.now()
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
103
69
|
* Initialize update queues for all views
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
/**
|
|
70
|
+
*/ initializeUpdateQueues() {
|
|
71
|
+
const views = [
|
|
72
|
+
'neural',
|
|
73
|
+
'analysis',
|
|
74
|
+
'workflow',
|
|
75
|
+
'github',
|
|
76
|
+
'daa',
|
|
77
|
+
'system',
|
|
78
|
+
'tools',
|
|
79
|
+
'orchestration',
|
|
80
|
+
'memory'
|
|
81
|
+
];
|
|
82
|
+
views.forEach((view)=>{
|
|
83
|
+
this.updateQueues.set(view, []);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
123
87
|
* Subscribe to specific event types
|
|
124
|
-
*/
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
88
|
+
*/ subscribe(eventType, callback) {
|
|
89
|
+
if (!this.subscribers.has(eventType)) {
|
|
90
|
+
this.subscribers.set(eventType, new Set());
|
|
91
|
+
}
|
|
92
|
+
this.subscribers.get(eventType).add(callback);
|
|
93
|
+
// Return unsubscribe function
|
|
94
|
+
return ()=>{
|
|
95
|
+
const subs = this.subscribers.get(eventType);
|
|
96
|
+
if (subs) {
|
|
97
|
+
subs.delete(callback);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
128
100
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// Return unsubscribe function
|
|
132
|
-
return () => {
|
|
133
|
-
const subs = this.subscribers.get(eventType);
|
|
134
|
-
if (subs) {
|
|
135
|
-
subs.delete(callback);
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
101
|
+
/**
|
|
141
102
|
* Emit event to all subscribers
|
|
142
|
-
*/
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
} catch (error) {
|
|
165
|
-
console.error(`Error in event subscriber for ${eventType}:`, error);
|
|
103
|
+
*/ emit(eventType, data) {
|
|
104
|
+
const timestamp = Date.now();
|
|
105
|
+
// Add to event history
|
|
106
|
+
this.eventHistory.push({
|
|
107
|
+
type: eventType,
|
|
108
|
+
data,
|
|
109
|
+
timestamp
|
|
110
|
+
});
|
|
111
|
+
// Trim history if too large
|
|
112
|
+
if (this.eventHistory.length > this.maxHistorySize) {
|
|
113
|
+
this.eventHistory.shift();
|
|
114
|
+
}
|
|
115
|
+
// Notify subscribers
|
|
116
|
+
const subscribers = this.subscribers.get(eventType);
|
|
117
|
+
if (subscribers) {
|
|
118
|
+
subscribers.forEach((callback)=>{
|
|
119
|
+
try {
|
|
120
|
+
callback(data, timestamp);
|
|
121
|
+
} catch (error) {
|
|
122
|
+
console.error(`Error in event subscriber for ${eventType}:`, error);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
166
125
|
}
|
|
167
|
-
});
|
|
168
126
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
/**
|
|
127
|
+
/**
|
|
172
128
|
* Broadcast update to specific view
|
|
173
|
-
*/
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
this.updateMetrics.totalUpdates++;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
129
|
+
*/ broadcastUpdate(viewName, updateData) {
|
|
130
|
+
const queue = this.updateQueues.get(viewName);
|
|
131
|
+
if (!queue) return;
|
|
132
|
+
// Add update to queue
|
|
133
|
+
queue.push({
|
|
134
|
+
...updateData,
|
|
135
|
+
id: `update_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`
|
|
136
|
+
});
|
|
137
|
+
// Schedule batched update
|
|
138
|
+
this.scheduleBatchedUpdate(viewName);
|
|
139
|
+
this.updateMetrics.totalUpdates++;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
191
142
|
* Schedule batched update for a view
|
|
192
|
-
*/
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
143
|
+
*/ scheduleBatchedUpdate(viewName) {
|
|
144
|
+
// Clear existing timer
|
|
145
|
+
const existingTimer = this.updateTimers.get(viewName);
|
|
146
|
+
if (existingTimer) {
|
|
147
|
+
clearTimeout(existingTimer);
|
|
148
|
+
}
|
|
149
|
+
// Schedule new batched update
|
|
150
|
+
const timer = setTimeout(()=>{
|
|
151
|
+
this.processBatchedUpdates(viewName);
|
|
152
|
+
}, this.batchDelay);
|
|
153
|
+
this.updateTimers.set(viewName, timer);
|
|
198
154
|
}
|
|
199
|
-
|
|
200
|
-
// Schedule new batched update
|
|
201
|
-
const timer = setTimeout(() => {
|
|
202
|
-
this.processBatchedUpdates(viewName);
|
|
203
|
-
}, this.batchDelay);
|
|
204
|
-
|
|
205
|
-
this.updateTimers.set(viewName, timer);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
155
|
+
/**
|
|
209
156
|
* Process batched updates for a view
|
|
210
|
-
*/
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
// Keep only last 100 latency measurements
|
|
232
|
-
if (this.updateMetrics.updateLatency.length > 100) {
|
|
233
|
-
this.updateMetrics.updateLatency.shift();
|
|
157
|
+
*/ processBatchedUpdates(viewName) {
|
|
158
|
+
const queue = this.updateQueues.get(viewName);
|
|
159
|
+
if (!queue || queue.length === 0) return;
|
|
160
|
+
const startTime = Date.now();
|
|
161
|
+
// Group updates by type
|
|
162
|
+
const groupedUpdates = this.groupUpdatesByType(queue);
|
|
163
|
+
// Apply updates
|
|
164
|
+
this.applyUpdatesToView(viewName, groupedUpdates);
|
|
165
|
+
// Clear processed updates
|
|
166
|
+
queue.length = 0;
|
|
167
|
+
// Update metrics
|
|
168
|
+
const latency = Date.now() - startTime;
|
|
169
|
+
this.updateMetrics.updateLatency.push(latency);
|
|
170
|
+
this.updateMetrics.batchedUpdates++;
|
|
171
|
+
// Keep only last 100 latency measurements
|
|
172
|
+
if (this.updateMetrics.updateLatency.length > 100) {
|
|
173
|
+
this.updateMetrics.updateLatency.shift();
|
|
174
|
+
}
|
|
175
|
+
// Clear timer
|
|
176
|
+
this.updateTimers.delete(viewName);
|
|
234
177
|
}
|
|
235
|
-
|
|
236
|
-
// Clear timer
|
|
237
|
-
this.updateTimers.delete(viewName);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/**
|
|
178
|
+
/**
|
|
241
179
|
* Group updates by type for efficient processing
|
|
242
|
-
*/
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return grouped;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
180
|
+
*/ groupUpdatesByType(updates) {
|
|
181
|
+
const grouped = new Map();
|
|
182
|
+
updates.forEach((update)=>{
|
|
183
|
+
if (!grouped.has(update.type)) {
|
|
184
|
+
grouped.set(update.type, []);
|
|
185
|
+
}
|
|
186
|
+
grouped.get(update.type).push(update);
|
|
187
|
+
});
|
|
188
|
+
return grouped;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
257
191
|
* Apply grouped updates to a specific view
|
|
258
|
-
*/
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
this.updateMetrics.droppedUpdates++;
|
|
192
|
+
*/ applyUpdatesToView(viewName, groupedUpdates) {
|
|
193
|
+
try {
|
|
194
|
+
// Different views handle updates differently
|
|
195
|
+
switch(viewName){
|
|
196
|
+
case 'neural':
|
|
197
|
+
this.applyNeuralUpdates(groupedUpdates);
|
|
198
|
+
break;
|
|
199
|
+
case 'analysis':
|
|
200
|
+
this.applyAnalysisUpdates(groupedUpdates);
|
|
201
|
+
break;
|
|
202
|
+
case 'workflow':
|
|
203
|
+
this.applyWorkflowUpdates(groupedUpdates);
|
|
204
|
+
break;
|
|
205
|
+
case 'tools':
|
|
206
|
+
this.applyToolsUpdates(groupedUpdates);
|
|
207
|
+
break;
|
|
208
|
+
case 'orchestration':
|
|
209
|
+
this.applyOrchestrationUpdates(groupedUpdates);
|
|
210
|
+
break;
|
|
211
|
+
case 'memory':
|
|
212
|
+
this.applyMemoryUpdates(groupedUpdates);
|
|
213
|
+
break;
|
|
214
|
+
default:
|
|
215
|
+
this.applyGenericUpdates(viewName, groupedUpdates);
|
|
216
|
+
}
|
|
217
|
+
// Trigger UI refresh if this is the current view
|
|
218
|
+
if (this.ui.currentView === viewName) {
|
|
219
|
+
this.requestUIRefresh();
|
|
220
|
+
}
|
|
221
|
+
} catch (error) {
|
|
222
|
+
console.error(`Error applying updates to ${viewName}:`, error);
|
|
223
|
+
this.updateMetrics.droppedUpdates++;
|
|
224
|
+
}
|
|
292
225
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
/**
|
|
226
|
+
/**
|
|
296
227
|
* Apply neural-specific updates
|
|
297
|
-
*/
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
228
|
+
*/ applyNeuralUpdates(groupedUpdates) {
|
|
229
|
+
const neuralData = this.ui.enhancedViews?.viewData?.get('neural');
|
|
230
|
+
if (!neuralData) return;
|
|
231
|
+
// Handle training job updates
|
|
232
|
+
const trainingUpdates = groupedUpdates.get('training_progress');
|
|
233
|
+
if (trainingUpdates) {
|
|
234
|
+
trainingUpdates.forEach((update)=>{
|
|
235
|
+
const existingJob = neuralData.trainingJobs.find((job)=>job.id === update.jobId);
|
|
236
|
+
if (existingJob) {
|
|
237
|
+
Object.assign(existingJob, update.data);
|
|
238
|
+
} else {
|
|
239
|
+
neuralData.trainingJobs.push({
|
|
240
|
+
id: update.jobId,
|
|
241
|
+
...update.data,
|
|
242
|
+
startTime: update.timestamp
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
});
|
|
315
246
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
});
|
|
247
|
+
// Handle model updates
|
|
248
|
+
const modelUpdates = groupedUpdates.get('model_update');
|
|
249
|
+
if (modelUpdates) {
|
|
250
|
+
modelUpdates.forEach((update)=>{
|
|
251
|
+
const existingModel = neuralData.models.find((model)=>model.id === update.modelId);
|
|
252
|
+
if (existingModel) {
|
|
253
|
+
Object.assign(existingModel, update.data);
|
|
254
|
+
} else {
|
|
255
|
+
neuralData.models.push({
|
|
256
|
+
id: update.modelId,
|
|
257
|
+
...update.data,
|
|
258
|
+
createdAt: update.timestamp
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
});
|
|
332
262
|
}
|
|
333
|
-
});
|
|
334
263
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
/**
|
|
264
|
+
/**
|
|
338
265
|
* Apply analysis-specific updates
|
|
339
|
-
*/
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
analysisData.reports = analysisData.reports.slice(0, 50);
|
|
266
|
+
*/ applyAnalysisUpdates(groupedUpdates) {
|
|
267
|
+
const analysisData = this.ui.enhancedViews?.viewData?.get('analysis');
|
|
268
|
+
if (!analysisData) return;
|
|
269
|
+
// Handle performance report updates
|
|
270
|
+
const reportUpdates = groupedUpdates.get('performance_report');
|
|
271
|
+
if (reportUpdates) {
|
|
272
|
+
reportUpdates.forEach((update)=>{
|
|
273
|
+
analysisData.reports.unshift({
|
|
274
|
+
id: update.reportId || `report_${update.timestamp}`,
|
|
275
|
+
...update.data,
|
|
276
|
+
timestamp: update.timestamp
|
|
277
|
+
});
|
|
278
|
+
// Keep only last 50 reports
|
|
279
|
+
if (analysisData.reports.length > 50) {
|
|
280
|
+
analysisData.reports = analysisData.reports.slice(0, 50);
|
|
281
|
+
}
|
|
282
|
+
});
|
|
357
283
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
if (analysisData.metrics.length > 100) {
|
|
372
|
-
analysisData.metrics.shift();
|
|
284
|
+
// Handle metrics updates
|
|
285
|
+
const metricsUpdates = groupedUpdates.get('metrics_update');
|
|
286
|
+
if (metricsUpdates) {
|
|
287
|
+
metricsUpdates.forEach((update)=>{
|
|
288
|
+
analysisData.metrics.push({
|
|
289
|
+
...update.data,
|
|
290
|
+
timestamp: update.timestamp
|
|
291
|
+
});
|
|
292
|
+
// Keep only last 100 metric points
|
|
293
|
+
if (analysisData.metrics.length > 100) {
|
|
294
|
+
analysisData.metrics.shift();
|
|
295
|
+
}
|
|
296
|
+
});
|
|
373
297
|
}
|
|
374
|
-
});
|
|
375
298
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
/**
|
|
299
|
+
/**
|
|
379
300
|
* Apply tools-specific updates
|
|
380
|
-
*/
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
301
|
+
*/ applyToolsUpdates(groupedUpdates) {
|
|
302
|
+
// Handle execution updates
|
|
303
|
+
const executionUpdates = groupedUpdates.get('execution_start');
|
|
304
|
+
if (executionUpdates) {
|
|
305
|
+
executionUpdates.forEach((update)=>{
|
|
306
|
+
this.ui.addLog('info', `🔧 Started: ${update.toolName}`);
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
const completionUpdates = groupedUpdates.get('execution_complete');
|
|
310
|
+
if (completionUpdates) {
|
|
311
|
+
completionUpdates.forEach((update)=>{
|
|
312
|
+
this.ui.addLog('success', `✅ Completed: ${update.toolName}`);
|
|
313
|
+
// Show result summary if available
|
|
314
|
+
if (update.result && update.result.summary) {
|
|
315
|
+
this.ui.addLog('info', `📋 ${update.result.summary}`);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
const errorUpdates = groupedUpdates.get('execution_error');
|
|
320
|
+
if (errorUpdates) {
|
|
321
|
+
errorUpdates.forEach((update)=>{
|
|
322
|
+
this.ui.addLog('error', `❌ Failed: ${update.toolName} - ${update.error}`);
|
|
323
|
+
});
|
|
398
324
|
}
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
const errorUpdates = groupedUpdates.get('execution_error');
|
|
403
|
-
if (errorUpdates) {
|
|
404
|
-
errorUpdates.forEach((update) => {
|
|
405
|
-
this.ui.addLog('error', `❌ Failed: ${update.toolName} - ${update.error}`);
|
|
406
|
-
});
|
|
407
325
|
}
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
/**
|
|
326
|
+
/**
|
|
411
327
|
* Apply orchestration-specific updates
|
|
412
|
-
*/
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
328
|
+
*/ applyOrchestrationUpdates(groupedUpdates) {
|
|
329
|
+
// Handle swarm updates
|
|
330
|
+
const swarmUpdates = groupedUpdates.get('swarm_update');
|
|
331
|
+
if (swarmUpdates) {
|
|
332
|
+
swarmUpdates.forEach((update)=>{
|
|
333
|
+
// Update swarm integration data
|
|
334
|
+
if (this.ui.swarmIntegration) {
|
|
335
|
+
this.ui.swarmIntegration.updateSwarmStatus();
|
|
336
|
+
}
|
|
337
|
+
this.ui.addLog('info', `🐝 Swarm ${update.swarmId}: ${update.status}`);
|
|
338
|
+
});
|
|
421
339
|
}
|
|
422
|
-
|
|
423
|
-
this.ui.addLog('info', `🐝 Swarm ${update.swarmId}: ${update.status}`);
|
|
424
|
-
});
|
|
425
340
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
/**
|
|
341
|
+
/**
|
|
429
342
|
* Apply memory-specific updates
|
|
430
|
-
*/
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
343
|
+
*/ applyMemoryUpdates(groupedUpdates) {
|
|
344
|
+
// Handle memory operation updates
|
|
345
|
+
const memoryUpdates = groupedUpdates.get('memory_update');
|
|
346
|
+
if (memoryUpdates) {
|
|
347
|
+
memoryUpdates.forEach((update)=>{
|
|
348
|
+
// Update memory stats
|
|
349
|
+
if (this.ui.memoryStats) {
|
|
350
|
+
const namespace = this.ui.memoryStats.namespaces.find((ns)=>ns.name === update.namespace);
|
|
351
|
+
if (namespace) {
|
|
352
|
+
// Update existing namespace stats
|
|
353
|
+
if (update.operation === 'store') {
|
|
354
|
+
namespace.entries++;
|
|
355
|
+
} else if (update.operation === 'delete') {
|
|
356
|
+
namespace.entries = Math.max(0, namespace.entries - 1);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
this.ui.addLog('info', `💾 Memory ${update.operation} in ${update.namespace}`);
|
|
361
|
+
});
|
|
449
362
|
}
|
|
450
|
-
|
|
451
|
-
this.ui.addLog('info', `💾 Memory ${update.operation} in ${update.namespace}`);
|
|
452
|
-
});
|
|
453
363
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
/**
|
|
364
|
+
/**
|
|
457
365
|
* Apply generic updates for other views
|
|
458
|
-
*/
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
/**
|
|
366
|
+
*/ applyGenericUpdates(viewName, groupedUpdates) {
|
|
367
|
+
// Log generic updates
|
|
368
|
+
groupedUpdates.forEach((updates, type)=>{
|
|
369
|
+
updates.forEach((update)=>{
|
|
370
|
+
this.ui.addLog('info', `📡 ${viewName}: ${type} update`);
|
|
371
|
+
});
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
469
375
|
* Update related views based on tool execution
|
|
470
|
-
*/
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
376
|
+
*/ updateRelatedViews(toolName, result) {
|
|
377
|
+
// Map tool names to affected views
|
|
378
|
+
const toolViewMap = {
|
|
379
|
+
// Neural tools affect neural view
|
|
380
|
+
neural_train: [
|
|
381
|
+
'neural'
|
|
382
|
+
],
|
|
383
|
+
neural_predict: [
|
|
384
|
+
'neural'
|
|
385
|
+
],
|
|
386
|
+
neural_status: [
|
|
387
|
+
'neural'
|
|
388
|
+
],
|
|
389
|
+
model_save: [
|
|
390
|
+
'neural'
|
|
391
|
+
],
|
|
392
|
+
model_load: [
|
|
393
|
+
'neural'
|
|
394
|
+
],
|
|
395
|
+
// Analysis tools affect analysis view
|
|
396
|
+
performance_report: [
|
|
397
|
+
'analysis'
|
|
398
|
+
],
|
|
399
|
+
bottleneck_analyze: [
|
|
400
|
+
'analysis'
|
|
401
|
+
],
|
|
402
|
+
token_usage: [
|
|
403
|
+
'analysis'
|
|
404
|
+
],
|
|
405
|
+
benchmark_run: [
|
|
406
|
+
'analysis'
|
|
407
|
+
],
|
|
408
|
+
// Swarm tools affect orchestration view
|
|
409
|
+
swarm_init: [
|
|
410
|
+
'orchestration'
|
|
411
|
+
],
|
|
412
|
+
agent_spawn: [
|
|
413
|
+
'orchestration'
|
|
414
|
+
],
|
|
415
|
+
task_orchestrate: [
|
|
416
|
+
'orchestration'
|
|
417
|
+
],
|
|
418
|
+
// Memory tools affect memory view
|
|
419
|
+
memory_usage: [
|
|
420
|
+
'memory'
|
|
421
|
+
],
|
|
422
|
+
memory_search: [
|
|
423
|
+
'memory'
|
|
424
|
+
],
|
|
425
|
+
memory_backup: [
|
|
426
|
+
'memory'
|
|
427
|
+
]
|
|
428
|
+
};
|
|
429
|
+
const affectedViews = toolViewMap[toolName] || [];
|
|
430
|
+
affectedViews.forEach((viewName)=>{
|
|
431
|
+
this.broadcastUpdate(viewName, {
|
|
432
|
+
type: 'tool_result',
|
|
433
|
+
toolName,
|
|
434
|
+
result,
|
|
435
|
+
timestamp: Date.now()
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
511
440
|
* Request UI refresh (throttled)
|
|
512
|
-
*/
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
/**
|
|
441
|
+
*/ requestUIRefresh() {
|
|
442
|
+
if (this.refreshThrottle) return;
|
|
443
|
+
this.refreshThrottle = setTimeout(()=>{
|
|
444
|
+
if (this.ui && typeof this.ui.render === 'function') {
|
|
445
|
+
this.ui.render();
|
|
446
|
+
}
|
|
447
|
+
this.refreshThrottle = null;
|
|
448
|
+
}, 50); // Throttle to max 20 FPS
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
525
451
|
* Start performance monitoring
|
|
526
|
-
*/
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
/**
|
|
452
|
+
*/ startPerformanceMonitoring() {
|
|
453
|
+
setInterval(()=>{
|
|
454
|
+
this.reportPerformanceMetrics();
|
|
455
|
+
}, 60000); // Report every minute
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
534
458
|
* Report performance metrics
|
|
535
|
-
*/
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
batchedUpdates: this.updateMetrics.batchedUpdates,
|
|
550
|
-
droppedUpdates: this.updateMetrics.droppedUpdates,
|
|
551
|
-
totalQueueSize,
|
|
552
|
-
eventHistorySize: this.eventHistory.length,
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
/**
|
|
459
|
+
*/ reportPerformanceMetrics() {
|
|
460
|
+
const avgLatency = this.updateMetrics.updateLatency.length > 0 ? this.updateMetrics.updateLatency.reduce((a, b)=>a + b, 0) / this.updateMetrics.updateLatency.length : 0;
|
|
461
|
+
const queueSizes = Array.from(this.updateQueues.values()).map((q)=>q.length);
|
|
462
|
+
const totalQueueSize = queueSizes.reduce((a, b)=>a + b, 0);
|
|
463
|
+
this.emit('performance_metrics', {
|
|
464
|
+
totalUpdates: this.updateMetrics.totalUpdates,
|
|
465
|
+
averageLatency: avgLatency,
|
|
466
|
+
batchedUpdates: this.updateMetrics.batchedUpdates,
|
|
467
|
+
droppedUpdates: this.updateMetrics.droppedUpdates,
|
|
468
|
+
totalQueueSize,
|
|
469
|
+
eventHistorySize: this.eventHistory.length
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
557
473
|
* Get system status
|
|
558
|
-
*/
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
queueSizes[viewName] = queue.length;
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
return {
|
|
566
|
-
subscribers: this.subscribers.size,
|
|
567
|
-
queueSizes,
|
|
568
|
-
metrics: this.updateMetrics,
|
|
569
|
-
eventHistorySize: this.eventHistory.length,
|
|
570
|
-
activeTimers: this.updateTimers.size,
|
|
571
|
-
};
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
/**
|
|
575
|
-
* Create progressive loading handler
|
|
576
|
-
*/
|
|
577
|
-
createProgressiveLoader(viewName, dataLoader, options = {}) {
|
|
578
|
-
const { chunkSize = 10, delay = 100, onProgress = null, onComplete = null } = options;
|
|
579
|
-
|
|
580
|
-
return async () => {
|
|
581
|
-
try {
|
|
582
|
-
const data = await dataLoader();
|
|
583
|
-
|
|
584
|
-
if (!Array.isArray(data)) {
|
|
585
|
-
// Non-array data, load immediately
|
|
586
|
-
this.broadcastUpdate(viewName, {
|
|
587
|
-
type: 'data_loaded',
|
|
588
|
-
data,
|
|
589
|
-
timestamp: Date.now(),
|
|
590
|
-
});
|
|
591
|
-
|
|
592
|
-
if (onComplete) onComplete(data);
|
|
593
|
-
return;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
// Progressive loading for arrays
|
|
597
|
-
for (let i = 0; i < data.length; i += chunkSize) {
|
|
598
|
-
const chunk = data.slice(i, i + chunkSize);
|
|
599
|
-
|
|
600
|
-
this.broadcastUpdate(viewName, {
|
|
601
|
-
type: 'data_chunk',
|
|
602
|
-
chunk,
|
|
603
|
-
progress: {
|
|
604
|
-
loaded: Math.min(i + chunkSize, data.length),
|
|
605
|
-
total: data.length,
|
|
606
|
-
percentage: Math.min(((i + chunkSize) / data.length) * 100, 100),
|
|
607
|
-
},
|
|
608
|
-
timestamp: Date.now(),
|
|
609
|
-
});
|
|
610
|
-
|
|
611
|
-
if (onProgress) {
|
|
612
|
-
onProgress({
|
|
613
|
-
loaded: Math.min(i + chunkSize, data.length),
|
|
614
|
-
total: data.length,
|
|
615
|
-
percentage: Math.min(((i + chunkSize) / data.length) * 100, 100),
|
|
616
|
-
});
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
// Small delay between chunks to prevent blocking
|
|
620
|
-
if (i + chunkSize < data.length) {
|
|
621
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
if (onComplete) onComplete(data);
|
|
626
|
-
} catch (error) {
|
|
627
|
-
this.broadcastUpdate(viewName, {
|
|
628
|
-
type: 'data_error',
|
|
629
|
-
error: error.message,
|
|
630
|
-
timestamp: Date.now(),
|
|
474
|
+
*/ getStatus() {
|
|
475
|
+
const queueSizes = {};
|
|
476
|
+
this.updateQueues.forEach((queue, viewName)=>{
|
|
477
|
+
queueSizes[viewName] = queue.length;
|
|
631
478
|
});
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
479
|
+
return {
|
|
480
|
+
subscribers: this.subscribers.size,
|
|
481
|
+
queueSizes,
|
|
482
|
+
metrics: this.updateMetrics,
|
|
483
|
+
eventHistorySize: this.eventHistory.length,
|
|
484
|
+
activeTimers: this.updateTimers.size
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Create progressive loading handler
|
|
489
|
+
*/ createProgressiveLoader(viewName, dataLoader, options = {}) {
|
|
490
|
+
const { chunkSize = 10, delay = 100, onProgress = null, onComplete = null } = options;
|
|
491
|
+
return async ()=>{
|
|
492
|
+
try {
|
|
493
|
+
const data = await dataLoader();
|
|
494
|
+
if (!Array.isArray(data)) {
|
|
495
|
+
// Non-array data, load immediately
|
|
496
|
+
this.broadcastUpdate(viewName, {
|
|
497
|
+
type: 'data_loaded',
|
|
498
|
+
data,
|
|
499
|
+
timestamp: Date.now()
|
|
500
|
+
});
|
|
501
|
+
if (onComplete) onComplete(data);
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
// Progressive loading for arrays
|
|
505
|
+
for(let i = 0; i < data.length; i += chunkSize){
|
|
506
|
+
const chunk = data.slice(i, i + chunkSize);
|
|
507
|
+
this.broadcastUpdate(viewName, {
|
|
508
|
+
type: 'data_chunk',
|
|
509
|
+
chunk,
|
|
510
|
+
progress: {
|
|
511
|
+
loaded: Math.min(i + chunkSize, data.length),
|
|
512
|
+
total: data.length,
|
|
513
|
+
percentage: Math.min((i + chunkSize) / data.length * 100, 100)
|
|
514
|
+
},
|
|
515
|
+
timestamp: Date.now()
|
|
516
|
+
});
|
|
517
|
+
if (onProgress) {
|
|
518
|
+
onProgress({
|
|
519
|
+
loaded: Math.min(i + chunkSize, data.length),
|
|
520
|
+
total: data.length,
|
|
521
|
+
percentage: Math.min((i + chunkSize) / data.length * 100, 100)
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
// Small delay between chunks to prevent blocking
|
|
525
|
+
if (i + chunkSize < data.length) {
|
|
526
|
+
await new Promise((resolve)=>setTimeout(resolve, delay));
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
if (onComplete) onComplete(data);
|
|
530
|
+
} catch (error) {
|
|
531
|
+
this.broadcastUpdate(viewName, {
|
|
532
|
+
type: 'data_error',
|
|
533
|
+
error: error.message,
|
|
534
|
+
timestamp: Date.now()
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
637
540
|
* Cleanup resources
|
|
638
|
-
*/
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
541
|
+
*/ cleanup() {
|
|
542
|
+
// Clear all timers
|
|
543
|
+
this.updateTimers.forEach((timer)=>clearTimeout(timer));
|
|
544
|
+
this.updateTimers.clear();
|
|
545
|
+
// Clear refresh throttle
|
|
546
|
+
if (this.refreshThrottle) {
|
|
547
|
+
clearTimeout(this.refreshThrottle);
|
|
548
|
+
}
|
|
549
|
+
// Clear all subscribers
|
|
550
|
+
this.subscribers.clear();
|
|
551
|
+
// Clear update queues
|
|
552
|
+
this.updateQueues.clear();
|
|
553
|
+
this.ui.addLog('info', 'Real-time update system cleaned up');
|
|
554
|
+
}
|
|
555
|
+
constructor(ui){
|
|
556
|
+
this.ui = ui;
|
|
557
|
+
this.subscribers = new Map(); // Event type -> Set of callbacks
|
|
558
|
+
this.updateQueues = new Map(); // View -> Queue of pending updates
|
|
559
|
+
this.updateTimers = new Map(); // View -> Timer for batched updates
|
|
560
|
+
this.batchDelay = 100; // ms to batch updates
|
|
561
|
+
this.eventHistory = []; // Keep last 100 events
|
|
562
|
+
this.maxHistorySize = 100;
|
|
563
|
+
// Performance monitoring
|
|
564
|
+
this.updateMetrics = {
|
|
565
|
+
totalUpdates: 0,
|
|
566
|
+
updateLatency: [],
|
|
567
|
+
batchedUpdates: 0,
|
|
568
|
+
droppedUpdates: 0
|
|
569
|
+
};
|
|
570
|
+
this.initializeSystem();
|
|
647
571
|
}
|
|
648
|
-
|
|
649
|
-
// Clear all subscribers
|
|
650
|
-
this.subscribers.clear();
|
|
651
|
-
|
|
652
|
-
// Clear update queues
|
|
653
|
-
this.updateQueues.clear();
|
|
654
|
-
|
|
655
|
-
this.ui.addLog('info', 'Real-time update system cleaned up');
|
|
656
|
-
}
|
|
657
572
|
}
|
|
658
|
-
|
|
659
573
|
export default RealtimeUpdateSystem;
|