flash-mac: auto-run ac-login if ~/.ac-token is stale
Split the script's bootstrap into two phases:
Phase 1 (as user): check ~/.ac-token expiry. If within 60s of
expiring (or missing entirely), invoke tezos/ac-login.mjs to open
the OAuth browser dance. The fresh token lands at ~/.ac-token.
Phase 2 (re-exec as root via sudo): carries on with the existing
privileged flash work.
Why split: ac-login.mjs needs to open a browser as the actual logged-in
user (not root), so we can't wait until after the sudo escalation.
Doing it unconditionally in phase 1 means a reflash always produces
a fresh token for the MongoDB fetch in the newly-root phase — which
means a reflash always bakes the latest Claude OAuth token and
GitHub PAT into the initramfs without any manual pre-step.
If ac-login.mjs isn't found (e.g. user copied just flash-mac.sh to
another machine) we warn and proceed; the downstream MongoDB fetch
will then fail-soft with a "creds fetch: skipped" log.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>