browser

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package browser provides browser automation tools for omniagent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Headless bool
	UserData string
	Logger   *slog.Logger

	// EvaluateTimeout is the default timeout for JavaScript evaluation.
	// Zero means use the action timeout.
	EvaluateTimeout time.Duration

	// DialogCallback is called when a dialog is observed.
	DialogCallback func(Dialog)
}

Config configures the browser tool.

type Dialog added in v0.9.0

type Dialog struct {
	// Type is the dialog type: "alert", "confirm", "prompt", "beforeunload".
	Type string

	// Message is the dialog message text.
	Message string

	// DefaultValue is the default value for prompt dialogs.
	DefaultValue string

	// URL is the page URL where the dialog appeared.
	URL string

	// Timestamp is when the dialog was observed.
	Timestamp time.Time

	// Handled indicates if the dialog was automatically handled.
	Handled bool

	// Response is the response given (for confirm: "true"/"false", for prompt: input text).
	Response string
}

Dialog represents a browser dialog (alert, confirm, prompt).

type Tool

type Tool struct {
	// contains filtered or unexported fields
}

Tool provides browser automation capabilities.

func New

func New(config Config) (*Tool, error)

New creates a new browser tool.

func (*Tool) AcceptDialog added in v0.9.0

func (t *Tool) AcceptDialog(ctx context.Context, response string) error

AcceptDialog accepts a dialog with an optional response.

func (*Tool) ClearDialogs added in v0.9.0

func (t *Tool) ClearDialogs()

ClearDialogs clears the dialog history.

func (*Tool) Close

func (t *Tool) Close() error

Close closes the browser.

func (*Tool) Description

func (t *Tool) Description() string

Description returns the tool description.

func (*Tool) DismissDialogWithCancel added in v0.9.0

func (t *Tool) DismissDialogWithCancel(ctx context.Context) error

DismissDialogWithCancel dismisses a dialog by clicking cancel.

func (*Tool) Execute

func (t *Tool) Execute(ctx context.Context, args json.RawMessage) (string, error)

Execute runs the browser tool.

func (*Tool) GetObservedDialogs added in v0.9.0

func (t *Tool) GetObservedDialogs() []Dialog

GetObservedDialogs returns the list of observed dialogs.

func (*Tool) Name

func (t *Tool) Name() string

Name returns the tool name.

func (*Tool) Parameters

func (t *Tool) Parameters() map[string]interface{}

Parameters returns the JSON schema for tool parameters.

func (*Tool) SetDialogCallback added in v0.9.0

func (t *Tool) SetDialogCallback(callback func(Dialog))

SetDialogCallback sets a callback for dialog events.

Jump to

Keyboard shortcuts

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