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:
leeguooooo
2026-06-11 22:48:31 +09:00
parent 36c593631c
commit fa47a0b8e5
4 changed files with 49 additions and 2 deletions
+13 -1
View File
@@ -832,7 +832,19 @@ pub fn send_command(mut cmd: Value, session: &str) -> Result<Response, String> {
obj.insert("_clickMode".to_string(), Value::String(m));
}
if let Ok(h) = std::env::var("AGENT_BROWSER_HUMANIZE") {
obj.insert("_humanize".to_string(), Value::String(h));
// Only forward a recognized level; warn once (like the --humanize flag
// does) when the env var is set to garbage, instead of silently
// ignoring it.
if crate::native::humanize::HumanizeLevel::parse(&h).is_some() {
obj.insert("_humanize".to_string(), Value::String(h));
} else {
static WARNED: std::sync::Once = std::sync::Once::new();
WARNED.call_once(|| {
eprintln!(
"warning: AGENT_BROWSER_HUMANIZE must be off|fast|human, got {h:?} (ignored)"
);
});
}
}
}