@capagents/forgeqe 2.8.8 → 2.8.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HOW_TO_USE.md +10 -2
- package/dist/docs-site/docs/index.html +9 -2
- package/dist/docs-site/docs/search.js +1 -1
- package/dist/forgeqe.js +1443 -1443
- package/dist/web/assets/{Agent-Cp8VlBIz.js → Agent-CHliM9aG.js} +1 -1
- package/dist/web/assets/{ApiTests-BcZLc09C.js → ApiTests-DcGDtIjl.js} +1 -1
- package/dist/web/assets/{Browse-C_YjgIEb.js → Browse-DWZgEdaB.js} +1 -1
- package/dist/web/assets/{Chat-BoCGL6_O.js → Chat-DVolc6Rs.js} +1 -1
- package/dist/web/assets/{CommandPalette-BfM5HzzB.js → CommandPalette-CdwjRIsa.js} +1 -1
- package/dist/web/assets/{Cost-TS6CXmoR.js → Cost-BifpK_Ac.js} +1 -1
- package/dist/web/assets/{Data-CBPzLyv3.js → Data-Crk0ef8O.js} +1 -1
- package/dist/web/assets/{Evidence-BZq0G649.js → Evidence-EYGofupD.js} +1 -1
- package/dist/web/assets/{Explore-l6Hdu8Sv.js → Explore-DtqBRQi7.js} +1 -1
- package/dist/web/assets/{Features-YYJcXLBf.js → Features-B_ZtQEtR.js} +1 -1
- package/dist/web/assets/{Flags-C60CLbzH.js → Flags-DCLSg8Na.js} +1 -1
- package/dist/web/assets/{Flaky-BkLguGXu.js → Flaky-HpgrkJIF.js} +1 -1
- package/dist/web/assets/{ForceGraph-D1krkEJe.js → ForceGraph-Dm4VEUjO.js} +1 -1
- package/dist/web/assets/{Impact-640wqe0S.js → Impact-CyzbgGih.js} +1 -1
- package/dist/web/assets/{Jobs-C97GqHLF.js → Jobs-CbTd9csb.js} +1 -1
- package/dist/web/assets/{KindPage-Bux228tV.js → KindPage-cfP76U_9.js} +1 -1
- package/dist/web/assets/{Migration-VTuXJ3MF.js → Migration-va16JqtB.js} +1 -1
- package/dist/web/assets/{Product-BNDHj6KV.js → Product-D0iY6orX.js} +1 -1
- package/dist/web/assets/{Production-BC-kcNIt.js → Production-CBUb6wZJ.js} +1 -1
- package/dist/web/assets/{Quality-CuSQTvtJ.js → Quality-OMhrUKTU.js} +1 -1
- package/dist/web/assets/{Readiness-Bh2cynJx.js → Readiness-B64Rxahv.js} +1 -1
- package/dist/web/assets/{Record-DJfuaIqW.js → Record-B_JXq6Dv.js} +1 -1
- package/dist/web/assets/{Regression-oW_4rSE7.js → Regression-2blJAX7v.js} +1 -1
- package/dist/web/assets/{Reports-CBkl7Abx.js → Reports-DCgjGdw4.js} +1 -1
- package/dist/web/assets/{Response-f5217Gw2.js → Response-BtMM8nqx.js} +1 -1
- package/dist/web/assets/{RunDiff-B7o9vQBr.js → RunDiff-KuUVRuQI.js} +1 -1
- package/dist/web/assets/{Runs-CkdASpHU.js → Runs-zHDZ-rSo.js} +1 -1
- package/dist/web/assets/{TestCases-BPif-KCg.js → TestCases-B1j2Oelt.js} +1 -1
- package/dist/web/assets/{TestData-CQAI8n3o.js → TestData-CZSynoi-.js} +1 -1
- package/dist/web/assets/{TestDebt-C94phbAj.js → TestDebt-DEdIBwdb.js} +1 -1
- package/dist/web/assets/{Tosca-CX7hZsNJ.js → Tosca-BcuaHsQC.js} +1 -1
- package/dist/web/assets/{WhatsNew-ktL7koKS.js → WhatsNew-CjvX6DNo.js} +1 -1
- package/dist/web/assets/{dataParts-DD_0rviO.js → dataParts-BImZKYEu.js} +1 -1
- package/dist/web/assets/{families-7ZW63NF1.js → families-q4nF1Fqo.js} +1 -1
- package/dist/web/assets/{frame-Ct3Ey3bQ.js → frame-eAHxqKfn.js} +2 -2
- package/dist/web/assets/{index-tdO1bZWq.js → index-COTk3Bz-.js} +21 -21
- package/dist/web/assets/{logos-Czko8FVx.js → logos-DEPdha9g.js} +1 -1
- package/dist/web/assets/{parts-ryIgw8NG.js → parts-CVdJRIxI.js} +1 -1
- package/dist/web/assets/{productParts-CSw1V5I9.js → productParts-CqY4Zs7J.js} +1 -1
- package/dist/web/assets/{qualityParts-Czf68wgs.js → qualityParts-BcrXEQ9B.js} +1 -1
- package/dist/web/assets/{segmented-CCfjZKVa.js → segmented-BJECij_J.js} +1 -1
- package/dist/web/assets/{thread-_hyYtCeH.js → thread-Cuvu0HhP.js} +1 -1
- package/dist/web/assets/{usePageChat-Cm84Zkf4.js → usePageChat-Bz7fuynu.js} +1 -1
- package/dist/web/index.html +2 -2
- package/docs/user-guide.html +13 -2
- package/forgeqe.example.yaml +1 -0
- package/package.json +1 -1
- package/py/forgeqe_engine/browser.py +239 -12
- package/py/forgeqe_engine/logins.py +1 -1
- package/py/forgeqe_engine/recordsession.py +1 -1
- package/py/forgeqe_engine/service.py +1 -1
|
@@ -159,8 +159,185 @@ def local_browser_launch_kwargs(*, headless: bool) -> Dict[str, Any]:
|
|
|
159
159
|
# The library's words when Chrome exits before its DevTools port answers, and close variants of other versions.
|
|
160
160
|
_EARLY_EXIT = ("exited before CDP", "before CDP became available", "Browser process exited", "Failed to start browser", "Chrome failed to start")
|
|
161
161
|
|
|
162
|
-
# How long one browser has to
|
|
163
|
-
|
|
162
|
+
# How long one browser's DevTools port has to answer before the next browser is tried. Company PCs are slow to start a
|
|
163
|
+
# browser (security software scans it first); FORGEQE_ENGINE_BROWSER_START_SECONDS changes it, from 15 to 600.
|
|
164
|
+
DEVTOOLS_WAIT_SECONDS = 90.0
|
|
165
|
+
# After the process ForgeQE started has exited, how long a browser it handed over to has to answer on the same port.
|
|
166
|
+
HANDOVER_SECONDS = 30.0
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def devtools_wait_seconds() -> float:
|
|
170
|
+
try:
|
|
171
|
+
value = float((os.getenv("FORGEQE_ENGINE_BROWSER_START_SECONDS") or "").strip())
|
|
172
|
+
except ValueError:
|
|
173
|
+
return DEVTOOLS_WAIT_SECONDS
|
|
174
|
+
return min(600.0, max(15.0, value)) if value == value else DEVTOOLS_WAIT_SECONDS
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
start_logger = logging.getLogger("forgeqe_engine.browser_start")
|
|
178
|
+
|
|
179
|
+
# Browsers a launcher handed over to (not this engine's own descendants), closed with the ones it started.
|
|
180
|
+
_HANDED_OVER: Dict[int, List[str]] = {}
|
|
181
|
+
|
|
182
|
+
_SAFE_FLAG_VALUES = ("--remote-debugging-port", "--user-data-dir", "--profile-directory", "--headless", "--window-size")
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def describe_args(args: List[str]) -> str:
|
|
186
|
+
"""A browser's command line for the log: the program, and each flag by name, with a value only for flags whose
|
|
187
|
+
value says how it was started (never a proxy, a URL or anything else that may hold a credential)."""
|
|
188
|
+
if not args:
|
|
189
|
+
return "(unknown)"
|
|
190
|
+
shown = [args[0]]
|
|
191
|
+
for a in args[1:]:
|
|
192
|
+
name = a.split("=", 1)[0]
|
|
193
|
+
if not name.startswith("--"):
|
|
194
|
+
continue
|
|
195
|
+
shown.append(a if name in _SAFE_FLAG_VALUES else name)
|
|
196
|
+
return " ".join(shown)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def _process_args(proc: Any) -> List[str]:
|
|
200
|
+
try:
|
|
201
|
+
return list(proc.cmdline())
|
|
202
|
+
except Exception:
|
|
203
|
+
return []
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def _alive(proc: Any) -> bool:
|
|
207
|
+
import psutil
|
|
208
|
+
|
|
209
|
+
try:
|
|
210
|
+
return bool(proc.is_running()) and proc.status() != psutil.STATUS_ZOMBIE
|
|
211
|
+
except psutil.AccessDenied:
|
|
212
|
+
return True
|
|
213
|
+
except Exception:
|
|
214
|
+
return False
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def _exit_code(proc: Any) -> str:
|
|
218
|
+
try:
|
|
219
|
+
code = proc.wait(timeout=0)
|
|
220
|
+
except Exception:
|
|
221
|
+
return "not known"
|
|
222
|
+
if code is None:
|
|
223
|
+
return "not known"
|
|
224
|
+
# Windows reports codes like 0xC0000022 (access denied) as large unsigned numbers: show them as Windows does.
|
|
225
|
+
return f"{code} (0x{code & 0xFFFFFFFF:08X})" if isinstance(code, int) and (code < 0 or code > 255) else str(code)
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def port_owner(port: int, *, not_pid: Optional[int] = None) -> Optional[Any]:
|
|
229
|
+
"""The browser's main process started with this DevTools port, when it is not the one ForgeQE started (a launcher
|
|
230
|
+
on the PC may start the browser again under another process and exit). None when there is none."""
|
|
231
|
+
import psutil
|
|
232
|
+
|
|
233
|
+
flag = f"--remote-debugging-port={port}"
|
|
234
|
+
for proc in psutil.process_iter():
|
|
235
|
+
if proc.pid == not_pid:
|
|
236
|
+
continue
|
|
237
|
+
args = _process_args(proc)
|
|
238
|
+
if flag in args and not any(a.startswith("--type=") for a in args):
|
|
239
|
+
return proc
|
|
240
|
+
return None
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def _handed_over(proc: Any) -> None:
|
|
244
|
+
args = _process_args(proc)
|
|
245
|
+
if args:
|
|
246
|
+
_HANDED_OVER[proc.pid] = args
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
async def wait_for_devtools(port: int, timeout: float = 30, process: Any = None) -> str:
|
|
250
|
+
"""
|
|
251
|
+
Wait for a browser's DevTools port to answer; the library's own wait, made patient and logged. The library gives up
|
|
252
|
+
the moment the process it started has exited; on a company PC that process is often a launcher that starts the
|
|
253
|
+
browser again under another process (security software, a browser wrapper) and exits, and the browser answers on
|
|
254
|
+
the same port a few seconds later. So an exit is noted and the port still watched, for HANDOVER_SECONDS more when no
|
|
255
|
+
other browser has the port and up to the full wait when one has. Every step goes to the run's log.
|
|
256
|
+
"""
|
|
257
|
+
import aiohttp
|
|
258
|
+
|
|
259
|
+
loop = asyncio.get_running_loop()
|
|
260
|
+
started = loop.time()
|
|
261
|
+
limit = max(float(timeout or 0), devtools_wait_seconds())
|
|
262
|
+
pid = getattr(process, "pid", None)
|
|
263
|
+
start_logger.info("browser start: PID %s, %s", pid, describe_args(_process_args(process)) if process is not None else "(no process)")
|
|
264
|
+
start_logger.info("browser start: waiting up to %ds for DevTools on 127.0.0.1:%d", int(limit), port)
|
|
265
|
+
exited_at: Optional[float] = None
|
|
266
|
+
exit_code = "not known"
|
|
267
|
+
children: Dict[int, Any] = {}
|
|
268
|
+
owner: Any = None
|
|
269
|
+
last = "no answer yet"
|
|
270
|
+
next_note = started + 5
|
|
271
|
+
next_scan = started
|
|
272
|
+
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=3)) as session:
|
|
273
|
+
while True:
|
|
274
|
+
now = loop.time()
|
|
275
|
+
waited = now - started
|
|
276
|
+
try:
|
|
277
|
+
async with session.get(f"http://127.0.0.1:{port}/json/version") as resp:
|
|
278
|
+
if resp.status == 200:
|
|
279
|
+
if owner is None and exited_at is not None:
|
|
280
|
+
owner = port_owner(port, not_pid=pid)
|
|
281
|
+
if owner is not None:
|
|
282
|
+
_handed_over(owner)
|
|
283
|
+
start_logger.info("browser start: DevTools answered after %.1fs from PID %s, which took over from PID %s", waited, owner.pid, pid)
|
|
284
|
+
else:
|
|
285
|
+
start_logger.info("browser start: DevTools answered after %.1fs", waited)
|
|
286
|
+
return f"http://127.0.0.1:{port}/"
|
|
287
|
+
last = f"HTTP {resp.status}"
|
|
288
|
+
except Exception as ex:
|
|
289
|
+
last = type(ex).__name__
|
|
290
|
+
if process is not None and exited_at is None:
|
|
291
|
+
if _alive(process):
|
|
292
|
+
try:
|
|
293
|
+
for child in process.children(recursive=True):
|
|
294
|
+
children.setdefault(child.pid, child)
|
|
295
|
+
except Exception:
|
|
296
|
+
pass
|
|
297
|
+
else:
|
|
298
|
+
exited_at = waited
|
|
299
|
+
exit_code = _exit_code(process)
|
|
300
|
+
start_logger.warning(
|
|
301
|
+
"browser start: PID %s exited after %.1fs, exit code %s, before DevTools answered; it started %d other process%s",
|
|
302
|
+
pid, waited, exit_code, len(children), "" if len(children) == 1 else "es",
|
|
303
|
+
)
|
|
304
|
+
if exited_at is not None and owner is None and now >= next_scan:
|
|
305
|
+
next_scan = now + 1
|
|
306
|
+
owner = next((c for c in children.values() if _alive(c) and f"--remote-debugging-port={port}" in _process_args(c)), None)
|
|
307
|
+
owner = owner or port_owner(port, not_pid=pid)
|
|
308
|
+
if owner is not None:
|
|
309
|
+
_handed_over(owner)
|
|
310
|
+
start_logger.warning("browser start: PID %s now runs the browser with DevTools port %d (%s); still waiting for it", owner.pid, port, describe_args(_process_args(owner)))
|
|
311
|
+
if exited_at is not None and owner is None and waited - exited_at >= HANDOVER_SECONDS:
|
|
312
|
+
raise RuntimeError(
|
|
313
|
+
f"Browser process (PID {pid}) exited before CDP became available on port {port}. It exited after "
|
|
314
|
+
f"{exited_at:.1f}s with exit code {exit_code}, and no other browser took its port in {int(HANDOVER_SECONDS)}s ({last})."
|
|
315
|
+
)
|
|
316
|
+
if owner is not None and not _alive(owner) and exited_at is not None:
|
|
317
|
+
raise RuntimeError(
|
|
318
|
+
f"Browser process (PID {pid}) exited before CDP became available on port {port}, and PID {owner.pid}, "
|
|
319
|
+
f"which took it over, exited too ({last})."
|
|
320
|
+
)
|
|
321
|
+
if waited >= limit:
|
|
322
|
+
state = f"PID {pid} " + (f"exited after {exited_at:.1f}s with exit code {exit_code}" if exited_at is not None else "still runs")
|
|
323
|
+
if owner is not None:
|
|
324
|
+
state += f"; PID {owner.pid} has the port"
|
|
325
|
+
raise RuntimeError(f"Failed to start browser: DevTools on port {port} did not answer within {int(limit)}s ({state}; {last}).")
|
|
326
|
+
if now >= next_note:
|
|
327
|
+
next_note = now + 5
|
|
328
|
+
start_logger.info(
|
|
329
|
+
"browser start: still waiting after %.0fs (%s; PID %s %s)", waited, last, pid,
|
|
330
|
+
"running" if exited_at is None else f"exited at {exited_at:.1f}s" + (f", PID {owner.pid} has the port" if owner is not None else ""),
|
|
331
|
+
)
|
|
332
|
+
await asyncio.sleep(0.25)
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def install_patient_start() -> None:
|
|
336
|
+
"""Use `wait_for_devtools` for every local browser the library starts."""
|
|
337
|
+
from browser_use.browser.watchdogs.local_browser_watchdog import LocalBrowserWatchdog
|
|
338
|
+
|
|
339
|
+
if getattr(LocalBrowserWatchdog._wait_for_cdp_url, "__name__", "") != "wait_for_devtools":
|
|
340
|
+
LocalBrowserWatchdog._wait_for_cdp_url = staticmethod(wait_for_devtools)
|
|
164
341
|
|
|
165
342
|
|
|
166
343
|
def find_playwright_chromium() -> Optional[str]:
|
|
@@ -197,20 +374,44 @@ def find_playwright_chromium() -> Optional[str]:
|
|
|
197
374
|
return max(files, key=build) if files else None
|
|
198
375
|
|
|
199
376
|
|
|
200
|
-
|
|
377
|
+
LOCAL_BROWSERS = ("auto", "chrome", "edge", "chromium")
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def local_browser_choice(value: Any) -> str:
|
|
381
|
+
"""browser.local_browser of forgeqe.yaml: auto (the default), chrome, edge or chromium; anything else is auto."""
|
|
382
|
+
v = str(value or "").strip().lower()
|
|
383
|
+
return v if v in LOCAL_BROWSERS else "auto"
|
|
384
|
+
|
|
385
|
+
|
|
386
|
+
def local_launch_candidates(*, headless: bool, choice: Any = "auto") -> List[Dict[str, Any]]:
|
|
201
387
|
"""
|
|
202
|
-
The local browsers to try, in order: the one `local_browser_launch_kwargs` picks
|
|
203
|
-
then Microsoft Edge, then Playwright's Chromium
|
|
204
|
-
|
|
388
|
+
The local browsers to try, in order. With browser.local_browser auto: the one `local_browser_launch_kwargs` picks
|
|
389
|
+
(installed Chrome by default), then Microsoft Edge, then Playwright's Chromium; the same browser is never listed
|
|
390
|
+
twice. chrome, edge or chromium: that browser only. A browser named with BROWSER_USE_EXECUTABLE_PATH wins over the
|
|
391
|
+
setting, and it or BROWSER_USE_FALLBACK=0 means that one only. Each is a full set of launch kwargs.
|
|
205
392
|
"""
|
|
206
393
|
first = local_browser_launch_kwargs(headless=headless)
|
|
207
394
|
pinned = bool((os.getenv("BROWSER_USE_EXECUTABLE_PATH") or "").strip()) and first.get("executable_path")
|
|
395
|
+
if pinned:
|
|
396
|
+
return [first]
|
|
397
|
+
base = {k: v for k, v in first.items() if k not in ("channel", "executable_path")}
|
|
398
|
+
pick = local_browser_choice(choice)
|
|
399
|
+
if pick == "edge":
|
|
400
|
+
edge = find_edge_executable()
|
|
401
|
+
if not edge:
|
|
402
|
+
raise RuntimeError("browser.local_browser is edge, but Microsoft Edge is not installed on this computer.")
|
|
403
|
+
return [{**base, "channel": "msedge", "executable_path": edge}]
|
|
404
|
+
if pick == "chromium":
|
|
405
|
+
pw = find_playwright_chromium()
|
|
406
|
+
# Without Playwright's Chromium here, the library finds a Chromium or installs its own.
|
|
407
|
+
return [{**base, "channel": "chromium", **({"executable_path": pw} if pw else {})}]
|
|
408
|
+
if pick == "chrome":
|
|
409
|
+
return [first]
|
|
208
410
|
off = (os.getenv("BROWSER_USE_FALLBACK") or "").strip().lower() in ("0", "false", "no", "off")
|
|
209
411
|
out = [first]
|
|
210
|
-
if
|
|
412
|
+
if off:
|
|
211
413
|
return out
|
|
212
414
|
seen = {os.path.normcase(str(first.get("executable_path") or ""))}
|
|
213
|
-
base = {k: v for k, v in first.items() if k not in ("channel", "executable_path")}
|
|
214
415
|
for channel, exe in (("msedge", find_edge_executable()), ("chromium", find_playwright_chromium())):
|
|
215
416
|
key = os.path.normcase(str(exe or ""))
|
|
216
417
|
if exe and key not in seen:
|
|
@@ -238,12 +439,22 @@ def can_fall_back(error: BaseException) -> bool:
|
|
|
238
439
|
return any(m.lower() in text for m in _EARLY_EXIT) or "failed to launch browser" in text
|
|
239
440
|
|
|
240
441
|
|
|
442
|
+
async def _within(coro: Any, seconds: float) -> Any:
|
|
443
|
+
"""Await coro in the caller's own task, as it was before a time limit was put on it (asyncio.wait_for would run the
|
|
444
|
+
browser's start in a task of its own); on Python before 3.11, which has no asyncio.timeout, through wait_for."""
|
|
445
|
+
limit = getattr(asyncio, "timeout", None)
|
|
446
|
+
if limit is None:
|
|
447
|
+
return await asyncio.wait_for(coro, timeout=seconds)
|
|
448
|
+
async with limit(seconds):
|
|
449
|
+
return await coro
|
|
450
|
+
|
|
451
|
+
|
|
241
452
|
async def start_local_browser(
|
|
242
453
|
candidates: List[Dict[str, Any]],
|
|
243
454
|
*,
|
|
244
455
|
make: Any,
|
|
245
456
|
on_fallback: Any = None,
|
|
246
|
-
timeout: float =
|
|
457
|
+
timeout: Optional[float] = None,
|
|
247
458
|
) -> "tuple[Any, Dict[str, Any]]":
|
|
248
459
|
"""
|
|
249
460
|
Start the first candidate browser that starts; returns it with its launch kwargs. A browser that closes before it
|
|
@@ -253,10 +464,15 @@ async def start_local_browser(
|
|
|
253
464
|
"""
|
|
254
465
|
failures: List[str] = []
|
|
255
466
|
first_error: Optional[BaseException] = None
|
|
467
|
+
with contextlib.suppress(Exception):
|
|
468
|
+
install_patient_start()
|
|
469
|
+
# The library's setup around the DevTools wait (devtools_wait_seconds) gets 30s more.
|
|
470
|
+
timeout = timeout if timeout is not None else devtools_wait_seconds() + 30.0
|
|
256
471
|
for i, launch in enumerate(candidates):
|
|
257
472
|
browser = make(launch)
|
|
473
|
+
start_logger.info("browser start: trying %s (%s)", browser_name(launch), launch.get("executable_path") or f"channel {launch.get('channel')}")
|
|
258
474
|
try:
|
|
259
|
-
await
|
|
475
|
+
await _within(browser.start(), timeout)
|
|
260
476
|
return browser, launch
|
|
261
477
|
except Exception as ex:
|
|
262
478
|
await _shutdown_browser_instance(browser)
|
|
@@ -348,7 +564,10 @@ def explain_browser_start(message: str, policy: Optional[str] = None, *, check_p
|
|
|
348
564
|
"policy that turns off remote debugging (open chrome://policy and look for RemoteDebuggingAllowed), security "
|
|
349
565
|
"software that stops a Chrome started for automation, or a Chrome update in progress (restart Chrome once). "
|
|
350
566
|
"ForgeQE also tries Microsoft Edge and Playwright's Chromium (npx playwright install chromium) when they are "
|
|
351
|
-
"installed.
|
|
567
|
+
"installed; browser.local_browser in forgeqe.yaml picks one of them. On a slow computer, give the browser longer "
|
|
568
|
+
"to answer with FORGEQE_ENGINE_BROWSER_START_SECONDS (90 by default); the run's log has each step of the start "
|
|
569
|
+
"(browser start: ...). Run with --headed to watch it start, or set "
|
|
570
|
+
"BROWSER_USE_EXECUTABLE_PATH to another Chrome or Edge."
|
|
352
571
|
)
|
|
353
572
|
|
|
354
573
|
|
|
@@ -617,6 +836,14 @@ async def stop_video(browser: Any) -> Optional[Path]:
|
|
|
617
836
|
return Path(path) if path and Path(path).is_file() and Path(path).stat().st_size else None
|
|
618
837
|
|
|
619
838
|
|
|
839
|
+
def _handed_over_browsers() -> Dict[int, List[str]]:
|
|
840
|
+
"""Browsers a launcher started for this engine (`wait_for_devtools` found them by their DevTools port): taken out of
|
|
841
|
+
the list here, so each is closed once, and only while it still runs with the same command line (`_end_browsers`)."""
|
|
842
|
+
out = dict(_HANDED_OVER)
|
|
843
|
+
_HANDED_OVER.clear()
|
|
844
|
+
return out
|
|
845
|
+
|
|
846
|
+
|
|
620
847
|
def _automation_browsers_of_mine() -> Dict[int, List[str]]:
|
|
621
848
|
"""
|
|
622
849
|
The browsers this engine started for automation that run now: its own descendants started with a debugging port,
|
|
@@ -682,7 +909,7 @@ async def _shutdown_browser_instance(browser: Any) -> None:
|
|
|
682
909
|
"""
|
|
683
910
|
if browser is None:
|
|
684
911
|
return
|
|
685
|
-
mine = _automation_browsers_of_mine()
|
|
912
|
+
mine = {**_handed_over_browsers(), **_automation_browsers_of_mine()}
|
|
686
913
|
for name in ("kill", "stop"):
|
|
687
914
|
fn = getattr(browser, name, None)
|
|
688
915
|
if not callable(fn):
|
|
@@ -308,7 +308,7 @@ async def interactive_login(payload: Dict[str, Any], emit: Any, finished: Any) -
|
|
|
308
308
|
return {"success": False, "error": "A login with a url is required."}
|
|
309
309
|
brand.install()
|
|
310
310
|
stored = load_sessions(logins)
|
|
311
|
-
candidates = [{**c, "storage_state": stored} if stored else c for c in local_launch_candidates(headless=False)]
|
|
311
|
+
candidates = [{**c, "storage_state": stored} if stored else c for c in local_launch_candidates(headless=False, choice=payload.get("local_browser"))]
|
|
312
312
|
|
|
313
313
|
def fell_back(failed: Dict[str, Any], nxt: Dict[str, Any], reason: str) -> None:
|
|
314
314
|
emit({"type": "log", "level": "warn", "text": f"{browser_name(failed)} did not start ({reason}); trying {browser_name(nxt)}"})
|
|
@@ -172,7 +172,7 @@ class RecordSession:
|
|
|
172
172
|
|
|
173
173
|
brand.install()
|
|
174
174
|
stored = load_sessions(logins) if self.payload.get("signed_in") else None
|
|
175
|
-
candidates = [{**c, "storage_state": stored} if stored else c for c in local_launch_candidates(headless=False)]
|
|
175
|
+
candidates = [{**c, "storage_state": stored} if stored else c for c in local_launch_candidates(headless=False, choice=self.payload.get("local_browser"))]
|
|
176
176
|
self.browser, self.launch = await start_local_browser(
|
|
177
177
|
candidates,
|
|
178
178
|
make=lambda kw: Browser(**kw),
|
|
@@ -1127,7 +1127,7 @@ async def run_browser_task(req: RunRequest, emit: Emit, cancel_event: asyncio.Ev
|
|
|
1127
1127
|
emit({"type": "log", "level": "warn", "text": f"{browser_name(failed)} did not start ({reason}); trying {browser_name(nxt)}"})
|
|
1128
1128
|
|
|
1129
1129
|
browser, browser_kw = await start_local_browser(
|
|
1130
|
-
[{**c, **extra} for c in local_launch_candidates(headless=headless)],
|
|
1130
|
+
[{**c, **extra} for c in local_launch_candidates(headless=headless, choice=browser_cfg.get("local_browser"))],
|
|
1131
1131
|
make=lambda kw: Browser(**kw),
|
|
1132
1132
|
on_fallback=_fell_back,
|
|
1133
1133
|
)
|