feat: add browser launch --args, --user-agent, --proxy-bypass configuration support. (#35)

* feat: add browser launch args, user-agent, and proxy configuration support

* fix: User Agent env need added

* fix: command pass error

---------

Co-authored-by: Chris Tate <chris@ctate.dev>
This commit is contained in:
Oanakiaja
2026-01-22 00:19:37 -06:00
committed by GitHub
co-authored by Chris Tate
parent e892bceadf
commit 083a946aac
12 changed files with 1075 additions and 198 deletions
+7 -1
View File
@@ -865,14 +865,18 @@ export class BrowserManager {
if (hasExtensions) {
const extPaths = options.extensions!.join(',');
const session = process.env.AGENT_BROWSER_SESSION || 'default';
// Combine extension args with custom args
const extArgs = [`--disable-extensions-except=${extPaths}`, `--load-extension=${extPaths}`];
const allArgs = options.args ? [...extArgs, ...options.args] : extArgs;
context = await launcher.launchPersistentContext(
path.join(os.tmpdir(), `agent-browser-ext-${session}`),
{
headless: false,
executablePath: options.executablePath,
args: [`--disable-extensions-except=${extPaths}`, `--load-extension=${extPaths}`],
args: allArgs,
viewport,
extraHTTPHeaders: options.headers,
userAgent: options.userAgent,
...(options.proxy && { proxy: options.proxy }),
}
);
@@ -881,11 +885,13 @@ export class BrowserManager {
this.browser = await launcher.launch({
headless: options.headless ?? true,
executablePath: options.executablePath,
args: options.args,
});
this.cdpEndpoint = null;
context = await this.browser.newContext({
viewport,
extraHTTPHeaders: options.headers,
userAgent: options.userAgent,
...(options.proxy && { proxy: options.proxy }),
});
}