browseract

package
v0.16.397 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	PollAction = iota
	PollNothing
	PollTooMany
)

Poll results.

View Source
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"
	ToolNavigate = "browser_navigate"
	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 NewHub

func NewHub() *Hub

NewHub is a hub with the default durations.

func (*Hub) Answer

func (h *Hub) Answer(chatID, id, state, text string) bool

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

func (h *Hub) Dispatch(ctx context.Context, chatID string, a Action) Outcome

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

func (h *Hub) Poll(ctx context.Context, chatID string) (Action, int)

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

type Outcome struct {
	Kind   string
	Failed bool
	Text   string
}

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.

type Tools

type Tools struct {
	Hub  *Hub
	Chat string
	Why  string
}

Tools are the browser tools for one calling agent. Chat is its conversation ("" when the runtime could not tell, Why says why).

func (Tools) Call

func (t Tools) Call(ctx context.Context, name string, args *jsvalue.Object) *jsvalue.Object

func (Tools) Has

func (Tools) Has(name string) bool

func (Tools) Instructions

func (Tools) Instructions() string

func (Tools) Tools

func (Tools) Tools() []any

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL