File tree Expand file tree Collapse file tree 3 files changed +1461
-0
lines changed
Expand file tree Collapse file tree 3 files changed +1461
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ Shared extension loading logic for sync and async implementations
3+ """
4+
5+ from pathlib import Path
6+
7+
8+ def find_extension_path () -> Path :
9+ """
10+ Find Sentience extension directory (shared logic for sync and async).
11+
12+ Checks multiple locations:
13+ 1. sentience/extension/ (installed package)
14+ 2. ../sentience-chrome (development/monorepo)
15+
16+ Returns:
17+ Path to extension directory
18+
19+ Raises:
20+ FileNotFoundError: If extension not found in any location
21+ """
22+ # 1. Try relative to this file (installed package structure)
23+ # sentience/_extension_loader.py -> sentience/extension/
24+ package_ext_path = Path (__file__ ).parent / "extension"
25+
26+ # 2. Try development root (if running from source repo)
27+ # sentience/_extension_loader.py -> ../sentience-chrome
28+ dev_ext_path = Path (__file__ ).parent .parent .parent / "sentience-chrome"
29+
30+ if package_ext_path .exists () and (package_ext_path / "manifest.json" ).exists ():
31+ return package_ext_path
32+ elif dev_ext_path .exists () and (dev_ext_path / "manifest.json" ).exists ():
33+ return dev_ext_path
34+ else :
35+ raise FileNotFoundError (
36+ f"Extension not found. Checked:\n "
37+ f"1. { package_ext_path } \n "
38+ f"2. { dev_ext_path } \n "
39+ "Make sure the extension is built and 'sentience/extension' directory exists."
40+ )
41+
You can’t perform that action at this time.
0 commit comments