What Pakistan did during Soviet Invasion of Afghanistan was the best we could. We usually lash out on our policies during that phase, rather impulsively and habitually, I might add, but it's important to remember the threat matrix for Pakistani establishment, at that time, dictated the need to thwart possible Soviet advance inside our borders and halt her expanding influence by any and all means necessary.
Where failure lies, however, is in the modalities, not the conception of threat. We proceeded to act upon our national security policy at that time rather incautiously. Providing a more selective, and controlled assistance to resistance, one that didn't radicalize our society so disastrously must have been pursued. A farsighted analysis as to how the conflict in Afghanistan could have had spilled over to our side of the fence and perpetuate decades long bloodshed ought to have been anticipated and a strategy precluding or minimizing said ripples must have been formulated and implemented.
As far as the question of 'whether it was in our best to respond to evolving situation in Afghanistan?' is concerned, the answer is a definite yes. The questions, rather the debate, essentially boils down to 'how and to what extent, if at all, should we have extended military assistance to factions resisting the Soviets' and whether military involvement was needed at all?' This is indeed something to looked into by qualified persons lest we repeat those errors.