Documentation Index
Fetch the complete documentation index at: https://mintlify.com/l-xiaoshen/handstage/llms.txt
Use this file to discover all available pages before exploring further.
HandstagesAgentToolHandlers is the interface you implement to connect the tool definitions in handstagesAgentTools to an actual running browser. Each method in the interface receives a typed input object (inferred from the tool’s Zod schema) and returns a typed output object. You pass your implementation’s methods as the execute function on each tool when setting up the Vercel AI SDK.
Supporting types
HandstagesAgentContext
HandstagesAgentContext represents the browser context that your handler implementation typically holds onto. It maps directly to the context object you get from V3.connectLocal().
| Method | Description |
|---|---|
pages() | Returns all currently open Page instances in the context. |
activePage() | Returns the foreground Page, or undefined if none is active. |
setActivePage(page) | Brings the given Page to the foreground. |
newPage(url?) | Opens a new Page, optionally navigating to url immediately. |
HandstagesAgent namespace
The HandstagesAgent namespace re-exports typed input and output types for every tool, inferred directly from the Zod schemas in handstagesAgentTools. Use these types to annotate your handler methods without manually writing interface types.
| Type | Description |
|---|---|
HandstagesAgent.ToolName | Union of all 17 tool name strings. |
HandstagesAgent.PagesInput | Input for pages — {} |
HandstagesAgent.PagesOutput | Output for pages — { pages: PageEntry[] } |
HandstagesAgent.PageEntry | Single entry in PagesOutput.pages |
HandstagesAgent.NewPageInput | Input for newPage — { url?: string } |
HandstagesAgent.NewPageOutput | Output for newPage — { pageId: string } |
HandstagesAgent.SetActivePageInput | Input for setActivePage — { pageId: string } |
HandstagesAgent.SetActivePageOutput | Output for setActivePage — { ok: true } | { ok: false; error: string } |
HandstagesAgent.GotoInput | Input for goto |
HandstagesAgent.GotoOutput | Output for goto |
HandstagesAgent.ReloadInput | Input for reload |
HandstagesAgent.ReloadOutput | Output for reload |
HandstagesAgent.GoBackInput | Input for goBack |
HandstagesAgent.GoBackOutput | Output for goBack |
HandstagesAgent.GoForwardInput | Input for goForward |
HandstagesAgent.GoForwardOutput | Output for goForward |
HandstagesAgent.SnapshotInput | Input for snapshot |
HandstagesAgent.SnapshotOutput | Output for snapshot |
HandstagesAgent.PageInfoInput | Input for pageInfo |
HandstagesAgent.PageInfoOutput | Output for pageInfo |
HandstagesAgent.ClickInput | Input for click |
HandstagesAgent.ClickOutput | Output for click |
HandstagesAgent.HoverInput | Input for hover |
HandstagesAgent.HoverOutput | Output for hover |
HandstagesAgent.ScrollInput | Input for scroll |
HandstagesAgent.ScrollOutput | Output for scroll |
HandstagesAgent.TypeInput | Input for type |
HandstagesAgent.TypeOutput | Output for type |
HandstagesAgent.ClickOnInput | Input for click_on |
HandstagesAgent.ClickOnOutput | Output for click_on |
HandstagesAgent.FillOnInput | Input for fill_on |
HandstagesAgent.FillOnOutput | Output for fill_on |
HandstagesAgent.TypeOnInput | Input for type_on |
HandstagesAgent.TypeOnOutput | Output for type_on |
HandstagesAgent.HoverOnInput | Input for hover_on |
HandstagesAgent.HoverOnOutput | Output for hover_on |
HandstagesAgent.OkResult | { ok: true } |
HandstagesAgent.ErrResult | { ok: false; error: string } |
HandstagesAgentToolHandlers interface
Each method in HandstagesAgentToolHandlers corresponds to one of the 17 tools in handstagesAgentTools. Your implementation is responsible for translating tool inputs into Handstage browser operations and returning the correct output shape.
pages(input)
pages(input)
newPage(input)
newPage(input)
setActivePage(input)
setActivePage(input)
goto(input)
goto(input)
Navigates a tab to a URL.SignatureInputOutput
Target tab ID.
Destination URL.
Lifecycle event to await.
Navigation timeout in milliseconds.
true on success; false on failure.Final URL after navigation. Only present when
ok is true.Error message when
ok is false.reload(input)
reload(input)
Reloads the current document in a tab.SignatureInputOutput
Target tab ID.
Lifecycle event to await.
Reload timeout in milliseconds.
Pass
true to bypass the browser cache.true on success; false on failure.URL after reload. Only present when
ok is true.Error message when
ok is false.goBack(input)
goBack(input)
Goes back one step in a tab’s session history.SignatureInputOutput
Target tab ID.
Lifecycle event to await after navigation.
Timeout in milliseconds.
true on success; false on failure.Whether the tab actually navigated back. Only present when
ok is true.Current URL after the operation. Only present when
ok is true.Error message when
ok is false.goForward(input)
goForward(input)
Goes forward one step in a tab’s session history.SignatureInputOutput
Target tab ID.
Lifecycle event to await after navigation.
Timeout in milliseconds.
true on success; false on failure.Whether the tab actually navigated forward. Only present when
ok is true.Current URL after the operation. Only present when
ok is true.Error message when
ok is false.snapshot(input)
snapshot(input)
Captures the accessibility tree for a tab.SignatureInputOutput
Target tab ID.
Whether to include nodes from embedded iframes.
true on success; false on failure.Accessibility tree as multiline text. Only present when
ok is true.Maps encoded node IDs to XPath selectors. Only present when
ok is true.Maps encoded node IDs to link
href values. Only present when ok is true.Error message when
ok is false.pageInfo(input)
pageInfo(input)
Returns the current URL and document title for a tab.SignatureInputOutput
Target tab ID.
true on success; false on failure.Current URL. Only present when
ok is true.Document title. Only present when
ok is true.Error message when
ok is false.click(input)
click(input)
Dispatches a mouse click at viewport coordinates.SignatureInputOutput
Target tab ID.
Horizontal coordinate in CSS pixels.
Vertical coordinate in CSS pixels.
Mouse button. Defaults to
"left".Number of clicks. Positive integer.
true on success; false on failure.XPath of the element at the clicked point, if available. Only present when
ok is true.Error message when
ok is false.hover(input)
hover(input)
Moves the pointer to viewport coordinates.SignatureInputOutput
Target tab ID.
Horizontal coordinate in CSS pixels.
Vertical coordinate in CSS pixels.
true on success; false on failure.XPath of the element at the pointer position. Only present when
ok is true.Error message when
ok is false.scroll(input)
scroll(input)
Dispatches a mouse wheel event at viewport coordinates.SignatureInputOutput
Target tab ID.
Horizontal coordinate of the wheel event in CSS pixels.
Vertical coordinate of the wheel event in CSS pixels.
Horizontal scroll delta in pixels.
Vertical scroll delta in pixels.
true on success; false on failure.XPath of the element at the scroll position. Only present when
ok is true.Error message when
ok is false.type(input)
type(input)
Types text at the currently focused element using key events.SignatureInputOutput
Target tab ID.
Text to type.
Milliseconds between keystrokes. Non-negative.
Simulate human-like typing with occasional errors and corrections.
true on success; false on failure.Error message when
ok is false.click_on(input)
click_on(input)
fill_on(input)
fill_on(input)
Clears and fills an input element matched by a CSS or XPath selector.SignatureInputOutput
Target tab ID.
CSS selector or XPath expression targeting the input element.
New value to set.
true on success; false on failure.Error message when
ok is false.type_on(input)
type_on(input)
Focuses an element by selector, then types text into it using key events.SignatureInputOutput
Target tab ID.
CSS selector or XPath expression targeting the element.
Text to type.
Milliseconds between keystrokes. Non-negative.
true on success; false on failure.Error message when
ok is false.hover_on(input)
hover_on(input)
Moves the pointer to the first element matching a CSS or XPath selector.SignatureInputOutput
Target tab ID.
CSS selector or XPath expression targeting the element.
true on success; false on failure.Error message when
ok is false.Example implementation
Below is a minimal but complete implementation ofHandstagesAgentToolHandlers. It holds a reference to a HandstagesAgentContext and delegates each method to the underlying Handstage browser APIs.
Complete browser agent example
The following example shows how to wire everything together: create a Handstage browser, implement the handlers, attach execution to each tool, and run a browser automation task with the Vercel AI SDK.The
execute functions are the only thing that separates handstagesAgentTools (schema only) from a fully runnable tool set. Keep your handler class separate from the AI SDK wiring so you can test each method in isolation.