fix(auth): exit non-zero when login is needed and stdin is not a terminal
Commands that need an API key (crawl, map, agent, monitor, and the rest of AUTH_REQUIRED_COMMANDS) call ensureAuthenticated(). With no key configured it shows the interactive login menu. When stdin is not a terminal (CI, agents, scripts, </dev/null), the readline prompt reads EOF, never resolves, and Node exits with code 0 after printing the menu. Callers see success with no output.
ensureAuthenticated() now checks process.stdin.isTTY before prompting. Without a terminal it prints
Error: Not authenticated. Set FIRECRAWL_API_KEY, pass --api-key, or run "firecrawl login" in a terminal.
to stderr and exits 1. Interactive terminals keep the existing login menu, and a configured key (flag, env, or stored credentials) is still returned without any check.
Before and after, with an empty HOME and no FIRECRAWL_API_KEY:
$ firecrawl crawl https://example.com </dev/null; echo $?
# before: login menu, then 0
# after: the error above, then 1
Tests in src/__tests__/utils/auth.test.ts cover both paths without a terminal: a configured key resolves with no exit, and a missing key exits 1 without printing the login menu or saving credentials.
No version bump here, since the open PRs already claim 1.26.10; this ships with the next release.
Summary by cubic
Makes CLI commands that require an API key (crawl, map, agent, monitor, and other AUTH_REQUIRED_COMMANDS) exit with code 1 when no key is configured and stdin is not a terminal, instead of hanging on an unanswerable login prompt and exiting 0.
- Without a terminal (CI, scripts,
</dev/null),ensureAuthenticated()writes an error to stderr explaining how to authenticate and callsprocess.exit(1). - Interactive terminals keep the existing login menu, and a configured key (flag, env, or stored credentials) still resolves without any exit.
- Tests cover both non-terminal paths: a configured key resolves cleanly, and a missing key exits 1 without printing the login menu or saving credentials.