Documentation
¶
Index ¶
- Constants
- type Config
- type WebHelper
- func (w *WebHelper) Close() error
- func (w *WebHelper) FetchImageTool() ds4.ToolHandler
- func (w *WebHelper) GoogleSearch(ctx context.Context, query string) (string, error)
- func (w *WebHelper) GoogleSearchTool() ds4.Tool
- func (w *WebHelper) Search(ctx context.Context, query string, provider string) (string, error)
- func (w *WebHelper) VisitPage(ctx context.Context, targetURL string) (string, error)
- func (w *WebHelper) VisitPageTool() ds4.Tool
Constants ¶
const FetchImageParametersSchema = `` /* 155-byte string literal not displayed */
FetchImageParametersSchema is the JSON schema for the fetch_image tool.
const GoogleSearchParametersSchema = `{
"type": "object",
"properties": {
"query": {
"type": "string"
}
},
"required": [
"query"
]
}`
const VisitPageParametersSchema = `{
"type": "object",
"properties": {
"url": {
"type": "string"
}
},
"required": [
"url"
]
}`
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// HomeDir is the directory containing user configuration.
// Defaults to $HOME, or "." if unset.
HomeDir string
// Port is the debugging port to run Chrome on. Defaults to 9333.
Port int
// ChromePath is the path to the Chrome or Chromium executable.
// If empty, auto-detection searches standard paths.
ChromePath string
// ConfirmApproval is called to prompt the user before starting Chrome for the first time.
// If nil, starting Chrome will fail with an error.
ConfirmApproval func(message string) (bool, error)
// Log receives status messages from the helper.
Log func(message string)
// SearchProvider specifies the search engine to use.
// Supported values: "google" (default), "duckduckgo", "bing".
SearchProvider string
// VisionAvailable reports whether the engine can encode images. When nil
// or false, fetch_image returns a text observation asking for --vision.
VisionAvailable func() bool
// AllowPrivateFetch lets fetch_image and visit_page reach loopback,
// private, and link-local addresses, on the first hop or via redirect.
// Off by default so a model cannot be steered at services behind the
// tool's host. Non-http(s) schemes such as file:// are refused either way.
AllowPrivateFetch bool
// MaxImageBytes caps one fetched image. Zero means upstream's 64 MiB.
MaxImageBytes int
// HTTPClient serves fetch_image; nil uses a client with a 60 s timeout.
HTTPClient *http.Client
}
Config configures the WebHelper.
type WebHelper ¶
type WebHelper struct {
// contains filtered or unexported fields
}
WebHelper implements browser-backed web tools using Chrome DevTools Protocol.
func (*WebHelper) Close ¶
Close terminates the spawned Chrome browser if it was started by this helper.
func (*WebHelper) FetchImageTool ¶ added in v0.7.0
func (w *WebHelper) FetchImageTool() ds4.ToolHandler
FetchImageTool returns fetch_image: download a PNG or JPEG over http(s) and hand it to the model as a visual observation, the web counterpart of workspacetool's view_image. The bytes travel in the observation, so the tool loop encodes them once and re-renders history without refetching. The body is accepted by signature, not Content-Type, and capped at Config.MaxImageBytes. Private, loopback, and link-local destinations are refused on every hop unless Config.AllowPrivateFetch is set. Without a vision encoder it returns a text observation rather than an error, so the model can carry on, matching view_image.
func (*WebHelper) GoogleSearch ¶
GoogleSearch searches Google (or the default configured SearchProvider) and returns search result Markdown links.
func (*WebHelper) GoogleSearchTool ¶
func (w *WebHelper) GoogleSearchTool() ds4.Tool
GoogleSearchTool returns the Tool schema and handler for Google Search.
func (*WebHelper) Search ¶
Search executes a web search using the specified provider and returns Markdown links. Supported providers: "google", "duckduckgo", "bing". If provider is empty, the default configured SearchProvider is used (falling back to "google").
func (*WebHelper) VisitPage ¶
VisitPage navigates to a URL, optionally scrolls, and extracts its text layout. The URL passes the same policy as fetch_image first: http(s) only, and no loopback, private, or link-local destination unless Config.AllowPrivateFetch, checked again on the page the browser lands on. The browser would otherwise render file://, chrome://, and internal services for a model steered by page content.
func (*WebHelper) VisitPageTool ¶
func (w *WebHelper) VisitPageTool() ds4.Tool
VisitPageTool returns the Tool schema and handler for visiting web pages.