claude-flow-novice 1.5.11 → 1.5.13

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-flow-novice/dist/mcp/auth.js +347 -0
  2. package/.claude-flow-novice/dist/mcp/claude-code-wrapper.js +717 -0
  3. package/.claude-flow-novice/dist/mcp/claude-flow-tools.js +1365 -0
  4. package/.claude-flow-novice/dist/mcp/client.js +201 -0
  5. package/.claude-flow-novice/dist/mcp/index.js +192 -0
  6. package/.claude-flow-novice/dist/mcp/integrate-wrapper.js +85 -0
  7. package/.claude-flow-novice/dist/mcp/lifecycle-manager.js +348 -0
  8. package/.claude-flow-novice/dist/mcp/load-balancer.js +386 -0
  9. package/.claude-flow-novice/dist/mcp/mcp-config-manager.js +1362 -0
  10. package/.claude-flow-novice/dist/mcp/mcp-server-novice-simplified.js +583 -0
  11. package/.claude-flow-novice/dist/mcp/mcp-server-novice.js +723 -0
  12. package/.claude-flow-novice/dist/mcp/mcp-server-sdk.js +649 -0
  13. package/.claude-flow-novice/dist/mcp/mcp-server.js +2256 -0
  14. package/.claude-flow-novice/dist/mcp/orchestration-integration.js +800 -0
  15. package/.claude-flow-novice/dist/mcp/performance-monitor.js +489 -0
  16. package/.claude-flow-novice/dist/mcp/protocol-manager.js +376 -0
  17. package/.claude-flow-novice/dist/mcp/router.js +220 -0
  18. package/.claude-flow-novice/dist/mcp/ruv-swarm-tools.js +671 -0
  19. package/.claude-flow-novice/dist/mcp/ruv-swarm-wrapper.js +254 -0
  20. package/.claude-flow-novice/dist/mcp/server-with-wrapper.js +32 -0
  21. package/.claude-flow-novice/dist/mcp/server-wrapper-mode.js +26 -0
  22. package/.claude-flow-novice/dist/mcp/server.js +539 -0
  23. package/.claude-flow-novice/dist/mcp/session-manager.js +338 -0
  24. package/.claude-flow-novice/dist/mcp/sparc-modes.js +455 -0
  25. package/.claude-flow-novice/dist/mcp/swarm-tools.js +903 -0
  26. package/.claude-flow-novice/dist/mcp/tools.js +426 -0
  27. package/.claude-flow-novice/dist/src/cli/commands/swarm.js +23 -1
  28. package/.claude-flow-novice/dist/src/cli/commands/swarm.js.map +1 -1
  29. package/.claude-flow-novice/dist/src/cli/simple-commands/init/templates/CLAUDE.md +40 -101
  30. package/.claude-flow-novice/dist/src/coordination/swarm-coordinator-factory.js +36 -0
  31. package/.claude-flow-novice/dist/src/coordination/swarm-coordinator-factory.js.map +1 -0
  32. package/.claude-flow-novice/dist/src/validators/index.js +12 -0
  33. package/.claude-flow-novice/dist/src/validators/index.js.map +1 -0
  34. package/.claude-flow-novice/dist/src/validators/swarm-init-validator.js +261 -0
  35. package/.claude-flow-novice/dist/src/validators/swarm-init-validator.js.map +1 -0
  36. package/.claude-flow-novice/dist/src/validators/todowrite-batching-validator.js +204 -0
  37. package/.claude-flow-novice/dist/src/validators/todowrite-batching-validator.js.map +1 -0
  38. package/.claude-flow-novice/dist/src/validators/todowrite-integration.js +189 -0
  39. package/.claude-flow-novice/dist/src/validators/todowrite-integration.js.map +1 -0
  40. package/CLAUDE.md +98 -102
  41. package/package.json +2 -2
  42. package/src/cli/simple-commands/init/templates/CLAUDE.md +4 -40
@@ -0,0 +1,1365 @@
1
+ /**
2
+ * Claude-Flow specific MCP tools
3
+ */ import { getAvailableAgentTypes } from '../constants/agent-types.js';
4
+ /**
5
+ * Enhance tool schema with dynamic agent types
6
+ */ async function enhanceToolWithAgentTypes(tool) {
7
+ const availableTypes = await getAvailableAgentTypes();
8
+ // Clone the tool to avoid modifying the original
9
+ const enhancedTool = JSON.parse(JSON.stringify(tool));
10
+ // Find and populate enum fields for agent types
11
+ function addEnumToAgentTypeFields(obj) {
12
+ if (typeof obj !== 'object' || obj === null) return;
13
+ for (const [key, value] of Object.entries(obj)){
14
+ if (typeof value === 'object' && value !== null) {
15
+ // Check if this is an agent type field
16
+ if (key === 'type' || key === 'filterByType' || key === 'assignToAgentType') {
17
+ const field = value;
18
+ if (field.type === 'string' && field.description?.includes('loaded dynamically from .claude/agents/')) {
19
+ field.enum = availableTypes;
20
+ }
21
+ }
22
+ addEnumToAgentTypeFields(value);
23
+ }
24
+ }
25
+ }
26
+ addEnumToAgentTypeFields(enhancedTool.inputSchema);
27
+ return enhancedTool;
28
+ }
29
+ /**
30
+ * Create all Claude-Flow specific MCP tools
31
+ */ export async function createClaudeFlowTools(logger) {
32
+ const tools = [
33
+ // Agent management tools
34
+ createSpawnAgentTool(logger),
35
+ createListAgentsTool(logger),
36
+ createTerminateAgentTool(logger),
37
+ createGetAgentInfoTool(logger),
38
+ // Task management tools
39
+ createCreateTaskTool(logger),
40
+ createListTasksTool(logger),
41
+ createGetTaskStatusTool(logger),
42
+ createCancelTaskTool(logger),
43
+ createAssignTaskTool(logger),
44
+ // Memory management tools
45
+ createQueryMemoryTool(logger),
46
+ createStoreMemoryTool(logger),
47
+ createDeleteMemoryTool(logger),
48
+ createExportMemoryTool(logger),
49
+ createImportMemoryTool(logger),
50
+ // System monitoring tools
51
+ createGetSystemStatusTool(logger),
52
+ createGetMetricsTool(logger),
53
+ createHealthCheckTool(logger),
54
+ // Configuration tools
55
+ createGetConfigTool(logger),
56
+ createUpdateConfigTool(logger),
57
+ createValidateConfigTool(logger),
58
+ // Workflow tools
59
+ createExecuteWorkflowTool(logger),
60
+ createCreateWorkflowTool(logger),
61
+ createListWorkflowsTool(logger),
62
+ // Terminal management tools
63
+ createExecuteCommandTool(logger),
64
+ createListTerminalsTool(logger),
65
+ createCreateTerminalTool(logger)
66
+ ];
67
+ // Enhance tools with dynamic agent types
68
+ const enhancedTools = await Promise.all(tools.map((tool)=>enhanceToolWithAgentTypes(tool)));
69
+ return enhancedTools;
70
+ }
71
+ function createSpawnAgentTool(logger) {
72
+ return {
73
+ name: 'agents/spawn',
74
+ description: 'Spawn a new Claude agent with specified configuration',
75
+ inputSchema: {
76
+ type: 'object',
77
+ properties: {
78
+ type: {
79
+ type: 'string',
80
+ // Note: enum will be populated dynamically at runtime
81
+ description: 'Type of specialized agent to spawn (loaded dynamically from .claude/agents/)'
82
+ },
83
+ name: {
84
+ type: 'string',
85
+ description: 'Display name for the agent'
86
+ },
87
+ capabilities: {
88
+ type: 'array',
89
+ items: {
90
+ type: 'string'
91
+ },
92
+ description: 'List of capabilities for the agent'
93
+ },
94
+ systemPrompt: {
95
+ type: 'string',
96
+ description: 'Custom system prompt for the agent'
97
+ },
98
+ maxConcurrentTasks: {
99
+ type: 'number',
100
+ default: 3,
101
+ description: 'Maximum number of concurrent tasks'
102
+ },
103
+ priority: {
104
+ type: 'number',
105
+ default: 5,
106
+ description: 'Agent priority level (1-10)'
107
+ },
108
+ environment: {
109
+ type: 'object',
110
+ description: 'Environment variables for the agent'
111
+ },
112
+ workingDirectory: {
113
+ type: 'string',
114
+ description: 'Working directory for the agent'
115
+ }
116
+ },
117
+ required: [
118
+ 'type',
119
+ 'name'
120
+ ]
121
+ },
122
+ handler: async (input, context)=>{
123
+ logger.info('Spawning agent', {
124
+ input,
125
+ sessionId: context?.sessionId
126
+ });
127
+ if (!context?.orchestrator) {
128
+ throw new Error('Orchestrator not available');
129
+ }
130
+ const profile = {
131
+ id: `agent_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
132
+ name: input.name,
133
+ type: input.type,
134
+ capabilities: input.capabilities || [],
135
+ systemPrompt: input.systemPrompt || getDefaultSystemPrompt(input.type),
136
+ maxConcurrentTasks: input.maxConcurrentTasks || 3,
137
+ priority: input.priority || 5,
138
+ environment: input.environment,
139
+ workingDirectory: input.workingDirectory
140
+ };
141
+ const sessionId = await context.orchestrator.spawnAgent(profile);
142
+ return {
143
+ agentId: profile.id,
144
+ sessionId,
145
+ profile,
146
+ status: 'spawned',
147
+ timestamp: new Date().toISOString()
148
+ };
149
+ }
150
+ };
151
+ }
152
+ function createListAgentsTool(logger) {
153
+ return {
154
+ name: 'agents/list',
155
+ description: 'List all active agents in the system',
156
+ inputSchema: {
157
+ type: 'object',
158
+ properties: {
159
+ includeTerminated: {
160
+ type: 'boolean',
161
+ default: false,
162
+ description: 'Include terminated agents in the list'
163
+ },
164
+ filterByType: {
165
+ type: 'string',
166
+ // Note: enum will be populated dynamically at runtime
167
+ description: 'Filter agents by type (loaded dynamically from .claude/agents/)'
168
+ }
169
+ }
170
+ },
171
+ handler: async (input, context)=>{
172
+ logger.info('Listing agents', {
173
+ input,
174
+ sessionId: context?.sessionId
175
+ });
176
+ if (!context?.orchestrator) {
177
+ throw new Error('Orchestrator not available');
178
+ }
179
+ const agents = await context.orchestrator.listAgents();
180
+ let filteredAgents = agents;
181
+ if (!input.includeTerminated) {
182
+ filteredAgents = filteredAgents.filter((agent)=>agent.status !== 'terminated');
183
+ }
184
+ if (input.filterByType) {
185
+ filteredAgents = filteredAgents.filter((agent)=>agent.type === input.filterByType);
186
+ }
187
+ return {
188
+ agents: filteredAgents,
189
+ count: filteredAgents.length,
190
+ timestamp: new Date().toISOString()
191
+ };
192
+ }
193
+ };
194
+ }
195
+ function createTerminateAgentTool(logger) {
196
+ return {
197
+ name: 'agents/terminate',
198
+ description: 'Terminate a specific agent',
199
+ inputSchema: {
200
+ type: 'object',
201
+ properties: {
202
+ agentId: {
203
+ type: 'string',
204
+ description: 'ID of the agent to terminate'
205
+ },
206
+ reason: {
207
+ type: 'string',
208
+ description: 'Reason for termination'
209
+ },
210
+ graceful: {
211
+ type: 'boolean',
212
+ default: true,
213
+ description: 'Whether to perform graceful shutdown'
214
+ }
215
+ },
216
+ required: [
217
+ 'agentId'
218
+ ]
219
+ },
220
+ handler: async (input, context)=>{
221
+ logger.info('Terminating agent', {
222
+ input,
223
+ sessionId: context?.sessionId
224
+ });
225
+ if (!context?.orchestrator) {
226
+ throw new Error('Orchestrator not available');
227
+ }
228
+ await context.orchestrator.terminateAgent(input.agentId, {
229
+ reason: input.reason || 'Manual termination',
230
+ graceful: input.graceful !== false
231
+ });
232
+ return {
233
+ agentId: input.agentId,
234
+ status: 'terminated',
235
+ reason: input.reason || 'Manual termination',
236
+ timestamp: new Date().toISOString()
237
+ };
238
+ }
239
+ };
240
+ }
241
+ function createGetAgentInfoTool(logger) {
242
+ return {
243
+ name: 'agents/info',
244
+ description: 'Get detailed information about a specific agent',
245
+ inputSchema: {
246
+ type: 'object',
247
+ properties: {
248
+ agentId: {
249
+ type: 'string',
250
+ description: 'ID of the agent'
251
+ }
252
+ },
253
+ required: [
254
+ 'agentId'
255
+ ]
256
+ },
257
+ handler: async (input, context)=>{
258
+ logger.info('Getting agent info', {
259
+ input,
260
+ sessionId: context?.sessionId
261
+ });
262
+ if (!context?.orchestrator) {
263
+ throw new Error('Orchestrator not available');
264
+ }
265
+ const agentInfo = await context.orchestrator.getAgentInfo(input.agentId);
266
+ if (!agentInfo) {
267
+ throw new Error(`Agent not found: ${input.agentId}`);
268
+ }
269
+ return {
270
+ agent: agentInfo,
271
+ timestamp: new Date().toISOString()
272
+ };
273
+ }
274
+ };
275
+ }
276
+ function createCreateTaskTool(logger) {
277
+ return {
278
+ name: 'tasks/create',
279
+ description: 'Create a new task for execution',
280
+ inputSchema: {
281
+ type: 'object',
282
+ properties: {
283
+ type: {
284
+ type: 'string',
285
+ description: 'Type of task to create'
286
+ },
287
+ description: {
288
+ type: 'string',
289
+ description: 'Description of the task'
290
+ },
291
+ priority: {
292
+ type: 'number',
293
+ default: 5,
294
+ description: 'Task priority (1-10)'
295
+ },
296
+ dependencies: {
297
+ type: 'array',
298
+ items: {
299
+ type: 'string'
300
+ },
301
+ description: 'List of task IDs this task depends on'
302
+ },
303
+ assignToAgent: {
304
+ type: 'string',
305
+ description: 'Specific agent ID to assign the task to'
306
+ },
307
+ assignToAgentType: {
308
+ type: 'string',
309
+ // Note: enum will be populated dynamically at runtime
310
+ description: 'Type of specialized agent to assign the task to (loaded dynamically from .claude/agents/)'
311
+ },
312
+ input: {
313
+ type: 'object',
314
+ description: 'Input data for the task'
315
+ },
316
+ timeout: {
317
+ type: 'number',
318
+ description: 'Task timeout in milliseconds'
319
+ }
320
+ },
321
+ required: [
322
+ 'type',
323
+ 'description'
324
+ ]
325
+ },
326
+ handler: async (input, context)=>{
327
+ logger.info('Creating task', {
328
+ input,
329
+ sessionId: context?.sessionId
330
+ });
331
+ if (!context?.orchestrator) {
332
+ throw new Error('Orchestrator not available');
333
+ }
334
+ const task = {
335
+ type: input.type,
336
+ description: input.description,
337
+ priority: input.priority || 5,
338
+ dependencies: input.dependencies || [],
339
+ input: input.input || {},
340
+ status: 'pending',
341
+ createdAt: new Date()
342
+ };
343
+ const taskId = await context.orchestrator.createTask(task);
344
+ // Handle assignment
345
+ if (input.assignToAgent) {
346
+ await context.orchestrator.assignTask(taskId, input.assignToAgent);
347
+ } else if (input.assignToAgentType) {
348
+ await context.orchestrator.assignTaskToType(taskId, input.assignToAgentType);
349
+ }
350
+ return {
351
+ taskId,
352
+ task: {
353
+ ...task,
354
+ id: taskId
355
+ },
356
+ timestamp: new Date().toISOString()
357
+ };
358
+ }
359
+ };
360
+ }
361
+ function createListTasksTool(logger) {
362
+ return {
363
+ name: 'tasks/list',
364
+ description: 'List tasks with optional filtering',
365
+ inputSchema: {
366
+ type: 'object',
367
+ properties: {
368
+ status: {
369
+ type: 'string',
370
+ enum: [
371
+ 'pending',
372
+ 'queued',
373
+ 'assigned',
374
+ 'running',
375
+ 'completed',
376
+ 'failed',
377
+ 'cancelled'
378
+ ],
379
+ description: 'Filter by task status'
380
+ },
381
+ agentId: {
382
+ type: 'string',
383
+ description: 'Filter by assigned agent ID'
384
+ },
385
+ type: {
386
+ type: 'string',
387
+ description: 'Filter by task type'
388
+ },
389
+ limit: {
390
+ type: 'number',
391
+ default: 50,
392
+ description: 'Maximum number of tasks to return'
393
+ },
394
+ offset: {
395
+ type: 'number',
396
+ default: 0,
397
+ description: 'Number of tasks to skip'
398
+ }
399
+ }
400
+ },
401
+ handler: async (input, context)=>{
402
+ logger.info('Listing tasks', {
403
+ input,
404
+ sessionId: context?.sessionId
405
+ });
406
+ if (!context?.orchestrator) {
407
+ throw new Error('Orchestrator not available');
408
+ }
409
+ const tasks = await context.orchestrator.listTasks({
410
+ status: input.status,
411
+ agentId: input.agentId,
412
+ type: input.type,
413
+ limit: input.limit || 50,
414
+ offset: input.offset || 0
415
+ });
416
+ return {
417
+ tasks,
418
+ count: tasks.length,
419
+ timestamp: new Date().toISOString()
420
+ };
421
+ }
422
+ };
423
+ }
424
+ function createGetTaskStatusTool(logger) {
425
+ return {
426
+ name: 'tasks/status',
427
+ description: 'Get detailed status of a specific task',
428
+ inputSchema: {
429
+ type: 'object',
430
+ properties: {
431
+ taskId: {
432
+ type: 'string',
433
+ description: 'ID of the task'
434
+ }
435
+ },
436
+ required: [
437
+ 'taskId'
438
+ ]
439
+ },
440
+ handler: async (input, context)=>{
441
+ logger.info('Getting task status', {
442
+ input,
443
+ sessionId: context?.sessionId
444
+ });
445
+ if (!context?.orchestrator) {
446
+ throw new Error('Orchestrator not available');
447
+ }
448
+ const task = await context.orchestrator.getTask(input.taskId);
449
+ if (!task) {
450
+ throw new Error(`Task not found: ${input.taskId}`);
451
+ }
452
+ return {
453
+ task,
454
+ timestamp: new Date().toISOString()
455
+ };
456
+ }
457
+ };
458
+ }
459
+ function createCancelTaskTool(logger) {
460
+ return {
461
+ name: 'tasks/cancel',
462
+ description: 'Cancel a pending or running task',
463
+ inputSchema: {
464
+ type: 'object',
465
+ properties: {
466
+ taskId: {
467
+ type: 'string',
468
+ description: 'ID of the task to cancel'
469
+ },
470
+ reason: {
471
+ type: 'string',
472
+ description: 'Reason for cancellation'
473
+ }
474
+ },
475
+ required: [
476
+ 'taskId'
477
+ ]
478
+ },
479
+ handler: async (input, context)=>{
480
+ logger.info('Cancelling task', {
481
+ input,
482
+ sessionId: context?.sessionId
483
+ });
484
+ if (!context?.orchestrator) {
485
+ throw new Error('Orchestrator not available');
486
+ }
487
+ await context.orchestrator.cancelTask(input.taskId, input.reason || 'Manual cancellation');
488
+ return {
489
+ taskId: input.taskId,
490
+ status: 'cancelled',
491
+ reason: input.reason || 'Manual cancellation',
492
+ timestamp: new Date().toISOString()
493
+ };
494
+ }
495
+ };
496
+ }
497
+ function createAssignTaskTool(logger) {
498
+ return {
499
+ name: 'tasks/assign',
500
+ description: 'Assign a task to a specific agent',
501
+ inputSchema: {
502
+ type: 'object',
503
+ properties: {
504
+ taskId: {
505
+ type: 'string',
506
+ description: 'ID of the task to assign'
507
+ },
508
+ agentId: {
509
+ type: 'string',
510
+ description: 'ID of the agent to assign the task to'
511
+ }
512
+ },
513
+ required: [
514
+ 'taskId',
515
+ 'agentId'
516
+ ]
517
+ },
518
+ handler: async (input, context)=>{
519
+ logger.info('Assigning task', {
520
+ input,
521
+ sessionId: context?.sessionId
522
+ });
523
+ if (!context?.orchestrator) {
524
+ throw new Error('Orchestrator not available');
525
+ }
526
+ await context.orchestrator.assignTask(input.taskId, input.agentId);
527
+ return {
528
+ taskId: input.taskId,
529
+ agentId: input.agentId,
530
+ status: 'assigned',
531
+ timestamp: new Date().toISOString()
532
+ };
533
+ }
534
+ };
535
+ }
536
+ function createQueryMemoryTool(logger) {
537
+ return {
538
+ name: 'memory/query',
539
+ description: 'Query agent memory with filters and search',
540
+ inputSchema: {
541
+ type: 'object',
542
+ properties: {
543
+ agentId: {
544
+ type: 'string',
545
+ description: 'Filter by agent ID'
546
+ },
547
+ sessionId: {
548
+ type: 'string',
549
+ description: 'Filter by session ID'
550
+ },
551
+ type: {
552
+ type: 'string',
553
+ enum: [
554
+ 'observation',
555
+ 'insight',
556
+ 'decision',
557
+ 'artifact',
558
+ 'error'
559
+ ],
560
+ description: 'Filter by entry type'
561
+ },
562
+ tags: {
563
+ type: 'array',
564
+ items: {
565
+ type: 'string'
566
+ },
567
+ description: 'Filter by tags'
568
+ },
569
+ search: {
570
+ type: 'string',
571
+ description: 'Full-text search query'
572
+ },
573
+ startTime: {
574
+ type: 'string',
575
+ format: 'date-time',
576
+ description: 'Filter entries after this time'
577
+ },
578
+ endTime: {
579
+ type: 'string',
580
+ format: 'date-time',
581
+ description: 'Filter entries before this time'
582
+ },
583
+ limit: {
584
+ type: 'number',
585
+ default: 50,
586
+ description: 'Maximum number of entries to return'
587
+ },
588
+ offset: {
589
+ type: 'number',
590
+ default: 0,
591
+ description: 'Number of entries to skip'
592
+ }
593
+ }
594
+ },
595
+ handler: async (input, context)=>{
596
+ logger.info('Querying memory', {
597
+ input,
598
+ sessionId: context?.sessionId
599
+ });
600
+ if (!context?.orchestrator) {
601
+ throw new Error('Orchestrator not available');
602
+ }
603
+ const query = {
604
+ agentId: input.agentId,
605
+ sessionId: input.sessionId,
606
+ type: input.type,
607
+ tags: input.tags,
608
+ search: input.search,
609
+ startTime: input.startTime ? new Date(input.startTime) : undefined,
610
+ endTime: input.endTime ? new Date(input.endTime) : undefined,
611
+ limit: input.limit || 50,
612
+ offset: input.offset || 0
613
+ };
614
+ const entries = await context.orchestrator.queryMemory(query);
615
+ return {
616
+ entries,
617
+ count: entries.length,
618
+ query,
619
+ timestamp: new Date().toISOString()
620
+ };
621
+ }
622
+ };
623
+ }
624
+ function createStoreMemoryTool(logger) {
625
+ return {
626
+ name: 'memory/store',
627
+ description: 'Store a new memory entry',
628
+ inputSchema: {
629
+ type: 'object',
630
+ properties: {
631
+ agentId: {
632
+ type: 'string',
633
+ description: 'Agent ID for the memory entry'
634
+ },
635
+ sessionId: {
636
+ type: 'string',
637
+ description: 'Session ID for the memory entry'
638
+ },
639
+ type: {
640
+ type: 'string',
641
+ enum: [
642
+ 'observation',
643
+ 'insight',
644
+ 'decision',
645
+ 'artifact',
646
+ 'error'
647
+ ],
648
+ description: 'Type of memory entry'
649
+ },
650
+ content: {
651
+ type: 'string',
652
+ description: 'Content of the memory entry'
653
+ },
654
+ context: {
655
+ type: 'object',
656
+ description: 'Context data for the memory entry'
657
+ },
658
+ tags: {
659
+ type: 'array',
660
+ items: {
661
+ type: 'string'
662
+ },
663
+ description: 'Tags for the memory entry'
664
+ },
665
+ parentId: {
666
+ type: 'string',
667
+ description: 'Parent memory entry ID'
668
+ }
669
+ },
670
+ required: [
671
+ 'agentId',
672
+ 'sessionId',
673
+ 'type',
674
+ 'content'
675
+ ]
676
+ },
677
+ handler: async (input, context)=>{
678
+ logger.info('Storing memory', {
679
+ input,
680
+ sessionId: context?.sessionId
681
+ });
682
+ if (!context?.orchestrator) {
683
+ throw new Error('Orchestrator not available');
684
+ }
685
+ const entry = {
686
+ agentId: input.agentId,
687
+ sessionId: input.sessionId,
688
+ type: input.type,
689
+ content: input.content,
690
+ context: input.context || {},
691
+ tags: input.tags || [],
692
+ parentId: input.parentId,
693
+ timestamp: new Date(),
694
+ version: 1
695
+ };
696
+ const entryId = await context.orchestrator.storeMemory(entry);
697
+ return {
698
+ entryId,
699
+ entry: {
700
+ ...entry,
701
+ id: entryId
702
+ },
703
+ timestamp: new Date().toISOString()
704
+ };
705
+ }
706
+ };
707
+ }
708
+ function createDeleteMemoryTool(logger) {
709
+ return {
710
+ name: 'memory/delete',
711
+ description: 'Delete a memory entry',
712
+ inputSchema: {
713
+ type: 'object',
714
+ properties: {
715
+ entryId: {
716
+ type: 'string',
717
+ description: 'ID of the memory entry to delete'
718
+ }
719
+ },
720
+ required: [
721
+ 'entryId'
722
+ ]
723
+ },
724
+ handler: async (input, context)=>{
725
+ logger.info('Deleting memory', {
726
+ input,
727
+ sessionId: context?.sessionId
728
+ });
729
+ if (!context?.orchestrator) {
730
+ throw new Error('Orchestrator not available');
731
+ }
732
+ await context.orchestrator.deleteMemory(input.entryId);
733
+ return {
734
+ entryId: input.entryId,
735
+ status: 'deleted',
736
+ timestamp: new Date().toISOString()
737
+ };
738
+ }
739
+ };
740
+ }
741
+ function createExportMemoryTool(logger) {
742
+ return {
743
+ name: 'memory/export',
744
+ description: 'Export memory entries to a file',
745
+ inputSchema: {
746
+ type: 'object',
747
+ properties: {
748
+ format: {
749
+ type: 'string',
750
+ enum: [
751
+ 'json',
752
+ 'csv',
753
+ 'markdown'
754
+ ],
755
+ default: 'json',
756
+ description: 'Export format'
757
+ },
758
+ agentId: {
759
+ type: 'string',
760
+ description: 'Filter by agent ID'
761
+ },
762
+ sessionId: {
763
+ type: 'string',
764
+ description: 'Filter by session ID'
765
+ },
766
+ startTime: {
767
+ type: 'string',
768
+ format: 'date-time',
769
+ description: 'Export entries after this time'
770
+ },
771
+ endTime: {
772
+ type: 'string',
773
+ format: 'date-time',
774
+ description: 'Export entries before this time'
775
+ }
776
+ }
777
+ },
778
+ handler: async (input, context)=>{
779
+ logger.info('Exporting memory', {
780
+ input,
781
+ sessionId: context?.sessionId
782
+ });
783
+ if (!context?.orchestrator) {
784
+ throw new Error('Orchestrator not available');
785
+ }
786
+ const exportResult = await context.orchestrator.exportMemory({
787
+ format: input.format || 'json',
788
+ agentId: input.agentId,
789
+ sessionId: input.sessionId,
790
+ startTime: input.startTime ? new Date(input.startTime) : undefined,
791
+ endTime: input.endTime ? new Date(input.endTime) : undefined
792
+ });
793
+ return {
794
+ ...exportResult,
795
+ timestamp: new Date().toISOString()
796
+ };
797
+ }
798
+ };
799
+ }
800
+ function createImportMemoryTool(logger) {
801
+ return {
802
+ name: 'memory/import',
803
+ description: 'Import memory entries from a file',
804
+ inputSchema: {
805
+ type: 'object',
806
+ properties: {
807
+ filePath: {
808
+ type: 'string',
809
+ description: 'Path to the file to import'
810
+ },
811
+ format: {
812
+ type: 'string',
813
+ enum: [
814
+ 'json',
815
+ 'csv'
816
+ ],
817
+ default: 'json',
818
+ description: 'Import format'
819
+ },
820
+ mergeStrategy: {
821
+ type: 'string',
822
+ enum: [
823
+ 'skip',
824
+ 'overwrite',
825
+ 'version'
826
+ ],
827
+ default: 'skip',
828
+ description: 'Strategy for handling duplicate entries'
829
+ }
830
+ },
831
+ required: [
832
+ 'filePath'
833
+ ]
834
+ },
835
+ handler: async (input, context)=>{
836
+ logger.info('Importing memory', {
837
+ input,
838
+ sessionId: context?.sessionId
839
+ });
840
+ if (!context?.orchestrator) {
841
+ throw new Error('Orchestrator not available');
842
+ }
843
+ const importResult = await context.orchestrator.importMemory({
844
+ filePath: input.filePath,
845
+ format: input.format || 'json',
846
+ mergeStrategy: input.mergeStrategy || 'skip'
847
+ });
848
+ return {
849
+ ...importResult,
850
+ timestamp: new Date().toISOString()
851
+ };
852
+ }
853
+ };
854
+ }
855
+ function createGetSystemStatusTool(logger) {
856
+ return {
857
+ name: 'system/status',
858
+ description: 'Get comprehensive system status information',
859
+ inputSchema: {
860
+ type: 'object',
861
+ properties: {}
862
+ },
863
+ handler: async (input, context)=>{
864
+ logger.info('Getting system status', {
865
+ sessionId: context?.sessionId
866
+ });
867
+ if (!context?.orchestrator) {
868
+ throw new Error('Orchestrator not available');
869
+ }
870
+ const status = await context.orchestrator.getSystemStatus();
871
+ return {
872
+ ...status,
873
+ timestamp: new Date().toISOString()
874
+ };
875
+ }
876
+ };
877
+ }
878
+ function createGetMetricsTool(logger) {
879
+ return {
880
+ name: 'system/metrics',
881
+ description: 'Get system performance metrics',
882
+ inputSchema: {
883
+ type: 'object',
884
+ properties: {
885
+ timeRange: {
886
+ type: 'string',
887
+ enum: [
888
+ '1h',
889
+ '6h',
890
+ '24h',
891
+ '7d'
892
+ ],
893
+ default: '1h',
894
+ description: 'Time range for metrics'
895
+ }
896
+ }
897
+ },
898
+ handler: async (input, context)=>{
899
+ logger.info('Getting system metrics', {
900
+ input,
901
+ sessionId: context?.sessionId
902
+ });
903
+ if (!context?.orchestrator) {
904
+ throw new Error('Orchestrator not available');
905
+ }
906
+ const metrics = await context.orchestrator.getMetrics(input.timeRange || '1h');
907
+ return {
908
+ metrics,
909
+ timeRange: input.timeRange || '1h',
910
+ timestamp: new Date().toISOString()
911
+ };
912
+ }
913
+ };
914
+ }
915
+ function createHealthCheckTool(logger) {
916
+ return {
917
+ name: 'system/health',
918
+ description: 'Perform a comprehensive health check',
919
+ inputSchema: {
920
+ type: 'object',
921
+ properties: {
922
+ deep: {
923
+ type: 'boolean',
924
+ default: false,
925
+ description: 'Perform deep health check including component tests'
926
+ }
927
+ }
928
+ },
929
+ handler: async (input, context)=>{
930
+ logger.info('Performing health check', {
931
+ input,
932
+ sessionId: context?.sessionId
933
+ });
934
+ if (!context?.orchestrator) {
935
+ throw new Error('Orchestrator not available');
936
+ }
937
+ const healthCheck = await context.orchestrator.performHealthCheck(input.deep || false);
938
+ return {
939
+ ...healthCheck,
940
+ timestamp: new Date().toISOString()
941
+ };
942
+ }
943
+ };
944
+ }
945
+ function createGetConfigTool(logger) {
946
+ return {
947
+ name: 'config/get',
948
+ description: 'Get current system configuration',
949
+ inputSchema: {
950
+ type: 'object',
951
+ properties: {
952
+ section: {
953
+ type: 'string',
954
+ enum: [
955
+ 'orchestrator',
956
+ 'terminal',
957
+ 'memory',
958
+ 'coordination',
959
+ 'mcp',
960
+ 'logging'
961
+ ],
962
+ description: 'Specific configuration section to retrieve'
963
+ }
964
+ }
965
+ },
966
+ handler: async (input, context)=>{
967
+ logger.info('Getting configuration', {
968
+ input,
969
+ sessionId: context?.sessionId
970
+ });
971
+ if (!context?.orchestrator) {
972
+ throw new Error('Orchestrator not available');
973
+ }
974
+ const config = await context.orchestrator.getConfig(input.section);
975
+ return {
976
+ config,
977
+ section: input.section,
978
+ timestamp: new Date().toISOString()
979
+ };
980
+ }
981
+ };
982
+ }
983
+ function createUpdateConfigTool(logger) {
984
+ return {
985
+ name: 'config/update',
986
+ description: 'Update system configuration',
987
+ inputSchema: {
988
+ type: 'object',
989
+ properties: {
990
+ section: {
991
+ type: 'string',
992
+ enum: [
993
+ 'orchestrator',
994
+ 'terminal',
995
+ 'memory',
996
+ 'coordination',
997
+ 'mcp',
998
+ 'logging'
999
+ ],
1000
+ description: 'Configuration section to update'
1001
+ },
1002
+ config: {
1003
+ type: 'object',
1004
+ description: 'Configuration values to update'
1005
+ },
1006
+ restart: {
1007
+ type: 'boolean',
1008
+ default: false,
1009
+ description: 'Restart affected components after update'
1010
+ }
1011
+ },
1012
+ required: [
1013
+ 'section',
1014
+ 'config'
1015
+ ]
1016
+ },
1017
+ handler: async (input, context)=>{
1018
+ logger.info('Updating configuration', {
1019
+ input,
1020
+ sessionId: context?.sessionId
1021
+ });
1022
+ if (!context?.orchestrator) {
1023
+ throw new Error('Orchestrator not available');
1024
+ }
1025
+ const result = await context.orchestrator.updateConfig(input.section, input.config, input.restart || false);
1026
+ return {
1027
+ ...result,
1028
+ timestamp: new Date().toISOString()
1029
+ };
1030
+ }
1031
+ };
1032
+ }
1033
+ function createValidateConfigTool(logger) {
1034
+ return {
1035
+ name: 'config/validate',
1036
+ description: 'Validate a configuration object',
1037
+ inputSchema: {
1038
+ type: 'object',
1039
+ properties: {
1040
+ config: {
1041
+ type: 'object',
1042
+ description: 'Configuration object to validate'
1043
+ }
1044
+ },
1045
+ required: [
1046
+ 'config'
1047
+ ]
1048
+ },
1049
+ handler: async (input, context)=>{
1050
+ logger.info('Validating configuration', {
1051
+ input,
1052
+ sessionId: context?.sessionId
1053
+ });
1054
+ if (!context?.orchestrator) {
1055
+ throw new Error('Orchestrator not available');
1056
+ }
1057
+ const validation = await context.orchestrator.validateConfig(input.config);
1058
+ return {
1059
+ ...validation,
1060
+ timestamp: new Date().toISOString()
1061
+ };
1062
+ }
1063
+ };
1064
+ }
1065
+ function createExecuteWorkflowTool(logger) {
1066
+ return {
1067
+ name: 'workflow/execute',
1068
+ description: 'Execute a workflow from a file or definition',
1069
+ inputSchema: {
1070
+ type: 'object',
1071
+ properties: {
1072
+ filePath: {
1073
+ type: 'string',
1074
+ description: 'Path to workflow file'
1075
+ },
1076
+ workflow: {
1077
+ type: 'object',
1078
+ description: 'Inline workflow definition'
1079
+ },
1080
+ parameters: {
1081
+ type: 'object',
1082
+ description: 'Parameters to pass to the workflow'
1083
+ }
1084
+ }
1085
+ },
1086
+ handler: async (input, context)=>{
1087
+ logger.info('Executing workflow', {
1088
+ input,
1089
+ sessionId: context?.sessionId
1090
+ });
1091
+ if (!context?.orchestrator) {
1092
+ throw new Error('Orchestrator not available');
1093
+ }
1094
+ if (!input.filePath && !input.workflow) {
1095
+ throw new Error('Either filePath or workflow must be provided');
1096
+ }
1097
+ const result = await context.orchestrator.executeWorkflow({
1098
+ filePath: input.filePath,
1099
+ workflow: input.workflow,
1100
+ parameters: input.parameters || {}
1101
+ });
1102
+ return {
1103
+ ...result,
1104
+ timestamp: new Date().toISOString()
1105
+ };
1106
+ }
1107
+ };
1108
+ }
1109
+ function createCreateWorkflowTool(logger) {
1110
+ return {
1111
+ name: 'workflow/create',
1112
+ description: 'Create a new workflow definition',
1113
+ inputSchema: {
1114
+ type: 'object',
1115
+ properties: {
1116
+ name: {
1117
+ type: 'string',
1118
+ description: 'Name of the workflow'
1119
+ },
1120
+ description: {
1121
+ type: 'string',
1122
+ description: 'Description of the workflow'
1123
+ },
1124
+ tasks: {
1125
+ type: 'array',
1126
+ items: {
1127
+ type: 'object',
1128
+ properties: {
1129
+ id: {
1130
+ type: 'string'
1131
+ },
1132
+ type: {
1133
+ type: 'string'
1134
+ },
1135
+ description: {
1136
+ type: 'string'
1137
+ },
1138
+ dependencies: {
1139
+ type: 'array',
1140
+ items: {
1141
+ type: 'string'
1142
+ }
1143
+ },
1144
+ assignTo: {
1145
+ type: 'string'
1146
+ }
1147
+ },
1148
+ required: [
1149
+ 'id',
1150
+ 'type',
1151
+ 'description'
1152
+ ]
1153
+ },
1154
+ description: 'List of tasks in the workflow'
1155
+ },
1156
+ savePath: {
1157
+ type: 'string',
1158
+ description: 'Path to save the workflow file'
1159
+ }
1160
+ },
1161
+ required: [
1162
+ 'name',
1163
+ 'tasks'
1164
+ ]
1165
+ },
1166
+ handler: async (input, context)=>{
1167
+ logger.info('Creating workflow', {
1168
+ input,
1169
+ sessionId: context?.sessionId
1170
+ });
1171
+ if (!context?.orchestrator) {
1172
+ throw new Error('Orchestrator not available');
1173
+ }
1174
+ const workflow = {
1175
+ name: input.name,
1176
+ description: input.description,
1177
+ tasks: input.tasks,
1178
+ created: new Date().toISOString()
1179
+ };
1180
+ const result = await context.orchestrator.createWorkflow(workflow, input.savePath);
1181
+ return {
1182
+ ...result,
1183
+ workflow,
1184
+ timestamp: new Date().toISOString()
1185
+ };
1186
+ }
1187
+ };
1188
+ }
1189
+ function createListWorkflowsTool(logger) {
1190
+ return {
1191
+ name: 'workflow/list',
1192
+ description: 'List available workflows',
1193
+ inputSchema: {
1194
+ type: 'object',
1195
+ properties: {
1196
+ directory: {
1197
+ type: 'string',
1198
+ description: 'Directory to search for workflows'
1199
+ }
1200
+ }
1201
+ },
1202
+ handler: async (input, context)=>{
1203
+ logger.info('Listing workflows', {
1204
+ input,
1205
+ sessionId: context?.sessionId
1206
+ });
1207
+ if (!context?.orchestrator) {
1208
+ throw new Error('Orchestrator not available');
1209
+ }
1210
+ const workflows = await context.orchestrator.listWorkflows(input.directory);
1211
+ return {
1212
+ workflows,
1213
+ count: workflows.length,
1214
+ timestamp: new Date().toISOString()
1215
+ };
1216
+ }
1217
+ };
1218
+ }
1219
+ function createExecuteCommandTool(logger) {
1220
+ return {
1221
+ name: 'terminal/execute',
1222
+ description: 'Execute a command in a terminal session',
1223
+ inputSchema: {
1224
+ type: 'object',
1225
+ properties: {
1226
+ command: {
1227
+ type: 'string',
1228
+ description: 'Command to execute'
1229
+ },
1230
+ args: {
1231
+ type: 'array',
1232
+ items: {
1233
+ type: 'string'
1234
+ },
1235
+ description: 'Command arguments'
1236
+ },
1237
+ cwd: {
1238
+ type: 'string',
1239
+ description: 'Working directory for the command'
1240
+ },
1241
+ env: {
1242
+ type: 'object',
1243
+ description: 'Environment variables'
1244
+ },
1245
+ timeout: {
1246
+ type: 'number',
1247
+ default: 30000,
1248
+ description: 'Command timeout in milliseconds'
1249
+ },
1250
+ terminalId: {
1251
+ type: 'string',
1252
+ description: 'Specific terminal ID to use'
1253
+ }
1254
+ },
1255
+ required: [
1256
+ 'command'
1257
+ ]
1258
+ },
1259
+ handler: async (input, context)=>{
1260
+ logger.info('Executing command', {
1261
+ input,
1262
+ sessionId: context?.sessionId
1263
+ });
1264
+ if (!context?.orchestrator) {
1265
+ throw new Error('Orchestrator not available');
1266
+ }
1267
+ const result = await context.orchestrator.executeCommand({
1268
+ command: input.command,
1269
+ args: input.args,
1270
+ cwd: input.cwd,
1271
+ env: input.env,
1272
+ timeout: input.timeout || 30000,
1273
+ terminalId: input.terminalId
1274
+ });
1275
+ return {
1276
+ ...result,
1277
+ timestamp: new Date().toISOString()
1278
+ };
1279
+ }
1280
+ };
1281
+ }
1282
+ function createListTerminalsTool(logger) {
1283
+ return {
1284
+ name: 'terminal/list',
1285
+ description: 'List all terminal sessions',
1286
+ inputSchema: {
1287
+ type: 'object',
1288
+ properties: {
1289
+ includeIdle: {
1290
+ type: 'boolean',
1291
+ default: true,
1292
+ description: 'Include idle terminals'
1293
+ }
1294
+ }
1295
+ },
1296
+ handler: async (input, context)=>{
1297
+ logger.info('Listing terminals', {
1298
+ input,
1299
+ sessionId: context?.sessionId
1300
+ });
1301
+ if (!context?.orchestrator) {
1302
+ throw new Error('Orchestrator not available');
1303
+ }
1304
+ const terminals = await context.orchestrator.listTerminals(input.includeIdle !== false);
1305
+ return {
1306
+ terminals,
1307
+ count: terminals.length,
1308
+ timestamp: new Date().toISOString()
1309
+ };
1310
+ }
1311
+ };
1312
+ }
1313
+ function createCreateTerminalTool(logger) {
1314
+ return {
1315
+ name: 'terminal/create',
1316
+ description: 'Create a new terminal session',
1317
+ inputSchema: {
1318
+ type: 'object',
1319
+ properties: {
1320
+ cwd: {
1321
+ type: 'string',
1322
+ description: 'Working directory for the terminal'
1323
+ },
1324
+ env: {
1325
+ type: 'object',
1326
+ description: 'Environment variables'
1327
+ },
1328
+ shell: {
1329
+ type: 'string',
1330
+ description: 'Shell to use (bash, zsh, etc.)'
1331
+ }
1332
+ }
1333
+ },
1334
+ handler: async (input, context)=>{
1335
+ logger.info('Creating terminal', {
1336
+ input,
1337
+ sessionId: context?.sessionId
1338
+ });
1339
+ if (!context?.orchestrator) {
1340
+ throw new Error('Orchestrator not available');
1341
+ }
1342
+ const terminal = await context.orchestrator.createTerminal({
1343
+ cwd: input.cwd,
1344
+ env: input.env,
1345
+ shell: input.shell
1346
+ });
1347
+ return {
1348
+ terminal,
1349
+ timestamp: new Date().toISOString()
1350
+ };
1351
+ }
1352
+ };
1353
+ }
1354
+ function getDefaultSystemPrompt(type) {
1355
+ const prompts = {
1356
+ coordinator: 'You are a coordinator agent responsible for planning, delegating, and orchestrating tasks across multiple agents.',
1357
+ researcher: 'You are a research agent specialized in gathering, analyzing, and synthesizing information from various sources.',
1358
+ implementer: 'You are an implementation agent focused on writing code, creating solutions, and executing technical tasks.',
1359
+ analyst: 'You are an analysis agent that identifies patterns, generates insights, and provides data-driven recommendations.',
1360
+ custom: 'You are a specialized agent with custom capabilities defined by your configuration.'
1361
+ };
1362
+ return prompts[type] || prompts.custom;
1363
+ }
1364
+
1365
+ //# sourceMappingURL=claude-flow-tools.js.map