Withdrawal from Afghanistan was required.
But perhaps America should consider a "Forward Policy" - Forward deployment of Airborne Assets surrounding and containing Taliban areas. Bases in Tajikistan, Uzbekistan, Pakistan and UAE. Iran wont allow US assets to be deployed on its soil, but perhaps the Iranians can be incentivised to contain Taliban from the West. Drones, High altitude Bombers, Electronic Warfare and Recon aircraft flying over Afghanistan keeping a 24/7 watch.
This kind of containment will be cheaper and entail less risk to Western Allies while achieving the ultimate goal of ensuring that the Taliban are contained within the Durand Line and that its territory is not used as a safe haven by terrorists.
Or you can do "geopolotics on the cheap".
If you inflame fundamentalist rhetoric, on both sides of Iran-Afghanistan border, strongly enough -- they'll not get around to cooperate very easily. Fundamentalist Shias and fundamentalist Sunnis are not the best bedfellows (as in "hate each other like poison"). Which means they will contain each other minimum, and maybe fight. So you don't worry too much.
Uzbekistan is already gearing up to contain threat from the south, and small targeted military support can go a long way there (Uzbekistan military is relatively well-trained and motivated, with plenty of Soviet arms in good shape. They might need a bit of modern tech here and there, and might even appreciate getting it).
Turkmenistan and Tajikistan are more problematic -- longer and less defensible borders, governments less obvious to invest in defense. Tajikistan has defense treaties with Russia, so on the one hand, Russia should protect it (whether it can, and will -- is a very good question). Turkmenistan is staunchly isolationist (probably the only country in the world, having no visa-free travel with anyone on Earth), but despite its authoritarian quirks, it's a secular government, and faced with existential threat from religious fundamentalists, it might look for military support elsewhere. What capability does their military have -- somebody more knowledgeable should chime in.
Now, the Durand line. Actually, if somebody wanted to create difficulties to the China-Pakistan axis, isn't it most natural to let Taliban dig under this fixture? I mean, any Afghan government, for the last hundred years or so, is more or less openly questioning validity of that border, and "fairness" of Afghanistan remaining land-locked, despite it's "historical rights" to access the sea. Now, for the first time in decades, Afghanistan will have a government that has means of outward expansion (gotta deploy all of those high-adrenaline fellas somewhere, and Americans have left enough guns to fight a hell of a war...)