claude-flow-novice 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-flow-novice/preferences/generation.json +147 -0
- package/.claude-flow-novice/preferences/language-configs/javascript.json +51 -0
- package/.claude-flow-novice/preferences/language-configs/python.json +50 -0
- package/.claude-flow-novice/preferences/language-configs/rust.json +237 -0
- package/.claude-flow-novice/preferences/language-configs/typescript.json +54 -0
- package/.claude-flow-novice/preferences/project-local.json +91 -0
- package/.claude-flow-novice/preferences/resource-delegation.json +120 -0
- package/.claude-flow-novice/preferences/team-shared.json +195 -0
- package/.claude-flow-novice/preferences/user-global.json +247 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-JAVASCRIPT.md +769 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-PYTHON.md +1214 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-RUST.md +475 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-TYPESCRIPT.md +851 -0
- package/.claude-flow-novice/templates/claude-md-templates/README.md +263 -0
- package/CLAUDE.md +81 -0
- package/README-NPM.md +0 -0
- package/package.json +11 -7
- package/scripts/build/README.md +167 -0
- package/scripts/build/build-config.js +27 -0
- package/scripts/build/build-prompt-copier.sh +30 -0
- package/scripts/build/performance-monitor.js +869 -0
- package/scripts/build/prepare-publish.js +150 -0
- package/scripts/build/typescript-fixer.js +621 -0
- package/scripts/build/unified-builder.sh +428 -0
- package/scripts/build/update-bin-version.js +32 -0
- package/scripts/dev/README.md +264 -0
- package/scripts/dev/claude-flow-wrapper.sh +35 -0
- package/scripts/dev/claude-monitor.py +419 -0
- package/scripts/dev/claude-sparc.sh +562 -0
- package/scripts/dev/claude-wrapper.sh +17 -0
- package/scripts/dev/demo-phase3-compliance.js +172 -0
- package/scripts/dev/demo-task-system.ts +224 -0
- package/scripts/dev/deployment-validator.js +315 -0
- package/scripts/dev/spawn-claude-terminal.sh +32 -0
- package/scripts/dev/start-portal.sh +506 -0
- package/scripts/dev/start-web-ui.js +15 -0
- package/scripts/dev/stop-portal.sh +311 -0
- package/scripts/dev/validate-examples.ts +288 -0
- package/scripts/dev/validate-phase2.cjs +451 -0
- package/scripts/dev/validate-phase2.js +785 -0
- package/scripts/dev/validate-phase3.cjs +208 -0
- package/scripts/dev/validate-security-remediation.js +1 -0
- package/scripts/legacy/README.md +272 -0
- package/scripts/legacy/batch-fix-ts.sh +54 -0
- package/scripts/legacy/build-migration.sh +105 -0
- package/scripts/legacy/build-monitor.js +209 -0
- package/scripts/legacy/build-with-filter.sh +84 -0
- package/scripts/legacy/build-workaround.sh +71 -0
- package/scripts/legacy/fix-ts-advanced.js +358 -0
- package/scripts/legacy/fix-ts-final.sh +50 -0
- package/scripts/legacy/fix-ts-targeted.sh +49 -0
- package/scripts/legacy/fix-typescript-errors.js +305 -0
- package/scripts/legacy/force-build.sh +63 -0
- package/scripts/legacy/optimize-performance.js +400 -0
- package/scripts/legacy/performance-monitor.js +263 -0
- package/scripts/legacy/performance-monitoring.js +532 -0
- package/scripts/legacy/performance-test-runner.js +645 -0
- package/scripts/legacy/quick-fix-ts.js +281 -0
- package/scripts/legacy/safe-build.sh +63 -0
- package/scripts/migration/README.md +434 -0
- package/scripts/migration/install-arm64.js +78 -0
- package/scripts/migration/install.js +83 -0
- package/scripts/migration/migrate-hooks.js +173 -0
- package/scripts/migration/migration-examples.ts +318 -0
- package/scripts/optimization/build-optimizer.js +438 -0
- package/scripts/optimization/config-validator.js +761 -0
- package/scripts/optimization/test-optimization.js +432 -0
- package/scripts/optimization/unified-activation.js +839 -0
- package/scripts/performance/ACTIVATION_COMMANDS.md +292 -0
- package/scripts/performance/sqlite-enhanced-activation.sh +583 -0
- package/scripts/performance/test-enhanced-backend.sh +504 -0
- package/scripts/performance-test-runner.js +698 -0
- package/scripts/security/README.md +339 -0
- package/scripts/security/install-git-hooks.sh +132 -0
- package/scripts/security/ruv-swarm-safe.js +74 -0
- package/scripts/test/README.md +236 -0
- package/scripts/test/check-links.ts +274 -0
- package/scripts/test/check-performance-regression.ts +168 -0
- package/scripts/test/coverage-report.ts +692 -0
- package/scripts/test/generate-swarm-tests.js +633 -0
- package/scripts/test/integration-test-validation.cjs +253 -0
- package/scripts/test/load-test-swarm.js +576 -0
- package/scripts/test/run-phase3-compliance-tests.js +427 -0
- package/scripts/test/test-batch-tasks.ts +29 -0
- package/scripts/test/test-byzantine-resolution.js +246 -0
- package/scripts/test/test-claude-spawn-options.sh +63 -0
- package/scripts/test/test-cli-wizard.js +331 -0
- package/scripts/test/test-comprehensive.js +401 -0
- package/scripts/test/test-coordination-features.ts +238 -0
- package/scripts/test/test-fallback-systems.js +276 -0
- package/scripts/test/test-init-command.ts +302 -0
- package/scripts/test/test-mcp.ts +251 -0
- package/scripts/test/test-runner.ts +568 -0
- package/scripts/test/test-swarm-integration.sh +92 -0
- package/scripts/test/test-swarm.ts +142 -0
- package/scripts/test/validation-summary.ts +408 -0
- package/scripts/utils/README.md +261 -0
- package/scripts/utils/clean-build-artifacts.sh +94 -0
- package/scripts/utils/cleanup-root.sh +69 -0
- package/scripts/utils/fix-cliffy-imports.js +307 -0
- package/scripts/utils/fix-duplicate-imports.js +114 -0
- package/scripts/utils/fix-error-handling.cjs +70 -0
- package/scripts/utils/fix-import-paths.js +104 -0
- package/scripts/utils/fix-imports.js +116 -0
- package/scripts/utils/fix-shebang.js +78 -0
- package/scripts/utils/fix-test-modules.js +27 -0
- package/scripts/utils/fix-timezone-issue-246.js +200 -0
- package/scripts/utils/fix-ts-comprehensive.py +182 -0
- package/scripts/utils/fix-ts-targeted-batch.js +250 -0
- package/scripts/utils/remove-benchmark-conflicts.sh +140 -0
- package/scripts/utils/simple-test-fixer.js +190 -0
- package/scripts/utils/validate-metrics-structure.cjs +144 -0
- package/scripts/verify-mcp-server.js +86 -0
- package/src/cli/simple-commands/__tests__/agent.test.js +291 -0
- package/src/cli/simple-commands/__tests__/memory.test.js +8 -0
- package/src/cli/simple-commands/__tests__/swarm.test.js +371 -0
- package/src/cli/simple-commands/__tests__/task.test.js +8 -0
- package/src/cli/simple-commands/agent.js +216 -0
- package/src/cli/simple-commands/analysis.js +570 -0
- package/src/cli/simple-commands/automation-executor.js +1603 -0
- package/src/cli/simple-commands/automation.js +627 -0
- package/src/cli/simple-commands/batch-manager.js +338 -0
- package/src/cli/simple-commands/claude-telemetry.js +311 -0
- package/src/cli/simple-commands/claude-track.js +102 -0
- package/src/cli/simple-commands/concurrent-display.js +348 -0
- package/src/cli/simple-commands/config.js +319 -0
- package/src/cli/simple-commands/coordination.js +307 -0
- package/src/cli/simple-commands/enhanced-ui-views.js +654 -0
- package/src/cli/simple-commands/enhanced-webui-complete.js +1038 -0
- package/src/cli/simple-commands/fix-hook-variables.js +363 -0
- package/src/cli/simple-commands/github/gh-coordinator.js +605 -0
- package/src/cli/simple-commands/github/github-api.js +624 -0
- package/src/cli/simple-commands/github/init.js +543 -0
- package/src/cli/simple-commands/github.js +377 -0
- package/src/cli/simple-commands/goal.js +145 -0
- package/src/cli/simple-commands/hive-mind/auto-save-middleware.js +311 -0
- package/src/cli/simple-commands/hive-mind/communication.js +740 -0
- package/src/cli/simple-commands/hive-mind/core.js +1031 -0
- package/src/cli/simple-commands/hive-mind/db-optimizer.js +872 -0
- package/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1364 -0
- package/src/cli/simple-commands/hive-mind/memory.js +1292 -0
- package/src/cli/simple-commands/hive-mind/performance-optimizer.js +618 -0
- package/src/cli/simple-commands/hive-mind/performance-test.js +373 -0
- package/src/cli/simple-commands/hive-mind/queen.js +809 -0
- package/src/cli/simple-commands/hive-mind/session-manager.js +1223 -0
- package/src/cli/simple-commands/hive-mind-optimize.js +361 -0
- package/src/cli/simple-commands/hive-mind-wizard.js +281 -0
- package/src/cli/simple-commands/hive-mind.js +3112 -0
- package/src/cli/simple-commands/hive.js +140 -0
- package/src/cli/simple-commands/hook-safety.js +671 -0
- package/src/cli/simple-commands/hooks.js +1268 -0
- package/src/cli/simple-commands/init/.claude/checkpoints/1756224542.json +7 -0
- package/src/cli/simple-commands/init/.claude/checkpoints/1756224544.json +8 -0
- package/src/cli/simple-commands/init/README.md +106 -0
- package/src/cli/simple-commands/init/VALIDATION_ROLLBACK.md +488 -0
- package/src/cli/simple-commands/init/agent-copier.js +347 -0
- package/src/cli/simple-commands/init/batch-init.js +663 -0
- package/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +438 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +876 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +356 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +501 -0
- package/src/cli/simple-commands/init/claude-commands/slash-commands.js +57 -0
- package/src/cli/simple-commands/init/claude-commands/sparc-commands.js +296 -0
- package/src/cli/simple-commands/init/copy-revised-templates.js +175 -0
- package/src/cli/simple-commands/init/executable-wrapper.js +122 -0
- package/src/cli/simple-commands/init/gitignore-updater.js +137 -0
- package/src/cli/simple-commands/init/help.js +110 -0
- package/src/cli/simple-commands/init/hive-mind-init.js +749 -0
- package/src/cli/simple-commands/init/index.js +1953 -0
- package/src/cli/simple-commands/init/performance-monitor.js +344 -0
- package/src/cli/simple-commands/init/rollback/backup-manager.js +542 -0
- package/src/cli/simple-commands/init/rollback/index.js +399 -0
- package/src/cli/simple-commands/init/rollback/recovery-manager.js +778 -0
- package/src/cli/simple-commands/init/rollback/rollback-executor.js +521 -0
- package/src/cli/simple-commands/init/rollback/state-tracker.js +486 -0
- package/src/cli/simple-commands/init/sparc/roo-readme.js +61 -0
- package/src/cli/simple-commands/init/sparc/roomodes-config.js +102 -0
- package/src/cli/simple-commands/init/sparc/workflows.js +40 -0
- package/src/cli/simple-commands/init/sparc-structure.js +68 -0
- package/src/cli/simple-commands/init/template-copier.js +640 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md +1185 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md.optimized +265 -0
- package/src/cli/simple-commands/init/templates/claude-flow-universal +81 -0
- package/src/cli/simple-commands/init/templates/claude-flow.bat +18 -0
- package/src/cli/simple-commands/init/templates/claude-flow.ps1 +24 -0
- package/src/cli/simple-commands/init/templates/claude-md.js +1101 -0
- package/src/cli/simple-commands/init/templates/commands/analysis/bottleneck-detect.md +162 -0
- package/src/cli/simple-commands/init/templates/commands/automation/auto-agent.md +122 -0
- package/src/cli/simple-commands/init/templates/commands/coordination/swarm-init.md +85 -0
- package/src/cli/simple-commands/init/templates/commands/github/github-swarm.md +121 -0
- package/src/cli/simple-commands/init/templates/commands/helpers/standard-checkpoint-hooks.sh +179 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/notification.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-command.md +116 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-edit.md +117 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-task.md +112 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-command.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-edit.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-search.md +112 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-task.md +111 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-end.md +118 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-restore.md +118 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-start.md +117 -0
- package/src/cli/simple-commands/init/templates/coordination-md.js +340 -0
- package/src/cli/simple-commands/init/templates/coordination.md +16 -0
- package/src/cli/simple-commands/init/templates/enhanced-templates.js +2347 -0
- package/src/cli/simple-commands/init/templates/github-safe-enhanced.js +331 -0
- package/src/cli/simple-commands/init/templates/github-safe.js +106 -0
- package/src/cli/simple-commands/init/templates/memory-bank-md.js +259 -0
- package/src/cli/simple-commands/init/templates/memory-bank.md +16 -0
- package/src/cli/simple-commands/init/templates/readme-files.js +72 -0
- package/src/cli/simple-commands/init/templates/safe-hook-patterns.js +430 -0
- package/src/cli/simple-commands/init/templates/settings.json +109 -0
- package/src/cli/simple-commands/init/templates/settings.json.enhanced +35 -0
- package/src/cli/simple-commands/init/templates/sparc-modes.js +1401 -0
- package/src/cli/simple-commands/init/templates/verification-claude-md.js +432 -0
- package/src/cli/simple-commands/init/validation/config-validator.js +354 -0
- package/src/cli/simple-commands/init/validation/health-checker.js +599 -0
- package/src/cli/simple-commands/init/validation/index.js +388 -0
- package/src/cli/simple-commands/init/validation/mode-validator.js +387 -0
- package/src/cli/simple-commands/init/validation/post-init-validator.js +390 -0
- package/src/cli/simple-commands/init/validation/pre-init-validator.js +290 -0
- package/src/cli/simple-commands/init/validation/test-runner.js +488 -0
- package/src/cli/simple-commands/init.js +4 -0
- package/src/cli/simple-commands/mcp-health.js +163 -0
- package/src/cli/simple-commands/mcp-integration-layer.js +689 -0
- package/src/cli/simple-commands/mcp.js +420 -0
- package/src/cli/simple-commands/memory-consolidation.js +631 -0
- package/src/cli/simple-commands/memory.js +345 -0
- package/src/cli/simple-commands/migrate-hooks.js +63 -0
- package/src/cli/simple-commands/monitor.js +417 -0
- package/src/cli/simple-commands/neural.js +148 -0
- package/src/cli/simple-commands/pair-autofix-only.js +755 -0
- package/src/cli/simple-commands/pair-basic.js +751 -0
- package/src/cli/simple-commands/pair-old.js +623 -0
- package/src/cli/simple-commands/pair-working.js +849 -0
- package/src/cli/simple-commands/pair.js +849 -0
- package/src/cli/simple-commands/performance-hooks.js +149 -0
- package/src/cli/simple-commands/performance-metrics.js +601 -0
- package/src/cli/simple-commands/process-ui-enhanced.js +821 -0
- package/src/cli/simple-commands/process-ui.js +274 -0
- package/src/cli/simple-commands/realtime-update-system.js +659 -0
- package/src/cli/simple-commands/sparc/architecture.js +1750 -0
- package/src/cli/simple-commands/sparc/commands.js +575 -0
- package/src/cli/simple-commands/sparc/completion.js +1831 -0
- package/src/cli/simple-commands/sparc/coordinator.js +1045 -0
- package/src/cli/simple-commands/sparc/index.js +321 -0
- package/src/cli/simple-commands/sparc/phase-base.js +430 -0
- package/src/cli/simple-commands/sparc/pseudocode.js +984 -0
- package/src/cli/simple-commands/sparc/refinement.js +1856 -0
- package/src/cli/simple-commands/sparc/specification.js +736 -0
- package/src/cli/simple-commands/sparc-modes/architect.js +125 -0
- package/src/cli/simple-commands/sparc-modes/ask.js +126 -0
- package/src/cli/simple-commands/sparc-modes/code.js +148 -0
- package/src/cli/simple-commands/sparc-modes/debug.js +112 -0
- package/src/cli/simple-commands/sparc-modes/devops.js +137 -0
- package/src/cli/simple-commands/sparc-modes/docs-writer.js +38 -0
- package/src/cli/simple-commands/sparc-modes/generic.js +34 -0
- package/src/cli/simple-commands/sparc-modes/index.js +201 -0
- package/src/cli/simple-commands/sparc-modes/integration.js +55 -0
- package/src/cli/simple-commands/sparc-modes/mcp.js +38 -0
- package/src/cli/simple-commands/sparc-modes/monitoring.js +38 -0
- package/src/cli/simple-commands/sparc-modes/optimization.js +38 -0
- package/src/cli/simple-commands/sparc-modes/security-review.js +130 -0
- package/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +167 -0
- package/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +38 -0
- package/src/cli/simple-commands/sparc-modes/supabase-admin.js +149 -0
- package/src/cli/simple-commands/sparc-modes/swarm.js +436 -0
- package/src/cli/simple-commands/sparc-modes/tdd.js +112 -0
- package/src/cli/simple-commands/sparc-modes/tutorial.js +277 -0
- package/src/cli/simple-commands/sparc.js +530 -0
- package/src/cli/simple-commands/start-ui.js +147 -0
- package/src/cli/simple-commands/start-wrapper.js +285 -0
- package/src/cli/simple-commands/start.js +2 -0
- package/src/cli/simple-commands/status.js +303 -0
- package/src/cli/simple-commands/stream-chain-clean.js +221 -0
- package/src/cli/simple-commands/stream-chain-fixed.js +89 -0
- package/src/cli/simple-commands/stream-chain-real.js +408 -0
- package/src/cli/simple-commands/stream-chain-working.js +323 -0
- package/src/cli/simple-commands/stream-chain.js +491 -0
- package/src/cli/simple-commands/stream-processor.js +340 -0
- package/src/cli/simple-commands/swarm-executor.js +253 -0
- package/src/cli/simple-commands/swarm-metrics-integration.js +371 -0
- package/src/cli/simple-commands/swarm-ui.js +741 -0
- package/src/cli/simple-commands/swarm-webui-integration.js +311 -0
- package/src/cli/simple-commands/swarm.js +2277 -0
- package/src/cli/simple-commands/task.js +228 -0
- package/src/cli/simple-commands/templates/mle-star-workflow.json +294 -0
- package/src/cli/simple-commands/timestamp-fix.js +104 -0
- package/src/cli/simple-commands/token-tracker.js +372 -0
- package/src/cli/simple-commands/tool-execution-framework.js +555 -0
- package/src/cli/simple-commands/train-and-stream.js +354 -0
- package/src/cli/simple-commands/training-pipeline.js +874 -0
- package/src/cli/simple-commands/training.js +288 -0
- package/src/cli/simple-commands/verification-hooks.js +336 -0
- package/src/cli/simple-commands/verification-integration.js +464 -0
- package/src/cli/simple-commands/verification-training-integration.js +646 -0
- package/src/cli/simple-commands/verification.js +551 -0
- package/src/cli/simple-commands/web-server.js +929 -0
- package/src/cli/simple-commands/webui-validator.js +136 -0
- package/src/language/README.md +503 -0
- package/src/language/claude-md-generator.js +618 -0
- package/src/language/cli.js +422 -0
- package/src/language/example.js +347 -0
- package/src/language/integration-system.js +619 -0
- package/src/language/language-detector.js +581 -0
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Real-time Update System for Claude-Flow Web UI
|
|
3
|
+
* Provides event-driven architecture for live data updates
|
|
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
|
+
/**
|
|
29
|
+
* Initialize the real-time update system
|
|
30
|
+
*/
|
|
31
|
+
initializeSystem() {
|
|
32
|
+
// Setup system event listeners
|
|
33
|
+
this.setupSystemEvents();
|
|
34
|
+
|
|
35
|
+
// Initialize update queues for all views
|
|
36
|
+
this.initializeUpdateQueues();
|
|
37
|
+
|
|
38
|
+
// Start performance monitoring
|
|
39
|
+
this.startPerformanceMonitoring();
|
|
40
|
+
|
|
41
|
+
this.ui.addLog('success', 'Real-time update system initialized');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Setup system-level event listeners
|
|
46
|
+
*/
|
|
47
|
+
setupSystemEvents() {
|
|
48
|
+
// Listen for tool execution events
|
|
49
|
+
this.subscribe('tool_start', (data) => {
|
|
50
|
+
this.broadcastUpdate('tools', {
|
|
51
|
+
type: 'execution_start',
|
|
52
|
+
toolName: data.toolName,
|
|
53
|
+
executionId: data.executionId,
|
|
54
|
+
timestamp: Date.now(),
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
this.subscribe('tool_complete', (data) => {
|
|
59
|
+
this.broadcastUpdate('tools', {
|
|
60
|
+
type: 'execution_complete',
|
|
61
|
+
toolName: data.toolName,
|
|
62
|
+
executionId: data.executionId,
|
|
63
|
+
result: data.result,
|
|
64
|
+
timestamp: Date.now(),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Update relevant views based on tool type
|
|
68
|
+
this.updateRelatedViews(data.toolName, data.result);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
this.subscribe('tool_error', (data) => {
|
|
72
|
+
this.broadcastUpdate('tools', {
|
|
73
|
+
type: 'execution_error',
|
|
74
|
+
toolName: data.toolName,
|
|
75
|
+
executionId: data.executionId,
|
|
76
|
+
error: data.error,
|
|
77
|
+
timestamp: Date.now(),
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Listen for swarm events
|
|
82
|
+
this.subscribe('swarm_status_change', (data) => {
|
|
83
|
+
this.broadcastUpdate('orchestration', {
|
|
84
|
+
type: 'swarm_update',
|
|
85
|
+
swarmId: data.swarmId,
|
|
86
|
+
status: data.status,
|
|
87
|
+
timestamp: Date.now(),
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Listen for memory events
|
|
92
|
+
this.subscribe('memory_change', (data) => {
|
|
93
|
+
this.broadcastUpdate('memory', {
|
|
94
|
+
type: 'memory_update',
|
|
95
|
+
namespace: data.namespace,
|
|
96
|
+
operation: data.operation,
|
|
97
|
+
timestamp: Date.now(),
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Initialize update queues for all views
|
|
104
|
+
*/
|
|
105
|
+
initializeUpdateQueues() {
|
|
106
|
+
const views = [
|
|
107
|
+
'neural',
|
|
108
|
+
'analysis',
|
|
109
|
+
'workflow',
|
|
110
|
+
'github',
|
|
111
|
+
'daa',
|
|
112
|
+
'system',
|
|
113
|
+
'tools',
|
|
114
|
+
'orchestration',
|
|
115
|
+
'memory',
|
|
116
|
+
];
|
|
117
|
+
views.forEach((view) => {
|
|
118
|
+
this.updateQueues.set(view, []);
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Subscribe to specific event types
|
|
124
|
+
*/
|
|
125
|
+
subscribe(eventType, callback) {
|
|
126
|
+
if (!this.subscribers.has(eventType)) {
|
|
127
|
+
this.subscribers.set(eventType, new Set());
|
|
128
|
+
}
|
|
129
|
+
this.subscribers.get(eventType).add(callback);
|
|
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
|
+
/**
|
|
141
|
+
* Emit event to all subscribers
|
|
142
|
+
*/
|
|
143
|
+
emit(eventType, data) {
|
|
144
|
+
const timestamp = Date.now();
|
|
145
|
+
|
|
146
|
+
// Add to event history
|
|
147
|
+
this.eventHistory.push({
|
|
148
|
+
type: eventType,
|
|
149
|
+
data,
|
|
150
|
+
timestamp,
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Trim history if too large
|
|
154
|
+
if (this.eventHistory.length > this.maxHistorySize) {
|
|
155
|
+
this.eventHistory.shift();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Notify subscribers
|
|
159
|
+
const subscribers = this.subscribers.get(eventType);
|
|
160
|
+
if (subscribers) {
|
|
161
|
+
subscribers.forEach((callback) => {
|
|
162
|
+
try {
|
|
163
|
+
callback(data, timestamp);
|
|
164
|
+
} catch (error) {
|
|
165
|
+
console.error(`Error in event subscriber for ${eventType}:`, error);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Broadcast update to specific view
|
|
173
|
+
*/
|
|
174
|
+
broadcastUpdate(viewName, updateData) {
|
|
175
|
+
const queue = this.updateQueues.get(viewName);
|
|
176
|
+
if (!queue) return;
|
|
177
|
+
|
|
178
|
+
// Add update to queue
|
|
179
|
+
queue.push({
|
|
180
|
+
...updateData,
|
|
181
|
+
id: `update_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`,
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
// Schedule batched update
|
|
185
|
+
this.scheduleBatchedUpdate(viewName);
|
|
186
|
+
|
|
187
|
+
this.updateMetrics.totalUpdates++;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Schedule batched update for a view
|
|
192
|
+
*/
|
|
193
|
+
scheduleBatchedUpdate(viewName) {
|
|
194
|
+
// Clear existing timer
|
|
195
|
+
const existingTimer = this.updateTimers.get(viewName);
|
|
196
|
+
if (existingTimer) {
|
|
197
|
+
clearTimeout(existingTimer);
|
|
198
|
+
}
|
|
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
|
+
/**
|
|
209
|
+
* Process batched updates for a view
|
|
210
|
+
*/
|
|
211
|
+
processBatchedUpdates(viewName) {
|
|
212
|
+
const queue = this.updateQueues.get(viewName);
|
|
213
|
+
if (!queue || queue.length === 0) return;
|
|
214
|
+
|
|
215
|
+
const startTime = Date.now();
|
|
216
|
+
|
|
217
|
+
// Group updates by type
|
|
218
|
+
const groupedUpdates = this.groupUpdatesByType(queue);
|
|
219
|
+
|
|
220
|
+
// Apply updates
|
|
221
|
+
this.applyUpdatesToView(viewName, groupedUpdates);
|
|
222
|
+
|
|
223
|
+
// Clear processed updates
|
|
224
|
+
queue.length = 0;
|
|
225
|
+
|
|
226
|
+
// Update metrics
|
|
227
|
+
const latency = Date.now() - startTime;
|
|
228
|
+
this.updateMetrics.updateLatency.push(latency);
|
|
229
|
+
this.updateMetrics.batchedUpdates++;
|
|
230
|
+
|
|
231
|
+
// Keep only last 100 latency measurements
|
|
232
|
+
if (this.updateMetrics.updateLatency.length > 100) {
|
|
233
|
+
this.updateMetrics.updateLatency.shift();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Clear timer
|
|
237
|
+
this.updateTimers.delete(viewName);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Group updates by type for efficient processing
|
|
242
|
+
*/
|
|
243
|
+
groupUpdatesByType(updates) {
|
|
244
|
+
const grouped = new Map();
|
|
245
|
+
|
|
246
|
+
updates.forEach((update) => {
|
|
247
|
+
if (!grouped.has(update.type)) {
|
|
248
|
+
grouped.set(update.type, []);
|
|
249
|
+
}
|
|
250
|
+
grouped.get(update.type).push(update);
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
return grouped;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Apply grouped updates to a specific view
|
|
258
|
+
*/
|
|
259
|
+
applyUpdatesToView(viewName, groupedUpdates) {
|
|
260
|
+
try {
|
|
261
|
+
// Different views handle updates differently
|
|
262
|
+
switch (viewName) {
|
|
263
|
+
case 'neural':
|
|
264
|
+
this.applyNeuralUpdates(groupedUpdates);
|
|
265
|
+
break;
|
|
266
|
+
case 'analysis':
|
|
267
|
+
this.applyAnalysisUpdates(groupedUpdates);
|
|
268
|
+
break;
|
|
269
|
+
case 'workflow':
|
|
270
|
+
this.applyWorkflowUpdates(groupedUpdates);
|
|
271
|
+
break;
|
|
272
|
+
case 'tools':
|
|
273
|
+
this.applyToolsUpdates(groupedUpdates);
|
|
274
|
+
break;
|
|
275
|
+
case 'orchestration':
|
|
276
|
+
this.applyOrchestrationUpdates(groupedUpdates);
|
|
277
|
+
break;
|
|
278
|
+
case 'memory':
|
|
279
|
+
this.applyMemoryUpdates(groupedUpdates);
|
|
280
|
+
break;
|
|
281
|
+
default:
|
|
282
|
+
this.applyGenericUpdates(viewName, groupedUpdates);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Trigger UI refresh if this is the current view
|
|
286
|
+
if (this.ui.currentView === viewName) {
|
|
287
|
+
this.requestUIRefresh();
|
|
288
|
+
}
|
|
289
|
+
} catch (error) {
|
|
290
|
+
console.error(`Error applying updates to ${viewName}:`, error);
|
|
291
|
+
this.updateMetrics.droppedUpdates++;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Apply neural-specific updates
|
|
297
|
+
*/
|
|
298
|
+
applyNeuralUpdates(groupedUpdates) {
|
|
299
|
+
const neuralData = this.ui.enhancedViews?.viewData?.get('neural');
|
|
300
|
+
if (!neuralData) return;
|
|
301
|
+
|
|
302
|
+
// Handle training job updates
|
|
303
|
+
const trainingUpdates = groupedUpdates.get('training_progress');
|
|
304
|
+
if (trainingUpdates) {
|
|
305
|
+
trainingUpdates.forEach((update) => {
|
|
306
|
+
const existingJob = neuralData.trainingJobs.find((job) => job.id === update.jobId);
|
|
307
|
+
if (existingJob) {
|
|
308
|
+
Object.assign(existingJob, update.data);
|
|
309
|
+
} else {
|
|
310
|
+
neuralData.trainingJobs.push({
|
|
311
|
+
id: update.jobId,
|
|
312
|
+
...update.data,
|
|
313
|
+
startTime: update.timestamp,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// Handle model updates
|
|
320
|
+
const modelUpdates = groupedUpdates.get('model_update');
|
|
321
|
+
if (modelUpdates) {
|
|
322
|
+
modelUpdates.forEach((update) => {
|
|
323
|
+
const existingModel = neuralData.models.find((model) => model.id === update.modelId);
|
|
324
|
+
if (existingModel) {
|
|
325
|
+
Object.assign(existingModel, update.data);
|
|
326
|
+
} else {
|
|
327
|
+
neuralData.models.push({
|
|
328
|
+
id: update.modelId,
|
|
329
|
+
...update.data,
|
|
330
|
+
createdAt: update.timestamp,
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Apply analysis-specific updates
|
|
339
|
+
*/
|
|
340
|
+
applyAnalysisUpdates(groupedUpdates) {
|
|
341
|
+
const analysisData = this.ui.enhancedViews?.viewData?.get('analysis');
|
|
342
|
+
if (!analysisData) return;
|
|
343
|
+
|
|
344
|
+
// Handle performance report updates
|
|
345
|
+
const reportUpdates = groupedUpdates.get('performance_report');
|
|
346
|
+
if (reportUpdates) {
|
|
347
|
+
reportUpdates.forEach((update) => {
|
|
348
|
+
analysisData.reports.unshift({
|
|
349
|
+
id: update.reportId || `report_${update.timestamp}`,
|
|
350
|
+
...update.data,
|
|
351
|
+
timestamp: update.timestamp,
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
// Keep only last 50 reports
|
|
355
|
+
if (analysisData.reports.length > 50) {
|
|
356
|
+
analysisData.reports = analysisData.reports.slice(0, 50);
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Handle metrics updates
|
|
362
|
+
const metricsUpdates = groupedUpdates.get('metrics_update');
|
|
363
|
+
if (metricsUpdates) {
|
|
364
|
+
metricsUpdates.forEach((update) => {
|
|
365
|
+
analysisData.metrics.push({
|
|
366
|
+
...update.data,
|
|
367
|
+
timestamp: update.timestamp,
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
// Keep only last 100 metric points
|
|
371
|
+
if (analysisData.metrics.length > 100) {
|
|
372
|
+
analysisData.metrics.shift();
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Apply tools-specific updates
|
|
380
|
+
*/
|
|
381
|
+
applyToolsUpdates(groupedUpdates) {
|
|
382
|
+
// Handle execution updates
|
|
383
|
+
const executionUpdates = groupedUpdates.get('execution_start');
|
|
384
|
+
if (executionUpdates) {
|
|
385
|
+
executionUpdates.forEach((update) => {
|
|
386
|
+
this.ui.addLog('info', `🔧 Started: ${update.toolName}`);
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const completionUpdates = groupedUpdates.get('execution_complete');
|
|
391
|
+
if (completionUpdates) {
|
|
392
|
+
completionUpdates.forEach((update) => {
|
|
393
|
+
this.ui.addLog('success', `✅ Completed: ${update.toolName}`);
|
|
394
|
+
|
|
395
|
+
// Show result summary if available
|
|
396
|
+
if (update.result && update.result.summary) {
|
|
397
|
+
this.ui.addLog('info', `📋 ${update.result.summary}`);
|
|
398
|
+
}
|
|
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
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Apply orchestration-specific updates
|
|
412
|
+
*/
|
|
413
|
+
applyOrchestrationUpdates(groupedUpdates) {
|
|
414
|
+
// Handle swarm updates
|
|
415
|
+
const swarmUpdates = groupedUpdates.get('swarm_update');
|
|
416
|
+
if (swarmUpdates) {
|
|
417
|
+
swarmUpdates.forEach((update) => {
|
|
418
|
+
// Update swarm integration data
|
|
419
|
+
if (this.ui.swarmIntegration) {
|
|
420
|
+
this.ui.swarmIntegration.updateSwarmStatus();
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
this.ui.addLog('info', `🐝 Swarm ${update.swarmId}: ${update.status}`);
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Apply memory-specific updates
|
|
430
|
+
*/
|
|
431
|
+
applyMemoryUpdates(groupedUpdates) {
|
|
432
|
+
// Handle memory operation updates
|
|
433
|
+
const memoryUpdates = groupedUpdates.get('memory_update');
|
|
434
|
+
if (memoryUpdates) {
|
|
435
|
+
memoryUpdates.forEach((update) => {
|
|
436
|
+
// Update memory stats
|
|
437
|
+
if (this.ui.memoryStats) {
|
|
438
|
+
const namespace = this.ui.memoryStats.namespaces.find(
|
|
439
|
+
(ns) => ns.name === update.namespace,
|
|
440
|
+
);
|
|
441
|
+
if (namespace) {
|
|
442
|
+
// Update existing namespace stats
|
|
443
|
+
if (update.operation === 'store') {
|
|
444
|
+
namespace.entries++;
|
|
445
|
+
} else if (update.operation === 'delete') {
|
|
446
|
+
namespace.entries = Math.max(0, namespace.entries - 1);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
this.ui.addLog('info', `💾 Memory ${update.operation} in ${update.namespace}`);
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Apply generic updates for other views
|
|
458
|
+
*/
|
|
459
|
+
applyGenericUpdates(viewName, groupedUpdates) {
|
|
460
|
+
// Log generic updates
|
|
461
|
+
groupedUpdates.forEach((updates, type) => {
|
|
462
|
+
updates.forEach((update) => {
|
|
463
|
+
this.ui.addLog('info', `📡 ${viewName}: ${type} update`);
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Update related views based on tool execution
|
|
470
|
+
*/
|
|
471
|
+
updateRelatedViews(toolName, result) {
|
|
472
|
+
// Map tool names to affected views
|
|
473
|
+
const toolViewMap = {
|
|
474
|
+
// Neural tools affect neural view
|
|
475
|
+
neural_train: ['neural'],
|
|
476
|
+
neural_predict: ['neural'],
|
|
477
|
+
neural_status: ['neural'],
|
|
478
|
+
model_save: ['neural'],
|
|
479
|
+
model_load: ['neural'],
|
|
480
|
+
|
|
481
|
+
// Analysis tools affect analysis view
|
|
482
|
+
performance_report: ['analysis'],
|
|
483
|
+
bottleneck_analyze: ['analysis'],
|
|
484
|
+
token_usage: ['analysis'],
|
|
485
|
+
benchmark_run: ['analysis'],
|
|
486
|
+
|
|
487
|
+
// Swarm tools affect orchestration view
|
|
488
|
+
swarm_init: ['orchestration'],
|
|
489
|
+
agent_spawn: ['orchestration'],
|
|
490
|
+
task_orchestrate: ['orchestration'],
|
|
491
|
+
|
|
492
|
+
// Memory tools affect memory view
|
|
493
|
+
memory_usage: ['memory'],
|
|
494
|
+
memory_search: ['memory'],
|
|
495
|
+
memory_backup: ['memory'],
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
const affectedViews = toolViewMap[toolName] || [];
|
|
499
|
+
|
|
500
|
+
affectedViews.forEach((viewName) => {
|
|
501
|
+
this.broadcastUpdate(viewName, {
|
|
502
|
+
type: 'tool_result',
|
|
503
|
+
toolName,
|
|
504
|
+
result,
|
|
505
|
+
timestamp: Date.now(),
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Request UI refresh (throttled)
|
|
512
|
+
*/
|
|
513
|
+
requestUIRefresh() {
|
|
514
|
+
if (this.refreshThrottle) return;
|
|
515
|
+
|
|
516
|
+
this.refreshThrottle = setTimeout(() => {
|
|
517
|
+
if (this.ui && typeof this.ui.render === 'function') {
|
|
518
|
+
this.ui.render();
|
|
519
|
+
}
|
|
520
|
+
this.refreshThrottle = null;
|
|
521
|
+
}, 50); // Throttle to max 20 FPS
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Start performance monitoring
|
|
526
|
+
*/
|
|
527
|
+
startPerformanceMonitoring() {
|
|
528
|
+
setInterval(() => {
|
|
529
|
+
this.reportPerformanceMetrics();
|
|
530
|
+
}, 60000); // Report every minute
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* Report performance metrics
|
|
535
|
+
*/
|
|
536
|
+
reportPerformanceMetrics() {
|
|
537
|
+
const avgLatency =
|
|
538
|
+
this.updateMetrics.updateLatency.length > 0
|
|
539
|
+
? this.updateMetrics.updateLatency.reduce((a, b) => a + b, 0) /
|
|
540
|
+
this.updateMetrics.updateLatency.length
|
|
541
|
+
: 0;
|
|
542
|
+
|
|
543
|
+
const queueSizes = Array.from(this.updateQueues.values()).map((q) => q.length);
|
|
544
|
+
const totalQueueSize = queueSizes.reduce((a, b) => a + b, 0);
|
|
545
|
+
|
|
546
|
+
this.emit('performance_metrics', {
|
|
547
|
+
totalUpdates: this.updateMetrics.totalUpdates,
|
|
548
|
+
averageLatency: avgLatency,
|
|
549
|
+
batchedUpdates: this.updateMetrics.batchedUpdates,
|
|
550
|
+
droppedUpdates: this.updateMetrics.droppedUpdates,
|
|
551
|
+
totalQueueSize,
|
|
552
|
+
eventHistorySize: this.eventHistory.length,
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Get system status
|
|
558
|
+
*/
|
|
559
|
+
getStatus() {
|
|
560
|
+
const queueSizes = {};
|
|
561
|
+
this.updateQueues.forEach((queue, viewName) => {
|
|
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(),
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/**
|
|
637
|
+
* Cleanup resources
|
|
638
|
+
*/
|
|
639
|
+
cleanup() {
|
|
640
|
+
// Clear all timers
|
|
641
|
+
this.updateTimers.forEach((timer) => clearTimeout(timer));
|
|
642
|
+
this.updateTimers.clear();
|
|
643
|
+
|
|
644
|
+
// Clear refresh throttle
|
|
645
|
+
if (this.refreshThrottle) {
|
|
646
|
+
clearTimeout(this.refreshThrottle);
|
|
647
|
+
}
|
|
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
|
+
}
|
|
658
|
+
|
|
659
|
+
export default RealtimeUpdateSystem;
|