fetch

package
v1.60.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ToolNameFetch = "fetch"
)

Variables

This section is empty.

Functions

func CreateToolSet added in v1.60.0

func CreateToolSet(ctx context.Context, toolset latest.Toolset, runConfig *config.RuntimeConfig) (tools.ToolSet, error)

CreateToolSet is used by the tools registry.

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 ToolArgs

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

type ToolOption

type ToolOption func(*ToolSet)

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

type ToolSet added in v1.60.0

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

func New added in v1.60.0

func New(options ...ToolOption) *ToolSet

func (*ToolSet) Instructions added in v1.60.0

func (t *ToolSet) Instructions() string

func (*ToolSet) Tools added in v1.60.0

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

Jump to

Keyboard shortcuts

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