Adds _at_shell_prompt() helper that detects a shell prompt by checking
whether any line ends with '#' or '# ', rather than using a bare '#' in
response check guarded by 'login' not in output. The old guard caused a
false negative when the IOM echoed 'Last login: ...' text alongside the
prompt, sending an unnecessary login attempt to an active session.
Also broadens _ANSI_RE to catch all CSI escape sequences and two-character
ESC sequences, not just the original five terminal codes.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>