@stackmemoryai/stackmemory 1.10.5 → 1.14.0
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/LICENSE +131 -64
- package/README.md +107 -24
- package/bin/claude-sm +16 -1
- package/bin/claude-smd +16 -1
- package/bin/codex-smd +16 -1
- package/bin/gemini-sm +16 -1
- package/bin/hermes-sm +21 -0
- package/bin/hermes-smd +21 -0
- package/bin/opencode-sm +16 -1
- package/dist/src/cli/claude-sm.js +266 -84
- package/dist/src/cli/codex-sm.js +225 -33
- package/dist/src/cli/commands/bench.js +209 -2
- package/dist/src/cli/commands/brain.js +206 -0
- package/dist/src/cli/commands/cache.js +126 -0
- package/dist/src/cli/commands/company-os.js +184 -0
- package/dist/src/cli/commands/context.js +5 -0
- package/dist/src/cli/commands/daemon.js +41 -0
- package/dist/src/cli/commands/handoff.js +40 -9
- package/dist/src/cli/commands/onboard.js +70 -3
- package/dist/src/cli/commands/operator.js +127 -0
- package/dist/src/cli/commands/optimize.js +117 -0
- package/dist/src/cli/commands/orchestrate.js +232 -5
- package/dist/src/cli/commands/orchestrator.js +315 -26
- package/dist/src/cli/commands/pack.js +322 -0
- package/dist/src/cli/commands/patterns.js +254 -0
- package/dist/src/cli/commands/portal.js +161 -0
- package/dist/src/cli/commands/scaffold.js +92 -0
- package/dist/src/cli/commands/search.js +40 -1
- package/dist/src/cli/commands/setup.js +178 -11
- package/dist/src/cli/commands/skills.js +10 -1
- package/dist/src/cli/commands/state.js +265 -0
- package/dist/src/cli/commands/sync.js +253 -0
- package/dist/src/cli/commands/tasks.js +130 -1
- package/dist/src/cli/commands/vision.js +221 -0
- package/dist/src/cli/gemini-sm.js +19 -29
- package/dist/src/cli/hermes-sm.js +224 -0
- package/dist/src/cli/index.js +105 -39
- package/dist/src/cli/opencode-sm.js +38 -21
- package/dist/src/cli/utils/determinism-watcher.js +66 -0
- package/dist/src/cli/utils/real-cli-bin.js +116 -0
- package/dist/src/core/brain/brain-store.js +187 -0
- package/dist/src/core/brain/brain-sync.js +193 -0
- package/dist/src/core/brain/index.js +78 -0
- package/dist/src/core/brain/types.js +10 -0
- package/dist/src/core/cache/content-cache.js +238 -0
- package/dist/src/{integrations/diffmem → core/cache}/index.js +5 -5
- package/dist/src/core/cache/token-estimator.js +39 -0
- package/dist/src/core/config/feature-flags.js +2 -6
- package/dist/src/core/context/frame-database.js +79 -27
- package/dist/src/core/context/recursive-context-manager.js +1 -1
- package/dist/src/core/context/rehydration.js +2 -1
- package/dist/src/core/cross-search/cross-project-search.js +269 -0
- package/dist/src/core/cross-search/index.js +10 -0
- package/dist/src/core/database/sqlite-adapter.js +14 -84
- package/dist/src/core/extensions/provider-adapter.js +5 -0
- package/dist/src/core/models/model-router.js +54 -2
- package/dist/src/core/models/provider-pricing.js +58 -4
- package/dist/src/core/monitoring/logger.js +2 -1
- package/dist/src/core/optimization/trace-optimizer.js +413 -0
- package/dist/src/core/patterns/index.js +22 -0
- package/dist/src/core/patterns/pattern-applier.js +39 -0
- package/dist/src/core/patterns/pattern-observer.js +157 -0
- package/dist/src/core/patterns/pattern-store.js +259 -0
- package/dist/src/core/patterns/types.js +19 -0
- package/dist/src/core/provenance/confidence-scorer.js +128 -0
- package/dist/src/core/provenance/index.js +40 -0
- package/dist/src/core/provenance/provenance-store.js +194 -0
- package/dist/src/core/provenance/types.js +82 -0
- package/dist/src/core/retrieval/llm-context-retrieval.js +5 -4
- package/dist/src/core/retrieval/unified-context-assembler.js +11 -66
- package/dist/src/core/session/project-handoff.js +64 -0
- package/dist/src/core/session/session-manager.js +28 -0
- package/dist/src/core/shared-state/canonical-store.js +564 -0
- package/dist/src/core/skill-packs/index.js +18 -0
- package/dist/src/core/skill-packs/parser.js +42 -0
- package/dist/src/core/skill-packs/registry.js +224 -0
- package/dist/src/core/skill-packs/types.js +79 -0
- package/dist/src/core/storage/cloud-sync-manager.js +116 -0
- package/dist/src/core/storage/cloud-sync.js +574 -0
- package/dist/src/core/storage/two-tier-storage.js +5 -1
- package/dist/src/core/tasks/master-tasks-template.js +43 -0
- package/dist/src/core/tasks/md-task-parser.js +138 -0
- package/dist/src/core/trace/trace-event-store.js +282 -0
- package/dist/src/core/vision/index.js +27 -0
- package/dist/src/core/vision/signals.js +79 -0
- package/dist/src/core/vision/types.js +22 -0
- package/dist/src/core/vision/vision-file.js +146 -0
- package/dist/src/core/vision/vision-loop.js +220 -0
- package/dist/src/core/wiki/wiki-compiler.js +103 -1
- package/dist/src/daemon/daemon-config.js +52 -0
- package/dist/src/daemon/services/desire-path-service.js +566 -0
- package/dist/src/daemon/services/github-service.js +126 -0
- package/dist/src/daemon/services/research-stream-service.js +320 -0
- package/dist/src/daemon/services/telemetry-service.js +192 -0
- package/dist/src/daemon/unified-daemon.js +58 -1
- package/dist/src/features/browser/cli-browser-agent.js +417 -0
- package/dist/src/features/browser/stagehand-workflows.js +578 -0
- package/dist/src/features/operator/adapter-factory.js +62 -0
- package/dist/src/features/operator/browser-adapter.js +109 -0
- package/dist/src/features/operator/desktop-adapter.js +125 -0
- package/dist/src/features/operator/index.js +39 -0
- package/dist/src/features/operator/llm-decision.js +137 -0
- package/dist/src/features/operator/operator-logger.js +92 -0
- package/dist/src/features/operator/overnight-runner.js +327 -0
- package/dist/src/features/operator/screen-adapter.js +91 -0
- package/dist/src/features/operator/session-manager.js +127 -0
- package/dist/src/features/operator/state-machine.js +227 -0
- package/dist/src/features/operator/task-queue.js +81 -0
- package/dist/src/features/portal/index.js +26 -0
- package/dist/src/features/portal/server.js +240 -0
- package/dist/src/features/portal/types.js +14 -0
- package/dist/src/features/portal/ui.js +195 -0
- package/dist/src/features/sweep/pty-wrapper.js +13 -5
- package/dist/src/features/tasks/task-aware-context.js +2 -1
- package/dist/src/features/tui/simple-monitor.js +0 -23
- package/dist/src/features/tui/swarm-monitor.js +8 -66
- package/dist/src/features/web/client/hooks/use-socket.js +12 -0
- package/dist/src/{core/merge/index.js → features/web/client/lib/utils.js} +8 -4
- package/dist/src/features/web/client/next-env.d.js +4 -0
- package/dist/src/features/web/client/stores/session-store.js +12 -0
- package/dist/src/features/web/server/gcp-billing.js +76 -0
- package/dist/src/features/web/server/index.js +10 -0
- package/dist/src/features/web/server/spend-calculator.js +228 -0
- package/dist/src/hooks/schemas.js +6 -1
- package/dist/src/integrations/anthropic/client.js +3 -2
- package/dist/src/integrations/claude-code/agent-bridge.js +0 -3
- package/dist/src/integrations/claude-code/subagent-client.js +307 -11
- package/dist/src/integrations/claude-code/task-coordinator.js +2 -1
- package/dist/src/integrations/github/pr-state.js +158 -0
- package/dist/src/integrations/linear/client.js +4 -1
- package/dist/src/integrations/linear/webhook-retry.js +196 -0
- package/dist/src/integrations/linear/webhook-server.js +18 -22
- package/dist/src/integrations/mcp/handlers/cloud-sync-handlers.js +101 -0
- package/dist/src/integrations/mcp/handlers/index.js +40 -84
- package/dist/src/integrations/mcp/server.js +542 -641
- package/dist/src/integrations/mcp/tool-alias-registry.js +297 -0
- package/dist/src/integrations/mcp/tool-definitions.js +152 -682
- package/dist/src/mcp/stackmemory-mcp-server.js +571 -231
- package/dist/src/orchestrators/multimodal/determinism.js +244 -0
- package/dist/src/orchestrators/multimodal/harness.js +149 -78
- package/dist/src/orchestrators/multimodal/providers.js +44 -3
- package/dist/src/skills/recursive-agent-orchestrator.js +2 -4
- package/dist/src/utils/hook-installer.js +0 -8
- package/dist/src/utils/process-cleanup.js +1 -7
- package/docs/README.md +42 -0
- package/docs/guides/README_INSTALL.md +208 -0
- package/package.json +27 -9
- package/packs/coding/python-fastapi/instructions.md +60 -0
- package/packs/coding/python-fastapi/pack.yaml +28 -0
- package/packs/coding/typescript-react/instructions.md +47 -0
- package/packs/coding/typescript-react/pack.yaml +28 -0
- package/packs/core/commands/capture.md +32 -0
- package/packs/core/commands/learn.md +73 -0
- package/packs/core/commands/next.md +36 -0
- package/packs/core/commands/restart.md +58 -0
- package/packs/core/commands/restore.md +29 -0
- package/packs/core/commands/start.md +57 -0
- package/packs/core/commands/stop.md +65 -0
- package/packs/core/commands/summary.md +40 -0
- package/packs/core/manifest.json +24 -0
- package/packs/ops/decision-recovery/instructions.md +65 -0
- package/packs/ops/decision-recovery/pack.yaml +89 -0
- package/scripts/claude-code-wrapper.sh +11 -0
- package/scripts/claude-sm-setup.sh +12 -1
- package/scripts/codex-wrapper.sh +11 -0
- package/scripts/git-hooks/branch-context-manager.sh +11 -0
- package/scripts/git-hooks/post-checkout-stackmemory.sh +11 -0
- package/scripts/git-hooks/post-commit-stackmemory.sh +11 -0
- package/scripts/git-hooks/pre-commit-stackmemory.sh +11 -0
- package/scripts/hooks/cleanup-shell.sh +12 -1
- package/scripts/hooks/task-complete.sh +12 -1
- package/scripts/install-code-execution-hooks.sh +12 -1
- package/scripts/install-sweep-hook.sh +12 -0
- package/scripts/install.sh +11 -0
- package/scripts/opencode-wrapper.sh +11 -0
- package/scripts/portal/cloud-init.yaml +69 -0
- package/scripts/portal/setup.sh +69 -0
- package/scripts/portal/stackmemory-portal.service +34 -0
- package/scripts/setup-claude-integration.sh +12 -1
- package/scripts/smoke-init-db.sh +23 -0
- package/scripts/stackmemory-daemon.sh +11 -0
- package/scripts/verify-dist.cjs +11 -4
- package/dist/src/cli/commands/ralph.js +0 -1053
- package/dist/src/cli/commands/team.js +0 -168
- package/dist/src/core/context/shared-context-layer.js +0 -620
- package/dist/src/core/context/stack-merge-resolver.js +0 -748
- package/dist/src/core/merge/conflict-detector.js +0 -430
- package/dist/src/core/merge/resolution-engine.js +0 -557
- package/dist/src/core/merge/stack-diff.js +0 -531
- package/dist/src/core/merge/unified-merge-resolver.js +0 -302
- package/dist/src/hooks/diffmem-hooks.js +0 -376
- package/dist/src/integrations/diffmem/client.js +0 -208
- package/dist/src/integrations/diffmem/config.js +0 -14
- package/dist/src/integrations/greptile/client.js +0 -101
- package/dist/src/integrations/greptile/config.js +0 -14
- package/dist/src/integrations/greptile/index.js +0 -11
- package/dist/src/integrations/mcp/handlers/cord-handlers.js +0 -397
- package/dist/src/integrations/mcp/handlers/diffmem-handlers.js +0 -455
- package/dist/src/integrations/mcp/handlers/greptile-handlers.js +0 -456
- package/dist/src/integrations/mcp/handlers/provider-handlers.js +0 -227
- package/dist/src/integrations/mcp/handlers/team-handlers.js +0 -211
- package/dist/src/integrations/ralph/bridge/ralph-stackmemory-bridge.js +0 -863
- package/dist/src/integrations/ralph/context/context-budget-manager.js +0 -308
- package/dist/src/integrations/ralph/context/stackmemory-context-loader.js +0 -391
- package/dist/src/integrations/ralph/index.js +0 -17
- package/dist/src/integrations/ralph/learning/pattern-learner.js +0 -435
- package/dist/src/integrations/ralph/lifecycle/iteration-lifecycle.js +0 -448
- package/dist/src/integrations/ralph/loopmax.js +0 -488
- package/dist/src/integrations/ralph/monitoring/swarm-dashboard.js +0 -293
- package/dist/src/integrations/ralph/monitoring/swarm-registry.js +0 -107
- package/dist/src/integrations/ralph/orchestration/multi-loop-orchestrator.js +0 -508
- package/dist/src/integrations/ralph/patterns/compounding-engineering-pattern.js +0 -407
- package/dist/src/integrations/ralph/patterns/extended-coherence-sessions.js +0 -495
- package/dist/src/integrations/ralph/patterns/oracle-worker-pattern.js +0 -387
- package/dist/src/integrations/ralph/performance/performance-optimizer.js +0 -357
- package/dist/src/integrations/ralph/recovery/crash-recovery.js +0 -461
- package/dist/src/integrations/ralph/state/state-reconciler.js +0 -420
- package/dist/src/integrations/ralph/swarm/git-workflow-manager.js +0 -444
- package/dist/src/integrations/ralph/swarm/swarm-coordinator.js +0 -1007
- package/dist/src/integrations/ralph/visualization/ralph-debugger.js +0 -635
- package/scripts/ralph-loop-implementation.js +0 -404
- /package/dist/src/core/{merge → cache}/types.js +0 -0
- /package/dist/src/{integrations/diffmem/types.js → core/storage/cloud-sync-types.js} +0 -0
- /package/dist/src/{integrations/greptile/types.js → core/trace/trace-event.js} +0 -0
- /package/dist/src/{integrations/ralph → features/operator}/types.js +0 -0
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
2
|
-
import { dirname as __pathDirname } from 'path';
|
|
3
|
-
const __filename = __fileURLToPath(import.meta.url);
|
|
4
|
-
const __dirname = __pathDirname(__filename);
|
|
5
|
-
import { EventEmitter } from "events";
|
|
6
|
-
import { logger } from "../../../core/monitoring/logger.js";
|
|
7
|
-
class SwarmDashboard extends EventEmitter {
|
|
8
|
-
metrics = /* @__PURE__ */ new Map();
|
|
9
|
-
alerts = [];
|
|
10
|
-
monitoringInterval;
|
|
11
|
-
swarmCoordinator;
|
|
12
|
-
constructor(swarmCoordinator) {
|
|
13
|
-
super();
|
|
14
|
-
this.swarmCoordinator = swarmCoordinator;
|
|
15
|
-
this.setupDefaultAlerts();
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Start real-time monitoring
|
|
19
|
-
*/
|
|
20
|
-
startMonitoring(intervalMs = 5e3) {
|
|
21
|
-
this.monitoringInterval = setInterval(() => {
|
|
22
|
-
this.collectMetrics();
|
|
23
|
-
this.checkAlerts();
|
|
24
|
-
}, intervalMs);
|
|
25
|
-
logger.info("Swarm monitoring dashboard started");
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Stop monitoring
|
|
29
|
-
*/
|
|
30
|
-
stopMonitoring() {
|
|
31
|
-
if (this.monitoringInterval) {
|
|
32
|
-
clearInterval(this.monitoringInterval);
|
|
33
|
-
this.monitoringInterval = void 0;
|
|
34
|
-
}
|
|
35
|
-
logger.info("Swarm monitoring dashboard stopped");
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Get current metrics for a swarm
|
|
39
|
-
*/
|
|
40
|
-
getSwarmMetrics(swarmId) {
|
|
41
|
-
return this.metrics.get(swarmId);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Get all active swarm metrics
|
|
45
|
-
*/
|
|
46
|
-
getAllMetrics() {
|
|
47
|
-
return Array.from(this.metrics.values());
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Add custom alert rule
|
|
51
|
-
*/
|
|
52
|
-
addAlert(rule) {
|
|
53
|
-
this.alerts.push(rule);
|
|
54
|
-
logger.info(`Added alert rule: ${rule.id}`);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Generate real-time dashboard HTML
|
|
58
|
-
*/
|
|
59
|
-
generateDashboardHTML() {
|
|
60
|
-
const metrics = this.getAllMetrics();
|
|
61
|
-
return `
|
|
62
|
-
<!DOCTYPE html>
|
|
63
|
-
<html>
|
|
64
|
-
<head>
|
|
65
|
-
<title>Ralph Swarm Dashboard</title>
|
|
66
|
-
<style>
|
|
67
|
-
body { font-family: Arial, sans-serif; margin: 20px; background: #f5f5f5; }
|
|
68
|
-
.dashboard { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
|
|
69
|
-
.card { background: white; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
|
70
|
-
.metric { display: flex; justify-content: space-between; margin: 10px 0; }
|
|
71
|
-
.status-active { color: #28a745; }
|
|
72
|
-
.status-error { color: #dc3545; }
|
|
73
|
-
.status-idle { color: #6c757d; }
|
|
74
|
-
.alert-critical { color: #dc3545; font-weight: bold; }
|
|
75
|
-
.progress { background: #e9ecef; border-radius: 4px; height: 8px; }
|
|
76
|
-
.progress-bar { background: #007bff; height: 100%; border-radius: 4px; }
|
|
77
|
-
</style>
|
|
78
|
-
<script>
|
|
79
|
-
setTimeout(() => location.reload(), 5000); // Auto-refresh
|
|
80
|
-
</script>
|
|
81
|
-
</head>
|
|
82
|
-
<body>
|
|
83
|
-
<h1>\u{1F9BE} Ralph Swarm Dashboard</h1>
|
|
84
|
-
<div class="dashboard">
|
|
85
|
-
${metrics.map(
|
|
86
|
-
(swarm) => `
|
|
87
|
-
<div class="card">
|
|
88
|
-
<h3>Swarm ${swarm.swarmId.substring(0, 8)}</h3>
|
|
89
|
-
<div class="metric">
|
|
90
|
-
<span>Status:</span>
|
|
91
|
-
<span class="status-${swarm.status}">${swarm.status.toUpperCase()}</span>
|
|
92
|
-
</div>
|
|
93
|
-
<div class="metric">
|
|
94
|
-
<span>Agents:</span>
|
|
95
|
-
<span>${swarm.activeAgents}/${swarm.totalAgents}</span>
|
|
96
|
-
</div>
|
|
97
|
-
<div class="metric">
|
|
98
|
-
<span>Tasks:</span>
|
|
99
|
-
<span>${swarm.completedTasks}/${swarm.activeTasks + swarm.completedTasks}</span>
|
|
100
|
-
</div>
|
|
101
|
-
<div class="metric">
|
|
102
|
-
<span>Throughput:</span>
|
|
103
|
-
<span>${swarm.performance.throughput.toFixed(2)} tasks/min</span>
|
|
104
|
-
</div>
|
|
105
|
-
<div class="metric">
|
|
106
|
-
<span>Memory:</span>
|
|
107
|
-
<span>${swarm.resourceUsage.memoryMB} MB</span>
|
|
108
|
-
</div>
|
|
109
|
-
<div class="metric">
|
|
110
|
-
<span>Uptime:</span>
|
|
111
|
-
<span>${Math.round(swarm.performance.uptime / 1e3)}s</span>
|
|
112
|
-
</div>
|
|
113
|
-
<div style="margin-top: 15px;">
|
|
114
|
-
<h4>Agents:</h4>
|
|
115
|
-
${swarm.agents.map(
|
|
116
|
-
(agent) => `
|
|
117
|
-
<div class="metric">
|
|
118
|
-
<span>${agent.role}:</span>
|
|
119
|
-
<span class="status-${agent.status}">${agent.status}</span>
|
|
120
|
-
</div>
|
|
121
|
-
`
|
|
122
|
-
).join("")}
|
|
123
|
-
</div>
|
|
124
|
-
</div>
|
|
125
|
-
`
|
|
126
|
-
).join("")}
|
|
127
|
-
</div>
|
|
128
|
-
|
|
129
|
-
<div class="card" style="margin-top: 20px;">
|
|
130
|
-
<h3>\u{1F6A8} Active Alerts</h3>
|
|
131
|
-
<div id="alerts">${this.getActiveAlerts().map(
|
|
132
|
-
(alert) => `<div class="alert-${alert.severity}">${alert.message}</div>`
|
|
133
|
-
).join("")}</div>
|
|
134
|
-
</div>
|
|
135
|
-
</body>
|
|
136
|
-
</html>`;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Export metrics to JSON
|
|
140
|
-
*/
|
|
141
|
-
exportMetrics() {
|
|
142
|
-
return JSON.stringify(
|
|
143
|
-
{
|
|
144
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
145
|
-
swarms: this.getAllMetrics(),
|
|
146
|
-
alerts: this.getActiveAlerts()
|
|
147
|
-
},
|
|
148
|
-
null,
|
|
149
|
-
2
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
collectMetrics() {
|
|
153
|
-
const usage = this.swarmCoordinator.getResourceUsage();
|
|
154
|
-
const swarmState = this.swarmCoordinator.swarmState;
|
|
155
|
-
if (!swarmState || !swarmState.id) return;
|
|
156
|
-
const metrics = {
|
|
157
|
-
swarmId: swarmState.id,
|
|
158
|
-
status: swarmState.status,
|
|
159
|
-
totalAgents: usage.activeAgents,
|
|
160
|
-
activeAgents: usage.activeAgents,
|
|
161
|
-
completedTasks: swarmState.completedTaskCount || 0,
|
|
162
|
-
activeTasks: swarmState.activeTaskCount || 0,
|
|
163
|
-
averageTaskTime: 0,
|
|
164
|
-
// Calculate from agent metrics
|
|
165
|
-
resourceUsage: {
|
|
166
|
-
memoryMB: usage.memoryEstimate,
|
|
167
|
-
cpuPercent: this.estimateCpuUsage(),
|
|
168
|
-
diskMB: this.estimateDiskUsage()
|
|
169
|
-
},
|
|
170
|
-
performance: {
|
|
171
|
-
throughput: swarmState.performance?.throughput || 0,
|
|
172
|
-
efficiency: swarmState.performance?.efficiency || 0,
|
|
173
|
-
uptime: Date.now() - swarmState.startTime
|
|
174
|
-
},
|
|
175
|
-
agents: this.collectAgentMetrics()
|
|
176
|
-
};
|
|
177
|
-
this.metrics.set(swarmState.id, metrics);
|
|
178
|
-
this.emit("metricsUpdated", metrics);
|
|
179
|
-
}
|
|
180
|
-
collectAgentMetrics() {
|
|
181
|
-
const agents = this.swarmCoordinator.activeAgents;
|
|
182
|
-
if (!agents) return [];
|
|
183
|
-
return Array.from(agents.values()).map(
|
|
184
|
-
(agent) => ({
|
|
185
|
-
id: agent.id,
|
|
186
|
-
role: agent.role,
|
|
187
|
-
status: agent.status,
|
|
188
|
-
currentTask: agent.currentTask || void 0,
|
|
189
|
-
tasksCompleted: agent.performance?.tasksCompleted || 0,
|
|
190
|
-
averageTaskTime: agent.performance?.averageTaskTime || 0,
|
|
191
|
-
successRate: agent.performance?.successRate || 1,
|
|
192
|
-
lastActivity: agent.performance?.lastFreshStart || Date.now(),
|
|
193
|
-
resourceUsage: {
|
|
194
|
-
memoryMB: 50,
|
|
195
|
-
// Estimate per agent
|
|
196
|
-
iterations: agent.performance?.tasksCompleted || 0
|
|
197
|
-
}
|
|
198
|
-
})
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
checkAlerts() {
|
|
202
|
-
const metrics = this.getAllMetrics();
|
|
203
|
-
for (const swarmMetrics of metrics) {
|
|
204
|
-
for (const alert of this.alerts) {
|
|
205
|
-
if (this.evaluateAlertCondition(alert, swarmMetrics)) {
|
|
206
|
-
this.emit("alert", {
|
|
207
|
-
...alert,
|
|
208
|
-
swarmId: swarmMetrics.swarmId,
|
|
209
|
-
timestamp: Date.now(),
|
|
210
|
-
value: this.getMetricValue(alert.condition, swarmMetrics)
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
evaluateAlertCondition(alert, metrics) {
|
|
217
|
-
const value = this.getMetricValue(alert.condition, metrics);
|
|
218
|
-
switch (alert.type) {
|
|
219
|
-
case "performance":
|
|
220
|
-
return value < alert.threshold;
|
|
221
|
-
case "error":
|
|
222
|
-
return 1 - metrics.performance.efficiency > alert.threshold;
|
|
223
|
-
case "resource":
|
|
224
|
-
return metrics.resourceUsage.memoryMB > alert.threshold;
|
|
225
|
-
case "completion":
|
|
226
|
-
return metrics.performance.uptime > alert.threshold;
|
|
227
|
-
default:
|
|
228
|
-
return false;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
getMetricValue(condition, metrics) {
|
|
232
|
-
if (condition.includes("throughput")) return metrics.performance.throughput;
|
|
233
|
-
if (condition.includes("efficiency")) return metrics.performance.efficiency;
|
|
234
|
-
if (condition.includes("memory")) return metrics.resourceUsage.memoryMB;
|
|
235
|
-
if (condition.includes("uptime")) return metrics.performance.uptime;
|
|
236
|
-
return 0;
|
|
237
|
-
}
|
|
238
|
-
getActiveAlerts() {
|
|
239
|
-
return [];
|
|
240
|
-
}
|
|
241
|
-
estimateCpuUsage() {
|
|
242
|
-
const activeAgents = this.collectAgentMetrics().filter(
|
|
243
|
-
(a) => a.status === "active"
|
|
244
|
-
).length;
|
|
245
|
-
return Math.min(activeAgents * 15, 100);
|
|
246
|
-
}
|
|
247
|
-
estimateDiskUsage() {
|
|
248
|
-
const usage = this.swarmCoordinator.getResourceUsage();
|
|
249
|
-
return usage.workingDirectories.length * 10;
|
|
250
|
-
}
|
|
251
|
-
setupDefaultAlerts() {
|
|
252
|
-
this.alerts = [
|
|
253
|
-
{
|
|
254
|
-
id: "low-throughput",
|
|
255
|
-
type: "performance",
|
|
256
|
-
condition: "throughput < 0.5",
|
|
257
|
-
threshold: 0.5,
|
|
258
|
-
message: "Low throughput detected: Less than 0.5 tasks per minute",
|
|
259
|
-
severity: "medium"
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
id: "high-memory",
|
|
263
|
-
type: "resource",
|
|
264
|
-
condition: "memory > 500",
|
|
265
|
-
threshold: 500,
|
|
266
|
-
message: "High memory usage detected: Over 500MB",
|
|
267
|
-
severity: "high"
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
id: "long-running",
|
|
271
|
-
type: "completion",
|
|
272
|
-
condition: "uptime > 1800000",
|
|
273
|
-
threshold: 18e5,
|
|
274
|
-
// 30 minutes
|
|
275
|
-
message: "Long running swarm detected: Over 30 minutes",
|
|
276
|
-
severity: "low"
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
id: "low-efficiency",
|
|
280
|
-
type: "error",
|
|
281
|
-
condition: "errorRate > 0.3",
|
|
282
|
-
threshold: 0.3,
|
|
283
|
-
message: "High error rate detected: Over 30% failure rate",
|
|
284
|
-
severity: "critical"
|
|
285
|
-
}
|
|
286
|
-
];
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
var swarm_dashboard_default = SwarmDashboard;
|
|
290
|
-
export {
|
|
291
|
-
SwarmDashboard,
|
|
292
|
-
swarm_dashboard_default as default
|
|
293
|
-
};
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
2
|
-
import { dirname as __pathDirname } from 'path';
|
|
3
|
-
const __filename = __fileURLToPath(import.meta.url);
|
|
4
|
-
const __dirname = __pathDirname(__filename);
|
|
5
|
-
import { EventEmitter } from "events";
|
|
6
|
-
import { logger } from "../../../core/monitoring/logger.js";
|
|
7
|
-
class SwarmRegistry extends EventEmitter {
|
|
8
|
-
static instance = null;
|
|
9
|
-
swarms = /* @__PURE__ */ new Map();
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
logger.info("SwarmRegistry initialized");
|
|
13
|
-
}
|
|
14
|
-
static getInstance() {
|
|
15
|
-
if (!SwarmRegistry.instance) {
|
|
16
|
-
SwarmRegistry.instance = new SwarmRegistry();
|
|
17
|
-
}
|
|
18
|
-
return SwarmRegistry.instance;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Register a swarm coordinator
|
|
22
|
-
*/
|
|
23
|
-
registerSwarm(coordinator, description) {
|
|
24
|
-
const swarmId = this.generateSwarmId();
|
|
25
|
-
const registration = {
|
|
26
|
-
id: swarmId,
|
|
27
|
-
coordinator,
|
|
28
|
-
startTime: Date.now(),
|
|
29
|
-
status: "active",
|
|
30
|
-
description
|
|
31
|
-
};
|
|
32
|
-
this.swarms.set(swarmId, registration);
|
|
33
|
-
this.emit("swarmRegistered", registration);
|
|
34
|
-
logger.info(`Swarm registered: ${swarmId} - ${description}`);
|
|
35
|
-
return swarmId;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Unregister a swarm
|
|
39
|
-
*/
|
|
40
|
-
unregisterSwarm(swarmId) {
|
|
41
|
-
const swarm = this.swarms.get(swarmId);
|
|
42
|
-
if (swarm) {
|
|
43
|
-
this.swarms.delete(swarmId);
|
|
44
|
-
this.emit("swarmUnregistered", { id: swarmId });
|
|
45
|
-
logger.info(`Swarm unregistered: ${swarmId}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Get a specific swarm by ID
|
|
50
|
-
*/
|
|
51
|
-
getSwarm(swarmId) {
|
|
52
|
-
return this.swarms.get(swarmId) || null;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* List all active swarms
|
|
56
|
-
*/
|
|
57
|
-
listActiveSwarms() {
|
|
58
|
-
return Array.from(this.swarms.values()).filter(
|
|
59
|
-
(swarm) => swarm.status === "active"
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Update swarm status
|
|
64
|
-
*/
|
|
65
|
-
updateSwarmStatus(swarmId, status) {
|
|
66
|
-
const swarm = this.swarms.get(swarmId);
|
|
67
|
-
if (swarm) {
|
|
68
|
-
swarm.status = status;
|
|
69
|
-
this.emit("swarmStatusChanged", { id: swarmId, status });
|
|
70
|
-
logger.debug(`Swarm ${swarmId} status updated: ${status}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Get swarm statistics
|
|
75
|
-
*/
|
|
76
|
-
getStatistics() {
|
|
77
|
-
const active = this.listActiveSwarms();
|
|
78
|
-
const completed = Array.from(this.swarms.values()).filter(
|
|
79
|
-
(s) => s.status === "completed"
|
|
80
|
-
);
|
|
81
|
-
const totalUptime = active.reduce(
|
|
82
|
-
(sum, swarm) => sum + (Date.now() - swarm.startTime),
|
|
83
|
-
0
|
|
84
|
-
);
|
|
85
|
-
return {
|
|
86
|
-
totalSwarms: this.swarms.size,
|
|
87
|
-
activeSwarms: active.length,
|
|
88
|
-
completedSwarms: completed.length,
|
|
89
|
-
averageUptime: active.length > 0 ? totalUptime / active.length : 0
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Cleanup all swarms and reset registry
|
|
94
|
-
*/
|
|
95
|
-
cleanup() {
|
|
96
|
-
this.swarms.clear();
|
|
97
|
-
logger.info("SwarmRegistry cleaned up");
|
|
98
|
-
}
|
|
99
|
-
generateSwarmId() {
|
|
100
|
-
return `swarm_${Date.now()}_${Math.random().toString(36).substring(2, 8)}`;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
var swarm_registry_default = SwarmRegistry;
|
|
104
|
-
export {
|
|
105
|
-
SwarmRegistry,
|
|
106
|
-
swarm_registry_default as default
|
|
107
|
-
};
|