overmind-mcp 2.0.6 → 2.0.7
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 +145 -145
- package/dist/server.js +51 -51
- package/docs/INDEX.md +144 -144
- package/docs/api/prompt/Claude_code.md +74 -74
- package/docs/api/prompt/Kilo.md +74 -74
- package/docs/api/prompt/Kilo_Hermes.md +170 -170
- package/docs/api/prompt/Minimax4.md +96 -96
- package/docs/changelog/CHANGELOG.add.md +106 -106
- package/docs/guides/DEPLOYMENT.md +418 -418
- package/docs/guides/SWARM_USAGE.md +444 -444
- package/install-overmind-unix.sh +250 -250
- package/install-overmind-windows.bat +257 -257
- package/package.json +131 -127
- package/scripts/postinstall.mjs +465 -465
|
@@ -1,444 +1,444 @@
|
|
|
1
|
-
# 🐋 OverMind-MCP Swarm Orchestration - Guide d'Utilisation
|
|
2
|
-
|
|
3
|
-
## 📚 Table des Matières
|
|
4
|
-
|
|
5
|
-
1. [Introduction](#introduction)
|
|
6
|
-
2. [Configuration du Swarm](#configuration-du-swarm)
|
|
7
|
-
3. [Allocation de Tâches](#allocation-de-tâches)
|
|
8
|
-
4. [Workflows Long-Running](#workflows-long-running)
|
|
9
|
-
5. [Exemples Pratiques](#exemples-pratiques)
|
|
10
|
-
6. [Monitoring & Debug](#monitoring--debug)
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## 🎯 Introduction
|
|
15
|
-
|
|
16
|
-
Le **Swarm Orchestration** d'OverMind-MCP permet :
|
|
17
|
-
- **Allocation dynamique** de tâches aux agents spécialisés
|
|
18
|
-
- **Équilibrage de charge** automatique (load balancing)
|
|
19
|
-
- **Workflows stateful** long-running (OSINT, analyses complètes)
|
|
20
|
-
- **Parallélisme intelligent** avec gestion des ressources
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## 🏗️ Configuration du Swarm
|
|
25
|
-
|
|
26
|
-
### 1. Définir les Capacités des Agents
|
|
27
|
-
|
|
28
|
-
```typescript
|
|
29
|
-
import { createSwarmOrchestrator } from 'overmind-mcp';
|
|
30
|
-
|
|
31
|
-
const swarm = createSwarmOrchestrator({
|
|
32
|
-
// Liste des agents disponibles avec leurs capacités
|
|
33
|
-
agents: [
|
|
34
|
-
{
|
|
35
|
-
agentName: 'crypto-analyst',
|
|
36
|
-
runner: 'claude',
|
|
37
|
-
capabilities: ['analysis', 'crypto', 'osint', 'data-processing'],
|
|
38
|
-
maxConcurrentTasks: 3,
|
|
39
|
-
currentLoad: 0,
|
|
40
|
-
estimatedCompletionTime: 120000 // 2 minutes par tâche
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
agentName: 'web-scraper',
|
|
44
|
-
runner: 'kilo',
|
|
45
|
-
capabilities: ['scraping', 'web', 'data-extraction'],
|
|
46
|
-
maxConcurrentTasks: 5,
|
|
47
|
-
currentLoad: 0,
|
|
48
|
-
estimatedCompletionTime: 60000 // 1 minute par tâche
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
agentName: 'code-reviewer',
|
|
52
|
-
runner: 'gemini',
|
|
53
|
-
capabilities: ['code', 'analysis', 'review', 'security'],
|
|
54
|
-
maxConcurrentTasks: 2,
|
|
55
|
-
currentLoad: 0,
|
|
56
|
-
estimatedCompletionTime: 180000 // 3 minutes par tâche
|
|
57
|
-
}
|
|
58
|
-
],
|
|
59
|
-
|
|
60
|
-
// Liste des tâches à exécuter
|
|
61
|
-
tasks: [
|
|
62
|
-
{
|
|
63
|
-
id: 'task-1',
|
|
64
|
-
type: 'analysis',
|
|
65
|
-
prompt: 'Analyser le sentiment du marché crypto',
|
|
66
|
-
priority: 10, // 1-10, 10 = priorité maximale
|
|
67
|
-
requiresCapabilities: ['analysis', 'crypto'],
|
|
68
|
-
estimatedDuration: 120000
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
id: 'task-2',
|
|
72
|
-
type: 'scraping',
|
|
73
|
-
prompt: 'Scraper les derniers articles de CoinDesk',
|
|
74
|
-
priority: 8,
|
|
75
|
-
requiresCapabilities: ['scraping', 'web'],
|
|
76
|
-
estimatedDuration: 60000
|
|
77
|
-
}
|
|
78
|
-
],
|
|
79
|
-
|
|
80
|
-
maxParallelTasks: 8, // Nombre max de tâches en parallèle
|
|
81
|
-
enableLoadBalancing: true, // Activer l'équilibrage de charge
|
|
82
|
-
enableTaskPriority: true // Respecter les priorités des tâches
|
|
83
|
-
});
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### 2. Stratégies d'Allocation
|
|
87
|
-
|
|
88
|
-
**Load Balancing** (recommandé) :
|
|
89
|
-
- Alloue les tâches en fonction de la charge actuelle des agents
|
|
90
|
-
- Prend en compte le temps d'achèvement estimé
|
|
91
|
-
- Optimise l'utilisation des ressources
|
|
92
|
-
|
|
93
|
-
**Round Robin** (simple) :
|
|
94
|
-
- Alloue les tâches au premier agent disponible
|
|
95
|
-
- Plus rapide mais moins optimal
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
## 🎮 Allocation de Tâches
|
|
100
|
-
|
|
101
|
-
### Allocation Automatique
|
|
102
|
-
|
|
103
|
-
```typescript
|
|
104
|
-
// Allouer les tâches aux agents disponibles
|
|
105
|
-
const allocations = await swarm.allocateTasks();
|
|
106
|
-
|
|
107
|
-
console.log('Allocations:', allocations);
|
|
108
|
-
// [
|
|
109
|
-
// {
|
|
110
|
-
// taskId: 'task-1',
|
|
111
|
-
// agentName: 'crypto-analyst',
|
|
112
|
-
// runner: 'claude',
|
|
113
|
-
// estimatedStart: 1699000000000,
|
|
114
|
-
// estimatedCompletion: 1699000120000
|
|
115
|
-
// }
|
|
116
|
-
// ]
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Exécution des Tâches Allouées
|
|
120
|
-
|
|
121
|
-
```typescript
|
|
122
|
-
// Exécuter une tâche spécifique
|
|
123
|
-
const task = swarm.getTaskStatus('task-1');
|
|
124
|
-
const allocation = swarm.allocations.get('task-1');
|
|
125
|
-
|
|
126
|
-
if (task && allocation) {
|
|
127
|
-
const result = await swarm.executeTask(task, allocation);
|
|
128
|
-
|
|
129
|
-
console.log('Result:', result);
|
|
130
|
-
// {
|
|
131
|
-
// taskId: 'task-1',
|
|
132
|
-
// status: 'completed',
|
|
133
|
-
// agentName: 'crypto-analyst',
|
|
134
|
-
// result: [...],
|
|
135
|
-
// startedAt: 1699000000000,
|
|
136
|
-
// completedAt: 1699000120000
|
|
137
|
-
// }
|
|
138
|
-
}
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
---
|
|
142
|
-
|
|
143
|
-
## ⏱️ Workflows Long-Running
|
|
144
|
-
|
|
145
|
-
### 1. Définir un Workflow Long-Running
|
|
146
|
-
|
|
147
|
-
```typescript
|
|
148
|
-
import { startLongRunningWorkflow } from 'overmind-mcp';
|
|
149
|
-
|
|
150
|
-
const workflow = await startLongRunningWorkflow({
|
|
151
|
-
batches: [
|
|
152
|
-
{
|
|
153
|
-
id: 'osint-batch-1',
|
|
154
|
-
status: 'pending',
|
|
155
|
-
tasks: [
|
|
156
|
-
{
|
|
157
|
-
runner: 'claude',
|
|
158
|
-
prompt: 'OSINT: Analyser les mentions de BTC sur Twitter/X',
|
|
159
|
-
agentName: 'crypto-analyst'
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
runner: 'kilo',
|
|
163
|
-
prompt: 'Scraper CoinDesk pour les dernières news crypto',
|
|
164
|
-
agentName: 'web-scraper'
|
|
165
|
-
}
|
|
166
|
-
]
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
id: 'osint-batch-2',
|
|
170
|
-
status: 'pending',
|
|
171
|
-
tasks: [
|
|
172
|
-
{
|
|
173
|
-
runner: 'gemini',
|
|
174
|
-
prompt: 'Analyser les on-chain metrics de Ethereum',
|
|
175
|
-
agentName: 'crypto-analyst'
|
|
176
|
-
}
|
|
177
|
-
]
|
|
178
|
-
}
|
|
179
|
-
],
|
|
180
|
-
maxParallelBatches: 3,
|
|
181
|
-
batchTimeout: '24 hours'
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
console.log('Workflow ID:', workflow.workflowId);
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### 2. Contrôler le Workflow
|
|
188
|
-
|
|
189
|
-
```typescript
|
|
190
|
-
// Obtenir l'état actuel
|
|
191
|
-
const state = await workflow.query(LongRunningWorkflowState);
|
|
192
|
-
console.log('State:', state);
|
|
193
|
-
// {
|
|
194
|
-
// totalBatches: 2,
|
|
195
|
-
// completedBatches: 1,
|
|
196
|
-
// failedBatches: 0,
|
|
197
|
-
// currentBatch: 'osint-batch-2',
|
|
198
|
-
// errors: []
|
|
199
|
-
// }
|
|
200
|
-
|
|
201
|
-
// Signaux de contrôle
|
|
202
|
-
await workflow.signal(cancelSignal); // Annuler le workflow
|
|
203
|
-
await workflow.signal(pauseSignal); // Mettre en pause
|
|
204
|
-
await workflow.signal(resumeSignal); // Reprendre
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
## 💼 Exemples Pratiques
|
|
210
|
-
|
|
211
|
-
### Exemple 1: Veille Crypto 24/7
|
|
212
|
-
|
|
213
|
-
```typescript
|
|
214
|
-
import { createSwarmOrchestrator } from 'overmind-mcp';
|
|
215
|
-
|
|
216
|
-
// Créer un swarm pour surveillance crypto 24/7
|
|
217
|
-
const cryptoSwarm = createSwarmOrchestrator({
|
|
218
|
-
agents: [
|
|
219
|
-
{
|
|
220
|
-
agentName: 'btc-sentiment-analyst',
|
|
221
|
-
runner: 'claude',
|
|
222
|
-
capabilities: ['sentiment', 'btc', 'social-media'],
|
|
223
|
-
maxConcurrentTasks: 5,
|
|
224
|
-
currentLoad: 0
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
agentName: 'eth-onchain-analyst',
|
|
228
|
-
runner: 'gemini',
|
|
229
|
-
capabilities: ['onchain', 'eth', 'defi'],
|
|
230
|
-
maxConcurrentTasks: 3,
|
|
231
|
-
currentLoad: 0
|
|
232
|
-
}
|
|
233
|
-
],
|
|
234
|
-
tasks: [
|
|
235
|
-
{
|
|
236
|
-
id: 'btc-twitter-sentiment',
|
|
237
|
-
type: 'sentiment-analysis',
|
|
238
|
-
prompt: 'Analyser le sentiment BTC sur Twitter (dernières 100 mentions)',
|
|
239
|
-
priority: 10,
|
|
240
|
-
requiresCapabilities: ['sentiment', 'btc', 'social-media'],
|
|
241
|
-
estimatedDuration: 300000
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
id: 'eth-whale-tracking',
|
|
245
|
-
type: 'onchain-analysis',
|
|
246
|
-
prompt: 'Tracker les mouvements de baleines Ethereum (>1000 ETH)',
|
|
247
|
-
priority: 9,
|
|
248
|
-
requiresCapabilities: ['onchain', 'eth'],
|
|
249
|
-
estimatedDuration: 180000
|
|
250
|
-
}
|
|
251
|
-
],
|
|
252
|
-
maxParallelTasks: 8,
|
|
253
|
-
enableLoadBalancing: true,
|
|
254
|
-
enableTaskPriority: true
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
// Lancer l'allocation
|
|
258
|
-
const allocations = await cryptoSwarm.allocateTasks();
|
|
259
|
-
console.log('Crypto surveillance lancée:', allocations);
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
### Exemple 2: Analyse de Repos Entiers
|
|
263
|
-
|
|
264
|
-
```typescript
|
|
265
|
-
import { startLongRunningWorkflow } from 'overmind-mcp';
|
|
266
|
-
|
|
267
|
-
// Workflow longue durée pour analyser un repo complet
|
|
268
|
-
const repoAnalysisWorkflow = await startLongRunningWorkflow({
|
|
269
|
-
batches: [
|
|
270
|
-
{
|
|
271
|
-
id: 'code-scanning',
|
|
272
|
-
status: 'pending',
|
|
273
|
-
tasks: [
|
|
274
|
-
{
|
|
275
|
-
runner: 'kilo',
|
|
276
|
-
prompt: 'Scanner tous les fichiers TypeScript du repo pour vulnérabilités',
|
|
277
|
-
agentName: 'security-scanner'
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
runner: 'claude',
|
|
281
|
-
prompt: 'Analyser l\'architecture globale du codebase',
|
|
282
|
-
agentName: 'architect-analyst'
|
|
283
|
-
}
|
|
284
|
-
]
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
id: 'code-quality',
|
|
288
|
-
status: 'pending',
|
|
289
|
-
tasks: [
|
|
290
|
-
{
|
|
291
|
-
runner: 'gemini',
|
|
292
|
-
prompt: 'Évaluer la qualité du code (duplication, complexité, documentation)',
|
|
293
|
-
agentName: 'quality-analyst'
|
|
294
|
-
}
|
|
295
|
-
]
|
|
296
|
-
}
|
|
297
|
-
],
|
|
298
|
-
maxParallelBatches: 2,
|
|
299
|
-
batchTimeout: '4 hours'
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
// Surveiller la progression
|
|
303
|
-
setInterval(async () => {
|
|
304
|
-
const state = await repoAnalysisWorkflow.query();
|
|
305
|
-
console.log('Analyse en cours:', state);
|
|
306
|
-
}, 60000); // Toutes les minutes
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
### Exemple 3: Pipeline de Scraping Distribué
|
|
310
|
-
|
|
311
|
-
```typescript
|
|
312
|
-
// Pipeline de scraping avec allocation dynamique
|
|
313
|
-
const scrapingPipeline = createSwarmOrchestrator({
|
|
314
|
-
agents: [
|
|
315
|
-
{
|
|
316
|
-
agentName: 'news-scraper',
|
|
317
|
-
runner: 'kilo',
|
|
318
|
-
capabilities: ['scraping', 'news', 'html-parsing'],
|
|
319
|
-
maxConcurrentTasks: 10,
|
|
320
|
-
currentLoad: 0
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
agentName: 'social-scraper',
|
|
324
|
-
runner: 'claude',
|
|
325
|
-
capabilities: ['scraping', 'social', 'api'],
|
|
326
|
-
maxConcurrentTasks: 5,
|
|
327
|
-
currentLoad: 0
|
|
328
|
-
}
|
|
329
|
-
],
|
|
330
|
-
tasks: [
|
|
331
|
-
{
|
|
332
|
-
id: 'scrape-coindesk',
|
|
333
|
-
type: 'scraping',
|
|
334
|
-
prompt: 'Scraper les 50 derniers articles de CoinDesk',
|
|
335
|
-
priority: 10,
|
|
336
|
-
requiresCapabilities: ['scraping', 'news'],
|
|
337
|
-
estimatedDuration: 120000
|
|
338
|
-
},
|
|
339
|
-
{
|
|
340
|
-
id: 'scrape-reddit-crypto',
|
|
341
|
-
type: 'scraping',
|
|
342
|
-
prompt: 'Scraper r/CryptoCurrency pour les posts trending',
|
|
343
|
-
priority: 9,
|
|
344
|
-
requiresCapabilities: ['scraping', 'social'],
|
|
345
|
-
estimatedDuration: 180000
|
|
346
|
-
}
|
|
347
|
-
],
|
|
348
|
-
maxParallelTasks: 15,
|
|
349
|
-
enableLoadBalancing: true,
|
|
350
|
-
enableTaskPriority: true
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
// Exécuter en continu
|
|
354
|
-
setInterval(async () => {
|
|
355
|
-
const stats = scrapingPipeline.getStatistics();
|
|
356
|
-
console.log('Pipeline stats:', stats);
|
|
357
|
-
// {
|
|
358
|
-
// totalTasks: 100,
|
|
359
|
-
// completed: 45,
|
|
360
|
-
// failed: 2,
|
|
361
|
-
// running: 10,
|
|
362
|
-
// pending: 43,
|
|
363
|
-
// totalAgents: 2,
|
|
364
|
-
// averageLoad: 3.5
|
|
365
|
-
// }
|
|
366
|
-
}, 30000); // Toutes les 30 secondes
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
---
|
|
370
|
-
|
|
371
|
-
## 🔍 Monitoring & Debug
|
|
372
|
-
|
|
373
|
-
### Statistiques du Swarm
|
|
374
|
-
|
|
375
|
-
```typescript
|
|
376
|
-
// Statistiques globales
|
|
377
|
-
const stats = swarm.getStatistics();
|
|
378
|
-
console.log('Swarm Statistics:', stats);
|
|
379
|
-
// {
|
|
380
|
-
// totalTasks: 50,
|
|
381
|
-
// completed: 20,
|
|
382
|
-
// failed: 2,
|
|
383
|
-
// running: 5,
|
|
384
|
-
// pending: 23,
|
|
385
|
-
// totalAgents: 3,
|
|
386
|
-
// averageLoad: 2.5
|
|
387
|
-
// }
|
|
388
|
-
|
|
389
|
-
// État d'un agent spécifique
|
|
390
|
-
const agentStatus = swarm.getAgentStatus('crypto-analyst');
|
|
391
|
-
console.log('Agent Status:', agentStatus);
|
|
392
|
-
// {
|
|
393
|
-
// agentName: 'crypto-analyst',
|
|
394
|
-
// runner: 'claude',
|
|
395
|
-
// capabilities: ['analysis', 'crypto', 'osint'],
|
|
396
|
-
// maxConcurrentTasks: 3,
|
|
397
|
-
// currentLoad: 2,
|
|
398
|
-
// estimatedCompletionTime: 120000
|
|
399
|
-
// }
|
|
400
|
-
|
|
401
|
-
// Résultats de toutes les tâches
|
|
402
|
-
const allResults = swarm.getAllResults();
|
|
403
|
-
console.log('All Results:', allResults);
|
|
404
|
-
|
|
405
|
-
// Tâches en attente
|
|
406
|
-
const pendingTasks = swarm.getPendingTasks();
|
|
407
|
-
console.log('Pending Tasks:', pendingTasks);
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
### Debug Workflow Long-Running
|
|
411
|
-
|
|
412
|
-
```typescript
|
|
413
|
-
// Obtenir un handle sur un workflow existant
|
|
414
|
-
import { getLongRunningWorkflowHandle } from 'overmind-mcp';
|
|
415
|
-
|
|
416
|
-
const workflow = await getLongRunningWorkflowHandle('long-running-1699000000');
|
|
417
|
-
|
|
418
|
-
// État actuel
|
|
419
|
-
const state = await workflow.query();
|
|
420
|
-
console.log('Workflow State:', state);
|
|
421
|
-
|
|
422
|
-
// Historique d'exécution
|
|
423
|
-
const history = await workflow.history();
|
|
424
|
-
console.log('Workflow History:', history.events);
|
|
425
|
-
```
|
|
426
|
-
|
|
427
|
-
---
|
|
428
|
-
|
|
429
|
-
## 🚀 Bonnes Pratiques
|
|
430
|
-
|
|
431
|
-
1. **Capacités des Agents** : Définissez des capacités précises pour une allocation optimale
|
|
432
|
-
2. **Priorités des Tâches** : Utilisez la priorité (1-10) pour les tâches critiques
|
|
433
|
-
3. **Parallelisme** : Ajustez `maxParallelTasks` selon vos ressources (RAM, CPU)
|
|
434
|
-
4. **Timeouts** : Définissez des `estimatedDuration` réalistes pour éviter les blocages
|
|
435
|
-
5. **Monitoring** : Surveillez régulièrement les statistiques du swarm
|
|
436
|
-
6. **Fallback** : Prévoyez des agents de secours pour les tâches critiques
|
|
437
|
-
|
|
438
|
-
---
|
|
439
|
-
|
|
440
|
-
## 📚 Ressources Additionnelles
|
|
441
|
-
|
|
442
|
-
- **API Temporal**: https://docs.temporal.io
|
|
443
|
-
- **Guide Swarm**: https://github.com/DeamonDev888/overmind-mcp
|
|
444
|
-
- **Support Discord**: https://discord.gg/4AR82phtBz
|
|
1
|
+
# 🐋 OverMind-MCP Swarm Orchestration - Guide d'Utilisation
|
|
2
|
+
|
|
3
|
+
## 📚 Table des Matières
|
|
4
|
+
|
|
5
|
+
1. [Introduction](#introduction)
|
|
6
|
+
2. [Configuration du Swarm](#configuration-du-swarm)
|
|
7
|
+
3. [Allocation de Tâches](#allocation-de-tâches)
|
|
8
|
+
4. [Workflows Long-Running](#workflows-long-running)
|
|
9
|
+
5. [Exemples Pratiques](#exemples-pratiques)
|
|
10
|
+
6. [Monitoring & Debug](#monitoring--debug)
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 🎯 Introduction
|
|
15
|
+
|
|
16
|
+
Le **Swarm Orchestration** d'OverMind-MCP permet :
|
|
17
|
+
- **Allocation dynamique** de tâches aux agents spécialisés
|
|
18
|
+
- **Équilibrage de charge** automatique (load balancing)
|
|
19
|
+
- **Workflows stateful** long-running (OSINT, analyses complètes)
|
|
20
|
+
- **Parallélisme intelligent** avec gestion des ressources
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 🏗️ Configuration du Swarm
|
|
25
|
+
|
|
26
|
+
### 1. Définir les Capacités des Agents
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { createSwarmOrchestrator } from 'overmind-mcp';
|
|
30
|
+
|
|
31
|
+
const swarm = createSwarmOrchestrator({
|
|
32
|
+
// Liste des agents disponibles avec leurs capacités
|
|
33
|
+
agents: [
|
|
34
|
+
{
|
|
35
|
+
agentName: 'crypto-analyst',
|
|
36
|
+
runner: 'claude',
|
|
37
|
+
capabilities: ['analysis', 'crypto', 'osint', 'data-processing'],
|
|
38
|
+
maxConcurrentTasks: 3,
|
|
39
|
+
currentLoad: 0,
|
|
40
|
+
estimatedCompletionTime: 120000 // 2 minutes par tâche
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
agentName: 'web-scraper',
|
|
44
|
+
runner: 'kilo',
|
|
45
|
+
capabilities: ['scraping', 'web', 'data-extraction'],
|
|
46
|
+
maxConcurrentTasks: 5,
|
|
47
|
+
currentLoad: 0,
|
|
48
|
+
estimatedCompletionTime: 60000 // 1 minute par tâche
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
agentName: 'code-reviewer',
|
|
52
|
+
runner: 'gemini',
|
|
53
|
+
capabilities: ['code', 'analysis', 'review', 'security'],
|
|
54
|
+
maxConcurrentTasks: 2,
|
|
55
|
+
currentLoad: 0,
|
|
56
|
+
estimatedCompletionTime: 180000 // 3 minutes par tâche
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
|
|
60
|
+
// Liste des tâches à exécuter
|
|
61
|
+
tasks: [
|
|
62
|
+
{
|
|
63
|
+
id: 'task-1',
|
|
64
|
+
type: 'analysis',
|
|
65
|
+
prompt: 'Analyser le sentiment du marché crypto',
|
|
66
|
+
priority: 10, // 1-10, 10 = priorité maximale
|
|
67
|
+
requiresCapabilities: ['analysis', 'crypto'],
|
|
68
|
+
estimatedDuration: 120000
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'task-2',
|
|
72
|
+
type: 'scraping',
|
|
73
|
+
prompt: 'Scraper les derniers articles de CoinDesk',
|
|
74
|
+
priority: 8,
|
|
75
|
+
requiresCapabilities: ['scraping', 'web'],
|
|
76
|
+
estimatedDuration: 60000
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
|
|
80
|
+
maxParallelTasks: 8, // Nombre max de tâches en parallèle
|
|
81
|
+
enableLoadBalancing: true, // Activer l'équilibrage de charge
|
|
82
|
+
enableTaskPriority: true // Respecter les priorités des tâches
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 2. Stratégies d'Allocation
|
|
87
|
+
|
|
88
|
+
**Load Balancing** (recommandé) :
|
|
89
|
+
- Alloue les tâches en fonction de la charge actuelle des agents
|
|
90
|
+
- Prend en compte le temps d'achèvement estimé
|
|
91
|
+
- Optimise l'utilisation des ressources
|
|
92
|
+
|
|
93
|
+
**Round Robin** (simple) :
|
|
94
|
+
- Alloue les tâches au premier agent disponible
|
|
95
|
+
- Plus rapide mais moins optimal
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 🎮 Allocation de Tâches
|
|
100
|
+
|
|
101
|
+
### Allocation Automatique
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
// Allouer les tâches aux agents disponibles
|
|
105
|
+
const allocations = await swarm.allocateTasks();
|
|
106
|
+
|
|
107
|
+
console.log('Allocations:', allocations);
|
|
108
|
+
// [
|
|
109
|
+
// {
|
|
110
|
+
// taskId: 'task-1',
|
|
111
|
+
// agentName: 'crypto-analyst',
|
|
112
|
+
// runner: 'claude',
|
|
113
|
+
// estimatedStart: 1699000000000,
|
|
114
|
+
// estimatedCompletion: 1699000120000
|
|
115
|
+
// }
|
|
116
|
+
// ]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Exécution des Tâches Allouées
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
// Exécuter une tâche spécifique
|
|
123
|
+
const task = swarm.getTaskStatus('task-1');
|
|
124
|
+
const allocation = swarm.allocations.get('task-1');
|
|
125
|
+
|
|
126
|
+
if (task && allocation) {
|
|
127
|
+
const result = await swarm.executeTask(task, allocation);
|
|
128
|
+
|
|
129
|
+
console.log('Result:', result);
|
|
130
|
+
// {
|
|
131
|
+
// taskId: 'task-1',
|
|
132
|
+
// status: 'completed',
|
|
133
|
+
// agentName: 'crypto-analyst',
|
|
134
|
+
// result: [...],
|
|
135
|
+
// startedAt: 1699000000000,
|
|
136
|
+
// completedAt: 1699000120000
|
|
137
|
+
// }
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## ⏱️ Workflows Long-Running
|
|
144
|
+
|
|
145
|
+
### 1. Définir un Workflow Long-Running
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
import { startLongRunningWorkflow } from 'overmind-mcp';
|
|
149
|
+
|
|
150
|
+
const workflow = await startLongRunningWorkflow({
|
|
151
|
+
batches: [
|
|
152
|
+
{
|
|
153
|
+
id: 'osint-batch-1',
|
|
154
|
+
status: 'pending',
|
|
155
|
+
tasks: [
|
|
156
|
+
{
|
|
157
|
+
runner: 'claude',
|
|
158
|
+
prompt: 'OSINT: Analyser les mentions de BTC sur Twitter/X',
|
|
159
|
+
agentName: 'crypto-analyst'
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
runner: 'kilo',
|
|
163
|
+
prompt: 'Scraper CoinDesk pour les dernières news crypto',
|
|
164
|
+
agentName: 'web-scraper'
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
id: 'osint-batch-2',
|
|
170
|
+
status: 'pending',
|
|
171
|
+
tasks: [
|
|
172
|
+
{
|
|
173
|
+
runner: 'gemini',
|
|
174
|
+
prompt: 'Analyser les on-chain metrics de Ethereum',
|
|
175
|
+
agentName: 'crypto-analyst'
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
maxParallelBatches: 3,
|
|
181
|
+
batchTimeout: '24 hours'
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
console.log('Workflow ID:', workflow.workflowId);
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 2. Contrôler le Workflow
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
// Obtenir l'état actuel
|
|
191
|
+
const state = await workflow.query(LongRunningWorkflowState);
|
|
192
|
+
console.log('State:', state);
|
|
193
|
+
// {
|
|
194
|
+
// totalBatches: 2,
|
|
195
|
+
// completedBatches: 1,
|
|
196
|
+
// failedBatches: 0,
|
|
197
|
+
// currentBatch: 'osint-batch-2',
|
|
198
|
+
// errors: []
|
|
199
|
+
// }
|
|
200
|
+
|
|
201
|
+
// Signaux de contrôle
|
|
202
|
+
await workflow.signal(cancelSignal); // Annuler le workflow
|
|
203
|
+
await workflow.signal(pauseSignal); // Mettre en pause
|
|
204
|
+
await workflow.signal(resumeSignal); // Reprendre
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## 💼 Exemples Pratiques
|
|
210
|
+
|
|
211
|
+
### Exemple 1: Veille Crypto 24/7
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
import { createSwarmOrchestrator } from 'overmind-mcp';
|
|
215
|
+
|
|
216
|
+
// Créer un swarm pour surveillance crypto 24/7
|
|
217
|
+
const cryptoSwarm = createSwarmOrchestrator({
|
|
218
|
+
agents: [
|
|
219
|
+
{
|
|
220
|
+
agentName: 'btc-sentiment-analyst',
|
|
221
|
+
runner: 'claude',
|
|
222
|
+
capabilities: ['sentiment', 'btc', 'social-media'],
|
|
223
|
+
maxConcurrentTasks: 5,
|
|
224
|
+
currentLoad: 0
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
agentName: 'eth-onchain-analyst',
|
|
228
|
+
runner: 'gemini',
|
|
229
|
+
capabilities: ['onchain', 'eth', 'defi'],
|
|
230
|
+
maxConcurrentTasks: 3,
|
|
231
|
+
currentLoad: 0
|
|
232
|
+
}
|
|
233
|
+
],
|
|
234
|
+
tasks: [
|
|
235
|
+
{
|
|
236
|
+
id: 'btc-twitter-sentiment',
|
|
237
|
+
type: 'sentiment-analysis',
|
|
238
|
+
prompt: 'Analyser le sentiment BTC sur Twitter (dernières 100 mentions)',
|
|
239
|
+
priority: 10,
|
|
240
|
+
requiresCapabilities: ['sentiment', 'btc', 'social-media'],
|
|
241
|
+
estimatedDuration: 300000
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
id: 'eth-whale-tracking',
|
|
245
|
+
type: 'onchain-analysis',
|
|
246
|
+
prompt: 'Tracker les mouvements de baleines Ethereum (>1000 ETH)',
|
|
247
|
+
priority: 9,
|
|
248
|
+
requiresCapabilities: ['onchain', 'eth'],
|
|
249
|
+
estimatedDuration: 180000
|
|
250
|
+
}
|
|
251
|
+
],
|
|
252
|
+
maxParallelTasks: 8,
|
|
253
|
+
enableLoadBalancing: true,
|
|
254
|
+
enableTaskPriority: true
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
// Lancer l'allocation
|
|
258
|
+
const allocations = await cryptoSwarm.allocateTasks();
|
|
259
|
+
console.log('Crypto surveillance lancée:', allocations);
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
### Exemple 2: Analyse de Repos Entiers
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
import { startLongRunningWorkflow } from 'overmind-mcp';
|
|
266
|
+
|
|
267
|
+
// Workflow longue durée pour analyser un repo complet
|
|
268
|
+
const repoAnalysisWorkflow = await startLongRunningWorkflow({
|
|
269
|
+
batches: [
|
|
270
|
+
{
|
|
271
|
+
id: 'code-scanning',
|
|
272
|
+
status: 'pending',
|
|
273
|
+
tasks: [
|
|
274
|
+
{
|
|
275
|
+
runner: 'kilo',
|
|
276
|
+
prompt: 'Scanner tous les fichiers TypeScript du repo pour vulnérabilités',
|
|
277
|
+
agentName: 'security-scanner'
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
runner: 'claude',
|
|
281
|
+
prompt: 'Analyser l\'architecture globale du codebase',
|
|
282
|
+
agentName: 'architect-analyst'
|
|
283
|
+
}
|
|
284
|
+
]
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
id: 'code-quality',
|
|
288
|
+
status: 'pending',
|
|
289
|
+
tasks: [
|
|
290
|
+
{
|
|
291
|
+
runner: 'gemini',
|
|
292
|
+
prompt: 'Évaluer la qualité du code (duplication, complexité, documentation)',
|
|
293
|
+
agentName: 'quality-analyst'
|
|
294
|
+
}
|
|
295
|
+
]
|
|
296
|
+
}
|
|
297
|
+
],
|
|
298
|
+
maxParallelBatches: 2,
|
|
299
|
+
batchTimeout: '4 hours'
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// Surveiller la progression
|
|
303
|
+
setInterval(async () => {
|
|
304
|
+
const state = await repoAnalysisWorkflow.query();
|
|
305
|
+
console.log('Analyse en cours:', state);
|
|
306
|
+
}, 60000); // Toutes les minutes
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Exemple 3: Pipeline de Scraping Distribué
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
// Pipeline de scraping avec allocation dynamique
|
|
313
|
+
const scrapingPipeline = createSwarmOrchestrator({
|
|
314
|
+
agents: [
|
|
315
|
+
{
|
|
316
|
+
agentName: 'news-scraper',
|
|
317
|
+
runner: 'kilo',
|
|
318
|
+
capabilities: ['scraping', 'news', 'html-parsing'],
|
|
319
|
+
maxConcurrentTasks: 10,
|
|
320
|
+
currentLoad: 0
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
agentName: 'social-scraper',
|
|
324
|
+
runner: 'claude',
|
|
325
|
+
capabilities: ['scraping', 'social', 'api'],
|
|
326
|
+
maxConcurrentTasks: 5,
|
|
327
|
+
currentLoad: 0
|
|
328
|
+
}
|
|
329
|
+
],
|
|
330
|
+
tasks: [
|
|
331
|
+
{
|
|
332
|
+
id: 'scrape-coindesk',
|
|
333
|
+
type: 'scraping',
|
|
334
|
+
prompt: 'Scraper les 50 derniers articles de CoinDesk',
|
|
335
|
+
priority: 10,
|
|
336
|
+
requiresCapabilities: ['scraping', 'news'],
|
|
337
|
+
estimatedDuration: 120000
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
id: 'scrape-reddit-crypto',
|
|
341
|
+
type: 'scraping',
|
|
342
|
+
prompt: 'Scraper r/CryptoCurrency pour les posts trending',
|
|
343
|
+
priority: 9,
|
|
344
|
+
requiresCapabilities: ['scraping', 'social'],
|
|
345
|
+
estimatedDuration: 180000
|
|
346
|
+
}
|
|
347
|
+
],
|
|
348
|
+
maxParallelTasks: 15,
|
|
349
|
+
enableLoadBalancing: true,
|
|
350
|
+
enableTaskPriority: true
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
// Exécuter en continu
|
|
354
|
+
setInterval(async () => {
|
|
355
|
+
const stats = scrapingPipeline.getStatistics();
|
|
356
|
+
console.log('Pipeline stats:', stats);
|
|
357
|
+
// {
|
|
358
|
+
// totalTasks: 100,
|
|
359
|
+
// completed: 45,
|
|
360
|
+
// failed: 2,
|
|
361
|
+
// running: 10,
|
|
362
|
+
// pending: 43,
|
|
363
|
+
// totalAgents: 2,
|
|
364
|
+
// averageLoad: 3.5
|
|
365
|
+
// }
|
|
366
|
+
}, 30000); // Toutes les 30 secondes
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## 🔍 Monitoring & Debug
|
|
372
|
+
|
|
373
|
+
### Statistiques du Swarm
|
|
374
|
+
|
|
375
|
+
```typescript
|
|
376
|
+
// Statistiques globales
|
|
377
|
+
const stats = swarm.getStatistics();
|
|
378
|
+
console.log('Swarm Statistics:', stats);
|
|
379
|
+
// {
|
|
380
|
+
// totalTasks: 50,
|
|
381
|
+
// completed: 20,
|
|
382
|
+
// failed: 2,
|
|
383
|
+
// running: 5,
|
|
384
|
+
// pending: 23,
|
|
385
|
+
// totalAgents: 3,
|
|
386
|
+
// averageLoad: 2.5
|
|
387
|
+
// }
|
|
388
|
+
|
|
389
|
+
// État d'un agent spécifique
|
|
390
|
+
const agentStatus = swarm.getAgentStatus('crypto-analyst');
|
|
391
|
+
console.log('Agent Status:', agentStatus);
|
|
392
|
+
// {
|
|
393
|
+
// agentName: 'crypto-analyst',
|
|
394
|
+
// runner: 'claude',
|
|
395
|
+
// capabilities: ['analysis', 'crypto', 'osint'],
|
|
396
|
+
// maxConcurrentTasks: 3,
|
|
397
|
+
// currentLoad: 2,
|
|
398
|
+
// estimatedCompletionTime: 120000
|
|
399
|
+
// }
|
|
400
|
+
|
|
401
|
+
// Résultats de toutes les tâches
|
|
402
|
+
const allResults = swarm.getAllResults();
|
|
403
|
+
console.log('All Results:', allResults);
|
|
404
|
+
|
|
405
|
+
// Tâches en attente
|
|
406
|
+
const pendingTasks = swarm.getPendingTasks();
|
|
407
|
+
console.log('Pending Tasks:', pendingTasks);
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### Debug Workflow Long-Running
|
|
411
|
+
|
|
412
|
+
```typescript
|
|
413
|
+
// Obtenir un handle sur un workflow existant
|
|
414
|
+
import { getLongRunningWorkflowHandle } from 'overmind-mcp';
|
|
415
|
+
|
|
416
|
+
const workflow = await getLongRunningWorkflowHandle('long-running-1699000000');
|
|
417
|
+
|
|
418
|
+
// État actuel
|
|
419
|
+
const state = await workflow.query();
|
|
420
|
+
console.log('Workflow State:', state);
|
|
421
|
+
|
|
422
|
+
// Historique d'exécution
|
|
423
|
+
const history = await workflow.history();
|
|
424
|
+
console.log('Workflow History:', history.events);
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
## 🚀 Bonnes Pratiques
|
|
430
|
+
|
|
431
|
+
1. **Capacités des Agents** : Définissez des capacités précises pour une allocation optimale
|
|
432
|
+
2. **Priorités des Tâches** : Utilisez la priorité (1-10) pour les tâches critiques
|
|
433
|
+
3. **Parallelisme** : Ajustez `maxParallelTasks` selon vos ressources (RAM, CPU)
|
|
434
|
+
4. **Timeouts** : Définissez des `estimatedDuration` réalistes pour éviter les blocages
|
|
435
|
+
5. **Monitoring** : Surveillez régulièrement les statistiques du swarm
|
|
436
|
+
6. **Fallback** : Prévoyez des agents de secours pour les tâches critiques
|
|
437
|
+
|
|
438
|
+
---
|
|
439
|
+
|
|
440
|
+
## 📚 Ressources Additionnelles
|
|
441
|
+
|
|
442
|
+
- **API Temporal**: https://docs.temporal.io
|
|
443
|
+
- **Guide Swarm**: https://github.com/DeamonDev888/overmind-mcp
|
|
444
|
+
- **Support Discord**: https://discord.gg/4AR82phtBz
|