Gmail whoami (signed-in account)
Report which Gmail account this browser is signed in as: display name and email, from Gmail's account switcher. When the browser is signed out, the run fails with a signed-out error that asks to sign in to Gmail, so it can be used to check a session before running other Gmail scripts.
Input
account optionalOptional Google account to report on, for a browser signed into several: its email address, or a bare mailbox index such as "2". Omit for the first account (u/0).
Output
loggedIn requiredname optionalemail optionalFAQ
Search Gmail
Search the signed-in Gmail with the native query syntax (from:, to:, subject:, has:attachment, after:/before:, labels…) and return matching threads: threadId (feed it to get_thread / reply_to_email), sender, senderEmail, subject, snippet, date, unread, starred, hasAttachment. Results are threads rather than individual messages, which is Gmail's own search granularity, and only the first page of results is returned (up to 50).
Send Gmail email
Send an email from the signed-in Gmail account, with a plain-text body and up to 10 file attachments in the same email (attachment, attachment2 ... attachment10; name them with attachmentNames). Returns every attachment's name as Gmail showed it before sending. Always starts a new conversation. To answer inside an existing thread, use mail.google.com/reply_to_email.
Get Gmail thread
Read a Gmail thread by its hex threadId (as returned by search_emails): subject plus every rendered message's from, fromEmail, to, date, plain-text body and attachment names. In long threads Gmail collapses older messages, so only rendered (expanded) messages are returned.
