webtool

package
v0.22.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoContentExtracted = errors.New("no content extracted")

Functions

This section is empty.

Types

type FetchURLArgs

type FetchURLArgs struct {
	URL        string `json:"url"`
	Encoding   string `json:"encoding,omitempty"`
	MaxLength  int    `json:"maxLength,omitempty"`
	StartIndex int    `json:"startIndex,omitempty"`
	Raw        bool   `json:"raw,omitempty"`
}

type FetchURLEncoding

type FetchURLEncoding string
const (
	FetchEncodingAuto   FetchURLEncoding = "auto"
	FetchEncodingText   FetchURLEncoding = "text"
	FetchEncodingBinary FetchURLEncoding = "binary"
)

type WebTool

type WebTool struct {
	// contains filtered or unexported fields
}

WebTool is an instance-owned HTTP fetchURL tool.

Default security posture is conservative: - only http/https URLs are allowed - localhost, private, link-local, multicast and reserved IP ranges are blocked - redirects are revalidated - response bytes are bounded.

func NewWebTool

func NewWebTool(opts ...WebToolOption) (*WebTool, error)

func (*WebTool) FetchURL

func (wt *WebTool) FetchURL(ctx context.Context, args FetchURLArgs) ([]spec.ToolOutputUnion, error)

func (*WebTool) FetchURLTool

func (wt *WebTool) FetchURLTool() spec.Tool

type WebToolOption

type WebToolOption func(*WebTool) error

func WithAllowPrivateNetwork

func WithAllowPrivateNetwork(allow bool) WebToolOption

WithAllowPrivateNetwork allows fetching private/internal network addresses.

Keep this false for autonomous LLM usage unless the host application has its own network sandbox.

func WithHTTPTimeout

func WithHTTPTimeout(timeout time.Duration) WebToolOption

WithHTTPTimeout sets the HTTP client timeout.

A zero timeout disables the client-level timeout, but callers should still use context deadlines or registry call timeouts.

func WithMaxFetchBytes

func WithMaxFetchBytes(maxBytes int64) WebToolOption

WithMaxFetchBytes sets the maximum bytes downloaded for one fetch.

It cannot exceed toolutil.MaxFileReadBytes, so the web tool remains aligned with local file read safety limits.

func WithMaxRedirects

func WithMaxRedirects(maxRedirects int) WebToolOption

WithMaxRedirects sets the maximum number of redirects.

Use 0 to disable redirects.

func WithProxyURL

func WithProxyURL(proxyRawURL string) WebToolOption

WithProxyURL configures an HTTP/HTTPS proxy.

func WithUserAgent

func WithUserAgent(userAgent string) WebToolOption

WithUserAgent sets the User-Agent sent by fetchURL requests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL