“Even before the Taliban’s stunning takeover this week, American military and intelligence officials were racing to devise plans for containing extrem