Harden CLI so browser automation works without manual recovery - #24
Merged
Conversation
The bridge, the browser, and first-run setup each had failure modes that left the user to diagnose and repair by hand. Each is now detected and resolved automatically, or reported with the command that fixes it. Bridge lifecycle: - /health carries package version, pid and boot id; a bridge running pre-upgrade code is replaced instead of looking healthy forever - never signal a pid that has not been identified as ours (a recycled pid after reboot could previously be SIGTERMed) - exclusive start lock and a port range, so concurrent commands start exactly one bridge and a taken port is not a hard error - READY/FAILED handshake surfaces a dead child in milliseconds rather than a 30s blind poll, with the bridge log tail in the error - dropped connections restart and retry once; Opera AI tools are never silently replayed - add restart/status; stop escalates to SIGKILL and clears stale pid files Browser conflicts: - detect a profile held by a running browser via SingletonLock - attach automatically when it exposes a debug port (DevToolsActivePort) - otherwise offer to restart it (TTY, or --takeover); never quit a browser unprompted, and never SIGKILL one - add attach and launch-args First run: - detect and configure on first use instead of hinting at `setup` - setup gains non-interactive flags and no longer requires a TTY - headed when an Opera binary is configured, since AI sign-in needs a window; headless machines keep the old default Caller contract: - exit codes distinguish bad arguments, environment, auth, timeout and stale page state; new AUTH_REQUIRED code - add login; doctor gains --fix and MCP/profile/browser checks - logs gains --follow and --errors Plan and rationale in specs/robustness-hardening.md.
Detect a wedged bridged (up but pointed at a dead browser) by probing the attach URL on /health, so findUsableBridge stops reusing it and the next command rebuilds against the current target. open now fails loudly (exit 3) instead of faking success. Condense SKILL.md and keep the ask-the-user rule.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens the CLI so browser automation works without manual recovery, and stops the CLI from reporting fake success when the browser it points at is actually unreachable.
Changes
12d57ac→a9fd83f): bridge restarts itself on version skew, crash, or dropped connection; falls back to another port if one is taken; and detects a wedged bridge (up but pointed at a dead browser) by probing the attach URL on/health, sofindUsableBridgestops reusing it and rebuilds against the current target.open(and unreachable-browser recovery incallTool) now fail loudly withBROWSER_ERROR(exit 3) instead of emitting a fakerefs:0page when the browser is running without a debug port or the bridge points at a browser that has closed.SKILL.mdwith the ask-the-user rule for browsers that can't be automated.Testing
preflight,bridge-recovery,bridge-lifecycle,bridge-startup,browser-target, andexit-codessuites, plus a stub-MCP fixture for unreachable-browser recovery.tsc --noEmitclean.Notes
Resolves the behaviour described in
specs/robustness-hardening.md.