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
feat(cli): add profile list-local command and fix real browser profile loading
ShawnPana2b2dc2b4e530
diff --git a/browser_use/skill_cli/main.py b/browser_use/skill_cli/main.pyindex 7f71955b6..db558bc06 100755--- a/browser_use/skill_cli/main.py+++ b/browser_use/skill_cli/main.py@@ -389,9 +389,76 @@ Examples:server_sub.add_parser('stop', help='Stop server')server_sub.add_parser('logs', help='View server logs')+ # -------------------------------------------------------------------------+ # Profile Management+ # -------------------------------------------------------------------------++ profile_p = subparsers.add_parser('profile', help='Manage browser profiles')+ profile_sub = profile_p.add_subparsers(dest='profile_command')++ # profile list-local+ profile_sub.add_parser('list-local', help='List local Chrome profiles')+return parser+def handle_profile_command(args: argparse.Namespace) -> int:+ """Handle profile subcommands."""+ if args.profile_command == 'list-local':+ profiles = list_local_chrome_profiles()++ if args.json:+ print(json.dumps({'profiles': profiles}))+ else:+ if profiles:+ print('Local Chrome profiles:')+ for p in profiles:+ email_str = f' ({p["email"]})' if p['email'] != 'local' else ''+ print(f' {p["id"]}: {p["name"]}{email_str}')+ else:+ print('No Chrome profiles found')+ return 0++ # No subcommand specified+ print('Usage: browser-use profile <command>')+ print('Commands: list-local')+ return 1+++def list_local_chrome_profiles() -> list[dict]:+ """List local Chrome profiles from the Local State file."""+ local_state_paths = [+ Path.home() / 'Library/Application Support/Google/Chrome/Local State', # macOS+ Path.home() / '.config/google-chrome/Local State', # Linux+ Path.home() / 'AppData/Local/Google/Chrome/User Data/Local State', # Windows+ ]++ local_state = None+ for path in local_state_paths:+ if path.exists():+ local_state = path+ break++ if not local_state:+ return []++ try:+ data = json.loads(local_state.read_text())+ profiles_info = data.get('profile', {}).get('info_cache', {})++ profiles = []+ for profile_id, info in profiles_info.items():+ profiles.append({+ 'id': profile_id,+ 'name': info.get('name', 'Unknown'),+ 'email': info.get('user_name') or info.get('gaia_name') or 'local',+ })++ return profiles+ except Exception:+ return []++def handle_server_command(args: argparse.Namespace) -> int:"""Handle server subcommands."""if args.server_command == 'status':@@ -449,6 +516,10 @@ def main() -> int:if args.command == 'server':return handle_server_command(args)+ # Handle profile subcommands without starting server+ if args.command == 'profile':+ return handle_profile_command(args)+# Handle sessions list - find all running sessionsif args.command == 'sessions':from browser_use.skill_cli.utils import find_all_sessionsdiff --git a/browser_use/skill_cli/sessions.py b/browser_use/skill_cli/sessions.pyindex d98f3868c..0e4f6b9e6 100644--- a/browser_use/skill_cli/sessions.py+++ b/browser_use/skill_cli/sessions.py@@ -126,11 +126,15 @@ async def create_browser_session(if not chrome_path:raise RuntimeError('Could not find Chrome executable. Please install Chrome or specify --browser chromium')- user_data_dir = get_chrome_profile_path(profile)+ # Always get the Chrome user data directory (not the profile subdirectory)+ user_data_dir = get_chrome_profile_path(None)+ # Profile directory defaults to 'Default', or use the specified profile name+ profile_directory = profile if profile else 'Default'return BrowserSession(executable_path=chrome_path,user_data_dir=user_data_dir,+ profile_directory=profile_directory,headless=False, # Real browser always visible)diff --git a/skills/browser-use/SKILL.md b/skills/browser-use/SKILL.mdindex d8c4b859b..00e5c21e8 100644--- a/skills/browser-use/SKILL.md+++ b/skills/browser-use/SKILL.md@@ -166,6 +166,27 @@ browser-use close # Close current sessionbrowser-use close --all # Close all sessions```+### Profile Management+```bash+browser-use profile list-local # List local Chrome profiles+```++**Before opening a real browser (`--browser real`)**, always ask the user if they want to use a specific Chrome profile or no profile. Use `profile list-local` to show available profiles:++```bash+browser-use profile list-local+# Output: Default: Person 1 ([email protected])+# Profile 1: Work ([email protected])++# With a specific profile (has that profile's cookies/logins)+browser-use --browser real --profile "Profile 1" open https://gmail.com++# Without a profile (fresh browser, no existing logins)+browser-use --browser real open https://gmail.com+```++Each Chrome profile has its own cookies, history, and logged-in sessions. Choosing the right profile determines whether sites will be pre-authenticated.+### Server Control```bashbrowser-use server status # Check if server is running