Skip to main content

codetether_agent/browser/session/lifecycle/
mod.rs

1mod attach;
2mod browser;
3mod discover;
4mod handler;
5mod launch;
6mod mode;
7mod start;
8mod stop;
9
10/// Probe the host for a Chromium-family browser executable.
11///
12/// Returns the absolute path of the first candidate that exists, or `None`
13/// if none of the well-known install locations contain a usable binary.
14pub fn detect_browser() -> Option<std::path::PathBuf> {
15    discover::find_chromium_browser()
16}
17
18/// Apply the user-agent stealth override to a freshly created page so it
19/// stops advertising `HeadlessChrome`. No-op if the UA is already clean.
20pub(in crate::browser::session) async fn apply_stealth_ua(
21    page: &chromiumoxide::page::Page,
22) -> Result<(), crate::browser::BrowserError> {
23    launch::apply_stealth_ua(page).await
24}
25
26/// Install the document-start hooks (network-idle tracker, webdriver
27/// fingerprint removal) on a freshly created page. Errors are non-fatal.
28pub(in crate::browser::session) async fn install_page_hooks(
29    page: &chromiumoxide::page::Page,
30) -> Result<(), crate::browser::BrowserError> {
31    launch::install_page_hooks(page).await
32}
33
34pub(super) async fn start(
35    session: &super::BrowserSession,
36    request: crate::browser::request::StartRequest,
37) -> Result<crate::browser::BrowserOutput, crate::browser::BrowserError> {
38    start::run(session, request).await
39}
40
41pub(super) async fn stop(
42    session: &super::BrowserSession,
43) -> Result<crate::browser::BrowserOutput, crate::browser::BrowserError> {
44    stop::run(session).await
45}