pilot_evaluate
Evaluate a JavaScript expression or function in the browser page context to read DOM, extract data, perform calculations, or call APIs. Supports async/await for promises.
Instructions
Execute a JavaScript expression or function in the browser page context and return the result. Use when the user wants to run custom JavaScript on the page, read or modify DOM elements, extract data, or perform calculations. Supports async/await — use "await" to wait for promises. Multi-line code with await is automatically wrapped in an async IIFE.
Parameters:
expression: JavaScript expression to evaluate (e.g., "document.title", "JSON.stringify(localStorage)", "await fetch('/api').then(r => r.json())"). Maximum 50 KB.
Returns: The expression result as a string, or pretty-printed JSON for objects/arrays.
Errors:
"Evaluation failed": The JavaScript threw an error. Fix the expression syntax or handle the error in the page context.
"Promise rejected": An awaited promise rejected. Check the API endpoint or async logic.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expression | Yes | JavaScript expression to evaluate (max 50 KB) |