import { Type } from "typebox";
import type { BrowserClient } from "../client";
import { type Result, err, ok } from "../util/result";
import { defineBrowserTool, type ToolErr, type ToolOk } from "../util/tool";
// ── Page-side functions ──────────────────────────────────────────────────────
// These run inside the page via Runtime.callFunctionOn with `this` bound to the
// resolved element. They are NOT string-interpolated with user data — the value
// is passed as a structured `arguments` entry, so safeJs is unnecessary here.
/**
* Universal field setter. Auto-detects the element type and applies the right
* strategy, then reads the resulting value back so the caller can confirm.
*
* The /