feat: eval --file, tab-list URL truncation, skill doc fixes (issue #2/#3 + Hermes)
- `eval --file <path>`: read JS from a file, sent verbatim — avoids shell-mangling of non-ASCII identifiers/strings (Chinese), quotes, and large scripts (issue #3). - `tab list`: truncate multi-KB URLs (JWT/OTP login links) middle-out with a char count so the list stays readable (issue #3). - skill: fix the snapshot example to match real output (`- role "name" [ref=eN]`, not `@e1 [role]`); document that eval runs in the page MAIN world with persistent state (top-level `const` collides — use IIFE / window / unique names) and to prefer --file/--stdin/-b for non-ASCII or big JS.
This commit is contained in:
@@ -182,14 +182,17 @@ Snapshot output looks like:
|
||||
Page: Example - Log in
|
||||
URL: https://example.com/login
|
||||
|
||||
@e1 [heading] "Log in"
|
||||
@e2 [form]
|
||||
@e3 [input type="email"] placeholder="Email"
|
||||
@e4 [input type="password"] placeholder="Password"
|
||||
@e5 [button type="submit"] "Continue"
|
||||
@e6 [link] "Forgot password?"
|
||||
- heading "Log in" [level=1, ref=e1]
|
||||
- textbox "Email" [ref=e2]
|
||||
- textbox "Password" [ref=e3]
|
||||
- button "Continue" [ref=e4]
|
||||
- link "Forgot password?" [ref=e5]
|
||||
```
|
||||
|
||||
Each line is `- <role> "<accessible name>" [<attrs>, ref=eN]`, indented by nesting
|
||||
depth. You pass the ref to commands as `@eN` (e.g. `click @e4`). Refs are
|
||||
assigned fresh on every snapshot.
|
||||
|
||||
For unstructured reading (no refs needed):
|
||||
|
||||
```bash
|
||||
@@ -386,9 +389,16 @@ Array.from(rows).map(r => ({
|
||||
EOF
|
||||
```
|
||||
|
||||
Prefer `eval --stdin` (heredoc) or `eval -b <base64>` for any JS with
|
||||
quotes or special characters. Inline `agent-browser eval "..."` works
|
||||
only for simple expressions.
|
||||
Prefer `eval --stdin` (heredoc), `eval --file <path>`, or `eval -b <base64>`
|
||||
for any JS with quotes, **non-ASCII identifiers/strings (e.g. Chinese)**, or
|
||||
large scripts — inline `agent-browser eval "..."` is shell-mangled and works
|
||||
only for simple ASCII expressions.
|
||||
|
||||
**`eval` runs in the page's MAIN world and state persists across calls**, so a
|
||||
top-level `const x`/`let x`/`var x` in one call collides with the next
|
||||
(`SyntaxError: Identifier 'x' has already been declared`). Either use unique
|
||||
names, assign to `window.x`, or wrap the body in an IIFE
|
||||
(`(() => { const x = …; return x; })()`).
|
||||
|
||||
### Screenshot
|
||||
|
||||
|
||||
Reference in New Issue
Block a user