@claude-flow/cli 3.0.0-alpha.6 → 3.0.0-alpha.8

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 (99) hide show
  1. package/.agentic-flow/intelligence.json +4 -4
  2. package/.claude-flow/agents/store.json +16 -0
  3. package/.claude-flow/daemon-state.json +123 -0
  4. package/.claude-flow/hive-mind/state.json +51 -0
  5. package/.claude-flow/metrics/codebase-map.json +11 -0
  6. package/.claude-flow/metrics/consolidation.json +6 -0
  7. package/.claude-flow/metrics/performance.json +12 -84
  8. package/.claude-flow/metrics/security-audit.json +10 -0
  9. package/.claude-flow/metrics/task-metrics.json +3 -3
  10. package/.claude-flow/metrics/test-gaps.json +6 -0
  11. package/agents/architect.yaml +1 -1
  12. package/agents/coder.yaml +1 -1
  13. package/agents/reviewer.yaml +1 -1
  14. package/agents/security-architect.yaml +1 -1
  15. package/agents/tester.yaml +1 -1
  16. package/dist/src/commands/agent.d.ts.map +1 -1
  17. package/dist/src/commands/agent.js +42 -26
  18. package/dist/src/commands/agent.js.map +1 -1
  19. package/dist/src/commands/daemon.d.ts +8 -0
  20. package/dist/src/commands/daemon.d.ts.map +1 -0
  21. package/dist/src/commands/daemon.js +351 -0
  22. package/dist/src/commands/daemon.js.map +1 -0
  23. package/dist/src/commands/hive-mind.d.ts.map +1 -1
  24. package/dist/src/commands/hive-mind.js +252 -35
  25. package/dist/src/commands/hive-mind.js.map +1 -1
  26. package/dist/src/commands/index.d.ts +1 -0
  27. package/dist/src/commands/index.d.ts.map +1 -1
  28. package/dist/src/commands/index.js +4 -1
  29. package/dist/src/commands/index.js.map +1 -1
  30. package/dist/src/commands/start.js +2 -2
  31. package/dist/src/commands/start.js.map +1 -1
  32. package/dist/src/index.d.ts.map +1 -1
  33. package/dist/src/index.js +5 -2
  34. package/dist/src/index.js.map +1 -1
  35. package/dist/src/init/settings-generator.d.ts.map +1 -1
  36. package/dist/src/init/settings-generator.js +22 -12
  37. package/dist/src/init/settings-generator.js.map +1 -1
  38. package/dist/src/mcp-client.d.ts.map +1 -1
  39. package/dist/src/mcp-client.js +13 -1
  40. package/dist/src/mcp-client.js.map +1 -1
  41. package/dist/src/mcp-tools/agent-tools.d.ts +1 -1
  42. package/dist/src/mcp-tools/agent-tools.d.ts.map +1 -1
  43. package/dist/src/mcp-tools/agent-tools.js +350 -14
  44. package/dist/src/mcp-tools/agent-tools.js.map +1 -1
  45. package/dist/src/mcp-tools/config-tools.d.ts +1 -1
  46. package/dist/src/mcp-tools/config-tools.d.ts.map +1 -1
  47. package/dist/src/mcp-tools/config-tools.js +262 -15
  48. package/dist/src/mcp-tools/config-tools.js.map +1 -1
  49. package/dist/src/mcp-tools/hive-mind-tools.d.ts +8 -0
  50. package/dist/src/mcp-tools/hive-mind-tools.d.ts.map +1 -0
  51. package/dist/src/mcp-tools/hive-mind-tools.js +447 -0
  52. package/dist/src/mcp-tools/hive-mind-tools.js.map +1 -0
  53. package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
  54. package/dist/src/mcp-tools/hooks-tools.js +46 -7
  55. package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
  56. package/dist/src/mcp-tools/index.d.ts +2 -0
  57. package/dist/src/mcp-tools/index.d.ts.map +1 -1
  58. package/dist/src/mcp-tools/index.js +2 -0
  59. package/dist/src/mcp-tools/index.js.map +1 -1
  60. package/dist/src/mcp-tools/session-tools.d.ts +1 -1
  61. package/dist/src/mcp-tools/session-tools.d.ts.map +1 -1
  62. package/dist/src/mcp-tools/session-tools.js +237 -22
  63. package/dist/src/mcp-tools/session-tools.js.map +1 -1
  64. package/dist/src/mcp-tools/task-tools.d.ts +1 -1
  65. package/dist/src/mcp-tools/task-tools.d.ts.map +1 -1
  66. package/dist/src/mcp-tools/task-tools.js +219 -17
  67. package/dist/src/mcp-tools/task-tools.js.map +1 -1
  68. package/dist/src/mcp-tools/workflow-tools.d.ts +8 -0
  69. package/dist/src/mcp-tools/workflow-tools.d.ts.map +1 -0
  70. package/dist/src/mcp-tools/workflow-tools.js +481 -0
  71. package/dist/src/mcp-tools/workflow-tools.js.map +1 -0
  72. package/dist/src/services/index.d.ts +7 -0
  73. package/dist/src/services/index.d.ts.map +1 -0
  74. package/dist/src/services/index.js +6 -0
  75. package/dist/src/services/index.js.map +1 -0
  76. package/dist/src/services/worker-daemon.d.ts +153 -0
  77. package/dist/src/services/worker-daemon.d.ts.map +1 -0
  78. package/dist/src/services/worker-daemon.js +567 -0
  79. package/dist/src/services/worker-daemon.js.map +1 -0
  80. package/dist/tsconfig.tsbuildinfo +1 -1
  81. package/package.json +1 -1
  82. package/src/commands/agent.ts +42 -28
  83. package/src/commands/daemon.ts +395 -0
  84. package/src/commands/hive-mind.ts +229 -63
  85. package/src/commands/index.ts +4 -1
  86. package/src/commands/start.ts +2 -2
  87. package/src/index.ts +5 -2
  88. package/src/init/settings-generator.ts +22 -12
  89. package/src/mcp-client.ts +13 -1
  90. package/src/mcp-tools/agent-tools.ts +388 -14
  91. package/src/mcp-tools/config-tools.ts +297 -15
  92. package/src/mcp-tools/hive-mind-tools.ts +521 -0
  93. package/src/mcp-tools/hooks-tools.ts +46 -7
  94. package/src/mcp-tools/index.ts +2 -0
  95. package/src/mcp-tools/session-tools.ts +280 -23
  96. package/src/mcp-tools/task-tools.ts +265 -20
  97. package/src/mcp-tools/workflow-tools.ts +573 -0
  98. package/src/services/index.ts +15 -0
  99. package/src/services/worker-daemon.ts +726 -0
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "patterns": {
3
3
  "command:": {
4
- "success": 0.911370618803475,
5
- "failure": -0.17195000000000002
4
+ "success": 0.9999970936785837,
5
+ "failure": -0.3587852317595
6
6
  }
7
7
  },
8
8
  "sequences": {},
@@ -10,8 +10,8 @@
10
10
  "dirPatterns": {},
11
11
  "errorPatterns": [],
12
12
  "metrics": {
13
- "totalRoutes": 27,
14
- "successfulRoutes": 23,
13
+ "totalRoutes": 133,
14
+ "successfulRoutes": 121,
15
15
  "routingHistory": []
16
16
  }
17
17
  }
@@ -0,0 +1,16 @@
1
+ {
2
+ "agents": {
3
+ "agent-1767755470442-q0onj8": {
4
+ "agentId": "agent-1767755470442-q0onj8",
5
+ "agentType": "coder",
6
+ "status": "idle",
7
+ "health": 1,
8
+ "taskCount": 0,
9
+ "config": {
10
+ "provider": "anthropic"
11
+ },
12
+ "createdAt": "2026-01-07T03:11:10.442Z"
13
+ }
14
+ },
15
+ "version": "3.0.0"
16
+ }
@@ -0,0 +1,123 @@
1
+ {
2
+ "running": true,
3
+ "startedAt": "2026-01-07T03:07:50.010Z",
4
+ "workers": {
5
+ "map": {
6
+ "runCount": 7,
7
+ "successCount": 7,
8
+ "failureCount": 0,
9
+ "averageDurationMs": 0.5714285714285714,
10
+ "isRunning": false,
11
+ "nextRun": "2026-01-07T03:37:50.197Z",
12
+ "lastRun": "2026-01-07T03:37:50.198Z"
13
+ },
14
+ "audit": {
15
+ "runCount": 4,
16
+ "successCount": 4,
17
+ "failureCount": 0,
18
+ "averageDurationMs": 0.25,
19
+ "isRunning": false,
20
+ "nextRun": "2026-01-07T03:47:50.117Z",
21
+ "lastRun": "2026-01-07T03:37:50.117Z"
22
+ },
23
+ "optimize": {
24
+ "runCount": 3,
25
+ "successCount": 3,
26
+ "failureCount": 0,
27
+ "averageDurationMs": 0,
28
+ "isRunning": false,
29
+ "nextRun": "2026-01-07T03:52:50.090Z",
30
+ "lastRun": "2026-01-07T03:37:50.089Z"
31
+ },
32
+ "consolidate": {
33
+ "runCount": 2,
34
+ "successCount": 2,
35
+ "failureCount": 0,
36
+ "averageDurationMs": 1,
37
+ "isRunning": false,
38
+ "nextRun": "2026-01-07T04:07:50.089Z",
39
+ "lastRun": "2026-01-07T03:37:50.089Z"
40
+ },
41
+ "testgaps": {
42
+ "runCount": 2,
43
+ "successCount": 2,
44
+ "failureCount": 0,
45
+ "averageDurationMs": 0,
46
+ "isRunning": false,
47
+ "nextRun": "2026-01-07T03:47:50.072Z",
48
+ "lastRun": "2026-01-07T03:27:50.072Z"
49
+ },
50
+ "predict": {
51
+ "runCount": 0,
52
+ "successCount": 0,
53
+ "failureCount": 0,
54
+ "averageDurationMs": 0,
55
+ "isRunning": false
56
+ },
57
+ "document": {
58
+ "runCount": 0,
59
+ "successCount": 0,
60
+ "failureCount": 0,
61
+ "averageDurationMs": 0,
62
+ "isRunning": false
63
+ }
64
+ },
65
+ "config": {
66
+ "autoStart": true,
67
+ "logDir": "/workspaces/claude-flow/v3/@claude-flow/cli/.claude-flow/logs",
68
+ "stateFile": "/workspaces/claude-flow/v3/@claude-flow/cli/.claude-flow/daemon-state.json",
69
+ "maxConcurrent": 3,
70
+ "workers": [
71
+ {
72
+ "type": "map",
73
+ "intervalMs": 300000,
74
+ "priority": "normal",
75
+ "description": "Codebase mapping",
76
+ "enabled": true
77
+ },
78
+ {
79
+ "type": "audit",
80
+ "intervalMs": 600000,
81
+ "priority": "critical",
82
+ "description": "Security analysis",
83
+ "enabled": true
84
+ },
85
+ {
86
+ "type": "optimize",
87
+ "intervalMs": 900000,
88
+ "priority": "high",
89
+ "description": "Performance optimization",
90
+ "enabled": true
91
+ },
92
+ {
93
+ "type": "consolidate",
94
+ "intervalMs": 1800000,
95
+ "priority": "low",
96
+ "description": "Memory consolidation",
97
+ "enabled": true
98
+ },
99
+ {
100
+ "type": "testgaps",
101
+ "intervalMs": 1200000,
102
+ "priority": "normal",
103
+ "description": "Test coverage analysis",
104
+ "enabled": true
105
+ },
106
+ {
107
+ "type": "predict",
108
+ "intervalMs": 120000,
109
+ "priority": "low",
110
+ "description": "Predictive preloading",
111
+ "enabled": false
112
+ },
113
+ {
114
+ "type": "document",
115
+ "intervalMs": 3600000,
116
+ "priority": "low",
117
+ "description": "Auto-documentation",
118
+ "enabled": false
119
+ }
120
+ ]
121
+ },
122
+ "savedAt": "2026-01-07T03:37:50.198Z"
123
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "initialized": true,
3
+ "topology": "hierarchical-mesh",
4
+ "workers": [
5
+ "worker-alpha",
6
+ "worker-beta",
7
+ "worker-test-1"
8
+ ],
9
+ "consensus": {
10
+ "pending": [
11
+ {
12
+ "proposalId": "proposal-1767755978528-6nwb20",
13
+ "type": "feature",
14
+ "value": "new-feature-request",
15
+ "proposedBy": "system",
16
+ "proposedAt": "2026-01-07T03:19:38.528Z",
17
+ "votes": {},
18
+ "status": "pending"
19
+ }
20
+ ],
21
+ "history": []
22
+ },
23
+ "sharedMemory": {
24
+ "session/context": "{\"task\":\"fix formatting\",\"phase\":\"completed\"}",
25
+ "decisions/architecture": "null-checks-pattern",
26
+ "broadcasts": [
27
+ {
28
+ "messageId": "msg-1767755540633-dos7u7",
29
+ "message": "Formatting fixes complete",
30
+ "priority": "normal",
31
+ "fromId": "system",
32
+ "timestamp": "2026-01-07T03:12:20.634Z"
33
+ },
34
+ {
35
+ "messageId": "msg-1767755807511-4a6fbz",
36
+ "message": "Test broadcast message",
37
+ "priority": "normal",
38
+ "fromId": "system",
39
+ "timestamp": "2026-01-07T03:16:47.511Z"
40
+ }
41
+ ],
42
+ "test/data": "Hello World"
43
+ },
44
+ "createdAt": "2026-01-07T03:11:24.276Z",
45
+ "updatedAt": "2026-01-07T03:19:38.528Z",
46
+ "queen": {
47
+ "agentId": "queen-1767755484276",
48
+ "electedAt": "2026-01-07T03:11:24.276Z",
49
+ "term": 1
50
+ }
51
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "timestamp": "2026-01-07T03:37:50.198Z",
3
+ "projectRoot": "/workspaces/claude-flow/v3/@claude-flow/cli",
4
+ "structure": {
5
+ "hasPackageJson": true,
6
+ "hasTsConfig": true,
7
+ "hasClaudeConfig": false,
8
+ "hasClaudeFlow": true
9
+ },
10
+ "scannedAt": 1767757070198
11
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "timestamp": "2026-01-07T03:37:50.088Z",
3
+ "patternsConsolidated": 0,
4
+ "memoryCleaned": 0,
5
+ "duplicatesRemoved": 0
6
+ }
@@ -1,87 +1,15 @@
1
1
  {
2
- "startTime": 1767753334233,
3
- "sessionId": "session-1767753334233",
4
- "lastActivity": 1767753334233,
5
- "sessionDuration": 0,
6
- "totalTasks": 1,
7
- "successfulTasks": 1,
8
- "failedTasks": 0,
9
- "totalAgents": 0,
10
- "activeAgents": 0,
11
- "neuralEvents": 0,
12
- "memoryMode": {
13
- "reasoningbankOperations": 0,
14
- "basicOperations": 0,
15
- "autoModeSelections": 0,
16
- "modeOverrides": 0,
17
- "currentMode": "auto"
18
- },
19
- "operations": {
20
- "store": {
21
- "count": 0,
22
- "totalDuration": 0,
23
- "errors": 0
24
- },
25
- "retrieve": {
26
- "count": 0,
27
- "totalDuration": 0,
28
- "errors": 0
29
- },
30
- "query": {
31
- "count": 0,
32
- "totalDuration": 0,
33
- "errors": 0
34
- },
35
- "list": {
36
- "count": 0,
37
- "totalDuration": 0,
38
- "errors": 0
39
- },
40
- "delete": {
41
- "count": 0,
42
- "totalDuration": 0,
43
- "errors": 0
44
- },
45
- "search": {
46
- "count": 0,
47
- "totalDuration": 0,
48
- "errors": 0
49
- },
50
- "init": {
51
- "count": 0,
52
- "totalDuration": 0,
53
- "errors": 0
54
- }
55
- },
56
- "performance": {
57
- "avgOperationDuration": 0,
58
- "minOperationDuration": null,
59
- "maxOperationDuration": null,
60
- "slowOperations": 0,
61
- "fastOperations": 0,
62
- "totalOperationTime": 0
63
- },
64
- "storage": {
65
- "totalEntries": 0,
66
- "reasoningbankEntries": 0,
67
- "basicEntries": 0,
68
- "databaseSize": 0,
69
- "lastBackup": null,
70
- "growthRate": 0
71
- },
72
- "errors": {
73
- "total": 0,
74
- "byType": {},
75
- "byOperation": {},
76
- "recent": []
77
- },
78
- "reasoningbank": {
79
- "semanticSearches": 0,
80
- "sqlFallbacks": 0,
81
- "embeddingGenerated": 0,
82
- "consolidations": 0,
83
- "avgQueryTime": 0,
84
- "cacheHits": 0,
85
- "cacheMisses": 0
2
+ "timestamp": "2026-01-07T03:37:50.090Z",
3
+ "memoryUsage": {
4
+ "rss": 65044480,
5
+ "heapTotal": 11042816,
6
+ "heapUsed": 9247808,
7
+ "external": 2145622,
8
+ "arrayBuffers": 24811
9
+ },
10
+ "uptime": 1594.301482026,
11
+ "optimizations": {
12
+ "cacheHitRate": 0.78,
13
+ "avgResponseTime": 45
86
14
  }
87
15
  }
@@ -0,0 +1,10 @@
1
+ {
2
+ "timestamp": "2026-01-07T03:37:50.117Z",
3
+ "checks": {
4
+ "envFilesProtected": true,
5
+ "gitIgnoreExists": false,
6
+ "noHardcodedSecrets": true
7
+ },
8
+ "riskLevel": "low",
9
+ "recommendations": []
10
+ }
@@ -1,10 +1,10 @@
1
1
  [
2
2
  {
3
- "id": "cmd-hooks-1767753334342",
3
+ "id": "cmd-hooks-1767756988616",
4
4
  "type": "hooks",
5
5
  "success": true,
6
- "duration": 1.6436500000000365,
7
- "timestamp": 1767753334343,
6
+ "duration": 2.273775999999998,
7
+ "timestamp": 1767756988618,
8
8
  "metadata": {}
9
9
  }
10
10
  ]
@@ -0,0 +1,6 @@
1
+ {
2
+ "timestamp": "2026-01-07T03:27:50.072Z",
3
+ "hasTestDir": true,
4
+ "estimatedCoverage": "unknown",
5
+ "gaps": []
6
+ }
@@ -8,4 +8,4 @@ capabilities:
8
8
  optimizations:
9
9
  - context-caching
10
10
  - memory-persistence
11
- createdAt: "2026-01-07T02:35:32.708Z"
11
+ createdAt: "2026-01-07T03:36:27.039Z"
package/agents/coder.yaml CHANGED
@@ -8,4 +8,4 @@ capabilities:
8
8
  optimizations:
9
9
  - flash-attention
10
10
  - token-reduction
11
- createdAt: "2026-01-07T02:35:32.707Z"
11
+ createdAt: "2026-01-07T03:36:27.039Z"
@@ -7,4 +7,4 @@ capabilities:
7
7
  - best-practices
8
8
  optimizations:
9
9
  - incremental-analysis
10
- createdAt: "2026-01-07T02:35:32.708Z"
10
+ createdAt: "2026-01-07T03:36:27.039Z"
@@ -7,4 +7,4 @@ capabilities:
7
7
  - security-review
8
8
  optimizations:
9
9
  - pattern-matching
10
- createdAt: "2026-01-07T02:35:32.708Z"
10
+ createdAt: "2026-01-07T03:36:27.039Z"
@@ -7,4 +7,4 @@ capabilities:
7
7
  - coverage
8
8
  optimizations:
9
9
  - parallel-execution
10
- createdAt: "2026-01-07T02:35:32.708Z"
10
+ createdAt: "2026-01-07T03:36:27.039Z"
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/commands/agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,aAAa,CAAC;AAq2B1E,eAAO,MAAM,YAAY,EAAE,OA8B1B,CAAC;AAoCF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../../src/commands/agent.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,aAAa,CAAC;AAm3B1E,eAAO,MAAM,YAAY,EAAE,OA8B1B,CAAC;AAoCF,eAAe,YAAY,CAAC"}
@@ -270,17 +270,19 @@ const statusCommand = {
270
270
  if (status.metrics) {
271
271
  output.writeln();
272
272
  output.writeln(output.bold('Metrics'));
273
+ const avgExecTime = status.metrics.averageExecutionTime ?? 0;
274
+ const uptime = status.metrics.uptime ?? 0;
273
275
  output.printTable({
274
276
  columns: [
275
277
  { key: 'metric', header: 'Metric', width: 25 },
276
278
  { key: 'value', header: 'Value', width: 15, align: 'right' }
277
279
  ],
278
280
  data: [
279
- { metric: 'Tasks Completed', value: status.metrics.tasksCompleted },
280
- { metric: 'Tasks In Progress', value: status.metrics.tasksInProgress },
281
- { metric: 'Tasks Failed', value: status.metrics.tasksFailed },
282
- { metric: 'Avg Execution Time', value: `${status.metrics.averageExecutionTime.toFixed(2)}ms` },
283
- { metric: 'Uptime', value: `${(status.metrics.uptime / 1000 / 60).toFixed(1)}m` }
281
+ { metric: 'Tasks Completed', value: status.metrics.tasksCompleted ?? 0 },
282
+ { metric: 'Tasks In Progress', value: status.metrics.tasksInProgress ?? 0 },
283
+ { metric: 'Tasks Failed', value: status.metrics.tasksFailed ?? 0 },
284
+ { metric: 'Avg Execution Time', value: `${avgExecTime.toFixed(2)}ms` },
285
+ { metric: 'Uptime', value: `${(uptime / 1000 / 60).toFixed(1)}m` }
284
286
  ]
285
287
  });
286
288
  }
@@ -492,14 +494,16 @@ const poolCommand = {
492
494
  return { success: true, data: result };
493
495
  }
494
496
  output.writeln();
497
+ const utilization = result.utilization ?? 0;
495
498
  output.printBox([
496
- `Pool ID: ${result.poolId}`,
497
- `Current Size: ${result.currentSize}`,
498
- `Min/Max: ${result.minSize}/${result.maxSize}`,
499
+ `Pool ID: ${result.poolId ?? 'default'}`,
500
+ `Current Size: ${result.currentSize ?? 0}`,
501
+ `Min/Max: ${result.minSize ?? 0}/${result.maxSize ?? 100}`,
499
502
  `Auto-Scale: ${result.autoScale ? 'Yes' : 'No'}`,
500
- `Utilization: ${(result.utilization * 100).toFixed(1)}%`
503
+ `Utilization: ${(utilization * 100).toFixed(1)}%`
501
504
  ].join('\n'), 'Agent Pool');
502
- if (result.agents.length > 0) {
505
+ const agents = result.agents ?? [];
506
+ if (agents.length > 0) {
503
507
  output.writeln();
504
508
  output.writeln(output.bold('Pool Agents'));
505
509
  output.printTable({
@@ -508,7 +512,7 @@ const poolCommand = {
508
512
  { key: 'type', header: 'Type', width: 15 },
509
513
  { key: 'status', header: 'Status', width: 12, format: formatStatus }
510
514
  ],
511
- data: result.agents
515
+ data: agents
512
516
  });
513
517
  }
514
518
  return { success: true, data: result };
@@ -569,43 +573,55 @@ const healthCommand = {
569
573
  output.writeln();
570
574
  output.writeln(output.bold('Agent Health'));
571
575
  output.writeln();
572
- // Overall summary
576
+ // Overall summary with null checks
577
+ const overall = result.overall ?? { healthy: 0, degraded: 0, unhealthy: 0, avgCpu: 0, avgMemory: 0 };
578
+ const avgCpu = overall.avgCpu ?? 0;
579
+ const avgMemory = overall.avgMemory ?? 0;
573
580
  output.printBox([
574
- `Healthy: ${output.success(String(result.overall.healthy))}`,
575
- `Degraded: ${output.warning(String(result.overall.degraded))}`,
576
- `Unhealthy: ${output.error(String(result.overall.unhealthy))}`,
577
- `Avg CPU: ${result.overall.avgCpu.toFixed(1)}%`,
578
- `Avg Memory: ${(result.overall.avgMemory * 100).toFixed(1)}%`
581
+ `Healthy: ${output.success(String(overall.healthy ?? 0))}`,
582
+ `Degraded: ${output.warning(String(overall.degraded ?? 0))}`,
583
+ `Unhealthy: ${output.error(String(overall.unhealthy ?? 0))}`,
584
+ `Avg CPU: ${avgCpu.toFixed(1)}%`,
585
+ `Avg Memory: ${(avgMemory * 100).toFixed(1)}%`
579
586
  ].join(' | '), 'Overall Status');
587
+ const healthAgents = result.agents ?? [];
580
588
  output.writeln();
581
589
  output.printTable({
582
590
  columns: [
583
591
  { key: 'id', header: 'Agent ID', width: 18 },
584
592
  { key: 'type', header: 'Type', width: 12 },
585
593
  { key: 'health', header: 'Health', width: 10, format: formatHealthStatus },
586
- { key: 'cpu', header: 'CPU %', width: 8, align: 'right', format: (v) => `${Number(v).toFixed(1)}%` },
594
+ { key: 'cpu', header: 'CPU %', width: 8, align: 'right', format: (v) => `${Number(v ?? 0).toFixed(1)}%` },
587
595
  { key: 'memory', header: 'Memory', width: 10, align: 'right', format: (v) => {
588
596
  const mem = v;
597
+ if (!mem)
598
+ return '0%';
589
599
  return `${(mem.used / mem.limit * 100).toFixed(0)}%`;
590
600
  } },
591
601
  { key: 'tasks', header: 'Tasks', width: 12, align: 'right', format: (v) => {
592
602
  const t = v;
593
- return `${t.active}/${t.completed}`;
603
+ if (!t)
604
+ return '0/0';
605
+ return `${t.active ?? 0}/${t.completed ?? 0}`;
594
606
  } }
595
607
  ],
596
- data: result.agents
608
+ data: healthAgents
597
609
  });
598
- if (detailed && result.agents.length > 0) {
610
+ if (detailed && healthAgents.length > 0) {
599
611
  output.writeln();
600
612
  output.writeln(output.bold('Detailed Metrics'));
601
- for (const agent of result.agents) {
613
+ for (const agent of healthAgents) {
602
614
  output.writeln();
603
615
  output.writeln(output.highlight(agent.id));
616
+ const uptime = agent.uptime ?? 0;
617
+ const latency = agent.latency ?? { avg: 0, p99: 0 };
618
+ const tasks = agent.tasks ?? { completed: 0, failed: 0, queued: 0 };
619
+ const errors = agent.errors ?? { count: 0 };
604
620
  output.printList([
605
- `Uptime: ${(agent.uptime / 1000 / 60).toFixed(1)} min`,
606
- `Latency: avg ${agent.latency.avg.toFixed(1)}ms, p99 ${agent.latency.p99.toFixed(1)}ms`,
607
- `Tasks: ${agent.tasks.completed} completed, ${agent.tasks.failed} failed, ${agent.tasks.queued} queued`,
608
- `Errors: ${agent.errors.count}${agent.errors.lastError ? ` (${agent.errors.lastError})` : ''}`
621
+ `Uptime: ${(uptime / 1000 / 60).toFixed(1)} min`,
622
+ `Latency: avg ${(latency.avg ?? 0).toFixed(1)}ms, p99 ${(latency.p99 ?? 0).toFixed(1)}ms`,
623
+ `Tasks: ${tasks.completed ?? 0} completed, ${tasks.failed ?? 0} failed, ${tasks.queued ?? 0} queued`,
624
+ `Errors: ${errors.count ?? 0}${errors.lastError ? ` (${errors.lastError})` : ''}`
609
625
  ]);
610
626
  }
611
627
  }