@stackmemoryai/stackmemory 1.2.2 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -6
- package/dist/src/cli/claude-sm.js +33 -4
- package/dist/src/cli/codex-sm-danger.js +4 -1
- package/dist/src/cli/codex-sm.js +6 -8
- package/dist/src/cli/commands/config.js +0 -81
- package/dist/src/cli/commands/context-rehydrate.js +133 -47
- package/dist/src/cli/commands/db.js +35 -8
- package/dist/src/cli/commands/handoff.js +1 -1
- package/dist/src/cli/commands/linear.js +9 -0
- package/dist/src/cli/commands/ralph.js +2 -2
- package/dist/src/cli/commands/setup.js +2 -2
- package/dist/src/cli/commands/signup.js +3 -1
- package/dist/src/cli/commands/skills.js +108 -1
- package/dist/src/cli/commands/storage-tier.js +26 -8
- package/dist/src/cli/index.js +1 -57
- package/dist/src/core/config/feature-flags.js +0 -4
- package/dist/src/core/context/dual-stack-manager.js +10 -3
- package/dist/src/core/context/frame-database.js +32 -0
- package/dist/src/core/context/frame-handoff-manager.js +2 -2
- package/dist/src/core/context/{refactored-frame-manager.js → frame-manager.js} +3 -3
- package/dist/src/core/context/index.js +2 -2
- package/dist/src/core/database/sqlite-adapter.js +161 -1
- package/dist/src/core/digest/frame-digest-integration.js +1 -1
- package/dist/src/core/digest/index.js +1 -1
- package/dist/src/core/execution/parallel-executor.js +5 -1
- package/dist/src/core/projects/project-isolation.js +18 -4
- package/dist/src/core/security/index.js +2 -0
- package/dist/src/core/security/input-sanitizer.js +23 -0
- package/dist/src/core/utils/update-checker.js +10 -6
- package/dist/src/daemon/daemon-config.js +2 -1
- package/dist/src/daemon/services/auto-save-service.js +121 -0
- package/dist/src/daemon/services/maintenance-service.js +76 -1
- package/dist/src/features/sweep/prompt-builder.js +2 -2
- package/dist/src/hooks/daemon.js +0 -8
- package/dist/src/integrations/linear/config.js +3 -1
- package/dist/src/integrations/linear/sync.js +18 -5
- package/dist/src/integrations/linear/webhook.js +0 -16
- package/dist/src/integrations/mcp/handlers/code-execution-handlers.js +33 -7
- package/dist/src/integrations/mcp/handlers/cord-handlers.js +397 -0
- package/dist/src/integrations/mcp/handlers/index.js +55 -9
- package/dist/src/integrations/mcp/handlers/task-handlers.js +55 -12
- package/dist/src/integrations/mcp/handlers/team-handlers.js +211 -0
- package/dist/src/integrations/mcp/handlers/trace-handlers.js +28 -9
- package/dist/src/integrations/mcp/index.js +2 -2
- package/dist/src/integrations/mcp/refactored-server.js +31 -10
- package/dist/src/integrations/mcp/server.js +0 -130
- package/dist/src/integrations/mcp/tool-definitions.js +196 -67
- package/dist/src/integrations/ralph/context/context-budget-manager.js +10 -2
- package/dist/src/integrations/ralph/context/stackmemory-context-loader.js +54 -22
- package/dist/src/integrations/ralph/learning/pattern-learner.js +59 -24
- package/dist/src/integrations/ralph/orchestration/multi-loop-orchestrator.js +81 -35
- package/dist/src/integrations/ralph/patterns/compounding-engineering-pattern.js +12 -4
- package/dist/src/integrations/ralph/patterns/extended-coherence-sessions.js +32 -9
- package/dist/src/integrations/ralph/swarm/git-workflow-manager.js +25 -8
- package/dist/src/integrations/ralph/swarm/swarm-coordinator.js +17 -5
- package/dist/src/integrations/ralph/visualization/ralph-debugger.js +73 -22
- package/dist/src/skills/claude-skills.js +37 -103
- package/dist/src/skills/theory-skill.js +191 -0
- package/dist/src/utils/hook-installer.js +16 -0
- package/package.json +6 -6
- package/scripts/install-claude-hooks-auto.js +8 -0
- package/templates/claude-hooks/cord-trace.js +225 -0
- package/templates/claude-hooks/theory-capture.js +100 -0
- package/dist/src/core/config/storage-config.js +0 -114
- package/dist/src/core/storage/chromadb-adapter.js +0 -379
- package/dist/src/hooks/graphiti-hooks.js +0 -253
- package/dist/src/integrations/claude-code/enhanced-pre-clear-hooks.js +0 -458
- package/dist/src/integrations/graphiti/client.js +0 -115
- package/dist/src/integrations/graphiti/config.js +0 -17
- package/dist/src/integrations/graphiti/linear-graphiti-bridge.js +0 -115
- package/dist/src/integrations/graphiti/types.js +0 -4
- package/dist/src/integrations/ralph/coordination/enhanced-coordination.js +0 -409
- package/dist/src/skills/repo-ingestion-skill.js +0 -631
- package/templates/claude-hooks/chromadb-wrapper +0 -21
- /package/dist/src/core/context/{enhanced-rehydration.js → rehydration.js} +0 -0
- /package/dist/src/core/digest/{enhanced-hybrid-digest.js → hybrid-digest.js} +0 -0
- /package/dist/src/core/session/{enhanced-handoff.js → handoff.js} +0 -0
|
@@ -1,409 +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 EnhancedCoordinationSystem extends EventEmitter {
|
|
8
|
-
agents = /* @__PURE__ */ new Map();
|
|
9
|
-
messageQueue = [];
|
|
10
|
-
dependencies = /* @__PURE__ */ new Map();
|
|
11
|
-
conflicts = /* @__PURE__ */ new Map();
|
|
12
|
-
coordinationRules = [];
|
|
13
|
-
constructor() {
|
|
14
|
-
super();
|
|
15
|
-
this.setupDefaultRules();
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Register an agent with the coordination system
|
|
19
|
-
*/
|
|
20
|
-
registerAgent(agent) {
|
|
21
|
-
this.agents.set(agent.id, agent);
|
|
22
|
-
logger.info(`Agent ${agent.role} registered for coordination`);
|
|
23
|
-
this.broadcastMessage({
|
|
24
|
-
id: this.generateId(),
|
|
25
|
-
from: "system",
|
|
26
|
-
to: "broadcast",
|
|
27
|
-
type: "status_update",
|
|
28
|
-
content: { type: "agent_joined", agent: agent.role },
|
|
29
|
-
timestamp: Date.now(),
|
|
30
|
-
priority: "normal"
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Send message between agents
|
|
35
|
-
*/
|
|
36
|
-
sendMessage(message) {
|
|
37
|
-
const fullMessage = {
|
|
38
|
-
...message,
|
|
39
|
-
id: this.generateId(),
|
|
40
|
-
timestamp: Date.now()
|
|
41
|
-
};
|
|
42
|
-
this.messageQueue.push(fullMessage);
|
|
43
|
-
this.routeMessage(fullMessage);
|
|
44
|
-
this.emit("messageReceived", fullMessage);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Broadcast message to all agents
|
|
48
|
-
*/
|
|
49
|
-
broadcastMessage(message) {
|
|
50
|
-
this.sendMessage({
|
|
51
|
-
...message,
|
|
52
|
-
to: "broadcast"
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Request help from other agents
|
|
57
|
-
*/
|
|
58
|
-
requestHelp(fromAgent, helpType, context) {
|
|
59
|
-
const suitableAgents = this.findSuitableHelpers(helpType);
|
|
60
|
-
this.sendMessage({
|
|
61
|
-
from: fromAgent,
|
|
62
|
-
to: suitableAgents,
|
|
63
|
-
type: "help_request",
|
|
64
|
-
content: {
|
|
65
|
-
helpType,
|
|
66
|
-
context,
|
|
67
|
-
requesterCapabilities: this.agents.get(fromAgent)?.capabilities || []
|
|
68
|
-
},
|
|
69
|
-
priority: "high"
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Add task dependency
|
|
74
|
-
*/
|
|
75
|
-
addDependency(dependency) {
|
|
76
|
-
this.dependencies.set(dependency.taskId, dependency);
|
|
77
|
-
this.updateCriticalPath();
|
|
78
|
-
logger.info(
|
|
79
|
-
`Added dependency: ${dependency.taskId} depends on ${dependency.dependsOn.join(", ")}`
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Resolve conflicts automatically
|
|
84
|
-
*/
|
|
85
|
-
async resolveConflict(conflictId) {
|
|
86
|
-
const conflict = this.conflicts.get(conflictId);
|
|
87
|
-
if (!conflict) return false;
|
|
88
|
-
try {
|
|
89
|
-
switch (conflict.resolutionStrategy) {
|
|
90
|
-
case "voting":
|
|
91
|
-
conflict.resolution = await this.resolveByVoting(conflict);
|
|
92
|
-
break;
|
|
93
|
-
case "expertise_based":
|
|
94
|
-
conflict.resolution = await this.resolveByExpertise(conflict);
|
|
95
|
-
break;
|
|
96
|
-
case "random":
|
|
97
|
-
conflict.resolution = await this.resolveRandomly(conflict);
|
|
98
|
-
break;
|
|
99
|
-
case "manager_override":
|
|
100
|
-
conflict.resolution = await this.resolveByManagerOverride(conflict);
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
conflict.status = "resolved";
|
|
104
|
-
this.conflicts.set(conflictId, conflict);
|
|
105
|
-
this.broadcastMessage({
|
|
106
|
-
from: "system",
|
|
107
|
-
to: conflict.involvedAgents,
|
|
108
|
-
type: "status_update",
|
|
109
|
-
content: {
|
|
110
|
-
type: "conflict_resolved",
|
|
111
|
-
conflictId,
|
|
112
|
-
resolution: conflict.resolution
|
|
113
|
-
},
|
|
114
|
-
priority: "high"
|
|
115
|
-
});
|
|
116
|
-
return true;
|
|
117
|
-
} catch (error) {
|
|
118
|
-
conflict.status = "escalated";
|
|
119
|
-
logger.error(`Failed to resolve conflict ${conflictId}:`, error);
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Get optimal task execution order considering dependencies
|
|
125
|
-
*/
|
|
126
|
-
getOptimalExecutionOrder(tasks) {
|
|
127
|
-
const graph = this.buildDependencyGraph(tasks);
|
|
128
|
-
return this.topologicalSort(graph, tasks);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Detect and report coordination patterns
|
|
132
|
-
*/
|
|
133
|
-
analyzeCoordinationPatterns() {
|
|
134
|
-
const patterns = {
|
|
135
|
-
communicationFrequency: /* @__PURE__ */ new Map(),
|
|
136
|
-
helpRequestPatterns: [],
|
|
137
|
-
conflictFrequency: /* @__PURE__ */ new Map(),
|
|
138
|
-
bottlenecks: this.identifyBottlenecks()
|
|
139
|
-
};
|
|
140
|
-
for (const message of this.messageQueue) {
|
|
141
|
-
const key = `${message.from}-${message.type}`;
|
|
142
|
-
patterns.communicationFrequency.set(
|
|
143
|
-
key,
|
|
144
|
-
(patterns.communicationFrequency.get(key) || 0) + 1
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
for (const conflict of this.conflicts.values()) {
|
|
148
|
-
patterns.conflictFrequency.set(
|
|
149
|
-
conflict.type,
|
|
150
|
-
(patterns.conflictFrequency.get(conflict.type) || 0) + 1
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
return patterns;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Load balancing recommendations
|
|
157
|
-
*/
|
|
158
|
-
getLoadBalancingRecommendations() {
|
|
159
|
-
const recommendations = {
|
|
160
|
-
overloadedAgents: [],
|
|
161
|
-
underutilizedAgents: [],
|
|
162
|
-
suggestedReassignments: []
|
|
163
|
-
};
|
|
164
|
-
for (const agent of this.agents.values()) {
|
|
165
|
-
const workload = this.calculateAgentWorkload(agent);
|
|
166
|
-
if (workload > 0.8) {
|
|
167
|
-
recommendations.overloadedAgents.push(agent.id);
|
|
168
|
-
} else if (workload < 0.3) {
|
|
169
|
-
recommendations.underutilizedAgents.push(agent.id);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
for (const overloaded of recommendations.overloadedAgents) {
|
|
173
|
-
for (const underutilized of recommendations.underutilizedAgents) {
|
|
174
|
-
const compatibility = this.checkAgentCompatibility(
|
|
175
|
-
overloaded,
|
|
176
|
-
underutilized
|
|
177
|
-
);
|
|
178
|
-
if (compatibility.score > 0.7) {
|
|
179
|
-
recommendations.suggestedReassignments.push({
|
|
180
|
-
fromAgent: overloaded,
|
|
181
|
-
toAgent: underutilized,
|
|
182
|
-
taskType: compatibility.bestTaskType,
|
|
183
|
-
reason: `Load balancing: ${compatibility.reason}`
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return recommendations;
|
|
189
|
-
}
|
|
190
|
-
routeMessage(message) {
|
|
191
|
-
if (message.to === "broadcast") {
|
|
192
|
-
for (const agentId of this.agents.keys()) {
|
|
193
|
-
if (agentId !== message.from) {
|
|
194
|
-
this.deliverMessage(agentId, message);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
} else {
|
|
198
|
-
for (const agentId of message.to) {
|
|
199
|
-
this.deliverMessage(agentId, message);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
this.applyCoordinationRules(message);
|
|
203
|
-
}
|
|
204
|
-
deliverMessage(agentId, message) {
|
|
205
|
-
const agent = this.agents.get(agentId);
|
|
206
|
-
if (agent) {
|
|
207
|
-
logger.debug(`Message delivered to ${agent.role}: ${message.type}`);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
findSuitableHelpers(helpType) {
|
|
211
|
-
const helpers = [];
|
|
212
|
-
for (const agent of this.agents.values()) {
|
|
213
|
-
if (this.canProvideHelp(agent, helpType)) {
|
|
214
|
-
helpers.push(agent.id);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return helpers;
|
|
218
|
-
}
|
|
219
|
-
canProvideHelp(agent, helpType) {
|
|
220
|
-
const capabilities = agent.capabilities || [];
|
|
221
|
-
switch (helpType) {
|
|
222
|
-
case "code_review":
|
|
223
|
-
return capabilities.includes("code_review") || agent.role === "reviewer";
|
|
224
|
-
case "debugging":
|
|
225
|
-
return capabilities.includes("debugging") || agent.role === "developer";
|
|
226
|
-
case "testing":
|
|
227
|
-
return capabilities.includes("testing") || agent.role === "tester";
|
|
228
|
-
case "optimization":
|
|
229
|
-
return capabilities.includes("optimization") || agent.role === "optimizer";
|
|
230
|
-
default:
|
|
231
|
-
return false;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
async resolveByVoting(conflict) {
|
|
235
|
-
const votes = /* @__PURE__ */ new Map();
|
|
236
|
-
for (const agentId of conflict.involvedAgents) {
|
|
237
|
-
const agent = this.agents.get(agentId);
|
|
238
|
-
if (agent) {
|
|
239
|
-
votes.set(agentId, Math.random() > 0.5 ? "option_a" : "option_b");
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
const results = /* @__PURE__ */ new Map();
|
|
243
|
-
for (const vote of votes.values()) {
|
|
244
|
-
results.set(vote, (results.get(vote) || 0) + 1);
|
|
245
|
-
}
|
|
246
|
-
return Array.from(results.entries()).reduce(
|
|
247
|
-
(a, b) => a[1] > b[1] ? a : b
|
|
248
|
-
)[0];
|
|
249
|
-
}
|
|
250
|
-
async resolveByExpertise(conflict) {
|
|
251
|
-
let bestAgent = null;
|
|
252
|
-
let bestExpertise = 0;
|
|
253
|
-
for (const agentId of conflict.involvedAgents) {
|
|
254
|
-
const agent = this.agents.get(agentId);
|
|
255
|
-
if (agent) {
|
|
256
|
-
const expertise = this.calculateExpertise(agent, conflict.type);
|
|
257
|
-
if (expertise > bestExpertise) {
|
|
258
|
-
bestExpertise = expertise;
|
|
259
|
-
bestAgent = agent;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
return {
|
|
264
|
-
resolutionSource: bestAgent?.id,
|
|
265
|
-
method: "expertise_based",
|
|
266
|
-
expertiseScore: bestExpertise
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
async resolveRandomly(conflict) {
|
|
270
|
-
const options = ["option_a", "option_b", "compromise"];
|
|
271
|
-
return options[Math.floor(Math.random() * options.length)];
|
|
272
|
-
}
|
|
273
|
-
async resolveByManagerOverride(conflict) {
|
|
274
|
-
const manager = Array.from(this.agents.values()).find(
|
|
275
|
-
(agent) => agent.role === "coordinator" || agent.role === "architect"
|
|
276
|
-
);
|
|
277
|
-
return {
|
|
278
|
-
resolutionSource: manager?.id || "system",
|
|
279
|
-
method: "manager_override"
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
calculateExpertise(agent, conflictType) {
|
|
283
|
-
const capabilities = agent.capabilities || [];
|
|
284
|
-
const performance = agent.performance;
|
|
285
|
-
let expertise = 0;
|
|
286
|
-
switch (conflictType) {
|
|
287
|
-
case "resource":
|
|
288
|
-
expertise += capabilities.includes("resource_optimization") ? 0.5 : 0;
|
|
289
|
-
break;
|
|
290
|
-
case "task_overlap":
|
|
291
|
-
expertise += capabilities.includes("coordination") ? 0.5 : 0;
|
|
292
|
-
break;
|
|
293
|
-
}
|
|
294
|
-
if (performance) {
|
|
295
|
-
expertise += performance.successRate * 0.3;
|
|
296
|
-
expertise += Math.min(performance.tasksCompleted / 10, 0.2);
|
|
297
|
-
}
|
|
298
|
-
return Math.min(expertise, 1);
|
|
299
|
-
}
|
|
300
|
-
buildDependencyGraph(tasks) {
|
|
301
|
-
const graph = /* @__PURE__ */ new Map();
|
|
302
|
-
for (const task of tasks) {
|
|
303
|
-
const deps = this.dependencies.get(task.id);
|
|
304
|
-
graph.set(task.id, deps?.dependsOn || []);
|
|
305
|
-
}
|
|
306
|
-
return graph;
|
|
307
|
-
}
|
|
308
|
-
topologicalSort(graph, tasks) {
|
|
309
|
-
const result = [];
|
|
310
|
-
const visited = /* @__PURE__ */ new Set();
|
|
311
|
-
const visiting = /* @__PURE__ */ new Set();
|
|
312
|
-
const visit = (taskId) => {
|
|
313
|
-
if (visited.has(taskId)) return;
|
|
314
|
-
if (visiting.has(taskId)) {
|
|
315
|
-
logger.warn(`Circular dependency detected involving task: ${taskId}`);
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
visiting.add(taskId);
|
|
319
|
-
const deps = graph.get(taskId) || [];
|
|
320
|
-
for (const dep of deps) {
|
|
321
|
-
visit(dep);
|
|
322
|
-
}
|
|
323
|
-
visiting.delete(taskId);
|
|
324
|
-
visited.add(taskId);
|
|
325
|
-
const task = tasks.find((t) => t.id === taskId);
|
|
326
|
-
if (task) result.push(task);
|
|
327
|
-
};
|
|
328
|
-
for (const task of tasks) {
|
|
329
|
-
visit(task.id);
|
|
330
|
-
}
|
|
331
|
-
return result;
|
|
332
|
-
}
|
|
333
|
-
updateCriticalPath() {
|
|
334
|
-
logger.debug("Critical path updated");
|
|
335
|
-
}
|
|
336
|
-
identifyBottlenecks() {
|
|
337
|
-
const bottlenecks = [];
|
|
338
|
-
for (const [taskId, dep] of this.dependencies) {
|
|
339
|
-
if (dep.blockingFor.length > 2) {
|
|
340
|
-
bottlenecks.push(taskId);
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
return bottlenecks;
|
|
344
|
-
}
|
|
345
|
-
calculateAgentWorkload(agent) {
|
|
346
|
-
let workload = 0;
|
|
347
|
-
if (agent.status === "active") workload += 0.5;
|
|
348
|
-
if (agent.currentTask) workload += 0.3;
|
|
349
|
-
const recentMessages = this.messageQueue.filter(
|
|
350
|
-
(m) => (m.from === agent.id || Array.isArray(m.to) && m.to.includes(agent.id)) && Date.now() - m.timestamp < 3e5
|
|
351
|
-
// 5 minutes
|
|
352
|
-
);
|
|
353
|
-
workload += Math.min(recentMessages.length * 0.05, 0.2);
|
|
354
|
-
return Math.min(workload, 1);
|
|
355
|
-
}
|
|
356
|
-
checkAgentCompatibility(agent1Id, agent2Id) {
|
|
357
|
-
const agent1 = this.agents.get(agent1Id);
|
|
358
|
-
const agent2 = this.agents.get(agent2Id);
|
|
359
|
-
if (!agent1 || !agent2) {
|
|
360
|
-
return { score: 0, bestTaskType: "", reason: "Agent not found" };
|
|
361
|
-
}
|
|
362
|
-
const caps1 = new Set(agent1.capabilities || []);
|
|
363
|
-
const caps2 = new Set(agent2.capabilities || []);
|
|
364
|
-
const overlap = new Set([...caps1].filter((x) => caps2.has(x)));
|
|
365
|
-
const score = overlap.size / Math.max(caps1.size, caps2.size, 1);
|
|
366
|
-
return {
|
|
367
|
-
score,
|
|
368
|
-
bestTaskType: Array.from(overlap)[0] || "general",
|
|
369
|
-
reason: `Capability overlap: ${overlap.size} common skills`
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
applyCoordinationRules(message) {
|
|
373
|
-
for (const rule of this.coordinationRules) {
|
|
374
|
-
if (rule.condition(message)) {
|
|
375
|
-
rule.action(message, this);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
setupDefaultRules() {
|
|
380
|
-
this.coordinationRules = [
|
|
381
|
-
{
|
|
382
|
-
id: "help_request_timeout",
|
|
383
|
-
condition: (msg) => msg.type === "help_request",
|
|
384
|
-
action: (msg, system) => {
|
|
385
|
-
setTimeout(() => {
|
|
386
|
-
system.broadcastMessage({
|
|
387
|
-
from: "system",
|
|
388
|
-
to: "broadcast",
|
|
389
|
-
type: "status_update",
|
|
390
|
-
content: {
|
|
391
|
-
type: "help_request_timeout",
|
|
392
|
-
originalRequest: msg.id
|
|
393
|
-
},
|
|
394
|
-
priority: "urgent"
|
|
395
|
-
});
|
|
396
|
-
}, 3e5);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
];
|
|
400
|
-
}
|
|
401
|
-
generateId() {
|
|
402
|
-
return `coord_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
var enhanced_coordination_default = EnhancedCoordinationSystem;
|
|
406
|
-
export {
|
|
407
|
-
EnhancedCoordinationSystem,
|
|
408
|
-
enhanced_coordination_default as default
|
|
409
|
-
};
|