Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
fix: State command now outputs LLM representation, add CLI aliases
Gregor Žunič4716ae50ced4
diff --git a/browser_use/skill_cli/commands/browser.py b/browser_use/skill_cli/commands/browser.pyindex f5c2a5a37..862442423 100644--- a/browser_use/skill_cli/commands/browser.py+++ b/browser_use/skill_cli/commands/browser.py@@ -119,28 +119,9 @@ async def handle(action: str, session: SessionInfo, params: dict[str, Any]) -> Areturn {'screenshot': base64.b64encode(data).decode(), 'size': len(data)}elif action == 'state':- state = await bs.get_browser_state_summary(include_screenshot=False)- if state:- # Build element list with indices from DOM state- elements = []- if state.dom_state and state.dom_state.selector_map:- for idx, elem in state.dom_state.selector_map.items():- elements.append(- {- 'index': idx,- 'tag': getattr(elem, 'tag_name', ''),- 'text': (getattr(elem, 'text', '') or '')[:50],- 'role': getattr(elem, 'role', ''),- }- )-- return {- 'url': state.url,- 'title': state.title,- 'element_count': len(elements),- 'elements': elements[:20], # Return first 20 elements- }- return {'url': '', 'title': '', 'elements': []}+ # Return the same LLM representation that browser-use agents see+ state_text = await bs.get_state_as_text()+ return {'_raw_text': state_text}elif action == 'switch':from browser_use.browser.events import SwitchTabEventdiff --git a/browser_use/skill_cli/main.py b/browser_use/skill_cli/main.pyindex bd5d760c5..18dbe2b91 100755--- a/browser_use/skill_cli/main.py+++ b/browser_use/skill_cli/main.py@@ -390,11 +390,15 @@ def main() -> int:data = response.get('data')if data is not None:if isinstance(data, dict):- for key, value in data.items():- if key == 'screenshot' and len(str(value)) > 100:- print(f'{key}: <{len(value)} bytes>')- else:- print(f'{key}: {value}')+ # Special case: raw text output (e.g., state command)+ if '_raw_text' in data:+ print(data['_raw_text'])+ else:+ for key, value in data.items():+ if key == 'screenshot' and len(str(value)) > 100:+ print(f'{key}: <{len(value)} bytes>')+ else:+ print(f'{key}: {value}')elif isinstance(data, str):print(data)else:diff --git a/pyproject.toml b/pyproject.tomlindex a8a7c7719..560c66b9c 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -93,6 +93,8 @@ Repository = "https://github.com/browser-use/browser-use"[project.scripts]browser-use = "browser_use.skill_cli.main:main" # Fast CLI for browser automation+bu = "browser_use.skill_cli.main:main" # Alias for browser-use+browser = "browser_use.skill_cli.main:main" # Alias for browser-usebrowser-use-tui = "browser_use.cli:main" # Legacy TUI interface[build-system]