claude-flow 1.0.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.
Files changed (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +612 -0
  3. package/bin/claude-flow +0 -0
  4. package/bin/claude-flow-simple +0 -0
  5. package/bin/claude-flow-typecheck +0 -0
  6. package/deno.json +84 -0
  7. package/package.json +45 -0
  8. package/scripts/check-links.ts +274 -0
  9. package/scripts/check-performance-regression.ts +168 -0
  10. package/scripts/claude-sparc.sh +562 -0
  11. package/scripts/coverage-report.ts +692 -0
  12. package/scripts/demo-task-system.ts +224 -0
  13. package/scripts/install.js +72 -0
  14. package/scripts/test-batch-tasks.ts +29 -0
  15. package/scripts/test-coordination-features.ts +238 -0
  16. package/scripts/test-mcp.ts +251 -0
  17. package/scripts/test-runner.ts +571 -0
  18. package/scripts/validate-examples.ts +288 -0
  19. package/src/cli/cli-core.ts +273 -0
  20. package/src/cli/commands/agent.ts +83 -0
  21. package/src/cli/commands/config.ts +442 -0
  22. package/src/cli/commands/help.ts +765 -0
  23. package/src/cli/commands/index.ts +963 -0
  24. package/src/cli/commands/mcp.ts +191 -0
  25. package/src/cli/commands/memory.ts +74 -0
  26. package/src/cli/commands/monitor.ts +403 -0
  27. package/src/cli/commands/session.ts +595 -0
  28. package/src/cli/commands/start.ts +156 -0
  29. package/src/cli/commands/status.ts +345 -0
  30. package/src/cli/commands/task.ts +79 -0
  31. package/src/cli/commands/workflow.ts +763 -0
  32. package/src/cli/completion.ts +553 -0
  33. package/src/cli/formatter.ts +310 -0
  34. package/src/cli/index.ts +211 -0
  35. package/src/cli/main.ts +23 -0
  36. package/src/cli/repl.ts +1050 -0
  37. package/src/cli/simple-cli.js +211 -0
  38. package/src/cli/simple-cli.ts +211 -0
  39. package/src/coordination/README.md +400 -0
  40. package/src/coordination/advanced-scheduler.ts +487 -0
  41. package/src/coordination/circuit-breaker.ts +366 -0
  42. package/src/coordination/conflict-resolution.ts +490 -0
  43. package/src/coordination/dependency-graph.ts +475 -0
  44. package/src/coordination/index.ts +63 -0
  45. package/src/coordination/manager.ts +460 -0
  46. package/src/coordination/messaging.ts +290 -0
  47. package/src/coordination/metrics.ts +585 -0
  48. package/src/coordination/resources.ts +322 -0
  49. package/src/coordination/scheduler.ts +390 -0
  50. package/src/coordination/work-stealing.ts +224 -0
  51. package/src/core/config.ts +627 -0
  52. package/src/core/event-bus.ts +186 -0
  53. package/src/core/json-persistence.ts +183 -0
  54. package/src/core/logger.ts +262 -0
  55. package/src/core/orchestrator-fixed.ts +312 -0
  56. package/src/core/orchestrator.ts +1234 -0
  57. package/src/core/persistence.ts +276 -0
  58. package/src/mcp/auth.ts +438 -0
  59. package/src/mcp/claude-flow-tools.ts +1280 -0
  60. package/src/mcp/load-balancer.ts +510 -0
  61. package/src/mcp/router.ts +240 -0
  62. package/src/mcp/server.ts +548 -0
  63. package/src/mcp/session-manager.ts +418 -0
  64. package/src/mcp/tools.ts +180 -0
  65. package/src/mcp/transports/base.ts +21 -0
  66. package/src/mcp/transports/http.ts +457 -0
  67. package/src/mcp/transports/stdio.ts +254 -0
  68. package/src/memory/backends/base.ts +22 -0
  69. package/src/memory/backends/markdown.ts +283 -0
  70. package/src/memory/backends/sqlite.ts +329 -0
  71. package/src/memory/cache.ts +238 -0
  72. package/src/memory/indexer.ts +238 -0
  73. package/src/memory/manager.ts +572 -0
  74. package/src/terminal/adapters/base.ts +29 -0
  75. package/src/terminal/adapters/native.ts +504 -0
  76. package/src/terminal/adapters/vscode.ts +340 -0
  77. package/src/terminal/manager.ts +308 -0
  78. package/src/terminal/pool.ts +271 -0
  79. package/src/terminal/session.ts +250 -0
  80. package/src/terminal/vscode-bridge.ts +242 -0
  81. package/src/utils/errors.ts +231 -0
  82. package/src/utils/helpers.ts +476 -0
  83. package/src/utils/types.ts +493 -0
@@ -0,0 +1,224 @@
1
+ #!/usr/bin/env -S deno run --allow-all
2
+
3
+ /**
4
+ * Simple demonstration of Claude-Flow task system
5
+ * Shows the basic flow of:
6
+ * 1. Creating tasks
7
+ * 2. Spawning agents
8
+ * 3. Assigning tasks
9
+ * 4. Tracking execution
10
+ * 5. Getting results
11
+ */
12
+
13
+ import { EventBus } from '../src/core/event-bus.ts';
14
+ import { Logger } from '../src/core/logger.ts';
15
+ import { SystemEvents, Task, AgentProfile } from '../src/utils/types.ts';
16
+ import { delay } from '../src/utils/helpers.ts';
17
+
18
+ // Simple task executor
19
+ class SimpleTaskExecutor {
20
+ private tasks = new Map<string, Task>();
21
+ private agents = new Map<string, AgentProfile>();
22
+ private results = new Map<string, any>();
23
+
24
+ constructor(
25
+ private eventBus: EventBus,
26
+ private logger: Logger
27
+ ) {
28
+ this.setupHandlers();
29
+ }
30
+
31
+ async createAgent(name: string, capabilities: string[]): Promise<string> {
32
+ const agent: AgentProfile = {
33
+ id: `agent-${Date.now()}`,
34
+ name,
35
+ type: 'custom',
36
+ capabilities,
37
+ systemPrompt: `You are ${name}`,
38
+ maxConcurrentTasks: 2,
39
+ priority: 50,
40
+ };
41
+
42
+ this.agents.set(agent.id, agent);
43
+ this.logger.info(`Created agent: ${name}`, { agentId: agent.id });
44
+
45
+ this.eventBus.emit(SystemEvents.AGENT_SPAWNED, {
46
+ agentId: agent.id,
47
+ profile: agent,
48
+ });
49
+
50
+ return agent.id;
51
+ }
52
+
53
+ async createTask(type: string, description: string, input: any): Promise<string> {
54
+ const task: Task = {
55
+ id: `task-${Date.now()}-${Math.random().toString(36).substr(2, 5)}`,
56
+ type,
57
+ description,
58
+ priority: 50,
59
+ dependencies: [],
60
+ status: 'pending',
61
+ input,
62
+ createdAt: new Date(),
63
+ };
64
+
65
+ this.tasks.set(task.id, task);
66
+ this.logger.info(`Created task: ${description}`, { taskId: task.id });
67
+
68
+ this.eventBus.emit(SystemEvents.TASK_CREATED, { task });
69
+
70
+ return task.id;
71
+ }
72
+
73
+ async assignTask(taskId: string, agentId: string): Promise<void> {
74
+ const task = this.tasks.get(taskId);
75
+ const agent = this.agents.get(agentId);
76
+
77
+ if (!task || !agent) {
78
+ throw new Error('Task or agent not found');
79
+ }
80
+
81
+ task.assignedAgent = agentId;
82
+ task.status = 'assigned';
83
+
84
+ this.eventBus.emit(SystemEvents.TASK_ASSIGNED, {
85
+ taskId,
86
+ agentId,
87
+ });
88
+
89
+ // Simulate execution
90
+ this.executeTask(task, agent);
91
+ }
92
+
93
+ private async executeTask(task: Task, agent: AgentProfile): Promise<void> {
94
+ // Start task
95
+ task.status = 'running';
96
+ task.startedAt = new Date();
97
+
98
+ this.eventBus.emit(SystemEvents.TASK_STARTED, {
99
+ taskId: task.id,
100
+ agentId: agent.id,
101
+ });
102
+
103
+ // Simulate processing
104
+ await delay(1000 + Math.random() * 2000);
105
+
106
+ // Generate result
107
+ const result = {
108
+ taskId: task.id,
109
+ agentId: agent.id,
110
+ output: `${agent.name} completed ${task.type}: ${task.description}`,
111
+ processingTime: Date.now() - task.startedAt.getTime(),
112
+ data: task.input,
113
+ };
114
+
115
+ this.results.set(task.id, result);
116
+
117
+ // Complete task
118
+ task.status = 'completed';
119
+ task.completedAt = new Date();
120
+ task.output = result;
121
+
122
+ this.eventBus.emit(SystemEvents.TASK_COMPLETED, {
123
+ taskId: task.id,
124
+ result,
125
+ });
126
+ }
127
+
128
+ getResults(): Map<string, any> {
129
+ return this.results;
130
+ }
131
+
132
+ getStats() {
133
+ const tasks = Array.from(this.tasks.values());
134
+ return {
135
+ total: tasks.length,
136
+ completed: tasks.filter(t => t.status === 'completed').length,
137
+ running: tasks.filter(t => t.status === 'running').length,
138
+ pending: tasks.filter(t => t.status === 'pending').length,
139
+ };
140
+ }
141
+
142
+ private setupHandlers() {
143
+ this.eventBus.on(SystemEvents.TASK_COMPLETED, (data: any) => {
144
+ this.logger.info(`Task completed: ${data.taskId}`);
145
+ });
146
+ }
147
+ }
148
+
149
+ // Demo runner
150
+ async function runDemo() {
151
+ console.log('šŸŽÆ Claude-Flow Task System Demo\n');
152
+
153
+ const eventBus = new EventBus();
154
+ const logger = new Logger(
155
+ { level: 'info', format: 'pretty', destination: 'console' },
156
+ { component: 'demo' }
157
+ );
158
+
159
+ const executor = new SimpleTaskExecutor(eventBus, logger);
160
+
161
+ // Track events
162
+ let tasksCompleted = 0;
163
+ eventBus.on(SystemEvents.TASK_COMPLETED, () => tasksCompleted++);
164
+
165
+ console.log('šŸ“‹ Step 1: Creating Agents\n');
166
+
167
+ // Create agents with different capabilities
168
+ const coder = await executor.createAgent('Code Master', ['coding', 'testing']);
169
+ const analyst = await executor.createAgent('Data Analyst', ['analysis', 'reporting']);
170
+ const researcher = await executor.createAgent('Research Bot', ['research', 'documentation']);
171
+
172
+ console.log('\nšŸ“‹ Step 2: Creating Tasks\n');
173
+
174
+ // Create various tasks
175
+ const tasks = [
176
+ await executor.createTask('code', 'Implement user authentication', { feature: 'auth' }),
177
+ await executor.createTask('analyze', 'Analyze user behavior data', { dataset: 'users' }),
178
+ await executor.createTask('research', 'Research best practices for API design', { topic: 'REST' }),
179
+ await executor.createTask('code', 'Add unit tests for payment module', { module: 'payments' }),
180
+ await executor.createTask('analyze', 'Generate performance report', { period: 'Q4' }),
181
+ ];
182
+
183
+ console.log('\nšŸ“‹ Step 3: Assigning Tasks to Agents\n');
184
+
185
+ // Assign tasks based on capabilities
186
+ await executor.assignTask(tasks[0], coder); // auth implementation
187
+ await executor.assignTask(tasks[1], analyst); // behavior analysis
188
+ await executor.assignTask(tasks[2], researcher); // API research
189
+ await executor.assignTask(tasks[3], coder); // unit tests
190
+ await executor.assignTask(tasks[4], analyst); // performance report
191
+
192
+ console.log('\nā³ Step 4: Waiting for Completion...\n');
193
+
194
+ // Wait for all tasks to complete
195
+ while (tasksCompleted < tasks.length) {
196
+ await delay(500);
197
+ const stats = executor.getStats();
198
+ console.log(`šŸ“Š Progress: ${stats.completed}/${stats.total} completed, ${stats.running} running`);
199
+ }
200
+
201
+ console.log('\nšŸ“‹ Step 5: Results Summary\n');
202
+
203
+ // Display results
204
+ const results = executor.getResults();
205
+ for (const [taskId, result] of results) {
206
+ console.log(`āœ… ${result.output}`);
207
+ console.log(` ā±ļø Time: ${result.processingTime}ms`);
208
+ }
209
+
210
+ // Final stats
211
+ const finalStats = executor.getStats();
212
+ console.log('\n' + '='.repeat(50));
213
+ console.log('šŸ“Š DEMO COMPLETE');
214
+ console.log('='.repeat(50));
215
+ console.log(`Total tasks: ${finalStats.total}`);
216
+ console.log(`Completed: ${finalStats.completed}`);
217
+ console.log(`Success rate: 100%`);
218
+ console.log('\n✨ Claude-Flow task system is working perfectly!');
219
+ }
220
+
221
+ // Run the demo
222
+ if (import.meta.main) {
223
+ runDemo().catch(console.error);
224
+ }
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+
3
+ const os = require('os');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+ const https = require('https');
7
+ const { spawn } = require('child_process');
8
+
9
+ console.log('Installing Claude-Flow...');
10
+
11
+ // Check if Deno is available
12
+ function checkDeno() {
13
+ return new Promise((resolve) => {
14
+ const deno = spawn('deno', ['--version'], { stdio: 'pipe' });
15
+ deno.on('close', (code) => {
16
+ resolve(code === 0);
17
+ });
18
+ deno.on('error', () => {
19
+ resolve(false);
20
+ });
21
+ });
22
+ }
23
+
24
+ // Install Deno if not available
25
+ async function installDeno() {
26
+ console.log('Deno not found. Installing Deno...');
27
+
28
+ const platform = os.platform();
29
+ const arch = os.arch();
30
+
31
+ if (platform === 'win32') {
32
+ console.log('Please install Deno manually from https://deno.land/');
33
+ process.exit(1);
34
+ }
35
+
36
+ return new Promise((resolve, reject) => {
37
+ const installScript = spawn('curl', ['-fsSL', 'https://deno.land/x/install/install.sh'], { stdio: 'pipe' });
38
+ const sh = spawn('sh', [], { stdio: ['pipe', 'inherit', 'inherit'] });
39
+
40
+ installScript.stdout.pipe(sh.stdin);
41
+
42
+ sh.on('close', (code) => {
43
+ if (code === 0) {
44
+ console.log('Deno installed successfully!');
45
+ resolve();
46
+ } else {
47
+ reject(new Error('Failed to install Deno'));
48
+ }
49
+ });
50
+ });
51
+ }
52
+
53
+ // Main installation process
54
+ async function main() {
55
+ try {
56
+ const denoAvailable = await checkDeno();
57
+
58
+ if (!denoAvailable) {
59
+ await installDeno();
60
+ }
61
+
62
+ console.log('Claude-Flow installation completed!');
63
+ console.log('You can now use: npx claude-flow or claude-flow (if installed globally)');
64
+
65
+ } catch (error) {
66
+ console.error('Installation failed:', error.message);
67
+ console.log('Please install Deno manually from https://deno.land/ and try again.');
68
+ process.exit(1);
69
+ }
70
+ }
71
+
72
+ main();
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env -S deno run --allow-all
2
+
3
+ /**
4
+ * Test runner script for Claude-Flow batch task system
5
+ * Run with: deno run --allow-all scripts/test-batch-tasks.ts
6
+ */
7
+
8
+ import { runBatchTaskTest } from '../tests/integration/batch-task-test.ts';
9
+
10
+ console.log('šŸš€ Claude-Flow Batch Task System Test Runner\n');
11
+ console.log('This test will demonstrate:');
12
+ console.log(' • Task creation and queuing');
13
+ console.log(' • Agent spawning and assignment');
14
+ console.log(' • Parallel task execution');
15
+ console.log(' • Batch tool usage for efficiency');
16
+ console.log(' • Task completion tracking');
17
+ console.log(' • System coordination\n');
18
+ console.log('Starting test in 3 seconds...\n');
19
+
20
+ // Give user time to read
21
+ await new Promise(resolve => setTimeout(resolve, 3000));
22
+
23
+ try {
24
+ await runBatchTaskTest();
25
+ Deno.exit(0);
26
+ } catch (error) {
27
+ console.error('Test failed:', error);
28
+ Deno.exit(1);
29
+ }
@@ -0,0 +1,238 @@
1
+ #!/usr/bin/env -S deno run --allow-all
2
+
3
+ /**
4
+ * Test script for advanced coordination features
5
+ * Demonstrates:
6
+ * - Resource management and deadlock detection
7
+ * - Task dependencies and scheduling
8
+ * - Work stealing and load balancing
9
+ * - Circuit breakers and fault tolerance
10
+ */
11
+
12
+ import { EventBus } from '../src/core/event-bus.ts';
13
+ import { ConsoleLogger } from '../src/core/logger.ts';
14
+ import { CoordinationManager } from '../src/coordination/manager.ts';
15
+ import { Task, SystemEvents } from '../src/utils/types.ts';
16
+ import { delay } from '../src/utils/helpers.ts';
17
+
18
+ async function testCoordinationFeatures() {
19
+ console.log('šŸ”„ Testing Claude-Flow Coordination Features\n');
20
+
21
+ const eventBus = new EventBus();
22
+ const logger = new ConsoleLogger('coord-test');
23
+
24
+ const config = {
25
+ maxRetries: 3,
26
+ retryDelay: 1000,
27
+ resourceTimeout: 5000,
28
+ deadlockDetection: true,
29
+ priorityLevels: 5,
30
+ };
31
+
32
+ const coordinator = new CoordinationManager(config, eventBus, logger);
33
+
34
+ try {
35
+ await coordinator.initialize();
36
+ console.log('āœ… Coordination manager initialized\n');
37
+
38
+ // Test 1: Resource Management
39
+ console.log('šŸ“‹ Test 1: Resource Management');
40
+ console.log('Testing resource acquisition and release...');
41
+
42
+ // Agent 1 acquires resource A
43
+ await coordinator.acquireResource('resource-A', 'agent-1');
44
+ console.log('āœ… Agent 1 acquired resource A');
45
+
46
+ // Agent 2 tries to acquire resource A (should wait)
47
+ const acquire2Promise = coordinator.acquireResource('resource-A', 'agent-2');
48
+ console.log('ā³ Agent 2 waiting for resource A...');
49
+
50
+ // Release after delay
51
+ setTimeout(async () => {
52
+ await coordinator.releaseResource('resource-A', 'agent-1');
53
+ console.log('āœ… Agent 1 released resource A');
54
+ }, 1000);
55
+
56
+ await acquire2Promise;
57
+ console.log('āœ… Agent 2 acquired resource A\n');
58
+
59
+ // Test 2: Task Dependencies
60
+ console.log('šŸ“‹ Test 2: Task Dependencies');
61
+
62
+ const parentTask: Task = {
63
+ id: 'parent-task',
64
+ type: 'process',
65
+ description: 'Parent task',
66
+ priority: 90,
67
+ dependencies: [],
68
+ status: 'pending',
69
+ input: {},
70
+ createdAt: new Date(),
71
+ };
72
+
73
+ const childTask: Task = {
74
+ id: 'child-task',
75
+ type: 'process',
76
+ description: 'Child task (depends on parent)',
77
+ priority: 80,
78
+ dependencies: ['parent-task'],
79
+ status: 'pending',
80
+ input: {},
81
+ createdAt: new Date(),
82
+ };
83
+
84
+ await coordinator.assignTask(parentTask, 'agent-1');
85
+ console.log('āœ… Assigned parent task to agent-1');
86
+
87
+ try {
88
+ await coordinator.assignTask(childTask, 'agent-2');
89
+ } catch (error) {
90
+ console.log('āœ… Child task correctly blocked by dependency');
91
+ }
92
+
93
+ // Complete parent task
94
+ eventBus.emit(SystemEvents.TASK_COMPLETED, {
95
+ taskId: 'parent-task',
96
+ result: { data: 'parent result' },
97
+ });
98
+
99
+ await delay(100);
100
+
101
+ // Now child should be assignable
102
+ await coordinator.assignTask(childTask, 'agent-2');
103
+ console.log('āœ… Child task assigned after parent completion\n');
104
+
105
+ // Test 3: Deadlock Detection
106
+ console.log('šŸ“‹ Test 3: Deadlock Detection');
107
+ console.log('Creating potential deadlock scenario...');
108
+
109
+ // Agent 3 holds B, wants A
110
+ await coordinator.acquireResource('resource-B', 'agent-3');
111
+ const agent3WantsA = coordinator.acquireResource('resource-A', 'agent-3')
112
+ .catch(() => console.log('āœ… Deadlock detected and resolved'));
113
+
114
+ // Agent 2 holds A, wants B (creates cycle)
115
+ const agent2WantsB = coordinator.acquireResource('resource-B', 'agent-2')
116
+ .catch(() => console.log('āœ… Agent 2 resource request failed'));
117
+
118
+ // Wait for deadlock detection
119
+ await delay(2000);
120
+
121
+ // Clean up resources
122
+ await coordinator.releaseResource('resource-A', 'agent-2');
123
+ await coordinator.releaseResource('resource-B', 'agent-3');
124
+ console.log('āœ… Resources cleaned up\n');
125
+
126
+ // Test 4: Advanced Scheduling
127
+ console.log('šŸ“‹ Test 4: Advanced Scheduling Features');
128
+ coordinator.enableAdvancedScheduling();
129
+ console.log('āœ… Advanced scheduling enabled');
130
+
131
+ // Create tasks with different priorities
132
+ const highPriorityTask: Task = {
133
+ id: 'high-priority',
134
+ type: 'urgent',
135
+ description: 'High priority task',
136
+ priority: 100,
137
+ dependencies: [],
138
+ status: 'pending',
139
+ input: {},
140
+ createdAt: new Date(),
141
+ };
142
+
143
+ const lowPriorityTask: Task = {
144
+ id: 'low-priority',
145
+ type: 'batch',
146
+ description: 'Low priority task',
147
+ priority: 10,
148
+ dependencies: [],
149
+ status: 'pending',
150
+ input: {},
151
+ createdAt: new Date(),
152
+ };
153
+
154
+ await coordinator.assignTask(lowPriorityTask, 'agent-1');
155
+ await coordinator.assignTask(highPriorityTask, 'agent-1');
156
+ console.log('āœ… Tasks assigned with priority scheduling\n');
157
+
158
+ // Test 5: Conflict Resolution
159
+ console.log('šŸ“‹ Test 5: Conflict Resolution');
160
+
161
+ // Report a resource conflict
162
+ await coordinator.reportConflict('resource', 'shared-resource', ['agent-1', 'agent-2']);
163
+ console.log('āœ… Resource conflict reported and auto-resolved');
164
+
165
+ // Report a task conflict
166
+ await coordinator.reportConflict('task', 'disputed-task', ['agent-1', 'agent-2']);
167
+ console.log('āœ… Task conflict reported and auto-resolved\n');
168
+
169
+ // Test 6: Health and Metrics
170
+ console.log('šŸ“‹ Test 6: Health Monitoring and Metrics');
171
+
172
+ const health = await coordinator.getHealthStatus();
173
+ console.log('šŸ„ Health Status:', health.healthy ? 'Healthy' : 'Unhealthy');
174
+
175
+ const metrics = await coordinator.getCoordinationMetrics();
176
+ console.log('šŸ“Š Coordination Metrics:');
177
+ console.log(` Tasks assigned: ${metrics.assigned || 0}`);
178
+ console.log(` Resources managed: ${metrics.resources || 0}`);
179
+ console.log(` Conflicts resolved: ${metrics.conflicts?.resolved || 0}`);
180
+ console.log(` Advanced scheduling: ${metrics.advancedScheduling ? 'Enabled' : 'Disabled'}`);
181
+
182
+ // Test 7: Message Routing
183
+ console.log('\nšŸ“‹ Test 7: Inter-Agent Messaging');
184
+
185
+ // Set up message handler
186
+ let messagesReceived = 0;
187
+ eventBus.on('message:agent-2', (data: any) => {
188
+ messagesReceived++;
189
+ console.log(`āœ… Agent 2 received message: ${data.message.content}`);
190
+ });
191
+
192
+ // Send messages
193
+ await coordinator.sendMessage('agent-1', 'agent-2', {
194
+ type: 'status',
195
+ content: 'Task completed'
196
+ });
197
+
198
+ await coordinator.sendMessage('agent-1', 'agent-2', {
199
+ type: 'data',
200
+ content: 'Results available'
201
+ });
202
+
203
+ await delay(100);
204
+ console.log(`āœ… Sent and received ${messagesReceived} messages\n`);
205
+
206
+ // Perform maintenance
207
+ console.log('šŸ“‹ Performing maintenance...');
208
+ await coordinator.performMaintenance();
209
+ console.log('āœ… Maintenance completed');
210
+
211
+ // Shutdown
212
+ await coordinator.shutdown();
213
+ console.log('\nāœ… Coordination manager shut down successfully');
214
+
215
+ // Summary
216
+ console.log('\n' + '='.repeat(50));
217
+ console.log('āœ… ALL COORDINATION TESTS PASSED!');
218
+ console.log('='.repeat(50));
219
+ console.log('\nFeatures tested:');
220
+ console.log(' āœ“ Resource management with mutual exclusion');
221
+ console.log(' āœ“ Task dependencies and scheduling');
222
+ console.log(' āœ“ Deadlock detection and prevention');
223
+ console.log(' āœ“ Advanced scheduling with priorities');
224
+ console.log(' āœ“ Conflict detection and resolution');
225
+ console.log(' āœ“ Health monitoring and metrics');
226
+ console.log(' āœ“ Inter-agent messaging');
227
+ console.log(' āœ“ System maintenance');
228
+
229
+ } catch (error) {
230
+ console.error('āŒ Test failed:', error);
231
+ throw error;
232
+ }
233
+ }
234
+
235
+ // Run the test
236
+ if (import.meta.main) {
237
+ testCoordinationFeatures().catch(console.error);
238
+ }