Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

fix Browser Use CLI skill install and telemetry edge cases

Laith Weinberger4c13e2830144
diff --git a/browser_use/cli.py b/browser_use/cli.py
index a11921008..e3554ef4d 100644
--- a/browser_use/cli.py
+++ b/browser_use/cli.py
@@ -42,6 +42,12 @@ def _detect_model() -> tuple[str | None, str | None]:
return _first_env_value(('BROWSER_USE_AGENT_MODEL',)), _first_env_value(('BROWSER_USE_MODEL_PROVIDER',))
+def _redacted_task(task: str | None) -> str | None:
+ if task is None:
+ return None
+ return '[redacted]'
+
+
def _capture_cli_event(
*,
action: str,
@@ -63,7 +69,8 @@ def _capture_cli_event(
action=action,
mode=mode,
command=command,
- task=task,
+ task=_redacted_task(task),
+ task_length=len(task) if task is not None else None,
agent_client=_detect_agent_client(),
model=model,
model_provider=model_provider,
@@ -222,6 +229,20 @@ def _read_harness_task(args: list[str]) -> str | None:
return code
+def _command_context(args: list[str]) -> tuple[str, str]:
+ if '--mcp' in args:
+ return 'mcp_server', 'mcp'
+ if args and args[0] == 'install':
+ return 'install', 'install'
+ if args and args[0] == 'init':
+ return 'init', 'init'
+ if '--template' in args or '-t' in args:
+ return 'init', 'init'
+ if args and args[0] == 'skill':
+ return 'skill', 'skill'
+ return 'browser_harness', args[0] if args else 'run'
+
+
def _dispatch(args: list[str]) -> tuple[int | None, str, str, str | None]:
if '--mcp' in args:
_run_mcp_server()
@@ -249,8 +270,7 @@ def browser_use_tui_main() -> int | None:
def main() -> int | None:
args = sys.argv[1:]
start_time = time.monotonic()
- mode = 'browser_harness'
- command = args[0] if args else 'run'
+ mode, command = _command_context(args)
task = None
try:
result, mode, command, task = _dispatch(args)
diff --git a/browser_use/skills/install.py b/browser_use/skills/install.py
index 44595885c..910a0a8e4 100644
--- a/browser_use/skills/install.py
+++ b/browser_use/skills/install.py
@@ -1,6 +1,7 @@
from __future__ import annotations
import argparse
+import os
import shutil
import subprocess
import sys
@@ -8,15 +9,25 @@ from pathlib import Path
SKILL_NAME = 'browser-use'
DEFAULT_TARGET = 'all'
-TARGET_DIRS = {
- 'agents': Path.home() / '.agents' / 'skills' / SKILL_NAME,
- 'claude': Path.home() / '.claude' / 'skills' / SKILL_NAME,
- 'codex': Path.home() / '.codex' / 'skills' / SKILL_NAME,
- 'copilot': Path.home() / '.copilot' / 'skills' / SKILL_NAME,
- 'cursor': Path.home() / '.cursor' / 'skills' / SKILL_NAME,
- 'gemini': Path.home() / '.gemini' / 'skills' / SKILL_NAME,
- 'opencode': Path.home() / '.config' / 'opencode' / 'skills' / SKILL_NAME,
-}
+
+
+def _xdg_config_home() -> Path:
+ return Path(os.environ.get('XDG_CONFIG_HOME', Path.home() / '.config')).expanduser()
+
+
+def _target_dirs() -> dict[str, Path]:
+ return {
+ 'agents': Path.home() / '.agents' / 'skills' / SKILL_NAME,
+ 'claude': Path.home() / '.claude' / 'skills' / SKILL_NAME,
+ 'codex': Path.home() / '.codex' / 'skills' / SKILL_NAME,
+ 'copilot': Path.home() / '.copilot' / 'skills' / SKILL_NAME,
+ 'cursor': Path.home() / '.cursor' / 'skills' / SKILL_NAME,
+ 'gemini': Path.home() / '.gemini' / 'skills' / SKILL_NAME,
+ 'opencode': _xdg_config_home() / 'opencode' / 'skills' / SKILL_NAME,
+ }
+
+
+TARGET_NAMES = ('agents', 'claude', 'codex', 'copilot', 'cursor', 'gemini', 'opencode')
def _load_skill_text_from_package() -> str:
@@ -75,7 +86,7 @@ def _build_parser() -> argparse.ArgumentParser:
install = subparsers.add_parser('install', help='Install the skill')
install.add_argument(
'--target',
- choices=sorted([*TARGET_DIRS, 'all']),
+ choices=sorted([*TARGET_NAMES, 'all']),
default=DEFAULT_TARGET,
help='Assistant skill directory to install into',
)
@@ -100,9 +111,10 @@ def _build_parser() -> argparse.ArgumentParser:
def _resolve_output_paths(target: str, custom_path: Path | None) -> list[Path]:
if custom_path is None:
+ target_dirs = _target_dirs()
if target == 'all':
- return [path / 'SKILL.md' for path in TARGET_DIRS.values()]
- return [TARGET_DIRS[target] / 'SKILL.md']
+ return [path / 'SKILL.md' for path in target_dirs.values()]
+ return [target_dirs[target] / 'SKILL.md']
path = custom_path.expanduser()
if path.name == 'SKILL.md':
diff --git a/browser_use/telemetry/views.py b/browser_use/telemetry/views.py
index 08c62e80a..13ee63c34 100644
--- a/browser_use/telemetry/views.py
+++ b/browser_use/telemetry/views.py
@@ -97,6 +97,7 @@ class CLITelemetryEvent(BaseTelemetryEvent):
mode: str # 'browser_harness', 'install', 'init', 'skill', 'mcp_server'
command: str | None = None
task: str | None = None
+ task_length: int | None = None
agent_client: str | None = None
model: str | None = None
model_provider: str | None = None