South Korean President Chun Doo Hwan's just-concluded visit here climaxed a triumph in secret diplomacy by the Reagan administration conducted out of an obscure downtown Washington office before the newly elected president had assumed power.

Had it not been for President Reagan's informal intervention through his national security assistant, Richard V. Allen, Chun certainly would not have been Reagan's guest at Blair House. Korean dissident Kim Dae Jung would have been executed, U.S.-Korean relations would be at an all-time low and South Korea would stand as an outlaw nation in the eyes of the world. l

Instead, Gen. Chun's regime has won legitimacy, its more moderate elements strengthened enough to plant hope for democratization ahead. Reagan's mixture of determination and flexibility suggests he may not only restore tattered alliances such as the Korean link but possibly achieve more in human rights than Jimmy Carter's self-righteous approach.

When we visited Seoul last September, the situation looked bleak. Chun's most moderate advisers contended he could not bow to Carter administration public demands to spare the life of Kim Dae Jung, accused of subversion and sedition. If he did, Chun's brief presidential tenure might end abruptly. Having just formalized his previous role as strong man of the military regime, Chun was dependent on the hard-line young colonels who engineered the coup that brought him to power. They would not tolerate losing face by surrendering to Carter.

Consequently, there is agreement in Korea that Kim would be dead today had President Carter been reelected. Actually, the supposition there immediately after Nov. 4 was that Reagan's win also doomed Kim. Jubilant colonels in Seoul toasted the Republican victory, rejoicing that troublesome Carter had been replaced by permissive Reagan, who would give them a free hand on Kim Dae Jung.

They misread Ronald Reagan. He authorized Allen to leak a story that the president-elect opposed Kim's execution and believed it would harm U.S.-Korean relations. A news report quoting a "senior aide" to that effect appeared in the Nov. 18 New York Times.

It did not do the trick. Koreans well placed out side the government informed us that the colonels interpreted it as political posturing to protect Reagan from being blamed for Kim's death. The Koreans told us Reagan must do more to prevent the execution before Jan. 20. But if he went public, Reagan's advice would have to be spurned, just as Carter's was, in order to save Chun's face. The recommendation by these Koreans: a confidential letter to Chun from Reagan, delivered by an American or Korean businessman. l

We relayed this information to the Reagan camp. A letter to Chun was quickly ruled out. So was any other direct activity by the president-elect. Nor could he work through the State Department while Carter was president; starting Nov. 4, the Chun regime would not seriously discuss Kim with U.S. diplomats. How, then, could a catastrophe in U.S.-Korean relations be prevented before Reagan had the power to act?

With Reagan's approval, Dick Allen started secret negotiations with Korean emissaries, most held in his private office at 16th and I streets here. To guard against publicity that could have aborted the delicate process, nothing was said to the State Department.

Allen's first talks were held in November with Gen. Lew Byung Hyun, chairman of the Korean Joint Chiefs of Staff. Allen was blunt: killing Kim would do irreparable damage to South Korea's relations with the world, particularly Japan and the United States; hopes of reviving the alliance under Reagan would disappear.

In December, Allen stepped up the pace. He conferred twice with the man sent by Chun to Washington to represent him personally: the Korean Embassy's minister, Gen. Sohn Jang Rae. Allen extended Reagan's invititation to visit Washington immediately after the inauguration. Nothing was to be said publicly. Just before Christmas, Chun tentatively accepted.

That at least bought time. Having accepted the invitation, Chun could not permit Kim's execution before Jan. 20. Even if the death sentence were not commuted, Reagan could deal with the problem once he had taken office. But there was realistic hope that Seoul would grant clemency before Chun's trip, if only to avoid full-blown demonstrations in front of the White House against the Korean president (in contrast to the actual token protests).

Not until Jan. 20 did Reagan learn of Chun's decision to commute Kim's sentence to life imprisonment, quickly followed by his lifting of martial law. South Korea had opted for respectability. The regime's moderate elements were strengthened, and the hard-line colonels dealt a severe blow. It was Ronald Reagan's triumph, accomplished without oozing preachments of paternalistic America that for four years have managed to undermine U.S. alliances while failing to improve human rights.