Documentation
¶
Overview ¶
Package browseract lets the coding agent act on the page in the browser tab of the person's right pane. The agent's tool call becomes an action; the person's page takes it with a long poll, runs it in the page's frame, asks the person where the site is new, and posts the outcome, which goes back to the agent that waits.
Index ¶
Constants ¶
const ( PollAction = iota PollNothing PollTooMany )
Poll results.
const ( ToolSnapshot = "browser_snapshot" ToolRead = "browser_read" ToolClick = "browser_click" ToolType = "browser_type" ToolPress = "browser_press" ToolHover = "browser_hover" ToolSelect = "browser_select" ToolScroll = "browser_scroll" ToolWait = "browser_wait" ToolBack = "browser_back" // The site's own tools (WebMCP, navigator.modelContext), where the page offers them. ToolSiteTools = "browser_site_tools" ToolCallSiteTool = "browser_call_site_tool" )
The MCP tools of this package, and the op of the action each one sends.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct {
ID string `json:"id"`
Op string `json:"op"`
Ref string `json:"ref"`
Element string `json:"element"`
Text string `json:"text"`
Key string `json:"key"`
Value string `json:"value"`
URL string `json:"url"`
DY int `json:"dy"`
MS int `json:"ms"`
Submit bool `json:"submit"`
// Event is what a wait is for on a video or audio of the page: ended, playing or paused.
Event string `json:"event"`
// Tool and Input are a site tool's name and its arguments as JSON text (op "call").
Tool string `json:"tool"`
Input string `json:"input"`
}
Action is what the agent asks of the page. All fields are always sent; the unused ones are zero.
type Hub ¶
type Hub struct {
Now func() time.Time
// Hold, Present, Timeout, AskTimeout and AskStale are the durations above.
Hold, Present, Timeout, AskTimeout, AskStale time.Duration
// contains filtered or unexported fields
}
Hub holds each chat's page presence and its one action in flight.
func (*Hub) Answer ¶
Answer settles the chat's action: "done" and "failed" end it with text, "asking" says the page asks the person about the site in text (repeated while the question is open). False for an id that is not the chat's action in flight.
func (*Hub) Dispatch ¶
Dispatch gives the action to the chat's page and waits for its outcome. While the page asks the person about the site, the call ends with «asking» before the bridge's cut and the question stays open: the next call waits for the person's answer, then sends its own action.
func (*Hub) Poll ¶
Poll holds the page's request until an action comes for the chat, Hold passes or ctx ends. It marks the page present for the whole time and for Present after.
func (*Hub) ServeHTTP ¶
func (h *Hub) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP is the page's side, /api/v2/pane-act:
GET ?conversation=<chat> a long poll: 200 with one action, 204 when none came within Hold, 429 past 4 open polls
POST {conversation, id, state: done|failed|asking, text} the outcome of an action: 204, 404 for an id not in flight
type Outcome ¶
Outcome is how an action ended: answered (Failed and Text tell how), asking (Text is the site the person is asked about, "" when the page did not say), no-ui, timeout, busy or rate-limited.