Cops can ask for ID (which you do have to provide, sadly) and can briefly frisk you to look for weapons -- if they have reasonable suspicion to believe a crime has or is about to happen.
One other thing of note and what makes this situation a bit odd is that once you get into a TSA line (basically past the first TSA person), you legally have to complete it. But the TSA is not law enforcement and they cannot detain you.
This is different for foreign nationals trying to enter the country (you can be turned away), but U.S. citizens have a right of return (though you can get held for a long time if they make up some reason to suspect you for simply refusing to answer questions.)
And the OP ought to file a complaint with TSA and FOIA the incident report. He should also talk to CCR about a possible lawsuit. Being detained for 18 hours without food or water is dangerous and illegal.
Also fuck JetBlue. Remember they voluntarily turned over their entire customer database to the feds in 2002 to help with datamining. Sounds to me like JetBlue also violated common carriage rules. A captain can refuse to transport a passenger for any reason, but an airline cannot.