mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
The tool put ~120 actions in a Literal enum and ~60 parameters in its
schema, all of it in every agent's context, and most of it Playwright
locator builders that returned a count. Three hand-kept lists (the enum,
extension_actions, _zap_method_for) disagreed: snapshot, wait and
select_option routed to the extension under names it did not answer.
ACTIONS is now the one table: each action once, its topic, its usage
line, and the extension method that serves it. The schema carries the
core loop (navigate, snapshot, click, fill, type, press, read,
screenshot, evaluate, wait, tabs, help) with an open `action` string;
help prints the rest by topic, and their parameters travel in `args`.
snapshot, click-by-ref and friends go to the extension's page engine
(hanzo.snapshot / hanzo.act / hanzo.read / hanzo.wait / hanzo.navigate,
screenshot annotate=true to hanzo.annotate). A tree or a page answers as
text; a refusal ("Stale ref @e4 … run snapshot again", "covered by
<div#consent>") is the error, not a success wrapping "ERR:", and is
never retried on Playwright, which has no refs to act on.
Aliases and no-ops are gone: select_option (select), get_inner_text and
get_value (get_text), clear (fill), content (get_html), new_page
(new_tab), press_key, mouse_wheel (scroll), list_browsers and
list_mcp_instances (browsers), use_browser, set_default_browser,
claim/release_browser, the locator/get_by_*/first/last/nth/filter/all
builders, is_hidden, frame, main_frame, on and off.
Claude-Session: https://claude.ai/code/session_01Dc8DXc3fEQCRHUa6XWK4Ku
1.4 KiB
1.4 KiB
hanzo-tools-browser
Browser tools for Hanzo MCP: browser drives the user's own browser through
the Hanzo extension (headless Playwright when none is connected), playwright
is the same tool pinned to Playwright, and cdp sends a raw DevTools method.
Installation
pip install hanzo-tools-browser
pip install 'hanzo-tools-browser[playwright]' && playwright install chromium # headless fallback
The loop
browser(action="navigate", url="https://example.com")
browser(action="snapshot", interactive=True) # - button "Sign in" [ref=e2]
browser(action="click", selector="@e2")
browser(action="fill", selector="@e3", text="[email protected]")
browser(action="press", key="Enter")
browser(action="read", outline=True) # the page as markdown
browser(action="screenshot", annotate=True) # labels [N] = @eN, with a legend
selector takes a ref from the last snapshot or a CSS selector. A stale ref,
or a click on an element covered by a banner or modal, is refused with what to
do next.
Progressive surface
The schema carries the core actions: navigate, snapshot, click, fill, type,
press, read, screenshot, evaluate, wait, tabs, help. browser(action="help")
lists the rest by topic, and their parameters go in args:
browser(action="select", selector="@e4", args={"value": "Weekly"})
License
MIT