blob: 0e60d735e8f5589dc6cf352f936711f2813c912d [file] [log] [blame]
Philip Zeyliger33d282f2025-05-03 04:01:54 +00001package browse
2
3import (
4 "context"
Philip Zeyliger33d282f2025-05-03 04:01:54 +00005
6 "sketch.dev/llm"
7)
8
Philip Zeyliger80b488d2025-05-10 18:21:54 -07009// RegisterBrowserTools returns all browser tools ready to be added to an agent.
10// It also returns a cleanup function that should be called when done to properly close the browser.
11// The browser will be initialized lazily when a browser tool is first used.
Philip Zeyliger72252cb2025-05-10 17:00:08 -070012func RegisterBrowserTools(ctx context.Context, supportsScreenshots bool) ([]*llm.Tool, func()) {
Philip Zeyliger33d282f2025-05-03 04:01:54 +000013 browserTools := NewBrowseTools(ctx)
14
Philip Zeyliger72252cb2025-05-10 17:00:08 -070015 return browserTools.GetTools(supportsScreenshots), func() {
Philip Zeyliger33d282f2025-05-03 04:01:54 +000016 browserTools.Close()
17 }
18}
19
20// Tool is an alias for llm.Tool to make the documentation clearer
21type Tool = llm.Tool