Documentation
¶
Index ¶
- func DefaultSystemPrompt(maxActions int) string
- func DefaultTools() []responses.ToolUnionParam
- func DetectAnthropic45Model(model string) bool
- func DetectAnthropicModel(model string) bool
- func DetectBrowserUseModel(model string) bool
- func SystemPrompt(cfg PromptConfig) (string, error)
- type Action
- type ActionContext
- type ActionResult
- type Agent
- type AgentConfig
- type BoundingBox
- type BrowserSession
- func (bs *BrowserSession) BrowserStateText() string
- func (bs *BrowserSession) Close() error
- func (bs *BrowserSession) ClosePage(ctx context.Context, targetID string) error
- func (bs *BrowserSession) Connect(ctx context.Context) error
- func (bs *BrowserSession) FileSystem() *FileSystem
- func (bs *BrowserSession) GetBrowserStateSummary(ctx context.Context, includeScreenshot bool) (*BrowserStateSummary, error)
- func (bs *BrowserSession) GetCurrentPage() *Page
- func (bs *BrowserSession) GetOrCreateSession(ctx context.Context, targetID string, focus bool) (*CDPSession, error)
- func (bs *BrowserSession) GetPages() []*Page
- func (bs *BrowserSession) Kill() error
- func (bs *BrowserSession) NewPage(ctx context.Context, url string) (*Page, error)
- func (bs *BrowserSession) SelectorForIndex(index int) (string, bool)
- func (bs *BrowserSession) SetFileSystem(fs *FileSystem)
- type BrowserStateSummary
- type CDPClient
- func (c *CDPClient) Register(method string, handler EventHandler)
- func (c *CDPClient) Send(ctx context.Context, method string, params map[string]any, sessionID string) (map[string]any, error)
- func (c *CDPClient) SendWithTimeout(method string, params map[string]any, sessionID string, timeout time.Duration) (map[string]any, error)
- func (c *CDPClient) Start(ctx context.Context) error
- func (c *CDPClient) Stop() error
- type CDPError
- type CDPEvent
- type CDPResponse
- type CDPSession
- type Element
- func (e *Element) Click(ctx context.Context) error
- func (e *Element) Evaluate(ctx context.Context, function string, args ...any) (string, error)
- func (e *Element) Fill(ctx context.Context, text string, clear bool) error
- func (e *Element) Focus(ctx context.Context) error
- func (e *Element) GetAttribute(ctx context.Context, name string) (string, error)
- func (e *Element) GetBoundingBox(ctx context.Context) (*BoundingBox, error)
- func (e *Element) Hover(ctx context.Context) error
- func (e *Element) ScrollIntoView(ctx context.Context) error
- func (e *Element) SetFileInputFiles(ctx context.Context, paths []string) error
- type EventHandler
- type FileSystem
- func (fs *FileSystem) ListFiles() ([]string, error)
- func (fs *FileSystem) Open(name string) (io.ReadCloser, error)
- func (fs *FileSystem) ReadFile(name string) (string, error)
- func (fs *FileSystem) ReplaceFile(name, oldStr, newStr string) error
- func (fs *FileSystem) WriteFile(name, content string, appendMode, trailingNewline, leadingNewline bool) error
- type IndexedElement
- type Mouse
- func (m *Mouse) Click(ctx context.Context, x, y int, button string, clickCount int) error
- func (m *Mouse) Down(ctx context.Context, button string, clickCount int) error
- func (m *Mouse) Move(ctx context.Context, x, y int) error
- func (m *Mouse) Scroll(ctx context.Context, x, y int, deltaX, deltaY int) error
- func (m *Mouse) Up(ctx context.Context, button string, clickCount int) error
- type Page
- func (p *Page) DevicePixelRatio(ctx context.Context) float64
- func (p *Page) Evaluate(ctx context.Context, pageFunction string, args ...any) (string, error)
- func (p *Page) GetElementByCSSSelector(ctx context.Context, selector string) (*Element, error)
- func (p *Page) GetElementsByCSSSelector(ctx context.Context, selector string) ([]*Element, error)
- func (p *Page) GetTitle(ctx context.Context) (string, error)
- func (p *Page) GetURL(ctx context.Context) (string, error)
- func (p *Page) GoBack(ctx context.Context) error
- func (p *Page) Goto(ctx context.Context, url string) error
- func (p *Page) InsertText(ctx context.Context, text string) error
- func (p *Page) Mouse(ctx context.Context) (*Mouse, error)
- func (p *Page) Press(ctx context.Context, key string) error
- func (p *Page) Reload(ctx context.Context) error
- func (p *Page) Screenshot(ctx context.Context, format string, quality *int, maxWidth, maxHeight int) (string, error)
- func (p *Page) SetViewportSize(ctx context.Context, width, height int) error
- func (p *Page) WaitForReadyState(ctx context.Context, timeout time.Duration) error
- func (p *Page) WaitForSelector(ctx context.Context, selector string, timeout time.Duration) (*Element, error)
- type PromptConfig
- type PromptStyle
- type SessionManager
- func (sm *SessionManager) GetAllPageTargets() []*Target
- func (sm *SessionManager) GetSessionForTarget(targetID string) *CDPSession
- func (sm *SessionManager) GetTarget(targetID string) *Target
- func (sm *SessionManager) StartMonitoring(ctx context.Context) error
- func (sm *SessionManager) WaitForSession(targetID string, timeout time.Duration) (*CDPSession, error)
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultSystemPrompt ¶
func DefaultTools ¶
func DefaultTools() []responses.ToolUnionParam
func DetectAnthropic45Model ¶
func DetectAnthropicModel ¶
func DetectBrowserUseModel ¶
func SystemPrompt ¶
func SystemPrompt(cfg PromptConfig) (string, error)
Types ¶
type ActionContext ¶
type ActionContext struct {
Session *BrowserSession
FileSystem *FileSystem
Client *openai.Client
Model string
}
type ActionResult ¶
type ActionResult struct {
ExtractedContent string `json:"extracted_content,omitempty"`
Error string `json:"error,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
LongTermMemory string `json:"long_term_memory,omitempty"`
Screenshot string `json:"screenshot,omitempty"`
FilesToDisplay []string `json:"files_to_display,omitempty"`
}
func ExecuteAction ¶
func ExecuteAction(ctx context.Context, action Action, actionCtx ActionContext) (ActionResult, error)
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func NewAgent ¶
func NewAgent(cfg AgentConfig) (*Agent, error)
type AgentConfig ¶
type AgentConfig struct {
Task string
Model string
Session *BrowserSession
Client *openai.Client
Tools []responses.ToolUnionParam
MaxSteps int
MaxActionsPerStep int
SystemPrompt string
PromptStyle PromptStyle
UseToolCalls bool
UseVision string
LogRequests bool
LogResponses bool
Reasoning *shared.ReasoningParam
Logger *log.Logger
}
type BoundingBox ¶
type BrowserSession ¶
type BrowserSession struct {
CDPURL string
Headers map[string]string
AgentFocusTarget string
// contains filtered or unexported fields
}
func NewBrowserSession ¶
func NewBrowserSession(cdpURL string, headers map[string]string) *BrowserSession
func (*BrowserSession) BrowserStateText ¶
func (bs *BrowserSession) BrowserStateText() string
func (*BrowserSession) Close ¶
func (bs *BrowserSession) Close() error
func (*BrowserSession) ClosePage ¶
func (bs *BrowserSession) ClosePage(ctx context.Context, targetID string) error
func (*BrowserSession) FileSystem ¶
func (bs *BrowserSession) FileSystem() *FileSystem
func (*BrowserSession) GetBrowserStateSummary ¶
func (bs *BrowserSession) GetBrowserStateSummary(ctx context.Context, includeScreenshot bool) (*BrowserStateSummary, error)
func (*BrowserSession) GetCurrentPage ¶
func (bs *BrowserSession) GetCurrentPage() *Page
func (*BrowserSession) GetOrCreateSession ¶
func (bs *BrowserSession) GetOrCreateSession(ctx context.Context, targetID string, focus bool) (*CDPSession, error)
func (*BrowserSession) GetPages ¶
func (bs *BrowserSession) GetPages() []*Page
func (*BrowserSession) Kill ¶
func (bs *BrowserSession) Kill() error
func (*BrowserSession) SelectorForIndex ¶
func (bs *BrowserSession) SelectorForIndex(index int) (string, bool)
func (*BrowserSession) SetFileSystem ¶
func (bs *BrowserSession) SetFileSystem(fs *FileSystem)
type BrowserStateSummary ¶
type CDPClient ¶
type CDPClient struct {
// contains filtered or unexported fields
}
func (*CDPClient) Register ¶
func (c *CDPClient) Register(method string, handler EventHandler)
func (*CDPClient) SendWithTimeout ¶
type CDPEvent ¶
type CDPEvent struct {
Method string `json:"method"`
Params json.RawMessage `json:"params"`
SessionID string `json:"sessionId"`
}
type CDPResponse ¶
type CDPResponse struct {
ID int64 `json:"id"`
Result json.RawMessage `json:"result"`
Error *CDPError `json:"error"`
SessionID string `json:"sessionId"`
}
type CDPSession ¶
type Element ¶
type Element struct {
// contains filtered or unexported fields
}
func NewElement ¶
func NewElement(browser *BrowserSession, backendNodeID int, sessionID string) *Element
func (*Element) GetAttribute ¶
func (*Element) GetBoundingBox ¶
func (e *Element) GetBoundingBox(ctx context.Context) (*BoundingBox, error)
type EventHandler ¶
type EventHandler func(event CDPEvent)
type FileSystem ¶
type FileSystem struct {
Root string
}
FileSystem provides a minimal, sandboxed filesystem similar to browser_use.
func NewFileSystem ¶
func NewFileSystem(root string) (*FileSystem, error)
func (*FileSystem) ListFiles ¶
func (fs *FileSystem) ListFiles() ([]string, error)
func (*FileSystem) Open ¶
func (fs *FileSystem) Open(name string) (io.ReadCloser, error)
func (*FileSystem) ReplaceFile ¶
func (fs *FileSystem) ReplaceFile(name, oldStr, newStr string) error
type IndexedElement ¶
type Mouse ¶
type Mouse struct {
// contains filtered or unexported fields
}
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
func (*Page) GetElementByCSSSelector ¶
func (*Page) GetElementsByCSSSelector ¶
func (*Page) Screenshot ¶
func (*Page) SetViewportSize ¶
func (*Page) WaitForReadyState ¶
type PromptConfig ¶
type PromptConfig struct {
Style PromptStyle
MaxActionsPerStep int
IsAnthropic bool
IsBrowserUseModel bool
ModelName string
}
type PromptStyle ¶
type PromptStyle string
const ( PromptStyleDefault PromptStyle = "default" PromptStyleNoThinking PromptStyle = "no_thinking" PromptStyleFlash PromptStyle = "flash" )
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func NewSessionManager ¶
func NewSessionManager(client *CDPClient) *SessionManager
func (*SessionManager) GetAllPageTargets ¶
func (sm *SessionManager) GetAllPageTargets() []*Target
func (*SessionManager) GetSessionForTarget ¶
func (sm *SessionManager) GetSessionForTarget(targetID string) *CDPSession
func (*SessionManager) GetTarget ¶
func (sm *SessionManager) GetTarget(targetID string) *Target
func (*SessionManager) StartMonitoring ¶
func (sm *SessionManager) StartMonitoring(ctx context.Context) error
func (*SessionManager) WaitForSession ¶
func (sm *SessionManager) WaitForSession(targetID string, timeout time.Duration) (*CDPSession, error)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.