IN this dirt-street Pakistani border post, the Afghan war is in the endgame - for everyone but the Afghans.Western diplomats herald brisk diplomatic moves to settle the 13-year civil war. Afghan rebels celebrate recent military gains against President Najibullah in Kabul. Aid from the United States and Saudi Arabia to the rebels shrinks. But Afghan commanders still call for more weapons to counter continued Soviet backing of Kabul. And cash-strapped aid agencies scratch for funds to help Afghans go home. Thousands of refugees are stuck in sprawling Pakistani camps, afraid of fighting and landmines in Afghanistan. "There have been steps forward. We know the end of the road is out there somewhere," says a Western official. "We just have to convince the Afghans." For their part, the patrons in this proxy war - the US, the Soviet Union, Pakistan, Iran, and Saudi Arabia - are increasingly anxious to get out. All have welcomed a new United Nations initiative. After months of trimming assistance, the US, which provides $250 million a year to the guerrillas, is threatening to cut the mujahideen (resistance fighters) out of the next fiscal budget. The Saudis, the rebels' other major backer, are also less generous. The Saudis, who joined the US-led coalition in the Gulf war, feel betrayed by their fundamentalist Afghan favorites who backed Iraq, analysts say. In turn, Iran has broadened its role, pushing Shia mujahideen based in Tehran to join Sunni Afghan rebels in Peshawar for recent talks. And Pakistan, which had long urged the Afghan rebels to seize Kabul, decided last April to press for a political settlement, although there is still support for fundamentalist leader Gulbuddin Hekmatyar. Yet the big sticking point is Najib, the Afghan president who defied a predicted collapse after the Soviet withdrawal in 1989 and holds most of the towns. The guerrillas control almost the entire countryside. The US wants Najib to hand over most of his powers to an interim authority. The Soviets say he should surrender only enough powers to clear the way for elections. Moscow, worried about its southern border and Afghanistan's impact on Soviet central Asia, channels more than $200 million a month to keep Najib in power. Much of the Afghan resistence, though, refuses to accept even interim powers for Najib, formerly head of Kabul's brutal secret police, which is blamed for the deaths of thousands of Afghans. Equally, they despise Mr. Hekmatyar, who has battled rival mujahideen and enjoyed a large share of US arms thanks to Pakistani favoritism. For years, Pakistan has controlled the flow of US weapons to the rebels. "It's very emotional. It doesn't make any difference that Najib is the single most qualified Afghan to run the country," says a senior Western diplomat in Islamabad. "The devil on this side is Hekmatyar," says the official, saying that Pakistani officials secretly explored with Kabul a powersharing deal between Najib and Hekmatyar. "That's almost as ludicrous as saying that military pressure will bring down Kabul." So the political and military drift continues amid a growing Western distaste for Afghan infighting and intransigence. Flushed with their April capture of Khost, a small government garrison near the Pakistani border, the rebels have buzzed with reports of an impending attack on Gardez, a town south of Kabul. "We have already taken Khost," says a spokesman for Jalaluddin Haqqani, leader in the Khost attack. "We will finally take Kabul." But Western observers in Peshawar say the conquest of Khost had an unsavory end. After taking the town, the rebels squabbled over the captured weapons and ammunition and the town was totally looted. "From 1979 to 1989, they were real freedom fighters. Now they are pure mercenaries," says a Western intelligence official in Peshawar. "Khost is free now, but is it really free? It's a big junkyard." The Khost incident has further disgraced the already discredited Afghan resistence in Peshawar. Western officials say residents of Kandahar, where rebels have reached a comfortable truce with the government, asked mujahideen not to attack. Squabbling already has doomed one exile government and tainted the so-called commanders' shura, or council, which last year was promoted by Pakistani and US intelligence officials as the rebels' final chance to form a united front. "They call themselves a commanders' shura just to try to get money," says an Afghan aid official. "Everyone knows the lifestyle of the Afghan leaders. It's a totally corrupt system." Nor has Khost's fall altered the overall deadlock or stopped the political interplay. As Najib has tried to negotiate with moderate rebels and supporters of the exiled King Zahir Shah, the return of former president Babrak Karmal from the Soviet Union has been interpreted by some as Moscow's effort to undermine Najib. In Pakistan, resentment over the presence of more than 3 million Afghan refugees is building pressure for a settlement, officials say. Although Pakistani infighting over controlling Afghan policy has abated and the foreign office is playing a larger role, the country's military intelligence apparatus is still in control, observers say. As the longtime conduit for military assistance to the Afghan rebels, intelligence officials this spring shifted gears from backing military action to political negotiations. "The military feels that it's the end of the game," says an Army analyst. "In Afghanistan, between now and next year, the party will be over."