Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion plugins/notte/skills/notte-browser/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,14 @@ notte page upload --session-id <session-id> "#file-input" --file report.pdf
**Run JavaScript in the page:**

- Escape single quotes if needed.
- Don't use logging - stdout is not captured.
- `console.log` output is discarded - only the returned value comes back.
- Use a single expression, or a function that returns a value.
- **The returned value is printed alone on stdout** (objects and arrays as JSON,
a JS `null` as `null`), with the status line on stderr - so it captures into a
shell variable and pipes without post-processing. Use `-o json` when you want
the whole execution result instead.
- A failing script exits non-zero and reports the actual JavaScript error, so
`set -e` and `||` fallbacks behave.

```bash
# Single expression
Expand All @@ -299,8 +305,18 @@ notte page eval-js --session-id <session-id> '
return els.length;
}
'

# Capture the value, or pipe it - the value is all stdout carries
title=$(notte page eval-js --session-id <session-id> 'document.title')

notte page eval-js --session-id <session-id> \
'JSON.stringify([...document.querySelectorAll("a")].map(a => a.href))' | jq length
```

Return `JSON.stringify(...)` whenever the answer is structured: it arrives as a
JSON document, so `jq` does the filtering instead of another round trip through
the page.

**Navigation:**
```bash
notte page goto --session-id <session-id> "https://example.com"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ async () => {
'
```

The evaluated value is all stdout carries, so pipe it straight into `jq` while
exploring - `... | jq '.count'` - and capture it with `$(...)` when a later
command needs it.

Inside a deployed Function the equivalent is `session.evaluate_js(code)`, which returns the evaluated string directly (objects and arrays as JSON) and raises with the actual JavaScript error on failure — so `json.loads(session.evaluate_js(code))` is the whole read.

If the endpoint returns the data reliably, that is your path. Note it and move to generation.
Expand Down
Loading