claude-flow 3.5.31 → 3.5.32

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.
@@ -348,6 +348,10 @@ async function doStatus() {
348
348
 
349
349
  const command = process.argv[2] || 'status';
350
350
 
351
+ // Suppress unhandled rejection warnings from dynamic import() failures
352
+ // which can cause non-zero exit codes even when caught
353
+ process.on('unhandledRejection', () => {});
354
+
351
355
  try {
352
356
  switch (command) {
353
357
  case 'import': await doImport(); break;
@@ -361,3 +365,5 @@ try {
361
365
  // Hooks must never crash Claude Code - fail silently
362
366
  dim(`Error (non-critical): ${err.message}`);
363
367
  }
368
+ // Ensure clean exit for Claude Code hooks (exit 0 = success, no stderr = no error)
369
+ process.exit(0);
@@ -228,4 +228,7 @@ if (command && handlers[command]) {
228
228
 
229
229
  main().catch(function(e) {
230
230
  console.log('[WARN] Hook handler error: ' + e.message);
231
+ }).finally(function() {
232
+ // Ensure clean exit for Claude Code hooks
233
+ process.exit(0);
231
234
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "3.5.31",
3
+ "version": "3.5.32",
4
4
  "description": "Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -716,6 +716,8 @@ const hooksCommand = {
716
716
  stop: false,
717
717
  preCompact: false,
718
718
  notification: false,
719
+ teammateIdle: false,
720
+ taskCompleted: false,
719
721
  timeout: 5000,
720
722
  continueOnError: true,
721
723
  }
@@ -581,7 +581,7 @@ export function generateHookHandler() {
581
581
  '} // end main',
582
582
  '',
583
583
  'process.exitCode = 0;',
584
- 'main().catch(() => { process.exitCode = 0; });',
584
+ 'main().catch(() => {}).finally(() => { process.exit(0); });',
585
585
  ];
586
586
  return lines.join('\n') + '\n';
587
587
  }
@@ -897,6 +897,9 @@ function doStatus() {
897
897
  console.log('');
898
898
  }
899
899
 
900
+ // Suppress unhandled rejection warnings from dynamic import() failures
901
+ process.on('unhandledRejection', () => {});
902
+
900
903
  const command = process.argv[2] || 'status';
901
904
 
902
905
  try {
@@ -912,6 +915,8 @@ try {
912
915
  // Hooks must never crash Claude Code - fail silently
913
916
  dim(\`Error (non-critical): \${err.message}\`);
914
917
  }
918
+ // Ensure clean exit for Claude Code hooks (exit 0 = success)
919
+ process.exit(0);
915
920
  `;
916
921
  }
917
922
  /**
@@ -399,8 +399,59 @@ function generateHooksConfig(config) {
399
399
  },
400
400
  ];
401
401
  }
402
- // NOTE: TeammateIdle and TaskCompleted are NOT valid Claude Code hook events.
403
- // Their configuration lives in claudeFlow.agentTeams.hooks instead (see generateSettings).
402
+ // TeammateIdle auto-assign pending tasks when a teammate goes idle
403
+ if (config.teammateIdle) {
404
+ hooks.TeammateIdle = [
405
+ {
406
+ hooks: [
407
+ {
408
+ type: 'command',
409
+ command: hookHandlerCmd('post-task'),
410
+ timeout: 5000,
411
+ },
412
+ ],
413
+ },
414
+ ];
415
+ }
416
+ // TaskCompleted — train patterns and notify lead when a task completes
417
+ if (config.taskCompleted) {
418
+ hooks.TaskCompleted = [
419
+ {
420
+ hooks: [
421
+ {
422
+ type: 'command',
423
+ command: hookHandlerCmd('post-task'),
424
+ timeout: 5000,
425
+ },
426
+ ],
427
+ },
428
+ ];
429
+ }
430
+ // PostCompact — persist state after compaction completes
431
+ if (config.preCompact) {
432
+ hooks.PostCompact = [
433
+ {
434
+ matcher: 'manual',
435
+ hooks: [
436
+ {
437
+ type: 'command',
438
+ command: hookHandlerCmd('session-restore'),
439
+ timeout: 5000,
440
+ },
441
+ ],
442
+ },
443
+ {
444
+ matcher: 'auto',
445
+ hooks: [
446
+ {
447
+ type: 'command',
448
+ command: hookHandlerCmd('session-restore'),
449
+ timeout: 5000,
450
+ },
451
+ ],
452
+ },
453
+ ];
454
+ }
404
455
  return hooks;
405
456
  }
406
457
  /**
@@ -27,8 +27,12 @@ export interface InitComponents {
27
27
  }
28
28
  /**
29
29
  * Hook configuration options
30
- * Valid hook types: PreToolUse, PostToolUse, Notification, UserPromptSubmit,
31
- * SessionStart, SessionEnd, Stop, SubagentStop, PreCompact
30
+ * Valid Claude Code hook events (23 total):
31
+ * PreToolUse, PostToolUse, PostToolUseFailure, UserPromptSubmit,
32
+ * SessionStart, SessionEnd, Stop, SubagentStart, SubagentStop,
33
+ * PreCompact, PostCompact, Notification, ConfigChange,
34
+ * InstructionsLoaded, PermissionRequest, WorktreeCreate, WorktreeRemove,
35
+ * TeammateIdle, TaskCompleted, Elicitation, ElicitationResult
32
36
  */
33
37
  export interface HooksConfig {
34
38
  /** Enable PreToolUse hooks */
@@ -45,6 +49,10 @@ export interface HooksConfig {
45
49
  preCompact: boolean;
46
50
  /** Enable Notification hooks */
47
51
  notification: boolean;
52
+ /** Enable TeammateIdle hooks (agent teams auto-assign) */
53
+ teammateIdle: boolean;
54
+ /** Enable TaskCompleted hooks (agent teams pattern learning) */
55
+ taskCompleted: boolean;
48
56
  /** Hook timeout in milliseconds */
49
57
  timeout: number;
50
58
  /** Continue on hook error */
@@ -65,6 +65,8 @@ export const DEFAULT_INIT_OPTIONS = {
65
65
  stop: true,
66
66
  preCompact: true,
67
67
  notification: true,
68
+ teammateIdle: true,
69
+ taskCompleted: true,
68
70
  timeout: 5000,
69
71
  continueOnError: true,
70
72
  },
@@ -160,6 +162,8 @@ export const MINIMAL_INIT_OPTIONS = {
160
162
  userPromptSubmit: false,
161
163
  stop: false,
162
164
  notification: false,
165
+ teammateIdle: false,
166
+ taskCompleted: false,
163
167
  },
164
168
  skills: {
165
169
  core: true,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@claude-flow/cli",
3
- "version": "3.5.31",
3
+ "version": "3.5.32",
4
4
  "type": "module",
5
5
  "description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
6
6
  "main": "dist/src/index.js",