feat: eval prints its origin URL, type --focused, AGENT_BROWSER_HUMANIZE bogus warn
- eval now prints `eval @ <url>` to stderr (stdout stays the raw value) so an agent can catch tab drift — e.g. a logged-in fetch that hit the wrong origin — before trusting the result. Mitigates the issue #2/#3 P0 safety concern. (eval already returned the origin; the default output just never surfaced it.) - `type --focused <text>`: type into the currently-focused element with no selector, for custom widgets that move focus to a hidden input (issue #2 P3). - AGENT_BROWSER_HUMANIZE set to an unrecognized value now warns once (like the --humanize flag) instead of being silently ignored (Hermes #3).
This commit is contained in:
@@ -358,6 +358,16 @@ pub fn print_response_with_opts(resp: &Response, action: Option<&str>, opts: &Ou
|
||||
}
|
||||
// Eval result
|
||||
if let Some(result) = data.get("result") {
|
||||
// Surface which page the eval actually ran on — to stderr, so it
|
||||
// never corrupts the parsed value on stdout. Lets an agent catch tab
|
||||
// drift (commands landing on the wrong tab) before trusting a result,
|
||||
// e.g. a logged-in `fetch` that hit the wrong origin. (In
|
||||
// content-boundaries mode the origin is already in the banner.)
|
||||
if !opts.content_boundaries {
|
||||
if let Some(o) = origin.filter(|o| !o.is_empty()) {
|
||||
eprintln!("eval @ {o}");
|
||||
}
|
||||
}
|
||||
let formatted = serde_json::to_string_pretty(result).unwrap_or_default();
|
||||
print_with_boundaries(&formatted, origin, opts);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user