Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,12 @@ mod tests {
executable_path: None,
extensions: Vec::new(),
cdp: None,
connection_mode: None,
relay_url: None,
profile_id: None,
profile_directory: None,
persist_tab_assignment: false,
agent_id: None,
profile: None,
state: None,
proxy: None,
Expand Down
24 changes: 24 additions & 0 deletions cli/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ pub struct DaemonOptions<'a> {
pub debug: bool,
pub executable_path: Option<&'a str>,
pub extensions: &'a [String],
pub connection_mode: Option<&'a str>,
pub relay_url: Option<&'a str>,
pub profile_id: Option<&'a str>,
pub profile_directory: Option<&'a str>,
pub persist_tab_assignment: bool,
pub agent_id: Option<&'a str>,
pub args: Option<&'a str>,
pub user_agent: Option<&'a str>,
pub proxy: Option<&'a str>,
Expand Down Expand Up @@ -219,6 +225,24 @@ fn apply_daemon_env(cmd: &mut Command, session: &str, opts: &DaemonOptions) {
if !opts.extensions.is_empty() {
cmd.env("AGENT_BROWSER_EXTENSIONS", opts.extensions.join(","));
}
if let Some(mode) = opts.connection_mode {
cmd.env("AGENT_BROWSER_CONNECTION_MODE", mode);
}
if let Some(relay_url) = opts.relay_url {
cmd.env("AGENT_BROWSER_RELAY_URL", relay_url);
}
if let Some(profile_id) = opts.profile_id {
cmd.env("AGENT_BROWSER_PROFILE_ID", profile_id);
}
if let Some(profile_directory) = opts.profile_directory {
cmd.env("AGENT_BROWSER_PROFILE_DIRECTORY", profile_directory);
}
if opts.persist_tab_assignment {
cmd.env("AGENT_BROWSER_PERSIST_TAB_ASSIGNMENT", "1");
}
if let Some(agent_id) = opts.agent_id {
cmd.env("AGENT_BROWSER_AGENT_ID", agent_id);
}
if let Some(a) = opts.args {
cmd.env("AGENT_BROWSER_ARGS", a);
}
Expand Down
81 changes: 81 additions & 0 deletions cli/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ pub struct Config {
pub ignore_https_errors: Option<bool>,
pub allow_file_access: Option<bool>,
pub cdp: Option<String>,
pub connection_mode: Option<String>,
pub relay_url: Option<String>,
pub profile_id: Option<String>,
pub profile_directory: Option<String>,
pub persist_tab_assignment: Option<bool>,
pub agent_id: Option<String>,
pub auto_connect: Option<bool>,
pub headers: Option<String>,
pub annotate: Option<bool>,
Expand Down Expand Up @@ -116,6 +122,12 @@ impl Config {
ignore_https_errors: other.ignore_https_errors.or(self.ignore_https_errors),
allow_file_access: other.allow_file_access.or(self.allow_file_access),
cdp: other.cdp.or(self.cdp),
connection_mode: other.connection_mode.or(self.connection_mode),
relay_url: other.relay_url.or(self.relay_url),
profile_id: other.profile_id.or(self.profile_id),
profile_directory: other.profile_directory.or(self.profile_directory),
persist_tab_assignment: other.persist_tab_assignment.or(self.persist_tab_assignment),
agent_id: other.agent_id.or(self.agent_id),
auto_connect: other.auto_connect.or(self.auto_connect),
headers: other.headers.or(self.headers),
annotate: other.annotate.or(self.annotate),
Expand Down Expand Up @@ -195,6 +207,10 @@ fn extract_config_path(args: &[String]) -> Option<Option<String>> {
"--headers",
"--executable-path",
"--cdp",
"--connection-mode",
"--relay-url",
"--profile-id",
"--profile-directory",
"--extension",
"--profile",
"--state",
Expand All @@ -206,6 +222,7 @@ fn extract_config_path(args: &[String]) -> Option<Option<String>> {
"--provider",
"--device",
"--session-name",
"--agent-id",
"--color-scheme",
"--download-path",
"--max-output",
Expand Down Expand Up @@ -271,6 +288,12 @@ pub struct Flags {
pub headers: Option<String>,
pub executable_path: Option<String>,
pub cdp: Option<String>,
pub connection_mode: Option<String>,
pub relay_url: Option<String>,
pub profile_id: Option<String>,
pub profile_directory: Option<String>,
pub persist_tab_assignment: bool,
pub agent_id: Option<String>,
pub extensions: Vec<String>,
pub profile: Option<String>,
pub state: Option<String>,
Expand Down Expand Up @@ -350,6 +373,21 @@ pub fn parse_flags(args: &[String]) -> Flags {
.ok()
.or(config.executable_path),
cdp: config.cdp,
connection_mode: env::var("AGENT_BROWSER_CONNECTION_MODE")
.ok()
.or(config.connection_mode),
relay_url: env::var("AGENT_BROWSER_RELAY_URL")
.ok()
.or(config.relay_url),
profile_id: env::var("AGENT_BROWSER_PROFILE_ID")
.ok()
.or(config.profile_id),
profile_directory: env::var("AGENT_BROWSER_PROFILE_DIRECTORY")
.ok()
.or(config.profile_directory),
persist_tab_assignment: env_var_is_truthy("AGENT_BROWSER_PERSIST_TAB_ASSIGNMENT")
|| config.persist_tab_assignment.unwrap_or(false),
agent_id: env::var("AGENT_BROWSER_AGENT_ID").ok().or(config.agent_id),
extensions,
profile: env::var("AGENT_BROWSER_PROFILE").ok().or(config.profile),
state: env::var("AGENT_BROWSER_STATE").ok().or(config.state),
Expand Down Expand Up @@ -503,6 +541,30 @@ pub fn parse_flags(args: &[String]) -> Flags {
i += 1;
}
}
"--connection-mode" => {
if let Some(s) = args.get(i + 1) {
flags.connection_mode = Some(s.clone());
i += 1;
}
}
"--relay-url" => {
if let Some(s) = args.get(i + 1) {
flags.relay_url = Some(s.clone());
i += 1;
}
}
"--profile-id" => {
if let Some(s) = args.get(i + 1) {
flags.profile_id = Some(s.clone());
i += 1;
}
}
"--profile-directory" => {
if let Some(s) = args.get(i + 1) {
flags.profile_directory = Some(s.clone());
i += 1;
}
}
"--profile" => {
if let Some(s) = args.get(i + 1) {
flags.profile = Some(s.clone());
Expand Down Expand Up @@ -579,6 +641,19 @@ pub fn parse_flags(args: &[String]) -> Flags {
i += 1;
}
}
"--persist-tab-assignment" => {
let (val, consumed) = parse_bool_arg(args, i);
flags.persist_tab_assignment = val;
if consumed {
i += 1;
}
}
"--agent-id" => {
if let Some(s) = args.get(i + 1) {
flags.agent_id = Some(s.clone());
i += 1;
}
}
"--session-name" => {
if let Some(s) = args.get(i + 1) {
flags.session_name = Some(s.clone());
Expand Down Expand Up @@ -716,6 +791,7 @@ pub fn clean_args(args: &[String]) -> Vec<String> {
"--ignore-https-errors",
"--allow-file-access",
"--auto-connect",
"--persist-tab-assignment",
"--annotate",
"--content-boundaries",
"--confirm-interactive",
Expand All @@ -726,6 +802,10 @@ pub fn clean_args(args: &[String]) -> Vec<String> {
"--headers",
"--executable-path",
"--cdp",
"--connection-mode",
"--relay-url",
"--profile-id",
"--profile-directory",
"--extension",
"--profile",
"--state",
Expand All @@ -736,6 +816,7 @@ pub fn clean_args(args: &[String]) -> Vec<String> {
"-p",
"--provider",
"--device",
"--agent-id",
"--session-name",
"--color-scheme",
"--download-path",
Expand Down
6 changes: 6 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ fn main() {
debug: flags.debug,
executable_path: flags.executable_path.as_deref(),
extensions: &flags.extensions,
connection_mode: flags.connection_mode.as_deref(),
relay_url: flags.relay_url.as_deref(),
profile_id: flags.profile_id.as_deref(),
profile_directory: flags.profile_directory.as_deref(),
persist_tab_assignment: flags.persist_tab_assignment,
agent_id: flags.agent_id.as_deref(),
args: flags.args.as_deref(),
user_agent: flags.user_agent.as_deref(),
proxy: flags.proxy.as_deref(),
Expand Down
Loading
Loading