Its been restated by plenty here but just to get some refocused discussion on this.
There are still 3 main issues at play here:
1. Durand line: This was done between Afghan Emirs and the Brits in 1893 which EVERY Afghan government since 47 has rejected it saying it was void by the Brits leaving. This is a STATE practice REGARDLESS of WHO RULES AFGHANISTAN. Now, they are using it to give sanctuary to TTP basically under the guise of getting some territory. This is a long standing emotional string pulled by every Afghan government EVER.
2. TTP: This movement was practically DEAD late 2020 and then suddenly when the TTA take over - they freed even those TTP that were jailed in Afghanistan by Ghani through pressure from the US... under the aspect that all TTP are their brothers. They are treating the TTP as an ethnic brotherhood - not as a foreign terrorist force for a variety of reasons that also tie back to how Islamabad pre-2001 created the Taliban and promoted intermarriages in FATA and Afghanistan border regions(more than the usual)
3. Pakistan expected a lot more out of the Taliban and instead they got their ... handed back to them because the Afghan did not care for Pakistan's help. Unfortunately only ignorant people tie this to Pakistan role in WoT when infact even in the first Afghan Emirate the Taliban really did not deliver ANYTHING to Pakistan and WERE STILL HARPING ON THE DURAND line - with only Haqqani and a few others helping keep the peace.
Basically, the establishment's breeding of snakes (For goals that ranged from keeping the Soviets out to "second army" to establishing free trade corridor to central asia) backfired.
Barring the overall aspect of Pakistan's own failed system -
The only logical path that emerges knowing how the Afghan acts is:
1. Pakistan stops caring and even talking on Durand line but also does not try to "invade"
2. Kabul is told - keep the border districts clean of TTP and we stop the bombing, open all trade with additional sweeteners thrown in.
3. Fix your own governance and political mess in KP - APOLOGIZE for how your operations against TTP impacted civilians REGARDLESS of how the local population did or did not behave because at the end they are YOUR countrymen and NOT KABULs. No matter HOW THEY acted before - you serve THEM.
4. Linking to 2 - both let those that get money from trade in those area get it but provide the people of the area more incentives to make money eastward, northward and other places. Give them alternative ways to make money with what they do currently and then over a decade or so wean them off.
Those trade programs and schools are great until you cannot have these people make the same amount of money they were before. If growing and pushing drugs, smuggling or even militant groups provides more - why would someone choose a lower paying trade in this era of expense? Expecting "honesty" from people who really do survive in abject poverty is idiotic while you live great lifestyles.