blob: a540c8fe39aab9d853b356de5f418210675eb7f9 [file] [log] [blame]
Philip Zeyliger33d282f2025-05-03 04:01:54 +00001package browse
2
3import (
4 "context"
5 "log"
6
7 "sketch.dev/llm"
8)
9
10// RegisterBrowserTools initializes the browser tools and returns all the tools
11// ready to be added to an agent. It also returns a cleanup function that should
12// be called when done to properly close the browser.
13func RegisterBrowserTools(ctx context.Context) ([]*llm.Tool, func()) {
14 browserTools := NewBrowseTools(ctx)
15
16 // Initialize the browser
17 if err := browserTools.Initialize(); err != nil {
18 log.Printf("Warning: Failed to initialize browser: %v", err)
19 }
20
21 // Return all tools and a cleanup function
22 return browserTools.GetAllTools(), func() {
23 browserTools.Close()
24 }
25}
26
27// Tool is an alias for llm.Tool to make the documentation clearer
28type Tool = llm.Tool