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

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 (171) hide show
  1. package/.claude/agents/reasoning/README.md +171 -0
  2. package/.claude/agents/reasoning/agent.md +816 -0
  3. package/.claude/agents/reasoning/example-reasoning-agent-template.md +362 -0
  4. package/.claude/agents/reasoning/goal-planner.md +73 -0
  5. package/.claude/settings.json +2 -1
  6. package/.claude/sparc-modes.json +108 -0
  7. package/README.md +45 -55
  8. package/bin/claude-flow +1 -1
  9. package/dist/src/cli/command-registry.js +70 -6
  10. package/dist/src/cli/command-registry.js.map +1 -1
  11. package/dist/src/cli/commands/hive-mind/pause.js +2 -9
  12. package/dist/src/cli/commands/hive-mind/pause.js.map +1 -1
  13. package/dist/src/cli/commands/index.js +1 -114
  14. package/dist/src/cli/commands/index.js.map +1 -1
  15. package/dist/src/cli/commands/swarm-spawn.js +5 -33
  16. package/dist/src/cli/commands/swarm-spawn.js.map +1 -1
  17. package/dist/src/cli/help-formatter.js +0 -3
  18. package/dist/src/cli/help-formatter.js.map +1 -1
  19. package/dist/src/cli/help-text.js +69 -7
  20. package/dist/src/cli/help-text.js.map +1 -1
  21. package/dist/src/cli/simple-cli.js +182 -172
  22. package/dist/src/cli/simple-cli.js.map +1 -1
  23. package/dist/src/cli/simple-commands/agent-booster.js +415 -0
  24. package/dist/src/cli/simple-commands/agent-booster.js.map +1 -0
  25. package/dist/src/cli/simple-commands/agent.js +856 -13
  26. package/dist/src/cli/simple-commands/agent.js.map +1 -1
  27. package/dist/src/cli/simple-commands/env-template.js +180 -0
  28. package/dist/src/cli/simple-commands/env-template.js.map +1 -0
  29. package/dist/src/cli/simple-commands/hooks.js +233 -0
  30. package/dist/src/cli/simple-commands/hooks.js.map +1 -1
  31. package/dist/src/cli/simple-commands/init/help.js +23 -0
  32. package/dist/src/cli/simple-commands/init/help.js.map +1 -1
  33. package/dist/src/cli/simple-commands/init/index.js +63 -0
  34. package/dist/src/cli/simple-commands/init/index.js.map +1 -1
  35. package/dist/src/cli/simple-commands/memory.js +307 -16
  36. package/dist/src/cli/simple-commands/memory.js.map +1 -1
  37. package/dist/src/cli/simple-commands/proxy.js +304 -0
  38. package/dist/src/cli/simple-commands/proxy.js.map +1 -0
  39. package/dist/src/cli/simple-commands/sparc.js +16 -19
  40. package/dist/src/cli/simple-commands/sparc.js.map +1 -1
  41. package/dist/src/cli/validation-helper.js.map +1 -1
  42. package/dist/src/execution/agent-executor.js +181 -0
  43. package/dist/src/execution/agent-executor.js.map +1 -0
  44. package/dist/src/execution/index.js +12 -0
  45. package/dist/src/execution/index.js.map +1 -0
  46. package/dist/src/execution/provider-manager.js +110 -0
  47. package/dist/src/execution/provider-manager.js.map +1 -0
  48. package/dist/src/hooks/index.js +0 -3
  49. package/dist/src/hooks/index.js.map +1 -1
  50. package/dist/src/hooks/redaction-hook.js +89 -0
  51. package/dist/src/hooks/redaction-hook.js.map +1 -0
  52. package/dist/src/mcp/claude-flow-tools.js +205 -150
  53. package/dist/src/mcp/claude-flow-tools.js.map +1 -1
  54. package/dist/src/mcp/mcp-server.js +125 -0
  55. package/dist/src/mcp/mcp-server.js.map +1 -1
  56. package/dist/src/sdk/query-control.js +293 -139
  57. package/dist/src/sdk/query-control.js.map +1 -1
  58. package/dist/src/sdk/session-forking.js +206 -129
  59. package/dist/src/sdk/session-forking.js.map +1 -1
  60. package/dist/src/utils/key-redactor.js +108 -0
  61. package/dist/src/utils/key-redactor.js.map +1 -0
  62. package/dist/src/utils/metrics-reader.js +37 -39
  63. package/dist/src/utils/metrics-reader.js.map +1 -1
  64. package/docs/AGENT-BOOSTER-INTEGRATION.md +407 -0
  65. package/docs/AGENTIC-FLOW-INTEGRATION-GUIDE.md +753 -0
  66. package/docs/AGENTIC_FLOW_EXECUTION_FIX_REPORT.md +474 -0
  67. package/docs/AGENTIC_FLOW_INTEGRATION_STATUS.md +143 -0
  68. package/docs/AGENTIC_FLOW_MVP_COMPLETE.md +367 -0
  69. package/docs/AGENTIC_FLOW_SECURITY_TEST_REPORT.md +369 -0
  70. package/docs/COMMAND-VERIFICATION-REPORT.md +441 -0
  71. package/docs/COMMIT_SUMMARY.md +247 -0
  72. package/docs/DEEP_REVIEW_COMPREHENSIVE_REPORT.md +922 -0
  73. package/docs/DOCKER-VALIDATION-REPORT.md +281 -0
  74. package/docs/ENV-SETUP-GUIDE.md +270 -0
  75. package/docs/FINAL_PRE_PUBLISH_VALIDATION.md +823 -0
  76. package/docs/FINAL_VALIDATION_REPORT.md +165 -0
  77. package/docs/HOOKS-V2-MODIFICATION.md +146 -0
  78. package/docs/INDEX.md +568 -0
  79. package/docs/INTEGRATION_COMPLETE.md +414 -0
  80. package/docs/MEMORY_REDACTION_TEST_REPORT.md +300 -0
  81. package/docs/PERFORMANCE-SYSTEMS-STATUS.md +340 -0
  82. package/docs/PRE_RELEASE_FIXES_REPORT.md +435 -0
  83. package/docs/README.md +35 -0
  84. package/docs/REASONING-AGENTS.md +482 -0
  85. package/docs/REASONINGBANK-AGENT-CREATION-GUIDE.md +813 -0
  86. package/docs/REASONINGBANK-ANALYSIS-COMPLETE.md +479 -0
  87. package/docs/REASONINGBANK-BENCHMARK-RESULTS.md +166 -0
  88. package/docs/REASONINGBANK-BENCHMARK.md +396 -0
  89. package/docs/REASONINGBANK-CLI-INTEGRATION.md +455 -0
  90. package/docs/REASONINGBANK-CORE-INTEGRATION.md +658 -0
  91. package/docs/REASONINGBANK-COST-OPTIMIZATION.md +329 -0
  92. package/docs/REASONINGBANK-DEMO.md +419 -0
  93. package/docs/REASONINGBANK-INTEGRATION-COMPLETE.md +249 -0
  94. package/docs/REASONINGBANK-VALIDATION.md +532 -0
  95. package/docs/REASONINGBANK_ARCHITECTURE.md +475 -0
  96. package/docs/REASONINGBANK_INTEGRATION_COMPLETE.md +558 -0
  97. package/docs/REASONINGBANK_INTEGRATION_PLAN.md +1188 -0
  98. package/docs/REGRESSION-ANALYSIS-REPORT.md +500 -0
  99. package/docs/RELEASE_v2.6.0-alpha.2.md +658 -0
  100. package/docs/api/API_DOCUMENTATION.md +721 -0
  101. package/docs/architecture/ARCHITECTURE.md +1690 -0
  102. package/docs/ci-cd/README.md +368 -0
  103. package/docs/development/DEPLOYMENT.md +2348 -0
  104. package/docs/development/DEVELOPMENT_WORKFLOW.md +1333 -0
  105. package/docs/development/build-analysis-report.md +252 -0
  106. package/docs/development/pair-optimization.md +156 -0
  107. package/docs/development/token-tracking-status.md +103 -0
  108. package/docs/development/training-pipeline-demo.md +163 -0
  109. package/docs/development/training-pipeline-real-only.md +196 -0
  110. package/docs/epic-sdk-integration.md +1269 -0
  111. package/docs/experimental/RIEMANN_HYPOTHESIS_PROOF.md +124 -0
  112. package/docs/experimental/computational_verification.py +436 -0
  113. package/docs/experimental/novel_approaches.md +560 -0
  114. package/docs/experimental/riemann_hypothesis_analysis.md +263 -0
  115. package/docs/experimental/riemann_proof_attempt.md +124 -0
  116. package/docs/experimental/riemann_synthesis.md +277 -0
  117. package/docs/experimental/verification_results.json +12 -0
  118. package/docs/experimental/visualization_insights.md +720 -0
  119. package/docs/guides/USER_GUIDE.md +1138 -0
  120. package/docs/guides/token-tracking-guide.md +291 -0
  121. package/docs/reference/AGENTS.md +1011 -0
  122. package/docs/reference/MCP_TOOLS.md +2188 -0
  123. package/docs/reference/SPARC.md +717 -0
  124. package/docs/reference/SWARM.md +2000 -0
  125. package/docs/sdk/CLAUDE-CODE-SDK-DEEP-ANALYSIS.md +649 -0
  126. package/docs/sdk/CLAUDE-FLOW-SDK-INTEGRATION-ANALYSIS.md +242 -0
  127. package/docs/sdk/INTEGRATION-ROADMAP.md +420 -0
  128. package/docs/sdk/MCP-TOOLS-UPDATE.md +270 -0
  129. package/docs/sdk/SDK-ADVANCED-FEATURES-INTEGRATION.md +723 -0
  130. package/docs/sdk/SDK-ALL-FEATURES-INTEGRATION-MATRIX.md +612 -0
  131. package/docs/sdk/SDK-INTEGRATION-COMPLETE.md +358 -0
  132. package/docs/sdk/SDK-INTEGRATION-PHASES-V2.5.md +750 -0
  133. package/docs/sdk/SDK-LEVERAGE-REAL-FEATURES.md +676 -0
  134. package/docs/sdk/SDK-VALIDATION-RESULTS.md +400 -0
  135. package/docs/sdk/epic-sdk-integration.md +1269 -0
  136. package/docs/setup/remote-setup.md +93 -0
  137. package/docs/validation/final-validation-summary.md +220 -0
  138. package/docs/validation/verification-integration.md +190 -0
  139. package/docs/validation/verification-validation.md +349 -0
  140. package/docs/wiki/background-commands.md +1213 -0
  141. package/docs/wiki/session-persistence.md +342 -0
  142. package/docs/wiki/stream-chain-command.md +537 -0
  143. package/package.json +4 -2
  144. package/src/cli/command-registry.js +70 -5
  145. package/src/cli/commands/hive-mind/pause.ts +2 -15
  146. package/src/cli/commands/index.ts +1 -84
  147. package/src/cli/commands/swarm-spawn.ts +3 -47
  148. package/src/cli/help-text.js +42 -7
  149. package/src/cli/simple-cli.ts +18 -8
  150. package/src/cli/simple-commands/agent-booster.js +515 -0
  151. package/src/cli/simple-commands/agent.js +1001 -12
  152. package/src/cli/simple-commands/agent.ts +137 -0
  153. package/src/cli/simple-commands/config.ts +127 -0
  154. package/src/cli/simple-commands/env-template.js +190 -0
  155. package/src/cli/simple-commands/hooks.js +310 -0
  156. package/src/cli/simple-commands/init/help.js +23 -0
  157. package/src/cli/simple-commands/init/index.js +84 -6
  158. package/src/cli/simple-commands/memory.js +363 -16
  159. package/src/cli/simple-commands/proxy.js +384 -0
  160. package/src/cli/simple-commands/sparc.js +16 -19
  161. package/src/execution/agent-executor.ts +306 -0
  162. package/src/execution/index.ts +19 -0
  163. package/src/execution/provider-manager.ts +187 -0
  164. package/src/hooks/index.ts +0 -5
  165. package/src/hooks/redaction-hook.ts +115 -0
  166. package/src/mcp/claude-flow-tools.ts +203 -120
  167. package/src/mcp/mcp-server.js +86 -0
  168. package/src/sdk/query-control.ts +377 -223
  169. package/src/sdk/session-forking.ts +312 -207
  170. package/src/utils/key-redactor.js +178 -0
  171. package/src/utils/key-redactor.ts +184 -0
@@ -49,11 +49,14 @@ export async function createClaudeFlowTools(logger: ILogger): Promise<MCPTool[]>
49
49
  const tools = [
50
50
  // Agent management tools
51
51
  createSpawnAgentTool(logger),
52
+ createSpawnParallelAgentsTool(logger), // NEW: Phase 4 - Parallel spawning
52
53
  createListAgentsTool(logger),
53
54
  createTerminateAgentTool(logger),
54
55
  createGetAgentInfoTool(logger),
55
56
 
56
- // SDK Session Management Tools (NEW: SDK Integration)
57
+ // Query control tools (NEW: Phase 4 - Real-time control)
58
+ createQueryControlTool(logger),
59
+ createListQueriesTool(logger),
57
60
 
58
61
  // Task management tools
59
62
  createCreateTaskTool(logger),
@@ -550,7 +553,7 @@ function createAssignTaskTool(logger: ILogger): MCPTool {
550
553
 
551
554
  function createQueryMemoryTool(logger: ILogger): MCPTool {
552
555
  return {
553
- name: 'memory_query',
556
+ name: 'memory/query',
554
557
  description: 'Query agent memory with filters and search',
555
558
  inputSchema: {
556
559
  type: 'object',
@@ -632,7 +635,7 @@ function createQueryMemoryTool(logger: ILogger): MCPTool {
632
635
 
633
636
  function createStoreMemoryTool(logger: ILogger): MCPTool {
634
637
  return {
635
- name: 'memory_store',
638
+ name: 'memory/store',
636
639
  description: 'Store a new memory entry',
637
640
  inputSchema: {
638
641
  type: 'object',
@@ -702,7 +705,7 @@ function createStoreMemoryTool(logger: ILogger): MCPTool {
702
705
 
703
706
  function createDeleteMemoryTool(logger: ILogger): MCPTool {
704
707
  return {
705
- name: 'memory_delete',
708
+ name: 'memory/delete',
706
709
  description: 'Delete a memory entry',
707
710
  inputSchema: {
708
711
  type: 'object',
@@ -734,7 +737,7 @@ function createDeleteMemoryTool(logger: ILogger): MCPTool {
734
737
 
735
738
  function createExportMemoryTool(logger: ILogger): MCPTool {
736
739
  return {
737
- name: 'memory_export',
740
+ name: 'memory/export',
738
741
  description: 'Export memory entries to a file',
739
742
  inputSchema: {
740
743
  type: 'object',
@@ -790,7 +793,7 @@ function createExportMemoryTool(logger: ILogger): MCPTool {
790
793
 
791
794
  function createImportMemoryTool(logger: ILogger): MCPTool {
792
795
  return {
793
- name: 'memory_import',
796
+ name: 'memory/import',
794
797
  description: 'Import memory entries from a file',
795
798
  inputSchema: {
796
799
  type: 'object',
@@ -1309,156 +1312,236 @@ function createCreateTerminalTool(logger: ILogger): MCPTool {
1309
1312
  }
1310
1313
 
1311
1314
  /**
1312
- * SDK Integration Tools - Session Checkpoints
1315
+ * NEW: Phase 4 - Parallel Agent Spawning (10-20x faster)
1316
+ * Spawn multiple agents in parallel using ParallelSwarmExecutor
1313
1317
  */
1314
- function createCheckpointCreateTool(logger: ILogger): MCPTool {
1318
+ function createSpawnParallelAgentsTool(logger: ILogger): MCPTool {
1315
1319
  return {
1316
- name: 'checkpoint_create',
1317
- description: 'Create a checkpoint for a session (Git-like time travel)',
1320
+ name: 'agents/spawn_parallel',
1321
+ description: 'Spawn multiple agents in parallel (10-20x faster than sequential spawning)',
1318
1322
  inputSchema: {
1319
1323
  type: 'object',
1320
1324
  properties: {
1321
- sessionId: { type: 'string', description: 'Session ID to checkpoint' },
1322
- description: { type: 'string', description: 'Checkpoint description' },
1325
+ agents: {
1326
+ type: 'array',
1327
+ items: {
1328
+ type: 'object',
1329
+ properties: {
1330
+ type: { type: 'string', description: 'Agent type' },
1331
+ name: { type: 'string', description: 'Agent name' },
1332
+ capabilities: { type: 'array', items: { type: 'string' } },
1333
+ priority: {
1334
+ type: 'string',
1335
+ enum: ['low', 'medium', 'high', 'critical'],
1336
+ default: 'medium'
1337
+ },
1338
+ },
1339
+ required: ['type', 'name'],
1340
+ },
1341
+ description: 'Array of agent configurations to spawn in parallel',
1342
+ },
1343
+ maxConcurrency: {
1344
+ type: 'number',
1345
+ default: 5,
1346
+ description: 'Maximum number of agents to spawn concurrently',
1347
+ },
1348
+ batchSize: {
1349
+ type: 'number',
1350
+ default: 3,
1351
+ description: 'Number of agents per batch',
1352
+ },
1323
1353
  },
1324
- required: ['sessionId'],
1354
+ required: ['agents'],
1325
1355
  },
1326
- handler: async (input: any) => {
1327
-
1328
- const checkpointId = await checkpointManager.createCheckpoint(
1329
- input.sessionId,
1330
- input.description || `Checkpoint at ${new Date().toLocaleString()}`
1331
- );
1332
- return { success: true, checkpointId, sessionId: input.sessionId };
1333
- },
1334
- };
1335
- }
1356
+ handler: async (input: any, context?: ClaudeFlowToolContext) => {
1357
+ logger.info('Spawning parallel agents', {
1358
+ count: input.agents?.length,
1359
+ sessionId: context?.sessionId
1360
+ });
1336
1361
 
1337
- function createCheckpointListTool(logger: ILogger): MCPTool {
1338
- return {
1339
- name: 'checkpoint_list',
1340
- description: 'List all checkpoints for a session',
1341
- inputSchema: {
1342
- type: 'object',
1343
- properties: {
1344
- sessionId: { type: 'string', description: 'Session ID' },
1345
- },
1346
- required: ['sessionId'],
1347
- },
1348
- handler: async (input: any) => {
1349
-
1350
- const checkpoints = checkpointManager.listCheckpoints(input.sessionId);
1351
- return { success: true, checkpoints, count: checkpoints.length };
1352
- },
1353
- };
1354
- }
1362
+ if (!context?.orchestrator) {
1363
+ throw new Error('Orchestrator not available');
1364
+ }
1355
1365
 
1356
- function createCheckpointRollbackTool(logger: ILogger): MCPTool {
1357
- return {
1358
- name: 'checkpoint_rollback',
1359
- description: 'Rollback session to a checkpoint',
1360
- inputSchema: {
1361
- type: 'object',
1362
- properties: {
1363
- checkpointId: { type: 'string', description: 'Checkpoint ID to restore' },
1364
- prompt: { type: 'string', description: 'Continue prompt after rollback' },
1365
- },
1366
- required: ['checkpointId'],
1367
- },
1368
- handler: async (input: any) => {
1369
-
1370
- await checkpointManager.rollbackToCheckpoint(
1371
- input.checkpointId,
1372
- input.prompt || 'Continue from checkpoint'
1373
- );
1374
- return { success: true, checkpointId: input.checkpointId };
1366
+ const executor = context.orchestrator.getParallelExecutor();
1367
+ if (!executor) {
1368
+ throw new Error('ParallelSwarmExecutor not initialized');
1369
+ }
1370
+
1371
+ // Convert input agents to ParallelAgentConfig format
1372
+ const agentConfigs = input.agents.map((agent: any) => ({
1373
+ agentId: `agent_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
1374
+ agentType: agent.type,
1375
+ task: `Spawn ${agent.name} agent`,
1376
+ capabilities: agent.capabilities || [],
1377
+ priority: agent.priority || 'medium',
1378
+ }));
1379
+
1380
+ const startTime = Date.now();
1381
+ const sessions = await executor.spawnParallelAgents(agentConfigs, {
1382
+ maxConcurrency: input.maxConcurrency || 5,
1383
+ batchSize: input.batchSize || 3,
1384
+ });
1385
+
1386
+ const elapsedTime = Date.now() - startTime;
1387
+
1388
+ return {
1389
+ success: true,
1390
+ agentsSpawned: sessions.size,
1391
+ sessions: Array.from(sessions.entries()).map(([id, session]) => ({
1392
+ agentId: id,
1393
+ sessionId: session.sessionId,
1394
+ status: session.status,
1395
+ })),
1396
+ performance: {
1397
+ totalTime: elapsedTime,
1398
+ averageTimePerAgent: elapsedTime / sessions.size,
1399
+ speedupVsSequential: `~${Math.round((sessions.size * 750) / elapsedTime)}x`,
1400
+ },
1401
+ timestamp: new Date().toISOString(),
1402
+ };
1375
1403
  },
1376
1404
  };
1377
1405
  }
1378
1406
 
1379
1407
  /**
1380
- * SDK Integration Tools - Session Forking
1408
+ * NEW: Phase 4 - Real-Time Query Control
1409
+ * Control running queries: pause, resume, terminate, change model
1381
1410
  */
1382
- function createSessionForkTool(logger: ILogger): MCPTool {
1411
+ function createQueryControlTool(logger: ILogger): MCPTool {
1383
1412
  return {
1384
- name: 'session_fork',
1385
- description: 'Fork a session for parallel exploration (real SDK forking)',
1413
+ name: 'query/control',
1414
+ description: 'Control running queries (pause, resume, terminate, change model)',
1386
1415
  inputSchema: {
1387
1416
  type: 'object',
1388
1417
  properties: {
1389
- sessionId: { type: 'string', description: 'Base session ID to fork from' },
1390
- forkOptions: {
1391
- type: 'object',
1392
- description: 'Fork configuration options',
1393
- properties: {},
1418
+ action: {
1419
+ type: 'string',
1420
+ enum: ['pause', 'resume', 'terminate', 'change_model', 'change_permissions', 'execute_command'],
1421
+ description: 'Control action to perform',
1422
+ },
1423
+ queryId: {
1424
+ type: 'string',
1425
+ description: 'ID of the query to control',
1426
+ },
1427
+ model: {
1428
+ type: 'string',
1429
+ enum: ['claude-3-5-sonnet-20241022', 'claude-3-5-haiku-20241022', 'claude-3-opus-20240229'],
1430
+ description: 'Model to switch to (for change_model action)',
1431
+ },
1432
+ permissionMode: {
1433
+ type: 'string',
1434
+ enum: ['default', 'acceptEdits', 'bypassPermissions', 'plan'],
1435
+ description: 'Permission mode to switch to (for change_permissions action)',
1436
+ },
1437
+ command: {
1438
+ type: 'string',
1439
+ description: 'Command to execute (for execute_command action)',
1394
1440
  },
1395
1441
  },
1396
- required: ['sessionId'],
1397
- },
1398
- handler: async (input: any) => {
1399
-
1400
- const fork = await sessionForking.fork(input.sessionId, input.forkOptions || {});
1401
- return { success: true, fork };
1442
+ required: ['action', 'queryId'],
1402
1443
  },
1403
- };
1404
- }
1444
+ handler: async (input: any, context?: ClaudeFlowToolContext) => {
1445
+ logger.info('Query control action', {
1446
+ action: input.action,
1447
+ queryId: input.queryId,
1448
+ sessionId: context?.sessionId
1449
+ });
1405
1450
 
1406
- function createSessionInfoTool(logger: ILogger): MCPTool {
1407
- return {
1408
- name: 'session_info',
1409
- description: 'Get session and fork information',
1410
- inputSchema: {
1411
- type: 'object',
1412
- properties: {
1413
- sessionId: { type: 'string', description: 'Session ID' },
1414
- },
1415
- required: ['sessionId'],
1416
- },
1417
- handler: async (input: any) => {
1418
-
1419
- const info = sessionForking.getSessionInfo(input.sessionId);
1420
- return { success: true, session: info };
1451
+ if (!context?.orchestrator) {
1452
+ throw new Error('Orchestrator not available');
1453
+ }
1454
+
1455
+ const controller = context.orchestrator.getQueryController();
1456
+ if (!controller) {
1457
+ throw new Error('RealTimeQueryController not initialized');
1458
+ }
1459
+
1460
+ let result;
1461
+ switch (input.action) {
1462
+ case 'pause':
1463
+ result = await controller.pauseQuery(input.queryId);
1464
+ break;
1465
+ case 'resume':
1466
+ result = await controller.resumeQuery(input.queryId);
1467
+ break;
1468
+ case 'terminate':
1469
+ result = await controller.terminateQuery(input.queryId);
1470
+ break;
1471
+ case 'change_model':
1472
+ if (!input.model) {
1473
+ throw new Error('model parameter required for change_model action');
1474
+ }
1475
+ result = await controller.changeModel(input.queryId, input.model);
1476
+ break;
1477
+ case 'change_permissions':
1478
+ if (!input.permissionMode) {
1479
+ throw new Error('permissionMode parameter required for change_permissions action');
1480
+ }
1481
+ result = await controller.changePermissionMode(input.queryId, input.permissionMode);
1482
+ break;
1483
+ case 'execute_command':
1484
+ if (!input.command) {
1485
+ throw new Error('command parameter required for execute_command action');
1486
+ }
1487
+ result = await controller.executeCommand(input.queryId, input.command);
1488
+ break;
1489
+ default:
1490
+ throw new Error(`Unknown action: ${input.action}`);
1491
+ }
1492
+
1493
+ return {
1494
+ success: true,
1495
+ action: input.action,
1496
+ queryId: input.queryId,
1497
+ result,
1498
+ timestamp: new Date().toISOString(),
1499
+ };
1421
1500
  },
1422
1501
  };
1423
1502
  }
1424
1503
 
1425
1504
  /**
1426
- * SDK Integration Tools - Query Control
1505
+ * NEW: Phase 4 - List Active Queries
1506
+ * Get status of all active queries being controlled
1427
1507
  */
1428
- function createPauseQueryTool(logger: ILogger): MCPTool {
1508
+ function createListQueriesTool(logger: ILogger): MCPTool {
1429
1509
  return {
1430
- name: 'query_pause',
1431
- description: 'Pause a query with SDK (real pause with resumeSessionAt)',
1510
+ name: 'query/list',
1511
+ description: 'List all active queries and their status',
1432
1512
  inputSchema: {
1433
1513
  type: 'object',
1434
1514
  properties: {
1435
- sessionId: { type: 'string', description: 'Session ID to pause' },
1515
+ includeHistory: {
1516
+ type: 'boolean',
1517
+ default: false,
1518
+ description: 'Include completed queries in the list',
1519
+ },
1436
1520
  },
1437
- required: ['sessionId'],
1438
- },
1439
- handler: async (input: any) => {
1440
- const { queryController } = await import('../sdk/query-control.js');
1441
- queryController.requestPause(input.sessionId);
1442
- return { success: true, sessionId: input.sessionId, paused: true };
1443
1521
  },
1444
- };
1445
- }
1522
+ handler: async (input: any, context?: ClaudeFlowToolContext) => {
1523
+ logger.info('Listing queries', { sessionId: context?.sessionId });
1446
1524
 
1447
- function createResumeQueryTool(logger: ILogger): MCPTool {
1448
- return {
1449
- name: 'query_resume',
1450
- description: 'Resume a paused query',
1451
- inputSchema: {
1452
- type: 'object',
1453
- properties: {
1454
- sessionId: { type: 'string', description: 'Session ID to resume' },
1455
- },
1456
- required: ['sessionId'],
1457
- },
1458
- handler: async (input: any) => {
1459
- const { queryController } = await import('../sdk/query-control.js');
1460
- const result = await queryController.resumeQuery(input.sessionId);
1461
- return { success: true, sessionId: input.sessionId, resumed: true, result };
1525
+ if (!context?.orchestrator) {
1526
+ throw new Error('Orchestrator not available');
1527
+ }
1528
+
1529
+ const controller = context.orchestrator.getQueryController();
1530
+ if (!controller) {
1531
+ throw new Error('RealTimeQueryController not initialized');
1532
+ }
1533
+
1534
+ const queries = controller.getAllQueries();
1535
+
1536
+ return {
1537
+ success: true,
1538
+ queries: Array.from(queries.entries()).map(([id, status]) => ({
1539
+ queryId: id,
1540
+ ...status,
1541
+ })),
1542
+ count: queries.size,
1543
+ timestamp: new Date().toISOString(),
1544
+ };
1462
1545
  },
1463
1546
  };
1464
1547
  }
@@ -932,6 +932,92 @@ class ClaudeFlowMCPServer {
932
932
  inputSchema: { type: 'object', properties: { components: { type: 'array' } } },
933
933
  },
934
934
 
935
+ // Phase 4: SDK Integration - Real-Time Query Control & Parallel Spawning (v2.5.0-alpha.131)
936
+ agents_spawn_parallel: {
937
+ name: 'agents_spawn_parallel',
938
+ description: 'Spawn multiple agents in parallel (10-20x faster than sequential spawning)',
939
+ inputSchema: {
940
+ type: 'object',
941
+ properties: {
942
+ agents: {
943
+ type: 'array',
944
+ items: {
945
+ type: 'object',
946
+ properties: {
947
+ type: { type: 'string', description: 'Agent type' },
948
+ name: { type: 'string', description: 'Agent name' },
949
+ capabilities: { type: 'array', items: { type: 'string' } },
950
+ priority: {
951
+ type: 'string',
952
+ enum: ['low', 'medium', 'high', 'critical'],
953
+ default: 'medium'
954
+ },
955
+ },
956
+ required: ['type', 'name'],
957
+ },
958
+ description: 'Array of agent configurations to spawn in parallel',
959
+ },
960
+ maxConcurrency: {
961
+ type: 'number',
962
+ default: 5,
963
+ description: 'Maximum number of agents to spawn concurrently',
964
+ },
965
+ batchSize: {
966
+ type: 'number',
967
+ default: 3,
968
+ description: 'Number of agents per batch',
969
+ },
970
+ },
971
+ required: ['agents'],
972
+ },
973
+ },
974
+ query_control: {
975
+ name: 'query_control',
976
+ description: 'Control running queries (pause, resume, terminate, change model)',
977
+ inputSchema: {
978
+ type: 'object',
979
+ properties: {
980
+ action: {
981
+ type: 'string',
982
+ enum: ['pause', 'resume', 'terminate', 'change_model', 'change_permissions', 'execute_command'],
983
+ description: 'Control action to perform',
984
+ },
985
+ queryId: {
986
+ type: 'string',
987
+ description: 'ID of the query to control',
988
+ },
989
+ model: {
990
+ type: 'string',
991
+ enum: ['claude-3-5-sonnet-20241022', 'claude-3-5-haiku-20241022', 'claude-3-opus-20240229'],
992
+ description: 'Model to switch to (for change_model action)',
993
+ },
994
+ permissionMode: {
995
+ type: 'string',
996
+ enum: ['default', 'acceptEdits', 'bypassPermissions', 'plan'],
997
+ description: 'Permission mode to switch to (for change_permissions action)',
998
+ },
999
+ command: {
1000
+ type: 'string',
1001
+ description: 'Command to execute (for execute_command action)',
1002
+ },
1003
+ },
1004
+ required: ['action', 'queryId'],
1005
+ },
1006
+ },
1007
+ query_list: {
1008
+ name: 'query_list',
1009
+ description: 'List all active queries and their status',
1010
+ inputSchema: {
1011
+ type: 'object',
1012
+ properties: {
1013
+ includeHistory: {
1014
+ type: 'boolean',
1015
+ default: false,
1016
+ description: 'Include completed queries in the list',
1017
+ },
1018
+ },
1019
+ },
1020
+ },
935
1021
  };
936
1022
  }
937
1023