Skip to main content

distri_types/browser/
mod.rs

1pub use browsr_types::BrowsrClientConfig;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5/// Agent-level configuration for enabling the shared browser runtime
6#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
7#[serde(default, deny_unknown_fields)]
8#[derive(Default)]
9pub struct BrowserAgentConfig {
10    /// Whether the orchestrator should eagerly initialize the browser
11    pub enabled: bool,
12    /// Persist and restore session cookies/state between runs
13    pub persist_session: bool,
14    /// Optional runtime overrides for the Chromium driver
15    #[serde(skip_serializing_if = "Option::is_none", flatten)]
16    pub runtime: Option<BrowsrClientConfig>,
17}
18
19impl BrowserAgentConfig {
20    pub fn is_enabled(&self) -> bool {
21        self.enabled
22    }
23
24    pub fn should_persist_session(&self) -> bool {
25        self.persist_session
26    }
27
28    pub fn runtime_config(&self) -> BrowsrClientConfig {
29        self.runtime.clone().unwrap_or_default()
30    }
31}