If you are traveling imminently, you can request an emergency passport from the US embassy. It’s good for 1 year, & is a fully valid passport. If you apply for a new, regular passport while the emergency passport is still valid, there is no additional charge. Email them with “urgent” in the subject. This happened to me when moving from Hong Kong to Thailand. I emailed the US embassy in HK in a panic, no room left in passport, they told me to come in the next day for an emergency passport. Got it that day.
You apply at immigration for the Non-O 90 day visa, then when approved it converts to a 1-year retirement extension. You must be 50 years old, & have 800,000 THB in your Thai bank account. Some other requirements. There is a lot about this in this facebook group.