claude-flow-novice 2.15.8 → 2.15.10

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 (66) hide show
  1. package/.claude/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +519 -0
  2. package/.claude/skills/cfn-loop-orchestration/ORCHESTRATOR_IMPLEMENTATION.md +493 -0
  3. package/.claude/skills/cfn-loop-orchestration/ORCHESTRATOR_QUICK_START.md +499 -0
  4. package/.claude/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +104 -0
  5. package/.claude/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +123 -0
  6. package/.claude/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +89 -0
  7. package/.claude/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +104 -0
  8. package/.claude/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +47 -0
  9. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +2 -2
  10. package/.claude/skills/cfn-loop-orchestration/src/orchestrate.ts +648 -0
  11. package/.claude/skills/cfn-loop-orchestration/tests/orchestrate.test.ts +836 -0
  12. package/.claude/skills/cfn-redis-coordination/report-completion.sh +55 -10
  13. package/.claude/skills/cfn-redis-coordination/store-context.sh +31 -1
  14. package/README.md +205 -10
  15. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +6 -1
  16. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +180 -229
  17. package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +6 -1
  18. package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +6 -1
  19. package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +6 -1
  20. package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +20 -8
  21. package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +20 -8
  22. package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +20 -9
  23. package/claude-assets/agents/cfn-dev-team/developers/backend-developer.md +17 -7
  24. package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +3 -0
  25. package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +4 -1
  26. package/claude-assets/agents/cfn-dev-team/developers/frontend/react-frontend-engineer.md +4 -1
  27. package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +4 -1
  28. package/claude-assets/agents/cfn-dev-team/developers/frontend/ui-designer.md +5 -0
  29. package/claude-assets/agents/cfn-dev-team/developers/graphql-specialist.md +19 -9
  30. package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +20 -9
  31. package/claude-assets/agents/cfn-dev-team/documentation/pseudocode.md +2 -7
  32. package/claude-assets/agents/cfn-dev-team/reviewers/code-reviewer.md +9 -5
  33. package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +13 -6
  34. package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +13 -6
  35. package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +13 -6
  36. package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +15 -5
  37. package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +9 -5
  38. package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +8 -4
  39. package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +16 -13
  40. package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +9 -5
  41. package/claude-assets/agents/cfn-dev-team/testers/tester.md +9 -5
  42. package/claude-assets/agents/cfn-dev-team/utility/epic-creator.md +16 -9
  43. package/claude-assets/agents/cfn-dev-team/utility/memory-leak-specialist.md +16 -9
  44. package/claude-assets/agents/cfn-dev-team/utility/z-ai-specialist.md +16 -9
  45. package/claude-assets/skills/cfn-loop-orchestration/IMPLEMENTATION_SUMMARY.md +519 -0
  46. package/claude-assets/skills/cfn-loop-orchestration/ORCHESTRATOR_IMPLEMENTATION.md +493 -0
  47. package/claude-assets/skills/cfn-loop-orchestration/ORCHESTRATOR_QUICK_START.md +499 -0
  48. package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus-ts.sh +104 -0
  49. package/claude-assets/skills/cfn-loop-orchestration/helpers/deliverable-verifier-ts.sh +123 -0
  50. package/claude-assets/skills/cfn-loop-orchestration/helpers/iteration-manager-ts.sh +89 -0
  51. package/claude-assets/skills/cfn-loop-orchestration/helpers/orchestrate-ts.sh +104 -0
  52. package/claude-assets/skills/cfn-loop-orchestration/helpers/timeout-calculator-ts.sh +47 -0
  53. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +2 -2
  54. package/claude-assets/skills/cfn-loop-orchestration/src/orchestrate.ts +648 -0
  55. package/claude-assets/skills/cfn-loop-orchestration/tests/orchestrate.test.ts +836 -0
  56. package/claude-assets/skills/cfn-redis-coordination/report-completion.sh +55 -10
  57. package/claude-assets/skills/cfn-redis-coordination/store-context.sh +31 -1
  58. package/dist/cli/config-manager.js +91 -109
  59. package/dist/cli/config-manager.js.map +1 -1
  60. package/dist/coordination/coordinate.js +369 -0
  61. package/dist/coordination/coordinate.js.map +1 -0
  62. package/dist/coordination/spawn-agent.js +364 -0
  63. package/dist/coordination/spawn-agent.js.map +1 -0
  64. package/dist/coordination/types-export.js +38 -0
  65. package/dist/coordination/types-export.js.map +1 -0
  66. package/package.json +1 -1
@@ -0,0 +1,364 @@
1
+ /**
2
+ * Agent Spawning Abstraction Layer
3
+ *
4
+ * Provides unified interface for spawning agents in both Task Mode and CLI Mode.
5
+ * Abstracts away the complexity of determining spawn method and managing processes.
6
+ *
7
+ * Key Features:
8
+ * - Automatic mode detection (Task vs CLI)
9
+ * - Process management and cleanup
10
+ * - Error handling and retry logic
11
+ * - Process PID tracking
12
+ * - Wait for agent completion
13
+ * - Resource limits and timeouts
14
+ */ import { spawn } from 'child_process';
15
+ import { EventEmitter } from 'events';
16
+ import { CoordinationError, CoordinationErrorType } from './types-export';
17
+ /**
18
+ * Agent Spawner
19
+ *
20
+ * Creates and manages agent processes with support for both Task and CLI modes.
21
+ *
22
+ * Task Mode: Spawns via npx CLI (no Redis coordination)
23
+ * CLI Mode: Spawns via npx CLI with Redis coordination environment variables
24
+ */ export class AgentSpawner extends EventEmitter {
25
+ logger;
26
+ executionMode;
27
+ canUseRedis;
28
+ projectRoot;
29
+ dockerEnabled;
30
+ // Track running agents
31
+ processes = new Map();
32
+ constructor(config){
33
+ super();
34
+ this.logger = config.logger;
35
+ this.executionMode = config.executionMode;
36
+ this.canUseRedis = config.canUseRedis;
37
+ this.projectRoot = config.projectRoot || process.cwd();
38
+ this.dockerEnabled = config.dockerEnabled ?? false;
39
+ }
40
+ /**
41
+ * Spawn an agent (auto-detects mode)
42
+ *
43
+ * Automatically selects appropriate spawn method based on execution mode.
44
+ */ async spawnAgent(config) {
45
+ if (this.executionMode === 'cli' || this.executionMode === 'unknown') {
46
+ // Try CLI mode first
47
+ return this.spawnCLIAgent(config);
48
+ } else {
49
+ // Task mode: Still spawn via CLI but without Redis
50
+ return this.spawnTaskAgent(config);
51
+ }
52
+ }
53
+ /**
54
+ * Spawn agent in CLI mode
55
+ *
56
+ * Spawns via npx with TASK_ID and AGENT_ID for Redis coordination.
57
+ */ async spawnCLIAgent(config) {
58
+ if (!this.canUseRedis && this.executionMode !== 'unknown') {
59
+ // In true CLI mode but Redis unavailable
60
+ this.logger.warn('CLI Mode but Redis unavailable - spawning without coordination');
61
+ }
62
+ const args = [
63
+ 'claude-flow-novice',
64
+ 'agent',
65
+ config.agentType,
66
+ '--task-id',
67
+ config.taskId,
68
+ '--agent-id',
69
+ config.agentId
70
+ ];
71
+ if (config.iteration !== undefined) {
72
+ args.push('--iteration', config.iteration.toString());
73
+ }
74
+ if (config.context) {
75
+ args.push('--context', JSON.stringify(config.context));
76
+ }
77
+ // Build environment
78
+ const env = {
79
+ ...process.env,
80
+ TASK_ID: config.taskId,
81
+ AGENT_ID: config.agentId,
82
+ CFN_MODE: 'cli',
83
+ ...config.environment || {}
84
+ };
85
+ // Add Redis connection info if available
86
+ if (this.canUseRedis) {
87
+ const redisHost = process.env.REDIS_HOST || 'localhost';
88
+ const redisPort = process.env.REDIS_PORT || '6379';
89
+ const redisPassword = process.env.REDIS_PASSWORD || process.env.CFN_REDIS_PASSWORD;
90
+ env.REDIS_HOST = redisHost;
91
+ env.REDIS_PORT = redisPort;
92
+ if (redisPassword) {
93
+ env.REDIS_PASSWORD = redisPassword;
94
+ }
95
+ }
96
+ return this._spawnProcess(config, args, env, 'cli');
97
+ }
98
+ /**
99
+ * Spawn agent in Task mode
100
+ *
101
+ * Spawns via npx without Task/Agent IDs for Main Chat execution.
102
+ */ async spawnTaskAgent(config) {
103
+ const args = [
104
+ 'claude-flow-novice',
105
+ 'agent',
106
+ config.agentType
107
+ ];
108
+ // In Task Mode, don't pass TASK_ID/AGENT_ID (Main Chat doesn't know about them)
109
+ if (config.context) {
110
+ args.push('--context', JSON.stringify(config.context));
111
+ }
112
+ // Build environment without TASK_ID/AGENT_ID
113
+ const env = {
114
+ ...process.env,
115
+ CFN_MODE: 'task',
116
+ ...config.environment || {}
117
+ };
118
+ // Remove Redis connection in Task Mode
119
+ delete env.TASK_ID;
120
+ delete env.AGENT_ID;
121
+ delete env.REDIS_HOST;
122
+ delete env.REDIS_PORT;
123
+ delete env.REDIS_PASSWORD;
124
+ return this._spawnProcess(config, args, env, 'task');
125
+ }
126
+ /**
127
+ * Internal: Spawn process with retry logic
128
+ *
129
+ * Handles actual process spawning with error handling and retries.
130
+ */ async _spawnProcess(config, args, env, mode) {
131
+ const maxRetries = config.maxRetries ?? 1;
132
+ let lastError = null;
133
+ for(let attempt = 1; attempt <= maxRetries; attempt++){
134
+ try {
135
+ // Spawn the process
136
+ const spawnOptions = {
137
+ stdio: [
138
+ 'ignore',
139
+ 'pipe',
140
+ 'pipe'
141
+ ],
142
+ env,
143
+ detached: true,
144
+ timeout: config.timeoutMs ?? 600000
145
+ };
146
+ this.logger.debug(`Spawning agent ${config.agentId} (attempt ${attempt}/${maxRetries})`);
147
+ const process1 = spawn('npx', args, spawnOptions);
148
+ const pid = process1.pid || null;
149
+ const processInfo = {
150
+ agentId: config.agentId,
151
+ agentType: config.agentType,
152
+ taskId: config.taskId,
153
+ pid,
154
+ mode,
155
+ process: process1,
156
+ startedAt: new Date().toISOString(),
157
+ exitCode: null,
158
+ signal: null,
159
+ killed: false
160
+ };
161
+ // Track process
162
+ this.processes.set(config.agentId, processInfo);
163
+ // Attach event handlers
164
+ this._attachProcessHandlers(processInfo);
165
+ this.logger.info(`Spawned agent ${config.agentId} (PID: ${pid || 'unknown'}, mode: ${mode})`);
166
+ this.emit('agent-spawned', processInfo);
167
+ return processInfo;
168
+ } catch (error) {
169
+ lastError = error;
170
+ if (attempt < maxRetries) {
171
+ // Wait before retry (exponential backoff)
172
+ const delayMs = Math.min(1000 * Math.pow(2, attempt - 1), 10000);
173
+ this.logger.warn(`Failed to spawn agent ${config.agentId} (attempt ${attempt}/${maxRetries}), retrying in ${delayMs}ms...`);
174
+ await new Promise((resolve)=>setTimeout(resolve, delayMs));
175
+ }
176
+ }
177
+ }
178
+ throw new CoordinationError(CoordinationErrorType.AGENT_SPAWN_ERROR, `Failed to spawn agent ${config.agentId} after ${maxRetries} attempts: ${lastError?.message}`, mode, true // Retryable
179
+ );
180
+ }
181
+ /**
182
+ * Attach process event handlers
183
+ *
184
+ * Monitors process lifecycle and emits events.
185
+ */ _attachProcessHandlers(processInfo) {
186
+ const { process: process1, agentId } = processInfo;
187
+ if (!process1) return;
188
+ // Handle process exit
189
+ process1.on('exit', (code, signal)=>{
190
+ processInfo.exitCode = code;
191
+ processInfo.signal = signal;
192
+ this.logger.info(`Agent ${agentId} exited with code ${code}${signal ? ` (signal: ${signal})` : ''}`);
193
+ this.emit('agent-exit', processInfo);
194
+ });
195
+ // Handle process errors
196
+ process1.on('error', (error)=>{
197
+ this.logger.error(`Agent ${agentId} process error`, error);
198
+ this.emit('agent-error', {
199
+ agentId,
200
+ error
201
+ });
202
+ });
203
+ // Handle stdout/stderr
204
+ process1.stdout?.on('data', (data)=>{
205
+ this.logger.debug(`Agent ${agentId} stdout:`, data.toString());
206
+ });
207
+ process1.stderr?.on('data', (data)=>{
208
+ this.logger.debug(`Agent ${agentId} stderr:`, data.toString());
209
+ });
210
+ }
211
+ /**
212
+ * Kill an agent process
213
+ *
214
+ * Forcefully terminates an agent and cleanup.
215
+ */ async killAgent(agentId, signal = 'SIGTERM') {
216
+ const processInfo = this.processes.get(agentId);
217
+ if (!processInfo || !processInfo.process || !processInfo.pid) {
218
+ this.logger.warn(`Cannot kill agent ${agentId}: not found or no PID`);
219
+ return;
220
+ }
221
+ try {
222
+ // Kill the process group (not just the process)
223
+ process.kill(-processInfo.pid, signal);
224
+ processInfo.killed = true;
225
+ this.logger.info(`Killed agent ${agentId} (PID: ${processInfo.pid}, signal: ${signal})`);
226
+ this.emit('agent-killed', processInfo);
227
+ // Wait a bit for graceful shutdown
228
+ await new Promise((resolve)=>setTimeout(resolve, 1000));
229
+ // Force kill if still alive
230
+ if (!processInfo.process.killed) {
231
+ process.kill(-processInfo.pid, 'SIGKILL');
232
+ this.logger.warn(`Force-killed agent ${agentId} (SIGKILL)`);
233
+ }
234
+ } catch (error) {
235
+ this.logger.error(`Failed to kill agent ${agentId}`, error);
236
+ }
237
+ }
238
+ /**
239
+ * Get agent PID
240
+ *
241
+ * Returns process ID for a spawned agent.
242
+ */ getAgentPID(agentId) {
243
+ return this.processes.get(agentId)?.pid ?? null;
244
+ }
245
+ /**
246
+ * Get agent process info
247
+ *
248
+ * Returns full process information for tracking.
249
+ */ getAgentProcessInfo(agentId) {
250
+ return this.processes.get(agentId) ?? null;
251
+ }
252
+ /**
253
+ * Get all running agents
254
+ *
255
+ * Returns information for all spawned agents.
256
+ */ getAllRunningAgents() {
257
+ return Array.from(this.processes.values()).filter((info)=>info.process && !info.process.killed);
258
+ }
259
+ /**
260
+ * Wait for agent completion
261
+ *
262
+ * Blocking wait for agent process to exit with timeout.
263
+ */ async waitForAgent(agentId, timeoutMs = 600000 // 10 minutes
264
+ ) {
265
+ const startTime = Date.now();
266
+ return new Promise((resolve, reject)=>{
267
+ const processInfo = this.processes.get(agentId);
268
+ if (!processInfo) {
269
+ return reject(new CoordinationError(CoordinationErrorType.AGENT_NOT_FOUND, `Agent ${agentId} not found`));
270
+ }
271
+ // If already exited, return immediately
272
+ if (processInfo.exitCode !== null) {
273
+ return resolve(processInfo);
274
+ }
275
+ // Wait for exit event
276
+ const exitHandler = ()=>{
277
+ resolve(processInfo);
278
+ clearTimeout(timeoutHandle);
279
+ };
280
+ const timeoutHandle = setTimeout(()=>{
281
+ if (processInfo.process) {
282
+ processInfo.process.removeListener('exit', exitHandler);
283
+ }
284
+ processInfo.exitCode = -1; // Timeout code
285
+ reject(new CoordinationError(CoordinationErrorType.TIMEOUT, `Agent ${agentId} did not complete within ${timeoutMs}ms`));
286
+ }, timeoutMs);
287
+ if (processInfo.process) {
288
+ processInfo.process.once('exit', exitHandler);
289
+ }
290
+ });
291
+ }
292
+ /**
293
+ * Wait for multiple agents
294
+ *
295
+ * Blocking wait for all agents to complete.
296
+ */ async waitForAgents(agentIds, timeoutMs = 600000) {
297
+ const results = new Map();
298
+ const startTime = Date.now();
299
+ for (const agentId of agentIds){
300
+ const elapsedMs = Date.now() - startTime;
301
+ const remainingMs = timeoutMs - elapsedMs;
302
+ if (remainingMs <= 0) {
303
+ throw new CoordinationError(CoordinationErrorType.TIMEOUT, `Timeout waiting for agents: exceeded ${timeoutMs}ms`);
304
+ }
305
+ try {
306
+ const processInfo = await this.waitForAgent(agentId, remainingMs);
307
+ results.set(agentId, processInfo);
308
+ } catch (error) {
309
+ // Continue waiting for other agents even if one fails
310
+ const processInfo = this.processes.get(agentId);
311
+ if (processInfo) {
312
+ results.set(agentId, processInfo);
313
+ }
314
+ }
315
+ }
316
+ return results;
317
+ }
318
+ /**
319
+ * Cleanup all spawned agents
320
+ *
321
+ * Kills all running agents and clears tracking.
322
+ */ async cleanup() {
323
+ const runningAgents = this.getAllRunningAgents();
324
+ this.logger.info(`Cleaning up ${runningAgents.length} running agents...`);
325
+ for (const agentInfo of runningAgents){
326
+ try {
327
+ await this.killAgent(agentInfo.agentId, 'SIGTERM');
328
+ } catch (error) {
329
+ this.logger.error(`Failed to cleanup agent ${agentInfo.agentId}`, error);
330
+ }
331
+ }
332
+ this.processes.clear();
333
+ this.logger.info('Agent cleanup complete');
334
+ }
335
+ /**
336
+ * Get statistics about spawned agents
337
+ *
338
+ * Returns summary of spawned agents by status.
339
+ */ getSpawnStatistics() {
340
+ const all = Array.from(this.processes.values());
341
+ const running = all.filter((info)=>info.exitCode === null && !info.killed);
342
+ const completed = all.filter((info)=>info.exitCode === 0 && !info.killed);
343
+ const failed = all.filter((info)=>info.exitCode !== 0 && info.exitCode !== null || info.killed);
344
+ return {
345
+ total: all.length,
346
+ running: running.length,
347
+ completed: completed.length,
348
+ failed: failed.length
349
+ };
350
+ }
351
+ }
352
+ /**
353
+ * Factory function for creating spawner with sensible defaults
354
+ */ export function createAgentSpawner(logger, config) {
355
+ return new AgentSpawner({
356
+ logger,
357
+ executionMode: config?.executionMode ?? 'unknown',
358
+ canUseRedis: config?.canUseRedis ?? false,
359
+ projectRoot: config?.projectRoot,
360
+ dockerEnabled: config?.dockerEnabled ?? false
361
+ });
362
+ }
363
+
364
+ //# sourceMappingURL=spawn-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/coordination/spawn-agent.ts"],"sourcesContent":["/**\r\n * Agent Spawning Abstraction Layer\r\n *\r\n * Provides unified interface for spawning agents in both Task Mode and CLI Mode.\r\n * Abstracts away the complexity of determining spawn method and managing processes.\r\n *\r\n * Key Features:\r\n * - Automatic mode detection (Task vs CLI)\r\n * - Process management and cleanup\r\n * - Error handling and retry logic\r\n * - Process PID tracking\r\n * - Wait for agent completion\r\n * - Resource limits and timeouts\r\n */\r\n\r\nimport { spawn, SpawnOptions } from 'child_process';\r\nimport { EventEmitter } from 'events';\r\nimport type { ChildProcess } from 'child_process';\r\n// Types from Redis coordination skill\r\nimport type {\r\n AgentId,\r\n TaskId,\r\n ExecutionMode,\r\n Logger,\r\n} from './types-export';\r\nimport {\r\n CoordinationError,\r\n CoordinationErrorType,\r\n} from './types-export';\r\n\r\n/**\r\n * Agent Spawn Configuration\r\n *\r\n * Configuration for spawning an agent with all necessary parameters.\r\n */\r\nexport interface AgentSpawnConfig {\r\n agentType: string;\r\n taskId: TaskId;\r\n agentId: AgentId;\r\n iteration?: number;\r\n context?: Record<string, unknown>;\r\n memoryLimit?: number; // MB\r\n timeoutMs?: number;\r\n maxRetries?: number;\r\n environment?: Record<string, string>;\r\n}\r\n\r\n/**\r\n * Agent Process Information\r\n *\r\n * Tracks spawned agent process and its lifecycle.\r\n */\r\nexport interface AgentProcessInfo {\r\n agentId: AgentId;\r\n agentType: string;\r\n taskId: TaskId;\r\n pid: number | null;\r\n mode: ExecutionMode;\r\n process: ChildProcess | null;\r\n startedAt: string;\r\n exitCode: number | null;\r\n signal: string | null;\r\n killed: boolean;\r\n}\r\n\r\n/**\r\n * Agent Spawner Options\r\n *\r\n * Configuration for the spawner itself.\r\n */\r\nexport interface SpawnerConfig {\r\n logger: Logger;\r\n executionMode: ExecutionMode;\r\n canUseRedis: boolean;\r\n projectRoot?: string;\r\n dockerEnabled?: boolean;\r\n}\r\n\r\n/**\r\n * Agent Spawner\r\n *\r\n * Creates and manages agent processes with support for both Task and CLI modes.\r\n *\r\n * Task Mode: Spawns via npx CLI (no Redis coordination)\r\n * CLI Mode: Spawns via npx CLI with Redis coordination environment variables\r\n */\r\nexport class AgentSpawner extends EventEmitter {\r\n private logger: Logger;\r\n private executionMode: ExecutionMode;\r\n private canUseRedis: boolean;\r\n private projectRoot: string;\r\n private dockerEnabled: boolean;\r\n\r\n // Track running agents\r\n private processes = new Map<AgentId, AgentProcessInfo>();\r\n\r\n constructor(config: SpawnerConfig) {\r\n super();\r\n this.logger = config.logger;\r\n this.executionMode = config.executionMode;\r\n this.canUseRedis = config.canUseRedis;\r\n this.projectRoot = config.projectRoot || process.cwd();\r\n this.dockerEnabled = config.dockerEnabled ?? false;\r\n }\r\n\r\n /**\r\n * Spawn an agent (auto-detects mode)\r\n *\r\n * Automatically selects appropriate spawn method based on execution mode.\r\n */\r\n async spawnAgent(config: AgentSpawnConfig): Promise<AgentProcessInfo> {\r\n if (this.executionMode === 'cli' || this.executionMode === 'unknown') {\r\n // Try CLI mode first\r\n return this.spawnCLIAgent(config);\r\n } else {\r\n // Task mode: Still spawn via CLI but without Redis\r\n return this.spawnTaskAgent(config);\r\n }\r\n }\r\n\r\n /**\r\n * Spawn agent in CLI mode\r\n *\r\n * Spawns via npx with TASK_ID and AGENT_ID for Redis coordination.\r\n */\r\n async spawnCLIAgent(config: AgentSpawnConfig): Promise<AgentProcessInfo> {\r\n if (!this.canUseRedis && this.executionMode !== 'unknown') {\r\n // In true CLI mode but Redis unavailable\r\n this.logger.warn('CLI Mode but Redis unavailable - spawning without coordination');\r\n }\r\n\r\n const args = [\r\n 'claude-flow-novice',\r\n 'agent',\r\n config.agentType,\r\n '--task-id', config.taskId,\r\n '--agent-id', config.agentId,\r\n ];\r\n\r\n if (config.iteration !== undefined) {\r\n args.push('--iteration', config.iteration.toString());\r\n }\r\n\r\n if (config.context) {\r\n args.push('--context', JSON.stringify(config.context));\r\n }\r\n\r\n // Build environment\r\n const env: Record<string, string> = {\r\n ...process.env,\r\n TASK_ID: config.taskId,\r\n AGENT_ID: config.agentId,\r\n CFN_MODE: 'cli',\r\n ...(config.environment || {}),\r\n };\r\n\r\n // Add Redis connection info if available\r\n if (this.canUseRedis) {\r\n const redisHost = process.env.REDIS_HOST || 'localhost';\r\n const redisPort = process.env.REDIS_PORT || '6379';\r\n const redisPassword = process.env.REDIS_PASSWORD || process.env.CFN_REDIS_PASSWORD;\r\n\r\n env.REDIS_HOST = redisHost;\r\n env.REDIS_PORT = redisPort;\r\n if (redisPassword) {\r\n env.REDIS_PASSWORD = redisPassword;\r\n }\r\n }\r\n\r\n return this._spawnProcess(config, args, env, 'cli');\r\n }\r\n\r\n /**\r\n * Spawn agent in Task mode\r\n *\r\n * Spawns via npx without Task/Agent IDs for Main Chat execution.\r\n */\r\n async spawnTaskAgent(config: AgentSpawnConfig): Promise<AgentProcessInfo> {\r\n const args = [\r\n 'claude-flow-novice',\r\n 'agent',\r\n config.agentType,\r\n ];\r\n\r\n // In Task Mode, don't pass TASK_ID/AGENT_ID (Main Chat doesn't know about them)\r\n if (config.context) {\r\n args.push('--context', JSON.stringify(config.context));\r\n }\r\n\r\n // Build environment without TASK_ID/AGENT_ID\r\n const env: Record<string, string> = {\r\n ...process.env,\r\n CFN_MODE: 'task',\r\n ...(config.environment || {}),\r\n };\r\n\r\n // Remove Redis connection in Task Mode\r\n delete env.TASK_ID;\r\n delete env.AGENT_ID;\r\n delete env.REDIS_HOST;\r\n delete env.REDIS_PORT;\r\n delete env.REDIS_PASSWORD;\r\n\r\n return this._spawnProcess(config, args, env, 'task');\r\n }\r\n\r\n /**\r\n * Internal: Spawn process with retry logic\r\n *\r\n * Handles actual process spawning with error handling and retries.\r\n */\r\n private async _spawnProcess(\r\n config: AgentSpawnConfig,\r\n args: string[],\r\n env: Record<string, string>,\r\n mode: ExecutionMode\r\n ): Promise<AgentProcessInfo> {\r\n const maxRetries = config.maxRetries ?? 1;\r\n let lastError: Error | null = null;\r\n\r\n for (let attempt = 1; attempt <= maxRetries; attempt++) {\r\n try {\r\n // Spawn the process\r\n const spawnOptions: SpawnOptions = {\r\n stdio: ['ignore', 'pipe', 'pipe'], // Inherit stdio for logging\r\n env,\r\n detached: true, // Allow process to outlive parent\r\n timeout: config.timeoutMs ?? 600000, // 10 minute default\r\n };\r\n\r\n this.logger.debug(`Spawning agent ${config.agentId} (attempt ${attempt}/${maxRetries})`);\r\n\r\n const process = spawn('npx', args, spawnOptions);\r\n const pid = process.pid || null;\r\n\r\n const processInfo: AgentProcessInfo = {\r\n agentId: config.agentId,\r\n agentType: config.agentType,\r\n taskId: config.taskId,\r\n pid,\r\n mode,\r\n process,\r\n startedAt: new Date().toISOString(),\r\n exitCode: null,\r\n signal: null,\r\n killed: false,\r\n };\r\n\r\n // Track process\r\n this.processes.set(config.agentId, processInfo);\r\n\r\n // Attach event handlers\r\n this._attachProcessHandlers(processInfo);\r\n\r\n this.logger.info(\r\n `Spawned agent ${config.agentId} (PID: ${pid || 'unknown'}, mode: ${mode})`\r\n );\r\n\r\n this.emit('agent-spawned', processInfo);\r\n\r\n return processInfo;\r\n } catch (error) {\r\n lastError = error as Error;\r\n\r\n if (attempt < maxRetries) {\r\n // Wait before retry (exponential backoff)\r\n const delayMs = Math.min(1000 * Math.pow(2, attempt - 1), 10000);\r\n this.logger.warn(\r\n `Failed to spawn agent ${config.agentId} (attempt ${attempt}/${maxRetries}), retrying in ${delayMs}ms...`\r\n );\r\n await new Promise(resolve => setTimeout(resolve, delayMs));\r\n }\r\n }\r\n }\r\n\r\n throw new CoordinationError(\r\n CoordinationErrorType.AGENT_SPAWN_ERROR,\r\n `Failed to spawn agent ${config.agentId} after ${maxRetries} attempts: ${lastError?.message}`,\r\n mode,\r\n true // Retryable\r\n );\r\n }\r\n\r\n /**\r\n * Attach process event handlers\r\n *\r\n * Monitors process lifecycle and emits events.\r\n */\r\n private _attachProcessHandlers(processInfo: AgentProcessInfo): void {\r\n const { process, agentId } = processInfo;\r\n\r\n if (!process) return;\r\n\r\n // Handle process exit\r\n process.on('exit', (code, signal) => {\r\n processInfo.exitCode = code;\r\n processInfo.signal = signal;\r\n this.logger.info(\r\n `Agent ${agentId} exited with code ${code}${signal ? ` (signal: ${signal})` : ''}`\r\n );\r\n this.emit('agent-exit', processInfo);\r\n });\r\n\r\n // Handle process errors\r\n process.on('error', (error) => {\r\n this.logger.error(`Agent ${agentId} process error`, error);\r\n this.emit('agent-error', { agentId, error });\r\n });\r\n\r\n // Handle stdout/stderr\r\n process.stdout?.on('data', (data) => {\r\n this.logger.debug(`Agent ${agentId} stdout:`, data.toString());\r\n });\r\n\r\n process.stderr?.on('data', (data) => {\r\n this.logger.debug(`Agent ${agentId} stderr:`, data.toString());\r\n });\r\n }\r\n\r\n /**\r\n * Kill an agent process\r\n *\r\n * Forcefully terminates an agent and cleanup.\r\n */\r\n async killAgent(agentId: AgentId, signal: string = 'SIGTERM'): Promise<void> {\r\n const processInfo = this.processes.get(agentId);\r\n\r\n if (!processInfo || !processInfo.process || !processInfo.pid) {\r\n this.logger.warn(`Cannot kill agent ${agentId}: not found or no PID`);\r\n return;\r\n }\r\n\r\n try {\r\n // Kill the process group (not just the process)\r\n process.kill(-processInfo.pid, signal);\r\n processInfo.killed = true;\r\n\r\n this.logger.info(`Killed agent ${agentId} (PID: ${processInfo.pid}, signal: ${signal})`);\r\n this.emit('agent-killed', processInfo);\r\n\r\n // Wait a bit for graceful shutdown\r\n await new Promise(resolve => setTimeout(resolve, 1000));\r\n\r\n // Force kill if still alive\r\n if (!processInfo.process.killed) {\r\n process.kill(-processInfo.pid, 'SIGKILL');\r\n this.logger.warn(`Force-killed agent ${agentId} (SIGKILL)`);\r\n }\r\n } catch (error) {\r\n this.logger.error(`Failed to kill agent ${agentId}`, error);\r\n }\r\n }\r\n\r\n /**\r\n * Get agent PID\r\n *\r\n * Returns process ID for a spawned agent.\r\n */\r\n getAgentPID(agentId: AgentId): number | null {\r\n return this.processes.get(agentId)?.pid ?? null;\r\n }\r\n\r\n /**\r\n * Get agent process info\r\n *\r\n * Returns full process information for tracking.\r\n */\r\n getAgentProcessInfo(agentId: AgentId): AgentProcessInfo | null {\r\n return this.processes.get(agentId) ?? null;\r\n }\r\n\r\n /**\r\n * Get all running agents\r\n *\r\n * Returns information for all spawned agents.\r\n */\r\n getAllRunningAgents(): AgentProcessInfo[] {\r\n return Array.from(this.processes.values()).filter(\r\n info => info.process && !info.process.killed\r\n );\r\n }\r\n\r\n /**\r\n * Wait for agent completion\r\n *\r\n * Blocking wait for agent process to exit with timeout.\r\n */\r\n async waitForAgent(\r\n agentId: AgentId,\r\n timeoutMs: number = 600000 // 10 minutes\r\n ): Promise<AgentProcessInfo> {\r\n const startTime = Date.now();\r\n\r\n return new Promise((resolve, reject) => {\r\n const processInfo = this.processes.get(agentId);\r\n\r\n if (!processInfo) {\r\n return reject(\r\n new CoordinationError(\r\n CoordinationErrorType.AGENT_NOT_FOUND,\r\n `Agent ${agentId} not found`\r\n )\r\n );\r\n }\r\n\r\n // If already exited, return immediately\r\n if (processInfo.exitCode !== null) {\r\n return resolve(processInfo);\r\n }\r\n\r\n // Wait for exit event\r\n const exitHandler = () => {\r\n resolve(processInfo);\r\n clearTimeout(timeoutHandle);\r\n };\r\n\r\n const timeoutHandle = setTimeout(() => {\r\n if (processInfo.process) {\r\n processInfo.process.removeListener('exit', exitHandler);\r\n }\r\n processInfo.exitCode = -1; // Timeout code\r\n reject(\r\n new CoordinationError(\r\n CoordinationErrorType.TIMEOUT,\r\n `Agent ${agentId} did not complete within ${timeoutMs}ms`\r\n )\r\n );\r\n }, timeoutMs);\r\n\r\n if (processInfo.process) {\r\n processInfo.process.once('exit', exitHandler);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Wait for multiple agents\r\n *\r\n * Blocking wait for all agents to complete.\r\n */\r\n async waitForAgents(\r\n agentIds: AgentId[],\r\n timeoutMs: number = 600000\r\n ): Promise<Map<AgentId, AgentProcessInfo>> {\r\n const results = new Map<AgentId, AgentProcessInfo>();\r\n const startTime = Date.now();\r\n\r\n for (const agentId of agentIds) {\r\n const elapsedMs = Date.now() - startTime;\r\n const remainingMs = timeoutMs - elapsedMs;\r\n\r\n if (remainingMs <= 0) {\r\n throw new CoordinationError(\r\n CoordinationErrorType.TIMEOUT,\r\n `Timeout waiting for agents: exceeded ${timeoutMs}ms`\r\n );\r\n }\r\n\r\n try {\r\n const processInfo = await this.waitForAgent(agentId, remainingMs);\r\n results.set(agentId, processInfo);\r\n } catch (error) {\r\n // Continue waiting for other agents even if one fails\r\n const processInfo = this.processes.get(agentId);\r\n if (processInfo) {\r\n results.set(agentId, processInfo);\r\n }\r\n }\r\n }\r\n\r\n return results;\r\n }\r\n\r\n /**\r\n * Cleanup all spawned agents\r\n *\r\n * Kills all running agents and clears tracking.\r\n */\r\n async cleanup(): Promise<void> {\r\n const runningAgents = this.getAllRunningAgents();\r\n\r\n this.logger.info(`Cleaning up ${runningAgents.length} running agents...`);\r\n\r\n for (const agentInfo of runningAgents) {\r\n try {\r\n await this.killAgent(agentInfo.agentId, 'SIGTERM');\r\n } catch (error) {\r\n this.logger.error(`Failed to cleanup agent ${agentInfo.agentId}`, error);\r\n }\r\n }\r\n\r\n this.processes.clear();\r\n this.logger.info('Agent cleanup complete');\r\n }\r\n\r\n /**\r\n * Get statistics about spawned agents\r\n *\r\n * Returns summary of spawned agents by status.\r\n */\r\n getSpawnStatistics(): {\r\n total: number;\r\n running: number;\r\n completed: number;\r\n failed: number;\r\n } {\r\n const all = Array.from(this.processes.values());\r\n const running = all.filter(info => info.exitCode === null && !info.killed);\r\n const completed = all.filter(\r\n info => info.exitCode === 0 && !info.killed\r\n );\r\n const failed = all.filter(\r\n info => (info.exitCode !== 0 && info.exitCode !== null) || info.killed\r\n );\r\n\r\n return {\r\n total: all.length,\r\n running: running.length,\r\n completed: completed.length,\r\n failed: failed.length,\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Factory function for creating spawner with sensible defaults\r\n */\r\nexport function createAgentSpawner(\r\n logger: Logger,\r\n config?: Partial<SpawnerConfig>\r\n): AgentSpawner {\r\n return new AgentSpawner({\r\n logger,\r\n executionMode: config?.executionMode ?? 'unknown',\r\n canUseRedis: config?.canUseRedis ?? false,\r\n projectRoot: config?.projectRoot,\r\n dockerEnabled: config?.dockerEnabled ?? false,\r\n });\r\n}\r\n"],"names":["spawn","EventEmitter","CoordinationError","CoordinationErrorType","AgentSpawner","logger","executionMode","canUseRedis","projectRoot","dockerEnabled","processes","Map","config","process","cwd","spawnAgent","spawnCLIAgent","spawnTaskAgent","warn","args","agentType","taskId","agentId","iteration","undefined","push","toString","context","JSON","stringify","env","TASK_ID","AGENT_ID","CFN_MODE","environment","redisHost","REDIS_HOST","redisPort","REDIS_PORT","redisPassword","REDIS_PASSWORD","CFN_REDIS_PASSWORD","_spawnProcess","mode","maxRetries","lastError","attempt","spawnOptions","stdio","detached","timeout","timeoutMs","debug","pid","processInfo","startedAt","Date","toISOString","exitCode","signal","killed","set","_attachProcessHandlers","info","emit","error","delayMs","Math","min","pow","Promise","resolve","setTimeout","AGENT_SPAWN_ERROR","message","on","code","stdout","data","stderr","killAgent","get","kill","getAgentPID","getAgentProcessInfo","getAllRunningAgents","Array","from","values","filter","waitForAgent","startTime","now","reject","AGENT_NOT_FOUND","exitHandler","clearTimeout","timeoutHandle","removeListener","TIMEOUT","once","waitForAgents","agentIds","results","elapsedMs","remainingMs","cleanup","runningAgents","length","agentInfo","clear","getSpawnStatistics","all","running","completed","failed","total","createAgentSpawner"],"mappings":"AAAA;;;;;;;;;;;;;CAaC,GAED,SAASA,KAAK,QAAsB,gBAAgB;AACpD,SAASC,YAAY,QAAQ,SAAS;AAStC,SACEC,iBAAiB,EACjBC,qBAAqB,QAChB,iBAAiB;AAkDxB;;;;;;;CAOC,GACD,OAAO,MAAMC,qBAAqBH;IACxBI,OAAe;IACfC,cAA6B;IAC7BC,YAAqB;IACrBC,YAAoB;IACpBC,cAAuB;IAE/B,uBAAuB;IACfC,YAAY,IAAIC,MAAiC;IAEzD,YAAYC,MAAqB,CAAE;QACjC,KAAK;QACL,IAAI,CAACP,MAAM,GAAGO,OAAOP,MAAM;QAC3B,IAAI,CAACC,aAAa,GAAGM,OAAON,aAAa;QACzC,IAAI,CAACC,WAAW,GAAGK,OAAOL,WAAW;QACrC,IAAI,CAACC,WAAW,GAAGI,OAAOJ,WAAW,IAAIK,QAAQC,GAAG;QACpD,IAAI,CAACL,aAAa,GAAGG,OAAOH,aAAa,IAAI;IAC/C;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SAASH,IAAIvB,MAAM,CACvB1B,CAAAA,OAAQ,AAACA,KAAKL,QAAQ,KAAK,KAAKK,KAAKL,QAAQ,KAAK,QAASK,KAAKH,MAAM;QAGxE,OAAO;YACLwD,OAAOJ,IAAIJ,MAAM;YACjBK,SAASA,QAAQL,MAAM;YACvBM,WAAWA,UAAUN,MAAM;YAC3BO,QAAQA,OAAOP,MAAM;QACvB;IACF;AACF;AAEA;;CAEC,GACD,OAAO,SAASS,mBACdhH,MAAc,EACdO,MAA+B;IAE/B,OAAO,IAAIR,aAAa;QACtBC;QACAC,eAAeM,QAAQN,iBAAiB;QACxCC,aAAaK,QAAQL,eAAe;QACpCC,aAAaI,QAAQJ;QACrBC,eAAeG,QAAQH,iBAAiB;IAC1C;AACF"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Type definitions for coordination layer
3
+ *
4
+ * These are branded types for type safety. Since we can't reliably import
5
+ * from the external Redis coordination skill, we define them here.
6
+ */ /**
7
+ * Branded types for type safety
8
+ *
9
+ * These branded types prevent accidental mixing of different string values
10
+ * at compile time while remaining efficient at runtime.
11
+ */ /**
12
+ * Coordination error types
13
+ */ export var CoordinationErrorType = /*#__PURE__*/ function(CoordinationErrorType) {
14
+ CoordinationErrorType["MODE_MISMATCH"] = "MODE_MISMATCH";
15
+ CoordinationErrorType["REDIS_UNAVAILABLE"] = "REDIS_UNAVAILABLE";
16
+ CoordinationErrorType["TIMEOUT"] = "TIMEOUT";
17
+ CoordinationErrorType["VALIDATION_ERROR"] = "VALIDATION_ERROR";
18
+ CoordinationErrorType["MISSING_CONTEXT"] = "MISSING_CONTEXT";
19
+ CoordinationErrorType["INVALID_STATE"] = "INVALID_STATE";
20
+ CoordinationErrorType["AGENT_SPAWN_ERROR"] = "AGENT_SPAWN_ERROR";
21
+ CoordinationErrorType["AGENT_NOT_FOUND"] = "AGENT_NOT_FOUND";
22
+ CoordinationErrorType["REDIS_ERROR"] = "REDIS_ERROR";
23
+ return CoordinationErrorType;
24
+ }({});
25
+ /**
26
+ * Coordination error with mode awareness
27
+ */ export class CoordinationError extends Error {
28
+ type;
29
+ mode;
30
+ canRetry;
31
+ constructor(type, message, mode, canRetry = false){
32
+ super(message), this.type = type, this.mode = mode, this.canRetry = canRetry;
33
+ this.name = 'CoordinationError';
34
+ Object.setPrototypeOf(this, CoordinationError.prototype);
35
+ }
36
+ }
37
+
38
+ //# sourceMappingURL=types-export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/coordination/types-export.ts"],"sourcesContent":["/**\r\n * Type definitions for coordination layer\r\n *\r\n * These are branded types for type safety. Since we can't reliably import\r\n * from the external Redis coordination skill, we define them here.\r\n */\r\n\r\n/**\r\n * Branded types for type safety\r\n *\r\n * These branded types prevent accidental mixing of different string values\r\n * at compile time while remaining efficient at runtime.\r\n */\r\n\r\nexport type TaskId = string & { readonly __brand: 'TaskId' };\r\nexport type AgentId = string & { readonly __brand: 'AgentId' };\r\nexport type CorrelationId = string & { readonly __brand: 'CorrelationId' };\r\n\r\n/**\r\n * Execution mode enum\r\n */\r\nexport type ExecutionMode = 'task' | 'cli' | 'unknown';\r\n\r\n/**\r\n * Coordination error types\r\n */\r\nexport enum CoordinationErrorType {\r\n MODE_MISMATCH = 'MODE_MISMATCH',\r\n REDIS_UNAVAILABLE = 'REDIS_UNAVAILABLE',\r\n TIMEOUT = 'TIMEOUT',\r\n VALIDATION_ERROR = 'VALIDATION_ERROR',\r\n MISSING_CONTEXT = 'MISSING_CONTEXT',\r\n INVALID_STATE = 'INVALID_STATE',\r\n AGENT_SPAWN_ERROR = 'AGENT_SPAWN_ERROR',\r\n AGENT_NOT_FOUND = 'AGENT_NOT_FOUND',\r\n REDIS_ERROR = 'REDIS_ERROR',\r\n}\r\n\r\n/**\r\n * Coordination error with mode awareness\r\n */\r\nexport class CoordinationError extends Error {\r\n constructor(\r\n public readonly type: CoordinationErrorType,\r\n message: string,\r\n public readonly mode?: ExecutionMode,\r\n public readonly canRetry: boolean = false\r\n ) {\r\n super(message);\r\n this.name = 'CoordinationError';\r\n Object.setPrototypeOf(this, CoordinationError.prototype);\r\n }\r\n}\r\n\r\n/**\r\n * Logger interface for dependency injection\r\n */\r\nexport interface Logger {\r\n debug(message: string, ...args: unknown[]): void;\r\n info(message: string, ...args: unknown[]): void;\r\n warn(message: string, ...args: unknown[]): void;\r\n error(message: string, ...args: unknown[]): void;\r\n}\r\n"],"names":["CoordinationErrorType","CoordinationError","Error","type","message","mode","canRetry","name","Object","setPrototypeOf","prototype"],"mappings":"AAAA;;;;;CAKC,GAED;;;;;CAKC,GAWD;;CAEC,GACD,OAAO,IAAA,AAAKA,+CAAAA;;;;;;;;;;WAAAA;MAUX;AAED;;CAEC,GACD,OAAO,MAAMC,0BAA0BC;;;;IACrC,YACE,AAAgBC,IAA2B,EAC3CC,OAAe,EACf,AAAgBC,IAAoB,EACpC,AAAgBC,WAAoB,KAAK,CACzC;QACA,KAAK,CAACF,eALUD,OAAAA,WAEAE,OAAAA,WACAC,WAAAA;QAGhB,IAAI,CAACC,IAAI,GAAG;QACZC,OAAOC,cAAc,CAAC,IAAI,EAAER,kBAAkBS,SAAS;IACzD;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow-novice",
3
- "version": "2.15.8",
3
+ "version": "2.15.10",
4
4
  "description": "AI agent orchestration framework with namespace-isolated skills, agents, and CFN Loop validation. Safe installation with ~0.01% collision risk.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",