claude-flow 2.5.0-alpha.139 → 2.5.0-alpha.141

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 (42) hide show
  1. package/.claude/settings.json +3 -2
  2. package/README.md +50 -55
  3. package/bin/claude-flow +1 -1
  4. package/dist/src/cli/commands/hive-mind/pause.js +2 -9
  5. package/dist/src/cli/commands/hive-mind/pause.js.map +1 -1
  6. package/dist/src/cli/commands/index.js +1 -114
  7. package/dist/src/cli/commands/index.js.map +1 -1
  8. package/dist/src/cli/commands/swarm-spawn.js +5 -33
  9. package/dist/src/cli/commands/swarm-spawn.js.map +1 -1
  10. package/dist/src/cli/help-formatter.js.map +1 -1
  11. package/dist/src/cli/help-text.js +16 -2
  12. package/dist/src/cli/help-text.js.map +1 -1
  13. package/dist/src/cli/simple-commands/hooks.js +233 -0
  14. package/dist/src/cli/simple-commands/hooks.js.map +1 -1
  15. package/dist/src/cli/validation-helper.js.map +1 -1
  16. package/dist/src/core/version.js +1 -1
  17. package/dist/src/hooks/index.js +0 -3
  18. package/dist/src/hooks/index.js.map +1 -1
  19. package/dist/src/mcp/claude-flow-tools.js +205 -150
  20. package/dist/src/mcp/claude-flow-tools.js.map +1 -1
  21. package/dist/src/mcp/mcp-server.js +125 -0
  22. package/dist/src/mcp/mcp-server.js.map +1 -1
  23. package/dist/src/memory/swarm-memory.js +421 -340
  24. package/dist/src/memory/swarm-memory.js.map +1 -1
  25. package/dist/src/sdk/query-control.js +293 -139
  26. package/dist/src/sdk/query-control.js.map +1 -1
  27. package/dist/src/sdk/session-forking.js +206 -129
  28. package/dist/src/sdk/session-forking.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/cli/commands/hive-mind/pause.ts +2 -15
  31. package/src/cli/commands/index.ts +1 -84
  32. package/src/cli/commands/swarm-spawn.ts +3 -47
  33. package/src/cli/help-text.js +16 -2
  34. package/src/cli/simple-cli.ts +0 -1
  35. package/src/cli/simple-commands/hooks.js +310 -0
  36. package/src/hooks/index.ts +0 -5
  37. package/src/mcp/claude-flow-tools.ts +203 -120
  38. package/src/mcp/mcp-server.js +86 -0
  39. package/src/sdk/query-control.ts +377 -223
  40. package/src/sdk/session-forking.ts +312 -207
  41. package/.claude/commands/coordination/README.md +0 -9
  42. package/.claude/commands/memory/README.md +0 -9
@@ -22,9 +22,12 @@ async function enhanceToolWithAgentTypes(tool) {
22
22
  export async function createClaudeFlowTools(logger) {
23
23
  const tools = [
24
24
  createSpawnAgentTool(logger),
25
+ createSpawnParallelAgentsTool(logger),
25
26
  createListAgentsTool(logger),
26
27
  createTerminateAgentTool(logger),
27
28
  createGetAgentInfoTool(logger),
29
+ createQueryControlTool(logger),
30
+ createListQueriesTool(logger),
28
31
  createCreateTaskTool(logger),
29
32
  createListTasksTool(logger),
30
33
  createGetTaskStatusTool(logger),
@@ -514,7 +517,7 @@ function createAssignTaskTool(logger) {
514
517
  }
515
518
  function createQueryMemoryTool(logger) {
516
519
  return {
517
- name: 'memory_query',
520
+ name: 'memory/query',
518
521
  description: 'Query agent memory with filters and search',
519
522
  inputSchema: {
520
523
  type: 'object',
@@ -602,7 +605,7 @@ function createQueryMemoryTool(logger) {
602
605
  }
603
606
  function createStoreMemoryTool(logger) {
604
607
  return {
605
- name: 'memory_store',
608
+ name: 'memory/store',
606
609
  description: 'Store a new memory entry',
607
610
  inputSchema: {
608
611
  type: 'object',
@@ -686,7 +689,7 @@ function createStoreMemoryTool(logger) {
686
689
  }
687
690
  function createDeleteMemoryTool(logger) {
688
691
  return {
689
- name: 'memory_delete',
692
+ name: 'memory/delete',
690
693
  description: 'Delete a memory entry',
691
694
  inputSchema: {
692
695
  type: 'object',
@@ -719,7 +722,7 @@ function createDeleteMemoryTool(logger) {
719
722
  }
720
723
  function createExportMemoryTool(logger) {
721
724
  return {
722
- name: 'memory_export',
725
+ name: 'memory/export',
723
726
  description: 'Export memory entries to a file',
724
727
  inputSchema: {
725
728
  type: 'object',
@@ -778,7 +781,7 @@ function createExportMemoryTool(logger) {
778
781
  }
779
782
  function createImportMemoryTool(logger) {
780
783
  return {
781
- name: 'memory_import',
784
+ name: 'memory/import',
782
785
  description: 'Import memory entries from a file',
783
786
  inputSchema: {
784
787
  type: 'object',
@@ -1330,197 +1333,249 @@ function createCreateTerminalTool(logger) {
1330
1333
  }
1331
1334
  };
1332
1335
  }
1333
- function createCheckpointCreateTool(logger) {
1336
+ function createSpawnParallelAgentsTool(logger) {
1334
1337
  return {
1335
- name: 'checkpoint_create',
1336
- description: 'Create a checkpoint for a session (Git-like time travel)',
1338
+ name: 'agents/spawn_parallel',
1339
+ description: 'Spawn multiple agents in parallel (10-20x faster than sequential spawning)',
1337
1340
  inputSchema: {
1338
1341
  type: 'object',
1339
1342
  properties: {
1340
- sessionId: {
1341
- type: 'string',
1342
- description: 'Session ID to checkpoint'
1343
+ agents: {
1344
+ type: 'array',
1345
+ items: {
1346
+ type: 'object',
1347
+ properties: {
1348
+ type: {
1349
+ type: 'string',
1350
+ description: 'Agent type'
1351
+ },
1352
+ name: {
1353
+ type: 'string',
1354
+ description: 'Agent name'
1355
+ },
1356
+ capabilities: {
1357
+ type: 'array',
1358
+ items: {
1359
+ type: 'string'
1360
+ }
1361
+ },
1362
+ priority: {
1363
+ type: 'string',
1364
+ enum: [
1365
+ 'low',
1366
+ 'medium',
1367
+ 'high',
1368
+ 'critical'
1369
+ ],
1370
+ default: 'medium'
1371
+ }
1372
+ },
1373
+ required: [
1374
+ 'type',
1375
+ 'name'
1376
+ ]
1377
+ },
1378
+ description: 'Array of agent configurations to spawn in parallel'
1343
1379
  },
1344
- description: {
1345
- type: 'string',
1346
- description: "Checkpoint description"
1347
- }
1348
- },
1349
- required: [
1350
- 'sessionId'
1351
- ]
1352
- },
1353
- handler: async (input)=>{
1354
- const checkpointId = await checkpointManager.createCheckpoint(input.sessionId, input.description || `Checkpoint at ${new Date().toLocaleString()}`);
1355
- return {
1356
- success: true,
1357
- checkpointId,
1358
- sessionId: input.sessionId
1359
- };
1360
- }
1361
- };
1362
- }
1363
- function createCheckpointListTool(logger) {
1364
- return {
1365
- name: 'checkpoint_list',
1366
- description: 'List all checkpoints for a session',
1367
- inputSchema: {
1368
- type: 'object',
1369
- properties: {
1370
- sessionId: {
1371
- type: 'string',
1372
- description: 'Session ID'
1380
+ maxConcurrency: {
1381
+ type: 'number',
1382
+ default: 5,
1383
+ description: 'Maximum number of agents to spawn concurrently'
1384
+ },
1385
+ batchSize: {
1386
+ type: 'number',
1387
+ default: 3,
1388
+ description: 'Number of agents per batch'
1373
1389
  }
1374
1390
  },
1375
1391
  required: [
1376
- 'sessionId'
1392
+ 'agents'
1377
1393
  ]
1378
1394
  },
1379
- handler: async (input)=>{
1380
- const checkpoints = checkpointManager.listCheckpoints(input.sessionId);
1395
+ handler: async (input, context)=>{
1396
+ logger.info('Spawning parallel agents', {
1397
+ count: input.agents?.length,
1398
+ sessionId: context?.sessionId
1399
+ });
1400
+ if (!context?.orchestrator) {
1401
+ throw new Error('Orchestrator not available');
1402
+ }
1403
+ const executor = context.orchestrator.getParallelExecutor();
1404
+ if (!executor) {
1405
+ throw new Error('ParallelSwarmExecutor not initialized');
1406
+ }
1407
+ const agentConfigs = input.agents.map((agent)=>({
1408
+ agentId: `agent_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
1409
+ agentType: agent.type,
1410
+ task: `Spawn ${agent.name} agent`,
1411
+ capabilities: agent.capabilities || [],
1412
+ priority: agent.priority || 'medium'
1413
+ }));
1414
+ const startTime = Date.now();
1415
+ const sessions = await executor.spawnParallelAgents(agentConfigs, {
1416
+ maxConcurrency: input.maxConcurrency || 5,
1417
+ batchSize: input.batchSize || 3
1418
+ });
1419
+ const elapsedTime = Date.now() - startTime;
1381
1420
  return {
1382
1421
  success: true,
1383
- checkpoints,
1384
- count: checkpoints.length
1422
+ agentsSpawned: sessions.size,
1423
+ sessions: Array.from(sessions.entries()).map(([id, session])=>({
1424
+ agentId: id,
1425
+ sessionId: session.sessionId,
1426
+ status: session.status
1427
+ })),
1428
+ performance: {
1429
+ totalTime: elapsedTime,
1430
+ averageTimePerAgent: elapsedTime / sessions.size,
1431
+ speedupVsSequential: `~${Math.round(sessions.size * 750 / elapsedTime)}x`
1432
+ },
1433
+ timestamp: new Date().toISOString()
1385
1434
  };
1386
1435
  }
1387
1436
  };
1388
1437
  }
1389
- function createCheckpointRollbackTool(logger) {
1438
+ function createQueryControlTool(logger) {
1390
1439
  return {
1391
- name: 'checkpoint_rollback',
1392
- description: 'Rollback session to a checkpoint',
1440
+ name: 'query/control',
1441
+ description: 'Control running queries (pause, resume, terminate, change model)',
1393
1442
  inputSchema: {
1394
1443
  type: 'object',
1395
1444
  properties: {
1396
- checkpointId: {
1445
+ action: {
1397
1446
  type: 'string',
1398
- description: 'Checkpoint ID to restore'
1447
+ enum: [
1448
+ 'pause',
1449
+ 'resume',
1450
+ 'terminate',
1451
+ 'change_model',
1452
+ 'change_permissions',
1453
+ 'execute_command'
1454
+ ],
1455
+ description: 'Control action to perform'
1399
1456
  },
1400
- prompt: {
1457
+ queryId: {
1401
1458
  type: 'string',
1402
- description: 'Continue prompt after rollback'
1403
- }
1404
- },
1405
- required: [
1406
- 'checkpointId'
1407
- ]
1408
- },
1409
- handler: async (input)=>{
1410
- await checkpointManager.rollbackToCheckpoint(input.checkpointId, input.prompt || 'Continue from checkpoint');
1411
- return {
1412
- success: true,
1413
- checkpointId: input.checkpointId
1414
- };
1415
- }
1416
- };
1417
- }
1418
- function createSessionForkTool(logger) {
1419
- return {
1420
- name: 'session_fork',
1421
- description: 'Fork a session for parallel exploration (real SDK forking)',
1422
- inputSchema: {
1423
- type: 'object',
1424
- properties: {
1425
- sessionId: {
1459
+ description: 'ID of the query to control'
1460
+ },
1461
+ model: {
1426
1462
  type: 'string',
1427
- description: 'Base session ID to fork from'
1463
+ enum: [
1464
+ 'claude-3-5-sonnet-20241022',
1465
+ 'claude-3-5-haiku-20241022',
1466
+ 'claude-3-opus-20240229'
1467
+ ],
1468
+ description: 'Model to switch to (for change_model action)'
1428
1469
  },
1429
- forkOptions: {
1430
- type: 'object',
1431
- description: 'Fork configuration options',
1432
- properties: {}
1433
- }
1434
- },
1435
- required: [
1436
- 'sessionId'
1437
- ]
1438
- },
1439
- handler: async (input)=>{
1440
- const fork = await sessionForking.fork(input.sessionId, input.forkOptions || {});
1441
- return {
1442
- success: true,
1443
- fork
1444
- };
1445
- }
1446
- };
1447
- }
1448
- function createSessionInfoTool(logger) {
1449
- return {
1450
- name: 'session_info',
1451
- description: 'Get session and fork information',
1452
- inputSchema: {
1453
- type: 'object',
1454
- properties: {
1455
- sessionId: {
1470
+ permissionMode: {
1456
1471
  type: 'string',
1457
- description: 'Session ID'
1458
- }
1459
- },
1460
- required: [
1461
- 'sessionId'
1462
- ]
1463
- },
1464
- handler: async (input)=>{
1465
- const info = sessionForking.getSessionInfo(input.sessionId);
1466
- return {
1467
- success: true,
1468
- session: info
1469
- };
1470
- }
1471
- };
1472
- }
1473
- function createPauseQueryTool(logger) {
1474
- return {
1475
- name: 'query_pause',
1476
- description: 'Pause a query with SDK (real pause with resumeSessionAt)',
1477
- inputSchema: {
1478
- type: 'object',
1479
- properties: {
1480
- sessionId: {
1472
+ enum: [
1473
+ 'default',
1474
+ 'acceptEdits',
1475
+ 'bypassPermissions',
1476
+ 'plan'
1477
+ ],
1478
+ description: 'Permission mode to switch to (for change_permissions action)'
1479
+ },
1480
+ command: {
1481
1481
  type: 'string',
1482
- description: 'Session ID to pause'
1482
+ description: 'Command to execute (for execute_command action)'
1483
1483
  }
1484
1484
  },
1485
1485
  required: [
1486
- 'sessionId'
1486
+ 'action',
1487
+ 'queryId'
1487
1488
  ]
1488
1489
  },
1489
- handler: async (input)=>{
1490
- const { queryController } = await import('../sdk/query-control.js');
1491
- queryController.requestPause(input.sessionId);
1490
+ handler: async (input, context)=>{
1491
+ logger.info('Query control action', {
1492
+ action: input.action,
1493
+ queryId: input.queryId,
1494
+ sessionId: context?.sessionId
1495
+ });
1496
+ if (!context?.orchestrator) {
1497
+ throw new Error('Orchestrator not available');
1498
+ }
1499
+ const controller = context.orchestrator.getQueryController();
1500
+ if (!controller) {
1501
+ throw new Error('RealTimeQueryController not initialized');
1502
+ }
1503
+ let result;
1504
+ switch(input.action){
1505
+ case 'pause':
1506
+ result = await controller.pauseQuery(input.queryId);
1507
+ break;
1508
+ case 'resume':
1509
+ result = await controller.resumeQuery(input.queryId);
1510
+ break;
1511
+ case 'terminate':
1512
+ result = await controller.terminateQuery(input.queryId);
1513
+ break;
1514
+ case 'change_model':
1515
+ if (!input.model) {
1516
+ throw new Error('model parameter required for change_model action');
1517
+ }
1518
+ result = await controller.changeModel(input.queryId, input.model);
1519
+ break;
1520
+ case 'change_permissions':
1521
+ if (!input.permissionMode) {
1522
+ throw new Error('permissionMode parameter required for change_permissions action');
1523
+ }
1524
+ result = await controller.changePermissionMode(input.queryId, input.permissionMode);
1525
+ break;
1526
+ case 'execute_command':
1527
+ if (!input.command) {
1528
+ throw new Error('command parameter required for execute_command action');
1529
+ }
1530
+ result = await controller.executeCommand(input.queryId, input.command);
1531
+ break;
1532
+ default:
1533
+ throw new Error(`Unknown action: ${input.action}`);
1534
+ }
1492
1535
  return {
1493
1536
  success: true,
1494
- sessionId: input.sessionId,
1495
- paused: true
1537
+ action: input.action,
1538
+ queryId: input.queryId,
1539
+ result,
1540
+ timestamp: new Date().toISOString()
1496
1541
  };
1497
1542
  }
1498
1543
  };
1499
1544
  }
1500
- function createResumeQueryTool(logger) {
1545
+ function createListQueriesTool(logger) {
1501
1546
  return {
1502
- name: 'query_resume',
1503
- description: 'Resume a paused query',
1547
+ name: 'query/list',
1548
+ description: 'List all active queries and their status',
1504
1549
  inputSchema: {
1505
1550
  type: 'object',
1506
1551
  properties: {
1507
- sessionId: {
1508
- type: 'string',
1509
- description: 'Session ID to resume'
1552
+ includeHistory: {
1553
+ type: 'boolean',
1554
+ default: false,
1555
+ description: 'Include completed queries in the list'
1510
1556
  }
1511
- },
1512
- required: [
1513
- 'sessionId'
1514
- ]
1557
+ }
1515
1558
  },
1516
- handler: async (input)=>{
1517
- const { queryController } = await import('../sdk/query-control.js');
1518
- const result = await queryController.resumeQuery(input.sessionId);
1559
+ handler: async (input, context)=>{
1560
+ logger.info('Listing queries', {
1561
+ sessionId: context?.sessionId
1562
+ });
1563
+ if (!context?.orchestrator) {
1564
+ throw new Error('Orchestrator not available');
1565
+ }
1566
+ const controller = context.orchestrator.getQueryController();
1567
+ if (!controller) {
1568
+ throw new Error('RealTimeQueryController not initialized');
1569
+ }
1570
+ const queries = controller.getAllQueries();
1519
1571
  return {
1520
1572
  success: true,
1521
- sessionId: input.sessionId,
1522
- resumed: true,
1523
- result
1573
+ queries: Array.from(queries.entries()).map(([id, status])=>({
1574
+ queryId: id,
1575
+ ...status
1576
+ })),
1577
+ count: queries.size,
1578
+ timestamp: new Date().toISOString()
1524
1579
  };
1525
1580
  }
1526
1581
  };