Add --profile flag for persistent browser profiles (#68)

* Add --profile flag for persistent browser profiles

Adds support for persistent browser profiles that preserve cookies,
localStorage, and login sessions across browser restarts.

Changes:
- Add --profile <path> CLI flag (flags.rs)
- Add AGENT_BROWSER_PROFILE environment variable support
- Add profile field to LaunchCommand type (types.ts)
- Use launchPersistentContext when profile is specified (browser.ts)
- Update help text and README with documentation

Usage:
  agent-browser --profile ~/.myapp-profile open myapp.com

This enables AI agents to maintain authenticated sessions across
browser restarts without re-authenticating each time.

* Expand tilde in profile path to home directory

* fix: add missing profile field to test Flags struct

---------

Co-authored-by: Chris Tate <chris@ctate.dev>
This commit is contained in:
Lindsey Simon
2026-01-22 08:05:25 -06:00
committed by GitHub
co-authored by Chris Tate
parent c6a92a1472
commit 36cca10c10
7 changed files with 64 additions and 2 deletions
+8 -2
View File
@@ -217,6 +217,7 @@ fn main() {
let ignored_flags: Vec<&str> = [
flags.executable_path.as_ref().map(|_| "--executable-path"),
if has_extensions { Some("--extension") } else { None },
flags.profile.as_ref().map(|_| "--profile"),
flags.args.as_ref().map(|_| "--args"),
flags.user_agent.as_ref().map(|_| "--user-agent"),
flags.proxy.as_ref().map(|_| "--proxy"),
@@ -358,8 +359,8 @@ fn main() {
}
}
// Launch headed browser or proxy if flags are set (without CDP or provider)
if (flags.headed || flags.proxy.is_some() || flags.args.is_some() || flags.user_agent.is_some()) && flags.cdp.is_none() && flags.provider.is_none() {
// Launch headed browser or configure browser options (without CDP or provider)
if (flags.headed || flags.profile.is_some() || flags.proxy.is_some() || flags.args.is_some() || flags.user_agent.is_some()) && flags.cdp.is_none() && flags.provider.is_none() {
let mut launch_cmd = json!({
"id": gen_id(),
"action": "launch",
@@ -369,6 +370,11 @@ fn main() {
let cmd_obj = launch_cmd.as_object_mut()
.expect("json! macro guarantees object type");
// Add profile path if specified
if let Some(ref profile_path) = flags.profile {
cmd_obj.insert("profile".to_string(), json!(profile_path));
}
if let Some(ref proxy_str) = flags.proxy {
let mut proxy_obj = parse_proxy(proxy_str);
// Add bypass if specified