Documentation
¶
Overview ¶
Package browser performs computer-use actions in a browser context.
It speaks the Chrome DevTools Protocol over a WebSocket, which needs no driver binary, no cgo, and nothing on the machine except a Chromium that is already listening. A browser context is also the right default target: blast radius is bounded by what the browser can reach, and nothing here can touch an ambient desktop.
The surface it implements is nine methods wide and knows nothing about authority, confirmation, or auditing. Those live above it, which is what lets this file be only about making the browser do things.
Index ¶
- type Config
- type MarkedElement
- type Surface
- func (surface *Surface) Capture(ctx context.Context) ([]byte, error)
- func (surface *Surface) CaptureMarked(ctx context.Context) ([]byte, []MarkedElement, error)
- func (surface *Surface) Click(ctx context.Context, x, y int, button string) error
- func (surface *Surface) ClickElement(ctx context.Context, elementID string) error
- func (surface *Surface) Close() error
- func (surface *Surface) DoubleClick(ctx context.Context, x, y int) error
- func (surface *Surface) Drag(ctx context.Context, fromX, fromY, toX, toY int) error
- func (surface *Surface) Evaluate(ctx context.Context, expression string, destination any) error
- func (surface *Surface) Key(ctx context.Context, keys []string) error
- func (surface *Surface) Location(ctx context.Context) (string, error)
- func (surface *Surface) Move(ctx context.Context, x, y int) error
- func (surface *Surface) Name() string
- func (surface *Surface) Navigate(ctx context.Context, url string) error
- func (surface *Surface) Screenshot(ctx context.Context) error
- func (surface *Surface) Scroll(ctx context.Context, x, y, deltaX, deltaY int) error
- func (surface *Surface) Type(ctx context.Context, text string) error
- func (surface *Surface) Viewport(ctx context.Context) (width, height int, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// DevToolsURL is the browser's debugging endpoint, such as
// http://127.0.0.1:9222. A page target is discovered through it.
DevToolsURL string
// TargetURL connects directly to a known page WebSocket instead, which is
// what a deployment that manages its own tabs will have.
TargetURL string
// Timeout bounds one command.
Timeout time.Duration
// TypingDelay paces synthetic keystrokes. Zero types instantly, which is
// correct for a form and wrong for a page that debounces input.
TypingDelay time.Duration
}
Config configures the connection.
type MarkedElement ¶
type MarkedElement struct {
ID string `json:"id"`
Role string `json:"role,omitempty"`
Name string `json:"name,omitempty"`
X int `json:"x"`
Y int `json:"y"`
Width int `json:"width"`
Height int `json:"height"`
}
MarkedElement describes one interactive element in a set-of-mark frame. Bounds use the same CSS-pixel coordinate space as the video source.
type Surface ¶
type Surface struct {
// contains filtered or unexported fields
}
Surface drives one browser page.
func (*Surface) Capture ¶
Capture returns a screenshot, for a caller that is feeding the video stream rather than acting.
func (*Surface) CaptureMarked ¶
CaptureMarked labels visible interactive DOM elements and captures the resulting page. The labels are part of the pixels the model sees; the returned metadata exists for audit and scoring, never as a model shortcut.
Labels persist on their target elements across captures while the red marker bubbles themselves are removed immediately after the screenshot. That makes computer.click_element stable without changing the page a person would use.
func (*Surface) ClickElement ¶
ClickElement clicks the centre of an element carrying the mark shown in the most recent marked frame. It still dispatches ordinary pointer events: the DOM is used only to resolve the label into the pixel space the model saw.
func (*Surface) DoubleClick ¶
DoubleClick sends a two-click sequence.
func (*Surface) Evaluate ¶
Evaluate runs an operator expression and decodes its value.
Like Navigate, this is not a computer-use action. It exists for an environment owner to reset and score a task through a deliberately separate control plane. The model never receives this method or its result.
func (*Surface) Navigate ¶
Navigate points the page at a URL and waits for the load to finish.
It is not an action in the computer-use namespace and is deliberately not one. A model that could navigate by naming a URL would be reaching past the page it was shown - the whole grounding argument for this vocabulary is that an action lands somewhere the model actually looked at. So this is here for the operator setting up a run, and it is not offered to a session.
func (*Surface) Screenshot ¶
Screenshot captures the page.
The bytes are discarded here rather than returned, and deliberately: the result of an action is the next screen, and the screen arrives through the video stream. Carrying an image back through a function result would put the same picture on two paths.