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)]
8pub struct BrowserAgentConfig {
9    /// Whether the orchestrator should eagerly initialize the browser
10    pub enabled: bool,
11    /// Persist and restore session cookies/state between runs
12    pub persist_session: bool,
13    /// Optional runtime overrides for the Chromium driver
14    #[serde(skip_serializing_if = "Option::is_none", flatten)]
15    pub runtime: Option<BrowsrClientConfig>,
16}
17
18impl Default for BrowserAgentConfig {
19    fn default() -> Self {
20        Self {
21            enabled: false,
22            persist_session: false,
23            runtime: None,
24        }
25    }
26}
27
28impl BrowserAgentConfig {
29    pub fn is_enabled(&self) -> bool {
30        self.enabled
31    }
32
33    pub fn should_persist_session(&self) -> bool {
34        self.persist_session
35    }
36
37    pub fn runtime_config(&self) -> BrowsrClientConfig {
38        self.runtime.clone().unwrap_or_default()
39    }
40}