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 browser-use extensions dir to use .config/browseruse like everything else and cache in actions
Nick Sweetingf5925b1080c7
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yamlindex 7451d7d6d..1bddc275e 100644--- a/.github/workflows/test.yaml+++ b/.github/workflows/test.yaml@@ -105,6 +105,15 @@ jobs:- run: playwright install chromium --with-deps# - run: patchright install chromium --with-deps+ - name: Cache browser-use extensions+ uses: actions/cache@v4+ with:+ path: |+ ~/.config/browseruse/extensions+ key: ${{ runner.os }}-browseruse-extensions-${{ hashFiles('browser_use/browser/profile.py') }}+ restore-keys: |+ ${{ runner.os }}-browseruse-extensions-+- run: pytest tests/ci/${{ matrix.test_filename }}.pyevaluate-tasks:@@ -156,6 +165,15 @@ jobs:- run: playwright install chromium --with-deps- run: patchright install chromium --with-deps+ - name: Cache browser-use extensions+ uses: actions/cache@v4+ with:+ path: |+ ~/.config/browseruse/extensions+ key: ${{ runner.os }}-browseruse-extensions-${{ hashFiles('browser_use/browser/profile.py') }}+ restore-keys: |+ ${{ runner.os }}-browseruse-extensions-+- name: Run agent tasks evaluation and capture scoreid: evalrun: |diff --git a/browser_use/browser/profile.py b/browser_use/browser/profile.pyindex e3b9afdb9..22a4aa40f 100644--- a/browser_use/browser/profile.py+++ b/browser_use/browser/profile.py@@ -736,7 +736,6 @@ class BrowserProfile(BrowserConnectArgs, BrowserLaunchPersistentContextArgs, BroEnsure default extensions are downloaded and cached locally.Returns list of paths to extension directories."""- from pathlib import Path# Extension definitions - optimized for automation and content extractionextensions = [@@ -758,7 +757,7 @@ class BrowserProfile(BrowserConnectArgs, BrowserLaunchPersistentContextArgs, Bro]# Create extensions cache directory- cache_dir = Path.home() / '.browser-use' / 'extensions'+ cache_dir = CONFIG.BROWSER_USE_EXTENSIONS_DIRcache_dir.mkdir(parents=True, exist_ok=True)extension_paths = []diff --git a/browser_use/config.py b/browser_use/config.pyindex 63beea8ef..9b1b91446 100644--- a/browser_use/config.py+++ b/browser_use/config.py@@ -105,6 +105,12 @@ class OldConfig:def BROWSER_USE_DEFAULT_USER_DATA_DIR(self) -> Path:return self.BROWSER_USE_PROFILES_DIR / 'default'+ @property+ def BROWSER_USE_EXTENSIONS_DIR(self) -> Path:+ path = self.BROWSER_USE_CONFIG_DIR / 'extensions'+ self._ensure_dirs()+ return path+def _ensure_dirs(self) -> None:"""Create directories if they don't exist (only once)"""if not self._dirs_created:@@ -113,6 +119,7 @@ class OldConfig:)config_dir.mkdir(parents=True, exist_ok=True)(config_dir / 'profiles').mkdir(parents=True, exist_ok=True)+ (config_dir / 'extensions').mkdir(parents=True, exist_ok=True)self._dirs_created = True# LLM API key configuration