In all cases you must temporarily surrender your passport to get a renewal.
You can do it by mail, either through the regular or expedited process. To get an urgent same-day passport in person, you usually have to demonstrate the need for it (travel in a week or so). You can also use a passport service which you authorize to do the in person visit.
The issue with a damaged passport is that it can be altered -- if it's delaminated and the photo is falling off, the photo could be replaced. Hole punches could be disguised as tears to the page.
The lost passport procedure is the same as for a new passport -- you have to apply in person at an agent (regular or expedited) or at a passport office (urgent). You also have to provide a sworn statement as to what happened to your old passport.
I haven't had experience with getting a passport at a consulate.