Skip to content

Commit 9fa6dd3

Browse files
committed
share utility for loading textensions
1 parent 9c1a8c5 commit 9fa6dd3

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

screenshot.png

141 Bytes
Loading

sentience/browser.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from playwright.sync_api import BrowserContext, Page, Playwright, sync_playwright
1313

14+
from sentience._extension_loader import find_extension_path
1415
from sentience.models import ProxyConfig, StorageState
1516

1617
# Import stealth for bot evasion (optional - graceful fallback if not available)
@@ -156,28 +157,8 @@ def _parse_proxy(self, proxy_string: str) -> ProxyConfig | None:
156157

157158
def start(self) -> None:
158159
"""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()
181162

182163
# Create temporary extension bundle
183164
# We copy it to a temp dir to avoid file locking issues and ensure clean state

0 commit comments

Comments
 (0)