|
11 | 11 |
|
12 | 12 | from playwright.sync_api import BrowserContext, Page, Playwright, sync_playwright |
13 | 13 |
|
| 14 | +from sentience._extension_loader import find_extension_path |
14 | 15 | from sentience.models import ProxyConfig, StorageState |
15 | 16 |
|
16 | 17 | # Import stealth for bot evasion (optional - graceful fallback if not available) |
@@ -156,28 +157,8 @@ def _parse_proxy(self, proxy_string: str) -> ProxyConfig | None: |
156 | 157 |
|
157 | 158 | def start(self) -> None: |
158 | 159 | """Launch browser with extension loaded""" |
159 | | - # Get extension source path (relative to project root/package) |
160 | | - # Handle both development (src/) and installed package cases |
161 | | - |
162 | | - # 1. Try relative to this file (installed package structure) |
163 | | - # sentience/browser.py -> sentience/extension/ |
164 | | - package_ext_path = Path(__file__).parent / "extension" |
165 | | - |
166 | | - # 2. Try development root (if running from source repo) |
167 | | - # sentience/browser.py -> ../sentience-chrome |
168 | | - dev_ext_path = Path(__file__).parent.parent.parent / "sentience-chrome" |
169 | | - |
170 | | - if package_ext_path.exists() and (package_ext_path / "manifest.json").exists(): |
171 | | - extension_source = package_ext_path |
172 | | - elif dev_ext_path.exists() and (dev_ext_path / "manifest.json").exists(): |
173 | | - extension_source = dev_ext_path |
174 | | - else: |
175 | | - raise FileNotFoundError( |
176 | | - f"Extension not found. Checked:\n" |
177 | | - f"1. {package_ext_path}\n" |
178 | | - f"2. {dev_ext_path}\n" |
179 | | - "Make sure the extension is built and 'sentience/extension' directory exists." |
180 | | - ) |
| 160 | + # Get extension source path using shared utility |
| 161 | + extension_source = find_extension_path() |
181 | 162 |
|
182 | 163 | # Create temporary extension bundle |
183 | 164 | # We copy it to a temp dir to avoid file locking issues and ensure clean state |
|
0 commit comments