TheDocumentation 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.
@handstage/agent package provides a ready-made set of browser-control tools designed for LLM function-calling. You supply the tool definitions to your AI SDK, implement the handlers that talk to a real browser, and the model decides when and how to call each tool. This pattern keeps the AI layer and the browser layer loosely coupled — you can swap out either side independently.
Installation
Key exports
| Export | Description |
|---|---|
handstagesAgentTools | Pre-built ToolSet compatible with the Vercel AI SDK. Pass directly to generateText or streamText. |
createHandstagesAgentToolDefinitions() | Function that returns the same ToolSet. Useful when you need to call it lazily. |
HandstagesAgentToolHandlers | TypeScript interface listing one method per tool. Implement this to connect tool calls to a real browser. |
HandstagesAgentContext | Interface describing the browser context your handlers operate on (pages, activePage, setActivePage, newPage). |
HandstagesAgent | Namespace of inferred input/output types for every tool (e.g. HandstagesAgent.GotoInput). |
Available tools
pages — list open tabs
pages — list open tabs
pageId, url, title, and whether it is the active (foreground) tab.Input: noneOutput: { pages: Array<{ pageId, url, title, activated }> }newPage — open a new tab
newPage — open a new tab
pageId. You can optionally pass a starting URL.Input: { url?: string } — defaults to "about:blank"Output: { pageId: string }setActivePage — focus a tab
setActivePage — focus a tab
pageId. Use after newPage or when the model needs to switch context.Input: { pageId: string }Output: { ok: true } | { ok: false; error: string }goto — navigate to a URL
goto — navigate to a URL
reload — reload the current document
reload — reload the current document
{ pageId, waitUntil?, timeoutMs?, ignoreCache? }Output: { ok: true; url: string } | { ok: false; error: string }goBack — navigate back in history
goBack — navigate back in history
goForward — navigate forward in history
goForward — navigate forward in history
snapshot — accessibility tree
snapshot — accessibility tree
xpathMap (node id → XPath) and a urlMap (node id → href) for use with selector-based tools.Input: { pageId, includeIframes? }Output: { ok: true; tree: string; xpathMap: Record<string, string>; urlMap: Record<string, string> } | { ok: false; error: string }pageInfo — current URL and title
pageInfo — current URL and title
{ pageId }Output: { ok: true; url: string; title: string } | { ok: false; error: string }click — click at viewport coordinates
click — click at viewport coordinates
{ pageId, x, y, button?, clickCount? }button accepts "left", "right", or "middle".Output: { ok: true; xpathAtPoint?: string } | { ok: false; error: string }hover — move the pointer
hover — move the pointer
{ pageId, x, y }Output: { ok: true; xpathAtPoint?: string } | { ok: false; error: string }scroll — dispatch a wheel event
scroll — dispatch a wheel event
deltaX and deltaY in pixels.Input: { pageId, x, y, deltaX, deltaY }Output: { ok: true; xpathAtPoint?: string } | { ok: false; error: string }type — type text at the current focus
type — type text at the current focus
click_on) before calling this.Input: { pageId, text, delay?, withMistakes? }Output: { ok: true } | { ok: false; error: string }click_on — click by selector
click_on — click by selector
{ pageId, select } where select is a CSS selector or XPath (e.g. //button[@id='submit']).Output: { ok: true } | { ok: false; error: string }fill_on — fill an input by selector
fill_on — fill an input by selector
{ pageId, select, value }Output: { ok: true } | { ok: false; error: string }type_on — type into an element by selector
type_on — type into an element by selector
{ pageId, select, text, delay? }Output: { ok: true } | { ok: false; error: string }hover_on — hover over an element by selector
hover_on — hover over an element by selector
{ pageId, select }Output: { ok: true } | { ok: false; error: string }Wiring up with the Vercel AI SDK
Implement HandstagesAgentToolHandlers
HandstagesAgentToolHandlers interface. Each method receives the tool input from the AI model and must return the typed output.Using the function form
createHandstagesAgentToolDefinitions() returns the same tool set as handstagesAgentTools. Use it when you need to call a function rather than reference a constant:
Type-safe tool inputs and outputs
TheHandstagesAgent namespace exports inferred input and output types for every tool. Use these when implementing handlers or when processing tool results in your own code:
HandstagesAgent.<ToolName>Input and HandstagesAgent.<ToolName>Output for every tool listed in the available tools section above.