--navigator-script
- CLI
- --navigator-script
- REST
- navigator_script
Gives the navigator a script it runs on the current page with RUN_SCRIPT, such as an accessibility audit or extracting a table as JSON. The title is free text that tells the navigator what the script returns. Repeatable, up to 20.
| Source | Where |
|---|---|
| A JavaScript file | Command line |
An http(s) URL | Command line and server |
data:text/ or data:text/ | Command line and server |
The source runs in the page as the body of an async function, and what it returns is the result: a promise is awaited and the value is shown to the navigator as JSON for that step. A script that throws, returns nothing or returns a value that cannot be serialized as JSON is reported to the navigator as such. Sources are loaded when the session starts, capped at 4 MiB each with a 30-second fetch timeout, and one that fails to load is skipped with a warning. Results are truncated at 60,000 characters, and the navigator runs up to 4 scripts per step. In server mode, pass http(s) URLs or data: URIs per request in navigator_script as strings or {"title", "source"} objects; the CLI flag is rejected at server startup.
Example
axe-audit.js runs the axe-core accessibility rules and returns the violations it finds.
zshot -t goal \
--navigator-type "anthropic://YOUR_API_KEY@" \
--navigator-script "axe accessibility audit, JSON violations for this page=https://zshot-cli.com/scripts/axe-audit.js" \
--navigate "Report the accessibility violations on this page" \
https://zshot-cli.com/example_assets/zemu/{
"url": "https://zshot-cli.com/example_assets/zemu/",
"output_type": "goal",
"navigate": "Report the accessibility violations on this page",
"navigator_type": ["anthropic://YOUR_API_KEY@"],
"navigator_script": [
{
"title": "axe accessibility audit, JSON violations for this page",
"source": "https://zshot-cli.com/scripts/axe-audit.js"
}
]
}curl -X POST http://127.0.0.1:3000/ \
-H "Content-Type: application/json" \
-d '{"url":"https://zshot-cli.com/example_assets/zemu/","output_type":"goal","navigate":"Report the accessibility violations on this page","navigator_type":["anthropic://YOUR_API_KEY@"],"navigator_script":[{"title":"axe accessibility audit, JSON violations for this page","source":"https://zshot-cli.com/scripts/axe-audit.js"}]}'