Artificial intelligence (AI) promises remarkable gains in productivity, science, medicine and education. But it is also poised to wipe out millions of jobs, hollow out the middle class, and drain the tax revenues that pay for hospitals, schools and pensions. The process has already begun, and the time to act is running out.