When it's payday for the few Afghans still allowed to work for the American Embassy in Kabul, administrative officer Peter S. Flynn counts out the money himself. The Soviet-installed Afghan government has arrested most of the local workers who used to handle the payroll.

When a local truck tries to deliver cases of soda for the Marine guards who live on the embassy compound, a scuffle often breaks out. Vehicles with Afghan license plates are not allowed inside the embassy compound.

The 20 Americans assigned to the Kabul embassy operate in one of the most hostile environments of any U.S. diplomatic mission in the world. Even more than in eastern Europe or the People's Republic of China, they are isolated almost totally from their host country's people and officials, hampered in their work by the arrests of local employes, and subject to frequent officially organized demonstrations.

"There is a very high degree of official hostility, as high as it can be and still have an embassy there," said Charles F. Dunbar, who recently completed a 22-month assignment in Kabul. During the last 16 months he served as charge d'affaires, the highest ranking U.S. official in Afghanistan.

"Hostility certainly is the operative word," said Dunbar, who has been assigned to Washington for Arabic-language training.

The hostility reached a peak this winter, when the Afghan authorities picked up and presumably jailed more than a dozen local employes of the embassy, virtually the entire white-collar clerical staff.

The local workers, many of whom were long-time employes of the embassy, were the backbone of its operations, taking care of payrolls, handling local purchases, getting supplies through customs, working as receptionists, talking to people allowed to apply for visas and translating local papers.

U.S. officials assumed that local employes had been pressured by the Afghan secret police to spy on their American employers, so they were carefully isolated from any embassy secrets. For their part, the employes were obviously fearful of being considered U.S. agents, so they were careful never to meet alone with Americans in the embassy.

One man, a guard at the embassy gate who was arrested in the spring of 1982, later appeared on Afghan television in what Dunbar described as "an anti-American spectacular." This man described the embassy as a nest of spies, which Dunbar vehemently denied.

Dunbar contended that employes of the U.S. Embassy were singled out by Afghan authorities, while other diplomatic missions were left untouched. He said American diplomats also face other forms of everyday harassment not meted out to the few other free-world nations with embassies in Kabul: France, Italy, West Germany, Britain, Turkey and Japan.

There are frequent, officially organized demonstrations outside the once-beautiful embassy compound, he said, which is guarded by special elements of Afghan secret police instead of the ordinary police assigned to most missions.

No Afghan citizens are allowed into the embassy or any American diplomat's home, with the exception of the few who have permission to work in those places or were given clearance to come in for visas. Even foreign visitors have to prove their identities before police will allow them through the gate.

Further, no cars with Afghan licenses are allowed through the gate and "low-level fights" sometimes develop over deliveries. "It's a constant struggle to bring supplies in, part of the visceral hostility of low-level functionaries," Dunbar said.

But the worst problem, he said, was the disappearance of the local embassy employes. "It was the most agonizing form of harassment that I faced, the feeling of pain and frustration of having those people arrested and being able to do nothing."

The first four local employes were picked up early last year, Dunbar said. There was a pause until last March and April, near the fifth anniversary celebration April 27 of the "Saur Revolution" that turned Afghanistan communist, when another 15 embassy employes were picked up.

Dunbar believes they were all jailed, but Afghan officials have never confirmed it. Later, another six employes were forced to resign. In all, three-fourths of the local white-collar employes either disappeared or were forced to quit, though gate guards and a few house servants were allowed to continue working for the Americans.

Three Indian citizens employed at the embassy were told by Afghan authorities they could no longer get the visas that allowed them to keep their jobs. In addition, a Pakistani who worked for the embassy in an administrative position was arrested at his American-owned house in what both the United States and Pakistan argue is a violation of diplomatic immunity.

The Pakistan government has been allowed consular access to its citizens in jail, and the arrests of the Afghan employes have stopped, possibly as a result of strong protests leveled at the Afghans by the United States and other non-communist diplomatic missions in Kabul.

The local staff of the embassy now consists of a medical lab technician, a translator, a clerk in the budget office, a telephone technician, a mail clerk and a telephone receptionist.

Without the local help most embassies rely on, the administrative officer, Flynn, does payroll duty. Gladys Rigsby, the embassy secretary, doubles as a consular officer, as does Lee O. Coldren, the number two man under Dunbar's replacement, Edward Hurwitz.

All lead rather isolated lives in what once was a prized, peaceful and relatively undemanding post.

The Americans still can walk safely through the more westernized sections of Kabul, though Dunbar said he warned against going into the once-popular, crowded old bazaar area. Americans are welcomed into carpet, antique and jewelry shops on Chicken Street, once a haunt of tourists on the "Hippie Trail"--especially when the owners realize they are not Soviets.

The United States refuses to recognize the government of Babrak Karmal, which was installed on the backs of Soviet tanks and airborne troops in December, 1979, with the overthrow of the unstable though communist government of Hafizullah Amin. Washington, however, continues to recognize Afghanistan as a country, which is why the United States maintains an embassy there.

"The Afghans are willing to have us there because our presence lends a degree of legitimacy to their government," Dunbar said.

But during his 22 months in the country, Dunbar said he saw no Afghan government official except members of the Foreign Ministry's protocol branch, with whom he dealt on consular or administrative matters. The United States has a policy of limiting its contact with the Babrak government.