feat(cdp): 默认优先连接 9333 常驻 Chrome

- 无显式连接参数时先尝试 CDP 9333,失败后回退本地浏览器启动

- 修复 CDP 页选择稳定性:过滤 omnibox 系统页、无可用页时自动创建 fallback 页

- 调整页面关闭后的 active 索引维护,降低 No page found 问题

- 新增 agent-browser-stealth 二进制入口并保持与 agent-browser 行为一致

- 同步更新 CLI 帮助、README、技能文档与 docs 说明
This commit is contained in:
leeguooooo
2026-02-24 16:22:49 +09:00
parent ea2e93dbba
commit 893ddfd259
11 changed files with 236 additions and 18 deletions
+34
View File
@@ -513,6 +513,39 @@ fn main() {
}
}
// Default fork behavior: when no explicit connection mode is provided,
// try attaching to resident Chrome on CDP :9333 first. If unavailable,
// silently fall back to local launch behavior below.
let can_try_default_cdp = flags.cdp.is_none()
&& !flags.auto_connect
&& flags.provider.is_none()
&& flags.executable_path.is_none()
&& flags.profile.is_none()
&& flags.state.is_none()
&& flags.proxy.is_none()
&& flags.args.is_none()
&& flags.user_agent.is_none()
&& !flags.ignore_https_errors
&& !flags.allow_file_access
&& flags.extensions.is_empty();
let mut launched_via_default_cdp = false;
if can_try_default_cdp {
let mut launch_cmd = json!({
"id": gen_id(),
"action": "launch",
"cdpPort": 9333
});
if let Some(ref cs) = flags.color_scheme {
launch_cmd["colorScheme"] = json!(cs);
}
if let Ok(resp) = send_command(launch_cmd, &flags.session) {
launched_via_default_cdp = resp.success;
}
}
// Launch headed browser or configure browser options (without CDP or provider)
if (flags.headed
|| flags.executable_path.is_some()
@@ -527,6 +560,7 @@ fn main() {
|| flags.color_scheme.is_some())
&& flags.cdp.is_none()
&& flags.provider.is_none()
&& !launched_via_default_cdp
{
let mut launch_cmd = json!({
"id": gen_id(),
+1
View File
@@ -0,0 +1 @@
include!("main.rs");
+1
View File
@@ -2122,6 +2122,7 @@ Options:
--headed Show browser window (not headless)
--cdp <port> Connect via CDP (Chrome DevTools Protocol)
--auto-connect Auto-discover and connect to running Chrome
Default launch tries CDP at localhost:9333 first, then falls back to local browser launch
--color-scheme <scheme> Color scheme: dark, light, no-preference (or AGENT_BROWSER_COLOR_SCHEME)
--session-name <name> Auto-save/restore session state (cookies, localStorage)
--config <path> Use a custom config file (or AGENT_BROWSER_CONFIG env)