Documentation
¶
Index ¶
- func CleanupSession(agentID string) error
- func ConnectCDP(parentCtx context.Context, session *BrowserSession) error
- func CreateSessionWithData(agentID string, initialURL string, proxyEnabled bool, proxyCountry string) (string, map[string]interface{}, error)
- func EnsureBrowserSession(operatorConfig *config.OperatorConfig) error
- func ExecuteCDPCommand(ctx context.Context, session *BrowserSession, cmdType string, ...) (map[string]interface{}, error)
- func ExecuteVirtualCommand(sessionID string, cmdType string, params map[string]interface{}) (map[string]interface{}, error)
- func ExecuteVirtualCommandWithContext(ctx context.Context, sessionID string, cmdType string, ...) (map[string]interface{}, error)
- func GetOrCreateSession(agentID string, initialURL string, proxyEnabled bool, proxyCountry string) (string, error)
- func GetPendingURL() string
- func GetStatus() map[string]interface{}
- func HandleComputerTool(input map[string]interface{}) (map[string]interface{}, error)
- func HandleComputerToolWithContext(ctx context.Context, input map[string]interface{}) (map[string]interface{}, error)
- func HandleHighQualityScreenshot(fullPage bool, quality int) (map[string]interface{}, error)
- func InitBrowserSession()
- func InitBrowserSessionOnEnable(operatorConfig *config.OperatorConfig)
- func SetPendingURL(url string)
- func SetSessionID(agentID, sessionID string)
- type BrowserEngineProvider
- func (p *BrowserEngineProvider) CreateSession(ctx context.Context, opts SessionOptions) (*BrowserSession, error)
- func (p *BrowserEngineProvider) DestroySession(ctx context.Context, sessionID string) error
- func (p *BrowserEngineProvider) ExecuteCommand(ctx context.Context, sessionID, cmdType string, params map[string]interface{}) (map[string]interface{}, error)
- func (p *BrowserEngineProvider) Name() string
- type BrowserProvider
- type BrowserSession
- type BrowserbaseProvider
- type CDPProvider
- type KeyDef
- type SessionOptions
- type SteelProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupSession ¶
CleanupSession cleans up a browser session
func ConnectCDP ¶ added in v1.39.0
func ConnectCDP(parentCtx context.Context, session *BrowserSession) error
ConnectCDP establishes a CDP WebSocket connection for a session. Called after a provider returns a ConnectURL.
func CreateSessionWithData ¶
func CreateSessionWithData(agentID string, initialURL string, proxyEnabled bool, proxyCountry string) (string, map[string]interface{}, error)
CreateSessionWithData creates a new session and returns both the session ID and full response data
func EnsureBrowserSession ¶
func EnsureBrowserSession(operatorConfig *config.OperatorConfig) error
EnsureBrowserSession ensures browser session is active (no-op, sessions are on-demand)
func ExecuteCDPCommand ¶ added in v1.39.0
func ExecuteCDPCommand(ctx context.Context, session *BrowserSession, cmdType string, params map[string]interface{}) (map[string]interface{}, error)
ExecuteCDPCommand runs a browser action via CDP WebSocket. Returns results in the same format as REST commands for transparent routing.
func ExecuteVirtualCommand ¶
func ExecuteVirtualCommand(sessionID string, cmdType string, params map[string]interface{}) (map[string]interface{}, error)
ExecuteVirtualCommand executes a command in a browser session (no cancellation)
func ExecuteVirtualCommandWithContext ¶ added in v1.34.0
func ExecuteVirtualCommandWithContext(ctx context.Context, sessionID string, cmdType string, params map[string]interface{}) (map[string]interface{}, error)
ExecuteVirtualCommandWithContext executes a command with cancellation support. Routes to CDP or REST depending on session state.
func GetOrCreateSession ¶
func GetOrCreateSession(agentID string, initialURL string, proxyEnabled bool, proxyCountry string) (string, error)
GetOrCreateSession gets existing session or creates a new one
func GetPendingURL ¶
func GetPendingURL() string
GetPendingURL retrieves the pending URL for the current agent
func GetStatus ¶ added in v1.42.0
func GetStatus() map[string]interface{}
GetStatus returns the current operator/browser provider status for the debug UI.
func HandleComputerTool ¶
HandleComputerTool handles Claude's computer tool requests (no cancellation)
func HandleComputerToolWithContext ¶ added in v1.34.0
func HandleComputerToolWithContext(ctx context.Context, input map[string]interface{}) (map[string]interface{}, error)
HandleComputerToolWithContext handles Claude's computer tool requests with cancellation support
func HandleHighQualityScreenshot ¶
HandleHighQualityScreenshot captures a high-quality screenshot with full-page support
func InitBrowserSession ¶
func InitBrowserSession()
InitBrowserSession initializes browser session if operator mode is enabled
func InitBrowserSessionOnEnable ¶
func InitBrowserSessionOnEnable(operatorConfig *config.OperatorConfig)
InitBrowserSessionOnEnable initializes browser session when operator mode is enabled via config
func SetPendingURL ¶
func SetPendingURL(url string)
SetPendingURL stores a URL to be used when creating the next browser session
func SetSessionID ¶
func SetSessionID(agentID, sessionID string)
SetSessionID injects an existing session ID into the cache for reuse
Types ¶
type BrowserEngineProvider ¶ added in v1.39.0
type BrowserEngineProvider struct {
BaseURL string // e.g., "https://api.browserengine.co"
APIKey string // X-API-Key header value
}
BrowserEngineProvider implements BrowserProvider for the BrowserEngine cloud service. Routes through the API with authentication, billing, and usage tracking.
func NewBrowserEngineProvider ¶ added in v1.39.0
func NewBrowserEngineProvider(baseURL, apiKey string) *BrowserEngineProvider
NewBrowserEngineProvider creates a new BrowserEngineProvider.
func (*BrowserEngineProvider) CreateSession ¶ added in v1.39.0
func (p *BrowserEngineProvider) CreateSession(ctx context.Context, opts SessionOptions) (*BrowserSession, error)
func (*BrowserEngineProvider) DestroySession ¶ added in v1.39.0
func (p *BrowserEngineProvider) DestroySession(ctx context.Context, sessionID string) error
func (*BrowserEngineProvider) ExecuteCommand ¶ added in v1.42.0
func (p *BrowserEngineProvider) ExecuteCommand(ctx context.Context, sessionID, cmdType string, params map[string]interface{}) (map[string]interface{}, error)
ExecuteCommand sends a command through the BrowserEngine API.
func (*BrowserEngineProvider) Name ¶ added in v1.39.0
func (p *BrowserEngineProvider) Name() string
type BrowserProvider ¶ added in v1.39.0
type BrowserProvider interface {
// Name returns the provider identifier ("browserengine", "browserbase", "steel", "cdp")
Name() string
// CreateSession creates a browser session and returns connection metadata.
// Sessions with a non-empty ConnectURL support direct CDP WebSocket control.
CreateSession(ctx context.Context, opts SessionOptions) (*BrowserSession, error)
// DestroySession terminates a browser session and cleans up resources.
DestroySession(ctx context.Context, sessionID string) error
}
BrowserProvider abstracts browser session lifecycle. All providers create sessions (possibly via REST) and return connection info. Providers that support CDP return a ConnectURL for direct WebSocket control.
func InitProvider ¶ added in v1.39.0
func InitProvider(operatorConfig *config.OperatorConfig) BrowserProvider
InitProvider initializes the browser provider based on config.
type BrowserSession ¶ added in v1.39.0
type BrowserSession struct {
ID string // Provider-assigned session ID
ConnectURL string // CDP WebSocket URL (empty for REST-only providers)
StreamURL string // Optional: live stream URL for viewing
ViewURL string // Optional: browser view URL
TargetID string // Optional: CDP target ID
Provider string // Provider name that created this session
Metadata map[string]interface{} // Extra provider-specific data
// contains filtered or unexported fields
}
BrowserSession holds the state of a connected browser session.
func (*BrowserSession) Close ¶ added in v1.39.0
func (s *BrowserSession) Close()
Close cleans up the CDP connection if active.
func (*BrowserSession) GetCDPContext ¶ added in v1.39.0
func (s *BrowserSession) GetCDPContext() context.Context
GetCDPContext returns the CDP context for command execution.
func (*BrowserSession) IsConnectedCDP ¶ added in v1.39.0
func (s *BrowserSession) IsConnectedCDP() bool
IsConnectedCDP returns true if this session has an active CDP WebSocket.
func (*BrowserSession) SetCDP ¶ added in v1.39.0
func (s *BrowserSession) SetCDP(ctx context.Context, cancel context.CancelFunc)
SetCDP stores the CDP connection state.
type BrowserbaseProvider ¶ added in v1.39.0
type BrowserbaseProvider struct {
APIKey string
ProjectID string
BaseURL string // Default: "https://api.browserbase.com"
}
BrowserbaseProvider implements BrowserProvider for Browserbase (browserbase.com). Sessions are created via REST API and controlled via CDP WebSocket.
func NewBrowserbaseProvider ¶ added in v1.39.0
func NewBrowserbaseProvider(apiKey, projectID string) *BrowserbaseProvider
NewBrowserbaseProvider creates a new BrowserbaseProvider.
func (*BrowserbaseProvider) CreateSession ¶ added in v1.39.0
func (p *BrowserbaseProvider) CreateSession(ctx context.Context, opts SessionOptions) (*BrowserSession, error)
func (*BrowserbaseProvider) DestroySession ¶ added in v1.39.0
func (p *BrowserbaseProvider) DestroySession(ctx context.Context, sessionID string) error
func (*BrowserbaseProvider) Name ¶ added in v1.39.0
func (p *BrowserbaseProvider) Name() string
type CDPProvider ¶ added in v1.42.0
type CDPProvider struct {
URL string // e.g., "ws://localhost:9222" or "http://localhost:9222"
}
CDPProvider implements BrowserProvider for direct CDP WebSocket connections. Use this to connect to any browser exposing a Chrome DevTools Protocol endpoint.
func NewCDPProvider ¶ added in v1.42.0
func NewCDPProvider(url string) *CDPProvider
NewCDPProvider creates a new CDPProvider.
func (*CDPProvider) CreateSession ¶ added in v1.42.0
func (p *CDPProvider) CreateSession(ctx context.Context, opts SessionOptions) (*BrowserSession, error)
func (*CDPProvider) DestroySession ¶ added in v1.42.0
func (p *CDPProvider) DestroySession(ctx context.Context, sessionID string) error
func (*CDPProvider) Name ¶ added in v1.42.0
func (p *CDPProvider) Name() string
type KeyDef ¶ added in v1.39.0
type KeyDef struct {
Key string // DOM key value (e.g., "Enter", "ArrowUp", "a")
Code string // DOM code value (e.g., "Enter", "ArrowUp", "KeyA")
KeyCode int // Legacy keyCode
Text string // Character to insert (empty for non-printable keys)
WindowsVirtualKeyCode int // Windows virtual key code
}
KeyDef defines a CDP key with all fields needed for DispatchKeyEvent
type SessionOptions ¶ added in v1.39.0
type SessionOptions struct {
InitialURL string
ViewportWidth int
ViewportHeight int
Proxy bool
ProxyCountry string // ISO 3166-1 alpha-2 country code (e.g., "US", "GB", "DE")
TestMode bool
}
SessionOptions contains parameters for session creation.
type SteelProvider ¶ added in v1.39.0
type SteelProvider struct {
APIKey string
BaseURL string // Default: "https://api.steel.dev"
}
SteelProvider implements BrowserProvider for Steel.dev. Sessions are created via REST API and controlled via CDP WebSocket.
func NewSteelProvider ¶ added in v1.39.0
func NewSteelProvider(apiKey, baseURL string) *SteelProvider
NewSteelProvider creates a new SteelProvider.
func (*SteelProvider) CreateSession ¶ added in v1.39.0
func (p *SteelProvider) CreateSession(ctx context.Context, opts SessionOptions) (*BrowserSession, error)
func (*SteelProvider) DestroySession ¶ added in v1.39.0
func (p *SteelProvider) DestroySession(ctx context.Context, sessionID string) error
func (*SteelProvider) Name ¶ added in v1.39.0
func (p *SteelProvider) Name() string