browser

package
v0.182.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package browser is the browser-use capability: Playwright-driven (or extension-bridged) page automation exposed to the agent as agentdomain.Tool implementations. Playwright is imported only by this package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTools

func NewTools(cfg *config.Config, driver browserdomain.BrowserDriver) map[string]agentdomain.Tool

NewTools builds the browser tool set against one shared driver and rate limiter. The caller (the container) owns the driver's lifecycle.

Types

type BrowserClickTool

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

BrowserClickTool clicks an element in the shared browser session

func NewBrowserClickTool

func NewBrowserClickTool(cfg *config.Config, rateLimiter rateLimiter, driver browserdomain.BrowserDriver) *BrowserClickTool

NewBrowserClickTool creates a new browser click tool

func (*BrowserClickTool) Definition

func (t *BrowserClickTool) Definition() sdk.ChatCompletionTool

Definition returns the tool definition for the LLM

func (*BrowserClickTool) Execute

Execute runs the browser click tool with given arguments

func (*BrowserClickTool) FormatForLLM

func (b *BrowserClickTool) FormatForLLM(result *agentdomain.ToolExecutionResult) string

FormatForLLM formats the result for LLM consumption

func (*BrowserClickTool) FormatPreview

func (b *BrowserClickTool) FormatPreview(result *agentdomain.ToolExecutionResult) string

FormatPreview returns a short preview of the result for UI display

func (*BrowserClickTool) FormatResult

func (b *BrowserClickTool) FormatResult(result *agentdomain.ToolExecutionResult, formatType agentdomain.FormatterType) string

FormatResult formats tool execution results for different contexts

func (*BrowserClickTool) IsEnabled

func (b *BrowserClickTool) IsEnabled() bool

IsEnabled returns whether this tool is enabled

func (*BrowserClickTool) ShouldAlwaysExpand

func (b *BrowserClickTool) ShouldAlwaysExpand() bool

ShouldAlwaysExpand determines if tool results should always be expanded in UI

func (*BrowserClickTool) ShouldCollapseArg

func (b *BrowserClickTool) ShouldCollapseArg(string) bool

ShouldCollapseArg determines if an argument should be collapsed in display

func (*BrowserClickTool) Validate

func (t *BrowserClickTool) Validate(args map[string]any) error

Validate checks if the tool arguments are valid: a selector, or an x/y pair.

type BrowserNavigateTool

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

BrowserNavigateTool opens a URL in the shared browser session

func NewBrowserNavigateTool

func NewBrowserNavigateTool(cfg *config.Config, rateLimiter rateLimiter, driver browserdomain.BrowserDriver) *BrowserNavigateTool

NewBrowserNavigateTool creates a new browser navigate tool

func (*BrowserNavigateTool) Definition

func (t *BrowserNavigateTool) Definition() sdk.ChatCompletionTool

Definition returns the tool definition for the LLM

func (*BrowserNavigateTool) Execute

Execute runs the browser navigate tool with given arguments

func (*BrowserNavigateTool) FormatForLLM

func (b *BrowserNavigateTool) FormatForLLM(result *agentdomain.ToolExecutionResult) string

FormatForLLM formats the result for LLM consumption

func (*BrowserNavigateTool) FormatPreview

func (b *BrowserNavigateTool) FormatPreview(result *agentdomain.ToolExecutionResult) string

FormatPreview returns a short preview of the result for UI display

func (*BrowserNavigateTool) FormatResult

func (b *BrowserNavigateTool) FormatResult(result *agentdomain.ToolExecutionResult, formatType agentdomain.FormatterType) string

FormatResult formats tool execution results for different contexts

func (*BrowserNavigateTool) IsEnabled

func (b *BrowserNavigateTool) IsEnabled() bool

IsEnabled returns whether this tool is enabled

func (*BrowserNavigateTool) ShouldAlwaysExpand

func (b *BrowserNavigateTool) ShouldAlwaysExpand() bool

ShouldAlwaysExpand determines if tool results should always be expanded in UI

func (*BrowserNavigateTool) ShouldCollapseArg

func (b *BrowserNavigateTool) ShouldCollapseArg(string) bool

ShouldCollapseArg determines if an argument should be collapsed in display

func (*BrowserNavigateTool) Validate

func (t *BrowserNavigateTool) Validate(args map[string]any) error

Validate checks if the tool arguments are valid

type BrowserReadTool

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

BrowserReadTool reads page content from the shared browser session

func NewBrowserReadTool

func NewBrowserReadTool(cfg *config.Config, rateLimiter rateLimiter, driver browserdomain.BrowserDriver) *BrowserReadTool

NewBrowserReadTool creates a new browser read tool

func (*BrowserReadTool) Definition

func (t *BrowserReadTool) Definition() sdk.ChatCompletionTool

Definition returns the tool definition for the LLM

func (*BrowserReadTool) Execute

Execute runs the browser read tool with given arguments

func (*BrowserReadTool) FormatForLLM

func (b *BrowserReadTool) FormatForLLM(result *agentdomain.ToolExecutionResult) string

FormatForLLM formats the result for LLM consumption

func (*BrowserReadTool) FormatPreview

func (b *BrowserReadTool) FormatPreview(result *agentdomain.ToolExecutionResult) string

FormatPreview returns a short preview of the result for UI display

func (*BrowserReadTool) FormatResult

func (b *BrowserReadTool) FormatResult(result *agentdomain.ToolExecutionResult, formatType agentdomain.FormatterType) string

FormatResult formats tool execution results for different contexts

func (*BrowserReadTool) IsEnabled

func (b *BrowserReadTool) IsEnabled() bool

IsEnabled returns whether this tool is enabled

func (*BrowserReadTool) ShouldAlwaysExpand

func (b *BrowserReadTool) ShouldAlwaysExpand() bool

ShouldAlwaysExpand determines if tool results should always be expanded in UI

func (*BrowserReadTool) ShouldCollapseArg

func (b *BrowserReadTool) ShouldCollapseArg(string) bool

ShouldCollapseArg determines if an argument should be collapsed in display

func (*BrowserReadTool) Validate

func (t *BrowserReadTool) Validate(args map[string]any) error

Validate checks if the tool arguments are valid

type BrowserScreenshotTool

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

BrowserScreenshotTool captures the current browser page as an image and attaches it to the conversation (vision models see it inline; others get a file path for ImageDecode).

func NewBrowserScreenshotTool

func NewBrowserScreenshotTool(cfg *config.Config, rateLimiter rateLimiter, driver browserdomain.BrowserDriver) *BrowserScreenshotTool

NewBrowserScreenshotTool creates a new browser screenshot tool

func (*BrowserScreenshotTool) Definition

Definition returns the tool definition for the LLM

func (*BrowserScreenshotTool) Execute

Execute captures the screenshot and returns it as an attached image

func (*BrowserScreenshotTool) FormatForLLM

func (b *BrowserScreenshotTool) FormatForLLM(result *agentdomain.ToolExecutionResult) string

FormatForLLM formats the result for LLM consumption

func (*BrowserScreenshotTool) FormatPreview

func (b *BrowserScreenshotTool) FormatPreview(result *agentdomain.ToolExecutionResult) string

FormatPreview returns a short preview of the result for UI display

func (*BrowserScreenshotTool) FormatResult

func (b *BrowserScreenshotTool) FormatResult(result *agentdomain.ToolExecutionResult, formatType agentdomain.FormatterType) string

FormatResult formats tool execution results for different contexts

func (*BrowserScreenshotTool) IsEnabled

func (b *BrowserScreenshotTool) IsEnabled() bool

IsEnabled returns whether this tool is enabled

func (*BrowserScreenshotTool) ShouldAlwaysExpand

func (b *BrowserScreenshotTool) ShouldAlwaysExpand() bool

ShouldAlwaysExpand determines if tool results should always be expanded in UI

func (*BrowserScreenshotTool) ShouldCollapseArg

func (b *BrowserScreenshotTool) ShouldCollapseArg(string) bool

ShouldCollapseArg determines if an argument should be collapsed in display

func (*BrowserScreenshotTool) Validate

func (t *BrowserScreenshotTool) Validate(map[string]any) error

Validate checks if the tool arguments are valid

type BrowserTabsTool

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

BrowserTabsTool lists the browser's open tabs and marks the active one, so the agent knows what the user is currently looking at.

func NewBrowserTabsTool

func NewBrowserTabsTool(cfg *config.Config, rateLimiter rateLimiter, driver browserdomain.BrowserDriver) *BrowserTabsTool

NewBrowserTabsTool creates a new browser tabs tool

func (*BrowserTabsTool) Definition

func (t *BrowserTabsTool) Definition() sdk.ChatCompletionTool

Definition returns the tool definition for the LLM

func (*BrowserTabsTool) Execute

Execute lists the open tabs

func (*BrowserTabsTool) FormatForLLM

func (t *BrowserTabsTool) FormatForLLM(result *agentdomain.ToolExecutionResult) string

FormatForLLM formats the tab list for LLM consumption

func (*BrowserTabsTool) FormatPreview

func (t *BrowserTabsTool) FormatPreview(result *agentdomain.ToolExecutionResult) string

FormatPreview returns a short preview of the result for UI display

func (*BrowserTabsTool) FormatResult

func (t *BrowserTabsTool) FormatResult(result *agentdomain.ToolExecutionResult, formatType agentdomain.FormatterType) string

FormatResult formats tool execution results for different contexts

func (*BrowserTabsTool) IsEnabled

func (b *BrowserTabsTool) IsEnabled() bool

IsEnabled returns whether this tool is enabled

func (*BrowserTabsTool) ShouldAlwaysExpand

func (b *BrowserTabsTool) ShouldAlwaysExpand() bool

ShouldAlwaysExpand determines if tool results should always be expanded in UI

func (*BrowserTabsTool) ShouldCollapseArg

func (b *BrowserTabsTool) ShouldCollapseArg(string) bool

ShouldCollapseArg determines if an argument should be collapsed in display

func (*BrowserTabsTool) Validate

func (t *BrowserTabsTool) Validate(map[string]any) error

Validate checks if the tool arguments are valid

type BrowserTypeTool

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

BrowserTypeTool types text into an element in the shared browser session

func NewBrowserTypeTool

func NewBrowserTypeTool(cfg *config.Config, rateLimiter rateLimiter, driver browserdomain.BrowserDriver) *BrowserTypeTool

NewBrowserTypeTool creates a new browser type tool

func (*BrowserTypeTool) Definition

func (t *BrowserTypeTool) Definition() sdk.ChatCompletionTool

Definition returns the tool definition for the LLM

func (*BrowserTypeTool) Execute

Execute runs the browser type tool with given arguments

func (*BrowserTypeTool) FormatForLLM

func (b *BrowserTypeTool) FormatForLLM(result *agentdomain.ToolExecutionResult) string

FormatForLLM formats the result for LLM consumption

func (*BrowserTypeTool) FormatPreview

func (b *BrowserTypeTool) FormatPreview(result *agentdomain.ToolExecutionResult) string

FormatPreview returns a short preview of the result for UI display

func (*BrowserTypeTool) FormatResult

func (b *BrowserTypeTool) FormatResult(result *agentdomain.ToolExecutionResult, formatType agentdomain.FormatterType) string

FormatResult formats tool execution results for different contexts

func (*BrowserTypeTool) IsEnabled

func (b *BrowserTypeTool) IsEnabled() bool

IsEnabled returns whether this tool is enabled

func (*BrowserTypeTool) ShouldAlwaysExpand

func (b *BrowserTypeTool) ShouldAlwaysExpand() bool

ShouldAlwaysExpand determines if tool results should always be expanded in UI

func (*BrowserTypeTool) ShouldCollapseArg

func (b *BrowserTypeTool) ShouldCollapseArg(string) bool

ShouldCollapseArg determines if an argument should be collapsed in display

func (*BrowserTypeTool) Validate

func (t *BrowserTypeTool) Validate(args map[string]any) error

Validate checks if the tool arguments are valid

Directories

Path Synopsis
Package domain holds the browser-use bounded context's contracts: the driver interface the tools consume and the wire/result types it produces.
Package domain holds the browser-use bounded context's contracts: the driver interface the tools consume and the wire/result types it produces.

Jump to

Keyboard shortcuts

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