session_eval
Evaluate a JavaScript expression on an open session's current page and return the JSON result, or a structured error when the expression throws.
Instructions
Evaluate a JavaScript expression on the session's current page.
Requires a session opened with profile_start first. A page-JS error is data to read, not a tool failure: the daemon returns {"ok": false, "error", "error_type"} instead of raising when the expression throws.
Args: name: identity name, exactly as profiles_list reports it. expr: the JavaScript expression to evaluate in the page, e.g. "document.title" or "document.querySelectorAll('a').length".
Returns the {ok, result} envelope: {"ok": true, "result": } on
success. result is whatever the expression evaluates to as JSON —
string, number, boolean, object, array, or null — not necessarily a
string; do not assume its type. Fails with a readable message (raises,
rather than the {ok: false} envelope above) if the session is not open
(409 — call profile_start first) or the identity does not exist (404).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expr | Yes | ||
| name | Yes |