Skip to content

The agent that turns websites into APIs!

revert(manual): drop --headless flag — manual mode requires a human

Kalil Bouzigues0e5ef06db77a
diff --git a/src/reverse_api/browser.py b/src/reverse_api/browser.py
index eae7771..8986147 100644
--- a/src/reverse_api/browser.py
+++ b/src/reverse_api/browser.py
@@ -187,13 +187,11 @@ class ManualBrowser:
prompt: str,
output_dir: str | None = None,
use_real_chrome: bool = True, # New option to use real Chrome
- headless: bool = False,
):
self.run_id = run_id
self.prompt = prompt
self.output_dir = output_dir
self.use_real_chrome = use_real_chrome
- self.headless = headless
self.har_dir = get_har_dir(run_id, output_dir)
self.har_path = self.har_dir / "recording.har"
@@ -251,7 +249,7 @@ class ManualBrowser:
self._context = self._playwright.chromium.launch_persistent_context(
user_data_dir=str(temp_profile_dir),
channel="chrome", # Use real Chrome binary
- headless=self.headless,
+ headless=False,
record_har_path=str(self.har_path),
record_har_content="embed",
no_viewport=True,
@@ -328,15 +326,10 @@ class ManualBrowser:
"--use-mock-keychain",
]
- # In headless mode (scripted / CI / VPS), keep Playwright's default
- # `--no-sandbox` so Chromium can launch on hosts without unprivileged
- # user namespaces. In headed mode we still strip it for a more
- # realistic browser fingerprint.
- ignore = ["--enable-automation"] if self.headless else ["--enable-automation", "--no-sandbox"]
self._browser = self._playwright.chromium.launch(
- headless=self.headless,
+ headless=False,
args=chrome_args,
- ignore_default_args=ignore,
+ ignore_default_args=["--enable-automation", "--no-sandbox"],
)
# Create context with HAR recording and realistic settings
diff --git a/src/reverse_api/cli.py b/src/reverse_api/cli.py
index 6c73cfd..be94944 100644
--- a/src/reverse_api/cli.py
+++ b/src/reverse_api/cli.py
@@ -1035,14 +1035,20 @@ def handle_messages(run_id: str, mode_color=THEME_PRIMARY):
default=None,
)
@click.option("--output-dir", "-o", default=None, help="Custom output directory.")
- "--headless",
- is_flag=True,
- help="Launch the browser in headless mode (no UI). Required on machines without an X server (CI / VPS).",
-)
-def manual(prompt, url, reverse_engineer, model, output_dir, headless):
- """Start a manual browser session."""
- run_manual_capture(prompt, url, reverse_engineer, model, output_dir, headless=headless)
+def manual(prompt, url, reverse_engineer, model, output_dir):
+ """Start a manual browser session.
+
+ \b
+ Interactive only — this mode requires a human in front of a real,
+ visible browser to navigate, click, and submit forms. It cannot be
+ driven by an agent or run on a headless machine. There is no
+ --headless / --json / --no-interactive flag here on purpose.
+
+ For scripted / agent / CI use cases, use `agent --json --headless`
+ instead, which runs an autonomous AI-driven capture without needing
+ a human or an X server.
+ """
+ run_manual_capture(prompt, url, reverse_engineer, model, output_dir)
@main.command(
@@ -1162,7 +1168,7 @@ def agent(prompt, url, model, output_dir, no_interactive, as_json, headless):
sys.exit(0 if payload["status"] == "ok" else 1)
-def run_manual_capture(prompt=None, url=None, reverse_engineer=True, model=None, output_dir=None, headless=False):
+def run_manual_capture(prompt=None, url=None, reverse_engineer=True, model=None, output_dir=None):
"""Shared logic for manual capture."""
output_dir = output_dir or config_manager.get("output_dir")
@@ -1196,7 +1202,7 @@ def run_manual_capture(prompt=None, url=None, reverse_engineer=True, model=None,
paths={"har_dir": str(get_har_dir(run_id, output_dir))},
)
- browser = ManualBrowser(run_id=run_id, prompt=prompt, output_dir=output_dir, headless=headless)
+ browser = ManualBrowser(run_id=run_id, prompt=prompt, output_dir=output_dir)
har_path = browser.start(start_url=url)
if reverse_engineer:
diff --git a/tests/test_cli_followups.py b/tests/test_cli_followups.py
index 1c8b920..c4d99af 100644
--- a/tests/test_cli_followups.py
+++ b/tests/test_cli_followups.py
@@ -324,27 +324,31 @@ class TestFollowUpPromptSuppressed:
class TestHeadlessFlag:
- """`--headless` wires through to ManualBrowser / auto-engineer constructors
- and adjusts MCP args (drops --autoConnect for chrome-mcp, adds --headless
- for both chrome-mcp and playwright)."""
+ """`--headless` wires through to auto-engineer constructors (agent only —
+ manual mode is intentionally human-only and rejects --headless)."""
- def test_manual_command_threads_headless(self):
+ def test_manual_rejects_headless_flag(self):
+ """`manual --headless` must fail: manual mode requires a human and a
+ visible browser; agents should use `agent --headless` instead."""
from reverse_api.cli import manual as manual_cmd
runner = CliRunner()
- with patch("reverse_api.cli.run_manual_capture") as mock_run:
- result = runner.invoke(manual_cmd, ["-p", "x", "-u", "https://example.com", "--headless"])
- assert result.exit_code == 0, result.output
- assert mock_run.call_args.kwargs["headless"] is True
-
- def test_manual_default_headless_false(self):
+ result = runner.invoke(manual_cmd, ["-p", "x", "-u", "https://example.com", "--headless"])
+ assert result.exit_code != 0
+ assert "no such option" in result.output.lower() or "--headless" in result.output
+
+ def test_manual_help_mentions_human_only(self):
+ """`manual --help` must make it explicit that the mode requires a
+ human and is not scriptable (so agents inspecting --help self-route
+ to `agent` instead)."""
from reverse_api.cli import manual as manual_cmd
runner = CliRunner()
- with patch("reverse_api.cli.run_manual_capture") as mock_run:
- result = runner.invoke(manual_cmd, ["-p", "x", "-u", "https://example.com"])
- assert result.exit_code == 0, result.output
- assert mock_run.call_args.kwargs["headless"] is False
+ result = runner.invoke(manual_cmd, ["--help"])
+ assert result.exit_code == 0
+ out = result.output.lower()
+ assert "human" in out
+ assert "agent" in out # tells the agent where to go instead
def test_agent_command_threads_headless(self):
from reverse_api.cli import agent as agent_cmd