Skip to content

Commit e4436cc

Browse files
committed
allow passing chrome path as init param not only env var
1 parent fc21b94 commit e4436cc

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/stagehand/_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def __init__(
6666
local_host: str = "127.0.0.1",
6767
local_port: int = 0,
6868
local_headless: bool = True,
69+
local_chrome_path: str | None = None,
6970
local_ready_timeout_s: float = 10.0,
7071
local_openai_api_key: str | None = None,
7172
local_shutdown_on_close: bool = True,
@@ -100,6 +101,7 @@ def __init__(
100101
self._local_host = local_host
101102
self._local_port = local_port
102103
self._local_headless = local_headless
104+
self._local_chrome_path = local_chrome_path
103105
self._local_ready_timeout_s = local_ready_timeout_s
104106
self._local_openai_api_key = local_openai_api_key
105107
self._local_shutdown_on_close = local_shutdown_on_close
@@ -134,6 +136,7 @@ def __init__(
134136
headless=local_headless,
135137
ready_timeout_s=local_ready_timeout_s,
136138
openai_api_key=openai_api_key,
139+
chrome_path=local_chrome_path,
137140
shutdown_on_close=local_shutdown_on_close,
138141
),
139142
_local_stagehand_binary_path=_local_stagehand_binary_path,
@@ -350,6 +353,7 @@ def __init__(
350353
local_host: str = "127.0.0.1",
351354
local_port: int = 0,
352355
local_headless: bool = True,
356+
local_chrome_path: str | None = None,
353357
local_ready_timeout_s: float = 10.0,
354358
local_openai_api_key: str | None = None,
355359
local_shutdown_on_close: bool = True,
@@ -384,6 +388,7 @@ def __init__(
384388
self._local_host = local_host
385389
self._local_port = local_port
386390
self._local_headless = local_headless
391+
self._local_chrome_path = local_chrome_path
387392
self._local_ready_timeout_s = local_ready_timeout_s
388393
self._local_openai_api_key = local_openai_api_key
389394
self._local_shutdown_on_close = local_shutdown_on_close
@@ -417,6 +422,7 @@ def __init__(
417422
headless=local_headless,
418423
ready_timeout_s=local_ready_timeout_s,
419424
openai_api_key=openai_api_key,
425+
chrome_path=local_chrome_path,
420426
shutdown_on_close=local_shutdown_on_close,
421427
),
422428
_local_stagehand_binary_path=_local_stagehand_binary_path,

src/stagehand/lib/sea_server.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class SeaServerConfig:
2525
headless: bool
2626
ready_timeout_s: float
2727
openai_api_key: str | None
28+
chrome_path: str | None
2829
shutdown_on_close: bool
2930

3031

@@ -179,6 +180,9 @@ def _start_sync(self) -> tuple[str, subprocess.Popen[bytes]]:
179180
proc_env["HEADLESS"] = "true" if self._config.headless else "false"
180181
if self._config.openai_api_key:
181182
proc_env["OPENAI_API_KEY"] = self._config.openai_api_key
183+
if self._config.chrome_path:
184+
proc_env["CHROME_PATH"] = self._config.chrome_path
185+
proc_env["LIGHTHOUSE_CHROMIUM_PATH"] = self._config.chrome_path
182186

183187
preexec_fn = None
184188
creationflags = 0
@@ -226,6 +230,9 @@ async def _start_async(self) -> tuple[str, subprocess.Popen[bytes]]:
226230
proc_env["HEADLESS"] = "true" if self._config.headless else "false"
227231
if self._config.openai_api_key:
228232
proc_env["OPENAI_API_KEY"] = self._config.openai_api_key
233+
if self._config.chrome_path:
234+
proc_env["CHROME_PATH"] = self._config.chrome_path
235+
proc_env["LIGHTHOUSE_CHROMIUM_PATH"] = self._config.chrome_path
229236

230237
preexec_fn = None
231238
creationflags = 0

0 commit comments

Comments
 (0)