Add --stdin flag for eval command (#348)

Adds --stdin flag to read JavaScript from stdin, enabling heredoc usage
for multiline scripts without shell escaping issues.
This commit is contained in:
Chris Tate
2026-02-02 20:29:43 -06:00
committed by GitHub
parent f770593c66
commit 0dc36f2cff
5 changed files with 50 additions and 17 deletions
+9 -2
View File
@@ -189,14 +189,21 @@ agent-browser dialog dismiss # Dismiss dialog
```bash
agent-browser eval "document.title" # Simple expressions only
agent-browser eval -b "<base64>" # Any JavaScript (recommended)
agent-browser eval -b "<base64>" # Any JavaScript (base64 encoded)
agent-browser eval --stdin # Read script from stdin
```
Use `-b`/`--base64` for reliable execution. Shell escaping with nested quotes and special characters is error-prone.
Use `-b`/`--base64` or `--stdin` for reliable execution. Shell escaping with nested quotes and special characters is error-prone.
```bash
# Base64 encode your script, then:
agent-browser eval -b "ZG9jdW1lbnQucXVlcnlTZWxlY3RvcignW3NyYyo9Il9uZXh0Il0nKQ=="
# Or use stdin with heredoc for multiline scripts:
cat <<'EOF' | agent-browser eval --stdin
const links = document.querySelectorAll('a');
Array.from(links).map(a => a.href);
EOF
```
## State Management