U.S. special envoy Philip C. Habib said today that "we are working on finishing up our task" of negotiating an agreement to forestall an Israeli attack on West Beirut and send the thousands of trapped Palestinian guerrillas out of Lebanon.

Habib's departure from his normally sealed-lip style of diplomacy was echoed by caretaker Prime Minister Shafiq Wazzan, who told reporters after their meeting, "There is a better situation today than yesterday. Things are slowly becoming clearer."

But Saeb Salam, the veteran Sunni Moslem former prime minister who has been the key man in the indirect dealings between Americans and Palestinians, stressed the difficulties still ahead.

The more positive outlook expressed here, as well as the relative optimism from Israel, surprised many diplomats and Lebanese analysts.

Their pessimism had stemmed from the Palestinians' delaying tactics--the guerrillas have acknowledged they are playing for time--and the still unsolved problems remaining.

Salam noted "intricate and time-consuming procedures" involving details of the "package deal," which he said "could not be concluded overnight."

He indicated that the details had become as important as the principle of evacuation that the Palestinians accepted Sunday, conditioned on Israeli acceptance of an honorable way out for them.

Both Salam and diplomats mentioned the difficult problems of where, when and how the Palestinian troops and their leaders might go if they left Lebanon.

So far, no Arab country has offered to take the Palestinians, although the visit to Paris yesterday of Egyptian Deputy Foreign Minister Butros Ghali reportedly dealt with that problem.

In Paris, French Foreign Minister Claude Cheysson told the National Assembly that the Palestine Liberation Organization must represent the Palestinians in any peace talks with Israel, and he urged that the PLO not be annihilated and dishonored after its military defeat, United Press International reported. Cheysson also said France would send a special envoy to the Middle East to help negotiate a solution to the Lebanon crisis.

With Israel having agreed to allow the Palestinian forces to take personal light weapons with them, diplomats are trying to work out the practical problems involved in that many armed troops boarding and traveling in foreign vessels, aircraft or land vehicles. A departure by sea has been mentioned as a way of sparing the departing Palestinians the humiliation of having to travel along some 18 miles of Israeli-controlled road on their way to exile in Syria.

Informed sources said, meanwhile, the Palestinians want to take away "more than twice" the 5,000 Palestinian fighters previously mentioned.

Salam, speaking of the problems, asked, "Where do they go, how do they go, who is responsible for taking their arms from them? They can't just throw their arms at the feet of the Israelis and walk out."

Such practical considerations underlined one veteran Lebanese analyst's concern that neither PLO leader Yasser Arafat nor his chief lieutenants seemingly had faced the difficult political decision of laying out the PLO's role outside Lebanon.

These doubts were reflected in a commentary by Wafa, the Palestinian news agency, that betrayed anguish at the prospect of the PLO's becoming a purely political entity outside this country.

Wafa said that without their guns, the guerrillas' "very existence as representatives of the Palestinian people everywhere would be mortally endangered."

The news agency added, "There is a bottom line beyond which it the PLO will not go. The Palestinian resistance has no intention of leaving Lebanon. For if it did and was forced to take refuge in one of the Arab states whose regimes are in bloody complicity with the U.S.-Israeli butchers, it would be finished."

The commentary appeared aimed at defending PLO claims to a vestigial military presence under tight Lebanese Army control and maintaining the same kind of status as enjoyed in other Arab capitals for its political, research-institute and commercial activities in Lebanon.

Despite such brave talk, the Palestinians appear to have done little to prepare for the threatened Israeli onslaught and their troops, if anything, are more relaxed as a result of the five-day-old cease-fire than at any time since the invasion began June 6.

Although Salam said the Palestinians were still insisting on leaving a token military force in Lebanon, along the lines of regular Palestinian troops elsewhere, officered and controlled by their Arab host governments, he reiterated his unbending conviction that henceforth "the PLO can no longer be a military entity." In the future, he said, it must "fight for its cause by nonmilitary means."

In any case, Israel and the Christian side of the divided Lebanese government--President Elias Sarkis and Foreign Minister Fuad Butros--are adamantly opposed to even a token Palestinian military presence in Lebanon.

Salam warned reporters that the "Israelis did not care" about the fate of West Beirut because "they think they have complete military hegemony."

He credited Egypt and Saudi Arabia with "working hard with the Americans to impress them with the danger of Israel's invasion and the continuation of [its] hard attitude.