Compare commits

...
4 Commits
Author SHA1 Message Date
leeguooooo 58dc02bfdc chore(release): 1.5.14 — fix eval await regression (replMode) + default scroll; green CI (#36, #38)
Release binaries / Build macOS ARM64 (push) Has been cancelled
Release binaries / Build macOS x64 (push) Has been cancelled
Release binaries / Build Linux ARM64 (push) Has been cancelled
Release binaries / Build Linux musl ARM64 (push) Has been cancelled
Release binaries / Build Linux musl x64 (push) Has been cancelled
Release binaries / Build Linux x64 (push) Has been cancelled
Release binaries / Build Windows x64 (push) Has been cancelled
Release binaries / Attach binaries to GitHub Release (push) Has been cancelled
2026-06-17 02:34:55 +09:00
leeguooooo c47601bd7b fix(eval): replMode only for sync let/const decls, keep awaitPromise for async (#38)
replMode and awaitPromise are mutually exclusive in Chrome — under replMode a
returned promise serialises to {} instead of being awaited, which broke every
fetch/async eval (e2e_domain_filter, e2e_headers, e2e_react_tree all regressed).
Enable replMode only for synchronous scripts that declare a top-level let/const
(the #38 case); promise-returning scripts keep awaitPromise — restoring the
pre-#38 await behaviour while still fixing the let-redeclaration collision.
2026-06-17 02:08:11 +09:00
leeguooooo 0296bc7a88 fix(scroll): keep default scroll on window.scrollBy; wheel only for --at/--frame (#36)
The centered-wheel default no-op'd on some pages (headless e2e_hover_scroll_press
regressed). Restore window.scrollBy for plain page scroll; the coordinate wheel
stays opt-in via --at/--frame for cross-origin iframe content.
2026-06-17 02:01:23 +09:00
leeguooooo 32e203b908 style: cargo fmt (fixes the CI format-check failure) 2026-06-17 01:33:22 +09:00
10 changed files with 240 additions and 78 deletions
+1 -1
View File
@@ -290,7 +290,7 @@ checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
[[package]] [[package]]
name = "chrome-use" name = "chrome-use"
version = "1.5.13" version = "1.5.14"
dependencies = [ dependencies = [
"aes", "aes",
"aes-gcm", "aes-gcm",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "chrome-use" name = "chrome-use"
version = "1.5.13" version = "1.5.14"
edition = "2021" edition = "2021"
description = "Fast browser automation CLI for AI agents" description = "Fast browser automation CLI for AI agents"
license = "Apache-2.0" license = "Apache-2.0"
+72 -16
View File
@@ -34,11 +34,50 @@ pub enum ParseError {
/// suggestions on an unknown command (issue #29). Not exhaustive — just the /// suggestions on an unknown command (issue #29). Not exhaustive — just the
/// common verbs plus a few known wrong-guesses mapped to the real command. /// common verbs plus a few known wrong-guesses mapped to the real command.
const KNOWN_COMMANDS: &[&str] = &[ const KNOWN_COMMANDS: &[&str] = &[
"open", "navigate", "click", "fill", "type", "press", "snapshot", "screenshot", "eval", "get", "open",
"text", "html", "frames", "find", "wait", "scroll", "hover", "select", "check", "uncheck", "navigate",
"tab", "tabs", "close", "back", "forward", "reload", "sessions", "status", "daemon", "doctor", "click",
"upgrade", "connect", "cookies", "mouse", "keyboard", "stream", "frame", "profiles", "title", "fill",
"url", "is", "drag", "dialog", "upload", "type",
"press",
"snapshot",
"screenshot",
"eval",
"get",
"text",
"html",
"frames",
"find",
"wait",
"scroll",
"hover",
"select",
"check",
"uncheck",
"tab",
"tabs",
"close",
"back",
"forward",
"reload",
"sessions",
"status",
"daemon",
"doctor",
"upgrade",
"connect",
"cookies",
"mouse",
"keyboard",
"stream",
"frame",
"profiles",
"title",
"url",
"is",
"drag",
"dialog",
"upload",
]; ];
/// Levenshtein distance, capped — small inputs only (command names). /// Levenshtein distance, capped — small inputs only (command names).
@@ -547,7 +586,9 @@ fn parse_command_inner(args: &[String], flags: &Flags) -> Result<Value, ParseErr
context: "type".to_string(), context: "type".to_string(),
usage: "type <selector> <text> (or: type --focused <text>) [--key-events]", usage: "type <selector> <text> (or: type --focused <text>) [--key-events]",
})?; })?;
Ok(json!({ "id": id, "action": "type", "selector": sel, "text": rest[1..].join(" "), "keyEvents": key_events })) Ok(
json!({ "id": id, "action": "type", "selector": sel, "text": rest[1..].join(" "), "keyEvents": key_events }),
)
} }
"pick" => { "pick" => {
// pick <selector|@ref> --option "<text>" — atomic combobox select: // pick <selector|@ref> --option "<text>" — atomic combobox select:
@@ -761,7 +802,8 @@ fn parse_command_inner(args: &[String], flags: &Flags) -> Result<Value, ParseErr
_ => { _ => {
return Err(ParseError::InvalidValue { return Err(ParseError::InvalidValue {
message: format!("scroll --at: invalid coordinate `{}`", val), message: format!("scroll --at: invalid coordinate `{}`", val),
usage: "scroll [direction] [amount] --at <x,y> (e.g. --at 640,400)", usage:
"scroll [direction] [amount] --at <x,y> (e.g. --at 640,400)",
}) })
} }
} }
@@ -970,17 +1012,21 @@ fn parse_command_inner(args: &[String], flags: &Flags) -> Result<Value, ParseErr
"--full" | "-f" => full_page = true, "--full" | "-f" => full_page = true,
// `--clip x,y,w,h` captures a pixel region (issue #34). // `--clip x,y,w,h` captures a pixel region (issue #34).
"--clip" => { "--clip" => {
let raw = rest.get(i + 1).ok_or_else(|| ParseError::MissingArguments { let raw = rest
context: "screenshot --clip".to_string(), .get(i + 1)
usage: "screenshot --clip <x,y,w,h> [path]", .ok_or_else(|| ParseError::MissingArguments {
})?; context: "screenshot --clip".to_string(),
usage: "screenshot --clip <x,y,w,h> [path]",
})?;
let nums: Vec<f64> = raw let nums: Vec<f64> = raw
.split(',') .split(',')
.filter_map(|n| n.trim().parse::<f64>().ok()) .filter_map(|n| n.trim().parse::<f64>().ok())
.collect(); .collect();
if nums.len() != 4 { if nums.len() != 4 {
return Err(ParseError::InvalidValue { return Err(ParseError::InvalidValue {
message: format!("--clip expects 'x,y,w,h' (4 numbers), got '{raw}'"), message: format!(
"--clip expects 'x,y,w,h' (4 numbers), got '{raw}'"
),
usage: "screenshot --clip <x,y,w,h> [path]", usage: "screenshot --clip <x,y,w,h> [path]",
}); });
} }
@@ -4128,7 +4174,11 @@ mod tests {
fn test_type_key_events() { fn test_type_key_events() {
// --key-events sends real keystrokes (for autocomplete/combobox) and must // --key-events sends real keystrokes (for autocomplete/combobox) and must
// not be swallowed into the typed text. // not be swallowed into the typed text.
let cmd = parse_command(&args("type #postal 201-0001 --key-events"), &default_flags()).unwrap(); let cmd = parse_command(
&args("type #postal 201-0001 --key-events"),
&default_flags(),
)
.unwrap();
assert_eq!(cmd["action"], "type"); assert_eq!(cmd["action"], "type");
assert_eq!(cmd["selector"], "#postal"); assert_eq!(cmd["selector"], "#postal");
assert_eq!(cmd["text"], "201-0001"); assert_eq!(cmd["text"], "201-0001");
@@ -4426,8 +4476,11 @@ mod tests {
#[test] #[test]
fn test_screenshot_clip() { fn test_screenshot_clip() {
// `--clip x,y,w,h` captures a pixel region (issue #34); the path still parses. // `--clip x,y,w,h` captures a pixel region (issue #34); the path still parses.
let cmd = parse_command(&args("screenshot --clip 10,20,200,40 out.png"), &default_flags()) let cmd = parse_command(
.unwrap(); &args("screenshot --clip 10,20,200,40 out.png"),
&default_flags(),
)
.unwrap();
assert_eq!(cmd["action"], "screenshot"); assert_eq!(cmd["action"], "screenshot");
assert_eq!(cmd["clip"]["x"], 10.0); assert_eq!(cmd["clip"]["x"], 10.0);
assert_eq!(cmd["clip"]["y"], 20.0); assert_eq!(cmd["clip"]["y"], 20.0);
@@ -5005,7 +5058,10 @@ mod tests {
assert_eq!(nearest_command("sesions").as_deref(), Some("sessions")); assert_eq!(nearest_command("sesions").as_deref(), Some("sessions"));
assert_eq!(nearest_command("session").as_deref(), Some("sessions")); assert_eq!(nearest_command("session").as_deref(), Some("sessions"));
assert_eq!(nearest_command("clik").as_deref(), Some("click")); assert_eq!(nearest_command("clik").as_deref(), Some("click"));
assert_eq!(nearest_command("screenshits").as_deref(), Some("screenshot")); assert_eq!(
nearest_command("screenshits").as_deref(),
Some("screenshot")
);
// Nonsense with no close match stays silent. // Nonsense with no close match stays silent.
assert_eq!(nearest_command("xyzzy"), None); assert_eq!(nearest_command("xyzzy"), None);
// The unknown-command error embeds the suggestion. // The unknown-command error embeds the suggestion.
+48 -29
View File
@@ -3244,8 +3244,14 @@ async fn handle_type(cmd: &Value, state: &mut DaemonState) -> Result<Value, Stri
.get("text") .get("text")
.and_then(|v| v.as_str()) .and_then(|v| v.as_str())
.ok_or("Missing 'text' parameter")?; .ok_or("Missing 'text' parameter")?;
interaction::type_text_into_active_context(&mgr.client, &session_id, text, None, key_events) interaction::type_text_into_active_context(
.await?; &mgr.client,
&session_id,
text,
None,
key_events,
)
.await?;
return Ok(json!({ "typed": text, "focused": true })); return Ok(json!({ "typed": text, "focused": true }));
} }
@@ -3493,27 +3499,40 @@ async fn handle_scroll(cmd: &Value, state: &mut DaemonState) -> Result<Value, St
return Ok(json!({ "scrolled": true, "via": "selector" })); return Ok(json!({ "scrolled": true, "via": "selector" }));
} }
// No selector: dispatch a real (isTrusted) wheel at a viewport coordinate. // `--at x,y` / `--frame n`: dispatch a real (isTrusted) wheel at a viewport
// This hits the compositor and scrolls whatever scroll container is under the // coordinate. This hits the compositor and scrolls whatever scroll container
// pointer — including cross-origin iframes that `window.scrollBy` on the top // is under the pointer — including cross-origin iframes that `window.scrollBy`
// document silently no-ops on (issue #36). The coordinate is, in priority: // on the top document silently no-ops on (issue #36).
// --at x,y → that exact pixel if cmd.get("at").is_some() || cmd.get("frame").is_some() {
// --frame n → the center of frame n from `chrome-use frames` let (x, y, via) = if let Some(at) = cmd.get("at").and_then(|v| v.as_array()) {
// default → the viewport center let x = at.first().and_then(|v| v.as_f64()).unwrap_or(0.0);
let (x, y, via) = if let Some(at) = cmd.get("at").and_then(|v| v.as_array()) { let y = at.get(1).and_then(|v| v.as_f64()).unwrap_or(0.0);
let x = at.first().and_then(|v| v.as_f64()).unwrap_or(0.0); (x, y, "at")
let y = at.get(1).and_then(|v| v.as_f64()).unwrap_or(0.0); } else {
(x, y, "at") let n = cmd.get("frame").and_then(|v| v.as_u64()).unwrap_or(0);
} else if let Some(n) = cmd.get("frame").and_then(|v| v.as_u64()) { let (x, y) = frame_center(mgr, &session_id, &state.iframe_sessions, n as usize).await?;
let (x, y) = frame_center(mgr, &session_id, &state.iframe_sessions, n as usize).await?; (x, y, "frame")
(x, y, "frame") };
} else { dispatch_wheel(&mgr.client, &session_id, x, y, dx, dy).await?;
let (x, y) = viewport_center(mgr, &session_id).await?; return Ok(json!({ "scrolled": true, "via": via, "at": [x, y] }));
(x, y, "center") }
};
dispatch_wheel(&mgr.client, &session_id, x, y, dx, dy).await?; // Default (no selector/at/frame): scroll the page with `window.scrollBy`. This
Ok(json!({ "scrolled": true, "via": via, "at": [x, y] })) // is the reliable path for ordinary page scrolling; a coordinate wheel at the
// viewport centre is NOT a dependable substitute (it no-ops on some pages,
// e.g. headless), so the wheel stays opt-in via `--at`/`--frame` for the
// cross-origin-iframe case (issue #36).
interaction::scroll(
&mgr.client,
&session_id,
&state.ref_map,
None,
dx,
dy,
&state.iframe_sessions,
)
.await?;
Ok(json!({ "scrolled": true, "via": "page" }))
} }
/// Viewport center in CSS pixels, used as the default wheel landing point for /// Viewport center in CSS pixels, used as the default wheel landing point for
@@ -3836,12 +3855,9 @@ async fn handle_gettext(cmd: &Value, state: &mut DaemonState) -> Result<Value, S
async fn handle_frames(_cmd: &Value, state: &mut DaemonState) -> Result<Value, String> { async fn handle_frames(_cmd: &Value, state: &mut DaemonState) -> Result<Value, String> {
let mgr = state.browser.as_ref().ok_or("Browser not launched")?; let mgr = state.browser.as_ref().ok_or("Browser not launched")?;
let session_id = mgr.active_session_id()?.to_string(); let session_id = mgr.active_session_id()?.to_string();
let frames = super::element::collect_all_frames_text( let frames =
&mgr.client, super::element::collect_all_frames_text(&mgr.client, &session_id, &state.iframe_sessions)
&session_id, .await?;
&state.iframe_sessions,
)
.await?;
let list: Vec<Value> = frames let list: Vec<Value> = frames
.iter() .iter()
.enumerate() .enumerate()
@@ -4337,7 +4353,10 @@ async fn handle_cf_status(_cmd: &Value, state: &mut DaemonState) -> Result<Value
let url = mgr.get_url().await.unwrap_or_default(); let url = mgr.get_url().await.unwrap_or_default();
// 1. Is the page a Cloudflare challenge right now? // 1. Is the page a Cloudflare challenge right now?
let probe_raw = mgr.evaluate(CF_CHALLENGE_JS, None).await.unwrap_or(Value::Null); let probe_raw = mgr
.evaluate(CF_CHALLENGE_JS, None)
.await
.unwrap_or(Value::Null);
let probe = parse_json_string(probe_raw, "cf challenge probe").unwrap_or(Value::Null); let probe = parse_json_string(probe_raw, "cf challenge probe").unwrap_or(Value::Null);
let challenged = probe let challenged = probe
.get("challenged") .get("challenged")
+42 -16
View File
@@ -579,7 +579,10 @@ impl BrowserManager {
crate::connect::log_connect_mode( crate::connect::log_connect_mode(
&ws_url, &ws_url,
true, true,
DAEMON_SESSION.get().map(String::as_str).unwrap_or("default"), DAEMON_SESSION
.get()
.map(String::as_str)
.unwrap_or("default"),
); );
let manager = if engine == "lightpanda" { let manager = if engine == "lightpanda" {
initialize_lightpanda_manager(ws_url, process).await? initialize_lightpanda_manager(ws_url, process).await?
@@ -681,7 +684,10 @@ impl BrowserManager {
crate::connect::log_connect_mode( crate::connect::log_connect_mode(
&ws_url, &ws_url,
false, false,
DAEMON_SESSION.get().map(String::as_str).unwrap_or("default"), DAEMON_SESSION
.get()
.map(String::as_str)
.unwrap_or("default"),
); );
let client = Arc::new(CdpClient::connect_with_headers(&ws_url, headers).await?); let client = Arc::new(CdpClient::connect_with_headers(&ws_url, headers).await?);
let mut manager = Self { let mut manager = Self {
@@ -1202,13 +1208,21 @@ impl BrowserManager {
pub async fn evaluate(&self, script: &str, _args: Option<Value>) -> Result<Value, String> { pub async fn evaluate(&self, script: &str, _args: Option<Value>) -> Result<Value, String> {
let session_id = self.active_session_id()?.to_string(); let session_id = self.active_session_id()?.to_string();
// `replMode: true` matches the DevTools console: top-level `let`/`const` // `replMode: true` lets successive `eval`s re-declare top-level
// can be re-declared across successive `eval`s instead of throwing // `let`/`const` instead of throwing "Identifier 'x' has already been
// "Identifier 'x' has already been declared" (issue #38 — independent // declared" (issue #38 — independent `eval` steps in a test suite collided
// `eval` steps in a test suite collided in the page's shared lexical // in the page's shared lexical scope). BUT replMode and `awaitPromise` are
// scope), and top-level `await` is allowed. Completion-value and // mutually exclusive in Chrome: under replMode a returned promise is NOT
// main-world semantics are unchanged. Built as raw params so the other // awaited (it serialises to `{}`), which breaks `fetch(...).then(...)` and
// ~28 EvaluateParams literals don't all need a new field. // every other async eval. So enable replMode ONLY for synchronous scripts
// that declare a top-level `let`/`const`; promise-returning scripts keep
// `awaitPromise` (no replMode) — exactly the pre-#38 behaviour.
let mentions_async = script.contains("await")
|| script.contains(".then(")
|| script.contains("fetch(")
|| script.contains("Promise");
let declares = script.contains("let ") || script.contains("const ");
let repl_mode = declares && !mentions_async;
let result: EvaluateResult = self let result: EvaluateResult = self
.client .client
.send_command_typed( .send_command_typed(
@@ -1216,8 +1230,8 @@ impl BrowserManager {
&json!({ &json!({
"expression": script, "expression": script,
"returnByValue": true, "returnByValue": true,
"awaitPromise": true, "awaitPromise": !repl_mode,
"replMode": true, "replMode": repl_mode,
}), }),
Some(&session_id), Some(&session_id),
) )
@@ -2815,7 +2829,9 @@ mod tests {
its tab is gone (closed, navigated across processes, or lost after an extension \ its tab is gone (closed, navigated across processes, or lost after an extension \
restart). Re-attach by re-opening your target URL before retrying." restart). Re-attach by re-opening your target URL before retrying."
)); ));
assert!(is_stale_target_error("unknown sessionId cb-tab-7 for Page.navigate")); assert!(is_stale_target_error(
"unknown sessionId cb-tab-7 for Page.navigate"
));
assert!(is_stale_target_error("no attached tab for Page.navigate")); assert!(is_stale_target_error("no attached tab for Page.navigate"));
} }
@@ -2823,8 +2839,12 @@ mod tests {
fn stale_target_error_ignores_unrelated_failures() { fn stale_target_error_ignores_unrelated_failures() {
// A genuine navigation failure (bad URL, DNS, blocked) must NOT trigger // A genuine navigation failure (bad URL, DNS, blocked) must NOT trigger
// the open-a-fresh-tab recovery — that would mask the real error. // the open-a-fresh-tab recovery — that would mask the real error.
assert!(!is_stale_target_error("Navigation failed: net::ERR_NAME_NOT_RESOLVED")); assert!(!is_stale_target_error(
assert!(!is_stale_target_error("CDP command timed out: Page.navigate")); "Navigation failed: net::ERR_NAME_NOT_RESOLVED"
));
assert!(!is_stale_target_error(
"CDP command timed out: Page.navigate"
));
} }
fn page(target_id: &str) -> PageInfo { fn page(target_id: &str) -> PageInfo {
@@ -2931,7 +2951,10 @@ mod tests {
let dirty = "\u{200d}\u{2061}\u{200d}\u{2063}\u{200b}\u{2062}\u{feff}GitHub"; let dirty = "\u{200d}\u{2061}\u{200d}\u{2063}\u{200b}\u{2062}\u{feff}GitHub";
assert_eq!(sanitize_title(dirty), "GitHub"); assert_eq!(sanitize_title(dirty), "GitHub");
// Clean titles (incl. CJK + normal punctuation) pass through untouched. // Clean titles (incl. CJK + normal punctuation) pass through untouched.
assert_eq!(sanitize_title("購入手続きへ - メルカリ"), "購入手続きへ - メルカリ"); assert_eq!(
sanitize_title("購入手続きへ - メルカリ"),
"購入手続きへ - メルカリ"
);
assert_eq!(sanitize_title(" Hello World "), "Hello World"); assert_eq!(sanitize_title(" Hello World "), "Hello World");
// Emoji and real content survive; only the invisibles are dropped. // Emoji and real content survive; only the invisibles are dropped.
assert_eq!(sanitize_title("✓ Done\u{200b}"), "✓ Done"); assert_eq!(sanitize_title("✓ Done\u{200b}"), "✓ Done");
@@ -2963,7 +2986,10 @@ mod tests {
// A pinned target that IS in the live set is simply not prunable anyway. // A pinned target that IS in the live set is simply not prunable anyway.
let mut live2 = HashSet::new(); let mut live2 = HashSet::new();
live2.insert("A".to_string()); live2.insert("A".to_string());
assert_eq!(prunable_target_ids(&pages, &live2, Some("A")), vec!["B".to_string()]); assert_eq!(
prunable_target_ids(&pages, &live2, Some("A")),
vec!["B".to_string()]
);
} }
#[test] #[test]
+7 -2
View File
@@ -1028,7 +1028,9 @@ async fn eval_text_in_frame(client: &CdpClient, session_id: &str, frame_id: &str
.await .await
.ok() .ok()
.and_then(|v| v.get("executionContextId").and_then(|c| c.as_i64())); .and_then(|v| v.get("executionContextId").and_then(|c| c.as_i64()));
let Some(ctx_id) = ctx else { return String::new() }; let Some(ctx_id) = ctx else {
return String::new();
};
let res = client let res = client
.send_command( .send_command(
"Runtime.evaluate", "Runtime.evaluate",
@@ -1099,7 +1101,10 @@ pub async fn collect_all_frames_text(
let (kind, text) = if is_top { let (kind, text) = if is_top {
("top", eval_text_default(client, top_session).await) ("top", eval_text_default(client, top_session).await)
} else { } else {
("inline", eval_text_in_frame(client, top_session, &fid).await) (
"inline",
eval_text_in_frame(client, top_session, &fid).await,
)
}; };
out.push(FrameText { out.push(FrameText {
frame_id: fid, frame_id: fid,
+21 -3
View File
@@ -65,7 +65,11 @@ pub async fn click(
// the element's click in its own (frame) session, always hitting the right // the element's click in its own (frame) session, always hitting the right
// element in the right tab. Double/right clicks still need true pointer // element in the right tab. Double/right clicks still need true pointer
// semantics, and `coord` mode is an explicit opt-out. // semantics, and `coord` mode is an explicit opt-out.
if mode != "coord" && button == "left" && click_count == 1 && prefer_dom_dispatch(ref_map, selector_or_ref) { if mode != "coord"
&& button == "left"
&& click_count == 1
&& prefer_dom_dispatch(ref_map, selector_or_ref)
{
return dom_click( return dom_click(
client, client,
session_id, session_id,
@@ -319,7 +323,14 @@ pub async fn dblclick(
if std::env::var("AGENT_BROWSER_CLICK_MODE").as_deref() != Ok("coord") if std::env::var("AGENT_BROWSER_CLICK_MODE").as_deref() != Ok("coord")
&& prefer_dom_dispatch(ref_map, selector_or_ref) && prefer_dom_dispatch(ref_map, selector_or_ref)
{ {
return dom_dblclick(client, session_id, ref_map, selector_or_ref, iframe_sessions).await; return dom_dblclick(
client,
session_id,
ref_map,
selector_or_ref,
iframe_sessions,
)
.await;
} }
click( click(
client, client,
@@ -387,7 +398,14 @@ pub async fn hover(
// Coordinate `mouseMoved` drifts to the foreground tab over the relay and // Coordinate `mouseMoved` drifts to the foreground tab over the relay and
// can't reach an OOPIF — DOM-dispatch the hover there (issues #31/#36). // can't reach an OOPIF — DOM-dispatch the hover there (issues #31/#36).
if prefer_dom_dispatch(ref_map, selector_or_ref) { if prefer_dom_dispatch(ref_map, selector_or_ref) {
return dom_hover(client, session_id, ref_map, selector_or_ref, iframe_sessions).await; return dom_hover(
client,
session_id,
ref_map,
selector_or_ref,
iframe_sessions,
)
.await;
} }
let (x, y, _w, _h, effective_session_id) = resolve_element_center( let (x, y, _w, _h, effective_session_id) = resolve_element_center(
client, client,
+10 -1
View File
@@ -345,7 +345,16 @@ pub async fn take_snapshot(
frame_id: Option<&str>, frame_id: Option<&str>,
iframe_sessions: &HashMap<String, String>, iframe_sessions: &HashMap<String, String>,
) -> Result<String, String> { ) -> Result<String, String> {
take_snapshot_at_depth(client, session_id, options, ref_map, frame_id, iframe_sessions, 0).await take_snapshot_at_depth(
client,
session_id,
options,
ref_map,
frame_id,
iframe_sessions,
0,
)
.await
} }
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
+37 -8
View File
@@ -228,13 +228,28 @@ pub fn print_response_with_opts(resp: &Response, action: Option<&str>, opts: &Ou
// because its response carries `url`/`title`, which later generic // because its response carries `url`/`title`, which later generic
// renderers would otherwise swallow. // renderers would otherwise swallow.
if action == Some("cf_status") { if action == Some("cf_status") {
let challenged = data.get("challenged").and_then(|v| v.as_bool()).unwrap_or(false); let challenged = data
let rec = data.get("recommendation").and_then(|v| v.as_str()).unwrap_or("?"); .get("challenged")
.and_then(|v| v.as_bool())
.unwrap_or(false);
let rec = data
.get("recommendation")
.and_then(|v| v.as_str())
.unwrap_or("?");
let cl = data.get("clearance"); let cl = data.get("clearance");
let present = cl.and_then(|c| c.get("present")).and_then(|v| v.as_bool()).unwrap_or(false); let present = cl
let expired = cl.and_then(|c| c.get("expired")).and_then(|v| v.as_bool()).unwrap_or(false); .and_then(|c| c.get("present"))
.and_then(|v| v.as_bool())
.unwrap_or(false);
let expired = cl
.and_then(|c| c.get("expired"))
.and_then(|v| v.as_bool())
.unwrap_or(false);
let expires_in = cl.and_then(|c| c.get("expiresIn")).and_then(|v| v.as_i64()); let expires_in = cl.and_then(|c| c.get("expiresIn")).and_then(|v| v.as_i64());
let device = data.get("deviceVerified").and_then(|v| v.as_bool()).unwrap_or(false); let device = data
.get("deviceVerified")
.and_then(|v| v.as_bool())
.unwrap_or(false);
let (icon, headline) = match rec { let (icon, headline) = match rec {
"proceed" => (color::success_indicator().to_string(), "cleared — no challenge, proceed"), "proceed" => (color::success_indicator().to_string(), "cleared — no challenge, proceed"),
@@ -243,7 +258,10 @@ pub fn print_response_with_opts(resp: &Response, action: Option<&str>, opts: &Ou
_ => (color::cyan("").to_string(), "unknown"), _ => (color::cyan("").to_string(), "unknown"),
}; };
println!("{} {}", icon, headline); println!("{} {}", icon, headline);
println!(" challenged: {}", if challenged { "yes" } else { "no" }); println!(
" challenged: {}",
if challenged { "yes" } else { "no" }
);
let cl_desc = if !present { let cl_desc = if !present {
"absent".to_string() "absent".to_string()
} else if expired { } else if expired {
@@ -254,7 +272,14 @@ pub fn print_response_with_opts(resp: &Response, action: Option<&str>, opts: &Ou
"present (session)".to_string() "present (session)".to_string()
}; };
println!(" cf_clearance: {}", cl_desc); println!(" cf_clearance: {}", cl_desc);
println!(" device trusted: {}", if device { "yes (CF_VERIFIED_DEVICE)" } else { "no" }); println!(
" device trusted: {}",
if device {
"yes (CF_VERIFIED_DEVICE)"
} else {
"no"
}
);
return; return;
} }
@@ -382,7 +407,11 @@ pub fn print_response_with_opts(resp: &Response, action: Option<&str>, opts: &Ou
let count = list.len(); let count = list.len();
println!( println!(
"{}", "{}",
color::bold(&format!("{} frame{}", count, if count == 1 { "" } else { "s" })) color::bold(&format!(
"{} frame{}",
count,
if count == 1 { "" } else { "s" }
))
); );
for f in list { for f in list {
let idx = f.get("index").and_then(|v| v.as_i64()).unwrap_or(0); let idx = f.get("index").and_then(|v| v.as_i64()).unwrap_or(0);
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "chrome-use", "name": "chrome-use",
"version": "1.5.13", "version": "1.5.14",
"description": "chrome-use — drive your real, logged-in Chrome from any AI agent, stealth by default", "description": "chrome-use — drive your real, logged-in Chrome from any AI agent, stealth by default",
"type": "module", "type": "module",
"packageManager": "pnpm@11.1.3", "packageManager": "pnpm@11.1.3",