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.
- package/.claude/agents/reasoning/README.md +171 -0
- package/.claude/agents/reasoning/agent.md +816 -0
- package/.claude/agents/reasoning/example-reasoning-agent-template.md +362 -0
- package/.claude/agents/reasoning/goal-planner.md +73 -0
- package/.claude/settings.json +2 -1
- package/.claude/sparc-modes.json +108 -0
- package/README.md +45 -55
- package/bin/claude-flow +1 -1
- package/dist/src/cli/command-registry.js +70 -6
- package/dist/src/cli/command-registry.js.map +1 -1
- package/dist/src/cli/commands/hive-mind/pause.js +2 -9
- package/dist/src/cli/commands/hive-mind/pause.js.map +1 -1
- package/dist/src/cli/commands/index.js +1 -114
- package/dist/src/cli/commands/index.js.map +1 -1
- package/dist/src/cli/commands/swarm-spawn.js +5 -33
- package/dist/src/cli/commands/swarm-spawn.js.map +1 -1
- package/dist/src/cli/help-formatter.js +0 -3
- package/dist/src/cli/help-formatter.js.map +1 -1
- package/dist/src/cli/help-text.js +69 -7
- package/dist/src/cli/help-text.js.map +1 -1
- package/dist/src/cli/simple-cli.js +182 -172
- package/dist/src/cli/simple-cli.js.map +1 -1
- package/dist/src/cli/simple-commands/agent-booster.js +415 -0
- package/dist/src/cli/simple-commands/agent-booster.js.map +1 -0
- package/dist/src/cli/simple-commands/agent.js +856 -13
- package/dist/src/cli/simple-commands/agent.js.map +1 -1
- package/dist/src/cli/simple-commands/env-template.js +180 -0
- package/dist/src/cli/simple-commands/env-template.js.map +1 -0
- package/dist/src/cli/simple-commands/hooks.js +233 -0
- package/dist/src/cli/simple-commands/hooks.js.map +1 -1
- package/dist/src/cli/simple-commands/init/help.js +23 -0
- package/dist/src/cli/simple-commands/init/help.js.map +1 -1
- package/dist/src/cli/simple-commands/init/index.js +63 -0
- package/dist/src/cli/simple-commands/init/index.js.map +1 -1
- package/dist/src/cli/simple-commands/memory.js +307 -16
- package/dist/src/cli/simple-commands/memory.js.map +1 -1
- package/dist/src/cli/simple-commands/proxy.js +304 -0
- package/dist/src/cli/simple-commands/proxy.js.map +1 -0
- package/dist/src/cli/simple-commands/sparc.js +16 -19
- package/dist/src/cli/simple-commands/sparc.js.map +1 -1
- package/dist/src/cli/validation-helper.js.map +1 -1
- package/dist/src/execution/agent-executor.js +181 -0
- package/dist/src/execution/agent-executor.js.map +1 -0
- package/dist/src/execution/index.js +12 -0
- package/dist/src/execution/index.js.map +1 -0
- package/dist/src/execution/provider-manager.js +110 -0
- package/dist/src/execution/provider-manager.js.map +1 -0
- package/dist/src/hooks/index.js +0 -3
- package/dist/src/hooks/index.js.map +1 -1
- package/dist/src/hooks/redaction-hook.js +89 -0
- package/dist/src/hooks/redaction-hook.js.map +1 -0
- package/dist/src/mcp/claude-flow-tools.js +205 -150
- package/dist/src/mcp/claude-flow-tools.js.map +1 -1
- package/dist/src/mcp/mcp-server.js +125 -0
- package/dist/src/mcp/mcp-server.js.map +1 -1
- package/dist/src/sdk/query-control.js +293 -139
- package/dist/src/sdk/query-control.js.map +1 -1
- package/dist/src/sdk/session-forking.js +206 -129
- package/dist/src/sdk/session-forking.js.map +1 -1
- package/dist/src/utils/key-redactor.js +108 -0
- package/dist/src/utils/key-redactor.js.map +1 -0
- package/dist/src/utils/metrics-reader.js +37 -39
- package/dist/src/utils/metrics-reader.js.map +1 -1
- package/docs/AGENT-BOOSTER-INTEGRATION.md +407 -0
- package/docs/AGENTIC-FLOW-INTEGRATION-GUIDE.md +753 -0
- package/docs/AGENTIC_FLOW_EXECUTION_FIX_REPORT.md +474 -0
- package/docs/AGENTIC_FLOW_INTEGRATION_STATUS.md +143 -0
- package/docs/AGENTIC_FLOW_MVP_COMPLETE.md +367 -0
- package/docs/AGENTIC_FLOW_SECURITY_TEST_REPORT.md +369 -0
- package/docs/COMMAND-VERIFICATION-REPORT.md +441 -0
- package/docs/COMMIT_SUMMARY.md +247 -0
- package/docs/DEEP_REVIEW_COMPREHENSIVE_REPORT.md +922 -0
- package/docs/DOCKER-VALIDATION-REPORT.md +281 -0
- package/docs/ENV-SETUP-GUIDE.md +270 -0
- package/docs/FINAL_PRE_PUBLISH_VALIDATION.md +823 -0
- package/docs/FINAL_VALIDATION_REPORT.md +165 -0
- package/docs/HOOKS-V2-MODIFICATION.md +146 -0
- package/docs/INDEX.md +568 -0
- package/docs/INTEGRATION_COMPLETE.md +414 -0
- package/docs/MEMORY_REDACTION_TEST_REPORT.md +300 -0
- package/docs/PERFORMANCE-SYSTEMS-STATUS.md +340 -0
- package/docs/PRE_RELEASE_FIXES_REPORT.md +435 -0
- package/docs/README.md +35 -0
- package/docs/REASONING-AGENTS.md +482 -0
- package/docs/REASONINGBANK-AGENT-CREATION-GUIDE.md +813 -0
- package/docs/REASONINGBANK-ANALYSIS-COMPLETE.md +479 -0
- package/docs/REASONINGBANK-BENCHMARK-RESULTS.md +166 -0
- package/docs/REASONINGBANK-BENCHMARK.md +396 -0
- package/docs/REASONINGBANK-CLI-INTEGRATION.md +455 -0
- package/docs/REASONINGBANK-CORE-INTEGRATION.md +658 -0
- package/docs/REASONINGBANK-COST-OPTIMIZATION.md +329 -0
- package/docs/REASONINGBANK-DEMO.md +419 -0
- package/docs/REASONINGBANK-INTEGRATION-COMPLETE.md +249 -0
- package/docs/REASONINGBANK-VALIDATION.md +532 -0
- package/docs/REASONINGBANK_ARCHITECTURE.md +475 -0
- package/docs/REASONINGBANK_INTEGRATION_COMPLETE.md +558 -0
- package/docs/REASONINGBANK_INTEGRATION_PLAN.md +1188 -0
- package/docs/REGRESSION-ANALYSIS-REPORT.md +500 -0
- package/docs/RELEASE_v2.6.0-alpha.2.md +658 -0
- package/docs/api/API_DOCUMENTATION.md +721 -0
- package/docs/architecture/ARCHITECTURE.md +1690 -0
- package/docs/ci-cd/README.md +368 -0
- package/docs/development/DEPLOYMENT.md +2348 -0
- package/docs/development/DEVELOPMENT_WORKFLOW.md +1333 -0
- package/docs/development/build-analysis-report.md +252 -0
- package/docs/development/pair-optimization.md +156 -0
- package/docs/development/token-tracking-status.md +103 -0
- package/docs/development/training-pipeline-demo.md +163 -0
- package/docs/development/training-pipeline-real-only.md +196 -0
- package/docs/epic-sdk-integration.md +1269 -0
- package/docs/experimental/RIEMANN_HYPOTHESIS_PROOF.md +124 -0
- package/docs/experimental/computational_verification.py +436 -0
- package/docs/experimental/novel_approaches.md +560 -0
- package/docs/experimental/riemann_hypothesis_analysis.md +263 -0
- package/docs/experimental/riemann_proof_attempt.md +124 -0
- package/docs/experimental/riemann_synthesis.md +277 -0
- package/docs/experimental/verification_results.json +12 -0
- package/docs/experimental/visualization_insights.md +720 -0
- package/docs/guides/USER_GUIDE.md +1138 -0
- package/docs/guides/token-tracking-guide.md +291 -0
- package/docs/reference/AGENTS.md +1011 -0
- package/docs/reference/MCP_TOOLS.md +2188 -0
- package/docs/reference/SPARC.md +717 -0
- package/docs/reference/SWARM.md +2000 -0
- package/docs/sdk/CLAUDE-CODE-SDK-DEEP-ANALYSIS.md +649 -0
- package/docs/sdk/CLAUDE-FLOW-SDK-INTEGRATION-ANALYSIS.md +242 -0
- package/docs/sdk/INTEGRATION-ROADMAP.md +420 -0
- package/docs/sdk/MCP-TOOLS-UPDATE.md +270 -0
- package/docs/sdk/SDK-ADVANCED-FEATURES-INTEGRATION.md +723 -0
- package/docs/sdk/SDK-ALL-FEATURES-INTEGRATION-MATRIX.md +612 -0
- package/docs/sdk/SDK-INTEGRATION-COMPLETE.md +358 -0
- package/docs/sdk/SDK-INTEGRATION-PHASES-V2.5.md +750 -0
- package/docs/sdk/SDK-LEVERAGE-REAL-FEATURES.md +676 -0
- package/docs/sdk/SDK-VALIDATION-RESULTS.md +400 -0
- package/docs/sdk/epic-sdk-integration.md +1269 -0
- package/docs/setup/remote-setup.md +93 -0
- package/docs/validation/final-validation-summary.md +220 -0
- package/docs/validation/verification-integration.md +190 -0
- package/docs/validation/verification-validation.md +349 -0
- package/docs/wiki/background-commands.md +1213 -0
- package/docs/wiki/session-persistence.md +342 -0
- package/docs/wiki/stream-chain-command.md +537 -0
- package/package.json +4 -2
- package/src/cli/command-registry.js +70 -5
- package/src/cli/commands/hive-mind/pause.ts +2 -15
- package/src/cli/commands/index.ts +1 -84
- package/src/cli/commands/swarm-spawn.ts +3 -47
- package/src/cli/help-text.js +42 -7
- package/src/cli/simple-cli.ts +18 -8
- package/src/cli/simple-commands/agent-booster.js +515 -0
- package/src/cli/simple-commands/agent.js +1001 -12
- package/src/cli/simple-commands/agent.ts +137 -0
- package/src/cli/simple-commands/config.ts +127 -0
- package/src/cli/simple-commands/env-template.js +190 -0
- package/src/cli/simple-commands/hooks.js +310 -0
- package/src/cli/simple-commands/init/help.js +23 -0
- package/src/cli/simple-commands/init/index.js +84 -6
- package/src/cli/simple-commands/memory.js +363 -16
- package/src/cli/simple-commands/proxy.js +384 -0
- package/src/cli/simple-commands/sparc.js +16 -19
- package/src/execution/agent-executor.ts +306 -0
- package/src/execution/index.ts +19 -0
- package/src/execution/provider-manager.ts +187 -0
- package/src/hooks/index.ts +0 -5
- package/src/hooks/redaction-hook.ts +115 -0
- package/src/mcp/claude-flow-tools.ts +203 -120
- package/src/mcp/mcp-server.js +86 -0
- package/src/sdk/query-control.ts +377 -223
- package/src/sdk/session-forking.ts +312 -207
- package/src/utils/key-redactor.js +178 -0
- package/src/utils/key-redactor.ts +184 -0
|
@@ -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: '
|
|
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: '
|
|
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: '
|
|
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: '
|
|
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: '
|
|
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
|
|
1336
|
+
function createSpawnParallelAgentsTool(logger) {
|
|
1334
1337
|
return {
|
|
1335
|
-
name: '
|
|
1336
|
-
description: '
|
|
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
|
-
|
|
1341
|
-
type: '
|
|
1342
|
-
|
|
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
|
-
|
|
1345
|
-
type: '
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
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
|
-
'
|
|
1392
|
+
'agents'
|
|
1377
1393
|
]
|
|
1378
1394
|
},
|
|
1379
|
-
handler: async (input)=>{
|
|
1380
|
-
|
|
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
|
-
|
|
1384
|
-
|
|
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
|
|
1438
|
+
function createQueryControlTool(logger) {
|
|
1390
1439
|
return {
|
|
1391
|
-
name: '
|
|
1392
|
-
description: '
|
|
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
|
-
|
|
1445
|
+
action: {
|
|
1397
1446
|
type: 'string',
|
|
1398
|
-
|
|
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
|
-
|
|
1457
|
+
queryId: {
|
|
1401
1458
|
type: 'string',
|
|
1402
|
-
description: '
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
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: '
|
|
1482
|
+
description: 'Command to execute (for execute_command action)'
|
|
1483
1483
|
}
|
|
1484
1484
|
},
|
|
1485
1485
|
required: [
|
|
1486
|
-
'
|
|
1486
|
+
'action',
|
|
1487
|
+
'queryId'
|
|
1487
1488
|
]
|
|
1488
1489
|
},
|
|
1489
|
-
handler: async (input)=>{
|
|
1490
|
-
|
|
1491
|
-
|
|
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
|
-
|
|
1495
|
-
|
|
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
|
|
1545
|
+
function createListQueriesTool(logger) {
|
|
1501
1546
|
return {
|
|
1502
|
-
name: '
|
|
1503
|
-
description: '
|
|
1547
|
+
name: 'query/list',
|
|
1548
|
+
description: 'List all active queries and their status',
|
|
1504
1549
|
inputSchema: {
|
|
1505
1550
|
type: 'object',
|
|
1506
1551
|
properties: {
|
|
1507
|
-
|
|
1508
|
-
type: '
|
|
1509
|
-
|
|
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
|
-
|
|
1518
|
-
|
|
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
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
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
|
};
|