fetch

package
v1.55.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ToolNameFetch = "fetch"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	URL           string `json:"url"`
	StatusCode    int    `json:"statusCode"`
	Status        string `json:"status"`
	ContentType   string `json:"contentType,omitempty"`
	ContentLength int    `json:"contentLength"`
	Body          string `json:"body,omitempty"`
	Error         string `json:"error,omitempty"`
}

type Tool

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

func NewFetchTool

func NewFetchTool(options ...ToolOption) *Tool

func (*Tool) Instructions

func (t *Tool) Instructions() string

func (*Tool) Tools

func (t *Tool) Tools(context.Context) ([]tools.Tool, error)

type ToolArgs

type ToolArgs struct {
	URLs    []string `json:"urls"`
	Timeout int      `json:"timeout,omitempty"`
	Format  string   `json:"format,omitempty"`
}

type ToolOption

type ToolOption func(*Tool)

func WithAllowPrivateIPs

func WithAllowPrivateIPs(allow bool) ToolOption

WithAllowPrivateIPs controls whether the fetch tool may dial non-public IP addresses (loopback, RFC1918, link-local incl. cloud metadata at 169.254.169.254, multicast and the unspecified address). The default is false: such addresses are refused at dial time, after DNS resolution, so DNS rebinding cannot bypass the check. Set to true only when an agent legitimately needs to reach internal services.

func WithAllowedDomains

func WithAllowedDomains(domains []string) ToolOption

WithAllowedDomains restricts the fetch tool to URLs whose host matches one of the supplied domain patterns. See matchesDomain for matching rules. An empty or nil slice disables the allow-list (every host is allowed).

func WithBlockedDomains

func WithBlockedDomains(domains []string) ToolOption

WithBlockedDomains forbids the fetch tool from fetching URLs whose host matches one of the supplied domain patterns. See matchesDomain for matching rules. An empty or nil slice disables the deny-list.

func WithHeaders

func WithHeaders(headers map[string]string) ToolOption

WithHeaders sets static HTTP headers attached to every fetch request. Typical use is supplying credentials such as `Authorization: Bearer ...`. These are applied last, so they override the default User-Agent and the format-driven Accept header. An empty or nil map is a no-op.

func WithTimeout

func WithTimeout(timeout time.Duration) ToolOption

Jump to

Keyboard shortcuts

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