Internal developments in Iran have been the driving force for the whole Mideast since the shah began to topple a year ago. The course of events has brought new opportunities for American diplomacy as well as new dangers.

But the Carter administration, obsessed with the illusion that everything depends on Israelis and Palestinians, has turned a blind eye to the far more significant happenings affecting Iran and its neigbors. So when Iranian students seized the American embassy in Tehran over the weekend, Washington was on the defensive and took, not the firm stance enjoined by circumstances, but a craven position.

The steady drift of affairs inside Iran has been toward chaos. The Ayatollah Khomeini has not been able to translate into into simple acts of government the fervid faith that brought him back to succeed the shah. Law and order in Tehran have fallen in to the hands of bully boys. Around the edges of what used to be the shah's empire, there has been incipient revolt.

The response of the ayatollah to this coming-apart has been to push Islamic principle with ever-increasing intensity. He is working up a new constitution that vests absolute power in his person. He has moved to export the Shi'ite form of Islam to neighboring countries where the most orthodox Moslems, the Sunnis, are in power.

Neighboring countries have, naturally, dug in hard against Shi'ite activism. In Iraq, where a radical secular regime holds sway, President Saddam Hussain staged a preemptive coup in July to get a tighter grip on affairs. Last week, in another major development, the Iraqis denounced a 1975 treaty with Iran that governs borders, minorities in the Persian Gulf. The Iraqi break with Iran has had repercussions on Syria, the Palestine liberation Organization and the oil monarchies of the Persian Gulf.

These developments have given the United States new room to maneuver. The ayatollah has to practice an imperial policy in Iran and needs American arms. Iran and needs American arms. Iraq and Syria are both open to gestures of interest from this country. Washington could encourage the Gulf states to take action toward their joint security. It could tie up oil deals with the other Gulf states, leaving the Iranians to sell their crude to the Germans, the Japanese, the French and whoever else is willing to buy.

But the carter administration has expended all of its energy in the Middle East on forcing Israelis to be nice to Palestinians. It has left Iranian affairs in the hands of a Foreign Service officer, Undersecretary of State David Newsom, who is renowned for his mild manner and lack bureaucratic clout.

So the United States has been turning the other cheek when the ayatollah says that U.S. imperialism is the No. 1 enemy of the Iranian nation in revolution. Washington resumed the flow of arms last summer without stipulating any conditions.

The same soft policy obtained last week when Iranian students began picketing the American embassy to protest the medical care being given the shah in this country. Then the students seized the embassy and held Americans hostage. The State Department said it was negotiating with the Iranian government to ensure the safety of Americans. "We appreciate the efforts of the Iranian government," the department said in a notable display of timidity.

As long as Americans are held hostage, this country will probably have to follow through on that pusillanimous line. But once the immediate danger is over, a firm stance should be taken.

This country should close its embassy in Tehran and shut down the Iranian embassy here. It should deport the thousands of Iranian students now living in this country without proper papers. It should rally the multiple forces working to contain the ayatollah. For unless it takes such steps, the continuing unraveling of Iran will spread chaos through the area in ways that eventually play into Russian hands.

Partisans of Jimmy Carter like to say that he doesn't panic in a crisis. The test now being posed in Tehran raises the question of whether he does anything.