Help us shape the future of Go! Take the 2026 Go Developer Survey

browser

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package browser defines session-bound browser actions without a driver dependency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tool

func Tool(session Session, maxBytes int, options ...tool.Option) (tool.Tool, error)

Tool binds a model to one application-owned session. Browser interaction has side effects, so it is neither ReadOnly nor Concurrent. Callers can retain normal Agent approval policy with the supplied tool options.

Types

type Action

type Action struct {
	Operation Operation `json:"operation" jsonschema:"enum=navigate,enum=read,enum=click,enum=fill,enum=screenshot,enum=download"`
	URL       string    `json:"url,omitempty"`
	Selector  string    `json:"selector,omitempty"`
	Value     string    `json:"value,omitempty"`
}

Action cannot select credentials, profiles, filesystem paths or tenant identity.

func (Action) Validate

func (a Action) Validate() error

Validate rejects unsupported or ambiguous actions before execution.

type Browser

type Browser interface {
	NewSession(ctx context.Context) (Session, error)
}

Browser creates an isolated session whose owner context lives until Close.

type Control

type Control struct {
	Selector string `json:"selector"`
	Tag      string `json:"tag"`
	Text     string `json:"text"`
	Type     string `json:"type,omitempty"`
}

Control describes an interactive element without exposing input values.

type Operation

type Operation string

Operation identifies one explicit browser action.

const (
	Navigate   Operation = "navigate"
	Read       Operation = "read"
	Click      Operation = "click"
	Fill       Operation = "fill"
	Screenshot Operation = "screenshot"
	Download   Operation = "download"
)

Supported browser operations.

type Result

type Result struct {
	Document  *web.Document `json:"document,omitempty"`
	Controls  []Control     `json:"controls,omitempty"`
	Name      string        `json:"name,omitempty"`
	MediaType string        `json:"media_type,omitempty"`
	Data      []byte        `json:"data,omitempty"`
}

Result preserves readable content or a bounded binary result. Data is never a local path; applications can persist it using their existing artifact.Store.

type Session

type Session interface {
	Do(ctx context.Context, action Action) (*Result, error)
	Close() error
}

Session owns an isolated browsing context. Do serializes actions. Cancelling an action may invalidate the session; callers then create a fresh one. The session is bound by the application, never selected by model arguments.

Jump to

Keyboard shortcuts

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